@xopcai/xopc 0.0.187 → 0.0.188
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/demo-memory/src/index.js +1 -0
- package/dist/extensions/feishu/src/streaming/streaming-adapter.js +1 -3
- package/dist/extensions/telegram/src/adapters/streaming-adapter.js +0 -2
- package/dist/extensions/telegram/src/draft-stream.d.ts +0 -4
- package/dist/extensions/telegram/src/draft-stream.js +1 -53
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-WlR2zEvA.js → activity-store--QoUGhiS.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-RedDszrG.js → agent-avatar-dicebear-B0yweLNQ.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-Df9mTa-K.js → agents-C6OV-gMm.js} +1 -1
- package/dist/gateway/static/root/assets/{api-tVOllncq.js → api-5laWqfiE.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-C9hKBzaF.js → app-management-settings-panel-BXJ8Jiv_.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-5cQvq7hd.js → appearance-settings-DG9n9D1M.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-Bd3tN-k2.js → apps-page-Ci14lDeO.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-Ct-shK4n.js → archive-plugin-Ceh5qrZf.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CpPj3m-q.js → attachment-load-jFW7uYf7.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-Q1xmb4Rh.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BpSXZBle.js → binary-plugins-XDlkI1r4.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-B8hR2tXc.js → block-editor-kyKc2IhE.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-jb5Hf-hm.js → browser-settings-page-DbowrHXD.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-D_LAXUrh.js → browser-workflow-inputs-BJa5Iz_v.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CPAs7-6s.js → browser-workflows-page-CTQQOsn5.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-BjUe4raq.js → capabilities-settings-panel-DoZPFdKF.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-api-CKklVY2p.js → capability-presets-api-Dn-7MMEo.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DiWIMYRr.js → capability-presets-settings-panel-Bt8Hnx0h.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-WWN-nbFL.js → channel-recipient-api-BgIkWq01.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-D8IkjMuX.js → channels-settings-Bpsebsru.js} +1 -1
- package/dist/gateway/static/root/assets/channels-status-swr-DFmdYRE5.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-CdNkVFdB.js → connector-logo-TRr9ybf6.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-BT2ahw52.js → connectors-page-Tg5kl22i.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Bm_IEAf3.js → desktop-pet-CSwd00CV.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-C0Ve04-G.js → desktop-pet-settings-CuNQvHGu.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-B2cvhvAI.js → directory-picker-path-field-ct0n5Rje.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DNashgGu.js → extension-debug-page-BeRBuMUU.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Bvo-5htX.js → extension-page-DbK-Cwao.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BBESdISV.js → extension-settings-page-C9ag5tb5.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-ClQvokMo.js → gateway-config-api-CC7EvEFp.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CIRs2QVy.js → gateway-settings-9g8uIry9.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CntXJF6W.js → gateway-startup-retry-B2DmdlwO.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-CWKcZuvc.js → heartbeat-settings-fl1oC_-5.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-C59f8UJw.js → home-page-Bao9jq_z.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-DjSAQwGy.js → image-generation-api-GMTaS6eI.js} +1 -1
- package/dist/gateway/static/root/assets/index-Cl5n1f_U.css +1 -0
- package/dist/gateway/static/root/assets/index-OJgiMh07.js +223 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-ahKHpjoW.js → keyboard-shortcuts-settings-DhGYddbI.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DRB4UQBE.js → local-app-workbench-page-B69NvtvH.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-B6GKdgza.js → local-apps-page-CmnrBmWi.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Bff30u5V.js → locale-store-D6hs74o5.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CNp4XiBN.js → logs-page-Cq3cABqg.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-BeNMJm_i.js → markdown-split-CZaBPOVn.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Bdzrj_-6.js → media-plugins-CiKvSgCv.js} +1 -1
- package/dist/gateway/static/root/assets/messages-D02NNLCZ.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-MYIi-9S9.js → notes-page-Bisbzqlz.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-DqSkeDXX.js → notes-workbench-BOZfJFhE.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-3t88bbGx.js → page-tabs-BxlwhAbH.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-Cf_BWbeE.js → preview-open-alternatives-RM8wXxfT.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CKq73c98.js → product-open-page-DdBlibek.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-BrbHs4Wp.js → project-detail-page-TSKFb2tN.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-B80rtkj6.js → projects-page-BokeBrTT.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-_Q3GEznb.js → remote-access-hub-C56anxCX.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-NqOm-OG1.js → schema-form-BDKbpmXv.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-55dJOUVg.js → sessions-page-C7TQADrD.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BDOPKeAX.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-DYAS8p8z.js → settings-form-section-zxo5ZGOu.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DZFhxihA.js → settings-loading-skeleton-DgIp8_S6.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BSIiMLi-.js → settings-page-BUPSIa9P.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-DfFfkdED.js → settings-page-layout-97LmwrzC.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-q_yE6-H1.js → setup-status-panel-BRg766eW.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CYtrQaZN.js → share-preview-page-BH7i3g1S.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-gYkRX9Ik.js → shares-settings-DhEAviQ_.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Ct7AV8ls.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-GZHKDFSb.js → skills-page-DoVuprZm.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-BBXirAjc.js → skills-page.utils-s-a5WV9j.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DLf5YvFl.js → system-settings-panel-BxjeMT5k.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DFGkuYfl.js → task-detail-page-BahycnfW.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-y7e_tvYi.js → theme-store-BRxdsmic.js} +1 -1
- package/dist/gateway/static/root/assets/{time-picker-5sHEZ5w5.js → time-picker-BGk_Tbsj.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-DR12j_dr.js → typed-models-lib-39MjwPSq.js} +1 -1
- package/dist/gateway/static/root/assets/{use-save-bar-registration-BsvcJgZl.js → use-save-bar-registration-5aVSjTjO.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-q5dr8JFG.js → user-context-page-B9K41qmy.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DKADXFWD.js → voice-api-key-field-XU-7sBSg.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BC1nExf8.js → work-discovery-overlay-CJqu8UHq.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-fNvSg40M.js → work-discovery-page-BBVnRHju.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C8X5W-8k.js → workflow-run-setup-panel-DXtg8Qxl.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-YJBKmPYK.js → workflows-page-Bs_tYfst.js} +1 -1
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/tool-activity.js +223 -0
- package/dist/src/agent/agent-manager.js +2 -8
- package/dist/src/agent/code-intelligence/binary.js +1 -1
- package/dist/src/agent/embedded/run-for-session.d.ts +0 -2
- package/dist/src/agent/embedded/run-for-session.js +99 -112
- package/dist/src/agent/external-tools/composio-provider.d.ts +29 -0
- package/dist/src/agent/external-tools/composio-provider.js +307 -0
- package/dist/src/agent/external-tools/extension-provider.d.ts +20 -0
- package/dist/src/agent/external-tools/extension-provider.js +68 -0
- package/dist/src/agent/external-tools/gateway-tools.d.ts +8 -0
- package/dist/src/agent/external-tools/gateway-tools.js +89 -0
- package/dist/src/agent/external-tools/index.d.ts +24 -0
- package/dist/src/agent/external-tools/index.js +40 -0
- package/dist/src/agent/external-tools/mcp-provider.d.ts +29 -0
- package/dist/src/agent/external-tools/mcp-provider.js +118 -0
- package/dist/src/agent/external-tools/memory-provider.d.ts +21 -0
- package/dist/src/agent/external-tools/memory-provider.js +56 -0
- package/dist/src/agent/external-tools/refs.d.ts +5 -0
- package/dist/src/agent/external-tools/refs.js +18 -0
- package/dist/src/agent/external-tools/service.d.ts +26 -0
- package/dist/src/agent/external-tools/service.js +117 -0
- package/dist/src/agent/external-tools/types.d.ts +28 -0
- package/dist/src/agent/external-tools/types.js +9 -0
- package/dist/src/agent/inbound/inbound-loop.d.ts +0 -2
- package/dist/src/agent/inbound/inbound-loop.js +0 -3
- package/dist/src/agent/mcp/{bundle-mcp-materialize.d.ts → bundle-mcp-gateway.d.ts} +1 -19
- package/dist/src/agent/mcp/bundle-mcp-gateway.js +60 -0
- package/dist/src/agent/mcp/bundle-mcp-names.d.ts +0 -8
- package/dist/src/agent/mcp/bundle-mcp-names.js +2 -29
- package/dist/src/agent/mcp/bundle-mcp-policy.d.ts +4 -7
- package/dist/src/agent/mcp/bundle-mcp-policy.js +6 -20
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +2 -2
- package/dist/src/agent/mcp/bundle-mcp-tools.d.ts +1 -2
- package/dist/src/agent/mcp/bundle-mcp-tools.js +1 -2
- package/dist/src/agent/mcp/bundle-mcp-types.d.ts +0 -5
- package/dist/src/agent/mcp/index.d.ts +0 -2
- package/dist/src/agent/mcp/index.js +2 -5
- package/dist/src/agent/mcp/mcp-stdio-transport.js +1 -1
- package/dist/src/agent/mcp/mcp-transport.js +1 -1
- package/dist/src/agent/memory/context/planner.d.ts +1 -0
- package/dist/src/agent/memory/context/planner.js +22 -7
- package/dist/src/agent/memory/manager.d.ts +4 -1
- package/dist/src/agent/memory/manager.js +5 -2
- package/dist/src/agent/memory/types.d.ts +2 -0
- package/dist/src/agent/messaging/stream-manager.d.ts +2 -14
- package/dist/src/agent/messaging/stream-manager.js +0 -12
- package/dist/src/agent/orchestration/agent-event-handler.d.ts +1 -3
- package/dist/src/agent/orchestration/agent-event-handler.js +0 -36
- package/dist/src/agent/orchestration/agent-orchestrator.d.ts +0 -5
- package/dist/src/agent/orchestration/agent-orchestrator.js +0 -5
- package/dist/src/agent/prompt/sections/behavior.js +6 -4
- package/dist/src/agent/service.d.ts +0 -3
- package/dist/src/agent/service.js +0 -28
- package/dist/src/agent/service.types.d.ts +0 -3
- package/dist/src/agent/skills/hub-pull.js +1 -1
- package/dist/src/agent/starter-agents.js +2 -2
- package/dist/src/agent/tools/delegate-tool.js +5 -1
- package/dist/src/agent/tools/executor.js +1 -1
- package/dist/src/agent/tools/factory.d.ts +2 -1
- package/dist/src/agent/tools/factory.js +16 -22
- package/dist/src/agent/tools/index.d.ts +0 -1
- package/dist/src/agent/tools/index.js +1 -2
- package/dist/src/agent/workflow/workflow-child-tools.js +7 -1
- package/dist/src/browser/providers/cloakbrowser.js +1 -1
- package/dist/src/channels/channel-domain.d.ts +0 -4
- package/dist/src/channels/plugin-types.d.ts +0 -2
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/connectors/health.js +1 -1
- package/dist/src/extensions/extension-registry-impl.d.ts +3 -1
- package/dist/src/extensions/extension-registry-impl.js +7 -1
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/extensions/types/core.d.ts +2 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agent-builtin-tools.js +5 -2
- package/dist/src/gateway/chat-stream/mapper.js +16 -1
- package/dist/src/gateway/chat-stream/protocol.d.ts +4 -0
- package/dist/src/gateway/file-reference-errors.d.ts +6 -0
- package/dist/src/gateway/file-reference-errors.js +21 -0
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/hono/routes/projects.js +34 -13
- package/dist/src/gateway/hono/routes/workflows.js +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +34 -13
- package/dist/src/gateway/hono/routes/you.js +3 -3
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +4 -1
- package/dist/src/gateway/service.js +6 -6
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/share/share-zip.js +1 -1
- package/dist/src/storage/sqlite/memory-records-repository.js +3 -1
- package/dist/src/storage/sqlite/migrations/108_repair_user_memory_provider.sql +18 -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/tui/tool-summary.d.ts +1 -2
- package/dist/src/tui/tool-summary.js +2 -18
- package/dist/src/tunnel/frpc-binary.js +1 -1
- package/dist/src/user-context/projection.d.ts +1 -0
- package/dist/src/user-context/projection.js +2 -1
- package/dist/src/voice/local/model-files.js +1 -1
- package/dist/src/work-discovery/service.js +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/automations-page-w6K9GZQ7.js +0 -6
- package/dist/gateway/static/root/assets/channels-status-swr-CySs1GQX.js +0 -1
- package/dist/gateway/static/root/assets/index-D-YfWVyS.css +0 -1
- package/dist/gateway/static/root/assets/index-vi5KlR5_.js +0 -222
- package/dist/gateway/static/root/assets/messages-CPxz48hr.js +0 -3
- package/dist/gateway/static/root/assets/settings-advanced-gate-CSFCZj14.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BoNBMKW6.js +0 -1
- package/dist/src/agent/feedback/feedback-coordinator.d.ts +0 -73
- package/dist/src/agent/feedback/feedback-coordinator.js +0 -156
- package/dist/src/agent/feedback/index.d.ts +0 -4
- package/dist/src/agent/feedback/index.js +0 -2
- package/dist/src/agent/lifecycle/progress.d.ts +0 -90
- package/dist/src/agent/lifecycle/progress.js +0 -339
- package/dist/src/agent/mcp/bundle-mcp-materialize.js +0 -183
- package/dist/src/agent/mcp/mcp-tool-meta.d.ts +0 -8
- package/dist/src/agent/mcp/mcp-tool-meta.js +0 -13
- package/dist/src/agent/mcp/resolve-embedded-mcp-tools.d.ts +0 -14
- package/dist/src/agent/mcp/resolve-embedded-mcp-tools.js +0 -48
- package/dist/src/agent/tools/composio-tool.d.ts +0 -21
- package/dist/src/agent/tools/composio-tool.js +0 -261
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,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-
|
|
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-D02NNLCZ.js";import{l as d,n as f,o as p,r as m,s as h}from"./locale-store-D6hs74o5.js";import{i as g}from"./vendor-swr-BIWyz7Rc.js";import{$a as _,$o as v,$s as y,An as b,Bn as x,Bo as S,Cc as C,Cn as w,Cs as T,Dn as E,Dt as D,En as O,Es as k,Fl as A,Fn as j,Ft as M,Gn as N,Go as P,Gr as F,Hn as I,Ho as L,Hs as R,In as ee,Io as z,It as B,Jn as V,Jo as te,Kc as H,Kn as ne,Ln as U,Lo as re,Lt as ie,Mn as ae,Nn as W,Ns as G,On as K,Ot as oe,Pl as se,Pn as q,Ps as ce,Qo as J,Rn as le,Ro as ue,Rr as de,Sn as fe,Tc as pe,Tn as me,Ts as he,Un as ge,Us as _e,Vc as ve,Vo as ye,Wn as be,Wo as xe,Xn as Se,Yn as Ce,Zn as we,_s as Te,as as Ee,bn as De,bs as Oe,cl as ke,eo as Ae,es as Y,fc as je,fl as Me,gc as Ne,hs as Pe,ic as Fe,jn as Ie,kc as Le,kn as Re,ks as ze,lc as Be,lu as Ve,ms as He,os as Ue,ou as We,qc as X,ql as Ge,qn as Ke,qo as qe,to as Je,tr as Ye,vs as Xe,wc as Ze,wn as Qe,ws as $e,wu as et,xl as tt,xn as nt,xu as rt,yn as it,ys as at,zn as ot,zo as st}from"./index-OJgiMh07.js";import{n as ct,r as lt}from"./settings-page-layout-97LmwrzC.js";import{t as ut}from"./settings-loading-skeleton-DgIp8_S6.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-XU-7sBSg.js";import{t as xt}from"./settings-advanced-gate-BDOPKeAX.js";import{n as St,t as Ct}from"./settings-form-section-zxo5ZGOu.js";import{t as wt}from"./page-tabs-BxlwhAbH.js";import{a as Tt,i as Et,n as Dt,o as Ot,r as kt,t as At}from"./image-generation-api-GMTaS6eI.js";import{n as jt,r as Mt,t as Nt}from"./use-save-bar-registration-5aVSjTjO.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
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)(``),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(`/images/generations`),[O,A]=(0,Q.useState)(`/images/edits`),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(``),[F,I]=(0,Q.useState)([It()]),[R,ee]=(0,Q.useState)(``),[B,V]=(0,Q.useState)(),[te,H]=(0,Q.useState)(!1),[U,ie]=(0,Q.useState)(),[ae,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??``),T(t?.documentationUrl??``),D(t?.paths?.generations??`/images/generations`),A(t?.paths?.edits??`/images/edits`),M(t?.network?.allowedHosts.join(`
|
|
3
3
|
`)??``),P(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
4
4
|
`)),I(t?.models.map(It)??[It()]),ee(t?.defaultModel??``),V(void 0),H(!1),ie(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))},oe=()=>{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=R||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=Lt(N)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:f.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:u.trim(),...w.trim()?{documentationUrl:w.trim()}:{},...b.trim()?{apiKeyUrl:b.trim()}:{},defaultModel:n,auth:m===`header`?{type:`header`,headerName:g.trim()}:{type:m},paths:{...E.trim()?{generations:E.trim()}:{},...O.trim()?{edits:O.trim()}:{}},...j.trim()?{network:{allowedHosts:j.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,s as t}from"./locale-store-
|
|
1
|
+
import{r as e,s as t}from"./locale-store-D6hs74o5.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`,`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,r){let i=await t(e(`/api/capability-presets/${encodeURIComponent(n)}/preview`),{method:`POST`,body:JSON.stringify(r)});if(!Array.isArray(i.payload?.agents))throw Error(`Invalid capability preset preview response`);return i.payload}async function l(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{s as a,c as i,l as n,n as o,a as r,i as s,o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-CPxz48hr.js";import{l as c,n as l}from"./locale-store-Bff30u5V.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$o as d,As as f,Bo as p,Cc as m,Cu as h,Du as g,Es as _,Eu as v,Hl as y,Ho as b,Io as x,Kr as S,Lo as C,Mt as w,Pl as T,Qo as E,Ro as D,Us as O,Vo as k,as as A,bc as j,du as M,es as N,ic as P,ks as ee,os as F,pc as I,qc as L,sl as R,ts as z,wu as B,ys as V,yu as H,zo as U}from"./index-vi5KlR5_.js";import{n as W,r as te}from"./settings-page-layout-DfFfkdED.js";import{n as ne,r as re}from"./settings-loading-skeleton-DZFhxihA.js";import{n as G,t as K}from"./settings-form-section-DYAS8p8z.js";import{a as ie,i as ae,n as oe,o as se,r as ce,s as le,t as ue}from"./capability-presets-api-CKklVY2p.js";import{a as de,i as fe,o as q,s as J,t as Y}from"./typed-models-lib-DR12j_dr.js";import{r as pe}from"./image-generation-api-DjSAQwGy.js";var me=n(),X=e(t(),1),Z=r(),Q=[`deep`,`fast`,`cheap`,`code`,`review`];function he(e){return Q.includes(e)}function ge(e){let{rows:t,onChange:n,disabled:r,defaultRole:i,chat:a,labels:o}=e,s=(0,X.useRef)([]),c=(0,X.useRef)(0);for(;s.current.length<t.length;)s.current.push(`preset-model-row-${c.current++}`);s.current.length>t.length&&(s.current.length=t.length);let l=i??(t.some(e=>e.id===`deep`)?`deep`:t[0]?.id)??`deep`,u=t.findIndex(e=>e.id===l),d=u>=0?t[u]:void 0,f=t.map((e,t)=>({row:e,index:t})).filter(({index:e})=>e!==u),p=(e,r)=>{n(t.map((t,n)=>n===e?{...t,...r}:t))},h=e=>{if(u>=0){p(u,{model:e});return}s.current.unshift(`preset-model-row-${c.current++}`),n([{id:l,model:e,fallbacks:[],description:he(l)?o.roleDescriptions[l]:``},...t])},g=e=>{let n=t[e];n&&p(e,{fallbacks:[...n.fallbacks??[],``]})},v=(e,n,r)=>{let i=t[e];if(!i)return;let a=[...i.fallbacks??[]];a[n]=r,p(e,{fallbacks:a})},y=(e,n)=>{let r=t[e];r&&p(e,{fallbacks:(r.fallbacks??[]).filter((e,t)=>t!==n)})},b=e=>{s.current.splice(e,1),n(t.filter((t,n)=>n!==e))},x=e=>{if(!e)return;let r=e===`__custom__`?``:e;s.current.push(`preset-model-row-${c.current++}`),n([...t,{id:r,model:``,fallbacks:[],description:he(r)?o.roleDescriptions[r]:``}])},S=[...Q.filter(e=>e!==l&&!t.some(t=>t.id===e)).map(e=>({value:e,label:o.roleNames[e]})),{value:`__custom__`,label:o.customRole}],C=(e,t)=>(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.fallbackModels}),(0,Z.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:r,onClick:()=>g(t),children:[(0,Z.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),o.addFallback]})]}),(e.fallbacks??[]).length>0?(0,Z.jsx)(`div`,{className:`grid gap-1.5`,children:(e.fallbacks??[]).map((e,n)=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,Z.jsx)(w,{value:e,disabled:r,placeholder:o.fallbackPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>v(t,n,e)}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:r,"aria-label":o.removeFallback,onClick:()=>y(t,n),children:(0,Z.jsx)(O,{className:`size-4`,"aria-hidden":!0})})]},`${s.current[t]}-fallback-${n}`))}):(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.fallbackEmptyHint})]}),(0,Z.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-fg-muted`,children:[o.description,(0,Z.jsx)(`input`,{type:`text`,className:J(),value:e.description,disabled:r,placeholder:o.descriptionPlaceholder,onChange:e=>p(t,{description:e.target.value})})]})]});return(0,Z.jsxs)(`div`,{className:`grid gap-5`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:o.defaultTitle}),(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:o.defaultBadge})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:o.defaultHint})]}),(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 font-mono text-[11px] text-fg-subtle`,children:[o.roleId,`: `,l]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.primaryModel}),(0,Z.jsx)(w,{value:d?.model??``,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:h})]}),d?(0,Z.jsxs)(`details`,{className:`group mt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-md text-xs font-medium text-fg-muted hover:text-fg`,children:[o.moreSettings,(0,Z.jsx)(M,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3`,children:C(d,u)})]}):null]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:o.otherRolesTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:o.otherRolesHint})]}),f.length>0?(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:f.map(({row:e,index:t})=>{let n=he(e.id)?e.id:void 0;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/60 p-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(8rem,12rem)_minmax(0,1fr)] md:items-end`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n?o.roleNames[n]:o.customRole}),n?(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:e.id}):(0,Z.jsxs)(`label`,{className:`mt-1 grid gap-1 text-[11px] text-fg-muted`,children:[o.roleId,(0,Z.jsx)(`input`,{type:`text`,className:J(),value:e.id,disabled:r,placeholder:o.roleIdPlaceholder,onChange:e=>p(t,{id:e.target.value.toLowerCase()})})]})]}),(0,Z.jsxs)(`label`,{className:`grid min-w-0 gap-1.5 text-xs font-medium text-fg-muted`,children:[o.primaryModel,(0,Z.jsx)(w,{value:e.model,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>p(t,{model:e})})]})]}),(0,Z.jsxs)(`details`,{className:`group mt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[o.moreSettings,(0,Z.jsx)(M,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsxs)(`div`,{className:`mt-3`,children:[C(e,t),(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(_,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>b(t),children:[(0,Z.jsx)(O,{className:`size-4`,"aria-hidden":!0}),o.removeRole]})})]})]})]},s.current[t])})}):(0,Z.jsx)(`p`,{className:`mt-3 rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:o.otherRolesEmpty}),(0,Z.jsx)(E,{value:``,options:S,placeholder:o.addTaskModel,allowEmpty:!1,disabled:r,triggerClassName:`mt-3 w-fit`,onChange:x})]})]})}function _e(e){let t=(0,me.c)(62),{extendsIds:n,onExtendsChange:r,presetOptions:i,jsonFields:a,onJsonFieldsChange:o,disabled:s,labels:c}=e,l;t[0]===a?l=t[1]:(l=Object.keys(a),t[0]=a,t[1]=l);let u=l,d;t[2]===i?d=t[3]:(d=new Map(i.map(ve)),t[2]=i,t[3]=d);let f=d,p,v,y,b,x;if(t[4]!==s||t[5]!==n||t[6]!==c.inheritanceAdd||t[7]!==c.inheritanceApplied||t[8]!==c.inheritanceAvailable||t[9]!==c.inheritanceEmpty||t[10]!==c.inheritanceHint||t[11]!==c.inheritanceMoveDown||t[12]!==c.inheritanceMoveUp||t[13]!==c.inheritanceRemove||t[14]!==c.inheritanceTitle||t[15]!==r||t[16]!==f||t[17]!==i){let e;t[23]===n?e=t[24]:(e=e=>!n.includes(e.id),t[23]=n,t[24]=e);let a=i.filter(e);x=`flex flex-col gap-6`,t[25]===c.inheritanceTitle?p=t[26]:(p=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[25]=c.inheritanceTitle,t[26]=p),t[27]===c.inheritanceHint?v=t[28]:(v=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[27]=c.inheritanceHint,t[28]=v),t[29]!==s||t[30]!==n||t[31]!==c.inheritanceApplied||t[32]!==c.inheritanceMoveDown||t[33]!==c.inheritanceMoveUp||t[34]!==c.inheritanceRemove||t[35]!==r||t[36]!==f?(y=n.length>0?(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:c.inheritanceApplied}),(0,Z.jsx)(`div`,{className:`grid gap-2`,children:n.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:f.get(e)?.name??e}),(0,Z.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-fg-subtle`,children:e})]}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s||t===0,"aria-label":c.inheritanceMoveUp,onClick:()=>{let e=[...n],[i,a]=[e[t],e[t-1]];e[t-1]=i,e[t]=a,r(e)},children:(0,Z.jsx)(h,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s||t===n.length-1,"aria-label":c.inheritanceMoveDown,onClick:()=>{let e=[...n],[i,a]=[e[t+1],e[t]];e[t]=i,e[t+1]=a,r(e)},children:(0,Z.jsx)(g,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s,"aria-label":c.inheritanceRemove,onClick:()=>r(n.filter(t=>t!==e)),children:(0,Z.jsx)(O,{className:`size-3.5`,"aria-hidden":!0})})]},e))})]}):null,t[29]=s,t[30]=n,t[31]=c.inheritanceApplied,t[32]=c.inheritanceMoveDown,t[33]=c.inheritanceMoveUp,t[34]=c.inheritanceRemove,t[35]=r,t[36]=f,t[37]=y):y=t[37],b=a.length>0?(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:c.inheritanceAvailable}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:a.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s,"aria-label":c.inheritanceAdd,onClick:()=>r([...n,e.id]),children:(0,Z.jsx)(m,{className:`size-3.5`,"aria-hidden":!0})})]},e.id))})]}):n.length===0?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}):null,t[4]=s,t[5]=n,t[6]=c.inheritanceAdd,t[7]=c.inheritanceApplied,t[8]=c.inheritanceAvailable,t[9]=c.inheritanceEmpty,t[10]=c.inheritanceHint,t[11]=c.inheritanceMoveDown,t[12]=c.inheritanceMoveUp,t[13]=c.inheritanceRemove,t[14]=c.inheritanceTitle,t[15]=r,t[16]=f,t[17]=i,t[18]=p,t[19]=v,t[20]=y,t[21]=b,t[22]=x}else p=t[18],v=t[19],y=t[20],b=t[21],x=t[22];let S;t[38]!==p||t[39]!==v||t[40]!==y||t[41]!==b?(S=(0,Z.jsxs)(`section`,{children:[p,v,y,b]}),t[38]=p,t[39]=v,t[40]=y,t[41]=b,t[42]=S):S=t[42];let C;t[43]===c.jsonTitle?C=t[44]:(C=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[43]=c.jsonTitle,t[44]=C);let w;t[45]===c.jsonHint?w=t[46]:(w=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[45]=c.jsonHint,t[46]=w);let T;t[47]!==s||t[48]!==u||t[49]!==a||t[50]!==c.fieldHints||t[51]!==c.fieldLabels||t[52]!==o?(T=(0,Z.jsx)(`div`,{className:`mt-3 grid gap-4 lg:grid-cols-2`,children:u.map(e=>(0,Z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:c.fieldLabels[e]}),(0,Z.jsx)(`span`,{className:`min-h-8 text-xs leading-relaxed text-fg-muted`,children:c.fieldHints[e]}),(0,Z.jsx)(`textarea`,{className:`min-h-36 resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:a[e],disabled:s,spellCheck:!1,placeholder:`{}`,onChange:t=>o({...a,[e]:t.target.value})})]},e))}),t[47]=s,t[48]=u,t[49]=a,t[50]=c.fieldHints,t[51]=c.fieldLabels,t[52]=o,t[53]=T):T=t[53];let E;t[54]!==T||t[55]!==C||t[56]!==w?(E=(0,Z.jsxs)(`section`,{children:[C,w,T]}),t[54]=T,t[55]=C,t[56]=w,t[57]=E):E=t[57];let D;return t[58]!==E||t[59]!==x||t[60]!==S?(D=(0,Z.jsxs)(`div`,{className:x,children:[S,E]}),t[58]=E,t[59]=x,t[60]=S,t[61]=D):D=t[61],D}function ve(e){return[e.id,e]}function ye(e){return e.name||e.directoryId}function be(e){let t=(0,me.c)(56),{mode:n,selected:r,catalog:i,loading:a,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,f;t[0]===i?f=t[1]:(f=i.map(ye).filter(Boolean),t[0]=i,t[1]=f);let p=f,m;bb0:{if(n===`inherit`){m=u.inheritSummary;break bb0}if(n===`all`){m=u.allSummary;break bb0}if(n===`off`){m=u.offSummary;break bb0}let e=n===`allowlist`?u.allowSummary:u.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],m=i}let h=m,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(H,{className:`size-3.5`,"aria-hidden":!0}),t[5]=g):g=t[5];let v;t[6]===u.overrideSummaryTitle?v=t[7]:(v=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[g,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=v);let y;t[8]===h?y=t[9]:(y=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:h}),t[8]=h,t[9]=y);let b;t[10]!==v||t[11]!==y?(b=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[v,y]}),t[10]=v,t[11]=y,t[12]=b):b=t[12];let x;t[13]===u.modeLabel?x=t[14]:(x=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=x);let S;t[15]===u.modeInherit?S=t[16]:(S=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=S);let C;t[17]===u.modeAll?C=t[18]:(C=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=C);let w;t[19]===u.modeAllowlist?w=t[20]:(w=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=w);let T;t[21]===u.modeDenylist?T=t[22]:(T=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=T);let E;t[23]===u.modeOff?E=t[24]:(E=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=E);let D;t[25]!==T||t[26]!==E||t[27]!==S||t[28]!==C||t[29]!==w?(D=[S,C,w,T,E],t[25]=T,t[26]=E,t[27]=S,t[28]=C,t[29]=w,t[30]=D):D=t[30];let O=D,k;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==O?(k=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:O.map(e=>{let[t,r]=e;return(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=O,t[35]=k):k=t[35];let A;t[36]!==k||t[37]!==x?(A=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[x,k]}),t[36]=k,t[37]=x,t[38]=A):A=t[38];let j;t[39]!==i||t[40]!==p||t[41]!==s||t[42]!==u.emptyCatalog||t[43]!==u.noDescription||t[44]!==u.quickActionsLabel||t[45]!==u.quickClear||t[46]!==u.quickSelectAll||t[47]!==a||t[48]!==l||t[49]!==d||t[50]!==r?(j=d?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:s||a||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:s||a||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),a?(0,Z.jsx)(re,{rows:3}):i.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:i.map(e=>{let t=ye(e),n=r.has(t),i=typeof e.description==`string`?e.description.trim():``,a=i||u.noDescription;return(0,Z.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,Z.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,Z.jsx)(`p`,{className:o(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!i&&`italic text-fg-subtle`),title:a,children:a})]})]})},t)})})]}):null,t[39]=i,t[40]=p,t[41]=s,t[42]=u.emptyCatalog,t[43]=u.noDescription,t[44]=u.quickActionsLabel,t[45]=u.quickClear,t[46]=u.quickSelectAll,t[47]=a,t[48]=l,t[49]=d,t[50]=r,t[51]=j):j=t[51];let M;return t[52]!==A||t[53]!==j||t[54]!==b?(M=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[b,A,j]}),t[52]=A,t[53]=j,t[54]=b,t[55]=M):M=t[55],M}var xe=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],Se=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],Ce=[`send_message`,`send_media`,`text_to_speech`,`create_share`],we=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],Te=[...xe,...Ce],Ee=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],De=[`send_message`,`send_media`];function Oe(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]={mode:i});return n}function ke(e){let t=(0,me.c)(105),{builtinToolIds:n,toolPolicies:r,onChange:i,disabled:a,getToolDescription:s,getGroupTitle:c,labels:l}=e,u;t[0]===n?u=t[1]:(u=new Set(n),t[0]=n,t[1]=u);let f=u,p;t[2]!==f||t[3]!==r?(p=Object.entries(r).filter(e=>{let[t]=e;return f.has(t)}).toSorted(Ae),t[2]=f,t[3]=r,t[4]=p):p=t[4];let m=p,h;if(t[5]!==f||t[6]!==n){h=[];for(let e of se){let t=e.toolIds.filter(e=>f.has(e));t.length>0&&h.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=le(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),h.push(e)}t[5]=f,t[6]=n,t[7]=h}else h=t[7];let g=h,v;t[12]!==i||t[13]!==r?(v=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]={...n[e],mode:t},i(n)},t[12]=i,t[13]=r,t[14]=v):v=t[14];let y=v,b;t[15]!==i||t[16]!==r?(b=(e,t)=>{let n=r[e];n&&i({...r,[e]:t(n)})},t[15]=i,t[16]=r,t[17]=b):b=t[17];let x=b,S;t[18]!==f||t[19]!==i?(S=e=>{i(Oe(f,e))},t[18]=f,t[19]=i,t[20]=S):S=t[20];let C=S;if(n.length===0){let e;return t[21]===l.emptyBuiltin?e=t[22]:(e=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[21]=l.emptyBuiltin,t[22]=e),e}let w;t[23]===l.quickActionsLabel?w=t[24]:(w=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[23]=l.quickActionsLabel,t[24]=w);let T;t[25]===i?T=t[26]:(T=()=>i({}),t[25]=i,t[26]=T);let E;t[27]!==a||t[28]!==l.quickClearOverrides||t[29]!==T?(E=(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:T,children:l.quickClearOverrides}),t[27]=a,t[28]=l.quickClearOverrides,t[29]=T,t[30]=E):E=t[30];let D;t[31]===C?D=t[32]:(D=()=>C([[xe,`deny`]]),t[31]=C,t[32]=D);let O;t[33]!==a||t[34]!==l.quickReadOnlyWorkspace||t[35]!==D?(O=(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:D,children:l.quickReadOnlyWorkspace}),t[33]=a,t[34]=l.quickReadOnlyWorkspace,t[35]=D,t[36]=O):O=t[36];let k;t[37]===C?k=t[38]:(k=()=>C([[Se,`deny`]]),t[37]=C,t[38]=k);let A;t[39]!==a||t[40]!==l.quickHighRiskOff||t[41]!==k?(A=(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:k,children:l.quickHighRiskOff}),t[39]=a,t[40]=l.quickHighRiskOff,t[41]=k,t[42]=A):A=t[42];let j;t[43]===C?j=t[44]:(j=()=>C([[Ce,`deny`]]),t[43]=C,t[44]=j);let M;t[45]!==a||t[46]!==l.quickNoOutbound||t[47]!==j?(M=(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:j,children:l.quickNoOutbound}),t[45]=a,t[46]=l.quickNoOutbound,t[47]=j,t[48]=M):M=t[48];let P;t[49]===C?P=t[50]:(P=()=>C([[we,`allow`],[Te,`deny`]]),t[49]=C,t[50]=P);let ee;t[51]!==a||t[52]!==l.quickResearchMode||t[53]!==P?(ee=(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:P,children:l.quickResearchMode}),t[51]=a,t[52]=l.quickResearchMode,t[53]=P,t[54]=ee):ee=t[54];let F;t[55]===C?F=t[56]:(F=()=>C([[Ee,`allow`],[De,`deny`]]),t[55]=C,t[56]=F);let I;t[57]!==a||t[58]!==l.quickCodingMode||t[59]!==F?(I=(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:F,children:l.quickCodingMode}),t[57]=a,t[58]=l.quickCodingMode,t[59]=F,t[60]=I):I=t[60];let L;t[61]!==A||t[62]!==M||t[63]!==ee||t[64]!==I||t[65]!==E||t[66]!==O?(L=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[E,O,A,M,ee,I]}),t[61]=A,t[62]=M,t[63]=ee,t[64]=I,t[65]=E,t[66]=O,t[67]=L):L=t[67];let R;t[68]!==L||t[69]!==w?(R=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[w,L]}),t[68]=L,t[69]=w,t[70]=R):R=t[70];let z;t[71]===l.overrideSummaryTitle?z=t[72]:(z=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[71]=l.overrideSummaryTitle,t[72]=z);let B;t[73]!==l.modeAllow||t[74]!==l.modeConfirm||t[75]!==l.modeDeny||t[76]!==l.noOverrides||t[77]!==m?(B=m.length>0?(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:m.map(e=>{let[t,n]=e;return(0,Z.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n.mode===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n.mode===`confirm`&&`border-amber-500/25 bg-amber-500/10 text-amber-700 dark:text-amber-300`,n.mode===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,Z.jsx)(`span`,{className:`font-sans opacity-80`,children:n.mode===`allow`?l.modeAllow:n.mode===`confirm`?l.modeConfirm:l.modeDeny})]},t)})}):(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[73]=l.modeAllow,t[74]=l.modeConfirm,t[75]=l.modeDeny,t[76]=l.noOverrides,t[77]=m,t[78]=B):B=t[78];let V;t[79]!==z||t[80]!==B?(V=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[z,B]}),t[79]=z,t[80]=B,t[81]=V):V=t[81];let H;t[82]!==a||t[83]!==c||t[84]!==s||t[85]!==g||t[86]!==l.inheritedMode||t[87]!==l.maxCallsLabel||t[88]!==l.modeAllow||t[89]!==l.modeConfirm||t[90]!==l.modeDeny||t[91]!==l.scopeInherit||t[92]!==l.scopeLabel||t[93]!==l.scopeReadonly||t[94]!==l.scopeUnrestricted||t[95]!==l.scopeWorkspace||t[96]!==l.timeoutLabel||t[97]!==y||t[98]!==r||t[99]!==x?(H=(0,Z.jsx)(`div`,{className:`flex flex-col gap-5`,children:g.map(e=>{let{key:t,ids:n}=e;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=r[e],i=n?n.mode:`inherit`;return(0,Z.jsxs)(`li`,{className:o(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,i===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:[(0,Z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,Z.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`confirm`,`deny`].map(t=>(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,i===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:a,onClick:()=>y(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:t===`confirm`?l.modeConfirm:l.modeDeny},t))})]}),n?(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 sm:grid-cols-3 dark:border-edge`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l.scopeLabel,(0,Z.jsxs)(d,{value:n.scope??``,disabled:a,onChange:t=>x(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,Z.jsx)(N,{value:``,children:l.scopeInherit}),(0,Z.jsx)(N,{value:`readonly`,children:l.scopeReadonly}),(0,Z.jsx)(N,{value:`workspace`,children:l.scopeWorkspace}),(0,Z.jsx)(N,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,Z.jsx)($,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:a,onChange:t=>x(e,e=>je(e,`maxCallsPerTurn`,t))}),(0,Z.jsx)($,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:a,onChange:t=>x(e,e=>je(e,`timeoutMs`,t))})]}):null]},e)})})]},t)})}),t[82]=a,t[83]=c,t[84]=s,t[85]=g,t[86]=l.inheritedMode,t[87]=l.maxCallsLabel,t[88]=l.modeAllow,t[89]=l.modeConfirm,t[90]=l.modeDeny,t[91]=l.scopeInherit,t[92]=l.scopeLabel,t[93]=l.scopeReadonly,t[94]=l.scopeUnrestricted,t[95]=l.scopeWorkspace,t[96]=l.timeoutLabel,t[97]=y,t[98]=r,t[99]=x,t[100]=H):H=t[100];let U;return t[101]!==R||t[102]!==V||t[103]!==H?(U=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[R,V,H]}),t[101]=R,t[102]=V,t[103]=H,t[104]=U):U=t[104],U}function Ae(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function je(e,t,n){let r={...e.limits};if(n===void 0?delete r[t]:r[t]=n,Object.keys(r).length===0){let{limits:t,...n}=e;return n}return{...e,limits:r}}function $(e){let t=(0,me.c)(9),n=e.value??``,r;t[0]===e?r=t[1]:(r=t=>{let n=t.target.value.trim();e.onChange(n?Number(n):void 0)},t[0]=e,t[1]=r);let i;t[2]!==e.disabled||t[3]!==n||t[4]!==r?(i=(0,Z.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:border-edge-strong focus:outline-none`,value:n,disabled:e.disabled,onChange:r}),t[2]=e.disabled,t[3]=n,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e.label||t[7]!==i?(a=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[e.label,i]}),t[6]=e.label,t[7]=i,t[8]=a):a=t[8],a}var Me=[`blank`,`safe-coder`,`read-only`,`low-cost`],Ne=[{id:`overview`,icon:y},{id:`models`,icon:R},{id:`tools`,icon:f},{id:`skills`,icon:j},{id:`advanced`,icon:P},{id:`impact`,icon:T}];function Pe(e){return fe(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function Fe(e){return structuredClone(e?.tools?.builtin??{})}function Ie(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function Le(){return{primary:``,fallbacks:[],timeoutMs:``,autoProviderFallback:``}}function Re(e){return{primary:e?.primary??``,fallbacks:[...e?.fallbacks??[]],timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function ze(){return{imageModel:Le(),imageGenerationModel:Le(),allowFallbacks:``,maxCostTier:``}}function Be(e){return{imageModel:Re(e?.models?.imageModel),imageGenerationModel:Re(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function Ve(e){return e===void 0?``:JSON.stringify(e,null,2)}function He(){return{mcp:``,workflows:``,boundaries:``,runtime:``,locks:``}}function Ue(e){return{mcp:Ve(e?.tools?.mcp),workflows:Ve(e?.workflows),boundaries:Ve(e?.boundaries),runtime:Ve(e?.runtime),locks:Ve(e?.locks)}}function We(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:Pe(e),modelAdvanced:Be(e),toolPolicies:Fe(e),skillMode:e?.skills?.mode??`inherit`,skillPick:Ie(e),extendsIds:[...e?.extends??[]],jsonFields:Ue(e)}}function Ge(e){let t=e.primary.trim();if(!t)return;let n=e.fallbacks.map(e=>e.trim()).filter(Boolean),r=e.timeoutMs.trim()?Number(e.timeoutMs):void 0,i=e.autoProviderFallback===``?void 0:e.autoProviderFallback===`true`;return{primary:t,...n.length>0?{fallbacks:n}:{},...r?{timeoutMs:r}:{},...i===void 0?{}:{autoProviderFallback:i}}}function Ke(e,t){let n=Y(e.modelRows),r=Ge(e.modelAdvanced.imageModel),i=Ge(e.modelAdvanced.imageGenerationModel),a=e.modelAdvanced.allowFallbacks||e.modelAdvanced.maxCostTier?{...e.modelAdvanced.allowFallbacks?{allowFallbacks:e.modelAdvanced.allowFallbacks===`true`}:{},...e.modelAdvanced.maxCostTier?{maxCostTier:e.modelAdvanced.maxCostTier}:{}}:void 0,o={...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},...n?.roles?{roles:n.roles}:{},...r?{imageModel:r}:{},...i?{imageGenerationModel:i}:{},...a?{policy:a}:{}};return Object.keys(o).length>0?o:null}function qe(e){return e.trim()?JSON.parse(e):void 0}function Je(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e))}catch{return`!invalid:${e}`}}function Ye(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=qe(e.jsonFields.mcp);return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function Xe(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function Ze(e){if(e.skillMode===`inherit`)return null;let t=[...e.skillPick].toSorted((e,t)=>e.localeCompare(t));return e.skillMode===`allowlist`?{mode:`allowlist`,allow:t}:e.skillMode===`denylist`?{mode:`denylist`,deny:t}:{mode:e.skillMode}}function Qe(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:Ke(e,t),tools:{builtin:Xe(e.toolPolicies),mcp:Je(e.jsonFields.mcp)},skills:Ze(e),extends:[...e.extendsIds].toSorted(),workflows:Je(e.jsonFields.workflows),boundaries:Je(e.jsonFields.boundaries),runtime:Je(e.jsonFields.runtime),locks:Je(e.jsonFields.locks)}}function $e(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:Xe(e.tools?.builtin),mcp:Je(Ve(e.tools?.mcp))},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:Je(Ve(e.workflows)),boundaries:Je(Ve(e.boundaries)),runtime:Je(Ve(e.runtime)),locks:Je(Ve(e.locks))}:null}function et(e,t){return[e.models?.roles?t.summaryModels.replace(`{{count}}`,String(Object.keys(e.models.roles).length)):``,e.tools?.builtin?t.summaryTools.replace(`{{count}}`,String(Object.keys(e.tools.builtin).length)):``,e.skills?t.summarySkills.replace(`{{mode}}`,t.skillModeLabels[e.skills.mode]):``].filter(Boolean).join(` · `)||t.summaryEmpty}function tt(e){return e===void 0?`—`:typeof e==`string`?e:JSON.stringify(e)}function nt(){return{modelAdvanced:ze(),extendsIds:[],jsonFields:He()}}function rt(e,t){return{extends:[...e.extendsIds],models:Ke(e,t)??void 0,tools:Ye(e)??void 0,skills:Ze(e)??void 0,workflows:qe(e.jsonFields.workflows),boundaries:qe(e.jsonFields.boundaries),runtime:qe(e.jsonFields.runtime),locks:qe(e.jsonFields.locks)}}function it(e,t){return e===`safe-coder`?{id:`safe-coder`,name:t.starters[`safe-coder`].title,description:t.starters[`safe-coder`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`code`,model:``,fallbacks:[],description:t.modelRoleDescriptions.code},{id:`review`,model:``,fallbacks:[],description:t.modelRoleDescriptions.review}],toolPolicies:{exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`]),...nt()}:e===`read-only`?{id:`read-only-research`,name:t.starters[`read-only`].title,description:t.starters[`read-only`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast}],toolPolicies:{write_file:{mode:`deny`},apply_patch:{mode:`deny`},exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`all`,skillPick:new Set,...nt()}:e===`low-cost`?{id:`low-cost-assistant`,name:t.starters[`low-cost`].title,description:t.starters[`low-cost`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast},{id:`cheap`,model:``,fallbacks:[],description:t.modelRoleDescriptions.cheap}],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...nt()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...nt()}}function at(){let e=s(l(e=>e.language)),t=e.capabilityPresetsSettings,n=(0,Z.jsx)(_,{asChild:!0,type:`button`,variant:`secondary`,children:(0,Z.jsxs)(a,{to:`/agents`,children:[t.manageAgents,(0,Z.jsx)(B,{className:`size-4`,"aria-hidden":!0})]})}),r=!!c(e=>e.token),{data:d,error:h,isLoading:g,mutate:w}=u(r?`settings-capability-presets`:null,ce,{revalidateOnFocus:!1}),{data:E=[],isLoading:M}=u(r?`settings-capability-presets-skills-catalog`:null,S,{revalidateOnFocus:!1}),[N,H]=i(),[se,le]=(0,X.useState)(``),[fe,q]=(0,X.useState)(`overview`),[J,Y]=(0,X.useState)(()=>it(`blank`,t)),[pe,me]=(0,X.useState)(null),[Q,he]=(0,X.useState)(!1),[ve,ye]=(0,X.useState)(null),[xe,Se]=(0,X.useState)(!1),[Ce,we]=(0,X.useState)(null),[Te,Ee]=(0,X.useState)(null),De=d?.presets??[],Oe=d?.defaultPresetId??`default`,Ae=De.find(e=>e.id===Oe)??null,je=De.filter(e=>e.id!==Oe),$=(0,X.useMemo)(()=>De.find(e=>e.id===se)??De[0]??null,[De,se]),Pe=!$||J.id.trim()!==$.id,Fe=!!($&&$.id===Oe),Ie=JSON.stringify(Qe(J,$))!==JSON.stringify($e($)),Le=Qe(J,$),Re=$e($),ze=[Le.id!==Re?.id||Le.name!==Re?.name||Le.description!==Re?.description?t.tabs.overview:``,JSON.stringify(Le.models)===JSON.stringify(Re?.models)?``:t.tabs.models,JSON.stringify(Le.tools)===JSON.stringify(Re?.tools)?``:t.tabs.tools,JSON.stringify(Le.skills)===JSON.stringify(Re?.skills)?``:t.tabs.skills,JSON.stringify({extends:Le.extends,workflows:Le.workflows,boundaries:Le.boundaries,runtime:Le.runtime,locks:Le.locks})===JSON.stringify({extends:Re?.extends,workflows:Re?.workflows,boundaries:Re?.boundaries,runtime:Re?.runtime,locks:Re?.locks})?``:t.tabs.advanced].filter(Boolean),Be=(0,X.useMemo)(()=>{if(!$||Pe)return null;try{let e=rt(J,$);return{name:J.name.trim(),description:J.description.trim()||null,extends:e.extends??null,models:e.models??null,tools:e.tools??null,skills:e.skills??null,workflows:e.workflows??null,boundaries:e.boundaries??null,runtime:e.runtime??null,locks:e.locks??null}}catch{return null}},[J,Pe,$]),{data:Ve,error:He,isLoading:Ue}=u(fe===`impact`&&$&&Be?[`capability-preset-impact-preview`,$.id,JSON.stringify(Be)]:null,()=>ae($.id,Be),{revalidateOnFocus:!1}),Ge=ve??(h instanceof Error?h.message:null),Ke=N.get(`action`)===`new`||!!N.get(`preset`),Je=N.get(`action`)===`new`&&pe===null,Ye=Pe?t.newPreset:$?.name??t.editorTitle,Xe=t=>e.agentsSettings.toolsDisableGroups[t],Ze=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,X.useEffect)(()=>{if(!d||Q)return;if(N.get(`action`)===`new`){le(``),Y(it(`blank`,t)),q(`overview`);return}let e=N.get(`preset`)?.trim(),n=e?d.presets.find(t=>t.id===e):null;if(n){le(n.id),Y(We(n)),q(N.get(`tab`)??`overview`);return}$&&(le($.id),Y(e=>e.id===$.id?e:We($)))},[Q,d,N,$]);function nt(e){me(null),le(e.id),Y(We(e)),H({preset:e.id},{replace:!0}),q(`overview`)}function at(){me(null),le(``),Y(it(`blank`,t)),ye(null),H({action:`new`},{replace:!0}),q(`overview`)}function ct(e){me(e),Y(it(e,t)),ye(null),q(`overview`)}function lt(){if(pe){let e=it(pe,t);if(JSON.stringify(Qe(J,null))!==JSON.stringify(Qe(e,null))&&!window.confirm(t.changeTemplateConfirm))return}me(null),ye(null)}function ut(){!Je&&Ie&&!window.confirm(t.discardConfirm)||(Se(!1),we(null),H({},{replace:!0}),me(null),ye(null),Y(We($)),q(`overview`))}async function dt(){let e=de(J.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){ye(e),q(`models`);return}for(let e of[J.modelAdvanced.imageModel,J.modelAdvanced.imageGenerationModel]){if([e.primary,...e.fallbacks].map(e=>e.trim()).filter(Boolean).some(e=>!/^[^/\s]+\/.+/.test(e))){ye(t.invalidModelRef),q(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){ye(t.advancedPositiveIntegerError),q(`models`);return}}for(let e of Object.values(J.toolPolicies))if([e.limits?.maxCallsPerTurn,e.limits?.timeoutMs].filter(e=>e!==void 0).some(e=>!Number.isInteger(e)||e<=0)){ye(t.advancedPositiveIntegerError),q(`tools`);return}for(let e of Object.keys(J.jsonFields))try{qe(J.jsonFields[e])}catch{ye(t.advancedJsonError.replace(`{{field}}`,t.advancedFieldLabels[e])),q(`advanced`);return}he(!0),ye(null);try{let e=rt(J,$);if(Pe){let t=await ue({id:J.id.trim(),name:J.name.trim(),...J.description.trim()?{description:J.description.trim()}:{},...e});await w(t.presets,{revalidate:!1}),le(t.presetId),me(null),H({preset:t.presetId},{replace:!0})}else $&&await w(await ie($.id,{name:J.name.trim(),description:J.description.trim()||null,extends:e.extends??null,models:e.models??null,tools:e.tools??null,skills:e.skills??null,workflows:e.workflows??null,boundaries:e.boundaries??null,runtime:e.runtime??null,locks:e.locks??null}),{revalidate:!1})}catch(e){ye(e instanceof Error?e.message:t.saveError)}finally{he(!1)}}async function ft(){if($){he(!0),ye(null),we(null);try{await w(await oe($.id),{revalidate:!1}),Se(!1),le(``),me(null),Y(it(`blank`,t)),q(`overview`),H({},{replace:!0})}catch(e){we(e instanceof Error?e.message:t.deleteError)}finally{he(!1)}}}return r?(0,Z.jsxs)(te,{gap:`gap-5`,className:`pb-24`,children:[(0,Z.jsx)(W,{title:t.title,subtitle:t.subtitle,actions:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[n,(0,Z.jsxs)(_,{type:`button`,onClick:at,disabled:Q,children:[(0,Z.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]})}),Ge?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Ge}):null,g?(0,Z.jsx)(ne,{sections:2}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[Ae?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:R,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>nt(Ae),className:`group rounded-lg bg-accent/5 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Ae.name}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Ae.id})]}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),Ae.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Ae.description}):null,(0,Z.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:et(Ae,t)})]})]}):null,(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:R,title:t.listTitle,subtitle:t.listHint}),je.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:[(0,Z.jsx)(`p`,{children:t.empty}),(0,Z.jsxs)(_,{type:`button`,variant:`secondary`,onClick:at,disabled:Q,children:[(0,Z.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]}):(0,Z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:je.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>nt(e),className:`group min-h-36 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,Z.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:et(e,t)})]},e.id))})]})]}),(0,Z.jsx)(x,{open:Ke,onOpenChange:e=>{e||ut()},children:(0,Z.jsxs)(k,{children:[(0,Z.jsx)(p,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,F)}),(0,Z.jsx)(D,{ref:Ee,className:o(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,760px)] w-[min(100%-2rem,64rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,A),onOpenAutoFocus:e=>e.preventDefault(),children:(0,Z.jsxs)(z,{layer:`modal`,portalContainer:Te,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[!Je&&Pe&&pe?(0,Z.jsx)(`button`,{type:`button`,className:o(V,`shrink-0 p-1.5 hover:bg-surface-base`),onClick:lt,"aria-label":t.changeTemplate,title:t.changeTemplate,children:(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":!0})}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(b,{className:`truncate text-base font-semibold text-fg`,children:Ye}),(0,Z.jsx)(U,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Je?t.templatePickerSubtitle:Pe&&pe?`${t.editorHint} · ${t.basedOnTemplate.replace(`{{template}}`,t.starters[pe].title)}`:Pe?t.editorHint:J.id})]})]}),(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:o(V,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,Z.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})})]}),Je?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 sm:p-5`,children:(0,Z.jsx)(`div`,{className:`mx-auto grid max-w-3xl gap-3 sm:grid-cols-2`,children:Me.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`group min-h-32 rounded-xl border border-edge-subtle bg-surface-base px-4 py-4 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>ct(e),children:[(0,Z.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),e===`blank`?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.templateRecommended}):null]}),(0,Z.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})}),(0,Z.jsx)(`div`,{className:`flex shrink-0 justify-end border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:(0,Z.jsx)(_,{type:`button`,variant:`secondary`,onClick:ut,children:t.cancel})})]}):(0,Z.jsxs)(Z.Fragment,{children:[Ge?(0,Z.jsx)(`div`,{className:`mx-4 mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Ge}):null,(0,Z.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2 border-b border-edge-subtle bg-surface-base px-4 py-2 dark:border-edge`,children:Ne.map(({id:e,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,className:o(`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,fe===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>q(e),children:[(0,Z.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:(0,Z.jsxs)(`div`,{className:`w-full`,children:[fe===`overview`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:y,title:t.overviewTitle,subtitle:t.overviewHint}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,Z.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.id,disabled:Q||!Pe,onChange:e=>Y(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),!Pe&&$?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg-muted`,children:t.versionAutomatic.replace(`{{version}}`,String($.version))})]}):null,(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,Z.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.name,disabled:Q,onChange:e=>Y(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,Z.jsx)(`textarea`,{className:`min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.description,disabled:Q,onChange:e=>Y(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(ot,{icon:R,label:t.modelsTitle,value:String(J.modelRows.length)}),(0,Z.jsx)(ot,{icon:f,label:t.toolsTitle,value:String(Object.keys(J.toolPolicies).length)}),(0,Z.jsx)(ot,{icon:j,label:t.skillsTitle,value:t.skillModeLabels[J.skillMode]})]})]}):null,fe===`models`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:R,title:t.modelsTitle,subtitle:t.modelsHint}),(0,Z.jsx)(ge,{rows:J.modelRows,onChange:e=>Y(t=>({...t,modelRows:e})),disabled:Q,defaultRole:$?.models?.defaultRole,chat:e.chat,labels:{defaultTitle:t.modelDefaultTitle,defaultHint:t.modelDefaultHint,defaultBadge:t.modelDefaultBadge,roleId:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,moreSettings:t.modelMoreSettings,otherRolesTitle:t.modelOtherRolesTitle,otherRolesHint:t.modelOtherRolesHint,otherRolesEmpty:t.modelOtherRolesEmpty,addTaskModel:t.modelAddTaskModel,customRole:t.modelCustomRole,removeRole:t.removeModelRole,roleIdPlaceholder:`custom-role`,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}}),(0,Z.jsx)(st,{value:J.modelAdvanced,onChange:e=>Y(t=>({...t,modelAdvanced:e})),disabled:Q,cp:t,chat:e.chat})]}):null,fe===`tools`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:f,title:t.toolsTitle,subtitle:t.toolsHint}),(0,Z.jsx)(ke,{builtinToolIds:d?.builtinToolIds??[],toolPolicies:J.toolPolicies,onChange:e=>Y(t=>({...t,toolPolicies:e})),disabled:Q,getToolDescription:Ze,getGroupTitle:Xe,labels:{quickActionsLabel:t.toolsQuickActionsLabel,quickClearOverrides:t.toolsQuickClearOverrides,quickReadOnlyWorkspace:t.toolsQuickReadOnlyWorkspace,quickHighRiskOff:t.toolsQuickHighRiskOff,quickNoOutbound:t.toolsQuickNoOutbound,quickResearchMode:t.toolsQuickResearchMode,quickCodingMode:t.toolsQuickCodingMode,emptyBuiltin:t.toolsEmptyBuiltin,overrideSummaryTitle:t.toolsOverrideSummaryTitle,noOverrides:t.toolsNoOverrides,inheritedMode:t.toolModes.inherit,modeAllow:t.toolModes.allow,modeConfirm:t.toolModes.confirm,modeDeny:t.toolModes.deny,scopeLabel:t.toolScopeLabel,scopeInherit:t.toolScopeInherit,scopeReadonly:t.toolScopeReadonly,scopeWorkspace:t.toolScopeWorkspace,scopeUnrestricted:t.toolScopeUnrestricted,maxCallsLabel:t.toolMaxCallsLabel,timeoutLabel:t.toolTimeoutLabel}})]}):null,fe===`skills`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:j,title:t.skillsTitle,subtitle:t.skillsHint}),(0,Z.jsx)(be,{mode:J.skillMode,selected:J.skillPick,catalog:E,loading:M,disabled:Q,onModeChange:e=>Y(t=>({...t,skillMode:e})),onSelectedChange:e=>Y(t=>({...t,skillPick:e})),labels:{modeLabel:t.skillsModeLabel,modeInherit:t.skillsModeInherit,modeAll:t.skillsModeAll,modeAllowlist:t.skillsModeAllowlist,modeDenylist:t.skillsModeDenylist,modeOff:t.skillsModeOff,quickActionsLabel:t.skillsQuickActionsLabel,quickSelectAll:t.skillsQuickSelectAll,quickClear:t.skillsQuickClear,catalogLoading:t.skillsCatalogLoading,emptyCatalog:t.skillsEmptyCatalog,noDescription:t.skillsNoDescription,overrideSummaryTitle:t.skillsOverrideSummaryTitle,inheritSummary:t.skillsInheritSummary,allSummary:t.skillsAllSummary,offSummary:t.skillsOffSummary,allowSummary:t.skillsAllowSummary,denySummary:t.skillsDenySummary}})]}):null,fe===`advanced`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:P,title:t.advancedTitle,subtitle:t.advancedHint}),(0,Z.jsx)(_e,{extendsIds:J.extendsIds,onExtendsChange:e=>Y(t=>({...t,extendsIds:e})),presetOptions:De.filter(e=>e.id!==$?.id&&e.id!==Oe),jsonFields:J.jsonFields,onJsonFieldsChange:e=>Y(t=>({...t,jsonFields:e})),disabled:Q,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,inheritanceApplied:t.advancedInheritanceApplied,inheritanceAvailable:t.advancedInheritanceAvailable,inheritanceAdd:t.advancedInheritanceAdd,inheritanceRemove:t.advancedInheritanceRemove,inheritanceMoveUp:t.advancedInheritanceMoveUp,inheritanceMoveDown:t.advancedInheritanceMoveDown,jsonTitle:t.advancedJsonTitle,jsonHint:t.advancedJsonHint,fieldLabels:t.advancedFieldLabels,fieldHints:t.advancedFieldHints}})]}):null,fe===`impact`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:T,title:t.usageTitle,subtitle:t.usageHint}),(0,Z.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.changePreviewTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:ze.length>0?t.changePreviewSections.replace(`{{sections}}`,ze.join(`、`)):t.changePreviewEmpty})]}),Pe?null:(0,Z.jsxs)(`div`,{className:`mb-4`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.effectiveChangePreviewTitle}),Ue?(0,Z.jsx)(re,{rows:2}):He?(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-red-600 shadow-surface dark:text-red-400`,children:t.effectiveChangePreviewError}):Be?Ve?.agents.length?(0,Z.jsx)(`div`,{className:`grid gap-3`,children:Ve.agents.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,Z.jsx)(`div`,{className:`mt-2 grid gap-2`,children:e.diffs.map(e=>(0,Z.jsxs)(`div`,{className:`grid gap-1 text-xs sm:grid-cols-[minmax(0,12rem)_minmax(0,1fr)]`,children:[(0,Z.jsx)(`div`,{className:`truncate font-mono text-fg-muted`,children:e.path}),(0,Z.jsxs)(`div`,{className:`min-w-0 text-fg`,children:[(0,Z.jsx)(`span`,{className:`break-all text-fg-muted`,children:tt(e.before)}),(0,Z.jsx)(`span`,{className:`px-1.5 text-fg-subtle`,"aria-hidden":!0,children:`→`}),(0,Z.jsx)(`span`,{className:`break-all`,children:tt(e.after)})]})]},e.path))})]},e.agentId))}):(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:t.effectiveChangePreviewEmpty}):(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:t.effectiveChangePreviewInvalid})]}),$?.usage.length?(0,Z.jsx)(`div`,{className:`grid gap-2`,children:$.usage.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId}),(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-fg-subtle`,children:e.direct?t.usageDirect:t.usageIndirect})]},e.agentId))}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-fg`,children:Ie?t.unsavedTitle:t.noUnsavedTitle}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Ie?($?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String($?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ie?(0,Z.jsx)(_,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>Y(We($)),children:t.discard}):null,$&&!Fe?(0,Z.jsxs)(_,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>{we(null),Se(!0)},children:[(0,Z.jsx)(O,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,Z.jsxs)(_,{type:`button`,disabled:Q||!J.id.trim()||!J.name.trim()||!Ie,onClick:()=>void dt(),children:[(0,Z.jsx)(I,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})]})})]})}),(0,Z.jsx)(x,{open:xe,onOpenChange:e=>{Q||(Se(e),e||we(null))},children:(0,Z.jsxs)(k,{children:[(0,Z.jsx)(p,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,F)}),(0,Z.jsxs)(D,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,A),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,Z.jsx)(b,{className:`text-base font-semibold text-fg`,children:t.deleteDialogTitle}),(0,Z.jsx)(U,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:$?t.deleteConfirm.replace(`{{name}}`,$.name):t.deleteConfirmFallback})]}),Ce?(0,Z.jsx)(`div`,{className:`mx-4 mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Ce}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,children:[(0,Z.jsx)(_,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>Se(!1),children:t.cancel}),(0,Z.jsxs)(_,{type:`button`,disabled:Q||!$,className:`bg-red-600 text-white shadow-surface hover:bg-red-700 focus-visible:ring-red-600 dark:bg-red-500 dark:hover:bg-red-600`,onClick:()=>void ft(),children:[Q?(0,Z.jsx)(L,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(O,{className:`size-4`,"aria-hidden":!0}),Q?t.deleting:t.delete]})]})]})]})})]}):(0,Z.jsxs)(te,{gap:`gap-3`,children:[(0,Z.jsx)(W,{title:t.title,actions:n}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function ot(e){let t=(0,me.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==a?(o=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[a,r]}),t[2]=r,t[3]=a,t[4]=o):o=t[4];let s;t[5]===i?s=t[6]:(s=(0,Z.jsx)(`div`,{className:`mt-1 text-sm font-medium text-fg`,children:i}),t[5]=i,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function st(e){let t=(0,me.c)(121),{value:n,onChange:r,disabled:i,cp:a,chat:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[0]=s):s=t[0];let{data:c,isLoading:l,error:f}=u(`capability-preset-image-generation-models`,pe,s),p;t[1]===c?p=t[2]:(p=(c??[]).filter(ut).flatMap(lt),t[1]=c,t[2]=p);let m=p,h;t[3]===m?h=t[4]:(h=new Set(m.map(ct)),t[3]=m,t[4]=h);let g=h,_,v;t[5]!==g||t[6]!==c||t[7]!==r||t[8]!==n?(_=()=>{if(!c)return;let e=n.imageGenerationModel,t=g.has(e.primary)?e.primary:``,i=e.fallbacks.filter(e=>g.has(e));t===e.primary&&i.length===e.fallbacks.length||r({...n,imageGenerationModel:{...e,primary:t,fallbacks:i}})},v=[g,c,r,n],t[5]=g,t[6]=c,t[7]=r,t[8]=n,t[9]=_,t[10]=v):(_=t[9],v=t[10]),(0,X.useEffect)(_,v);let y;t[11]!==r||t[12]!==n?(y=(e,t)=>{r({...n,[e]:t})},t[11]=r,t[12]=n,t[13]=y):y=t[13];let b=y,x;t[14]===a.modelSpecializedTitle?x=t[15]:(x=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelSpecializedTitle}),t[14]=a.modelSpecializedTitle,t[15]=x);let S;t[16]!==a.modelNotSet||t[17]!==a.modelSpecializedSummary||t[18]!==n.imageGenerationModel.primary||t[19]!==n.imageModel.primary?(S=a.modelSpecializedSummary.replace(`{{image}}`,n.imageModel.primary||a.modelNotSet).replace(`{{generation}}`,n.imageGenerationModel.primary||a.modelNotSet),t[16]=a.modelNotSet,t[17]=a.modelSpecializedSummary,t[18]=n.imageGenerationModel.primary,t[19]=n.imageModel.primary,t[20]=S):S=t[20];let C;t[21]===S?C=t[22]:(C=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:S}),t[21]=S,t[22]=C);let w;t[23]!==x||t[24]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[x,C]}),t[23]=x,t[24]=C,t[25]=w):w=t[25];let T;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(M,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[26]=T):T=t[26];let E;t[27]===w?E=t[28]:(E=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[w,T]}),t[27]=w,t[28]=E);let D;t[29]===b?D=t[30]:(D=e=>b(`imageModel`,e),t[29]=b,t[30]=D);let O;t[31]!==o||t[32]!==a||t[33]!==i||t[34]!==D||t[35]!==n.imageModel?(O=(0,Z.jsx)(dt,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:D,disabled:i,cp:a,chat:o,capabilitiesFilter:`vision`}),t[31]=o,t[32]=a,t[33]=i,t[34]=D,t[35]=n.imageModel,t[36]=O):O=t[36];let k;t[37]===b?k=t[38]:(k=e=>b(`imageGenerationModel`,e),t[37]=b,t[38]=k);let A;t[39]===a.modelImageSettingsLink?A=t[40]:(A={label:a.modelImageSettingsLink,path:`/settings/capabilities/image`},t[39]=a.modelImageSettingsLink,t[40]=A);let j;t[41]!==o||t[42]!==a||t[43]!==i||t[44]!==m||t[45]!==f||t[46]!==l||t[47]!==k||t[48]!==A||t[49]!==n.imageGenerationModel?(j=(0,Z.jsx)(dt,{title:a.imageGenerationTitle,value:n.imageGenerationModel,onChange:k,disabled:i,cp:a,chat:o,models:m,modelsLoading:l,modelsError:f,noMatches:a.modelNoConfiguredImageModels,settingsFooterLink:A}),t[41]=o,t[42]=a,t[43]=i,t[44]=m,t[45]=f,t[46]=l,t[47]=k,t[48]=A,t[49]=n.imageGenerationModel,t[50]=j):j=t[50];let P;t[51]!==O||t[52]!==j?(P=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge lg:grid-cols-2`,children:[O,j]}),t[51]=O,t[52]=j,t[53]=P):P=t[53];let ee;t[54]!==E||t[55]!==P?(ee=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[E,P]}),t[54]=E,t[55]=P,t[56]=ee):ee=t[56];let F;t[57]===a.modelAdvancedTitle?F=t[58]:(F=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelAdvancedTitle}),t[57]=a.modelAdvancedTitle,t[58]=F);let I;t[59]===a.modelAdvancedHint?I=t[60]:(I=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:a.modelAdvancedHint}),t[59]=a.modelAdvancedHint,t[60]=I);let L;t[61]!==F||t[62]!==I?(L=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[F,I]}),t[61]=F,t[62]=I,t[63]=L):L=t[63];let R;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Z.jsx)(M,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[64]=R):R=t[64];let z;t[65]===L?z=t[66]:(z=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[L,R]}),t[65]=L,t[66]=z);let B;t[67]===a.modelAllowFallbacksLabel?B=t[68]:(B=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelAllowFallbacksLabel}),t[67]=a.modelAllowFallbacksLabel,t[68]=B);let V;t[69]!==r||t[70]!==n?(V=e=>r({...n,allowFallbacks:e.target.value}),t[69]=r,t[70]=n,t[71]=V):V=t[71];let H;t[72]===a.policyInherit?H=t[73]:(H=(0,Z.jsx)(N,{value:``,children:a.policyInherit}),t[72]=a.policyInherit,t[73]=H);let U;t[74]===a.policyEnabled?U=t[75]:(U=(0,Z.jsx)(N,{value:`true`,children:a.policyEnabled}),t[74]=a.policyEnabled,t[75]=U);let W;t[76]===a.policyDisabled?W=t[77]:(W=(0,Z.jsx)(N,{value:`false`,children:a.policyDisabled}),t[76]=a.policyDisabled,t[77]=W);let te;t[78]!==i||t[79]!==V||t[80]!==H||t[81]!==U||t[82]!==W||t[83]!==n.allowFallbacks?(te=(0,Z.jsxs)(d,{value:n.allowFallbacks,disabled:i,side:`top`,onChange:V,children:[H,U,W]}),t[78]=i,t[79]=V,t[80]=H,t[81]=U,t[82]=W,t[83]=n.allowFallbacks,t[84]=te):te=t[84];let ne;t[85]!==B||t[86]!==te?(ne=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[B,te]}),t[85]=B,t[86]=te,t[87]=ne):ne=t[87];let re;t[88]===a.modelMaxCostTierLabel?re=t[89]:(re=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[88]=a.modelMaxCostTierLabel,t[89]=re);let G;t[90]!==r||t[91]!==n?(G=e=>r({...n,maxCostTier:e.target.value}),t[90]=r,t[91]=n,t[92]=G):G=t[92];let K;t[93]===a.policyInherit?K=t[94]:(K=(0,Z.jsx)(N,{value:``,children:a.policyInherit}),t[93]=a.policyInherit,t[94]=K);let ie;t[95]===a.costTierLow?ie=t[96]:(ie=(0,Z.jsx)(N,{value:`low`,children:a.costTierLow}),t[95]=a.costTierLow,t[96]=ie);let ae;t[97]===a.costTierMedium?ae=t[98]:(ae=(0,Z.jsx)(N,{value:`medium`,children:a.costTierMedium}),t[97]=a.costTierMedium,t[98]=ae);let oe;t[99]===a.costTierHigh?oe=t[100]:(oe=(0,Z.jsx)(N,{value:`high`,children:a.costTierHigh}),t[99]=a.costTierHigh,t[100]=oe);let se;t[101]!==i||t[102]!==G||t[103]!==K||t[104]!==ie||t[105]!==ae||t[106]!==oe||t[107]!==n.maxCostTier?(se=(0,Z.jsxs)(d,{value:n.maxCostTier,disabled:i,side:`top`,onChange:G,children:[K,ie,ae,oe]}),t[101]=i,t[102]=G,t[103]=K,t[104]=ie,t[105]=ae,t[106]=oe,t[107]=n.maxCostTier,t[108]=se):se=t[108];let ce;t[109]!==re||t[110]!==se?(ce=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[re,se]}),t[109]=re,t[110]=se,t[111]=ce):ce=t[111];let le;t[112]!==ne||t[113]!==ce?(le=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge sm:grid-cols-2`,children:[ne,ce]}),t[112]=ne,t[113]=ce,t[114]=le):le=t[114];let ue;t[115]!==z||t[116]!==le?(ue=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[z,le]}),t[115]=z,t[116]=le,t[117]=ue):ue=t[117];let de;return t[118]!==ee||t[119]!==ue?(de=(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-3 border-t border-edge-subtle pt-5 dark:border-edge`,children:[ee,ue]}),t[118]=ee,t[119]=ue,t[120]=de):de=t[120],de}function ct(e){return e.id}function lt(e){return e.models.map(t=>({id:`${e.id}/${t}`,name:t,provider:e.label}))}function ut(e){return e.configured||e.credentialMode===`none`}function dt(e){let t=(0,me.c)(109),{title:n,value:r,onChange:i,disabled:a,cp:o,chat:s,capabilitiesFilter:c,models:l,modelsLoading:u,modelsError:f,noMatches:p,settingsFooterLink:h}=e,g;t[0]!==i||t[1]!==r?(g=(e,t)=>{i({...r,fallbacks:r.fallbacks.map((n,r)=>r===e?t:n)})},t[0]=i,t[1]=r,t[2]=g):g=t[2];let v=g,y;t[3]===n?y=t[4]:(y=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n}),t[3]=n,t[4]=y);let b=r.primary||o.modelNotSet,x;t[5]===b?x=t[6]:(x=(0,Z.jsx)(`span`,{className:`max-w-48 truncate font-mono text-xs text-fg-muted`,children:b}),t[5]=b,t[6]=x);let S;t[7]!==y||t[8]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2.5`,children:[y,x]}),t[7]=y,t[8]=x,t[9]=S):S=t[9];let C;t[10]===o.modelToolPrimaryLabel?C=t[11]:(C=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolPrimaryLabel}),t[10]=o.modelToolPrimaryLabel,t[11]=C);let T=p??s.modelNoMatches,E;t[12]!==i||t[13]!==r?(E=e=>i({...r,primary:e}),t[12]=i,t[13]=r,t[14]=E):E=t[14];let D;t[15]!==c||t[16]!==s.modelPlaceholder||t[17]!==s.modelSearchPlaceholder||t[18]!==a||t[19]!==l||t[20]!==f||t[21]!==u||t[22]!==h||t[23]!==T||t[24]!==E||t[25]!==r.primary?(D=(0,Z.jsx)(w,{value:r.primary,disabled:a,placeholder:s.modelPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:T,models:l,modelsLoading:u,modelsError:f,settingsFooterLink:h,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:E}),t[15]=c,t[16]=s.modelPlaceholder,t[17]=s.modelSearchPlaceholder,t[18]=a,t[19]=l,t[20]=f,t[21]=u,t[22]=h,t[23]=T,t[24]=E,t[25]=r.primary,t[26]=D):D=t[26];let k;t[27]!==o.modelClearSelection||t[28]!==a||t[29]!==i||t[30]!==r?(k=r.primary?(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:a,"aria-label":o.modelClearSelection,onClick:()=>i({...r,primary:``}),children:(0,Z.jsx)(ee,{className:`size-4`,strokeWidth:1.75})}):null,t[27]=o.modelClearSelection,t[28]=a,t[29]=i,t[30]=r,t[31]=k):k=t[31];let A;t[32]!==D||t[33]!==k?(A=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[D,k]}),t[32]=D,t[33]=k,t[34]=A):A=t[34];let j;t[35]!==A||t[36]!==C?(j=(0,Z.jsxs)(`div`,{className:`grid gap-1`,children:[C,A]}),t[35]=A,t[36]=C,t[37]=j):j=t[37];let M;t[38]===o.modelToolFallbacksLabel?M=t[39]:(M=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolFallbacksLabel}),t[38]=o.modelToolFallbacksLabel,t[39]=M);let P;t[40]!==i||t[41]!==r?(P=()=>i({...r,fallbacks:[...r.fallbacks,``]}),t[40]=i,t[41]=r,t[42]=P):P=t[42];let F;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(m,{className:`size-3.5`,strokeWidth:1.75}),t[43]=F):F=t[43];let I;t[44]!==o.modelAddFallback||t[45]!==a||t[46]!==P?(I=(0,Z.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:a,onClick:P,children:[F,o.modelAddFallback]}),t[44]=o.modelAddFallback,t[45]=a,t[46]=P,t[47]=I):I=t[47];let L;t[48]!==M||t[49]!==I?(L=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[M,I]}),t[48]=M,t[49]=I,t[50]=L):L=t[50];let R;t[51]!==c||t[52]!==s.modelNoMatches||t[53]!==s.modelSearchPlaceholder||t[54]!==o.modelFallbackEmptyHint||t[55]!==o.modelFallbackPlaceholder||t[56]!==o.modelRemoveFallback||t[57]!==a||t[58]!==l||t[59]!==f||t[60]!==u||t[61]!==p||t[62]!==i||t[63]!==h||t[64]!==v||t[65]!==r?(R=r.fallbacks.length>0?(0,Z.jsx)(`div`,{className:`grid gap-1.5`,children:r.fallbacks.map((e,t)=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,Z.jsx)(w,{value:e,disabled:a,placeholder:o.modelFallbackPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:p??s.modelNoMatches,models:l,modelsLoading:u,modelsError:f,settingsFooterLink:h,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>v(t,e)}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:a,"aria-label":o.modelRemoveFallback,onClick:()=>i({...r,fallbacks:r.fallbacks.filter((e,n)=>n!==t)}),children:(0,Z.jsx)(O,{className:`size-4`,strokeWidth:1.75})})]},`fallback-${t}`))}):(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 text-xs text-fg-muted`,children:o.modelFallbackEmptyHint}),t[51]=c,t[52]=s.modelNoMatches,t[53]=s.modelSearchPlaceholder,t[54]=o.modelFallbackEmptyHint,t[55]=o.modelFallbackPlaceholder,t[56]=o.modelRemoveFallback,t[57]=a,t[58]=l,t[59]=f,t[60]=u,t[61]=p,t[62]=i,t[63]=h,t[64]=v,t[65]=r,t[66]=R):R=t[66];let z;t[67]!==L||t[68]!==R?(z=(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[L,R]}),t[67]=L,t[68]=R,t[69]=z):z=t[69];let B;t[70]!==i||t[71]!==r?(B=e=>i({...r,timeoutMs:e.target.value}),t[70]=i,t[71]=r,t[72]=B):B=t[72];let V;t[73]!==a||t[74]!==B||t[75]!==r.timeoutMs?(V=(0,Z.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:r.timeoutMs,disabled:a,onChange:B}),t[73]=a,t[74]=B,t[75]=r.timeoutMs,t[76]=V):V=t[76];let H;t[77]!==o.toolTimeoutLabel||t[78]!==V?(H=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.toolTimeoutLabel,V]}),t[77]=o.toolTimeoutLabel,t[78]=V,t[79]=H):H=t[79];let U;t[80]!==i||t[81]!==r?(U=e=>i({...r,autoProviderFallback:e.target.value}),t[80]=i,t[81]=r,t[82]=U):U=t[82];let W;t[83]===o.policyInherit?W=t[84]:(W=(0,Z.jsx)(N,{value:``,children:o.policyInherit}),t[83]=o.policyInherit,t[84]=W);let te;t[85]===o.policyEnabled?te=t[86]:(te=(0,Z.jsx)(N,{value:`true`,children:o.policyEnabled}),t[85]=o.policyEnabled,t[86]=te);let ne;t[87]===o.policyDisabled?ne=t[88]:(ne=(0,Z.jsx)(N,{value:`false`,children:o.policyDisabled}),t[87]=o.policyDisabled,t[88]=ne);let re;t[89]!==a||t[90]!==U||t[91]!==W||t[92]!==te||t[93]!==ne||t[94]!==r.autoProviderFallback?(re=(0,Z.jsxs)(d,{value:r.autoProviderFallback,disabled:a,side:`top`,onChange:U,children:[W,te,ne]}),t[89]=a,t[90]=U,t[91]=W,t[92]=te,t[93]=ne,t[94]=r.autoProviderFallback,t[95]=re):re=t[95];let G;t[96]!==o.modelAutoProviderFallbackLabel||t[97]!==re?(G=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.modelAutoProviderFallbackLabel,re]}),t[96]=o.modelAutoProviderFallbackLabel,t[97]=re,t[98]=G):G=t[98];let K;t[99]!==H||t[100]!==G?(K=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[H,G]}),t[99]=H,t[100]=G,t[101]=K):K=t[101];let ie;t[102]!==j||t[103]!==z||t[104]!==K?(ie=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-3 dark:border-edge`,children:[j,z,K]}),t[102]=j,t[103]=z,t[104]=K,t[105]=ie):ie=t[105];let ae;return t[106]!==ie||t[107]!==S?(ae=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 shadow-surface`,children:[S,ie]}),t[106]=ie,t[107]=S,t[108]=ae):ae=t[108],ae}export{at as CapabilityPresetsSettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-D02NNLCZ.js";import{l as c,n as l}from"./locale-store-D6hs74o5.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$o as d,As as f,Bo as p,Cc as m,Cu as h,Du as g,Es as _,Eu as v,Hl as y,Ho as b,Io as x,Kr as S,Lo as C,Mt as w,Pl as T,Qo as E,Ro as D,Us as O,Vo as k,as as A,bc as j,du as M,es as N,ic as P,ks as ee,os as F,pc as I,qc as L,sl as R,ts as z,wu as B,ys as V,yu as H,zo as U}from"./index-OJgiMh07.js";import{n as W,r as te}from"./settings-page-layout-97LmwrzC.js";import{n as ne,r as re}from"./settings-loading-skeleton-DgIp8_S6.js";import{n as G,t as K}from"./settings-form-section-zxo5ZGOu.js";import{a as ie,i as ae,n as oe,o as se,r as ce,s as le,t as ue}from"./capability-presets-api-Dn-7MMEo.js";import{a as de,i as fe,o as q,s as J,t as Y}from"./typed-models-lib-39MjwPSq.js";import{r as pe}from"./image-generation-api-GMTaS6eI.js";var me=n(),X=e(t(),1),Z=r(),Q=[`deep`,`fast`,`cheap`,`code`,`review`];function he(e){return Q.includes(e)}function ge(e){let{rows:t,onChange:n,disabled:r,defaultRole:i,chat:a,labels:o}=e,s=(0,X.useRef)([]),c=(0,X.useRef)(0);for(;s.current.length<t.length;)s.current.push(`preset-model-row-${c.current++}`);s.current.length>t.length&&(s.current.length=t.length);let l=i??(t.some(e=>e.id===`deep`)?`deep`:t[0]?.id)??`deep`,u=t.findIndex(e=>e.id===l),d=u>=0?t[u]:void 0,f=t.map((e,t)=>({row:e,index:t})).filter(({index:e})=>e!==u),p=(e,r)=>{n(t.map((t,n)=>n===e?{...t,...r}:t))},h=e=>{if(u>=0){p(u,{model:e});return}s.current.unshift(`preset-model-row-${c.current++}`),n([{id:l,model:e,fallbacks:[],description:he(l)?o.roleDescriptions[l]:``},...t])},g=e=>{let n=t[e];n&&p(e,{fallbacks:[...n.fallbacks??[],``]})},v=(e,n,r)=>{let i=t[e];if(!i)return;let a=[...i.fallbacks??[]];a[n]=r,p(e,{fallbacks:a})},y=(e,n)=>{let r=t[e];r&&p(e,{fallbacks:(r.fallbacks??[]).filter((e,t)=>t!==n)})},b=e=>{s.current.splice(e,1),n(t.filter((t,n)=>n!==e))},x=e=>{if(!e)return;let r=e===`__custom__`?``:e;s.current.push(`preset-model-row-${c.current++}`),n([...t,{id:r,model:``,fallbacks:[],description:he(r)?o.roleDescriptions[r]:``}])},S=[...Q.filter(e=>e!==l&&!t.some(t=>t.id===e)).map(e=>({value:e,label:o.roleNames[e]})),{value:`__custom__`,label:o.customRole}],C=(e,t)=>(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.fallbackModels}),(0,Z.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:r,onClick:()=>g(t),children:[(0,Z.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),o.addFallback]})]}),(e.fallbacks??[]).length>0?(0,Z.jsx)(`div`,{className:`grid gap-1.5`,children:(e.fallbacks??[]).map((e,n)=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,Z.jsx)(w,{value:e,disabled:r,placeholder:o.fallbackPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>v(t,n,e)}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:r,"aria-label":o.removeFallback,onClick:()=>y(t,n),children:(0,Z.jsx)(O,{className:`size-4`,"aria-hidden":!0})})]},`${s.current[t]}-fallback-${n}`))}):(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.fallbackEmptyHint})]}),(0,Z.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-fg-muted`,children:[o.description,(0,Z.jsx)(`input`,{type:`text`,className:J(),value:e.description,disabled:r,placeholder:o.descriptionPlaceholder,onChange:e=>p(t,{description:e.target.value})})]})]});return(0,Z.jsxs)(`div`,{className:`grid gap-5`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:o.defaultTitle}),(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:o.defaultBadge})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:o.defaultHint})]}),(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 font-mono text-[11px] text-fg-subtle`,children:[o.roleId,`: `,l]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.primaryModel}),(0,Z.jsx)(w,{value:d?.model??``,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:h})]}),d?(0,Z.jsxs)(`details`,{className:`group mt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-md text-xs font-medium text-fg-muted hover:text-fg`,children:[o.moreSettings,(0,Z.jsx)(M,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3`,children:C(d,u)})]}):null]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:o.otherRolesTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:o.otherRolesHint})]}),f.length>0?(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:f.map(({row:e,index:t})=>{let n=he(e.id)?e.id:void 0;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/60 p-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(8rem,12rem)_minmax(0,1fr)] md:items-end`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n?o.roleNames[n]:o.customRole}),n?(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:e.id}):(0,Z.jsxs)(`label`,{className:`mt-1 grid gap-1 text-[11px] text-fg-muted`,children:[o.roleId,(0,Z.jsx)(`input`,{type:`text`,className:J(),value:e.id,disabled:r,placeholder:o.roleIdPlaceholder,onChange:e=>p(t,{id:e.target.value.toLowerCase()})})]})]}),(0,Z.jsxs)(`label`,{className:`grid min-w-0 gap-1.5 text-xs font-medium text-fg-muted`,children:[o.primaryModel,(0,Z.jsx)(w,{value:e.model,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>p(t,{model:e})})]})]}),(0,Z.jsxs)(`details`,{className:`group mt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[o.moreSettings,(0,Z.jsx)(M,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsxs)(`div`,{className:`mt-3`,children:[C(e,t),(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(_,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>b(t),children:[(0,Z.jsx)(O,{className:`size-4`,"aria-hidden":!0}),o.removeRole]})})]})]})]},s.current[t])})}):(0,Z.jsx)(`p`,{className:`mt-3 rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:o.otherRolesEmpty}),(0,Z.jsx)(E,{value:``,options:S,placeholder:o.addTaskModel,allowEmpty:!1,disabled:r,triggerClassName:`mt-3 w-fit`,onChange:x})]})]})}function _e(e){let t=(0,me.c)(62),{extendsIds:n,onExtendsChange:r,presetOptions:i,jsonFields:a,onJsonFieldsChange:o,disabled:s,labels:c}=e,l;t[0]===a?l=t[1]:(l=Object.keys(a),t[0]=a,t[1]=l);let u=l,d;t[2]===i?d=t[3]:(d=new Map(i.map(ve)),t[2]=i,t[3]=d);let f=d,p,v,y,b,x;if(t[4]!==s||t[5]!==n||t[6]!==c.inheritanceAdd||t[7]!==c.inheritanceApplied||t[8]!==c.inheritanceAvailable||t[9]!==c.inheritanceEmpty||t[10]!==c.inheritanceHint||t[11]!==c.inheritanceMoveDown||t[12]!==c.inheritanceMoveUp||t[13]!==c.inheritanceRemove||t[14]!==c.inheritanceTitle||t[15]!==r||t[16]!==f||t[17]!==i){let e;t[23]===n?e=t[24]:(e=e=>!n.includes(e.id),t[23]=n,t[24]=e);let a=i.filter(e);x=`flex flex-col gap-6`,t[25]===c.inheritanceTitle?p=t[26]:(p=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[25]=c.inheritanceTitle,t[26]=p),t[27]===c.inheritanceHint?v=t[28]:(v=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[27]=c.inheritanceHint,t[28]=v),t[29]!==s||t[30]!==n||t[31]!==c.inheritanceApplied||t[32]!==c.inheritanceMoveDown||t[33]!==c.inheritanceMoveUp||t[34]!==c.inheritanceRemove||t[35]!==r||t[36]!==f?(y=n.length>0?(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:c.inheritanceApplied}),(0,Z.jsx)(`div`,{className:`grid gap-2`,children:n.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:f.get(e)?.name??e}),(0,Z.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-fg-subtle`,children:e})]}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s||t===0,"aria-label":c.inheritanceMoveUp,onClick:()=>{let e=[...n],[i,a]=[e[t],e[t-1]];e[t-1]=i,e[t]=a,r(e)},children:(0,Z.jsx)(h,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s||t===n.length-1,"aria-label":c.inheritanceMoveDown,onClick:()=>{let e=[...n],[i,a]=[e[t+1],e[t]];e[t]=i,e[t+1]=a,r(e)},children:(0,Z.jsx)(g,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s,"aria-label":c.inheritanceRemove,onClick:()=>r(n.filter(t=>t!==e)),children:(0,Z.jsx)(O,{className:`size-3.5`,"aria-hidden":!0})})]},e))})]}):null,t[29]=s,t[30]=n,t[31]=c.inheritanceApplied,t[32]=c.inheritanceMoveDown,t[33]=c.inheritanceMoveUp,t[34]=c.inheritanceRemove,t[35]=r,t[36]=f,t[37]=y):y=t[37],b=a.length>0?(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:c.inheritanceAvailable}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:a.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s,"aria-label":c.inheritanceAdd,onClick:()=>r([...n,e.id]),children:(0,Z.jsx)(m,{className:`size-3.5`,"aria-hidden":!0})})]},e.id))})]}):n.length===0?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}):null,t[4]=s,t[5]=n,t[6]=c.inheritanceAdd,t[7]=c.inheritanceApplied,t[8]=c.inheritanceAvailable,t[9]=c.inheritanceEmpty,t[10]=c.inheritanceHint,t[11]=c.inheritanceMoveDown,t[12]=c.inheritanceMoveUp,t[13]=c.inheritanceRemove,t[14]=c.inheritanceTitle,t[15]=r,t[16]=f,t[17]=i,t[18]=p,t[19]=v,t[20]=y,t[21]=b,t[22]=x}else p=t[18],v=t[19],y=t[20],b=t[21],x=t[22];let S;t[38]!==p||t[39]!==v||t[40]!==y||t[41]!==b?(S=(0,Z.jsxs)(`section`,{children:[p,v,y,b]}),t[38]=p,t[39]=v,t[40]=y,t[41]=b,t[42]=S):S=t[42];let C;t[43]===c.jsonTitle?C=t[44]:(C=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[43]=c.jsonTitle,t[44]=C);let w;t[45]===c.jsonHint?w=t[46]:(w=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[45]=c.jsonHint,t[46]=w);let T;t[47]!==s||t[48]!==u||t[49]!==a||t[50]!==c.fieldHints||t[51]!==c.fieldLabels||t[52]!==o?(T=(0,Z.jsx)(`div`,{className:`mt-3 grid gap-4 lg:grid-cols-2`,children:u.map(e=>(0,Z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:c.fieldLabels[e]}),(0,Z.jsx)(`span`,{className:`min-h-8 text-xs leading-relaxed text-fg-muted`,children:c.fieldHints[e]}),(0,Z.jsx)(`textarea`,{className:`min-h-36 resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:a[e],disabled:s,spellCheck:!1,placeholder:`{}`,onChange:t=>o({...a,[e]:t.target.value})})]},e))}),t[47]=s,t[48]=u,t[49]=a,t[50]=c.fieldHints,t[51]=c.fieldLabels,t[52]=o,t[53]=T):T=t[53];let E;t[54]!==T||t[55]!==C||t[56]!==w?(E=(0,Z.jsxs)(`section`,{children:[C,w,T]}),t[54]=T,t[55]=C,t[56]=w,t[57]=E):E=t[57];let D;return t[58]!==E||t[59]!==x||t[60]!==S?(D=(0,Z.jsxs)(`div`,{className:x,children:[S,E]}),t[58]=E,t[59]=x,t[60]=S,t[61]=D):D=t[61],D}function ve(e){return[e.id,e]}function ye(e){return e.name||e.directoryId}function be(e){let t=(0,me.c)(56),{mode:n,selected:r,catalog:i,loading:a,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,f;t[0]===i?f=t[1]:(f=i.map(ye).filter(Boolean),t[0]=i,t[1]=f);let p=f,m;bb0:{if(n===`inherit`){m=u.inheritSummary;break bb0}if(n===`all`){m=u.allSummary;break bb0}if(n===`off`){m=u.offSummary;break bb0}let e=n===`allowlist`?u.allowSummary:u.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],m=i}let h=m,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(H,{className:`size-3.5`,"aria-hidden":!0}),t[5]=g):g=t[5];let v;t[6]===u.overrideSummaryTitle?v=t[7]:(v=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[g,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=v);let y;t[8]===h?y=t[9]:(y=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:h}),t[8]=h,t[9]=y);let b;t[10]!==v||t[11]!==y?(b=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[v,y]}),t[10]=v,t[11]=y,t[12]=b):b=t[12];let x;t[13]===u.modeLabel?x=t[14]:(x=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=x);let S;t[15]===u.modeInherit?S=t[16]:(S=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=S);let C;t[17]===u.modeAll?C=t[18]:(C=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=C);let w;t[19]===u.modeAllowlist?w=t[20]:(w=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=w);let T;t[21]===u.modeDenylist?T=t[22]:(T=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=T);let E;t[23]===u.modeOff?E=t[24]:(E=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=E);let D;t[25]!==T||t[26]!==E||t[27]!==S||t[28]!==C||t[29]!==w?(D=[S,C,w,T,E],t[25]=T,t[26]=E,t[27]=S,t[28]=C,t[29]=w,t[30]=D):D=t[30];let O=D,k;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==O?(k=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:O.map(e=>{let[t,r]=e;return(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=O,t[35]=k):k=t[35];let A;t[36]!==k||t[37]!==x?(A=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[x,k]}),t[36]=k,t[37]=x,t[38]=A):A=t[38];let j;t[39]!==i||t[40]!==p||t[41]!==s||t[42]!==u.emptyCatalog||t[43]!==u.noDescription||t[44]!==u.quickActionsLabel||t[45]!==u.quickClear||t[46]!==u.quickSelectAll||t[47]!==a||t[48]!==l||t[49]!==d||t[50]!==r?(j=d?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:s||a||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:s||a||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),a?(0,Z.jsx)(re,{rows:3}):i.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:i.map(e=>{let t=ye(e),n=r.has(t),i=typeof e.description==`string`?e.description.trim():``,a=i||u.noDescription;return(0,Z.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,Z.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,Z.jsx)(`p`,{className:o(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!i&&`italic text-fg-subtle`),title:a,children:a})]})]})},t)})})]}):null,t[39]=i,t[40]=p,t[41]=s,t[42]=u.emptyCatalog,t[43]=u.noDescription,t[44]=u.quickActionsLabel,t[45]=u.quickClear,t[46]=u.quickSelectAll,t[47]=a,t[48]=l,t[49]=d,t[50]=r,t[51]=j):j=t[51];let M;return t[52]!==A||t[53]!==j||t[54]!==b?(M=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[b,A,j]}),t[52]=A,t[53]=j,t[54]=b,t[55]=M):M=t[55],M}var xe=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],Se=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],Ce=[`send_message`,`send_media`,`text_to_speech`,`create_share`],we=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],Te=[...xe,...Ce],Ee=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],De=[`send_message`,`send_media`];function Oe(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]={mode:i});return n}function ke(e){let t=(0,me.c)(105),{builtinToolIds:n,toolPolicies:r,onChange:i,disabled:a,getToolDescription:s,getGroupTitle:c,labels:l}=e,u;t[0]===n?u=t[1]:(u=new Set(n),t[0]=n,t[1]=u);let f=u,p;t[2]!==f||t[3]!==r?(p=Object.entries(r).filter(e=>{let[t]=e;return f.has(t)}).toSorted(Ae),t[2]=f,t[3]=r,t[4]=p):p=t[4];let m=p,h;if(t[5]!==f||t[6]!==n){h=[];for(let e of se){let t=e.toolIds.filter(e=>f.has(e));t.length>0&&h.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=le(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),h.push(e)}t[5]=f,t[6]=n,t[7]=h}else h=t[7];let g=h,v;t[12]!==i||t[13]!==r?(v=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]={...n[e],mode:t},i(n)},t[12]=i,t[13]=r,t[14]=v):v=t[14];let y=v,b;t[15]!==i||t[16]!==r?(b=(e,t)=>{let n=r[e];n&&i({...r,[e]:t(n)})},t[15]=i,t[16]=r,t[17]=b):b=t[17];let x=b,S;t[18]!==f||t[19]!==i?(S=e=>{i(Oe(f,e))},t[18]=f,t[19]=i,t[20]=S):S=t[20];let C=S;if(n.length===0){let e;return t[21]===l.emptyBuiltin?e=t[22]:(e=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[21]=l.emptyBuiltin,t[22]=e),e}let w;t[23]===l.quickActionsLabel?w=t[24]:(w=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[23]=l.quickActionsLabel,t[24]=w);let T;t[25]===i?T=t[26]:(T=()=>i({}),t[25]=i,t[26]=T);let E;t[27]!==a||t[28]!==l.quickClearOverrides||t[29]!==T?(E=(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:T,children:l.quickClearOverrides}),t[27]=a,t[28]=l.quickClearOverrides,t[29]=T,t[30]=E):E=t[30];let D;t[31]===C?D=t[32]:(D=()=>C([[xe,`deny`]]),t[31]=C,t[32]=D);let O;t[33]!==a||t[34]!==l.quickReadOnlyWorkspace||t[35]!==D?(O=(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:D,children:l.quickReadOnlyWorkspace}),t[33]=a,t[34]=l.quickReadOnlyWorkspace,t[35]=D,t[36]=O):O=t[36];let k;t[37]===C?k=t[38]:(k=()=>C([[Se,`deny`]]),t[37]=C,t[38]=k);let A;t[39]!==a||t[40]!==l.quickHighRiskOff||t[41]!==k?(A=(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:k,children:l.quickHighRiskOff}),t[39]=a,t[40]=l.quickHighRiskOff,t[41]=k,t[42]=A):A=t[42];let j;t[43]===C?j=t[44]:(j=()=>C([[Ce,`deny`]]),t[43]=C,t[44]=j);let M;t[45]!==a||t[46]!==l.quickNoOutbound||t[47]!==j?(M=(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:j,children:l.quickNoOutbound}),t[45]=a,t[46]=l.quickNoOutbound,t[47]=j,t[48]=M):M=t[48];let P;t[49]===C?P=t[50]:(P=()=>C([[we,`allow`],[Te,`deny`]]),t[49]=C,t[50]=P);let ee;t[51]!==a||t[52]!==l.quickResearchMode||t[53]!==P?(ee=(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:P,children:l.quickResearchMode}),t[51]=a,t[52]=l.quickResearchMode,t[53]=P,t[54]=ee):ee=t[54];let F;t[55]===C?F=t[56]:(F=()=>C([[Ee,`allow`],[De,`deny`]]),t[55]=C,t[56]=F);let I;t[57]!==a||t[58]!==l.quickCodingMode||t[59]!==F?(I=(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:F,children:l.quickCodingMode}),t[57]=a,t[58]=l.quickCodingMode,t[59]=F,t[60]=I):I=t[60];let L;t[61]!==A||t[62]!==M||t[63]!==ee||t[64]!==I||t[65]!==E||t[66]!==O?(L=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[E,O,A,M,ee,I]}),t[61]=A,t[62]=M,t[63]=ee,t[64]=I,t[65]=E,t[66]=O,t[67]=L):L=t[67];let R;t[68]!==L||t[69]!==w?(R=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[w,L]}),t[68]=L,t[69]=w,t[70]=R):R=t[70];let z;t[71]===l.overrideSummaryTitle?z=t[72]:(z=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[71]=l.overrideSummaryTitle,t[72]=z);let B;t[73]!==l.modeAllow||t[74]!==l.modeConfirm||t[75]!==l.modeDeny||t[76]!==l.noOverrides||t[77]!==m?(B=m.length>0?(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:m.map(e=>{let[t,n]=e;return(0,Z.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n.mode===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n.mode===`confirm`&&`border-amber-500/25 bg-amber-500/10 text-amber-700 dark:text-amber-300`,n.mode===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,Z.jsx)(`span`,{className:`font-sans opacity-80`,children:n.mode===`allow`?l.modeAllow:n.mode===`confirm`?l.modeConfirm:l.modeDeny})]},t)})}):(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[73]=l.modeAllow,t[74]=l.modeConfirm,t[75]=l.modeDeny,t[76]=l.noOverrides,t[77]=m,t[78]=B):B=t[78];let V;t[79]!==z||t[80]!==B?(V=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[z,B]}),t[79]=z,t[80]=B,t[81]=V):V=t[81];let H;t[82]!==a||t[83]!==c||t[84]!==s||t[85]!==g||t[86]!==l.inheritedMode||t[87]!==l.maxCallsLabel||t[88]!==l.modeAllow||t[89]!==l.modeConfirm||t[90]!==l.modeDeny||t[91]!==l.scopeInherit||t[92]!==l.scopeLabel||t[93]!==l.scopeReadonly||t[94]!==l.scopeUnrestricted||t[95]!==l.scopeWorkspace||t[96]!==l.timeoutLabel||t[97]!==y||t[98]!==r||t[99]!==x?(H=(0,Z.jsx)(`div`,{className:`flex flex-col gap-5`,children:g.map(e=>{let{key:t,ids:n}=e;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=r[e],i=n?n.mode:`inherit`;return(0,Z.jsxs)(`li`,{className:o(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,i===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:[(0,Z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,Z.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`confirm`,`deny`].map(t=>(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,i===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:a,onClick:()=>y(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:t===`confirm`?l.modeConfirm:l.modeDeny},t))})]}),n?(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 sm:grid-cols-3 dark:border-edge`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l.scopeLabel,(0,Z.jsxs)(d,{value:n.scope??``,disabled:a,onChange:t=>x(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,Z.jsx)(N,{value:``,children:l.scopeInherit}),(0,Z.jsx)(N,{value:`readonly`,children:l.scopeReadonly}),(0,Z.jsx)(N,{value:`workspace`,children:l.scopeWorkspace}),(0,Z.jsx)(N,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,Z.jsx)($,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:a,onChange:t=>x(e,e=>je(e,`maxCallsPerTurn`,t))}),(0,Z.jsx)($,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:a,onChange:t=>x(e,e=>je(e,`timeoutMs`,t))})]}):null]},e)})})]},t)})}),t[82]=a,t[83]=c,t[84]=s,t[85]=g,t[86]=l.inheritedMode,t[87]=l.maxCallsLabel,t[88]=l.modeAllow,t[89]=l.modeConfirm,t[90]=l.modeDeny,t[91]=l.scopeInherit,t[92]=l.scopeLabel,t[93]=l.scopeReadonly,t[94]=l.scopeUnrestricted,t[95]=l.scopeWorkspace,t[96]=l.timeoutLabel,t[97]=y,t[98]=r,t[99]=x,t[100]=H):H=t[100];let U;return t[101]!==R||t[102]!==V||t[103]!==H?(U=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[R,V,H]}),t[101]=R,t[102]=V,t[103]=H,t[104]=U):U=t[104],U}function Ae(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function je(e,t,n){let r={...e.limits};if(n===void 0?delete r[t]:r[t]=n,Object.keys(r).length===0){let{limits:t,...n}=e;return n}return{...e,limits:r}}function $(e){let t=(0,me.c)(9),n=e.value??``,r;t[0]===e?r=t[1]:(r=t=>{let n=t.target.value.trim();e.onChange(n?Number(n):void 0)},t[0]=e,t[1]=r);let i;t[2]!==e.disabled||t[3]!==n||t[4]!==r?(i=(0,Z.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:border-edge-strong focus:outline-none`,value:n,disabled:e.disabled,onChange:r}),t[2]=e.disabled,t[3]=n,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e.label||t[7]!==i?(a=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[e.label,i]}),t[6]=e.label,t[7]=i,t[8]=a):a=t[8],a}var Me=[`blank`,`safe-coder`,`read-only`,`low-cost`],Ne=[{id:`overview`,icon:y},{id:`models`,icon:R},{id:`tools`,icon:f},{id:`skills`,icon:j},{id:`advanced`,icon:P},{id:`impact`,icon:T}];function Pe(e){return fe(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function Fe(e){return structuredClone(e?.tools?.builtin??{})}function Ie(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function Le(){return{primary:``,fallbacks:[],timeoutMs:``,autoProviderFallback:``}}function Re(e){return{primary:e?.primary??``,fallbacks:[...e?.fallbacks??[]],timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function ze(){return{imageModel:Le(),imageGenerationModel:Le(),allowFallbacks:``,maxCostTier:``}}function Be(e){return{imageModel:Re(e?.models?.imageModel),imageGenerationModel:Re(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function Ve(e){return e===void 0?``:JSON.stringify(e,null,2)}function He(){return{mcp:``,workflows:``,boundaries:``,runtime:``,locks:``}}function Ue(e){return{mcp:Ve(e?.tools?.mcp),workflows:Ve(e?.workflows),boundaries:Ve(e?.boundaries),runtime:Ve(e?.runtime),locks:Ve(e?.locks)}}function We(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:Pe(e),modelAdvanced:Be(e),toolPolicies:Fe(e),skillMode:e?.skills?.mode??`inherit`,skillPick:Ie(e),extendsIds:[...e?.extends??[]],jsonFields:Ue(e)}}function Ge(e){let t=e.primary.trim();if(!t)return;let n=e.fallbacks.map(e=>e.trim()).filter(Boolean),r=e.timeoutMs.trim()?Number(e.timeoutMs):void 0,i=e.autoProviderFallback===``?void 0:e.autoProviderFallback===`true`;return{primary:t,...n.length>0?{fallbacks:n}:{},...r?{timeoutMs:r}:{},...i===void 0?{}:{autoProviderFallback:i}}}function Ke(e,t){let n=Y(e.modelRows),r=Ge(e.modelAdvanced.imageModel),i=Ge(e.modelAdvanced.imageGenerationModel),a=e.modelAdvanced.allowFallbacks||e.modelAdvanced.maxCostTier?{...e.modelAdvanced.allowFallbacks?{allowFallbacks:e.modelAdvanced.allowFallbacks===`true`}:{},...e.modelAdvanced.maxCostTier?{maxCostTier:e.modelAdvanced.maxCostTier}:{}}:void 0,o={...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},...n?.roles?{roles:n.roles}:{},...r?{imageModel:r}:{},...i?{imageGenerationModel:i}:{},...a?{policy:a}:{}};return Object.keys(o).length>0?o:null}function qe(e){return e.trim()?JSON.parse(e):void 0}function Je(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e))}catch{return`!invalid:${e}`}}function Ye(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=qe(e.jsonFields.mcp);return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function Xe(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function Ze(e){if(e.skillMode===`inherit`)return null;let t=[...e.skillPick].toSorted((e,t)=>e.localeCompare(t));return e.skillMode===`allowlist`?{mode:`allowlist`,allow:t}:e.skillMode===`denylist`?{mode:`denylist`,deny:t}:{mode:e.skillMode}}function Qe(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:Ke(e,t),tools:{builtin:Xe(e.toolPolicies),mcp:Je(e.jsonFields.mcp)},skills:Ze(e),extends:[...e.extendsIds].toSorted(),workflows:Je(e.jsonFields.workflows),boundaries:Je(e.jsonFields.boundaries),runtime:Je(e.jsonFields.runtime),locks:Je(e.jsonFields.locks)}}function $e(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:Xe(e.tools?.builtin),mcp:Je(Ve(e.tools?.mcp))},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:Je(Ve(e.workflows)),boundaries:Je(Ve(e.boundaries)),runtime:Je(Ve(e.runtime)),locks:Je(Ve(e.locks))}:null}function et(e,t){return[e.models?.roles?t.summaryModels.replace(`{{count}}`,String(Object.keys(e.models.roles).length)):``,e.tools?.builtin?t.summaryTools.replace(`{{count}}`,String(Object.keys(e.tools.builtin).length)):``,e.skills?t.summarySkills.replace(`{{mode}}`,t.skillModeLabels[e.skills.mode]):``].filter(Boolean).join(` · `)||t.summaryEmpty}function tt(e){return e===void 0?`—`:typeof e==`string`?e:JSON.stringify(e)}function nt(){return{modelAdvanced:ze(),extendsIds:[],jsonFields:He()}}function rt(e,t){return{extends:[...e.extendsIds],models:Ke(e,t)??void 0,tools:Ye(e)??void 0,skills:Ze(e)??void 0,workflows:qe(e.jsonFields.workflows),boundaries:qe(e.jsonFields.boundaries),runtime:qe(e.jsonFields.runtime),locks:qe(e.jsonFields.locks)}}function it(e,t){return e===`safe-coder`?{id:`safe-coder`,name:t.starters[`safe-coder`].title,description:t.starters[`safe-coder`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`code`,model:``,fallbacks:[],description:t.modelRoleDescriptions.code},{id:`review`,model:``,fallbacks:[],description:t.modelRoleDescriptions.review}],toolPolicies:{exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`]),...nt()}:e===`read-only`?{id:`read-only-research`,name:t.starters[`read-only`].title,description:t.starters[`read-only`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast}],toolPolicies:{write_file:{mode:`deny`},apply_patch:{mode:`deny`},exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`all`,skillPick:new Set,...nt()}:e===`low-cost`?{id:`low-cost-assistant`,name:t.starters[`low-cost`].title,description:t.starters[`low-cost`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast},{id:`cheap`,model:``,fallbacks:[],description:t.modelRoleDescriptions.cheap}],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...nt()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...nt()}}function at(){let e=s(l(e=>e.language)),t=e.capabilityPresetsSettings,n=(0,Z.jsx)(_,{asChild:!0,type:`button`,variant:`secondary`,children:(0,Z.jsxs)(a,{to:`/agents`,children:[t.manageAgents,(0,Z.jsx)(B,{className:`size-4`,"aria-hidden":!0})]})}),r=!!c(e=>e.token),{data:d,error:h,isLoading:g,mutate:w}=u(r?`settings-capability-presets`:null,ce,{revalidateOnFocus:!1}),{data:E=[],isLoading:M}=u(r?`settings-capability-presets-skills-catalog`:null,S,{revalidateOnFocus:!1}),[N,H]=i(),[se,le]=(0,X.useState)(``),[fe,q]=(0,X.useState)(`overview`),[J,Y]=(0,X.useState)(()=>it(`blank`,t)),[pe,me]=(0,X.useState)(null),[Q,he]=(0,X.useState)(!1),[ve,ye]=(0,X.useState)(null),[xe,Se]=(0,X.useState)(!1),[Ce,we]=(0,X.useState)(null),[Te,Ee]=(0,X.useState)(null),De=d?.presets??[],Oe=d?.defaultPresetId??`default`,Ae=De.find(e=>e.id===Oe)??null,je=De.filter(e=>e.id!==Oe),$=(0,X.useMemo)(()=>De.find(e=>e.id===se)??De[0]??null,[De,se]),Pe=!$||J.id.trim()!==$.id,Fe=!!($&&$.id===Oe),Ie=JSON.stringify(Qe(J,$))!==JSON.stringify($e($)),Le=Qe(J,$),Re=$e($),ze=[Le.id!==Re?.id||Le.name!==Re?.name||Le.description!==Re?.description?t.tabs.overview:``,JSON.stringify(Le.models)===JSON.stringify(Re?.models)?``:t.tabs.models,JSON.stringify(Le.tools)===JSON.stringify(Re?.tools)?``:t.tabs.tools,JSON.stringify(Le.skills)===JSON.stringify(Re?.skills)?``:t.tabs.skills,JSON.stringify({extends:Le.extends,workflows:Le.workflows,boundaries:Le.boundaries,runtime:Le.runtime,locks:Le.locks})===JSON.stringify({extends:Re?.extends,workflows:Re?.workflows,boundaries:Re?.boundaries,runtime:Re?.runtime,locks:Re?.locks})?``:t.tabs.advanced].filter(Boolean),Be=(0,X.useMemo)(()=>{if(!$||Pe)return null;try{let e=rt(J,$);return{name:J.name.trim(),description:J.description.trim()||null,extends:e.extends??null,models:e.models??null,tools:e.tools??null,skills:e.skills??null,workflows:e.workflows??null,boundaries:e.boundaries??null,runtime:e.runtime??null,locks:e.locks??null}}catch{return null}},[J,Pe,$]),{data:Ve,error:He,isLoading:Ue}=u(fe===`impact`&&$&&Be?[`capability-preset-impact-preview`,$.id,JSON.stringify(Be)]:null,()=>ae($.id,Be),{revalidateOnFocus:!1}),Ge=ve??(h instanceof Error?h.message:null),Ke=N.get(`action`)===`new`||!!N.get(`preset`),Je=N.get(`action`)===`new`&&pe===null,Ye=Pe?t.newPreset:$?.name??t.editorTitle,Xe=t=>e.agentsSettings.toolsDisableGroups[t],Ze=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,X.useEffect)(()=>{if(!d||Q)return;if(N.get(`action`)===`new`){le(``),Y(it(`blank`,t)),q(`overview`);return}let e=N.get(`preset`)?.trim(),n=e?d.presets.find(t=>t.id===e):null;if(n){le(n.id),Y(We(n)),q(N.get(`tab`)??`overview`);return}$&&(le($.id),Y(e=>e.id===$.id?e:We($)))},[Q,d,N,$]);function nt(e){me(null),le(e.id),Y(We(e)),H({preset:e.id},{replace:!0}),q(`overview`)}function at(){me(null),le(``),Y(it(`blank`,t)),ye(null),H({action:`new`},{replace:!0}),q(`overview`)}function ct(e){me(e),Y(it(e,t)),ye(null),q(`overview`)}function lt(){if(pe){let e=it(pe,t);if(JSON.stringify(Qe(J,null))!==JSON.stringify(Qe(e,null))&&!window.confirm(t.changeTemplateConfirm))return}me(null),ye(null)}function ut(){!Je&&Ie&&!window.confirm(t.discardConfirm)||(Se(!1),we(null),H({},{replace:!0}),me(null),ye(null),Y(We($)),q(`overview`))}async function dt(){let e=de(J.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){ye(e),q(`models`);return}for(let e of[J.modelAdvanced.imageModel,J.modelAdvanced.imageGenerationModel]){if([e.primary,...e.fallbacks].map(e=>e.trim()).filter(Boolean).some(e=>!/^[^/\s]+\/.+/.test(e))){ye(t.invalidModelRef),q(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){ye(t.advancedPositiveIntegerError),q(`models`);return}}for(let e of Object.values(J.toolPolicies))if([e.limits?.maxCallsPerTurn,e.limits?.timeoutMs].filter(e=>e!==void 0).some(e=>!Number.isInteger(e)||e<=0)){ye(t.advancedPositiveIntegerError),q(`tools`);return}for(let e of Object.keys(J.jsonFields))try{qe(J.jsonFields[e])}catch{ye(t.advancedJsonError.replace(`{{field}}`,t.advancedFieldLabels[e])),q(`advanced`);return}he(!0),ye(null);try{let e=rt(J,$);if(Pe){let t=await ue({id:J.id.trim(),name:J.name.trim(),...J.description.trim()?{description:J.description.trim()}:{},...e});await w(t.presets,{revalidate:!1}),le(t.presetId),me(null),H({preset:t.presetId},{replace:!0})}else $&&await w(await ie($.id,{name:J.name.trim(),description:J.description.trim()||null,extends:e.extends??null,models:e.models??null,tools:e.tools??null,skills:e.skills??null,workflows:e.workflows??null,boundaries:e.boundaries??null,runtime:e.runtime??null,locks:e.locks??null}),{revalidate:!1})}catch(e){ye(e instanceof Error?e.message:t.saveError)}finally{he(!1)}}async function ft(){if($){he(!0),ye(null),we(null);try{await w(await oe($.id),{revalidate:!1}),Se(!1),le(``),me(null),Y(it(`blank`,t)),q(`overview`),H({},{replace:!0})}catch(e){we(e instanceof Error?e.message:t.deleteError)}finally{he(!1)}}}return r?(0,Z.jsxs)(te,{gap:`gap-5`,className:`pb-24`,children:[(0,Z.jsx)(W,{title:t.title,subtitle:t.subtitle,actions:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[n,(0,Z.jsxs)(_,{type:`button`,onClick:at,disabled:Q,children:[(0,Z.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]})}),Ge?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Ge}):null,g?(0,Z.jsx)(ne,{sections:2}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[Ae?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:R,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>nt(Ae),className:`group rounded-lg bg-accent/5 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Ae.name}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Ae.id})]}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),Ae.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Ae.description}):null,(0,Z.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:et(Ae,t)})]})]}):null,(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:R,title:t.listTitle,subtitle:t.listHint}),je.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:[(0,Z.jsx)(`p`,{children:t.empty}),(0,Z.jsxs)(_,{type:`button`,variant:`secondary`,onClick:at,disabled:Q,children:[(0,Z.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]}):(0,Z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:je.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>nt(e),className:`group min-h-36 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,Z.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:et(e,t)})]},e.id))})]})]}),(0,Z.jsx)(x,{open:Ke,onOpenChange:e=>{e||ut()},children:(0,Z.jsxs)(k,{children:[(0,Z.jsx)(p,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,F)}),(0,Z.jsx)(D,{ref:Ee,className:o(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,760px)] w-[min(100%-2rem,64rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,A),onOpenAutoFocus:e=>e.preventDefault(),children:(0,Z.jsxs)(z,{layer:`modal`,portalContainer:Te,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[!Je&&Pe&&pe?(0,Z.jsx)(`button`,{type:`button`,className:o(V,`shrink-0 p-1.5 hover:bg-surface-base`),onClick:lt,"aria-label":t.changeTemplate,title:t.changeTemplate,children:(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":!0})}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(b,{className:`truncate text-base font-semibold text-fg`,children:Ye}),(0,Z.jsx)(U,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Je?t.templatePickerSubtitle:Pe&&pe?`${t.editorHint} · ${t.basedOnTemplate.replace(`{{template}}`,t.starters[pe].title)}`:Pe?t.editorHint:J.id})]})]}),(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:o(V,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,Z.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})})]}),Je?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 sm:p-5`,children:(0,Z.jsx)(`div`,{className:`mx-auto grid max-w-3xl gap-3 sm:grid-cols-2`,children:Me.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`group min-h-32 rounded-xl border border-edge-subtle bg-surface-base px-4 py-4 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>ct(e),children:[(0,Z.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),e===`blank`?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.templateRecommended}):null]}),(0,Z.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})}),(0,Z.jsx)(`div`,{className:`flex shrink-0 justify-end border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:(0,Z.jsx)(_,{type:`button`,variant:`secondary`,onClick:ut,children:t.cancel})})]}):(0,Z.jsxs)(Z.Fragment,{children:[Ge?(0,Z.jsx)(`div`,{className:`mx-4 mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Ge}):null,(0,Z.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2 border-b border-edge-subtle bg-surface-base px-4 py-2 dark:border-edge`,children:Ne.map(({id:e,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,className:o(`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,fe===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>q(e),children:[(0,Z.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:(0,Z.jsxs)(`div`,{className:`w-full`,children:[fe===`overview`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:y,title:t.overviewTitle,subtitle:t.overviewHint}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,Z.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.id,disabled:Q||!Pe,onChange:e=>Y(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),!Pe&&$?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg-muted`,children:t.versionAutomatic.replace(`{{version}}`,String($.version))})]}):null,(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,Z.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.name,disabled:Q,onChange:e=>Y(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,Z.jsx)(`textarea`,{className:`min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.description,disabled:Q,onChange:e=>Y(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(ot,{icon:R,label:t.modelsTitle,value:String(J.modelRows.length)}),(0,Z.jsx)(ot,{icon:f,label:t.toolsTitle,value:String(Object.keys(J.toolPolicies).length)}),(0,Z.jsx)(ot,{icon:j,label:t.skillsTitle,value:t.skillModeLabels[J.skillMode]})]})]}):null,fe===`models`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:R,title:t.modelsTitle,subtitle:t.modelsHint}),(0,Z.jsx)(ge,{rows:J.modelRows,onChange:e=>Y(t=>({...t,modelRows:e})),disabled:Q,defaultRole:$?.models?.defaultRole,chat:e.chat,labels:{defaultTitle:t.modelDefaultTitle,defaultHint:t.modelDefaultHint,defaultBadge:t.modelDefaultBadge,roleId:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,moreSettings:t.modelMoreSettings,otherRolesTitle:t.modelOtherRolesTitle,otherRolesHint:t.modelOtherRolesHint,otherRolesEmpty:t.modelOtherRolesEmpty,addTaskModel:t.modelAddTaskModel,customRole:t.modelCustomRole,removeRole:t.removeModelRole,roleIdPlaceholder:`custom-role`,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}}),(0,Z.jsx)(st,{value:J.modelAdvanced,onChange:e=>Y(t=>({...t,modelAdvanced:e})),disabled:Q,cp:t,chat:e.chat})]}):null,fe===`tools`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:f,title:t.toolsTitle,subtitle:t.toolsHint}),(0,Z.jsx)(ke,{builtinToolIds:d?.builtinToolIds??[],toolPolicies:J.toolPolicies,onChange:e=>Y(t=>({...t,toolPolicies:e})),disabled:Q,getToolDescription:Ze,getGroupTitle:Xe,labels:{quickActionsLabel:t.toolsQuickActionsLabel,quickClearOverrides:t.toolsQuickClearOverrides,quickReadOnlyWorkspace:t.toolsQuickReadOnlyWorkspace,quickHighRiskOff:t.toolsQuickHighRiskOff,quickNoOutbound:t.toolsQuickNoOutbound,quickResearchMode:t.toolsQuickResearchMode,quickCodingMode:t.toolsQuickCodingMode,emptyBuiltin:t.toolsEmptyBuiltin,overrideSummaryTitle:t.toolsOverrideSummaryTitle,noOverrides:t.toolsNoOverrides,inheritedMode:t.toolModes.inherit,modeAllow:t.toolModes.allow,modeConfirm:t.toolModes.confirm,modeDeny:t.toolModes.deny,scopeLabel:t.toolScopeLabel,scopeInherit:t.toolScopeInherit,scopeReadonly:t.toolScopeReadonly,scopeWorkspace:t.toolScopeWorkspace,scopeUnrestricted:t.toolScopeUnrestricted,maxCallsLabel:t.toolMaxCallsLabel,timeoutLabel:t.toolTimeoutLabel}})]}):null,fe===`skills`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:j,title:t.skillsTitle,subtitle:t.skillsHint}),(0,Z.jsx)(be,{mode:J.skillMode,selected:J.skillPick,catalog:E,loading:M,disabled:Q,onModeChange:e=>Y(t=>({...t,skillMode:e})),onSelectedChange:e=>Y(t=>({...t,skillPick:e})),labels:{modeLabel:t.skillsModeLabel,modeInherit:t.skillsModeInherit,modeAll:t.skillsModeAll,modeAllowlist:t.skillsModeAllowlist,modeDenylist:t.skillsModeDenylist,modeOff:t.skillsModeOff,quickActionsLabel:t.skillsQuickActionsLabel,quickSelectAll:t.skillsQuickSelectAll,quickClear:t.skillsQuickClear,catalogLoading:t.skillsCatalogLoading,emptyCatalog:t.skillsEmptyCatalog,noDescription:t.skillsNoDescription,overrideSummaryTitle:t.skillsOverrideSummaryTitle,inheritSummary:t.skillsInheritSummary,allSummary:t.skillsAllSummary,offSummary:t.skillsOffSummary,allowSummary:t.skillsAllowSummary,denySummary:t.skillsDenySummary}})]}):null,fe===`advanced`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:P,title:t.advancedTitle,subtitle:t.advancedHint}),(0,Z.jsx)(_e,{extendsIds:J.extendsIds,onExtendsChange:e=>Y(t=>({...t,extendsIds:e})),presetOptions:De.filter(e=>e.id!==$?.id&&e.id!==Oe),jsonFields:J.jsonFields,onJsonFieldsChange:e=>Y(t=>({...t,jsonFields:e})),disabled:Q,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,inheritanceApplied:t.advancedInheritanceApplied,inheritanceAvailable:t.advancedInheritanceAvailable,inheritanceAdd:t.advancedInheritanceAdd,inheritanceRemove:t.advancedInheritanceRemove,inheritanceMoveUp:t.advancedInheritanceMoveUp,inheritanceMoveDown:t.advancedInheritanceMoveDown,jsonTitle:t.advancedJsonTitle,jsonHint:t.advancedJsonHint,fieldLabels:t.advancedFieldLabels,fieldHints:t.advancedFieldHints}})]}):null,fe===`impact`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:T,title:t.usageTitle,subtitle:t.usageHint}),(0,Z.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.changePreviewTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:ze.length>0?t.changePreviewSections.replace(`{{sections}}`,ze.join(`、`)):t.changePreviewEmpty})]}),Pe?null:(0,Z.jsxs)(`div`,{className:`mb-4`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.effectiveChangePreviewTitle}),Ue?(0,Z.jsx)(re,{rows:2}):He?(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-red-600 shadow-surface dark:text-red-400`,children:t.effectiveChangePreviewError}):Be?Ve?.agents.length?(0,Z.jsx)(`div`,{className:`grid gap-3`,children:Ve.agents.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,Z.jsx)(`div`,{className:`mt-2 grid gap-2`,children:e.diffs.map(e=>(0,Z.jsxs)(`div`,{className:`grid gap-1 text-xs sm:grid-cols-[minmax(0,12rem)_minmax(0,1fr)]`,children:[(0,Z.jsx)(`div`,{className:`truncate font-mono text-fg-muted`,children:e.path}),(0,Z.jsxs)(`div`,{className:`min-w-0 text-fg`,children:[(0,Z.jsx)(`span`,{className:`break-all text-fg-muted`,children:tt(e.before)}),(0,Z.jsx)(`span`,{className:`px-1.5 text-fg-subtle`,"aria-hidden":!0,children:`→`}),(0,Z.jsx)(`span`,{className:`break-all`,children:tt(e.after)})]})]},e.path))})]},e.agentId))}):(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:t.effectiveChangePreviewEmpty}):(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:t.effectiveChangePreviewInvalid})]}),$?.usage.length?(0,Z.jsx)(`div`,{className:`grid gap-2`,children:$.usage.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId}),(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-fg-subtle`,children:e.direct?t.usageDirect:t.usageIndirect})]},e.agentId))}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-fg`,children:Ie?t.unsavedTitle:t.noUnsavedTitle}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Ie?($?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String($?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ie?(0,Z.jsx)(_,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>Y(We($)),children:t.discard}):null,$&&!Fe?(0,Z.jsxs)(_,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>{we(null),Se(!0)},children:[(0,Z.jsx)(O,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,Z.jsxs)(_,{type:`button`,disabled:Q||!J.id.trim()||!J.name.trim()||!Ie,onClick:()=>void dt(),children:[(0,Z.jsx)(I,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})]})})]})}),(0,Z.jsx)(x,{open:xe,onOpenChange:e=>{Q||(Se(e),e||we(null))},children:(0,Z.jsxs)(k,{children:[(0,Z.jsx)(p,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,F)}),(0,Z.jsxs)(D,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,A),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,Z.jsx)(b,{className:`text-base font-semibold text-fg`,children:t.deleteDialogTitle}),(0,Z.jsx)(U,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:$?t.deleteConfirm.replace(`{{name}}`,$.name):t.deleteConfirmFallback})]}),Ce?(0,Z.jsx)(`div`,{className:`mx-4 mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Ce}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,children:[(0,Z.jsx)(_,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>Se(!1),children:t.cancel}),(0,Z.jsxs)(_,{type:`button`,disabled:Q||!$,className:`bg-red-600 text-white shadow-surface hover:bg-red-700 focus-visible:ring-red-600 dark:bg-red-500 dark:hover:bg-red-600`,onClick:()=>void ft(),children:[Q?(0,Z.jsx)(L,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(O,{className:`size-4`,"aria-hidden":!0}),Q?t.deleting:t.delete]})]})]})]})})]}):(0,Z.jsxs)(te,{gap:`gap-3`,children:[(0,Z.jsx)(W,{title:t.title,actions:n}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function ot(e){let t=(0,me.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==a?(o=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[a,r]}),t[2]=r,t[3]=a,t[4]=o):o=t[4];let s;t[5]===i?s=t[6]:(s=(0,Z.jsx)(`div`,{className:`mt-1 text-sm font-medium text-fg`,children:i}),t[5]=i,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function st(e){let t=(0,me.c)(121),{value:n,onChange:r,disabled:i,cp:a,chat:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[0]=s):s=t[0];let{data:c,isLoading:l,error:f}=u(`capability-preset-image-generation-models`,pe,s),p;t[1]===c?p=t[2]:(p=(c??[]).filter(ut).flatMap(lt),t[1]=c,t[2]=p);let m=p,h;t[3]===m?h=t[4]:(h=new Set(m.map(ct)),t[3]=m,t[4]=h);let g=h,_,v;t[5]!==g||t[6]!==c||t[7]!==r||t[8]!==n?(_=()=>{if(!c)return;let e=n.imageGenerationModel,t=g.has(e.primary)?e.primary:``,i=e.fallbacks.filter(e=>g.has(e));t===e.primary&&i.length===e.fallbacks.length||r({...n,imageGenerationModel:{...e,primary:t,fallbacks:i}})},v=[g,c,r,n],t[5]=g,t[6]=c,t[7]=r,t[8]=n,t[9]=_,t[10]=v):(_=t[9],v=t[10]),(0,X.useEffect)(_,v);let y;t[11]!==r||t[12]!==n?(y=(e,t)=>{r({...n,[e]:t})},t[11]=r,t[12]=n,t[13]=y):y=t[13];let b=y,x;t[14]===a.modelSpecializedTitle?x=t[15]:(x=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelSpecializedTitle}),t[14]=a.modelSpecializedTitle,t[15]=x);let S;t[16]!==a.modelNotSet||t[17]!==a.modelSpecializedSummary||t[18]!==n.imageGenerationModel.primary||t[19]!==n.imageModel.primary?(S=a.modelSpecializedSummary.replace(`{{image}}`,n.imageModel.primary||a.modelNotSet).replace(`{{generation}}`,n.imageGenerationModel.primary||a.modelNotSet),t[16]=a.modelNotSet,t[17]=a.modelSpecializedSummary,t[18]=n.imageGenerationModel.primary,t[19]=n.imageModel.primary,t[20]=S):S=t[20];let C;t[21]===S?C=t[22]:(C=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:S}),t[21]=S,t[22]=C);let w;t[23]!==x||t[24]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[x,C]}),t[23]=x,t[24]=C,t[25]=w):w=t[25];let T;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(M,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[26]=T):T=t[26];let E;t[27]===w?E=t[28]:(E=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[w,T]}),t[27]=w,t[28]=E);let D;t[29]===b?D=t[30]:(D=e=>b(`imageModel`,e),t[29]=b,t[30]=D);let O;t[31]!==o||t[32]!==a||t[33]!==i||t[34]!==D||t[35]!==n.imageModel?(O=(0,Z.jsx)(dt,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:D,disabled:i,cp:a,chat:o,capabilitiesFilter:`vision`}),t[31]=o,t[32]=a,t[33]=i,t[34]=D,t[35]=n.imageModel,t[36]=O):O=t[36];let k;t[37]===b?k=t[38]:(k=e=>b(`imageGenerationModel`,e),t[37]=b,t[38]=k);let A;t[39]===a.modelImageSettingsLink?A=t[40]:(A={label:a.modelImageSettingsLink,path:`/settings/capabilities/image`},t[39]=a.modelImageSettingsLink,t[40]=A);let j;t[41]!==o||t[42]!==a||t[43]!==i||t[44]!==m||t[45]!==f||t[46]!==l||t[47]!==k||t[48]!==A||t[49]!==n.imageGenerationModel?(j=(0,Z.jsx)(dt,{title:a.imageGenerationTitle,value:n.imageGenerationModel,onChange:k,disabled:i,cp:a,chat:o,models:m,modelsLoading:l,modelsError:f,noMatches:a.modelNoConfiguredImageModels,settingsFooterLink:A}),t[41]=o,t[42]=a,t[43]=i,t[44]=m,t[45]=f,t[46]=l,t[47]=k,t[48]=A,t[49]=n.imageGenerationModel,t[50]=j):j=t[50];let P;t[51]!==O||t[52]!==j?(P=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge lg:grid-cols-2`,children:[O,j]}),t[51]=O,t[52]=j,t[53]=P):P=t[53];let ee;t[54]!==E||t[55]!==P?(ee=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[E,P]}),t[54]=E,t[55]=P,t[56]=ee):ee=t[56];let F;t[57]===a.modelAdvancedTitle?F=t[58]:(F=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelAdvancedTitle}),t[57]=a.modelAdvancedTitle,t[58]=F);let I;t[59]===a.modelAdvancedHint?I=t[60]:(I=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:a.modelAdvancedHint}),t[59]=a.modelAdvancedHint,t[60]=I);let L;t[61]!==F||t[62]!==I?(L=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[F,I]}),t[61]=F,t[62]=I,t[63]=L):L=t[63];let R;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Z.jsx)(M,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[64]=R):R=t[64];let z;t[65]===L?z=t[66]:(z=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[L,R]}),t[65]=L,t[66]=z);let B;t[67]===a.modelAllowFallbacksLabel?B=t[68]:(B=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelAllowFallbacksLabel}),t[67]=a.modelAllowFallbacksLabel,t[68]=B);let V;t[69]!==r||t[70]!==n?(V=e=>r({...n,allowFallbacks:e.target.value}),t[69]=r,t[70]=n,t[71]=V):V=t[71];let H;t[72]===a.policyInherit?H=t[73]:(H=(0,Z.jsx)(N,{value:``,children:a.policyInherit}),t[72]=a.policyInherit,t[73]=H);let U;t[74]===a.policyEnabled?U=t[75]:(U=(0,Z.jsx)(N,{value:`true`,children:a.policyEnabled}),t[74]=a.policyEnabled,t[75]=U);let W;t[76]===a.policyDisabled?W=t[77]:(W=(0,Z.jsx)(N,{value:`false`,children:a.policyDisabled}),t[76]=a.policyDisabled,t[77]=W);let te;t[78]!==i||t[79]!==V||t[80]!==H||t[81]!==U||t[82]!==W||t[83]!==n.allowFallbacks?(te=(0,Z.jsxs)(d,{value:n.allowFallbacks,disabled:i,side:`top`,onChange:V,children:[H,U,W]}),t[78]=i,t[79]=V,t[80]=H,t[81]=U,t[82]=W,t[83]=n.allowFallbacks,t[84]=te):te=t[84];let ne;t[85]!==B||t[86]!==te?(ne=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[B,te]}),t[85]=B,t[86]=te,t[87]=ne):ne=t[87];let re;t[88]===a.modelMaxCostTierLabel?re=t[89]:(re=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[88]=a.modelMaxCostTierLabel,t[89]=re);let G;t[90]!==r||t[91]!==n?(G=e=>r({...n,maxCostTier:e.target.value}),t[90]=r,t[91]=n,t[92]=G):G=t[92];let K;t[93]===a.policyInherit?K=t[94]:(K=(0,Z.jsx)(N,{value:``,children:a.policyInherit}),t[93]=a.policyInherit,t[94]=K);let ie;t[95]===a.costTierLow?ie=t[96]:(ie=(0,Z.jsx)(N,{value:`low`,children:a.costTierLow}),t[95]=a.costTierLow,t[96]=ie);let ae;t[97]===a.costTierMedium?ae=t[98]:(ae=(0,Z.jsx)(N,{value:`medium`,children:a.costTierMedium}),t[97]=a.costTierMedium,t[98]=ae);let oe;t[99]===a.costTierHigh?oe=t[100]:(oe=(0,Z.jsx)(N,{value:`high`,children:a.costTierHigh}),t[99]=a.costTierHigh,t[100]=oe);let se;t[101]!==i||t[102]!==G||t[103]!==K||t[104]!==ie||t[105]!==ae||t[106]!==oe||t[107]!==n.maxCostTier?(se=(0,Z.jsxs)(d,{value:n.maxCostTier,disabled:i,side:`top`,onChange:G,children:[K,ie,ae,oe]}),t[101]=i,t[102]=G,t[103]=K,t[104]=ie,t[105]=ae,t[106]=oe,t[107]=n.maxCostTier,t[108]=se):se=t[108];let ce;t[109]!==re||t[110]!==se?(ce=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[re,se]}),t[109]=re,t[110]=se,t[111]=ce):ce=t[111];let le;t[112]!==ne||t[113]!==ce?(le=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge sm:grid-cols-2`,children:[ne,ce]}),t[112]=ne,t[113]=ce,t[114]=le):le=t[114];let ue;t[115]!==z||t[116]!==le?(ue=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[z,le]}),t[115]=z,t[116]=le,t[117]=ue):ue=t[117];let de;return t[118]!==ee||t[119]!==ue?(de=(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-3 border-t border-edge-subtle pt-5 dark:border-edge`,children:[ee,ue]}),t[118]=ee,t[119]=ue,t[120]=de):de=t[120],de}function ct(e){return e.id}function lt(e){return e.models.map(t=>({id:`${e.id}/${t}`,name:t,provider:e.label}))}function ut(e){return e.configured||e.credentialMode===`none`}function dt(e){let t=(0,me.c)(109),{title:n,value:r,onChange:i,disabled:a,cp:o,chat:s,capabilitiesFilter:c,models:l,modelsLoading:u,modelsError:f,noMatches:p,settingsFooterLink:h}=e,g;t[0]!==i||t[1]!==r?(g=(e,t)=>{i({...r,fallbacks:r.fallbacks.map((n,r)=>r===e?t:n)})},t[0]=i,t[1]=r,t[2]=g):g=t[2];let v=g,y;t[3]===n?y=t[4]:(y=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n}),t[3]=n,t[4]=y);let b=r.primary||o.modelNotSet,x;t[5]===b?x=t[6]:(x=(0,Z.jsx)(`span`,{className:`max-w-48 truncate font-mono text-xs text-fg-muted`,children:b}),t[5]=b,t[6]=x);let S;t[7]!==y||t[8]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2.5`,children:[y,x]}),t[7]=y,t[8]=x,t[9]=S):S=t[9];let C;t[10]===o.modelToolPrimaryLabel?C=t[11]:(C=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolPrimaryLabel}),t[10]=o.modelToolPrimaryLabel,t[11]=C);let T=p??s.modelNoMatches,E;t[12]!==i||t[13]!==r?(E=e=>i({...r,primary:e}),t[12]=i,t[13]=r,t[14]=E):E=t[14];let D;t[15]!==c||t[16]!==s.modelPlaceholder||t[17]!==s.modelSearchPlaceholder||t[18]!==a||t[19]!==l||t[20]!==f||t[21]!==u||t[22]!==h||t[23]!==T||t[24]!==E||t[25]!==r.primary?(D=(0,Z.jsx)(w,{value:r.primary,disabled:a,placeholder:s.modelPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:T,models:l,modelsLoading:u,modelsError:f,settingsFooterLink:h,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:E}),t[15]=c,t[16]=s.modelPlaceholder,t[17]=s.modelSearchPlaceholder,t[18]=a,t[19]=l,t[20]=f,t[21]=u,t[22]=h,t[23]=T,t[24]=E,t[25]=r.primary,t[26]=D):D=t[26];let k;t[27]!==o.modelClearSelection||t[28]!==a||t[29]!==i||t[30]!==r?(k=r.primary?(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:a,"aria-label":o.modelClearSelection,onClick:()=>i({...r,primary:``}),children:(0,Z.jsx)(ee,{className:`size-4`,strokeWidth:1.75})}):null,t[27]=o.modelClearSelection,t[28]=a,t[29]=i,t[30]=r,t[31]=k):k=t[31];let A;t[32]!==D||t[33]!==k?(A=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[D,k]}),t[32]=D,t[33]=k,t[34]=A):A=t[34];let j;t[35]!==A||t[36]!==C?(j=(0,Z.jsxs)(`div`,{className:`grid gap-1`,children:[C,A]}),t[35]=A,t[36]=C,t[37]=j):j=t[37];let M;t[38]===o.modelToolFallbacksLabel?M=t[39]:(M=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolFallbacksLabel}),t[38]=o.modelToolFallbacksLabel,t[39]=M);let P;t[40]!==i||t[41]!==r?(P=()=>i({...r,fallbacks:[...r.fallbacks,``]}),t[40]=i,t[41]=r,t[42]=P):P=t[42];let F;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(m,{className:`size-3.5`,strokeWidth:1.75}),t[43]=F):F=t[43];let I;t[44]!==o.modelAddFallback||t[45]!==a||t[46]!==P?(I=(0,Z.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:a,onClick:P,children:[F,o.modelAddFallback]}),t[44]=o.modelAddFallback,t[45]=a,t[46]=P,t[47]=I):I=t[47];let L;t[48]!==M||t[49]!==I?(L=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[M,I]}),t[48]=M,t[49]=I,t[50]=L):L=t[50];let R;t[51]!==c||t[52]!==s.modelNoMatches||t[53]!==s.modelSearchPlaceholder||t[54]!==o.modelFallbackEmptyHint||t[55]!==o.modelFallbackPlaceholder||t[56]!==o.modelRemoveFallback||t[57]!==a||t[58]!==l||t[59]!==f||t[60]!==u||t[61]!==p||t[62]!==i||t[63]!==h||t[64]!==v||t[65]!==r?(R=r.fallbacks.length>0?(0,Z.jsx)(`div`,{className:`grid gap-1.5`,children:r.fallbacks.map((e,t)=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,Z.jsx)(w,{value:e,disabled:a,placeholder:o.modelFallbackPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:p??s.modelNoMatches,models:l,modelsLoading:u,modelsError:f,settingsFooterLink:h,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>v(t,e)}),(0,Z.jsx)(_,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:a,"aria-label":o.modelRemoveFallback,onClick:()=>i({...r,fallbacks:r.fallbacks.filter((e,n)=>n!==t)}),children:(0,Z.jsx)(O,{className:`size-4`,strokeWidth:1.75})})]},`fallback-${t}`))}):(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 text-xs text-fg-muted`,children:o.modelFallbackEmptyHint}),t[51]=c,t[52]=s.modelNoMatches,t[53]=s.modelSearchPlaceholder,t[54]=o.modelFallbackEmptyHint,t[55]=o.modelFallbackPlaceholder,t[56]=o.modelRemoveFallback,t[57]=a,t[58]=l,t[59]=f,t[60]=u,t[61]=p,t[62]=i,t[63]=h,t[64]=v,t[65]=r,t[66]=R):R=t[66];let z;t[67]!==L||t[68]!==R?(z=(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[L,R]}),t[67]=L,t[68]=R,t[69]=z):z=t[69];let B;t[70]!==i||t[71]!==r?(B=e=>i({...r,timeoutMs:e.target.value}),t[70]=i,t[71]=r,t[72]=B):B=t[72];let V;t[73]!==a||t[74]!==B||t[75]!==r.timeoutMs?(V=(0,Z.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:r.timeoutMs,disabled:a,onChange:B}),t[73]=a,t[74]=B,t[75]=r.timeoutMs,t[76]=V):V=t[76];let H;t[77]!==o.toolTimeoutLabel||t[78]!==V?(H=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.toolTimeoutLabel,V]}),t[77]=o.toolTimeoutLabel,t[78]=V,t[79]=H):H=t[79];let U;t[80]!==i||t[81]!==r?(U=e=>i({...r,autoProviderFallback:e.target.value}),t[80]=i,t[81]=r,t[82]=U):U=t[82];let W;t[83]===o.policyInherit?W=t[84]:(W=(0,Z.jsx)(N,{value:``,children:o.policyInherit}),t[83]=o.policyInherit,t[84]=W);let te;t[85]===o.policyEnabled?te=t[86]:(te=(0,Z.jsx)(N,{value:`true`,children:o.policyEnabled}),t[85]=o.policyEnabled,t[86]=te);let ne;t[87]===o.policyDisabled?ne=t[88]:(ne=(0,Z.jsx)(N,{value:`false`,children:o.policyDisabled}),t[87]=o.policyDisabled,t[88]=ne);let re;t[89]!==a||t[90]!==U||t[91]!==W||t[92]!==te||t[93]!==ne||t[94]!==r.autoProviderFallback?(re=(0,Z.jsxs)(d,{value:r.autoProviderFallback,disabled:a,side:`top`,onChange:U,children:[W,te,ne]}),t[89]=a,t[90]=U,t[91]=W,t[92]=te,t[93]=ne,t[94]=r.autoProviderFallback,t[95]=re):re=t[95];let G;t[96]!==o.modelAutoProviderFallbackLabel||t[97]!==re?(G=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.modelAutoProviderFallbackLabel,re]}),t[96]=o.modelAutoProviderFallbackLabel,t[97]=re,t[98]=G):G=t[98];let K;t[99]!==H||t[100]!==G?(K=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[H,G]}),t[99]=H,t[100]=G,t[101]=K):K=t[101];let ie;t[102]!==j||t[103]!==z||t[104]!==K?(ie=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-3 dark:border-edge`,children:[j,z,K]}),t[102]=j,t[103]=z,t[104]=K,t[105]=ie):ie=t[105];let ae;return t[106]!==ie||t[107]!==S?(ae=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 shadow-surface`,children:[S,ie]}),t[106]=ie,t[107]=S,t[108]=ae):ae=t[108],ae}export{at as CapabilityPresetsSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,s as t}from"./locale-store-
|
|
1
|
+
import{r as e,s as t}from"./locale-store-D6hs74o5.js";function n(e,t){let n=Date.now()-new Date(e).getTime();return n<6e4?t.justNow:n<36e5?t.minutesAgo.replace(`{{count}}`,String(Math.floor(n/6e4))):n<864e5?t.hoursAgo.replace(`{{count}}`,String(Math.floor(n/36e5))):n<6048e5?t.daysAgo.replace(`{{count}}`,String(Math.floor(n/864e5))):new Date(e).toLocaleDateString()}function r(e,t){let r=n(e.lastActive,t);return e.channel===`telegram`&&e.peerId?`${e.accountId??`default`} · ${e.peerKind??``} · ${e.peerId} · ${r}`:`${e.channel}: ${e.chatId} · ${r}`}async function i(){return(await t(e(`/api/channels/status`))).payload?.channels||[]}async function a(n){return(await t(e(`/api/sessions/chat-ids${n?`?channel=${encodeURIComponent(n)}`:``}`))).payload?.chatIds||[]}export{i as n,a as r,r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-CPxz48hr.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-Bff30u5V.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Bo as m,Es as h,Fl as g,Ho as _,Hs as v,Io as y,Lo as b,Qa as x,Qo as S,Ro as C,Rr as w,Vo as T,Zs as E,ai as D,as as O,ca as k,cu as A,do as j,dt as M,hc as N,ii as P,ks as F,lc as I,no as L,os as ee,ou as R,qc as z,ri as te,to as B,ts as ne,yc as re,ys as ie,zo as ae}from"./index-vi5KlR5_.js";import{n as oe,r as se}from"./settings-page-layout-DfFfkdED.js";import{n as ce}from"./settings-loading-skeleton-DZFhxihA.js";import{t as le}from"./schema-form-NqOm-OG1.js";import{t as ue}from"./browser-BLJWD7WI.js";import{n as de,t as fe}from"./channels-status-swr-CySs1GQX.js";var V=e(t(),1),H=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ue(),1),U=r();async function he(e){let t=await u(d(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>pe(e),[e]),s=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,V.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,V.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=a?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,p=G(c.payload),m=K(c.payload,e.id),_=m?c.generatedQr:q(c.payload),v=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),y=c.payload?.type===`form`?c.payload:null,b=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:o(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(h,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,U.jsx)(z,{className:`size-4 animate-spin`}):(0,U.jsx)(re,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(h,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,U.jsx)(E,{className:`size-4`}),f]}):null]})]}),p?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,v?(0,U.jsxs)(`div`,{className:o(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,U.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(B,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:o(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[_?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(B,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(B,{className:`h-4 w-36 max-w-full`})]}),m?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:m,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(g,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(R,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,y?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(le,{schema:y.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:s}),(0,U.jsx)(h,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(y.submitAction,c.formDraft),children:n.saveSetup})]}):null,b?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?o(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,O):o(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,O,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:g}=e,v=p===void 0?!1:p,x=n===`drawer`,[S,w]=(0,V.useState)(null),E;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,U.jsx)(m,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),t[0]=E):E=t[0];let D;t[1]!==n||t[2]!==v?(D=Se(n,v),t[1]=n,t[2]=v,t[3]=D):D=t[3];let O;t[4]===c?O=t[5]:(O=c?(0,U.jsx)(_,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=O);let k;t[6]===l?k=t[7]:(k=l?(0,U.jsx)(ae,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=k);let A;t[8]!==u||t[9]!==s||t[10]!==g||t[11]!==x||t[12]!==a?(A=x?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(b,{asChild:!0,children:(0,U.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(F,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(b,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:o(ie,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(F,{className:`size-4`})})}),g]}),t[8]=u,t[9]=s,t[10]=g,t[11]=x,t[12]=a,t[13]=A):A=t[13];let j=x?`p-4`:`p-6`,M;t[14]===j?M=t[15]:(M=o(`min-h-0 flex-1 overflow-y-auto`,j),t[14]=j,t[15]=M);let N;t[16]!==d||t[17]!==M?(N=(0,U.jsx)(`div`,{className:M,children:d}),t[16]=d,t[17]=M,t[18]=N):N=t[18];let P;t[19]!==f||t[20]!==S||t[21]!==O||t[22]!==k||t[23]!==A||t[24]!==N?(P=(0,U.jsxs)(ne,{layer:`modal`,portalContainer:S,children:[O,k,A,N,f]}),t[19]=f,t[20]=S,t[21]=O,t[22]=k,t[23]=A,t[24]=N,t[25]=P):P=t[25];let I;t[26]!==P||t[27]!==D?(I=(0,U.jsxs)(T,{children:[E,(0,U.jsx)(C,{ref:w,className:D,onOpenAutoFocus:we,children:P})]}),t[26]=P,t[27]=D,t[28]=I):I=t[28];let L;return t[29]!==i||t[30]!==r||t[31]!==I?(L=(0,U.jsx)(y,{open:r,onOpenChange:i,children:I}),t[29]=i,t[30]=r,t[31]=I,t[32]=L):L=t[32],L}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(k,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(h,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(h,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,g;t[11]===s?g=t[12]:(g=()=>void s(),t[11]=s,t[12]=g);let _=i?n.saving:n.save,v;t[13]!==m||t[14]!==g||t[15]!==_?(v=(0,U.jsx)(h,{type:`button`,variant:`primary`,disabled:m,onClick:g,children:_}),t[13]=m,t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==d||t[18]!==p||t[19]!==v?(y=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,v]}),t[17]=d,t[18]=p,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==y||t[22]!==u?(b=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,y]}),t[21]=y,t[22]=u,t[23]=b):b=t[23],b}function De(e){return d(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await f(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=p(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?d(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await f(d(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await f(d(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ue(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Q(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function et(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let t=c(e=>e.token),[n,r]=(0,V.useState)(!1),i=(0,V.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(d(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(L,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,s;t[0]===i?s=t[1]:(s=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=s);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=o(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=o(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:s,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=s,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:s,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,g,_,v,y,b,x;if(t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Xe(n,r,c),s=$e(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,b=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let h;t[21]===n.label?h=t[22]:(h=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=h);let S;t[23]===i?S=t[24]:(S=o(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Be(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==h?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[h,w]}),t[31]=w,t[32]=h,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(x=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=x):x=t[47],g=`button`,_=l,v=`mt-5 min-h-[6.25rem] text-left`,y=p.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,c)}),s.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:s.map(it)}):null]}),t[2]=a,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x}else m=t[12],g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18];let S;t[48]!==g||t[49]!==_||t[50]!==v||t[51]!==y?(S=(0,U.jsx)(`button`,{type:g,onClick:_,className:v,children:y}),t[48]=g,t[49]=_,t[50]=v,t[51]=y,t[52]=S):S=t[52];let C=a||s,w;t[53]!==a||t[54]!==s?(w=a||s?(0,U.jsx)(z,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=s,t[55]=w):w=t[55];let T;t[56]!==c||t[57]!==n||t[58]!==s||t[59]!==i?(T=s?c.restartingChannel:i===`stopped`?c.restartChannel:Ze(n,c),t[56]=c,t[57]=n,t[58]=s,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==w||t[63]!==T||t[64]!==C?(E=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(h,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:C,children:[w,T]})}),t[61]=m,t[62]=w,t[63]=T,t[64]=C,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==b||t[68]!==x||t[69]!==S?(D=(0,U.jsxs)(`article`,{className:b,children:[x,S,E]}),t[66]=E,t[67]=b,t[68]=x,t[69]=S,t[70]=D):D=t[70],D}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:s,ch:c,onRestart:l,onCheck:u,onManageConnection:d}=e,f=n===`running`?R:n===`stopped`||n===`needs_setup`?A:z,p=n===`running`&&`text-emerald-600 dark:text-emerald-400`,m=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==p||t[1]!==m||t[2]!==g||t[3]!==_||t[4]!==v?(y=o(`mt-0.5 size-5 shrink-0`,p,m,g,_,v),t[0]=p,t[1]=m,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==f||t[7]!==y?(b=(0,U.jsx)(f,{className:y}),t[6]=f,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=Ve(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let w;t[16]!==C||t[17]!==x?(w=(0,U.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=w):w=t[18];let T;t[19]!==w||t[20]!==b?(T=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[19]=w,t[20]=b,t[21]=T):T=t[21];let E=i||r,D;t[22]===i?D=t[23]:(D=i?(0,U.jsx)(z,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=D);let O=i?c.checkingConnection:c.checkConnection,k;t[24]!==u||t[25]!==E||t[26]!==D||t[27]!==O?(k=(0,U.jsxs)(h,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:E,onClick:u,children:[D,O]}),t[24]=u,t[25]=E,t[26]=D,t[27]=O,t[28]=k):k=t[28];let j;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==l||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,U.jsxs)(h,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:l,children:[r?(0,U.jsx)(z,{className:`size-4 animate-spin`}):(0,U.jsx)(N,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=l,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==d||t[41]!==r||t[42]!==a?(M=s?(0,U.jsx)(h,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:d,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=d,t[41]=r,t[42]=a,t[43]=M):M=t[43];let P;t[44]!==k||t[45]!==j||t[46]!==M?(P=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[k,j,M]}),t[44]=k,t[45]=j,t[46]=M,t[47]=P):P=t[47];let F;return t[48]!==T||t[49]!==P?(F=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[T,P]})}),t[48]=T,t[49]=P,t[50]=F):F=t[50],F}function ot(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(v,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:et(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=l(e=>e.language),t=s(e),n=c(e=>!!e.token),r=a(),{channelId:f}=i(),m=D(f),h=ke(n,e),_=h.entries,{data:v,mutate:y,isValidating:b}=p(n?fe():null,de,{revalidateOnFocus:!0}),{data:C,mutate:T}=p(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),E=C?.channels??{},O=C?.bindings??[],{data:k}=p(n?`channel-routing-agents`:null,x,{revalidateOnFocus:!1}),A=j(e=>e.setPageHeader),N=j(e=>e.clearPageHeader),F=(0,V.useMemo)(()=>_.find(e=>e.id===m),[m,_]),L=F?ze(F):null,{data:ee,mutate:R}=p(n&&L?Pe(L):null,()=>Fe(L)),[z,B]=(0,V.useState)(null),[ne,re]=(0,V.useState)(!1),[ie,ae]=(0,V.useState)(null),[ue,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=z??ee??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>F?.configSchema??{type:`object`,properties:{}},[F?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(F),[F]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=F?K??ve(O,F.id):``,Re=(0,V.useMemo)(()=>(k?.items??[]).map(e=>{let n=w(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[k?.items,t.agentsSettings]),Ve=k?.items.find(e=>e.id===k.defaultId),X=Ve?w(Ve,t.agentsSettings):k?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((v??[]).map(e=>[e.name,e])),[v]),Je=v!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([h.mutate(),y()])},[h,y]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&y(t,!1)},[y]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:h.isValidating||b,saveOk:!1,onRefresh:()=>void Q()}):null,[h.isValidating,J,n,b,Q]);(0,V.useLayoutEffect)(()=>(A({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>N()),[N,Xe,t.settingsSections.channels,A]);let Ze=(0,V.useCallback)(e=>{r(P(e)),B(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(te),B(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await u(d(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),he(!1)},[F?.id]);let et=(0,V.useCallback)(async()=>{if(!F||!z&&K===null)return!1;let e=ze(F);re(!0),G(null);try{let t=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({...z?{channels:{[e]:z}}:{},...K===null?{}:{bindings:ye(O,F.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return z&&await R(z,!1),await T(),await h.mutate(),B(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{re(!1)}},[F,K,O,h,z,T,R]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=F?.id===e.id?z:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ae(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await h.mutate(),await T(),await y(),F?.id===e.id&&(await R(),B(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(null)}},[F?.id,h,z,T,R,y,Ze]),$=F?.ui?.modal,st=$?.placement!==`replace-config`,ct=F?Ye(F):`checking`,lt=F?!Y(F).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,children:[h.isLoading?(0,U.jsx)(ce,{sections:2}):h.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(h.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:_.map(e=>(0,U.jsx)(rt,{entry:e,config:E[ze(e)]?.config,runtime:Ye(e),busy:ie===e.id,restarting:ue===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!F,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:F?.label??J.selectChannel,srDescription:F?.description,wide:!0,footer:F?(0,U.jsx)(Ee,{ch:J,dirty:!!z||K!==null,saving:ne,onCancel:Qe,onDiscard:()=>{B(null),q(null)},onSave:et}):null,children:F?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(tt,{entry:F}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:F.label}),(0,U.jsx)(`span`,{className:o(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(F).ready&&pe(F)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,F.label):F.description}),F.docsPath?(0,U.jsxs)(`a`,{href:F.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(g,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(F).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(nt,{checked:Y(F).enabled,disabled:ie===F.id,label:J.toggleChannel.replace(`{{channel}}`,F.label),onToggle:()=>void it(F)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ue===F.id,checking:b,showConnectionOptions:me,canManageConnection:Y(F).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(F),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:F,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:F,locale:e,messages:J,compact:!0,onChanged:async()=>{await R(),await Q(),await T()}},F.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(M,{extensionId:F.extensionId,extensionName:F.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:F.id,entry:F,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(M,{extensionId:F.extensionId,extensionName:F.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:F.id,entry:F,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(le,{schema:De,values:_e,onChange:e=>B(e),disabled:ne,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(I,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(S,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:ne||!k,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(I,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(le,{schema:Oe,values:_e,onChange:e=>B(e),disabled:ne,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
|
|
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,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-D02NNLCZ.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-D6hs74o5.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Bo as m,Es as h,Fl as g,Ho as _,Hs as v,Io as y,Lo as b,Qa as x,Qo as S,Ro as C,Rr as w,Vo as T,Zs as E,ai as D,as as O,ca as k,cu as A,do as j,dt as M,hc as N,ii as P,ks as F,lc as I,no as L,os as ee,ou as R,qc as z,ri as te,to as B,ts as ne,yc as re,ys as ie,zo as ae}from"./index-OJgiMh07.js";import{n as oe,r as se}from"./settings-page-layout-97LmwrzC.js";import{n as ce}from"./settings-loading-skeleton-DgIp8_S6.js";import{t as le}from"./schema-form-BDKbpmXv.js";import{t as ue}from"./browser-BLJWD7WI.js";import{n as de,t as fe}from"./channels-status-swr-DFmdYRE5.js";var V=e(t(),1),H=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ue(),1),U=r();async function he(e){let t=await u(d(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>pe(e),[e]),s=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,V.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,V.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=a?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,p=G(c.payload),m=K(c.payload,e.id),_=m?c.generatedQr:q(c.payload),v=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),y=c.payload?.type===`form`?c.payload:null,b=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:o(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(h,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,U.jsx)(z,{className:`size-4 animate-spin`}):(0,U.jsx)(re,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(h,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,U.jsx)(E,{className:`size-4`}),f]}):null]})]}),p?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,v?(0,U.jsxs)(`div`,{className:o(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,U.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(B,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:o(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[_?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(B,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(B,{className:`h-4 w-36 max-w-full`})]}),m?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:m,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(g,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(R,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,y?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(le,{schema:y.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:s}),(0,U.jsx)(h,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(y.submitAction,c.formDraft),children:n.saveSetup})]}):null,b?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?o(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,O):o(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,O,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:g}=e,v=p===void 0?!1:p,x=n===`drawer`,[S,w]=(0,V.useState)(null),E;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,U.jsx)(m,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),t[0]=E):E=t[0];let D;t[1]!==n||t[2]!==v?(D=Se(n,v),t[1]=n,t[2]=v,t[3]=D):D=t[3];let O;t[4]===c?O=t[5]:(O=c?(0,U.jsx)(_,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=O);let k;t[6]===l?k=t[7]:(k=l?(0,U.jsx)(ae,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=k);let A;t[8]!==u||t[9]!==s||t[10]!==g||t[11]!==x||t[12]!==a?(A=x?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(b,{asChild:!0,children:(0,U.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(F,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(b,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:o(ie,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(F,{className:`size-4`})})}),g]}),t[8]=u,t[9]=s,t[10]=g,t[11]=x,t[12]=a,t[13]=A):A=t[13];let j=x?`p-4`:`p-6`,M;t[14]===j?M=t[15]:(M=o(`min-h-0 flex-1 overflow-y-auto`,j),t[14]=j,t[15]=M);let N;t[16]!==d||t[17]!==M?(N=(0,U.jsx)(`div`,{className:M,children:d}),t[16]=d,t[17]=M,t[18]=N):N=t[18];let P;t[19]!==f||t[20]!==S||t[21]!==O||t[22]!==k||t[23]!==A||t[24]!==N?(P=(0,U.jsxs)(ne,{layer:`modal`,portalContainer:S,children:[O,k,A,N,f]}),t[19]=f,t[20]=S,t[21]=O,t[22]=k,t[23]=A,t[24]=N,t[25]=P):P=t[25];let I;t[26]!==P||t[27]!==D?(I=(0,U.jsxs)(T,{children:[E,(0,U.jsx)(C,{ref:w,className:D,onOpenAutoFocus:we,children:P})]}),t[26]=P,t[27]=D,t[28]=I):I=t[28];let L;return t[29]!==i||t[30]!==r||t[31]!==I?(L=(0,U.jsx)(y,{open:r,onOpenChange:i,children:I}),t[29]=i,t[30]=r,t[31]=I,t[32]=L):L=t[32],L}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(k,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(h,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(h,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,g;t[11]===s?g=t[12]:(g=()=>void s(),t[11]=s,t[12]=g);let _=i?n.saving:n.save,v;t[13]!==m||t[14]!==g||t[15]!==_?(v=(0,U.jsx)(h,{type:`button`,variant:`primary`,disabled:m,onClick:g,children:_}),t[13]=m,t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==d||t[18]!==p||t[19]!==v?(y=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,v]}),t[17]=d,t[18]=p,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==y||t[22]!==u?(b=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,y]}),t[21]=y,t[22]=u,t[23]=b):b=t[23],b}function De(e){return d(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await f(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=p(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?d(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await f(d(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await f(d(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ue(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Q(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function et(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let t=c(e=>e.token),[n,r]=(0,V.useState)(!1),i=(0,V.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(d(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(L,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,s;t[0]===i?s=t[1]:(s=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=s);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=o(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=o(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:s,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=s,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:s,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,g,_,v,y,b,x;if(t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Xe(n,r,c),s=$e(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,b=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let h;t[21]===n.label?h=t[22]:(h=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=h);let S;t[23]===i?S=t[24]:(S=o(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Be(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==h?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[h,w]}),t[31]=w,t[32]=h,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(x=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=x):x=t[47],g=`button`,_=l,v=`mt-5 min-h-[6.25rem] text-left`,y=p.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,c)}),s.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:s.map(it)}):null]}),t[2]=a,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x}else m=t[12],g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18];let S;t[48]!==g||t[49]!==_||t[50]!==v||t[51]!==y?(S=(0,U.jsx)(`button`,{type:g,onClick:_,className:v,children:y}),t[48]=g,t[49]=_,t[50]=v,t[51]=y,t[52]=S):S=t[52];let C=a||s,w;t[53]!==a||t[54]!==s?(w=a||s?(0,U.jsx)(z,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=s,t[55]=w):w=t[55];let T;t[56]!==c||t[57]!==n||t[58]!==s||t[59]!==i?(T=s?c.restartingChannel:i===`stopped`?c.restartChannel:Ze(n,c),t[56]=c,t[57]=n,t[58]=s,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==w||t[63]!==T||t[64]!==C?(E=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(h,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:C,children:[w,T]})}),t[61]=m,t[62]=w,t[63]=T,t[64]=C,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==b||t[68]!==x||t[69]!==S?(D=(0,U.jsxs)(`article`,{className:b,children:[x,S,E]}),t[66]=E,t[67]=b,t[68]=x,t[69]=S,t[70]=D):D=t[70],D}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:s,ch:c,onRestart:l,onCheck:u,onManageConnection:d}=e,f=n===`running`?R:n===`stopped`||n===`needs_setup`?A:z,p=n===`running`&&`text-emerald-600 dark:text-emerald-400`,m=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==p||t[1]!==m||t[2]!==g||t[3]!==_||t[4]!==v?(y=o(`mt-0.5 size-5 shrink-0`,p,m,g,_,v),t[0]=p,t[1]=m,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==f||t[7]!==y?(b=(0,U.jsx)(f,{className:y}),t[6]=f,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=Ve(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let w;t[16]!==C||t[17]!==x?(w=(0,U.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=w):w=t[18];let T;t[19]!==w||t[20]!==b?(T=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[19]=w,t[20]=b,t[21]=T):T=t[21];let E=i||r,D;t[22]===i?D=t[23]:(D=i?(0,U.jsx)(z,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=D);let O=i?c.checkingConnection:c.checkConnection,k;t[24]!==u||t[25]!==E||t[26]!==D||t[27]!==O?(k=(0,U.jsxs)(h,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:E,onClick:u,children:[D,O]}),t[24]=u,t[25]=E,t[26]=D,t[27]=O,t[28]=k):k=t[28];let j;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==l||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,U.jsxs)(h,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:l,children:[r?(0,U.jsx)(z,{className:`size-4 animate-spin`}):(0,U.jsx)(N,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=l,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==d||t[41]!==r||t[42]!==a?(M=s?(0,U.jsx)(h,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:d,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=d,t[41]=r,t[42]=a,t[43]=M):M=t[43];let P;t[44]!==k||t[45]!==j||t[46]!==M?(P=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[k,j,M]}),t[44]=k,t[45]=j,t[46]=M,t[47]=P):P=t[47];let F;return t[48]!==T||t[49]!==P?(F=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[T,P]})}),t[48]=T,t[49]=P,t[50]=F):F=t[50],F}function ot(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(v,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:et(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=l(e=>e.language),t=s(e),n=c(e=>!!e.token),r=a(),{channelId:f}=i(),m=D(f),h=ke(n,e),_=h.entries,{data:v,mutate:y,isValidating:b}=p(n?fe():null,de,{revalidateOnFocus:!0}),{data:C,mutate:T}=p(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),E=C?.channels??{},O=C?.bindings??[],{data:k}=p(n?`channel-routing-agents`:null,x,{revalidateOnFocus:!1}),A=j(e=>e.setPageHeader),N=j(e=>e.clearPageHeader),F=(0,V.useMemo)(()=>_.find(e=>e.id===m),[m,_]),L=F?ze(F):null,{data:ee,mutate:R}=p(n&&L?Pe(L):null,()=>Fe(L)),[z,B]=(0,V.useState)(null),[ne,re]=(0,V.useState)(!1),[ie,ae]=(0,V.useState)(null),[ue,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=z??ee??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>F?.configSchema??{type:`object`,properties:{}},[F?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(F),[F]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=F?K??ve(O,F.id):``,Re=(0,V.useMemo)(()=>(k?.items??[]).map(e=>{let n=w(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[k?.items,t.agentsSettings]),Ve=k?.items.find(e=>e.id===k.defaultId),X=Ve?w(Ve,t.agentsSettings):k?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((v??[]).map(e=>[e.name,e])),[v]),Je=v!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([h.mutate(),y()])},[h,y]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&y(t,!1)},[y]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:h.isValidating||b,saveOk:!1,onRefresh:()=>void Q()}):null,[h.isValidating,J,n,b,Q]);(0,V.useLayoutEffect)(()=>(A({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>N()),[N,Xe,t.settingsSections.channels,A]);let Ze=(0,V.useCallback)(e=>{r(P(e)),B(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(te),B(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await u(d(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),he(!1)},[F?.id]);let et=(0,V.useCallback)(async()=>{if(!F||!z&&K===null)return!1;let e=ze(F);re(!0),G(null);try{let t=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({...z?{channels:{[e]:z}}:{},...K===null?{}:{bindings:ye(O,F.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return z&&await R(z,!1),await T(),await h.mutate(),B(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{re(!1)}},[F,K,O,h,z,T,R]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=F?.id===e.id?z:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ae(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await h.mutate(),await T(),await y(),F?.id===e.id&&(await R(),B(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(null)}},[F?.id,h,z,T,R,y,Ze]),$=F?.ui?.modal,st=$?.placement!==`replace-config`,ct=F?Ye(F):`checking`,lt=F?!Y(F).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,children:[h.isLoading?(0,U.jsx)(ce,{sections:2}):h.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(h.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:_.map(e=>(0,U.jsx)(rt,{entry:e,config:E[ze(e)]?.config,runtime:Ye(e),busy:ie===e.id,restarting:ue===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!F,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:F?.label??J.selectChannel,srDescription:F?.description,wide:!0,footer:F?(0,U.jsx)(Ee,{ch:J,dirty:!!z||K!==null,saving:ne,onCancel:Qe,onDiscard:()=>{B(null),q(null)},onSave:et}):null,children:F?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(tt,{entry:F}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:F.label}),(0,U.jsx)(`span`,{className:o(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(F).ready&&pe(F)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,F.label):F.description}),F.docsPath?(0,U.jsxs)(`a`,{href:F.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(g,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(F).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(nt,{checked:Y(F).enabled,disabled:ie===F.id,label:J.toggleChannel.replace(`{{channel}}`,F.label),onToggle:()=>void it(F)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ue===F.id,checking:b,showConnectionOptions:me,canManageConnection:Y(F).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(F),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:F,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:F,locale:e,messages:J,compact:!0,onChanged:async()=>{await R(),await Q(),await T()}},F.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(M,{extensionId:F.extensionId,extensionName:F.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:F.id,entry:F,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(M,{extensionId:F.extensionId,extensionName:F.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:F.id,entry:F,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(le,{schema:De,values:_e,onChange:e=>B(e),disabled:ne,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(I,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(S,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:ne||!k,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(I,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(le,{schema:Oe,values:_e,onChange:e=>B(e),disabled:ne,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./locale-store-D6hs74o5.js";import{n as t}from"./channel-recipient-api-BgIkWq01.js";function n(){return e(`/api/channels/status`)}var r=t;export{r as n,n as t};
|