@xopcai/xopc 0.0.143 → 0.0.144
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/feishu/src/workflow-progress.js +1 -1
- package/dist/extensions/telegram/src/adapters/streaming-adapter.js +1 -1
- package/dist/extensions/telegram/src/inbound-processor.js +1 -1
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/src/routing-integration.js +2 -2
- package/dist/extensions/telegram/src/workflow-progress.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/api/api.js +1 -1
- package/dist/extensions/weixin/src/plugin.js +1 -1
- package/dist/extensions/weixin/src/workflow-progress.js +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DiME9u_P.js → agent-avatar-dicebear-EAVnrCAs.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-DzBXhZXO.js → agents-5rTuJOtT.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Cuo7SbUP.js → app-management-settings-panel-Bu568NpC.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DUfdNQqk.js → appearance-settings-DSkm9bp_.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-CKuKK5AU.js → apps-page-DWetalKp.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-B-Qk6cGr.js → archive-plugin-C99N0vV6.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Di6EEbQX.js → attachment-load-CHTDqME5.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-DGxvRxtO.js → automation-suggestion-card-CBt6U3-S.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-D-FF_WKV.js → automations-page-ICUfxeOz.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-ZaOZDH2I.js → binary-plugins-BRtxOLlM.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BTFhjWfg.js → block-editor-CUlXfgXd.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-BvKLdEQt.js → browser-settings-page-D7Bj4MKi.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-api-BU-pVZiZ.js → capability-presets-api-Bg1ntFSD.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DgyeEwzh.js → capability-presets-settings-panel-C-8I-Ktn.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-BbVsdD_I.js → channels-settings-Dm5EqQyK.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-B8QqVy3I.js → connectors-page-BOzjh-OK.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet---yzVxVR.js → desktop-pet-C-Drhqyk.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-Dc3gqBJE.js → desktop-pet-settings-CRGiolqF.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DCmOGLtK.js → directory-picker-path-field-Dw1L3M84.js} +1 -1
- package/dist/gateway/static/root/assets/dist-SwiI0Xu3.js +1 -0
- package/dist/gateway/static/root/assets/{dreaming-settings-BgT5KZVe.js → dreaming-settings-CF21cbjo.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-ByaKTTq4.js → extension-debug-page-Dcl8LJG_.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BmRzHAZr.js → extension-page-i_BXmO_x.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-JUtwIhbF.js → extension-settings-page-CWIi7xsn.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-CxicF50_.js → gateway-config-api-2sLP2kkA.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-Bz2I_EO5.js → gateway-settings-DMHiZc-2.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-VcoyuZGN.js → goal-create-dialog-CAODVDiA.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-detail-page-Cilkap2G.js → goal-detail-page-_d4DjmeX.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-config-api-CwcHRdC0.js → goals-config-api-B4qeLKQS.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-C6eoni4z.js → goals-page-lgsop664.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-settings-o4i-qAOS.js → goals-settings-Dx_1ZNgb.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DQQkETX8.js → heartbeat-settings-DeTseEk_.js} +1 -1
- package/dist/gateway/static/root/assets/{index-BKRqeRHm.js → index-VWvztcst.js} +7 -7
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-LT6qB-ua.js → keyboard-shortcuts-settings-BpwpMmlk.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Dli2e3fS.js → logs-page-9_hbTg3j.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-Dw-yE2-y.js → markdown-split-BTRFTK0w.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-D9NNNUgE.js → media-plugins-BABfIZPU.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-panel-DVn2Q1Ik.js → models-hub-panel-B1CUvZxh.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-CRgbJGgk.js → notes-page-88QBHW9a.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-BxZRHLWx.js → notes-workbench-CerZOeLW.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-D4hkWVt_.js → page-tabs-je95DZOf.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CIckv0uy.js → preview-open-alternatives-BJbwi7Rc.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-Doz53xLn.js → project-detail-page-BmrApldl.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-DoMtcRLg.js → projects-page-tTn-k76N.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BeHVEgrm.js → remote-access-hub-DeA2-pOi.js} +1 -1
- package/dist/gateway/static/root/assets/{save-bar-controls-B0b42kB2.js → save-bar-controls-qWMQ9mod.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-BtjEkczK.js → schedule-field-kxd270Gs.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Bf0bk3i6.js → schema-form-DLnD-MuD.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-Bk4bQsBe.js → sessions-page-D4kvvcL1.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CI1OG4gq.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-BTKTdTNX.js → settings-collapsible-section-DQprvu5J.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-DL4P0sAj.js → settings-form-section-Cqq7Y98y.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-BV6KFNj4.js → settings-loading-skeleton-b6rXULL5.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B_4DsX5W.js → settings-page-BtBVz3cX.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-CyGlrInB.js → settings-page-layout-BNJbtklV.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-DJ1_MLgX.js → setup-status-panel-cmclUJzS.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BQBV7YrV.js → share-preview-page--zO-A1W1.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-0VuFLBeU.js → shares-settings-DNJvqA67.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DWr_0Xgn.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-D3VdtxAn.js → skills-page-DEGsTbJx.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-D85fBBuI.js → system-settings-panel-Cq9J7i7v.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-CwEuYrHX.js → typed-models-lib-CdSwi1gT.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-m9JVQ73F.js → user-context-page-C-V73ZaJ.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-fields-editor-DtQiuY7E.js → user-profile-fields-editor-B1cxoGkh.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-CWM0fEpb.js → user-profile-settings-panel-B8hlamVB.js} +1 -1
- package/dist/gateway/static/root/assets/{utils--BO6xT3u.js → utils-Dx01V8qF.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-LoT3wgZ9.js → voice-api-key-field-DGpIUelZ.js} +1 -1
- package/dist/gateway/static/root/assets/{work-item-detail-page-DSTMz_mO.js → work-item-detail-page-fzWTxF26.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-B35lJzvm.js → workflow-run-setup-panel-Dt_x8LGg.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-BfSm9oR8.js → workflows-page-Bg02zEUh.js} +1 -1
- package/dist/gateway/static/root/index.html +2 -2
- package/dist/package.js +1 -1
- package/dist/src/activity/emitter.js +1 -1
- package/dist/src/agent/agent-manager.js +4 -4
- package/dist/src/agent/code-intelligence/binary.js +1 -1
- package/dist/src/agent/context/project-context.js +2 -2
- package/dist/src/agent/context/workspace-seed.js +2 -2
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/goals/post-turn.js +2 -2
- package/dist/src/agent/ipc/bus.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-materialize.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
- package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
- package/dist/src/agent/mcp/mcp-transport.js +1 -1
- package/dist/src/agent/memory/plugin-discovery.js +1 -1
- package/dist/src/agent/models/manager.js +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js +1 -1
- package/dist/src/agent/service.js +3 -3
- package/dist/src/agent/session/session-inspector.js +2 -2
- package/dist/src/agent/skills/hub-pull.js +1 -1
- package/dist/src/agent/tools/composio-tool.js +1 -1
- package/dist/src/agent/tools/goal-tool.js +2 -2
- package/dist/src/agent/tools/workflow-tool.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +1 -1
- package/dist/src/agent/workspace-runtime/registry.js +2 -2
- package/dist/src/automations/api/routes.js +1 -1
- package/dist/src/automations/service/action-executor.js +2 -2
- package/dist/src/browser/cdp-local-launcher.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +3 -3
- package/dist/src/browser/providers/cloakbrowser.js +2 -2
- package/dist/src/browser/providers/playwright-doctor.js +1 -1
- package/dist/src/browser/stealth.js +1 -1
- package/dist/src/capabilities/store-connector.js +1 -1
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/chat-commands/builtins/config.js +1 -1
- package/dist/src/chat-commands/builtins/goal.js +2 -2
- package/dist/src/chat-commands/context.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/session-integrity.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/extension-pack.js +1 -1
- package/dist/src/cli/commands/goal.js +2 -2
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/commands/project.js +3 -3
- package/dist/src/config/gateway-bind.js +1 -1
- package/dist/src/config/index.js +1 -1
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/connectors/composio-sessions.js +1 -1
- package/dist/src/connectors/composio.js +1 -1
- package/dist/src/daemon/launchd.js +1 -1
- package/dist/src/daemon/systemd.js +1 -1
- package/dist/src/extensions/discover-extensions.js +1 -1
- package/dist/src/extensions/loader.js +2 -2
- package/dist/src/gateway/hono/lib/static-ui.js +1 -1
- package/dist/src/gateway/hono/routes/home.js +2 -2
- package/dist/src/gateway/hono/routes/memory.js +3 -3
- package/dist/src/gateway/hono/routes/projects.js +5 -5
- package/dist/src/gateway/hono/routes/workflows.js +1 -1
- package/dist/src/gateway/hono/routes/you.js +6 -6
- package/dist/src/gateway/lock.js +1 -1
- package/dist/src/gateway/ports.js +1 -1
- package/dist/src/gateway/service.js +6 -6
- package/dist/src/goals/goal-workflow-judge.js +1 -1
- package/dist/src/infra/ports.js +1 -1
- package/dist/src/infra/ssh-tunnel.js +1 -1
- package/dist/src/infra/update-check.js +1 -1
- package/dist/src/migrations/runner.js +1 -1
- package/dist/src/notes/service.js +3 -3
- package/dist/src/notes/store.js +1 -1
- package/dist/src/projects/project-service.js +1 -1
- package/dist/src/projects/workspace.js +1 -1
- package/dist/src/routing/agent-session-key.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/session/init-session-turn.js +1 -1
- package/dist/src/session/resolve-session.js +1 -1
- package/dist/src/session/session-title.js +2 -2
- package/dist/src/session/store.js +1 -1
- package/dist/src/storage/sqlite/connection.js +1 -1
- package/dist/src/storage/sqlite/row-mappers.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +4 -4
- package/dist/src/tui/clipboard-image.js +1 -1
- package/dist/src/tui/tui-command-formatters.js +2 -2
- package/dist/src/tui/tui-commands.js +3 -3
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/utils/index.js +1 -1
- package/dist/src/utils/logger/index.js +1 -1
- package/dist/src/utils/logger.js +1 -1
- package/dist/src/work-items/work-item-service.js +1 -1
- package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
- package/dist/src/workflows/service/workflow-session-bridge.js +3 -3
- package/package.json +2 -2
- package/dist/gateway/static/root/assets/dist-Mys7eFJ5.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DdFyaRMm.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DO87Ckeo.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-CzKxM6I4.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{cr as s,or as c,ro as l,sr as u}from"./index-BKRqeRHm.js";import{n as d,t as f}from"./settings-page-layout-CyGlrInB.js";var p=n(),m=e(t(),1),h=r(),g=typeof navigator<`u`&&(navigator.platform?.includes(`Mac`)??navigator.userAgent.includes(`Mac`)),_=g?`⌘`:`Ctrl`;function v(e){return e.split(`+`).map(e=>e===`control`?`Ctrl`:e===`meta`?g?`⌘`:`Win`:e===`alt`?g?`Option`:`Alt`:e===`shift`?`Shift`:e===`space`?`Space`:e.length===1?e.toUpperCase():e)}function y(){let e=(0,p.c)(47),t=o(w),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n.keyboardShortcutsSettings,l=s(C),d=s(S),[f,_]=(0,m.useState)(!1),[y,T]=(0,m.useState)(null),E,D;e[2]===f?(E=e[3],D=e[4]):(E=()=>(window.dispatchEvent(new CustomEvent(`quick-capture-shortcut-recording`,{detail:{active:f}})),x),D=[f],e[2]=f,e[3]=E,e[4]=D),(0,m.useEffect)(E,D);let O;e[5]!==r.quickCaptureShortcutConflict||e[6]!==f||e[7]!==d?(O=e=>{if(!f)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){_(!1);return}let t=u(e.nativeEvent);if(!t)return;let n=g?`meta`:`control`;if(new Set([`${n}+k`,`${n}+n`,`${n}+b`,`${n}+,`]).has(t)){T(r.quickCaptureShortcutConflict);return}d(t),T(null),_(!1)},e[5]=r.quickCaptureShortcutConflict,e[6]=f,e[7]=d,e[8]=O):O=e[8];let k=O,A=r.quickCaptureShortcutTitle,j;e[9]===r.quickCaptureShortcutTitle?j=e[10]:(j=(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.quickCaptureShortcutTitle}),e[9]=r.quickCaptureShortcutTitle,e[10]=j);let M;e[11]===r.quickCaptureShortcutDescription?M=e[12]:(M=(0,h.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.quickCaptureShortcutDescription}),e[11]=r.quickCaptureShortcutDescription,e[12]=M);let N;e[13]!==j||e[14]!==M?(N=(0,h.jsxs)(`div`,{className:`min-w-0`,children:[j,M]}),e[13]=j,e[14]=M,e[15]=N):N=e[15];let P;e[16]===l?P=e[17]:(P=v(l).map(b),e[16]=l,e[17]=P);let F;e[18]===P?F=e[19]:(F=(0,h.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:P}),e[18]=P,e[19]=F);let I;e[20]!==N||e[21]!==F?(I=(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[N,F]}),e[20]=N,e[21]=F,e[22]=I):I=e[22];let L,R;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=i(`rounded-lg bg-accent px-3 py-1.5 text-sm font-medium text-accent-contrast transition-colors hover:bg-accent/90`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),R=()=>{T(null),_(!0)},e[23]=L,e[24]=R):(L=e[23],R=e[24]);let z;e[25]===r.quickCaptureShortcutChange?z=e[26]:(z=(0,h.jsx)(`button`,{type:`button`,className:L,onClick:R,children:r.quickCaptureShortcutChange}),e[25]=r.quickCaptureShortcutChange,e[26]=z);let B;e[27]===d?B=e[28]:(B=()=>{d(c()),T(null)},e[27]=d,e[28]=B);let V;e[29]!==r.quickCaptureShortcutReset||e[30]!==B?(V=(0,h.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:B,children:r.quickCaptureShortcutReset}),e[29]=r.quickCaptureShortcutReset,e[30]=B,e[31]=V):V=e[31];let H;e[32]!==r.quickCaptureShortcutRecording||e[33]!==k||e[34]!==f?(H=f?(0,h.jsx)(`button`,{type:`button`,autoFocus:!0,className:`rounded-lg border border-accent bg-accent-soft px-3 py-1.5 text-sm font-medium text-accent-fg outline-none`,onKeyDown:k,onClick:()=>_(!1),children:r.quickCaptureShortcutRecording}):null,e[32]=r.quickCaptureShortcutRecording,e[33]=k,e[34]=f,e[35]=H):H=e[35];let U;e[36]!==z||e[37]!==V||e[38]!==H?(U=(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[z,V,H]}),e[36]=z,e[37]=V,e[38]=H,e[39]=U):U=e[39];let W;e[40]===y?W=e[41]:(W=y?(0,h.jsx)(`p`,{className:`mt-2 text-sm text-danger-fg`,children:y}):null,e[40]=y,e[41]=W);let G;return e[42]!==r.quickCaptureShortcutTitle||e[43]!==I||e[44]!==U||e[45]!==W?(G=(0,h.jsxs)(`section`,{className:`rounded-xl bg-surface-base px-4 py-3.5 sm:px-5 sm:py-4`,"aria-label":A,children:[I,U,W]}),e[42]=r.quickCaptureShortcutTitle,e[43]=I,e[44]=U,e[45]=W,e[46]=G):G=e[46],G}function b(e,t){return(0,h.jsx)(T,{children:e},`${e}-${String(t)}`)}function x(){window.dispatchEvent(new CustomEvent(`quick-capture-shortcut-recording`,{detail:{active:!1}}))}function S(e){return e.setShortcut}function C(e){return e.shortcut}function w(e){return e.language}function T(e){let t=(0,p.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,h.jsx)(`kbd`,{className:`inline-flex min-w-[1.5rem] items-center justify-center rounded-md border border-edge-subtle bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs font-medium text-fg-muted shadow-[0_1px_0_0_var(--color-edge-subtle)]`,children:n}),t[0]=n,t[1]=r),r}function E(e){let t=(0,p.c)(14),{keys:n,label:r,note:i}=e,a;t[0]===r?a=t[1]:(a=(0,h.jsx)(`span`,{className:`text-sm text-fg`,children:r}),t[0]=r,t[1]=a);let o;t[2]===i?o=t[3]:(o=i&&(0,h.jsxs)(`span`,{className:`ml-1.5 text-xs text-fg-muted`,children:[`(`,i,`)`]}),t[2]=i,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,h.jsxs)(`div`,{className:`min-w-0`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===n?c=t[8]:(c=n.map(D),t[7]=n,t[8]=c);let l;t[9]===c?l=t[10]:(l=(0,h.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:c}),t[9]=c,t[10]=l);let u;return t[11]!==s||t[12]!==l?(u=(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-2.5`,children:[s,l]}),t[11]=s,t[12]=l,t[13]=u):u=t[13],u}function D(e){return(0,h.jsx)(T,{children:e},e)}function O(e){let t=(0,p.c)(11),{title:n,shortcuts:r}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=i(`rounded-xl bg-surface-base px-4 sm:px-5`),t[0]=a):a=t[0];let o;t[1]===n?o=t[2]:(o=(0,h.jsx)(`h2`,{className:`pb-1 pt-3.5 text-sm font-semibold text-fg sm:pt-4`,children:n}),t[1]=n,t[2]=o);let s;t[3]===r?s=t[4]:(s=r.map(k),t[3]=r,t[4]=s);let c;t[5]===s?c=t[6]:(c=(0,h.jsx)(`div`,{className:`grid gap-1 pb-3 sm:pb-4`,children:s}),t[5]=s,t[6]=c);let l;return t[7]!==o||t[8]!==c||t[9]!==n?(l=(0,h.jsxs)(`section`,{className:a,"aria-label":n,children:[o,c]}),t[7]=o,t[8]=c,t[9]=n,t[10]=l):l=t[10],l}function k(e){return(0,h.jsx)(E,{...e},e.label)}function A(){let e=(0,p.c)(115),t=o(N),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n.keyboardShortcutsSettings,i=s(M),c;if(e[2]!==r.categoryChat||e[3]!==r.categoryEditor||e[4]!==r.categoryGlobal||e[5]!==r.categoryNavigation||e[6]!==r.chatForceSend||e[7]!==r.chatNewLine||e[8]!==r.chatSend||e[9]!==r.editorBulletList||e[10]!==r.editorHeading1||e[11]!==r.editorHeading2||e[12]!==r.editorHeading3||e[13]!==r.editorOrderedList||e[14]!==r.editorTaskList||e[15]!==r.globalNewChat||e[16]!==r.globalOpenSettings||e[17]!==r.globalToggleWindow||e[18]!==r.navCloseDialog||e[19]!==r.navCommandPalette||e[20]!==r.navQuickCapture||e[21]!==r.navToggleFullscreen||e[22]!==r.navToggleSidebar||e[23]!==i){if(c=[],l()){let t;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(t=[_,`Shift`,`Space`],e[25]=t):t=e[25];let n;e[26]===r.globalToggleWindow?n=e[27]:(n=[{keys:t,label:r.globalToggleWindow}],e[26]=r.globalToggleWindow,e[27]=n);let i;e[28]!==r.categoryGlobal||e[29]!==n?(i={title:r.categoryGlobal,shortcuts:n},e[28]=r.categoryGlobal,e[29]=n,e[30]=i):i=e[30],c.push(i)}let t=r.categoryNavigation,n;e[31]===Symbol.for(`react.memo_cache_sentinel`)?(n=[_,`N`],e[31]=n):n=e[31];let a;e[32]===r.globalNewChat?a=e[33]:(a={keys:n,label:r.globalNewChat},e[32]=r.globalNewChat,e[33]=a);let o;e[34]===Symbol.for(`react.memo_cache_sentinel`)?(o=[_,`K`],e[34]=o):o=e[34];let s;e[35]===r.navCommandPalette?s=e[36]:(s={keys:o,label:r.navCommandPalette},e[35]=r.navCommandPalette,e[36]=s);let u;e[37]===i?u=e[38]:(u=v(i),e[37]=i,e[38]=u);let d;e[39]!==r.navQuickCapture||e[40]!==u?(d={keys:u,label:r.navQuickCapture},e[39]=r.navQuickCapture,e[40]=u,e[41]=d):d=e[41];let f;e[42]===r.navToggleSidebar?f=e[43]:(f=l()?[{keys:[_,`B`],label:r.navToggleSidebar}]:[],e[42]=r.navToggleSidebar,e[43]=f);let p;e[44]===r.navToggleFullscreen?p=e[45]:(p=l()?[{keys:[`F11`],label:r.navToggleFullscreen}]:[],e[44]=r.navToggleFullscreen,e[45]=p);let m;e[46]===r.globalOpenSettings?m=e[47]:(m=l()?[{keys:[_,`,`],label:r.globalOpenSettings}]:[],e[46]=r.globalOpenSettings,e[47]=m);let h;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(h=[`Esc`],e[48]=h):h=e[48];let g;e[49]===r.navCloseDialog?g=e[50]:(g={keys:h,label:r.navCloseDialog},e[49]=r.navCloseDialog,e[50]=g);let y;e[51]!==m||e[52]!==g||e[53]!==a||e[54]!==s||e[55]!==d||e[56]!==f||e[57]!==p?(y=[a,s,d,...f,...p,...m,g],e[51]=m,e[52]=g,e[53]=a,e[54]=s,e[55]=d,e[56]=f,e[57]=p,e[58]=y):y=e[58];let b;e[59]!==r.categoryNavigation||e[60]!==y?(b={title:t,shortcuts:y},e[59]=r.categoryNavigation,e[60]=y,e[61]=b):b=e[61],c.push(b);let x;e[62]===Symbol.for(`react.memo_cache_sentinel`)?(x=[`Enter`],e[62]=x):x=e[62];let S;e[63]===r.chatSend?S=e[64]:(S={keys:x,label:r.chatSend},e[63]=r.chatSend,e[64]=S);let C;e[65]===Symbol.for(`react.memo_cache_sentinel`)?(C=[`Shift`,`Enter`],e[65]=C):C=e[65];let w;e[66]===r.chatNewLine?w=e[67]:(w={keys:C,label:r.chatNewLine},e[66]=r.chatNewLine,e[67]=w);let T;e[68]===Symbol.for(`react.memo_cache_sentinel`)?(T=[_,`Enter`],e[68]=T):T=e[68];let E;e[69]===r.chatForceSend?E=e[70]:(E={keys:T,label:r.chatForceSend},e[69]=r.chatForceSend,e[70]=E);let D;e[71]!==S||e[72]!==w||e[73]!==E?(D=[S,w,E],e[71]=S,e[72]=w,e[73]=E,e[74]=D):D=e[74];let O;e[75]!==r.categoryChat||e[76]!==D?(O={title:r.categoryChat,shortcuts:D},e[75]=r.categoryChat,e[76]=D,e[77]=O):O=e[77],c.push(O);let k;e[78]===Symbol.for(`react.memo_cache_sentinel`)?(k=[_,`Shift`,`1`],e[78]=k):k=e[78];let A;e[79]===r.editorHeading1?A=e[80]:(A={keys:k,label:r.editorHeading1},e[79]=r.editorHeading1,e[80]=A);let j;e[81]===Symbol.for(`react.memo_cache_sentinel`)?(j=[_,`Shift`,`2`],e[81]=j):j=e[81];let M;e[82]===r.editorHeading2?M=e[83]:(M={keys:j,label:r.editorHeading2},e[82]=r.editorHeading2,e[83]=M);let N;e[84]===Symbol.for(`react.memo_cache_sentinel`)?(N=[_,`Shift`,`3`],e[84]=N):N=e[84];let P;e[85]===r.editorHeading3?P=e[86]:(P={keys:N,label:r.editorHeading3},e[85]=r.editorHeading3,e[86]=P);let F;e[87]===Symbol.for(`react.memo_cache_sentinel`)?(F=[_,`Shift`,`8`],e[87]=F):F=e[87];let I;e[88]===r.editorBulletList?I=e[89]:(I={keys:F,label:r.editorBulletList},e[88]=r.editorBulletList,e[89]=I);let L;e[90]===Symbol.for(`react.memo_cache_sentinel`)?(L=[_,`Shift`,`9`],e[90]=L):L=e[90];let R;e[91]===r.editorOrderedList?R=e[92]:(R={keys:L,label:r.editorOrderedList},e[91]=r.editorOrderedList,e[92]=R);let z;e[93]===Symbol.for(`react.memo_cache_sentinel`)?(z=[_,`Shift`,`0`],e[93]=z):z=e[93];let B;e[94]===r.editorTaskList?B=e[95]:(B={keys:z,label:r.editorTaskList},e[94]=r.editorTaskList,e[95]=B);let V;e[96]!==A||e[97]!==M||e[98]!==P||e[99]!==I||e[100]!==R||e[101]!==B?(V=[A,M,P,I,R,B],e[96]=A,e[97]=M,e[98]=P,e[99]=I,e[100]=R,e[101]=B,e[102]=V):V=e[102];let H;e[103]!==r.categoryEditor||e[104]!==V?(H={title:r.categoryEditor,shortcuts:V},e[103]=r.categoryEditor,e[104]=V,e[105]=H):H=e[105],c.push(H),e[2]=r.categoryChat,e[3]=r.categoryEditor,e[4]=r.categoryGlobal,e[5]=r.categoryNavigation,e[6]=r.chatForceSend,e[7]=r.chatNewLine,e[8]=r.chatSend,e[9]=r.editorBulletList,e[10]=r.editorHeading1,e[11]=r.editorHeading2,e[12]=r.editorHeading3,e[13]=r.editorOrderedList,e[14]=r.editorTaskList,e[15]=r.globalNewChat,e[16]=r.globalOpenSettings,e[17]=r.globalToggleWindow,e[18]=r.navCloseDialog,e[19]=r.navCommandPalette,e[20]=r.navQuickCapture,e[21]=r.navToggleFullscreen,e[22]=r.navToggleSidebar,e[23]=i,e[24]=c}else c=e[24];let u;e[106]!==r.pageTitle||e[107]!==r.subtitle?(u=(0,h.jsx)(d,{title:r.pageTitle,subtitle:r.subtitle}),e[106]=r.pageTitle,e[107]=r.subtitle,e[108]=u):u=e[108];let m;e[109]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,h.jsx)(y,{}),e[109]=m):m=e[109];let g;e[110]===c?g=e[111]:(g=c.map(j),e[110]=c,e[111]=g);let b;return e[112]!==u||e[113]!==g?(b=(0,h.jsxs)(f,{gap:`gap-6`,children:[u,m,g]}),e[112]=u,e[113]=g,e[114]=b):b=e[114],b}function j(e){return(0,h.jsx)(O,{...e},e.title)}function M(e){return e.shortcut}function N(e){return e.language}export{A as KeyboardShortcutsSettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-CzKxM6I4.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{cr as s,or as c,ro as l,sr as u}from"./index-VWvztcst.js";import{n as d,t as f}from"./settings-page-layout-BNJbtklV.js";var p=n(),m=e(t(),1),h=r(),g=typeof navigator<`u`&&(navigator.platform?.includes(`Mac`)??navigator.userAgent.includes(`Mac`)),_=g?`⌘`:`Ctrl`;function v(e){return e.split(`+`).map(e=>e===`control`?`Ctrl`:e===`meta`?g?`⌘`:`Win`:e===`alt`?g?`Option`:`Alt`:e===`shift`?`Shift`:e===`space`?`Space`:e.length===1?e.toUpperCase():e)}function y(){let e=(0,p.c)(47),t=o(w),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n.keyboardShortcutsSettings,l=s(C),d=s(S),[f,_]=(0,m.useState)(!1),[y,T]=(0,m.useState)(null),E,D;e[2]===f?(E=e[3],D=e[4]):(E=()=>(window.dispatchEvent(new CustomEvent(`quick-capture-shortcut-recording`,{detail:{active:f}})),x),D=[f],e[2]=f,e[3]=E,e[4]=D),(0,m.useEffect)(E,D);let O;e[5]!==r.quickCaptureShortcutConflict||e[6]!==f||e[7]!==d?(O=e=>{if(!f)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){_(!1);return}let t=u(e.nativeEvent);if(!t)return;let n=g?`meta`:`control`;if(new Set([`${n}+k`,`${n}+n`,`${n}+b`,`${n}+,`]).has(t)){T(r.quickCaptureShortcutConflict);return}d(t),T(null),_(!1)},e[5]=r.quickCaptureShortcutConflict,e[6]=f,e[7]=d,e[8]=O):O=e[8];let k=O,A=r.quickCaptureShortcutTitle,j;e[9]===r.quickCaptureShortcutTitle?j=e[10]:(j=(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.quickCaptureShortcutTitle}),e[9]=r.quickCaptureShortcutTitle,e[10]=j);let M;e[11]===r.quickCaptureShortcutDescription?M=e[12]:(M=(0,h.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.quickCaptureShortcutDescription}),e[11]=r.quickCaptureShortcutDescription,e[12]=M);let N;e[13]!==j||e[14]!==M?(N=(0,h.jsxs)(`div`,{className:`min-w-0`,children:[j,M]}),e[13]=j,e[14]=M,e[15]=N):N=e[15];let P;e[16]===l?P=e[17]:(P=v(l).map(b),e[16]=l,e[17]=P);let F;e[18]===P?F=e[19]:(F=(0,h.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:P}),e[18]=P,e[19]=F);let I;e[20]!==N||e[21]!==F?(I=(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[N,F]}),e[20]=N,e[21]=F,e[22]=I):I=e[22];let L,R;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=i(`rounded-lg bg-accent px-3 py-1.5 text-sm font-medium text-accent-contrast transition-colors hover:bg-accent/90`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),R=()=>{T(null),_(!0)},e[23]=L,e[24]=R):(L=e[23],R=e[24]);let z;e[25]===r.quickCaptureShortcutChange?z=e[26]:(z=(0,h.jsx)(`button`,{type:`button`,className:L,onClick:R,children:r.quickCaptureShortcutChange}),e[25]=r.quickCaptureShortcutChange,e[26]=z);let B;e[27]===d?B=e[28]:(B=()=>{d(c()),T(null)},e[27]=d,e[28]=B);let V;e[29]!==r.quickCaptureShortcutReset||e[30]!==B?(V=(0,h.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:B,children:r.quickCaptureShortcutReset}),e[29]=r.quickCaptureShortcutReset,e[30]=B,e[31]=V):V=e[31];let H;e[32]!==r.quickCaptureShortcutRecording||e[33]!==k||e[34]!==f?(H=f?(0,h.jsx)(`button`,{type:`button`,autoFocus:!0,className:`rounded-lg border border-accent bg-accent-soft px-3 py-1.5 text-sm font-medium text-accent-fg outline-none`,onKeyDown:k,onClick:()=>_(!1),children:r.quickCaptureShortcutRecording}):null,e[32]=r.quickCaptureShortcutRecording,e[33]=k,e[34]=f,e[35]=H):H=e[35];let U;e[36]!==z||e[37]!==V||e[38]!==H?(U=(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[z,V,H]}),e[36]=z,e[37]=V,e[38]=H,e[39]=U):U=e[39];let W;e[40]===y?W=e[41]:(W=y?(0,h.jsx)(`p`,{className:`mt-2 text-sm text-danger-fg`,children:y}):null,e[40]=y,e[41]=W);let G;return e[42]!==r.quickCaptureShortcutTitle||e[43]!==I||e[44]!==U||e[45]!==W?(G=(0,h.jsxs)(`section`,{className:`rounded-xl bg-surface-base px-4 py-3.5 sm:px-5 sm:py-4`,"aria-label":A,children:[I,U,W]}),e[42]=r.quickCaptureShortcutTitle,e[43]=I,e[44]=U,e[45]=W,e[46]=G):G=e[46],G}function b(e,t){return(0,h.jsx)(T,{children:e},`${e}-${String(t)}`)}function x(){window.dispatchEvent(new CustomEvent(`quick-capture-shortcut-recording`,{detail:{active:!1}}))}function S(e){return e.setShortcut}function C(e){return e.shortcut}function w(e){return e.language}function T(e){let t=(0,p.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,h.jsx)(`kbd`,{className:`inline-flex min-w-[1.5rem] items-center justify-center rounded-md border border-edge-subtle bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs font-medium text-fg-muted shadow-[0_1px_0_0_var(--color-edge-subtle)]`,children:n}),t[0]=n,t[1]=r),r}function E(e){let t=(0,p.c)(14),{keys:n,label:r,note:i}=e,a;t[0]===r?a=t[1]:(a=(0,h.jsx)(`span`,{className:`text-sm text-fg`,children:r}),t[0]=r,t[1]=a);let o;t[2]===i?o=t[3]:(o=i&&(0,h.jsxs)(`span`,{className:`ml-1.5 text-xs text-fg-muted`,children:[`(`,i,`)`]}),t[2]=i,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,h.jsxs)(`div`,{className:`min-w-0`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===n?c=t[8]:(c=n.map(D),t[7]=n,t[8]=c);let l;t[9]===c?l=t[10]:(l=(0,h.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:c}),t[9]=c,t[10]=l);let u;return t[11]!==s||t[12]!==l?(u=(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-2.5`,children:[s,l]}),t[11]=s,t[12]=l,t[13]=u):u=t[13],u}function D(e){return(0,h.jsx)(T,{children:e},e)}function O(e){let t=(0,p.c)(11),{title:n,shortcuts:r}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=i(`rounded-xl bg-surface-base px-4 sm:px-5`),t[0]=a):a=t[0];let o;t[1]===n?o=t[2]:(o=(0,h.jsx)(`h2`,{className:`pb-1 pt-3.5 text-sm font-semibold text-fg sm:pt-4`,children:n}),t[1]=n,t[2]=o);let s;t[3]===r?s=t[4]:(s=r.map(k),t[3]=r,t[4]=s);let c;t[5]===s?c=t[6]:(c=(0,h.jsx)(`div`,{className:`grid gap-1 pb-3 sm:pb-4`,children:s}),t[5]=s,t[6]=c);let l;return t[7]!==o||t[8]!==c||t[9]!==n?(l=(0,h.jsxs)(`section`,{className:a,"aria-label":n,children:[o,c]}),t[7]=o,t[8]=c,t[9]=n,t[10]=l):l=t[10],l}function k(e){return(0,h.jsx)(E,{...e},e.label)}function A(){let e=(0,p.c)(115),t=o(N),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n.keyboardShortcutsSettings,i=s(M),c;if(e[2]!==r.categoryChat||e[3]!==r.categoryEditor||e[4]!==r.categoryGlobal||e[5]!==r.categoryNavigation||e[6]!==r.chatForceSend||e[7]!==r.chatNewLine||e[8]!==r.chatSend||e[9]!==r.editorBulletList||e[10]!==r.editorHeading1||e[11]!==r.editorHeading2||e[12]!==r.editorHeading3||e[13]!==r.editorOrderedList||e[14]!==r.editorTaskList||e[15]!==r.globalNewChat||e[16]!==r.globalOpenSettings||e[17]!==r.globalToggleWindow||e[18]!==r.navCloseDialog||e[19]!==r.navCommandPalette||e[20]!==r.navQuickCapture||e[21]!==r.navToggleFullscreen||e[22]!==r.navToggleSidebar||e[23]!==i){if(c=[],l()){let t;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(t=[_,`Shift`,`Space`],e[25]=t):t=e[25];let n;e[26]===r.globalToggleWindow?n=e[27]:(n=[{keys:t,label:r.globalToggleWindow}],e[26]=r.globalToggleWindow,e[27]=n);let i;e[28]!==r.categoryGlobal||e[29]!==n?(i={title:r.categoryGlobal,shortcuts:n},e[28]=r.categoryGlobal,e[29]=n,e[30]=i):i=e[30],c.push(i)}let t=r.categoryNavigation,n;e[31]===Symbol.for(`react.memo_cache_sentinel`)?(n=[_,`N`],e[31]=n):n=e[31];let a;e[32]===r.globalNewChat?a=e[33]:(a={keys:n,label:r.globalNewChat},e[32]=r.globalNewChat,e[33]=a);let o;e[34]===Symbol.for(`react.memo_cache_sentinel`)?(o=[_,`K`],e[34]=o):o=e[34];let s;e[35]===r.navCommandPalette?s=e[36]:(s={keys:o,label:r.navCommandPalette},e[35]=r.navCommandPalette,e[36]=s);let u;e[37]===i?u=e[38]:(u=v(i),e[37]=i,e[38]=u);let d;e[39]!==r.navQuickCapture||e[40]!==u?(d={keys:u,label:r.navQuickCapture},e[39]=r.navQuickCapture,e[40]=u,e[41]=d):d=e[41];let f;e[42]===r.navToggleSidebar?f=e[43]:(f=l()?[{keys:[_,`B`],label:r.navToggleSidebar}]:[],e[42]=r.navToggleSidebar,e[43]=f);let p;e[44]===r.navToggleFullscreen?p=e[45]:(p=l()?[{keys:[`F11`],label:r.navToggleFullscreen}]:[],e[44]=r.navToggleFullscreen,e[45]=p);let m;e[46]===r.globalOpenSettings?m=e[47]:(m=l()?[{keys:[_,`,`],label:r.globalOpenSettings}]:[],e[46]=r.globalOpenSettings,e[47]=m);let h;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(h=[`Esc`],e[48]=h):h=e[48];let g;e[49]===r.navCloseDialog?g=e[50]:(g={keys:h,label:r.navCloseDialog},e[49]=r.navCloseDialog,e[50]=g);let y;e[51]!==m||e[52]!==g||e[53]!==a||e[54]!==s||e[55]!==d||e[56]!==f||e[57]!==p?(y=[a,s,d,...f,...p,...m,g],e[51]=m,e[52]=g,e[53]=a,e[54]=s,e[55]=d,e[56]=f,e[57]=p,e[58]=y):y=e[58];let b;e[59]!==r.categoryNavigation||e[60]!==y?(b={title:t,shortcuts:y},e[59]=r.categoryNavigation,e[60]=y,e[61]=b):b=e[61],c.push(b);let x;e[62]===Symbol.for(`react.memo_cache_sentinel`)?(x=[`Enter`],e[62]=x):x=e[62];let S;e[63]===r.chatSend?S=e[64]:(S={keys:x,label:r.chatSend},e[63]=r.chatSend,e[64]=S);let C;e[65]===Symbol.for(`react.memo_cache_sentinel`)?(C=[`Shift`,`Enter`],e[65]=C):C=e[65];let w;e[66]===r.chatNewLine?w=e[67]:(w={keys:C,label:r.chatNewLine},e[66]=r.chatNewLine,e[67]=w);let T;e[68]===Symbol.for(`react.memo_cache_sentinel`)?(T=[_,`Enter`],e[68]=T):T=e[68];let E;e[69]===r.chatForceSend?E=e[70]:(E={keys:T,label:r.chatForceSend},e[69]=r.chatForceSend,e[70]=E);let D;e[71]!==S||e[72]!==w||e[73]!==E?(D=[S,w,E],e[71]=S,e[72]=w,e[73]=E,e[74]=D):D=e[74];let O;e[75]!==r.categoryChat||e[76]!==D?(O={title:r.categoryChat,shortcuts:D},e[75]=r.categoryChat,e[76]=D,e[77]=O):O=e[77],c.push(O);let k;e[78]===Symbol.for(`react.memo_cache_sentinel`)?(k=[_,`Shift`,`1`],e[78]=k):k=e[78];let A;e[79]===r.editorHeading1?A=e[80]:(A={keys:k,label:r.editorHeading1},e[79]=r.editorHeading1,e[80]=A);let j;e[81]===Symbol.for(`react.memo_cache_sentinel`)?(j=[_,`Shift`,`2`],e[81]=j):j=e[81];let M;e[82]===r.editorHeading2?M=e[83]:(M={keys:j,label:r.editorHeading2},e[82]=r.editorHeading2,e[83]=M);let N;e[84]===Symbol.for(`react.memo_cache_sentinel`)?(N=[_,`Shift`,`3`],e[84]=N):N=e[84];let P;e[85]===r.editorHeading3?P=e[86]:(P={keys:N,label:r.editorHeading3},e[85]=r.editorHeading3,e[86]=P);let F;e[87]===Symbol.for(`react.memo_cache_sentinel`)?(F=[_,`Shift`,`8`],e[87]=F):F=e[87];let I;e[88]===r.editorBulletList?I=e[89]:(I={keys:F,label:r.editorBulletList},e[88]=r.editorBulletList,e[89]=I);let L;e[90]===Symbol.for(`react.memo_cache_sentinel`)?(L=[_,`Shift`,`9`],e[90]=L):L=e[90];let R;e[91]===r.editorOrderedList?R=e[92]:(R={keys:L,label:r.editorOrderedList},e[91]=r.editorOrderedList,e[92]=R);let z;e[93]===Symbol.for(`react.memo_cache_sentinel`)?(z=[_,`Shift`,`0`],e[93]=z):z=e[93];let B;e[94]===r.editorTaskList?B=e[95]:(B={keys:z,label:r.editorTaskList},e[94]=r.editorTaskList,e[95]=B);let V;e[96]!==A||e[97]!==M||e[98]!==P||e[99]!==I||e[100]!==R||e[101]!==B?(V=[A,M,P,I,R,B],e[96]=A,e[97]=M,e[98]=P,e[99]=I,e[100]=R,e[101]=B,e[102]=V):V=e[102];let H;e[103]!==r.categoryEditor||e[104]!==V?(H={title:r.categoryEditor,shortcuts:V},e[103]=r.categoryEditor,e[104]=V,e[105]=H):H=e[105],c.push(H),e[2]=r.categoryChat,e[3]=r.categoryEditor,e[4]=r.categoryGlobal,e[5]=r.categoryNavigation,e[6]=r.chatForceSend,e[7]=r.chatNewLine,e[8]=r.chatSend,e[9]=r.editorBulletList,e[10]=r.editorHeading1,e[11]=r.editorHeading2,e[12]=r.editorHeading3,e[13]=r.editorOrderedList,e[14]=r.editorTaskList,e[15]=r.globalNewChat,e[16]=r.globalOpenSettings,e[17]=r.globalToggleWindow,e[18]=r.navCloseDialog,e[19]=r.navCommandPalette,e[20]=r.navQuickCapture,e[21]=r.navToggleFullscreen,e[22]=r.navToggleSidebar,e[23]=i,e[24]=c}else c=e[24];let u;e[106]!==r.pageTitle||e[107]!==r.subtitle?(u=(0,h.jsx)(d,{title:r.pageTitle,subtitle:r.subtitle}),e[106]=r.pageTitle,e[107]=r.subtitle,e[108]=u):u=e[108];let m;e[109]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,h.jsx)(y,{}),e[109]=m):m=e[109];let g;e[110]===c?g=e[111]:(g=c.map(j),e[110]=c,e[111]=g);let b;return e[112]!==u||e[113]!==g?(b=(0,h.jsxs)(f,{gap:`gap-6`,children:[u,m,g]}),e[112]=u,e[113]=g,e[114]=b):b=e[114],b}function j(e){return(0,h.jsx)(O,{...e},e.title)}function M(e){return e.shortcut}function N(e){return e.language}export{A as KeyboardShortcutsSettingsPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-CzKxM6I4.js";import{a as s,n as c,o as l}from"./fetch-8QNN25Sh.js";import{n as u}from"./locale-store-Ba72bFmP.js";import{$c as d,Bc as f,Co as p,Do as m,Eo as h,Fi as g,Ho as _,Is as v,Kc as y,Na as b,Oo as x,Po as S,So as C,Vc as w,Wi as T,Wo as E,ao as D,bo as O,co as k,cs as A,dl as j,gc as M,io as N,ko as P,ks as F,lo as I,qo as L,so as R,uo as z,vo as B,wl as ee,wo as V,zo as te}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-CzKxM6I4.js";import{a as s,n as c,o as l}from"./fetch-8QNN25Sh.js";import{n as u}from"./locale-store-Ba72bFmP.js";import{$c as d,Bc as f,Co as p,Do as m,Eo as h,Fi as g,Ho as _,Is as v,Kc as y,Na as b,Oo as x,Po as S,So as C,Vc as w,Wi as T,Wo as E,ao as D,bo as O,co as k,cs as A,dl as j,gc as M,io as N,ko as P,ks as F,lo as I,qo as L,so as R,uo as z,vo as B,wl as ee,wo as V,zo as te}from"./index-VWvztcst.js";import{r as H}from"./segmented-styles-BL8oLBEp.js";var U=e(t(),1),W=n();function G(e){let t=new URLSearchParams;if(!e)return``;e.level?.length&&t.set(`level`,e.level.join(`,`)),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.q&&t.set(`q`,e.q),e.module&&t.set(`module`,e.module),e.requestId&&t.set(`requestId`,e.requestId),e.sessionKey&&t.set(`sessionKey`,e.sessionKey),e.sessionId&&t.set(`sessionId`,e.sessionId),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let n=t.toString();return n?`?${n}`:``}async function K(e){return c(l(`/api/logs${G(e)}`))}async function q(){return(await c(l(`/api/logs/files`))).files??[]}async function J(){return(await c(l(`/api/logs/modules`))).modules??[]}async function Y(){let e=await c(l(`/api/logs/stats`));return{byLevel:e.byLevel??{},runtime:e.runtime}}async function ne(){return(await c(l(`/api/logs/dir`))).dir??``}async function X(){return(await c(l(`/api/logs/level`))).level??`info`}async function Z(e,t){return c(l(`/api/logs/level`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({level:e,...t==null?{}:{duration:String(t)}})})}async function re(e){let t=new URLSearchParams;e?.from&&t.set(`from`,e.from),e?.to&&t.set(`to`,e.to),e?.limit!=null&&t.set(`limit`,String(e.limit));let n=t.toString();return(await c(l(`/api/logs/errors/summary${n?`?${n}`:``}`))).items??[]}var ie=500,ae=class{_token;_callbacks;_abort;constructor(e,t){this._token=e,this._callbacks=t}connect(e,t){this.disconnect();let n=new AbortController;this._abort=n,this._consume(n,e,t)}async _consume(e,t,n){let r=new URL(l(`/api/logs/stream`));t?.length?r.searchParams.set(`levels`,t.join(`,`)):r.searchParams.set(`levels`,`trace,debug,info,warn,error,fatal`),n&&r.searchParams.set(`module`,n);try{let t=new Headers({Accept:`text/event-stream`});this._token&&t.set(`Authorization`,`Bearer ${this._token}`);let n=await fetch(r.toString(),{headers:t,signal:e.signal});if(!n.ok||!n.body)throw Error(`Log stream failed: ${n.status}`);let i=n.body.getReader(),a=new TextDecoder,o=``;for(;!e.signal.aborted;){let{done:e,value:t}=await i.read();if(e)break;o+=a.decode(t,{stream:!0});let n=o.indexOf(`
|
|
2
2
|
|
|
3
3
|
`);for(;n>=0;)this._dispatchChunk(o.slice(0,n)),o=o.slice(n+2),n=o.indexOf(`
|
|
4
4
|
|
package/dist/gateway/static/root/assets/{markdown-split-Dw-yE2-y.js → markdown-split-BTRFTK0w.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{bi as r}from"./index-
|
|
1
|
+
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{bi as r}from"./index-VWvztcst.js";import{t as i}from"./markdown-editor-jD1LPiP-.js";var a=t();e();var o=n();function s(e){let t=(0,a.c)(12),{initialContent:n,onSave:s,isDark:c,wordWrap:l,onToggleWordWrap:u}=e,d=c===void 0?!1:c,f=l===void 0?!1:l,p;t[0]===s?p=t[1]:(p=e=>{s?.(e)},t[0]=s,t[1]=p);let m=r(p,500),h;t[2]===m?h=t[3]:(h=e=>{m(e)},t[2]=m,t[3]=h);let g=h,_;t[4]===u?_=t[5]:(_=[{key:`Alt-z`,run:()=>(u?.(),!0)}],t[4]=u,t[5]=_);let v=_,y;return t[6]!==g||t[7]!==n||t[8]!==d||t[9]!==v||t[10]!==f?(y=(0,o.jsx)(`div`,{className:`h-full min-w-0 overflow-hidden`,children:(0,o.jsx)(i,{initialContent:n,onChange:g,isDark:d,lineWrap:f,keyBindings:v})}),t[6]=g,t[7]=n,t[8]=d,t[9]=v,t[10]=f,t[11]=y):y=t[11],y}export{s as MarkdownSplit};
|
package/dist/gateway/static/root/assets/{media-plugins-D9NNNUgE.js → media-plugins-BABfIZPU.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./messages-CzKxM6I4.js";import{Da as i}from"./index-
|
|
1
|
+
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./messages-CzKxM6I4.js";import{Da as i}from"./index-VWvztcst.js";import{t as a}from"./preview-open-alternatives-BJbwi7Rc.js";import{t as o}from"./use-blob-object-url-D4BFuzZB.js";var s=t();e();var c=n();function l(e){let t=(0,s.c)(2),n;return t[0]===e?n=t[1]:(n=(0,c.jsx)(d,{props:e,kind:`audio`}),t[0]=e,t[1]=n),n}function u(e){let t=(0,s.c)(2),n;return t[0]===e?n=t[1]:(n=(0,c.jsx)(d,{props:e,kind:`video`}),t[0]=e,t[1]=n),n}function d(e){let t=(0,s.c)(8),{props:n,kind:r}=e,a;bb0:{if(!n.binaryBuffer){a=null;break bb0}let e;if(t[0]!==r||t[1]!==n.binaryBuffer||t[2]!==n.descriptor.fileName||t[3]!==n.descriptor.mimeType){let a=i(n.descriptor.fileName)??n.descriptor.mimeType;e=new Blob([n.binaryBuffer],{type:a||`${r}/*`}),t[0]=r,t[1]=n.binaryBuffer,t[2]=n.descriptor.fileName,t[3]=n.descriptor.mimeType,t[4]=e}else e=t[4];a=e}let l=o(a);if(!l)return null;let u;return t[5]!==r||t[6]!==l?(u=(0,c.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto bg-surface-base p-4 dark:bg-surface-hover/20`,children:r===`audio`?(0,c.jsx)(`audio`,{src:l,controls:!0,className:`w-full max-w-2xl`}):(0,c.jsx)(`video`,{src:l,controls:!0,playsInline:!0,className:`max-h-full max-w-full rounded-md bg-black`})}),t[5]=r,t[6]=l,t[7]=u):u=t[7],u}function f(e){let t=(0,s.c)(12),n;t[0]===e.language?n=t[1]:(n=r(e.language),t[0]=e.language,t[1]=n);let i=n,o=e.descriptor.context===`workspace`,l=o?`${i.workspace.cannotPreviewType} ${i.workspace.openElsewhereHint}`:i.chat.attachmentPreviewOpenElsewhereHint,u=o?i.workspace.openSystemApp:void 0,d=o?i.workspace.chooseApp:void 0,f;return t[2]!==i.chat.attachmentPreviewDownloadFull||t[3]!==e.actions.canChooseOpenWithApp||t[4]!==e.actions.canOpenWithSystemApp||t[5]!==e.actions.onChooseOpenWithApp||t[6]!==e.actions.onDownload||t[7]!==e.actions.onOpenWithSystemApp||t[8]!==l||t[9]!==u||t[10]!==d?(f=(0,c.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:(0,c.jsx)(a,{message:l,downloadLabel:i.chat.attachmentPreviewDownloadFull,onDownload:e.actions.onDownload,openSystemLabel:u,onOpenWithSystemApp:e.actions.onOpenWithSystemApp,canOpenWithSystemApp:e.actions.canOpenWithSystemApp,chooseAppLabel:d,onChooseOpenWithApp:e.actions.onChooseOpenWithApp,canChooseOpenWithApp:e.actions.canChooseOpenWithApp})}),t[2]=i.chat.attachmentPreviewDownloadFull,t[3]=e.actions.canChooseOpenWithApp,t[4]=e.actions.canOpenWithSystemApp,t[5]=e.actions.onChooseOpenWithApp,t[6]=e.actions.onDownload,t[7]=e.actions.onOpenWithSystemApp,t[8]=l,t[9]=u,t[10]=d,t[11]=f):f=t[11],f}export{l as AudioPreviewPluginView,f as UnsupportedPreviewPluginView,u as VideoPreviewPluginView};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,t as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./messages-CzKxM6I4.js";import{a as c,n as l,o as u,t as d}from"./fetch-8QNN25Sh.js";import{n as f}from"./locale-store-Ba72bFmP.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{An as m,Ao as h,Co as g,Dn as _,Ds as v,Dt as y,En as b,Es as x,Et as S,Fl as C,Ft as w,Ho as T,Hs as E,Ia as D,It as O,Js as k,Lo as A,Lt as j,Ma as M,Mn as N,Na as P,No as F,On as I,Ot as L,Pt as R,Rc as z,Ro as B,Rt as V,Sl as ee,Sn as te,So as H,T as ne,Tn as U,Uo as W,Us as G,Vo as re,Wo as K,Ws as ie,Xc as ae,Zo as oe,_n as se,_o as ce,ac as le,ao as ue,as as de,bl as fe,bn as pe,bo as q,cn as me,co as he,dc as ge,dn as _e,dr as ve,fn as ye,gn as be,gs as xe,hn as Se,io as Ce,ja as we,jn as Te,jo as Ee,kc as De,kn as Oe,ks as ke,lc as Ae,ln as je,lo as Me,mn as Ne,pn as Pe,po as Fe,qo as Ie,sn as Le,so as Re,un as ze,uo as Be,vn as Ve,vo as J,vr as He,wn as Ue,xn as We,yn as Ge}from"./index-BKRqeRHm.js";import{n as Ke,t as qe}from"./settings-page-layout-CyGlrInB.js";import{r as Je}from"./settings-loading-skeleton-BV6KFNj4.js";import{a as Ye,c as Xe,d as Ze,f as Qe,l as $e,n as et,o as tt,r as nt,s as rt,t as it,u as at}from"./voice-api-key-field-LoT3wgZ9.js";import{t as ot}from"./settings-advanced-gate-DdFyaRMm.js";import{t as st}from"./settings-collapsible-section-BTKTdTNX.js";import{n as ct,t as lt}from"./settings-form-section-DL4P0sAj.js";import{t as ut}from"./page-tabs-D4hkWVt_.js";import{n as dt,t as ft}from"./save-bar-controls-B0b42kB2.js";var Y=n(),X=e(t(),1),Z=r(),pt=()=>u(Qe),mt=e=>{let t=e?.trim();return u(t?`/api/image/capabilities?agentId=${encodeURIComponent(t)}`:`/api/image/capabilities`)},ht=()=>u(`/api/global-defaults`),gt=()=>`image-models-agents`,_t={imageModel:``,imageModelFallbacks:[],imageGenerationModel:``,imageGenerationModelFallbacks:[],imageGenerationModelTimeoutMs:``,imageGenerationModelAutoProviderFallback:!1};async function vt(e){let t=await l(e);if(!t.payload)throw Error(`Invalid image capabilities response`);return t.payload}function yt(e){return{imageModel:e?.imageModel?.primary??``,imageModelFallbacks:e?.imageModel?.fallbacks??[],imageGenerationModel:e?.imageGenerationModel?.primary??``,imageGenerationModelFallbacks:e?.imageGenerationModel?.fallbacks??[],imageGenerationModelTimeoutMs:e?.imageGenerationModel?.timeoutMs?String(e.imageGenerationModel.timeoutMs):``,imageGenerationModelAutoProviderFallback:e?.imageGenerationModel?.autoProviderFallback===!0}}function bt(e){return e.map(e=>e.trim()).filter(Boolean)}function xt(e,t){let n={...e,roles:{...e.roles}},r=t.imageModel.trim();if(r){let e=bt(t.imageModelFallbacks);n.imageModel={primary:r,...e.length>0?{fallbacks:e}:{}}}else delete n.imageModel;let i=t.imageGenerationModel.trim();if(i){let e=bt(t.imageGenerationModelFallbacks),r=t.imageGenerationModelTimeoutMs.trim(),a=r?Number(r):void 0;n.imageGenerationModel={primary:i,...e.length>0?{fallbacks:e}:{},...Number.isFinite(a)&&a&&a>0?{timeoutMs:Math.floor(a)}:{},...t.imageGenerationModelAutoProviderFallback?{autoProviderFallback:!0}:{}}}else delete n.imageGenerationModel;return n}function St(e){return e.filter(e=>e.configured).flatMap(e=>e.models.map(t=>({value:t.ref,label:`${t.name||t.id} · ${t.ref}`,configured:e.configured}))).sort((e,t)=>Number(t.configured)-Number(e.configured)||e.value.localeCompare(t.value))}function Ct(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,n),e)}function wt(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}var Tt={saving:!1,savedFlash:!1,error:void 0};function Et(e){let t=(0,Y.c)(40),{current:n,agentId:r,agentOptions:i,t:a,onAgentIdChange:o}=e,s=n?.effectiveImageModel??null,c=n?.imageModelSource??`none`,l=n?.imageModelRoleId??n?.imageModelRoleDescription??``,u;t[0]!==l||t[1]!==c||t[2]!==a.runtimeUnderstandingAutoProvider||t[3]!==a.runtimeUnderstandingAutoRole||t[4]!==a.runtimeUnderstandingExplicit||t[5]!==a.runtimeUnderstandingNone?(u=c===`explicit`?a.runtimeUnderstandingExplicit:c===`auto-role`?Ct(a.runtimeUnderstandingAutoRole,{role:l||`unknown`}):c===`auto-provider`?a.runtimeUnderstandingAutoProvider:a.runtimeUnderstandingNone,t[0]=l,t[1]=c,t[2]=a.runtimeUnderstandingAutoProvider,t[3]=a.runtimeUnderstandingAutoRole,t[4]=a.runtimeUnderstandingExplicit,t[5]=a.runtimeUnderstandingNone,t[6]=u):u=t[6];let d=u,f;t[7]!==n||t[8]!==a.runtimeUnderstandingFallbacks||t[9]!==a.runtimeUnderstandingNoFallbacks?(f=n?.effectiveImageModelFallbacks?.length?Ct(a.runtimeUnderstandingFallbacks,{models:n.effectiveImageModelFallbacks.join(`, `)}):a.runtimeUnderstandingNoFallbacks,t[7]=n,t[8]=a.runtimeUnderstandingFallbacks,t[9]=a.runtimeUnderstandingNoFallbacks,t[10]=f):f=t[10];let p=f,m;t[11]===a.runtimeUnderstandingTitle?m=t[12]:(m=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.runtimeUnderstandingTitle}),t[11]=a.runtimeUnderstandingTitle,t[12]=m);let h;t[13]===d?h=t[14]:(h=(0,Z.jsx)(`p`,{className:`mt-1 max-w-[72ch] text-xs leading-relaxed text-fg-muted`,children:d}),t[13]=d,t[14]=h);let g;t[15]!==m||t[16]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[15]=m,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==r||t[19]!==i||t[20]!==o||t[21]!==a.runtimeAgentLabel?(_=i.length>0?(0,Z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs font-medium text-fg-muted sm:w-56`,children:[a.runtimeAgentLabel,(0,Z.jsx)(ce,{value:r,options:i,placeholder:a.runtimeAgentLabel,allowEmpty:!1,triggerClassName:`bg-surface-panel`,onChange:o})]}):null,t[18]=r,t[19]=i,t[20]=o,t[21]=a.runtimeAgentLabel,t[22]=_):_=t[22];let v;t[23]!==g||t[24]!==_?(v=(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[g,_]}),t[23]=g,t[24]=_,t[25]=v):v=t[25];let y=s??a.noModelSelected,b;t[26]===y?b=t[27]:(b=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:y}),t[26]=y,t[27]=b);let x;t[28]===p?x=t[29]:(x=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:p}),t[28]=p,t[29]=x);let S;t[30]!==x||t[31]!==b?(S=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-subtle px-3 py-2 shadow-surface`,children:[b,x]}),t[30]=x,t[31]=b,t[32]=S):S=t[32];let C;t[33]!==i.length||t[34]!==a.runtimeAgentHint?(C=i.length>0?(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:a.runtimeAgentHint}):null,t[33]=i.length,t[34]=a.runtimeAgentHint,t[35]=C):C=t[35];let w;return t[36]!==S||t[37]!==C||t[38]!==v?(w=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-4`,children:[v,S,C]}),t[36]=S,t[37]=C,t[38]=v,t[39]=w):w=t[39],w}function Dt(e){let t=(0,Y.c)(63),{title:n,description:r,primaryLabel:i,fallbackLabel:a,fallbackPlaceholder:o,value:s,fallbackValues:c,options:l,emptyLabel:u,onValueChange:d,onFallbackValuesChange:f}=e,p;t[0]!==c||t[1]!==s?(p=new Set([s,...c].filter(Boolean)),t[0]=c,t[1]=s,t[2]=p):p=t[2];let m=p,h;t[3]!==l||t[4]!==m||t[5]!==s?(h=s?l.find(e=>!m.has(e.value))?.value??``:``,t[3]=l,t[4]=m,t[5]=s,t[6]=h):h=t[6];let g=h,_;t[7]!==c||t[8]!==g||t[9]!==f?(_=()=>{g&&f([...c,g])},t[7]=c,t[8]=g,t[9]=f,t[10]=_):_=t[10];let v=_,y;t[11]!==c||t[12]!==f?(y=(e,t)=>{let n=[...c];n[e]=t,f(n)},t[11]=c,t[12]=f,t[13]=y):y=t[13];let b=y,x;t[14]!==c||t[15]!==f?(x=e=>{f(c.filter((t,n)=>n!==e))},t[14]=c,t[15]=f,t[16]=x):x=t[16];let S=x,C;t[17]===n?C=t[18]:(C=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[17]=n,t[18]=C);let w;t[19]===r?w=t[20]:(w=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[19]=r,t[20]=w);let T;t[21]!==C||t[22]!==w?(T=(0,Z.jsxs)(`div`,{className:`mb-3`,children:[C,w]}),t[21]=C,t[22]=w,t[23]=T):T=t[23];let D;t[24]===c?D=t[25]:(D=new Set(c),t[24]=c,t[25]=D);let O;t[26]!==u||t[27]!==d||t[28]!==l||t[29]!==D||t[30]!==s?(O=(0,Z.jsx)(ce,{value:s,options:l,placeholder:u,emptyLabel:u,disabledValues:D,onChange:d}),t[26]=u,t[27]=d,t[28]=l,t[29]=D,t[30]=s,t[31]=O):O=t[31];let k;t[32]!==i||t[33]!==O?(k=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[i,O]}),t[32]=i,t[33]=O,t[34]=k):k=t[34];let A;t[35]===a?A=t[36]:(A=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:a}),t[35]=a,t[36]=A);let j;t[37]!==u||t[38]!==a||t[39]!==o||t[40]!==c||t[41]!==l||t[42]!==S||t[43]!==m||t[44]!==b?(j=c.length===0?(0,Z.jsx)(`div`,{className:`flex min-h-10 items-center rounded-lg bg-surface-subtle px-3 text-sm font-normal text-fg-subtle shadow-surface`,children:o}):c.map((e,t)=>(0,Z.jsxs)(`div`,{className:`grid h-10 grid-cols-[minmax(0,1fr)_2.5rem] gap-2`,children:[(0,Z.jsx)(ce,{value:e,options:l,placeholder:u,emptyLabel:u,allowEmpty:!1,disabledValues:m,onChange:e=>b(t,e)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>S(t),className:`box-border inline-flex size-10 shrink-0 items-center justify-center rounded-lg border border-edge bg-surface-subtle text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:border-edge-strong`,"aria-label":a,children:(0,Z.jsx)(de,{className:`size-4`,"aria-hidden":`true`})})]},`${t}:${e}`)),t[37]=u,t[38]=a,t[39]=o,t[40]=c,t[41]=l,t[42]=S,t[43]=m,t[44]=b,t[45]=j):j=t[45];let M=!g,N;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(E,{className:`size-4`,"aria-hidden":`true`}),t[46]=N):N=t[46];let P;t[47]!==v||t[48]!==a||t[49]!==M?(P=(0,Z.jsxs)(`button`,{type:`button`,onClick:v,disabled:M,className:`box-border inline-flex h-9 w-fit min-w-[7.5rem] items-center justify-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:border-edge-strong`,children:[N,a]}),t[47]=v,t[48]=a,t[49]=M,t[50]=P):P=t[50];let F;t[51]!==j||t[52]!==P?(F=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[j,P]}),t[51]=j,t[52]=P,t[53]=F):F=t[53];let I;t[54]!==A||t[55]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[A,F]}),t[54]=A,t[55]=F,t[56]=I):I=t[56];let L;t[57]!==k||t[58]!==I?(L=(0,Z.jsxs)(`div`,{className:`grid gap-3`,children:[k,I]}),t[57]=k,t[58]=I,t[59]=L):L=t[59];let R;return t[60]!==L||t[61]!==T?(R=(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[T,L]}),t[60]=L,t[61]=T,t[62]=R):R=t[62],R}function Ot(){let e=(0,Y.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Array.from({length:2}).map(kt),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(P,{className:`h-4 w-36`}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[t,(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[n,(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2`,children:[(0,Z.jsx)(P,{className:`h-10 rounded-lg`}),(0,Z.jsx)(P,{className:`h-16 rounded-lg`})]})]})]}),e[2]=r):r=e[2],r}function kt(e,t){return(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,Z.jsx)(P,{className:`h-4 w-40`}),(0,Z.jsx)(P,{className:`mt-2 h-3 w-72 max-w-full`}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3`,children:[(0,Z.jsx)(P,{className:`h-10 rounded-lg`}),(0,Z.jsx)(P,{className:`h-10 rounded-lg`}),(0,Z.jsx)(P,{className:`h-9 w-36 rounded-lg`})]})]},t)}function At(){let e=f(e=>e.language),t=s(e),n=t.imageModelsSettings,r=!!c(e=>e.token),[i,a]=(0,X.useReducer)(L,Tt),{saving:o,error:l}=i,u=D(),d=(0,X.useMemo)(()=>new Set(u.map(e=>e.id)),[u]),{data:m=[],isLoading:h}=p(r?pt():null,Ze,{revalidateOnFocus:!1}),{data:g,isLoading:_}=p(r?gt():null,He,{revalidateOnFocus:!1}),[y,b]=(0,X.useState)(``);(0,X.useEffect)(()=>{g&&b(e=>e&&g.agents.some(t=>t.id===e)?e:g.defaultId||g.agents[0]?.id||``)},[g]);let{data:x,isLoading:S,mutate:C}=p(r?mt(y):null,vt,{revalidateOnFocus:!1}),{data:w,isLoading:T,mutate:E}=p(r?ht():null,j,{revalidateOnFocus:!1}),O=m.some(e=>e.configured),k=$e(m),[A,M]=(0,X.useState)(_t),[N,P]=(0,X.useState)(_t);(0,X.useEffect)(()=>{if(!w?.models)return;let e=yt(w.models);M(e),P(e)},[w?.models]);let F=JSON.stringify(A)!==JSON.stringify(N),I=k.credDirty||F;(0,X.useEffect)(()=>{if(!I)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[I]),dt({id:`image-models`,dirty:I,saving:o,save:(0,X.useCallback)(async()=>{a({type:`patch`,patch:{saving:!0,error:void 0}});try{if(F){if(!w?.models)throw Error(n.loadError);let e=await V(xt(w.models,A));await E(e,!1),await C();let t=yt(e.models);M(t),P(t)}k.credDirty&&(await k.saveCredentials(n.credentialsSaveError),await C()),a({type:`patch`,patch:{savedFlash:!0}})}catch(e){a({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{saving:!1}})}},[k,w?.models,F,A,E,C,n.credentialsSaveError,n.loadError,n.saved]),discard:(0,X.useCallback)(()=>{k.credDirty&&k.onDiscardCredentials(),F&&M(N),a({type:`patch`,patch:{error:void 0,savedFlash:!1}})},[k,N,F])});let R=(0,X.useMemo)(()=>wt(n),[n]),z=(0,X.useMemo)(()=>St(x?.imageUnderstanding.providers??[]),[x?.imageUnderstanding.providers]),B=(0,X.useMemo)(()=>St(x?.imageGeneration.providers??[]),[x?.imageGeneration.providers]),ee=(0,X.useMemo)(()=>({getApiKey:t.providersSettings.getApiKey,getApiKeyIntl:t.providersSettings.getApiKeyIntl,getApiKeyCn:t.providersSettings.getApiKeyCn}),[t.providersSettings]),te=(0,X.useMemo)(()=>(g?.agents??[]).map(e=>({value:e.id,label:ve(e,t.agentsSettings)})),[g?.agents,t.agentsSettings]);return r?h||S||T||_?(0,Z.jsx)(Ot,{}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[l?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:l}):null,(0,Z.jsx)(Et,{current:x?.current,agentId:y,agentOptions:te,t:n,onAgentIdChange:b}),(0,Z.jsx)(Dt,{title:n.understandingTitle,description:n.understandingDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:A.imageModel,fallbackValues:A.imageModelFallbacks,options:z,emptyLabel:n.noModelSelected,onValueChange:e=>M(t=>({...t,imageModel:e,imageModelFallbacks:e?t.imageModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>M(t=>({...t,imageModelFallbacks:e}))}),(0,Z.jsx)(Dt,{title:n.generationTitle,description:n.generationDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:A.imageGenerationModel,fallbackValues:A.imageGenerationModelFallbacks,options:B,emptyLabel:n.noModelSelected,onValueChange:e=>M(t=>({...t,imageGenerationModel:e,imageGenerationModelFallbacks:e?t.imageGenerationModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>M(t=>({...t,imageGenerationModelFallbacks:e}))}),(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.runtimeTuningTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.runtimeTuningHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,220px)_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[n.timeoutLabel,(0,Z.jsx)(`input`,{type:`number`,min:1,value:A.imageGenerationModelTimeoutMs,onChange:e=>M(t=>({...t,imageGenerationModelTimeoutMs:e.target.value})),placeholder:`120000`,className:`h-10 rounded-lg border border-edge bg-surface-subtle px-3 text-sm font-normal text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),(0,Z.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:A.imageGenerationModelAutoProviderFallback,onChange:e=>M(t=>({...t,imageGenerationModelAutoProviderFallback:e.target.checked})),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:n.autoFallbackLabel}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-fg-muted`,children:n.autoFallbackHint})]})]})]})]}),(0,Z.jsx)(st,{icon:v,showLabel:n.providersTitle,hideLabel:n.providersTitle,defaultOpen:O,children:m.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.providersEmpty}):(0,Z.jsx)(at,{summaries:m,credDraft:k.credDraft,credBaseline:k.credBaseline,credDirty:k.credDirty,credSaving:k.credSaving,credError:k.credError,credSavedFlash:k.credSavedFlash,credNoopFlash:k.credNoopFlash,updateCredRow:k.updateCredRow,onDiscardCredentials:k.onDiscardCredentials,onSaveCredentials:()=>void k.saveCredentials(n.credentialsSaveError),extensionIds:d,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:e,apiKeyLinkLabels:ee,messages:R})})]}):(0,Z.jsx)(`div`,{className:`w-full text-sm text-fg-muted`,children:e===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var jt=re;function Mt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function Nt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Pt(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,W,`dark:border-edge`)}function Q(){return o(T,re)}function Ft(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function It(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}))}var Lt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],Rt=[{id:`whisper-1`,name:`Whisper-1`}],zt=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],Bt=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],Vt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Ht=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],Ut=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],Wt=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],Gt=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],Kt=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],qt=[{id:`piper`,command:`piper --model /path/to/voice.onnx --output_file "{{OutputPath}}"`,outputFormat:`wav`},{id:`sherpa-onnx`,command:`sherpa-onnx-offline-tts --text "{{Text}}" --output-filename "{{OutputPath}}"`,outputFormat:`wav`},{id:`mlx-audio`,command:`python -m mlx_audio.tts.generate --text "{{Text}}" --file_prefix "{{OutputBase}}"`,outputFormat:`wav`}];function Jt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Yt(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function Xt(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function Zt(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;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function Qt(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function $t(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 en(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 tn(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`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function nn(){let e=s(f(e=>e.language)).voiceSettings,t=!!c(e=>e.token),[n,r]=(0,X.useReducer)(tn,{form:null,baseline:null}),i=n.form,a=n.baseline,[o,l]=(0,X.useState)(null),[d,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),_=(0,X.useRef)(!1),v=(0,X.useRef)({parsed:null,models:void 0}),{data:y,error:b,isLoading:x,mutate:S}=M(t),{data:C,error:w,isLoading:T,mutate:E}=p(t?u(`/api/voice/models`):null,et,{revalidateOnFocus:!1}),{data:D,error:O,isLoading:k}=p(t?u(`/api/voice/providers`):null,nt,{revalidateOnFocus:!1}),{data:A,error:j,isLoading:N}=p(t?u(`/api/voice/stt-providers`):null,Ye,{revalidateOnFocus:!1}),P=(0,X.useMemo)(()=>D?.providers??[],[D]),F=(0,X.useMemo)(()=>A?.providers??[],[A]),I=(0,X.useMemo)(()=>y?.payload?.config===void 0?null:tt(y.payload.config),[y]),L=(0,X.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]);t?I!==null&&C!==void 0&&!_.current&&(v.current.parsed!==I||v.current.models!==C)&&(v.current={parsed:I,models:C},r({type:`sync`,value:I}),l(C)):(v.current.parsed!==null||v.current.models!==void 0)&&(v.current={parsed:null,models:void 0},r({type:`reset`}),l(null),_.current=!1);let R=!!(t&&(I===null||C===void 0||D===void 0||A===void 0)&&(x||T||k||N)),z=b instanceof Error?b.message:b?String(b):w instanceof Error?w.message:w?String(w):O instanceof Error?O.message:O?String(O):j instanceof Error?j.message:j?String(j):null,B=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),V=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),ee=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),te=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!0,order:[`alibaba`,`openai`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),H=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),ne=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),U=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),W=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),G=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),re=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]);if(dt({id:`voice`,dirty:L,saving:d,save:(0,X.useCallback)(async()=>{if(!(!i||d)){m(!0),g(null);try{await rt(i),r({type:`saved`,value:i}),_.current=!1}catch(t){g(t instanceof Error?t.message:e.saveError)}finally{m(!1)}}},[i,d,e.saveError]),discard:(0,X.useCallback)(()=>{a&&(_.current=!1,r({type:`discard`}),g(null))},[a])}),!t)return(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.needToken})});if(R)return(0,Z.jsx)(Je,{rows:4});if(!i||o===null)return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h??z??e.loadError}),(0,Z.jsx)(K,{type:`button`,variant:`secondary`,onClick:()=>{S(),E()},children:e.retry})]});let ie=i.stt,ae=i.tts,oe=Qt(e);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(rn,{v:e,stt:ie,tts:ae}),(0,Z.jsx)(on,{v:e,apiKeyLabels:oe,stt:ie,models:o,sttProviders:F,updateStt:B,updateSttAlibaba:V,updateSttOpenai:ee,updateSttFallback:te}),(0,Z.jsx)(dn,{v:e,apiKeyLabels:oe,tts:ae,models:o,ttsProviders:P,updateTts:H,updateTtsAlibaba:ne,updateTtsOpenai:U,updateTtsEdge:W,updateTtsMinimax:G,updateTtsLocalCli:re})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,Z.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,Z.jsx)(`strong`,{className:`text-accent`,children:e.notes.title}),` `,e.notes.duration]}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:e.notes.envVars})]})]})}function rn(e){let t=(0,Y.c)(39),{v:n,stt:r,tts:i}=e,a=i.provider===`openai`?i.openai?.voice:i.provider===`alibaba`?i.alibaba?.voice:i.provider===`minimax`?i.minimax?.voice:i.provider===`edge`?i.edge?.voice:void 0,o;t[0]===n.overview.title?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=o);let s;t[2]===n.overview.description?s=t[3]:(s=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(l=r.enabled?`${n.overview.ready} · ${Jt(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=l):l=t[10];let u;t[11]!==r.enabled||t[12]!==l||t[13]!==n.overview.input?(u=(0,Z.jsx)(an,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?Xt(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=d):d=t[18];let f=i.enabled&&i.trigger!==`off`,p;t[19]!==d||t[20]!==f||t[21]!==n.overview.replies?(p=(0,Z.jsx)(an,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${Yt(i.provider,n)}${a?` · ${a}`:``}`:n.overview.off,t[23]=a,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=m):m=t[27];let h;t[28]!==m||t[29]!==i.enabled||t[30]!==n.overview.voice?(h=(0,Z.jsx)(an,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,p,h]}),t[32]=h,t[33]=u,t[34]=p,t[35]=g):g=t[35];let _;return t[36]!==g||t[37]!==c?(_=(0,Z.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[c,g]}),t[36]=g,t[37]=c,t[38]=_):_=t[38],_}function an(e){let t=(0,Y.c)(10),{label:n,value:r,ready:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=a);let s=i?`text-fg`:`text-fg-muted`,c;t[2]===s?c=t[3]:(c=o(`mt-1 text-sm font-medium`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,Z.jsx)(`div`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==a||t[8]!==l?(u=(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[a,l]}),t[7]=a,t[8]=l,t[9]=u):u=t[9],u}function on(e){let t=(0,Y.c)(46),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:s,updateStt:c,updateSttAlibaba:l,updateSttOpenai:u,updateSttFallback:d}=e,f=a?.stt?.alibaba?.length?a.stt.alibaba:Lt,p=a?.stt?.openai?.length?a.stt.openai:Rt,m;if(t[0]!==s){let e=new Set;m=[];for(let t of s)e.has(t.id)||(e.add(t.id),m.push(t));t[0]=s,t[1]=m}else m=t[1];let h=m,g,_,v,y,b;if(t[2]!==f||t[3]!==r||t[4]!==p||t[5]!==h||t[6]!==i||t[7]!==c||t[8]!==l||t[9]!==d||t[10]!==u||t[11]!==n){let e=h.find(e=>e.id===i.provider),a=i.providers?.[i.provider],s=typeof a?.apiKey==`string`?a.apiKey:``,m=typeof a?.model==`string`?a.model:``,x={...i.provider===`alibaba`?i.alibaba??{}:{},...i.provider===`openai`?i.openai??{}:{},...a??{}},S=(e?.fields??[]).filter(un),C;t[17]!==i.provider||t[18]!==i.providers||t[19]!==c?(C=e=>{c({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[17]=i.provider,t[18]=i.providers,t[19]=c,t[20]=C):C=t[20];let w=C;y=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(le,{className:`size-4 text-accent`,strokeWidth:1.75}),t[21]=T):T=t[21];let E;t[22]===n.stt.title?E=t[23]:(E=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[22]=n.stt.title,t[23]=E);let D;t[24]===n.stt.description?D=t[25]:(D=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[24]=n.stt.description,t[25]=D),t[26]!==E||t[27]!==D?(b=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[26]=E,t[27]=D,t[28]=b):b=t[28],g=`space-y-4`;let O;t[29]===c?O=t[30]:(O=e=>c({enabled:e}),t[29]=c,t[30]=O),t[31]!==i.enabled||t[32]!==O||t[33]!==n.overview.off||t[34]!==n.overview.ready||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(_=(0,Z.jsx)(fn,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:O}),t[31]=i.enabled,t[32]=O,t[33]=n.overview.off,t[34]=n.overview.ready,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=_):_=t[37],v=i.enabled?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:n.stt.provider}),(0,Z.jsx)(J,{className:Q(),value:i.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,Z.jsxs)(q,{value:e.id,children:[Jt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:n.stt.model}),i.provider===`alibaba`?(0,Z.jsx)(J,{className:Q(),value:i.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(ln)}):i.provider===`openai`?(0,Z.jsx)(J,{className:Q(),value:i.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map(cn)}):i.provider===`groq`?(0,Z.jsx)(J,{className:Q(),value:m||zt[0].id,onChange:e=>w({model:e.target.value}),children:zt.map(sn)}):(0,Z.jsx)(`input`,{className:Pt(),value:m,onChange:e=>w({model:e.target.value}),placeholder:i.provider})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:n.stt.apiKey}),(0,Z.jsx)(it,{kind:`stt`,providerId:i.provider,fieldId:`voice-stt-${i.provider}-api-key`,value:i.provider===`alibaba`?i.alibaba?.apiKey??``:i.provider===`openai`?i.openai?.apiKey??``:s,onChange:e=>{i.provider===`alibaba`?l({apiKey:e}):i.provider===`openai`?u({apiKey:e}):w({apiKey:e})},labels:r,placeholder:i.provider===`groq`?`gsk_...`:`sk-...`}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Mt(i.provider)?` ${Mt(i.provider)}`:``]})]})]}),S.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,Z.jsx)(pn,{field:e,value:$t(x,e),onChange:t=>w({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:jt},e.key))}):null,(0,Z.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,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!0,onChange:e=>d({enabled:e.target.checked})})]})]}):null,t[2]=f,t[3]=r,t[4]=p,t[5]=h,t[6]=i,t[7]=c,t[8]=l,t[9]=d,t[10]=u,t[11]=n,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b}else g=t[12],_=t[13],v=t[14],y=t[15],b=t[16];let x;t[38]!==g||t[39]!==_||t[40]!==v?(x=(0,Z.jsxs)(`div`,{className:g,children:[_,v]}),t[38]=g,t[39]=_,t[40]=v,t[41]=x):x=t[41];let S;return t[42]!==y||t[43]!==b||t[44]!==x?(S=(0,Z.jsxs)(`section`,{className:y,children:[b,x]}),t[42]=y,t[43]=b,t[44]=x,t[45]=S):S=t[45],S}function sn(e){return(0,Z.jsx)(q,{value:e.id,children:e.name},e.id)}function cn(e){return(0,Z.jsx)(q,{value:e.id,children:e.name},e.id)}function ln(e){return(0,Z.jsx)(q,{value:e.id,children:e.name},e.id)}function un(e){return e.key!==`apiKey`&&e.key!==`model`}function dn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,updateTtsAlibaba:s,updateTtsOpenai:c,updateTtsEdge:l,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:Bt,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:Vt,m=r?.tts?.alibaba?.length?r.tts.alibaba:Ht,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:Ut,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:Wt,_=r?.tts?.minimax?.length?r.tts.minimax:Gt,v=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:Kt,[y,b]=(0,X.useState)(e.tts.test.sampleText),[x,S]=(0,X.useState)({status:`idle`}),C=(0,X.useRef)(null),w=(0,X.useRef)(null),T=(0,X.useCallback)(()=>{C.current?.pause(),C.current=null,w.current&&=(URL.revokeObjectURL(w.current),null)},[]),E=(0,X.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]),D=E.find(e=>e.id===n.provider),O=n.providers?.[n.provider],k={...n.provider===`openai`?n.openai??{}:{},...n.provider===`alibaba`?n.alibaba??{}:{},...n.provider===`edge`?n.edge??{}:{},...n.provider===`minimax`?n.minimax??{}:{},...n.provider===`tts-local-cli`?n[`tts-local-cli`]??{}:{},...O??{}},A=(D?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),j=!!D?.diagnostics.requiresApiKey,M=!!D?.configured||!j,N=n.enabled?M?`ready`:`action`:`muted`,P=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,F=n.provider===`openai`?n.openai?.voice:n.provider===`alibaba`?n.alibaba?.voice:n.provider===`minimax`?n.minimax?.voice:n.provider===`edge`?n.edge?.voice:void 0;(0,X.useEffect)(()=>()=>T(),[T]);let I=(0,X.useCallback)(e=>{a({provider:e}),S({status:`idle`})},[a]),L=(0,X.useCallback)(async()=>{let t=y.trim();if(!t){S({status:`error`,message:e.tts.test.emptyText});return}T(),S({status:`loading`});try{let r=await Xe({text:t,provider:n.provider,providerConfig:k,...P?{model:P}:{},...F?{voice:F}:{}}),i=It(r.audio,r.mimeType);w.current=i;let a=new Audio(i);C.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,Ft(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>S({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>S({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),S({status:`playing`,summary:o})}catch(e){T(),S({status:`error`,message:e instanceof Error?e.message:String(e)})}},[P,F,k,T,y,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),R=(0,X.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]),z=(0,X.useCallback)((e,t)=>{let r={[e.key]:t};R(r),n.provider===`openai`&&e.key===`baseUrl`?c(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&l(r)},[n.provider,R,l,u,c]);return(0,Z.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,Z.jsxs)(`div`,{className:`mb-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(oe,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(fn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>a({enabled:e})}),(0,Z.jsxs)(`div`,{className:o(`rounded-xl border px-3 py-2.5 text-sm`,N===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:N===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,Z.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?M?`${e.tts.statusReady} ${Yt(n.provider,e)}${F?` · ${F}`:``}`:`${e.tts.statusNeedsSetup} ${Yt(n.provider,e)} · ${D?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:e.tts.trigger}),(0,Z.jsxs)(J,{className:Q(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,Z.jsx)(q,{value:`off`,children:e.tts.triggerOff}),(0,Z.jsx)(q,{value:`inbound`,children:e.tts.triggerInbound}),(0,Z.jsx)(q,{value:`tagged`,children:e.tts.triggerTagged}),(0,Z.jsx)(q,{value:`always`,children:e.tts.triggerAlways})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:e.tts.provider}),(0,Z.jsx)(J,{className:Q(),value:n.provider,onChange:e=>I(e.target.value),children:E.map(t=>(0,Z.jsx)(q,{value:t.id,children:Yt(t.id,e)},t.id))}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[D?.configured?e.tts.configured:D?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${D.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,D?.description??Zt(n.provider,e)]})]})]}),(0,Z.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!M||n.provider===`tts-local-cli`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:e.stt.apiKey}),(0,Z.jsx)(it,{kind:`tts`,providerId:n.provider,fieldId:`voice-tts-${n.provider}-api-key`,value:n.provider===`openai`?n.openai?.apiKey??``:n.provider===`alibaba`?n.alibaba?.apiKey??``:n.minimax?.apiKey??``,onChange:e=>{n.provider===`openai`?c({apiKey:e}):n.provider===`alibaba`?s({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,Nt(n.provider)?` ${Nt(n.provider)}`:``]})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:e.stt.model}),(0,Z.jsx)(J,{className:Q(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?c({model:e.target.value}):n.provider===`alibaba`?s({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:_).map(e=>(0,Z.jsx)(q,{value:e.id,children:e.name},e.id))})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(J,{className:Q(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?c({voice:e.target.value}):n.provider===`alibaba`?s({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:v).map(e=>(0,Z.jsx)(q,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(J,{className:Q(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:g.map(e=>(0,Z.jsx)(q,{value:e.id,children:e.name},e.id))}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.preset}),(0,Z.jsxs)(J,{className:Q(),value:``,onChange:e=>{let t=qt.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,Z.jsx)(q,{value:``,children:e.tts.localCli.presetPlaceholder}),qt.map(e=>(0,Z.jsx)(q,{value:e.id,children:e.id},e.id))]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.command}),(0,Z.jsx)(`input`,{className:o(Pt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.command??``,onChange:e=>d({command:e.target.value}),placeholder:e.tts.localCli.commandPlaceholder}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)($,{children:e.tts.localCli.cwd}),(0,Z.jsx)(`input`,{className:o(Pt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.cwd??``,onChange:e=>d({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)($,{children:e.tts.localCli.outputFormat}),(0,Z.jsxs)(J,{className:Q(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,Z.jsx)(q,{value:`wav`,children:`wav`}),(0,Z.jsx)(q,{value:`mp3`,children:`mp3`}),(0,Z.jsx)(q,{value:`opus`,children:`opus`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.timeoutMs}),(0,Z.jsx)(`input`,{className:Pt(),type:`number`,min:0,step:1e3,value:typeof n[`tts-local-cli`]?.timeoutMs==`number`?String(n[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){d({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&d({timeoutMs:n})},placeholder:`30000`}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,A.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:A.map(e=>(0,Z.jsx)(pn,{field:e,value:$t(k,e),onChange:t=>z(e,t),className:e.type===`textarea`?`sm:col-span-2`:jt},e.key))}):null]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Z.jsxs)(K,{type:`button`,variant:`primary`,onClick:()=>void L(),disabled:x.status===`loading`,className:`h-9`,children:[x.status===`loading`?(0,Z.jsx)(ge,{className:`size-4 animate-spin`}):(0,Z.jsx)(ie,{className:`size-4`}),x.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,Z.jsxs)(K,{type:`button`,variant:`secondary`,onClick:()=>{T(),S(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:x.status!==`playing`,className:`h-9`,children:[(0,Z.jsx)(xe,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,Z.jsx)(`textarea`,{className:o(Pt(),`mt-3 min-h-20 resize-y`),value:y,onChange:e=>b(e.target.value),maxLength:1e3}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,Z.jsxs)(`span`,{className:`text-fg-subtle`,children:[y.length,`/1000`]}),x.status===`playing`||x.status===`done`?(0,Z.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[x.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,x.summary]}):null,x.status===`error`?(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:x.message}):null]})]})]}):null]})]})}function fn(e){let t=(0,Y.c)(33),{checked:n,title:r,description:i,onLabel:a,offLabel:s,onChange:c}=e,l;t[0]!==n||t[1]!==c?(l=()=>c(!n),t[0]=n,t[1]=c,t[2]=l):l=t[2];let u=n?`bg-accent/10 text-fg ring-1 ring-accent/45 dark:bg-accent/15`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=o(`group flex w-full items-center justify-between gap-4 rounded-2xl px-4 py-3 text-left shadow-surface transition-colors`,W,u),t[3]=u,t[4]=d);let f=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,p;t[5]===f?p=t[6]:(p=o(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?a:s,h;t[7]!==p||t[8]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==h||t[11]!==r?(g=(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,h]}),t[10]=h,t[11]=r,t[12]=g):g=t[12];let _;t[13]===i?_=t[14]:(_=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:i}),t[13]=i,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,b;t[18]===y?b=t[19]:(b=o(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=b);let x=n?`translate-x-5`:`translate-x-0.5`,S;t[20]===x?S=t[21]:(S=o(`size-5 rounded-full bg-white shadow-surface transition-transform`,x),t[20]=x,t[21]=S);let C;t[22]===S?C=t[23]:(C=(0,Z.jsx)(`span`,{className:S}),t[22]=S,t[23]=C);let w;t[24]!==b||t[25]!==C?(w=(0,Z.jsx)(`span`,{className:b,"aria-hidden":!0,children:C}),t[24]=b,t[25]=C,t[26]=w):w=t[26];let T;return t[27]!==n||t[28]!==l||t[29]!==v||t[30]!==w||t[31]!==d?(T=(0,Z.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:l,className:d,children:[v,w]}),t[27]=n,t[28]=l,t[29]=v,t[30]=w,t[31]=d,t[32]=T):T=t[32],T}function pn(e){let t=(0,Y.c)(36),{field:n,value:r,onChange:i,className:a}=e,s=`voice-schema-field-${n.key}`,c=n.description;if(n.type===`boolean`){let e;t[0]===a?e=t[1]:(e=o(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,a),t[0]=a,t[1]=e);let s;t[2]===n.label?s=t[3]:(s=(0,Z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=s);let l;t[4]===c?l=t[5]:(l=c?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,Z.jsxs)(`span`,{children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==i?(f=e=>i(en(n,e.target.checked)),t[9]=n,t[10]=i,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:f}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==e||t[16]!==u||t[17]!==p?(m=(0,Z.jsxs)(`label`,{className:e,children:[u,p]}),t[15]=e,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}let l=typeof r==`boolean`?``:String(r),u;t[19]===a?u=t[20]:(u=o(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,Z.jsx)($,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==a||t[24]!==n||t[25]!==l||t[26]!==s||t[27]!==i?(f=n.type===`select`?(0,Z.jsx)(J,{id:s,className:Q(),value:l,required:n.required,onChange:e=>i(en(n,e.target.value)),children:(n.options??[]).map(mn)}):n.type===`textarea`?(0,Z.jsx)(`textarea`,{id:s,className:o(Pt(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>i(en(n,e.target.value))}):n.type===`password`?(0,Z.jsx)(F,{id:s,className:a,value:l,onChange:e=>i(en(n,e)),placeholder:n.placeholder,labels:h}):(0,Z.jsx)(`input`,{id:s,className:Pt(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:l,required:n.required,placeholder:n.placeholder,onChange:e=>i(en(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=l,t[26]=s,t[27]=i,t[28]=f):f=t[28];let p;t[29]===c?p=t[30]:(p=c?(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[29]=c,t[30]=p);let m;return t[31]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,Z.jsxs)(`div`,{className:u,children:[d,f,p]}),t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function mn(e){return(0,Z.jsx)(q,{value:e.id,children:e.name},e.id)}function $(e){let t=(0,Y.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function hn(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function gn(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 l(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),we()}async function _n(e){let t=await l(u(`/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 vn(e){let t=(0,Y.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.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,Z.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,Z.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 yn(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,W,`dark:border-edge`)}function bn(){return o(T,re)}var xn=[`brave`,`tavily`,`bing`,`searxng`];function Sn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var Cn=S();function wn(){let e=s(f(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!c(e=>e.token),[i,a]=(0,X.useReducer)(Cn,{form:null,baseline:null}),l=i.form,u=i.baseline,[d,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),g=(0,X.useRef)(!1),_=(0,X.useRef)(null),{data:v,error:b,isLoading:x,mutate:S}=M(r);y({enabled:r,parsed:(0,X.useMemo)(()=>v?.payload?.config===void 0?null:hn(v.payload.config),[v]),dirty:g.current,trackedParsedRef:_,dispatch:a,onResetDirty:()=>{g.current=!1}});let w=!!(r&&x&&v===void 0&&!b),T=b instanceof Error?b.message:b?String(b):null,D=(0,X.useMemo)(()=>!l||!u?!1:JSON.stringify(l)!==JSON.stringify(u),[l,u]),O=(0,X.useCallback)(e=>{g.current=!0,a({type:`patch`,patch:e})},[]);return dt({id:`search`,dirty:D,saving:d,save:(0,X.useCallback)(async()=>{if(!(!l||d)){p(!0),h(null);try{await gn(l),g.current=!1,a({type:`saved`,value:l})}catch(e){h(e instanceof Error?e.message:t.saveError)}finally{p(!1)}}},[l,d,t.saveError]),discard:(0,X.useCallback)(()=>{u&&(g.current=!1,a({type:`discard`}),h(null))},[u])}),r?w?(0,Z.jsx)(Je,{rows:3}):l?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[m?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,Z.jsxs)(lt,{children:[(0,Z.jsx)(ct,{icon:ke,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,Z.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,Z.jsx)(vn,{label:t.regionLabel,description:t.regionDesc,children:(0,Z.jsxs)(J,{className:bn(),value:l.regionMode,onChange:e=>O({regionMode:e.target.value}),children:[(0,Z.jsx)(q,{value:`auto`,children:t.regionAuto}),(0,Z.jsx)(q,{value:`cn`,children:t.regionCn}),(0,Z.jsx)(q,{value:`global`,children:t.regionGlobal})]})})})]}),(0,Z.jsx)(ot,{children:(0,Z.jsxs)(lt,{children:[(0,Z.jsx)(ct,{icon:C,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,Z.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:l.blocklistEnabled,onChange:e=>O({blocklistEnabled:e.target.checked})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),(0,Z.jsx)(vn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,Z.jsx)(`textarea`,{className:o(yn(),`min-h-[6rem] font-mono text-xs`),value:l.blocklistDomains.join(`
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,t as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./messages-CzKxM6I4.js";import{a as c,n as l,o as u,t as d}from"./fetch-8QNN25Sh.js";import{n as f}from"./locale-store-Ba72bFmP.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{An as m,Ao as h,Co as g,Dn as _,Ds as v,Dt as y,En as b,Es as x,Et as S,Fl as C,Ft as w,Ho as T,Hs as E,Ia as D,It as O,Js as k,Lo as A,Lt as j,Ma as M,Mn as N,Na as P,No as F,On as I,Ot as L,Pt as R,Rc as z,Ro as B,Rt as V,Sl as ee,Sn as te,So as H,T as ne,Tn as U,Uo as W,Us as G,Vo as re,Wo as K,Ws as ie,Xc as ae,Zo as oe,_n as se,_o as ce,ac as le,ao as ue,as as de,bl as fe,bn as pe,bo as q,cn as me,co as he,dc as ge,dn as _e,dr as ve,fn as ye,gn as be,gs as xe,hn as Se,io as Ce,ja as we,jn as Te,jo as Ee,kc as De,kn as Oe,ks as ke,lc as Ae,ln as je,lo as Me,mn as Ne,pn as Pe,po as Fe,qo as Ie,sn as Le,so as Re,un as ze,uo as Be,vn as Ve,vo as J,vr as He,wn as Ue,xn as We,yn as Ge}from"./index-VWvztcst.js";import{n as Ke,t as qe}from"./settings-page-layout-BNJbtklV.js";import{r as Je}from"./settings-loading-skeleton-b6rXULL5.js";import{a as Ye,c as Xe,d as Ze,f as Qe,l as $e,n as et,o as tt,r as nt,s as rt,t as it,u as at}from"./voice-api-key-field-DGpIUelZ.js";import{t as ot}from"./settings-advanced-gate-CI1OG4gq.js";import{t as st}from"./settings-collapsible-section-DQprvu5J.js";import{n as ct,t as lt}from"./settings-form-section-Cqq7Y98y.js";import{t as ut}from"./page-tabs-je95DZOf.js";import{n as dt,t as ft}from"./save-bar-controls-qWMQ9mod.js";var Y=n(),X=e(t(),1),Z=r(),pt=()=>u(Qe),mt=e=>{let t=e?.trim();return u(t?`/api/image/capabilities?agentId=${encodeURIComponent(t)}`:`/api/image/capabilities`)},ht=()=>u(`/api/global-defaults`),gt=()=>`image-models-agents`,_t={imageModel:``,imageModelFallbacks:[],imageGenerationModel:``,imageGenerationModelFallbacks:[],imageGenerationModelTimeoutMs:``,imageGenerationModelAutoProviderFallback:!1};async function vt(e){let t=await l(e);if(!t.payload)throw Error(`Invalid image capabilities response`);return t.payload}function yt(e){return{imageModel:e?.imageModel?.primary??``,imageModelFallbacks:e?.imageModel?.fallbacks??[],imageGenerationModel:e?.imageGenerationModel?.primary??``,imageGenerationModelFallbacks:e?.imageGenerationModel?.fallbacks??[],imageGenerationModelTimeoutMs:e?.imageGenerationModel?.timeoutMs?String(e.imageGenerationModel.timeoutMs):``,imageGenerationModelAutoProviderFallback:e?.imageGenerationModel?.autoProviderFallback===!0}}function bt(e){return e.map(e=>e.trim()).filter(Boolean)}function xt(e,t){let n={...e,roles:{...e.roles}},r=t.imageModel.trim();if(r){let e=bt(t.imageModelFallbacks);n.imageModel={primary:r,...e.length>0?{fallbacks:e}:{}}}else delete n.imageModel;let i=t.imageGenerationModel.trim();if(i){let e=bt(t.imageGenerationModelFallbacks),r=t.imageGenerationModelTimeoutMs.trim(),a=r?Number(r):void 0;n.imageGenerationModel={primary:i,...e.length>0?{fallbacks:e}:{},...Number.isFinite(a)&&a&&a>0?{timeoutMs:Math.floor(a)}:{},...t.imageGenerationModelAutoProviderFallback?{autoProviderFallback:!0}:{}}}else delete n.imageGenerationModel;return n}function St(e){return e.filter(e=>e.configured).flatMap(e=>e.models.map(t=>({value:t.ref,label:`${t.name||t.id} · ${t.ref}`,configured:e.configured}))).sort((e,t)=>Number(t.configured)-Number(e.configured)||e.value.localeCompare(t.value))}function Ct(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,n),e)}function wt(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}var Tt={saving:!1,savedFlash:!1,error:void 0};function Et(e){let t=(0,Y.c)(40),{current:n,agentId:r,agentOptions:i,t:a,onAgentIdChange:o}=e,s=n?.effectiveImageModel??null,c=n?.imageModelSource??`none`,l=n?.imageModelRoleId??n?.imageModelRoleDescription??``,u;t[0]!==l||t[1]!==c||t[2]!==a.runtimeUnderstandingAutoProvider||t[3]!==a.runtimeUnderstandingAutoRole||t[4]!==a.runtimeUnderstandingExplicit||t[5]!==a.runtimeUnderstandingNone?(u=c===`explicit`?a.runtimeUnderstandingExplicit:c===`auto-role`?Ct(a.runtimeUnderstandingAutoRole,{role:l||`unknown`}):c===`auto-provider`?a.runtimeUnderstandingAutoProvider:a.runtimeUnderstandingNone,t[0]=l,t[1]=c,t[2]=a.runtimeUnderstandingAutoProvider,t[3]=a.runtimeUnderstandingAutoRole,t[4]=a.runtimeUnderstandingExplicit,t[5]=a.runtimeUnderstandingNone,t[6]=u):u=t[6];let d=u,f;t[7]!==n||t[8]!==a.runtimeUnderstandingFallbacks||t[9]!==a.runtimeUnderstandingNoFallbacks?(f=n?.effectiveImageModelFallbacks?.length?Ct(a.runtimeUnderstandingFallbacks,{models:n.effectiveImageModelFallbacks.join(`, `)}):a.runtimeUnderstandingNoFallbacks,t[7]=n,t[8]=a.runtimeUnderstandingFallbacks,t[9]=a.runtimeUnderstandingNoFallbacks,t[10]=f):f=t[10];let p=f,m;t[11]===a.runtimeUnderstandingTitle?m=t[12]:(m=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.runtimeUnderstandingTitle}),t[11]=a.runtimeUnderstandingTitle,t[12]=m);let h;t[13]===d?h=t[14]:(h=(0,Z.jsx)(`p`,{className:`mt-1 max-w-[72ch] text-xs leading-relaxed text-fg-muted`,children:d}),t[13]=d,t[14]=h);let g;t[15]!==m||t[16]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[15]=m,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==r||t[19]!==i||t[20]!==o||t[21]!==a.runtimeAgentLabel?(_=i.length>0?(0,Z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs font-medium text-fg-muted sm:w-56`,children:[a.runtimeAgentLabel,(0,Z.jsx)(ce,{value:r,options:i,placeholder:a.runtimeAgentLabel,allowEmpty:!1,triggerClassName:`bg-surface-panel`,onChange:o})]}):null,t[18]=r,t[19]=i,t[20]=o,t[21]=a.runtimeAgentLabel,t[22]=_):_=t[22];let v;t[23]!==g||t[24]!==_?(v=(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[g,_]}),t[23]=g,t[24]=_,t[25]=v):v=t[25];let y=s??a.noModelSelected,b;t[26]===y?b=t[27]:(b=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:y}),t[26]=y,t[27]=b);let x;t[28]===p?x=t[29]:(x=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:p}),t[28]=p,t[29]=x);let S;t[30]!==x||t[31]!==b?(S=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-subtle px-3 py-2 shadow-surface`,children:[b,x]}),t[30]=x,t[31]=b,t[32]=S):S=t[32];let C;t[33]!==i.length||t[34]!==a.runtimeAgentHint?(C=i.length>0?(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:a.runtimeAgentHint}):null,t[33]=i.length,t[34]=a.runtimeAgentHint,t[35]=C):C=t[35];let w;return t[36]!==S||t[37]!==C||t[38]!==v?(w=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-4`,children:[v,S,C]}),t[36]=S,t[37]=C,t[38]=v,t[39]=w):w=t[39],w}function Dt(e){let t=(0,Y.c)(63),{title:n,description:r,primaryLabel:i,fallbackLabel:a,fallbackPlaceholder:o,value:s,fallbackValues:c,options:l,emptyLabel:u,onValueChange:d,onFallbackValuesChange:f}=e,p;t[0]!==c||t[1]!==s?(p=new Set([s,...c].filter(Boolean)),t[0]=c,t[1]=s,t[2]=p):p=t[2];let m=p,h;t[3]!==l||t[4]!==m||t[5]!==s?(h=s?l.find(e=>!m.has(e.value))?.value??``:``,t[3]=l,t[4]=m,t[5]=s,t[6]=h):h=t[6];let g=h,_;t[7]!==c||t[8]!==g||t[9]!==f?(_=()=>{g&&f([...c,g])},t[7]=c,t[8]=g,t[9]=f,t[10]=_):_=t[10];let v=_,y;t[11]!==c||t[12]!==f?(y=(e,t)=>{let n=[...c];n[e]=t,f(n)},t[11]=c,t[12]=f,t[13]=y):y=t[13];let b=y,x;t[14]!==c||t[15]!==f?(x=e=>{f(c.filter((t,n)=>n!==e))},t[14]=c,t[15]=f,t[16]=x):x=t[16];let S=x,C;t[17]===n?C=t[18]:(C=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[17]=n,t[18]=C);let w;t[19]===r?w=t[20]:(w=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[19]=r,t[20]=w);let T;t[21]!==C||t[22]!==w?(T=(0,Z.jsxs)(`div`,{className:`mb-3`,children:[C,w]}),t[21]=C,t[22]=w,t[23]=T):T=t[23];let D;t[24]===c?D=t[25]:(D=new Set(c),t[24]=c,t[25]=D);let O;t[26]!==u||t[27]!==d||t[28]!==l||t[29]!==D||t[30]!==s?(O=(0,Z.jsx)(ce,{value:s,options:l,placeholder:u,emptyLabel:u,disabledValues:D,onChange:d}),t[26]=u,t[27]=d,t[28]=l,t[29]=D,t[30]=s,t[31]=O):O=t[31];let k;t[32]!==i||t[33]!==O?(k=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[i,O]}),t[32]=i,t[33]=O,t[34]=k):k=t[34];let A;t[35]===a?A=t[36]:(A=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:a}),t[35]=a,t[36]=A);let j;t[37]!==u||t[38]!==a||t[39]!==o||t[40]!==c||t[41]!==l||t[42]!==S||t[43]!==m||t[44]!==b?(j=c.length===0?(0,Z.jsx)(`div`,{className:`flex min-h-10 items-center rounded-lg bg-surface-subtle px-3 text-sm font-normal text-fg-subtle shadow-surface`,children:o}):c.map((e,t)=>(0,Z.jsxs)(`div`,{className:`grid h-10 grid-cols-[minmax(0,1fr)_2.5rem] gap-2`,children:[(0,Z.jsx)(ce,{value:e,options:l,placeholder:u,emptyLabel:u,allowEmpty:!1,disabledValues:m,onChange:e=>b(t,e)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>S(t),className:`box-border inline-flex size-10 shrink-0 items-center justify-center rounded-lg border border-edge bg-surface-subtle text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:border-edge-strong`,"aria-label":a,children:(0,Z.jsx)(de,{className:`size-4`,"aria-hidden":`true`})})]},`${t}:${e}`)),t[37]=u,t[38]=a,t[39]=o,t[40]=c,t[41]=l,t[42]=S,t[43]=m,t[44]=b,t[45]=j):j=t[45];let M=!g,N;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(E,{className:`size-4`,"aria-hidden":`true`}),t[46]=N):N=t[46];let P;t[47]!==v||t[48]!==a||t[49]!==M?(P=(0,Z.jsxs)(`button`,{type:`button`,onClick:v,disabled:M,className:`box-border inline-flex h-9 w-fit min-w-[7.5rem] items-center justify-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:border-edge-strong`,children:[N,a]}),t[47]=v,t[48]=a,t[49]=M,t[50]=P):P=t[50];let F;t[51]!==j||t[52]!==P?(F=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[j,P]}),t[51]=j,t[52]=P,t[53]=F):F=t[53];let I;t[54]!==A||t[55]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[A,F]}),t[54]=A,t[55]=F,t[56]=I):I=t[56];let L;t[57]!==k||t[58]!==I?(L=(0,Z.jsxs)(`div`,{className:`grid gap-3`,children:[k,I]}),t[57]=k,t[58]=I,t[59]=L):L=t[59];let R;return t[60]!==L||t[61]!==T?(R=(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[T,L]}),t[60]=L,t[61]=T,t[62]=R):R=t[62],R}function Ot(){let e=(0,Y.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Array.from({length:2}).map(kt),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(P,{className:`h-4 w-36`}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[t,(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[n,(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2`,children:[(0,Z.jsx)(P,{className:`h-10 rounded-lg`}),(0,Z.jsx)(P,{className:`h-16 rounded-lg`})]})]})]}),e[2]=r):r=e[2],r}function kt(e,t){return(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,Z.jsx)(P,{className:`h-4 w-40`}),(0,Z.jsx)(P,{className:`mt-2 h-3 w-72 max-w-full`}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3`,children:[(0,Z.jsx)(P,{className:`h-10 rounded-lg`}),(0,Z.jsx)(P,{className:`h-10 rounded-lg`}),(0,Z.jsx)(P,{className:`h-9 w-36 rounded-lg`})]})]},t)}function At(){let e=f(e=>e.language),t=s(e),n=t.imageModelsSettings,r=!!c(e=>e.token),[i,a]=(0,X.useReducer)(L,Tt),{saving:o,error:l}=i,u=D(),d=(0,X.useMemo)(()=>new Set(u.map(e=>e.id)),[u]),{data:m=[],isLoading:h}=p(r?pt():null,Ze,{revalidateOnFocus:!1}),{data:g,isLoading:_}=p(r?gt():null,He,{revalidateOnFocus:!1}),[y,b]=(0,X.useState)(``);(0,X.useEffect)(()=>{g&&b(e=>e&&g.agents.some(t=>t.id===e)?e:g.defaultId||g.agents[0]?.id||``)},[g]);let{data:x,isLoading:S,mutate:C}=p(r?mt(y):null,vt,{revalidateOnFocus:!1}),{data:w,isLoading:T,mutate:E}=p(r?ht():null,j,{revalidateOnFocus:!1}),O=m.some(e=>e.configured),k=$e(m),[A,M]=(0,X.useState)(_t),[N,P]=(0,X.useState)(_t);(0,X.useEffect)(()=>{if(!w?.models)return;let e=yt(w.models);M(e),P(e)},[w?.models]);let F=JSON.stringify(A)!==JSON.stringify(N),I=k.credDirty||F;(0,X.useEffect)(()=>{if(!I)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[I]),dt({id:`image-models`,dirty:I,saving:o,save:(0,X.useCallback)(async()=>{a({type:`patch`,patch:{saving:!0,error:void 0}});try{if(F){if(!w?.models)throw Error(n.loadError);let e=await V(xt(w.models,A));await E(e,!1),await C();let t=yt(e.models);M(t),P(t)}k.credDirty&&(await k.saveCredentials(n.credentialsSaveError),await C()),a({type:`patch`,patch:{savedFlash:!0}})}catch(e){a({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{saving:!1}})}},[k,w?.models,F,A,E,C,n.credentialsSaveError,n.loadError,n.saved]),discard:(0,X.useCallback)(()=>{k.credDirty&&k.onDiscardCredentials(),F&&M(N),a({type:`patch`,patch:{error:void 0,savedFlash:!1}})},[k,N,F])});let R=(0,X.useMemo)(()=>wt(n),[n]),z=(0,X.useMemo)(()=>St(x?.imageUnderstanding.providers??[]),[x?.imageUnderstanding.providers]),B=(0,X.useMemo)(()=>St(x?.imageGeneration.providers??[]),[x?.imageGeneration.providers]),ee=(0,X.useMemo)(()=>({getApiKey:t.providersSettings.getApiKey,getApiKeyIntl:t.providersSettings.getApiKeyIntl,getApiKeyCn:t.providersSettings.getApiKeyCn}),[t.providersSettings]),te=(0,X.useMemo)(()=>(g?.agents??[]).map(e=>({value:e.id,label:ve(e,t.agentsSettings)})),[g?.agents,t.agentsSettings]);return r?h||S||T||_?(0,Z.jsx)(Ot,{}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[l?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:l}):null,(0,Z.jsx)(Et,{current:x?.current,agentId:y,agentOptions:te,t:n,onAgentIdChange:b}),(0,Z.jsx)(Dt,{title:n.understandingTitle,description:n.understandingDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:A.imageModel,fallbackValues:A.imageModelFallbacks,options:z,emptyLabel:n.noModelSelected,onValueChange:e=>M(t=>({...t,imageModel:e,imageModelFallbacks:e?t.imageModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>M(t=>({...t,imageModelFallbacks:e}))}),(0,Z.jsx)(Dt,{title:n.generationTitle,description:n.generationDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:A.imageGenerationModel,fallbackValues:A.imageGenerationModelFallbacks,options:B,emptyLabel:n.noModelSelected,onValueChange:e=>M(t=>({...t,imageGenerationModel:e,imageGenerationModelFallbacks:e?t.imageGenerationModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>M(t=>({...t,imageGenerationModelFallbacks:e}))}),(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.runtimeTuningTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.runtimeTuningHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,220px)_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[n.timeoutLabel,(0,Z.jsx)(`input`,{type:`number`,min:1,value:A.imageGenerationModelTimeoutMs,onChange:e=>M(t=>({...t,imageGenerationModelTimeoutMs:e.target.value})),placeholder:`120000`,className:`h-10 rounded-lg border border-edge bg-surface-subtle px-3 text-sm font-normal text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),(0,Z.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:A.imageGenerationModelAutoProviderFallback,onChange:e=>M(t=>({...t,imageGenerationModelAutoProviderFallback:e.target.checked})),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:n.autoFallbackLabel}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-fg-muted`,children:n.autoFallbackHint})]})]})]})]}),(0,Z.jsx)(st,{icon:v,showLabel:n.providersTitle,hideLabel:n.providersTitle,defaultOpen:O,children:m.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.providersEmpty}):(0,Z.jsx)(at,{summaries:m,credDraft:k.credDraft,credBaseline:k.credBaseline,credDirty:k.credDirty,credSaving:k.credSaving,credError:k.credError,credSavedFlash:k.credSavedFlash,credNoopFlash:k.credNoopFlash,updateCredRow:k.updateCredRow,onDiscardCredentials:k.onDiscardCredentials,onSaveCredentials:()=>void k.saveCredentials(n.credentialsSaveError),extensionIds:d,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:e,apiKeyLinkLabels:ee,messages:R})})]}):(0,Z.jsx)(`div`,{className:`w-full text-sm text-fg-muted`,children:e===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var jt=re;function Mt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function Nt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Pt(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,W,`dark:border-edge`)}function Q(){return o(T,re)}function Ft(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function It(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}))}var Lt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],Rt=[{id:`whisper-1`,name:`Whisper-1`}],zt=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],Bt=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],Vt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Ht=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],Ut=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],Wt=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],Gt=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],Kt=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],qt=[{id:`piper`,command:`piper --model /path/to/voice.onnx --output_file "{{OutputPath}}"`,outputFormat:`wav`},{id:`sherpa-onnx`,command:`sherpa-onnx-offline-tts --text "{{Text}}" --output-filename "{{OutputPath}}"`,outputFormat:`wav`},{id:`mlx-audio`,command:`python -m mlx_audio.tts.generate --text "{{Text}}" --file_prefix "{{OutputBase}}"`,outputFormat:`wav`}];function Jt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Yt(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function Xt(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function Zt(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;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function Qt(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function $t(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 en(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 tn(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`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function nn(){let e=s(f(e=>e.language)).voiceSettings,t=!!c(e=>e.token),[n,r]=(0,X.useReducer)(tn,{form:null,baseline:null}),i=n.form,a=n.baseline,[o,l]=(0,X.useState)(null),[d,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),_=(0,X.useRef)(!1),v=(0,X.useRef)({parsed:null,models:void 0}),{data:y,error:b,isLoading:x,mutate:S}=M(t),{data:C,error:w,isLoading:T,mutate:E}=p(t?u(`/api/voice/models`):null,et,{revalidateOnFocus:!1}),{data:D,error:O,isLoading:k}=p(t?u(`/api/voice/providers`):null,nt,{revalidateOnFocus:!1}),{data:A,error:j,isLoading:N}=p(t?u(`/api/voice/stt-providers`):null,Ye,{revalidateOnFocus:!1}),P=(0,X.useMemo)(()=>D?.providers??[],[D]),F=(0,X.useMemo)(()=>A?.providers??[],[A]),I=(0,X.useMemo)(()=>y?.payload?.config===void 0?null:tt(y.payload.config),[y]),L=(0,X.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]);t?I!==null&&C!==void 0&&!_.current&&(v.current.parsed!==I||v.current.models!==C)&&(v.current={parsed:I,models:C},r({type:`sync`,value:I}),l(C)):(v.current.parsed!==null||v.current.models!==void 0)&&(v.current={parsed:null,models:void 0},r({type:`reset`}),l(null),_.current=!1);let R=!!(t&&(I===null||C===void 0||D===void 0||A===void 0)&&(x||T||k||N)),z=b instanceof Error?b.message:b?String(b):w instanceof Error?w.message:w?String(w):O instanceof Error?O.message:O?String(O):j instanceof Error?j.message:j?String(j):null,B=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),V=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),ee=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),te=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!0,order:[`alibaba`,`openai`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),H=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),ne=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),U=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),W=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),G=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),re=(0,X.useCallback)(e=>{_.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]);if(dt({id:`voice`,dirty:L,saving:d,save:(0,X.useCallback)(async()=>{if(!(!i||d)){m(!0),g(null);try{await rt(i),r({type:`saved`,value:i}),_.current=!1}catch(t){g(t instanceof Error?t.message:e.saveError)}finally{m(!1)}}},[i,d,e.saveError]),discard:(0,X.useCallback)(()=>{a&&(_.current=!1,r({type:`discard`}),g(null))},[a])}),!t)return(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.needToken})});if(R)return(0,Z.jsx)(Je,{rows:4});if(!i||o===null)return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h??z??e.loadError}),(0,Z.jsx)(K,{type:`button`,variant:`secondary`,onClick:()=>{S(),E()},children:e.retry})]});let ie=i.stt,ae=i.tts,oe=Qt(e);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(rn,{v:e,stt:ie,tts:ae}),(0,Z.jsx)(on,{v:e,apiKeyLabels:oe,stt:ie,models:o,sttProviders:F,updateStt:B,updateSttAlibaba:V,updateSttOpenai:ee,updateSttFallback:te}),(0,Z.jsx)(dn,{v:e,apiKeyLabels:oe,tts:ae,models:o,ttsProviders:P,updateTts:H,updateTtsAlibaba:ne,updateTtsOpenai:U,updateTtsEdge:W,updateTtsMinimax:G,updateTtsLocalCli:re})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,Z.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,Z.jsx)(`strong`,{className:`text-accent`,children:e.notes.title}),` `,e.notes.duration]}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:e.notes.envVars})]})]})}function rn(e){let t=(0,Y.c)(39),{v:n,stt:r,tts:i}=e,a=i.provider===`openai`?i.openai?.voice:i.provider===`alibaba`?i.alibaba?.voice:i.provider===`minimax`?i.minimax?.voice:i.provider===`edge`?i.edge?.voice:void 0,o;t[0]===n.overview.title?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=o);let s;t[2]===n.overview.description?s=t[3]:(s=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(l=r.enabled?`${n.overview.ready} · ${Jt(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=l):l=t[10];let u;t[11]!==r.enabled||t[12]!==l||t[13]!==n.overview.input?(u=(0,Z.jsx)(an,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?Xt(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=d):d=t[18];let f=i.enabled&&i.trigger!==`off`,p;t[19]!==d||t[20]!==f||t[21]!==n.overview.replies?(p=(0,Z.jsx)(an,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${Yt(i.provider,n)}${a?` · ${a}`:``}`:n.overview.off,t[23]=a,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=m):m=t[27];let h;t[28]!==m||t[29]!==i.enabled||t[30]!==n.overview.voice?(h=(0,Z.jsx)(an,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,p,h]}),t[32]=h,t[33]=u,t[34]=p,t[35]=g):g=t[35];let _;return t[36]!==g||t[37]!==c?(_=(0,Z.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[c,g]}),t[36]=g,t[37]=c,t[38]=_):_=t[38],_}function an(e){let t=(0,Y.c)(10),{label:n,value:r,ready:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=a);let s=i?`text-fg`:`text-fg-muted`,c;t[2]===s?c=t[3]:(c=o(`mt-1 text-sm font-medium`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,Z.jsx)(`div`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==a||t[8]!==l?(u=(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[a,l]}),t[7]=a,t[8]=l,t[9]=u):u=t[9],u}function on(e){let t=(0,Y.c)(46),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:s,updateStt:c,updateSttAlibaba:l,updateSttOpenai:u,updateSttFallback:d}=e,f=a?.stt?.alibaba?.length?a.stt.alibaba:Lt,p=a?.stt?.openai?.length?a.stt.openai:Rt,m;if(t[0]!==s){let e=new Set;m=[];for(let t of s)e.has(t.id)||(e.add(t.id),m.push(t));t[0]=s,t[1]=m}else m=t[1];let h=m,g,_,v,y,b;if(t[2]!==f||t[3]!==r||t[4]!==p||t[5]!==h||t[6]!==i||t[7]!==c||t[8]!==l||t[9]!==d||t[10]!==u||t[11]!==n){let e=h.find(e=>e.id===i.provider),a=i.providers?.[i.provider],s=typeof a?.apiKey==`string`?a.apiKey:``,m=typeof a?.model==`string`?a.model:``,x={...i.provider===`alibaba`?i.alibaba??{}:{},...i.provider===`openai`?i.openai??{}:{},...a??{}},S=(e?.fields??[]).filter(un),C;t[17]!==i.provider||t[18]!==i.providers||t[19]!==c?(C=e=>{c({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[17]=i.provider,t[18]=i.providers,t[19]=c,t[20]=C):C=t[20];let w=C;y=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(le,{className:`size-4 text-accent`,strokeWidth:1.75}),t[21]=T):T=t[21];let E;t[22]===n.stt.title?E=t[23]:(E=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[22]=n.stt.title,t[23]=E);let D;t[24]===n.stt.description?D=t[25]:(D=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[24]=n.stt.description,t[25]=D),t[26]!==E||t[27]!==D?(b=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[26]=E,t[27]=D,t[28]=b):b=t[28],g=`space-y-4`;let O;t[29]===c?O=t[30]:(O=e=>c({enabled:e}),t[29]=c,t[30]=O),t[31]!==i.enabled||t[32]!==O||t[33]!==n.overview.off||t[34]!==n.overview.ready||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(_=(0,Z.jsx)(fn,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:O}),t[31]=i.enabled,t[32]=O,t[33]=n.overview.off,t[34]=n.overview.ready,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=_):_=t[37],v=i.enabled?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:n.stt.provider}),(0,Z.jsx)(J,{className:Q(),value:i.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,Z.jsxs)(q,{value:e.id,children:[Jt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:n.stt.model}),i.provider===`alibaba`?(0,Z.jsx)(J,{className:Q(),value:i.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(ln)}):i.provider===`openai`?(0,Z.jsx)(J,{className:Q(),value:i.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map(cn)}):i.provider===`groq`?(0,Z.jsx)(J,{className:Q(),value:m||zt[0].id,onChange:e=>w({model:e.target.value}),children:zt.map(sn)}):(0,Z.jsx)(`input`,{className:Pt(),value:m,onChange:e=>w({model:e.target.value}),placeholder:i.provider})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:n.stt.apiKey}),(0,Z.jsx)(it,{kind:`stt`,providerId:i.provider,fieldId:`voice-stt-${i.provider}-api-key`,value:i.provider===`alibaba`?i.alibaba?.apiKey??``:i.provider===`openai`?i.openai?.apiKey??``:s,onChange:e=>{i.provider===`alibaba`?l({apiKey:e}):i.provider===`openai`?u({apiKey:e}):w({apiKey:e})},labels:r,placeholder:i.provider===`groq`?`gsk_...`:`sk-...`}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Mt(i.provider)?` ${Mt(i.provider)}`:``]})]})]}),S.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,Z.jsx)(pn,{field:e,value:$t(x,e),onChange:t=>w({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:jt},e.key))}):null,(0,Z.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,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!0,onChange:e=>d({enabled:e.target.checked})})]})]}):null,t[2]=f,t[3]=r,t[4]=p,t[5]=h,t[6]=i,t[7]=c,t[8]=l,t[9]=d,t[10]=u,t[11]=n,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b}else g=t[12],_=t[13],v=t[14],y=t[15],b=t[16];let x;t[38]!==g||t[39]!==_||t[40]!==v?(x=(0,Z.jsxs)(`div`,{className:g,children:[_,v]}),t[38]=g,t[39]=_,t[40]=v,t[41]=x):x=t[41];let S;return t[42]!==y||t[43]!==b||t[44]!==x?(S=(0,Z.jsxs)(`section`,{className:y,children:[b,x]}),t[42]=y,t[43]=b,t[44]=x,t[45]=S):S=t[45],S}function sn(e){return(0,Z.jsx)(q,{value:e.id,children:e.name},e.id)}function cn(e){return(0,Z.jsx)(q,{value:e.id,children:e.name},e.id)}function ln(e){return(0,Z.jsx)(q,{value:e.id,children:e.name},e.id)}function un(e){return e.key!==`apiKey`&&e.key!==`model`}function dn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,updateTtsAlibaba:s,updateTtsOpenai:c,updateTtsEdge:l,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:Bt,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:Vt,m=r?.tts?.alibaba?.length?r.tts.alibaba:Ht,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:Ut,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:Wt,_=r?.tts?.minimax?.length?r.tts.minimax:Gt,v=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:Kt,[y,b]=(0,X.useState)(e.tts.test.sampleText),[x,S]=(0,X.useState)({status:`idle`}),C=(0,X.useRef)(null),w=(0,X.useRef)(null),T=(0,X.useCallback)(()=>{C.current?.pause(),C.current=null,w.current&&=(URL.revokeObjectURL(w.current),null)},[]),E=(0,X.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]),D=E.find(e=>e.id===n.provider),O=n.providers?.[n.provider],k={...n.provider===`openai`?n.openai??{}:{},...n.provider===`alibaba`?n.alibaba??{}:{},...n.provider===`edge`?n.edge??{}:{},...n.provider===`minimax`?n.minimax??{}:{},...n.provider===`tts-local-cli`?n[`tts-local-cli`]??{}:{},...O??{}},A=(D?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),j=!!D?.diagnostics.requiresApiKey,M=!!D?.configured||!j,N=n.enabled?M?`ready`:`action`:`muted`,P=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,F=n.provider===`openai`?n.openai?.voice:n.provider===`alibaba`?n.alibaba?.voice:n.provider===`minimax`?n.minimax?.voice:n.provider===`edge`?n.edge?.voice:void 0;(0,X.useEffect)(()=>()=>T(),[T]);let I=(0,X.useCallback)(e=>{a({provider:e}),S({status:`idle`})},[a]),L=(0,X.useCallback)(async()=>{let t=y.trim();if(!t){S({status:`error`,message:e.tts.test.emptyText});return}T(),S({status:`loading`});try{let r=await Xe({text:t,provider:n.provider,providerConfig:k,...P?{model:P}:{},...F?{voice:F}:{}}),i=It(r.audio,r.mimeType);w.current=i;let a=new Audio(i);C.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,Ft(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>S({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>S({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),S({status:`playing`,summary:o})}catch(e){T(),S({status:`error`,message:e instanceof Error?e.message:String(e)})}},[P,F,k,T,y,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),R=(0,X.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]),z=(0,X.useCallback)((e,t)=>{let r={[e.key]:t};R(r),n.provider===`openai`&&e.key===`baseUrl`?c(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&l(r)},[n.provider,R,l,u,c]);return(0,Z.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,Z.jsxs)(`div`,{className:`mb-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(oe,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(fn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>a({enabled:e})}),(0,Z.jsxs)(`div`,{className:o(`rounded-xl border px-3 py-2.5 text-sm`,N===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:N===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,Z.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?M?`${e.tts.statusReady} ${Yt(n.provider,e)}${F?` · ${F}`:``}`:`${e.tts.statusNeedsSetup} ${Yt(n.provider,e)} · ${D?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:e.tts.trigger}),(0,Z.jsxs)(J,{className:Q(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,Z.jsx)(q,{value:`off`,children:e.tts.triggerOff}),(0,Z.jsx)(q,{value:`inbound`,children:e.tts.triggerInbound}),(0,Z.jsx)(q,{value:`tagged`,children:e.tts.triggerTagged}),(0,Z.jsx)(q,{value:`always`,children:e.tts.triggerAlways})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:e.tts.provider}),(0,Z.jsx)(J,{className:Q(),value:n.provider,onChange:e=>I(e.target.value),children:E.map(t=>(0,Z.jsx)(q,{value:t.id,children:Yt(t.id,e)},t.id))}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[D?.configured?e.tts.configured:D?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${D.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,D?.description??Zt(n.provider,e)]})]})]}),(0,Z.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!M||n.provider===`tts-local-cli`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:e.stt.apiKey}),(0,Z.jsx)(it,{kind:`tts`,providerId:n.provider,fieldId:`voice-tts-${n.provider}-api-key`,value:n.provider===`openai`?n.openai?.apiKey??``:n.provider===`alibaba`?n.alibaba?.apiKey??``:n.minimax?.apiKey??``,onChange:e=>{n.provider===`openai`?c({apiKey:e}):n.provider===`alibaba`?s({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,Nt(n.provider)?` ${Nt(n.provider)}`:``]})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:e.stt.model}),(0,Z.jsx)(J,{className:Q(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?c({model:e.target.value}):n.provider===`alibaba`?s({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:_).map(e=>(0,Z.jsx)(q,{value:e.id,children:e.name},e.id))})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(J,{className:Q(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?c({voice:e.target.value}):n.provider===`alibaba`?s({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:v).map(e=>(0,Z.jsx)(q,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,jt),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(J,{className:Q(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:g.map(e=>(0,Z.jsx)(q,{value:e.id,children:e.name},e.id))}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.preset}),(0,Z.jsxs)(J,{className:Q(),value:``,onChange:e=>{let t=qt.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,Z.jsx)(q,{value:``,children:e.tts.localCli.presetPlaceholder}),qt.map(e=>(0,Z.jsx)(q,{value:e.id,children:e.id},e.id))]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.command}),(0,Z.jsx)(`input`,{className:o(Pt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.command??``,onChange:e=>d({command:e.target.value}),placeholder:e.tts.localCli.commandPlaceholder}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)($,{children:e.tts.localCli.cwd}),(0,Z.jsx)(`input`,{className:o(Pt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.cwd??``,onChange:e=>d({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)($,{children:e.tts.localCli.outputFormat}),(0,Z.jsxs)(J,{className:Q(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,Z.jsx)(q,{value:`wav`,children:`wav`}),(0,Z.jsx)(q,{value:`mp3`,children:`mp3`}),(0,Z.jsx)(q,{value:`opus`,children:`opus`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.timeoutMs}),(0,Z.jsx)(`input`,{className:Pt(),type:`number`,min:0,step:1e3,value:typeof n[`tts-local-cli`]?.timeoutMs==`number`?String(n[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){d({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&d({timeoutMs:n})},placeholder:`30000`}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,A.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:A.map(e=>(0,Z.jsx)(pn,{field:e,value:$t(k,e),onChange:t=>z(e,t),className:e.type===`textarea`?`sm:col-span-2`:jt},e.key))}):null]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Z.jsxs)(K,{type:`button`,variant:`primary`,onClick:()=>void L(),disabled:x.status===`loading`,className:`h-9`,children:[x.status===`loading`?(0,Z.jsx)(ge,{className:`size-4 animate-spin`}):(0,Z.jsx)(ie,{className:`size-4`}),x.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,Z.jsxs)(K,{type:`button`,variant:`secondary`,onClick:()=>{T(),S(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:x.status!==`playing`,className:`h-9`,children:[(0,Z.jsx)(xe,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,Z.jsx)(`textarea`,{className:o(Pt(),`mt-3 min-h-20 resize-y`),value:y,onChange:e=>b(e.target.value),maxLength:1e3}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,Z.jsxs)(`span`,{className:`text-fg-subtle`,children:[y.length,`/1000`]}),x.status===`playing`||x.status===`done`?(0,Z.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[x.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,x.summary]}):null,x.status===`error`?(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:x.message}):null]})]})]}):null]})]})}function fn(e){let t=(0,Y.c)(33),{checked:n,title:r,description:i,onLabel:a,offLabel:s,onChange:c}=e,l;t[0]!==n||t[1]!==c?(l=()=>c(!n),t[0]=n,t[1]=c,t[2]=l):l=t[2];let u=n?`bg-accent/10 text-fg ring-1 ring-accent/45 dark:bg-accent/15`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=o(`group flex w-full items-center justify-between gap-4 rounded-2xl px-4 py-3 text-left shadow-surface transition-colors`,W,u),t[3]=u,t[4]=d);let f=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,p;t[5]===f?p=t[6]:(p=o(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?a:s,h;t[7]!==p||t[8]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==h||t[11]!==r?(g=(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,h]}),t[10]=h,t[11]=r,t[12]=g):g=t[12];let _;t[13]===i?_=t[14]:(_=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:i}),t[13]=i,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,b;t[18]===y?b=t[19]:(b=o(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=b);let x=n?`translate-x-5`:`translate-x-0.5`,S;t[20]===x?S=t[21]:(S=o(`size-5 rounded-full bg-white shadow-surface transition-transform`,x),t[20]=x,t[21]=S);let C;t[22]===S?C=t[23]:(C=(0,Z.jsx)(`span`,{className:S}),t[22]=S,t[23]=C);let w;t[24]!==b||t[25]!==C?(w=(0,Z.jsx)(`span`,{className:b,"aria-hidden":!0,children:C}),t[24]=b,t[25]=C,t[26]=w):w=t[26];let T;return t[27]!==n||t[28]!==l||t[29]!==v||t[30]!==w||t[31]!==d?(T=(0,Z.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:l,className:d,children:[v,w]}),t[27]=n,t[28]=l,t[29]=v,t[30]=w,t[31]=d,t[32]=T):T=t[32],T}function pn(e){let t=(0,Y.c)(36),{field:n,value:r,onChange:i,className:a}=e,s=`voice-schema-field-${n.key}`,c=n.description;if(n.type===`boolean`){let e;t[0]===a?e=t[1]:(e=o(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,a),t[0]=a,t[1]=e);let s;t[2]===n.label?s=t[3]:(s=(0,Z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=s);let l;t[4]===c?l=t[5]:(l=c?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,Z.jsxs)(`span`,{children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==i?(f=e=>i(en(n,e.target.checked)),t[9]=n,t[10]=i,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:f}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==e||t[16]!==u||t[17]!==p?(m=(0,Z.jsxs)(`label`,{className:e,children:[u,p]}),t[15]=e,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}let l=typeof r==`boolean`?``:String(r),u;t[19]===a?u=t[20]:(u=o(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,Z.jsx)($,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==a||t[24]!==n||t[25]!==l||t[26]!==s||t[27]!==i?(f=n.type===`select`?(0,Z.jsx)(J,{id:s,className:Q(),value:l,required:n.required,onChange:e=>i(en(n,e.target.value)),children:(n.options??[]).map(mn)}):n.type===`textarea`?(0,Z.jsx)(`textarea`,{id:s,className:o(Pt(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>i(en(n,e.target.value))}):n.type===`password`?(0,Z.jsx)(F,{id:s,className:a,value:l,onChange:e=>i(en(n,e)),placeholder:n.placeholder,labels:h}):(0,Z.jsx)(`input`,{id:s,className:Pt(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:l,required:n.required,placeholder:n.placeholder,onChange:e=>i(en(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=l,t[26]=s,t[27]=i,t[28]=f):f=t[28];let p;t[29]===c?p=t[30]:(p=c?(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[29]=c,t[30]=p);let m;return t[31]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,Z.jsxs)(`div`,{className:u,children:[d,f,p]}),t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function mn(e){return(0,Z.jsx)(q,{value:e.id,children:e.name},e.id)}function $(e){let t=(0,Y.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function hn(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function gn(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 l(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),we()}async function _n(e){let t=await l(u(`/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 vn(e){let t=(0,Y.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.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,Z.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,Z.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 yn(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,W,`dark:border-edge`)}function bn(){return o(T,re)}var xn=[`brave`,`tavily`,`bing`,`searxng`];function Sn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var Cn=S();function wn(){let e=s(f(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!c(e=>e.token),[i,a]=(0,X.useReducer)(Cn,{form:null,baseline:null}),l=i.form,u=i.baseline,[d,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),g=(0,X.useRef)(!1),_=(0,X.useRef)(null),{data:v,error:b,isLoading:x,mutate:S}=M(r);y({enabled:r,parsed:(0,X.useMemo)(()=>v?.payload?.config===void 0?null:hn(v.payload.config),[v]),dirty:g.current,trackedParsedRef:_,dispatch:a,onResetDirty:()=>{g.current=!1}});let w=!!(r&&x&&v===void 0&&!b),T=b instanceof Error?b.message:b?String(b):null,D=(0,X.useMemo)(()=>!l||!u?!1:JSON.stringify(l)!==JSON.stringify(u),[l,u]),O=(0,X.useCallback)(e=>{g.current=!0,a({type:`patch`,patch:e})},[]);return dt({id:`search`,dirty:D,saving:d,save:(0,X.useCallback)(async()=>{if(!(!l||d)){p(!0),h(null);try{await gn(l),g.current=!1,a({type:`saved`,value:l})}catch(e){h(e instanceof Error?e.message:t.saveError)}finally{p(!1)}}},[l,d,t.saveError]),discard:(0,X.useCallback)(()=>{u&&(g.current=!1,a({type:`discard`}),h(null))},[u])}),r?w?(0,Z.jsx)(Je,{rows:3}):l?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[m?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,Z.jsxs)(lt,{children:[(0,Z.jsx)(ct,{icon:ke,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,Z.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,Z.jsx)(vn,{label:t.regionLabel,description:t.regionDesc,children:(0,Z.jsxs)(J,{className:bn(),value:l.regionMode,onChange:e=>O({regionMode:e.target.value}),children:[(0,Z.jsx)(q,{value:`auto`,children:t.regionAuto}),(0,Z.jsx)(q,{value:`cn`,children:t.regionCn}),(0,Z.jsx)(q,{value:`global`,children:t.regionGlobal})]})})})]}),(0,Z.jsx)(ot,{children:(0,Z.jsxs)(lt,{children:[(0,Z.jsx)(ct,{icon:C,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,Z.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:l.blocklistEnabled,onChange:e=>O({blocklistEnabled:e.target.checked})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),(0,Z.jsx)(vn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,Z.jsx)(`textarea`,{className:o(yn(),`min-h-[6rem] font-mono text-xs`),value:l.blocklistDomains.join(`
|
|
2
2
|
`),placeholder:t.blocklistDomainsPlaceholder,disabled:!l.blocklistEnabled,onChange:e=>{O({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,Z.jsxs)(lt,{children:[(0,Z.jsx)(ct,{icon:ke,title:t.sectionSearch,subtitle:t.sectionSearchHint}),(0,Z.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,Z.jsx)(vn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,Z.jsx)(`input`,{type:`number`,min:1,max:50,className:yn(),value:l.maxResults,onChange:e=>O({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.providersTitle}),l.providers.map((n,r)=>(0,Z.jsx)(Tn,{row:n,providerIndex:r,labels:t,secretLabels:Ee(e.providersSettings),onChange:e=>{let t=[...l.providers];t[r]=e,O({providers:t})},onRemove:()=>{O({providers:l.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,Z.jsxs)(K,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>O({providers:[...l.providers,Sn()]}),children:[(0,Z.jsx)(E,{className:`size-4`}),t.addProvider]})]})]})]}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t.footerHint})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m??T??t.loadError}),(0,Z.jsx)(K,{type:`button`,variant:`secondary`,onClick:()=>void S(),children:n.refresh})]}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})})}function Tn(e){let t=(0,Y.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:s,onRemove:c}=e,l;t[0]===r?l=t[1]:(l=()=>_n(r).then(En),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=o(bn(),`min-w-[8rem]`),t[2]=d):d=t[2];let f=n.type,p;t[3]!==s||t[4]!==n?(p=e=>s({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=s,t[4]=n,t[5]=p):p=t[5];let m;t[6]===i.providerTypes?m=t[7]:(m=xn.map(e=>(0,Z.jsx)(q,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=m);let h;t[8]!==n.type||t[9]!==p||t[10]!==m?(h=(0,Z.jsx)(J,{className:d,value:f,onChange:p,children:m}),t[8]=n.type,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==s||t[13]!==n?(g=e=>s({...n,disabled:e.target.checked}),t[12]=s,t[13]=n,t[14]=g):g=t[14];let _;t[15]!==n.disabled||t[16]!==g?(_=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:g}),t[15]=n.disabled,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==i.disabled||t[19]!==_?(v=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[_,i.disabled]}),t[18]=i.disabled,t[19]=_,t[20]=v):v=t[20];let y;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(de,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===c?b=t[23]:(b=(0,Z.jsx)(K,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:c,children:y}),t[22]=c,t[23]=b);let x;t[24]!==b||t[25]!==v?(x=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v,b]}),t[24]=b,t[25]=v,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==h?(S=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[h,x]}),t[27]=x,t[28]=h,t[29]=S):S=t[29];let C;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==s||t[33]!==n?(C=n.type===`searxng`?(0,Z.jsx)(vn,{label:i.urlLabel,description:i.urlDesc,children:(0,Z.jsx)(`input`,{type:`url`,className:yn(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>s({...n,url:e.target.value})})}):null,t[30]=i.urlDesc,t[31]=i.urlLabel,t[32]=s,t[33]=n,t[34]=C):C=t[34];let w;t[35]!==s||t[36]!==n?(w=e=>s({...n,apiKey:e}),t[35]=s,t[36]=n,t[37]=w):w=t[37];let T;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==u||t[42]!==n.apiKey||t[43]!==a||t[44]!==w?(T=(0,Z.jsx)(F,{value:n.apiKey,onChange:w,placeholder:i.keyPlaceholder,labels:a,reveal:u,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[38]=i.keyPlaceholder,t[39]=i.keyPlaceholderMasked,t[40]=i.saveError,t[41]=u,t[42]=n.apiKey,t[43]=a,t[44]=w,t[45]=T):T=t[45];let E;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==T?(E=(0,Z.jsx)(vn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:T}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=T,t[49]=E):E=t[49];let D;return t[50]!==S||t[51]!==C||t[52]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/70 p-4 shadow-surface`,children:[S,C,E]}),t[50]=S,t[51]=C,t[52]=E,t[53]=D):D=t[53],D}function En(e){return e.apiKey??null}function Dn(){let e=(0,Y.c)(31),t=c(Mn),n=!!t,{data:r,isLoading:i}=M(n),a;e[0]===n?a=e[1]:(a=n?u(`/api/providers/meta`):null,e[0]=n,e[1]=a);let o;e[2]===t?o=e[3]:(o=async e=>{let{payload:n}=await(await fetch(e,{headers:{Authorization:`Bearer ${t}`}})).json();return n?.providers??[]},e[2]=t,e[3]=o);let s;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},e[4]=s):s=e[4];let{data:l,isLoading:d}=p(a,o,s),f;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},e[5]=f):f=e[5];let{data:m,isLoading:h}=p(n?Te:null,jn,f),g;e[6]===m?g=e[7]:(g=m===void 0?[]:m,e[6]=m,e[7]=g);let v=g,y;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(y={revalidateOnFocus:!1},e[8]=y):y=e[8];let{data:b}=p(n?Oe:null,An,y),x;bb0:{if(!l||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],x=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==l||e[12]!==v?(t=U(l,_(r?.payload?.config),v),e[10]=r?.payload?.config,e[11]=l,e[12]=v,e[13]=t):t=e[13],x=t}let S=x,C;bb1:{if(!b){C=null;break bb1}let t;e[14]===b.config?t=e[15]:(t=_e(b.config),e[14]=b.config,e[15]=t),C=t}let w=C,T;if(e[16]!==S||e[17]!==w||e[18]!==l||e[19]!==v){T=[];let t=new Set((l??[]).filter(kn).map(On)),n;e[21]===w?n=e[22]:(n=new Set(w?Object.keys(w.providers):[]),e[21]=w,e[22]=n);let r=n;for(let e of S){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?w.providers[e.id]?.models?.length??0:v.filter(t=>t.provider===e.id).length;T.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(w){let t;e[23]===w.providers?t=e[24]:(t=Object.entries(w.providers),e[23]=w.providers,e[24]=t);for(let[e,n]of t)T.some(t=>t.id===e)||T.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=S,e[17]=w,e[18]=l,e[19]=v,e[20]=T}else T=e[20];let E=T,D=i||d||h,O;return e[25]!==S||e[26]!==E||e[27]!==w||e[28]!==D||e[29]!==v?(O={cards:E,loading:D,builtinRows:S,customConfig:w,allModels:v},e[25]=S,e[26]=E,e[27]=w,e[28]=D,e[29]=v,e[30]=O):O=e[30],O}function On(e){return e.id}function kn(e){return e.configured}function An(){return ze()}function jn(){return N()}function Mn(e){return e.token}function Nn(e){let t=(0,Y.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=Dn();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(P,{className:`h-6 w-48 max-w-full`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[e,(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(Fn)})]}),t[1]=n):n=t[1],n}let s;if(t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==i){let e=a.filter(Pn),o=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,c;t[7]===o?c=t[8]:(c=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o}),t[7]=o,t[8]=c);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(E,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==r?(u=(0,Z.jsxs)(K,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:r,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=r,t[12]=u):u=t[12];let d;t[13]!==c||t[14]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,Z.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel/60 px-6 py-10 text-center shadow-surface`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,Z.jsxs)(K,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,Z.jsx)(E,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,Z.jsx)(In,{card:e,labels:n,onManage:()=>i(e.id,e.isCustom)},e.id))})]}),t[2]=a,t[3]=n,t[4]=r,t[5]=i,t[6]=s}else s=t[6];return s}function Pn(e){return e.configured}function Fn(e){return(0,Z.jsx)(P,{className:`h-32 rounded-2xl`},e)}function In(e){let t=(0,Y.c)(28),{card:n,labels:r,onManage:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=o(`group relative flex flex-col justify-between rounded-2xl bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,B.pressCard),t[0]=a):a=t[0];let s;t[1]===n.name?s=t[2]:(s=(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=s);let c;t[3]!==n.isCustom||t[4]!==r.custom?(c=n.isCustom?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:r.custom}):null,t[3]=n.isCustom,t[4]=r.custom,t[5]=c):c=t[5];let l;t[6]!==s||t[7]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(fe,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=u):u=t[9];let d;t[10]===l?d=t[11]:(d=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,u]}),t[10]=l,t[11]=d);let f;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(f=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=f):f=t[15];let p;t[16]===f?p=t[17]:(p=(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f}),t[16]=f,t[17]=p);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(x,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[m,r.manage]}),t[19]=r.manage,t[20]=h);let g;t[21]!==h||t[22]!==p?(g=(0,Z.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[p,h]}),t[21]=h,t[22]=p,t[23]=g):g=t[23];let _;return t[24]!==i||t[25]!==g||t[26]!==d?(_=(0,Z.jsxs)(`button`,{type:`button`,onClick:i,className:a,children:[d,g]}),t[24]=i,t[25]=g,t[26]=d,t[27]=_):_=t[27],_}async function Ln(e){let t=await d(u(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${t.status}`)}return(await t.json()).payload}async function Rn(e){let t=await d(u(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function zn(e,t){let n=await d(u(`/api/auth/oauth-async/${encodeURIComponent(e)}/code`),{method:`POST`,body:JSON.stringify({code:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${n.status}`)}}async function Bn(e){let t=await d(u(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function Vn(e){let t=await d(u(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function Hn(e){let t=await d(u(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var Un=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function Wn(e){let t=new Map;for(let e of Un)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function Gn(e){let t=(0,Y.c)(22),{open:n,onOpenChange:r,builtinRows:i,customConfig:a,labels:s,language:c,onSaved:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,X.useState)(u),[p,m]=(0,X.useState)(``),h;t[1]===r?h=t[2]:(h=e=>{e||window.setTimeout(()=>{f({type:`pick`}),m(``)},200),r(e)},t[1]=r,t[2]=h);let _=h,v;t[3]!==_||t[4]!==l?(v=()=>{l(),_(!1)},t[3]=_,t[4]=l,t[5]=v):v=t[5];let y=v,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(Re,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,g)}),t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x=o(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,H),t[7]=x):x=t[7];let S;t[8]!==i||t[9]!==a||t[10]!==y||t[11]!==s||t[12]!==c||t[13]!==p||t[14]!==d.presetKey||t[15]!==d.providerId||t[16]!==d.type?(S=(0,Z.jsxs)(he,{children:[b,(0,Z.jsx)(ue,{className:x,children:d.type===`pick`?(0,Z.jsx)(qn,{builtinRows:i,searchQuery:p,onSearchChange:m,labels:s,onPickBuiltin:e=>{let t=Ve(e);f(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,Z.jsx)(Jn,{providerId:d.providerId,builtinRows:i,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:y}):(0,Z.jsx)(Zn,{initialPresetKey:d.presetKey,customConfig:a,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:y})})]}),t[8]=i,t[9]=a,t[10]=y,t[11]=s,t[12]=c,t[13]=p,t[14]=d.presetKey,t[15]=d.providerId,t[16]=d.type,t[17]=S):S=t[17];let C;return t[18]!==_||t[19]!==n||t[20]!==S?(C=(0,Z.jsx)(Me,{open:n,onOpenChange:_,children:S}),t[18]=_,t[19]=n,t[20]=S,t[21]=C):C=t[21],C}function Kn(e){let t=(0,Y.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.press),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Ie,{className:`size-4`,"aria-hidden":!0}),t[1]=i):i=t[1];let a;return t[2]===n?a=t[3]:(a=(0,Z.jsx)(Ce,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:i})}),t[2]=n,t[3]=a),a}function qn(e){let t=(0,Y.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:i,labels:a,onPickBuiltin:s,onPickCustom:c}=e,l;t[0]===r?l=t[1]:(l=r.trim().toLowerCase(),t[0]=r,t[1]=l);let u=l,d;bb0:{if(!u){d=n;break bb0}let e;if(t[2]!==n||t[3]!==u){let r;t[5]===u?r=t[6]:(r=e=>{let t=R[e.id]?.aliases??[];return e.id.toLowerCase().includes(u)||e.name.toLowerCase().includes(u)||t.some(e=>e.toLowerCase().includes(u))},t[5]=u,t[6]=r),e=n.filter(r),t[2]=n,t[3]=u,t[4]=e}else e=t[4];d=e}let f=d,p;t[7]===f?p=t[8]:(p=Wn(f),t[7]=f,t[8]=p);let m=p,h;t[9]===a.step1Title?h=t[10]:(h=(0,Z.jsx)(Be,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:a.step1Title}),t[9]=a.step1Title,t[10]=h);let g;t[11]===a.close?g=t[12]:(g=(0,Z.jsx)(Kn,{label:a.close}),t[11]=a.close,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(ke,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]===i?y=t[18]:(y=e=>i(e.target.value),t[17]=i,t[18]=y);let b=a.searchPlaceholder,x;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(x=o(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,W),t[19]=x):x=t[19];let S;t[20]!==a.searchPlaceholder||t[21]!==r||t[22]!==y?(S=(0,Z.jsx)(`div`,{className:`px-5 pt-3`,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[v,(0,Z.jsx)(`input`,{type:`search`,value:r,onChange:y,placeholder:b,autoComplete:`off`,autoFocus:!0,className:x})]})}),t[20]=a.searchPlaceholder,t[21]=r,t[22]=y,t[23]=S):S=t[23];let C;t[24]!==a.addCustom||t[25]!==a.customDescription||t[26]!==c||t[27]!==u?(C=u?null:(0,Z.jsxs)(`button`,{type:`button`,onClick:c,className:o(`mb-3 flex w-full items-center gap-3 rounded-xl border border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,B.press),children:[(0,Z.jsx)(z,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.addCustom}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:a.customDescription})]}),(0,Z.jsx)(ee,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=a.addCustom,t[25]=a.customDescription,t[26]=c,t[27]=u,t[28]=C):C=t[28];let w;t[29]!==f.length||t[30]!==m||t[31]!==a.categories||t[32]!==a.noResults||t[33]!==s?(w=f.length===0?(0,Z.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:a.noResults}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:Un.map(e=>{let t=m.get(e)??[];return t.length===0?null:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:a.categories[e]??e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:o(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2.5 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,B.press),children:[(0,Z.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,Z.jsx)(fe,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null]},e.id))})]},e)})}),t[29]=f.length,t[30]=m,t[31]=a.categories,t[32]=a.noResults,t[33]=s,t[34]=w):w=t[34];let T;t[35]!==C||t[36]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[C,w]}),t[35]=C,t[36]=w,t[37]=T):T=t[37];let E;return t[38]!==S||t[39]!==T||t[40]!==_?(E=(0,Z.jsxs)(Z.Fragment,{children:[_,S,T]}),t[38]=S,t[39]=T,t[40]=_,t[41]=E):E=t[41],E}function Jn({providerId:e,builtinRows:t,labels:n,language:r,onBack:i,onSaved:a}){let c=t.find(t=>t.id===e),l=R[e],[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),v=(0,X.useRef)(null),y=s(r).providersSettings,x=Ee(y),S=(0,X.useMemo)(()=>w(e,r),[e,r]),C=c?.supportsApiKey!==!1,T=c?.supportsOAuth===!0,[E,D]=(0,X.useState)(null),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(`idle`),[N,P]=(0,X.useState)(null),[I,L]=(0,X.useState)(null),[z,V]=(0,X.useState)(``),te=j===`waiting`||j===`waiting_code`;(0,X.useEffect)(()=>{if(!E||!te)return;let e=window.setInterval(()=>{(async()=>{try{let t=await Rn(E);t.status===`waiting_auth`||t.status===`waiting_code`?(M(t.status===`waiting_code`?`waiting_code`:`waiting`),A(t.message??null),P(t.authUrl??null),L(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),M(`success`),A(t.message??y.saved),window.setTimeout(a,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),M(`error`),A(t.error??t.message??y.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[E,te,a,y.revokeFailed,y.saved]),(0,X.useEffect)(()=>()=>{E&&Vn(E).catch(()=>{})},[E]);let H=async()=>{M(`waiting`),A(y.oauthStarting),h(null);try{D((await Ln(e)).sessionId)}catch(e){M(`error`),A(e instanceof Error?e.message:y.revokeFailed)}},ne=async()=>{if(E){try{await Bn(E)}catch{}M(`idle`),A(null),D(null),P(null),L(null)}},U=async()=>{if(!(!E||!z.trim()))try{await zn(E,z.trim()),V(``),A(y.oauthProcessingCode)}catch(e){M(`error`),A(e instanceof Error?e.message:y.revokeFailed)}},G=async()=>{let t=u.trim();if(!(!t||!C)){p(!0),h(null);try{await b({[e]:t}),_(!0),window.setTimeout(a,600)}catch(e){h(e instanceof Error?e.message:n.saveError)}finally{p(!1)}}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:i,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.press),"aria-label":n.back,children:(0,Z.jsx)(ee,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Z.jsx)(Be,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:c?.name??e}),(0,Z.jsx)(Kn,{label:n.close})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[l?.description?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.description}):null,C?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,Z.jsx)(F,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:x,inputRef:v,onKeyDown:e=>{e.key===`Enter`&&G()}})]}):null,T?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:y.oauth}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:y.oauthHint})]}),(0,Z.jsxs)(K,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:te,onClick:()=>void H(),children:[te?(0,Z.jsx)(ge,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,y.oauth]})]}),k?(0,Z.jsx)(`p`,{className:o(`text-xs`,j===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:k}):null,j===`waiting`||j===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[N?(0,Z.jsxs)(`a`,{href:N,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-white hover:bg-accent-hover`,children:[y.openAuthPage,(0,Z.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,Z.jsx)(K,{type:`button`,variant:`secondary`,onClick:()=>void ne(),children:y.cancelOAuth})]}):null,I?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:I}):null,j===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(`input`,{type:`text`,value:z,onChange:e=>V(e.target.value),onKeyDown:e=>e.key===`Enter`&&void U(),placeholder:y.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`,W)}),(0,Z.jsx)(K,{type:`button`,variant:`primary`,onClick:()=>void U(),children:y.submitCode})]}):null]}):null,S.length>0&&C?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:S.map(({kind:e,href:t})=>(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[O(e,n),(0,Z.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,m?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(K,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),C?(0,Z.jsx)(K,{type:`button`,variant:`primary`,disabled:!u.trim()||f||g,onClick:()=>void G(),children:g?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(fe,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ge,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function Yn(e=`custom`){if(e!==`custom`&&Ne[e]){let t=Ne[e].config;return{preset:e,providerId:pe(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:t.models?.map(e=>e.id)??[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function Xn(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:Ne[t.key]?Yn(t.key):e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`setModelIds`:return{...e,modelIds:t.values.length>0?t.values:[``]};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function Zn({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:i,onSaved:a}){let[c,l]=(0,X.useReducer)(Xn,void 0,()=>Yn(e)),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),m=Ee(s(r).providersSettings),{preset:h,providerId:g,baseUrl:_,api:v,apiKey:y,modelIds:b,error:x}=c,S=async()=>{let e=g.trim(),r=_.trim();if(!e){l({type:`setError`,value:n.providerIdRequired});return}if(!r){l({type:`setError`,value:n.baseUrlRequired});return}let i=b.map(e=>e.trim()).filter(Boolean);d(!0),l({type:`setError`,value:null});try{let n=t?.providers??{},o=h===`custom`?void 0:Ne[h]?.config,s={...o??{},baseUrl:r,api:v,apiKey:y.trim()||void 0,models:i.map(e=>o?.models?.find(t=>t.id===e)??{id:e})};await ye({providers:{...n,[e]:s}}),a()}catch(e){l({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{d(!1)}},C=async()=>{let e=g.trim()||pe(h)||`custom`,t=_.trim();if(!t){l({type:`setError`,value:n.baseUrlRequired});return}p(!0),l({type:`setError`,value:null});try{let r=h===`custom`?void 0:Ne[h]?.config,i=(await je({providerId:e,baseUrl:t,apiKey:y.trim()||void 0,api:v,headers:r?.headers})).map(e=>e.id).filter(e=>e&&!e.includes(`/`));l({type:`setModelIds`,values:i}),i.length===0&&l({type:`setError`,value:n.discoverModelsHint})}catch(e){l({type:`setError`,value:e instanceof Error?e.message:n.discoverModelsHint})}finally{p(!1)}},w=g.trim()&&_.trim(),T=(v===`openai-completions`||v===`openai-responses`)&&_.trim();return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:i,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.press),"aria-label":n.back,children:(0,Z.jsx)(ee,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Z.jsx)(Be,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,Z.jsx)(Kn,{label:n.close})]}),(0,Z.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.customDescription}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:n.presetLabel}),(0,Z.jsxs)(J,{id:`custom-preset`,value:h,onChange:e=>l({type:`applyPreset`,key:e.target.value}),className:We(),children:[(0,Z.jsx)(q,{value:`custom`,children:n.presetCustom}),Se.map(e=>(0,Z.jsx)(q,{value:e.key,children:e.label},e.key))]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:n.providerIdLabel}),(0,Z.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,autoFocus:!0,value:g,onChange:e=>l({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:o(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,W)})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,Z.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:_,onChange:e=>l({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:o(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,W)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:n.apiTypeLabel}),(0,Z.jsx)(J,{id:`custom-api-type`,value:v,onChange:e=>l({type:`setApi`,value:e.target.value}),className:We(),children:Le.map(e=>(0,Z.jsx)(q,{value:e.value,children:e.label},e.value))})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,Z.jsx)(F,{id:`custom-api-key`,value:y,onChange:e=>l({type:`setApiKey`,value:e}),placeholder:n.apiKeyPlaceholder,labels:m})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.modelIdLabel}),(0,Z.jsxs)(K,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!T||f,onClick:()=>void C(),children:[f?(0,Z.jsx)(ge,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(ke,{className:`size-3.5`,"aria-hidden":!0}),f?n.discoveringModels:n.discoverModels]})]}),b.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>l({type:`updateModelId`,index:t,value:e.target.value}),placeholder:n.modelIdPlaceholder,className:o(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,W)}),b.length>1?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>l({type:`removeModelSlot`,index:t}),className:o(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,B.press),children:(0,Z.jsx)(Ie,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,Z.jsxs)(K,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>l({type:`addModelSlot`}),children:[(0,Z.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),x?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,Z.jsx)(K,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),(0,Z.jsx)(K,{type:`button`,variant:`primary`,disabled:!w||u,onClick:()=>void S(),children:u?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ge,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function Qn(e){let t=(0,Y.c)(156),{model:n,isNew:r,providerId:i,onSave:a,onClose:s,m:c}=e,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:me(``),t[0]=n,t[1]=l);let[u,d]=(0,X.useState)(l),[f,p]=(0,X.useState)($n),m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(e,t)=>{d(n=>({...n,[e]:t})),p(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=m):m=t[2];let h=m,g;t[3]!==u.contextWindow||t[4]!==u.id||t[5]!==u.maxTokens||t[6]!==c.modelIdRequired||t[7]!==c.mustBePositive?(g=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,c.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,c.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,c.mustBePositive),p(e),e.size===0},t[3]=u.contextWindow,t[4]=u.id,t[5]=u.maxTokens,t[6]=c.modelIdRequired,t[7]=c.mustBePositive,t[8]=g):g=t[8];let _=g,v;t[9]!==u||t[10]!==s||t[11]!==a||t[12]!==_?(v=()=>{if(!_())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}}),s()},t[9]=u,t[10]=s,t[11]=a,t[12]=_,t[13]=v):v=t[13];let y=v,b=u,x;t[14]===b?x=t[15]:(x=Ge(b),t[14]=b,t[15]=x);let S=x,C=r?c.addModelTitle:c.editModelTitle,w;t[16]===C?w=t[17]:(w=(0,Z.jsx)(Be,{className:`text-base font-semibold text-fg`,children:C}),t[16]=C,t[17]=w);let T;t[18]!==c.modelProviderLabel||t[19]!==i?(T=i?(0,Z.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[c.modelProviderLabel,`: `,i]}):null,t[18]=c.modelProviderLabel,t[19]=i,t[20]=T):T=t[20];let E;t[21]!==w||t[22]!==T?(E=(0,Z.jsxs)(`div`,{children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(D=o(A,`p-1.5 hover:bg-surface-base`),t[24]=D):D=t[24];let O;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(Ie,{className:`size-4`}),t[25]=O):O=t[25];let k;t[26]===c.close?k=t[27]:(k=(0,Z.jsx)(Ce,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:D,"aria-label":c.close,children:O})}),t[26]=c.close,t[27]=k);let j;t[28]!==E||t[29]!==k?(j=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[E,k]}),t[28]=E,t[29]=k,t[30]=j):j=t[30];let M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=M):M=t[31];let N;t[32]===c.modelId?N=t[33]:(N=(0,Z.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[c.modelId,M]}),t[32]=c.modelId,t[33]=N);let P;t[34]===f?P=t[35]:(P=o(be(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=P);let F=u.id||``,I;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>h(`id`,e.target.value),t[36]=I):I=t[36];let L=!r,R;t[37]!==P||t[38]!==F||t[39]!==L?(R=(0,Z.jsx)(`input`,{className:P,value:F,onChange:I,placeholder:`e.g. llama3.1:8b`,disabled:L}),t[37]=P,t[38]=F,t[39]=L,t[40]=R):R=t[40];let z;t[41]===f?z=t[42]:(z=f.has(`id`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[41]=f,t[42]=z);let B;t[43]!==N||t[44]!==R||t[45]!==z?(B=(0,Z.jsxs)(`div`,{children:[N,R,z]}),t[43]=N,t[44]=R,t[45]=z,t[46]=B):B=t[46];let V;t[47]===c.displayName?V=t[48]:(V=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.displayName}),t[47]=c.displayName,t[48]=V);let ee;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ee=be(),t[49]=ee):ee=t[49];let te=u.name||``,H;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>h(`name`,e.target.value),t[50]=H):H=t[50];let ne;t[51]===te?ne=t[52]:(ne=(0,Z.jsx)(`input`,{className:ee,value:te,onChange:H}),t[51]=te,t[52]=ne);let U;t[53]!==V||t[54]!==ne?(U=(0,Z.jsxs)(`div`,{children:[V,ne]}),t[53]=V,t[54]=ne,t[55]=U):U=t[55];let W;t[56]===c.inputTypes?W=t[57]:(W=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.inputTypes}),t[56]=c.inputTypes,t[57]=W);let G;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(G=We(),t[58]=G):G=t[58];let re;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>h(`input`,se(e.target.value)),t[59]=re):re=t[59];let ie;t[60]===c?ie=t[61]:(ie=Pe.map(e=>(0,Z.jsx)(q,{value:e.value,children:c[e.labelKey]},e.value)),t[60]=c,t[61]=ie);let ae;t[62]!==S||t[63]!==ie?(ae=(0,Z.jsx)(J,{className:G,value:S,onChange:re,children:ie}),t[62]=S,t[63]=ie,t[64]=ae):ae=t[64];let oe;t[65]!==W||t[66]!==ae?(oe=(0,Z.jsxs)(`div`,{children:[W,ae]}),t[65]=W,t[66]=ae,t[67]=oe):oe=t[67];let ce=u.reasoning||!1,le;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>h(`reasoning`,e.target.checked),t[68]=le):le=t[68];let ue;t[69]===ce?ue=t[70]:(ue=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:ce,onChange:le}),t[69]=ce,t[70]=ue);let de;t[71]!==c.reasoning||t[72]!==ue?(de=(0,Z.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ue,c.reasoning]}),t[71]=c.reasoning,t[72]=ue,t[73]=de):de=t[73];let fe;t[74]!==oe||t[75]!==de?(fe=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[oe,de]}),t[74]=oe,t[75]=de,t[76]=fe):fe=t[76];let pe;t[77]===c.contextWindow?pe=t[78]:(pe=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.contextWindow}),t[77]=c.contextWindow,t[78]=pe);let he;t[79]===f?he=t[80]:(he=o(be(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=he);let ge=u.contextWindow??128e3,_e;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>h(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=_e):_e=t[81];let ve;t[82]!==he||t[83]!==ge?(ve=(0,Z.jsx)(`input`,{type:`number`,min:1,className:he,value:ge,onChange:_e}),t[82]=he,t[83]=ge,t[84]=ve):ve=t[84];let ye;t[85]===f?ye=t[86]:(ye=f.has(`contextWindow`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=ye);let xe;t[87]!==pe||t[88]!==ve||t[89]!==ye?(xe=(0,Z.jsxs)(`div`,{children:[pe,ve,ye]}),t[87]=pe,t[88]=ve,t[89]=ye,t[90]=xe):xe=t[90];let Se;t[91]===c.maxOutputTokens?Se=t[92]:(Se=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.maxOutputTokens}),t[91]=c.maxOutputTokens,t[92]=Se);let we;t[93]===f?we=t[94]:(we=o(be(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=we);let Te=u.maxTokens??16384,Ee;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>h(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=Ee):Ee=t[95];let De;t[96]!==we||t[97]!==Te?(De=(0,Z.jsx)(`input`,{type:`number`,min:1,className:we,value:Te,onChange:Ee}),t[96]=we,t[97]=Te,t[98]=De):De=t[98];let Oe;t[99]===f?Oe=t[100]:(Oe=f.has(`maxTokens`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=Oe);let ke;t[101]!==Se||t[102]!==De||t[103]!==Oe?(ke=(0,Z.jsxs)(`div`,{children:[Se,De,Oe]}),t[101]=Se,t[102]=De,t[103]=Oe,t[104]=ke):ke=t[104];let Ae;t[105]!==xe||t[106]!==ke?(Ae=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[xe,ke]}),t[105]=xe,t[106]=ke,t[107]=Ae):Ae=t[107];let je;t[108]===c.costSection?je=t[109]:(je=(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:c.costSection}),t[108]=c.costSection,t[109]=je);let Me;t[110]===c.costInput?Me=t[111]:(Me=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costInput}),t[110]=c.costInput,t[111]=Me);let Ne;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=be(),t[112]=Ne):Ne=t[112];let Fe=u.cost?.input??0,Le;t[113]===u.cost?Le=t[114]:(Le=e=>h(`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[113]=u.cost,t[114]=Le);let Re;t[115]!==Fe||t[116]!==Le?(Re=(0,Z.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ne,value:Fe,onChange:Le}),t[115]=Fe,t[116]=Le,t[117]=Re):Re=t[117];let ze;t[118]!==Me||t[119]!==Re?(ze=(0,Z.jsxs)(`div`,{children:[Me,Re]}),t[118]=Me,t[119]=Re,t[120]=ze):ze=t[120];let Ve;t[121]===c.costOutput?Ve=t[122]:(Ve=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costOutput}),t[121]=c.costOutput,t[122]=Ve);let He;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(He=be(),t[123]=He):He=t[123];let Ue=u.cost?.output??0,Ke;t[124]===u.cost?Ke=t[125]:(Ke=e=>h(`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[124]=u.cost,t[125]=Ke);let qe;t[126]!==Ue||t[127]!==Ke?(qe=(0,Z.jsx)(`input`,{type:`number`,step:`any`,min:0,className:He,value:Ue,onChange:Ke}),t[126]=Ue,t[127]=Ke,t[128]=qe):qe=t[128];let Je;t[129]!==Ve||t[130]!==qe?(Je=(0,Z.jsxs)(`div`,{children:[Ve,qe]}),t[129]=Ve,t[130]=qe,t[131]=Je):Je=t[131];let Ye;t[132]!==ze||t[133]!==Je?(Ye=(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[ze,Je]}),t[132]=ze,t[133]=Je,t[134]=Ye):Ye=t[134];let Xe;t[135]!==je||t[136]!==Ye?(Xe=(0,Z.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[je,Ye]}),t[135]=je,t[136]=Ye,t[137]=Xe):Xe=t[137];let Ze;t[138]!==B||t[139]!==U||t[140]!==fe||t[141]!==Ae||t[142]!==Xe?(Ze=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[B,U,fe,Ae,Xe]}),t[138]=B,t[139]=U,t[140]=fe,t[141]=Ae,t[142]=Xe,t[143]=Ze):Ze=t[143];let Qe;t[144]===c.cancel?Qe=t[145]:(Qe=(0,Z.jsx)(Ce,{asChild:!0,children:(0,Z.jsx)(K,{type:`button`,variant:`secondary`,children:c.cancel})}),t[144]=c.cancel,t[145]=Qe);let $e=r?c.addModelConfirm:c.saveModelConfirm,et;t[146]!==y||t[147]!==$e?(et=(0,Z.jsx)(K,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:y,children:$e}),t[146]=y,t[147]=$e,t[148]=et):et=t[148];let tt;t[149]!==Qe||t[150]!==et?(tt=(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Qe,et]}),t[149]=Qe,t[150]=et,t[151]=tt):tt=t[151];let nt;return t[152]!==j||t[153]!==Ze||t[154]!==tt?(nt=(0,Z.jsxs)(Z.Fragment,{children:[j,Ze,tt]}),t[152]=j,t[153]=Ze,t[154]=tt,t[155]=nt):nt=t[155],nt}function $n(){return new Map}function er(e){let t=(0,Y.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:s,onSave:c,m:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Re,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,g)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=o(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,H,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=d):d=t[1];let f;t[2]!==s||t[3]!==l||t[4]!==a||t[5]!==r||t[6]!==c||t[7]!==n||t[8]!==i?(f=n?(0,Z.jsx)(Qn,{model:a,isNew:s,providerId:i,onSave:c,onClose:()=>r(!1),m:l},`${i??`none`}-${a?.id??`new`}`):null,t[2]=s,t[3]=l,t[4]=a,t[5]=r,t[6]=c,t[7]=n,t[8]=i,t[9]=f):f=t[9];let p;t[10]===f?p=t[11]:(p=(0,Z.jsxs)(he,{children:[u,(0,Z.jsx)(ue,{className:d,onOpenAutoFocus:tr,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,Z.jsx)(Me,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function tr(e){return e.preventDefault()}function nr(e){let t=(0,Y.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>I(n).then(rr),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,Z.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,Z.jsx)(F,{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,Z.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 rr(e){return e.apiKey??null}function ir(e){let t=(0,Y.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:s,customConfig:c,allModels:l,labels:u,language:d,onSaved:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(Re,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,g)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=o(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,H),t[1]=m):m=t[1];let h;t[2]!==l||t[3]!==s||t[4]!==c||t[5]!==a||t[6]!==u||t[7]!==d||t[8]!==r||t[9]!==f||t[10]!==i?(h=(0,Z.jsxs)(he,{children:[p,(0,Z.jsx)(ue,{className:m,children:a?(0,Z.jsx)(or,{providerId:i,customConfig:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,Z.jsx)(ar,{providerId:i,builtinRows:s,allModels:l,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=l,t[3]=s,t[4]=c,t[5]=a,t[6]=u,t[7]=d,t[8]=r,t[9]=f,t[10]=i,t[11]=h):h=t[11];let _;return t[12]!==r||t[13]!==n||t[14]!==h?(_=(0,Z.jsx)(Me,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=_):_=t[15],_}function ar({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:c,onSaved:l}){let u=t.find(t=>t.id===e),d=R[e],f=n.filter(t=>t.provider===e),[p,m]=(0,X.useState)(u?.apiKey??``),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(!1),[y,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(!1),T=s(i).providersSettings,E=u?.supportsApiKey!==!1,D=u?.supportsOAuth===!0,k=u?.authMode===`oauth`&&u.authStatus===`connected`,A=u?.configured===!0&&u.activeKeySource!==`env`&&u.activeKeySource!==`extension`&&u.activeKeySource!==`models_json`,[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),[F,I]=(0,X.useState)(`idle`),[L,z]=(0,X.useState)(null),[V,ee]=(0,X.useState)(null),[H,U]=(0,X.useState)(``),G=F===`waiting`||F===`waiting_code`,re=(0,X.useMemo)(()=>w(e,i),[e,i]),ie=p!==(u?.apiKey??``),oe=async()=>{let t=p.trim();if(!(!t||!E||Ue(t))){g(!0),x(null);try{await b({[e]:t}),v(!0),window.setTimeout(()=>{l(),c()},600)}catch(e){x(e instanceof Error?e.message:r.saveError)}finally{g(!1)}}};(0,X.useEffect)(()=>{if(!j||!G)return;let e=window.setInterval(()=>{(async()=>{try{let t=await Rn(j);t.status===`waiting_auth`||t.status===`waiting_code`?(I(t.status===`waiting_code`?`waiting_code`:`waiting`),P(t.message??null),z(t.authUrl??null),ee(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),I(`success`),P(t.message??T.saved),window.setTimeout(()=>{l(),c()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),I(`error`),P(t.error??t.message??T.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[j,G,c,l,T.revokeFailed,T.saved]),(0,X.useEffect)(()=>()=>{j&&Vn(j).catch(()=>{})},[j]);let se=async()=>{try{await te(e),l(),c()}catch{}},ce=async()=>{I(`waiting`),P(T.oauthStarting),x(null);try{M((await Ln(e)).sessionId)}catch(e){I(`error`),P(e instanceof Error?e.message:T.revokeFailed)}},le=async()=>{if(j){try{await Bn(j)}catch{}I(`idle`),P(null),M(null),z(null),ee(null)}},ue=async()=>{if(!(!j||!H.trim()))try{await zn(j,H.trim()),U(``),P(T.oauthProcessingCode)}catch(e){I(`error`),P(e instanceof Error?e.message:T.revokeFailed)}},pe=async()=>{try{await Hn(e),l(),c()}catch(e){x(e instanceof Error?e.message:T.revokeFailed)}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(Be,{className:`text-base font-semibold text-fg`,children:u?.name??e}),(0,Z.jsx)(Ce,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.press),children:(0,Z.jsx)(Ie,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[d?.description?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.description}):null,u?.baseUrl?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,Z.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:u.baseUrl})]}):u?.category===`extension`?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,E?(0,Z.jsx)(nr,{providerId:e,inputId:`manage-api-key`,value:p,onChange:e=>{m(e),v(!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}}):u?.category===`extension`?(0,Z.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,Z.jsx)(`p`,{children:r.extensionKeyHint}),u?.extensionId?(0,Z.jsxs)(a,{to:`/settings/ext/${encodeURIComponent(u.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:c,children:[r.openExtensionSettings,(0,Z.jsx)(ae,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,D?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:T.oauth}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:k?T.sourceOauth:T.oauthHint})]}),k?(0,Z.jsx)(K,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void pe(),children:T.revoke}):(0,Z.jsxs)(K,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:G,onClick:()=>void ce(),children:[G?(0,Z.jsx)(ge,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(Ae,{className:`size-3.5`,"aria-hidden":!0}),T.oauth]})]}),N?(0,Z.jsx)(`p`,{className:o(`text-xs`,F===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:N}):null,F===`waiting`||F===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[L?(0,Z.jsxs)(`a`,{href:L,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-white hover:bg-accent-hover`,children:[(0,Z.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),T.openAuthPage]}):null,(0,Z.jsx)(K,{type:`button`,variant:`secondary`,onClick:()=>void le(),children:T.cancelOAuth})]}):null,V?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:V}):null,F===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(`input`,{type:`text`,value:H,onChange:e=>U(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ue(),placeholder:T.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`,W)}),(0,Z.jsx)(K,{type:`button`,variant:`primary`,onClick:()=>void ue(),children:T.submitCode})]}):null]}):null,re.length>0&&E?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:re.map(({kind:e,href:t})=>(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[O(e,r),(0,Z.jsx)(ae,{className:`size-3`,"aria-hidden":!0})]},e))}):null,f.length>0?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,f.length,`)`]}),(0,Z.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,Z.jsx)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:e.id.includes(`/`)?e.id.split(`/`).pop():e.id},e.id))})})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),y?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[A?(0,Z.jsxs)(K,{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:()=>C(!0),children:[(0,Z.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:E&&ie&&!Ue(p.trim())?(0,Z.jsx)(K,{type:`button`,variant:`primary`,disabled:!p.trim()||h||_,onClick:()=>void oe(),children:_?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(fe,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):h?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ge,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,Z.jsx)(ne,{open:S,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,u?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void se(),onCancel:()=>C(!1)})]})}function or({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let c=s(r).modelsSettings,l=t?.providers[e],[u,d]=(0,X.useState)(l?.baseUrl??``),[f,p]=(0,X.useState)(l?.apiKey??``),[m,h]=(0,X.useState)(l?.models??[]),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(!1),[D,O]=(0,X.useState)(null),A=n=>{if(!t)return null;let r=f.trim(),i={...l,baseUrl:u.trim()||void 0,apiKey:Ue(r)?l?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},j=async()=>{let e=A({models:m});if(e){_(!0),y(null);try{await ye(e),a(),i()}catch(e){y(e instanceof Error?e.message:n.saveError)}finally{_(!1)}}},M=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await ye({providers:r}),a(),i()}catch{}},N=(e,t)=>{O({model:e,isNew:t}),T(!0)},P=async e=>{if(!D)return;let t=D.isNew?[...m,e]:m.map(t=>t.id===e.id?e:t);h(t);let r=A({models:t});if(r)try{await ye(r),a()}catch(e){y(e instanceof Error?e.message:n.saveError)}},F=async e=>{let t=m.filter(t=>t.id!==e);h(t),C(null);let r=A({models:t});if(r)try{await ye(r),a()}catch(e){y(e instanceof Error?e.message:n.saveError)}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Be,{className:`text-base font-semibold text-fg`,children:e}),(0,Z.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,Z.jsx)(Ce,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.press),children:(0,Z.jsx)(Ie,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,Z.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:u,onChange:e=>d(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`,W)})]}),(0,Z.jsx)(nr,{providerId:e,inputId:`manage-custom-api-key`,value:f,onChange:p,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,Z.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[c.modelsSection,m.length>0?` (${m.length})`:``]}),(0,Z.jsxs)(K,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>N(null,!0),children:[(0,Z.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),c.addModel]})]}),m.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.modelsEmpty}):(0,Z.jsx)(`ul`,{className:`space-y-2`,children:m.map(e=>(0,Z.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,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,Z.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.press),onClick:()=>N(e,!1),"aria-label":c.editModel,children:(0,Z.jsx)(k,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.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`,B.press),onClick:()=>C(e.id),"aria-label":c.removeModel,children:(0,Z.jsx)(de,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),v?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,Z.jsxs)(K,{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:()=>x(!0),children:[(0,Z.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(K,{type:`button`,variant:`primary`,disabled:g,onClick:()=>void j(),children:g?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ge,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,Z.jsx)(ne,{open:b,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void M(),onCancel:()=>x(!1)}),(0,Z.jsx)(ne,{open:S!==null,title:c.removeModel,description:c.removeModelConfirm.replace(`{{id}}`,S??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{S&&F(S)},onCancel:()=>C(null)}),(0,Z.jsx)(er,{open:w,onOpenChange:e=>{T(e),e||O(null)},providerId:e,model:D?.model??null,isNew:D?.isNew??!1,onSave:e=>void P(e),m:c})]})}var sr=[`services`,`image-models`,`voice`,`search`];function cr(e){let t=(e??``).trim();return t===`providers`||t===`catalog`?`services`:sr.includes(t)?t:`services`}function lr(){let e=(0,Y.c)(59),t=f(dr),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n,a=r.modelsHub,[o,c]=i(),l;e[2]===o?l=e[3]:(l=cr(o.get(`tab`)),e[2]=o,e[3]=l);let u=l,[d,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),g=Dn(),_;e[4]!==a.servicesHint||e[5]!==a.tabs.services?(_={id:`services`,icon:G,label:a.tabs.services,hint:a.servicesHint},e[4]=a.servicesHint,e[5]=a.tabs.services,e[6]=_):_=e[6];let v;e[7]!==a.imageModelsHint||e[8]!==a.tabs.imageModels?(v={id:`image-models`,icon:De,label:a.tabs.imageModels,hint:a.imageModelsHint},e[7]=a.imageModelsHint,e[8]=a.tabs.imageModels,e[9]=v):v=e[9];let y;e[10]!==a.tabs.voice||e[11]!==a.voiceHint?(y={id:`voice`,icon:le,label:a.tabs.voice,hint:a.voiceHint},e[10]=a.tabs.voice,e[11]=a.voiceHint,e[12]=y):y=e[12];let b;e[13]!==a.searchHint||e[14]!==a.tabs.search?(b={id:`search`,icon:ke,label:a.tabs.search,hint:a.searchHint},e[13]=a.searchHint,e[14]=a.tabs.search,e[15]=b):b=e[15];let x;e[16]!==_||e[17]!==v||e[18]!==y||e[19]!==b?(x=[_,v,y,b],e[16]=_,e[17]=v,e[18]=y,e[19]=b,e[20]=x):x=e[20];let S=x,C;e[21]===c?C=e[22]:(C=e=>{c(t=>{let n=new URLSearchParams(t);return e===`services`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[21]=c,e[22]=C);let w=C,T=ur,E=r.settingsSections.credentials,D=a.subtitle,O;e[23]===t?O=e[24]:(O=Fe(t,`configuration`),e[23]=t,e[24]=O);let k;e[25]!==a.docsLink||e[26]!==a.subtitle||e[27]!==r.settingsSections.credentials||e[28]!==O?(k=(0,Z.jsx)(Ke,{title:E,subtitle:D,docsLink:O,docsLabel:a.docsLink}),e[25]=a.docsLink,e[26]=a.subtitle,e[27]=r.settingsSections.credentials,e[28]=O,e[29]=k):k=e[29];let A;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(ft,{}),e[30]=A):A=e[30];let j;e[31]!==u||e[32]!==a.tabsAria||e[33]!==w||e[34]!==S?(j=(0,Z.jsx)(ut,{items:S,activeTab:u,onChange:w,ariaLabel:a.tabsAria,tabIdPrefix:`hub-tab`,panelIdPrefix:`hub-panel`}),e[31]=u,e[32]=a.tabsAria,e[33]=w,e[34]=S,e[35]=j):j=e[35];let M;e[36]!==u||e[37]!==a.connectedProviders||e[38]!==S?(M=S.map(e=>(0,Z.jsx)(pr,{id:e.id,activeTab:u,hint:e.hint,children:e.id===`services`?(0,Z.jsx)(Nn,{labels:a.connectedProviders,onAdd:()=>p(!0),onManage:(e,t)=>h({providerId:e,isCustom:t})}):(0,Z.jsx)(fr,{tab:e.id})},e.id)),e[36]=u,e[37]=a.connectedProviders,e[38]=S,e[39]=M):M=e[39];let N;e[40]!==d||e[41]!==a.addProviderDialog||e[42]!==t||e[43]!==g.builtinRows||e[44]!==g.customConfig?(N=(0,Z.jsx)(Gn,{open:d,onOpenChange:p,builtinRows:g.builtinRows,customConfig:g.customConfig,labels:a.addProviderDialog,language:t,onSaved:T}),e[40]=d,e[41]=a.addProviderDialog,e[42]=t,e[43]=g.builtinRows,e[44]=g.customConfig,e[45]=N):N=e[45];let P;e[46]!==a.manageProviderDialog||e[47]!==t||e[48]!==m||e[49]!==g.allModels||e[50]!==g.builtinRows||e[51]!==g.customConfig?(P=m?(0,Z.jsx)(ir,{open:!0,onOpenChange:e=>{e||h(null)},providerId:m.providerId,isCustom:m.isCustom,builtinRows:g.builtinRows,customConfig:g.customConfig,allModels:g.allModels,labels:a.manageProviderDialog,language:t,onSaved:T}):null,e[46]=a.manageProviderDialog,e[47]=t,e[48]=m,e[49]=g.allModels,e[50]=g.builtinRows,e[51]=g.customConfig,e[52]=P):P=e[52];let F;return e[53]!==k||e[54]!==j||e[55]!==M||e[56]!==N||e[57]!==P?(F=(0,Z.jsxs)(qe,{children:[k,A,j,M,N,P]}),e[53]=k,e[54]=j,e[55]=M,e[56]=N,e[57]=P,e[58]=F):F=e[58],F}function ur(){m()}function dr(e){return e.language}function fr(e){let t=(0,Y.c)(3),{tab:n}=e;switch(n){case`services`:return null;case`image-models`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(At,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(nn,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(wn,{}),t[2]=e):e=t[2],e}}}function pr({id:e,activeTab:t,hint:n,children:r}){let i=e===t,a=(0,X.useRef)(i);return i&&(a.current=!0),a.current?(0,Z.jsxs)(`div`,{role:`tabpanel`,id:`hub-panel-${e}`,"aria-labelledby":`hub-tab-${e}`,hidden:!i,className:o(`min-w-0 rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,i?`flex flex-col gap-3`:void 0),children:[i?(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{lr as ModelsHubPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{u as n}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as r}from"./notes-workbench-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{u as n}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as r}from"./notes-workbench-CerZOeLW.js";var i=e(),a=t();function o(){let e=(0,i.c)(2),{noteId:t}=n(),o;return e[0]===t?o=e[1]:(o=(0,a.jsx)(r,{selectedNoteId:t,basePath:`/notes`,managePageHeader:!0,showLibrary:!0,allowMediaCapture:!0,listWidthStorageKey:`xopc.notes.listWidth`}),e[0]=t,e[1]=o),o}export{o as NotesPage};
|