@xopcai/xopc 0.0.377 → 0.0.380
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/_locales/en/messages.json +1 -0
- package/dist/browser-ext/_locales/zh_CN/messages.json +1 -0
- package/dist/browser-ext/dist/sidepanel.js +36 -9
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-BVtU6S1w.js → activity-store-D2oKh5ik.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BD63ce58.js → agent-avatar-dicebear-OKK1A-IR.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-By5OXUfL.js +1 -0
- package/dist/gateway/static/root/assets/agent-plugin-dialog-b24CxjaT.js +1 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-DgQph1Pu.js → agents-admin-api-D-DNV0ms.js} +1 -1
- package/dist/gateway/static/root/assets/agents-tJxKA9VH.js +66 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B0yP8rNC.js → app-management-settings-panel-DxKh06hG.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Bnq1nzDX.js → appearance-settings-C8CeHpdR.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-CSIFuEnj.js → apps-page-CZSTLErb.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-FBVMH4ym.js → archive-plugin-aoEF5gna.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-qsg6pZlF.js → automations-page-CSWWUZse.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-D2RJ-Lzn.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-B0qGhVNs.js → binary-plugins-BM3Lr1BP.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CjQv4zlo.js → block-editor-DMZ3_pPz.js} +39 -39
- package/dist/gateway/static/root/assets/{browser-automation-inputs-DSbRHrG7.js → browser-automation-inputs-BcBLdyVd.js} +1 -1
- package/dist/gateway/static/root/assets/browser-automations-page-BLSr6du1.js +3 -0
- package/dist/gateway/static/root/assets/browser-settings-page-BlDHSstc.js +3 -0
- package/dist/gateway/static/root/assets/{capabilities-HaRLmYU1.js → capabilities-BOJYAeEJ.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-LpGa-olH.js → capabilities-Bf6NYuvT.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-BeQ-Yj3_.js → capabilities-page-DHT4cB-Y.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-NZZNtjwZ.js +8 -0
- package/dist/gateway/static/root/assets/{capability-header-actions-DuBac0EK.js → capability-header-actions-V7TdNf7i.js} +1 -1
- package/dist/gateway/static/root/assets/channels-sgWMfPkw.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CQc1mqZM.js → chat-terminal-dock-B4HNp59x.js} +2 -2
- package/dist/gateway/static/root/assets/{computer-settings-page-BIwOemaK.js → computer-settings-page-B2iwtbBu.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-CG9KKuXq.js → connector-service-page-DTn3Z-MT.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-BJii6NMu.js +1 -0
- package/dist/gateway/static/root/assets/{date-picker-DoZGE2hF.js → date-picker-DrUc4ivy.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-hrz7p1Lv.js → dependency-picker-Bs16sgfD.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-C1bTu_dG.js → desktop-pet-Dg0Cp16O.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-C2xCFimg.js → desktop-pet-settings-BeJg3R-X.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-DPqFaLVI.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BaHQhI4z.js → directory-picker-path-field-BZkjdejC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-B1uMVNGe.js → extension-debug-page-CFnlTs2-.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-850m5tOc.js → extension-page-BH25rxhA.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-B-_CkaD2.js → extension-provider-CmaIRIVP.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-P3FNAW0n.js → extension-settings-page-D0af0S3r.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-BoJZA9Cm.js → fallback-models-BD_9_8lg.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-siY2J0hx.js → gateway-config-swr-f-4qw3AG.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-Biz18NiE.js → gateway-realtime-BGhPOSfz.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BYe-jWB1.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-Bzrm6DMQ.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CeL1OFDZ.js → gateway-startup-retry-90pvxKox.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-oHguULk0.js +2 -0
- package/dist/gateway/static/root/assets/{image-generation-api-CeDrok06.js → image-generation-api-CtDjTXwX.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-C9FTl2dW.js → imports-page-CjFNSzDN.js} +1 -1
- package/dist/gateway/static/root/assets/index-_xgO2IDa.css +1 -0
- package/dist/gateway/static/root/assets/index-hn5CBddI.js +106 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Dx-36I-c.js → keyboard-shortcuts-settings-DKdWZ7pq.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-Cg4gdTwm.js → local-app-workbench-page-CXJQpTS9.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-3GKgu7at.js → local-apps-page-9dyoG2s0.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-DnSw14fE.js → local-session-drafts-CrD74S6k.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-DSsLH7JO.js → locale-store-pmT2B_By.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-pMgnuu0O.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-DcgCzPd-.js → management-settings-CxElPS5j.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-2rwSrMXW.js → markdown-view-B_7--qVD.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CjGiKLFo.js → media-plugins-C6tT2oPH.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-Cn25s55n.js → messages-Ib6DaUTo.js} +3 -3
- package/dist/gateway/static/root/assets/models-hub-cache-3slk24cw.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-4GI5kfs2.js +5 -0
- package/dist/gateway/static/root/assets/{notes-api-D9fGUbkK.js → notes-api-ChO4X97y.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-DaMnzWfF.js +8 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-CKqYL9AQ.js → page-context-capture-button-3bLWMSqt.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-BeAW5QQd.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-DFu_ZT2h.js → product-open-page-BiGwWy9s.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-tPBCFa7L.js → product-preview-content-Dvy5ieTo.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BNgCsfeE.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-CATt0m8t.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-ZhIt79wL.js → registry-api-Bi4muyaZ.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-5o06KAdu.js +1 -0
- package/dist/gateway/static/root/assets/runtime-tools-api-9bk1payF.js +5 -0
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-BnRVbeGi.js +1 -0
- package/dist/gateway/static/root/assets/{scenes-page-7LjR8Aek.js → scenes-page-BVjQ4A9S.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-GwVc8KsT.js → schema-form-C0QHo3do.js} +1 -1
- package/dist/gateway/static/root/assets/send-session-input-BhWG0d-Z.js +1 -0
- package/dist/gateway/static/root/assets/{session-api-BUa3BaGX.js → session-api-D2J6VacQ.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-D2xce33J.js +16 -0
- package/dist/gateway/static/root/assets/sessions-page-BHYhAsHC.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DO148Ocl.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-DAvi3P8Q.js → settings-page-BT6dQ5nv.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-B9EqOzrI.js +1 -0
- package/dist/gateway/static/root/assets/{share-link-dialog-CbkS1cj-.js → share-link-dialog-Cu1miKUo.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-DicRCB4L.js → share-preview-page-CWH4BdnM.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-BUGeqXCG.js → shares-api-cGtd3rjc.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-B3Z6sQEA.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-DpTUuYWk.js → skill-api-pzPKld3K.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-CII18PA5.js → skill-reload-api-VT8F0enn.js} +1 -1
- package/dist/gateway/static/root/assets/skills-page-Busjd4VD.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-DlNaQp-l.js → system-settings-panel-CDuqpAIG.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DeElbs6T.js → task-detail-page-CNt-P3Kl.js} +2 -2
- package/dist/gateway/static/root/assets/{task-expandable-content-sONbgbwR.js → task-expandable-content-Dgk9lYGd.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-Kz0VUMSb.js → theme-store-D7m5Eng5.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-CZHhm1Nn.js → tracing-settings-page-B90frz6c.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-sUbAaSX6.js → tunnel-api-BJ2UEjeF.js} +1 -1
- package/dist/gateway/static/root/assets/usage-page-DrV2qcKO.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-CZzYhcAl.js → use-autosave-Ct1x4pqI.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-Bb_Hqqry.js → use-composer-attachments-CyWRo1B1.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-D4WI5JDn.js → use-file-preview-expanded-JIgp5qPT.js} +2 -2
- package/dist/gateway/static/root/assets/user-model-page-CQReU8e2.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CIIGmtHR.js → voice-api-key-field-CSG8Hx8V.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-BtWFziQc.js → voice-config-api-415pyWx8.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-Dp107FXF.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Be_Rey6d.js → workflow-run-setup-panel-CZKJ6leF.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-2HuveBs_.js +6 -0
- package/dist/gateway/static/root/assets/{workspace-api-B5ssQs4p.js → workspace-api-DO_TWsiS.js} +2 -2
- package/dist/gateway/static/root/assets/xopc-cloud-account-card-CBjtpPiL.js +1 -0
- package/dist/gateway/static/root/index.html +27 -27
- package/dist/package.js +1 -1
- package/dist/packages/realtime-protocol/src/voice-catalog.js +7 -2
- package/dist/src/agent/embedded/execution-tool-policy.d.ts +14 -0
- package/dist/src/agent/embedded/execution-tool-policy.js +41 -0
- package/dist/src/agent/embedded/run-for-session.js +6 -4
- package/dist/src/agent/embedded/run-turn.js +56 -1
- package/dist/src/agent/embedded/session-runner.d.ts +3 -0
- package/dist/src/agent/embedded/session-runner.js +29 -8
- package/dist/src/agent/embedded/types.d.ts +2 -0
- package/dist/src/agent/prompt/response-language.js +9 -1
- package/dist/src/agent/service.js +1 -0
- package/dist/src/agent/session/session-config-service.js +0 -13
- package/dist/src/agent/tasks/task-judge-service.d.ts +2 -2
- package/dist/src/agent/tasks/task-judge-service.js +16 -9
- package/dist/src/agent/tools/factory.js +14 -13
- package/dist/src/agent/tools/knowledge-memory-tool.js +5 -4
- package/dist/src/agent/tools/local-read-budget.d.ts +2 -0
- package/dist/src/agent/tools/local-read-budget.js +5 -0
- package/dist/src/agent/tools/media-read-tool.js +2 -1
- package/dist/src/agent/tools/personal-read-tool.js +34 -10
- package/dist/src/agent/tools/read.js +5 -2
- package/dist/src/agent/tools/session-recall-tool.d.ts +1 -0
- package/dist/src/agent/tools/session-recall-tool.js +53 -12
- package/dist/src/agent/tools/session-search-tool.js +34 -8
- package/dist/src/agent/tools/user-context-tool.js +5 -4
- package/dist/src/agent/tools/xopc-use-tool.js +6 -2
- package/dist/src/browser/native-messaging-host.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +2 -2
- package/dist/src/gateway/chat-stream/mapper.d.ts +2 -0
- package/dist/src/gateway/chat-stream/mapper.js +4 -1
- package/dist/src/gateway/chat-stream/protocol.d.ts +4 -1
- package/dist/src/gateway/hono/app.js +1 -1
- package/dist/src/gateway/hono/routes/browser-install.js +1 -1
- package/dist/src/gateway/hono/routes/chat-model-config.d.ts +0 -4
- package/dist/src/gateway/hono/routes/chat-model-config.js +0 -6
- package/dist/src/gateway/hono/routes/personal-agent.js +4 -2
- package/dist/src/gateway/hono/routes/voice.js +12 -4
- package/dist/src/gateway/rate-limit/buckets.d.ts +1 -1
- package/dist/src/gateway/rate-limit/buckets.js +2 -2
- package/dist/src/gateway/service/run-gateway-agent.js +8 -3
- package/dist/src/gateway/side-chat/manager.js +1 -1
- package/dist/src/personal-agent/communication.d.ts +2 -1
- package/dist/src/personal-agent/communication.js +4 -3
- package/dist/src/personal-agent/policy.js +4 -4
- package/dist/src/personal-agent/prompts.d.ts +1 -0
- package/dist/src/personal-agent/prompts.js +32 -5
- package/dist/src/personal-agent/reply-composer.js +19 -4
- package/dist/src/personal-agent/reply-style.d.ts +4 -2
- package/dist/src/personal-agent/reply-style.js +57 -5
- package/dist/src/providers/prompt-cache-payload.js +2 -3
- package/dist/src/providers/prompt-cache-plan.d.ts +1 -0
- package/dist/src/providers/prompt-cache-plan.js +2 -2
- package/dist/src/session/store.d.ts +1 -0
- package/dist/src/storage/sqlite/device-pairing-approval.js +1 -1
- package/dist/src/storage/sqlite/transcript-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/transcript-repository.js +5 -3
- package/dist/src/tasks/capabilities/write.js +10 -1
- package/dist/src/tasks/task-application-service.js +5 -4
- package/dist/src/tasks/task-context-assembler.js +1 -0
- package/dist/src/tasks/task-contract-definition.d.ts +1 -1
- package/dist/src/tasks/task-contract-definition.js +2 -2
- package/dist/src/tasks/task-contract-planner.d.ts +1 -0
- package/dist/src/tasks/task-contract-planner.js +2 -1
- package/dist/src/tasks/task-language.d.ts +7 -0
- package/dist/src/tasks/task-language.js +15 -0
- package/dist/src/tasks/task-read-model-projector.js +3 -2
- package/dist/src/tasks/task-result-delivery-service.js +2 -1
- package/dist/src/tasks/task-run-coordinator.js +22 -8
- package/dist/src/tasks/task-run-dispatcher.js +8 -6
- package/dist/src/voice/platform-catalog.d.ts +1 -0
- package/dist/src/voice/platform-settings.d.ts +1 -1
- package/dist/src/voice/platform-settings.js +6 -2
- package/dist/src/voice/platform-streams.js +3 -1
- package/dist/src/voice/realtime/omniRoute.d.ts +1 -1
- package/dist/src/voice/realtime/omniRoute.js +4 -1
- package/dist/src/voice/tts/providers/xopc-cloud-speech.js +6 -2
- package/dist/src/voice/tts/speech-provider-types.d.ts +1 -0
- package/package.json +4 -4
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Ch07F4uX.js +0 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-CdCVOg5e.js +0 -1
- package/dist/gateway/static/root/assets/agents-D2__mhy8.js +0 -66
- package/dist/gateway/static/root/assets/automations-workspace-DqBWLl61.js +0 -6
- package/dist/gateway/static/root/assets/browser-automations-page-CzEWM_ie.js +0 -3
- package/dist/gateway/static/root/assets/browser-settings-page-CsDck88G.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BQ-I3L-C.js +0 -8
- package/dist/gateway/static/root/assets/channels-1wUJcCxP.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BFzjGpKE.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-CZ5Wmq5U.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BazlseY_.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-BG1zXG8B.js +0 -1
- package/dist/gateway/static/root/assets/home-page-B8RmZbDw.js +0 -2
- package/dist/gateway/static/root/assets/index-CGVecvp4.css +0 -1
- package/dist/gateway/static/root/assets/index-DU5FmDQh.js +0 -106
- package/dist/gateway/static/root/assets/logs-page-CApZnDPi.js +0 -2
- package/dist/gateway/static/root/assets/models-hub-cache-DaqiLHPe.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-CncL3xmy.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-D9romxNU.js +0 -8
- package/dist/gateway/static/root/assets/personal-page-DoG-2fru.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-C9Bt5toA.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-Bu3jZa3A.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-C9MNGl2t.js +0 -1
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-BYQuPsWk.js +0 -5
- package/dist/gateway/static/root/assets/send-session-input-B64q4_6R.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-BWLIDok4.js +0 -16
- package/dist/gateway/static/root/assets/sessions-page-CzbNB_RT.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CmNe5RJ4.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DoAn6P_k.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-Bbkz0xuD.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-BuBSAOOd.js +0 -2
- package/dist/gateway/static/root/assets/usage-page-NPLApyNj.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-DAEiJzNV.js +0 -2
- package/dist/gateway/static/root/assets/work-discovery-overlay-DxRDLQvs.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-wJk7l1_H.js +0 -6
- package/dist/gateway/static/root/assets/xopc-cloud-account-card-D7Rtu5eI.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 ee}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as r}from"./bot-DjLkhyZL.js";import{t as i}from"./popover-select-BgSdSbCL.js";import{t as a}from"./circle-pause-CN9jYH2s.js";import{t as o}from"./clock-3-DnrAnuyZ.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as c}from"./pencil-DmIY3Oa-.js";import{t as l}from"./play-kxZvpBg8.js";import{t as u}from"./x-B_N4OPjy.js";import{a as d,n as f,r as p}from"./locale-store-DSsLH7JO.js";import{t as m}from"./button-CS04eWY9.js";import{t as h}from"./skeleton-BwbyijEw.js";import{Do as g,Sc as _,V as v,co as y,ea as b,go as x,oc as S,qo as C,z as w}from"./index-DU5FmDQh.js";import{i as T,n as E,r as D,t as O}from"./browser-automation-inputs-DSbRHrG7.js";var k=e(t(),1),A=n();function j({availability:e,endpointId:t,recordingBusy:n,onSelect:r,onRefresh:a,onStart:o,onClose:c}){let l=f(e=>e.language)===`zh`,g=ee(),[_,y]=(0,k.useState)(),[b,x]=(0,k.useState)(!0),[S,T]=(0,k.useState)(!1),[E,D]=(0,k.useState)(``),[O,j]=(0,k.useState)(!1),M=e.endpoints.length>0,N=e.state===`update_required`;(0,k.useEffect)(()=>{let e=!1;if(M){x(!1);return}return d(p(`/api/browser/extension-status`)).then(t=>{e||y(t)}).catch(t=>{e||D(t instanceof Error?t.message:String(t))}).finally(()=>{e||x(!1)}),()=>{e=!0}},[M]);let P=async()=>{T(!0),D(``);try{(N||!_?.artifacts?.installed||_.artifacts.needsRefresh)&&await w(N||!!_?.artifacts?.needsRefresh),await v(_?.artifacts?.installed?`chrome`:`both`),j(!0),await a()}catch(e){D(e instanceof Error?e.message:String(e))}finally{T(!1)}};return(0,A.jsxs)(`section`,{role:`status`,"aria-live":`polite`,className:`mb-4 shrink-0 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,A.jsx)(C,{className:`mt-0.5 size-5 shrink-0 text-accent`}),(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:M?l?`浏览器已连接`:`Browser connected`:N?l?`更新扩展后即可录制`:`Update the extension to record`:l?`连接 Chrome,录制你的操作`:`Connect Chrome to record your actions`}),(0,A.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:M?l?`在 Chrome 中切换到要录制的网页,然后开始录制。`:`Switch to the website you want to record in Chrome, then start recording.`:N?l?`当前扩展还不支持录制。更新扩展文件后,在 Chrome 扩展页重新加载 xopc。`:`Your connected extension does not support recording yet. Update its files, then reload xopc in Chrome Extensions.`:l?`录制需要 xopc Chrome 扩展。已有扩展请打开 xopc 侧栏,它会自动连接本机服务。`:`Recording uses the xopc Chrome extension. If already installed, open its side panel to connect to your local Gateway.`})]}),(0,A.jsx)(`button`,{type:`button`,disabled:S||n,onClick:c,"aria-label":l?`收起连接引导`:`Close connection guide`,className:`rounded p-1 text-fg-muted hover:bg-surface-hover`,children:(0,A.jsx)(u,{className:`size-4`})})]}),O&&!M&&(0,A.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:_?.artifacts?.installed?l?`重新加载后打开 xopc 侧栏。连接状态会自动更新。`:`After reloading, open the xopc side panel. Connection status updates automatically.`:l?`在 Chrome 扩展页开启开发者模式,点击“加载已解压的扩展程序”,选择已打开的扩展目录,再打开 xopc 侧栏。连接状态会自动更新。`:`Enable Developer mode in Chrome Extensions, choose Load unpacked and select the opened extension folder, then open the xopc side panel. Connection status updates automatically.`}),M&&e.endpoints.length>1&&(0,A.jsx)(`div`,{className:`mt-3 max-w-sm`,children:(0,A.jsx)(i,{value:t??``,ariaLabel:l?`选择录制浏览器`:`Choose a browser to record`,placeholder:l?`选择浏览器`:`Choose a browser`,allowEmpty:!1,options:e.endpoints.map(e=>({value:e.endpointId,label:e.displayName})),onChange:r})}),(0,A.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[M?(0,A.jsx)(m,{onClick:o,disabled:n||!t&&e.endpoints.length>1,children:l?`开始录制`:`Start recording`}):b?(0,A.jsx)(h,{className:`h-9 w-32 rounded-lg`}):_?.artifacts?.extensionDir?(0,A.jsxs)(m,{onClick:()=>void P(),disabled:S,children:[S&&(0,A.jsx)(s,{className:`size-4 animate-spin`}),N?l?`更新并打开扩展页`:`Update and open extensions`:_.artifacts.installed?l?`打开 Chrome 扩展页`:`Open Chrome Extensions`:l?`安装 Chrome 扩展`:`Install Chrome extension`]}):(0,A.jsx)(m,{onClick:()=>g(`/settings/agent-browser`),children:l?`设置浏览器连接`:`Set up browser connection`}),!M&&(0,A.jsx)(m,{variant:`secondary`,disabled:S,onClick:()=>void a().catch(e=>D(e instanceof Error?e.message:String(e))),children:l?`检查连接`:`Check connection`})]}),E&&(0,A.jsx)(`p`,{className:`mt-2 text-sm text-danger`,role:`alert`,children:E})]})}var M={en:{record:`Record my actions`,finishRecording:`Finish and save`,recording:`Recording`,syncing:`Saved locally, syncing…`,verified:`Result verified`,saved:`Saved draft`,unknown:`Check the business result before repeating`,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:{record:`录制我的操作`,finishRecording:`完成并保存`,recording:`正在录制`,syncing:`已保存到本机,正在同步…`,verified:`结果已验证`,saved:`已保存草稿`,unknown:`结果待检查,请先检查业务结果再重复运行`,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 N(e){return e!==`queued`&&e!==`running`}function P(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${P(e)}`).join(`
|
|
2
|
-
`):typeof e==`object`?Object.entries(e).map(([e,t])=>`${e}: ${P(t)}`).join(`
|
|
3
|
-
`):String(e)}function F(){let e=f(e=>e.language),t=M[e],n=ee(),i=b(e=>e.setPageHeader),s=b(e=>e.clearPageHeader),[u,d]=(0,k.useState)(null),[p,v]=(0,k.useState)(),[C,w]=(0,k.useState)({}),[F,I]=(0,k.useState)([]),[L,R]=(0,k.useState)(),[z,B]=(0,k.useState)(``),[V,H]=(0,k.useState)(!1),[U,W]=(0,k.useState)(),[G,K]=(0,k.useState)(),[q,J]=(0,k.useState)(),Y=(0,k.useMemo)(()=>u?.find(e=>e.id===p),[p,u]),X=(0,k.useCallback)(async()=>{let e=await T.list();d(e.automations),v(t=>t&&e.automations.some(e=>e.id===t)?t:e.automations[0]?.id)},[]);(0,k.useEffect)(()=>{X().catch(e=>B(String(e)))},[X]),(0,k.useEffect)(()=>{Y&&(w(D(Y)),R(void 0),B(``),T.listRuns(Y.id).then(e=>I(e.runs)).catch(e=>B(String(e))))},[Y?.id,Y?.revision]),(0,k.useEffect)(()=>{if(!L||N(L.status))return;let e=window.setInterval(()=>{T.getRun(L.id).then(({run:e})=>{R(e),N(e.status)&&Y&&(T.listRuns(Y.id).then(e=>I(e.runs)),X())}).catch(e=>B(String(e)))},700);return()=>window.clearInterval(e)},[L,Y]);let Z=(0,k.useCallback)(async()=>{H(!0),B(``);try{let e=U&&[`recording`,`paused`].includes(U.state),t=G;if(!e){let e=await T.recordingAvailability();if(e.endpoints.length===1?t=e.endpoints[0].endpointId:e.endpoints.some(e=>e.endpointId===t)||(t=void 0),K(t),!t){J(e);return}}let n=await T.recording(e?`finish`:`start`,t);W(n.value),K(n.endpointId),J(void 0)}catch(e){let t=e.body;t?.code&&[`connect_required`,`update_required`,`choose_browser`].includes(t.code)?J({state:t.code,endpoints:t.endpoints??[]}):B(e instanceof Error?e.message:String(e))}finally{H(!1)}},[U,G]),te=(0,k.useCallback)(async()=>{let e=await T.recordingAvailability();J(e),K(t=>e.endpoints.length===1?e.endpoints[0].endpointId:e.endpoints.some(e=>e.endpointId===t)?t:void 0)},[]);(0,k.useEffect)(()=>{if(!q)return;let e=!1,t=window.setInterval(()=>{T.recordingAvailability().then(t=>{e||(J(t),K(e=>t.endpoints.length===1?t.endpoints[0].endpointId:t.endpoints.some(t=>t.endpointId===e)?e:void 0))}).catch(()=>void 0)},3e3);return()=>{e=!0,window.clearInterval(t)}},[!!q]),(0,k.useEffect)(()=>{if(!U||U.automationId)return;let e=!1,t=window.setInterval(()=>{T.recording(`status`,G).then(async t=>{let n=t.value.find(e=>e.id===U.id);!e&&n&&(W(n),n.automationId&&(await X(),e||v(n.automationId)))}).catch(t=>{e||B(String(t))})},1500);return()=>{e=!0,window.clearInterval(t)}},[U,G,X]);let Q=(0,k.useCallback)(e=>{n(`/chat/new?draft=${encodeURIComponent(e)}`)},[n]),ne=(0,k.useMemo)(()=>(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[z&&(0,A.jsx)(`span`,{role:`alert`,className:`max-w-64 truncate text-xs text-red-600`,title:z,children:z}),U?.state===`stopped`&&!U.automationId&&(0,A.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:U.error||t.syncing}),(0,A.jsxs)(m,{variant:`secondary`,disabled:V,onClick:()=>void Z(),children:[(0,A.jsx)(y,{className:`size-4`}),U&&[`recording`,`paused`].includes(U.state)?t.finishRecording:t.record]}),(0,A.jsxs)(m,{onClick:()=>Q(t.createPrompt),children:[(0,A.jsx)(r,{className:`size-4`}),t.create]})]}),[Q,t,V,Z,U,z]);(0,k.useLayoutEffect)(()=>(i({startExtra:null,main:(0,A.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),end:ne}),()=>s()),[s,ne,i,t.title]);let re=async()=>{if(Y){H(!0);try{await T.setEnabled(Y.id,!Y.enabled),await X()}catch(e){B(String(e))}finally{H(!1)}}},ie=async()=>{if(Y){if(!E(Y,C)){B(t.required);return}H(!0);try{let{run:e}=await T.run(Y.id,C);R(e),B(``)}catch(e){B(String(e))}finally{H(!1)}}},ae=async()=>{if(!(!Y||!window.confirm(t.confirmDelete))){H(!0);try{await T.remove(Y.id),v(void 0),I([]),await X()}catch(e){B(String(e))}finally{H(!1)}}},$=q&&(0,A.jsx)(j,{availability:q,endpointId:G,recordingBusy:V,onSelect:K,onRefresh:te,onStart:()=>void Z(),onClose:()=>J(void 0)});return u===null?(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel px-4 pb-4 pt-3 sm:px-6 sm:pb-6 lg:pt-4`,children:[$,(0,A.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,A.jsx)(h,{className:`h-[420px] rounded-xl`}),(0,A.jsx)(h,{className:`h-[420px] rounded-xl`})]})]}):u.length===0?(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel px-4 pb-4 pt-3 sm:px-6 sm:pb-6 lg:pt-4`,children:[$,(0,A.jsxs)(`div`,{className:`m-auto max-w-md py-12 text-center`,children:[(0,A.jsx)(r,{className:`mx-auto size-10 text-accent`}),(0,A.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-fg`,children:t.emptyTitle}),(0,A.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:t.emptyBody}),(0,A.jsxs)(m,{className:`mt-5`,onClick:()=>Q(t.createPrompt),children:[(0,A.jsx)(r,{className:`size-4`}),t.create]})]})]}):(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel px-4 pb-4 pt-3 sm:px-6 sm:pb-6 lg:pt-4`,children:[$,(0,A.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,A.jsx)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-2`,children:u.map(e=>(0,A.jsxs)(`button`,{onClick:()=>v(e.id),className:`mb-1 w-full rounded-lg p-3 text-left ${p===e.id?`bg-accent-soft text-accent-fg`:`hover:bg-surface-hover`}`,children:[(0,A.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,A.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-xs text-fg-muted`,children:[e.enabled?(0,A.jsx)(_,{className:`size-3.5 text-emerald-600`}):(0,A.jsx)(a,{className:`size-3.5`}),e.enabled?t.enabled:t.paused]})]},e.id))}),Y&&(0,A.jsxs)(`main`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Y.name}),Y.description&&(0,A.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:Y.description}),(0,A.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[(0,A.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2.5 py-1 text-fg-muted`,children:t[Y.risk]}),(0,A.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2.5 py-1 text-fg-muted`,children:Y.verified?t.verified:t.saved}),Y.domains.map(e=>(0,A.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-surface-inset px-2.5 py-1 text-fg-muted`,children:[(0,A.jsx)(S,{className:`size-3`}),e]},e))]})]}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsxs)(m,{variant:`secondary`,disabled:V,onClick:()=>void re(),children:[Y.enabled?(0,A.jsx)(a,{className:`size-4`}):(0,A.jsx)(_,{className:`size-4`}),Y.enabled?t.pause:t.enable]}),(0,A.jsxs)(m,{variant:`secondary`,onClick:()=>Q(t.editPrompt.replace(`{name}`,Y.name).replace(`{id}`,Y.id)),children:[(0,A.jsx)(c,{className:`size-4`}),t.edit]})]})]}),(0,A.jsxs)(`section`,{className:`mt-7 max-w-xl`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.inputs}),Object.keys(Y.inputs).length===0?(0,A.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.noInputs}):(0,A.jsx)(`div`,{className:`mt-3`,children:(0,A.jsx)(O,{automation:Y,values:C,language:e,onChange:w})}),(0,A.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,A.jsxs)(m,{variant:`primary`,disabled:!Y.enabled||V||!!(L&&!N(L.status)),onClick:()=>void ie(),children:[(0,A.jsx)(l,{className:`size-4`}),t.run]}),L&&!N(L.status)&&(0,A.jsxs)(m,{variant:`secondary`,onClick:()=>void T.cancel(L.id),children:[(0,A.jsx)(g,{className:`size-4`}),t.stop]})]}),z&&(0,A.jsx)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-300`,children:z})]}),L&&(0,A.jsxs)(`section`,{className:`mt-7 rounded-xl border border-edge bg-surface-inset p-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,A.jsx)(o,{className:`size-4`}),L.businessOutcome===`verified`?t.verified:t[L.status]]}),L.businessOutcome===`unknown`&&(0,A.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.unknown}),L.error&&(0,A.jsx)(`p`,{className:`mt-2 text-sm text-red-700 dark:text-red-300`,children:L.error}),L.status===`succeeded`&&L.result!==void 0&&(0,A.jsxs)(`div`,{className:`mt-3`,children:[(0,A.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.result}),(0,A.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-fg`,children:P(L.result)})]})]}),(0,A.jsxs)(`section`,{className:`mt-8`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.history}),(0,A.jsx)(`div`,{className:`mt-2 divide-y divide-edge`,children:F.slice(0,10).map(e=>(0,A.jsxs)(`button`,{className:`flex w-full items-center justify-between gap-3 py-3 text-left text-sm hover:text-accent`,onClick:()=>R(e),children:[(0,A.jsx)(`span`,{children:t[e.status]}),(0,A.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,A.jsx)(`div`,{className:`mt-8 border-t border-edge pt-4`,children:(0,A.jsxs)(m,{variant:`ghost`,className:`text-red-700 dark:text-red-300`,disabled:V,onClick:()=>void ae(),children:[(0,A.jsx)(x,{className:`size-4`}),t.delete]})})]})]})]})}export{F 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"./popover-select-BgSdSbCL.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./download-Dk-ZjtO6.js";import{t as l}from"./external-link-DjqjBmc3.js";import{t as u}from"./eye-CABVeTq0.js";import{t as d}from"./folder-open-CyzJ19I9.js";import{t as f}from"./loader-circle-CifKLtgG.js";import{t as p}from"./messages-Cn25s55n.js";import{a as m,c as h,n as g,r as _}from"./locale-store-DSsLH7JO.js";import{i as v}from"./vendor-swr-BIWyz7Rc.js";import{t as y}from"./button-CS04eWY9.js";import{n as b,r as x}from"./gateway-config-swr-siY2J0hx.js";import{t as S}from"./skeleton-BwbyijEw.js";import{n as C,t as w}from"./settings-form-draft-Dy10ldo8.js";import{B as T,H as ee,L as te,R as E,Uo as D,V as O,Zo as ne,cc as k,ho as re,ls as ie,qs as A,vs as j,z as ae}from"./index-DU5FmDQh.js";import{t as oe}from"./number-input-DDeqHK-G.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 F,t as se}from"./use-autosave-CZzYhcAl.js";import{t as I}from"./settings-advanced-gate-CmNe5RJ4.js";var L=n(),R=e(t(),1);function z(e){let[t,n]=(0,R.useState)(!1),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(null),[s,c]=(0,R.useState)(null),l=(0,R.useRef)(null);return{running:t,cancelling:r,progress:a,error:s,install:(0,R.useCallback)(async()=>{if(l.current)return;let t=new AbortController;l.current=t,n(!0),o(null),c(null);try{let n=await T(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,R.useCallback)(async()=>{l.current&&(i(!0),await te().catch(()=>{}),l.current.abort())},[])}}var B=r(),V={extension:`Chrome extension`,playwright:`Playwright Chromium`,cdp:`CDP`,remote:`Remote browser`};function ce(e){let{enabled:t,driverKind:n,autosaveStatus:r,zh:a}=e,o=i(),c=v(t?[`browser-control-status`,n]:null,E,{revalidateOnFocus:!0,refreshInterval:n===`extension`?3e3:0}),[l,u]=(0,R.useState)(null),[d,p]=(0,R.useState)(null),[m,h]=(0,R.useState)(null),g=r===`dirty`||r===`saving`;(0,R.useEffect)(()=>{r===`saved`&&c.mutate()},[r,c.mutate]);let _=(0,R.useCallback)(async(e,t,n)=>{u(e),p(null),h(null);try{await t(),h(n),await c.mutate()}catch(e){p(e instanceof Error?e.message:String(e))}finally{u(null)}},[c.mutate]),b=z((0,R.useCallback)(()=>{h(a?`Chromium 已安装,可以开始连接测试。`:`Chromium is installed and ready to test.`),c.mutate()},[c.mutate,a])),x=c.data?.payload,C=x?.driverKind===n,w=t?g||!C?`syncing`:x?.state:`disabled`;return(0,B.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(w===`ready`?s:w===`syncing`?f:re,{className:`size-4 shrink-0 ${w===`ready`?`text-success`:w===`syncing`?`animate-spin text-fg-muted`:w===`disabled`?`text-fg-subtle`:`text-warning`}`}),(0,B.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a?`浏览器就绪状态`:`Browser readiness`}),(0,B.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs ${w===`ready`?`bg-success-soft text-success`:w===`disabled`?`bg-surface-hover text-fg-muted`:`bg-warning-soft text-warning`}`,children:w===`ready`?a?`已就绪`:`Ready`:w===`disabled`?a?`未启用`:`Disabled`:w===`syncing`?a?`正在应用配置`:`Applying configuration`:a?`需要处理`:`Needs attention`})]}),(0,B.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[V[n],x?.detail&&C?` · ${x.detail}`:``]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsxs)(y,{variant:`ghost`,className:`h-9`,onClick:()=>void c.mutate(),disabled:c.isValidating,children:[(0,B.jsx)(D,{className:`size-3.5 ${c.isValidating?`animate-spin`:``}`}),a?`刷新`:`Refresh`]}),(0,B.jsxs)(y,{variant:`secondary`,className:`h-9`,disabled:!t||g||l!==null||b.running,onClick:()=>void _(`test`,ee,a?`连接测试成功。`:`Connection test passed.`),children:[l===`test`?(0,B.jsx)(f,{className:`size-3.5 animate-spin`}):(0,B.jsx)(ne,{className:`size-3.5`}),a?`测试连接`:`Test connection`]})]})]}),t&&c.isLoading?(0,B.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-3`,children:[(0,B.jsx)(S,{className:`h-12`}),(0,B.jsx)(S,{className:`h-12`}),(0,B.jsx)(S,{className:`h-12`})]}):null,t&&c.error?(0,B.jsx)(W,{tone:`error`,children:c.error instanceof Error?c.error.message:String(c.error)}):null,d||b.error?(0,B.jsx)(W,{tone:`error`,children:d??b.error}):null,m?(0,B.jsx)(W,{tone:`success`,children:m}):null,t&&n===`extension`&&C?(0,B.jsx)(H,{status:x?.driverStatus,zh:a,busy:l,run:_,onConnectRemote:()=>o(`/settings/devices?startDevicePairing=browser`)}):null,t&&n===`playwright`&&C?(0,B.jsx)(de,{status:x?.driverStatus,zh:a,installer:b}):null,t&&n===`cdp`?(0,B.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,B.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 H(e){let t=(0,L.c)(70),{status:n,zh:r,busy:i,run:a,onConnectRemote:o}=e,s=n?.artifacts,u=r?`扩展文件`:`Extension files`,p=s?.installed===!0,m=s?.installed?r?`已安装`:`Installed`:r?`未安装或需更新`:`Install or update required`,h;t[0]!==u||t[1]!==p||t[2]!==m?(h=(0,B.jsx)(U,{label:u,ok:p,value:m}),t[0]=u,t[1]=p,t[2]=m,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`),b;t[4]!==g||t[5]!==_||t[6]!==v?(b=(0,B.jsx)(U,{label:g,ok:_,value:v}),t[4]=g,t[5]=_,t[6]=v,t[7]=b):b=t[7];let x=r?`安全通道`:`Secure channel`,S=n?.transport===`gateway-realtime`,C=n?.transport===`gateway-realtime`?`Gateway Realtime`:r?`不可用`:`Unavailable`,w;t[8]!==C||t[9]!==x||t[10]!==S?(w=(0,B.jsx)(U,{label:x,ok:S,value:C}),t[8]=C,t[9]=x,t[10]=S,t[11]=w):w=t[11];let T=r?`Chrome 连接`:`Chrome connection`,ee=n?.connected===!0,te=n?.connected?r?`已连接`:`Connected`:n?.socketConnected?r?`需要重新加载扩展`:`Reload extension`:r?`等待扩展连接`:`Waiting for extension`,E;t[12]!==T||t[13]!==ee||t[14]!==te?(E=(0,B.jsx)(U,{label:T,ok:ee,value:te}),t[12]=T,t[13]=ee,t[14]=te,t[15]=E):E=t[15];let D;t[16]!==w||t[17]!==E||t[18]!==h||t[19]!==b?(D=(0,B.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:[h,b,w,E]}),t[16]=w,t[17]=E,t[18]=h,t[19]=b,t[20]=D):D=t[20];let O=s?.extensionDir??`Gateway Realtime`,k;t[21]===O?k=t[22]:(k=(0,B.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:O}),t[21]=O,t[22]=k);let re=s?.installed?`secondary`:`primary`,ie=i!==null,A;t[23]!==s?.installed||t[24]!==a||t[25]!==r?(A=()=>void a(`extension-install`,()=>ae(!!s?.installed),r?`扩展文件已准备好。`:`Extension files are ready.`),t[23]=s?.installed,t[24]=a,t[25]=r,t[26]=A):A=t[26];let j;t[27]===i?j=t[28]:(j=i===`extension-install`?(0,B.jsx)(f,{className:`size-3.5 animate-spin`}):(0,B.jsx)(c,{className:`size-3.5`}),t[27]=i,t[28]=j);let oe=s?.installed?r?`刷新扩展文件`:`Refresh files`:r?`安装扩展文件`:`Install extension`,M;t[29]!==re||t[30]!==ie||t[31]!==A||t[32]!==j||t[33]!==oe?(M=(0,B.jsxs)(y,{className:`h-9`,variant:re,disabled:ie,onClick:A,children:[j,oe]}),t[29]=re,t[30]=ie,t[31]=A,t[32]=j,t[33]=oe,t[34]=M):M=t[34];let N=!s?.installed||i!==null,P;t[35]!==a||t[36]!==r?(P=()=>void a(`extension-open`,ue,r?`已打开 Chrome 扩展页。`:`Chrome extensions opened.`),t[35]=a,t[36]=r,t[37]=P):P=t[37];let F;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,B.jsx)(l,{className:`size-3.5`}),t[38]=F):F=t[38];let se=r?`打开扩展页`:`Open extensions`,I;t[39]!==N||t[40]!==P||t[41]!==se?(I=(0,B.jsxs)(y,{className:`h-9`,variant:`secondary`,disabled:N,onClick:P,children:[F,se]}),t[39]=N,t[40]=P,t[41]=se,t[42]=I):I=t[42];let R=!s?.installed||i!==null,z;t[43]!==a||t[44]!==r?(z=()=>void a(`extension-folder`,le,r?`已打开扩展目录。`:`Extension folder opened.`),t[43]=a,t[44]=r,t[45]=z):z=t[45];let V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,B.jsx)(d,{className:`size-3.5`}),t[46]=V):V=t[46];let ce=r?`打开扩展目录`:`Open folder`,H;t[47]!==R||t[48]!==z||t[49]!==ce?(H=(0,B.jsxs)(y,{className:`h-9`,variant:`ghost`,disabled:R,onClick:z,children:[V,ce]}),t[47]=R,t[48]=z,t[49]=ce,t[50]=H):H=t[50];let de=i!==null,W;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,B.jsx)(ne,{className:`size-3.5`}),t[51]=W):W=t[51];let fe=r?`连接远程 Chrome`:`Connect remote Chrome`,G;t[52]!==o||t[53]!==de||t[54]!==fe?(G=(0,B.jsxs)(y,{className:`h-9`,variant:`secondary`,disabled:de,onClick:o,children:[W,fe]}),t[52]=o,t[53]=de,t[54]=fe,t[55]=G):G=t[55];let K;t[56]!==M||t[57]!==I||t[58]!==H||t[59]!==G?(K=(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[M,I,H,G]}),t[56]=M,t[57]=I,t[58]=H,t[59]=G,t[60]=K):K=t[60];let q;t[61]!==n?.connected||t[62]!==n?.socketConnected||t[63]!==r?(q=n?.connected?null:(0,B.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]=q):q=t[64];let J;return t[65]!==D||t[66]!==k||t[67]!==K||t[68]!==q?(J=(0,B.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base/45 p-4`,children:[D,k,K,q]}),t[65]=D,t[66]=k,t[67]=K,t[68]=q,t[69]=J):J=t[69],J}function le(){return O(`folder`)}function ue(){return O(`chrome`)}function de(e){let t=(0,L.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,B.jsx)(U,{label:`Chromium`,ok:a,value:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let l;t[3]===n?l=t[4]:(l=n?.executablePath?(0,B.jsx)(`p`,{className:`mt-2 break-all text-xs text-fg-subtle`,children:n.executablePath}):null,t[3]=n,t[4]=l);let u;t[5]===i.progress?u=t[6]:(u=i.progress?(0,B.jsxs)(`div`,{className:`mt-3`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-xs text-fg-muted`,children:[(0,B.jsx)(`span`,{children:i.progress.message??i.progress.phase}),(0,B.jsx)(`span`,{children:i.progress.percent==null?``:`${Math.round(i.progress.percent)}%`})]}),(0,B.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,B.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`,p;t[7]===i?p=t[8]:(p=()=>void i.install(),t[7]=i,t[8]=p);let m;t[9]===i.running?m=t[10]:(m=i.running?(0,B.jsx)(f,{className:`size-3.5 animate-spin`}):(0,B.jsx)(c,{className:`size-3.5`}),t[9]=i.running,t[10]=m);let h=n?.installed?r?`重新安装 Chromium`:`Reinstall Chromium`:r?`安装 Chromium`:`Install Chromium`,g;t[11]!==i.running||t[12]!==d||t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,B.jsxs)(y,{variant:d,className:`h-9`,disabled:i.running,onClick:p,children:[m,h]}),t[11]=i.running,t[12]=d,t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16];let _;t[17]!==i||t[18]!==r?(_=i.running?(0,B.jsx)(y,{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,B.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[g,_]}),t[20]=_,t[21]=g,t[22]=v):v=t[22];let b;return t[23]!==v||t[24]!==s||t[25]!==l||t[26]!==u?(b=(0,B.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base/45 p-4`,children:[s,l,u,v]}),t[23]=v,t[24]=s,t[25]=l,t[26]=u,t[27]=b):b=t[27],b}function U(e){let t=(0,L.c)(11),{label:n,ok:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,B.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,B.jsx)(`span`,{className:s}),t[2]=s,t[3]=c);let l;t[4]!==o||t[5]!==c||t[6]!==i?(l=(0,B.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,B.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 W(e){let t=(0,L.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,B.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 fe(e){let t=(0,L.c)(36),{sectionId:n,vm:r,children:i}=e,a=g(G),o;t[0]===a?o=t[1]:(o=p(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,B.jsx)(k,{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,B.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,B.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,B.jsx)(N,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,B.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,B.jsx)(N,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,B.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,B.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,B.jsx)(y,{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,B.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,B.jsx)(F,{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,B.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,B.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 m;t[29]===i?m=t[30]:(m=(0,B.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:i}),t[29]=i,t[30]=m);let h;return t[31]!==d||t[32]!==f||t[33]!==m||t[34]!==r.onBlurCapture?(h=(0,B.jsxs)(N,{gap:`gap-6`,onBlurCapture:r.onBlurCapture,children:[d,f,m]}),t[31]=d,t[32]=f,t[33]=m,t[34]=r.onBlurCapture,t[35]=h):h=t[35],h}function G(e){return e.language}var K={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:`allow`,uploads:`allow`,consequentialActions:`allow`};function q(e){let t=Y(Y(e).browser),n=Y(t.driver),r=Y(t.observation),i=Y(t.limits),a=Y(t.security),o=n.kind;return{...K,enabled:t.enabled!==!1,driverKind:o===`playwright`||o===`cdp`||o===`remote`?o:`extension`,headless:n.headless===!0,executablePath:X(n.executablePath,``),cdpEndpoint:X(n.endpoint,K.cdpEndpoint),remoteProvider:n.provider===`browser-use`?`browser-use`:`browserbase`,remoteApiKey:X(n.apiKey,``),remoteProjectId:X(n.projectId,``),remoteRegion:X(n.region,``),maxNodes:Z(r.maxNodes,K.maxNodes),maxCharacters:Z(r.maxCharacters,K.maxCharacters),visualFallback:r.visualFallback!==!1,actionTimeoutMs:Z(i.actionTimeoutMs,K.actionTimeoutMs),sessionTimeoutMs:Z(i.sessionTimeoutMs,K.sessionTimeoutMs),maxSequenceLength:Z(i.maxSequenceLength,K.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 J(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 pe(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 me(e){await m(_(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:J(e)})}),b()}function Y(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function X(e,t){return typeof e==`string`?e:t}function Z(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function he(e){return e===`deny`?`deny`:`allow`}var ge=w();function _e(e){let t=!!h(e=>e.conversationId),[n,r]=(0,R.useReducer)(ge,{form:null,baseline:null}),i=n.form,a=n.baseline,o=(0,R.useRef)(!1),s=(0,R.useRef)(i);s.current=i;let c=(0,R.useRef)(null),{data:l,error:u,isLoading:d,mutate:f}=x(t);C({enabled:t,parsed:(0,R.useMemo)(()=>l?.payload?.config===void 0?null:q(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,g=(0,R.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]),_=(0,R.useCallback)(e=>{o.current=!0,r({type:`patch`,patch:e})},[]),v=se({value:i,dirty:g,onSave:(0,R.useCallback)(async t=>{try{await me(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:pe});return{hasToken:t,loading:p,fetchError:m,form:i,update:_,autosaveStatus:v.status,error:v.error,onBlurCapture:v.onBlurCapture,mutate:f}}var ve=[`extension`,`playwright`,`cdp`,`remote`];function ye(){let e=(0,L.c)(29),t=g(be),n;e[0]===t?n=e[1]:(n=p(t),e[0]=t,e[1]=n);let r=_e(n.agentSettings),i=r.form,s=t===`zh`,[c]=a(),l=(0,R.useRef)(!1),d;e[2]!==i||e[3]!==c||e[4]!==r?(d=()=>{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]=d):d=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,R.useEffect)(d,f);let m=s?`Chrome 扩展(推荐)`:`Chrome extension (recommended)`,h;e[10]===m?h=e[11]:(h={value:`extension`,label:m},e[10]=m,e[11]=h);let _;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(_={value:`playwright`,label:`Playwright Chromium`},e[12]=_):_=e[12];let v=s?`CDP 已有浏览器`:`Existing browser over CDP`,y;e[13]===v?y=e[14]:(y={value:`cdp`,label:v},e[13]=v,e[14]=y);let b=s?`远程浏览器`:`Remote browser`,x;e[15]===b?x=e[16]:(x={value:`remote`,label:b},e[15]=b,e[16]=x);let S;e[17]!==h||e[18]!==y||e[19]!==x?(S=[h,_,y,x],e[17]=h,e[18]=y,e[19]=x,e[20]=S):S=e[20];let C=S,w;e[21]!==C||e[22]!==i||e[23]!==r||e[24]!==s?(w=i?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ce,{enabled:i.enabled,driverKind:i.driverKind,autosaveStatus:r.autosaveStatus,zh:s}),(0,B.jsxs)(Se,{title:s?`运行方式`:`Connection`,icon:(0,B.jsx)(ie,{className:`size-4`}),children:[(0,B.jsx)(we,{label:s?`启用浏览器控制`:`Enable browser control`,checked:i.enabled,onChange:e=>r.update({enabled:e})}),(0,B.jsx)(Q,{label:s?`浏览器连接`:`Browser connection`,children:(0,B.jsx)(o,{value:i.driverKind,options:C,placeholder:s?`选择连接方式`:`Choose a connection`,allowEmpty:!1,onChange:e=>r.update({driverKind:e})})}),(0,B.jsx)(xe,{kind:i.driverKind,zh:s}),i.driverKind===`playwright`?(0,B.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-inset p-4`,children:[(0,B.jsx)(we,{label:s?`无头模式`:`Headless mode`,description:s?`后台运行,不显示浏览器窗口。关闭后可观察智能体的操作过程。`:`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,B.jsx)($,{label:s?`Chromium 可执行文件(可选)`:`Chromium executable (optional)`,description:s?`留空时使用由 xopc 安装的 Chromium。`:`Leave empty to use Chromium installed by xopc.`,value:i.executablePath,onChange:e=>r.update({executablePath:e})})]}):null,i.driverKind===`cdp`?(0,B.jsx)(`div`,{className:`rounded-lg bg-surface-inset p-4`,children:(0,B.jsx)($,{label:`CDP endpoint`,description:s?`例如 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,B.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-inset p-4`,children:[(0,B.jsx)(Q,{label:s?`服务商`:`Provider`,children:(0,B.jsx)(o,{value:i.remoteProvider,options:[{value:`browserbase`,label:`Browserbase`},{value:`browser-use`,label:`Browser Use`}],placeholder:s?`选择服务商`:`Choose a provider`,allowEmpty:!1,onChange:e=>r.update({remoteProvider:e})})}),(0,B.jsx)($,{label:`API key`,type:`password`,autoComplete:`off`,value:i.remoteApiKey,onChange:e=>r.update({remoteApiKey:e})}),(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,B.jsx)($,{label:`Project ID`,value:i.remoteProjectId,onChange:e=>r.update({remoteProjectId:e})}),(0,B.jsx)($,{label:`Region`,value:i.remoteRegion,onChange:e=>r.update({remoteRegion:e})})]})]}):null]}),(0,B.jsx)(I,{children:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(Se,{title:s?`页面理解`:`Page understanding`,icon:(0,B.jsx)(u,{className:`size-4`}),children:[(0,B.jsx)(we,{label:s?`需要时附加截图`:`Attach screenshots when needed`,checked:i.visualFallback,onChange:e=>r.update({visualFallback:e})}),(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(Ce,{label:s?`语义节点上限`:`Semantic node limit`,description:`20–500`,min:20,max:500,value:i.maxNodes,onChange:e=>r.update({maxNodes:e})}),(0,B.jsx)(Ce,{label:s?`文本字符上限`:`Text character limit`,description:`1,000–50,000`,min:1e3,max:5e4,step:1e3,value:i.maxCharacters,onChange:e=>r.update({maxCharacters:e})})]})]}),(0,B.jsx)(Se,{title:s?`执行限制`:`Execution limits`,icon:(0,B.jsx)(A,{className:`size-4`}),children:(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,B.jsx)(Ce,{label:s?`操作超时(毫秒)`:`Action timeout (ms)`,min:1e3,max:12e4,step:1e3,value:i.actionTimeoutMs,onChange:e=>r.update({actionTimeoutMs:e})}),(0,B.jsx)(Ce,{label:s?`会话超时(毫秒)`:`Session timeout (ms)`,min:6e4,max:36e5,step:6e4,value:i.sessionTimeoutMs,onChange:e=>r.update({sessionTimeoutMs:e})}),(0,B.jsx)(Ce,{label:s?`批量步骤上限`:`Sequence step limit`,min:1,max:10,value:i.maxSequenceLength,onChange:e=>r.update({maxSequenceLength:e})})]})}),(0,B.jsxs)(Se,{title:s?`访问策略`:`Access policies`,icon:(0,B.jsx)(j,{className:`size-4`}),children:[(0,B.jsx)($,{label:s?`允许访问的私网主机`:`Allowed private hosts`,description:s?`每行一个主机名或 IP,不支持通配符。`:`One hostname or IP per line. Wildcards are not supported.`,multiline:!0,value:i.allowedPrivateHosts,onChange:e=>r.update({allowedPrivateHosts:e})}),(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,B.jsx)(Te,{zh:s,label:s?`跨域导航`:`Cross-domain navigation`,value:i.crossDomainNavigation,onChange:e=>r.update({crossDomainNavigation:e})}),(0,B.jsx)(Te,{zh:s,label:s?`高影响动作`:`Consequential actions`,value:i.consequentialActions,onChange:e=>r.update({consequentialActions:e})}),(0,B.jsx)(Te,{zh:s,label:s?`文件上传`:`File uploads`,value:i.uploads,onChange:e=>r.update({uploads:e})})]})]})]})})]}):null,e[21]=C,e[22]=i,e[23]=r,e[24]=s,e[25]=w):w=e[25];let T;return e[26]!==w||e[27]!==r?(T=(0,B.jsx)(fe,{sectionId:`agent-browser`,vm:r,children:w}),e[26]=w,e[27]=r,e[28]=T):T=e[28],T}function be(e){return e.language}function xe(e){let t=(0,L.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,B.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,L.c)(17),{title:n,description:r,icon:i,children:a}=e,o;t[0]===i?o=t[1]:(o=(0,B.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,B.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,B.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,B.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,B.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,B.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,B.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 Q(e){let t=(0,L.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,B.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,B.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,B.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 $(e){let t=(0,L.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,B.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,B.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,B.jsx)(Q,{label:n,description:r,children:d}),t[6]=r,t[7]=n,t[8]=d,t[9]=f):f=t[9],f}function Ce(e){let t=(0,L.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,B.jsx)(oe,{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,B.jsx)(Q,{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,L.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,B.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,B.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,B.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,B.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,B.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,L.c)(17),{zh:n,label:r,value:i,onChange:a}=e,s=n?`允许`:`Allow`,c;t[0]===s?c=t[1]:(c={value:`allow`,label:s},t[0]=s,t[1]=c);let l=n?`拒绝`:`Deny`,u;t[2]===l?u=t[3]:(u={value:`deny`,label:l},t[2]=l,t[3]=u);let d;t[4]!==c||t[5]!==u?(d=[c,u],t[4]=c,t[5]=u,t[6]=d):d=t[6];let f=d,p=n?`选择策略`:`Choose a policy`,m;t[7]===a?m=t[8]:(m=e=>a(e),t[7]=a,t[8]=m);let h;t[9]!==f||t[10]!==p||t[11]!==m||t[12]!==i?(h=(0,B.jsx)(o,{value:i,options:f,placeholder:p,allowEmpty:!1,onChange:m}),t[9]=f,t[10]=p,t[11]=m,t[12]=i,t[13]=h):h=t[13];let g;return t[14]!==r||t[15]!==h?(g=(0,B.jsx)(Q,{label:r,children:h}),t[14]=r,t[15]=h,t[16]=g):g=t[16],g}export{ye as AgentBrowserSettingsPage};
|
|
@@ -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"./chevron-right-BweFrslA.js";import{n as d,r as f,t as p}from"./popover-select-BgSdSbCL.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./circle-dashed-8qMD7gHf.js";import{t as g}from"./cloud-C4-yfnnk.js";import{t as _}from"./external-link-DjqjBmc3.js";import{t as v}from"./secret-input-D93UrW4C.js";import{t as y}from"./eye-CABVeTq0.js";import{t as b}from"./loader-circle-CifKLtgG.js";import{t as x}from"./mic-CuUb7zc-.js";import{t as S}from"./pencil-DmIY3Oa-.js";import{t as C}from"./play-kxZvpBg8.js";import{t as w}from"./plus-Q2yW6OE7.js";import{t as T}from"./settings-2-D-csvaET.js";import{t as E}from"./x-B_N4OPjy.js";import{t as D}from"./messages-Cn25s55n.js";import{t as O}from"./cn-JdwAhgNB.js";import{a as k,c as A,i as j,n as M,r as N}from"./locale-store-DSsLH7JO.js";import{a as P,i as F,n as I,o as L,r as R,s as ee,t as z}from"./dist-BGTk37IG.js";import{i as B}from"./vendor-swr-BIWyz7Rc.js";import{t as V}from"./button-CS04eWY9.js";import{n as te,t as ne}from"./interaction-BdhHBbYa.js";import{n as re,r as H}from"./gateway-config-swr-siY2J0hx.js";import{a as U,o as ie,s as ae}from"./form-field-width-DJw_jULe.js";import{n as W}from"./is-masked-secret-DOkL5b_X.js";import{t as G}from"./skeleton-BwbyijEw.js";import{i as K,o as q}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as J}from"./electron-env-Dit0bHgy.js";import{n as Y,t as oe}from"./settings-form-draft-Dy10ldo8.js";import{i as se,r as X,t as ce}from"./models-hub-cache-DaqiLHPe.js";import{At as le,Ct as ue,Dn as de,Do as fe,Dt as Z,Et as pe,Fo as me,Ft as he,Ht as ge,It as _e,Lt as ve,Mo as ye,Nt as be,Ot as xe,Ps as Se,Pt as Ce,Rc as we,Rs as Te,Rt as Ee,Sn as De,St as Oe,Tt as ke,Uo as Ae,Ut as je,Vt as Me,Xo as Ne,Xr as Pe,_a as Fe,_s as Ie,_t as Le,ao as Re,bt as ze,ga as Be,go as Ve,gt as He,ha as Ue,ho as We,ht as Ge,jt as Ke,kt as qe,li as Je,ma as Ye,na as Xe,oa as Ze,pa as Qe,ra as $e,sa as et,so as tt,ta as nt,ua as rt,va as it,vt as at,wt as ot,xt as st,ya as ct,yt as lt,zc as ut,zt as dt}from"./index-DU5FmDQh.js";import{t as ft}from"./page-tabs-D2xpUV26.js";import{t as pt}from"./number-input-DDeqHK-G.js";import{n as mt,r as ht}from"./settings-page-layout-X1x-2Cp9.js";import{n as gt,t as _t}from"./settings-form-section-exRhP9xn.js";import{t as vt}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as yt,t as bt}from"./use-autosave-CZzYhcAl.js";import{c as xt,d as St,i as Ct,l as wt,n as Tt,o as Et,r as Dt,s as Ot,t as kt}from"./voice-config-api-BtWFziQc.js";import{t as At}from"./voice-api-key-field-CIIGmtHR.js";import{t as jt}from"./settings-advanced-gate-CmNe5RJ4.js";import{a as Mt,i as Nt,n as Pt,o as Ft,r as It,t as Lt}from"./image-generation-api-CeDrok06.js";import{t as Rt}from"./xopc-cloud-account-card-D7Rtu5eI.js";var zt=n(),Q=e(t(),1),$=r(),Bt={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 必须使用“名称: 值”格式,每行一个。`}},Vt=`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 Ht(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 Ut(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 Wt({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=Bt[i],[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`bearer`),[g,_]=(0,Q.useState)(`x-api-key`),[x,S]=(0,Q.useState)(``),[C,T]=(0,Q.useState)(``),[D,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(`/images/generations`),[M,N]=(0,Q.useState)(`/images/edits`),[B,te]=(0,Q.useState)(``),[ne,re]=(0,Q.useState)(``),[H,U]=(0,Q.useState)([Ht()]),[ie,ae]=(0,Q.useState)(``),[G,J]=(0,Q.useState)(),[Y,oe]=(0,Q.useState)(!1),[se,X]=(0,Q.useState)(),[ce,le]=(0,Q.useState)(),[ue,de]=(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`),_(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),S(r?`••••••••••••`:``),T(t?.apiKeyUrl??``),k(t?.documentationUrl??``),j(t?.paths?.generations??`/images/generations`),N(t?.paths?.edits??`/images/edits`),te(t?.network?.allowedHosts.join(`
|
|
4
|
-
`)??``),re(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
5
|
-
`)),U(t?.models.map(Ht)??[Ht()]),ae(t?.defaultModel??``),le(void 0),J(void 0),oe(!1),X(void 0),de(void 0)},[r,e,n]);let fe=(0,Q.useMemo)(()=>H.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[H]),Z=(e,t)=>{U(n=>n.map((n,r)=>r===e?{...n,...t}:n))},pe=()=>{let e=s.trim(),t=H.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=ie||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=Ut(ne)}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()}:{},...C.trim()?{apiKeyUrl:C.trim()}:{},defaultModel:n,auth:m===`header`?{type:`header`,headerName:g.trim()}:{type:m},paths:{...A.trim()?{generations:A.trim()}:{},...M.trim()?{edits:M.trim()}:{}},...B.trim()?{network:{allowedHosts:B.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}}}))}}}},me=async()=>{let e=pe();return await Nt(e.providerId,e.input),m!==`none`&&x.trim()&&!W(x)&&await Mt(e.providerId,x.trim()),await a(e.providerId),e},he=async()=>{J(`save`),X(void 0),le(void 0);try{await me(),S(m===`none`?``:`••••••••••••`),le(o.saved)}catch(e){X(e instanceof Error?e.message:String(e))}finally{J(void 0)}},ge=async()=>{J(`test`),X(void 0),le(void 0),de(void 0);try{let e=await me();de((await Ft(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),le(o.testReady)}catch(e){X(e instanceof Error?e.message:String(e))}finally{J(void 0)}},_e=async()=>{if(n){if(!Y){oe(!0);return}J(`delete`),X(void 0);try{await Lt(n.providerId),await a(),t(!1)}catch(e){X(e instanceof Error?e.message:String(e))}finally{J(void 0)}}};return(0,$.jsx)(z,{open:e,onOpenChange:t,children:(0,$.jsxs)(L,{children:[(0,$.jsx)(P,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim`,q)}),(0,$.jsxs)(R,{className:O(`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`,K),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)(F,{className:`mt-1 text-sm text-fg-muted`,children:o.intro})]}),(0,$.jsx)(I,{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)(E,{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:Vt}),(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:Vt})]})]}),(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:Vt})]}),(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:g,onChange:e=>_(e.target.value),className:Vt})]}):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}),C.trim()?(0,$.jsxs)(`a`,{href:C.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[o.openKeyPage,(0,$.jsx)(we,{className:`size-3.5`})]}):null]}),(0,$.jsx)(v,{id:`custom-image-api-key`,value:x,onChange:e=>S(W(x)?e.replace(/^•+/,``):e),labels:{show:o.show,hide:o.hide,copy:o.copy,copied:o.copied},reveal:()=>je(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:C,onChange:e=>T(e.target.value),placeholder:`https://…`,className:Vt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.docsUrl,(0,$.jsx)(`input`,{value:D,onChange:e=>k(e.target.value),placeholder:`https://…`,className:Vt})]})]}),(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:A,onChange:e=>j(e.target.value),className:Vt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.editsPath,(0,$.jsx)(`input`,{value:M,onChange:e=>N(e.target.value),className:Vt})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.allowedHosts,(0,$.jsx)(`textarea`,{value:B,onChange:e=>te(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:ne,onChange:e=>re(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)(V,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>U(e=>[...e,Ht()]),children:[(0,$.jsx)(w,{className:`size-4`}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.defaultModel,(0,$.jsx)(p,{value:ie||fe[0]?.value||``,options:fe,placeholder:o.defaultModel,allowEmpty:!1,onChange:ae,triggerClassName:`mt-1.5 max-w-sm`})]}),H.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=>Z(t,{id:e.target.value}),placeholder:`image-1`,className:Vt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>Z(t,{name:e.target.value}),className:Vt})]})]}),(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=>Z(t,{maxCount:e.target.value}),className:Vt})]}),(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=>Z(t,{defaultCount:e.target.value}),className:Vt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>Z(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:Vt})]}),(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=>Z(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=>Z(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=>Z(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:H.length===1,onClick:()=>U(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)(Ve,{className:`size-3.5`}),o.remove]})]})]},t))]}),ue?(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)(y,{className:`size-4`}),o.testReady]}),(0,$.jsx)(`img`,{src:ue,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,ce?(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:ce}):null,se?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:se}):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)(V,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!G,onClick:()=>void _e(),children:[G===`delete`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(Ve,{className:`size-4`}),Y?o.confirmDelete:o.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(V,{variant:`secondary`,children:o.cancel})}),(0,$.jsxs)(V,{variant:`secondary`,disabled:!!G,onClick:()=>void ge(),children:[G===`test`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):null,G===`test`?o.testing:o.test]}),(0,$.jsxs)(V,{variant:`primary`,disabled:!!G,onClick:()=>void he(),children:[G===`save`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):null,G===`save`?o.saving:o.save]})]})]})]})]})})}var Gt=`••••••••••••`,Kt={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 qt(){let e=await k(N(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function Jt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function Yt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function Xt(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function Zt(e){let t=(0,zt.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(Qt),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 Qt(e){return{value:e.value,label:e.label}}function $t(){let e=(0,zt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(G,{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(en)}),(0,$.jsx)(G,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function en(e,t){return(0,$.jsx)(G,{className:`h-24 rounded-xl`},t)}function tn(){let e=M(e=>e.language),t=Kt[e],n=!!A(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,_]=(0,Q.useState)(),[y,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(),{data:O,isLoading:j,error:P,mutate:F}=B(n?N(`/api/image-generation/catalog`):null,It,{revalidateOnFocus:!1}),{data:I,isLoading:L,error:R,mutate:ee}=B(n?N(`/api/image-generation/custom-providers`):null,Pt,{revalidateOnFocus:!1}),{data:z,isLoading:te,error:ne,mutate:H}=B(n?`default-image-generation`:null,qt,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!O||!z)return;let e=Jt(z.model?.primary),t=O.find(t=>t.id===e)??O.find(e=>e.configured)??O[0];t&&(a(t.id),s(t.id===e&&Yt(z.model?.primary)||t.defaultModel),l(t.configured?Gt:``),d(Xt(t)))},[z,O]);let U=O?.find(e=>e.id===r),ie=U?U.apiKeyUrl??Z(U.id,e)[0]?.href:void 0,ae=(0,Q.useMemo)(()=>(U?.models??[]).map(e=>({value:e,label:e})),[U?.models]),G=z?.model?.primary,K=!!(U&&o&&(U.credentialMode!==`api-key`||U.configured||c.trim())&&U.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(j||L||te)return(0,$.jsx)($t,{});if(P||R||ne||!O||!I)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let q=e=>{a(e.id),s(e.defaultModel),l(e.configured?Gt:``),d(Xt(e)),_(void 0)},J=()=>{D(void 0),C(!0)},Y=()=>{let e=I.find(e=>e.providerId===U?.id);e&&(D(e),C(!0))},oe=async e=>{let[t,n]=await Promise.all([ee(),F()]);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?Gt:``),d(Xt(r)),D(t?.find(t=>t.providerId===e))}},se=async()=>{if(!(!U||!K)){h(!0),_(void 0),x(!1);try{let e=await k(N(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:U.id,modelId:o,...c.trim()&&!W(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([H(e.payload.default,{revalidate:!1}),F(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`)])),re()]),l(Gt),x(!0)}catch(e){_(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)(Te,{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)(V,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:J,children:[(0,$.jsx)(w,{className:`size-4`}),t.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:O.map(e=>{let n=e.id===r,i=e.id===Jt(G);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>q(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)(Se,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?t.configured:t.needsKey]})]},e.id)})})]}),U?(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:ae,placeholder:t.selectModel,allowEmpty:!1,onChange:s,triggerClassName:`mt-1.5`})]}),U.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(Zt,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))]}),U.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(V,{variant:`secondary`,onClick:Y,children:[(0,$.jsx)(T,{className:`size-4`}),t.manageService]})}):null,U.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}),ie?(0,$.jsxs)(`a`,{href:ie,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(we,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(v,{id:`image-generation-api-key`,value:c,onChange:e=>l(W(c)?e.replace(/^•+/,``):e),placeholder:U.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>je(U.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},U.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:U.configured?t.savedKey:t.apiKeyHint})]}):null,U.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)(ye,{className:`size-4`}),t.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:U.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(Zt,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))})]}):null,y?(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)(V,{variant:`primary`,disabled:!K||f,onClick:()=>void se(),children:[f?(0,$.jsx)(b,{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)(Wt,{open:S,onOpenChange:C,provider:E,configured:!!(E&&O.find(e=>e.id===E.providerId)?.configured),language:e,onSaved:oe})]})}function nn({disabled:e=!1}){let t=M(e=>e.language),n=t===`zh`,[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),{data:s,mutate:c,error:l}=B(N(`/api/voice/catalog`),async e=>{let t=await k(e);return Fe.parse(t.payload)}),u=n?{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`},p=async e=>{if(s){i(!0),o(``);try{let t=await k(N(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:s.revision,selection:e})}:{}});await c(Fe.parse(t.payload),!1),await re()}catch(e){o(e instanceof Error?e.message:String(e)),await c()}finally{i(!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:n?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(V,{variant:`secondary`,disabled:r||e||!s,onClick:()=>void p(),children:n?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`各设备共用此 Gateway 的模型设置,修改在下次调用生效。仅显示支持对应场景的已发布模型。`:`Devices share this gateway’s selections. Changes apply to the next call. Only published models supporting each mode are shown.`}),a||l?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a||String(l)}):null,s?Object.keys(u).map(i=>{let a=s.selections.find(e=>e.mode===i),o=s.models.filter(e=>e.voice.modes.includes(i)),c=o.find(e=>e.id===a?.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:u[i]}),(0,$.jsxs)(d,{className:`w-full`,value:a?.model??``,disabled:r||e||!o.length,onChange:e=>void p({mode:i,model:e.target.value}),children:[(0,$.jsx)(f,{value:``,disabled:!0,children:n?`选择模型`:`Choose model`}),a&&!c?(0,$.jsxs)(f,{value:a.model,disabled:!0,children:[a.model,` · `,n?`不可用`:`Unavailable`]}):null,o.map(e=>(0,$.jsx)(f,{value:e.id,children:Pe(e,t)},e.id))]}),o.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n?`暂无可用模型`:`No available model`})]}),c&&c.voice.voices.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:n?`音色`:`Voice`}),(0,$.jsx)(d,{className:`w-full`,value:a?.voice??``,disabled:r||e,onChange:e=>void p({mode:i,model:c.id,voice:e.target.value}),children:c.voice.voices.map(e=>(0,$.jsxs)(f,{value:e.id,children:[Pe(e,t),e.gender?` · ${n?e.gender===`female`?`女声`:`男声`:e.gender}`:``,e.style?` · ${e.style}`:``]},e.id))}),c.voice.voices.find(e=>e.id===(a?.voice??c.voice.defaultVoice))?.description?(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:c.voice.voices.find(e=>e.id===(a?.voice??c.voice.defaultVoice))?.description}):null]}):null]},i)}):(0,$.jsx)(G,{className:`h-48 w-full`})]})}function rn({v:e}){let t=it(e=>e.microphoneId),n=it(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)(V,{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 an({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Q.useContext)(rt)?.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 v(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 wt(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 Ue,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:ct()}),t.signal.aborted){l();return}if(s=await Be.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 Qe.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new Ye(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 y=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)(V,{type:`button`,variant:`primary`,disabled:o||r||!t||y,onClick:()=>void v(!0),children:[y?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(x,{className:`size-4`}),n?a.test:a.testInput]}),(0,$.jsxs)(V,{type:`button`,variant:`secondary`,disabled:o||r||!n||y,onClick:()=>void v(!1),children:[(0,$.jsx)(C,{className:`size-4`}),e.tts.test.play]}),y?(0,$.jsxs)(V,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`idle`)},children:[(0,$.jsx)(fe,{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)(V,{type:`button`,variant:`secondary`,onClick:()=>{_(),i?.({input:h.current,output:!0}),g(`passed`)},children:a.heard}),(0,$.jsx)(V,{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 on(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 sn(e){let t=(0,zt.c)(118),{section:n,v:r,form:i,pending:a,apiKeyLabels:o,sttProviders:s,onChange:c}=e,u=M(fn),p=r.setup,[m,h]=(0,Q.useState)(!1),g;t[0]===i?g=t[1]:(g=JSON.stringify(i),t[0]=i,t[1]=g);let _=g,v;t[2]===_?v=t[3]:(v={signature:_,input:!1,output:!1},t[2]=_,t[3]=v);let[y,b]=(0,Q.useState)(v);y.signature!==_&&b({signature:_,input:!1,output:!1});let x;t[4]!==a||t[5]!==_?(x=a?null:[`voice-realtime-status`,_],t[4]=a,t[5]=_,t[6]=x):x=t[6];let S;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!0},t[7]=S):S=t[7];let{data:C,error:w,isLoading:T}=B(x,kt,S),E;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(E=N(`/api/voice/catalog`),t[8]=E):E=t[8];let{data:D}=B(E,dn),O=i.voice.realtime,k=i.stt.provider,A=O.tts,j=A?.provider??C?.tts?.provider,P=C?.tts?.model,F;t[9]!==P||t[10]!==j?(F=j&&P?[`realtime-voices`,j,P]:null,t[9]=P,t[10]=j,t[11]=F):F=t[11];let I;t[12]!==P||t[13]!==j?(I=()=>Tt(j,P,`realtime`),t[12]=P,t[13]=j,t[14]=I):I=t[14];let L;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(L={revalidateOnFocus:!1},t[15]=L):L=t[15];let{data:R}=B(F,I,L),ee;t[16]===R?ee=t[17]:(ee=R===void 0?[]:R,t[16]=R,t[17]=ee);let z=ee,te=z,ne;t[18]===z?ne=t[19]:(ne=z.filter(un),t[18]=z,t[19]=ne);let re=ne,H=typeof i.stt.providers?.alibaba?.apiKey==`string`?i.stt.providers.alibaba.apiKey:``,U;t[20]!==H||t[21]!==s?(U=!!H||s.some(ln),t[20]=H,t[21]=s,t[22]=U):U=t[22];let ae=U,W=O.defaultEngine===`omni`,K=W?O.omni?.voice??``:A?.voice??C?.tts?.voice??``,q;t[23]!==D?.models||t[24]!==W||t[25]!==re||t[26]!==O.omni?.model||t[27]!==O.omni?.provider||t[28]!==te?(q=W?O.omni?.provider===`xopc-cloud`?D?.models.find(e=>e.id===O.omni?.model)?.voice.voices??[]:re.length?re:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(cn):te,t[23]=D?.models,t[24]=W,t[25]=re,t[26]=O.omni?.model,t[27]=O.omni?.provider,t[28]=te,t[29]=q):q=t[29];let J=q,Y=!!(C?.enabled&&C.stt),oe=!!(C?.enabled&&C.tts),se;t[30]!==i||t[31]!==c||t[32]!==O?(se=e=>c({...i,voice:{...i.voice,realtime:{...O,...e}}}),t[30]=i,t[31]=c,t[32]=O,t[33]=se):se=t[33];let X=se,ce;t[34]!==i||t[35]!==c?(ce=e=>c(on(i,e)),t[34]=i,t[35]=c,t[36]=ce):ce=t[36];let le=ce,ue;t[37]!==a||t[38]!==O.enabled||t[39]!==p.disabled||t[40]!==p.needsSetup||t[41]!==p.pending||t[42]!==p.unverified||t[43]!==p.verified||t[44]!==_||t[45]!==y.signature?(ue=(e,t)=>O.enabled?a?p.pending:e?t&&y.signature===_?p.verified:p.unverified:p.needsSetup:p.disabled,t[37]=a,t[38]=O.enabled,t[39]=p.disabled,t[40]=p.needsSetup,t[41]=p.pending,t[42]=p.unverified,t[43]=p.verified,t[44]=_,t[45]=y.signature,t[46]=ue):ue=t[46];let de=ue,fe;t[47]!==o||t[48]!==le||t[49]!==m||t[50]!==w||t[51]!==i||t[52]!==H||t[53]!==ae||t[54]!==c||t[55]!==a||t[56]!==k||t[57]!==O.defaultEngine||t[58]!==O.enabled||t[59]!==p.changeKey||t[60]!==p.configureConversation||t[61]!==p.customProvider||t[62]!==p.edgeHint||t[63]!==p.enable||t[64]!==p.finishSetup||t[65]!==p.hosted||t[66]!==p.hostedAccountHint||t[67]!==p.hostedHint||t[68]!==p.keyConfigured||t[69]!==p.keyHint||t[70]!==p.manageAccount||t[71]!==p.outputHint||t[72]!==p.ownKey||t[73]!==p.ownKeyHint||t[74]!==p.service||t[75]!==p.statusError||t[76]!==n||t[77]!==A||t[78]!==C?.tts||t[79]!==X||t[80]!==r.experience||t[81]!==r.stt?(fe=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":O.enabled,className:`size-4 accent-accent`,checked:O.enabled,onChange:e=>{e.target.checked?le(k===`alibaba`?`alibaba`:`xopc-cloud`):X({enabled:!1})}}),p.enable]})}),w?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:p.statusError}):null,(0,$.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,$.jsx)(`legend`,{className:`text-sm font-medium text-fg`,children:p.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:()=>le(e),className:`mt-1 accent-accent`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:e===`xopc-cloud`?p.hosted:p.ownKey}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e===`xopc-cloud`?p.hostedHint:p.ownKeyHint})]})]},e))})]}),k!==`alibaba`&&k!==`xopc-cloud`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p.customProvider.replace(`{provider}`,k)}):null,k===`alibaba`?(0,$.jsx)(`div`,{className:`space-y-2 text-xs`,children:ae&&!m?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:p.keyConfigured}),(0,$.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>h(!0),children:p.changeKey})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{htmlFor:`realtime-api-key`,className:`font-medium text-fg`,children:r.stt.apiKey}),(0,$.jsx)(At,{kind:`stt`,providerId:`alibaba`,fieldId:`realtime-api-key`,value:H,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:p.keyHint})]})}):null,k===`xopc-cloud`?(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[p.hostedAccountHint,` `,(0,$.jsx)(l,{className:`text-accent hover:underline`,to:`/settings/capabilities/models`,children:p.manageAccount})]}):null,!A&&!a&&!C?.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:p.finishSetup}),(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:i.tts.provider===`edge`?p.edgeHint:p.outputHint}),(0,$.jsx)(V,{className:`mt-2`,type:`button`,variant:`secondary`,onClick:()=>le(k),children:p.configureConversation})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(d,{value:O.defaultEngine,className:ie,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:[O.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]})]}):null,t[47]=o,t[48]=le,t[49]=m,t[50]=w,t[51]=i,t[52]=H,t[53]=ae,t[54]=c,t[55]=a,t[56]=k,t[57]=O.defaultEngine,t[58]=O.enabled,t[59]=p.changeKey,t[60]=p.configureConversation,t[61]=p.customProvider,t[62]=p.edgeHint,t[63]=p.enable,t[64]=p.finishSetup,t[65]=p.hosted,t[66]=p.hostedAccountHint,t[67]=p.hostedHint,t[68]=p.keyConfigured,t[69]=p.keyHint,t[70]=p.manageAccount,t[71]=p.outputHint,t[72]=p.ownKey,t[73]=p.ownKeyHint,t[74]=p.service,t[75]=p.statusError,t[76]=n,t[77]=A,t[78]=C?.tts,t[79]=X,t[80]=r.experience,t[81]=r.stt,t[82]=fe):fe=t[82];let Z;t[83]!==K||t[84]!==u||t[85]!==W||t[86]!==j||t[87]!==O.bargeIn||t[88]!==O.omni||t[89]!==O.tts||t[90]!==p.bargeIn||t[91]!==p.defaultVoice||t[92]!==p.voice||t[93]!==n||t[94]!==A||t[95]!==C?.tts||t[96]!==X||t[97]!==r.realtime||t[98]!==J?(Z=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:p.voice}),(0,$.jsxs)(d,{id:`realtime-voice`,className:`${ie} w-full sm:w-56`,value:K,disabled:W?!O.omni:!A&&!C?.tts,onChange:e=>{if(W&&O.omni){X({omni:{...O.omni,voice:e.target.value}});return}(j===`alibaba`||j===`xopc-cloud`)&&X({tts:{...O.tts,provider:j,...e.target.value?{voice:e.target.value}:{}},...O.omni&&[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.target.value)?{omni:{...O.omni,voice:e.target.value}}:{}})},children:[W?null:(0,$.jsx)(f,{value:``,children:p.defaultVoice}),K&&!J.some(e=>e.id===K)?(0,$.jsx)(f,{value:K,children:K}):null,J.map(e=>(0,$.jsxs)(f,{value:e.id,children:[Pe(e,u),`gender`in e&&e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,`style`in e&&e.style?` · ${e.style}`:``]},e.id))]}),(()=>{let e=J.find(e=>e.id===K);return e&&`description`in e&&typeof e.description==`string`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.description}):null})()]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,$.jsxs)(`span`,{children:[p.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":O.bargeIn,checked:O.bargeIn,className:`size-4 accent-accent`,onChange:e=>X({bargeIn:e.target.checked})})]})]}):null,t[83]=K,t[84]=u,t[85]=W,t[86]=j,t[87]=O.bargeIn,t[88]=O.omni,t[89]=O.tts,t[90]=p.bargeIn,t[91]=p.defaultVoice,t[92]=p.voice,t[93]=n,t[94]=A,t[95]=C?.tts,t[96]=X,t[97]=r.realtime,t[98]=J,t[99]=Z):Z=t[99];let pe;t[100]!==Y||t[101]!==oe||t[102]!==w||t[103]!==T||t[104]!==a||t[105]!==n||t[106]!==_||t[107]!==C||t[108]!==de||t[109]!==r||t[110]!==y.input||t[111]!==y.output?(pe=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[T?(0,$.jsx)(G,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,de(Y,y.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,de(Y&&oe,y.input&&y.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,de(!!(C?.enabled&&C.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(an,{v:r,canListen:Y,canSpeak:oe,disabled:a||T||!!w,onVerified:e=>b({signature:_,...e})},`${_}:${JSON.stringify(C)}`)]}):null,t[100]=Y,t[101]=oe,t[102]=w,t[103]=T,t[104]=a,t[105]=n,t[106]=_,t[107]=C,t[108]=de,t[109]=r,t[110]=y.input,t[111]=y.output,t[112]=pe):pe=t[112];let me;return t[113]!==p.service||t[114]!==fe||t[115]!==Z||t[116]!==pe?(me=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":p.service,children:[fe,Z,pe]}),t[113]=p.service,t[114]=fe,t[115]=Z,t[116]=pe,t[117]=me):me=t[117],me}function cn(e){return{id:e,name:e}}function ln(e){return e.id===`alibaba`&&e.configured}function un(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function dn(e){return Fe.parse((await k(e)).payload)}function fn(e){return e.language}function pn(e){let t=(0,zt.c)(22),{value:n,onChange:r}=e,i=M(hn)===`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(mn)})]}),(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)(V,{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 mn(e){return(0,$.jsx)(f,{value:e,children:e},e)}function hn(e){return e.language}var gn=U;function _n(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,ae,`dark:border-edge`)}function vn(){return O(ie,U)}function yn(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function bn(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 xn(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Sn(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 Cn(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 wn(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 Tn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function En(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 Dn(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 On(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 kn(){let e=M(e=>e.language),t=D(e).voiceSettings,[n,r]=(0,Q.useState)(`listening`),i=De(),a=it(e=>e.captions),o=it(e=>e.setCaptions),s=!!A(e=>e.conversationId);(0,Q.useEffect)(()=>{!i&&n===`diagnostics`&&r(`listening`)},[n,i]);let[c,l]=(0,Q.useReducer)(On,{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:S}=H(s),{data:C,error:w,isLoading:T,mutate:E}=B(s?N(`/api/voice/models`):null,Dt,{revalidateOnFocus:!1}),{data:O,error:k,isLoading:j}=B(s?N(`/api/voice/providers`):null,Ct,{revalidateOnFocus:!1}),{data:P,error:F,isLoading:I}=B(s?N(`/api/voice/stt-providers`):null,Et,{revalidateOnFocus:!1}),L=(0,Q.useMemo)(()=>O?.providers??[],[O]),R=(0,Q.useMemo)(()=>P?.providers??[],[P]),ee=(0,Q.useMemo)(()=>y?.payload?.config===void 0?null:Ot(y.payload.config),[y]),z=(0,Q.useMemo)(()=>!u||!p?!1:JSON.stringify(u)!==JSON.stringify(p),[u,p]);s?ee!==null&&C!==void 0&&!g.current&&(v.current.parsed!==ee||v.current.models!==C)&&(v.current={parsed:ee,models:C},l({type:`sync`,value:ee}),h(C)):(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 te=!!(s&&(ee===null||C===void 0||O===void 0||P===void 0)&&(x||T||j||I)),ne=b instanceof Error?b.message:b?String(b):w instanceof Error?w.message:w?String(w):k instanceof Error?k.message:k?String(k):F instanceof Error?F.message:F?String(F):null,re=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),U=(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}}}}})},[]),ie=(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})},[]),ae=(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]),W=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),G=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),K=bt({value:u,dirty:z,onSave:(0,Q.useCallback)(async e=>{try{await xt(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])}),q=(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(te)return(0,$.jsx)(vt,{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:ne??t.loadError}),(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>{S(),E()},children:t.retry})]});let J=u.stt,Y=u.tts,oe=u.voice.input.refinement,se=Tn(t);return(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,onBlurCapture:K.onBlurCapture,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,$.jsx)(yt,{status:K.status,error:K.error})}),K.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:K.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)(V,{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)(sn,{section:n,v:t,form:u,pending:z||K.status===`saving`||!!K.error,apiKeyLabels:se,sttProviders:R,onChange:q}):null,n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(An,{v:t,voice:u.voice,updateLanguageMode:ae}),(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:vn(),value:String(u.voice.realtime.silenceDurationMs),onChange:e=>W({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:vn(),value:oe.mode,onChange:e=>ie({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,` · `,Y.enabled?Cn(Y.trigger,t):t.overview.off]}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.setup.readoutHint}),(0,$.jsx)(Nn,{v:t,apiKeyLabels:se,tts:Y,models:m,ttsProviders:L,updateTts:G})]})]}):null,n===`devices`?(0,$.jsx)(rn,{v:t}):null,n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(nn,{disabled:z||K.status===`saving`}),u.voice.realtime.enabled&&u.voice.realtime.omni?.provider===`alibaba`?(0,$.jsx)(pn,{value:u.voice.realtime.omni,onChange:e=>W({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)(jn,{v:t,apiKeyLabels:se,stt:J,models:m,sttProviders:R,updateStt:re,updateSttFallback:U}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.notes.envVars})]})]}):null]})}function An(e){let t=(0,zt.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=vn(),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 jn(e){let t=(0,zt.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(Mn),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 S=b,C,w;t[17]!==v||t[18]!==y||t[19]!==_||t[20]!==S?(C=()=>{_&&y&&v!==y&&S({model:y})},w=[v,y,_,S],t[17]=v,t[18]=y,t[19]=_,t[20]=S,t[21]=C,t[22]=w):(C=t[21],w=t[22]),(0,Q.useEffect)(C,w);let T;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(x,{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 k;t[28]!==E||t[29]!==D?(k=(0,$.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[28]=E,t[29]=D,t[30]=k):k=t[30];let A;t[31]===s?A=t[32]:(A=e=>s({enabled:e}),t[31]=s,t[32]=A);let j;t[33]!==i.enabled||t[34]!==A||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(j=(0,$.jsx)(Ln,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onChange:A}),t[33]=i.enabled,t[34]=A,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=j):j=t[37];let M;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]!==S||t[48]!==s||t[49]!==c||t[50]!==n?(M=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,gn),children:[(0,$.jsx)(Bn,{children:n.stt.provider}),(0,$.jsx)(d,{className:vn(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:u.map(e=>(0,$.jsxs)(f,{value:e.id,children:[xn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(Pn,{kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:y,apiKeyLabels:r,onPatch:S})]}),(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]=S,t[48]=s,t[49]=c,t[50]=n,t[51]=M):M=t[51];let N;t[52]!==j||t[53]!==M?(N=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[j,M]}),t[52]=j,t[53]=M,t[54]=N):N=t[54];let P;return t[55]!==N||t[56]!==k?(P=(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[k,N]}),t[55]=N,t[56]=k,t[57]=P):P=t[57],P}function Mn(e){return e.key===`model`}function Nn({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),v=n.providers?.[n.provider]??{},y=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 v.model==`string`?v.model:void 0,T=w??(typeof x?.defaultValue==`string`?x.defaultValue:y[0]?.id),E=y.find(e=>e.id===T),D=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:_?.voices??[],{data:k=[]}=B(T?`voice:tts:${n.provider}:${T}`:null,()=>Tt(n.provider,T??``),{revalidateOnFocus:!1}),A=k.length>0?k:D,j=typeof v.voice==`string`?v.voice:void 0,M=j??A.find(e=>e.id===E?.tts?.defaultVoice)?.id??(typeof S?.defaultValue==`string`?S.defaultValue:A[0]?.id),N=(_?.fields??[]).filter(e=>(e.key!==`speed`||E?.tts?.speed!==!1)&&(e.key!==`instructions`||E?.tts?.instructions!==!1)),P=!!_?.diagnostics.requiresApiKey,F=!!_?.configured||!P,I=(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&&M&&j!==M&&(e.voice=M),Object.keys(e).length>0&&I(e)},[w,j,T,M,x,I,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 St({text:t,provider:n.provider,providerConfig:v,...T?{model:T}:{},...M?{voice:M}:{}},r.signal);if(r.signal.aborted)return;let a=bn(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`,yn(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,M,v,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)(tt,{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)(Ln,{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:O(`flex flex-col gap-1.5`,gn),children:[(0,$.jsx)(Bn,{children:e.tts.trigger}),(0,$.jsxs)(d,{className:vn(),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:O(`flex flex-col gap-1.5`,gn),children:[(0,$.jsx)(Bn,{children:e.tts.provider}),(0,$.jsx)(d,{className:vn(),value:n.provider,onChange:e=>L(e.target.value),children:g.map(t=>(0,$.jsx)(f,{value:t.id,children:Sn(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??wn(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!F,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)(Pn,{kind:`tts`,providerId:n.provider,fields:N,providerSlice:v,models:y,voices:A,currentModel:T,currentVoice:M,apiKeyLabels:t,onPatch:I,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)(V,{type:`button`,variant:`primary`,onClick:()=>void R(),disabled:c.status===`loading`,className:`h-9`,children:[c.status===`loading`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(C,{className:`size-4`}),c.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(V,{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)(fe,{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:O(_n(),`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 Pn(e){let t=(0,zt.c)(27),{kind:n,providerId:r,fields:i,providerSlice:a,models:o,voices:s,currentModel:c,currentVoice:l,apiKeyLabels:u,onPatch:p,resetVoiceOnModelChange:m}=e,h;t[0]===s?h=t[1]:(h=s===void 0?[]:s,t[0]=s,t[1]=h);let g=h,_=m===void 0?!1:m,v=M(In),y;if(t[2]!==u||t[3]!==c||t[4]!==l||t[5]!==i||t[6]!==n||t[7]!==v||t[8]!==o||t[9]!==p||t[10]!==r||t[11]!==a||t[12]!==_||t[13]!==g){let e;t[15]!==u||t[16]!==c||t[17]!==l||t[18]!==n||t[19]!==v||t[20]!==o||t[21]!==p||t[22]!==r||t[23]!==a||t[24]!==_||t[25]!==g?(e=e=>e.key===`apiKey`?(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,gn),children:[(0,$.jsx)(Bn,{children:e.label}),(0,$.jsx)(At,{kind:n,providerId:r,fieldId:`voice-${n}-${r}-api-key`,value:typeof a.apiKey==`string`?a.apiKey:``,onChange:e=>p({apiKey:e}),labels:u,placeholder:e.placeholder}),e.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.description}):null]},e.key):e.key===`model`&&o.length>0?(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,gn),children:[(0,$.jsx)(Bn,{children:e.label}),(0,$.jsx)(d,{className:vn(),value:c??``,onChange:e=>p({model:e.target.value,..._?{voice:void 0}:{}}),children:o.map(Fn)})]},e.key):e.key===`voice`&&g.length>0?(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,gn),children:[(0,$.jsx)(Bn,{children:e.label}),(0,$.jsxs)(d,{className:vn(),value:l??``,onChange:e=>p({voice:e.target.value}),children:[l&&!g.some(e=>e.id===l)?(0,$.jsxs)(f,{value:l,children:[l,` · unavailable`]}):null,g.map(e=>(0,$.jsxs)(f,{value:e.id,children:[Pe(e,v),e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,e.style?` · ${e.style}`:``]},e.id))]}),g.find(e=>e.id===l)?.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:g.find(e=>e.id===l)?.description}):null]},e.key):(0,$.jsx)(Rn,{field:e,value:En(a,e),onChange:t=>p({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:gn},e.key),t[15]=u,t[16]=c,t[17]=l,t[18]=n,t[19]=v,t[20]=o,t[21]=p,t[22]=r,t[23]=a,t[24]=_,t[25]=g,t[26]=e):e=t[26],y=i.map(e),t[2]=u,t[3]=c,t[4]=l,t[5]=i,t[6]=n,t[7]=v,t[8]=o,t[9]=p,t[10]=r,t[11]=a,t[12]=_,t[13]=g,t[14]=y}else y=t[14];return y}function Fn(e){return(0,$.jsx)(f,{value:e.id,children:e.name},e.id)}function In(e){return e.language}function Ln(e){let t=(0,zt.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=O(`group flex w-full items-center justify-between gap-4 rounded-lg bg-surface-base/55 px-3 py-3 text-left transition-colors`,ae,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=O(`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=O(`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 Rn(e){let t=(0,zt.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=O(`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(Dn(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=O(`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)(Bn,{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:vn(),value:c,required:n.required,onChange:e=>i(Dn(n,e.target.value)),children:(n.options??[]).map(zn)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:O(_n(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(Dn(n,e.target.value))}):n.type===`password`?(0,$.jsx)(v,{id:o,className:a,value:c,onChange:e=>i(Dn(n,e)),placeholder:n.placeholder,labels:Ze}):n.type===`number`?(0,$.jsx)(pt,{id:o,className:_n(),autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,allowEmpty:!n.required,placeholder:n.placeholder,min:n.min,max:n.max,step:n.step,onChange:e=>i(Dn(n,e.target.value))}):(0,$.jsx)(`input`,{id:o,className:_n(),type:`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(Dn(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 zn(e){return(0,$.jsx)(f,{value:e.id,children:e.name},e.id)}function Bn(e){let t=(0,zt.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 Vn(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function Hn(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,t)=>{let n=e&&typeof e==`object`?e:{},r=n.type,i=r===`brave`||r===`tavily`||r===`bing`||r===`searxng`?r:`brave`;return{clientKey:`search-provider-${t}`,type:i,apiKey:typeof n.apiKey==`string`?n.apiKey:``,url:typeof n.url==`string`?n.url:``,disabled:n.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function Un(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 k(N(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),re()}async function Wn(e){let t=await k(N(`/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 Gn(e){let t=(0,zt.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 Kn(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,ae,`dark:border-edge`)}function qn(){return O(ie,U)}var Jn=[`brave`,`tavily`,`bing`,`searxng`];function Yn(){return{clientKey:crypto.randomUUID(),type:`brave`,apiKey:``,url:``,disabled:!1}}var Xn=oe();function Zn(){let e=D(M(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!A(e=>e.conversationId),[i,a]=(0,Q.useReducer)(Xn,{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:_}=H(r);Y({enabled:r,parsed:(0,Q.useMemo)(()=>p?.payload?.config===void 0?null:Hn(p.payload.config),[p]),dirty:c.current,trackedParsedRef:u,dispatch:a,onResetDirty:()=>{c.current=!1}});let v=!!(r&&h&&p===void 0&&!m),y=m instanceof Error?m.message:m?String(m):null,b=(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})},[]),S=bt({value:o,dirty:b,onSave:(0,Q.useCallback)(async e=>{try{await Un(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(v)return(0,$.jsx)(vt,{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:y??t.loadError}),(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void _(),children:n.refresh})]});let C=Vn(o.providers);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,onBlurCapture:S.onBlurCapture,children:[S.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S.error}):null,(0,$.jsxs)(_t,{children:[(0,$.jsx)(gt,{icon:Ne,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(yt,{status:S.status,error:S.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)(g,{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:O(`rounded-full px-2 py-0.5 text-[11px] font-medium`,C?`bg-surface-panel text-fg-muted`:`bg-accent-soft text-accent`),children:C?t.cloudOverridden:t.cloudAutomatic})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-subtle`,children:C?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)(Qn,{row:n,providerIndex:r,labels:t,secretLabels:et(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.clientKey??r)),(0,$.jsxs)(V,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>x({providers:[...o.providers,Yn()]}),children:[(0,$.jsx)(w,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(_t,{children:[(0,$.jsx)(gt,{icon:ye,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(Gn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(d,{className:qn(),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)(Gn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(pt,{type:`number`,min:1,max:50,className:Kn(),value:o.maxResults,onChange:e=>x({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})})]})]}),(0,$.jsx)(jt,{children:(0,$.jsxs)(_t,{children:[(0,$.jsx)(gt,{icon:me,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)(Gn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:O(Kn(),`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 Qn(e){let t=(0,zt.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>Wn(r).then($n),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=O(qn(),`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=Jn.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 y;t[15]!==n.disabled||t[16]!==_?(y=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.disabled,onChange:_}),t[15]=n.disabled,t[16]=_,t[17]=y):y=t[17];let b;t[18]!==i.disabled||t[19]!==y?(b=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[y,i.disabled]}),t[18]=i.disabled,t[19]=y,t[20]=b):b=t[20];let x;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(Ve,{className:`size-4`}),t[21]=x):x=t[21];let S;t[22]===s?S=t[23]:(S=(0,$.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:x}),t[22]=s,t[23]=S);let C;t[24]!==S||t[25]!==b?(C=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,S]}),t[24]=S,t[25]=b,t[26]=C):C=t[26];let w;t[27]!==C||t[28]!==g?(w=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[g,C]}),t[27]=C,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)(Gn,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Kn(),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)(v,{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 k;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==D?(k=(0,$.jsx)(Gn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:D}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=D,t[49]=k):k=t[49];let A;return t[50]!==w||t[51]!==T||t[52]!==k?(A=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/60 p-4`,children:[w,T,k]}),t[50]=w,t[51]=T,t[52]=k,t[53]=A):A=t[53],A}function $n(e){return e.apiKey??null}function er(e){let t=(0,zt.c)(185),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=M(nr)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:ot(``),t[0]=n,t[1]=l);let[u,p]=(0,Q.useState)(l),[m,h]=(0,Q.useState)(tr),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 x=b,S=u,C;t[17]===S?C=t[18]:(C=Oe(S),t[17]=S,t[18]=C);let w=C,T=r?s.addModelTitle:s.editModelTitle,D;t[19]===T?D=t[20]:(D=(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:T}),t[19]=T,t[20]=D);let k;t[21]!==s.modelProviderLabel||t[22]!==i?(k=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]=k):k=t[23];let A;t[24]!==D||t[25]!==k?(A=(0,$.jsxs)(`div`,{children:[D,k]}),t[24]=D,t[25]=k,t[26]=A):A=t[26];let j;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(j=O(ne,`p-1.5 hover:bg-surface-base`),t[27]=j):j=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(E,{className:`size-4`}),t[28]=N):N=t[28];let P;t[29]===s.close?P=t[30]:(P=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:j,"aria-label":s.close,children:N})}),t[29]=s.close,t[30]=P);let F;t[31]!==A||t[32]!==P?(F=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[A,P]}),t[31]=A,t[32]=P,t[33]=F):F=t[33];let L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=L):L=t[34];let R;t[35]===s.modelId?R=t[36]:(R=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,L]}),t[35]=s.modelId,t[36]=R);let z;t[37]===m?z=t[38]:(z=O(ze(),m.has(`id`)&&`border-red-500`),t[37]=m,t[38]=z);let B=u.id||``,te;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>_(`id`,e.target.value),t[39]=te):te=t[39];let re=!r,H;t[40]!==z||t[41]!==B||t[42]!==re?(H=(0,$.jsx)(`input`,{className:z,value:B,onChange:te,placeholder:`e.g. llama3.1:8b`,disabled:re}),t[40]=z,t[41]=B,t[42]=re,t[43]=H):H=t[43];let U;t[44]===m?U=t[45]:(U=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]=U);let ie;t[46]!==R||t[47]!==H||t[48]!==U?(ie=(0,$.jsxs)(`div`,{children:[R,H,U]}),t[46]=R,t[47]=H,t[48]=U,t[49]=ie):ie=t[49];let ae;t[50]===s.displayName?ae=t[51]:(ae=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=ae);let W;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(W=ze(),t[52]=W):W=t[52];let G=u.name||``,K;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>_(`name`,e.target.value),t[53]=K):K=t[53];let q;t[54]===G?q=t[55]:(q=(0,$.jsx)(`input`,{className:W,value:G,onChange:K}),t[54]=G,t[55]=q);let J;t[56]!==ae||t[57]!==q?(J=(0,$.jsxs)(`div`,{children:[ae,q]}),t[56]=ae,t[57]=q,t[58]=J):J=t[58];let Y;t[59]===s.inputTypes?Y=t[60]:(Y=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=Y);let oe;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(oe=ue(),t[61]=oe):oe=t[61];let se;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>_(`input`,st(e.target.value)),t[62]=se):se=t[62];let X;t[63]===s?X=t[64]:(X=lt.map(e=>(0,$.jsx)(f,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=X);let ce;t[65]!==w||t[66]!==X?(ce=(0,$.jsx)(d,{className:oe,value:w,onChange:se,children:X}),t[65]=w,t[66]=X,t[67]=ce):ce=t[67];let le;t[68]!==Y||t[69]!==ce?(le=(0,$.jsxs)(`div`,{children:[Y,ce]}),t[68]=Y,t[69]=ce,t[70]=le):le=t[70];let de=u.reasoning||!1,fe;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>_(`reasoning`,e.target.checked),t[71]=fe):fe=t[71];let Z;t[72]===de?Z=t[73]:(Z=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:de,onChange:fe}),t[72]=de,t[73]=Z);let pe;t[74]!==s.reasoning||t[75]!==Z?(pe=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[Z,s.reasoning]}),t[74]=s.reasoning,t[75]=Z,t[76]=pe):pe=t[76];let me;t[77]!==le||t[78]!==pe?(me=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[le,pe]}),t[77]=le,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=O(ze(),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)(pt,{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=O(ze(),m.has(`maxTokens`)&&`border-red-500`),t[96]=m,t[97]=Ce);let we=u.maxTokens??16384,Te;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>_(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=Te):Te=t[98];let Ee;t[99]!==Ce||t[100]!==we?(Ee=(0,$.jsx)(pt,{type:`number`,min:1,className:Ce,value:we,onChange:Te}),t[99]=Ce,t[100]=we,t[101]=Ee):Ee=t[101];let De;t[102]===m?De=t[103]:(De=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]=De);let ke;t[104]!==Se||t[105]!==Ee||t[106]!==De?(ke=(0,$.jsxs)(`div`,{children:[Se,Ee,De]}),t[104]=Se,t[105]=Ee,t[106]=De,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=ze(),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)(pt,{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 Be;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Be=ze(),t[126]=Be):Be=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)(pt,{type:`number`,step:`any`,min:0,className:Be,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]!==ie||t[142]!==J||t[143]!==me||t[144]!==Ae||t[145]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[ie,J,me,Ae,Ke]}),t[141]=ie,t[142]=J,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 at=c?`协议必须与模型 API 匹配。声明协议不代表模型已通过效果验证。`:`The protocol must match the model API. Declaring a protocol does not certify model quality.`,ct;t[159]===at?ct=t[160]:(ct=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:at}),t[159]=at,t[160]=ct);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]!==ct||t[165]!==ut?(dt=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[it,ct,ut]}),t[163]=it,t[164]=ct,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 mt;t[170]!==qe||t[171]!==ft?(mt=(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]=mt):mt=t[172];let ht;t[173]===s.cancel?ht=t[174]:(ht=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(V,{type:`button`,variant:`secondary`,children:s.cancel})}),t[173]=s.cancel,t[174]=ht);let gt=r?s.addModelConfirm:s.saveModelConfirm,_t;t[175]!==x||t[176]!==gt?(_t=(0,$.jsx)(V,{type:`button`,variant:`primary`,className:`hover:bg-accent/90`,onClick:x,children:gt}),t[175]=x,t[176]=gt,t[177]=_t):_t=t[177];let vt;t[178]!==ht||t[179]!==_t?(vt=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[ht,_t]}),t[178]=ht,t[179]=_t,t[180]=vt):vt=t[180];let yt;return t[181]!==F||t[182]!==mt||t[183]!==vt?(yt=(0,$.jsxs)($.Fragment,{children:[F,mt,vt]}),t[181]=F,t[182]=mt,t[183]=vt,t[184]=yt):yt=t[184],yt}function tr(){return new Map}function nr(e){return e.language}function rr(e){let t=(0,zt.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)(P,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim`,q)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=O(`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`,K,`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)(er,{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)(L,{children:[l,(0,$.jsx)(R,{className:u,onOpenAutoFocus:ir,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(z,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function ir(e){return e.preventDefault()}function ar(e){let t=(0,zt.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>je(n).then(or),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)(v,{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 or(e){return e.apiKey??null}function sr(e){let t=(0,zt.c)(20),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,[f,p]=(0,Q.useState)(null),m;t[0]===r?m=t[1]:(m=e=>{e||p(null),r(e)},t[0]=r,t[1]=m);let h=m,g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(P,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,q)}),t[2]=g):g=t[2];let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=O(`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`,K),t[3]=_):_=t[3];let v;t[4]!==c||t[5]!==o||t[6]!==s||t[7]!==h||t[8]!==a||t[9]!==l||t[10]!==u||t[11]!==r||t[12]!==d||t[13]!==i||t[14]!==f?(v=(0,$.jsxs)(L,{children:[g,(0,$.jsx)(R,{className:_,children:f?(0,$.jsx)(at,{target:f,zh:u===`zh`,onDone:()=>h(!1)}):a?(0,$.jsx)(lr,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onModelAdded:e=>p({providerId:i,modelIds:[e]})}):(0,$.jsx)(cr,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d})})]}),t[4]=c,t[5]=o,t[6]=s,t[7]=h,t[8]=a,t[9]=l,t[10]=u,t[11]=r,t[12]=d,t[13]=i,t[14]=f,t[15]=v):v=t[15];let y;return t[16]!==h||t[17]!==n||t[18]!==v?(y=(0,$.jsx)(z,{open:n,onOpenChange:h,children:v}),t[16]=h,t[17]=n,t[18]=v,t[19]=y):y=t[19],y}function cr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let s=t.find(t=>t.id===e),c=pe[e],u=n.filter(t=>t.provider===e),[d,f]=(0,Q.useState)(!1),[p,h]=(0,Q.useState)(s?.apiKey??``),[g,v]=(0,Q.useState)(!1),[y,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),k=D(i).providersSettings,A=s?.supportsApiKey!==!1,j=s?.supportsOAuth===!0,M=s?.authMode===`oauth`&&s.authStatus===`connected`,N=s?.configured===!0&&s.activeKeySource!==`env`&&s.activeKeySource!==`extension`&&s.activeKeySource!==`models_json`,[P,F]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(null),[z,B]=(0,Q.useState)(`idle`),[ne,re]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null),[ie,W]=(0,Q.useState)(null),[G,K]=(0,Q.useState)(``),q=(0,Q.useRef)(null),J=(0,Q.useRef)(null),Y=z===`waiting`||z===`waiting_code`,oe=(0,Q.useMemo)(()=>Z(e,i),[e,i]),se=p!==(s?.apiKey??``),X=async()=>{let t=p.trim();if(!(!t||!A||Me(t))){v(!0),C(null);try{await ge({[e]:t}),x(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){C(e instanceof Error?e.message:r.saveError)}finally{v(!1)}}};(0,Q.useEffect)(()=>{if(!P||!Y)return;let e=window.setInterval(()=>{(async()=>{try{let t=await he(P);t.status===`waiting_auth`||t.status===`waiting_code`?(B(t.status===`waiting_code`?`waiting_code`:`waiting`),R(t.message??null),re(t.authUrl??null),U(t.instructions??null),W(t.deviceCode??null),t.authUrl&&t.authUrl!==J.current&&(J.current=t.authUrl,le(t.authUrl,q.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),qe(q.current),q.current=null,B(`success`),R(t.message??k.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),qe(q.current),q.current=null,B(`error`),R(t.error??t.message??k.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,Y,a,o,k.revokeFailed,k.saved]),(0,Q.useEffect)(()=>()=>{P&&Ce(P).catch(()=>{})},[P]),(0,Q.useEffect)(()=>()=>{qe(q.current),q.current=null},[]);let ce=async()=>{try{await dt(e),o(),a()}catch{}},ue=async()=>{qe(q.current),q.current=Ke(),J.current=null,B(`waiting`),R(k.oauthStarting),re(null),U(null),W(null),C(null);try{F((await ve(e)).sessionId)}catch(e){qe(q.current),q.current=null,B(`error`),R(e instanceof Error?e.message:k.revokeFailed)}},de=async()=>{if(P){try{await be(P)}catch{}qe(q.current),q.current=null,J.current=null,B(`idle`),R(null),F(null),re(null),U(null),W(null)}},fe=async()=>{if(!(!P||!G.trim()))try{await Ee(P,G.trim()),K(``),R(k.oauthProcessingCode)}catch(e){B(`error`),R(e instanceof Error?e.message:k.revokeFailed)}},me=async()=>{try{await _e(e),o(),a()}catch(e){C(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)(I,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,te.press),children:(0,$.jsx)(E,{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)(ar,{providerId:e,inputId:`manage-api-key`,value:p,onChange:e=>{h(e),x(!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)(_,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,j?(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:M?k.sourceOauth:k.oauthHint})]}),M?(0,$.jsx)(V,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void me(),children:k.revoke}):(0,$.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:Y,onClick:()=>void ue(),children:[Y?(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ie,{className:`size-3.5`,"aria-hidden":!0}),k.oauth]})]}),L?(0,$.jsx)(`p`,{className:O(`text-xs`,z===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:L}):null,z===`waiting`||z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ne?(0,$.jsxs)(`a`,{href:ne,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)(_,{className:`size-4`,"aria-hidden":!0}),k.openAuthPage]}):null,(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void de(),children:k.cancelOAuth})]}):null,H?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:H}):null,ie?(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:ie}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:k.deviceCodeHint})]}):null,z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:G,onChange:e=>K(e.target.value),onKeyDown:e=>e.key===`Enter`&&void fe(),placeholder:k.pasteRedirectUrl,className:O(`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`,ae)}),(0,$.jsx)(V,{type:`button`,variant:`primary`,onClick:()=>void fe(),children:k.submitCode})]}):null]}):null,oe.length>0&&A?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:oe.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:[xe(e,r),(0,$.jsx)(_,{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:[Pe(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),S?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[N?(0,$.jsxs)(V,{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:()=>T(!0),children:[(0,$.jsx)(Ve,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:A&&se&&!Me(p.trim())?(0,$.jsx)(V,{type:`button`,variant:`primary`,disabled:!p.trim()||g||y,onClick:()=>void X(),children:y?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):g?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(Je,{open:w,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,s?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void ce(),onCancel:()=>T(!1)})]})}function lr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a,onModelAdded:o}){let s=D(r).modelsSettings,c=t?.providers[e],[l,u]=(0,Q.useState)(c?.baseUrl??``),[d,f]=(0,Q.useState)(c?.apiKey??``),[p,m]=(0,Q.useState)(c?.models??[]),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(c?.modelDiscovery?.enabled===!0),[y,x]=(0,Q.useState)(!1),[C,T]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),[j,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=d.trim(),i={...c,baseUrl:l.trim()||void 0,apiKey:Me(r)?c?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},z=async()=>{let e=R({models:p,modelDiscovery:{enabled:_}});if(e){x(!0),T(null);try{await ke(e),a(),i()}catch(e){T(e instanceof Error?e.message:n.saveError)}finally{x(!1)}}},B=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await ke({providers:r}),a(),i()}catch{}},ne=(e,t)=>{L({model:e,isNew:t}),P(!0)},re=async e=>{if(!F)return;let t=F.isNew&&!p.some(t=>t.id===e.id),r=F.isNew?[...p,e]:p.map(t=>t.id===e.id?e:t);m(r);let i=R({models:r});if(i)try{await ke(i),a(),t&&!e.computerUse&&o(e.id)}catch(e){T(e instanceof Error?e.message:n.saveError)}},H=async e=>{let t=p.filter(t=>t.id!==e);m(t),M(null);let r=R({models:t});if(r)try{await ke(r),a()}catch(e){T(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)(I,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,te.press),children:(0,$.jsx)(E,{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:l,onChange:e=>u(e.target.value),className:O(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,ae)})]}),(0,$.jsx)(ar,{providerId:e,inputId:`manage-custom-api-key`,value:d,onChange:f,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:_,onChange:e=>v(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:[s.modelsSection,p.length>0?` (${p.length})`:``]}),(0,$.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>ne(null,!0),children:[(0,$.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),s.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:h,onChange:e=>g(e.target.checked)}),r===`zh`?`仅电脑控制模型`:`Computer Use only`]}),p.filter(e=>!h||e.computerUse).length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:p.filter(e=>!h||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:O(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,te.press),onClick:()=>ne(e,!1),"aria-label":s.editModel,children:(0,$.jsx)(S,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:O(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,te.press),onClick:()=>M(e.id),"aria-label":s.removeModel,children:(0,$.jsx)(Ve,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),C?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(V,{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:()=>A(!0),children:[(0,$.jsx)(Ve,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(V,{type:`button`,variant:`primary`,disabled:y,onClick:()=>void z(),children:y?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(Je,{open:k,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void B(),onCancel:()=>A(!1)}),(0,$.jsx)(Je,{open:j!==null,title:s.removeModel,description:s.removeModelConfirm.replace(`{{id}}`,j??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{j&&H(j)},onCancel:()=>M(null)}),(0,$.jsx)(rr,{open:N,onOpenChange:e=>{P(e),e||L(null)},providerId:e,model:F?.model??null,isNew:F?.isNew??!1,onSave:e=>void re(e),m:s})]})}function ur(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function dr(e,t){if(e.startsWith(`agentCatalog.defaults.models`))return{label:t?`全局智能体默认模型`:`Global agent defaults`,href:`/settings/agent-defaults`};let n=e.match(/^agentCatalog\.agents\.([^.]+)\.models/);return n?.[1]?{label:t?`智能体 ${n[1]}`:`Agent ${n[1]}`,href:de(n[1])}:e.startsWith(`sessions.`)?{label:t?`会话模型覆盖`:`Session model override`,href:`/settings/sessions`}:{label:e,href:`/settings/agent-defaults`}}function fr(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:`${Xe(`models`)}?add=1`,guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{href:Xe(`image`),guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{href:Xe(`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:Xe(`voice`),guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}function pr(e){switch(e){case`computer-use`:return`/settings/computer-use`;case`vision`:return Xe(`models`);case`image-generation`:return Xe(`image`);case`stt`:case`tts`:return Xe(`voice`)}}async function mr(){let e=await j(N(`/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 hr(){let e=await j(N(`/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 gr(){let e=M(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=B(X,mr,{revalidateOnFocus:!0,refreshInterval:6e4}),{data:i}=B(ce,hr,{revalidateOnFocus:!1}),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);if(r)return(0,$.jsx)(G,{className:`h-24 w-full rounded-2xl`});let d=Object.values(t?.sources??{}),f=d.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),p=(t?.references??[]).filter(e=>e.availability===`unavailable`),g=t?.sync.lastSuccessAt??Math.max(0,...d.map(e=>e.lastSuccessAt)),_=!!n,v=t?.sync.sourceErrors??{},y=[...t?.sync.lastError?[[`catalog`,t.sync.lastError]]:[],...Object.entries(v),...s?[[`refresh`,s]]:[],...n instanceof Error?[[`load`,n.message]]:[]],x=t?.sync.lastAttemptAt??g,S=Object.entries(i?.capabilities??{}).filter(([e])=>e!==`computer-use`||J()),C=S.some(([,e])=>{let t=ur(e);return t===`degraded`||t===`misconfigured`}),w=S.filter(([,e])=>ur(e)===`ready`).length,T=async()=>{o(!0),c(null);try{let e=await j(N(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await se()}catch(e){c(e instanceof Error?e.message:String(e))}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:C||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:[C?(0,$.jsx)(We,{className:`size-4 text-amber-500`,"aria-hidden":!0}):w===S.length&&S.length>0?(0,$.jsx)(m,{className:`size-4 text-emerald-500`,"aria-hidden":!0}):(0,$.jsx)(h,{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?`${w}/${S.length} 项已配置,不影响基础聊天功能`:`${w} of ${S.length} configured · Not required for chat`})]}),(0,$.jsx)(u,{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`&&!J())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=ur(n),o=a===`degraded`||a===`misconfigured`,s=fr(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)(ut,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]});return(0,$.jsx)(l,{to:o?s.href:pr(t),"aria-label":o?`${r}:${s.action}`:`${e?`配置`:`Configure`} ${r}`,className:O(`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]}),p.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-2`,"aria-live":`polite`,children:p.map(t=>(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 p-3`,children:(()=>{let n=!!v[t.ref.split(`/`)[0]??``],r=dr(t.locations[0]??``,e);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(We,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`p`,{className:`break-words text-sm font-medium text-fg`,children:[t.ref,(0,$.jsx)(`span`,{className:`ml-2 font-normal text-amber-700 dark:text-amber-300`,children:n?e?`暂时无法验证`:`Temporarily unverified`:e?`不可用`:`Unavailable`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[n?e?`模型目录同步暂时失败,当前状态可能已过期;不会影响其他可用模型。`:`Catalog sync temporarily failed, so this status may be stale. Other available models are unaffected.`:e?`此模型已无法从当前配置中解析,使用它的功能可能失败。`:`This model no longer resolves from the current configuration. Features using it may fail.`,x?` · ${e?`最近检测`:`Last checked`} ${new Date(x).toLocaleString()}`:``]}),t.suggestedRef?(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[e?`可替换为`:`Suggested replacement`,`:`,(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:t.suggestedRef})]}):null]})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:[(0,$.jsxs)(V,{className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,disabled:a,onClick:()=>void T(),children:[a?(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ae,{className:`size-3.5`,"aria-hidden":!0}),a?e?`检测中…`:`Checking…`:e?`重新检测`:`Check again`]}),(0,$.jsx)(V,{asChild:!0,className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,children:(0,$.jsxs)(l,{to:r.href,children:[(0,$.jsx)(Re,{className:`size-3.5`,"aria-hidden":!0}),t.suggestedRef?e?`更换模型`:`Replace model`:e?`调整配置`:`Adjust configuration`]})}),(0,$.jsxs)(`details`,{className:`group/references`,children:[(0,$.jsxs)(`summary`,{className:`touch-target inline-flex cursor-pointer list-none items-center gap-1 rounded-xl px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e?`查看 ${t.locations.length} 处引用`:`View ${t.locations.length} ${t.locations.length===1?`reference`:`references`}`,(0,$.jsx)(u,{className:`size-3.5 transition-transform group-open/references:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 pl-2 text-xs text-fg-muted`,children:t.locations.map(t=>{let n=dr(t,e);return(0,$.jsx)(`li`,{children:(0,$.jsx)(l,{className:`inline-flex rounded px-1.5 py-1 text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,to:n.href,title:t,children:n.label})},t)})})]})]})]})})()},t.ref))}):null,_||s?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:_?e?`暂时无法读取模型状态,请重新检测;详细信息可在高级诊断中查看。`:`Model status is temporarily unavailable. Check again; details are available in Advanced diagnostics.`:e?`重新检测失败,请稍后重试;详细信息可在高级诊断中查看。`:`The check failed. Try again later; details are available in Advanced diagnostics.`}):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,$.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:e?`${d.length} 个来源,${f} 个可用模型${g?` · 最近同步 ${new Date(g).toLocaleString()}`:``}`:`${d.length} sources, ${f} available models${g?` · Last synced ${new Date(g).toLocaleString()}`:``}`}),y.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 rounded-lg bg-surface-base/45 p-2 font-mono text-[11px] leading-5`,"aria-label":e?`同步错误详情`:`Sync error details`,children:y.map(([e,t],n)=>(0,$.jsxs)(`p`,{className:`break-words`,children:[e,`: `,t]},`${e}-${n}`))}):null]}),(0,$.jsxs)(V,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:a,onClick:()=>void T(),children:[a?(0,$.jsx)(b,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ae,{className:`size-4`,"aria-hidden":!0}),a?e?`刷新中…`:`Refreshing…`:e?`刷新目录`:`Refresh catalog`]})]})]})]})}function _r(e){return nt.includes(e)}function vr(){let e=(0,zt.c)(69),t=M(xr),n;e[0]===t?n=e[1]:(n=D(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,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=He(),x;e[4]===b.cards?x=e[5]:(x=b.cards.some(br),e[4]=b.cards,e[5]=x);let S=x,C,w;e[6]!==h||e[7]!==d||e[8]!==f?(C=()=>{if(h!==`models`||d.get(`add`)!==`1`)return;_(!0);let e=new URLSearchParams(d);e.delete(`add`),f(e,{replace:!0})},w=[h,d,f],e[6]=h,e[7]=d,e[8]=f,e[9]=C,e[10]=w):(C=e[9],w=e[10]),(0,Q.useEffect)(C,w);let T;e[11]===i.tabs.models?T=e[12]:(T={id:`models`,icon:Ne,label:i.tabs.models},e[11]=i.tabs.models,e[12]=T);let E;e[13]===i.tabs.image?E=e[14]:(E={id:`image`,icon:Te,label:i.tabs.image},e[13]=i.tabs.image,e[14]=E);let O;e[15]!==T||e[16]!==E?(O=[T,E],e[15]=T,e[16]=E,e[17]=O):O=e[17];let k=O,A;e[18]===u?A=e[19]:(A=e=>u(Xe(e)),e[18]=u,e[19]=A);let j=A,N=yr;if(!_r(h)){let t;return e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(c,{to:Xe(`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=$e(t,`configuration`),e[21]=t,e[22]=I);let L;e[23]!==i.docsLink||e[24]!==F||e[25]!==I?(L=(0,$.jsx)(mt,{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 ee;e[31]!==i.tabsAria||e[32]!==h||e[33]!==P||e[34]!==k||e[35]!==j?(ee=P?(0,$.jsx)(ft,{items:k,activeTab:h,onChange:j,ariaLabel:i.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}):null,e[31]=i.tabsAria,e[32]=h,e[33]=P,e[34]=k,e[35]=j,e[36]=ee):ee=e[36];let z=P?`tabpanel`:void 0,B=`capability-panel-${h}`,V=P?`capability-tab-${h}`:void 0,te;e[37]!==i.connectedProviders||e[38]!==i.xopcCloudAccount||e[39]!==h||e[40]!==b||e[41]!==S?(te=h===`models`?(0,$.jsxs)($.Fragment,{children:[S?(0,$.jsx)(Rt,{labels:i.xopcCloudAccount}):null,(0,$.jsx)(Ge,{labels:i.connectedProviders,data:b,onAdd:()=>_(!0),onManage:(e,t)=>y({providerId:e,isCustom:t})}),b.cards.length>0?(0,$.jsx)(gr,{}):null]}):(0,$.jsx)(Sr,{section:h}),e[37]=i.connectedProviders,e[38]=i.xopcCloudAccount,e[39]=h,e[40]=b,e[41]=S,e[42]=te):te=e[42];let ne;e[43]!==z||e[44]!==B||e[45]!==V||e[46]!==te?(ne=(0,$.jsx)(`div`,{role:z,id:B,"aria-labelledby":V,className:`flex min-w-0 flex-col gap-4`,children:te}),e[43]=z,e[44]=B,e[45]=V,e[46]=te,e[47]=ne):ne=e[47];let re;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>N(),e[48]=re):re=e[48];let H;e[49]!==g||e[50]!==i.addProviderDialog||e[51]!==t||e[52]!==b.builtinRows||e[53]!==b.customConfig?(H=(0,$.jsx)(Le,{open:g,onOpenChange:_,builtinRows:b.builtinRows,customConfig:b.customConfig,labels:i.addProviderDialog,language:t,onSaved:re}),e[49]=g,e[50]=i.addProviderDialog,e[51]=t,e[52]=b.builtinRows,e[53]=b.customConfig,e[54]=H):H=e[54];let U;e[55]!==i.manageProviderDialog||e[56]!==t||e[57]!==v||e[58]!==b.allModels||e[59]!==b.builtinRows||e[60]!==b.customConfig?(U=v?(0,$.jsx)(sr,{open:!0,onOpenChange:e=>{e||y(null)},providerId:v.providerId,isCustom:v.isCustom,builtinRows:b.builtinRows,customConfig:b.customConfig,allModels:b.allModels,labels:i.manageProviderDialog,language:t,onSaved:N}):null,e[55]=i.manageProviderDialog,e[56]=t,e[57]=v,e[58]=b.allModels,e[59]=b.builtinRows,e[60]=b.customConfig,e[61]=U):U=e[61];let ie;return e[62]!==L||e[63]!==R||e[64]!==ee||e[65]!==ne||e[66]!==H||e[67]!==U?(ie=(0,$.jsxs)(ht,{children:[L,R,ee,ne,H,U]}),e[62]=L,e[63]=R,e[64]=ee,e[65]=ne,e[66]=H,e[67]=U,e[68]=ie):ie=e[68],ie}function yr(){se()}function br(e){return e.id===`xopc-cloud`&&!e.isCustom}function xr(e){return e.language}function Sr(e){let t=(0,zt.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)(tn,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(kn,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Zn,{}),t[2]=e):e=t[2],e}}}export{vr 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{f as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{s as a,t as o}from"./popover-select-BgSdSbCL.js";import{t as s}from"./circle-alert-BEjgurr2.js";import{t as c}from"./circle-check-C23XjkUj.js";import{t as l}from"./external-link-DjqjBmc3.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{t as d}from"./rotate-ccw-JM1TBLpp.js";import{t as f}from"./settings-2-D-csvaET.js";import{t as p}from"./x-B_N4OPjy.js";import{t as m}from"./messages-Cn25s55n.js";import{t as h}from"./cn-JdwAhgNB.js";import{a as g,c as _,i as v,n as y,r as b}from"./locale-store-DSsLH7JO.js";import{a as x,i as S,n as C,o as w,r as T,s as E,t as D}from"./dist-BGTk37IG.js";import{i as O}from"./vendor-swr-BIWyz7Rc.js";import{t as k}from"./button-CS04eWY9.js";import{t as ee}from"./interaction-BdhHBbYa.js";import{t as A}from"./skeleton-BwbyijEw.js";import{i as j,o as M}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{Cn as N,Ko as P,Rr as F,Tn as I,To as L,ci as R,gi as z,ho as B,pi as te,wn as ne,yn as re}from"./index-DU5FmDQh.js";import{r as ie}from"./settings-page-layout-X1x-2Cp9.js";import{t as ae}from"./browser-BLJWD7WI.js";import{n as oe}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as se}from"./schema-form-GwVc8KsT.js";var V=e(t(),1),H=n();async function ce(){return(await g(b(`/api/channels/status`))).payload?.channels||[]}function le(){return b(`/api/channels/status`)}var ue=ce;function de(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var fe=e(ae(),1),U=r();async function W(e){let t=await v(b(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function G(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function J(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function pe({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>de(e),[e]),o=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[s,d]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{d({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let f=(0,V.useCallback)(async(n,i)=>{d(e=>({...e,busy:!0,error:null}));try{let a=await W({channelId:e.id,actionId:n,locale:t,input:i});d(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){d(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=q(s.payload,e.id);if(!t){d(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return d(e=>e.generatedQr?{...e,generatedQr:null}:e),fe.toDataURL(t,{width:220,margin:1}).then(e=>{n||d(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,s.payload]),(0,V.useEffect)(()=>{let n=s.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||W({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(d(t=>({...t,payload:e,poll:G(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),G(e)&&window.clearInterval(a))}).catch(e=>{i||d(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,s.poll]);let p=a?.[1].label??(e.configured?n.reconnect:n.connect),m=e.actions?.[`doctor.run`]?.label??n.diagnose,g=K(s.payload),_=q(s.payload,e.id),v=_?s.generatedQr:J(s.payload),y=a?.[1].result===`qr`&&(s.busy||s.payload?.type===`qr`||s.payload?.type===`poll`),b=s.payload?.type===`form`?s.payload:null,x=s.payload?.type===`diagnostics`?s.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:h(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(k,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void f(a[0]),children:[s.busy?(0,U.jsx)(u,{className:`size-4 animate-spin`}):(0,U.jsx)(P,{className:`size-4`}),p]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(k,{type:`button`,variant:`secondary`,disabled:s.busy,onClick:()=>void f(`doctor.run`),children:[(0,U.jsx)(L,{className:`size-4`}),m]}):null]})]}),g?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:g}):null,s.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,y?(0,U.jsxs)(`div`,{className:h(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:v?(0,U.jsx)(`img`,{src:v,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(A,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:h(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[v?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(A,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(A,{className:`h-4 w-36 max-w-full`})]}),_?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:_,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(l,{className:`size-3.5`})]}):null]})]}):null,s.payload?.type===`poll`&&s.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(c,{className:s.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:s.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:s.payload.message??(s.payload.ok?n.complete:n.failed)})]}):null,b?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(se,{schema:b.schema,values:s.formDraft,onChange:e=>d(t=>({...t,formDraft:e})),disabled:s.busy,labels:o}),(0,U.jsx)(k,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void f(b.submitAction,s.formDraft),children:n.saveSetup})]}):null,x?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var me=40;function Y(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function he(e,t){return e.find(e=>e.id===Y(t))?.agentId?.trim().toLowerCase()??``}function ge(e,t,n){let r=Y(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:me,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function _e(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function ve(e,t,n){let r=_e(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function ye(e,t=!1){return e===`drawer`?h(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,j):h(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,j,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function be(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:o,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:m,headerExtra:g}=e,_=m===void 0?!1:m,v=n===`drawer`,[y,b]=(0,V.useState)(null),O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,U.jsx)(x,{className:h(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,M)}),t[0]=O):O=t[0];let A;t[1]!==n||t[2]!==_?(A=ye(n,_),t[1]=n,t[2]=_,t[3]=A):A=t[3];let j;t[4]===c?j=t[5]:(j=c?(0,U.jsx)(E,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=j);let N;t[6]===l?N=t[7]:(N=l?(0,U.jsx)(S,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=N);let P;t[8]!==u||t[9]!==s||t[10]!==g||t[11]!==v||t[12]!==o?(P=v?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[o?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:o}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(C,{asChild:!0,children:(0,U.jsx)(k,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(p,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(C,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:h(ee,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(p,{className:`size-4`})})}),g]}),t[8]=u,t[9]=s,t[10]=g,t[11]=v,t[12]=o,t[13]=P):P=t[13];let F=v?`p-4`:`p-6`,I;t[14]===F?I=t[15]:(I=h(`min-h-0 flex-1 overflow-y-auto`,F),t[14]=F,t[15]=I);let L;t[16]!==d||t[17]!==I?(L=(0,U.jsx)(`div`,{className:I,children:d}),t[16]=d,t[17]=I,t[18]=L):L=t[18];let R;t[19]!==f||t[20]!==y||t[21]!==j||t[22]!==N||t[23]!==P||t[24]!==L?(R=(0,U.jsxs)(a,{layer:`modal`,portalContainer:y,children:[j,N,P,L,f]}),t[19]=f,t[20]=y,t[21]=j,t[22]=N,t[23]=P,t[24]=L,t[25]=R):R=t[25];let z;t[26]!==R||t[27]!==A?(z=(0,U.jsxs)(w,{children:[O,(0,U.jsx)(T,{ref:b,className:A,onOpenAutoFocus:xe,children:R})]}),t[26]=R,t[27]=A,t[28]=z):z=t[28];let B;return t[29]!==i||t[30]!==r||t[31]!==z?(B=(0,U.jsx)(D,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=B):B=t[32],B}function xe(e){return e.preventDefault()}var Se=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(R,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ce(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(k,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(k,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(k,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function we(e){return b(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Te(e){return(await g(we(e))).payload?.channels??[]}function Ee(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?we(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Te(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=O(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var De=`channels-status`;function Oe(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function ke(e){let t=t=>e(t.detail);return window.addEventListener(De,t),()=>window.removeEventListener(De,t)}function Ae(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return ke(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function je(e){return e?b(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Me(e){return(await g(b(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ne=[`enabled`],Pe=`max-w-7xl`,Fe=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Ie(){let e=await g(b(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Le(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Re(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function ze(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Be(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ve(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function He(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ne.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ne.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ue(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Ue(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Ue(r[n]),properties:{}}),e===t.length-1){o[n]=Ue(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Ue(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Q(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function Je(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Ye(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push($(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Ye(e,Q(t,e),n);i&&r.push(i)}let a=Je(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=X(e),r=de(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=de(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function $(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function et({entry:e}){let[t,n]=(0,V.useState)(!1),r=(0,V.useMemo)(()=>!e.ui?.icon||t?null:new URL(b(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Le(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,U.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,U.jsx)(z,{sourceChannel:e.id,className:`size-7`})})}function tt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=h(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=h(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,U.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function nt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:l,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=X(n),t[0]=n,t[1]=f);let p=f,m,g,_,v,y,b,x;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==d||t[8]!==l||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Xe(n,r,s),o=$e(n,s);m=!p.enabled&&p.ready?l:i===`stopped`?d:c,b=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let u;t[19]===n?u=t[20]:(u=(0,U.jsx)(et,{entry:n}),t[19]=n,t[20]=u);let f;t[21]===n.label?f=t[22]:(f=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=f);let S;t[23]===i?S=t[24]:(S=h(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ve(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=ze(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==f?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[f,w]}),t[31]=w,t[32]=f,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==u?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[u,T]}),t[34]=T,t[35]=u,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==l||t[42]!==p.enabled||t[43]!==O?(k=(0,U.jsx)(tt,{checked:D,disabled:a,label:O,onToggle:l}),t[40]=a,t[41]=l,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(x=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=x):x=t[47],g=`button`,_=c,v=`mt-5 min-h-[6.25rem] text-left`,y=p.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(it)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,s)}),o.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(rt)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=d,t[8]=l,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x}else m=t[12],g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18];let S;t[48]!==g||t[49]!==_||t[50]!==v||t[51]!==y?(S=(0,U.jsx)(`button`,{type:g,onClick:_,className:v,children:y}),t[48]=g,t[49]=_,t[50]=v,t[51]=y,t[52]=S):S=t[52];let C=a||o,w;t[53]!==a||t[54]!==o?(w=a||o?(0,U.jsx)(u,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=w):w=t[55];let T;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?s.restartingChannel:i===`stopped`?s.restartChannel:Ze(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==w||t[63]!==T||t[64]!==C?(E=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(k,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:C,children:[w,T]})}),t[61]=m,t[62]=w,t[63]=T,t[64]=C,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==b||t[68]!==x||t[69]!==S?(D=(0,U.jsxs)(`article`,{className:b,children:[x,S,E]}),t[66]=E,t[67]=b,t[68]=x,t[69]=S,t[70]=D):D=t[70],D}function rt(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function it(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:l,onRestart:f,onCheck:p,onManageConnection:m}=e,g=n===`running`?c:n===`stopped`||n===`needs_setup`?s:u,_=n===`running`&&`text-emerald-600 dark:text-emerald-400`,v=n===`stopped`&&`text-red-600 dark:text-red-400`,y=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,b=n===`disabled`&&`text-fg-muted`,x=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,S;t[0]!==_||t[1]!==v||t[2]!==y||t[3]!==b||t[4]!==x?(S=h(`mt-0.5 size-5 shrink-0`,_,v,y,b,x),t[0]=_,t[1]=v,t[2]=y,t[3]=b,t[4]=x,t[5]=S):S=t[5];let C;t[6]!==g||t[7]!==S?(C=(0,U.jsx)(g,{className:S}),t[6]=g,t[7]=S,t[8]=C):C=t[8];let w;t[9]===l.connectionStatus?w=t[10]:(w=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectionStatus}),t[9]=l.connectionStatus,t[10]=w);let T;t[11]!==l||t[12]!==n?(T=Be(n,l),t[11]=l,t[12]=n,t[13]=T):T=t[13];let E;t[14]===T?E=t[15]:(E=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:T}),t[14]=T,t[15]=E);let D;t[16]!==E||t[17]!==w?(D=(0,U.jsxs)(`div`,{children:[w,E]}),t[16]=E,t[17]=w,t[18]=D):D=t[18];let O;t[19]!==D||t[20]!==C?(O=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[C,D]}),t[19]=D,t[20]=C,t[21]=O):O=t[21];let ee=i||r,A;t[22]===i?A=t[23]:(A=i?(0,U.jsx)(u,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=A);let j=i?l.checkingConnection:l.checkConnection,M;t[24]!==p||t[25]!==ee||t[26]!==A||t[27]!==j?(M=(0,U.jsxs)(k,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:ee,onClick:p,children:[A,j]}),t[24]=p,t[25]=ee,t[26]=A,t[27]=j,t[28]=M):M=t[28];let N;t[29]!==l.restartChannel||t[30]!==l.restartingChannel||t[31]!==i||t[32]!==f||t[33]!==r||t[34]!==n?(N=n===`stopped`?(0,U.jsxs)(k,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:f,children:[r?(0,U.jsx)(u,{className:`size-4 animate-spin`}):(0,U.jsx)(d,{className:`size-4`}),r?l.restartingChannel:l.restartChannel]}):null,t[29]=l.restartChannel,t[30]=l.restartingChannel,t[31]=i,t[32]=f,t[33]=r,t[34]=n,t[35]=N):N=t[35];let P;t[36]!==o||t[37]!==l.connectionOptions||t[38]!==l.hideConnectionOptions||t[39]!==i||t[40]!==m||t[41]!==r||t[42]!==a?(P=o?(0,U.jsx)(k,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:m,children:a?l.hideConnectionOptions:l.connectionOptions}):null,t[36]=o,t[37]=l.connectionOptions,t[38]=l.hideConnectionOptions,t[39]=i,t[40]=m,t[41]=r,t[42]=a,t[43]=P):P=t[43];let F;t[44]!==M||t[45]!==N||t[46]!==P?(F=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[M,N,P]}),t[44]=M,t[45]=N,t[46]=P,t[47]=F):F=t[47];let I;return t[48]!==O||t[49]!==F?(I=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[O,F]})}),t[48]=O,t[49]=F,t[50]=I):I=t[50],I}function ot(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=X(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl bg-amber-50 px-4 py-3 text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(B,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:$(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st({channelId:e,onHeaderActionChange:t}){let n=y(e=>e.language),r=m(n),a=_(e=>!!e.conversationId),s=i(),c=I(e),u=Ee(a,n),d=u.entries,{data:p,mutate:g,isValidating:x}=O(a?le():null,ue,{revalidateOnFocus:!0}),{data:S,mutate:C}=O(a?`channels-config-map`:null,Ie,{revalidateOnFocus:!1}),w=S?.channels??{},T=S?.bindings??[],{data:E}=O(a?`channel-routing-agents`:null,te,{revalidateOnFocus:!1}),D=(0,V.useMemo)(()=>d.find(e=>e.id===c),[c,d]),k=D?Re(D):null,{data:ee,mutate:A}=O(a&&k?je(k):null,()=>Me(k)),[j,M]=(0,V.useState)(null),[P,L]=(0,V.useState)(!1),[R,z]=(0,V.useState)(null),[B,ae]=(0,V.useState)(null),[H,ce]=(0,V.useState)(!1),[fe,W]=(0,V.useState)(null),[G,K]=(0,V.useState)(null),q=j??ee??{},J=r.channelsSettings,me=(0,V.useMemo)(()=>D?.configSchema??{type:`object`,properties:{}},[D?.configSchema]),Y=(0,V.useMemo)(()=>Ke(me,Ne),[me]),_e=(0,V.useMemo)(()=>He(D),[D]),ye=(0,V.useMemo)(()=>We(Y,_e),[_e,Y]),xe=(0,V.useMemo)(()=>Ke(Y,_e),[_e,Y]),we=(0,V.useMemo)(()=>qe(ye),[ye]),Te=D?G??he(T,D.id):``,De=(0,V.useMemo)(()=>(E?.items??[]).map(e=>{let t=re(e,r.agentsSettings);return{value:e.id,label:t===e.id?t:`${t} · ${e.id}`}}),[E?.items,r.agentsSettings]),ke=E?.items.find(e=>e.id===E.defaultId),Le=ke?re(ke,r.agentsSettings):E?.defaultId??``,Be=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Z=(0,V.useMemo)(()=>new Map((p??[]).map(e=>[e.name,e])),[p]),Ue=p!==void 0,Ge=(0,V.useCallback)(e=>ve(e,Z.get(e.id),Ue),[Z,Ue]),Q=(0,V.useCallback)(async()=>{await Promise.all([u.mutate(),g()])},[u,g]);Ae((0,V.useCallback)(e=>{let t=Oe(e);t&&g(t,!1)},[g]),a);let Je=(0,V.useMemo)(()=>a?{secondary:(0,U.jsx)(Se,{ch:J,refreshing:u.isValidating||x,saveOk:!1,onRefresh:()=>void Q()})}:null,[u.isValidating,J,a,x,Q]);(0,V.useLayoutEffect)(()=>(t?.(Je),()=>t?.(null)),[Je,t]);let Ye=(0,V.useCallback)(e=>{s(ne(e)),M(null),K(null),W(null)},[s]),Xe=(0,V.useCallback)(()=>{s(N),M(null),K(null),W(null)},[s]),Ze=(0,V.useCallback)(async e=>{ae(e.id),W(null);try{let t=await v(b(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){W(e instanceof Error?e.message:String(e))}finally{ae(null)}},[Q]);(0,V.useEffect)(()=>{K(null),ce(!1)},[D?.id]);let Qe=(0,V.useCallback)(async()=>{if(!D||!j&&G===null)return!1;let e=Re(D);L(!0),W(null);try{let t=await v(b(`/api/config`),{method:`PATCH`,body:JSON.stringify({...j?{channels:{[e]:j}}:{},...G===null?{}:{bindings:ge(T,D.id,G)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return j&&await A(j,!1),await C(),await u.mutate(),M(null),K(null),!0}catch(e){return W(e instanceof Error?e.message:String(e)),!1}finally{L(!1)}},[D,G,T,u,j,C,A]),$e=(0,V.useCallback)(async e=>{let t=X(e),n=Re(e),r=D?.id===e.id?j:null;if(!t.enabled&&!t.ready&&!r){Ye(e.id);return}z(e.id),W(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await v(b(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await u.mutate(),await C(),await g(),D?.id===e.id&&(await A(),M(null))}catch(e){W(e instanceof Error?e.message:String(e))}finally{z(null)}},[D?.id,u,j,C,A,g,Ye]),$=D?.ui?.modal,rt=$?.placement!==`replace-config`,it=D?Ge(D):`checking`,st=D?!X(D).ready||H:!1;return a?(0,U.jsxs)(ie,{gap:`gap-4`,className:Pe,padding:Fe,children:[u.isLoading?(0,U.jsx)(oe,{sections:2}):u.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(u.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:d.map(e=>(0,U.jsx)(nt,{entry:e,config:w[Re(e)]?.config,runtime:Ge(e),busy:R===e.id,restarting:B===e.id,ch:J,onOpen:()=>Ye(e.id),onToggle:()=>void $e(e),onRestart:()=>void Ze(e)},e.id))}),fe?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:fe}):null,(0,U.jsx)(be,{presentation:`modal`,open:!!D,onOpenChange:e=>{e||Xe()},closeAriaLabel:J.close,srTitle:D?.label??J.selectChannel,srDescription:D?.description,wide:!0,footer:D?(0,U.jsx)(Ce,{ch:J,dirty:!!j||G!==null,saving:P,onCancel:Xe,onDiscard:()=>{M(null),K(null)},onSave:Qe}):null,children:D?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(et,{entry:D}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:D.label}),(0,U.jsx)(`span`,{className:h(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ve(it)),children:ze(it,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(D).ready&&de(D)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,D.label):D.description}),D.docsPath?(0,U.jsxs)(`a`,{href:D.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(l,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(D).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(tt,{checked:X(D).enabled,disabled:R===D.id,label:J.toggleChannel.replace(`{{channel}}`,D.label),onToggle:()=>void $e(D)})]})]})}),(0,U.jsx)(at,{runtime:it,restarting:B===D.id,checking:x,showConnectionOptions:H,canManageConnection:X(D).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void Ze(D),onCheck:()=>void Q(),onManageConnection:()=>ce(e=>!e)}),(0,U.jsx)(ot,{entry:D,ch:J}),st&&$?.placement!==`replace-config`?(0,U.jsx)(pe,{entry:D,locale:n,messages:J,compact:!0,onChanged:async()=>{await A(),await Q(),await C()}},D.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(F,{extensionId:D.extensionId,extensionName:D.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:D.id,entry:D,config:q}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(F,{extensionId:D.extensionId,extensionName:D.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:D.id,entry:D,config:q}}):null,rt&&we?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(se,{schema:ye,values:q,onChange:e=>M(e),disabled:P,labels:Be})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(f,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(o,{value:Te,options:De,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,Le||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:P||!E,onChange:e=>K(e)})]})]}),rt&&qe(xe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(f,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(se,{schema:xe,values:q,onChange:e=>M(e),disabled:P,labels:Be})})]}):null,fe?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:fe}):null]}):null})]}):(0,U.jsx)(ie,{gap:`gap-3`,className:Pe,padding:Fe,children:(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})})}export{st as ChannelsSettingsPanel};
|