@xopcai/xopc 0.0.170 → 0.0.172
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-CkUp1qvf.js → activity-store-C3Y-bESI.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DDuem4HM.js → agent-avatar-dicebear-CPyev9P7.js} +1 -1
- package/dist/gateway/static/root/assets/agents-Bf_kK2Ay.js +2 -0
- package/dist/gateway/static/root/assets/{api-BnuPQhJW.js → api-B7qEr_Rw.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DdZw8Hi1.js → app-management-settings-panel-Br_9-7fs.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BN8Vk2bX.js → appearance-settings-uyLcRPai.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-DXFCP5-1.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-C82MaDQj.js → archive-plugin-B19REnR5.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-uilrwSdW.js → attachment-load-DLWCC4Yi.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-CkDZjAmy.js → automation-suggestion-card-ky5S5lly.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-D8pT1o2O.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-B7NTL0_T.js → binary-plugins-CtPEzLlo.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-D_LDNlB-.js → block-editor-CQVR4Xij.js} +32 -32
- package/dist/gateway/static/root/assets/browser-settings-page-Bav_skKN.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-UFVUzn4v.js → browser-workflow-inputs-CimCGbhq.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CGgC0N92.js → browser-workflows-page-DewuCw3p.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BHaYYo9E.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-DUIorGUd.js → capability-presets-api-B5RTs-Az.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-PTz00nR4.js → capability-presets-settings-panel-BgchTh81.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-BYwSB8c6.js → channel-recipient-api-Czu0YzIZ.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-BP0e62wt.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-DBWKfeGe.js +1 -0
- package/dist/gateway/static/root/assets/connector-logo-Di3gnR_D.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-CC5kh0de.js +2 -0
- package/dist/gateway/static/root/assets/{desktop-pet-CkT98fPT.js → desktop-pet-D-ZUNHhn.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DkbIzdA3.js → desktop-pet-settings-C3L6AI8_.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-dBQvj1sG.js → directory-picker-path-field-Dvq4iG6P.js} +1 -1
- package/dist/gateway/static/root/assets/dreaming-settings-D9i54kWO.js +3 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-BfxoIiNo.js → extension-debug-page-BecQjU0J.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-EIJ3wIb7.js → extension-page-BeVkPSm-.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DBBec51N.js → extension-settings-page-DMoo2mKx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-4_u53Ufq.js → gateway-config-api-Bthb3_6v.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-v9kJM59H.js → gateway-settings-Bh8nPvJQ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CXITih5d.js → gateway-startup-retry-D3USVm9D.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-Dp0AyDHI.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-CNt7nrdS.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-D54YQPon.js → goals-config-api-C_2QWBtb.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-Bm_NZFiZ.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-DDezXaVi.js → goals-settings-DhL643tc.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-CRsIUeZN.js → heartbeat-settings-COVFwp7C.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-CY6cQUHL.js → image-generation-api-BNQlnwpU.js} +1 -1
- package/dist/gateway/static/root/assets/index-C_XSKOH6.css +1 -0
- package/dist/gateway/static/root/assets/{index-Dfq2laZe.js → index-DUasAutC.js} +67 -67
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D9k7EDdY.js → keyboard-shortcuts-settings-DfdJRJVy.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-DZwkD1co.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-DbaiBolh.js → local-apps-page-BvCPOgoi.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Dqp9H2Uf.js → locale-store-BP0vD37A.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DoCY0Mm9.js → logs-page-dNL0Y1dA.js} +3 -3
- package/dist/gateway/static/root/assets/{markdown-split-BGlQR-Be.js → markdown-split-YO1rDk9m.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BpaeV6f_.js → media-plugins-CU_RRf-q.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BWtP5TFz.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-Cd2HpciM.js → notes-page-CeFiOK3S.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-B8MKxpZb.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-DyimBUp_.js → page-tabs-tiHmRJUA.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BKZulEYr.js → preview-open-alternatives-CU6XgaCz.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-Bjz9BxBY.js → product-open-page-Dn4_qor4.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CWBuuX-S.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BJSsLsXH.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-DXJDb8vB.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BPTqb2_r.js → save-bar-controls-edDUIbXo.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-YN0D81Dk.js → schedule-field-DqJO_5Yb.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BmY5PSS2.js → schema-form-CMh0jzy5.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-DeHpWgxM.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-Cf-TEYUd.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-B-RhgD_p.js → settings-form-section-Bb0Bc3nJ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DkPupX2B.js → settings-loading-skeleton-DQhADvz1.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-2QBMvaxj.js → settings-page-b0M5HukN.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-CtrW-LD6.js → settings-page-layout-hvjtIjvh.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BFyfed_g.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BezIW1n9.js → share-preview-page-rbeaOpTg.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CYnH9sTt.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-Cr8_m-jS.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-Chtc1xDO.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-WAFhKyAu.js → system-settings-panel-BHo_hgnL.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-BiC0gIBa.js → theme-store-C3KnnjcU.js} +1 -1
- package/dist/gateway/static/root/assets/time-picker-D-G-uwVJ.js +1 -0
- package/dist/gateway/static/root/assets/{typed-models-lib-WAQO3F_8.js → typed-models-lib-DtRnG-YI.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CKlfsSeU.js → use-channel-catalog-CWWItX2g.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-D7qMR26X.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-BAFHF0_v.js → voice-api-key-field-BTnltQHZ.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-CpqFZze9.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-t4dXpGC0.js +1 -0
- package/dist/gateway/static/root/assets/work-page-BXwDKiMZ.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-1OP4HyvS.js → workflow-run-setup-panel-D7vKChFZ.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-Bos9HyqT.js +11 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +71 -24
- package/dist/src/agent/embedded/run-turn.js +68 -4
- package/dist/src/agent/inbound/inbound-loop.d.ts +0 -2
- package/dist/src/agent/inbound/inbound-loop.js +0 -2
- package/dist/src/agent/memory/builtin-provider.js +4 -4
- package/dist/src/agent/memory/compaction-planner.d.ts +16 -0
- package/dist/src/agent/memory/compaction-planner.js +152 -0
- package/dist/src/agent/memory/compaction-policy.d.ts +10 -0
- package/dist/src/agent/memory/compaction-policy.js +24 -0
- package/dist/src/agent/memory/compaction.d.ts +21 -22
- package/dist/src/agent/memory/compaction.js +220 -194
- package/dist/src/agent/memory/context-budget.d.ts +40 -0
- package/dist/src/agent/memory/context-budget.js +106 -0
- package/dist/src/agent/memory/manager.d.ts +4 -1
- package/dist/src/agent/memory/manager.js +8 -3
- package/dist/src/agent/memory/understanding/service.d.ts +2 -0
- package/dist/src/agent/memory/understanding/service.js +11 -9
- package/dist/src/agent/orchestration/context-overflow.d.ts +1 -0
- package/dist/src/agent/orchestration/context-overflow.js +19 -0
- package/dist/src/agent/orchestration/loop-guard.js +13 -9
- package/dist/src/agent/reply/post-compaction-context.d.ts +4 -0
- package/dist/src/agent/reply/post-compaction-context.js +5 -3
- package/dist/src/agent/service/process-direct-one-shot.js +1 -2
- package/dist/src/agent/service/process-direct-streaming.js +1 -2
- package/dist/src/agent/service.d.ts +1 -2
- package/dist/src/agent/service.js +16 -44
- package/dist/src/agent/session/session-inspector.js +10 -2
- package/dist/src/automations/domain/validation.d.ts +8 -8
- package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/schema.d.ts +17 -1
- package/dist/src/connectors/composio-sessions.d.ts +1 -0
- package/dist/src/connectors/composio-sessions.js +14 -5
- package/dist/src/connectors/composio-triggers.d.ts +1 -1
- package/dist/src/connectors/composio-triggers.js +4 -3
- package/dist/src/connectors/composio.js +1 -0
- package/dist/src/connectors/{connector-memory-sync.d.ts → connected-source-ingestion.d.ts} +11 -4
- package/dist/src/connectors/{connector-memory-sync.js → connected-source-ingestion.js} +49 -101
- package/dist/src/connectors/connected-source-normalizers.d.ts +15 -0
- package/dist/src/connectors/connected-source-normalizers.js +186 -0
- package/dist/src/connectors/connector-identity.d.ts +2 -0
- package/dist/src/connectors/connector-identity.js +29 -0
- package/dist/src/connectors/learning-coordinator.d.ts +25 -0
- package/dist/src/connectors/learning-coordinator.js +214 -0
- package/dist/src/connectors/learning-recipes.d.ts +22 -0
- package/dist/src/connectors/learning-recipes.js +121 -0
- package/dist/src/connectors/runtime-status.d.ts +1 -8
- package/dist/src/connectors/runtime-status.js +4 -29
- package/dist/src/gateway/hono/lib/config-payload.d.ts +23 -0
- package/dist/src/gateway/hono/lib/config-payload.js +3 -0
- package/dist/src/gateway/hono/routes/config-patch/misc.d.ts +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +28 -0
- package/dist/src/gateway/hono/routes/connectors.js +76 -118
- package/dist/src/gateway/hono/routes/models.js +24 -0
- package/dist/src/gateway/hono/routes/public-gateway.js +3 -2
- package/dist/src/gateway/hono/routes/sessions.js +17 -42
- package/dist/src/gateway/hono/routes/you.js +86 -5
- package/dist/src/gateway/service/sessions-api.d.ts +2 -3
- package/dist/src/gateway/service/sessions-api.js +4 -7
- package/dist/src/gateway/service.d.ts +5 -2
- package/dist/src/gateway/service.js +16 -11
- package/dist/src/knowledge/connected-understanding-pipeline.d.ts +19 -0
- package/dist/src/knowledge/connected-understanding-pipeline.js +268 -0
- package/dist/src/knowledge/index.d.ts +1 -0
- package/dist/src/knowledge/index.js +2 -1
- package/dist/src/knowledge/ingestion-service.d.ts +6 -4
- package/dist/src/knowledge/ingestion-service.js +13 -10
- package/dist/src/knowledge/local-folder-adapter.js +1 -0
- package/dist/src/knowledge/people-graph.js +43 -110
- package/dist/src/knowledge/types.d.ts +3 -0
- package/dist/src/providers/xopc-cloud-account-service.d.ts +40 -0
- package/dist/src/providers/xopc-cloud-account-service.js +65 -0
- package/dist/src/session/index.d.ts +1 -2
- package/dist/src/session/index.js +1 -2
- package/dist/src/session/init-session-turn.d.ts +0 -1
- package/dist/src/session/init-session-turn.js +1 -2
- package/dist/src/session/manager.d.ts +11 -17
- package/dist/src/session/manager.js +11 -14
- package/dist/src/session/session-context-for-llm.d.ts +19 -1
- package/dist/src/session/session-context-for-llm.js +87 -129
- package/dist/src/session/store.d.ts +28 -23
- package/dist/src/session/store.js +94 -83
- package/dist/src/session/transcript-format.d.ts +2 -8
- package/dist/src/session/types.d.ts +8 -6
- package/dist/src/session/user-round-delete.d.ts +3 -6
- package/dist/src/session/user-round-delete.js +12 -16
- package/dist/src/storage/sqlite/connector-learning-repository.d.ts +47 -0
- package/dist/src/storage/sqlite/connector-learning-repository.js +110 -0
- package/dist/src/storage/sqlite/index.d.ts +4 -2
- package/dist/src/storage/sqlite/index.js +5 -3
- package/dist/src/storage/sqlite/knowledge-repository.d.ts +4 -2
- package/dist/src/storage/sqlite/knowledge-repository.js +24 -13
- package/dist/src/storage/sqlite/migrations/060_remove_runtime_transcript_messages.sql +45 -0
- package/dist/src/storage/sqlite/migrations/061_drop_compaction_checkpoints.sql +2 -0
- package/dist/src/storage/sqlite/migrations/062_connector_learning_jobs.sql +27 -0
- package/dist/src/storage/sqlite/migrations/063_knowledge_collection_scopes.sql +14 -0
- package/dist/src/storage/sqlite/migrations/064_user_claims.sql +60 -0
- package/dist/src/storage/sqlite/migrations/065_knowledge_item_scope_identity.sql +116 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +0 -19
- package/dist/src/storage/sqlite/transcript-repository.d.ts +6 -11
- package/dist/src/storage/sqlite/transcript-repository.js +90 -84
- package/dist/src/storage/sqlite/user-claims-repository.d.ts +101 -0
- package/dist/src/storage/sqlite/user-claims-repository.js +241 -0
- package/dist/src/user-context/config.d.ts +67 -2
- package/dist/src/user-context/config.js +36 -3
- package/dist/src/user-context/projection.d.ts +36 -1
- package/dist/src/user-context/projection.js +84 -6
- package/dist/src/work-discovery/service.js +1 -0
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-BiaQhiQp.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-CuL8Q4yF.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-TZOluRNp.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-C-l6O68Z.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BW8c0xPp.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-h9CsE0GT.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-C058Mcfr.js +0 -1
- package/dist/gateway/static/root/assets/connector-logo-CsbegNqi.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BWALafGW.js +0 -2
- package/dist/gateway/static/root/assets/dreaming-settings-DkdnKMZx.js +0 -3
- package/dist/gateway/static/root/assets/goal-create-dialog-y2Y3p7_k.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DuzL-alv.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-OeLtfKI2.js +0 -2
- package/dist/gateway/static/root/assets/index-o4uaOGKT.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-3ssYIEK6.js +0 -2
- package/dist/gateway/static/root/assets/messages-KEk-hTFt.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-CatZNAPc.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-DJUOgqm4.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BQQAD_nu.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-fIGXTTnA.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BuU-8FCe.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DlKoeZm3.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BSUcDFnb.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-Bk2-SwGJ.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-e_Fx1kVC.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-D_cCADfj.js +0 -2
- package/dist/gateway/static/root/assets/time-picker-fqRXpNJV.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-9Ov4htPW.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-DGN2FxWv.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-HmyWSgUo.js +0 -1
- package/dist/gateway/static/root/assets/work-page-D3iKVjFq.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-B5L4SFw4.js +0 -11
- package/dist/src/agent/lifecycle/handlers/compaction.d.ts +0 -13
- package/dist/src/agent/lifecycle/handlers/compaction.js +0 -18
- package/dist/src/connectors/memory-sync-coordinator.d.ts +0 -28
- package/dist/src/connectors/memory-sync-coordinator.js +0 -162
- package/dist/src/connectors/memory-sync-profile.d.ts +0 -13
- package/dist/src/connectors/memory-sync-profile.js +0 -73
- package/dist/src/session/compaction-checkpoints.d.ts +0 -8
- package/dist/src/session/compaction-checkpoints.js +0 -19
|
@@ -0,0 +1,7 @@
|
|
|
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,f as a,l as o,r as s,t as c}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as l}from"./cn-JdwAhgNB.js";import{t as u}from"./messages-BWtP5TFz.js";import{l as d,n as f,o as p,r as m,s as h}from"./locale-store-BP0vD37A.js";import{i as g}from"./vendor-swr-BIWyz7Rc.js";import{$o as _,An as v,Bc as y,Bn as b,Bt as x,Cn as S,Cs as C,Dc as w,Dn as T,Ds as E,En as D,Es as O,Fc as k,Fn as A,Fu as j,Gn as M,Go as N,Gr as P,Hs as F,Ic as I,In as L,Jl as R,Jn as z,Jo as B,Kn as V,Ko as H,Ln as ee,Ls as te,Mn as ne,Ms as re,Mt as U,Nl as ie,Nn as W,Ns as G,Nu as K,On as ae,Os as q,Pc as oe,Pn as se,Ps as J,Qc as ce,Qn as le,Qo as ue,Rn as de,Rr as fe,Sn as pe,Ss as me,Tn as he,Ts as ge,Un as _e,Vn as ve,Vs as ye,Vt as be,Wn as xe,Wo as Se,Xn as Ce,Xo as we,Xs as Te,Yn as Ee,Yo as De,Ys as Oe,Zn as ke,_c as Ae,_u as je,al as Y,au as Me,bc as Ne,bl as Pe,bn as Fe,fc as Ie,hs as Le,io as Re,jn as ze,js as Be,jt as Ve,kn as He,ls as X,ms as Ue,no as We,nr as Ge,ns as Ke,os as qe,ql as Je,qn as Ye,qo as Xe,rl as Ze,ro as Qe,sc as $e,ss as et,ts as tt,wl as nt,wn as rt,xn as it,yu as at,zn as ot,zt as st}from"./index-DUasAutC.js";import{n as ct,r as lt}from"./settings-page-layout-hvjtIjvh.js";import{t as ut}from"./settings-loading-skeleton-DQhADvz1.js";import{c as dt,d as ft,i as pt,l as mt,n as ht,o as gt,r as _t,s as vt,t as yt,u as bt}from"./voice-api-key-field-BTnltQHZ.js";import{t as xt}from"./settings-advanced-gate-Cf-TEYUd.js";import{n as St,t as Ct}from"./settings-form-section-Bb0Bc3nJ.js";import{t as wt}from"./page-tabs-tiHmRJUA.js";import{a as Tt,i as Et,n as Dt,o as Ot,r as kt,t as At}from"./image-generation-api-BNQlnwpU.js";import{n as jt,r as Mt,t as Nt}from"./save-bar-controls-edDUIbXo.js";var Z=n(),Q=e(t(),1),$=r(),Pt={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},Ft=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function It(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function Lt(e){let t=e.split(`
|
|
2
|
+
`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function Rt({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=Pt[i],[s,c]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`bearer`),[g,_]=(0,Q.useState)(`x-api-key`),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(`/images/generations`),[E,D]=(0,Q.useState)(`/images/edits`),[k,A]=(0,Q.useState)(``),[M,P]=(0,Q.useState)(``),[F,I]=(0,Q.useState)([It()]),[L,R]=(0,Q.useState)(``),[z,V]=(0,Q.useState)(),[ee,ne]=(0,Q.useState)(!1),[re,U]=(0,Q.useState)(),[ie,W]=(0,Q.useState)();(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),d(t?.name??``),p(n?.baseUrl??``),h(t?.auth.type??`bearer`),_(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),y(r?`••••••••••••`:``),x(t?.apiKeyUrl??``),C(t?.documentationUrl??``),T(t?.paths?.generations??`/images/generations`),D(t?.paths?.edits??`/images/edits`),A(t?.network?.allowedHosts.join(`
|
|
3
|
+
`)??``),P(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
4
|
+
`)),I(t?.models.map(It)??[It()]),R(t?.defaultModel??``),V(void 0),ne(!1),U(void 0),W(void 0)},[r,e,n]);let G=(0,Q.useMemo)(()=>F.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[F]),K=(e,t)=>{I(n=>n.map((n,r)=>r===e?{...n,...t}:n))},ae=()=>{let e=s.trim(),t=F.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!u.trim()||!f.trim()||t.some(e=>!e.id))throw Error(o.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(o.duplicateModels);let n=L||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=Lt(M)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:f.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:u.trim(),...S.trim()?{documentationUrl:S.trim()}:{},...b.trim()?{apiKeyUrl:b.trim()}:{},defaultModel:n,auth:m===`header`?{type:`header`,headerName:g.trim()}:{type:m},paths:{...w.trim()?{generations:w.trim()}:{},...E.trim()?{edits:E.trim()}:{}},...k.trim()?{network:{allowedHosts:k.split(`
|
|
5
|
+
`).map(e=>e.trim()).filter(Boolean)}}:{},models:t.map(e=>({...e.original,id:e.id,...e.name?{name:e.name}:{name:void 0},capabilities:{...e.original.capabilities,generate:{...e.original.capabilities.generate,maxCount:Math.max(1,Number.parseInt(e.maxCount,10)||1),supportsSize:e.supportsSize},edit:{...e.original.capabilities.edit,enabled:e.editEnabled}},defaults:{...e.original.defaults,...e.defaultCount?{count:Math.max(1,Number.parseInt(e.defaultCount,10)||1)}:{count:void 0},...e.defaultSize.trim()?{size:e.defaultSize.trim()}:{size:void 0},...e.outputFormat?{outputFormat:e.outputFormat}:{outputFormat:void 0}}}))}}}},q=async()=>{let e=ae();return await Et(e.providerId,e.input),m!==`none`&&v.trim()&&!O(v)&&await Tt(e.providerId,v.trim()),await a(e.providerId),e},se=async()=>{V(`save`),U(void 0);try{await q(),y(m===`none`?``:`••••••••••••`),ue({type:`success`,title:o.saved})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(void 0)}},ce=async()=>{V(`test`),U(void 0),W(void 0);try{let e=await q();W((await Ot(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),ue({type:`success`,title:o.testReady})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(void 0)}},le=async()=>{if(n){if(!ee){ne(!0);return}V(`delete`),U(void 0);try{await At(n.providerId),await a(),ue({type:`success`,title:o.deleted}),t(!1)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(void 0)}}};return(0,$.jsx)(Se,{open:e,onOpenChange:t,children:(0,$.jsxs)(De,{children:[(0,$.jsx)(B,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Le)}),(0,$.jsxs)(H,{className:l(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(88vh,760px)] w-[min(calc(100%-2rem),52rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover`,Ue),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(we,{className:`font-semibold text-fg`,children:n?o.editTitle:o.addTitle}),(0,$.jsx)(Xe,{className:`mt-1 text-sm text-fg-muted`,children:o.intro})]}),(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-muted hover:bg-surface-subtle hover:text-fg`,"aria-label":o.cancel,children:(0,$.jsx)(te,{className:`size-5`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.connection}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.providerId,(0,$.jsx)(`input`,{value:s,disabled:!!n,onChange:e=>c(e.target.value),placeholder:`my-image-service`,className:Ft}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.name,(0,$.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:`My Image Service`,className:Ft})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.baseUrl,(0,$.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`https://api.example.com/v1`,className:Ft})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.auth,(0,$.jsx)(qe,{value:m,options:[{value:`bearer`,label:o.bearer},{value:`header`,label:o.header},{value:`none`,label:o.none}],placeholder:o.auth,allowEmpty:!1,onChange:e=>h(e),triggerClassName:`mt-1.5`})]}),m===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.headerName,(0,$.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),className:Ft})]}):null]}),m===`none`?null:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-image-api-key`,className:`text-xs font-medium text-fg-muted`,children:o.apiKey}),b.trim()?(0,$.jsxs)(`a`,{href:b.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[o.openKeyPage,(0,$.jsx)(j,{className:`size-3.5`})]}):null]}),(0,$.jsx)(ge,{id:`custom-image-api-key`,value:v,onChange:e=>y(O(v)?e.replace(/^•+/,``):e),labels:{show:o.show,hide:o.hide,copy:o.copy,copied:o.copied},reveal:()=>Ye(s).then(e=>e.apiKey),loadFailedLabel:o.revealFailed,notInConfigFile:o.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:o.apiKeyHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.apiKeyUrl,(0,$.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:`https://…`,className:Ft})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.docsUrl,(0,$.jsx)(`input`,{value:S,onChange:e=>C(e.target.value),placeholder:`https://…`,className:Ft})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-subtle px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:o.paths}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.generationsPath,(0,$.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),className:Ft})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.editsPath,(0,$.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),className:Ft})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.allowedHosts,(0,$.jsx)(`textarea`,{value:k,onChange:e=>A(e.target.value),rows:2,placeholder:`127.0.0.1
|
|
6
|
+
image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.staticHeaders,(0,$.jsx)(`textarea`,{value:M,onChange:e=>P(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.staticHeadersHint})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.models}),(0,$.jsxs)(J,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>I(e=>[...e,It()]),children:[(0,$.jsx)(oe,{className:`size-4`}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.defaultModel,(0,$.jsx)(qe,{value:L||G[0]?.value||``,options:G,placeholder:o.defaultModel,allowEmpty:!1,onChange:R,triggerClassName:`mt-1.5 max-w-sm`})]}),F.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>K(t,{id:e.target.value}),placeholder:`image-1`,className:Ft})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>K(t,{name:e.target.value}),className:Ft})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>K(t,{maxCount:e.target.value}),className:Ft})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>K(t,{defaultCount:e.target.value}),className:Ft})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>K(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:Ft})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.format,(0,$.jsx)(qe,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:o.format,allowEmpty:!0,onChange:e=>K(t,{outputFormat:e}),triggerClassName:`mt-1.5`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.supportsSize,onChange:e=>K(t,{supportsSize:e.target.checked})}),o.supportsSize]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.editEnabled,onChange:e=>K(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:F.length===1,onClick:()=>I(e=>e.filter((e,n)=>n!==t)),className:`ml-auto inline-flex items-center gap-1 text-xs text-red-600 disabled:opacity-40 dark:text-red-400`,children:[(0,$.jsx)(Te,{className:`size-3.5`}),o.remove]})]})]},t))]}),ie?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(Je,{className:`size-4`}),o.testReady]}),(0,$.jsx)(`img`,{src:ie,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,re?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:re}):null]}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-5 py-3`,children:[n?(0,$.jsxs)(J,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!z,onClick:()=>void le(),children:[z===`delete`?(0,$.jsx)(Y,{className:`size-4 animate-spin`}):(0,$.jsx)(Te,{className:`size-4`}),ee?o.confirmDelete:o.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(J,{variant:`secondary`,children:o.cancel})}),(0,$.jsxs)(J,{variant:`secondary`,disabled:!!z,onClick:()=>void ce(),children:[z===`test`?(0,$.jsx)(Y,{className:`size-4 animate-spin`}):null,z===`test`?o.testing:o.test]}),(0,$.jsxs)(J,{variant:`primary`,disabled:!!z,onClick:()=>void se(),children:[z===`save`?(0,$.jsx)(Y,{className:`size-4 animate-spin`}):null,z===`save`?o.saving:o.save]})]})]})]})]})})}var zt=`••••••••••••`,Bt={en:{title:`Image generation`,intro:`Choose an agent and image model, or connect an OpenAI Images service of your own.`,agent:`Agent`,provider:`Provider`,model:`Model`,apiKey:`API key`,getApiKey:`Get API key`,apiKeyHint:`Stored in the local credential store, never in xopc.json.`,existingKey:`A credential or environment variable is already available. Leave this blank to reuse it.`,savedKey:`A credential is saved. Use the eye button to view it, or type a new key to replace it.`,revealFailed:`Unable to load the saved API key.`,keyNotRevealable:`This credential comes from an environment variable or another non-revealable source.`,region:`Service region`,cn:`China`,intl:`International`,advanced:`Custom endpoint`,baseUrl:`Base URL (optional)`,enable:`Enable image generation`,enabling:`Verifying and enabling…`,enabled:`Image generation is ready.`,addService:`Add image service`,manageService:`Manage service`,custom:`Custom`,current:`Current`,configured:`Credential ready`,needsKey:`API key required`,connect:`Connect to a gateway to continue.`,loadError:`Unable to load image generation settings.`,selectAgent:`Select an agent`,selectModel:`Select a model`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`},zh:{title:`图片生成`,intro:`为 Agent 选择图片模型,也可以连接你自己的 OpenAI Images 服务。`,agent:`Agent`,provider:`Provider`,model:`模型`,apiKey:`API Key`,getApiKey:`获取 API Key`,apiKeyHint:`密钥只保存在本机凭据存储中,不会写入 xopc.json。`,existingKey:`已有凭据或环境变量;留空即可继续使用。`,savedKey:`凭据已保存。点击眼睛可查看,直接输入新密钥可替换。`,revealFailed:`无法读取已保存的 API Key。`,keyNotRevealable:`当前凭据来自环境变量或其他不可查看的来源。`,region:`服务地域`,cn:`中国站`,intl:`国际站`,advanced:`自定义服务地址`,baseUrl:`Base URL(可选)`,enable:`启用图片生成`,enabling:`正在验证并启用…`,enabled:`图片生成已可用。`,addService:`添加图片服务`,manageService:`管理服务`,custom:`自定义`,current:`当前使用`,configured:`凭据已就绪`,needsKey:`需要 API Key`,connect:`请先连接网关。`,loadError:`无法加载图片生成设置。`,selectAgent:`选择 Agent`,selectModel:`选择模型`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`}};async function Vt(e){let t=await h(m(`/api/agents/${encodeURIComponent(e)}/image-generation`));if(!t.payload)throw Error(`Invalid agent image generation response`);return t.payload}function Ht(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function Ut(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function Wt(e,t){return e===`minimax`?t===`cn`?`minimax-cn`:`minimax`:e===`dashscope`?t===`cn`?`dashscope-cn`:`dashscope-intl`:e}function Gt(){let e=(0,Z.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Re,{className:`h-24 rounded-xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[t,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:5}).map(Kt)}),(0,$.jsx)(Re,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function Kt(e,t){return(0,$.jsx)(Re,{className:`h-24 rounded-xl`},t)}function qt(){let e=f(e=>e.language),t=Bt[e],n=u(e),r=!!d(e=>e.token),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[p,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(e===`zh`?`cn`:`intl`),[b,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(),[D,k]=(0,Q.useState)(!1),[A,M]=(0,Q.useState)(),{data:N,isLoading:F,error:I}=g(r?`image-generation-agents`:null,P,{revalidateOnFocus:!1}),{data:L,isLoading:R,error:z,mutate:B}=g(r?m(`/api/image-generation/catalog`):null,kt,{revalidateOnFocus:!1}),{data:V,isLoading:H,error:ee,mutate:te}=g(r?m(`/api/image-generation/custom-providers`):null,Dt,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{!N||i||a(N.defaultId||N.agents[0]?.id||``)},[i,N]);let{data:ne,isLoading:re,error:U,mutate:ie}=g(r&&i?[`agent-image-generation`,i]:null,()=>Vt(i),{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!L||!ne)return;let e=Ht(ne.model?.primary),t=L.find(t=>t.id===e)??L.find(e=>e.configured)??L[0];t&&(s(t.id),l(t.id===e&&Ut(ne.model?.primary)||t.defaultModel),_(t.configured?zt:``))},[ne,L]),(0,Q.useEffect)(()=>{E(void 0)},[i]);let W=L?.find(e=>e.id===o),G=W?W.apiKeyUrl??x(Wt(W.id,v),e)[0]?.href:void 0,K=(0,Q.useMemo)(()=>(N?.agents??[]).map(e=>({value:e.id,label:fe(e,n.agentsSettings)})),[N?.agents,n.agentsSettings]),ae=(0,Q.useMemo)(()=>(W?.models??[]).map(e=>({value:e,label:e})),[W?.models]),q=ne?.model?.primary,se=!!(i&&W&&c&&(W.credentialMode===`none`||W.configured||p.trim()));if(!r)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connect});if(F||R||H||re)return(0,$.jsx)(Gt,{});if(I||z||ee||U||!L||!N||!V)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let ce=e=>{s(e.id),l(e.defaultModel),_(e.configured?zt:``),S(``),E(void 0)},le=()=>{M(void 0),k(!0)},de=()=>{let e=V.find(e=>e.providerId===W?.id);e&&(M(e),k(!0))},pe=async e=>{let[t,n]=await Promise.all([te(),B()]);if(e&&n?.some(t=>t.id===e)){let r=n.find(t=>t.id===e);s(r.id),l(r.defaultModel),_(r.configured?zt:``),M(t?.find(t=>t.providerId===e))}},me=async()=>{if(!(!W||!se)){w(!0),E(void 0);try{let e=await h(m(`/api/agents/${encodeURIComponent(i)}/image-generation/setup`),{method:`POST`,body:JSON.stringify({providerId:W.id,modelId:c,...p.trim()&&!O(p)?{apiKey:p.trim()}:{},...W.requiresRegion?{region:v}:{},...b.trim()?{baseUrl:b.trim()}:{}})});if(!e.payload)throw Error(`Invalid setup response`);await Promise.all([ie(e.payload.agent,{revalidate:!1}),B(e.payload.providers,{revalidate:!1})]),_(zt),ue({type:`success`,title:t.enabled})}catch(e){E(e instanceof Error?e.message:String(e))}finally{w(!1)}}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,$.jsx)(nt,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:t.intro})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[t.agent,(0,$.jsx)(qe,{value:i,options:K,placeholder:t.selectAgent,allowEmpty:!1,onChange:a,triggerClassName:`mt-1.5 max-w-md`})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:t.provider}),(0,$.jsxs)(J,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:le,children:[(0,$.jsx)(oe,{className:`size-4`}),t.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:L.map(e=>{let n=e.id===o,r=e.id===Ht(q);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ce(e),className:`min-h-24 rounded-xl border p-4 text-left transition-colors ${n?`border-accent bg-accent/5 ring-1 ring-accent/20`:`border-edge bg-surface-base hover:border-edge-strong`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[10px] text-fg-subtle`,children:t.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!r,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${r?``:`invisible`}`,children:t.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode===`none`?(0,$.jsx)(je,{className:`size-3.5`}):(0,$.jsx)(Pe,{className:`size-3.5`}),e.configured||e.credentialMode===`none`?t.configured:t.needsKey]})]},e.id)})})]}),W?(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[t.model,(0,$.jsx)(qe,{value:c,options:ae,placeholder:t.selectModel,allowEmpty:!1,onChange:l,triggerClassName:`mt-1.5`})]}),W.requiresRegion?(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[t.region,(0,$.jsx)(qe,{value:v,options:[{value:`cn`,label:t.cn},{value:`intl`,label:t.intl}],placeholder:t.region,allowEmpty:!1,onChange:e=>y(e),triggerClassName:`mt-1.5`})]}):null]}),W.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(J,{variant:`secondary`,onClick:de,children:[(0,$.jsx)(Ae,{className:`size-4`}),t.manageService]})}):null,W.credentialMode===`none`?null:(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`image-generation-api-key`,className:`text-xs font-medium text-fg-muted`,children:t.apiKey}),G?(0,$.jsxs)(`a`,{href:G,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(j,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(ge,{id:`image-generation-api-key`,value:p,onChange:e=>_(O(p)?e.replace(/^•+/,``):e),placeholder:W.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>Ye(W.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},W.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:W.configured?t.savedKey:t.apiKeyHint})]}),(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(Ie,{className:`size-4`}),t.advanced]}),(0,$.jsxs)(`label`,{className:`mt-3 block text-xs font-medium text-fg-muted`,children:[t.baseUrl,(0,$.jsx)(`input`,{value:b,onChange:e=>S(e.target.value),placeholder:`https://…`,className:`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`})]})]}),T?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:T}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(J,{variant:`primary`,disabled:!se||C,onClick:()=>void me(),children:[C?(0,$.jsx)(Y,{className:`size-4 animate-spin`}):(0,$.jsx)(je,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:C?t.enabling:t.enable})]})]})})]}):null,(0,$.jsx)(Rt,{open:D,onOpenChange:k,provider:A,configured:!!(A&&L.find(e=>e.id===A.providerId)?.configured),language:e,onSaved:pe})]})}var Jt=Be;function Yt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function Xt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Zt(){return l(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G,`dark:border-edge`)}function Qt(){return l(re,Be)}function $t(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function en(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 tn=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],nn=[{id:`whisper-1`,name:`Whisper-1`}],rn=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],an=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],on=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],sn=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],cn=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],ln=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],un=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],dn=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],fn=[{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 pn(e,t){switch(e){case`xopc-local`:return t.stt.localProvider;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function mn(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 hn(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 gn(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 _n(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function vn(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 yn(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 bn(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 xn(){let e=f(e=>e.language),t=u(e).voiceSettings,n=!!d(e=>e.token),[r,i]=(0,Q.useReducer)(bn,{form:null,baseline:null}),a=r.form,o=r.baseline,[s,c]=(0,Q.useState)(null),[l,p]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(null),v=(0,Q.useRef)(!1),y=(0,Q.useRef)({parsed:null,models:void 0}),{data:b,error:x,isLoading:S,mutate:C}=Qe(n),{data:w,error:T,isLoading:E,mutate:D}=g(n?m(`/api/voice/models`):null,_t,{revalidateOnFocus:!1}),{data:O,error:k,isLoading:A}=g(n?m(`/api/voice/providers`):null,pt,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:N}=g(n?m(`/api/voice/stt-providers`):null,gt,{revalidateOnFocus:!1}),P=(0,Q.useMemo)(()=>O?.providers??[],[O]),F=(0,Q.useMemo)(()=>j?.providers??[],[j]),I=(0,Q.useMemo)(()=>b?.payload?.config===void 0?null:dt(b.payload.config),[b]),L=(0,Q.useMemo)(()=>!a||!o?!1:JSON.stringify(a)!==JSON.stringify(o),[a,o]);n?I!==null&&w!==void 0&&!v.current&&(y.current.parsed!==I||y.current.models!==w)&&(y.current={parsed:I,models:w},i({type:`sync`,value:I}),c(w)):(y.current.parsed!==null||y.current.models!==void 0)&&(y.current={parsed:null,models:void 0},i({type:`reset`}),c(null),v.current=!1);let R=!!(n&&(I===null||w===void 0||O===void 0||j===void 0)&&(S||E||A||N)),z=x instanceof Error?x.message:x?String(x):T instanceof Error?T.message:T?String(T):k instanceof Error?k.message:k?String(k):M instanceof Error?M.message:M?String(M):null,B=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),V=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),H=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),ee=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[`xopc-local`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),te=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),ne=(0,Q.useCallback)(t=>{v.current=!0,i({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),re=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),U=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),ie=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),W=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,voice:e.voice!==void 0||e.lang!==void 0?{...t.voice,languageMode:`manual`}:t.voice,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),G=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),K=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]);if(jt({id:`voice`,dirty:L,saving:l,save:(0,Q.useCallback)(async()=>{if(!(!a||l)){p(!0),_(null);try{await mt(a),i({type:`saved`,value:a}),v.current=!1}catch(e){_(e instanceof Error?e.message:t.saveError)}finally{p(!1)}}},[a,l,t.saveError]),discard:(0,Q.useCallback)(()=>{o&&(v.current=!1,i({type:`discard`}),_(null))},[o])}),!n)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(R)return(0,$.jsx)(ut,{rows:4});if(!a||s===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h??z??t.loadError}),(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:()=>{C(),D()},children:t.retry})]});let ae=a.stt,q=a.tts,oe=a.voice.input.refinement,se=_n(t);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(Sn,{v:t,voice:a.voice,updateLanguageMode:ne}),(0,$.jsx)(Cn,{v:t,stt:ae,tts:q}),(0,$.jsx)(Tn,{v:t,apiKeyLabels:se,stt:ae,models:s,sttProviders:F,refinement:oe,updateStt:B,updateSttAlibaba:V,updateSttOpenai:H,updateSttFallback:ee,updateRefinement:te}),(0,$.jsx)(Nn,{v:t,apiKeyLabels:se,tts:q,models:s,ttsProviders:P,updateTts:re,updateTtsAlibaba:U,updateTtsOpenai:ie,updateTtsEdge:W,updateTtsMinimax:G,updateTtsLocalCli:K})]}),(0,$.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,$.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,$.jsx)(`strong`,{className:`text-accent`,children:t.notes.title}),` `,t.notes.duration]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.notes.envVars})]})]})}function Sn(e){let t=(0,Z.c)(22),{v:n,voice:r,updateLanguageMode:i}=e,a;t[0]===n.language.title?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.language.title}),t[0]=n.language.title,t[1]=a);let o=r.languageMode===`auto`?n.language.autoDescription:n.language.manualDescription,s;t[2]===o?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=Qt(),t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=e=>i(e.target.value),t[8]=i,t[9]=u);let d;t[10]===n.language.auto?d=t[11]:(d=(0,$.jsx)(X,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=d);let f;t[12]===n.language.manual?f=t[13]:(f=(0,$.jsx)(X,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=f);let p;t[14]!==u||t[15]!==d||t[16]!==f||t[17]!==r.languageMode?(p=(0,$.jsxs)(et,{className:l,value:r.languageMode,onChange:u,children:[d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=r.languageMode,t[18]=p):p=t[18];let m;return t[19]!==c||t[20]!==p?(m=(0,$.jsx)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,p]})}),t[19]=c,t[20]=p,t[21]=m):m=t[21],m}function Cn(e){let t=(0,Z.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,$.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,$.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,$.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} · ${pn(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,$.jsx)(wn,{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?hn(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,$.jsx)(wn,{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?`${mn(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,$.jsx)(wn,{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,$.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,$.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 wn(e){let t=(0,Z.c)(10),{label:n,value:r,ready:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o=i?`text-fg`:`text-fg-muted`,s;t[2]===o?s=t[3]:(s=l(`mt-1 text-sm font-medium`,o),t[2]=o,t[3]=s);let c;t[4]!==s||t[5]!==r?(c=(0,$.jsx)(`div`,{className:s,children:r}),t[4]=s,t[5]=r,t[6]=c):c=t[6];let u;return t[7]!==a||t[8]!==c?(u=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[a,c]}),t[7]=a,t[8]=c,t[9]=u):u=t[9],u}function Tn(e){let t=(0,Z.c)(49),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,refinement:s,updateStt:c,updateSttAlibaba:u,updateSttOpenai:d,updateSttFallback:f,updateRefinement:p}=e,m=a?.stt?.alibaba?.length?a.stt.alibaba:tn,h=a?.stt?.openai?.length?a.stt.openai:nn,g;if(t[0]!==o){let e=new Set;g=[];for(let t of o)e.has(t.id)||(e.add(t.id),g.push(t));t[0]=o,t[1]=g}else g=t[1];let _=g,v,y,b,x,S;if(t[2]!==m||t[3]!==r||t[4]!==a?.stt||t[5]!==h||t[6]!==_||t[7]!==s||t[8]!==i||t[9]!==p||t[10]!==c||t[11]!==u||t[12]!==f||t[13]!==d||t[14]!==n){let e=_.find(e=>e.id===i.provider),o=i.providers?.[i.provider],g=typeof o?.apiKey==`string`?o.apiKey:``,C=typeof o?.model==`string`?o.model:``,w={...i.provider===`alibaba`?i.alibaba??{}:{},...i.provider===`openai`?i.openai??{}:{},...o??{}},T=(e?.fields??[]).filter(An),E;t[20]!==i.provider||t[21]!==i.providers||t[22]!==c?(E=e=>{c({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[20]=i.provider,t[21]=i.providers,t[22]=c,t[23]=E):E=t[23];let D=E;x=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(ce,{className:`size-4 text-accent`,strokeWidth:1.75}),t[24]=O):O=t[24];let k;t[25]===n.stt.title?k=t[26]:(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[O,n.stt.title]}),t[25]=n.stt.title,t[26]=k);let A;t[27]===n.stt.description?A=t[28]:(A=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[27]=n.stt.description,t[28]=A),t[29]!==k||t[30]!==A?(S=(0,$.jsxs)(`div`,{className:`mb-4`,children:[k,A]}),t[29]=k,t[30]=A,t[31]=S):S=t[31],v=`space-y-4`;let j;t[32]===c?j=t[33]:(j=e=>c({enabled:e}),t[32]=c,t[33]=j),t[34]!==i.enabled||t[35]!==j||t[36]!==n.overview.off||t[37]!==n.overview.ready||t[38]!==n.stt.enable||t[39]!==n.stt.enableDesc?(y=(0,$.jsx)(Pn,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:j}),t[34]=i.enabled,t[35]=j,t[36]=n.overview.off,t[37]=n.overview.ready,t[38]=n.stt.enable,t[39]=n.stt.enableDesc,t[40]=y):y=t[40],b=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,Jt),children:[(0,$.jsx)(Ln,{children:n.stt.provider}),(0,$.jsx)(et,{className:Qt(),value:i.provider,onChange:e=>c({provider:e.target.value}),children:_.map(e=>(0,$.jsxs)(X,{value:e.id,children:[pn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,Jt),children:[(0,$.jsx)(Ln,{children:n.stt.model}),i.provider===`xopc-local`?(0,$.jsx)(et,{className:Qt(),value:C||`sensevoice-small`,onChange:e=>D({model:e.target.value}),children:(a?.stt?.[`xopc-local`]??[]).map(kn)}):i.provider===`alibaba`?(0,$.jsx)(et,{className:Qt(),value:i.alibaba?.model??``,onChange:e=>u({model:e.target.value}),children:m.map(On)}):i.provider===`openai`?(0,$.jsx)(et,{className:Qt(),value:i.openai?.model??``,onChange:e=>d({model:e.target.value}),children:h.map(Dn)}):i.provider===`groq`?(0,$.jsx)(et,{className:Qt(),value:C||rn[0].id,onChange:e=>D({model:e.target.value}),children:rn.map(En)}):(0,$.jsx)(`input`,{className:Zt(),value:C,onChange:e=>D({model:e.target.value}),placeholder:i.provider})]}),e?.diagnostics.requiresApiKey===!1?null:(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,Jt),children:[(0,$.jsx)(Ln,{children:n.stt.apiKey}),(0,$.jsx)(yt,{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??``:g,onChange:e=>{i.provider===`alibaba`?u({apiKey:e}):i.provider===`openai`?d({apiKey:e}):D({apiKey:e})},labels:r,placeholder:i.provider===`groq`?`gsk_...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Yt(i.provider)?` ${Yt(i.provider)}`:``]})]})]}),T.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:T.map(e=>(0,$.jsx)(Fn,{field:e,value:vn(w,e),onChange:t=>D({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Jt},e.key))}):null,i.provider===`xopc-local`?(0,$.jsx)(Mn,{v:n}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>f({enabled:e.target.checked})})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.refinementDesc})]}),(0,$.jsxs)(et,{className:Qt(),value:s.mode,onChange:e=>p({mode:e.target.value}),children:[(0,$.jsx)(X,{value:`off`,children:n.stt.refinementOff}),(0,$.jsx)(X,{value:`punctuation`,children:n.stt.refinementPunctuation}),(0,$.jsx)(X,{value:`light`,children:n.stt.refinementLight})]})]})]}):null,t[2]=m,t[3]=r,t[4]=a?.stt,t[5]=h,t[6]=_,t[7]=s,t[8]=i,t[9]=p,t[10]=c,t[11]=u,t[12]=f,t[13]=d,t[14]=n,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S}else v=t[15],y=t[16],b=t[17],x=t[18],S=t[19];let C;t[41]!==v||t[42]!==y||t[43]!==b?(C=(0,$.jsxs)(`div`,{className:v,children:[y,b]}),t[41]=v,t[42]=y,t[43]=b,t[44]=C):C=t[44];let w;return t[45]!==x||t[46]!==S||t[47]!==C?(w=(0,$.jsxs)(`section`,{className:x,children:[S,C]}),t[45]=x,t[46]=S,t[47]=C,t[48]=w):w=t[48],w}function En(e){return(0,$.jsx)(X,{value:e.id,children:e.name},e.id)}function Dn(e){return(0,$.jsx)(X,{value:e.id,children:e.name},e.id)}function On(e){return(0,$.jsx)(X,{value:e.id,children:e.name},e.id)}function kn(e){return(0,$.jsx)(X,{value:e.id,children:e.name},e.id)}function An(e){return e.key!==`apiKey`&&e.key!==`model`}function jn(e){return`${Math.round(e/1024/1024)} MB`}function Mn({v:e}){let{data:t,error:n,mutate:r}=g(m(`/api/voice/local/status`),ht,{revalidateOnFocus:!1,refreshInterval:e=>e?.models.some(e=>e.state===`downloading`)?1e3:0}),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),c=(0,Q.useCallback)(async(e,t)=>{a(e.id),s(null);try{t===`install`?await vt(e.id):await bt(e.id),await r()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(null)}},[r]);return(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel/60 p-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.stt.localModels}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.stt.localModelsDesc}),n?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:String(n)}):null,o?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:o}):null,(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:(t?.models??[]).map(t=>{let n=i===t.id||t.state===`downloading`;return(0,$.jsxs)(`div`,{className:l(`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2.5`,t.recommended?`ring-1 ring-accent/40`:``),children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium text-fg`,children:[t.name,t.recommended?(0,$.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent`,children:e.stt.localRecommended}):null]}),(0,$.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[jn(t.approximateBytes),` · `,t.description]}),(0,$.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:[t.engine,` · `,t.languages.join(` / `)]}),t.state===`downloading`?(0,$.jsxs)(`div`,{className:`mt-1 text-xs text-accent`,children:[e.stt.localDownloading,` `,Math.round((t.progress??0)*100),`%`]}):t.state===`error`?(0,$.jsx)(`div`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:t.error}):null]}),(0,$.jsx)(J,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void c(t,t.state===`ready`?`remove`:`install`),children:n?(0,$.jsx)(Y,{className:`size-4 animate-spin`}):t.state===`ready`?e.stt.localRemove:e.stt.localInstall})]},t.id)})})]})}function Nn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,updateTtsAlibaba:o,updateTtsOpenai:s,updateTtsEdge:c,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:an,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:on,m=r?.tts?.alibaba?.length?r.tts.alibaba:sn,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:cn,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:ln,_=r?.tts?.minimax?.length?r.tts.minimax:un,v=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:dn,[y,b]=(0,Q.useState)(e.tts.test.sampleText),[x,S]=(0,Q.useState)({status:`idle`}),C=(0,Q.useRef)(null),w=(0,Q.useRef)(null),T=(0,Q.useCallback)(()=>{C.current?.pause(),C.current=null,w.current&&=(URL.revokeObjectURL(w.current),null)},[]),E=(0,Q.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),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,Q.useEffect)(()=>()=>T(),[T]);let L=(0,Q.useCallback)(e=>{a({provider:e}),S({status:`idle`})},[a]),R=(0,Q.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 ft({text:t,provider:n.provider,providerConfig:k,...P?{model:P}:{},...F?{voice:F}:{}}),i=en(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`,$t(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]),z=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]),B=(0,Q.useCallback)((e,t)=>{let r={[e.key]:t};z(r),n.provider===`openai`&&e.key===`baseUrl`?s(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&c(r)},[n.provider,z,c,u,s]);return(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(ye,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Pn,{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,$.jsxs)(`div`,{className:l(`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,$.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?M?`${e.tts.statusReady} ${mn(n.provider,e)}${F?` · ${F}`:``}`:`${e.tts.statusNeedsSetup} ${mn(n.provider,e)} · ${D?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,Jt),children:[(0,$.jsx)(Ln,{children:e.tts.trigger}),(0,$.jsxs)(et,{className:Qt(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,$.jsx)(X,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(X,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(X,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(X,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,Jt),children:[(0,$.jsx)(Ln,{children:e.tts.provider}),(0,$.jsx)(et,{className:Qt(),value:n.provider,onChange:e=>L(e.target.value),children:E.map(t=>(0,$.jsx)(X,{value:t.id,children:mn(t.id,e)},t.id))}),(0,$.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??gn(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!M||n.provider===`tts-local-cli`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,$.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,Jt),children:[(0,$.jsx)(Ln,{children:e.stt.apiKey}),(0,$.jsx)(yt,{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`?s({apiKey:e}):n.provider===`alibaba`?o({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,Xt(n.provider)?` ${Xt(n.provider)}`:``]})]}),(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,Jt),children:[(0,$.jsx)(Ln,{children:e.stt.model}),(0,$.jsx)(et,{className:Qt(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?s({model:e.target.value}):n.provider===`alibaba`?o({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:_).map(e=>(0,$.jsx)(X,{value:e.id,children:e.name},e.id))})]}),(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,Jt),children:[(0,$.jsx)(Ln,{children:e.tts.voice}),(0,$.jsx)(et,{className:Qt(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?s({voice:e.target.value}):n.provider===`alibaba`?o({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:v).map(e=>(0,$.jsx)(X,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,Jt),children:[(0,$.jsx)(Ln,{children:e.tts.voice}),(0,$.jsx)(et,{className:Qt(),value:n.edge?.voice??``,onChange:e=>c({voice:e.target.value}),children:g.map(e=>(0,$.jsx)(X,{value:e.id,children:e.name},e.id))}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(Ln,{children:e.tts.localCli.preset}),(0,$.jsxs)(et,{className:Qt(),value:``,onChange:e=>{let t=fn.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,$.jsx)(X,{value:``,children:e.tts.localCli.presetPlaceholder}),fn.map(e=>(0,$.jsx)(X,{value:e.id,children:e.id},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(Ln,{children:e.tts.localCli.command}),(0,$.jsx)(`input`,{className:l(Zt(),`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,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Ln,{children:e.tts.localCli.cwd}),(0,$.jsx)(`input`,{className:l(Zt(),`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,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Ln,{children:e.tts.localCli.outputFormat}),(0,$.jsxs)(et,{className:Qt(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,$.jsx)(X,{value:`wav`,children:`wav`}),(0,$.jsx)(X,{value:`mp3`,children:`mp3`}),(0,$.jsx)(X,{value:`opus`,children:`opus`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(Ln,{children:e.tts.localCli.timeoutMs}),(0,$.jsx)(`input`,{className:Zt(),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,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,A.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:A.map(e=>(0,$.jsx)(Fn,{field:e,value:vn(k,e),onChange:t=>B(e,t),className:e.type===`textarea`?`sm:col-span-2`:Jt},e.key))}):null]})]}),(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(J,{type:`button`,variant:`primary`,onClick:()=>void R(),disabled:x.status===`loading`,className:`h-9`,children:[x.status===`loading`?(0,$.jsx)(Y,{className:`size-4 animate-spin`}):(0,$.jsx)(I,{className:`size-4`}),x.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(J,{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,$.jsx)($e,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsx)(`textarea`,{className:l(Zt(),`mt-3 min-h-20 resize-y`),value:y,onChange:e=>b(e.target.value),maxLength:1e3}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[y.length,`/1000`]}),x.status===`playing`||x.status===`done`?(0,$.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,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:x.message}):null]})]})]}):null]})]})}function Pn(e){let t=(0,Z.c)(33),{checked:n,title:r,description:i,onLabel:a,offLabel:o,onChange:s}=e,c;t[0]!==n||t[1]!==s?(c=()=>s(!n),t[0]=n,t[1]=s,t[2]=c):c=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=l(`group flex w-full items-center justify-between gap-4 rounded-2xl px-4 py-3 text-left shadow-surface transition-colors`,G,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=l(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?a:o,h;t[7]!==p||t[8]!==m?(h=(0,$.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,$.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,$.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,$.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=l(`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=l(`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,$.jsx)(`span`,{className:S}),t[22]=S,t[23]=C);let w;t[24]!==b||t[25]!==C?(w=(0,$.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]!==c||t[29]!==v||t[30]!==w||t[31]!==d?(T=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:c,className:d,children:[v,w]}),t[27]=n,t[28]=c,t[29]=v,t[30]=w,t[31]=d,t[32]=T):T=t[32],T}function Fn(e){let t=(0,Z.c)(36),{field:n,value:r,onChange:i,className:a}=e,o=`voice-schema-field-${n.key}`,s=n.description;if(n.type===`boolean`){let e;t[0]===a?e=t[1]:(e=l(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,a),t[0]=a,t[1]=e);let o;t[2]===n.label?o=t[3]:(o=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=o);let c;t[4]===s?c=t[5]:(c=s?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:s}):null,t[4]=s,t[5]=c);let u;t[6]!==o||t[7]!==c?(u=(0,$.jsxs)(`span`,{children:[o,c]}),t[6]=o,t[7]=c,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==i?(f=e=>i(yn(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,$.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,$.jsxs)(`label`,{className:e,children:[u,p]}),t[15]=e,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}let c=typeof r==`boolean`?``:String(r),u;t[19]===a?u=t[20]:(u=l(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,$.jsx)(Ln,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==a||t[24]!==n||t[25]!==c||t[26]!==o||t[27]!==i?(f=n.type===`select`?(0,$.jsx)(et,{id:o,className:Qt(),value:c,required:n.required,onChange:e=>i(yn(n,e.target.value)),children:(n.options??[]).map(In)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:l(Zt(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(yn(n,e.target.value))}):n.type===`password`?(0,$.jsx)(ge,{id:o,className:a,value:c,onChange:e=>i(yn(n,e)),placeholder:n.placeholder,labels:me}):(0,$.jsx)(`input`,{id:o,className:Zt(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(yn(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=c,t[26]=o,t[27]=i,t[28]=f):f=t[28];let p;t[29]===s?p=t[30]:(p=s?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:s}):null,t[29]=s,t[30]=p);let m;return t[31]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,$.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 In(e){return(0,$.jsx)(X,{value:e.id,children:e.name},e.id)}function Ln(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function Rn(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 zn(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 h(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),We()}async function Bn(e){let t=await h(m(`/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,Z.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Hn(){return l(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G,`dark:border-edge`)}function Un(){return l(re,Be)}var Wn=[`brave`,`tavily`,`bing`,`searxng`];function Gn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var Kn=Ve();function qn(){let e=u(f(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!d(e=>e.token),[i,a]=(0,Q.useReducer)(Kn,{form:null,baseline:null}),o=i.form,s=i.baseline,[c,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(!1),_=(0,Q.useRef)(null),{data:v,error:y,isLoading:b,mutate:x}=Qe(r);U({enabled:r,parsed:(0,Q.useMemo)(()=>v?.payload?.config===void 0?null:Rn(v.payload.config),[v]),dirty:g.current,trackedParsedRef:_,dispatch:a,onResetDirty:()=>{g.current=!1}});let S=!!(r&&b&&v===void 0&&!y),w=y instanceof Error?y.message:y?String(y):null,T=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),E=(0,Q.useCallback)(e=>{g.current=!0,a({type:`patch`,patch:e})},[]);return jt({id:`search`,dirty:T,saving:c,save:(0,Q.useCallback)(async()=>{if(!(!o||c)){p(!0),h(null);try{await zn(o),g.current=!1,a({type:`saved`,value:o})}catch(e){h(e instanceof Error?e.message:t.saveError)}finally{p(!1)}}},[o,c,t.saveError]),discard:(0,Q.useCallback)(()=>{s&&(g.current=!1,a({type:`discard`}),h(null))},[s])}),r?S?(0,$.jsx)(ut,{rows:3}):o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[m?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,$.jsxs)(Ct,{children:[(0,$.jsx)(St,{icon:Ne,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,$.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,$.jsx)(Vn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(et,{className:Un(),value:o.regionMode,onChange:e=>E({regionMode:e.target.value}),children:[(0,$.jsx)(X,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(X,{value:`cn`,children:t.regionCn}),(0,$.jsx)(X,{value:`global`,children:t.regionGlobal})]})})})]}),(0,$.jsx)(xt,{children:(0,$.jsxs)(Ct,{children:[(0,$.jsx)(St,{icon:K,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:o.blocklistEnabled,onChange:e=>E({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),(0,$.jsx)(Vn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:l(Hn(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
|
|
7
|
+
`),placeholder:t.blocklistDomainsPlaceholder,disabled:!o.blocklistEnabled,onChange:e=>{E({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,$.jsxs)(Ct,{children:[(0,$.jsx)(St,{icon:Ne,title:t.sectionSearch,subtitle:t.sectionSearchHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,$.jsx)(Vn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:Hn(),value:o.maxResults,onChange:e=>E({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(Jn,{row:n,providerIndex:r,labels:t,secretLabels:C(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,E({providers:t})},onRemove:()=>{E({providers:o.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,$.jsxs)(J,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>E({providers:[...o.providers,Gn()]}),children:[(0,$.jsx)(oe,{className:`size-4`}),t.addProvider]})]})]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t.footerHint})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m??w??t.loadError}),(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:()=>void x(),children:n.refresh})]}):(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})})}function Jn(e){let t=(0,Z.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>Bn(r).then(Yn),t[0]=r,t[1]=c);let u=c,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=l(Un(),`min-w-[8rem]`),t[2]=d):d=t[2];let f=n.type,p;t[3]!==o||t[4]!==n?(p=e=>o({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=o,t[4]=n,t[5]=p):p=t[5];let m;t[6]===i.providerTypes?m=t[7]:(m=Wn.map(e=>(0,$.jsx)(X,{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,$.jsx)(et,{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]!==o||t[13]!==n?(g=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=g):g=t[14];let _;t[15]!==n.disabled||t[16]!==g?(_=(0,$.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,$.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,$.jsx)(Te,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===s?b=t[23]:(b=(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:y}),t[22]=s,t[23]=b);let x;t[24]!==b||t[25]!==v?(x=(0,$.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,$.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]!==o||t[33]!==n?(C=n.type===`searxng`?(0,$.jsx)(Vn,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Hn(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.urlDesc,t[31]=i.urlLabel,t[32]=o,t[33]=n,t[34]=C):C=t[34];let w;t[35]!==o||t[36]!==n?(w=e=>o({...n,apiKey:e}),t[35]=o,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,$.jsx)(ge,{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,$.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,$.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 Yn(e){return e.apiKey??null}var Xn=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function Zn(e){let t=new Map;for(let e of Xn)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 Qn(e){let t=(0,Z.c)(22),{open:n,onOpenChange:r,builtinRows:i,customConfig:a,labels:o,language:s,onSaved:c}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,Q.useState)(u),[p,m]=(0,Q.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 g=h,_;t[3]!==g||t[4]!==c?(_=()=>{c(),g(!1)},t[3]=g,t[4]=c,t[5]=_):_=t[5];let v=_,y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(B,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Le)}),t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=l(`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`,Ue),t[7]=b):b=t[7];let x;t[8]!==i||t[9]!==a||t[10]!==v||t[11]!==o||t[12]!==s||t[13]!==p||t[14]!==d.presetKey||t[15]!==d.providerId||t[16]!==d.type?(x=(0,$.jsxs)(De,{children:[y,(0,$.jsx)(H,{className:b,children:d.type===`pick`?(0,$.jsx)(er,{builtinRows:i,searchQuery:p,onSearchChange:m,labels:o,onPickBuiltin:e=>{let t=ze(e);f(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,$.jsx)(tr,{providerId:d.providerId,builtinRows:i,labels:o,language:s,onBack:()=>f({type:`pick`}),onSaved:v}):(0,$.jsx)(ir,{initialPresetKey:d.presetKey,customConfig:a,labels:o,language:s,onBack:()=>f({type:`pick`}),onSaved:v})})]}),t[8]=i,t[9]=a,t[10]=v,t[11]=o,t[12]=s,t[13]=p,t[14]=d.presetKey,t[15]=d.providerId,t[16]=d.type,t[17]=x):x=t[17];let S;return t[18]!==g||t[19]!==n||t[20]!==x?(S=(0,$.jsx)(Se,{open:n,onOpenChange:g,children:x}),t[18]=g,t[19]=n,t[20]=x,t[21]=S):S=t[21],S}function $n(e){let t=(0,Z.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,q.press),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[1]=i):i=t[1];let a;return t[2]===n?a=t[3]:(a=(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:i})}),t[2]=n,t[3]=a),a}function er(e){let t=(0,Z.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:i,labels:a,onPickBuiltin:o,onPickCustom:s}=e,c;t[0]===r?c=t[1]:(c=r.trim().toLowerCase(),t[0]=r,t[1]=c);let u=c,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=st[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=Zn(f),t[7]=f,t[8]=p);let m=p,h;t[9]===a.step1Title?h=t[10]:(h=(0,$.jsx)(we,{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,$.jsx)($n,{label:a.close}),t[11]=a.close,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,$.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,$.jsx)(Ne,{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=l(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,G),t[19]=x):x=t[19];let S;t[20]!==a.searchPlaceholder||t[21]!==r||t[22]!==y?(S=(0,$.jsx)(`div`,{className:`px-5 pt-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[v,(0,$.jsx)(`input`,{type:`search`,value:r,onChange:y,placeholder:b,autoComplete:`off`,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]!==s||t[27]!==u?(C=u?null:(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:l(`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`,q.press),children:[(0,$.jsx)(ie,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.addCustom}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:a.customDescription})]}),(0,$.jsx)(at,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=a.addCustom,t[25]=a.customDescription,t[26]=s,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]!==o?(w=f.length===0?(0,$.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:a.noResults}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:Xn.map(e=>{let t=m.get(e)??[];return t.length===0?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:a.categories[e]??e}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),className:l(`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`,q.press),children:[(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,$.jsx)(je,{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]=o,t[34]=w):w=t[34];let T;t[35]!==C||t[36]!==w?(T=(0,$.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,$.jsxs)($.Fragment,{children:[_,S,T]}),t[38]=S,t[39]=T,t[40]=_,t[41]=E):E=t[41],E}function tr({providerId:e,builtinRows:t,labels:n,language:r,onBack:i,onSaved:a}){let o=t.find(t=>t.id===e),s=st[e],[c,d]=(0,Q.useState)(``),[f,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),S=(0,Q.useRef)(null),w=u(r).providersSettings,T=C(w),E=(0,Q.useMemo)(()=>x(e,r),[e,r]),D=o?.supportsApiKey!==!1,O=o?.supportsOAuth===!0,[k,j]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(`idle`),[R,z]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(null),[H,te]=(0,Q.useState)(``),ne=F===`waiting`||F===`waiting_code`;(0,Q.useEffect)(()=>{if(!k||!ne)return;let t=window.setInterval(()=>{(async()=>{try{let n=await ee(k);if(n.status===`waiting_auth`||n.status===`waiting_code`)I(n.status===`waiting_code`?`waiting_code`:`waiting`),P(n.message??null),z(n.authUrl??null),V(n.instructions??null);else if(n.status===`completed`){window.clearInterval(t);try{if(e===`xopc-cloud`){let e=await p(m(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`Model catalog refresh failed: ${e.status}`);await Ce()}}catch(e){I(`error`),P(e instanceof Error?e.message:w.revokeFailed);return}I(`success`),P(n.message??w.saved),window.setTimeout(a,600)}else (n.status===`failed`||n.status===`cancelled`)&&(window.clearInterval(t),I(`error`),P(n.error??n.message??w.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(t)},[k,ne,a,e,w.revokeFailed,w.saved]),(0,Q.useEffect)(()=>()=>{k&&L(k).catch(()=>{})},[k]);let re=async()=>{I(`waiting`),P(w.oauthStarting),_(null);try{j((await ot(e)).sessionId)}catch(e){I(`error`),P(e instanceof Error?e.message:w.revokeFailed)}},U=async()=>{if(k){try{await A(k)}catch{}I(`idle`),P(null),j(null),z(null),V(null)}},ie=async()=>{if(!(!k||!H.trim()))try{await b(k,H.trim()),te(``),P(w.oauthProcessingCode)}catch(e){I(`error`),P(e instanceof Error?e.message:w.revokeFailed)}},W=async()=>{let t=c.trim();if(!(!t||!D)){h(!0),_(null);try{await M({[e]:t}),y(!0),window.setTimeout(a,600)}catch(e){_(e instanceof Error?e.message:n.saveError)}finally{h(!1)}}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,q.press),"aria-label":n.back,children:(0,$.jsx)(at,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(we,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o?.name??e}),(0,$.jsx)($n,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[s?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.description}):null,D?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(ge,{id:`builtin-api-key`,value:c,onChange:d,placeholder:n.apiKeyPlaceholder,labels:T,inputRef:S,onKeyDown:e=>{e.key===`Enter`&&W()}})]}):null,O?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:w.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:w.oauthHint})]}),(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ne,onClick:()=>void re(),children:[ne?(0,$.jsx)(Y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,w.oauth]})]}),N?(0,$.jsx)(`p`,{className:l(`text-xs`,F===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:N}):null,F===`waiting`||F===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[R?(0,$.jsxs)(`a`,{href:R,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:[w.openAuthPage,(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:()=>void U(),children:w.cancelOAuth})]}):null,B?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:B}):null,F===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:H,onChange:e=>te(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ie(),placeholder:w.pasteRedirectUrl,className:l(`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`,G)}),(0,$.jsx)(J,{type:`button`,variant:`primary`,onClick:()=>void ie(),children:w.submitCode})]}):null]}):null,E.length>0&&D?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:E.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[be(e,n),(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,g?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),D?(0,$.jsx)(J,{type:`button`,variant:`primary`,disabled:!c.trim()||f||v,onClick:()=>void W(),children:v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function nr(e=`custom`){if(e!==`custom`&&T[e]){let t=T[e].config;return{preset:e,providerId:W(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 rr(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:T[t.key]?nr(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 ir({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:i,onSaved:a}){let[o,s]=(0,Q.useReducer)(rr,void 0,()=>nr(e)),[c,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),m=C(u(r).providersSettings),{preset:h,providerId:g,baseUrl:_,api:v,apiKey:y,modelIds:b,error:x}=o,S=async()=>{let e=g.trim(),r=_.trim();if(!e){s({type:`setError`,value:n.providerIdRequired});return}if(!r){s({type:`setError`,value:n.baseUrlRequired});return}let i=b.map(e=>e.trim()).filter(Boolean);d(!0),s({type:`setError`,value:null});try{let n=t?.providers??{},o=h===`custom`?void 0:T[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 he({providers:{...n,[e]:s}}),a()}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{d(!1)}},w=async()=>{let e=g.trim()||W(h)||`custom`,t=_.trim();if(!t){s({type:`setError`,value:n.baseUrlRequired});return}p(!0),s({type:`setError`,value:null});try{let r=h===`custom`?void 0:T[h]?.config,i=(await pe({providerId:e,baseUrl:t,apiKey:y.trim()||void 0,api:v,headers:r?.headers})).map(e=>e.id).filter(e=>e&&!e.includes(`/`));s({type:`setModelIds`,values:i}),i.length===0&&s({type:`setError`,value:n.discoverModelsHint})}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.discoverModelsHint})}finally{p(!1)}},E=g.trim()&&_.trim(),D=(v===`openai-completions`||v===`openai-responses`)&&_.trim();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,q.press),"aria-label":n.back,children:(0,$.jsx)(at,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(we,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,$.jsx)($n,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.customDescription}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:n.presetLabel}),(0,$.jsxs)(et,{id:`custom-preset`,value:h,onChange:e=>s({type:`applyPreset`,key:e.target.value}),className:se(),children:[(0,$.jsx)(X,{value:`custom`,children:n.presetCustom}),ae.map(e=>(0,$.jsx)(X,{value:e.key,children:e.label},e.key))]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:n.providerIdLabel}),(0,$.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,value:g,onChange:e=>s({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:l(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,G)})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:_,onChange:e=>s({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:l(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,G)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:n.apiTypeLabel}),(0,$.jsx)(et,{id:`custom-api-type`,value:v,onChange:e=>s({type:`setApi`,value:e.target.value}),className:se(),children:Fe.map(e=>(0,$.jsx)(X,{value:e.value,children:e.label},e.value))})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(ge,{id:`custom-api-key`,value:y,onChange:e=>s({type:`setApiKey`,value:e}),placeholder:n.apiKeyPlaceholder,labels:m})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.modelIdLabel}),(0,$.jsxs)(J,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!D||f,onClick:()=>void w(),children:[f?(0,$.jsx)(Y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0}),f?n.discoveringModels:n.discoverModels]})]}),b.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>s({type:`updateModelId`,index:t,value:e.target.value}),placeholder:n.modelIdPlaceholder,className:l(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,G)}),b.length>1?(0,$.jsx)(`button`,{type:`button`,onClick:()=>s({type:`removeModelSlot`,index:t}),className:l(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,q.press),children:(0,$.jsx)(te,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,$.jsxs)(J,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>s({type:`addModelSlot`}),children:[(0,$.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),x?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),(0,$.jsx)(J,{type:`button`,variant:`primary`,disabled:!E||c,onClick:()=>void S(),children:c?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function ar(){let e=(0,Z.c)(31),t=d(ur),n=!!t,{data:r,isLoading:i}=Qe(n),a;e[0]===n?a=e[1]:(a=n?m(`/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:c,isLoading:l}=g(a,o,s),u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={revalidateOnFocus:!1},e[5]=u):u=e[5];let{data:f,isLoading:p}=g(n?ke:null,lr,u),h;e[6]===f?h=e[7]:(h=f===void 0?[]:f,e[6]=f,e[7]=h);let _=h,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[8]=v):v=e[8];let{data:y}=g(n?z:null,cr,v),b;bb0:{if(!c||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],b=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==c||e[12]!==_?(t=xe(c,V(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=c,e[12]=_,e[13]=t):t=e[13],b=t}let x=b,S;bb1:{if(!y){S=null;break bb1}let t;e[14]===y.config?t=e[15]:(t=rt(y.config),e[14]=y.config,e[15]=t),S=t}let C=S,w;if(e[16]!==x||e[17]!==C||e[18]!==c||e[19]!==_){w=[];let t=new Set((c??[]).filter(sr).map(or)),n;e[21]===C?n=e[22]:(n=new Set(C?Object.keys(C.providers):[]),e[21]=C,e[22]=n);let r=n;for(let e of x){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?C.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;w.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(C){let t;e[23]===C.providers?t=e[24]:(t=Object.entries(C.providers),e[23]=C.providers,e[24]=t);for(let[e,n]of t)w.some(t=>t.id===e)||w.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=x,e[17]=C,e[18]=c,e[19]=_,e[20]=w}else w=e[20];let T=w,E=i||l||p,D;return e[25]!==x||e[26]!==T||e[27]!==C||e[28]!==E||e[29]!==_?(D={cards:T,loading:E,builtinRows:x,customConfig:C,allModels:_},e[25]=x,e[26]=T,e[27]=C,e[28]=E,e[29]=_,e[30]=D):D=e[30],D}function or(e){return e.id}function sr(e){return e.configured}function cr(){return S()}function lr(){return le()}function ur(e){return e.token}function dr(e){let t=(0,Z.c)(16),{labels:n,data:r,onAdd:i,onManage:a}=e,{cards:o,loading:s}=r;if(s){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Re,{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,$.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[e,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(pr)})]}),t[1]=n):n=t[1],n}let c;if(t[2]!==o||t[3]!==n||t[4]!==i||t[5]!==a){let e=o.filter(fr),r=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,s;t[7]===r?s=t[8]:(s=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r}),t[7]=r,t[8]=s);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(oe,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==i?(u=(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:i,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=i,t[12]=u):u=t[12];let d;t[13]!==s||t[14]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[s,u]}),t[13]=s,t[14]=u,t[15]=d):d=t[15],c=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel/60 px-6 py-10 text-center shadow-surface`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:i,children:[(0,$.jsx)(oe,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,$.jsx)(mr,{card:e,labels:n,onManage:()=>a(e.id,e.isCustom)},e.id))})]}),t[2]=o,t[3]=n,t[4]=i,t[5]=a,t[6]=c}else c=t[6];return c}function fr(e){return e.configured}function pr(e){return(0,$.jsx)(Re,{className:`h-32 rounded-2xl`},e)}function mr(e){let t=(0,Z.c)(28),{card:n,labels:r,onManage:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=l(`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`,q.pressCard),t[0]=a):a=t[0];let o;t[1]===n.name?o=t[2]:(o=(0,$.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=o);let s;t[3]!==n.isCustom||t[4]!==r.custom?(s=n.isCustom?(0,$.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]=s):s=t[5];let c;t[6]!==o||t[7]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(je,{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]===c?d=t[11]:(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[c,u]}),t[10]=c,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,$.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,$.jsx)(Ae,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,$.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,$.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,$.jsxs)(`button`,{type:`button`,onClick:i,className:a,children:[d,g]}),t[24]=i,t[25]=g,t[26]=d,t[27]=_):_=t[27],_}function hr(e){let t=(0,Z.c)(156),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c;t[0]===n?c=t[1]:(c=()=>n?{...n}:it(``),t[0]=n,t[1]=c);let[u,d]=(0,Q.useState)(c),[f,p]=(0,Q.useState)(gr),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]!==s.modelIdRequired||t[7]!==s.mustBePositive?(g=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,s.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),p(e),e.size===0},t[3]=u.contextWindow,t[4]=u.id,t[5]=u.maxTokens,t[6]=s.modelIdRequired,t[7]=s.mustBePositive,t[8]=g):g=t[8];let _=g,y;t[9]!==u||t[10]!==o||t[11]!==a||t[12]!==_?(y=()=>{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}}),o()},t[9]=u,t[10]=o,t[11]=a,t[12]=_,t[13]=y):y=t[13];let b=y,x=u,S;t[14]===x?S=t[15]:(S=ne(x),t[14]=x,t[15]=S);let C=S,w=r?s.addModelTitle:s.editModelTitle,T;t[16]===w?T=t[17]:(T=(0,$.jsx)(we,{className:`text-base font-semibold text-fg`,children:w}),t[16]=w,t[17]=T);let O;t[18]!==s.modelProviderLabel||t[19]!==i?(O=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[18]=s.modelProviderLabel,t[19]=i,t[20]=O):O=t[20];let k;t[21]!==T||t[22]!==O?(k=(0,$.jsxs)(`div`,{children:[T,O]}),t[21]=T,t[22]=O,t[23]=k):k=t[23];let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=l(E,`p-1.5 hover:bg-surface-base`),t[24]=A):A=t[24];let j;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(te,{className:`size-4`}),t[25]=j):j=t[25];let M;t[26]===s.close?M=t[27]:(M=(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:A,"aria-label":s.close,children:j})}),t[26]=s.close,t[27]=M);let P;t[28]!==k||t[29]!==M?(P=(0,$.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[k,M]}),t[28]=k,t[29]=M,t[30]=P):P=t[30];let F;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=F):F=t[31];let I;t[32]===s.modelId?I=t[33]:(I=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,F]}),t[32]=s.modelId,t[33]=I);let L;t[34]===f?L=t[35]:(L=l(He(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=L);let R=u.id||``,z;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>h(`id`,e.target.value),t[36]=z):z=t[36];let B=!r,V;t[37]!==L||t[38]!==R||t[39]!==B?(V=(0,$.jsx)(`input`,{className:L,value:R,onChange:z,placeholder:`e.g. llama3.1:8b`,disabled:B}),t[37]=L,t[38]=R,t[39]=B,t[40]=V):V=t[40];let H;t[41]===f?H=t[42]:(H=f.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[41]=f,t[42]=H);let ee;t[43]!==I||t[44]!==V||t[45]!==H?(ee=(0,$.jsxs)(`div`,{children:[I,V,H]}),t[43]=I,t[44]=V,t[45]=H,t[46]=ee):ee=t[46];let re;t[47]===s.displayName?re=t[48]:(re=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[47]=s.displayName,t[48]=re);let U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U=He(),t[49]=U):U=t[49];let ie=u.name||``,W;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>h(`name`,e.target.value),t[50]=W):W=t[50];let G;t[51]===ie?G=t[52]:(G=(0,$.jsx)(`input`,{className:U,value:ie,onChange:W}),t[51]=ie,t[52]=G);let K;t[53]!==re||t[54]!==G?(K=(0,$.jsxs)(`div`,{children:[re,G]}),t[53]=re,t[54]=G,t[55]=K):K=t[55];let ae;t[56]===s.inputTypes?ae=t[57]:(ae=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[56]=s.inputTypes,t[57]=ae);let q;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(q=se(),t[58]=q):q=t[58];let oe;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>h(`input`,v(e.target.value)),t[59]=oe):oe=t[59];let ce;t[60]===s?ce=t[61]:(ce=D.map(e=>(0,$.jsx)(X,{value:e.value,children:s[e.labelKey]},e.value)),t[60]=s,t[61]=ce);let le;t[62]!==C||t[63]!==ce?(le=(0,$.jsx)(et,{className:q,value:C,onChange:oe,children:ce}),t[62]=C,t[63]=ce,t[64]=le):le=t[64];let ue;t[65]!==ae||t[66]!==le?(ue=(0,$.jsxs)(`div`,{children:[ae,le]}),t[65]=ae,t[66]=le,t[67]=ue):ue=t[67];let de=u.reasoning||!1,fe;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>h(`reasoning`,e.target.checked),t[68]=fe):fe=t[68];let pe;t[69]===de?pe=t[70]:(pe=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:de,onChange:fe}),t[69]=de,t[70]=pe);let me;t[71]!==s.reasoning||t[72]!==pe?(me=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[pe,s.reasoning]}),t[71]=s.reasoning,t[72]=pe,t[73]=me):me=t[73];let he;t[74]!==ue||t[75]!==me?(he=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ue,me]}),t[74]=ue,t[75]=me,t[76]=he):he=t[76];let ge;t[77]===s.contextWindow?ge=t[78]:(ge=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[77]=s.contextWindow,t[78]=ge);let _e;t[79]===f?_e=t[80]:(_e=l(He(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=_e);let ve=u.contextWindow??128e3,ye;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(ye=e=>h(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=ye):ye=t[81];let be;t[82]!==_e||t[83]!==ve?(be=(0,$.jsx)(`input`,{type:`number`,min:1,className:_e,value:ve,onChange:ye}),t[82]=_e,t[83]=ve,t[84]=be):be=t[84];let xe;t[85]===f?xe=t[86]:(xe=f.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=xe);let Se;t[87]!==ge||t[88]!==be||t[89]!==xe?(Se=(0,$.jsxs)(`div`,{children:[ge,be,xe]}),t[87]=ge,t[88]=be,t[89]=xe,t[90]=Se):Se=t[90];let Ce;t[91]===s.maxOutputTokens?Ce=t[92]:(Ce=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[91]=s.maxOutputTokens,t[92]=Ce);let Te;t[93]===f?Te=t[94]:(Te=l(He(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=Te);let Ee=u.maxTokens??16384,De;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(De=e=>h(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=De):De=t[95];let Oe;t[96]!==Te||t[97]!==Ee?(Oe=(0,$.jsx)(`input`,{type:`number`,min:1,className:Te,value:Ee,onChange:De}),t[96]=Te,t[97]=Ee,t[98]=Oe):Oe=t[98];let ke;t[99]===f?ke=t[100]:(ke=f.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=ke);let Ae;t[101]!==Ce||t[102]!==Oe||t[103]!==ke?(Ae=(0,$.jsxs)(`div`,{children:[Ce,Oe,ke]}),t[101]=Ce,t[102]=Oe,t[103]=ke,t[104]=Ae):Ae=t[104];let je;t[105]!==Se||t[106]!==Ae?(je=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Se,Ae]}),t[105]=Se,t[106]=Ae,t[107]=je):je=t[107];let Y;t[108]===s.costSection?Y=t[109]:(Y=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[108]=s.costSection,t[109]=Y);let Me;t[110]===s.costInput?Me=t[111]:(Me=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[110]=s.costInput,t[111]=Me);let Ne;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=He(),t[112]=Ne):Ne=t[112];let Pe=u.cost?.input??0,Fe;t[113]===u.cost?Fe=t[114]:(Fe=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]=Fe);let Ie;t[115]!==Pe||t[116]!==Fe?(Ie=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ne,value:Pe,onChange:Fe}),t[115]=Pe,t[116]=Fe,t[117]=Ie):Ie=t[117];let Le;t[118]!==Me||t[119]!==Ie?(Le=(0,$.jsxs)(`div`,{children:[Me,Ie]}),t[118]=Me,t[119]=Ie,t[120]=Le):Le=t[120];let Re;t[121]===s.costOutput?Re=t[122]:(Re=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[121]=s.costOutput,t[122]=Re);let ze;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(ze=He(),t[123]=ze):ze=t[123];let Be=u.cost?.output??0,Ve;t[124]===u.cost?Ve=t[125]:(Ve=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]=Ve);let Ue;t[126]!==Be||t[127]!==Ve?(Ue=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:ze,value:Be,onChange:Ve}),t[126]=Be,t[127]=Ve,t[128]=Ue):Ue=t[128];let We;t[129]!==Re||t[130]!==Ue?(We=(0,$.jsxs)(`div`,{children:[Re,Ue]}),t[129]=Re,t[130]=Ue,t[131]=We):We=t[131];let Ge;t[132]!==Le||t[133]!==We?(Ge=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Le,We]}),t[132]=Le,t[133]=We,t[134]=Ge):Ge=t[134];let Ke;t[135]!==Y||t[136]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Y,Ge]}),t[135]=Y,t[136]=Ge,t[137]=Ke):Ke=t[137];let qe;t[138]!==ee||t[139]!==K||t[140]!==he||t[141]!==je||t[142]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[ee,K,he,je,Ke]}),t[138]=ee,t[139]=K,t[140]=he,t[141]=je,t[142]=Ke,t[143]=qe):qe=t[143];let Je;t[144]===s.cancel?Je=t[145]:(Je=(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,variant:`secondary`,children:s.cancel})}),t[144]=s.cancel,t[145]=Je);let Ye=r?s.addModelConfirm:s.saveModelConfirm,Xe;t[146]!==b||t[147]!==Ye?(Xe=(0,$.jsx)(J,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:b,children:Ye}),t[146]=b,t[147]=Ye,t[148]=Xe):Xe=t[148];let Ze;t[149]!==Je||t[150]!==Xe?(Ze=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Je,Xe]}),t[149]=Je,t[150]=Xe,t[151]=Ze):Ze=t[151];let Qe;return t[152]!==P||t[153]!==qe||t[154]!==Ze?(Qe=(0,$.jsxs)($.Fragment,{children:[P,qe,Ze]}),t[152]=P,t[153]=qe,t[154]=Ze,t[155]=Qe):Qe=t[155],Qe}function gr(){return new Map}function _r(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(B,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Le)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=l(`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`,Ue,`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]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(f=n?(0,$.jsx)(hr,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=f):f=t[9];let p;t[10]===f?p=t[11]:(p=(0,$.jsxs)(De,{children:[u,(0,$.jsx)(H,{className:d,onOpenAutoFocus:vr,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,$.jsx)(Se,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function vr(e){return e.preventDefault()}function yr(e){let t=(0,Z.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>Ye(n).then(br),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,$.jsx)(ge,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function br(e){return e.apiKey??null}function xr(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:u,language:d,onSaved:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(B,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Le)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=l(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-[calc(100%-2rem)] 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`,Ue),t[1]=m):m=t[1];let h;t[2]!==c||t[3]!==o||t[4]!==s||t[5]!==a||t[6]!==u||t[7]!==d||t[8]!==r||t[9]!==f||t[10]!==i?(h=(0,$.jsxs)(De,{children:[p,(0,$.jsx)(H,{className:m,children:a?(0,$.jsx)(Cr,{providerId:i,customConfig:s,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,$.jsx)(Sr,{providerId:i,builtinRows:o,allModels:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=c,t[3]=o,t[4]=s,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 g;return t[12]!==r||t[13]!==n||t[14]!==h?(g=(0,$.jsx)(Se,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function Sr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let s=t.find(t=>t.id===e),d=st[e],f=n.filter(t=>t.provider===e),[p,m]=(0,Q.useState)(s?.apiKey??``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(!1),T=u(i).providersSettings,E=s?.supportsApiKey!==!1,D=s?.supportsOAuth===!0,O=s?.authMode===`oauth`&&s.authStatus===`connected`,k=s?.configured===!0&&s.activeKeySource!==`env`&&s.activeKeySource!==`extension`&&s.activeKeySource!==`models_json`,[j,P]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(null),[z,B]=(0,Q.useState)(`idle`),[V,H]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(null),[U,ie]=(0,Q.useState)(``),W=z===`waiting`||z===`waiting_code`,K=(0,Q.useMemo)(()=>x(e,i),[e,i]),ae=p!==(s?.apiKey??``),oe=async()=>{let t=p.trim();if(!(!t||!E||_e(t))){g(!0),S(null);try{await M({[e]:t}),v(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){S(e instanceof Error?e.message:r.saveError)}finally{g(!1)}}};(0,Q.useEffect)(()=>{if(!j||!W)return;let e=window.setInterval(()=>{(async()=>{try{let t=await ee(j);t.status===`waiting_auth`||t.status===`waiting_code`?(B(t.status===`waiting_code`?`waiting_code`:`waiting`),I(t.message??null),H(t.authUrl??null),re(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),B(`success`),I(t.message??T.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),B(`error`),I(t.error??t.message??T.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[j,W,a,o,T.revokeFailed,T.saved]),(0,Q.useEffect)(()=>()=>{j&&L(j).catch(()=>{})},[j]);let se=async()=>{try{await ve(e),o(),a()}catch{}},ce=async()=>{B(`waiting`),I(T.oauthStarting),S(null);try{P((await ot(e)).sessionId)}catch(e){B(`error`),I(e instanceof Error?e.message:T.revokeFailed)}},le=async()=>{if(j){try{await A(j)}catch{}B(`idle`),I(null),P(null),H(null),re(null)}},ue=async()=>{if(!(!j||!U.trim()))try{await b(j,U.trim()),ie(``),I(T.oauthProcessingCode)}catch(e){B(`error`),I(e instanceof Error?e.message:T.revokeFailed)}},fe=async()=>{try{await de(e),o(),a()}catch(e){S(e instanceof Error?e.message:T.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(we,{className:`text-base font-semibold text-fg`,children:s?.name??e}),(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,q.press),children:(0,$.jsx)(te,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[d?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.description}):null,s?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:s.baseUrl})]}):s?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,E?(0,$.jsx)(yr,{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}}):s?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),s?.extensionId?(0,$.jsxs)(c,{to:`/settings/ext/${encodeURIComponent(s.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(R,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,D?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:T.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:O?T.sourceOauth:T.oauthHint})]}),O?(0,$.jsx)(J,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void fe(),children:T.revoke}):(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:W,onClick:()=>void ce(),children:[W?(0,$.jsx)(Y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ze,{className:`size-3.5`,"aria-hidden":!0}),T.oauth]})]}),F?(0,$.jsx)(`p`,{className:l(`text-xs`,z===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:F}):null,z===`waiting`||z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[V?(0,$.jsxs)(`a`,{href:V,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,$.jsx)(R,{className:`size-4`,"aria-hidden":!0}),T.openAuthPage]}):null,(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:()=>void le(),children:T.cancelOAuth})]}):null,ne?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ne}):null,z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:U,onChange:e=>ie(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ue(),placeholder:T.pasteRedirectUrl,className:l(`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`,G)}),(0,$.jsx)(J,{type:`button`,variant:`primary`,onClick:()=>void ue(),children:T.submitCode})]}):null]}):null,K.length>0&&E?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:K.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[be(e,r),(0,$.jsx)(R,{className:`size-3`,"aria-hidden":!0})]},e))}):null,f.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,f.length,`)`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,$.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,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),y?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[k?(0,$.jsxs)(J,{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:()=>w(!0),children:[(0,$.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:E&&ae&&!_e(p.trim())?(0,$.jsx)(J,{type:`button`,variant:`primary`,disabled:!p.trim()||h||_,onClick:()=>void oe(),children:_?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(Ge,{open:C,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,s?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void se(),onCancel:()=>w(!1)})]})}function Cr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let o=u(r).modelsSettings,s=t?.providers[e],[c,d]=(0,Q.useState)(s?.baseUrl??``),[f,p]=(0,Q.useState)(s?.apiKey??``),[m,h]=(0,Q.useState)(s?.models??[]),[g,_]=(0,Q.useState)(s?.modelDiscovery?.enabled===!0),[v,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(null),j=n=>{if(!t)return null;let r=f.trim(),i={...s,baseUrl:c.trim()||void 0,apiKey:_e(r)?s?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},M=async()=>{let e=j({models:m,modelDiscovery:{enabled:g}});if(e){b(!0),S(null);try{await he(e),a(),i()}catch(e){S(e instanceof Error?e.message:n.saveError)}finally{b(!1)}}},P=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await he({providers:r}),a(),i()}catch{}},F=(e,t)=>{A({model:e,isNew:t}),O(!0)},I=async e=>{if(!k)return;let t=k.isNew?[...m,e]:m.map(t=>t.id===e.id?e:t);h(t);let r=j({models:t});if(r)try{await he(r),a()}catch(e){S(e instanceof Error?e.message:n.saveError)}},L=async e=>{let t=m.filter(t=>t.id!==e);h(t),E(null);let r=j({models:t});if(r)try{await he(r),a()}catch(e){S(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(we,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,q.press),children:(0,$.jsx)(te,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:c,onChange:e=>d(e.target.value),className:l(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,G)})]}),(0,$.jsx)(yr,{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,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r===`zh`?`自动同步模型目录`:`Automatically sync model catalog`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:r===`zh`?`启动时及定时从此服务的 /models 接口更新模型。`:`Update models from this service’s /models endpoint at startup and on schedule.`})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[o.modelsSection,m.length>0?` (${m.length})`:``]}),(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>F(null,!0),children:[(0,$.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),o.addModel]})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:m.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,q.press),onClick:()=>F(e,!1),"aria-label":o.editModel,children:(0,$.jsx)(y,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,q.press),onClick:()=>E(e.id),"aria-label":o.removeModel,children:(0,$.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),x?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(J,{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:()=>w(!0),children:[(0,$.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(J,{type:`button`,variant:`primary`,disabled:v,onClick:()=>void M(),children:v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(Ge,{open:C,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void P(),onCancel:()=>w(!1)}),(0,$.jsx)(Ge,{open:T!==null,title:o.removeModel,description:o.removeModelConfirm.replace(`{{id}}`,T??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{T&&L(T)},onCancel:()=>E(null)}),(0,$.jsx)(_r,{open:D,onOpenChange:e=>{O(e),e||A(null)},providerId:e,model:k?.model??null,isNew:k?.isNew??!1,onSave:e=>void I(e),m:o})]})}async function wr(){let e=await p(m(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function Tr(){let e=f(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=g(Ee,wr,{revalidateOnFocus:!1}),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null);if(r)return(0,$.jsx)(Re,{className:`h-24 w-full rounded-2xl`});let c=Object.values(t?.sources??{}),l=c.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),u=(t?.references??[]).filter(e=>e.availability===`unavailable`),d=t?.sync.lastSuccessAt??Math.max(0,...c.map(e=>e.lastSuccessAt)),h=o??(n instanceof Error?n.message:t?.sync.lastError??Object.values(t?.sync.sourceErrors??{})[0]),_=async()=>{a(!0),s(null);try{let e=await p(m(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await Ce()}catch(t){s(t instanceof Error?t.message:e?`模型目录刷新失败`:`Model catalog refresh failed`)}finally{a(!1)}};return(0,$.jsx)(`div`,{className:`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-4`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h||u.length>0?(0,$.jsx)(Oe,{className:`size-4 text-amber-500`,"aria-hidden":!0}):(0,$.jsx)(je,{className:`size-4 text-emerald-500`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e?`模型目录同步`:`Model catalog sync`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e?`${c.length} 个来源,${l} 个可用模型${d?` · 最近同步 ${new Date(d).toLocaleString()}`:``}`:`${c.length} sources, ${l} available models${d?` · Last synced ${new Date(d).toLocaleString()}`:``}`}),u.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 text-sm text-amber-700 dark:text-amber-300`,children:u.slice(0,3).map(t=>(0,$.jsxs)(`p`,{children:[t.ref,` `,e?`不可用`:`is unavailable`,t.suggestedRef?` · ${e?`建议`:`Suggested`} ${t.suggestedRef}`:``,` · ${t.locations.length} ${e?`处引用`:`references`}`]},t.ref))}):null,h?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-danger`,children:h}):null]}),(0,$.jsxs)(J,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void _(),children:[i?(0,$.jsx)(Y,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(w,{className:`size-4`,"aria-hidden":!0}),i?e?`刷新中…`:`Refreshing…`:e?`立即刷新`:`Refresh now`]})]})})}async function Er(){return(await h(m(`/api/models/xopc-cloud/account-summary`))).payload}function Dr(e){let t=(0,Z.c)(93),{labels:n}=e,r=f(Or)===`zh`?`zh-CN`:`en-US`,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:6e4,revalidateOnFocus:!0},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,isValidating:c,mutate:l}=g(`/api/models/xopc-cloud/account-summary`,Er,i);if(s){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Re,{className:`h-48 w-full rounded-2xl`}),t[1]=e):e=t[1],e}if(o||!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Oe,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),t[2]=e):e=t[2];let r;t[3]===n.title?r=t[4]:(r=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[3]=n.title,t[4]=r);let i;t[5]===n.unavailable?i=t[6]:(i=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.unavailable}),t[5]=n.unavailable,t[6]=i);let a;t[7]!==r||t[8]!==i?(a=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[e,(0,$.jsxs)(`div`,{children:[r,i]})]}),t[7]=r,t[8]=i,t[9]=a):a=t[9];let o;t[10]===l?o=t[11]:(o=()=>void l(),t[10]=l,t[11]=o);let s=c?`size-4 animate-spin`:`size-4`,u;t[12]===s?u=t[13]:(u=(0,$.jsx)(w,{className:s,"aria-hidden":!0}),t[12]=s,t[13]=u);let d;t[14]!==c||t[15]!==n.retry||t[16]!==o||t[17]!==u?(d=(0,$.jsxs)(J,{type:`button`,variant:`secondary`,disabled:c,onClick:o,children:[u,n.retry]}),t[14]=c,t[15]=n.retry,t[16]=o,t[17]=u,t[18]=d):d=t[18];let f;return t[19]!==a||t[20]!==d?(f=(0,$.jsx)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[a,d]})}),t[19]=a,t[20]=d,t[21]=f):f=t[21],f}let u,d,p,m,h,_,v,y;if(t[22]!==a.balance.credits||t[23]!==a.usage.chargedCredits||t[24]!==a.usage.requests||t[25]!==a.usage.totalTokens||t[26]!==n.availableCredits||t[27]!==n.connected||t[28]!==n.title||t[29]!==n.usageSummary||t[30]!==r){let e=new Intl.NumberFormat(r);y=n.usageSummary.replace(`{{tokens}}`,e.format(a.usage.totalTokens)).replace(`{{credits}}`,e.format(a.usage.chargedCredits)).replace(`{{requests}}`,e.format(a.usage.requests)),v=`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-5`,_=`flex flex-col gap-5 sm:flex-row sm:items-start sm:justify-between`,p=`min-w-0 flex-1`;let i;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(Me,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),t[39]=i):i=t[39];let o;t[40]===n.title?o=t[41]:(o=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[40]=n.title,t[41]=o);let s;t[42]===n.connected?s=t[43]:(s=(0,$.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-700 dark:text-emerald-300`,children:n.connected}),t[42]=n.connected,t[43]=s),t[44]!==o||t[45]!==s?(m=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i,o,s]}),t[44]=o,t[45]=s,t[46]=m):m=t[46],t[47]===n.availableCredits?h=t[48]:(h=(0,$.jsx)(`p`,{className:`mt-5 text-xs font-medium text-fg-subtle`,children:n.availableCredits}),t[47]=n.availableCredits,t[48]=h),u=`mt-1 text-3xl font-semibold tracking-tight text-fg`,d=e.format(a.balance.credits),t[22]=a.balance.credits,t[23]=a.usage.chargedCredits,t[24]=a.usage.requests,t[25]=a.usage.totalTokens,t[26]=n.availableCredits,t[27]=n.connected,t[28]=n.title,t[29]=n.usageSummary,t[30]=r,t[31]=u,t[32]=d,t[33]=p,t[34]=m,t[35]=h,t[36]=_,t[37]=v,t[38]=y}else u=t[31],d=t[32],p=t[33],m=t[34],h=t[35],_=t[36],v=t[37],y=t[38];let b;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(`span`,{className:`ml-2 text-sm font-medium text-fg-muted`,children:`credits`}),t[49]=b):b=t[49];let x;t[50]!==u||t[51]!==d?(x=(0,$.jsxs)(`p`,{className:u,children:[d,b]}),t[50]=u,t[51]=d,t[52]=x):x=t[52];let S;t[53]!==a.balance.credits||t[54]!==n.zeroBalance?(S=a.balance.credits===0?(0,$.jsx)(`p`,{className:`mt-2 text-sm font-medium text-danger`,children:n.zeroBalance}):null,t[53]=a.balance.credits,t[54]=n.zeroBalance,t[55]=S):S=t[55];let C;t[56]===n.recentUsage?C=t[57]:(C=(0,$.jsx)(`p`,{className:`mt-5 text-xs font-medium text-fg-subtle`,children:n.recentUsage}),t[56]=n.recentUsage,t[57]=C);let T;t[58]===y?T=t[59]:(T=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:y}),t[58]=y,t[59]=T);let E;t[60]!==a.balance.updatedAt||t[61]!==n.updatedAt||t[62]!==r?(E=n.updatedAt.replace(`{{time}}`,new Date(a.balance.updatedAt).toLocaleString(r)),t[60]=a.balance.updatedAt,t[61]=n.updatedAt,t[62]=r,t[63]=E):E=t[63];let D;t[64]===E?D=t[65]:(D=(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:E}),t[64]=E,t[65]=D);let O;t[66]!==x||t[67]!==S||t[68]!==C||t[69]!==T||t[70]!==D||t[71]!==p||t[72]!==m||t[73]!==h?(O=(0,$.jsxs)(`div`,{className:p,children:[m,h,x,S,C,T,D]}),t[66]=x,t[67]=S,t[68]=C,t[69]=T,t[70]=D,t[71]=p,t[72]=m,t[73]=h,t[74]=O):O=t[74];let k;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(R,{className:`size-3.5`,"aria-hidden":!0}),t[75]=k):k=t[75];let A;t[76]!==a.links.purchase||t[77]!==n.purchase?(A=(0,$.jsx)(J,{asChild:!0,variant:`primary`,children:(0,$.jsxs)(`a`,{href:a.links.purchase,target:`_blank`,rel:`noreferrer`,children:[n.purchase,k]})}),t[76]=a.links.purchase,t[77]=n.purchase,t[78]=A):A=t[78];let j;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(R,{className:`size-3.5`,"aria-hidden":!0}),t[79]=j):j=t[79];let M;t[80]!==a.links.details||t[81]!==n.details?(M=(0,$.jsx)(J,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(`a`,{href:a.links.details,target:`_blank`,rel:`noreferrer`,children:[n.details,j]})}),t[80]=a.links.details,t[81]=n.details,t[82]=M):M=t[82];let N;t[83]!==A||t[84]!==M?(N=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[A,M]}),t[83]=A,t[84]=M,t[85]=N):N=t[85];let P;t[86]!==O||t[87]!==N||t[88]!==_?(P=(0,$.jsxs)(`div`,{className:_,children:[O,N]}),t[86]=O,t[87]=N,t[88]=_,t[89]=P):P=t[89];let F;return t[90]!==P||t[91]!==v?(F=(0,$.jsx)(`section`,{className:v,children:P}),t[90]=P,t[91]=v,t[92]=F):F=t[92],F}function Or(e){return e.language}function kr(e){return _.includes(e)}function Ar(){let e=(0,Z.c)(84),t=f(Pr),n;e[0]===t?n=e[1]:(n=u(t),e[0]=t,e[1]=n);let r=n,l=r.capabilitiesSettings,d=o(),[p,m]=a(),{capability:h}=i(),g=Mt(Nr),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),x=ar(),S;e[2]===x.cards?S=e[3]:(S=x.cards.some(Mr),e[2]=x.cards,e[3]=S);let C=S,w,T;e[4]!==h||e[5]!==p||e[6]!==m?(w=()=>{if(h!==`models`||p.get(`add`)!==`1`)return;v(!0);let e=new URLSearchParams(p);e.delete(`add`),m(e,{replace:!0})},T=[h,p,m],e[4]=h,e[5]=p,e[6]=m,e[7]=w,e[8]=T):(w=e[7],T=e[8]),(0,Q.useEffect)(w,T);let E;e[9]!==l.unsavedChanges||e[10]!==g?(E=e=>g.get(e)?.dirty?(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-label":l.unsavedChanges,title:l.unsavedChanges}):void 0,e[9]=l.unsavedChanges,e[10]=g,e[11]=E):E=e[11];let D=E,O;e[12]!==l.modelsHint||e[13]!==l.tabs.models?(O={id:`models`,icon:k,label:l.tabs.models,hint:l.modelsHint},e[12]=l.modelsHint,e[13]=l.tabs.models,e[14]=O):O=e[14];let A=l.tabs.image,j=l.imageHint,M;e[15]===D?M=e[16]:(M=D(`image-models`),e[15]=D,e[16]=M);let N;e[17]!==l.imageHint||e[18]!==l.tabs.image||e[19]!==M?(N={id:`image`,icon:nt,label:A,hint:j,suffix:M},e[17]=l.imageHint,e[18]=l.tabs.image,e[19]=M,e[20]=N):N=e[20];let P=l.tabs.voice,I=l.voiceHint,L;e[21]===D?L=e[22]:(L=D(`voice`),e[21]=D,e[22]=L);let R;e[23]!==l.tabs.voice||e[24]!==l.voiceHint||e[25]!==L?(R={id:`voice`,icon:ce,label:P,hint:I,suffix:L},e[23]=l.tabs.voice,e[24]=l.voiceHint,e[25]=L,e[26]=R):R=e[26];let z=l.tabs.search,B=l.searchHint,V;e[27]===D?V=e[28]:(V=D(`search`),e[27]=D,e[28]=V);let H;e[29]!==l.searchHint||e[30]!==l.tabs.search||e[31]!==V?(H={id:`search`,icon:Ne,label:z,hint:B,suffix:V},e[29]=l.searchHint,e[30]=l.tabs.search,e[31]=V,e[32]=H):H=e[32];let ee;e[33]!==R||e[34]!==H||e[35]!==O||e[36]!==N?(ee=[O,N,R,H],e[33]=R,e[34]=H,e[35]=O,e[36]=N,e[37]=ee):ee=e[37];let te=ee,ne;e[38]===d?ne=e[39]:(ne=e=>d(tt(e)),e[38]=d,e[39]=ne);let re=ne,U=jr;if(!kr(h)){let t;return e[40]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(s,{to:tt(`models`),replace:!0}),e[40]=t):t=e[40],t}let ie=r.nav.settingsCapabilities,W=l.subtitle,G;e[41]===t?G=e[42]:(G=Ke(t,`configuration`),e[41]=t,e[42]=G);let K;e[43]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(F,{className:`size-4`,"aria-hidden":!0}),e[43]=K):K=e[43];let ae;e[44]===l.agentSettingsLink?ae=e[45]:(ae=(0,$.jsx)(J,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(c,{to:`/agents`,children:[K,l.agentSettingsLink]})}),e[44]=l.agentSettingsLink,e[45]=ae);let q;e[46]!==l.docsLink||e[47]!==l.subtitle||e[48]!==r.nav.settingsCapabilities||e[49]!==G||e[50]!==ae?(q=(0,$.jsx)(ct,{title:ie,subtitle:W,docsLink:G,docsLabel:l.docsLink,actions:ae}),e[46]=l.docsLink,e[47]=l.subtitle,e[48]=r.nav.settingsCapabilities,e[49]=G,e[50]=ae,e[51]=q):q=e[51];let oe;e[52]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(Nt,{}),e[52]=oe):oe=e[52];let se;e[53]!==l.tabsAria||e[54]!==h||e[55]!==te||e[56]!==re?(se=(0,$.jsx)(wt,{items:te,activeTab:h,onChange:re,ariaLabel:l.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}),e[53]=l.tabsAria,e[54]=h,e[55]=te,e[56]=re,e[57]=se):se=e[57];let le;e[58]!==l.connectedProviders||e[59]!==l.xopcCloudAccount||e[60]!==h||e[61]!==x||e[62]!==te||e[63]!==C?(le=te.map(e=>(0,$.jsx)(Ir,{id:e.id,activeSection:h,hint:e.hint,children:e.id===`models`?(0,$.jsxs)($.Fragment,{children:[C?(0,$.jsx)(Dr,{labels:l.xopcCloudAccount}):null,(0,$.jsx)(Tr,{}),(0,$.jsx)(dr,{labels:l.connectedProviders,data:x,onAdd:()=>v(!0),onManage:(e,t)=>b({providerId:e,isCustom:t})})]}):(0,$.jsx)(Fr,{section:e.id})},e.id)),e[58]=l.connectedProviders,e[59]=l.xopcCloudAccount,e[60]=h,e[61]=x,e[62]=te,e[63]=C,e[64]=le):le=e[64];let ue;e[65]!==_||e[66]!==l.addProviderDialog||e[67]!==t||e[68]!==x.builtinRows||e[69]!==x.customConfig?(ue=(0,$.jsx)(Qn,{open:_,onOpenChange:v,builtinRows:x.builtinRows,customConfig:x.customConfig,labels:l.addProviderDialog,language:t,onSaved:U}),e[65]=_,e[66]=l.addProviderDialog,e[67]=t,e[68]=x.builtinRows,e[69]=x.customConfig,e[70]=ue):ue=e[70];let de;e[71]!==l.manageProviderDialog||e[72]!==t||e[73]!==y||e[74]!==x.allModels||e[75]!==x.builtinRows||e[76]!==x.customConfig?(de=y?(0,$.jsx)(xr,{open:!0,onOpenChange:e=>{e||b(null)},providerId:y.providerId,isCustom:y.isCustom,builtinRows:x.builtinRows,customConfig:x.customConfig,allModels:x.allModels,labels:l.manageProviderDialog,language:t,onSaved:U}):null,e[71]=l.manageProviderDialog,e[72]=t,e[73]=y,e[74]=x.allModels,e[75]=x.builtinRows,e[76]=x.customConfig,e[77]=de):de=e[77];let fe;return e[78]!==q||e[79]!==se||e[80]!==le||e[81]!==ue||e[82]!==de?(fe=(0,$.jsxs)(lt,{children:[q,oe,se,le,ue,de]}),e[78]=q,e[79]=se,e[80]=le,e[81]=ue,e[82]=de,e[83]=fe):fe=e[83],fe}function jr(){Ce()}function Mr(e){return e.id===`xopc-cloud`&&!e.isCustom}function Nr(e){return e.sections}function Pr(e){return e.language}function Fr(e){let t=(0,Z.c)(3),{section:n}=e;switch(n){case`models`:return null;case`image`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(qt,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(xn,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(qn,{}),t[2]=e):e=t[2],e}}}function Ir({id:e,activeSection:t,hint:n,children:r}){let i=e===t,a=(0,Q.useRef)(i);return i&&(a.current=!0),a.current?(0,$.jsxs)(`div`,{role:`tabpanel`,id:`capability-panel-${e}`,"aria-labelledby":`capability-tab-${e}`,hidden:!i,className:l(`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,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{Ar as CapabilitiesSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,s as t}from"./locale-store-
|
|
1
|
+
import{r as e,s as t}from"./locale-store-BP0vD37A.js";var n=[{key:`code-intelligence`,toolIds:[`code_search`,`code_read_symbol`,`code_trace`,`code_impact`,`code_architecture`]},{key:`workspace`,toolIds:[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`]},{key:`execution`,toolIds:[`exec_command`,`execute_code`]},{key:`messaging`,toolIds:[`send_message`,`send_media`,`text_to_speech`]},{key:`memory`,toolIds:[`memory_search`,`memory_get`,`curated_memory`,`session_search`]},{key:`media`,toolIds:[`image`,`image_generate`,`read_media`,`create_share`]},{key:`web`,toolIds:[`web_search`,`web_fetch`,`web_extract`,`browser_use`]},{key:`misc`,toolIds:[`session_status`,`dreaming`,`tool_manual`,`clarify`,`todo`,`update_plan`,`automation`,`workflow`,`delegate_task`]},{key:`unknown`,toolIds:[`skills_list`,`skill_view`,`skill_manage`]},{key:`extensions`,toolIds:[`extensions`]},{key:`mcp`,toolIds:[`bundle-mcp`]}],r=new Set(n.flatMap(e=>[...e.toolIds].map(e=>String(e))));function i(e){return e.filter(e=>e&&!r.has(e)).sort((e,t)=>e.localeCompare(t))}async function a(){let n=await t(e(`/api/capability-presets`));if(!Array.isArray(n.payload?.presets)||typeof n.payload.defaultPresetId!=`string`||!Array.isArray(n.payload.agents)||!Array.isArray(n.payload.builtinToolIds))throw Error(`Invalid /api/capability-presets response`);return n.payload}async function o(n){let r=await t(e(`/api/capability-presets`),{method:`POST`,body:JSON.stringify(n)}),i=r.payload?.presetId,a=r.payload?.presets;if(!i||!a||typeof a.defaultPresetId!=`string`||!Array.isArray(a.presets)||!Array.isArray(a.agents)||!Array.isArray(a.builtinToolIds))throw Error(`Invalid create capability preset response`);return{presetId:i,presets:a}}async function s(n,r){let i=await t(e(`/api/capability-presets/${encodeURIComponent(n)}`),{method:`PATCH`,body:JSON.stringify(r)});if(!Array.isArray(i.payload?.presets)||typeof i.payload.defaultPresetId!=`string`||!Array.isArray(i.payload.agents)||!Array.isArray(i.payload.builtinToolIds))throw Error(`Invalid update capability preset response`);return i.payload}async function c(n){let r=await t(e(`/api/capability-presets/${encodeURIComponent(n)}`),{method:`DELETE`});if(!Array.isArray(r.payload?.presets)||typeof r.payload.defaultPresetId!=`string`||!Array.isArray(r.payload.agents)||!Array.isArray(r.payload.builtinToolIds))throw Error(`Invalid delete capability preset response`);return r.payload}export{n as a,s as i,c as n,i as o,a as r,o as t};
|