@xopcai/xopc 0.0.329 → 0.0.330
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Bs1qnnhD.js → agent-avatar-dicebear-BDG0hI-J.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-ArM6Sm9S.js +1 -0
- package/dist/gateway/static/root/assets/agent-plugin-dialog-BX_Bhre1.js +1 -0
- package/dist/gateway/static/root/assets/agents-BiQqpMw0.js +70 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BrIji9B5.js → app-management-settings-panel-DgttzUCG.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Uts-MQ7K.js → appearance-settings-CHpyWV8Z.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BhfYQcm8.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-_EzRfBuI.js → archive-plugin-B7Q7Oeo7.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CHg7_XFl.js → attachment-load-BYwqQ8qN.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CGMErk_w.js → automations-page-CsvAtTNd.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-DMH_1Ped.js +7 -0
- package/dist/gateway/static/root/assets/{binary-plugins-D3WB-tVn.js → binary-plugins-DdgWCI-M.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Cm1W-14I.js → block-editor-DyOagNnn.js} +53 -53
- package/dist/gateway/static/root/assets/{browser-automation-inputs-VnvK-GQP.js → browser-automation-inputs-CwF8OQFN.js} +1 -1
- package/dist/gateway/static/root/assets/browser-automations-page-D_EQjiiu.js +3 -0
- package/dist/gateway/static/root/assets/browser-settings-page-BE6691Jz.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-page-MweWNrC1.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CdSWkh89.js +8 -0
- package/dist/gateway/static/root/assets/{capability-header-actions-C3chJDQu.js → capability-header-actions-C5F2GNE9.js} +1 -1
- package/dist/gateway/static/root/assets/channels-NGfwR3He.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-ClbmjCL2.js → chat-terminal-dock-C6tl9Rfw.js} +2 -2
- package/dist/gateway/static/root/assets/{computer-settings-page-BfZaf516.js → computer-settings-page-C0MsVw4l.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-F-fYNIx8.js → connector-service-page-DsF60pPs.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-BE8NdQcR.js +2 -0
- package/dist/gateway/static/root/assets/date-picker-CELKKqYN.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-B_z3zihW.js → dependency-picker-BcEwCnI5.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-C1TZzKS3.js → desktop-pet-Ww7Gm8-x.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-D-dbAxGu.js +1 -0
- package/dist/gateway/static/root/assets/device-pairing-wizard-DsYY6szg.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BfxaNwMB.js → directory-picker-path-field-CVmuCRyO.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-Bs8_FYCm.js → extension-debug-page-UUHNJj-d.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DH5vFbBw.js → extension-page-BvL452mX.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-hGKovxxC.js → extension-settings-page-CrNnUSOs.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BYMrbKZE.js → gateway-config-swr-DMm1vU51.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-DrHhtZqv.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DMqYXHAn.js → gateway-startup-retry-Ck6tj6yE.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-YgI6jfGA.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-D1sQGaJz.js → image-generation-api-BOh6j0BF.js} +1 -1
- package/dist/gateway/static/root/assets/imports-page-BuqdzA7h.js +1 -0
- package/dist/gateway/static/root/assets/index-DJmO2VAY.css +1 -0
- package/dist/gateway/static/root/assets/index-vCIBfJp7.js +121 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CMitbles.js → keyboard-shortcuts-settings-D9L7IdUg.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-DO8uUtos.js +1 -0
- package/dist/gateway/static/root/assets/local-apps-page-BEvyufm7.js +1 -0
- package/dist/gateway/static/root/assets/locale-store-DAOwT3Zp.js +1 -0
- package/dist/gateway/static/root/assets/logs-page-Jev1m9sS.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-41i7B1RO.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-DXubGEic.js → markdown-view-nL4xzvI8.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DLJrmU9J.js → media-plugins-dHbcqMan.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-D0G_sZvA.js → messages-BZbt9x1y.js} +3 -3
- package/dist/gateway/static/root/assets/note-detail-panel-DonP0E6Q.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-CYHMeVKo.js +8 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-C3JiQEKD.js → page-context-capture-button-BKsMcPOy.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-buk_gdip.js → preview-open-alternatives-Du18QgWc.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DwEEO0Ak.js → product-open-page-IY1QL6s0.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-Bpw9mxfV.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BdYbDNUn.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-tx8XCHOs.js → registry-api-DCFXWBOt.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CLhbz3TF.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-De7HmmBu.js → runtime-tools-settings-panel-CuTFmXyj.js} +2 -2
- package/dist/gateway/static/root/assets/scenes-page-XwK2IEmr.js +2 -0
- package/dist/gateway/static/root/assets/{schema-form-DPMEuj5D.js → schema-form-qWQii8IU.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-4-QoiDES.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BggQVM1y.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-DM0D-BQ_.js → settings-form-section-B0ZBr0L9.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-CWS9yOH3.js → settings-page-DpII4NO3.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-HPpC7EE0.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-CcRi2yGy.js → share-preview-page-B2CGYZHc.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DhVCRYGP.js +1 -0
- package/dist/gateway/static/root/assets/skill-api-_ddww47C.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-XPZkWJJe.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-uF7DkJMC.js +2 -0
- package/dist/gateway/static/root/assets/system-settings-panel-25ABVt7H.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-gepxhO4j.js +1 -0
- package/dist/gateway/static/root/assets/tunnel-api-CwQGBI_4.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-ZTHe1zCM.js → use-autosave-CL3wytbs.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-DldQW9Wh.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-C8Kpkct-.js → voice-api-key-field-zjAzQrx4.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-BvzxINUk.js → voice-config-api-DvzQ-128.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-ClB6T-dm.js → work-discovery-overlay-MaPPjWwl.js} +1 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-C3dQN1fE.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-B9lnTU3U.js +6 -0
- package/dist/gateway/static/root/index.html +8 -14
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +19 -4
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
- package/dist/src/agent/capabilities/definitions.d.ts +3 -2
- package/dist/src/agent/capabilities/definitions.js +3 -2
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/orchestration/llm-turn-retry.js +2 -15
- package/dist/src/agent/service.d.ts +1 -0
- package/dist/src/agent/service.js +5 -2
- package/dist/src/agent/tasks/task-judge-service.js +1 -1
- package/dist/src/agent/tools/factory.js +3 -2
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/agent/tools/workflow-manage-tool.d.ts +2 -0
- package/dist/src/agent/tools/workflow-manage-tool.js +225 -0
- package/dist/src/agent/tools/xopc-use-tool.js +1 -1
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/auth/credentials.js +1 -1
- package/dist/src/auth/oauth-provider-lock.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/draft/automation-draft-service.js +13 -4
- package/dist/src/bootstrap/application-state.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/chat-commands/builtins/config.js +1 -1
- package/dist/src/chat-previews/service.js +1 -2
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +2 -2
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.js +1 -1
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/extensions/bundled-extension-activation.d.ts +3 -1
- package/dist/src/extensions/bundled-extension-activation.js +5 -8
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/gateway-workflow-host.types.d.ts +1 -0
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +27 -5
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +1 -23
- package/dist/src/gateway/image-generation-setup.js +2 -2
- package/dist/src/gateway/lock.js +1 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +4 -4
- package/dist/src/gateway/service/config-coordinator.js +6 -6
- package/dist/src/gateway/service/marketplace-service.js +8 -6
- package/dist/src/gateway/service.d.ts +1 -1
- package/dist/src/gateway/service.js +14 -14
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/generator.js +7 -6
- package/dist/src/home-intelligence/host.js +1 -1
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/providers/model-response.d.ts +2 -0
- package/dist/src/providers/model-response.js +24 -1
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tui/backends/embedded-backend.js +6 -3
- package/dist/src/tui/tui-commands.js +2 -2
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +3 -3
- package/dist/src/voice/platform-streams.js +15 -7
- package/dist/src/voice/realtime/agentEngine.js +19 -3
- package/dist/src/voice/realtime/pcmFrameBuffer.js +2 -1
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/dist/src/voice/realtime/playback-echo.js +16 -1
- package/dist/src/workflows/authoring/index.d.ts +1 -0
- package/dist/src/workflows/authoring/index.js +2 -1
- package/dist/src/workflows/authoring/workflow-draft-defaults.d.ts +3 -0
- package/dist/src/workflows/authoring/workflow-draft-defaults.js +63 -0
- package/dist/src/workflows/domain/index.js +1 -1
- package/dist/src/workflows/engine/workflow-engine.js +1 -1
- package/dist/src/workflows/index.js +2 -2
- package/dist/src/workflows/service/workflow-run-service.d.ts +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +34 -11
- package/dist/src/workflows/service/workflow-session-bridge.js +2 -2
- package/package.json +4 -4
- package/skills/engineering/workflow-authoring/SKILL.md +32 -0
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DHJyAT7t.js +0 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-DLKj_iIh.js +0 -1
- package/dist/gateway/static/root/assets/agents-SXZ5O0g4.js +0 -70
- package/dist/gateway/static/root/assets/apps-page-DcclVdxW.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-Cc4yqiF6.js +0 -7
- package/dist/gateway/static/root/assets/box-DvYoGszj.js +0 -1
- package/dist/gateway/static/root/assets/braces-Cfmtagno.js +0 -1
- package/dist/gateway/static/root/assets/browser-automations-page-CZYCvSSU.js +0 -3
- package/dist/gateway/static/root/assets/browser-settings-page-DDz9PE6m.js +0 -3
- package/dist/gateway/static/root/assets/calendar-clock-D-quYVPe.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-page-DH3aDk53.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C8jMZAJl.js +0 -8
- package/dist/gateway/static/root/assets/capability-discover-page-CgGvsf3t.js +0 -1
- package/dist/gateway/static/root/assets/channels-CuVS_KsY.js +0 -1
- package/dist/gateway/static/root/assets/chevron-left-DqFhpbvK.js +0 -1
- package/dist/gateway/static/root/assets/clock-3-DnrAnuyZ.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-B4SLpvSL.js +0 -2
- package/dist/gateway/static/root/assets/date-picker-DXQTsUJn.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-B5JGIfqn.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-DFYK_Ywf.js +0 -1
- package/dist/gateway/static/root/assets/extension-marketplace-api-DqV4YRYs.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-BIsiP-JI.js +0 -1
- package/dist/gateway/static/root/assets/gauge-C78eD2BA.js +0 -1
- package/dist/gateway/static/root/assets/git-branch-Dh9uxTot.js +0 -1
- package/dist/gateway/static/root/assets/home-page-CoBivEvx.js +0 -1
- package/dist/gateway/static/root/assets/image-Cwyalflz.js +0 -1
- package/dist/gateway/static/root/assets/imports-page-rssb4rjP.js +0 -1
- package/dist/gateway/static/root/assets/inbox-DNoSz682.js +0 -1
- package/dist/gateway/static/root/assets/index-C4QN4gCi.css +0 -1
- package/dist/gateway/static/root/assets/index-Cr4SINLG.js +0 -121
- package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +0 -1
- package/dist/gateway/static/root/assets/layout-grid-CEVZdVFU.js +0 -1
- package/dist/gateway/static/root/assets/list-BBGUdmkF.js +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Di82Oacm.js +0 -1
- package/dist/gateway/static/root/assets/local-apps-page-CCvA9d9L.js +0 -1
- package/dist/gateway/static/root/assets/locale-store-BSkKhYkc.js +0 -1
- package/dist/gateway/static/root/assets/lock-keyhole-DEK5kH0u.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-BK8ol1q0.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-CebXkEtB.js +0 -1
- package/dist/gateway/static/root/assets/message-circle-Badhj-4D.js +0 -1
- package/dist/gateway/static/root/assets/message-square-fVE7Ghj1.js +0 -1
- package/dist/gateway/static/root/assets/models-hub-cache-B0EUPwTv.js +0 -1
- package/dist/gateway/static/root/assets/network-BUQLY1BV.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-xsKDIJdK.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-BFm7XnWH.js +0 -8
- package/dist/gateway/static/root/assets/paperclip-f1HujQY1.js +0 -1
- package/dist/gateway/static/root/assets/power-ZI-pBczI.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-CRQGCRSU.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DcqylysA.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Cq5MaiRW.js +0 -1
- package/dist/gateway/static/root/assets/scenes-page-GXJ-b3dO.js +0 -2
- package/dist/gateway/static/root/assets/server-BlHCBjiE.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-C6FwYIRA.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BEyQiZs0.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BhGKiTPf.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DNmcCBfX.js +0 -1
- package/dist/gateway/static/root/assets/skill-api-BCAV_F1P.js +0 -1
- package/dist/gateway/static/root/assets/skill-card-icon-BrrpZ3Mw.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BEV2WXGk.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-C8zOGpKw.js +0 -2
- package/dist/gateway/static/root/assets/star-BUWJqJ5c.js +0 -1
- package/dist/gateway/static/root/assets/stethoscope-DRqTAtjD.js +0 -1
- package/dist/gateway/static/root/assets/store-SzD1Jvgm.js +0 -1
- package/dist/gateway/static/root/assets/system-settings-panel-C_lajq9u.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-Dk8Bmlhw.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-CYvKiE_f.js +0 -1
- package/dist/gateway/static/root/assets/upload-rrb46c3c.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-C_SPNZbP.js +0 -2
- package/dist/gateway/static/root/assets/user-round-C9jxPhMR.js +0 -1
- package/dist/gateway/static/root/assets/wand-sparkles-DWuJz5ya.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-X0Cyh2AR.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-BrL6dzf0.js +0 -6
- package/dist/src/workflows/draft/index.d.ts +0 -3
- package/dist/src/workflows/draft/index.js +0 -3
- package/dist/src/workflows/draft/workflow-draft-prompt.d.ts +0 -22
- package/dist/src/workflows/draft/workflow-draft-prompt.js +0 -54
- package/dist/src/workflows/draft/workflow-draft-service.d.ts +0 -12
- package/dist/src/workflows/draft/workflow-draft-service.js +0 -125
- package/dist/src/workflows/draft/workflow-draft-validator.d.ts +0 -4
- package/dist/src/workflows/draft/workflow-draft-validator.js +0 -123
- package/dist/src/workflows/draft/workflow-draft.types.d.ts +0 -44
- package/dist/src/workflows/draft/workflow-draft.types.js +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{f as r}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as i}from"./createLucideIcon-DPHK1VkS.js";import{t as a}from"./clock-3-DnrAnuyZ.js";import{t as o}from"./pencil-DmIY3Oa-.js";import{n as s}from"./locale-store-BSkKhYkc.js";import{t as c}from"./button-CS04eWY9.js";import{t as l}from"./skeleton-BwbyijEw.js";import{Eo as u,Jl as d,Oc as f,Ol as p,Pc as m,Rl as h,Xc as g}from"./index-Cr4SINLG.js";import{i as _,n as v,r as y,t as b}from"./browser-automation-inputs-VnvK-GQP.js";var x=i(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),S=e(t(),1),C=n(),w={en:{title:`Browser automations`,subtitle:`Let your assistant repeat routine actions on the web.`,emptyTitle:`No browser automations yet`,emptyBody:`Tell your assistant what to do on the web. Once it works, save it and run it again whenever you need.`,create:`Create with assistant`,edit:`Edit with assistant`,run:`Run now`,stop:`Stop`,enable:`Enable`,pause:`Pause`,enabled:`Enabled`,paused:`Paused`,inputs:`Before running`,noInputs:`This automation is ready to run.`,history:`Recent activity`,delete:`Delete automation`,confirmDelete:`Delete this browser automation?`,required:`Please complete all required fields.`,queued:`Waiting to start`,running:`Running`,succeeded:`Completed`,failed:`Needs attention`,cancelled:`Stopped`,result:`Result`,read:`Reads information`,draft:`Edits the page locally`,external_effect:`Affects an external system`,destructive:`Destructive action`,sensitive:`Sensitive action`,createPrompt:`Help me create a reusable browser automation. Ask what I want the browser to do, perform it once with me, then save the successful steps. Keep all technical details hidden.`,editPrompt:`Help me update the browser automation "{name}" (id: {id}). Ask what should change, test the new browser steps, then save it.`},zh:{title:`浏览器自动化`,subtitle:`让助手自动重复完成网页上的固定操作。`,emptyTitle:`还没有浏览器自动化`,emptyBody:`告诉助手你希望在网页上自动完成什么。成功执行一次后,即可保存并重复运行。`,create:`让助手帮我创建`,edit:`让助手帮我修改`,run:`立即运行`,stop:`停止`,enable:`启用`,pause:`暂停`,enabled:`已启用`,paused:`已暂停`,inputs:`运行前需要填写`,noInputs:`这个自动化可以直接运行。`,history:`最近运行`,delete:`删除自动化`,confirmDelete:`确定删除这个浏览器自动化吗?`,required:`请填写所有必填内容。`,queued:`等待开始`,running:`正在运行`,succeeded:`已完成`,failed:`需要处理`,cancelled:`已停止`,result:`运行结果`,read:`仅读取信息`,draft:`仅在页面内编辑`,external_effect:`会影响外部系统`,destructive:`破坏性操作`,sensitive:`包含敏感操作`,createPrompt:`请帮我创建一个可重复运行的浏览器自动化。先询问我希望浏览器完成什么,陪我实际执行成功一次,然后保存成功步骤。不要让我处理技术细节。`,editPrompt:`请帮我修改浏览器自动化“{name}”(id:{id})。先询问我要修改什么,实际测试新的浏览器步骤,然后保存。`}};function T(e){return e!==`queued`&&e!==`running`}function E(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${E(e)}`).join(`
|
|
2
|
-
`):typeof e==`object`?Object.entries(e).map(([e,t])=>`${e}: ${E(t)}`).join(`
|
|
3
|
-
`):String(e)}function D(){let e=s(e=>e.language),t=w[e],n=r(),i=u(e=>e.setPageHeader),D=u(e=>e.clearPageHeader),[O,k]=(0,S.useState)(null),[A,j]=(0,S.useState)(),[M,N]=(0,S.useState)({}),[P,F]=(0,S.useState)([]),[I,L]=(0,S.useState)(),[R,z]=(0,S.useState)(``),[B,V]=(0,S.useState)(!1),H=(0,S.useMemo)(()=>O?.find(e=>e.id===A),[A,O]),U=(0,S.useCallback)(async()=>{let e=await _.list();k(e.automations),j(t=>t&&e.automations.some(e=>e.id===t)?t:e.automations[0]?.id)},[]);(0,S.useEffect)(()=>{U().catch(e=>z(String(e)))},[U]),(0,S.useEffect)(()=>{H&&(N(y(H)),L(void 0),z(``),_.listRuns(H.id).then(e=>F(e.runs)).catch(e=>z(String(e))))},[H]),(0,S.useEffect)(()=>{if(!I||T(I.status))return;let e=window.setInterval(()=>{_.getRun(I.id).then(({run:e})=>{L(e),T(e.status)&&H&&_.listRuns(H.id).then(e=>F(e.runs))}).catch(e=>z(String(e)))},700);return()=>window.clearInterval(e)},[I,H]);let W=(0,S.useCallback)(e=>{n(`/chat/new?draft=${encodeURIComponent(e)}`)},[n]),G=(0,S.useMemo)(()=>(0,C.jsxs)(c,{onClick:()=>W(t.createPrompt),children:[(0,C.jsx)(d,{className:`size-4`}),t.create]}),[W,t.create,t.createPrompt]);(0,S.useLayoutEffect)(()=>(i({startExtra:null,main:(0,C.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),end:G}),()=>D()),[D,G,i,t.title]);let K=async()=>{if(H){V(!0);try{await _.setEnabled(H.id,!H.enabled),await U()}catch(e){z(String(e))}finally{V(!1)}}},q=async()=>{if(H){if(!v(H,M)){z(t.required);return}V(!0);try{let{run:e}=await _.run(H.id,M);L(e),z(``)}catch(e){z(String(e))}finally{V(!1)}}},J=async()=>{if(!(!H||!window.confirm(t.confirmDelete))){V(!0);try{await _.remove(H.id),j(void 0),F([]),await U()}catch(e){z(String(e))}finally{V(!1)}}};return O===null?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,C.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,C.jsx)(l,{className:`h-[420px] rounded-xl`}),(0,C.jsx)(l,{className:`h-[420px] rounded-xl`})]})}):O.length===0?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,C.jsxs)(`div`,{className:`m-auto max-w-md py-12 text-center`,children:[(0,C.jsx)(d,{className:`mx-auto size-10 text-accent`}),(0,C.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-fg`,children:t.emptyTitle}),(0,C.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:t.emptyBody}),(0,C.jsxs)(c,{className:`mt-5`,onClick:()=>W(t.createPrompt),children:[(0,C.jsx)(d,{className:`size-4`}),t.create]})]})}):(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,C.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,C.jsx)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-2`,children:O.map(e=>(0,C.jsxs)(`button`,{onClick:()=>j(e.id),className:`mb-1 w-full rounded-lg p-3 text-left ${A===e.id?`bg-accent-soft text-accent-fg`:`hover:bg-surface-hover`}`,children:[(0,C.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,C.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-xs text-fg-muted`,children:[e.enabled?(0,C.jsx)(x,{className:`size-3.5 text-emerald-600`}):(0,C.jsx)(h,{className:`size-3.5`}),e.enabled?t.enabled:t.paused]})]},e.id))}),H&&(0,C.jsxs)(`main`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:H.name}),H.description&&(0,C.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:H.description}),(0,C.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[(0,C.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2.5 py-1 text-fg-muted`,children:t[H.risk]}),H.domains.map(e=>(0,C.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-surface-inset px-2.5 py-1 text-fg-muted`,children:[(0,C.jsx)(p,{className:`size-3`}),e]},e))]})]}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsxs)(c,{variant:`secondary`,disabled:B,onClick:()=>void K(),children:[H.enabled?(0,C.jsx)(h,{className:`size-4`}):(0,C.jsx)(x,{className:`size-4`}),H.enabled?t.pause:t.enable]}),(0,C.jsxs)(c,{variant:`secondary`,onClick:()=>W(t.editPrompt.replace(`{name}`,H.name).replace(`{id}`,H.id)),children:[(0,C.jsx)(o,{className:`size-4`}),t.edit]})]})]}),(0,C.jsxs)(`section`,{className:`mt-7 max-w-xl`,children:[(0,C.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.inputs}),Object.keys(H.inputs).length===0?(0,C.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.noInputs}):(0,C.jsx)(`div`,{className:`mt-3`,children:(0,C.jsx)(b,{automation:H,values:M,language:e,onChange:N})}),(0,C.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,C.jsxs)(c,{variant:`primary`,disabled:!H.enabled||B||!!(I&&!T(I.status)),onClick:()=>void q(),children:[(0,C.jsx)(g,{className:`size-4`}),t.run]}),I&&!T(I.status)&&(0,C.jsxs)(c,{variant:`secondary`,onClick:()=>void _.cancel(I.id),children:[(0,C.jsx)(m,{className:`size-4`}),t.stop]})]}),R&&(0,C.jsx)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-300`,children:R})]}),I&&(0,C.jsxs)(`section`,{className:`mt-7 rounded-xl border border-edge bg-surface-inset p-4`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,C.jsx)(a,{className:`size-4`}),t[I.status]]}),I.error&&(0,C.jsx)(`p`,{className:`mt-2 text-sm text-red-700 dark:text-red-300`,children:I.error}),I.status===`succeeded`&&I.result!==void 0&&(0,C.jsxs)(`div`,{className:`mt-3`,children:[(0,C.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.result}),(0,C.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-fg`,children:E(I.result)})]})]}),(0,C.jsxs)(`section`,{className:`mt-8`,children:[(0,C.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.history}),(0,C.jsx)(`div`,{className:`mt-2 divide-y divide-edge`,children:P.slice(0,10).map(e=>(0,C.jsxs)(`button`,{className:`flex w-full items-center justify-between gap-3 py-3 text-left text-sm hover:text-accent`,onClick:()=>L(e),children:[(0,C.jsx)(`span`,{children:t[e.status]}),(0,C.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[new Date(e.createdAtMs).toLocaleString(),e.durationMs?` · ${Math.max(1,Math.round(e.durationMs/1e3))}s`:``]})]},e.id))})]}),(0,C.jsx)(`div`,{className:`mt-8 border-t border-edge pt-4`,children:(0,C.jsxs)(c,{variant:`ghost`,className:`text-red-700 dark:text-red-300`,disabled:B,onClick:()=>void J(),children:[(0,C.jsx)(f,{className:`size-4`}),t.delete]})})]})]})})}export{D as BrowserAutomationsPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,g as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./createLucideIcon-DPHK1VkS.js";import{t as s}from"./popover-select-DcsFzD_i.js";import{t as c}from"./circle-check-C23XjkUj.js";import{t as l}from"./download-Dk-ZjtO6.js";import{t as u}from"./external-link-DjqjBmc3.js";import{t as d}from"./eye-CABVeTq0.js";import{t as f}from"./folder-open-CyzJ19I9.js";import{t as p}from"./gauge-C78eD2BA.js";import{t as m}from"./loader-circle-CifKLtgG.js";import{t as h}from"./lock-keyhole-DEK5kH0u.js";import{t as g}from"./messages-D0G_sZvA.js";import{a as _,c as v,n as y,r as b}from"./locale-store-BSkKhYkc.js";import{i as x}from"./vendor-swr-BIWyz7Rc.js";import{t as S}from"./button-CS04eWY9.js";import{n as C,r as w}from"./gateway-config-swr-BYMrbKZE.js";import{t as T}from"./skeleton-BwbyijEw.js";import{Dc as E,G as D,H as O,K as k,Ma as ee,U as A,W as te,Zc as ne,ja as re,q as ie,qc as j}from"./index-Cr4SINLG.js";import{n as M,r as N}from"./settings-page-layout-X1x-2Cp9.js";import{n as P}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as ae,t as F}from"./use-autosave-ZTHe1zCM.js";import{t as I}from"./settings-advanced-gate-BEyQiZs0.js";var oe=o(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),L=o(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),R=n(),z=e(t(),1);function B(e){let[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),l=(0,z.useRef)(null);return{running:t,cancelling:r,progress:a,error:s,install:(0,z.useCallback)(async()=>{if(l.current)return;let t=new AbortController;l.current=t,n(!0),o(null),c(null);try{let n=await D(o,t.signal);if(!n.ok){n.error!==`cancelled`&&c(n.message??n.error);return}e()}catch(e){t.signal.aborted||c(e instanceof Error?e.message:String(e))}finally{l.current===t&&(l.current=null),n(!1),i(!1)}},[e]),cancel:(0,z.useCallback)(async()=>{l.current&&(i(!0),await O().catch(()=>{}),l.current.abort())},[])}}var V=r(),H={extension:`Chrome extension`,playwright:`Playwright Chromium`,cdp:`CDP`,remote:`Remote browser`};function se(e){let{enabled:t,driverKind:n,autosaveStatus:r,zh:a}=e,o=i(),s=x(t?[`browser-control-status`,n]:null,A,{revalidateOnFocus:!0,refreshInterval:n===`extension`?3e3:0}),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(null),[p,h]=(0,z.useState)(null),g=r===`dirty`||r===`saving`;(0,z.useEffect)(()=>{r===`saved`&&s.mutate()},[r,s.mutate]);let _=(0,z.useCallback)(async(e,t,n)=>{u(e),f(null),h(null);try{await t(),h(n),await s.mutate()}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(null)}},[s.mutate]),v=B((0,z.useCallback)(()=>{h(a?`Chromium 已安装,可以开始连接测试。`:`Chromium is installed and ready to test.`),s.mutate()},[s.mutate,a])),y=s.data?.payload,b=y?.driverKind===n,C=t?g||!b?`syncing`:y?.state:`disabled`;return(0,V.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(C===`ready`?c:C===`syncing`?m:E,{className:`size-4 shrink-0 ${C===`ready`?`text-success`:C===`syncing`?`animate-spin text-fg-muted`:C===`disabled`?`text-fg-subtle`:`text-warning`}`}),(0,V.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a?`浏览器就绪状态`:`Browser readiness`}),(0,V.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs ${C===`ready`?`bg-success-soft text-success`:C===`disabled`?`bg-surface-hover text-fg-muted`:`bg-warning-soft text-warning`}`,children:C===`ready`?a?`已就绪`:`Ready`:C===`disabled`?a?`未启用`:`Disabled`:C===`syncing`?a?`正在应用配置`:`Applying configuration`:a?`需要处理`:`Needs attention`})]}),(0,V.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[H[n],y?.detail&&b?` · ${y.detail}`:``]})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsxs)(S,{variant:`ghost`,className:`h-9`,onClick:()=>void s.mutate(),disabled:s.isValidating,children:[(0,V.jsx)(j,{className:`size-3.5 ${s.isValidating?`animate-spin`:``}`}),a?`刷新`:`Refresh`]}),(0,V.jsxs)(S,{variant:`secondary`,className:`h-9`,disabled:!t||g||l!==null||v.running,onClick:()=>void _(`test`,ie,a?`连接测试成功。`:`Connection test passed.`),children:[l===`test`?(0,V.jsx)(m,{className:`size-3.5 animate-spin`}):(0,V.jsx)(ne,{className:`size-3.5`}),a?`测试连接`:`Test connection`]})]})]}),t&&s.isLoading?(0,V.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-3`,children:[(0,V.jsx)(T,{className:`h-12`}),(0,V.jsx)(T,{className:`h-12`}),(0,V.jsx)(T,{className:`h-12`})]}):null,t&&s.error?(0,V.jsx)(G,{tone:`error`,children:s.error instanceof Error?s.error.message:String(s.error)}):null,d||v.error?(0,V.jsx)(G,{tone:`error`,children:d??v.error}):null,p?(0,V.jsx)(G,{tone:`success`,children:p}):null,t&&n===`extension`&&b?(0,V.jsx)(U,{status:y?.driverStatus,zh:a,busy:l,run:_,onConnectRemote:()=>o(`/settings/devices?startDevicePairing=browser`)}):null,t&&n===`playwright`&&b?(0,V.jsx)(ue,{status:y?.driverStatus,zh:a,installer:v}):null,t&&n===`cdp`?(0,V.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:a?`连接测试会验证已保存的 CDP 地址,并复用浏览器中现有的标签页和登录状态。`:`The connection test verifies the saved CDP endpoint and reuses that browser’s existing tabs and signed-in state.`}):null,t&&n===`remote`?(0,V.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:a?`连接测试会在服务商侧创建一个临时浏览器会话,并在测试结束后立即关闭。`:`The connection test creates a temporary provider session and closes it immediately after the test.`}):null]})}function U(e){let t=(0,R.c)(70),{status:n,zh:r,busy:i,run:a,onConnectRemote:o}=e,s=n?.artifacts,c=r?`扩展文件`:`Extension files`,d=s?.installed===!0,p=s?.installed?r?`已安装`:`Installed`:r?`未安装或需更新`:`Install or update required`,h;t[0]!==c||t[1]!==d||t[2]!==p?(h=(0,V.jsx)(W,{label:c,ok:d,value:p}),t[0]=c,t[1]=d,t[2]=p,t[3]=h):h=t[3];let g=r?`本机自动发现`:`Local auto-discovery`,_=s?.nativeHost?.installed===!0,v=s?.nativeHost?.installed?r?`已就绪`:`Ready`:s?.nativeHost?.reason??(r?`需要修复`:`Repair required`),y;t[4]!==g||t[5]!==_||t[6]!==v?(y=(0,V.jsx)(W,{label:g,ok:_,value:v}),t[4]=g,t[5]=_,t[6]=v,t[7]=y):y=t[7];let b=r?`安全通道`:`Secure channel`,x=n?.transport===`gateway-realtime`,C=n?.transport===`gateway-realtime`?`Gateway Realtime`:r?`不可用`:`Unavailable`,w;t[8]!==C||t[9]!==b||t[10]!==x?(w=(0,V.jsx)(W,{label:b,ok:x,value:C}),t[8]=C,t[9]=b,t[10]=x,t[11]=w):w=t[11];let T=r?`Chrome 连接`:`Chrome connection`,E=n?.connected===!0,D=n?.connected?r?`已连接`:`Connected`:n?.socketConnected?r?`需要重新加载扩展`:`Reload extension`:r?`等待扩展连接`:`Waiting for extension`,O;t[12]!==T||t[13]!==E||t[14]!==D?(O=(0,V.jsx)(W,{label:T,ok:E,value:D}),t[12]=T,t[13]=E,t[14]=D,t[15]=O):O=t[15];let k;t[16]!==w||t[17]!==O||t[18]!==h||t[19]!==y?(k=(0,V.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:[h,y,w,O]}),t[16]=w,t[17]=O,t[18]=h,t[19]=y,t[20]=k):k=t[20];let ee=s?.extensionDir??`Gateway Realtime`,A;t[21]===ee?A=t[22]:(A=(0,V.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:ee}),t[21]=ee,t[22]=A);let re=s?.installed?`secondary`:`primary`,ie=i!==null,j;t[23]!==s?.installed||t[24]!==a||t[25]!==r?(j=()=>void a(`extension-install`,()=>te(!!s?.installed),r?`扩展文件已准备好。`:`Extension files are ready.`),t[23]=s?.installed,t[24]=a,t[25]=r,t[26]=j):j=t[26];let M;t[27]===i?M=t[28]:(M=i===`extension-install`?(0,V.jsx)(m,{className:`size-3.5 animate-spin`}):(0,V.jsx)(l,{className:`size-3.5`}),t[27]=i,t[28]=M);let N=s?.installed?r?`刷新扩展文件`:`Refresh files`:r?`安装扩展文件`:`Install extension`,P;t[29]!==re||t[30]!==ie||t[31]!==j||t[32]!==M||t[33]!==N?(P=(0,V.jsxs)(S,{className:`h-9`,variant:re,disabled:ie,onClick:j,children:[M,N]}),t[29]=re,t[30]=ie,t[31]=j,t[32]=M,t[33]=N,t[34]=P):P=t[34];let ae=!s?.installed||i!==null,F;t[35]!==a||t[36]!==r?(F=()=>void a(`extension-open`,le,r?`已打开 Chrome 扩展页。`:`Chrome extensions opened.`),t[35]=a,t[36]=r,t[37]=F):F=t[37];let I;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,V.jsx)(u,{className:`size-3.5`}),t[38]=I):I=t[38];let oe=r?`打开扩展页`:`Open extensions`,L;t[39]!==ae||t[40]!==F||t[41]!==oe?(L=(0,V.jsxs)(S,{className:`h-9`,variant:`secondary`,disabled:ae,onClick:F,children:[I,oe]}),t[39]=ae,t[40]=F,t[41]=oe,t[42]=L):L=t[42];let z=!s?.installed||i!==null,B;t[43]!==a||t[44]!==r?(B=()=>void a(`extension-folder`,ce,r?`已打开扩展目录。`:`Extension folder opened.`),t[43]=a,t[44]=r,t[45]=B):B=t[45];let H;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,V.jsx)(f,{className:`size-3.5`}),t[46]=H):H=t[46];let se=r?`打开扩展目录`:`Open folder`,U;t[47]!==z||t[48]!==B||t[49]!==se?(U=(0,V.jsxs)(S,{className:`h-9`,variant:`ghost`,disabled:z,onClick:B,children:[H,se]}),t[47]=z,t[48]=B,t[49]=se,t[50]=U):U=t[50];let ue=i!==null,G;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,V.jsx)(ne,{className:`size-3.5`}),t[51]=G):G=t[51];let de=r?`连接远程 Chrome`:`Connect remote Chrome`,K;t[52]!==o||t[53]!==ue||t[54]!==de?(K=(0,V.jsxs)(S,{className:`h-9`,variant:`secondary`,disabled:ue,onClick:o,children:[G,de]}),t[52]=o,t[53]=ue,t[54]=de,t[55]=K):K=t[55];let q;t[56]!==P||t[57]!==L||t[58]!==U||t[59]!==K?(q=(0,V.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[P,L,U,K]}),t[56]=P,t[57]=L,t[58]=U,t[59]=K,t[60]=q):q=t[60];let J;t[61]!==n?.connected||t[62]!==n?.socketConnected||t[63]!==r?(J=n?.connected?null:(0,V.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:n?.socketConnected?r?`扩展仍在运行旧协议。请打开 Chrome 扩展页,找到 xopc 并点击“重新加载”,然后刷新状态。`:`The extension is still running an older protocol. Open Chrome Extensions, find xopc, click Reload, then refresh status.`:r?`打开 xopc Chrome 扩展后,它会自动发现并安全连接本机 Gateway;只有连接另一台电脑时才需要一次性邀请和手动确认。`:`Open the xopc Chrome extension to discover and securely connect to a local Gateway automatically. A one-time invitation and explicit approval are only required for Chrome on another computer.`}),t[61]=n?.connected,t[62]=n?.socketConnected,t[63]=r,t[64]=J):J=t[64];let Y;return t[65]!==k||t[66]!==A||t[67]!==q||t[68]!==J?(Y=(0,V.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base/45 p-4`,children:[k,A,q,J]}),t[65]=k,t[66]=A,t[67]=q,t[68]=J,t[69]=Y):Y=t[69],Y}function ce(){return k(`folder`)}function le(){return k(`chrome`)}function ue(e){let t=(0,R.c)(28),{status:n,zh:r,installer:i}=e,a=n?.installed===!0,o=n?.installed?r?`已安装`:`Installed`:n?.reason??(r?`未安装`:`Not installed`),s;t[0]!==a||t[1]!==o?(s=(0,V.jsx)(W,{label:`Chromium`,ok:a,value:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]===n?c=t[4]:(c=n?.executablePath?(0,V.jsx)(`p`,{className:`mt-2 break-all text-xs text-fg-subtle`,children:n.executablePath}):null,t[3]=n,t[4]=c);let u;t[5]===i.progress?u=t[6]:(u=i.progress?(0,V.jsxs)(`div`,{className:`mt-3`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between text-xs text-fg-muted`,children:[(0,V.jsx)(`span`,{children:i.progress.message??i.progress.phase}),(0,V.jsx)(`span`,{children:i.progress.percent==null?``:`${Math.round(i.progress.percent)}%`})]}),(0,V.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,V.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width]`,style:{width:`${i.progress.percent??8}%`}})})]}):null,t[5]=i.progress,t[6]=u);let d=n?.installed?`secondary`:`primary`,f;t[7]===i?f=t[8]:(f=()=>void i.install(),t[7]=i,t[8]=f);let p;t[9]===i.running?p=t[10]:(p=i.running?(0,V.jsx)(m,{className:`size-3.5 animate-spin`}):(0,V.jsx)(l,{className:`size-3.5`}),t[9]=i.running,t[10]=p);let h=n?.installed?r?`重新安装 Chromium`:`Reinstall Chromium`:r?`安装 Chromium`:`Install Chromium`,g;t[11]!==i.running||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==h?(g=(0,V.jsxs)(S,{variant:d,className:`h-9`,disabled:i.running,onClick:f,children:[p,h]}),t[11]=i.running,t[12]=d,t[13]=f,t[14]=p,t[15]=h,t[16]=g):g=t[16];let _;t[17]!==i||t[18]!==r?(_=i.running?(0,V.jsx)(S,{variant:`ghost`,className:`h-9`,disabled:i.cancelling,onClick:()=>void i.cancel(),children:i.cancelling?r?`正在取消…`:`Cancelling…`:r?`取消`:`Cancel`}):null,t[17]=i,t[18]=r,t[19]=_):_=t[19];let v;t[20]!==_||t[21]!==g?(v=(0,V.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[g,_]}),t[20]=_,t[21]=g,t[22]=v):v=t[22];let y;return t[23]!==v||t[24]!==s||t[25]!==c||t[26]!==u?(y=(0,V.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base/45 p-4`,children:[s,c,u,v]}),t[23]=v,t[24]=s,t[25]=c,t[26]=u,t[27]=y):y=t[27],y}function W(e){let t=(0,R.c)(11),{label:n,ok:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,V.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=a);let o=`mt-1 flex items-center gap-1.5 text-sm ${r?`text-success`:`text-fg-muted`}`,s=`size-1.5 rounded-full ${r?`bg-success`:`bg-warning`}`,c;t[2]===s?c=t[3]:(c=(0,V.jsx)(`span`,{className:s}),t[2]=s,t[3]=c);let l;t[4]!==o||t[5]!==c||t[6]!==i?(l=(0,V.jsxs)(`p`,{className:o,children:[c,i]}),t[4]=o,t[5]=c,t[6]=i,t[7]=l):l=t[7];let u;return t[8]!==a||t[9]!==l?(u=(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2`,children:[a,l]}),t[8]=a,t[9]=l,t[10]=u):u=t[10],u}function G(e){let t=(0,R.c)(4),{tone:n,children:r}=e,i=`mt-3 rounded-lg px-3 py-2 text-xs ${n===`success`?`bg-success-soft text-success`:`bg-danger-soft text-danger`}`,a=n===`error`?`alert`:`status`,o;return t[0]!==r||t[1]!==i||t[2]!==a?(o=(0,V.jsx)(`p`,{className:i,role:a,children:r}),t[0]=r,t[1]=i,t[2]=a,t[3]=o):o=t[3],o}function de(e){let t=(0,R.c)(36),{sectionId:n,vm:r,children:i}=e,a=y(K),o;t[0]===a?o=t[1]:(o=g(a),t[0]=a,t[1]=o);let s=o,c=s.agentSettings,l=s.settingsSections[n]??n;if(!r.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,V.jsx)(oe,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===l?n=t[4]:(n=(0,V.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:l}),t[3]=l,t[4]=n);let r;t[5]===c.needToken?r=t[6]:(r=(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.needToken}),t[5]=c.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,V.jsx)(N,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,V.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,V.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(r.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,V.jsx)(N,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,V.jsx)(P,{sections:1})}),t[10]=e):e=t[10],e}if(!r.form){let e=r.error??r.fetchError??c.loadError,n;t[11]===e?n=t[12]:(n=(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let i;t[13]===r?i=t[14]:(i=()=>void r.mutate(),t[13]=r,t[14]=i);let a;t[15]!==s.logs.refresh||t[16]!==i?(a=(0,V.jsx)(S,{type:`button`,variant:`secondary`,onClick:i,children:s.logs.refresh}),t[15]=s.logs.refresh,t[16]=i,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,V.jsxs)(N,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let u;t[21]!==r.autosaveStatus||t[22]!==r.error?(u=(0,V.jsx)(ae,{status:r.autosaveStatus,error:r.error}),t[21]=r.autosaveStatus,t[22]=r.error,t[23]=u):u=t[23];let d;t[24]!==l||t[25]!==u?(d=(0,V.jsx)(M,{title:l,actions:u}),t[24]=l,t[25]=u,t[26]=d):d=t[26];let f;t[27]===r.error?f=t[28]:(f=r.error?(0,V.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:r.error}):null,t[27]=r.error,t[28]=f);let p;t[29]===i?p=t[30]:(p=(0,V.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:i}),t[29]=i,t[30]=p);let m;return t[31]!==d||t[32]!==f||t[33]!==p||t[34]!==r.onBlurCapture?(m=(0,V.jsxs)(N,{gap:`gap-6`,onBlurCapture:r.onBlurCapture,children:[d,f,p]}),t[31]=d,t[32]=f,t[33]=p,t[34]=r.onBlurCapture,t[35]=m):m=t[35],m}function K(e){return e.language}var q={enabled:!0,driverKind:`extension`,headless:!1,executablePath:``,cdpEndpoint:`http://127.0.0.1:9222`,remoteProvider:`browserbase`,remoteApiKey:``,remoteProjectId:``,remoteRegion:``,maxNodes:180,maxCharacters:12e3,visualFallback:!0,actionTimeoutMs:3e4,sessionTimeoutMs:9e5,maxSequenceLength:5,allowedPrivateHosts:``,crossDomainNavigation:`ask`,uploads:`ask`,consequentialActions:`ask`};function J(e){let t=X(X(e).browser),n=X(t.driver),r=X(t.observation),i=X(t.limits),a=X(t.security),o=n.kind;return{...q,enabled:t.enabled!==!1,driverKind:o===`playwright`||o===`cdp`||o===`remote`?o:`extension`,headless:n.headless===!0,executablePath:Z(n.executablePath,``),cdpEndpoint:Z(n.endpoint,q.cdpEndpoint),remoteProvider:n.provider===`browser-use`?`browser-use`:`browserbase`,remoteApiKey:Z(n.apiKey,``),remoteProjectId:Z(n.projectId,``),remoteRegion:Z(n.region,``),maxNodes:me(r.maxNodes,q.maxNodes),maxCharacters:me(r.maxCharacters,q.maxCharacters),visualFallback:r.visualFallback!==!1,actionTimeoutMs:me(i.actionTimeoutMs,q.actionTimeoutMs),sessionTimeoutMs:me(i.sessionTimeoutMs,q.sessionTimeoutMs),maxSequenceLength:me(i.maxSequenceLength,q.maxSequenceLength),allowedPrivateHosts:Array.isArray(a.allowedPrivateHosts)?a.allowedPrivateHosts.filter(e=>typeof e==`string`).join(`
|
|
2
|
-
`):``,crossDomainNavigation:he(a.crossDomainNavigation),uploads:he(a.uploads),consequentialActions:he(a.consequentialActions)}}function Y(e){let t=e.driverKind===`extension`?{kind:`extension`}:e.driverKind===`playwright`?{kind:`playwright`,headless:e.headless,...e.executablePath.trim()?{executablePath:e.executablePath.trim()}:{}}:e.driverKind===`cdp`?{kind:`cdp`,endpoint:e.cdpEndpoint.trim()}:{kind:`remote`,provider:e.remoteProvider,...e.remoteApiKey.trim()?{apiKey:e.remoteApiKey.trim()}:{},...e.remoteProjectId.trim()?{projectId:e.remoteProjectId.trim()}:{},...e.remoteRegion.trim()?{region:e.remoteRegion.trim()}:{}};return{enabled:e.enabled,driver:t,observation:{maxNodes:e.maxNodes,maxCharacters:e.maxCharacters,visualFallback:e.visualFallback},limits:{actionTimeoutMs:e.actionTimeoutMs,sessionTimeoutMs:e.sessionTimeoutMs,maxSequenceLength:e.maxSequenceLength},security:{privateNetworks:`deny`,allowedPrivateHosts:e.allowedPrivateHosts.split(`
|
|
3
|
-
`).map(e=>e.trim()).filter(Boolean),crossDomainNavigation:e.crossDomainNavigation,uploads:e.uploads,consequentialActions:e.consequentialActions}}}function fe(e){if(e.driverKind===`cdp`)try{let t=new URL(e.cdpEndpoint);if(t.protocol!==`http:`&&t.protocol!==`https:`&&t.protocol!==`ws:`&&t.protocol!==`wss:`)return`CDP endpoint must use http, https, ws, or wss.`}catch{return`Enter a valid CDP endpoint URL.`}return!Number.isInteger(e.maxNodes)||e.maxNodes<20||e.maxNodes>500?`Max nodes must be between 20 and 500.`:!Number.isInteger(e.maxCharacters)||e.maxCharacters<1e3||e.maxCharacters>5e4?`Max characters must be between 1,000 and 50,000.`:!Number.isInteger(e.actionTimeoutMs)||e.actionTimeoutMs<1e3||e.actionTimeoutMs>12e4?`Action timeout must be between 1,000 and 120,000 ms.`:!Number.isInteger(e.sessionTimeoutMs)||e.sessionTimeoutMs<6e4||e.sessionTimeoutMs>36e5?`Session timeout must be between 60,000 and 3,600,000 ms.`:!Number.isInteger(e.maxSequenceLength)||e.maxSequenceLength<1||e.maxSequenceLength>10?`Sequence length must be between 1 and 10.`:null}async function pe(e){await _(b(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:Y(e)})}),C()}function X(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Z(e,t){return typeof e==`string`?e:t}function me(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function he(e){return e===`allow`||e===`deny`?e:`ask`}var ge=re();function _e(e){let t=!!v(e=>e.conversationId),[n,r]=(0,z.useReducer)(ge,{form:null,baseline:null}),i=n.form,a=n.baseline,o=(0,z.useRef)(!1),s=(0,z.useRef)(i);s.current=i;let c=(0,z.useRef)(null),{data:l,error:u,isLoading:d,mutate:f}=w(t);ee({enabled:t,parsed:(0,z.useMemo)(()=>l?.payload?.config===void 0?null:J(l.payload.config),[l]),dirty:o.current,trackedParsedRef:c,dispatch:r,onResetDirty:()=>{o.current=!1}});let p=!!(t&&d&&l===void 0&&!u),m=u instanceof Error?u.message:u?String(u):null,h=(0,z.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]),g=(0,z.useCallback)(e=>{o.current=!0,r({type:`patch`,patch:e})},[]),_=F({value:i,dirty:h,onSave:(0,z.useCallback)(async t=>{try{await pe(t),r({type:`saved`,value:t}),o.current=!!(s.current&&JSON.stringify(s.current)!==JSON.stringify(t))}catch(t){throw Error(t instanceof Error?t.message:e.saveError)}},[e.saveError]),validate:fe});return{hasToken:t,loading:p,fetchError:m,form:i,update:g,autosaveStatus:_.status,error:_.error,onBlurCapture:_.onBlurCapture,mutate:f}}var ve=[`extension`,`playwright`,`cdp`,`remote`];function ye(){let e=(0,R.c)(29),t=y(be),n;e[0]===t?n=e[1]:(n=g(t),e[0]=t,e[1]=n);let r=_e(n.agentSettings),i=r.form,o=t===`zh`,[c]=a(),l=(0,z.useRef)(!1),u;e[2]!==i||e[3]!==c||e[4]!==r?(u=()=>{if(!i||l.current)return;l.current=!0;let e=c.get(`driver`);ve.includes(e)&&e!==i.driverKind&&r.update({driverKind:e})},e[2]=i,e[3]=c,e[4]=r,e[5]=u):u=e[5];let f;e[6]!==i||e[7]!==c||e[8]!==r.update?(f=[i,c,r.update],e[6]=i,e[7]=c,e[8]=r.update,e[9]=f):f=e[9],(0,z.useEffect)(u,f);let m=o?`Chrome 扩展(推荐)`:`Chrome extension (recommended)`,_;e[10]===m?_=e[11]:(_={value:`extension`,label:m},e[10]=m,e[11]=_);let v;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(v={value:`playwright`,label:`Playwright Chromium`},e[12]=v):v=e[12];let b=o?`CDP 已有浏览器`:`Existing browser over CDP`,x;e[13]===b?x=e[14]:(x={value:`cdp`,label:b},e[13]=b,e[14]=x);let S=o?`远程浏览器`:`Remote browser`,C;e[15]===S?C=e[16]:(C={value:`remote`,label:S},e[15]=S,e[16]=C);let w;e[17]!==_||e[18]!==x||e[19]!==C?(w=[_,v,x,C],e[17]=_,e[18]=x,e[19]=C,e[20]=w):w=e[20];let T=w,E;e[21]!==T||e[22]!==i||e[23]!==r||e[24]!==o?(E=i?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(se,{enabled:i.enabled,driverKind:i.driverKind,autosaveStatus:r.autosaveStatus,zh:o}),(0,V.jsxs)(Se,{title:o?`运行方式`:`Connection`,icon:(0,V.jsx)(L,{className:`size-4`}),children:[(0,V.jsx)(we,{label:o?`启用浏览器控制`:`Enable browser control`,checked:i.enabled,onChange:e=>r.update({enabled:e})}),(0,V.jsx)(Ce,{label:o?`浏览器连接`:`Browser connection`,children:(0,V.jsx)(s,{value:i.driverKind,options:T,placeholder:o?`选择连接方式`:`Choose a connection`,allowEmpty:!1,onChange:e=>r.update({driverKind:e})})}),(0,V.jsx)(xe,{kind:i.driverKind,zh:o}),i.driverKind===`playwright`?(0,V.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-inset p-4`,children:[(0,V.jsx)(we,{label:o?`无头模式`:`Headless mode`,description:o?`后台运行,不显示浏览器窗口。关闭后可观察智能体的操作过程。`:`Run in the background without a visible window. Turn off to watch the agent work.`,checked:i.headless,onChange:e=>r.update({headless:e})}),(0,V.jsx)(Q,{label:o?`Chromium 可执行文件(可选)`:`Chromium executable (optional)`,description:o?`留空时使用由 xopc 安装的 Chromium。`:`Leave empty to use Chromium installed by xopc.`,value:i.executablePath,onChange:e=>r.update({executablePath:e})})]}):null,i.driverKind===`cdp`?(0,V.jsx)(`div`,{className:`rounded-lg bg-surface-inset p-4`,children:(0,V.jsx)(Q,{label:`CDP endpoint`,description:o?`例如 http://127.0.0.1:9222。Chrome 需要开启 remote debugging。`:`For example http://127.0.0.1:9222. Chrome must be started with remote debugging enabled.`,value:i.cdpEndpoint,onChange:e=>r.update({cdpEndpoint:e})})}):null,i.driverKind===`remote`?(0,V.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-inset p-4`,children:[(0,V.jsx)(Ce,{label:o?`服务商`:`Provider`,children:(0,V.jsx)(s,{value:i.remoteProvider,options:[{value:`browserbase`,label:`Browserbase`},{value:`browser-use`,label:`Browser Use`}],placeholder:o?`选择服务商`:`Choose a provider`,allowEmpty:!1,onChange:e=>r.update({remoteProvider:e})})}),(0,V.jsx)(Q,{label:`API key`,type:`password`,autoComplete:`off`,value:i.remoteApiKey,onChange:e=>r.update({remoteApiKey:e})}),(0,V.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,V.jsx)(Q,{label:`Project ID`,value:i.remoteProjectId,onChange:e=>r.update({remoteProjectId:e})}),(0,V.jsx)(Q,{label:`Region`,value:i.remoteRegion,onChange:e=>r.update({remoteRegion:e})})]})]}):null]}),(0,V.jsx)(I,{children:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(Se,{title:o?`页面理解`:`Page understanding`,icon:(0,V.jsx)(d,{className:`size-4`}),children:[(0,V.jsx)(we,{label:o?`需要时附加截图`:`Attach screenshots when needed`,checked:i.visualFallback,onChange:e=>r.update({visualFallback:e})}),(0,V.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,V.jsx)($,{label:o?`语义节点上限`:`Semantic node limit`,description:`20–500`,min:20,max:500,value:i.maxNodes,onChange:e=>r.update({maxNodes:e})}),(0,V.jsx)($,{label:o?`文本字符上限`:`Text character limit`,description:`1,000–50,000`,min:1e3,max:5e4,step:1e3,value:i.maxCharacters,onChange:e=>r.update({maxCharacters:e})})]})]}),(0,V.jsx)(Se,{title:o?`执行限制`:`Execution limits`,icon:(0,V.jsx)(p,{className:`size-4`}),children:(0,V.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,V.jsx)($,{label:o?`操作超时(毫秒)`:`Action timeout (ms)`,min:1e3,max:12e4,step:1e3,value:i.actionTimeoutMs,onChange:e=>r.update({actionTimeoutMs:e})}),(0,V.jsx)($,{label:o?`会话超时(毫秒)`:`Session timeout (ms)`,min:6e4,max:36e5,step:6e4,value:i.sessionTimeoutMs,onChange:e=>r.update({sessionTimeoutMs:e})}),(0,V.jsx)($,{label:o?`批量步骤上限`:`Sequence step limit`,min:1,max:10,value:i.maxSequenceLength,onChange:e=>r.update({maxSequenceLength:e})})]})}),(0,V.jsxs)(Se,{title:o?`安全与审批`:`Safety and approvals`,icon:(0,V.jsx)(h,{className:`size-4`}),children:[(0,V.jsx)(Q,{label:o?`允许访问的私网主机`:`Allowed private hosts`,description:o?`每行一个主机名或 IP,不支持通配符。`:`One hostname or IP per line. Wildcards are not supported.`,multiline:!0,value:i.allowedPrivateHosts,onChange:e=>r.update({allowedPrivateHosts:e})}),(0,V.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,V.jsx)(Te,{zh:o,label:o?`跨域导航`:`Cross-domain navigation`,value:i.crossDomainNavigation,onChange:e=>r.update({crossDomainNavigation:e})}),(0,V.jsx)(Te,{zh:o,label:o?`高影响动作`:`Consequential actions`,value:i.consequentialActions,onChange:e=>r.update({consequentialActions:e})}),(0,V.jsx)(Te,{zh:o,label:o?`文件上传`:`File uploads`,value:i.uploads,onChange:e=>r.update({uploads:e})})]})]})]})})]}):null,e[21]=T,e[22]=i,e[23]=r,e[24]=o,e[25]=E):E=e[25];let D;return e[26]!==E||e[27]!==r?(D=(0,V.jsx)(de,{sectionId:`agent-browser`,vm:r,children:E}),e[26]=E,e[27]=r,e[28]=D):D=e[28],D}function be(e){return e.language}function xe(e){let t=(0,R.c)(7),{kind:n,zh:r}=e,i=r?`直接操作你正在使用的 Chrome,保留登录状态和现有标签页;最适合日常协作。`:`Operate your current Chrome with its signed-in state and existing tabs; best for daily collaboration.`,a=r?`由 xopc 启动独立 Chromium,环境隔离、自动化稳定,适合无人值守任务。`:`Let xopc launch an isolated Chromium; stable for unattended automation.`,o=r?`连接已开启远程调试的 Chrome 或 Chromium,适合自定义浏览器启动方式。`:`Connect to Chrome or Chromium already running with remote debugging.`,s=r?`使用 Browserbase 或 Browser Use 的云端浏览器,适合服务器环境和长任务。`:`Use a Browserbase or Browser Use cloud browser for servers and long-running tasks.`,c;t[0]!==i||t[1]!==a||t[2]!==o||t[3]!==s?(c={extension:i,playwright:a,cdp:o,remote:s},t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=c):c=t[4];let l=c[n],u;return t[5]===l?u=t[6]:(u=(0,V.jsx)(`p`,{className:`rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:l}),t[5]=l,t[6]=u),u}function Se(e){let t=(0,R.c)(17),{title:n,description:r,icon:i,children:a}=e,o;t[0]===i?o=t[1]:(o=(0,V.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:i}),t[0]=i,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,V.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=r?(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r}):null,t[4]=r,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,V.jsxs)(`div`,{children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==o||t[10]!==l?(u=(0,V.jsxs)(`div`,{className:`mb-4 flex items-start gap-2`,children:[o,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11];let d;t[12]===a?d=t[13]:(d=(0,V.jsx)(`div`,{className:`space-y-4`,children:a}),t[12]=a,t[13]=d);let f;return t[14]!==u||t[15]!==d?(f=(0,V.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function Ce(e){let t=(0,R.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,V.jsx)(`span`,{className:`mb-1.5 block font-medium`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,V.jsx)(`span`,{className:`mt-1.5 block text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,V.jsxs)(`label`,{className:`block text-sm text-fg`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Q(e){let t=(0,R.c)(10),{label:n,description:r,value:i,onChange:a,type:o,multiline:s,autoComplete:c}=e,l=o===void 0?`text`:o,u=s===void 0?!1:s,d;t[0]!==c||t[1]!==u||t[2]!==a||t[3]!==l||t[4]!==i?(d=u?(0,V.jsx)(`textarea`,{rows:3,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2 text-sm text-fg outline-none focus:border-accent`}):(0,V.jsx)(`input`,{type:l,autoComplete:c,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2 text-sm text-fg outline-none focus:border-accent`}),t[0]=c,t[1]=u,t[2]=a,t[3]=l,t[4]=i,t[5]=d):d=t[5];let f;return t[6]!==r||t[7]!==n||t[8]!==d?(f=(0,V.jsx)(Ce,{label:n,description:r,children:d}),t[6]=r,t[7]=n,t[8]=d,t[9]=f):f=t[9],f}function $(e){let t=(0,R.c)(12),{label:n,description:r,value:i,onChange:a,min:o,max:s,step:c}=e,l=c===void 0?1:c,u;t[0]===a?u=t[1]:(u=e=>{let t=Number(e.target.value);Number.isFinite(t)&&a(t)},t[0]=a,t[1]=u);let d;t[2]!==s||t[3]!==o||t[4]!==l||t[5]!==u||t[6]!==i?(d=(0,V.jsx)(`input`,{type:`number`,min:o,max:s,step:l,value:i,onChange:u,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-sm text-fg outline-none focus:border-accent`}),t[2]=s,t[3]=o,t[4]=l,t[5]=u,t[6]=i,t[7]=d):d=t[7];let f;return t[8]!==r||t[9]!==n||t[10]!==d?(f=(0,V.jsx)(Ce,{label:n,description:r,children:d}),t[8]=r,t[9]=n,t[10]=d,t[11]=f):f=t[11],f}function we(e){let t=(0,R.c)(15),{label:n,description:r,checked:i,onChange:a}=e,o;t[0]===a?o=t[1]:(o=e=>a(e.target.checked),t[0]=a,t[1]=o);let s;t[2]!==i||t[3]!==o?(s=(0,V.jsx)(`input`,{type:`checkbox`,checked:i,onChange:o,className:`mt-0.5 size-4 accent-accent`}),t[2]=i,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n?c=t[6]:(c=(0,V.jsx)(`span`,{className:`block font-medium`,children:n}),t[5]=n,t[6]=c);let l;t[7]===r?l=t[8]:(l=r?(0,V.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-subtle`,children:r}):null,t[7]=r,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,V.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;return t[12]!==s||t[13]!==u?(d=(0,V.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14],d}function Te(e){let t=(0,R.c)(20),{zh:n,label:r,value:i,onChange:a}=e,o=n?`每次询问`:`Ask each time`,c;t[0]===o?c=t[1]:(c={value:`ask`,label:o},t[0]=o,t[1]=c);let l=n?`允许`:`Allow`,u;t[2]===l?u=t[3]:(u={value:`allow`,label:l},t[2]=l,t[3]=u);let d=n?`拒绝`:`Deny`,f;t[4]===d?f=t[5]:(f={value:`deny`,label:d},t[4]=d,t[5]=f);let p;t[6]!==c||t[7]!==u||t[8]!==f?(p=[c,u,f],t[6]=c,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m=p,h=n?`选择策略`:`Choose a policy`,g;t[10]===a?g=t[11]:(g=e=>a(e),t[10]=a,t[11]=g);let _;t[12]!==m||t[13]!==h||t[14]!==g||t[15]!==i?(_=(0,V.jsx)(s,{value:i,options:m,placeholder:h,allowEmpty:!1,onChange:g}),t[12]=m,t[13]=h,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v;return t[17]!==r||t[18]!==_?(v=(0,V.jsx)(Ce,{label:r,children:_}),t[17]=r,t[18]=_,t[19]=v):v=t[19],v}export{ye as AgentBrowserSettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-DPHK1VkS.js";var t=e(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]);export{t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/skills-page-C8zOGpKw.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-Cr4SINLG.js","assets/preload-helper-zJ_50EbN.js","assets/es2015-DBLcMg5B.js","assets/vendor-react-BOUWij0V.js","assets/dist-CxGUk8J-.js","assets/dist-CI_fqRk-.js","assets/floating-ui.dom-B7uQOZZW.js","assets/markdown-view-DXubGEic.js","assets/dist-BGTk37IG.js","assets/chunk-KS7C4IRE-BMYIfy9x.js","assets/createLucideIcon-DPHK1VkS.js","assets/download-Dk-ZjtO6.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/locale-store-BSkKhYkc.js","assets/messages-D0G_sZvA.js","assets/cn-JdwAhgNB.js","assets/app-link-C6gA5Nck.js","assets/product-delivery-bv3z8Xkh.js","assets/schemas-88fK3zzl.js","assets/local-apps-Bpja8nC6.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/markdown-view-DSjfHfaW.css","assets/dist-Che_jiQF.js","assets/vendor-swr-BIWyz7Rc.js","assets/check-DUBLcKHA.js","assets/popover-select-DcsFzD_i.js","assets/dist-3h6cXXhT.js","assets/skeleton-BwbyijEw.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/settings-shell-layer-context-BTQUDoJ2.js","assets/circle-check-C23XjkUj.js","assets/clock-3-DnrAnuyZ.js","assets/copy-Dv6d4Dvw.js","assets/ellipsis-0k4rZLoy.js","assets/external-link-DjqjBmc3.js","assets/eye-CABVeTq0.js","assets/folder-open-CyzJ19I9.js","assets/git-branch-Dh9uxTot.js","assets/globe-DSSGFWFn.js","assets/link-2-D_ZKYUW7.js","assets/loader-circle-CifKLtgG.js","assets/message-circle-Badhj-4D.js","assets/message-square-plus-XP0tGdlV.js","assets/message-square-fVE7Ghj1.js","assets/minimize-2-DtOGrlpo.js","assets/pencil-DmIY3Oa-.js","assets/rotate-cw-LIg3Am9S.js","assets/search-DA7gz22f.js","assets/middleware-Pd0e8Igk.js","assets/capabilities-sAZT4brT.js","assets/tasks-CDR_RVbQ.js","assets/conversation-identity-Cw0n9uzK.js","assets/files-BK6enEvD.js","assets/tool-activity-BtJkgjFf.js","assets/turn-outcome-D0SnyZ3Z.js","assets/button-CS04eWY9.js","assets/registry-api-tx8XCHOs.js","assets/gateway-startup-retry-DMqYXHAn.js","assets/gateway-config-swr-BYMrbKZE.js","assets/models-hub-cache-B0EUPwTv.js","assets/electron-env-Dit0bHgy.js","assets/is-masked-secret-DOkL5b_X.js","assets/index-C4QN4gCi.css","assets/star-BUWJqJ5c.js","assets/capability-header-actions-C3chJDQu.js","assets/capability-icon-BYm2-nS-.js","assets/skill-api-BCAV_F1P.js","assets/skill-reload-api-BEV2WXGk.js","assets/skill-card-icon-BrrpZ3Mw.js","assets/connectors-page-B4SLpvSL.js","assets/server-BlHCBjiE.js","assets/store-SzD1Jvgm.js","assets/connector-service-page-F-fYNIx8.js","assets/agent-plugin-dialog-DLKj_iIh.js","assets/upload-rrb46c3c.js","assets/apps-page-DcclVdxW.js","assets/box-DvYoGszj.js","assets/extension-marketplace-api-DqV4YRYs.js","assets/agents-SXZ5O0g4.js","assets/gauge-C78eD2BA.js","assets/user-round-C9jxPhMR.js","assets/directory-picker-path-field-BfxaNwMB.js","assets/settings-page-layout-X1x-2Cp9.js","assets/channels-CuVS_KsY.js","assets/stethoscope-DRqTAtjD.js","assets/browser-BLJWD7WI.js","assets/schema-form-DPMEuj5D.js","assets/settings-loading-skeleton-CAmWMaOT.js","assets/capability-discover-page-CgGvsf3t.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{m as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./messages-D0G_sZvA.js";import{n as s}from"./locale-store-BSkKhYkc.js";import{t as c}from"./skeleton-BwbyijEw.js";import{Eo as l,Sc as u}from"./index-Cr4SINLG.js";import{t as d}from"./capability-header-actions-C3chJDQu.js";var f=n(),p=e(t(),1),m=r(),h=(0,p.lazy)(()=>i(()=>import(`./skills-page-C8zOGpKw.js`).then(e=>({default:e.SkillsPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71]))),g=(0,p.lazy)(()=>i(()=>import(`./connectors-page-B4SLpvSL.js`).then(e=>({default:e.ConnectorsPage})),__vite__mapDeps([72,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,73,74,67,75,76,77]))),_=(0,p.lazy)(()=>i(()=>import(`./apps-page-DcclVdxW.js`).then(e=>({default:e.ExtensionsPage})),__vite__mapDeps([78,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,79,67,68,76,77,80]))),v=(0,p.lazy)(()=>i(()=>import(`./agents-SXZ5O0g4.js`).then(e=>({default:e.AgentsSettingsPanel})),__vite__mapDeps([81,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,82,83,84,85]))),y=(0,p.lazy)(()=>i(()=>import(`./channels-CuVS_KsY.js`).then(e=>({default:e.ChannelsSettingsPanel})),__vite__mapDeps([86,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,87,88,89,90,85]))),b=(0,p.lazy)(()=>i(()=>import(`./capability-discover-page-CgGvsf3t.js`).then(e=>({default:e.CapabilityDiscoverPage})),__vite__mapDeps([91,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,67,68,80,69,70])));function x(e){return u.includes(e)?e:`discover`}function S(e){let t=(0,f.c)(3),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Array.from({length:6},C),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,m.jsx)(`div`,{className:`mx-auto grid w-full max-w-7xl gap-4 px-4 pb-7 pt-3 sm:grid-cols-2 sm:px-6 lg:grid-cols-3 lg:px-8 lg:pb-9 lg:pt-4`,"aria-label":n,"aria-busy":!0,children:r}),t[1]=n,t[2]=i),i}function C(e,t){return(0,m.jsx)(c,{className:`h-40 rounded-xl`},t)}function w(){let e=(0,f.c)(43),t=s(D),n;e[0]===t?n=e[1]:(n=o(t),e[0]=t,e[1]=n);let r=n.capabilitiesHub,{section:i,detailId:c}=a(),u;e[2]===i?u=e[3]:(u=x(i),e[2]=i,e[3]=u);let C=u,w=l(E),O=l(T),k;e[4]===C?k=e[5]:(k={section:C,value:null},e[4]=C,e[5]=k);let[A,j]=(0,p.useState)(k),M=A.section===C?A.value:null,N;e[6]===C?N=e[7]:(N=e=>{j({section:C,value:e})},e[6]=C,e[7]=N);let P=N,F,I;e[8]!==O||e[9]!==M||e[10]!==w?(F=()=>(w({startExtra:null,main:null,end:(0,m.jsx)(d,{contribution:M})}),()=>O()),I=[O,M,w],e[8]=O,e[9]=M,e[10]=w,e[11]=F,e[12]=I):(F=e[11],I=e[12]),(0,p.useLayoutEffect)(F,I);let L;e[13]===r.discoverLoading?L=e[14]:(L=(0,m.jsx)(S,{label:r.discoverLoading}),e[13]=r.discoverLoading,e[14]=L);let R;e[15]!==P||e[16]!==C?(R=C===`discover`?(0,m.jsx)(b,{onHeaderActionChange:P}):null,e[15]=P,e[16]=C,e[17]=R):R=e[17];let z;e[18]!==c||e[19]!==P||e[20]!==C?(z=C===`agents`?(0,m.jsx)(v,{agentId:c,onHeaderActionChange:P}):null,e[18]=c,e[19]=P,e[20]=C,e[21]=z):z=e[21];let B;e[22]!==P||e[23]!==C?(B=C===`skills`?(0,m.jsx)(h,{embedded:!0,onHeaderActionChange:P}):null,e[22]=P,e[23]=C,e[24]=B):B=e[24];let V;e[25]!==P||e[26]!==C?(V=C===`connectors`?(0,m.jsx)(g,{embedded:!0,onHeaderActionChange:P}):null,e[25]=P,e[26]=C,e[27]=V):V=e[27];let H;e[28]!==c||e[29]!==P||e[30]!==C?(H=C===`channels`?(0,m.jsx)(y,{channelId:c,onHeaderActionChange:P}):null,e[28]=c,e[29]=P,e[30]=C,e[31]=H):H=e[31];let U;e[32]!==P||e[33]!==C?(U=C===`extensions`?(0,m.jsx)(_,{embedded:!0,onHeaderActionChange:P}):null,e[32]=P,e[33]=C,e[34]=U):U=e[34];let W;return e[35]!==V||e[36]!==H||e[37]!==U||e[38]!==L||e[39]!==R||e[40]!==z||e[41]!==B?(W=(0,m.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,m.jsxs)(p.Suspense,{fallback:L,children:[R,z,B,V,H,U]})}),e[35]=V,e[36]=H,e[37]=U,e[38]=L,e[39]=R,e[40]=z,e[41]=B,e[42]=W):W=e[42],W}function T(e){return e.clearPageHeader}function E(e){return e.setPageHeader}function D(e){return e.language}export{w as CapabilitiesPage};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-BIWyz7Rc.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{f as a,g as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as u}from"./createLucideIcon-DPHK1VkS.js";import{n as d,r as f,t as p}from"./popover-select-DcsFzD_i.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./external-link-DjqjBmc3.js";import{t as g}from"./eye-CABVeTq0.js";import{t as _}from"./image-Cwyalflz.js";import{t as v}from"./loader-circle-CifKLtgG.js";import{t as y}from"./pencil-DmIY3Oa-.js";import{t as b}from"./plus-Q2yW6OE7.js";import{t as x}from"./x-B_N4OPjy.js";import{t as S}from"./messages-D0G_sZvA.js";import{t as C}from"./cn-JdwAhgNB.js";import{a as w,c as T,i as E,n as D,r as O}from"./locale-store-BSkKhYkc.js";import{a as k,i as A,n as j,o as M,r as N,s as ee,t as P}from"./dist-BGTk37IG.js";import{i as F}from"./vendor-swr-BIWyz7Rc.js";import{t as I}from"./button-CS04eWY9.js";import{n as L,r as R}from"./gateway-config-swr-BYMrbKZE.js";import{n as z}from"./is-masked-secret-DOkL5b_X.js";import{t as B}from"./skeleton-BwbyijEw.js";import{i as V,o as H}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as U}from"./electron-env-Dit0bHgy.js";import{i as W,r as G,t as K}from"./models-hub-cache-B0EUPwTv.js";import{$o as q,At as te,Bc as ne,Bl as re,Bo as J,Ct as Y,Dc as X,Dn as ie,Dt as ae,Et as oe,Ft as se,Ho as Z,Ht as ce,It as le,Js as ue,Ko as de,Li as fe,Lt as pe,Ma as me,Nt as he,Oc as ge,Ot as _e,Pc as ve,Pt as ye,Ql as be,Qo as xe,Rc as Se,Rt as Ce,St as we,Tc as Te,Tt as Ee,Uc as De,Ul as Oe,Ut as ke,Vo as Ae,Vt as je,Xc as Me,Yc as Ne,Yo as Pe,Ys as Fe,Zl as Ie,Zo as Le,_t as Re,as as ze,bt as Be,cs as Ve,ds as He,fs as Ue,gt as We,hl as Ge,is as Ke,ja as qe,jl as Je,jt as Ye,ka as Xe,kt as Ze,ll as Qe,ns as $e,os as et,qc as tt,qo as nt,ss as rt,vt as it,wt as at,xt as ot,yt as st,zo as ct,zt as lt}from"./index-Cr4SINLG.js";import{n as ut,r as dt}from"./settings-page-layout-X1x-2Cp9.js";import{n as ft,t as pt}from"./settings-form-section-DM0D-BQ_.js";import{t as mt}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as ht,t as gt}from"./use-autosave-ZTHe1zCM.js";import{c as _t,d as vt,i as yt,l as bt,n as xt,o as St,r as Ct,s as wt,t as Tt}from"./voice-config-api-BvzxINUk.js";import{t as Et}from"./voice-api-key-field-C8Kpkct-.js";import{t as Dt}from"./settings-advanced-gate-BEyQiZs0.js";import{a as Ot,i as kt,n as At,o as jt,r as Mt,t as Nt}from"./image-generation-api-D1sQGaJz.js";var Pt=u(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),Ft=n(),Q=e(t(),1),$=r(),It={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},Lt=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function Rt(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function zt(e){let t=e.split(`
|
|
3
|
-
`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function Bt({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=It[i],[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`bearer`),[_,y]=(0,Q.useState)(`x-api-key`),[S,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(``),[D,O]=(0,Q.useState)(``),[F,L]=(0,Q.useState)(`/images/generations`),[R,B]=(0,Q.useState)(`/images/edits`),[U,W]=(0,Q.useState)(``),[G,K]=(0,Q.useState)(``),[q,te]=(0,Q.useState)([Rt()]),[ne,re]=(0,Q.useState)(``),[J,Y]=(0,Q.useState)(),[X,ie]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(),[se,Z]=(0,Q.useState)(),[ce,le]=(0,Q.useState)();(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),u(t?.name??``),f(n?.baseUrl??``),h(t?.auth.type??`bearer`),y(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),w(r?`••••••••••••`:``),E(t?.apiKeyUrl??``),O(t?.documentationUrl??``),L(t?.paths?.generations??`/images/generations`),B(t?.paths?.edits??`/images/edits`),W(t?.network?.allowedHosts.join(`
|
|
4
|
-
`)??``),K(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
5
|
-
`)),te(t?.models.map(Rt)??[Rt()]),re(t?.defaultModel??``),Z(void 0),Y(void 0),ie(!1),oe(void 0),le(void 0)},[r,e,n]);let ue=(0,Q.useMemo)(()=>q.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[q]),de=(e,t)=>{te(n=>n.map((n,r)=>r===e?{...n,...t}:n))},fe=()=>{let e=s.trim(),t=q.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!l.trim()||!d.trim()||t.some(e=>!e.id))throw Error(o.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(o.duplicateModels);let n=ne||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=zt(G)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:d.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:l.trim(),...D.trim()?{documentationUrl:D.trim()}:{},...T.trim()?{apiKeyUrl:T.trim()}:{},defaultModel:n,auth:m===`header`?{type:`header`,headerName:_.trim()}:{type:m},paths:{...F.trim()?{generations:F.trim()}:{},...R.trim()?{edits:R.trim()}:{}},...U.trim()?{network:{allowedHosts:U.split(`
|
|
6
|
-
`).map(e=>e.trim()).filter(Boolean)}}:{},models:t.map(e=>({...e.original,id:e.id,...e.name?{name:e.name}:{name:void 0},capabilities:{...e.original.capabilities,generate:{...e.original.capabilities.generate,maxCount:Math.max(1,Number.parseInt(e.maxCount,10)||1),supportsSize:e.supportsSize},edit:{...e.original.capabilities.edit,enabled:e.editEnabled}},defaults:{...e.original.defaults,...e.defaultCount?{count:Math.max(1,Number.parseInt(e.defaultCount,10)||1)}:{count:void 0},...e.defaultSize.trim()?{size:e.defaultSize.trim()}:{size:void 0},...e.outputFormat?{outputFormat:e.outputFormat}:{outputFormat:void 0}}}))}}}},pe=async()=>{let e=fe();return await kt(e.providerId,e.input),m!==`none`&&S.trim()&&!z(S)&&await Ot(e.providerId,S.trim()),await a(e.providerId),e},me=async()=>{Y(`save`),oe(void 0),Z(void 0);try{await pe(),w(m===`none`?``:`••••••••••••`),Z(o.saved)}catch(e){oe(e instanceof Error?e.message:String(e))}finally{Y(void 0)}},he=async()=>{Y(`test`),oe(void 0),Z(void 0),le(void 0);try{let e=await pe();le((await jt(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),Z(o.testReady)}catch(e){oe(e instanceof Error?e.message:String(e))}finally{Y(void 0)}},_e=async()=>{if(n){if(!X){ie(!0);return}Y(`delete`),oe(void 0);try{await Nt(n.providerId),await a(),t(!1)}catch(e){oe(e instanceof Error?e.message:String(e))}finally{Y(void 0)}}};return(0,$.jsx)(P,{open:e,onOpenChange:t,children:(0,$.jsxs)(M,{children:[(0,$.jsx)(k,{className:C(`xopc-dialog-overlay fixed inset-0 bg-scrim`,H)}),(0,$.jsxs)(N,{className:C(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(88vh,760px)] w-[min(calc(100%-2rem),52rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,V),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ee,{className:`font-semibold text-fg`,children:n?o.editTitle:o.addTitle}),(0,$.jsx)(A,{className:`mt-1 text-sm text-fg-muted`,children:o.intro})]}),(0,$.jsx)(j,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-muted hover:bg-surface-inset hover:text-fg`,"aria-label":o.cancel,children:(0,$.jsx)(x,{className:`size-5`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.connection}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.providerId,(0,$.jsx)(`input`,{value:s,disabled:!!n,onChange:e=>c(e.target.value),placeholder:`my-image-service`,className:Lt}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.name,(0,$.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`My Image Service`,className:Lt})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.baseUrl,(0,$.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`https://api.example.com/v1`,className:Lt})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.auth,(0,$.jsx)(p,{value:m,options:[{value:`bearer`,label:o.bearer},{value:`header`,label:o.header},{value:`none`,label:o.none}],placeholder:o.auth,allowEmpty:!1,onChange:e=>h(e),triggerClassName:`mt-1.5`})]}),m===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.headerName,(0,$.jsx)(`input`,{value:_,onChange:e=>y(e.target.value),className:Lt})]}):null]}),m===`none`?null:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-image-api-key`,className:`text-xs font-medium text-fg-muted`,children:o.apiKey}),T.trim()?(0,$.jsxs)(`a`,{href:T.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[o.openKeyPage,(0,$.jsx)(Ie,{className:`size-3.5`})]}):null]}),(0,$.jsx)(Pe,{id:`custom-image-api-key`,value:S,onChange:e=>w(z(S)?e.replace(/^•+/,``):e),labels:{show:o.show,hide:o.hide,copy:o.copy,copied:o.copied},reveal:()=>ke(s).then(e=>e.apiKey),loadFailedLabel:o.revealFailed,notInConfigFile:o.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:o.apiKeyHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.apiKeyUrl,(0,$.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),placeholder:`https://…`,className:Lt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.docsUrl,(0,$.jsx)(`input`,{value:D,onChange:e=>O(e.target.value),placeholder:`https://…`,className:Lt})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:o.paths}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.generationsPath,(0,$.jsx)(`input`,{value:F,onChange:e=>L(e.target.value),className:Lt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.editsPath,(0,$.jsx)(`input`,{value:R,onChange:e=>B(e.target.value),className:Lt})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.allowedHosts,(0,$.jsx)(`textarea`,{value:U,onChange:e=>W(e.target.value),rows:2,placeholder:`127.0.0.1
|
|
7
|
-
image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.staticHeaders,(0,$.jsx)(`textarea`,{value:G,onChange:e=>K(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.staticHeadersHint})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.models}),(0,$.jsxs)(I,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>te(e=>[...e,Rt()]),children:[(0,$.jsx)(b,{className:`size-4`}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.defaultModel,(0,$.jsx)(p,{value:ne||ue[0]?.value||``,options:ue,placeholder:o.defaultModel,allowEmpty:!1,onChange:re,triggerClassName:`mt-1.5 max-w-sm`})]}),q.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>de(t,{id:e.target.value}),placeholder:`image-1`,className:Lt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>de(t,{name:e.target.value}),className:Lt})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>de(t,{maxCount:e.target.value}),className:Lt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>de(t,{defaultCount:e.target.value}),className:Lt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>de(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:Lt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.format,(0,$.jsx)(p,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:o.format,allowEmpty:!0,onChange:e=>de(t,{outputFormat:e}),triggerClassName:`mt-1.5`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.supportsSize,onChange:e=>de(t,{supportsSize:e.target.checked})}),o.supportsSize]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.editEnabled,onChange:e=>de(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:q.length===1,onClick:()=>te(e=>e.filter((e,n)=>n!==t)),className:`ml-auto inline-flex items-center gap-1 text-xs text-red-600 disabled:opacity-40 dark:text-red-400`,children:[(0,$.jsx)(ge,{className:`size-3.5`}),o.remove]})]})]},t))]}),ce?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(g,{className:`size-4`}),o.testReady]}),(0,$.jsx)(`img`,{src:ce,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,se?(0,$.jsx)(`p`,{className:`rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:se}):null,ae?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:ae}):null]}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-5 py-3`,children:[n?(0,$.jsxs)(I,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!J,onClick:()=>void _e(),children:[J===`delete`?(0,$.jsx)(v,{className:`size-4 animate-spin`}):(0,$.jsx)(ge,{className:`size-4`}),X?o.confirmDelete:o.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(j,{asChild:!0,children:(0,$.jsx)(I,{variant:`secondary`,children:o.cancel})}),(0,$.jsxs)(I,{variant:`secondary`,disabled:!!J,onClick:()=>void he(),children:[J===`test`?(0,$.jsx)(v,{className:`size-4 animate-spin`}):null,J===`test`?o.testing:o.test]}),(0,$.jsxs)(I,{variant:`primary`,disabled:!!J,onClick:()=>void me(),children:[J===`save`?(0,$.jsx)(v,{className:`size-4 animate-spin`}):null,J===`save`?o.saving:o.save]})]})]})]})]})})}var Vt=`••••••••••••`,Ht={en:{title:`Image generation`,intro:`Configure the default image model and service. Agents inherit this setting unless overridden in Agent settings.`,provider:`Provider`,model:`Model`,apiKey:`API key`,getApiKey:`Get API key`,apiKeyHint:`Stored in the local credential store, never in xopc.json.`,existingKey:`A credential or environment variable is already available. Leave this blank to reuse it.`,savedKey:`A credential is saved. Use the eye button to view it, or type a new key to replace it.`,revealFailed:`Unable to load the saved API key.`,keyNotRevealable:`This credential comes from an environment variable or another non-revealable source.`,advanced:`Provider settings`,enable:`Enable image generation`,enabling:`Verifying and enabling…`,enabled:`Image generation is ready.`,addService:`Add image service`,manageService:`Manage service`,custom:`Custom`,current:`Current`,configured:`Credential ready`,needsKey:`API key required`,connect:`Connect to a gateway to continue.`,loadError:`Unable to load image generation settings.`,selectModel:`Select a model`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`},zh:{title:`图片生成`,intro:`配置全局图片生成模型和服务。各智能体默认继承此设置,也可在智能体详情中单独覆盖。`,provider:`Provider`,model:`模型`,apiKey:`API Key`,getApiKey:`获取 API Key`,apiKeyHint:`密钥只保存在本机凭据存储中,不会写入 xopc.json。`,existingKey:`已有凭据或环境变量;留空即可继续使用。`,savedKey:`凭据已保存。点击眼睛可查看,直接输入新密钥可替换。`,revealFailed:`无法读取已保存的 API Key。`,keyNotRevealable:`当前凭据来自环境变量或其他不可查看的来源。`,advanced:`服务商设置`,enable:`启用图片生成`,enabling:`正在验证并启用…`,enabled:`图片生成已可用。`,addService:`添加图片服务`,manageService:`管理服务`,custom:`自定义`,current:`当前使用`,configured:`凭据已就绪`,needsKey:`需要 API Key`,connect:`请先连接网关。`,loadError:`无法加载图片生成设置。`,selectModel:`选择模型`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`}};async function Ut(){let e=await w(O(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function Wt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function Gt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function Kt(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function qt(e){let t=(0,Ft.c)(11),{field:n,value:r,onChange:i}=e,a;t[0]!==n.label||t[1]!==n.options||t[2]!==n.placeholder||t[3]!==n.required||t[4]!==n.type||t[5]!==i||t[6]!==r?(a=n.type===`select`?(0,$.jsx)(p,{value:r,options:(n.options??[]).map(Jt),placeholder:n.placeholder??n.label,allowEmpty:!n.required,onChange:i,triggerClassName:`mt-1.5`}):(0,$.jsx)(`input`,{type:`url`,value:r,required:n.required,onChange:e=>i(e.target.value),placeholder:n.placeholder,className:`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[0]=n.label,t[1]=n.options,t[2]=n.placeholder,t[3]=n.required,t[4]=n.type,t[5]=i,t[6]=r,t[7]=a):a=t[7];let o;return t[8]!==n.label||t[9]!==a?(o=(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[n.label,a]}),t[8]=n.label,t[9]=a,t[10]=o):o=t[10],o}function Jt(e){return{value:e.value,label:e.label}}function Yt(){let e=(0,Ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(B,{className:`h-24 rounded-xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[t,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:5}).map(Xt)}),(0,$.jsx)(B,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function Xt(e,t){return(0,$.jsx)(B,{className:`h-24 rounded-xl`},t)}function Zt(){let e=D(e=>e.language),t=Ht[e],n=!!T(e=>e.conversationId),[r,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)({}),[f,h]=(0,Q.useState)(!1),[g,y]=(0,Q.useState)(),[x,S]=(0,Q.useState)(!1),[C,E]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(),{data:j,isLoading:M,error:N,mutate:ee}=F(n?O(`/api/image-generation/catalog`):null,Mt,{revalidateOnFocus:!1}),{data:P,isLoading:R,error:B,mutate:V}=F(n?O(`/api/image-generation/custom-providers`):null,At,{revalidateOnFocus:!1}),{data:H,isLoading:U,error:W,mutate:G}=F(n?`default-image-generation`:null,Ut,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!j||!H)return;let e=Wt(H.model?.primary),t=j.find(t=>t.id===e)??j.find(e=>e.configured)??j[0];t&&(a(t.id),s(t.id===e&&Gt(H.model?.primary)||t.defaultModel),l(t.configured?Vt:``),d(Kt(t)))},[H,j]);let K=j?.find(e=>e.id===r),q=K?K.apiKeyUrl??ae(K.id,e)[0]?.href:void 0,te=(0,Q.useMemo)(()=>(K?.models??[]).map(e=>({value:e,label:e})),[K?.models]),ne=H?.model?.primary,re=!!(K&&o&&(K.credentialMode!==`api-key`||K.configured||c.trim())&&K.configFields.every(e=>!e.required||u[e.key]?.trim()));if(!n)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connect});if(M||R||U)return(0,$.jsx)(Yt,{});if(N||B||W||!j||!P)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let J=e=>{a(e.id),s(e.defaultModel),l(e.configured?Vt:``),d(Kt(e)),y(void 0)},Y=()=>{A(void 0),E(!0)},X=()=>{let e=P.find(e=>e.providerId===K?.id);e&&(A(e),E(!0))},ie=async e=>{let[t,n]=await Promise.all([V(),ee()]);if(e&&n?.some(t=>t.id===e)){let r=n.find(t=>t.id===e);a(r.id),s(r.defaultModel),l(r.configured?Vt:``),d(Kt(r)),A(t?.find(t=>t.providerId===e))}},oe=async()=>{if(!(!K||!re)){h(!0),y(void 0),S(!1);try{let e=await w(O(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:K.id,modelId:o,...c.trim()&&!z(c)?{apiKey:c.trim()}:{},providerConfig:Object.fromEntries(Object.entries(u).filter(([,e])=>e.trim()))})});if(!e.payload)throw Error(`Invalid setup response`);await Promise.all([G(e.payload.default,{revalidate:!1}),ee(e.payload.providers,{revalidate:!1}),i(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([0,1,2])).then(({mutate:e})=>Promise.all([e(`settings-agent-defaults`),e(`settings-gateway-agents`)])),L()]),l(Vt),S(!0)}catch(e){y(e instanceof Error?e.message:String(e))}finally{h(!1)}}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,$.jsx)(_,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:t.intro})]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:t.provider}),(0,$.jsxs)(I,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:Y,children:[(0,$.jsx)(b,{className:`size-4`}),t.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:j.map(e=>{let n=e.id===r,i=e.id===Wt(ne);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>J(e),className:`min-h-24 rounded-xl p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${n?`bg-accent-soft shadow-surface`:`bg-surface-base/55 hover:bg-surface-hover`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-[10px] text-fg-subtle`,children:t.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!i,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${i?``:`invisible`}`,children:t.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(m,{className:`size-3.5`}):(0,$.jsx)(Ge,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?t.configured:t.needsKey]})]},e.id)})})]}),K?(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[t.model,(0,$.jsx)(p,{value:o,options:te,placeholder:t.selectModel,allowEmpty:!1,onChange:s,triggerClassName:`mt-1.5`})]}),K.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(qt,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))]}),K.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(I,{variant:`secondary`,onClick:X,children:[(0,$.jsx)(De,{className:`size-4`}),t.manageService]})}):null,K.credentialMode===`api-key`?(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`image-generation-api-key`,className:`text-xs font-medium text-fg-muted`,children:t.apiKey}),q?(0,$.jsxs)(`a`,{href:q,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(Ie,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(Pe,{id:`image-generation-api-key`,value:c,onChange:e=>l(z(c)?e.replace(/^•+/,``):e),placeholder:K.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>ke(K.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},K.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:K.configured?t.savedKey:t.apiKeyHint})]}):null,K.configFields.some(e=>!e.required)?(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(Se,{className:`size-4`}),t.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:K.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(qt,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))})]}):null,x?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:t.enabled}):null,g?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:g}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(I,{variant:`primary`,disabled:!re||f,onClick:()=>void oe(),children:[f?(0,$.jsx)(v,{className:`size-4 animate-spin`}):(0,$.jsx)(m,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:f?t.enabling:t.enable})]})]})})]}):null,(0,$.jsx)(Bt,{open:C,onOpenChange:E,provider:k,configured:!!(k&&j.find(e=>e.id===k.providerId)?.configured),language:e,onSaved:ie})]})}function Qt({disabled:e=!1}){let t=D(e=>e.language)===`zh`,[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(``),{data:o,mutate:s,error:c}=F(O(`/api/voice/catalog`),async e=>{let t=await w(e);return Ve.parse(t.payload)}),l=t?{transcription:`录音转文字`,"transcription.stream":`实时听写 / 语音助手输入`,speech:`消息朗读`,"speech.stream":`语音助手输出`,conversation:`自然语音对话`}:{transcription:`Recorded transcription`,"transcription.stream":`Live dictation / assistant input`,speech:`Message readout`,"speech.stream":`Assistant speech`,conversation:`Natural conversation`},u=async e=>{if(o){r(!0),a(``);try{let t=await w(O(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:o.revision,selection:e})}:{}});await s(Ve.parse(t.payload),!1),await L()}catch(e){a(e instanceof Error?e.message:String(e)),await s()}finally{r(!1)}}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:t?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(I,{variant:`secondary`,disabled:n||e||!o,onClick:()=>void u(),children:t?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`各设备共用此 Gateway 的模型设置,修改在下次调用生效。仅显示支持对应场景的已发布模型。`:`Devices share this gateway’s selections. Changes apply to the next call. Only published models supporting each mode are shown.`}),i||c?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:i||String(c)}):null,o?Object.keys(l).map(r=>{let i=o.selections.find(e=>e.mode===r),a=o.models.filter(e=>e.voice.modes.includes(r)),s=a.find(e=>e.id===i?.model);return(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:l[r]}),(0,$.jsxs)(d,{className:`w-full`,value:i?.model??``,disabled:n||e||!a.length,onChange:e=>void u({mode:r,model:e.target.value}),children:[(0,$.jsx)(f,{value:``,disabled:!0,children:t?`选择模型`:`Choose model`}),i&&!s?(0,$.jsxs)(f,{value:i.model,disabled:!0,children:[i.model,` · `,t?`不可用`:`Unavailable`]}):null,a.map(e=>(0,$.jsx)(f,{value:e.id,children:e.name},e.id))]}),a.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t?`暂无可用模型`:`No available model`})]}),s&&s.voice.voices.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:t?`音色`:`Voice`}),(0,$.jsx)(d,{className:`w-full`,value:i?.voice??``,disabled:n||e,onChange:e=>void u({mode:r,model:s.id,voice:e.target.value}),children:s.voice.voices.map(e=>(0,$.jsx)(f,{value:e.id,children:e.name},e.id))})]}):null]},r)}):(0,$.jsx)(B,{className:`h-48 w-full`})]})}function $t({v:e}){let t=He(e=>e.microphoneId),n=He(e=>e.setMicrophoneId),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{l.current=!0;let e=()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{l.current&&i(e.filter(e=>e.kind===`audioinput`))}).catch(()=>{})};return e(),navigator.mediaDevices?.addEventListener(`devicechange`,e),()=>{l.current=!1,navigator.mediaDevices?.removeEventListener(`devicechange`,e)}},[]);let u=async()=>{c(!0),o(``);try{(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop());let e=await navigator.mediaDevices.enumerateDevices();l.current&&i(e.filter(e=>e.kind===`audioinput`))}catch(e){l.current&&o(e instanceof Error?e.message:String(e))}finally{l.current&&c(!1)}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:e.experience.microphone}),(0,$.jsxs)(d,{value:t,onChange:e=>n(e.target.value),children:[(0,$.jsx)(f,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,$.jsx)(f,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,$.jsx)(f,{value:t.deviceId,children:t.label||`${e.experience.microphone} ${n+1}`},t.deviceId))]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.experience.deviceHint}),(0,$.jsx)(I,{variant:`secondary`,disabled:s,onClick:()=>void u(),children:e.experience.refreshDevices}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a}):null]})}function en({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Q.useContext)($e)?.active??!1,[s,c]=(0,Q.useState)(`idle`),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),p=(0,Q.useRef)(`idle`),m=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),g=e=>{p.current=e,c(e)},_=()=>{m.current?.(),m.current=null};(0,Q.useEffect)(()=>()=>m.current?.(),[]);async function y(e){_(),i?.({input:!1,output:!1}),h.current=!1,u(``),f(``),g(e?`connecting`:`playing`);let t=new AbortController,r,o,s,c,l=()=>{o?.cancel(),r?.getTracks().forEach(e=>e.stop()),s?.stop(`surface_closed`)},d=window.setTimeout(()=>v(a.timeout),6e4);m.current=()=>{t.abort(),window.clearTimeout(d),l(),c?.close()};function v(e){t.signal.aborted||(g(`error`),f(e),_())}async function y(){g(`playing`),l();try{let e=await bt(t.signal);if(t.signal.aborted)return;c?.enqueue(e,()=>{t.signal.aborted||(window.clearTimeout(d),g(`confirm`))})}catch(e){v(e instanceof Error?e.message:a.testFailed)}}try{if(n&&(c=new et,await c.start(),t.signal.throwIfAborted()),!e){await y();return}let d=window.electronAPI?.system;if(d){let e=await d.requestMicrophone();if(t.signal.throwIfAborted(),e.status===`denied`)throw Error(a.microphoneDenied)}if(r=await navigator.mediaDevices.getUserMedia({audio:Ue()}),t.signal.aborted){l();return}if(s=await rt.connect({purpose:`dictation`,signal:t.signal,onEvent:e=>{t.signal.aborted||(e.type===`session.error`&&v(a.testFailed),p.current===`listening`&&(e.type===`input.transcript.delta`&&u(e.payload.text),e.type===`input.transcript.final`&&e.payload.text.trim()&&(u(e.payload.text.trim()),h.current=!0,n?y():(g(`passed`),i?.({input:!0,output:!1}),_()))))},onClose:()=>{(p.current===`listening`||p.current===`connecting`)&&v(a.testFailed)}}),t.signal.aborted){l();return}let f;if(o=await Ke.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new ze(o.sampleRate,s.session.inputFormat.sampleRate),g(`listening`)}catch(e){if(t.signal.aborted){l();return}v(e instanceof Error?e.message:a.testFailed)}}let b=s===`connecting`||s===`listening`||s===`playing`;return(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(I,{type:`button`,variant:`primary`,disabled:o||r||!t||b,onClick:()=>void y(!0),children:[b?(0,$.jsx)(v,{className:`size-4 animate-spin`}):(0,$.jsx)(Qe,{className:`size-4`}),n?a.test:a.testInput]}),(0,$.jsxs)(I,{type:`button`,variant:`secondary`,disabled:o||r||!n||b,onClick:()=>void y(!1),children:[(0,$.jsx)(Me,{className:`size-4`}),e.tts.test.play]}),b?(0,$.jsxs)(I,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`idle`)},children:[(0,$.jsx)(ve,{className:`size-4`}),e.tts.test.stop]}):null]}),(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`space-y-2 text-xs text-fg-muted`,children:[s===`idle`?(0,$.jsx)(`p`,{children:o?e.experience.endCallBeforeTest:r?a.saveBeforeTest:a.microphoneHint}):null,s===`connecting`?(0,$.jsx)(`p`,{children:a.connecting}):null,s===`listening`?(0,$.jsx)(`p`,{children:a.speakNow}):null,l?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-base p-3 text-sm text-fg`,children:l}):null,s===`playing`?(0,$.jsx)(`p`,{children:a.playing}):null,s===`confirm`?(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{children:a.heardQuestion}),(0,$.jsx)(I,{type:`button`,variant:`secondary`,onClick:()=>{_(),i?.({input:h.current,output:!0}),g(`passed`)},children:a.heard}),(0,$.jsx)(I,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`error`),f(a.notHeard)},children:a.notHeardButton})]}):null,s===`passed`?(0,$.jsx)(`p`,{children:h.current?n?a.passed:a.inputPassed:a.outputPassed}):null,s===`error`?(0,$.jsx)(`p`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:d}):null]})]})}function tn(e,t){return{...e,stt:{...e.stt,enabled:!0,provider:t},voice:{...e.voice,realtime:{...e.voice.realtime,enabled:!0,tts:e.voice.realtime.tts?.provider===t?e.voice.realtime.tts:{provider:t,...t===`alibaba`?{voice:`Cherry`}:{}},omni:e.voice.realtime.omni?.provider===t?e.voice.realtime.omni:t===`xopc-cloud`?void 0:{provider:t,model:`qwen3-omni-flash-realtime`,voice:e.voice.realtime.omni?.voice??`Cherry`,instructions:e.voice.realtime.omni?.instructions??`Keep replies conversational and concise.`}}}}}function nn(e){let t=(0,Ft.c)(117),{section:n,v:r,form:i,pending:a,apiKeyLabels:o,sttProviders:s,onChange:c}=e,u=r.setup,[p,m]=(0,Q.useState)(!1),h;t[0]===i?h=t[1]:(h=JSON.stringify(i),t[0]=i,t[1]=h);let g=h,_;t[2]===g?_=t[3]:(_={signature:g,input:!1,output:!1},t[2]=g,t[3]=_);let[v,y]=(0,Q.useState)(_);v.signature!==g&&y({signature:g,input:!1,output:!1});let b;t[4]!==a||t[5]!==g?(b=a?null:[`voice-realtime-status`,g],t[4]=a,t[5]=g,t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x={revalidateOnFocus:!0},t[7]=x):x=t[7];let{data:S,error:C,isLoading:w}=F(b,Tt,x),T;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(T=O(`/api/voice/catalog`),t[8]=T):T=t[8];let{data:E}=F(T,cn),D=i.voice.realtime,k=i.stt.provider,A=D.tts,j=A?.provider??S?.tts?.provider,M=S?.tts?.model,N;t[9]!==M||t[10]!==j?(N=j&&M?[`realtime-voices`,j,M]:null,t[9]=M,t[10]=j,t[11]=N):N=t[11];let ee;t[12]!==M||t[13]!==j?(ee=()=>xt(j,M,`realtime`),t[12]=M,t[13]=j,t[14]=ee):ee=t[14];let P;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(P={revalidateOnFocus:!1},t[15]=P):P=t[15];let{data:L}=F(N,ee,P),R;t[16]===L?R=t[17]:(R=L===void 0?[]:L,t[16]=L,t[17]=R);let z=R,V;t[18]!==j||t[19]!==z?(V=j===`alibaba`?z.filter(sn):z,t[18]=j,t[19]=z,t[20]=V):V=t[20];let H=V,U=typeof i.stt.providers?.alibaba?.apiKey==`string`?i.stt.providers.alibaba.apiKey:``,W;t[21]!==U||t[22]!==s?(W=!!U||s.some(on),t[21]=U,t[22]=s,t[23]=W):W=t[23];let G=W,K=D.defaultEngine===`omni`,q=K?D.omni?.voice??``:A?.voice??S?.tts?.voice??``,te;t[24]!==E?.models||t[25]!==K||t[26]!==D.omni?.model||t[27]!==D.omni?.provider||t[28]!==H?(te=K?D.omni?.provider===`xopc-cloud`?E?.models.find(e=>e.id===D.omni?.model)?.voice.voices??[]:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(an):H,t[24]=E?.models,t[25]=K,t[26]=D.omni?.model,t[27]=D.omni?.provider,t[28]=H,t[29]=te):te=t[29];let ne=te,re=!!(S?.enabled&&S.stt),J=!!(S?.enabled&&S.tts),Y;t[30]!==i||t[31]!==c||t[32]!==D?(Y=e=>c({...i,voice:{...i.voice,realtime:{...D,...e}}}),t[30]=i,t[31]=c,t[32]=D,t[33]=Y):Y=t[33];let X=Y,ie;t[34]!==i||t[35]!==c?(ie=e=>c(tn(i,e)),t[34]=i,t[35]=c,t[36]=ie):ie=t[36];let ae=ie,oe;t[37]!==a||t[38]!==D.enabled||t[39]!==u.disabled||t[40]!==u.needsSetup||t[41]!==u.pending||t[42]!==u.unverified||t[43]!==u.verified||t[44]!==g||t[45]!==v.signature?(oe=(e,t)=>D.enabled?a?u.pending:e?t&&v.signature===g?u.verified:u.unverified:u.needsSetup:u.disabled,t[37]=a,t[38]=D.enabled,t[39]=u.disabled,t[40]=u.needsSetup,t[41]=u.pending,t[42]=u.unverified,t[43]=u.verified,t[44]=g,t[45]=v.signature,t[46]=oe):oe=t[46];let se=oe,Z;t[47]!==o||t[48]!==ae||t[49]!==p||t[50]!==C||t[51]!==i||t[52]!==U||t[53]!==G||t[54]!==c||t[55]!==a||t[56]!==k||t[57]!==D.defaultEngine||t[58]!==D.enabled||t[59]!==u.changeKey||t[60]!==u.configureConversation||t[61]!==u.customProvider||t[62]!==u.edgeHint||t[63]!==u.enable||t[64]!==u.finishSetup||t[65]!==u.hosted||t[66]!==u.hostedAccountHint||t[67]!==u.hostedHint||t[68]!==u.keyConfigured||t[69]!==u.keyHint||t[70]!==u.manageAccount||t[71]!==u.outputHint||t[72]!==u.ownKey||t[73]!==u.ownKeyHint||t[74]!==u.service||t[75]!==u.statusError||t[76]!==n||t[77]!==A||t[78]!==S?.tts||t[79]!==X||t[80]!==r.experience||t[81]!==r.stt?(Z=n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-surface-base/45 p-3`,children:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":D.enabled,className:`size-4 accent-accent`,checked:D.enabled,onChange:e=>{e.target.checked?ae(k===`alibaba`?`alibaba`:`xopc-cloud`):X({enabled:!1})}}),u.enable]})}),C?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:u.statusError}):null,(0,$.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,$.jsx)(`legend`,{className:`text-sm font-medium text-fg`,children:u.service}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[`xopc-cloud`,`alibaba`].map(e=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg bg-surface-base/55 px-3 py-3 text-sm text-fg has-checked:bg-accent-soft`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`realtime-service`,value:e,checked:k===e,onChange:()=>ae(e),className:`mt-1 accent-accent`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:e===`xopc-cloud`?u.hosted:u.ownKey}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e===`xopc-cloud`?u.hostedHint:u.ownKeyHint})]})]},e))})]}),k!==`alibaba`&&k!==`xopc-cloud`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:u.customProvider.replace(`{provider}`,k)}):null,k===`alibaba`?(0,$.jsx)(`div`,{className:`space-y-2 text-xs`,children:G&&!p?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:u.keyConfigured}),(0,$.jsx)(I,{type:`button`,variant:`ghost`,onClick:()=>m(!0),children:u.changeKey})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{htmlFor:`realtime-api-key`,className:`font-medium text-fg`,children:r.stt.apiKey}),(0,$.jsx)(Et,{kind:`stt`,providerId:`alibaba`,fieldId:`realtime-api-key`,value:U,labels:{...o,maskedHelp:``},onChange:e=>c({...i,stt:{...i.stt,providers:{...i.stt.providers,alibaba:{...i.stt.providers?.alibaba,apiKey:e}}}})}),(0,$.jsx)(`p`,{className:`text-fg-muted`,children:u.keyHint})]})}):null,k===`xopc-cloud`?(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[u.hostedAccountHint,` `,(0,$.jsx)(l,{className:`text-accent hover:underline`,to:`/settings/capabilities/models`,children:u.manageAccount})]}):null,!A&&!a&&!S?.tts&&(k===`alibaba`||k===`xopc-cloud`)?(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3 text-xs`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:u.finishSetup}),(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:i.tts.provider===`edge`?u.edgeHint:u.outputHint}),(0,$.jsx)(I,{className:`mt-2`,type:`button`,variant:`secondary`,onClick:()=>ae(k),children:u.configureConversation})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(d,{value:D.defaultEngine,className:xe,onChange:e=>X({defaultEngine:e.target.value}),children:[(0,$.jsx)(f,{value:`agent`,children:r.experience.assistant}),(0,$.jsx)(f,{value:`omni`,children:r.experience.natural})]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[D.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]})]}):null,t[47]=o,t[48]=ae,t[49]=p,t[50]=C,t[51]=i,t[52]=U,t[53]=G,t[54]=c,t[55]=a,t[56]=k,t[57]=D.defaultEngine,t[58]=D.enabled,t[59]=u.changeKey,t[60]=u.configureConversation,t[61]=u.customProvider,t[62]=u.edgeHint,t[63]=u.enable,t[64]=u.finishSetup,t[65]=u.hosted,t[66]=u.hostedAccountHint,t[67]=u.hostedHint,t[68]=u.keyConfigured,t[69]=u.keyHint,t[70]=u.manageAccount,t[71]=u.outputHint,t[72]=u.ownKey,t[73]=u.ownKeyHint,t[74]=u.service,t[75]=u.statusError,t[76]=n,t[77]=A,t[78]=S?.tts,t[79]=X,t[80]=r.experience,t[81]=r.stt,t[82]=Z):Z=t[82];let ce;t[83]!==q||t[84]!==K||t[85]!==j||t[86]!==D.bargeIn||t[87]!==D.omni||t[88]!==D.tts||t[89]!==u.bargeIn||t[90]!==u.defaultVoice||t[91]!==u.voice||t[92]!==n||t[93]!==A||t[94]!==S?.tts||t[95]!==X||t[96]!==r.realtime||t[97]!==ne?(ce=n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`realtime-voice`,className:`text-sm font-medium text-fg`,children:u.voice}),(0,$.jsxs)(d,{id:`realtime-voice`,className:`${xe} w-full sm:w-56`,value:q,disabled:K?!D.omni:!A&&!S?.tts,onChange:e=>{if(K&&D.omni){X({omni:{...D.omni,voice:e.target.value}});return}(j===`alibaba`||j===`xopc-cloud`)&&X({tts:{...D.tts,provider:j,...e.target.value?{voice:e.target.value}:{}},...D.omni&&[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.target.value)?{omni:{...D.omni,voice:e.target.value}}:{}})},children:[K?null:(0,$.jsx)(f,{value:``,children:u.defaultVoice}),q&&!ne.some(e=>e.id===q)?(0,$.jsx)(f,{value:q,children:q}):null,ne.map(rn)]})]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,$.jsxs)(`span`,{children:[u.bargeIn,(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:r.realtime.bargeInDescription})]}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":D.bargeIn,checked:D.bargeIn,className:`size-4 accent-accent`,onChange:e=>X({bargeIn:e.target.checked})})]})]}):null,t[83]=q,t[84]=K,t[85]=j,t[86]=D.bargeIn,t[87]=D.omni,t[88]=D.tts,t[89]=u.bargeIn,t[90]=u.defaultVoice,t[91]=u.voice,t[92]=n,t[93]=A,t[94]=S?.tts,t[95]=X,t[96]=r.realtime,t[97]=ne,t[98]=ce):ce=t[98];let le;t[99]!==re||t[100]!==J||t[101]!==C||t[102]!==w||t[103]!==a||t[104]!==n||t[105]!==g||t[106]!==S||t[107]!==se||t[108]!==r||t[109]!==v.input||t[110]!==v.output?(le=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[w?(0,$.jsx)(B,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,se(re,v.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,se(re&&J,v.input&&v.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,se(!!(S?.enabled&&S.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(en,{v:r,canListen:re,canSpeak:J,disabled:a||w||!!C,onVerified:e=>y({signature:g,...e})},`${g}:${JSON.stringify(S)}`)]}):null,t[99]=re,t[100]=J,t[101]=C,t[102]=w,t[103]=a,t[104]=n,t[105]=g,t[106]=S,t[107]=se,t[108]=r,t[109]=v.input,t[110]=v.output,t[111]=le):le=t[111];let ue;return t[112]!==u.service||t[113]!==Z||t[114]!==ce||t[115]!==le?(ue=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":u.service,children:[Z,ce,le]}),t[112]=u.service,t[113]=Z,t[114]=ce,t[115]=le,t[116]=ue):ue=t[116],ue}function rn(e){return(0,$.jsx)(f,{value:e.id,children:e.name},e.id)}function an(e){return{id:e,name:e}}function on(e){return e.id===`alibaba`&&e.configured}function sn(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function cn(e){return Ve.parse((await w(e)).payload)}function ln(e){let t=(0,Ft.c)(22),{value:n,onChange:r}=e,i=D(dn)===`zh`,a;t[0]===i?a=t[1]:(a=(e,t)=>i?t:e,t[0]=i,t[1]=a);let o=a,s;t[2]!==r||t[3]!==n?(s=e=>{n&&r({...n,...e})},t[2]=r,t[3]=n,t[4]=s):s=t[4];let c=s,l;t[5]===o?l=t[6]:(l=o(`Natural conversation · advanced`,`自然对话 · 高级设置`),t[5]=o,t[6]=l);let u;t[7]===l?u=t[8]:(u=(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:l}),t[7]=l,t[8]=u);let p;t[9]===o?p=t[10]:(p=o(`Calls continue the same session using recent history. Service and credentials are shared with voice setup; override them here only when needed.`,`通话会接续同一会话的近期历史。默认共用语音服务与凭据,仅在需要独立配置时修改。`),t[9]=o,t[10]=p);let m;t[11]===p?m=t[12]:(m=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p}),t[11]=p,t[12]=m);let h;t[13]!==o||t[14]!==r||t[15]!==c||t[16]!==n?(h=n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Connection`,`连接方式`)}),(0,$.jsx)(d,{value:n.provider,onChange:e=>r({model:n.model,voice:n.voice,instructions:n.instructions,provider:e.target.value}),children:(0,$.jsxs)(f,{value:`alibaba`,children:[`DashScope · `,o(`Your API key`,`自有 API Key`)]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.provider===`xopc-cloud`?o(`Uses your XOPC sign-in and the platform’s published Omni route and credits.`,`使用 XOPC 登录授权、平台发布的 Omni 路由和额度。`):o(`Leave empty to use the shared voice service credential.`,`留空使用语音服务中已配置的凭据。`)}),(0,$.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.model}),n.provider===`alibaba`?(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:`API Key`}),(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,type:`password`,autoComplete:`new-password`,value:n.apiKey??``,onChange:e=>c({apiKey:e.target.value})})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Endpoint override (optional)`,`自定义服务地址(可选)`)}),(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:n.baseUrl??``,placeholder:n.provider===`alibaba`?`wss://dashscope.aliyuncs.com/api-ws/v1/realtime`:`https://router.xopc.ai/v1`,onChange:e=>c({baseUrl:e.target.value.trim()||void 0})})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Voice`,`音色`)}),(0,$.jsx)(d,{value:n.voice,onChange:e=>c({voice:e.target.value}),children:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(un)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Conversation instructions`,`聊天指令`)}),(0,$.jsx)(`textarea`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,rows:3,maxLength:8e3,value:n.instructions,onChange:e=>c({instructions:e.target.value})})]})]}):(0,$.jsx)(I,{variant:`secondary`,onClick:()=>r({provider:`alibaba`,model:`qwen3-omni-flash-realtime`,voice:`Cherry`,instructions:`You are a friendly voice companion. You cannot execute tools.`}),children:o(`Configure natural conversation`,`配置自然聊天`)}),t[13]=o,t[14]=r,t[15]=c,t[16]=n,t[17]=h):h=t[17];let g;return t[18]!==u||t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[u,m,h]}),t[18]=u,t[19]=m,t[20]=h,t[21]=g):g=t[21],g}function un(e){return(0,$.jsx)(f,{value:e,children:e},e)}function dn(e){return e.language}var fn=Le;function pn(){return C(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q,`dark:border-edge`)}function mn(){return C(xe,Le)}function hn(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function gn(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}function _n(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function vn(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`minimax`:return`MiniMax`;default:return e}}function yn(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function bn(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;default:return t.tts.providerHints.generic}}function xn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Sn(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function Cn(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function wn(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`saved`:{let n=structuredClone(t.value);return{form:e.form!==null&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function Tn(){let e=D(e=>e.language),t=S(e).voiceSettings,[n,r]=(0,Q.useState)(`listening`),i=ie(),a=He(e=>e.captions),o=He(e=>e.setCaptions),s=!!T(e=>e.conversationId);(0,Q.useEffect)(()=>{!i&&n===`diagnostics`&&r(`listening`)},[n,i]);let[c,l]=(0,Q.useReducer)(wn,{form:null,baseline:null}),u=c.form,p=c.baseline,[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(!1),_=(0,Q.useRef)(u);_.current=u;let v=(0,Q.useRef)({parsed:null,models:void 0}),{data:y,error:b,isLoading:x,mutate:C}=R(s),{data:w,error:E,isLoading:k,mutate:A}=F(s?O(`/api/voice/models`):null,Ct,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:N}=F(s?O(`/api/voice/providers`):null,yt,{revalidateOnFocus:!1}),{data:ee,error:P,isLoading:L}=F(s?O(`/api/voice/stt-providers`):null,St,{revalidateOnFocus:!1}),z=(0,Q.useMemo)(()=>j?.providers??[],[j]),B=(0,Q.useMemo)(()=>ee?.providers??[],[ee]),V=(0,Q.useMemo)(()=>y?.payload?.config===void 0?null:wt(y.payload.config),[y]),H=(0,Q.useMemo)(()=>!u||!p?!1:JSON.stringify(u)!==JSON.stringify(p),[u,p]);s?V!==null&&w!==void 0&&!g.current&&(v.current.parsed!==V||v.current.models!==w)&&(v.current={parsed:V,models:w},l({type:`sync`,value:V}),h(w)):(v.current.parsed!==null||v.current.models!==void 0)&&(v.current={parsed:null,models:void 0},l({type:`reset`}),h(null),g.current=!1);let U=!!(s&&(V===null||w===void 0||j===void 0||ee===void 0)&&(x||k||N||L)),W=b instanceof Error?b.message:b?String(b):E instanceof Error?E.message:E?String(E):M instanceof Error?M.message:M?String(M):P instanceof Error?P.message:P?String(P):null,G=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),K=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),q=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),te=(0,Q.useCallback)(t=>{g.current=!0,l({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),ne=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),re=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),J=gt({value:u,dirty:H,onSave:(0,Q.useCallback)(async e=>{try{await _t(e),l({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])}),Y=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:()=>e})},[]);if(!s)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(U)return(0,$.jsx)(mt,{rows:4});if(!u||m===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:W??t.loadError}),(0,$.jsx)(I,{type:`button`,variant:`secondary`,onClick:()=>{C(),A()},children:t.retry})]});let X=u.stt,ae=u.tts,oe=u.voice.input.refinement,se=xn(t);return(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,onBlurCapture:J.onBlurCapture,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,$.jsx)(ht,{status:J.status,error:J.error})}),J.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:J.error}):null,(0,$.jsx)(`nav`,{"aria-label":t.setup.advanced,className:`flex flex-wrap gap-2`,children:[`listening`,`input`,`devices`,`service`,...i?[`diagnostics`]:[]].map(e=>(0,$.jsx)(I,{variant:n===e?`secondary`:`ghost`,"aria-pressed":n===e,onClick:()=>r(e),children:t.experience[e]},e))}),n===`listening`||n===`service`||n===`diagnostics`?(0,$.jsx)(nn,{section:n,v:t,form:u,pending:H||J.status===`saving`||!!J.error,apiKeyLabels:se,sttProviders:B,onChange:Y}):null,n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(En,{v:t,voice:u.voice,updateLanguageMode:te}),(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.experience.pace}),(0,$.jsxs)(d,{className:mn(),value:String(u.voice.realtime.silenceDurationMs),onChange:e=>ne({silenceDurationMs:Number(e.target.value)}),children:[(0,$.jsx)(f,{value:`800`,children:t.experience.fast}),(0,$.jsx)(f,{value:`1200`,children:t.experience.standard}),(0,$.jsx)(f,{value:`2000`,children:t.experience.relaxed}),[800,1200,2e3].includes(u.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(f,{value:String(u.voice.realtime.silenceDurationMs),children:[u.voice.realtime.silenceDurationMs,` ms`]})]})]})})]}):null,n===`input`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[t.experience.captions,(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":a,className:`ui-checkbox`,checked:a,onChange:e=>o(e.target.checked)})]}),(0,$.jsxs)(`label`,{className:`space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:t.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.stt.refinementDesc}),(0,$.jsxs)(d,{className:mn(),value:oe.mode,onChange:e=>q({mode:e.target.value}),children:[(0,$.jsx)(f,{value:`off`,children:t.stt.refinementOff}),(0,$.jsx)(f,{value:`punctuation`,children:t.stt.refinementPunctuation}),(0,$.jsx)(f,{value:`light`,children:t.stt.refinementLight}),oe.mode===`custom`?(0,$.jsx)(f,{value:`custom`,children:t.setup.advanced}):null]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-base/55 px-4 py-3`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.setup.readout,` · `,ae.enabled?yn(ae.trigger,t):t.overview.off]}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.setup.readoutHint}),(0,$.jsx)(kn,{v:t,apiKeyLabels:se,tts:ae,models:m,ttsProviders:z,updateTts:re})]})]}):null,n===`devices`?(0,$.jsx)($t,{v:t}):null,n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Qt,{disabled:H||J.status===`saving`}),u.voice.realtime.enabled&&u.voice.realtime.omni?.provider===`alibaba`?(0,$.jsx)(ln,{value:u.voice.realtime.omni,onChange:e=>ne({omni:e})}):null,(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-base/55 px-4 py-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:t.experience.technical}),(0,$.jsx)(Dn,{v:t,apiKeyLabels:se,stt:X,models:m,sttProviders:B,updateStt:G,updateSttFallback:K}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.notes.envVars})]})]}):null]})}function En(e){let t=(0,Ft.c)(22),{v:n,voice:r,updateLanguageMode:i}=e,a;t[0]===n.language.title?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.language.title}),t[0]=n.language.title,t[1]=a);let o=r.languageMode===`auto`?n.language.autoDescription:n.language.manualDescription,s;t[2]===o?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=mn(),t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=e=>i(e.target.value),t[8]=i,t[9]=u);let p;t[10]===n.language.auto?p=t[11]:(p=(0,$.jsx)(f,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=p);let m;t[12]===n.language.manual?m=t[13]:(m=(0,$.jsx)(f,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=m);let h;t[14]!==u||t[15]!==p||t[16]!==m||t[17]!==r.languageMode?(h=(0,$.jsxs)(d,{className:l,value:r.languageMode,onChange:u,children:[p,m]}),t[14]=u,t[15]=p,t[16]=m,t[17]=r.languageMode,t[18]=h):h=t[18];let g;return t[19]!==c||t[20]!==h?(g=(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,h]})}),t[19]=c,t[20]=h,t[21]=g):g=t[21],g}function Dn(e){let t=(0,Ft.c)(58),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttFallback:c}=e,l;if(t[0]!==o){let e=new Set;l=[];for(let t of o)e.has(t.id)||(e.add(t.id),l.push(t));t[0]=o,t[1]=l}else l=t[1];let u=l,p,m,h,g;if(t[2]!==a||t[3]!==u||t[4]!==i.provider||t[5]!==i.providers){p=u.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],h=e,m=a?.stt?.[i.provider]?.length?a.stt[i.provider]:p?.models??[],g=p?.fields.find(On),t[2]=a,t[3]=u,t[4]=i.provider,t[5]=i.providers,t[6]=p,t[7]=m,t[8]=h,t[9]=g}else p=t[6],m=t[7],h=t[8],g=t[9];let _=g,v=typeof h.model==`string`?h.model:void 0,y=v??(typeof _?.defaultValue==`string`?_.defaultValue:m[0]?.id),b;t[13]!==i.provider||t[14]!==i.providers||t[15]!==s?(b=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[13]=i.provider,t[14]=i.providers,t[15]=s,t[16]=b):b=t[16];let x=b,S,w;t[17]!==v||t[18]!==y||t[19]!==_||t[20]!==x?(S=()=>{_&&y&&v!==y&&x({model:y})},w=[v,y,_,x],t[17]=v,t[18]=y,t[19]=_,t[20]=x,t[21]=S,t[22]=w):(S=t[21],w=t[22]),(0,Q.useEffect)(S,w);let T;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Qe,{className:`size-4 text-accent`,strokeWidth:1.75}),t[23]=T):T=t[23];let E;t[24]===n.stt.title?E=t[25]:(E=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[24]=n.stt.title,t[25]=E);let D;t[26]===n.stt.description?D=t[27]:(D=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[26]=n.stt.description,t[27]=D);let O;t[28]!==E||t[29]!==D?(O=(0,$.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[28]=E,t[29]=D,t[30]=O):O=t[30];let k;t[31]===s?k=t[32]:(k=e=>s({enabled:e}),t[31]=s,t[32]=k);let A;t[33]!==i.enabled||t[34]!==k||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(A=(0,$.jsx)(jn,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onChange:k}),t[33]=i.enabled,t[34]=k,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=A):A=t[37];let j;t[38]!==p?.fields||t[39]!==r||t[40]!==y||t[41]!==m||t[42]!==u||t[43]!==h||t[44]!==i.enabled||t[45]!==i.fallback?.enabled||t[46]!==i.provider||t[47]!==x||t[48]!==s||t[49]!==c||t[50]!==n?(j=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:C(`flex flex-col gap-1.5`,fn),children:[(0,$.jsx)(Pn,{children:n.stt.provider}),(0,$.jsx)(d,{className:mn(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:u.map(e=>(0,$.jsxs)(f,{value:e.id,children:[_n(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(An,{kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:y,apiKeyLabels:r,onPatch:x})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>c({enabled:e.target.checked})})]})]}):null,t[38]=p?.fields,t[39]=r,t[40]=y,t[41]=m,t[42]=u,t[43]=h,t[44]=i.enabled,t[45]=i.fallback?.enabled,t[46]=i.provider,t[47]=x,t[48]=s,t[49]=c,t[50]=n,t[51]=j):j=t[51];let M;t[52]!==A||t[53]!==j?(M=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[A,j]}),t[52]=A,t[53]=j,t[54]=M):M=t[54];let N;return t[55]!==M||t[56]!==O?(N=(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[O,M]}),t[55]=M,t[56]=O,t[57]=N):N=t[57],N}function On(e){return e.key===`model`}function kn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a}){let[o,s]=(0,Q.useState)(e.tts.test.sampleText),[c,l]=(0,Q.useState)({status:`idle`}),u=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(null),h=(0,Q.useCallback)(()=>{m.current?.abort(),m.current=null,u.current?.pause(),u.current=null,p.current&&=(URL.revokeObjectURL(p.current),null)},[]),g=(0,Q.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),_=g.find(e=>e.id===n.provider),y=n.providers?.[n.provider]??{},b=r?.tts?.[n.provider]?.length?r.tts[n.provider]:_?.models??[],x=_?.fields.find(e=>e.key===`model`),S=_?.fields.find(e=>e.key===`voice`),w=typeof y.model==`string`?y.model:void 0,T=w??(typeof x?.defaultValue==`string`?x.defaultValue:b[0]?.id),E=b.find(e=>e.id===T),D=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:_?.voices??[],{data:O=[]}=F(T?`voice:tts:${n.provider}:${T}`:null,()=>xt(n.provider,T??``),{revalidateOnFocus:!1}),k=O.length>0?O:D,A=typeof y.voice==`string`?y.voice:void 0,j=A??k.find(e=>e.id===E?.tts?.defaultVoice)?.id??(typeof S?.defaultValue==`string`?S.defaultValue:k[0]?.id),M=(_?.fields??[]).filter(e=>(e.key!==`speed`||E?.tts?.speed!==!1)&&(e.key!==`instructions`||E?.tts?.instructions!==!1)),N=!!_?.diagnostics.requiresApiKey,ee=!!_?.configured||!N,P=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Q.useEffect)(()=>{let e={};x&&T&&w!==T&&(e.model=T),S&&j&&A!==j&&(e.voice=j),Object.keys(e).length>0&&P(e)},[w,A,T,j,x,P,S]),(0,Q.useEffect)(()=>()=>h(),[h]);let L=(0,Q.useCallback)(e=>{a({provider:e}),l({status:`idle`})},[a]),R=(0,Q.useCallback)(async()=>{let t=o.trim();if(!t){l({status:`error`,message:e.tts.test.emptyText});return}h();let r=new AbortController;m.current=r,l({status:`loading`});try{let i=await vt({text:t,provider:n.provider,providerConfig:y,...T?{model:T}:{},...j?{voice:j}:{}},r.signal);if(r.signal.aborted)return;let a=gn(i.audio,i.mimeType);p.current=a;let o=new Audio(a);u.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,hn(i.audioSize)].filter(Boolean).join(` · `);o.addEventListener(`ended`,()=>l({status:`done`,summary:s}),{once:!0}),o.addEventListener(`error`,()=>l({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await o.play(),l({status:`playing`,summary:s})}catch(e){if(r.signal.aborted)return;h(),l({status:`error`,message:e instanceof Error?e.message:String(e)})}},[T,j,y,h,o,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]);return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Te,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(jn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onChange:e=>a({enabled:e})}),n.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:C(`flex flex-col gap-1.5`,fn),children:[(0,$.jsx)(Pn,{children:e.tts.trigger}),(0,$.jsxs)(d,{className:mn(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,$.jsx)(f,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(f,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(f,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(f,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:C(`flex flex-col gap-1.5`,fn),children:[(0,$.jsx)(Pn,{children:e.tts.provider}),(0,$.jsx)(d,{className:mn(),value:n.provider,onChange:e=>L(e.target.value),children:g.map(t=>(0,$.jsx)(f,{value:t.id,children:vn(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[_?.configured?e.tts.configured:_?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${_.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,_?.description??bn(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!ee,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,$.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(An,{kind:`tts`,providerId:n.provider,fields:M,providerSlice:y,models:b,voices:k,currentModel:T,currentVoice:j,apiKeyLabels:t,onPatch:P,resetVoiceOnModelChange:!0})})})]}),(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(I,{type:`button`,variant:`primary`,onClick:()=>void R(),disabled:c.status===`loading`,className:`h-9`,children:[c.status===`loading`?(0,$.jsx)(v,{className:`size-4 animate-spin`}):(0,$.jsx)(Me,{className:`size-4`}),c.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(I,{type:`button`,variant:`secondary`,onClick:()=>{h(),l(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:c.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(ve,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:e.setup.sampleText}),(0,$.jsx)(`textarea`,{className:C(pn(),`mt-3 min-h-20 resize-y`),value:o,onChange:e=>s(e.target.value),maxLength:1e3})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[o.length,`/1000`]}),c.status===`playing`||c.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[c.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,c.summary]}):null,c.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:c.message}):null]})]})]}):null]})]})}function An({kind:e,providerId:t,fields:n,providerSlice:r,models:i,voices:a=[],currentModel:o,currentVoice:s,apiKeyLabels:c,onPatch:l,resetVoiceOnModelChange:u=!1}){return n.map(n=>n.key===`apiKey`?(0,$.jsxs)(`div`,{className:C(`flex flex-col gap-1.5`,fn),children:[(0,$.jsx)(Pn,{children:n.label}),(0,$.jsx)(Et,{kind:e,providerId:t,fieldId:`voice-${e}-${t}-api-key`,value:typeof r.apiKey==`string`?r.apiKey:``,onChange:e=>l({apiKey:e}),labels:c,placeholder:n.placeholder}),n.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.description}):null]},n.key):n.key===`model`&&i.length>0?(0,$.jsxs)(`div`,{className:C(`flex flex-col gap-1.5`,fn),children:[(0,$.jsx)(Pn,{children:n.label}),(0,$.jsx)(d,{className:mn(),value:o??``,onChange:e=>l({model:e.target.value,...u?{voice:void 0}:{}}),children:i.map(e=>(0,$.jsx)(f,{value:e.id,children:e.name},e.id))})]},n.key):n.key===`voice`&&a.length>0?(0,$.jsxs)(`div`,{className:C(`flex flex-col gap-1.5`,fn),children:[(0,$.jsx)(Pn,{children:n.label}),(0,$.jsx)(d,{className:mn(),value:s??``,onChange:e=>l({voice:e.target.value}),children:a.map(e=>(0,$.jsx)(f,{value:e.id,children:e.name},e.id))})]},n.key):(0,$.jsx)(Mn,{field:n,value:Sn(r,n),onChange:e=>l({[n.key]:e}),className:n.type===`textarea`?`sm:col-span-2`:fn},n.key))}function jn(e){let t=(0,Ft.c)(27),{checked:n,title:r,description:i,onChange:a}=e,o;t[0]!==n||t[1]!==a?(o=()=>a(!n),t[0]=n,t[1]=a,t[2]=o):o=t[2];let s=n?`bg-surface-panel text-fg`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,c;t[3]===s?c=t[4]:(c=C(`group flex w-full items-center justify-between gap-4 rounded-lg bg-surface-base/55 px-3 py-3 text-left transition-colors`,q,s),t[3]=s,t[4]=c);let l;t[5]===r?l=t[6]:(l=(0,$.jsx)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:r}),t[5]=r,t[6]=l);let u;t[7]===i?u=t[8]:(u=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:i}),t[7]=i,t[8]=u);let d;t[9]!==l||t[10]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11];let f=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,p;t[12]===f?p=t[13]:(p=C(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,f),t[12]=f,t[13]=p);let m=n?`translate-x-5`:`translate-x-0.5`,h;t[14]===m?h=t[15]:(h=C(`size-5 rounded-full bg-white shadow-surface transition-transform`,m),t[14]=m,t[15]=h);let g;t[16]===h?g=t[17]:(g=(0,$.jsx)(`span`,{className:h}),t[16]=h,t[17]=g);let _;t[18]!==g||t[19]!==p?(_=(0,$.jsx)(`span`,{className:p,"aria-hidden":!0,children:g}),t[18]=g,t[19]=p,t[20]=_):_=t[20];let v;return t[21]!==n||t[22]!==o||t[23]!==_||t[24]!==c||t[25]!==d?(v=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:o,className:c,children:[d,_]}),t[21]=n,t[22]=o,t[23]=_,t[24]=c,t[25]=d,t[26]=v):v=t[26],v}function Mn(e){let t=(0,Ft.c)(36),{field:n,value:r,onChange:i,className:a}=e,o=`voice-schema-field-${n.key}`,s=n.description;if(n.type===`boolean`){let e;t[0]===a?e=t[1]:(e=C(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,a),t[0]=a,t[1]=e);let o;t[2]===n.label?o=t[3]:(o=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=o);let c;t[4]===s?c=t[5]:(c=s?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:s}):null,t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,$.jsxs)(`span`,{children:[o,c]}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u=!!r,d;t[9]!==n||t[10]!==i?(d=e=>i(Cn(n,e.target.checked)),t[9]=n,t[10]=i,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==e||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`label`,{className:e,children:[l,f]}),t[15]=e,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}let c=typeof r==`boolean`?``:String(r),l;t[19]===a?l=t[20]:(l=C(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=l);let u;t[21]===n.label?u=t[22]:(u=(0,$.jsx)(Pn,{children:n.label}),t[21]=n.label,t[22]=u);let f;t[23]!==a||t[24]!==n||t[25]!==c||t[26]!==o||t[27]!==i?(f=n.type===`select`?(0,$.jsx)(d,{id:o,className:mn(),value:c,required:n.required,onChange:e=>i(Cn(n,e.target.value)),children:(n.options??[]).map(Nn)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:C(pn(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(Cn(n,e.target.value))}):n.type===`password`?(0,$.jsx)(Pe,{id:o,className:a,value:c,onChange:e=>i(Cn(n,e)),placeholder:n.placeholder,labels:de}):(0,$.jsx)(`input`,{id:o,className:pn(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,placeholder:n.placeholder,min:n.min,max:n.max,step:n.step,onChange:e=>i(Cn(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=c,t[26]=o,t[27]=i,t[28]=f):f=t[28];let p;t[29]===s?p=t[30]:(p=s?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:s}):null,t[29]=s,t[30]=p);let m;return t[31]!==l||t[32]!==u||t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(`div`,{className:l,children:[u,f,p]}),t[31]=l,t[32]=u,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function Nn(e){return(0,$.jsx)(f,{value:e.id,children:e.name},e.id)}function Pn(e){let t=(0,Ft.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function Fn(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function In(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function Ln(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await w(O(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),L()}async function Rn(e){let t=await w(O(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function zn(e){let t=(0,Ft.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Bn(){return C(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q,`dark:border-edge`)}function Vn(){return C(xe,Le)}var Hn=[`brave`,`tavily`,`bing`,`searxng`];function Un(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var Wn=qe();function Gn(){let e=S(D(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!T(e=>e.conversationId),[i,a]=(0,Q.useReducer)(Wn,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),l=(0,Q.useRef)(o);l.current=o;let u=(0,Q.useRef)(null),{data:p,error:m,isLoading:h,mutate:g}=R(r);me({enabled:r,parsed:(0,Q.useMemo)(()=>p?.payload?.config===void 0?null:In(p.payload.config),[p]),dirty:c.current,trackedParsedRef:u,dispatch:a,onResetDirty:()=>{c.current=!1}});let _=!!(r&&h&&p===void 0&&!m),v=m instanceof Error?m.message:m?String(m):null,y=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),x=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),w=gt({value:o,dirty:y,onSave:(0,Q.useCallback)(async e=>{try{await Ln(e),a({type:`saved`,value:e}),c.current=!!(l.current&&JSON.stringify(l.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});if(!r)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(_)return(0,$.jsx)(mt,{rows:3});if(!o)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:v??t.loadError}),(0,$.jsx)(I,{type:`button`,variant:`secondary`,onClick:()=>void g(),children:n.refresh})]});let E=Fn(o.providers);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,onBlurCapture:w.onBlurCapture,children:[w.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w.error}):null,(0,$.jsxs)(pt,{children:[(0,$.jsx)(ft,{icon:Ne,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(ht,{status:w.status,error:w.error})}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-base/55 px-4 py-3`,children:[(0,$.jsx)(Je,{className:`mt-0.5 size-5 shrink-0 text-accent`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.cloudProvider}),(0,$.jsx)(`span`,{className:C(`rounded-full px-2 py-0.5 text-[11px] font-medium`,E?`bg-surface-panel text-fg-muted`:`bg-accent-soft text-accent`),children:E?t.cloudOverridden:t.cloudAutomatic})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-subtle`,children:E?t.cloudOverriddenHint:t.cloudAutomaticHint})]})]}),(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(Kn,{row:n,providerIndex:r,labels:t,secretLabels:nt(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,x({providers:t})},onRemove:()=>{x({providers:o.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,$.jsxs)(I,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>x({providers:[...o.providers,Un()]}),children:[(0,$.jsx)(b,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(pt,{children:[(0,$.jsx)(ft,{icon:Se,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(zn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(d,{className:Vn(),value:o.regionMode,onChange:e=>x({regionMode:e.target.value}),children:[(0,$.jsx)(f,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(f,{value:`cn`,children:t.regionCn}),(0,$.jsx)(f,{value:`global`,children:t.regionGlobal})]})}),(0,$.jsx)(zn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:Bn(),value:o.maxResults,onChange:e=>x({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})})]})]}),(0,$.jsx)(Dt,{children:(0,$.jsxs)(pt,{children:[(0,$.jsx)(ft,{icon:ne,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:o.blocklistEnabled,onChange:e=>x({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),o.blocklistEnabled?(0,$.jsx)(zn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:C(Bn(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
|
|
8
|
-
`),placeholder:t.blocklistDomainsPlaceholder,onChange:e=>{x({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})}):null]})]})})]})}function Kn(e){let t=(0,Ft.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>Rn(r).then(qn),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=C(Vn(),`min-w-[8rem]`),t[2]=u):u=t[2];let p=n.type,m;t[3]!==o||t[4]!==n?(m=e=>o({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=o,t[4]=n,t[5]=m):m=t[5];let h;t[6]===i.providerTypes?h=t[7]:(h=Hn.map(e=>(0,$.jsx)(f,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=h);let g;t[8]!==n.type||t[9]!==m||t[10]!==h?(g=(0,$.jsx)(d,{className:u,value:p,onChange:m,children:h}),t[8]=n.type,t[9]=m,t[10]=h,t[11]=g):g=t[11];let _;t[12]!==o||t[13]!==n?(_=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=_):_=t[14];let v;t[15]!==n.disabled||t[16]!==_?(v=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.disabled,onChange:_}),t[15]=n.disabled,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==i.disabled||t[19]!==v?(y=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[v,i.disabled]}),t[18]=i.disabled,t[19]=v,t[20]=y):y=t[20];let b;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(ge,{className:`size-4`}),t[21]=b):b=t[21];let x;t[22]===s?x=t[23]:(x=(0,$.jsx)(I,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:b}),t[22]=s,t[23]=x);let S;t[24]!==x||t[25]!==y?(S=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y,x]}),t[24]=x,t[25]=y,t[26]=S):S=t[26];let w;t[27]!==S||t[28]!==g?(w=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[g,S]}),t[27]=S,t[28]=g,t[29]=w):w=t[29];let T;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==o||t[33]!==n?(T=n.type===`searxng`?(0,$.jsx)(zn,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Bn(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.urlDesc,t[31]=i.urlLabel,t[32]=o,t[33]=n,t[34]=T):T=t[34];let E;t[35]!==o||t[36]!==n?(E=e=>o({...n,apiKey:e}),t[35]=o,t[36]=n,t[37]=E):E=t[37];let D;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==l||t[42]!==n.apiKey||t[43]!==a||t[44]!==E?(D=(0,$.jsx)(Pe,{value:n.apiKey,onChange:E,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[38]=i.keyPlaceholder,t[39]=i.keyPlaceholderMasked,t[40]=i.saveError,t[41]=l,t[42]=n.apiKey,t[43]=a,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==D?(O=(0,$.jsx)(zn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:D}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=D,t[49]=O):O=t[49];let k;return t[50]!==w||t[51]!==T||t[52]!==O?(k=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/60 p-4`,children:[w,T,O]}),t[50]=w,t[51]=T,t[52]=O,t[53]=k):k=t[53],k}function qn(e){return e.apiKey??null}function Jn(e){let t=(0,Ft.c)(185),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=D(Xn)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:at(``),t[0]=n,t[1]=l);let[u,p]=(0,Q.useState)(l),[m,h]=(0,Q.useState)(Yn),g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(e,t)=>{p(n=>({...n,[e]:t})),h(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=g):g=t[2];let _=g,v;t[3]!==u.computerUse||t[4]!==u.contextWindow||t[5]!==u.id||t[6]!==u.input||t[7]!==u.maxTokens||t[8]!==s.modelIdRequired||t[9]!==s.mustBePositive||t[10]!==c?(v=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,s.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),u.computerUse&&!u.input?.includes(`image`)&&e.set(`computerUse`,c?`电脑控制模型必须支持图片输入`:`Computer Use requires image input`),h(e),e.size===0},t[3]=u.computerUse,t[4]=u.contextWindow,t[5]=u.id,t[6]=u.input,t[7]=u.maxTokens,t[8]=s.modelIdRequired,t[9]=s.mustBePositive,t[10]=c,t[11]=v):v=t[11];let y=v,b;t[12]!==u||t[13]!==o||t[14]!==a||t[15]!==y?(b=()=>{if(!y())return;let e=(u.id||``).trim();a({...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}}),o()},t[12]=u,t[13]=o,t[14]=a,t[15]=y,t[16]=b):b=t[16];let S=b,w=u,T;t[17]===w?T=t[18]:(T=we(w),t[17]=w,t[18]=T);let E=T,O=r?s.addModelTitle:s.editModelTitle,k;t[19]===O?k=t[20]:(k=(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:O}),t[19]=O,t[20]=k);let A;t[21]!==s.modelProviderLabel||t[22]!==i?(A=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[21]=s.modelProviderLabel,t[22]=i,t[23]=A):A=t[23];let M;t[24]!==k||t[25]!==A?(M=(0,$.jsxs)(`div`,{children:[k,A]}),t[24]=k,t[25]=A,t[26]=M):M=t[26];let N;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(N=C(ue,`p-1.5 hover:bg-surface-base`),t[27]=N):N=t[27];let P;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(x,{className:`size-4`}),t[28]=P):P=t[28];let F;t[29]===s.close?F=t[30]:(F=(0,$.jsx)(j,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:N,"aria-label":s.close,children:P})}),t[29]=s.close,t[30]=F);let L;t[31]!==M||t[32]!==F?(L=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[M,F]}),t[31]=M,t[32]=F,t[33]=L):L=t[33];let R;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=R):R=t[34];let z;t[35]===s.modelId?z=t[36]:(z=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,R]}),t[35]=s.modelId,t[36]=z);let B;t[37]===m?B=t[38]:(B=C(Be(),m.has(`id`)&&`border-red-500`),t[37]=m,t[38]=B);let V=u.id||``,H;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>_(`id`,e.target.value),t[39]=H):H=t[39];let U=!r,W;t[40]!==B||t[41]!==V||t[42]!==U?(W=(0,$.jsx)(`input`,{className:B,value:V,onChange:H,placeholder:`e.g. llama3.1:8b`,disabled:U}),t[40]=B,t[41]=V,t[42]=U,t[43]=W):W=t[43];let G;t[44]===m?G=t[45]:(G=m.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`id`)}):null,t[44]=m,t[45]=G);let K;t[46]!==z||t[47]!==W||t[48]!==G?(K=(0,$.jsxs)(`div`,{children:[z,W,G]}),t[46]=z,t[47]=W,t[48]=G,t[49]=K):K=t[49];let q;t[50]===s.displayName?q=t[51]:(q=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=q);let te;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(te=Be(),t[52]=te):te=t[52];let ne=u.name||``,re;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>_(`name`,e.target.value),t[53]=re):re=t[53];let J;t[54]===ne?J=t[55]:(J=(0,$.jsx)(`input`,{className:te,value:ne,onChange:re}),t[54]=ne,t[55]=J);let X;t[56]!==q||t[57]!==J?(X=(0,$.jsxs)(`div`,{children:[q,J]}),t[56]=q,t[57]=J,t[58]=X):X=t[58];let ie;t[59]===s.inputTypes?ie=t[60]:(ie=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=ie);let ae;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(ae=Y(),t[61]=ae):ae=t[61];let oe;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>_(`input`,ot(e.target.value)),t[62]=oe):oe=t[62];let se;t[63]===s?se=t[64]:(se=st.map(e=>(0,$.jsx)(f,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=se);let Z;t[65]!==E||t[66]!==se?(Z=(0,$.jsx)(d,{className:ae,value:E,onChange:oe,children:se}),t[65]=E,t[66]=se,t[67]=Z):Z=t[67];let ce;t[68]!==ie||t[69]!==Z?(ce=(0,$.jsxs)(`div`,{children:[ie,Z]}),t[68]=ie,t[69]=Z,t[70]=ce):ce=t[70];let le=u.reasoning||!1,de;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>_(`reasoning`,e.target.checked),t[71]=de):de=t[71];let fe;t[72]===le?fe=t[73]:(fe=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:le,onChange:de}),t[72]=le,t[73]=fe);let pe;t[74]!==s.reasoning||t[75]!==fe?(pe=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[fe,s.reasoning]}),t[74]=s.reasoning,t[75]=fe,t[76]=pe):pe=t[76];let me;t[77]!==ce||t[78]!==pe?(me=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ce,pe]}),t[77]=ce,t[78]=pe,t[79]=me):me=t[79];let he;t[80]===s.contextWindow?he=t[81]:(he=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=he);let ge;t[82]===m?ge=t[83]:(ge=C(Be(),m.has(`contextWindow`)&&`border-red-500`),t[82]=m,t[83]=ge);let _e=u.contextWindow??128e3,ve;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>_(`contextWindow`,parseInt(e.target.value,10)||0),t[84]=ve):ve=t[84];let ye;t[85]!==ge||t[86]!==_e?(ye=(0,$.jsx)(`input`,{type:`number`,min:1,className:ge,value:_e,onChange:ve}),t[85]=ge,t[86]=_e,t[87]=ye):ye=t[87];let be;t[88]===m?be=t[89]:(be=m.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`contextWindow`)}):null,t[88]=m,t[89]=be);let xe;t[90]!==he||t[91]!==ye||t[92]!==be?(xe=(0,$.jsxs)(`div`,{children:[he,ye,be]}),t[90]=he,t[91]=ye,t[92]=be,t[93]=xe):xe=t[93];let Se;t[94]===s.maxOutputTokens?Se=t[95]:(Se=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[94]=s.maxOutputTokens,t[95]=Se);let Ce;t[96]===m?Ce=t[97]:(Ce=C(Be(),m.has(`maxTokens`)&&`border-red-500`),t[96]=m,t[97]=Ce);let Te=u.maxTokens??16384,Ee;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>_(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=Ee):Ee=t[98];let De;t[99]!==Ce||t[100]!==Te?(De=(0,$.jsx)(`input`,{type:`number`,min:1,className:Ce,value:Te,onChange:Ee}),t[99]=Ce,t[100]=Te,t[101]=De):De=t[101];let Oe;t[102]===m?Oe=t[103]:(Oe=m.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`maxTokens`)}):null,t[102]=m,t[103]=Oe);let ke;t[104]!==Se||t[105]!==De||t[106]!==Oe?(ke=(0,$.jsxs)(`div`,{children:[Se,De,Oe]}),t[104]=Se,t[105]=De,t[106]=Oe,t[107]=ke):ke=t[107];let Ae;t[108]!==xe||t[109]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[xe,ke]}),t[108]=xe,t[109]=ke,t[110]=Ae):Ae=t[110];let je;t[111]===s.costSection?je=t[112]:(je=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=je);let Me;t[113]===s.costInput?Me=t[114]:(Me=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Me);let Ne;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=Be(),t[115]=Ne):Ne=t[115];let Pe=u.cost?.input??0,Fe;t[116]===u.cost?Fe=t[117]:(Fe=e=>_(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[116]=u.cost,t[117]=Fe);let Ie;t[118]!==Pe||t[119]!==Fe?(Ie=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ne,value:Pe,onChange:Fe}),t[118]=Pe,t[119]=Fe,t[120]=Ie):Ie=t[120];let Le;t[121]!==Me||t[122]!==Ie?(Le=(0,$.jsxs)(`div`,{children:[Me,Ie]}),t[121]=Me,t[122]=Ie,t[123]=Le):Le=t[123];let Re;t[124]===s.costOutput?Re=t[125]:(Re=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=Re);let ze;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(ze=Be(),t[126]=ze):ze=t[126];let Ve=u.cost?.output??0,He;t[127]===u.cost?He=t[128]:(He=e=>_(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[127]=u.cost,t[128]=He);let Ue;t[129]!==Ve||t[130]!==He?(Ue=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:ze,value:Ve,onChange:He}),t[129]=Ve,t[130]=He,t[131]=Ue):Ue=t[131];let We;t[132]!==Re||t[133]!==Ue?(We=(0,$.jsxs)(`div`,{children:[Re,Ue]}),t[132]=Re,t[133]=Ue,t[134]=We):We=t[134];let Ge;t[135]!==Le||t[136]!==We?(Ge=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Le,We]}),t[135]=Le,t[136]=We,t[137]=Ge):Ge=t[137];let Ke;t[138]!==je||t[139]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[je,Ge]}),t[138]=je,t[139]=Ge,t[140]=Ke):Ke=t[140];let qe;t[141]!==K||t[142]!==X||t[143]!==me||t[144]!==Ae||t[145]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[K,X,me,Ae,Ke]}),t[141]=K,t[142]=X,t[143]=me,t[144]=Ae,t[145]=Ke,t[146]=qe):qe=t[146];let Je=c?`高级:电脑控制协议`:`Advanced: Computer Use protocol`,Ye;t[147]===Je?Ye=t[148]:(Ye=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Je}),t[147]=Je,t[148]=Ye);let Xe=c?`电脑控制协议`:`Computer Use protocol`,Ze=u.computerUse?.profile??``,Qe;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=e=>_(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=Qe):Qe=t[149];let $e=c?`未声明`:`Not declared`,et;t[150]===$e?et=t[151]:(et=(0,$.jsx)(f,{value:``,children:$e}),t[150]=$e,t[151]=et);let tt,nt,rt;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(tt=(0,$.jsx)(f,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),nt=(0,$.jsx)(f,{value:`structured-tools-v1`,children:`structured-tools-v1`}),rt=(0,$.jsx)(f,{value:`openai-responses-computer-v1`,children:`OpenAI Responses Computer`}),t[152]=tt,t[153]=nt,t[154]=rt):(tt=t[152],nt=t[153],rt=t[154]);let it;t[155]!==Xe||t[156]!==Ze||t[157]!==et?(it=(0,$.jsxs)(d,{"aria-label":Xe,value:Ze,onChange:Qe,children:[et,tt,nt,rt]}),t[155]=Xe,t[156]=Ze,t[157]=et,t[158]=it):it=t[158];let ct=c?`协议必须与模型 API 匹配。声明协议不代表模型已通过效果验证。`:`The protocol must match the model API. Declaring a protocol does not certify model quality.`,lt;t[159]===ct?lt=t[160]:(lt=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:ct}),t[159]=ct,t[160]=lt);let ut;t[161]===m?ut=t[162]:(ut=m.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:m.get(`computerUse`)}),t[161]=m,t[162]=ut);let dt;t[163]!==it||t[164]!==lt||t[165]!==ut?(dt=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[it,lt,ut]}),t[163]=it,t[164]=lt,t[165]=ut,t[166]=dt):dt=t[166];let ft;t[167]!==Ye||t[168]!==dt?(ft=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Ye,dt]}),t[167]=Ye,t[168]=dt,t[169]=ft):ft=t[169];let pt;t[170]!==qe||t[171]!==ft?(pt=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[qe,ft]}),t[170]=qe,t[171]=ft,t[172]=pt):pt=t[172];let mt;t[173]===s.cancel?mt=t[174]:(mt=(0,$.jsx)(j,{asChild:!0,children:(0,$.jsx)(I,{type:`button`,variant:`secondary`,children:s.cancel})}),t[173]=s.cancel,t[174]=mt);let ht=r?s.addModelConfirm:s.saveModelConfirm,gt;t[175]!==S||t[176]!==ht?(gt=(0,$.jsx)(I,{type:`button`,variant:`primary`,className:`hover:bg-accent/90`,onClick:S,children:ht}),t[175]=S,t[176]=ht,t[177]=gt):gt=t[177];let _t;t[178]!==mt||t[179]!==gt?(_t=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[mt,gt]}),t[178]=mt,t[179]=gt,t[180]=_t):_t=t[180];let vt;return t[181]!==L||t[182]!==pt||t[183]!==_t?(vt=(0,$.jsxs)($.Fragment,{children:[L,pt,_t]}),t[181]=L,t[182]=pt,t[183]=_t,t[184]=vt):vt=t[184],vt}function Yn(){return new Map}function Xn(e){return e.language}function Zn(e){let t=(0,Ft.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(k,{className:C(`xopc-dialog-overlay fixed inset-0 bg-scrim`,H)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=C(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col`,V,`overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`),t[1]=u):u=t[1];let d;t[2]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(d=n?(0,$.jsx)(Jn,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=d):d=t[9];let f;t[10]===d?f=t[11]:(f=(0,$.jsxs)(M,{children:[l,(0,$.jsx)(N,{className:u,onOpenAutoFocus:Qn,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(P,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function Qn(e){return e.preventDefault()}function $n(e){let t=(0,Ft.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>ke(n).then(er),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,$.jsx)(Pe,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function er(e){return e.apiKey??null}function tr(e){let t=(0,Ft.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(k,{className:C(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,H)}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=C(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(85vh,720px)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,V),t[1]=p):p=t[1];let m;t[2]!==c||t[3]!==o||t[4]!==s||t[5]!==a||t[6]!==l||t[7]!==u||t[8]!==r||t[9]!==d||t[10]!==i?(m=(0,$.jsxs)(M,{children:[f,(0,$.jsx)(N,{className:p,children:a?(0,$.jsx)(rr,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d}):(0,$.jsx)(nr,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d})})]}),t[2]=c,t[3]=o,t[4]=s,t[5]=a,t[6]=l,t[7]=u,t[8]=r,t[9]=d,t[10]=i,t[11]=m):m=t[11];let h;return t[12]!==r||t[13]!==n||t[14]!==m?(h=(0,$.jsx)(P,{open:n,onOpenChange:r,children:m}),t[12]=r,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function nr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let s=t.find(t=>t.id===e),c=oe[e],u=n.filter(t=>t.provider===e),[d,f]=(0,Q.useState)(!1),[p,g]=(0,Q.useState)(s?.apiKey??``),[_,y]=(0,Q.useState)(!1),[b,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(!1),k=S(i).providersSettings,A=s?.supportsApiKey!==!1,M=s?.supportsOAuth===!0,N=s?.authMode===`oauth`&&s.authStatus===`connected`,P=s?.configured===!0&&s.activeKeySource!==`env`&&s.activeKeySource!==`extension`&&s.activeKeySource!==`models_json`,[F,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(`idle`),[H,U]=(0,Q.useState)(null),[W,G]=(0,Q.useState)(null),[K,ne]=(0,Q.useState)(null),[re,J]=(0,Q.useState)(``),Y=(0,Q.useRef)(null),X=(0,Q.useRef)(null),ie=B===`waiting`||B===`waiting_code`,Z=(0,Q.useMemo)(()=>ae(e,i),[e,i]),ue=p!==(s?.apiKey??``),de=async()=>{let t=p.trim();if(!(!t||!A||je(t))){y(!0),E(null);try{await ce({[e]:t}),w(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){E(e instanceof Error?e.message:r.saveError)}finally{y(!1)}}};(0,Q.useEffect)(()=>{if(!F||!ie)return;let e=window.setInterval(()=>{(async()=>{try{let t=await se(F);t.status===`waiting_auth`||t.status===`waiting_code`?(V(t.status===`waiting_code`?`waiting_code`:`waiting`),z(t.message??null),U(t.authUrl??null),G(t.instructions??null),ne(t.deviceCode??null),t.authUrl&&t.authUrl!==X.current&&(X.current=t.authUrl,te(t.authUrl,Y.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),Ze(Y.current),Y.current=null,V(`success`),z(t.message??k.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),Ze(Y.current),Y.current=null,V(`error`),z(t.error??t.message??k.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[F,ie,a,o,k.revokeFailed,k.saved]),(0,Q.useEffect)(()=>()=>{F&&ye(F).catch(()=>{})},[F]),(0,Q.useEffect)(()=>()=>{Ze(Y.current),Y.current=null},[]);let me=async()=>{try{await lt(e),o(),a()}catch{}},ve=async()=>{Ze(Y.current),Y.current=Ye(),X.current=null,V(`waiting`),z(k.oauthStarting),U(null),G(null),ne(null),E(null);try{L((await pe(e)).sessionId)}catch(e){Ze(Y.current),Y.current=null,V(`error`),z(e instanceof Error?e.message:k.revokeFailed)}},be=async()=>{if(F){try{await he(F)}catch{}Ze(Y.current),Y.current=null,X.current=null,V(`idle`),z(null),L(null),U(null),G(null),ne(null)}},xe=async()=>{if(!(!F||!re.trim()))try{await Ce(F,re.trim()),J(``),z(k.oauthProcessingCode)}catch(e){V(`error`),z(e instanceof Error?e.message:k.revokeFailed)}},Se=async()=>{try{await le(e),o(),a()}catch(e){E(e instanceof Error?e.message:k.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:s?.name??e}),(0,$.jsx)(j,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:C(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Fe.press),children:(0,$.jsx)(x,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[c?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.description}):null,s?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:s.baseUrl})]}):s?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,A?(0,$.jsx)($n,{providerId:e,inputId:`manage-api-key`,value:p,onChange:e=>{g(e),w(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):s?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),s?.extensionId?(0,$.jsxs)(l,{to:`/settings/ext/${encodeURIComponent(s.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(h,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,M?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:k.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:N?k.sourceOauth:k.oauthHint})]}),N?(0,$.jsx)(I,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void Se(),children:k.revoke}):(0,$.jsxs)(I,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ie,onClick:()=>void ve(),children:[ie?(0,$.jsx)(v,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Pt,{className:`size-3.5`,"aria-hidden":!0}),k.oauth]})]}),R?(0,$.jsx)(`p`,{className:C(`text-xs`,B===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:R}):null,B===`waiting`||B===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[H?(0,$.jsxs)(`a`,{href:H,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover`,children:[(0,$.jsx)(h,{className:`size-4`,"aria-hidden":!0}),k.openAuthPage]}):null,(0,$.jsx)(I,{type:`button`,variant:`secondary`,onClick:()=>void be(),children:k.cancelOAuth})]}):null,W?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:W}):null,K?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:k.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:K}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:k.deviceCodeHint})]}):null,B===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:re,onChange:e=>J(e.target.value),onKeyDown:e=>e.key===`Enter`&&void xe(),placeholder:k.pasteRedirectUrl,className:C(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,q)}),(0,$.jsx)(I,{type:`button`,variant:`primary`,onClick:()=>void xe(),children:k.submitCode})]}):null]}):null,Z.length>0&&A?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Z.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[_e(e,r),(0,$.jsx)(h,{className:`size-3`,"aria-hidden":!0})]},e))}):null,u.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,u.length,`)`]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:e=>f(e.target.checked)}),i===`zh`?`仅电脑控制模型`:`Computer Use only`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.filter(e=>!d||e.computerUse).map(e=>(0,$.jsxs)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:[fe(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),T?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:T}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[P?(0,$.jsxs)(I,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>O(!0),children:[(0,$.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:A&&ue&&!je(p.trim())?(0,$.jsx)(I,{type:`button`,variant:`primary`,disabled:!p.trim()||_||b,onClick:()=>void de(),children:b?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):_?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(v,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(Xe,{open:D,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,s?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void me(),onCancel:()=>O(!1)})]})}function rr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let o=S(r).modelsSettings,s=t?.providers[e],[c,l]=(0,Q.useState)(s?.baseUrl??``),[u,d]=(0,Q.useState)(s?.apiKey??``),[f,p]=(0,Q.useState)(s?.models??[]),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(s?.modelDiscovery?.enabled===!0),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),[A,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(!1),[F,L]=(0,Q.useState)(null),R=n=>{if(!t)return null;let r=u.trim(),i={...s,baseUrl:c.trim()||void 0,apiKey:je(r)?s?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},z=async()=>{let e=R({models:f,modelDiscovery:{enabled:g}});if(e){T(!0),D(null);try{await Ee(e),a(),i()}catch(e){D(e instanceof Error?e.message:n.saveError)}finally{T(!1)}}},B=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await Ee({providers:r}),a(),i()}catch{}},V=(e,t)=>{L({model:e,isNew:t}),P(!0)},H=async e=>{if(!F)return;let t=F.isNew?[...f,e]:f.map(t=>t.id===e.id?e:t);p(t);let r=R({models:t});if(r)try{await Ee(r),a()}catch(e){D(e instanceof Error?e.message:n.saveError)}},U=async e=>{let t=f.filter(t=>t.id!==e);p(t),M(null);let r=R({models:t});if(r)try{await Ee(r),a()}catch(e){D(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(j,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:C(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Fe.press),children:(0,$.jsx)(x,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:c,onChange:e=>l(e.target.value),className:C(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,q)})]}),(0,$.jsx)($n,{providerId:e,inputId:`manage-custom-api-key`,value:u,onChange:d,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r===`zh`?`自动同步模型目录`:`Automatically sync model catalog`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:r===`zh`?`启动时及定时从此服务的 /models 接口更新模型。`:`Update models from this service’s /models endpoint at startup and on schedule.`})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[o.modelsSection,f.length>0?` (${f.length})`:``]}),(0,$.jsxs)(I,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>V(null,!0),children:[(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:m,onChange:e=>h(e.target.checked)}),r===`zh`?`仅电脑控制模型`:`Computer Use only`]}),f.filter(e=>!m||e.computerUse).length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:f.filter(e=>!m||e.computerUse).map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.computerUse&&(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Computer Use`}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:C(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Fe.press),onClick:()=>V(e,!1),"aria-label":o.editModel,children:(0,$.jsx)(y,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:C(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,Fe.press),onClick:()=>M(e.id),"aria-label":o.removeModel,children:(0,$.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),E?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:E}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(I,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>k(!0),children:[(0,$.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(I,{type:`button`,variant:`primary`,disabled:w,onClick:()=>void z(),children:w?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(v,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(Xe,{open:O,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void B(),onCancel:()=>k(!1)}),(0,$.jsx)(Xe,{open:A!==null,title:o.removeModel,description:o.removeModelConfirm.replace(`{{id}}`,A??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{A&&U(A)},onCancel:()=>M(null)}),(0,$.jsx)(Zn,{open:N,onOpenChange:e=>{P(e),e||L(null)},providerId:e,model:F?.model??null,isNew:F?.isNew??!1,onSave:e=>void H(e),m:o})]})}function ir(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function ar(e,t){switch(e){case`computer-use`:return{href:`/settings/computer-use`,guidance:t?`选择兼容的电脑控制模型;本机权限需单独授权`:`Select a compatible computer model; local access requires separate approval`,action:t?`配置电脑控制`:`Configure computer use`};case`vision`:return{href:`${Ae(`models`)}?add=1`,guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{href:Ae(`image`),guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{href:Ae(`voice`),guidance:t?`选择语音识别服务,或安装自管 STT 扩展`:`Choose a speech-to-text service or install a self-managed STT extension`,action:t?`去配置语音识别`:`Configure speech-to-text`};case`tts`:return{href:Ae(`voice`),guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}function or(e){switch(e){case`computer-use`:return`/settings/computer-use`;case`vision`:return Ae(`models`);case`image-generation`:return Ae(`image`);case`stt`:case`tts`:return Ae(`voice`)}}async function sr(){let e=await E(O(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}async function cr(){let e=await E(O(`/api/capabilities/readiness`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function lr(){let e=D(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=F(G,sr,{revalidateOnFocus:!1}),{data:i}=F(K,cr,{revalidateOnFocus:!1}),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);if(r)return(0,$.jsx)(B,{className:`h-24 w-full rounded-2xl`});let u=Object.values(t?.sources??{}),d=u.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),f=(t?.references??[]).filter(e=>e.availability===`unavailable`),p=t?.sync.lastSuccessAt??Math.max(0,...u.map(e=>e.lastSuccessAt)),h=s??(n instanceof Error?n.message:t?.sync.lastError??Object.values(t?.sync.sourceErrors??{})[0]),g=Object.entries(i?.capabilities??{}).filter(([e])=>e!==`computer-use`||U()),_=g.some(([,e])=>{let t=ir(e);return t===`degraded`||t===`misconfigured`}),y=g.filter(([,e])=>ir(e)===`ready`).length,b=async()=>{o(!0),c(null);try{let e=await E(O(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await W()}catch(t){c(t instanceof Error?t.message:e?`模型目录刷新失败`:`Model catalog refresh failed`)}finally{o(!1)}};return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[(0,$.jsxs)(`details`,{className:`group`,open:_||void 0,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2`,children:[_?(0,$.jsx)(X,{className:`size-4 text-amber-500`,"aria-hidden":!0}):y===g.length&&g.length>0?(0,$.jsx)(m,{className:`size-4 text-emerald-500`,"aria-hidden":!0}):(0,$.jsx)(re,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:e?`可选能力`:`Optional capabilities`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-fg-muted`,children:e?`${y}/${g.length} 项已配置,不影响基础聊天功能`:`${y} of ${g.length} configured · Not required for chat`})]}),(0,$.jsx)(Oe,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]})}),i?(0,$.jsx)(`div`,{className:`mt-3 grid gap-1 sm:grid-cols-2`,children:Object.entries(i.capabilities).map(([t,n])=>{if(t===`computer-use`&&!U())return null;let r=t===`vision`?e?`图片理解`:`Vision`:t===`image-generation`?e?`图片生成`:`Image generation`:t===`computer-use`?e?`电脑控制模型`:`Computer use model`:t.toUpperCase(),i=n.selectionSource!==`explicit-config`,a=ir(n),o=a===`degraded`||a===`misconfigured`,s=ar(t,e),c=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-xs font-medium text-fg`,children:r}),(0,$.jsx)(`span`,{className:a===`ready`?`shrink-0 text-xs text-emerald-600 dark:text-emerald-400`:a===`off`||a===`not-configured`?`shrink-0 text-xs text-fg-muted`:`shrink-0 text-xs text-amber-600 dark:text-amber-400`,children:a===`ready`?t===`computer-use`?e?`已配置`:`Configured`:e?`可用`:`Ready`:a===`off`?e?`已关闭`:`Off`:a===`not-configured`?e?`未配置`:`Not configured`:a===`degraded`?e?`正在使用备用方案`:`Using fallback`:e?`需处理`:`Needs attention`})]}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,title:n.primary?`${n.primary.provider}/${n.primary.model}`:void 0,children:n.primary?`${i?e?`自动`:`Auto`:e?`显式`:`Explicit`} · ${n.primary.provider}/${n.primary.model}`:a===`not-configured`?e?`可稍后按需配置`:`Set up later if needed`:e?`已配置的模型不可用`:`The configured model is unavailable`}),o?(0,$.jsxs)(`div`,{className:`mt-2 rounded-lg bg-amber-500/10 p-2`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-amber-700 dark:text-amber-300`,children:n.status===`degraded`?e?`当前配置不可用,正在使用备用方案。${s.guidance}`:`The current configuration is unavailable, so a fallback is in use. ${s.guidance}.`:s.guidance}),(0,$.jsxs)(`span`,{className:`mt-1 inline-flex items-center gap-1 text-xs font-medium text-accent`,children:[s.action,(0,$.jsx)(be,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]});return(0,$.jsx)(l,{to:o?s.href:or(t),"aria-label":o?`${r}:${s.action}`:`${e?`配置`:`Configure`} ${r}`,className:C(`rounded-lg bg-surface-base/45 px-3 py-3 transition-colors`,o?`bg-amber-500/5 hover:bg-amber-500/10`:`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:c},t)})}):null]}),f.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 text-sm text-amber-700 dark:text-amber-300`,children:f.slice(0,3).map(t=>(0,$.jsxs)(`p`,{children:[t.ref,` `,e?`不可用`:`is unavailable`,t.suggestedRef?` · ${e?`建议`:`Suggested`} ${t.suggestedRef}`:``,` · ${t.locations.length} ${e?`处引用`:`references`}`]},t.ref))}):null,h?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:h}):null,(0,$.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`summary`,{className:`min-h-8 cursor-pointer rounded-md py-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:e?`高级诊断`:`Advanced diagnostics`}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`${u.length} 个来源,${d} 个可用模型${p?` · 最近同步 ${new Date(p).toLocaleString()}`:``}`:`${u.length} sources, ${d} available models${p?` · Last synced ${new Date(p).toLocaleString()}`:``}`}),(0,$.jsxs)(I,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:a,onClick:()=>void b(),children:[a?(0,$.jsx)(v,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(tt,{className:`size-4`,"aria-hidden":!0}),a?e?`刷新中…`:`Refreshing…`:e?`刷新目录`:`Refresh catalog`]})]})]})]})}async function ur(){return(await w(O(`/api/models/xopc-cloud/account-summary`))).payload}function dr(e){let t=(0,Ft.c)(99),{labels:n}=e,r=D(fr)===`zh`?`zh-CN`:`en-US`,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:6e4,revalidateOnFocus:!0},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,isValidating:c,mutate:l}=F(`/api/models/xopc-cloud/account-summary`,ur,i);if(s){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(B,{className:`h-40 w-full rounded-xl`}),t[1]=e):e=t[1],e}if(o||!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),t[2]=e):e=t[2];let r;t[3]===n.title?r=t[4]:(r=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[3]=n.title,t[4]=r);let i;t[5]===n.unavailable?i=t[6]:(i=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.unavailable}),t[5]=n.unavailable,t[6]=i);let a;t[7]!==r||t[8]!==i?(a=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[e,(0,$.jsxs)(`div`,{children:[r,i]})]}),t[7]=r,t[8]=i,t[9]=a):a=t[9];let o;t[10]===l?o=t[11]:(o=()=>void l(),t[10]=l,t[11]=o);let s=c?`size-4 animate-spin`:`size-4`,u;t[12]===s?u=t[13]:(u=(0,$.jsx)(tt,{className:s,"aria-hidden":!0}),t[12]=s,t[13]=u);let d;t[14]!==c||t[15]!==n.retry||t[16]!==o||t[17]!==u?(d=(0,$.jsxs)(I,{type:`button`,variant:`secondary`,disabled:c,onClick:o,children:[u,n.retry]}),t[14]=c,t[15]=n.retry,t[16]=o,t[17]=u,t[18]=d):d=t[18];let f;return t[19]!==a||t[20]!==d?(f=(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/25 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[a,d]})}),t[19]=a,t[20]=d,t[21]=f):f=t[21],f}let u,d,f,p,m,g,_;if(t[22]!==a.balance.credits||t[23]!==a.links.details||t[24]!==a.links.purchase||t[25]!==a.usage.chargedCredits||t[26]!==a.usage.requests||t[27]!==a.usage.totalTokens||t[28]!==n.availableCredits||t[29]!==n.connected||t[30]!==n.details||t[31]!==n.purchase||t[32]!==n.title||t[33]!==n.usageSummary||t[34]!==r){let e=new Intl.NumberFormat(r);_=n.usageSummary.replace(`{{tokens}}`,e.format(a.usage.totalTokens)).replace(`{{credits}}`,e.format(a.usage.chargedCredits)).replace(`{{requests}}`,e.format(a.usage.requests)),m=`rounded-xl bg-surface-hover/40 p-4 sm:p-5`;let i;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(Je,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),t[42]=i):i=t[42];let o;t[43]===n.title?o=t[44]:(o=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[43]=n.title,t[44]=o);let s;t[45]===n.connected?s=t[46]:(s=(0,$.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-700 dark:text-emerald-300`,children:n.connected}),t[45]=n.connected,t[46]=s);let c;t[47]!==s||t[48]!==o?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i,o,s]}),t[47]=s,t[48]=o,t[49]=c):c=t[49];let l;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),t[50]=l):l=t[50];let v;t[51]!==a.links.purchase||t[52]!==n.purchase?(v=(0,$.jsx)(I,{asChild:!0,variant:`primary`,children:(0,$.jsxs)(`a`,{href:a.links.purchase,target:`_blank`,rel:`noreferrer`,children:[n.purchase,l]})}),t[51]=a.links.purchase,t[52]=n.purchase,t[53]=v):v=t[53];let y;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),t[54]=y):y=t[54];let b;t[55]!==a.links.details||t[56]!==n.details?(b=(0,$.jsx)(I,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(`a`,{href:a.links.details,target:`_blank`,rel:`noreferrer`,children:[n.details,y]})}),t[55]=a.links.details,t[56]=n.details,t[57]=b):b=t[57];let x;t[58]!==v||t[59]!==b?(x=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[v,b]}),t[58]=v,t[59]=b,t[60]=x):x=t[60],t[61]!==c||t[62]!==x?(g=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[c,x]}),t[61]=c,t[62]=x,t[63]=g):g=t[63],p=`mt-4 grid gap-4 rounded-lg bg-surface-base/45 p-3 sm:grid-cols-[minmax(12rem,0.7fr)_minmax(0,1.3fr)] sm:gap-6`,t[64]===n.availableCredits?f=t[65]:(f=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:n.availableCredits}),t[64]=n.availableCredits,t[65]=f),u=`mt-1 text-2xl font-semibold tracking-tight text-fg`,d=e.format(a.balance.credits),t[22]=a.balance.credits,t[23]=a.links.details,t[24]=a.links.purchase,t[25]=a.usage.chargedCredits,t[26]=a.usage.requests,t[27]=a.usage.totalTokens,t[28]=n.availableCredits,t[29]=n.connected,t[30]=n.details,t[31]=n.purchase,t[32]=n.title,t[33]=n.usageSummary,t[34]=r,t[35]=u,t[36]=d,t[37]=f,t[38]=p,t[39]=m,t[40]=g,t[41]=_}else u=t[35],d=t[36],f=t[37],p=t[38],m=t[39],g=t[40],_=t[41];let v;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`span`,{className:`ml-2 text-sm font-medium text-fg-muted`,children:`credits`}),t[66]=v):v=t[66];let y;t[67]!==u||t[68]!==d?(y=(0,$.jsxs)(`p`,{className:u,children:[d,v]}),t[67]=u,t[68]=d,t[69]=y):y=t[69];let b;t[70]!==a.balance.credits||t[71]!==n.zeroBalance?(b=a.balance.credits===0?(0,$.jsx)(`p`,{className:`mt-1 text-sm font-medium text-danger`,children:n.zeroBalance}):null,t[70]=a.balance.credits,t[71]=n.zeroBalance,t[72]=b):b=t[72];let x;t[73]!==b||t[74]!==f||t[75]!==y?(x=(0,$.jsxs)(`div`,{children:[f,y,b]}),t[73]=b,t[74]=f,t[75]=y,t[76]=x):x=t[76];let S;t[77]===n.recentUsage?S=t[78]:(S=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:n.recentUsage}),t[77]=n.recentUsage,t[78]=S);let C;t[79]===_?C=t[80]:(C=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:_}),t[79]=_,t[80]=C);let w;t[81]!==a.balance.updatedAt||t[82]!==n.updatedAt||t[83]!==r?(w=n.updatedAt.replace(`{{time}}`,new Date(a.balance.updatedAt).toLocaleString(r)),t[81]=a.balance.updatedAt,t[82]=n.updatedAt,t[83]=r,t[84]=w):w=t[84];let T;t[85]===w?T=t[86]:(T=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:w}),t[85]=w,t[86]=T);let E;t[87]!==S||t[88]!==C||t[89]!==T?(E=(0,$.jsxs)(`div`,{children:[S,C,T]}),t[87]=S,t[88]=C,t[89]=T,t[90]=E):E=t[90];let O;t[91]!==x||t[92]!==E||t[93]!==p?(O=(0,$.jsxs)(`div`,{className:p,children:[x,E]}),t[91]=x,t[92]=E,t[93]=p,t[94]=O):O=t[94];let k;return t[95]!==O||t[96]!==m||t[97]!==g?(k=(0,$.jsxs)(`section`,{className:m,children:[g,O]}),t[95]=O,t[96]=m,t[97]=g,t[98]=k):k=t[98],k}function fr(e){return e.language}function pr(e){return J.includes(e)}function mr(){let e=(0,Ft.c)(69),t=D(_r),n;e[0]===t?n=e[1]:(n=S(t),e[0]=t,e[1]=n);let r=n,i=r.capabilitiesSettings,u=a(),[d,f]=o(),p;if(e[2]!==d){let t=d.get(`returnTo`);p=t?.startsWith(`/chat/`)?t:null,e[2]=d,e[3]=p}else p=e[3];let m=p,{capability:h}=s(),[g,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),x=Re(),C;e[4]===x.cards?C=e[5]:(C=x.cards.some(gr),e[4]=x.cards,e[5]=C);let w=C,T,E;e[6]!==h||e[7]!==d||e[8]!==f?(T=()=>{if(h!==`models`||d.get(`add`)!==`1`)return;v(!0);let e=new URLSearchParams(d);e.delete(`add`),f(e,{replace:!0})},E=[h,d,f],e[6]=h,e[7]=d,e[8]=f,e[9]=T,e[10]=E):(T=e[9],E=e[10]),(0,Q.useEffect)(T,E);let O;e[11]===i.tabs.models?O=e[12]:(O={id:`models`,icon:Ne,label:i.tabs.models},e[11]=i.tabs.models,e[12]=O);let k;e[13]===i.tabs.image?k=e[14]:(k={id:`image`,icon:_,label:i.tabs.image},e[13]=i.tabs.image,e[14]=k);let A;e[15]!==O||e[16]!==k?(A=[O,k],e[15]=O,e[16]=k,e[17]=A):A=e[17];let j=A,M;e[18]===u?M=e[19]:(M=e=>u(Ae(e)),e[18]=u,e[19]=M);let N=M,ee=hr;if(!pr(h)){let t;return e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(c,{to:Ae(`models`),replace:!0}),e[20]=t):t=e[20],t}let P=h===`models`||h===`image`,F=h===`voice`?r.nav.settingsVoice:h===`search`?r.nav.settingsSearch:r.nav.settingsModels,I;e[21]===t?I=e[22]:(I=Z(t,`configuration`),e[21]=t,e[22]=I);let L;e[23]!==i.docsLink||e[24]!==F||e[25]!==I?(L=(0,$.jsx)(ut,{title:F,docsLink:I,docsLabel:i.docsLink}),e[23]=i.docsLink,e[24]=F,e[25]=I,e[26]=L):L=e[26];let R;e[27]!==h||e[28]!==m||e[29]!==t?(R=h===`voice`&&m?(0,$.jsx)(l,{to:m,className:`text-sm text-accent-fg hover:underline`,children:t===`zh`?`返回对话`:`Return to conversation`}):null,e[27]=h,e[28]=m,e[29]=t,e[30]=R):R=e[30];let z;e[31]!==i.tabsAria||e[32]!==h||e[33]!==P||e[34]!==j||e[35]!==N?(z=P?(0,$.jsx)(ct,{items:j,activeTab:h,onChange:N,ariaLabel:i.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}):null,e[31]=i.tabsAria,e[32]=h,e[33]=P,e[34]=j,e[35]=N,e[36]=z):z=e[36];let B=P?`tabpanel`:void 0,V=`capability-panel-${h}`,H=P?`capability-tab-${h}`:void 0,U;e[37]!==i.connectedProviders||e[38]!==i.xopcCloudAccount||e[39]!==h||e[40]!==x||e[41]!==w?(U=h===`models`?(0,$.jsxs)($.Fragment,{children:[w?(0,$.jsx)(dr,{labels:i.xopcCloudAccount}):null,(0,$.jsx)(We,{labels:i.connectedProviders,data:x,onAdd:()=>v(!0),onManage:(e,t)=>b({providerId:e,isCustom:t})}),x.cards.length>0?(0,$.jsx)(lr,{}):null]}):(0,$.jsx)(vr,{section:h}),e[37]=i.connectedProviders,e[38]=i.xopcCloudAccount,e[39]=h,e[40]=x,e[41]=w,e[42]=U):U=e[42];let W;e[43]!==B||e[44]!==V||e[45]!==H||e[46]!==U?(W=(0,$.jsx)(`div`,{role:B,id:V,"aria-labelledby":H,className:`flex min-w-0 flex-col gap-4`,children:U}),e[43]=B,e[44]=V,e[45]=H,e[46]=U,e[47]=W):W=e[47];let G;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(G=()=>ee(),e[48]=G):G=e[48];let K;e[49]!==g||e[50]!==i.addProviderDialog||e[51]!==t||e[52]!==x.builtinRows||e[53]!==x.customConfig?(K=(0,$.jsx)(it,{open:g,onOpenChange:v,builtinRows:x.builtinRows,customConfig:x.customConfig,labels:i.addProviderDialog,language:t,onSaved:G}),e[49]=g,e[50]=i.addProviderDialog,e[51]=t,e[52]=x.builtinRows,e[53]=x.customConfig,e[54]=K):K=e[54];let q;e[55]!==i.manageProviderDialog||e[56]!==t||e[57]!==y||e[58]!==x.allModels||e[59]!==x.builtinRows||e[60]!==x.customConfig?(q=y?(0,$.jsx)(tr,{open:!0,onOpenChange:e=>{e||b(null)},providerId:y.providerId,isCustom:y.isCustom,builtinRows:x.builtinRows,customConfig:x.customConfig,allModels:x.allModels,labels:i.manageProviderDialog,language:t,onSaved:ee}):null,e[55]=i.manageProviderDialog,e[56]=t,e[57]=y,e[58]=x.allModels,e[59]=x.builtinRows,e[60]=x.customConfig,e[61]=q):q=e[61];let te;return e[62]!==L||e[63]!==R||e[64]!==z||e[65]!==W||e[66]!==K||e[67]!==q?(te=(0,$.jsxs)(dt,{children:[L,R,z,W,K,q]}),e[62]=L,e[63]=R,e[64]=z,e[65]=W,e[66]=K,e[67]=q,e[68]=te):te=e[68],te}function hr(){W()}function gr(e){return e.id===`xopc-cloud`&&!e.isCustom}function _r(e){return e.language}function vr(e){let t=(0,Ft.c)(3),{section:n}=e;switch(n){case`models`:return null;case`image`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Zt,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Tn,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Gn,{}),t[2]=e):e=t[2],e}}}export{mr as CapabilitiesSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./popover-select-DcsFzD_i.js";import{t as o}from"./messages-D0G_sZvA.js";import{t as s}from"./cn-JdwAhgNB.js";import{c,n as l}from"./locale-store-BSkKhYkc.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{t as d}from"./button-CS04eWY9.js";import{t as f}from"./skeleton-BwbyijEw.js";import{Hi as p,Hl as m,Kl as h,Si as g,_s as _,gs as v,pl as y,rl as b,vs as x}from"./index-Cr4SINLG.js";import{n as S}from"./capability-header-actions-C3chJDQu.js";import{t as C}from"./capability-icon-BYm2-nS-.js";import{t as w}from"./extension-marketplace-api-DqV4YRYs.js";import{o as T}from"./skill-api-BCAV_F1P.js";var E=e(t(),1),D=n();function O(e,t){let n=t.trim().toLocaleLowerCase();return n?[e.name,e.description,e.source,...e.tags].some(e=>e.toLocaleLowerCase().includes(n)):!0}function k(e){return e?[`failed`,`unauthorized`,`degraded`,`not_configured`].includes(e.status)?`attention`:`installed`:`available`}function A(e,t,n){return e.filter(e=>(t===`all`||e.kind===t)&&O(e,n))}function j(e,t){let n=new Set(t.flatMap(e=>[e.directoryId,e.name]));return e.map(e=>({id:e.id,kind:`skill`,name:e.name,description:e.description,source:e.sourceLabel||e.author.username,status:n.has(e.id)||n.has(e.name)?`installed`:`available`,tags:[e.category,...e.categories??[],...e.tags??[]].filter(e=>!!e),href:`/capabilities/skills?tab=marketplace&q=${encodeURIComponent(e.name)}`,iconUrl:e.branding?.iconUrl}))}function M(e,t,n){let r=new Map(n.map(e=>[e.connectorId,e])),i=new Map;for(let t of e){let e=r.get(t.id);i.set(t.id,{id:t.id,kind:`connector`,name:t.displayName,description:t.description,source:t.source,status:k(e),tags:[t.category,t.kind,...t.tags??[]],href:`/capabilities/connectors?tab=${e?`connected`:`discover`}&${e?`instance`:`connector`}=${encodeURIComponent(e?.instanceId??t.id)}`,iconUrl:t.branding?.logoUrl})}for(let e of t){if(i.has(e.id))continue;let t=r.get(e.id);i.set(e.id,{id:e.id,kind:`connector`,name:e.name,description:e.description,source:e.author.username||`XOPC Store`,status:k(t),tags:[e.category].filter(e=>!!e),href:`/capabilities/connectors?tab=discover&connector=${encodeURIComponent(e.id)}`,iconUrl:e.branding?.iconUrl})}return[...i.values()]}function N(e,t){return e.map(e=>({id:e.id,kind:`extension`,name:e.name,description:e.description??``,source:e.author||e.npmPackage,status:t.has(e.id)?`installed`:`available`,tags:[...e.categories??[],...e.tags??[]],href:`/capabilities/extensions?tab=marketplace&q=${encodeURIComponent(e.name)}`,iconUrl:e.branding?.iconUrl}))}var P=r();async function F(e,t){let[n,r,i,a,o,s]=await Promise.allSettled([T({q:e,page:1,pageSize:18,sort:`downloads`}),p(),v(),x({q:e,page:1,pageSize:18,sort:`downloads`}),_(),w(e)]),c=[];n.status===`fulfilled`&&c.push(...j(n.value.items,r.status===`fulfilled`?r.value.catalog:[])),(i.status===`fulfilled`||a.status===`fulfilled`)&&c.push(...M(i.status===`fulfilled`?i.value:[],a.status===`fulfilled`?a.value.items:[],o.status===`fulfilled`?o.value:[])),s.status===`fulfilled`&&c.push(...N(s.value,t));let l=[n,i,a,s].filter(e=>e.status===`rejected`).length;if(l===4)throw Error(`Capability catalog unavailable`);return{items:c,failedSources:l}}var I={skill:y,connector:h,extension:b};function L({onHeaderActionChange:e}){let t=o(l(e=>e.language)).capabilitiesHub,n=c(e=>!!e.conversationId),r=g(),i=(0,E.useMemo)(()=>new Set(r.flatMap(e=>[e.id,e.pluginId].filter(e=>!!e))),[r]),s=[...i].sort().join(`|`),[d,f]=(0,E.useState)(``),[p,h]=(0,E.useState)(``),[_,v]=(0,E.useState)(`all`);(0,E.useEffect)(()=>{let e=window.setTimeout(()=>h(d.trim()),250);return()=>window.clearTimeout(e)},[d]);let{data:y,error:b,isLoading:x}=u(n?[`capability-catalog`,p,s]:null,()=>F(p,i),{keepPreviousData:!0,revalidateOnFocus:!1}),C=(0,E.useMemo)(()=>A(y?.items??[],_,d),[y?.items,_,d]),w=(0,E.useMemo)(()=>[{id:`all`,label:t.filterAll},{id:`skill`,label:t.tabSkills},{id:`connector`,label:t.tabConnectors},{id:`extension`,label:t.tabExtensions}],[t.filterAll,t.tabConnectors,t.tabExtensions,t.tabSkills]),T=(0,E.useMemo)(()=>({searchLabel:t.searchLabel,search:(0,P.jsx)(S,{value:d,onChange:f,placeholder:t.searchPlaceholder,ariaLabel:t.searchLabel}),secondary:(0,P.jsx)(a,{value:_,options:w.map(e=>({value:e.id,label:e.label})),placeholder:t.filterAll,allowEmpty:!1,ariaLabel:t.filterAria,triggerClassName:`h-9 w-auto min-w-[6.5rem] bg-surface-panel`,align:`end`,onChange:e=>v(e)})}),[t.filterAria,t.searchLabel,t.searchPlaceholder,_,w,d]);return(0,E.useLayoutEffect)(()=>(e?.(T),()=>e?.(null)),[T,e]),(0,P.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,P.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5 px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`,children:[y?.failedSources?(0,P.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl border border-edge bg-surface-panel px-3 py-2 text-sm text-fg-muted`,role:`status`,children:[(0,P.jsx)(m,{className:`size-4 shrink-0`,"aria-hidden":!0}),t.partialResults]}):null,b?(0,P.jsx)(`p`,{className:`text-sm text-danger`,role:`alert`,children:t.loadFailed}):null,x&&!y?(0,P.jsx)(z,{}):null,!x&&y&&C.length===0?(0,P.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge px-6 py-16 text-center`,children:[(0,P.jsx)(`p`,{className:`font-medium text-fg`,children:t.emptyTitle}),(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.emptyBody})]}):null,C.length>0?(0,P.jsx)(`ul`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:C.map(e=>(0,P.jsx)(R,{item:e,copy:t},`${e.kind}:${e.id}`))}):null]})})}function R(e){let t=(0,D.c)(38),{item:n,copy:r}=e,a=I[n.kind],o=n.status===`attention`?r.statusAttention:n.status===`installed`?r.statusInstalled:r.statusAvailable,c=n.kind===`skill`?r.kindSkill:n.kind===`connector`?r.kindConnector:r.kindExtension,l;t[0]!==a||t[1]!==n.iconUrl?(l=(0,P.jsx)(C,{iconUrl:n.iconUrl,fallback:a}),t[0]=a,t[1]=n.iconUrl,t[2]=l):l=t[2];let u;t[3]===n.name?u=t[4]:(u=(0,P.jsx)(`h2`,{className:`truncate font-semibold text-fg`,children:n.name}),t[3]=n.name,t[4]=u);let f;t[5]===n.source?f=t[6]:(f=(0,P.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.source}),t[5]=n.source,t[6]=f);let p;t[7]!==u||t[8]!==f?(p=(0,P.jsxs)(`div`,{className:`min-w-0`,children:[u,f]}),t[7]=u,t[8]=f,t[9]=p):p=t[9];let m;t[10]!==l||t[11]!==p?(m=(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[l,p]}),t[10]=l,t[11]=p,t[12]=m):m=t[12];let h=n.status===`attention`?`bg-danger/10 text-danger`:`bg-surface-hover text-fg-muted`,g;t[13]===h?g=t[14]:(g=s(`shrink-0 rounded-full px-2 py-1 text-xs`,h),t[13]=h,t[14]=g);let _;t[15]!==o||t[16]!==g?(_=(0,P.jsx)(`span`,{className:g,children:o}),t[15]=o,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==m||t[19]!==_?(v=(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[m,_]}),t[18]=m,t[19]=_,t[20]=v):v=t[20];let y=n.description||r.noDescription,b;t[21]===y?b=t[22]:(b=(0,P.jsx)(`p`,{className:`mt-4 line-clamp-3 flex-1 text-sm leading-6 text-fg-muted`,children:y}),t[21]=y,t[22]=b);let x;t[23]===c?x=t[24]:(x=(0,P.jsx)(`span`,{className:`text-xs uppercase tracking-wide text-fg-muted`,children:c}),t[23]=c,t[24]=x);let S=n.status===`available`?`primary`:`secondary`,w=n.status===`available`?r.viewAction:r.manageAction,T;t[25]!==n.href||t[26]!==w?(T=(0,P.jsx)(i,{to:n.href,children:w}),t[25]=n.href,t[26]=w,t[27]=T):T=t[27];let E;t[28]!==S||t[29]!==T?(E=(0,P.jsx)(d,{asChild:!0,variant:S,className:`h-8 px-3 py-1.5`,children:T}),t[28]=S,t[29]=T,t[30]=E):E=t[30];let O;t[31]!==x||t[32]!==E?(O=(0,P.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3 border-t border-edge-subtle pt-4`,children:[x,E]}),t[31]=x,t[32]=E,t[33]=O):O=t[33];let k;return t[34]!==b||t[35]!==O||t[36]!==v?(k=(0,P.jsxs)(`li`,{className:`flex min-h-52 min-w-0 flex-col rounded-2xl border border-edge bg-surface-panel p-5 shadow-surface`,children:[v,b,O]}),t[34]=b,t[35]=O,t[36]=v,t[37]=k):k=t[37],k}function z(){let e=(0,D.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":!0,children:Array.from({length:6},B)}),e[0]=t):t=e[0],t}function B(e,t){return(0,P.jsx)(f,{className:`h-52 rounded-2xl`},t)}export{L as CapabilityDiscoverPage};
|