@xopcai/xopc 0.0.380 → 0.0.381
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-OKK1A-IR.js → agent-avatar-dicebear-BnMiU8HX.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Ddv61pUQ.js +1 -0
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-b24CxjaT.js → agent-plugin-dialog-C7z3r3Z3.js} +1 -1
- package/dist/gateway/static/root/assets/agents-BstMN5nH.js +66 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DxKh06hG.js → app-management-settings-panel-D2boumUX.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-C8CeHpdR.js → appearance-settings-Cwf53Rqo.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-CZSTLErb.js → apps-page-CwWCU5Ib.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-aoEF5gna.js → archive-plugin-DivP9LfK.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CSWWUZse.js → automations-page-DztgYZdC.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-SVRa19EF.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BM3Lr1BP.js → binary-plugins-f-JnMRA1.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DMZ3_pPz.js → block-editor-CEnzVIbk.js} +39 -39
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BcBLdyVd.js → browser-automation-inputs-DD-SUHmv.js} +1 -1
- package/dist/gateway/static/root/assets/browser-automations-page-m-9ETOOE.js +3 -0
- package/dist/gateway/static/root/assets/browser-settings-page-DN37CRLL.js +3 -0
- package/dist/gateway/static/root/assets/{cn-JdwAhgNB.js → bundle-mjs-rHxsej31.js} +1 -1
- package/dist/gateway/static/root/assets/{button-CS04eWY9.js → button-aIC072nz.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-D1MJHORS.js +2 -0
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-NZZNtjwZ.js → capabilities-settings-panel-DmwDOIlV.js} +6 -6
- package/dist/gateway/static/root/assets/{capability-header-actions-V7TdNf7i.js → capability-header-actions-DG-feQV0.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-icon-BYm2-nS-.js → capability-icon-DVoZxEgW.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-sgWMfPkw.js → channels-Bl6g4Dg9.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-B4HNp59x.js → chat-terminal-dock-CE3tIjLW.js} +2 -2
- package/dist/gateway/static/root/assets/cn-0WouolD0.js +1 -0
- package/dist/gateway/static/root/assets/{computer-settings-page-B2iwtbBu.js → computer-settings-page-UMzIyZN5.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-DTn3Z-MT.js → connector-service-page-P6yEnQ6H.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-DXhBTvqp.js +1 -0
- package/dist/gateway/static/root/assets/{copy-text-row-C1gaJwlZ.js → copy-text-row-C7egVuKr.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-DrUc4ivy.js → date-picker-eg-Uf9Wx.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-Bs16sgfD.js → dependency-picker-BEn7eZXu.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Dg0Cp16O.js → desktop-pet-DPAFil05.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BeJg3R-X.js → desktop-pet-settings-DK38Nevi.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-sprite-DTqXSpqf.js → desktop-pet-sprite-BP6iMVw1.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-DaRk9VLg.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BZkjdejC.js → directory-picker-path-field-Dm7jp0Y9.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CFnlTs2-.js → extension-debug-page-DJ1wFpMs.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BH25rxhA.js → extension-page-tPkDLwrG.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-CmaIRIVP.js → extension-provider-Dnz8j6Q_.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-D0af0S3r.js → extension-settings-page-Vp9FPajP.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-BD_9_8lg.js → fallback-models-DirZnl7x.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-CRbb12ar.js +1 -0
- package/dist/gateway/static/root/assets/highlight-code-BH65IIbJ.js +1 -0
- package/dist/gateway/static/root/assets/highlighted-body-KQOG7T2V-DdDvTjik.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BeIZyioN.js +2 -0
- package/dist/gateway/static/root/assets/{imports-page-CjFNSzDN.js → imports-page-KIeykeaL.js} +1 -1
- package/dist/gateway/static/root/assets/index-DxydK_AA.js +255 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DKdWZ7pq.js → keyboard-shortcuts-settings-5Df9Rng_.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CXJQpTS9.js → local-app-workbench-page-BSuq_SAr.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-9dyoG2s0.js → local-apps-page-D5-69OHu.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DHYqPwJ3.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-CxElPS5j.js → management-settings-uIgzZZ_J.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-DSjfHfaW.css → markdown-view-ByJbFign.css} +1 -1
- package/dist/gateway/static/root/assets/markdown-view-CZlvyzow.js +66 -0
- package/dist/gateway/static/root/assets/{media-plugins-C6tT2oPH.js → media-plugins-BtFqN13D.js} +1 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-DOTWm1iy.js +1 -0
- package/dist/gateway/static/root/assets/mermaid-render-604gISVe.js +134 -0
- package/dist/gateway/static/root/assets/note-detail-panel-sujG9ZmW.js +5 -0
- package/dist/gateway/static/root/assets/{note-image-lightbox-1qg2v-9j.js → note-image-lightbox-BYNLO2pt.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-api-ChO4X97y.js → notes-api-D-VLGhjV.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-C_4Ib15d.js +8 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-3bLWMSqt.js → page-context-capture-button-DErqGBBe.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-D2xpUV26.js → page-tabs-BLGO2VIm.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-CC3W2EZ0.js +1 -0
- package/dist/gateway/static/root/assets/{popover-select-BgSdSbCL.js → popover-select-DHC7J4lG.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-Dvey7GwU.js → preview-open-alternatives-BJU2fmPn.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-BiGwWy9s.js → product-open-page-B3qxtYyi.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-Dvy5ieTo.js → product-preview-content-NOhtxfkq.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-7BFqLZj4.js +1 -0
- package/dist/gateway/static/root/assets/{projects-page-CATt0m8t.js → projects-page-qhnc7oNj.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CS-zmmtV.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BnRVbeGi.js → runtime-tools-settings-panel-B55OozGG.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-BVjQ4A9S.js → scenes-page-BJZqRz8a.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-C0QHo3do.js → schema-form-BND8Hs4C.js} +1 -1
- package/dist/gateway/static/root/assets/{secret-input-D93UrW4C.js → secret-input-BxWHx6J6.js} +1 -1
- package/dist/gateway/static/root/assets/{send-session-input-BhWG0d-Z.js → send-session-input-BtF5UWGp.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-64DD1cxN.js +16 -0
- package/dist/gateway/static/root/assets/sessions-page-U5k3iucx.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-D8dOvd8T.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-exRhP9xn.js → settings-form-section-num14vSv.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-CAmWMaOT.js → settings-loading-skeleton-BTqvr_Fw.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BT6dQ5nv.js → settings-page-DOMl-bv4.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-X1x-2Cp9.js → settings-page-layout-Dx5S-Msc.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Dgpd7bk0.js +1 -0
- package/dist/gateway/static/root/assets/{share-link-dialog-Cu1miKUo.js → share-link-dialog-BnqkFFBZ.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CWH4BdnM.js → share-preview-page-aGjIkYmH.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DmFLUeqg.js +1 -0
- package/dist/gateway/static/root/assets/{skeleton-BwbyijEw.js → skeleton-BI5TyibZ.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-pzPKld3K.js → skill-api-C9AYuE_b.js} +1 -1
- package/dist/gateway/static/root/assets/skills-page-CJIhQfG2.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-CDuqpAIG.js → system-settings-panel-Cg0qUX2j.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-CNt-P3Kl.js → task-detail-page-C-VbndI4.js} +2 -2
- package/dist/gateway/static/root/assets/{task-expandable-content-Dgk9lYGd.js → task-expandable-content-UI-0Elqy.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-B90frz6c.js → tracing-settings-page-CawYzT24.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-BJ2UEjeF.js → tunnel-api-B8bvJesa.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-DrV2qcKO.js → usage-page-DdA0F-qo.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-Ct1x4pqI.js → use-autosave-jrZBPSWn.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-CyWRo1B1.js → use-composer-attachments-hTgxke6e.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-JIgp5qPT.js → use-file-preview-expanded-tMUDUWVH.js} +2 -2
- package/dist/gateway/static/root/assets/user-model-page-Bs6hUk15.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CSG8Hx8V.js → voice-api-key-field-Bp8brswu.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-Dp107FXF.js → work-discovery-overlay-CcIDsZWn.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CZKJ6leF.js → workflow-run-setup-panel-YP4TJpWE.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CYqVuquq.js +6 -0
- package/dist/gateway/static/root/assets/{workspace-api-DO_TWsiS.js → workspace-api-C01xjDt2.js} +2 -2
- package/dist/gateway/static/root/assets/xml-_d7dTN2Q.js +3 -0
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-CBjtpPiL.js → xopc-cloud-account-card-Cspd770Z.js} +1 -1
- package/dist/gateway/static/root/index.html +23 -20
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +3 -3
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/embedded/session-runner.js +21 -3
- package/dist/src/agent/embedded/tool-metadata.d.ts +2 -1
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/external-tools/index.js +6 -3
- package/dist/src/agent/external-tools/tool-registry.d.ts +2 -1
- package/dist/src/agent/service/process-direct-streaming.js +1 -1
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/personal-read-tool.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent/workspace-runtime/registry.js +1 -1
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/service/action-executor.js +1 -1
- package/dist/src/bootstrap/application-state.js +1 -1
- package/dist/src/browser/native-messaging-host.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +2 -2
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/config/agent-profile.js +2 -2
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.js +1 -1
- package/dist/src/endpoint-tools/registry.d.ts +4 -1
- package/dist/src/endpoint-tools/registry.js +14 -0
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/hono/app.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/browser-install.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/context-sources.js +1 -1
- package/dist/src/gateway/hono/routes/devices.js +1 -0
- package/dist/src/gateway/hono/routes/endpoint-tools.js +1 -0
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/image-generation-setup.js +1 -1
- package/dist/src/gateway/lock.js +1 -1
- package/dist/src/gateway/service.js +2 -2
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/personal-agent/proactivity/service.js +1 -1
- package/dist/src/personal-agent/prompt-context.js +3 -3
- package/dist/src/personal-agent/service.js +2 -2
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/routing/resolve-route.js +1 -1
- package/dist/src/routing/resolve-tui-session-key.js +1 -1
- package/dist/src/storage/sqlite/device-pairing-approval.js +1 -1
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/capabilities/write.js +1 -1
- package/dist/src/tasks/task-handoff-service.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +2 -2
- package/dist/src/voice/platform-streams.js +1 -0
- package/dist/src/voice/realtime/agentEngine.js +51 -2
- package/dist/src/voice/realtime/engine.d.ts +4 -0
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/dist/src/voice/realtime/runtime.js +3 -3
- package/package.json +6 -6
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-By5OXUfL.js +0 -1
- package/dist/gateway/static/root/assets/agents-tJxKA9VH.js +0 -66
- package/dist/gateway/static/root/assets/automations-workspace-D2RJ-Lzn.js +0 -6
- package/dist/gateway/static/root/assets/browser-automations-page-BLSr6du1.js +0 -3
- package/dist/gateway/static/root/assets/browser-settings-page-BlDHSstc.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-page-DHT4cB-Y.js +0 -2
- package/dist/gateway/static/root/assets/connectors-page-BJii6NMu.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-DPqFaLVI.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-Bzrm6DMQ.js +0 -1
- package/dist/gateway/static/root/assets/home-page-oHguULk0.js +0 -2
- package/dist/gateway/static/root/assets/index-hn5CBddI.js +0 -106
- package/dist/gateway/static/root/assets/logs-page-pMgnuu0O.js +0 -2
- package/dist/gateway/static/root/assets/markdown-view-B_7--qVD.js +0 -201
- package/dist/gateway/static/root/assets/note-detail-panel-4GI5kfs2.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-DaMnzWfF.js +0 -8
- package/dist/gateway/static/root/assets/personal-page-BeAW5QQd.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-BNgCsfeE.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-5o06KAdu.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-D2xce33J.js +0 -16
- package/dist/gateway/static/root/assets/sessions-page-BHYhAsHC.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DO148Ocl.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-B9EqOzrI.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-B3Z6sQEA.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-Busjd4VD.js +0 -2
- package/dist/gateway/static/root/assets/user-model-page-CQReU8e2.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-2HuveBs_.js +0 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
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-
|
|
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,H]=(0,Q.useState)(``),[te,U]=(0,Q.useState)(``),[W,G]=(0,Q.useState)([Ht()]),[K,ne]=(0,Q.useState)(``),[q,Y]=(0,Q.useState)(),[ae,oe]=(0,Q.useState)(!1),[X,Z]=(0,Q.useState)(),[se,ce]=(0,Q.useState)(),[ue
|
|
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-DHC7J4lG.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-BxWHx6J6.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-Ib6DaUTo.js";import{t as O}from"./cn-0WouolD0.js";import{a as k,c as A,i as j,n as M,r as N}from"./locale-store-pmT2B_By.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-aIC072nz.js";import{n as H,t as te}from"./interaction-BdhHBbYa.js";import{n as U,r as W}from"./gateway-config-swr-f-4qw3AG.js";import{a as G,o as K,s as ne}from"./form-field-width-DJw_jULe.js";import{n as re}from"./is-masked-secret-DOkL5b_X.js";import{t as q}from"./skeleton-BI5TyibZ.js";import{i as ie,o as J}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as Y}from"./electron-env-Dit0bHgy.js";import{n as ae,t as oe}from"./settings-form-draft-Dy10ldo8.js";import{i as X,r as Z,t as se}from"./models-hub-cache-3slk24cw.js";import{At as ce,Bs as le,Bt as ue,Cs as de,Ct as fe,Dt as pe,Et as me,Ft as he,Gc as ge,Ht as _e,It as ve,Lt as ye,Mt as be,No as xe,On as Se,Ot as Ce,Pt as we,Ro as Te,Rt as Ee,So as De,St as Oe,Tt as ke,Ut as Ae,Vo as je,W as Me,Wc as Ne,Ws as Pe,Wt as Fe,Yo as Ie,Zr as Le,_a as Re,_t as ze,ba as Be,bt as Ve,ca as He,da as Ue,do as We,ga as Ge,gt as Ke,ha as qe,ia as Je,jt as Ye,kt as Xe,ma as Ze,na as Qe,ns as $e,po as et,ra as tt,sa as nt,ui as rt,va as it,vt as at,wt as ot,xa as st,xo as ct,xt as lt,ya as ut,yt as dt,zt as ft}from"./index-DxydK_AA.js";import{t as pt}from"./page-tabs-BLGO2VIm.js";import{t as mt}from"./number-input-DDeqHK-G.js";import{n as ht,r as gt}from"./settings-page-layout-Dx5S-Msc.js";import{n as _t,t as vt}from"./settings-form-section-num14vSv.js";import{t as yt}from"./settings-loading-skeleton-BTqvr_Fw.js";import{n as bt,t as xt}from"./use-autosave-jrZBPSWn.js";import{c as St,d as Ct,i as wt,l as Tt,n as Et,o as Dt,r as Ot,s as kt,t as At}from"./voice-config-api-415pyWx8.js";import{t as jt}from"./voice-api-key-field-Bp8brswu.js";import{a as Mt,i as Nt,n as Pt,o as Ft,r as It,t as Lt}from"./image-generation-api-CtDjTXwX.js";import{t as Rt}from"./xopc-cloud-account-card-Cspd770Z.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,H]=(0,Q.useState)(``),[te,U]=(0,Q.useState)(``),[W,G]=(0,Q.useState)([Ht()]),[K,ne]=(0,Q.useState)(``),[q,Y]=(0,Q.useState)(),[ae,oe]=(0,Q.useState)(!1),[X,Z]=(0,Q.useState)(),[se,ce]=(0,Q.useState)(),[le,ue]=(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`),H(t?.network?.allowedHosts.join(`
|
|
4
4
|
`)??``),U(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
5
|
-
`)),G(t?.models.map(Ht)??[Ht()]),ne(t?.defaultModel??``),ce(void 0),Y(void 0),oe(!1),Z(void 0),
|
|
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}}}))}}}},
|
|
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:te,onChange:e=>U(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:()=>G(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:K||fe[0]?.value||``,options:fe,placeholder:o.defaultModel,allowEmpty:!1,onChange:ne,triggerClassName:`mt-1.5 max-w-sm`})]}),W.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=>pe(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=>pe(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=>pe(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=>pe(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=>pe(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=>pe(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=>pe(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=>pe(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:W.length===1,onClick:()=>G(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)(it,{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,se?(0,$.jsx)(`p`,{className:`rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:se}):null,X?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:X}):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:!!q,onClick:()=>void ve(),children:[q===`delete`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(it,{className:`size-4`}),ae?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:!!q,onClick:()=>void _e(),children:[q===`test`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):null,q===`test`?o.testing:o.test]}),(0,$.jsxs)(V,{variant:`primary`,disabled:!!q,onClick:()=>void ge(),children:[q===`save`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):null,q===`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)(q,{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)(q,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function en(e,t){return(0,$.jsx)(q,{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:H,error:te,mutate:W}=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 G=O?.find(e=>e.id===r),K=G?G.apiKeyUrl??we(G.id,e)[0]?.href:void 0,ne=(0,Q.useMemo)(()=>(G?.models??[]).map(e=>({value:e,label:e})),[G?.models]),q=z?.model?.primary,ie=!!(G&&o&&(G.credentialMode!==`api-key`||G.configured||c.trim())&&G.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||H)return(0,$.jsx)($t,{});if(P||R||te||!O||!I)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let J=e=>{a(e.id),s(e.defaultModel),l(e.configured?Gt:``),d(Xt(e)),_(void 0)},Y=()=>{D(void 0),C(!0)},ae=()=>{let e=I.find(e=>e.providerId===G?.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))}},X=async()=>{if(!(!G||!ie)){h(!0),_(void 0),x(!1);try{let e=await k(N(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:G.id,modelId:o,...c.trim()&&!re(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([W(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`)])),U()]),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)(ue,{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:Y,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(q);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>J(e),className:`min-h-24 rounded-xl p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${n?`bg-accent-soft shadow-surface`:`bg-surface-base/55 hover:bg-surface-hover`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-[10px] text-fg-subtle`,children:t.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!i,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${i?``:`invisible`}`,children:t.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(m,{className:`size-3.5`}):(0,$.jsx)(ve,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?t.configured:t.needsKey]})]},e.id)})})]}),G?(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:ne,placeholder:t.selectModel,allowEmpty:!1,onChange:s,triggerClassName:`mt-1.5`})]}),G.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))]}),G.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(V,{variant:`secondary`,onClick:ae,children:[(0,$.jsx)(T,{className:`size-4`}),t.manageService]})}):null,G.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}),K?(0,$.jsxs)(`a`,{href:K,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(le,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(v,{id:`image-generation-api-key`,value:c,onChange:e=>l(re(c)?e.replace(/^•+/,``):e),placeholder:G.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>Pe(G.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},G.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:G.configured?t.savedKey:t.apiKeyHint})]}):null,G.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)(Te,{className:`size-4`}),t.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:G.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:!ie||f,onClick:()=>void X(),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,engine:t=`agent`}){let n=M(e=>e.language),r=n===`zh`,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),{data:c,mutate:l,error:u}=B(N(`/api/voice/catalog`),async e=>{let t=await k(e);return rt.parse(t.payload)}),p=r?{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`},m=async e=>{if(c){a(!0),s(``);try{let t=await k(N(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:c.revision,selection:e})}:{}});await l(rt.parse(t.payload),!1),await U()}catch(e){s(e instanceof Error?e.message:String(e)),await l()}finally{a(!1)}}},h=t=>{let a=c.selections.find(e=>e.mode===t),o=c.models.filter(e=>e.voice.modes.includes(t)),s=o.find(e=>e.id===a?.model),l=s?.voice.voices.filter(e=>lt(e,t))??[],u=a?.voice??l.find(e=>e.id===s?.voice.defaultVoice)?.id??l[0]?.id??``;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:p[t]}),(0,$.jsxs)(d,{className:`w-full`,value:a?.model??``,disabled:i||e||!o.length,onChange:e=>void m({mode:t,model:e.target.value}),children:[(0,$.jsx)(f,{value:``,disabled:!0,children:r?`选择模型`:`Choose model`}),a&&!s?(0,$.jsxs)(f,{value:a.model,disabled:!0,children:[a.model,` · `,r?`不可用`:`Unavailable`]}):null,o.map(e=>(0,$.jsx)(f,{value:e.id,children:Fe(e,n)},e.id))]}),o.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:r?`暂无可用模型`:`No available model`})]}),s&&l.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:r?`音色`:`Voice`}),(0,$.jsxs)(d,{className:`w-full`,value:u,disabled:i||e,onChange:e=>void m({mode:t,model:s.id,voice:e.target.value}),children:[a?.voice&&!l.some(e=>e.id===a.voice)?(0,$.jsxs)(f,{value:a.voice,disabled:!0,children:[a.voice,` · `,r?`当前场景不可用`:`Unavailable for this mode`]}):null,l.map(e=>(0,$.jsxs)(f,{value:e.id,children:[Fe(e,n),e.gender?` · ${r?e.gender===`female`?`女声`:`男声`:e.gender}`:``,e.style?` · ${e.style}`:``]},e.id))]}),l.find(e=>e.id===u)?.description?(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:l.find(e=>e.id===u)?.description}):null]}):null]},t)},g=t===`omni`?[`conversation`]:[`transcription.stream`,`speech.stream`];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:r?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(V,{variant:`secondary`,disabled:i||e||!c,onClick:()=>void m(),children:r?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r?`修改在下次调用生效。各设备共用此 Gateway 的配置。`:`Changes apply to the next call and are shared across devices.`}),o||u?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:o||String(u)}):null,c?(0,$.jsxs)($.Fragment,{children:[g.map(h),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r?`其他语音场景`:`Other voice features`}),(0,$.jsx)(`div`,{className:`mt-4 space-y-4`,children:Object.keys(p).filter(e=>!g.includes(e)).map(h)})]})]}):(0,$.jsx)(q,{className:`h-48 w-full`})]})}function rn({v:e}){let t=ze(e=>e.microphoneId),n=ze(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)(He)?.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 Tt(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:st()}),t.signal.aborted){l();return}if(s=await Ie.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 Ze.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new Ge(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)(Je,{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,stt:t===`xopc-cloud`?e.voice.realtime.stt:void 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)(105),{section:n,v:r,form:i,pending:a,onChange:o}=e,s=M(fn),c=r.setup,u;t[0]===i?u=t[1]:(u=JSON.stringify(i),t[0]=i,t[1]=u);let p=u,m;t[2]===p?m=t[3]:(m={signature:p,input:!1,output:!1},t[2]=p,t[3]=m);let[h,g]=(0,Q.useState)(m);h.signature!==p&&g({signature:p,input:!1,output:!1});let _;t[4]!==a||t[5]!==p?(_=a?null:[`voice-realtime-status`,p],t[4]=a,t[5]=p,t[6]=_):_=t[6];let v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!0},t[7]=v):v=t[7];let{data:y,error:b,isLoading:x}=B(_,At,v),S;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=N(`/api/voice/catalog`),t[8]=S):S=t[8];let{data:C}=B(S,dn),w=i.voice.realtime,T=i.stt.provider,E=w.tts,D=E?.provider??y?.tts?.provider,O=y?.tts?.model,k;t[9]!==O||t[10]!==D?(k=D&&O?[`realtime-voices`,D,O]:null,t[9]=O,t[10]=D,t[11]=k):k=t[11];let A;t[12]!==O||t[13]!==D?(A=()=>Et(D,O,`realtime`),t[12]=O,t[13]=D,t[14]=A):A=t[14];let j;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(j={revalidateOnFocus:!1},t[15]=j):j=t[15];let{data:P}=B(k,A,j),F;t[16]===P?F=t[17]:(F=P===void 0?[]:P,t[16]=P,t[17]=F);let I=F,L=I,R;t[18]===I?R=t[19]:(R=I.filter(un),t[18]=I,t[19]=R);let ee=R,z=w.defaultEngine===`omni`,H=z?w.omni?.voice??``:E?.voice??y?.tts?.voice??``,te;t[20]!==C?.models||t[21]!==z||t[22]!==ee||t[23]!==w.omni?.model||t[24]!==w.omni?.provider||t[25]!==L?(te=z?w.omni?.provider===`xopc-cloud`?C?.models.find(e=>e.id===w.omni?.model)?.voice.voices.filter(ln)??[]:ee.length?ee:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(cn):L,t[20]=C?.models,t[21]=z,t[22]=ee,t[23]=w.omni?.model,t[24]=w.omni?.provider,t[25]=L,t[26]=te):te=t[26];let U=te,W=!!(y?.enabled&&y.stt),G=!!(y?.enabled&&y.tts),ne;t[27]!==i||t[28]!==o||t[29]!==w?(ne=e=>o({...i,voice:{...i.voice,realtime:{...w,...e}}}),t[27]=i,t[28]=o,t[29]=w,t[30]=ne):ne=t[30];let re=ne,ie;t[31]!==i||t[32]!==o?(ie=e=>o(on(i,e)),t[31]=i,t[32]=o,t[33]=ie):ie=t[33];let J=ie,Y;t[34]!==a||t[35]!==w.enabled||t[36]!==c.disabled||t[37]!==c.needsSetup||t[38]!==c.pending||t[39]!==c.unverified||t[40]!==c.verified||t[41]!==p||t[42]!==h.signature?(Y=(e,t)=>w.enabled?a?c.pending:e?t&&h.signature===p?c.verified:c.unverified:c.needsSetup:c.disabled,t[34]=a,t[35]=w.enabled,t[36]=c.disabled,t[37]=c.needsSetup,t[38]=c.pending,t[39]=c.unverified,t[40]=c.verified,t[41]=p,t[42]=h.signature,t[43]=Y):Y=t[43];let ae=Y,oe;t[44]!==J||t[45]!==b||t[46]!==i.tts||t[47]!==a||t[48]!==T||t[49]!==c.configureConversation||t[50]!==c.customProvider||t[51]!==c.edgeHint||t[52]!==c.finishSetup||t[53]!==c.hosted||t[54]!==c.hostedAccountHint||t[55]!==c.hostedHint||t[56]!==c.manageAccount||t[57]!==c.outputHint||t[58]!==c.ownKey||t[59]!==c.ownKeyHint||t[60]!==c.service||t[61]!==c.statusError||t[62]!==n||t[63]!==E||t[64]!==y?.tts?(oe=n===`service`?(0,$.jsxs)($.Fragment,{children:[b?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:c.statusError}):null,(0,$.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,$.jsx)(`legend`,{className:`text-sm font-medium text-fg`,children:c.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:e===`xopc-cloud`?T===e:T!==`xopc-cloud`,onChange:()=>J(e),className:`mt-1 accent-accent`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:e===`xopc-cloud`?c.hosted:c.ownKey}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e===`xopc-cloud`?c.hostedHint:c.ownKeyHint})]})]},e))})]}),T!==`alibaba`&&T!==`xopc-cloud`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.customProvider.replace(`{provider}`,T)}):null,T===`xopc-cloud`?(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[c.hostedAccountHint,` `,(0,$.jsx)(l,{className:`text-accent hover:underline`,to:`/settings/capabilities/models`,children:c.manageAccount})]}):null,!E&&!a&&!y?.tts&&(T===`alibaba`||T===`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:c.finishSetup}),(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:i.tts.provider===`edge`?c.edgeHint:c.outputHint}),(0,$.jsx)(V,{className:`mt-2`,type:`button`,variant:`secondary`,onClick:()=>J(T),children:c.configureConversation})]}):null]}):null,t[44]=J,t[45]=b,t[46]=i.tts,t[47]=a,t[48]=T,t[49]=c.configureConversation,t[50]=c.customProvider,t[51]=c.edgeHint,t[52]=c.finishSetup,t[53]=c.hosted,t[54]=c.hostedAccountHint,t[55]=c.hostedHint,t[56]=c.manageAccount,t[57]=c.outputHint,t[58]=c.ownKey,t[59]=c.ownKeyHint,t[60]=c.service,t[61]=c.statusError,t[62]=n,t[63]=E,t[64]=y?.tts,t[65]=oe):oe=t[65];let X;t[66]!==H||t[67]!==s||t[68]!==z||t[69]!==D||t[70]!==w.bargeIn||t[71]!==w.defaultEngine||t[72]!==w.enabled||t[73]!==w.omni||t[74]!==w.tts||t[75]!==c.bargeIn||t[76]!==c.defaultVoice||t[77]!==c.enable||t[78]!==c.voice||t[79]!==n||t[80]!==E||t[81]!==y?.tts||t[82]!==re||t[83]!==r.experience||t[84]!==r.realtime||t[85]!==U?(X=n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:c.enable}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":w.enabled,className:`ui-checkbox`,checked:w.enabled,onChange:e=>re({enabled:e.target.checked})})]}),(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(d,{value:w.defaultEngine,className:K,onChange:e=>re({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:[w.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]}),(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:c.voice}),(0,$.jsxs)(d,{id:`realtime-voice`,className:`${K} w-full sm:w-56`,value:H,disabled:z?!w.omni:!E&&!y?.tts,onChange:e=>{if(z&&w.omni){re({omni:{...w.omni,voice:e.target.value}});return}(D===`alibaba`||D===`xopc-cloud`)&&re({tts:{...w.tts,provider:D,...e.target.value?{voice:e.target.value}:{}},...w.omni&&[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.target.value)?{omni:{...w.omni,voice:e.target.value}}:{}})},children:[z?null:(0,$.jsx)(f,{value:``,children:c.defaultVoice}),H&&!U.some(e=>e.id===H)?(0,$.jsx)(f,{value:H,children:H}):null,U.map(e=>(0,$.jsxs)(f,{value:e.id,children:[Fe(e,s),`gender`in e&&e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,`style`in e&&e.style?` · ${e.style}`:``]},e.id))]}),(()=>{let e=U.find(e=>e.id===H);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:[c.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":w.bargeIn,checked:w.bargeIn,className:`size-4 accent-accent`,onChange:e=>re({bargeIn:e.target.checked})})]})]}):null,t[66]=H,t[67]=s,t[68]=z,t[69]=D,t[70]=w.bargeIn,t[71]=w.defaultEngine,t[72]=w.enabled,t[73]=w.omni,t[74]=w.tts,t[75]=c.bargeIn,t[76]=c.defaultVoice,t[77]=c.enable,t[78]=c.voice,t[79]=n,t[80]=E,t[81]=y?.tts,t[82]=re,t[83]=r.experience,t[84]=r.realtime,t[85]=U,t[86]=X):X=t[86];let Z;t[87]!==W||t[88]!==G||t[89]!==b||t[90]!==x||t[91]!==a||t[92]!==n||t[93]!==p||t[94]!==y||t[95]!==ae||t[96]!==r||t[97]!==h.input||t[98]!==h.output?(Z=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[x?(0,$.jsx)(q,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,ae(W,h.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,ae(W&&G,h.input&&h.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,ae(!!(y?.enabled&&y.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(an,{v:r,canListen:W,canSpeak:G,disabled:a||x||!!b,onVerified:e=>g({signature:p,...e})},`${p}:${JSON.stringify(y)}`)]}):null,t[87]=W,t[88]=G,t[89]=b,t[90]=x,t[91]=a,t[92]=n,t[93]=p,t[94]=y,t[95]=ae,t[96]=r,t[97]=h.input,t[98]=h.output,t[99]=Z):Z=t[99];let se;return t[100]!==c.service||t[101]!==oe||t[102]!==X||t[103]!==Z?(se=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":c.service,children:[oe,X,Z]}),t[100]=c.service,t[101]=oe,t[102]=X,t[103]=Z,t[104]=se):se=t[104],se}function cn(e){return{id:e,name:e}}function ln(e){return lt(e,`conversation`)}function un(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function dn(e){return rt.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(mn)===`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 overrides`,`自然对话独立配置`),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 d;t[9]===o?d=t[10]:(d=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]=d);let f;t[11]===d?f=t[12]:(f=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d}),t[11]=d,t[12]=f);let p;t[13]!==o||t[14]!==r||t[15]!==c||t[16]!==n?(p=n?(0,$.jsxs)($.Fragment,{children:[(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:o(`Separate API key (optional)`,`独立 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,$.jsx)(Ne,{title:o(`Custom endpoint`,`自定义服务地址`),summary:n.baseUrl||o(`Use the default endpoint`,`使用默认服务地址`),children:(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,$.jsx)(Ne,{title:o(`Conversation instructions`,`聊天指令`),summary:o(`Current instructions remain active`,`当前聊天指令继续生效`),children:(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]=p):p=t[17];let m;return t[18]!==u||t[19]!==f||t[20]!==p?(m=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[u,f,p]}),t[18]=u,t[19]=f,t[20]=p,t[21]=m):m=t[21],m}function mn(e){return e.language}var hn=G;function gn(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,ne,`dark:border-edge`)}function _n(){return O(K,G)}function vn(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function yn(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 bn(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function xn(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;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 Sn(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 Cn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function wn(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 Tn(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 En(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 Dn(){let e=M(e=>e.language),t=D(e).voiceSettings,[n,r]=o(),i=n.get(`voiceTab`),a=i===`service`||i===`devices`?i:`listening`,s=e=>r(t=>{let n=new URLSearchParams(t);return n.set(`voiceTab`,e),n}),c=ze(e=>e.captions),l=ze(e=>e.setCaptions),u=!!A(e=>e.conversationId),[p,m]=(0,Q.useReducer)(En,{form:null,baseline:null}),h=p.form,g=p.baseline,[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1),x=(0,Q.useRef)(!1),S=(0,Q.useRef)(h);S.current=h;let C=(0,Q.useRef)({parsed:null,models:void 0}),{data:w,error:T,isLoading:E,mutate:O}=W(u),{data:k,error:j,isLoading:P,mutate:F}=B(u?N(`/api/voice/models`):null,Ot,{revalidateOnFocus:!1}),{data:I,error:L,isLoading:R}=B(u?N(`/api/voice/providers`):null,wt,{revalidateOnFocus:!1}),{data:ee,error:z,isLoading:H}=B(u?N(`/api/voice/stt-providers`):null,Dt,{revalidateOnFocus:!1}),te=(0,Q.useMemo)(()=>I?.providers??[],[I]),U=(0,Q.useMemo)(()=>ee?.providers??[],[ee]),G=(0,Q.useMemo)(()=>w?.payload?.config===void 0?null:kt(w.payload.config),[w]),K=(0,Q.useMemo)(()=>!h||!g?!1:JSON.stringify(h)!==JSON.stringify(g),[h,g]);u?G!==null&&k!==void 0&&!x.current&&(C.current.parsed!==G||C.current.models!==k)&&(C.current={parsed:G,models:k},m({type:`sync`,value:G}),v(k)):(C.current.parsed!==null||C.current.models!==void 0)&&(C.current={parsed:null,models:void 0},m({type:`reset`}),v(null),x.current=!1);let ne=!!(u&&(G===null||k===void 0||I===void 0||ee===void 0)&&(E||P||R||H)),re=T instanceof Error?T.message:T?String(T):j instanceof Error?j.message:j?String(j):L instanceof Error?L.message:L?String(L):z instanceof Error?z.message:z?String(z):null,q=(0,Q.useCallback)(e=>{x.current=!0,m({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e},...e.provider&&e.provider!==`xopc-cloud`?{voice:{...t.voice,realtime:{...t.voice.realtime,stt:void 0}}}:{}}:null})},[]),ie=(0,Q.useCallback)(e=>{x.current=!0,m({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),J=(0,Q.useCallback)(e=>{x.current=!0,m({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),Y=(0,Q.useCallback)(t=>{x.current=!0,m({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),ae=(0,Q.useCallback)(e=>{x.current=!0,m({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),oe=(0,Q.useCallback)(e=>{x.current=!0,m({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),X=xt({value:h,dirty:K,onSave:(0,Q.useCallback)(async e=>{try{await St(e),m({type:`saved`,value:e}),x.current=!!(S.current&&JSON.stringify(S.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])}),Z=(0,Q.useCallback)(e=>{x.current=!0,m({type:`update`,updater:()=>e})},[]);if(!u)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(ne)return(0,$.jsx)(yt,{rows:4});if(!h||_===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:re??t.loadError}),(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>{O(),F()},children:t.retry})]});let se=h.stt,ce=h.tts,le=h.voice.input.refinement,ue=Cn(t);return(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,onBlurCapture:X.onBlurCapture,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,$.jsx)(bt,{status:X.status,error:X.error})}),X.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:X.error}):null,(0,$.jsx)(`nav`,{"aria-label":t.experience.tabsLabel,className:`flex flex-wrap gap-2`,children:[`listening`,`service`,`devices`].map(e=>(0,$.jsx)(V,{variant:a===e?`secondary`:`ghost`,"aria-pressed":a===e,onClick:()=>s(e),children:t.experience[e]},e))}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.experience[`${a}Hint`]}),a===`devices`?null:(0,$.jsx)(sn,{section:a,v:t,form:h,pending:K||X.status===`saving`||!!X.error,onChange:Z}),a===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kn,{v:t,voice:h.voice,updateLanguageMode:Y}),(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:_n(),value:String(h.voice.realtime.silenceDurationMs),onChange:e=>ae({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(h.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(f,{value:String(h.voice.realtime.silenceDurationMs),children:[h.voice.realtime.silenceDurationMs,` ms`]})]})]})}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[t.experience.captions,(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":c,className:`ui-checkbox`,checked:c,onChange:e=>l(e.target.checked)})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.experience.inputProcessing,` · `,le.mode===`off`?t.stt.refinementOff:le.mode===`punctuation`?t.stt.refinementPunctuation:le.mode===`light`?t.stt.refinementLight:t.setup.advanced]}),(0,$.jsxs)(`label`,{className:`mt-4 block 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:_n(),value:le.mode,onChange:e=>J({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}),le.mode===`custom`?(0,$.jsx)(f,{value:`custom`,children:t.setup.advanced}):null]})]})]}),(0,$.jsx)(On,{v:t,tts:ce,updateTts:oe})]}):null,a===`devices`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(rn,{v:t}),(0,$.jsx)(sn,{section:`diagnostics`,v:t,form:h,pending:K||X.status===`saving`||!!X.error,onChange:Z})]}):null,a===`service`?(0,$.jsxs)($.Fragment,{children:[se.provider===`xopc-cloud`?(0,$.jsx)(nn,{engine:h.voice.realtime.defaultEngine,disabled:K||X.status===`saving`}):(0,$.jsx)($.Fragment,{children:(0,$.jsx)(An,{v:t,apiKeyLabels:ue,stt:se,models:_,sttProviders:U,updateStt:q,updateSttFallback:ie})}),h.voice.realtime.enabled&&h.voice.realtime.omni?.provider===`alibaba`?(0,$.jsx)(pn,{value:h.voice.realtime.omni,onChange:e=>ae({omni:e})}):null,(0,$.jsxs)(`details`,{open:y,className:`rounded-xl bg-surface-hover/20 p-4`,"data-voice-section":`readout-service`,children:[(0,$.jsxs)(`summary`,{onClick:e=>{e.preventDefault(),b(!y)},className:`cursor-pointer text-sm font-medium text-fg`,children:[t.experience.readoutService,(0,$.jsx)(`span`,{className:`ml-2 font-normal text-fg-muted`,children:xn(ce.provider,t)})]}),y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.setup.readoutHint}),(0,$.jsx)(Mn,{v:t,apiKeyLabels:ue,tts:ce,models:_,ttsProviders:te,updateTts:oe})]}):null]}),se.provider===`xopc-cloud`?(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-hover/20 p-4`,"data-voice-section":`advanced`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:t.experience.technical}),(0,$.jsx)(An,{v:t,apiKeyLabels:ue,stt:se,models:_,sttProviders:U,updateStt:q,updateSttFallback:ie}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.notes.envVars})]}):null]}):null]})}function On(e){let t=(0,zt.c)(29),{v:n,tts:r,updateTts:i}=e,a;t[0]===n.setup.readout?a=t[1]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:n.setup.readout}),t[0]=n.setup.readout,t[1]=a);let o=n.setup.readout,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=_n(),t[2]=s):s=t[2];let c=r.enabled?r.trigger:`off`,l;t[3]===i?l=t[4]:(l=e=>i({enabled:e.target.value!==`off`,trigger:e.target.value}),t[3]=i,t[4]=l);let u;t[5]===n.tts.triggerOff?u=t[6]:(u=(0,$.jsx)(f,{value:`off`,children:n.tts.triggerOff}),t[5]=n.tts.triggerOff,t[6]=u);let p;t[7]===n.tts.triggerInbound?p=t[8]:(p=(0,$.jsx)(f,{value:`inbound`,children:n.tts.triggerInbound}),t[7]=n.tts.triggerInbound,t[8]=p);let m;t[9]===n.tts.triggerAlways?m=t[10]:(m=(0,$.jsx)(f,{value:`always`,children:n.tts.triggerAlways}),t[9]=n.tts.triggerAlways,t[10]=m);let h;t[11]===n.tts.triggerTagged?h=t[12]:(h=(0,$.jsx)(f,{value:`tagged`,children:n.tts.triggerTagged}),t[11]=n.tts.triggerTagged,t[12]=h);let g;t[13]!==c||t[14]!==l||t[15]!==u||t[16]!==p||t[17]!==m||t[18]!==h||t[19]!==n.setup.readout?(g=(0,$.jsxs)(d,{"aria-label":o,className:s,value:c,onChange:l,children:[u,p,m,h]}),t[13]=c,t[14]=l,t[15]=u,t[16]=p,t[17]=m,t[18]=h,t[19]=n.setup.readout,t[20]=g):g=t[20];let _;t[21]!==a||t[22]!==g?(_=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[a,g]}),t[21]=a,t[22]=g,t[23]=_):_=t[23];let v;t[24]===n.setup.readoutHint?v=t[25]:(v=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.readoutHint}),t[24]=n.setup.readoutHint,t[25]=v);let y;return t[26]!==_||t[27]!==v?(y=(0,$.jsxs)(`section`,{className:`space-y-2 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,children:[_,v]}),t[26]=_,t[27]=v,t[28]=y):y=t[28],y}function kn(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=_n(),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 An(e){let t=(0,zt.c)(63),{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(jn),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,{"aria-hidden":`true`,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)(`h3`,{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.enable?D=t[27]:(D=(0,$.jsx)(`span`,{children:n.stt.enable}),t[26]=n.stt.enable,t[27]=D);let k;t[28]===s?k=t[29]:(k=e=>s({enabled:e.target.checked}),t[28]=s,t[29]=k);let A;t[30]!==i.enabled||t[31]!==k?(A=(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i.enabled,className:`ui-checkbox`,checked:i.enabled,onChange:k}),t[30]=i.enabled,t[31]=k,t[32]=A):A=t[32];let j;t[33]!==D||t[34]!==A?(j=(0,$.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-xs text-fg-muted`,children:[D,A]}),t[33]=D,t[34]=A,t[35]=j):j=t[35];let M;t[36]!==j||t[37]!==E?(M=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[E,j]}),t[36]=j,t[37]=E,t[38]=M):M=t[38];let N;t[39]===n.stt.description?N=t[40]:(N=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[39]=n.stt.description,t[40]=N);let P;t[41]!==M||t[42]!==N?(P=(0,$.jsxs)(`div`,{className:`mb-4`,children:[M,N]}),t[41]=M,t[42]=N,t[43]=P):P=t[43];let F;t[44]!==p?.fields||t[45]!==r||t[46]!==y||t[47]!==m||t[48]!==u||t[49]!==h||t[50]!==i.enabled||t[51]!==i.fallback?.enabled||t[52]!==i.provider||t[53]!==S||t[54]!==s||t[55]!==c||t[56]!==n?(F=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`,hn),children:[(0,$.jsx)(zn,{children:n.stt.provider}),(0,$.jsx)(d,{"aria-label":n.stt.provider,className:_n(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:u.map(e=>(0,$.jsxs)(f,{value:e.id,children:[bn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(Nn,{kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:y,apiKeyLabels:r,onPatch:S})]}),i.provider===`alibaba`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.keyHint}):null,(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:n.stt.fallback}),(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[44]=p?.fields,t[45]=r,t[46]=y,t[47]=m,t[48]=u,t[49]=h,t[50]=i.enabled,t[51]=i.fallback?.enabled,t[52]=i.provider,t[53]=S,t[54]=s,t[55]=c,t[56]=n,t[57]=F):F=t[57];let I;t[58]===F?I=t[59]:(I=(0,$.jsx)(`div`,{className:`space-y-4`,children:F}),t[58]=F,t[59]=I);let L;return t[60]!==P||t[61]!==I?(L=(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[P,I]}),t[60]=P,t[61]=I,t[62]=L):L=t[62],L}function jn(e){return e.key===`model`}function Mn({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,()=>Et(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=(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&&P(e)},[w,j,T,M,x,P,S]),(0,Q.useEffect)(()=>()=>h(),[h]);let F=(0,Q.useCallback)(e=>{a({provider:e}),l({status:`idle`})},[a]),I=(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 Ct({text:t,provider:n.provider,providerConfig:v,...T?{model:T}:{},...M?{voice:M}:{}},r.signal);if(r.signal.aborted)return;let a=yn(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`,vn(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)(Xe,{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,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:e.tts.provider}),(0,$.jsx)(d,{"aria-label":e.tts.provider,className:_n(),value:n.provider,onChange:e=>F(e.target.value),children:g.map(t=>(0,$.jsx)(f,{value:t.id,children:xn(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??Sn(n.provider,e)]})]})}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(Nn,{kind:`tts`,providerId:n.provider,fields:N,providerSlice:v,models:y,voices:A,currentModel:T,currentVoice:M,apiKeyLabels:t,onPatch:P,resetVoiceOnModelChange:!0})}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsx)(`div`,{children:(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 I(),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)(Je,{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(gn(),`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]})]})]})]})})]})}function Nn(e){let t=(0,zt.c)(39),{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;t[2]===v?y=t[3]:(y=D(v),t[2]=v,t[3]=y);let b=y.voiceSettings,x=Fn,S,C;if(t[4]!==u||t[5]!==c||t[6]!==l||t[7]!==i||t[8]!==n||t[9]!==v||t[10]!==o||t[11]!==p||t[12]!==r||t[13]!==a||t[14]!==_||t[15]!==b||t[16]!==g){let e;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>!x(e),t[19]=e):e=t[19];let s=i.filter(e),m;t[20]!==u||t[21]!==c||t[22]!==l||t[23]!==n||t[24]!==v||t[25]!==o||t[26]!==p||t[27]!==r||t[28]!==a||t[29]!==_||t[30]!==b||t[31]!==g?(m=e=>e.map(e=>e.key===`apiKey`?(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{htmlFor:`voice-${n}-${r}-api-key`,children:b.stt.apiKey}),(0,$.jsx)(jt,{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`,hn),children:[(0,$.jsx)(zn,{htmlFor:`voice-${n}-${r}-model`,children:b.stt.model}),(0,$.jsx)(d,{id:`voice-${n}-${r}-model`,className:_n(),value:c??``,onChange:e=>p({model:e.target.value,..._?{voice:void 0}:{}}),children:o.map(Pn)})]},e.key):e.key===`voice`&&g.length>0?(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{htmlFor:`voice-${n}-${r}-voice`,children:b.tts.voice}),(0,$.jsxs)(d,{id:`voice-${n}-${r}-voice`,className:_n(),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:[Fe(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)(Ln,{fieldId:`voice-${n}-${r}-${e.key}`,field:e,value:wn(a,e),onChange:t=>p({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:hn},e.key)),t[20]=u,t[21]=c,t[22]=l,t[23]=n,t[24]=v,t[25]=o,t[26]=p,t[27]=r,t[28]=a,t[29]=_,t[30]=b,t[31]=g,t[32]=m):m=t[32];let h=m;t[33]!==i||t[34]!==h?(S=h(i.filter(x)),t[33]=i,t[34]=h,t[35]=S):S=t[35],C=s.length?(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3 sm:col-span-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:b.experience.providerOptions}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:h(s)})]}):null,t[4]=u,t[5]=c,t[6]=l,t[7]=i,t[8]=n,t[9]=v,t[10]=o,t[11]=p,t[12]=r,t[13]=a,t[14]=_,t[15]=b,t[16]=g,t[17]=S,t[18]=C}else S=t[17],C=t[18];let w;return t[36]!==S||t[37]!==C?(w=(0,$.jsxs)($.Fragment,{children:[S,C]}),t[36]=S,t[37]=C,t[38]=w):w=t[38],w}function Pn(e){return(0,$.jsx)(f,{value:e.id,children:e.name},e.id)}function Fn(e){return e.required||[`apiKey`,`model`,`voice`].includes(e.key)}function In(e){return e.language}function Ln(e){let t=(0,zt.c)(37),{fieldId:n,field:r,value:i,onChange:a,className:o}=e,s=n??`voice-schema-field-${r.key}`,c=r.description;if(r.type===`boolean`){let e;t[0]===o?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`,o),t[0]=o,t[1]=e);let n;t[2]===r.label?n=t[3]:(n=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r.label}),t[2]=r.label,t[3]=n);let s;t[4]===c?s=t[5]:(s=c?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=s);let l;t[6]!==n||t[7]!==s?(l=(0,$.jsxs)(`span`,{children:[n,s]}),t[6]=n,t[7]=s,t[8]=l):l=t[8];let u=!!i,d;t[9]!==r||t[10]!==a?(d=e=>a(Tn(r,e.target.checked)),t[9]=r,t[10]=a,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 l=typeof i==`boolean`?``:String(i),u;t[19]===o?u=t[20]:(u=O(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let f;t[21]!==r.label||t[22]!==s?(f=(0,$.jsx)(zn,{htmlFor:s,children:r.label}),t[21]=r.label,t[22]=s,t[23]=f):f=t[23];let p;t[24]!==o||t[25]!==r||t[26]!==l||t[27]!==s||t[28]!==a?(p=r.type===`select`?(0,$.jsx)(d,{id:s,className:_n(),value:l,required:r.required,onChange:e=>a(Tn(r,e.target.value)),children:(r.options??[]).map(Rn)}):r.type===`textarea`?(0,$.jsx)(`textarea`,{id:s,className:O(gn(),`min-h-24 resize-y`),value:l,required:r.required,placeholder:r.placeholder,onChange:e=>a(Tn(r,e.target.value))}):r.type===`password`?(0,$.jsx)(v,{id:s,className:o,value:l,onChange:e=>a(Tn(r,e)),placeholder:r.placeholder,labels:et}):r.type===`number`?(0,$.jsx)(mt,{id:s,className:gn(),autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,allowEmpty:!r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(Tn(r,e.target.value))}):(0,$.jsx)(`input`,{id:s,className:gn(),type:`text`,autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(Tn(r,e.target.value))}),t[24]=o,t[25]=r,t[26]=l,t[27]=s,t[28]=a,t[29]=p):p=t[29];let m;t[30]===c?m=t[31]:(m=c?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[30]=c,t[31]=m);let h;return t[32]!==u||t[33]!==f||t[34]!==p||t[35]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[f,p,m]}),t[32]=u,t[33]=f,t[34]=p,t[35]=m,t[36]=h):h=t[36],h}function Rn(e){return(0,$.jsx)(f,{value:e.id,children:e.name},e.id)}function zn(e){let t=(0,zt.c)(3),{children:n,htmlFor:r}=e,i;return t[0]!==n||t[1]!==r?(i=r?(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:n}):(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Bn(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function Vn(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 Hn(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}}}})}),U()}async function Un(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 Wn(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 Gn(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,ne,`dark:border-edge`)}function Kn(){return O(K,G)}var qn=[`brave`,`tavily`,`bing`,`searxng`];function Jn(){return{clientKey:crypto.randomUUID(),type:`brave`,apiKey:``,url:``,disabled:!1}}var Yn=oe();function Xn(){let e=D(M(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!A(e=>e.conversationId),[i,a]=(0,Q.useReducer)(Yn,{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:_}=W(r);ae({enabled:r,parsed:(0,Q.useMemo)(()=>p?.payload?.config===void 0?null:Vn(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=xt({value:o,dirty:b,onSave:(0,Q.useCallback)(async e=>{try{await Hn(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)(yt,{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=Bn(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)(vt,{children:[(0,$.jsx)(_t,{icon:De,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(bt,{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)(Zn,{row:n,providerIndex:r,labels:t,secretLabels:Ve(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,Jn()]}),children:[(0,$.jsx)(w,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(vt,{children:[(0,$.jsx)(_t,{icon:Te,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(Wn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(d,{className:Kn(),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)(Ne,{title:t.maxResultsLabel,summary:o.maxResults,children:(0,$.jsx)(Wn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(mt,{type:`number`,min:1,max:50,className:Gn(),value:o.maxResults,onChange:e=>x({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})})})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.sectionBlocklist,` · `,o.blocklistEnabled?o.blocklistDomains.length:0]}),(0,$.jsxs)(vt,{children:[(0,$.jsx)(_t,{icon:be,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)(Wn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:O(Gn(),`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 Zn(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=()=>Un(r).then(Qn),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=O(Kn(),`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=qn.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)(it,{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)(Wn,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Gn(),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)(Wn,{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 Qn(e){return e.apiKey??null}function $n(e){let t=(0,zt.c)(185),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=M(tr)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:Ae(``),t[0]=n,t[1]=l);let[u,p]=(0,Q.useState)(l),[m,h]=(0,Q.useState)(er),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=fe(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(te,`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(ct(),m.has(`id`)&&`border-red-500`),t[37]=m,t[38]=z);let B=u.id||``,H;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>_(`id`,e.target.value),t[39]=H):H=t[39];let U=!r,W;t[40]!==z||t[41]!==B||t[42]!==U?(W=(0,$.jsx)(`input`,{className:z,value:B,onChange:H,placeholder:`e.g. llama3.1:8b`,disabled:U}),t[40]=z,t[41]=B,t[42]=U,t[43]=W):W=t[43];let G;t[44]===m?G=t[45]:(G=m.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`id`)}):null,t[44]=m,t[45]=G);let K;t[46]!==R||t[47]!==W||t[48]!==G?(K=(0,$.jsxs)(`div`,{children:[R,W,G]}),t[46]=R,t[47]=W,t[48]=G,t[49]=K):K=t[49];let ne;t[50]===s.displayName?ne=t[51]:(ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=ne);let re;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(re=ct(),t[52]=re):re=t[52];let q=u.name||``,ie;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>_(`name`,e.target.value),t[53]=ie):ie=t[53];let J;t[54]===q?J=t[55]:(J=(0,$.jsx)(`input`,{className:re,value:q,onChange:ie}),t[54]=q,t[55]=J);let Y;t[56]!==ne||t[57]!==J?(Y=(0,$.jsxs)(`div`,{children:[ne,J]}),t[56]=ne,t[57]=J,t[58]=Y):Y=t[58];let ae;t[59]===s.inputTypes?ae=t[60]:(ae=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=ae);let oe;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(oe=ot(),t[61]=oe):oe=t[61];let X;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(X=e=>_(`input`,ke(e.target.value)),t[62]=X):X=t[62];let Z;t[63]===s?Z=t[64]:(Z=Be.map(e=>(0,$.jsx)(f,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=Z);let se;t[65]!==w||t[66]!==Z?(se=(0,$.jsx)(d,{className:oe,value:w,onChange:X,children:Z}),t[65]=w,t[66]=Z,t[67]=se):se=t[67];let ce;t[68]!==ae||t[69]!==se?(ce=(0,$.jsxs)(`div`,{children:[ae,se]}),t[68]=ae,t[69]=se,t[70]=ce):ce=t[70];let le=u.reasoning||!1,ue;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>_(`reasoning`,e.target.checked),t[71]=ue):ue=t[71];let de;t[72]===le?de=t[73]:(de=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:le,onChange:ue}),t[72]=le,t[73]=de);let pe;t[74]!==s.reasoning||t[75]!==de?(pe=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[de,s.reasoning]}),t[74]=s.reasoning,t[75]=de,t[76]=pe):pe=t[76];let me;t[77]!==ce||t[78]!==pe?(me=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ce,pe]}),t[77]=ce,t[78]=pe,t[79]=me):me=t[79];let he;t[80]===s.contextWindow?he=t[81]:(he=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=he);let ge;t[82]===m?ge=t[83]:(ge=O(ct(),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)(mt,{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(ct(),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)(mt,{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 Oe;t[104]!==Se||t[105]!==Ee||t[106]!==De?(Oe=(0,$.jsxs)(`div`,{children:[Se,Ee,De]}),t[104]=Se,t[105]=Ee,t[106]=De,t[107]=Oe):Oe=t[107];let je;t[108]!==xe||t[109]!==Oe?(je=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[xe,Oe]}),t[108]=xe,t[109]=Oe,t[110]=je):je=t[110];let Me;t[111]===s.costSection?Me=t[112]:(Me=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=Me);let Ne;t[113]===s.costInput?Ne=t[114]:(Ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Ne);let Pe;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=ct(),t[115]=Pe):Pe=t[115];let Fe=u.cost?.input??0,Ie;t[116]===u.cost?Ie=t[117]:(Ie=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]=Ie);let Le;t[118]!==Fe||t[119]!==Ie?(Le=(0,$.jsx)(mt,{type:`number`,step:`any`,min:0,className:Pe,value:Fe,onChange:Ie}),t[118]=Fe,t[119]=Ie,t[120]=Le):Le=t[120];let Re;t[121]!==Ne||t[122]!==Le?(Re=(0,$.jsxs)(`div`,{children:[Ne,Le]}),t[121]=Ne,t[122]=Le,t[123]=Re):Re=t[123];let ze;t[124]===s.costOutput?ze=t[125]:(ze=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=ze);let Ve;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=ct(),t[126]=Ve):Ve=t[126];let He=u.cost?.output??0,Ue;t[127]===u.cost?Ue=t[128]:(Ue=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]=Ue);let We;t[129]!==He||t[130]!==Ue?(We=(0,$.jsx)(mt,{type:`number`,step:`any`,min:0,className:Ve,value:He,onChange:Ue}),t[129]=He,t[130]=Ue,t[131]=We):We=t[131];let Ge;t[132]!==ze||t[133]!==We?(Ge=(0,$.jsxs)(`div`,{children:[ze,We]}),t[132]=ze,t[133]=We,t[134]=Ge):Ge=t[134];let Ke;t[135]!==Re||t[136]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Re,Ge]}),t[135]=Re,t[136]=Ge,t[137]=Ke):Ke=t[137];let qe;t[138]!==Me||t[139]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Me,Ke]}),t[138]=Me,t[139]=Ke,t[140]=qe):qe=t[140];let Je;t[141]!==K||t[142]!==Y||t[143]!==me||t[144]!==je||t[145]!==qe?(Je=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[K,Y,me,je,qe]}),t[141]=K,t[142]=Y,t[143]=me,t[144]=je,t[145]=qe,t[146]=Je):Je=t[146];let Ye=c?`高级:电脑控制协议`:`Advanced: Computer Use protocol`,Xe;t[147]===Ye?Xe=t[148]:(Xe=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Ye}),t[147]=Ye,t[148]=Xe);let Ze=c?`电脑控制协议`:`Computer Use protocol`,Qe=u.computerUse?.profile??``,$e;t[149]===Symbol.for(`react.memo_cache_sentinel`)?($e=e=>_(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=$e):$e=t[149];let et=c?`未声明`:`Not declared`,tt;t[150]===et?tt=t[151]:(tt=(0,$.jsx)(f,{value:``,children:et}),t[150]=et,t[151]=tt);let nt,rt,it;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(nt=(0,$.jsx)(f,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),rt=(0,$.jsx)(f,{value:`structured-tools-v1`,children:`structured-tools-v1`}),it=(0,$.jsx)(f,{value:`openai-responses-computer-v1`,children:`OpenAI Responses Computer`}),t[152]=nt,t[153]=rt,t[154]=it):(nt=t[152],rt=t[153],it=t[154]);let at;t[155]!==Ze||t[156]!==Qe||t[157]!==tt?(at=(0,$.jsxs)(d,{"aria-label":Ze,value:Qe,onChange:$e,children:[tt,nt,rt,it]}),t[155]=Ze,t[156]=Qe,t[157]=tt,t[158]=at):at=t[158];let st=c?`协议必须与模型 API 匹配。声明协议不代表模型已通过效果验证。`:`The protocol must match the model API. Declaring a protocol does not certify model quality.`,lt;t[159]===st?lt=t[160]:(lt=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:st}),t[159]=st,t[160]=lt);let ut;t[161]===m?ut=t[162]:(ut=m.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:m.get(`computerUse`)}),t[161]=m,t[162]=ut);let dt;t[163]!==at||t[164]!==lt||t[165]!==ut?(dt=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[at,lt,ut]}),t[163]=at,t[164]=lt,t[165]=ut,t[166]=dt):dt=t[166];let ft;t[167]!==Xe||t[168]!==dt?(ft=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Xe,dt]}),t[167]=Xe,t[168]=dt,t[169]=ft):ft=t[169];let pt;t[170]!==Je||t[171]!==ft?(pt=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[Je,ft]}),t[170]=Je,t[171]=ft,t[172]=pt):pt=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]!==pt||t[183]!==vt?(yt=(0,$.jsxs)($.Fragment,{children:[F,pt,vt]}),t[181]=F,t[182]=pt,t[183]=vt,t[184]=yt):yt=t[184],yt}function er(){return new Map}function tr(e){return e.language}function nr(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`,J)}),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`,ie,`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)($n,{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:rr,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 rr(e){return e.preventDefault()}function ir(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=()=>Pe(n).then(ar),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 ar(e){return e.apiKey??null}function or(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]`,J)}),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`,ie),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)(dt,{target:f,zh:u===`zh`,onDone:()=>h(!1)}):a?(0,$.jsx)(cr,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onModelAdded:e=>p({providerId:i,modelIds:[e]})}):(0,$.jsx)(sr,{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 sr({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`),[te,U]=(0,Q.useState)(null),[W,G]=(0,Q.useState)(null),[K,re]=(0,Q.useState)(null),[q,ie]=(0,Q.useState)(``),J=(0,Q.useRef)(null),Y=(0,Q.useRef)(null),ae=z===`waiting`||z===`waiting_code`,oe=(0,Q.useMemo)(()=>we(e,i),[e,i]),X=p!==(s?.apiKey??``),Z=async()=>{let t=p.trim();if(!(!t||!A||_e(t))){v(!0),C(null);try{await je({[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||!ae)return;let e=window.setInterval(()=>{(async()=>{try{let t=await ye(P);t.status===`waiting_auth`||t.status===`waiting_code`?(B(t.status===`waiting_code`?`waiting_code`:`waiting`),R(t.message??null),U(t.authUrl??null),G(t.instructions??null),re(t.deviceCode??null),t.authUrl&&t.authUrl!==Y.current&&(Y.current=t.authUrl,qe(t.authUrl,J.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),ce(J.current),J.current=null,B(`success`),R(t.message??k.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),ce(J.current),J.current=null,B(`error`),R(t.error??t.message??k.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,ae,a,o,k.revokeFailed,k.saved]),(0,Q.useEffect)(()=>()=>{P&&he(P).catch(()=>{})},[P]),(0,Q.useEffect)(()=>()=>{ce(J.current),J.current=null},[]);let se=async()=>{try{await de(e),o(),a()}catch{}},le=async()=>{ce(J.current),J.current=Se(),Y.current=null,B(`waiting`),R(k.oauthStarting),U(null),G(null),re(null),C(null);try{F((await Oe(e)).sessionId)}catch(e){ce(J.current),J.current=null,B(`error`),R(e instanceof Error?e.message:k.revokeFailed)}},ue=async()=>{if(P){try{await Ee(P)}catch{}ce(J.current),J.current=null,Y.current=null,B(`idle`),R(null),F(null),U(null),G(null),re(null)}},fe=async()=>{if(!(!P||!q.trim()))try{await ft(P,q.trim()),ie(``),R(k.oauthProcessingCode)}catch(e){B(`error`),R(e instanceof Error?e.message:k.revokeFailed)}},me=async()=>{try{await xe(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`,H.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)(ir,{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:ae,onClick:()=>void le(),children:[ae?(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(ut,{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:[te?(0,$.jsxs)(`a`,{href:te,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 ue(),children:k.cancelOAuth})]}):null,W?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:W}):null,K?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:k.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:K}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:k.deviceCodeHint})]}):null,z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:q,onChange:e=>ie(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`,ne)}),(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:[Ye(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:[Fe(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)(it,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:A&&X&&!_e(p.trim())?(0,$.jsx)(V,{type:`button`,variant:`primary`,disabled:!p.trim()||g||y,onClick:()=>void Z(),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)(nt,{open:w,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,s?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void se(),onCancel:()=>T(!1)})]})}function cr({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:_e(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 me(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 me({providers:r}),a(),i()}catch{}},te=(e,t)=>{L({model:e,isNew:t}),P(!0)},U=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 me(i),a(),t&&!e.computerUse&&o(e.id)}catch(e){T(e instanceof Error?e.message:n.saveError)}},W=async e=>{let t=p.filter(t=>t.id!==e);m(t),M(null);let r=R({models:t});if(r)try{await me(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`,H.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`,ne)})]}),(0,$.jsx)(ir,{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:()=>te(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`,H.press),onClick:()=>te(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`,H.press),onClick:()=>M(e.id),"aria-label":s.removeModel,children:(0,$.jsx)(it,{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)(it,{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)(nt,{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)(nt,{open:j!==null,title:s.removeModel,description:s.removeModelConfirm.replace(`{{id}}`,j??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{j&&W(j)},onCancel:()=>M(null)}),(0,$.jsx)(nr,{open:N,onOpenChange:e=>{P(e),e||L(null)},providerId:e,model:F?.model??null,isNew:F?.isNew??!1,onSave:e=>void U(e),m:s})]})}function lr(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function ur(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:Ce(n[1])}:e.startsWith(`sessions.`)?{label:t?`会话模型覆盖`:`Session model override`,href:`/settings/sessions`}:{label:e,href:`/settings/agent-defaults`}}function dr(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:`${$e(`models`)}?add=1`,guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{href:$e(`image`),guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{href:$e(`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:$e(`voice`),guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}function fr(e){switch(e){case`computer-use`:return`/settings/computer-use`;case`vision`:return $e(`models`);case`image-generation`:return $e(`image`);case`stt`:case`tts`:return $e(`voice`)}}async function pr(){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 mr(){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 hr(){let e=M(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=B(Z,pr,{revalidateOnFocus:!0,refreshInterval:6e4}),{data:i}=B(se,mr,{revalidateOnFocus:!1}),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);if(r)return(0,$.jsx)(q,{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`||Y()),C=S.some(([,e])=>{let t=lr(e);return t===`degraded`||t===`misconfigured`}),w=S.filter(([,e])=>lr(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 X()}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)(Le,{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`&&!Y())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=lr(n),o=a===`degraded`||a===`misconfigured`,s=dr(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)(Me,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]});return(0,$.jsx)(l,{to:o?s.href:fr(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=ur(t.locations[0]??``,e);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(Le,{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)(ge,{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)(tt,{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=ur(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)(ge,{className:`size-4`,"aria-hidden":!0}),a?e?`刷新中…`:`Refreshing…`:e?`刷新目录`:`Refresh catalog`]})]})]})]})}function gr(e){return Qe.includes(e)}function _r(){let e=(0,zt.c)(69),t=M(br),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=Re(),x;e[4]===b.cards?x=e[5]:(x=b.cards.some(yr),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:De,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:ue,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($e(e)),e[18]=u,e[19]=A);let j=A,N=vr;if(!gr(h)){let t;return e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(c,{to:$e(`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=Ke(t,`configuration`),e[21]=t,e[22]=I);let L;e[23]!==i.docsLink||e[24]!==F||e[25]!==I?(L=(0,$.jsx)(ht,{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)(pt,{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,H;e[37]!==i.connectedProviders||e[38]!==i.xopcCloudAccount||e[39]!==h||e[40]!==b||e[41]!==S?(H=h===`models`?(0,$.jsxs)($.Fragment,{children:[S?(0,$.jsx)(Rt,{labels:i.xopcCloudAccount}):null,(0,$.jsx)(We,{labels:i.connectedProviders,data:b,onAdd:()=>_(!0),onManage:(e,t)=>y({providerId:e,isCustom:t})}),b.cards.length>0?(0,$.jsx)(hr,{}):null]}):(0,$.jsx)(xr,{section:h}),e[37]=i.connectedProviders,e[38]=i.xopcCloudAccount,e[39]=h,e[40]=b,e[41]=S,e[42]=H):H=e[42];let te;e[43]!==z||e[44]!==B||e[45]!==V||e[46]!==H?(te=(0,$.jsx)(`div`,{role:z,id:B,"aria-labelledby":V,className:`flex min-w-0 flex-col gap-4`,children:H}),e[43]=z,e[44]=B,e[45]=V,e[46]=H,e[47]=te):te=e[47];let U;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>N(),e[48]=U):U=e[48];let W;e[49]!==g||e[50]!==i.addProviderDialog||e[51]!==t||e[52]!==b.builtinRows||e[53]!==b.customConfig?(W=(0,$.jsx)(at,{open:g,onOpenChange:_,builtinRows:b.builtinRows,customConfig:b.customConfig,labels:i.addProviderDialog,language:t,onSaved:U}),e[49]=g,e[50]=i.addProviderDialog,e[51]=t,e[52]=b.builtinRows,e[53]=b.customConfig,e[54]=W):W=e[54];let G;e[55]!==i.manageProviderDialog||e[56]!==t||e[57]!==v||e[58]!==b.allModels||e[59]!==b.builtinRows||e[60]!==b.customConfig?(G=v?(0,$.jsx)(or,{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]=G):G=e[61];let K;return e[62]!==L||e[63]!==R||e[64]!==ee||e[65]!==te||e[66]!==W||e[67]!==G?(K=(0,$.jsxs)(gt,{children:[L,R,ee,te,W,G]}),e[62]=L,e[63]=R,e[64]=ee,e[65]=te,e[66]=W,e[67]=G,e[68]=K):K=e[68],K}function vr(){X()}function yr(e){return e.id===`xopc-cloud`&&!e.isCustom}function br(e){return e.language}function xr(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)(Dn,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Xn,{}),t[2]=e):e=t[2],e}}}export{_r as CapabilitiesSettingsPanel};
|
|
5
|
+
`)),G(t?.models.map(Ht)??[Ht()]),ne(t?.defaultModel??``),ce(void 0),Y(void 0),oe(!1),Z(void 0),ue(void 0)},[r,e,n]);let de=(0,Q.useMemo)(()=>W.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[W]),fe=(e,t)=>{G(n=>n.map((n,r)=>r===e?{...n,...t}:n))},pe=()=>{let e=s.trim(),t=W.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=K||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=Ut(te)}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()&&!re(x)&&await Mt(e.providerId,x.trim()),await a(e.providerId),e},he=async()=>{Y(`save`),Z(void 0),ce(void 0);try{await me(),S(m===`none`?``:`••••••••••••`),ce(o.saved)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Y(void 0)}},ge=async()=>{Y(`test`),Z(void 0),ce(void 0),ue(void 0);try{let e=await me();ue((await Ft(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),ce(o.testReady)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Y(void 0)}},_e=async()=>{if(n){if(!ae){oe(!0);return}Y(`delete`),Z(void 0);try{await Lt(n.providerId),await a(),t(!1)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Y(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`,J)}),(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`,ie),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)(Ne,{className:`size-3.5`})]}):null]}),(0,$.jsx)(v,{id:`custom-image-api-key`,value:x,onChange:e=>S(re(x)?e.replace(/^•+/,``):e),labels:{show:o.show,hide:o.hide,copy:o.copy,copied:o.copied},reveal:()=>Fe(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=>H(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:te,onChange:e=>U(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:()=>G(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:K||de[0]?.value||``,options:de,placeholder:o.defaultModel,allowEmpty:!1,onChange:ne,triggerClassName:`mt-1.5 max-w-sm`})]}),W.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=>fe(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=>fe(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=>fe(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=>fe(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=>fe(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=>fe(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=>fe(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=>fe(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:W.length===1,onClick:()=>G(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)(De,{className:`size-3.5`}),o.remove]})]})]},t))]}),le?(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:le,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,se?(0,$.jsx)(`p`,{className:`rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:se}):null,X?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:X}):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:!!q,onClick:()=>void _e(),children:[q===`delete`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(De,{className:`size-4`}),ae?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:!!q,onClick:()=>void ge(),children:[q===`test`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):null,q===`test`?o.testing:o.test]}),(0,$.jsxs)(V,{variant:`primary`,disabled:!!q,onClick:()=>void he(),children:[q===`save`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):null,q===`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)(q,{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)(q,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function en(e,t){return(0,$.jsx)(q,{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:H,error:te,mutate:W}=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 G=O?.find(e=>e.id===r),K=G?G.apiKeyUrl??Ce(G.id,e)[0]?.href:void 0,ne=(0,Q.useMemo)(()=>(G?.models??[]).map(e=>({value:e,label:e})),[G?.models]),q=z?.model?.primary,ie=!!(G&&o&&(G.credentialMode!==`api-key`||G.configured||c.trim())&&G.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||H)return(0,$.jsx)($t,{});if(P||R||te||!O||!I)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let J=e=>{a(e.id),s(e.defaultModel),l(e.configured?Gt:``),d(Xt(e)),_(void 0)},Y=()=>{D(void 0),C(!0)},ae=()=>{let e=I.find(e=>e.providerId===G?.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))}},X=async()=>{if(!(!G||!ie)){h(!0),_(void 0),x(!1);try{let e=await k(N(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:G.id,modelId:o,...c.trim()&&!re(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([W(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`)])),U()]),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)(Pe,{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:Y,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(q);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>J(e),className:`min-h-24 rounded-xl p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${n?`bg-accent-soft shadow-surface`:`bg-surface-base/55 hover:bg-surface-hover`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-[10px] text-fg-subtle`,children:t.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!i,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${i?``:`invisible`}`,children:t.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(m,{className:`size-3.5`}):(0,$.jsx)(le,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?t.configured:t.needsKey]})]},e.id)})})]}),G?(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:ne,placeholder:t.selectModel,allowEmpty:!1,onChange:s,triggerClassName:`mt-1.5`})]}),G.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))]}),G.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(V,{variant:`secondary`,onClick:ae,children:[(0,$.jsx)(T,{className:`size-4`}),t.manageService]})}):null,G.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}),K?(0,$.jsxs)(`a`,{href:K,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(Ne,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(v,{id:`image-generation-api-key`,value:c,onChange:e=>l(re(c)?e.replace(/^•+/,``):e),placeholder:G.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>Fe(G.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},G.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:G.configured?t.savedKey:t.apiKeyHint})]}):null,G.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)(Te,{className:`size-4`}),t.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:G.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:!ie||f,onClick:()=>void X(),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,engine:t=`agent`}){let n=M(e=>e.language),r=n===`zh`,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),{data:c,mutate:l,error:u}=B(N(`/api/voice/catalog`),async e=>{let t=await k(e);return it.parse(t.payload)}),p=r?{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`},m=async e=>{if(c){a(!0),s(``);try{let t=await k(N(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:c.revision,selection:e})}:{}});await l(it.parse(t.payload),!1),await U()}catch(e){s(e instanceof Error?e.message:String(e)),await l()}finally{a(!1)}}},h=t=>{let a=c.selections.find(e=>e.mode===t),o=c.models.filter(e=>e.voice.modes.includes(t)),s=o.find(e=>e.id===a?.model),l=s?.voice.voices.filter(e=>ut(e,t))??[],u=a?.voice??l.find(e=>e.id===s?.voice.defaultVoice)?.id??l[0]?.id??``;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:p[t]}),(0,$.jsxs)(d,{className:`w-full`,value:a?.model??``,disabled:i||e||!o.length,onChange:e=>void m({mode:t,model:e.target.value}),children:[(0,$.jsx)(f,{value:``,disabled:!0,children:r?`选择模型`:`Choose model`}),a&&!s?(0,$.jsxs)(f,{value:a.model,disabled:!0,children:[a.model,` · `,r?`不可用`:`Unavailable`]}):null,o.map(e=>(0,$.jsx)(f,{value:e.id,children:Le(e,n)},e.id))]}),o.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:r?`暂无可用模型`:`No available model`})]}),s&&l.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:r?`音色`:`Voice`}),(0,$.jsxs)(d,{className:`w-full`,value:u,disabled:i||e,onChange:e=>void m({mode:t,model:s.id,voice:e.target.value}),children:[a?.voice&&!l.some(e=>e.id===a.voice)?(0,$.jsxs)(f,{value:a.voice,disabled:!0,children:[a.voice,` · `,r?`当前场景不可用`:`Unavailable for this mode`]}):null,l.map(e=>(0,$.jsxs)(f,{value:e.id,children:[Le(e,n),e.gender?` · ${r?e.gender===`female`?`女声`:`男声`:e.gender}`:``,e.style?` · ${e.style}`:``]},e.id))]}),l.find(e=>e.id===u)?.description?(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:l.find(e=>e.id===u)?.description}):null]}):null]},t)},g=t===`omni`?[`conversation`]:[`transcription.stream`,`speech.stream`];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:r?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(V,{variant:`secondary`,disabled:i||e||!c,onClick:()=>void m(),children:r?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r?`修改在下次调用生效。各设备共用此 Gateway 的配置。`:`Changes apply to the next call and are shared across devices.`}),o||u?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:o||String(u)}):null,c?(0,$.jsxs)($.Fragment,{children:[g.map(h),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r?`其他语音场景`:`Other voice features`}),(0,$.jsx)(`div`,{className:`mt-4 space-y-4`,children:Object.keys(p).filter(e=>!g.includes(e)).map(h)})]})]}):(0,$.jsx)(q,{className:`h-48 w-full`})]})}function rn({v:e}){let t=Be(e=>e.microphoneId),n=Be(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)(Ue)?.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 Tt(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 Ge,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:st()}),t.signal.aborted){l();return}if(s=await Re.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 Ze.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new qe(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)(xe,{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,stt:t===`xopc-cloud`?e.voice.realtime.stt:void 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)(105),{section:n,v:r,form:i,pending:a,onChange:o}=e,s=M(fn),c=r.setup,u;t[0]===i?u=t[1]:(u=JSON.stringify(i),t[0]=i,t[1]=u);let p=u,m;t[2]===p?m=t[3]:(m={signature:p,input:!1,output:!1},t[2]=p,t[3]=m);let[h,g]=(0,Q.useState)(m);h.signature!==p&&g({signature:p,input:!1,output:!1});let _;t[4]!==a||t[5]!==p?(_=a?null:[`voice-realtime-status`,p],t[4]=a,t[5]=p,t[6]=_):_=t[6];let v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!0},t[7]=v):v=t[7];let{data:y,error:b,isLoading:x}=B(_,At,v),S;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=N(`/api/voice/catalog`),t[8]=S):S=t[8];let{data:C}=B(S,dn),w=i.voice.realtime,T=i.stt.provider,E=w.tts,D=E?.provider??y?.tts?.provider,O=y?.tts?.model,k;t[9]!==O||t[10]!==D?(k=D&&O?[`realtime-voices`,D,O]:null,t[9]=O,t[10]=D,t[11]=k):k=t[11];let A;t[12]!==O||t[13]!==D?(A=()=>Et(D,O,`realtime`),t[12]=O,t[13]=D,t[14]=A):A=t[14];let j;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(j={revalidateOnFocus:!1},t[15]=j):j=t[15];let{data:P}=B(k,A,j),F;t[16]===P?F=t[17]:(F=P===void 0?[]:P,t[16]=P,t[17]=F);let I=F,L=I,R;t[18]===I?R=t[19]:(R=I.filter(un),t[18]=I,t[19]=R);let ee=R,z=w.defaultEngine===`omni`,H=z?w.omni?.voice??``:E?.voice??y?.tts?.voice??``,te;t[20]!==C?.models||t[21]!==z||t[22]!==ee||t[23]!==w.omni?.model||t[24]!==w.omni?.provider||t[25]!==L?(te=z?w.omni?.provider===`xopc-cloud`?C?.models.find(e=>e.id===w.omni?.model)?.voice.voices.filter(ln)??[]:ee.length?ee:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(cn):L,t[20]=C?.models,t[21]=z,t[22]=ee,t[23]=w.omni?.model,t[24]=w.omni?.provider,t[25]=L,t[26]=te):te=t[26];let U=te,W=!!(y?.enabled&&y.stt),G=!!(y?.enabled&&y.tts),ne;t[27]!==i||t[28]!==o||t[29]!==w?(ne=e=>o({...i,voice:{...i.voice,realtime:{...w,...e}}}),t[27]=i,t[28]=o,t[29]=w,t[30]=ne):ne=t[30];let re=ne,ie;t[31]!==i||t[32]!==o?(ie=e=>o(on(i,e)),t[31]=i,t[32]=o,t[33]=ie):ie=t[33];let J=ie,Y;t[34]!==a||t[35]!==w.enabled||t[36]!==c.disabled||t[37]!==c.needsSetup||t[38]!==c.pending||t[39]!==c.unverified||t[40]!==c.verified||t[41]!==p||t[42]!==h.signature?(Y=(e,t)=>w.enabled?a?c.pending:e?t&&h.signature===p?c.verified:c.unverified:c.needsSetup:c.disabled,t[34]=a,t[35]=w.enabled,t[36]=c.disabled,t[37]=c.needsSetup,t[38]=c.pending,t[39]=c.unverified,t[40]=c.verified,t[41]=p,t[42]=h.signature,t[43]=Y):Y=t[43];let ae=Y,oe;t[44]!==J||t[45]!==b||t[46]!==i.tts||t[47]!==a||t[48]!==T||t[49]!==c.configureConversation||t[50]!==c.customProvider||t[51]!==c.edgeHint||t[52]!==c.finishSetup||t[53]!==c.hosted||t[54]!==c.hostedAccountHint||t[55]!==c.hostedHint||t[56]!==c.manageAccount||t[57]!==c.outputHint||t[58]!==c.ownKey||t[59]!==c.ownKeyHint||t[60]!==c.service||t[61]!==c.statusError||t[62]!==n||t[63]!==E||t[64]!==y?.tts?(oe=n===`service`?(0,$.jsxs)($.Fragment,{children:[b?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:c.statusError}):null,(0,$.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,$.jsx)(`legend`,{className:`text-sm font-medium text-fg`,children:c.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:e===`xopc-cloud`?T===e:T!==`xopc-cloud`,onChange:()=>J(e),className:`mt-1 accent-accent`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:e===`xopc-cloud`?c.hosted:c.ownKey}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e===`xopc-cloud`?c.hostedHint:c.ownKeyHint})]})]},e))})]}),T!==`alibaba`&&T!==`xopc-cloud`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.customProvider.replace(`{provider}`,T)}):null,T===`xopc-cloud`?(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[c.hostedAccountHint,` `,(0,$.jsx)(l,{className:`text-accent hover:underline`,to:`/settings/capabilities/models`,children:c.manageAccount})]}):null,!E&&!a&&!y?.tts&&(T===`alibaba`||T===`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:c.finishSetup}),(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:i.tts.provider===`edge`?c.edgeHint:c.outputHint}),(0,$.jsx)(V,{className:`mt-2`,type:`button`,variant:`secondary`,onClick:()=>J(T),children:c.configureConversation})]}):null]}):null,t[44]=J,t[45]=b,t[46]=i.tts,t[47]=a,t[48]=T,t[49]=c.configureConversation,t[50]=c.customProvider,t[51]=c.edgeHint,t[52]=c.finishSetup,t[53]=c.hosted,t[54]=c.hostedAccountHint,t[55]=c.hostedHint,t[56]=c.manageAccount,t[57]=c.outputHint,t[58]=c.ownKey,t[59]=c.ownKeyHint,t[60]=c.service,t[61]=c.statusError,t[62]=n,t[63]=E,t[64]=y?.tts,t[65]=oe):oe=t[65];let X;t[66]!==H||t[67]!==s||t[68]!==z||t[69]!==D||t[70]!==w.bargeIn||t[71]!==w.defaultEngine||t[72]!==w.enabled||t[73]!==w.omni||t[74]!==w.tts||t[75]!==c.bargeIn||t[76]!==c.defaultVoice||t[77]!==c.enable||t[78]!==c.voice||t[79]!==n||t[80]!==E||t[81]!==y?.tts||t[82]!==re||t[83]!==r.experience||t[84]!==r.realtime||t[85]!==U?(X=n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:c.enable}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":w.enabled,className:`ui-checkbox`,checked:w.enabled,onChange:e=>re({enabled:e.target.checked})})]}),(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(d,{value:w.defaultEngine,className:K,onChange:e=>re({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:[w.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]}),(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:c.voice}),(0,$.jsxs)(d,{id:`realtime-voice`,className:`${K} w-full sm:w-56`,value:H,disabled:z?!w.omni:!E&&!y?.tts,onChange:e=>{if(z&&w.omni){re({omni:{...w.omni,voice:e.target.value}});return}(D===`alibaba`||D===`xopc-cloud`)&&re({tts:{...w.tts,provider:D,...e.target.value?{voice:e.target.value}:{}},...w.omni&&[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.target.value)?{omni:{...w.omni,voice:e.target.value}}:{}})},children:[z?null:(0,$.jsx)(f,{value:``,children:c.defaultVoice}),H&&!U.some(e=>e.id===H)?(0,$.jsx)(f,{value:H,children:H}):null,U.map(e=>(0,$.jsxs)(f,{value:e.id,children:[Le(e,s),`gender`in e&&e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,`style`in e&&e.style?` · ${e.style}`:``]},e.id))]}),(()=>{let e=U.find(e=>e.id===H);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:[c.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":w.bargeIn,checked:w.bargeIn,className:`size-4 accent-accent`,onChange:e=>re({bargeIn:e.target.checked})})]})]}):null,t[66]=H,t[67]=s,t[68]=z,t[69]=D,t[70]=w.bargeIn,t[71]=w.defaultEngine,t[72]=w.enabled,t[73]=w.omni,t[74]=w.tts,t[75]=c.bargeIn,t[76]=c.defaultVoice,t[77]=c.enable,t[78]=c.voice,t[79]=n,t[80]=E,t[81]=y?.tts,t[82]=re,t[83]=r.experience,t[84]=r.realtime,t[85]=U,t[86]=X):X=t[86];let Z;t[87]!==W||t[88]!==G||t[89]!==b||t[90]!==x||t[91]!==a||t[92]!==n||t[93]!==p||t[94]!==y||t[95]!==ae||t[96]!==r||t[97]!==h.input||t[98]!==h.output?(Z=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[x?(0,$.jsx)(q,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,ae(W,h.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,ae(W&&G,h.input&&h.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,ae(!!(y?.enabled&&y.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(an,{v:r,canListen:W,canSpeak:G,disabled:a||x||!!b,onVerified:e=>g({signature:p,...e})},`${p}:${JSON.stringify(y)}`)]}):null,t[87]=W,t[88]=G,t[89]=b,t[90]=x,t[91]=a,t[92]=n,t[93]=p,t[94]=y,t[95]=ae,t[96]=r,t[97]=h.input,t[98]=h.output,t[99]=Z):Z=t[99];let se;return t[100]!==c.service||t[101]!==oe||t[102]!==X||t[103]!==Z?(se=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":c.service,children:[oe,X,Z]}),t[100]=c.service,t[101]=oe,t[102]=X,t[103]=Z,t[104]=se):se=t[104],se}function cn(e){return{id:e,name:e}}function ln(e){return ut(e,`conversation`)}function un(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function dn(e){return it.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(mn)===`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 overrides`,`自然对话独立配置`),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 d;t[9]===o?d=t[10]:(d=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]=d);let f;t[11]===d?f=t[12]:(f=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d}),t[11]=d,t[12]=f);let p;t[13]!==o||t[14]!==r||t[15]!==c||t[16]!==n?(p=n?(0,$.jsxs)($.Fragment,{children:[(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:o(`Separate API key (optional)`,`独立 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,$.jsx)(Me,{title:o(`Custom endpoint`,`自定义服务地址`),summary:n.baseUrl||o(`Use the default endpoint`,`使用默认服务地址`),children:(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,$.jsx)(Me,{title:o(`Conversation instructions`,`聊天指令`),summary:o(`Current instructions remain active`,`当前聊天指令继续生效`),children:(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]=p):p=t[17];let m;return t[18]!==u||t[19]!==f||t[20]!==p?(m=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[u,f,p]}),t[18]=u,t[19]=f,t[20]=p,t[21]=m):m=t[21],m}function mn(e){return e.language}var hn=G;function gn(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,ne,`dark:border-edge`)}function _n(){return O(K,G)}function vn(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function yn(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 bn(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function xn(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;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 Sn(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 Cn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function wn(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 Tn(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 En(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 Dn(){let e=M(e=>e.language),t=D(e).voiceSettings,[n,r]=o(),i=n.get(`voiceTab`),a=i===`service`||i===`devices`?i:`listening`,s=e=>r(t=>{let n=new URLSearchParams(t);return n.set(`voiceTab`,e),n}),c=Be(e=>e.captions),l=Be(e=>e.setCaptions),u=!!A(e=>e.conversationId),[p,m]=(0,Q.useReducer)(En,{form:null,baseline:null}),h=p.form,g=p.baseline,[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1),x=(0,Q.useRef)(!1),S=(0,Q.useRef)(h);S.current=h;let C=(0,Q.useRef)({parsed:null,models:void 0}),{data:w,error:T,isLoading:E,mutate:O}=W(u),{data:k,error:j,isLoading:P,mutate:F}=B(u?N(`/api/voice/models`):null,Ot,{revalidateOnFocus:!1}),{data:I,error:L,isLoading:R}=B(u?N(`/api/voice/providers`):null,wt,{revalidateOnFocus:!1}),{data:ee,error:z,isLoading:H}=B(u?N(`/api/voice/stt-providers`):null,Dt,{revalidateOnFocus:!1}),te=(0,Q.useMemo)(()=>I?.providers??[],[I]),U=(0,Q.useMemo)(()=>ee?.providers??[],[ee]),G=(0,Q.useMemo)(()=>w?.payload?.config===void 0?null:kt(w.payload.config),[w]),K=(0,Q.useMemo)(()=>!h||!g?!1:JSON.stringify(h)!==JSON.stringify(g),[h,g]);u?G!==null&&k!==void 0&&!x.current&&(C.current.parsed!==G||C.current.models!==k)&&(C.current={parsed:G,models:k},m({type:`sync`,value:G}),v(k)):(C.current.parsed!==null||C.current.models!==void 0)&&(C.current={parsed:null,models:void 0},m({type:`reset`}),v(null),x.current=!1);let ne=!!(u&&(G===null||k===void 0||I===void 0||ee===void 0)&&(E||P||R||H)),re=T instanceof Error?T.message:T?String(T):j instanceof Error?j.message:j?String(j):L instanceof Error?L.message:L?String(L):z instanceof Error?z.message:z?String(z):null,q=(0,Q.useCallback)(e=>{x.current=!0,m({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e},...e.provider&&e.provider!==`xopc-cloud`?{voice:{...t.voice,realtime:{...t.voice.realtime,stt:void 0}}}:{}}:null})},[]),ie=(0,Q.useCallback)(e=>{x.current=!0,m({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),J=(0,Q.useCallback)(e=>{x.current=!0,m({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),Y=(0,Q.useCallback)(t=>{x.current=!0,m({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),ae=(0,Q.useCallback)(e=>{x.current=!0,m({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),oe=(0,Q.useCallback)(e=>{x.current=!0,m({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),X=xt({value:h,dirty:K,onSave:(0,Q.useCallback)(async e=>{try{await St(e),m({type:`saved`,value:e}),x.current=!!(S.current&&JSON.stringify(S.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])}),Z=(0,Q.useCallback)(e=>{x.current=!0,m({type:`update`,updater:()=>e})},[]);if(!u)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(ne)return(0,$.jsx)(yt,{rows:4});if(!h||_===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:re??t.loadError}),(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>{O(),F()},children:t.retry})]});let se=h.stt,ce=h.tts,le=h.voice.input.refinement,ue=Cn(t);return(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,onBlurCapture:X.onBlurCapture,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,$.jsx)(bt,{status:X.status,error:X.error})}),X.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:X.error}):null,(0,$.jsx)(`nav`,{"aria-label":t.experience.tabsLabel,className:`flex flex-wrap gap-2`,children:[`listening`,`service`,`devices`].map(e=>(0,$.jsx)(V,{variant:a===e?`secondary`:`ghost`,"aria-pressed":a===e,onClick:()=>s(e),children:t.experience[e]},e))}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.experience[`${a}Hint`]}),a===`devices`?null:(0,$.jsx)(sn,{section:a,v:t,form:h,pending:K||X.status===`saving`||!!X.error,onChange:Z}),a===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kn,{v:t,voice:h.voice,updateLanguageMode:Y}),(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:_n(),value:String(h.voice.realtime.silenceDurationMs),onChange:e=>ae({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(h.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(f,{value:String(h.voice.realtime.silenceDurationMs),children:[h.voice.realtime.silenceDurationMs,` ms`]})]})]})}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[t.experience.captions,(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":c,className:`ui-checkbox`,checked:c,onChange:e=>l(e.target.checked)})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.experience.inputProcessing,` · `,le.mode===`off`?t.stt.refinementOff:le.mode===`punctuation`?t.stt.refinementPunctuation:le.mode===`light`?t.stt.refinementLight:t.setup.advanced]}),(0,$.jsxs)(`label`,{className:`mt-4 block 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:_n(),value:le.mode,onChange:e=>J({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}),le.mode===`custom`?(0,$.jsx)(f,{value:`custom`,children:t.setup.advanced}):null]})]})]}),(0,$.jsx)(On,{v:t,tts:ce,updateTts:oe})]}):null,a===`devices`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(rn,{v:t}),(0,$.jsx)(sn,{section:`diagnostics`,v:t,form:h,pending:K||X.status===`saving`||!!X.error,onChange:Z})]}):null,a===`service`?(0,$.jsxs)($.Fragment,{children:[se.provider===`xopc-cloud`?(0,$.jsx)(nn,{engine:h.voice.realtime.defaultEngine,disabled:K||X.status===`saving`}):(0,$.jsx)($.Fragment,{children:(0,$.jsx)(An,{v:t,apiKeyLabels:ue,stt:se,models:_,sttProviders:U,updateStt:q,updateSttFallback:ie})}),h.voice.realtime.enabled&&h.voice.realtime.omni?.provider===`alibaba`?(0,$.jsx)(pn,{value:h.voice.realtime.omni,onChange:e=>ae({omni:e})}):null,(0,$.jsxs)(`details`,{open:y,className:`rounded-xl bg-surface-hover/20 p-4`,"data-voice-section":`readout-service`,children:[(0,$.jsxs)(`summary`,{onClick:e=>{e.preventDefault(),b(!y)},className:`cursor-pointer text-sm font-medium text-fg`,children:[t.experience.readoutService,(0,$.jsx)(`span`,{className:`ml-2 font-normal text-fg-muted`,children:xn(ce.provider,t)})]}),y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.setup.readoutHint}),(0,$.jsx)(Mn,{v:t,apiKeyLabels:ue,tts:ce,models:_,ttsProviders:te,updateTts:oe})]}):null]}),se.provider===`xopc-cloud`?(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-hover/20 p-4`,"data-voice-section":`advanced`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:t.experience.technical}),(0,$.jsx)(An,{v:t,apiKeyLabels:ue,stt:se,models:_,sttProviders:U,updateStt:q,updateSttFallback:ie}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.notes.envVars})]}):null]}):null]})}function On(e){let t=(0,zt.c)(29),{v:n,tts:r,updateTts:i}=e,a;t[0]===n.setup.readout?a=t[1]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:n.setup.readout}),t[0]=n.setup.readout,t[1]=a);let o=n.setup.readout,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=_n(),t[2]=s):s=t[2];let c=r.enabled?r.trigger:`off`,l;t[3]===i?l=t[4]:(l=e=>i({enabled:e.target.value!==`off`,trigger:e.target.value}),t[3]=i,t[4]=l);let u;t[5]===n.tts.triggerOff?u=t[6]:(u=(0,$.jsx)(f,{value:`off`,children:n.tts.triggerOff}),t[5]=n.tts.triggerOff,t[6]=u);let p;t[7]===n.tts.triggerInbound?p=t[8]:(p=(0,$.jsx)(f,{value:`inbound`,children:n.tts.triggerInbound}),t[7]=n.tts.triggerInbound,t[8]=p);let m;t[9]===n.tts.triggerAlways?m=t[10]:(m=(0,$.jsx)(f,{value:`always`,children:n.tts.triggerAlways}),t[9]=n.tts.triggerAlways,t[10]=m);let h;t[11]===n.tts.triggerTagged?h=t[12]:(h=(0,$.jsx)(f,{value:`tagged`,children:n.tts.triggerTagged}),t[11]=n.tts.triggerTagged,t[12]=h);let g;t[13]!==c||t[14]!==l||t[15]!==u||t[16]!==p||t[17]!==m||t[18]!==h||t[19]!==n.setup.readout?(g=(0,$.jsxs)(d,{"aria-label":o,className:s,value:c,onChange:l,children:[u,p,m,h]}),t[13]=c,t[14]=l,t[15]=u,t[16]=p,t[17]=m,t[18]=h,t[19]=n.setup.readout,t[20]=g):g=t[20];let _;t[21]!==a||t[22]!==g?(_=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[a,g]}),t[21]=a,t[22]=g,t[23]=_):_=t[23];let v;t[24]===n.setup.readoutHint?v=t[25]:(v=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.readoutHint}),t[24]=n.setup.readoutHint,t[25]=v);let y;return t[26]!==_||t[27]!==v?(y=(0,$.jsxs)(`section`,{className:`space-y-2 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,children:[_,v]}),t[26]=_,t[27]=v,t[28]=y):y=t[28],y}function kn(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=_n(),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 An(e){let t=(0,zt.c)(63),{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(jn),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,{"aria-hidden":`true`,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)(`h3`,{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.enable?D=t[27]:(D=(0,$.jsx)(`span`,{children:n.stt.enable}),t[26]=n.stt.enable,t[27]=D);let k;t[28]===s?k=t[29]:(k=e=>s({enabled:e.target.checked}),t[28]=s,t[29]=k);let A;t[30]!==i.enabled||t[31]!==k?(A=(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i.enabled,className:`ui-checkbox`,checked:i.enabled,onChange:k}),t[30]=i.enabled,t[31]=k,t[32]=A):A=t[32];let j;t[33]!==D||t[34]!==A?(j=(0,$.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-xs text-fg-muted`,children:[D,A]}),t[33]=D,t[34]=A,t[35]=j):j=t[35];let M;t[36]!==j||t[37]!==E?(M=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[E,j]}),t[36]=j,t[37]=E,t[38]=M):M=t[38];let N;t[39]===n.stt.description?N=t[40]:(N=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[39]=n.stt.description,t[40]=N);let P;t[41]!==M||t[42]!==N?(P=(0,$.jsxs)(`div`,{className:`mb-4`,children:[M,N]}),t[41]=M,t[42]=N,t[43]=P):P=t[43];let F;t[44]!==p?.fields||t[45]!==r||t[46]!==y||t[47]!==m||t[48]!==u||t[49]!==h||t[50]!==i.enabled||t[51]!==i.fallback?.enabled||t[52]!==i.provider||t[53]!==S||t[54]!==s||t[55]!==c||t[56]!==n?(F=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`,hn),children:[(0,$.jsx)(zn,{children:n.stt.provider}),(0,$.jsx)(d,{"aria-label":n.stt.provider,className:_n(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:u.map(e=>(0,$.jsxs)(f,{value:e.id,children:[bn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(Nn,{kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:y,apiKeyLabels:r,onPatch:S})]}),i.provider===`alibaba`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.keyHint}):null,(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:n.stt.fallback}),(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[44]=p?.fields,t[45]=r,t[46]=y,t[47]=m,t[48]=u,t[49]=h,t[50]=i.enabled,t[51]=i.fallback?.enabled,t[52]=i.provider,t[53]=S,t[54]=s,t[55]=c,t[56]=n,t[57]=F):F=t[57];let I;t[58]===F?I=t[59]:(I=(0,$.jsx)(`div`,{className:`space-y-4`,children:F}),t[58]=F,t[59]=I);let L;return t[60]!==P||t[61]!==I?(L=(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[P,I]}),t[60]=P,t[61]=I,t[62]=L):L=t[62],L}function jn(e){return e.key===`model`}function Mn({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,()=>Et(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=(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&&P(e)},[w,j,T,M,x,P,S]),(0,Q.useEffect)(()=>()=>h(),[h]);let F=(0,Q.useCallback)(e=>{a({provider:e}),l({status:`idle`})},[a]),I=(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 Ct({text:t,provider:n.provider,providerConfig:v,...T?{model:T}:{},...M?{voice:M}:{}},r.signal);if(r.signal.aborted)return;let a=yn(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`,vn(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)(et,{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,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:e.tts.provider}),(0,$.jsx)(d,{"aria-label":e.tts.provider,className:_n(),value:n.provider,onChange:e=>F(e.target.value),children:g.map(t=>(0,$.jsx)(f,{value:t.id,children:xn(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??Sn(n.provider,e)]})]})}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(Nn,{kind:`tts`,providerId:n.provider,fields:N,providerSlice:v,models:y,voices:A,currentModel:T,currentVoice:M,apiKeyLabels:t,onPatch:P,resetVoiceOnModelChange:!0})}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsx)(`div`,{children:(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 I(),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)(xe,{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(gn(),`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]})]})]})]})})]})}function Nn(e){let t=(0,zt.c)(39),{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;t[2]===v?y=t[3]:(y=D(v),t[2]=v,t[3]=y);let b=y.voiceSettings,x=Fn,S,C;if(t[4]!==u||t[5]!==c||t[6]!==l||t[7]!==i||t[8]!==n||t[9]!==v||t[10]!==o||t[11]!==p||t[12]!==r||t[13]!==a||t[14]!==_||t[15]!==b||t[16]!==g){let e;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>!x(e),t[19]=e):e=t[19];let s=i.filter(e),m;t[20]!==u||t[21]!==c||t[22]!==l||t[23]!==n||t[24]!==v||t[25]!==o||t[26]!==p||t[27]!==r||t[28]!==a||t[29]!==_||t[30]!==b||t[31]!==g?(m=e=>e.map(e=>e.key===`apiKey`?(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{htmlFor:`voice-${n}-${r}-api-key`,children:b.stt.apiKey}),(0,$.jsx)(jt,{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`,hn),children:[(0,$.jsx)(zn,{htmlFor:`voice-${n}-${r}-model`,children:b.stt.model}),(0,$.jsx)(d,{id:`voice-${n}-${r}-model`,className:_n(),value:c??``,onChange:e=>p({model:e.target.value,..._?{voice:void 0}:{}}),children:o.map(Pn)})]},e.key):e.key===`voice`&&g.length>0?(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{htmlFor:`voice-${n}-${r}-voice`,children:b.tts.voice}),(0,$.jsxs)(d,{id:`voice-${n}-${r}-voice`,className:_n(),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:[Le(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)(Ln,{fieldId:`voice-${n}-${r}-${e.key}`,field:e,value:wn(a,e),onChange:t=>p({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:hn},e.key)),t[20]=u,t[21]=c,t[22]=l,t[23]=n,t[24]=v,t[25]=o,t[26]=p,t[27]=r,t[28]=a,t[29]=_,t[30]=b,t[31]=g,t[32]=m):m=t[32];let h=m;t[33]!==i||t[34]!==h?(S=h(i.filter(x)),t[33]=i,t[34]=h,t[35]=S):S=t[35],C=s.length?(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3 sm:col-span-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:b.experience.providerOptions}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:h(s)})]}):null,t[4]=u,t[5]=c,t[6]=l,t[7]=i,t[8]=n,t[9]=v,t[10]=o,t[11]=p,t[12]=r,t[13]=a,t[14]=_,t[15]=b,t[16]=g,t[17]=S,t[18]=C}else S=t[17],C=t[18];let w;return t[36]!==S||t[37]!==C?(w=(0,$.jsxs)($.Fragment,{children:[S,C]}),t[36]=S,t[37]=C,t[38]=w):w=t[38],w}function Pn(e){return(0,$.jsx)(f,{value:e.id,children:e.name},e.id)}function Fn(e){return e.required||[`apiKey`,`model`,`voice`].includes(e.key)}function In(e){return e.language}function Ln(e){let t=(0,zt.c)(37),{fieldId:n,field:r,value:i,onChange:a,className:o}=e,s=n??`voice-schema-field-${r.key}`,c=r.description;if(r.type===`boolean`){let e;t[0]===o?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`,o),t[0]=o,t[1]=e);let n;t[2]===r.label?n=t[3]:(n=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r.label}),t[2]=r.label,t[3]=n);let s;t[4]===c?s=t[5]:(s=c?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=s);let l;t[6]!==n||t[7]!==s?(l=(0,$.jsxs)(`span`,{children:[n,s]}),t[6]=n,t[7]=s,t[8]=l):l=t[8];let u=!!i,d;t[9]!==r||t[10]!==a?(d=e=>a(Tn(r,e.target.checked)),t[9]=r,t[10]=a,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 l=typeof i==`boolean`?``:String(i),u;t[19]===o?u=t[20]:(u=O(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let f;t[21]!==r.label||t[22]!==s?(f=(0,$.jsx)(zn,{htmlFor:s,children:r.label}),t[21]=r.label,t[22]=s,t[23]=f):f=t[23];let p;t[24]!==o||t[25]!==r||t[26]!==l||t[27]!==s||t[28]!==a?(p=r.type===`select`?(0,$.jsx)(d,{id:s,className:_n(),value:l,required:r.required,onChange:e=>a(Tn(r,e.target.value)),children:(r.options??[]).map(Rn)}):r.type===`textarea`?(0,$.jsx)(`textarea`,{id:s,className:O(gn(),`min-h-24 resize-y`),value:l,required:r.required,placeholder:r.placeholder,onChange:e=>a(Tn(r,e.target.value))}):r.type===`password`?(0,$.jsx)(v,{id:s,className:o,value:l,onChange:e=>a(Tn(r,e)),placeholder:r.placeholder,labels:nt}):r.type===`number`?(0,$.jsx)(mt,{id:s,className:gn(),autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,allowEmpty:!r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(Tn(r,e.target.value))}):(0,$.jsx)(`input`,{id:s,className:gn(),type:`text`,autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(Tn(r,e.target.value))}),t[24]=o,t[25]=r,t[26]=l,t[27]=s,t[28]=a,t[29]=p):p=t[29];let m;t[30]===c?m=t[31]:(m=c?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[30]=c,t[31]=m);let h;return t[32]!==u||t[33]!==f||t[34]!==p||t[35]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[f,p,m]}),t[32]=u,t[33]=f,t[34]=p,t[35]=m,t[36]=h):h=t[36],h}function Rn(e){return(0,$.jsx)(f,{value:e.id,children:e.name},e.id)}function zn(e){let t=(0,zt.c)(3),{children:n,htmlFor:r}=e,i;return t[0]!==n||t[1]!==r?(i=r?(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:n}):(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Bn(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function Vn(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 Hn(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}}}})}),U()}async function Un(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 Wn(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 Gn(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,ne,`dark:border-edge`)}function Kn(){return O(K,G)}var qn=[`brave`,`tavily`,`bing`,`searxng`];function Jn(){return{clientKey:crypto.randomUUID(),type:`brave`,apiKey:``,url:``,disabled:!1}}var Yn=oe();function Xn(){let e=D(M(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!A(e=>e.conversationId),[i,a]=(0,Q.useReducer)(Yn,{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:_}=W(r);ae({enabled:r,parsed:(0,Q.useMemo)(()=>p?.payload?.config===void 0?null:Vn(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=xt({value:o,dirty:b,onSave:(0,Q.useCallback)(async e=>{try{await Hn(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)(yt,{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=Bn(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)(vt,{children:[(0,$.jsx)(_t,{icon:$e,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(bt,{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)(Zn,{row:n,providerIndex:r,labels:t,secretLabels:He(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,Jn()]}),children:[(0,$.jsx)(w,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(vt,{children:[(0,$.jsx)(_t,{icon:Te,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(Wn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(d,{className:Kn(),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)(Me,{title:t.maxResultsLabel,summary:o.maxResults,children:(0,$.jsx)(Wn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(mt,{type:`number`,min:1,max:50,className:Gn(),value:o.maxResults,onChange:e=>x({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})})})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.sectionBlocklist,` · `,o.blocklistEnabled?o.blocklistDomains.length:0]}),(0,$.jsxs)(vt,{children:[(0,$.jsx)(_t,{icon:je,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)(Wn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:O(Gn(),`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 Zn(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=()=>Un(r).then(Qn),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=O(Kn(),`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=qn.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)(De,{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)(Wn,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Gn(),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)(Wn,{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 Qn(e){return e.apiKey??null}function $n(e){let t=(0,zt.c)(185),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=M(tr)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:ke(``),t[0]=n,t[1]=l);let[u,p]=(0,Q.useState)(l),[m,h]=(0,Q.useState)(er),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=fe(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(te,`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(lt(),m.has(`id`)&&`border-red-500`),t[37]=m,t[38]=z);let B=u.id||``,H;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>_(`id`,e.target.value),t[39]=H):H=t[39];let U=!r,W;t[40]!==z||t[41]!==B||t[42]!==U?(W=(0,$.jsx)(`input`,{className:z,value:B,onChange:H,placeholder:`e.g. llama3.1:8b`,disabled:U}),t[40]=z,t[41]=B,t[42]=U,t[43]=W):W=t[43];let G;t[44]===m?G=t[45]:(G=m.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`id`)}):null,t[44]=m,t[45]=G);let K;t[46]!==R||t[47]!==W||t[48]!==G?(K=(0,$.jsxs)(`div`,{children:[R,W,G]}),t[46]=R,t[47]=W,t[48]=G,t[49]=K):K=t[49];let ne;t[50]===s.displayName?ne=t[51]:(ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=ne);let re;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(re=lt(),t[52]=re):re=t[52];let q=u.name||``,ie;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>_(`name`,e.target.value),t[53]=ie):ie=t[53];let J;t[54]===q?J=t[55]:(J=(0,$.jsx)(`input`,{className:re,value:q,onChange:ie}),t[54]=q,t[55]=J);let Y;t[56]!==ne||t[57]!==J?(Y=(0,$.jsxs)(`div`,{children:[ne,J]}),t[56]=ne,t[57]=J,t[58]=Y):Y=t[58];let ae;t[59]===s.inputTypes?ae=t[60]:(ae=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=ae);let oe;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(oe=ot(),t[61]=oe):oe=t[61];let X;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(X=e=>_(`input`,Oe(e.target.value)),t[62]=X):X=t[62];let Z;t[63]===s?Z=t[64]:(Z=Ve.map(e=>(0,$.jsx)(f,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=Z);let se;t[65]!==w||t[66]!==Z?(se=(0,$.jsx)(d,{className:oe,value:w,onChange:X,children:Z}),t[65]=w,t[66]=Z,t[67]=se):se=t[67];let ce;t[68]!==ae||t[69]!==se?(ce=(0,$.jsxs)(`div`,{children:[ae,se]}),t[68]=ae,t[69]=se,t[70]=ce):ce=t[70];let le=u.reasoning||!1,ue;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>_(`reasoning`,e.target.checked),t[71]=ue):ue=t[71];let de;t[72]===le?de=t[73]:(de=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:le,onChange:ue}),t[72]=le,t[73]=de);let pe;t[74]!==s.reasoning||t[75]!==de?(pe=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[de,s.reasoning]}),t[74]=s.reasoning,t[75]=de,t[76]=pe):pe=t[76];let me;t[77]!==ce||t[78]!==pe?(me=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ce,pe]}),t[77]=ce,t[78]=pe,t[79]=me):me=t[79];let he;t[80]===s.contextWindow?he=t[81]:(he=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=he);let ge;t[82]===m?ge=t[83]:(ge=O(lt(),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)(mt,{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(lt(),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)(mt,{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 Ae;t[104]!==Se||t[105]!==Ee||t[106]!==De?(Ae=(0,$.jsxs)(`div`,{children:[Se,Ee,De]}),t[104]=Se,t[105]=Ee,t[106]=De,t[107]=Ae):Ae=t[107];let je;t[108]!==xe||t[109]!==Ae?(je=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[xe,Ae]}),t[108]=xe,t[109]=Ae,t[110]=je):je=t[110];let Me;t[111]===s.costSection?Me=t[112]:(Me=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=Me);let Ne;t[113]===s.costInput?Ne=t[114]:(Ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Ne);let Pe;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=lt(),t[115]=Pe):Pe=t[115];let Fe=u.cost?.input??0,Ie;t[116]===u.cost?Ie=t[117]:(Ie=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]=Ie);let Le;t[118]!==Fe||t[119]!==Ie?(Le=(0,$.jsx)(mt,{type:`number`,step:`any`,min:0,className:Pe,value:Fe,onChange:Ie}),t[118]=Fe,t[119]=Ie,t[120]=Le):Le=t[120];let Re;t[121]!==Ne||t[122]!==Le?(Re=(0,$.jsxs)(`div`,{children:[Ne,Le]}),t[121]=Ne,t[122]=Le,t[123]=Re):Re=t[123];let ze;t[124]===s.costOutput?ze=t[125]:(ze=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=ze);let Be;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Be=lt(),t[126]=Be):Be=t[126];let He=u.cost?.output??0,Ue;t[127]===u.cost?Ue=t[128]:(Ue=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]=Ue);let We;t[129]!==He||t[130]!==Ue?(We=(0,$.jsx)(mt,{type:`number`,step:`any`,min:0,className:Be,value:He,onChange:Ue}),t[129]=He,t[130]=Ue,t[131]=We):We=t[131];let Ge;t[132]!==ze||t[133]!==We?(Ge=(0,$.jsxs)(`div`,{children:[ze,We]}),t[132]=ze,t[133]=We,t[134]=Ge):Ge=t[134];let Ke;t[135]!==Re||t[136]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Re,Ge]}),t[135]=Re,t[136]=Ge,t[137]=Ke):Ke=t[137];let qe;t[138]!==Me||t[139]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Me,Ke]}),t[138]=Me,t[139]=Ke,t[140]=qe):qe=t[140];let Je;t[141]!==K||t[142]!==Y||t[143]!==me||t[144]!==je||t[145]!==qe?(Je=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[K,Y,me,je,qe]}),t[141]=K,t[142]=Y,t[143]=me,t[144]=je,t[145]=qe,t[146]=Je):Je=t[146];let Ye=c?`高级:电脑控制协议`:`Advanced: Computer Use protocol`,Xe;t[147]===Ye?Xe=t[148]:(Xe=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Ye}),t[147]=Ye,t[148]=Xe);let Ze=c?`电脑控制协议`:`Computer Use protocol`,Qe=u.computerUse?.profile??``,$e;t[149]===Symbol.for(`react.memo_cache_sentinel`)?($e=e=>_(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=$e):$e=t[149];let et=c?`未声明`:`Not declared`,tt;t[150]===et?tt=t[151]:(tt=(0,$.jsx)(f,{value:``,children:et}),t[150]=et,t[151]=tt);let nt,rt,it;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(nt=(0,$.jsx)(f,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),rt=(0,$.jsx)(f,{value:`structured-tools-v1`,children:`structured-tools-v1`}),it=(0,$.jsx)(f,{value:`openai-responses-computer-v1`,children:`OpenAI Responses Computer`}),t[152]=nt,t[153]=rt,t[154]=it):(nt=t[152],rt=t[153],it=t[154]);let at;t[155]!==Ze||t[156]!==Qe||t[157]!==tt?(at=(0,$.jsxs)(d,{"aria-label":Ze,value:Qe,onChange:$e,children:[tt,nt,rt,it]}),t[155]=Ze,t[156]=Qe,t[157]=tt,t[158]=at):at=t[158];let st=c?`协议必须与模型 API 匹配。声明协议不代表模型已通过效果验证。`:`The protocol must match the model API. Declaring a protocol does not certify model quality.`,ct;t[159]===st?ct=t[160]:(ct=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:st}),t[159]=st,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]!==at||t[164]!==ct||t[165]!==ut?(dt=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[at,ct,ut]}),t[163]=at,t[164]=ct,t[165]=ut,t[166]=dt):dt=t[166];let ft;t[167]!==Xe||t[168]!==dt?(ft=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Xe,dt]}),t[167]=Xe,t[168]=dt,t[169]=ft):ft=t[169];let pt;t[170]!==Je||t[171]!==ft?(pt=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[Je,ft]}),t[170]=Je,t[171]=ft,t[172]=pt):pt=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]!==pt||t[183]!==vt?(yt=(0,$.jsxs)($.Fragment,{children:[F,pt,vt]}),t[181]=F,t[182]=pt,t[183]=vt,t[184]=yt):yt=t[184],yt}function er(){return new Map}function tr(e){return e.language}function nr(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`,J)}),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`,ie,`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)($n,{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:rr,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 rr(e){return e.preventDefault()}function ir(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=()=>Fe(n).then(ar),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 ar(e){return e.apiKey??null}function or(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]`,J)}),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`,ie),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)(dt,{target:f,zh:u===`zh`,onDone:()=>h(!1)}):a?(0,$.jsx)(cr,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onModelAdded:e=>p({providerId:i,modelIds:[e]})}):(0,$.jsx)(sr,{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 sr({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`),[te,U]=(0,Q.useState)(null),[W,G]=(0,Q.useState)(null),[K,re]=(0,Q.useState)(null),[q,ie]=(0,Q.useState)(``),J=(0,Q.useRef)(null),Y=(0,Q.useRef)(null),ae=z===`waiting`||z===`waiting_code`,oe=(0,Q.useMemo)(()=>Ce(e,i),[e,i]),X=p!==(s?.apiKey??``),Z=async()=>{let t=p.trim();if(!(!t||!A||_e(t))){v(!0),C(null);try{await Ae({[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||!ae)return;let e=window.setInterval(()=>{(async()=>{try{let t=await ve(P);t.status===`waiting_auth`||t.status===`waiting_code`?(B(t.status===`waiting_code`?`waiting_code`:`waiting`),R(t.message??null),U(t.authUrl??null),G(t.instructions??null),re(t.deviceCode??null),t.authUrl&&t.authUrl!==Y.current&&(Y.current=t.authUrl,Ye(t.authUrl,J.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),ce(J.current),J.current=null,B(`success`),R(t.message??k.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),ce(J.current),J.current=null,B(`error`),R(t.error??t.message??k.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,ae,a,o,k.revokeFailed,k.saved]),(0,Q.useEffect)(()=>()=>{P&&he(P).catch(()=>{})},[P]),(0,Q.useEffect)(()=>()=>{ce(J.current),J.current=null},[]);let se=async()=>{try{await ue(e),o(),a()}catch{}},le=async()=>{ce(J.current),J.current=be(),Y.current=null,B(`waiting`),R(k.oauthStarting),U(null),G(null),re(null),C(null);try{F((await Ee(e)).sessionId)}catch(e){ce(J.current),J.current=null,B(`error`),R(e instanceof Error?e.message:k.revokeFailed)}},fe=async()=>{if(P){try{await we(P)}catch{}ce(J.current),J.current=null,Y.current=null,B(`idle`),R(null),F(null),U(null),G(null),re(null)}},me=async()=>{if(!(!P||!q.trim()))try{await ft(P,q.trim()),ie(``),R(k.oauthProcessingCode)}catch(e){B(`error`),R(e instanceof Error?e.message:k.revokeFailed)}},ge=async()=>{try{await ye(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`,H.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)(ir,{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 ge(),children:k.revoke}):(0,$.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ae,onClick:()=>void le(),children:[ae?(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(de,{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:[te?(0,$.jsxs)(`a`,{href:te,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 fe(),children:k.cancelOAuth})]}):null,W?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:W}):null,K?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:k.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:K}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:k.deviceCodeHint})]}):null,z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:q,onChange:e=>ie(e.target.value),onKeyDown:e=>e.key===`Enter`&&void me(),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`,ne)}),(0,$.jsx)(V,{type:`button`,variant:`primary`,onClick:()=>void me(),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:[Le(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)(De,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:A&&X&&!_e(p.trim())?(0,$.jsx)(V,{type:`button`,variant:`primary`,disabled:!p.trim()||g||y,onClick:()=>void Z(),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)(rt,{open:w,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,s?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void se(),onCancel:()=>T(!1)})]})}function cr({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:_e(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 me(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 me({providers:r}),a(),i()}catch{}},te=(e,t)=>{L({model:e,isNew:t}),P(!0)},U=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 me(i),a(),t&&!e.computerUse&&o(e.id)}catch(e){T(e instanceof Error?e.message:n.saveError)}},W=async e=>{let t=p.filter(t=>t.id!==e);m(t),M(null);let r=R({models:t});if(r)try{await me(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`,H.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`,ne)})]}),(0,$.jsx)(ir,{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:()=>te(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`,H.press),onClick:()=>te(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`,H.press),onClick:()=>M(e.id),"aria-label":s.removeModel,children:(0,$.jsx)(De,{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)(De,{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)(rt,{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)(rt,{open:j!==null,title:s.removeModel,description:s.removeModelConfirm.replace(`{{id}}`,j??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{j&&W(j)},onCancel:()=>M(null)}),(0,$.jsx)(nr,{open:N,onOpenChange:e=>{P(e),e||L(null)},providerId:e,model:F?.model??null,isNew:F?.isNew??!1,onSave:e=>void U(e),m:s})]})}function lr(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function ur(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:Se(n[1])}:e.startsWith(`sessions.`)?{label:t?`会话模型覆盖`:`Session model override`,href:`/settings/sessions`}:{label:e,href:`/settings/agent-defaults`}}function dr(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:`${tt(`models`)}?add=1`,guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{href:tt(`image`),guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{href:tt(`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:tt(`voice`),guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}function fr(e){switch(e){case`computer-use`:return`/settings/computer-use`;case`vision`:return tt(`models`);case`image-generation`:return tt(`image`);case`stt`:case`tts`:return tt(`voice`)}}async function pr(){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 mr(){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 hr(){let e=M(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=B(Z,pr,{revalidateOnFocus:!0,refreshInterval:6e4}),{data:i}=B(se,mr,{revalidateOnFocus:!1}),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);if(r)return(0,$.jsx)(q,{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`||Y()),C=S.some(([,e])=>{let t=lr(e);return t===`degraded`||t===`misconfigured`}),w=S.filter(([,e])=>lr(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 X()}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)(ct,{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`&&!Y())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=lr(n),o=a===`degraded`||a===`misconfigured`,s=dr(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)(ge,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]});return(0,$.jsx)(l,{to:o?s.href:fr(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=ur(t.locations[0]??``,e);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(ct,{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)(Ie,{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)(We,{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=ur(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)(Ie,{className:`size-4`,"aria-hidden":!0}),a?e?`刷新中…`:`Refreshing…`:e?`刷新目录`:`Refresh catalog`]})]})]})]})}function gr(e){return Qe.includes(e)}function _r(){let e=(0,zt.c)(69),t=M(br),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=ze(),x;e[4]===b.cards?x=e[5]:(x=b.cards.some(yr),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:$e,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:Pe,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(tt(e)),e[18]=u,e[19]=A);let j=A,N=vr;if(!gr(h)){let t;return e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(c,{to:tt(`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=Je(t,`configuration`),e[21]=t,e[22]=I);let L;e[23]!==i.docsLink||e[24]!==F||e[25]!==I?(L=(0,$.jsx)(ht,{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)(pt,{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,H;e[37]!==i.connectedProviders||e[38]!==i.xopcCloudAccount||e[39]!==h||e[40]!==b||e[41]!==S?(H=h===`models`?(0,$.jsxs)($.Fragment,{children:[S?(0,$.jsx)(Rt,{labels:i.xopcCloudAccount}):null,(0,$.jsx)(Ke,{labels:i.connectedProviders,data:b,onAdd:()=>_(!0),onManage:(e,t)=>y({providerId:e,isCustom:t})}),b.cards.length>0?(0,$.jsx)(hr,{}):null]}):(0,$.jsx)(xr,{section:h}),e[37]=i.connectedProviders,e[38]=i.xopcCloudAccount,e[39]=h,e[40]=b,e[41]=S,e[42]=H):H=e[42];let te;e[43]!==z||e[44]!==B||e[45]!==V||e[46]!==H?(te=(0,$.jsx)(`div`,{role:z,id:B,"aria-labelledby":V,className:`flex min-w-0 flex-col gap-4`,children:H}),e[43]=z,e[44]=B,e[45]=V,e[46]=H,e[47]=te):te=e[47];let U;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>N(),e[48]=U):U=e[48];let W;e[49]!==g||e[50]!==i.addProviderDialog||e[51]!==t||e[52]!==b.builtinRows||e[53]!==b.customConfig?(W=(0,$.jsx)(at,{open:g,onOpenChange:_,builtinRows:b.builtinRows,customConfig:b.customConfig,labels:i.addProviderDialog,language:t,onSaved:U}),e[49]=g,e[50]=i.addProviderDialog,e[51]=t,e[52]=b.builtinRows,e[53]=b.customConfig,e[54]=W):W=e[54];let G;e[55]!==i.manageProviderDialog||e[56]!==t||e[57]!==v||e[58]!==b.allModels||e[59]!==b.builtinRows||e[60]!==b.customConfig?(G=v?(0,$.jsx)(or,{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]=G):G=e[61];let K;return e[62]!==L||e[63]!==R||e[64]!==ee||e[65]!==te||e[66]!==W||e[67]!==G?(K=(0,$.jsxs)(gt,{children:[L,R,ee,te,W,G]}),e[62]=L,e[63]=R,e[64]=ee,e[65]=te,e[66]=W,e[67]=G,e[68]=K):K=e[68],K}function vr(){X()}function yr(e){return e.id===`xopc-cloud`&&!e.isCustom}function br(e){return e.language}function xr(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)(Dn,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Xn,{}),t[2]=e):e=t[2],e}}}export{_r as CapabilitiesSettingsPanel};
|