@xopcai/xopc 0.0.123 → 0.0.124
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/README.md +28 -11
- package/README.zh-CN.md +28 -11
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Bicr3ZBg.js → agent-avatar-dicebear-B5uSVAyJ.js} +1 -1
- package/dist/gateway/static/root/assets/agents-BjIxt67Z.js +2 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CbEy9sR1.js → app-management-settings-panel-CYCONLIL.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CTHja6n9.js → appearance-settings-Clw3ryKg.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-QICTeGjX.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-Bpy64GjU.js → archive-plugin-CXUGRp2i.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DMkp4xSb.js → attachment-load-Cmiub3Wg.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-KnYaP7NT.js → automation-suggestion-card-CU0-4nQ-.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-Car-jtiz.js +1 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DA9C5mCw.js → binary-plugins-0Izz-N3p.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CiSXk_YC.js → block-editor-C1Kv0IkJ.js} +6 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CMeBJzlS.js +8 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-CEJ44WCU.js → capability-presets-api-BmQTM9Il.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DZEJEoCF.js +1 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-CDhrhfhN.js → channel-recipient-api-BeA2aVor.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-kkW-xFau.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-BvaQvO5F.js +2 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-7jKfbH0J.js → directory-picker-path-field-2rjzUu57.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-m1-wmz4o.js → dreaming-settings-DnHO686d.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-C9qQQrBS.js → extension-debug-page-BGLRuWVN.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DcBBMEGl.js → extension-page-D978ePp9.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BQ-jMMP9.js → extension-settings-page-B6Ih4Swx.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-Dtpbbe0s.js → fetch-BU5S0Sn7.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-BN6pyX2c.js → gateway-config-api-BIPGwrl1.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-CMEA3r5u.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BIET2x3y.js → gateway-startup-retry-Cd0Zz30N.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-BuIMDx6C.js → goal-create-dialog-B-KHKeXN.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-BxrSoWdj.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-CQm2r1Ty.js → goals-config-api-B95KdGMj.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BTJzIl28.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-DDrdRMxB.js → goals-settings-BJyEuLLm.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-wkOjYNQT.js +1 -0
- package/dist/gateway/static/root/assets/{index-CBDr5xjB.css → index-BLaXr6Ev.css} +1 -1
- package/dist/gateway/static/root/assets/index-c_9TVr_C.js +191 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C2TuQppb.js → keyboard-shortcuts-settings-BT8T4DyC.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CrxBJUgI.js +2 -0
- package/dist/gateway/static/root/assets/{markdown-split-DhONQ81k.js → markdown-split-Dv66bO2b.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DS44pJzr.js → media-plugins-BhIQU5yS.js} +1 -1
- package/dist/gateway/static/root/assets/messages-O6TAtdFC.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-DOOpz6y1.js +2 -0
- package/dist/gateway/static/root/assets/notes-page-Br16pK9v.js +1 -0
- package/dist/gateway/static/root/assets/notes-workbench-PSJAi0ZC.js +2 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-Dej6zHnr.js → preview-open-alternatives-DGzet1d7.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CIGGgKuw.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-B2grhsBt.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-CXMORxBD.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-Zu1FzH6z.js → save-bar-controls-Cqgb-jqa.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-BW78mKc0.js → schedule-field-DVZcI8Yt.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Cc-IOydE.js → schema-form-Bj7sOxC8.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-Bi2wkBzU.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-B1L3G4IA.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-DIpIYht_.js → settings-collapsible-section-BmXn-8N6.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-BFxBNxOG.js → settings-form-section-BnqYMWHR.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-BfRSHJmO.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-CLx4o2PN.js → settings-page-layout-CdWZU1hd.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CWtPM7RK.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-ZswWCrDu.js → share-preview-page-IB1v8i86.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-ngbsBgij.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BIe442Gv.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-BfchZRVa.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-3ZNcGRhS.js → system-settings-panel-BxQ384RC.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-bpzZjiVF.js → typed-models-lib-BkcpvFYO.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-BCjZLZ3O.js → use-channel-catalog-Cd0FaEQ4.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-CIXafITi.js → user-profile-settings-panel-DQ7NnRSY.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-DXMtz5j_.js → utils-YKhVf7Ka.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-C5Ov8Uk_.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-BYD9BtOq.js +3 -0
- package/dist/gateway/static/root/assets/{workflow-start-dialog-B4sZpTDQ.js → workflow-start-dialog-BNJVCWoS.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-BYF29ANm.js +18 -0
- package/dist/gateway/static/root/index.html +5 -5
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +6 -1
- package/dist/src/agent/agent-manager.js +28 -12
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/context/workspace-templates/AGENTS.md +1 -1
- package/dist/src/agent/embedded/xopc-tools-bridge.js +11 -7
- package/dist/src/agent/embedded/xopc-tools-bridge.js.map +1 -1
- package/dist/src/agent/lifecycle/progress.js +3 -1
- package/dist/src/agent/lifecycle/progress.js.map +1 -1
- package/dist/src/agent/lifecycle/timeout-wrapper.d.ts +2 -2
- package/dist/src/agent/lifecycle/timeout-wrapper.js +4 -4
- package/dist/src/agent/lifecycle/timeout-wrapper.js.map +1 -1
- package/dist/src/agent/memory/summary-generator.d.ts +1 -1
- package/dist/src/agent/memory/summary-generator.js +1 -2
- package/dist/src/agent/memory/summary-generator.js.map +1 -1
- package/dist/src/agent/middleware/index.d.ts +1 -1
- package/dist/src/agent/middleware/self-verify.d.ts +44 -14
- package/dist/src/agent/middleware/self-verify.js +214 -44
- package/dist/src/agent/middleware/self-verify.js.map +1 -1
- package/dist/src/agent/orchestration/agent-event-handler.js +57 -15
- package/dist/src/agent/orchestration/agent-event-handler.js.map +1 -1
- package/dist/src/agent/prompt/sections/tooling.js +18 -13
- package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
- package/dist/src/agent/prompt/system-reminder.js +2 -2
- package/dist/src/agent/prompt/system-reminder.js.map +1 -1
- package/dist/src/agent/sandbox/sanitize-env-vars.d.ts +2 -2
- package/dist/src/agent/sandbox/sanitize-env-vars.js +2 -2
- package/dist/src/agent/sandbox/sanitize-env-vars.js.map +1 -1
- package/dist/src/agent/sandbox/types.d.ts +2 -2
- package/dist/src/agent/sandbox/types.js.map +1 -1
- package/dist/src/agent/service/btw-query.js +1 -1
- package/dist/src/agent/service/btw-query.js.map +1 -1
- package/dist/src/agent/service/process-direct-one-shot.js +6 -2
- package/dist/src/agent/service/process-direct-one-shot.js.map +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +12 -7
- package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
- package/dist/src/agent/service.js +2 -1
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/skills/skill-tool-gating.js +1 -1
- package/dist/src/agent/skills/skill-tool-gating.js.map +1 -1
- package/dist/src/agent/starter-agents.js +9 -9
- package/dist/src/agent/starter-agents.js.map +1 -1
- package/dist/src/agent/tools/apply-patch.d.ts +25 -0
- package/dist/src/agent/tools/apply-patch.js +256 -0
- package/dist/src/agent/tools/apply-patch.js.map +1 -0
- package/dist/src/agent/tools/delegate-tool.d.ts +1 -1
- package/dist/src/agent/tools/delegate-tool.js +3 -3
- package/dist/src/agent/tools/delegate-tool.js.map +1 -1
- package/dist/src/agent/tools/exec-command.d.ts +30 -0
- package/dist/src/agent/tools/exec-command.js +224 -0
- package/dist/src/agent/tools/exec-command.js.map +1 -0
- package/dist/src/agent/tools/execute-code-tool.js +7 -4
- package/dist/src/agent/tools/execute-code-tool.js.map +1 -1
- package/dist/src/agent/tools/factory.d.ts +3 -3
- package/dist/src/agent/tools/factory.js +7 -8
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/index.d.ts +3 -2
- package/dist/src/agent/tools/index.js +5 -4
- package/dist/src/agent/tools/skills-tools.d.ts +1 -1
- package/dist/src/agent/tools/skills-tools.js.map +1 -1
- package/dist/src/agent/tools/update-plan-tool.d.ts +11 -0
- package/dist/src/agent/tools/update-plan-tool.js +72 -0
- package/dist/src/agent/tools/update-plan-tool.js.map +1 -0
- package/dist/src/agent/workflow/builtins/debug-incident.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/debug-incident.js +1 -1
- package/dist/src/agent/workflow/builtins/debug-incident.js.map +1 -1
- package/dist/src/agent/workflow/builtins/pr-review.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/pr-review.js +1 -1
- package/dist/src/agent/workflow/builtins/pr-review.js.map +1 -1
- package/dist/src/agent/workflow/builtins/release-check.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/release-check.js +1 -1
- package/dist/src/agent/workflow/builtins/release-check.js.map +1 -1
- package/dist/src/agent/workflow/step-labels.js +7 -3
- package/dist/src/agent/workflow/step-labels.js.map +1 -1
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/chat-commands/agent-edit.js.map +1 -1
- package/dist/src/chat-commands/builtins/review.d.ts +1 -0
- package/dist/src/chat-commands/builtins/review.js +167 -0
- package/dist/src/chat-commands/builtins/review.js.map +1 -0
- package/dist/src/chat-commands/index.d.ts +1 -0
- package/dist/src/chat-commands/index.js +3 -1
- package/dist/src/chat-commands/index.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agent-builtin-tools.js +3 -2
- package/dist/src/gateway/agent-builtin-tools.js.map +1 -1
- package/dist/src/gateway/chat-stream/mapper.d.ts +6 -0
- package/dist/src/gateway/chat-stream/mapper.js +149 -6
- package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
- package/dist/src/gateway/chat-stream/protocol.d.ts +51 -1
- package/dist/src/gateway/hono/routes/commands-skills.js +21 -0
- package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
- package/dist/src/gateway/hono/routes/index.js +2 -0
- package/dist/src/gateway/hono/routes/index.js.map +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
- package/dist/src/gateway/hono/routes/projects.js +40 -2
- package/dist/src/gateway/hono/routes/projects.js.map +1 -1
- package/dist/src/gateway/hono/routes/search.d.ts +3 -0
- package/dist/src/gateway/hono/routes/search.js +47 -0
- package/dist/src/gateway/hono/routes/search.js.map +1 -0
- package/dist/src/gateway/security/dangerous-tools.js +1 -1
- package/dist/src/gateway/security/dangerous-tools.js.map +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/mcp/channel-bridge.js +1 -1
- package/dist/src/projects/index.d.ts +2 -0
- package/dist/src/projects/index.js +3 -1
- package/dist/src/projects/project-agent-suggestion.d.ts +14 -0
- package/dist/src/projects/project-agent-suggestion.js +19 -0
- package/dist/src/projects/project-agent-suggestion.js.map +1 -0
- package/dist/src/projects/project-kind.d.ts +13 -0
- package/dist/src/projects/project-kind.js +147 -0
- package/dist/src/projects/project-kind.js.map +1 -0
- package/dist/src/projects/project-service.d.ts +1 -0
- package/dist/src/projects/project-service.js +1 -1
- package/dist/src/projects/project-service.js.map +1 -1
- package/dist/src/projects/project-store.js +32 -8
- package/dist/src/projects/project-store.js.map +1 -1
- package/dist/src/projects/types.d.ts +1 -0
- package/dist/src/review/review-git.d.ts +48 -0
- package/dist/src/review/review-git.js +333 -0
- package/dist/src/review/review-git.js.map +1 -0
- package/dist/src/review/review-types.d.ts +22 -0
- package/dist/src/review/review-types.js +29 -0
- package/dist/src/review/review-types.js.map +1 -0
- package/dist/src/session/session-context-for-llm.js +151 -0
- package/dist/src/session/session-context-for-llm.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/021_projects_fts.sql +21 -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.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tui/backends/embedded-backend.d.ts +1 -0
- package/dist/src/tui/backends/embedded-backend.js +20 -0
- package/dist/src/tui/backends/embedded-backend.js.map +1 -1
- package/dist/src/tui/backends/gateway-sse-backend.d.ts +2 -0
- package/dist/src/tui/backends/gateway-sse-backend.js +7 -0
- package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
- package/dist/src/tui/components/assistant-message.js +35 -0
- package/dist/src/tui/components/assistant-message.js.map +1 -1
- package/dist/src/tui/tui-agent-events.js +25 -0
- package/dist/src/tui/tui-agent-events.js.map +1 -1
- package/dist/src/tui/tui-backend.d.ts +4 -0
- package/dist/src/tui/tui-commands.d.ts +1 -0
- package/dist/src/tui/tui-commands.js +110 -4
- package/dist/src/tui/tui-commands.js.map +1 -1
- package/dist/src/tui/tui-picker-overlay.d.ts +2 -0
- package/dist/src/tui/tui-picker-overlay.js +153 -1
- package/dist/src/tui/tui-picker-overlay.js.map +1 -1
- package/dist/src/tui/tui.js +16 -3
- package/dist/src/tui/tui.js.map +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-CxDSFHGx.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-CyZdgqvm.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-8VLKM4au.js +0 -1
- package/dist/gateway/static/root/assets/browser-settings-page-5tPg0DcP.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-BJW3aVST.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-CorUCTrs.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-VKstC3sP.js +0 -2
- package/dist/gateway/static/root/assets/gateway-settings-hQtgVmSR.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-FEypCq74.js +0 -1
- package/dist/gateway/static/root/assets/goals-page-C4-2_MLG.js +0 -2
- package/dist/gateway/static/root/assets/heartbeat-settings-BJVok3Sl.js +0 -1
- package/dist/gateway/static/root/assets/index-T0SaNd5a.js +0 -191
- package/dist/gateway/static/root/assets/logs-page-DwkwPgid.js +0 -2
- package/dist/gateway/static/root/assets/messages-avfvyZuQ.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-huNY4A1G.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-DdfGuEZ1.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-B0bT9Hqa.js +0 -2
- package/dist/gateway/static/root/assets/project-detail-page-CjxhPorG.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-C4Z5OJMF.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CVCOPUVd.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-B4qExXHC.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-Ce8yLTBi.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-C4fivemT.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Kyc4eUf0.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-Bu76CMiC.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-D-CFg86j.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CUU4f6Ss.js +0 -2
- package/dist/gateway/static/root/assets/voice-api-key-field-C1MrQD8R.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-DqizIcY5.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-B3sVNPFk.js +0 -18
- package/dist/src/agent/tools/edit.d.ts +0 -14
- package/dist/src/agent/tools/edit.js +0 -132
- package/dist/src/agent/tools/edit.js.map +0 -1
- package/dist/src/agent/tools/shell.d.ts +0 -15
- package/dist/src/agent/tools/shell.js +0 -158
- package/dist/src/agent/tools/shell.js.map +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-avfvyZuQ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-Dtpbbe0s.js";import{r as d}from"./toast-z0toXu32.js";import{Aa as f,Ba as p,Bs as m,Da as h,Ds as g,Fo as _,Gs as v,H as y,Io as b,Jo as x,Lo as S,Mi as C,Mo as w,Oo as T,Qa as E,Rc as D,Us as O,Wa as k,Xa as A,Zn as j,Zs as M,_o as N,ct as P,f as F,fc as I,ga as L,go as R,ji as z,ka as B,lc as V,lo as H,lt as U,mo as ee,nc as W,ns as G,oc as te,rc as ne,ua as re,ut as ie,va as K}from"./index-T0SaNd5a.js";import{t as ae}from"./settings-advanced-gate-Ce8yLTBi.js";import{n as oe,t as q}from"./settings-form-section-BFxBNxOG.js";import{n as se,r as ce,t as le}from"./settings-page-layout-CLx4o2PN.js";import{c as ue,r as de,s as J}from"./typed-models-lib-bpzZjiVF.js";import{i as fe,l as pe,s as me,u as he}from"./gateway-config-api-BN6pyX2c.js";var Y=e(t(),1),X=n(),Z=r();function Q(e){let t=(0,X.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function ge(e){switch(e){case`ready`:return`bg-emerald-500`;case`not_installed`:case`checking`:return`bg-amber-500`;case`error`:return`bg-red-500`;default:return`bg-fg-subtle/60`}}function _e(e){let t=(0,X.c)(28),{value:n,onChange:r,onOpenConfig:a,options:o,m:s}=e,c;if(t[0]!==s.browserGoToConfigure||t[1]!==s.browserPickerSubtitle||t[2]!==s.browserPickerTitle||t[3]!==r||t[4]!==a||t[5]!==o||t[6]!==n){let e=o.find(e=>e.value===n)??o[0],l;t[8]===s.browserPickerTitle?l=t[9]:(l=(0,Z.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:s.browserPickerTitle}),t[8]=s.browserPickerTitle,t[9]=l);let u;t[10]===s.browserPickerSubtitle?u=t[11]:(u=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:s.browserPickerSubtitle}),t[10]=s.browserPickerSubtitle,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=i(ue(),`min-w-0 flex-1 sm:max-w-md`),t[15]=f):f=t[15];let p;t[16]===r?p=t[17]:(p=e=>r(e.target.value),t[16]=r,t[17]=p);let m=s.browserPickerTitle,h;t[18]===o?h=t[19]:(h=o.map(ve),t[18]=o,t[19]=h);let g;t[20]!==s.browserPickerTitle||t[21]!==p||t[22]!==h||t[23]!==n?(g=(0,Z.jsx)(L,{id:`browser-backend-select`,className:f,value:n,onChange:p,"aria-label":m,children:h}),t[20]=s.browserPickerTitle,t[21]=p,t[22]=h,t[23]=n,t[24]=g):g=t[24];let _=a?(0,Z.jsxs)(`button`,{type:`button`,className:i(`inline-flex shrink-0 items-center justify-center gap-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-accent`,`transition-colors hover:border-edge-strong hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),onClick:()=>a(n),"aria-label":`${e?.name??n} — ${s.browserGoToConfigure}`,children:[(0,Z.jsx)(`span`,{children:s.browserGoToConfigure}),(0,Z.jsx)(I,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,v;t[25]!==_||t[26]!==g?(v=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[g,_]}),t[25]=_,t[26]=g,t[27]=v):v=t[27],c=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,v,e?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,Z.jsx)(`span`,{className:i(`inline-block size-1.5 rounded-full`,ge(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.tagline})]}):null]}),t[0]=s.browserGoToConfigure,t[1]=s.browserPickerSubtitle,t[2]=s.browserPickerTitle,t[3]=r,t[4]=a,t[5]=o,t[6]=n,t[7]=c}else c=t[7];return c}function ve(e){return(0,Z.jsx)(K,{value:e.value,children:e.name},e.value)}function ye(e){return`browser-focus-${e}`}function be(e){switch(e){case`connection`:case`extension`:case`local`:case`cloak`:case`cdp`:case`cloud`:case`runtime`:case`security`:return e;default:return null}}function xe(e){let t=(0,X.c)(89),{a:n,form:r,update:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=ye(`runtime`),t[0]=a):a=t[0];let o;t[1]===n.browserBehaviorShow?o=t[2]:(o=(0,Z.jsx)(oe,{icon:ee,title:n.browserBehaviorShow}),t[1]=n.browserBehaviorShow,t[2]=o);let s;t[3]===i?s=t[4]:(s=e=>i({browserHeadless:e.target.checked}),t[3]=i,t[4]=s);let c;t[5]!==r.browserHeadless||t[6]!==s?(c=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserHeadless,onChange:s}),t[5]=r.browserHeadless,t[6]=s,t[7]=c):c=t[7];let l;t[8]===n.browserHeadlessOn?l=t[9]:(l=(0,Z.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=l);let u;t[10]!==c||t[11]!==l?(u=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.desc.browserHeadless||t[14]!==n.label.browserHeadless||t[15]!==u?(d=(0,Z.jsx)(Q,{label:n.label.browserHeadless,description:n.desc.browserHeadless,children:u}),t[13]=n.desc.browserHeadless,t[14]=n.label.browserHeadless,t[15]=u,t[16]=d):d=t[16];let f=n.label.browserDialogPolicy,p=n.desc.browserDialogPolicy,m;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(m=ue(),t[17]=m):m=t[17];let h;t[18]===i?h=t[19]:(h=e=>i({browserDialogPolicy:e.target.value}),t[18]=i,t[19]=h);let g;t[20]===n.browserDialogPolicyMustRespond?g=t[21]:(g=(0,Z.jsx)(K,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=g);let _;t[22]===n.browserDialogPolicyAutoDismiss?_=t[23]:(_=(0,Z.jsx)(K,{value:`auto_dismiss`,children:n.browserDialogPolicyAutoDismiss}),t[22]=n.browserDialogPolicyAutoDismiss,t[23]=_);let v;t[24]===n.browserDialogPolicyAutoAccept?v=t[25]:(v=(0,Z.jsx)(K,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=v);let y;t[26]!==r.browserDialogPolicy||t[27]!==h||t[28]!==g||t[29]!==_||t[30]!==v?(y=(0,Z.jsxs)(L,{className:m,value:r.browserDialogPolicy,onChange:h,children:[g,_,v]}),t[26]=r.browserDialogPolicy,t[27]=h,t[28]=g,t[29]=_,t[30]=v,t[31]=y):y=t[31];let b;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==y?(b=(0,Z.jsx)(Q,{label:f,description:p,children:y}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=y,t[35]=b):b=t[35];let x=n.label.browserDialogTimeout,S=n.desc.browserDialogTimeout,C;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(C=J(),t[36]=C):C=t[36];let w=r.browserDialogTimeout??``,T;t[37]===i?T=t[38]:(T=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[37]=i,t[38]=T);let E;t[39]!==w||t[40]!==T?(E=(0,Z.jsx)(`input`,{type:`number`,className:C,min:1,value:w,placeholder:`300`,onChange:T}),t[39]=w,t[40]=T,t[41]=E):E=t[41];let D;t[42]!==n.desc.browserDialogTimeout||t[43]!==n.label.browserDialogTimeout||t[44]!==E?(D=(0,Z.jsx)(Q,{label:x,description:S,children:E}),t[42]=n.desc.browserDialogTimeout,t[43]=n.label.browserDialogTimeout,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==b||t[47]!==D||t[48]!==d?(O=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[d,b,D]}),t[46]=b,t[47]=D,t[48]=d,t[49]=O):O=t[49];let k;t[50]!==o||t[51]!==O?(k=(0,Z.jsx)(`div`,{id:a,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{children:[o,O]})}),t[50]=o,t[51]=O,t[52]=k):k=t[52];let A;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(A=ye(`security`),t[53]=A):A=t[53];let j;t[54]===n.browserSecurityShow?j=t[55]:(j=(0,Z.jsx)(oe,{icon:N,title:n.browserSecurityShow}),t[54]=n.browserSecurityShow,t[55]=j);let M;t[56]===i?M=t[57]:(M=e=>i({browserAllowPrivateUrls:e.target.checked}),t[56]=i,t[57]=M);let P;t[58]!==r.browserAllowPrivateUrls||t[59]!==M?(P=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:M}),t[58]=r.browserAllowPrivateUrls,t[59]=M,t[60]=P):P=t[60];let F;t[61]===n.browserAllowPrivateOn?F=t[62]:(F=(0,Z.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[61]=n.browserAllowPrivateOn,t[62]=F);let I;t[63]!==P||t[64]!==F?(I=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[P,F]}),t[63]=P,t[64]=F,t[65]=I):I=t[65];let R;t[66]!==n.desc.browserAllowPrivateUrls||t[67]!==n.label.browserAllowPrivateUrls||t[68]!==I?(R=(0,Z.jsx)(Q,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:I}),t[66]=n.desc.browserAllowPrivateUrls,t[67]=n.label.browserAllowPrivateUrls,t[68]=I,t[69]=R):R=t[69];let z=n.label.browserCommandTimeout,B=n.desc.browserCommandTimeout,V;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(V=J(),t[70]=V):V=t[70];let H=r.browserCommandTimeout??``,U;t[71]===i?U=t[72]:(U=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[71]=i,t[72]=U);let W;t[73]!==H||t[74]!==U?(W=(0,Z.jsx)(`input`,{type:`number`,className:V,min:5,value:H,placeholder:`30`,onChange:U}),t[73]=H,t[74]=U,t[75]=W):W=t[75];let G;t[76]!==n.desc.browserCommandTimeout||t[77]!==n.label.browserCommandTimeout||t[78]!==W?(G=(0,Z.jsx)(Q,{label:z,description:B,children:W}),t[76]=n.desc.browserCommandTimeout,t[77]=n.label.browserCommandTimeout,t[78]=W,t[79]=G):G=t[79];let te;t[80]!==R||t[81]!==G?(te=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[R,G]}),t[80]=R,t[81]=G,t[82]=te):te=t[82];let ne;t[83]!==j||t[84]!==te?(ne=(0,Z.jsx)(`div`,{id:A,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{className:`border border-amber-500/20`,children:[j,te]})}),t[83]=j,t[84]=te,t[85]=ne):ne=t[85];let re;return t[86]!==k||t[87]!==ne?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[k,ne]}),t[86]=k,t[87]=ne,t[88]=re):re=t[88],re}function Se(e){let t=(0,X.c)(9),{language:n,label:r,className:a}=e,o;t[0]===n?o=t[1]:(o=re(n),t[0]=n,t[1]=o);let s;t[2]===a?s=t[3]:(s=i(`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a),t[2]=a,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(m,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=c):c=t[4];let l;return t[5]!==r||t[6]!==o||t[7]!==s?(l=(0,Z.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:s,children:[r,c]}),t[5]=r,t[6]=o,t[7]=s,t[8]=l):l=t[8],l}function Ce(e){let t=(0,X.c)(27),{title:n,description:r,recommended:a,recommendedLabel:o,icon:s,onSelect:c,selectLabel:l}=e,u=`${n} — ${l}`,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(`group flex w-full flex-col rounded-xl border border-edge bg-surface-panel px-3 py-3 text-left transition-colors`,`hover:border-edge-strong hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=d):d=t[0];let f;t[1]===s?f=t[2]:(f=(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=s,t[2]=f);let p;t[3]===n?p=t[4]:(p=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==a||t[6]!==o?(m=a&&o?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent`,children:o}):null,t[5]=a,t[6]=o,t[7]=m):m=t[7];let h;t[8]!==p||t[9]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p,m]}),t[8]=p,t[9]=m,t[10]=h):h=t[10];let g;t[11]===r?g=t[12]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(I,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]!==f||t[18]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[f,_,v]}),t[17]=f,t[18]=_,t[19]=y):y=t[19];let b;t[20]===l?b=t[21]:(b=(0,Z.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:l}),t[20]=l,t[21]=b);let x;return t[22]!==c||t[23]!==u||t[24]!==y||t[25]!==b?(x=(0,Z.jsxs)(`button`,{type:`button`,onClick:c,"aria-label":u,className:d,children:[y,b]}),t[22]=c,t[23]=u,t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function we(e){let t=(0,X.c)(25),{m:n,onStart:r}=e,i=j(Te),a;t[0]!==n.browserBackendCloakBrowser||t[1]!==n.browserModeCloakTagline||t[2]!==n.browserSetupCloudDesc||t[3]!==n.browserSetupCloudTitle||t[4]!==n.browserSetupExtDesc||t[5]!==n.browserSetupExtTitle||t[6]!==n.browserSetupLocalDesc||t[7]!==n.browserSetupLocalTitle||t[8]!==i?(a=[{id:`extension`,icon:w,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:R,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:x,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:M,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>pe(e.id,i)),t[0]=n.browserBackendCloakBrowser,t[1]=n.browserModeCloakTagline,t[2]=n.browserSetupCloudDesc,t[3]=n.browserSetupCloudTitle,t[4]=n.browserSetupExtDesc,t[5]=n.browserSetupExtTitle,t[6]=n.browserSetupLocalDesc,t[7]=n.browserSetupLocalTitle,t[8]=i,t[9]=a):a=t[9];let o=a,s;t[10]===n.browserSetupTitle?s=t[11]:(s=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[10]=n.browserSetupTitle,t[11]=s);let c;t[12]===n.browserSetupSubtitle?c=t[13]:(c=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[12]=n.browserSetupSubtitle,t[13]=c);let l;t[14]!==s||t[15]!==c?(l=(0,Z.jsxs)(`div`,{children:[s,c]}),t[14]=s,t[15]=c,t[16]=l):l=t[16];let u;t[17]!==n.browserSetupRecommended||t[18]!==n.browserSetupSelect||t[19]!==o||t[20]!==r?(u=(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>(0,Z.jsx)(Ce,{icon:e.icon,title:e.title,description:e.description,recommended:e.recommended,recommendedLabel:n.browserSetupRecommended,selectLabel:n.browserSetupSelect,onSelect:()=>r(e.id)},e.id))}),t[17]=n.browserSetupRecommended,t[18]=n.browserSetupSelect,t[19]=o,t[20]=r,t[21]=u):u=t[21];let d;return t[22]!==l||t[23]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base px-4 py-4`,children:[l,u]}),t[22]=l,t[23]=u,t[24]=d):d=t[24],d}function Te(e){return e.mode}function Ee(e){if(e.kind===`loading`)return`checking`;if(e.kind===`error`)return`error`;if(e.kind===`ok`)return e.data.installed?`ready`:`not_installed`}function De(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Oe(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function ke(e,t){if(e.kind!==`idle`)return e.kind===`loading`?t.browserStatusChecking:e.kind===`error`?t.browserStatusError:e.data.connected?t.browserExtensionConnected:e.data.running?t.browserExtensionWaiting:t.browserExtensionServerOff}var Ae=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],je=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Me={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Ne(e){let t=(e??``).trim();return t===`behavior`?`overview`:Ae.includes(t)?t:`overview`}function Pe(e){return je.includes(e)}function Fe(e){let t=(0,X.c)(46),{icon:n,title:r,description:i,status:a,statusDetail:o,primaryAction:s,children:c,advanced:l,m:u,embedded:d,sectionTitle:f,advancedTitle:p}=e,m=d===void 0?!1:d,h;t[0]!==l||t[1]!==p?(h=l?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:p}):null,l]}):null,t[0]=l,t[1]=p,t[2]=h):h=t[2];let g=h;if(m){let e;t[3]!==i||t[4]!==f?(e=f?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}):null]}):null,t[3]=i,t[4]=f,t[5]=e):e=t[5];let n;t[6]!==u||t[7]!==s||t[8]!==a||t[9]!==o?(n=a||s?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Ie,{kind:a,detail:o,m:u})}):(0,Z.jsx)(`span`,{}),s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,t[6]=u,t[7]=s,t[8]=a,t[9]=o,t[10]=n):n=t[10];let r;t[11]===c?r=t[12]:(r=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[11]=c,t[12]=r);let l;return t[13]!==g||t[14]!==e||t[15]!==n||t[16]!==r?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,n,r,g]}),t[13]=g,t[14]=e,t[15]=n,t[16]=r,t[17]=l):l=t[17],l}let _;t[18]===n?_=t[19]:(_=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r}),t[20]=r,t[21]=v);let y;t[22]!==u||t[23]!==a||t[24]!==o?(y=a?(0,Z.jsx)(Ie,{kind:a,detail:o,m:u}):null,t[22]=u,t[23]=a,t[24]=o,t[25]=y):y=t[25];let b;t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28];let x;t[29]===i?x=t[30]:(x=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}),t[29]=i,t[30]=x);let S;t[31]!==b||t[32]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[b,x]}),t[31]=b,t[32]=x,t[33]=S):S=t[33];let C;t[34]===s?C=t[35]:(C=s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null,t[34]=s,t[35]=C);let w;t[36]!==_||t[37]!==S||t[38]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,S,C]}),t[36]=_,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]===c?T=t[41]:(T=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[40]=c,t[41]=T);let E;return t[42]!==g||t[43]!==w||t[44]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Ie(e){let t=(0,X.c)(27),{kind:n,detail:r,m:a}=e,o,s,c,l;if(t[0]!==n||t[1]!==a.browserStatusChecking||t[2]!==a.browserStatusError||t[3]!==a.browserStatusNotInstalled||t[4]!==a.browserStatusReady||t[5]!==a.browserStatusUnknown){let{icon:e,color:r,label:u}={ready:{icon:V,color:`text-green-600 dark:text-green-400`,label:a.browserStatusReady},not_installed:{icon:E,color:`text-amber-600 dark:text-amber-400`,label:a.browserStatusNotInstalled},checking:{icon:G,color:`text-fg-muted`,label:a.browserStatusChecking},unknown:{icon:te,color:`text-fg-muted`,label:a.browserStatusUnknown},error:{icon:ne,color:`text-red-600 dark:text-red-400`,label:a.browserStatusError}}[n];o=e,s=u,l=`inline-flex min-w-0 flex-col items-start gap-1`,c=i(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs font-medium`,r),t[0]=n,t[1]=a.browserStatusChecking,t[2]=a.browserStatusError,t[3]=a.browserStatusNotInstalled,t[4]=a.browserStatusReady,t[5]=a.browserStatusUnknown,t[6]=o,t[7]=s,t[8]=c,t[9]=l}else o=t[6],s=t[7],c=t[8],l=t[9];let u=n===`checking`&&`animate-spin`,d;t[10]===u?d=t[11]:(d=i(`size-3.5 shrink-0`,u),t[10]=u,t[11]=d);let f;t[12]!==o||t[13]!==d?(f=(0,Z.jsx)(o,{className:d}),t[12]=o,t[13]=d,t[14]=f):f=t[14];let p;t[15]===s?p=t[16]:(p=(0,Z.jsx)(`span`,{children:s}),t[15]=s,t[16]=p);let m;t[17]!==c||t[18]!==f||t[19]!==p?(m=(0,Z.jsxs)(`span`,{className:c,children:[f,p]}),t[17]=c,t[18]=f,t[19]=p,t[20]=m):m=t[20];let h;t[21]===r?h=t[22]:(h=r?(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=h);let g;return t[23]!==l||t[24]!==m||t[25]!==h?(g=(0,Z.jsxs)(`span`,{className:l,children:[m,h]}),t[23]=l,t[24]=m,t[25]=h,t[26]=g):g=t[26],g}function Le(e){let t=(0,X.c)(5),{kind:n,message:r}=e,a=n===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300`,o;t[0]===a?o=t[1]:(o=i(`rounded-lg border px-3 py-2 text-xs leading-relaxed`,a),t[0]=a,t[1]=o);let s;return t[2]!==r||t[3]!==o?(s=(0,Z.jsx)(`div`,{className:o,children:r}),t[2]=r,t[3]=o,t[4]=s):s=t[4],s}var Re={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function ze({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,Y.useReducer)(ie,Re),{instances:u,launchStatus:d,launchMessage:f,testStatus:p,testMessage:m,executablePath:h}=c,g=(0,Y.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,Y.useEffect)(()=>{g();let e=setInterval(()=>void g(),8e3);return()=>clearInterval(e)},[g]);let v=(0,Y.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(h.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await g()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[h,r,d,e.browserCdpLaunchedAtPort,n,g]),y=(0,Y.useCallback)(async e=>{await i(e),await g()},[g,i]),x=(0,Y.useCallback)(async()=>{if(t.trim()){l({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?l({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,t instanceof Error?t.message:String(t))}})}}},[t,e.browserCdpReachable,e.browserCdpUnreachable,o]);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Fe,{icon:b,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:d===`pending`,onClick:()=>void v(),children:[d===`pending`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(b,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[f?(0,Z.jsx)(Le,{kind:d===`error`?`error`:`success`,message:f}):null,(0,Z.jsx)(Q,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:h,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>l({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),u.length>0?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge bg-surface-base p-3 text-xs`,children:u.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,Z.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg hover:bg-surface-raised`,onClick:()=>void y(t.port),children:[(0,Z.jsx)(H,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,Z.jsxs)(Fe,{icon:k,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:!t.trim()||p===`pending`,onClick:()=>void x(),children:[p===`pending`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(_,{className:`size-3.5`}),p===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),m?(0,Z.jsx)(Le,{kind:p===`error`?`error`:`success`,message:m}):null]})]})}function Be(e,t){let n=t.phase;if(!n)return e.browserInstallPhaseStarting;if(n===`downloading`)return t.percent==null?e.browserInstallPhaseDownloading:e.browserInstallPhaseDownloadingPercent.replace(`{{percent}}`,String(t.percent));switch(n){case`starting`:return e.browserInstallPhaseStarting;case`verifying`:return e.browserInstallPhaseVerifying;case`extracting`:return e.browserInstallPhaseExtracting;case`running`:return t.message??e.browserInstallPhaseRunning;case`ready`:return e.browserInstallPhaseReady;default:return t.message??e.browserInstallPhaseRunning}}function Ve(e){let t=(0,X.c)(32),{m:n,progress:r,showLogs:i,onCancel:a,cancelling:o}=e,s=i===void 0?!1:i,c=o===void 0?!1:o;if(!r.phase)return null;let l;t[0]!==n||t[1]!==r?(l=Be(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d=r.percent==null?(r.phase===`extracting`||r.phase===`verifying`||r.phase===`running`||r.phase,null):Math.min(100,Math.max(0,r.percent)),f;t[3]===u?f=t[4]:(f=(0,Z.jsx)(`span`,{className:`text-fg`,children:u}),t[3]=u,t[4]=f);let p;t[5]===d?p=t[6]:(p=d==null?null:(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[d,`%`]}),t[5]=d,t[6]=p);let m;t[7]!==c||t[8]!==n||t[9]!==a?(m=a?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md border border-edge px-2 py-0.5 text-[11px] font-medium text-fg-muted hover:bg-surface-raised hover:text-fg disabled:cursor-not-allowed disabled:opacity-60`,disabled:c,onClick:()=>void a(),children:c?n.browserInstallCancelling:n.browserInstallCancel}):null,t[7]=c,t[8]=n,t[9]=a,t[10]=m):m=t[10];let h;t[11]!==p||t[12]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==f||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[f,h]}),t[14]=f,t[15]=h,t[16]=g):g=t[16];let _;t[17]===d?_=t[18]:(_=(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,Z.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out`,style:{width:`${d}%`}})}),t[17]=d,t[18]=_);let v;t[19]!==r.lines||t[20]!==s?(v=s&&r.lines.length>0?(0,Z.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded-md border border-edge bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted`,children:r.lines.map(He)}):null,t[19]=r.lines,t[20]=s,t[21]=v):v=t[21];let y;t[22]!==r.message||t[23]!==r.percent||t[24]!==r.phase||t[25]!==s?(y=!s&&r.phase===`downloading`&&r.message&&r.percent==null?(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:r.message}):null,t[22]=r.message,t[23]=r.percent,t[24]=r.phase,t[25]=s,t[26]=y):y=t[26];let b;return t[27]!==v||t[28]!==y||t[29]!==g||t[30]!==_?(b=(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function He(e){return(0,Z.jsx)(`div`,{className:`truncate`,children:e},e)}var Ue={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function We({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:a,launchCloak:o,form:s,onChange:c,embedded:l=!1}){let[u,d]=(0,Y.useReducer)(ie,Ue),{confirmOpen:f,installStatus:p,installMessage:m,openStatus:h,openMessage:g,runtime:_}=u,{progress:v,running:y,cancelling:x,run:S,reset:C,cancel:w}=i,E=t.kind===`ok`?t.data:null,D=E?.installed===!0,k=p===`installing`||y,A=(0,Y.useCallback)(async()=>{if(D)try{d({type:`patch`,patch:{runtime:await a()}})}catch{}},[a,D]);(0,Y.useEffect)(()=>{if(!D){d({type:`patch`,patch:{runtime:null}});return}A();let e=setInterval(()=>void A(),8e3);return()=>clearInterval(e)},[D,A]);let j=(0,Y.useCallback)(async()=>{d({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),C();let t=await S({body:{cacheDir:s.cacheDir.trim()||void 0,binaryPath:s.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){d({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){d({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),C();return}d({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),d({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:s.cacheDir,binaryPath:s.binaryPath}),await A()},[r,s.binaryPath,s.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,A,C,S]),M=(0,Y.useCallback)(async()=>{if(h!==`pending`){d({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await o();d({type:`patch`,patch:{openStatus:`ok`,openMessage:t.reused?e.browserCloakOpenReused.replace(`{{port}}`,String(t.port)):e.browserCloakOpenLaunched.replace(`{{port}}`,String(t.port)),runtime:t}})}catch(e){d({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[o,e.browserCloakOpenLaunched,e.browserCloakOpenReused,h]),N=t.kind===`loading`?`checking`:t.kind===`error`?`error`:D?`ready`:`not_installed`,P=D&&E?.version?`v${E.version} (${E.platform})`:void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fe,{icon:R,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:N,statusDetail:P,m:e,embedded:l,primaryAction:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[D?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h===`pending`,onClick:()=>void M(),children:[h===`pending`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(b,{className:`size-3.5`}),h===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:k,onClick:()=>d({type:`patch`,patch:{confirmOpen:!0}}),children:[k?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):D?(0,Z.jsx)(T,{className:`size-3.5`}):p===`installed`?(0,Z.jsx)(V,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(O,{className:`size-3.5`}),k?e.browserCloakInstalling:D?e.browserReinstall:e.browserCloakDownload]})]}),children:[y?(0,Z.jsx)(Ve,{m:e,progress:v,cancelling:x,onCancel:()=>void w()}):null,m?(0,Z.jsx)(Le,{kind:p===`failed`?`error`:`success`,message:m}):null,g?(0,Z.jsx)(Le,{kind:h===`error`?`error`:`success`,message:g}):null,D&&_?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge bg-surface-base p-3 text-xs`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:_.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(_.port)):e.browserCloakRuntimeOff})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:_.userDataDir})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),_.temporaryProfile?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.keepOpen,onChange:e=>c({keepOpen:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.temporaryProfile,onChange:e=>c({temporaryProfile:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.humanize,onChange:e=>c({humanize:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,Z.jsxs)(L,{className:ue(),value:s.humanPreset,onChange:e=>c({humanPreset:e.target.value}),children:[(0,Z.jsx)(K,{value:`careful`,children:e.browserHumanPresetCareful}),(0,Z.jsx)(K,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,Z.jsxs)(q,{className:`mt-4 border border-edge-subtle`,children:[(0,Z.jsx)(oe,{icon:R,title:e.browserCloakAdvancedShow}),(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsxs)(Q,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>c({cacheDir:e.target.value}),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,Z.jsxs)(Q,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>c({binaryPath:e.target.value}),autoComplete:`off`}),s.binaryPath.trim()?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,Z.jsx)(Q,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.timezone,placeholder:`America/New_York`,onChange:e=>c({timezone:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.locale,placeholder:`en-US`,onChange:e=>c({locale:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>c({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.fingerprintPlatform,placeholder:`macos`,onChange:e=>c({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Z.jsx)(Q,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,Z.jsx)(`textarea`,{className:Ge(),value:s.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>c({extraArgs:e.target.value})})})})]})]}),(0,Z.jsx)(F,{open:f,title:e.browserConfirmDownloadTitle,description:Ke(e,E),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void j(),onCancel:()=>d({type:`patch`,patch:{confirmOpen:!1}})})]})}function Ge(){return`${J()} min-h-[4.5rem] resize-y font-mono text-xs`}function Ke(e,t){if(!t)return e.browserConfirmDownloadBody;let n=[e.browserConfirmDownloadBody.replace(`{{version}}`,t.version??`—`).replace(`{{platform}}`,t.platform).replace(`{{url}}`,t.downloadUrl||`—`)];return t.expectedSha256?n.push(`SHA-256: ${t.expectedSha256.slice(0,16)}…`):n.push(e.browserCloakSha256Skipped),n.join(`
|
|
2
|
-
`)}function qe({m:e,form:t,onChange:n,testCloud:r,embedded:i=!1}){let[s,c]=(0,Y.useState)(`idle`),[l,u]=(0,Y.useState)(null),d=t.provider===`local`?`browserbase`:t.provider,f=a(o(e=>e.language)).providersSettings,p=h({show:f.show,hide:f.hide,copy:f.copy,copied:f.copied}),m=(0,Y.useCallback)(()=>fe().then(e=>e.apiKey??null),[]),g=(0,Y.useCallback)(async()=>{c(`pending`),u(null);try{let n=await r(d,t.apiKey);n.reachable?(c(`ok`),u(e.browserCloudTestOk)):(c(`error`),u(e.browserCloudTestFailed.replace(`{{error}}`,n.error??`—`)))}catch(t){c(`error`),u(e.browserCloudTestFailed.replace(`{{error}}`,t instanceof Error?t.message:String(t)))}},[t.apiKey,e.browserCloudTestFailed,e.browserCloudTestOk,d,r]);return(0,Z.jsxs)(Fe,{icon:M,title:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,m:e,embedded:i,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:s===`pending`,onClick:()=>void g(),children:[s===`pending`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(_,{className:`size-3.5`}),e.browserCloudTestConnection]}),children:[(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,children:(0,Z.jsxs)(L,{className:ue(),value:d,onChange:e=>n({provider:e.target.value}),children:[(0,Z.jsx)(K,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,Z.jsx)(K,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,Z.jsx)(B,{value:t.apiKey,onChange:e=>n({apiKey:e}),placeholder:d===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,labels:p,reveal:m,loadFailedLabel:`Failed to load key`})}),d===`browserbase`?(0,Z.jsx)(Q,{label:e.label.browserCloudProjectId,description:e.desc.browserCloudProjectId,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.projectId,placeholder:`BROWSERBASE_PROJECT_ID`,onChange:e=>n({projectId:e.target.value}),autoComplete:`off`})}):null,(0,Z.jsx)(Q,{label:e.label.browserCloudRegion,description:e.desc.browserCloudRegion,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.region,placeholder:`us-west-2`,onChange:e=>n({region:e.target.value}),autoComplete:`off`})})]}),l?(0,Z.jsx)(Le,{kind:s===`error`?`error`:`success`,message:l}):null]})}function Je(e){let t=(0,X.c)(48),{m:n,installed:r,extensionDir:a,connected:o,busy:s,onOpenChrome:c,onCopyPath:l,onRevealFolder:u,pathBusy:d,folderBusy:f}=e,p;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(p={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=p):p=t[2];let m=!!a&&o,h;t[3]!==s||t[4]!==a||t[5]!==f||t[6]!==n.browserExtensionCopyPath||t[7]!==n.browserExtensionInstallStep2FolderLabel||t[8]!==n.browserExtensionInstalling||t[9]!==n.browserExtensionOpenChrome||t[10]!==n.browserExtensionRevealFolder||t[11]!==l||t[12]!==c||t[13]!==u||t[14]!==d?(h=a?(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge bg-surface-raised px-2.5 py-2`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.browserExtensionInstallStep2FolderLabel}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-fg`,children:a}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:c,children:n.browserExtensionOpenChrome}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:l,title:a,children:d?n.browserExtensionInstalling:n.browserExtensionCopyPath}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:u,title:a,children:f?n.browserExtensionInstalling:n.browserExtensionRevealFolder})]})]}):null,t[3]=s,t[4]=a,t[5]=f,t[6]=n.browserExtensionCopyPath,t[7]=n.browserExtensionInstallStep2FolderLabel,t[8]=n.browserExtensionInstalling,t[9]=n.browserExtensionOpenChrome,t[10]=n.browserExtensionRevealFolder,t[11]=l,t[12]=c,t[13]=u,t[14]=d,t[15]=h):h=t[15];let g;t[16]!==n.browserExtensionInstallStep2||t[17]!==m||t[18]!==h?(g={id:`load`,label:n.browserExtensionInstallStep2,done:m,detail:h},t[16]=n.browserExtensionInstallStep2,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;t[20]!==o||t[21]!==n.browserExtensionInstallStep3?(_={id:`connect`,label:n.browserExtensionInstallStep3,done:o},t[20]=o,t[21]=n.browserExtensionInstallStep3,t[22]=_):_=t[22];let v;t[23]!==p||t[24]!==g||t[25]!==_?(v=[p,g,_],t[23]=p,t[24]=g,t[25]=_,t[26]=v):v=t[26];let y=v,b;t[27]===y?b=t[28]:(b=y.filter(Ye),t[27]=y,t[28]=b);let x=b.length,S=n.browserExtensionInstallGuideTitle,C;t[29]===n.browserExtensionInstallGuideTitle?C=t[30]:(C=(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=C);let w;t[31]!==x||t[32]!==n.browserExtensionChecklistProgress||t[33]!==y.length?(w=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(x)).replace(`{{total}}`,String(y.length)),t[31]=x,t[32]=n.browserExtensionChecklistProgress,t[33]=y.length,t[34]=w):w=t[34];let T;t[35]===w?T=t[36]:(T=(0,Z.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:w}),t[35]=w,t[36]=T);let E;t[37]!==T||t[38]!==C?(E=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[C,T]}),t[37]=T,t[38]=C,t[39]=E):E=t[39];let D;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==y?(D=(0,Z.jsx)(`ol`,{className:`flex flex-col gap-3`,children:y.map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex gap-2.5`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:e.done?(0,Z.jsx)(V,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,Z.jsx)(W,{className:`size-4 text-fg-subtle`,strokeWidth:1.75})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:i(`text-[11px] leading-relaxed`,e.done?`text-fg-muted line-through decoration-fg-subtle/60`:`text-fg`),children:[(0,Z.jsxs)(`span`,{className:`sr-only`,children:[e.done?n.browserExtensionChecklistDone:n.browserExtensionChecklistPending,` `]}),t+1,`. `,e.label]}),e.detail]})]},e.id))}),t[40]=n.browserExtensionChecklistDone,t[41]=n.browserExtensionChecklistPending,t[42]=y,t[43]=D):D=t[43];let O;return t[44]!==n.browserExtensionInstallGuideTitle||t[45]!==E||t[46]!==D?(O=(0,Z.jsxs)(`div`,{"aria-label":S,className:`rounded-xl border border-edge bg-surface-base px-3 py-3`,children:[E,D]}),t[44]=n.browserExtensionInstallGuideTitle,t[45]=E,t[46]=D,t[47]=O):O=t[47],O}function Ye(e){return e.done}var Xe=19820,Ze=3e4;function Qe({m:e,probe:t,artifacts:n,onChange:r,startBridge:i,stopBridge:a,disconnectExtension:o,installArtifacts:s,refetchArtifacts:c,openExtensionChrome:l,revealExtensionFolder:u,form:p,embedded:m=!1}){let[h,g]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(null),[x,C]=(0,Y.useState)(null),T=p.port??Xe,E=p.host||`127.0.0.1`,D=`ws://${E}:${T}/browser-ext`,k=t.kind===`ok`&&t.data.running,j=t.kind===`ok`&&t.data.connected,M=t.kind===`ok`&&t.data.bridgeHeld===!0,N=t.kind===`ok`&&t.data.portConflict===!0,P=k||M,F=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,I=F?.installed===!0,L=F?.extensionDir,R=F?.needsChromeReload===!0,z=t.kind===`ok`?j?{icon:S,color:`text-green-500`,label:e.browserExtensionConnected}:k?{icon:_,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:A,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:A,color:`text-fg-muted`,label:`…`},B=z.icon,V=(0,Y.useCallback)(async()=>{if(!h){g(`start`),y(null);try{await i({host:E,port:T})}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,E,T,i]),U=(0,Y.useCallback)(async()=>{if(!h){g(`stop`),y(null);try{await a()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,a]),ee=(0,Y.useCallback)(async()=>{if(!h){g(`disconnect`),y(null);try{await o()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,o]),W=(0,Y.useCallback)(async()=>{if(!h){g(`install`),y(null),C(null);try{let t=await s({force:I});t?.extensionDir?C(`${e.browserExtensionInstalled}: ${t.extensionDir}`):C(e.browserExtensionInstalled),await c()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,s,I,e.browserExtensionInstalled,c]),te=(0,Y.useCallback)(async()=>{if(!h){g(`open`),y(null);try{await l()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,l]),ne=(0,Y.useCallback)(async()=>{if(!(!L||h)){g(`path`),y(null),C(null);try{await f(L)?d({type:`success`,title:e.browserExtensionPathCopied}):C(e.browserExtensionPathCopyFailed)}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,L,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),re=(0,Y.useCallback)(async()=>{if(!(!L||h)){g(`folder`),y(null),C(null);try{await u(),d({type:`success`,title:e.browserExtensionFolderOpened})}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,L,e.browserExtensionFolderOpened,u]),ie=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void W(),children:[h===`install`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(O,{className:`size-3.5`}),h===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),P?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void U(),children:[h===`stop`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(H,{className:`size-3.5`}),e.browserExtensionStopBridge]}):(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void V(),children:[h===`start`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(b,{className:`size-3.5`}),h===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),j?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void ee(),children:[h===`disconnect`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(A,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,Z.jsx)(Fe,{icon:w,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:m,primaryAction:ie,advancedTitle:e.browserAdvancedShow,advanced:(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserExtensionPort,description:e.desc.browserExtensionPort,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1024,max:65535,value:p.port??``,placeholder:String(Xe),onChange:e=>{let t=e.target.value;r({port:t===``?void 0:Number.parseInt(t,10)})}})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionHost,description:e.desc.browserExtensionHost,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:p.host,placeholder:`127.0.0.1`,onChange:e=>r({host:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionConnectionTimeout,description:e.desc.browserExtensionConnectionTimeout,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1,step:1,value:p.connectionTimeoutMs==null?``:Math.round(p.connectionTimeoutMs/1e3),placeholder:String(Ze/1e3),onChange:e=>{let t=e.target.value;r({connectionTimeoutMs:t===``?void 0:Math.max(1,Number.parseInt(t,10))*1e3})}})})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:D}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${z.color}`,children:[(0,Z.jsx)(B,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:z.label})]})]}),(0,Z.jsx)(Je,{m:e,installed:I,extensionDir:L,connected:j,busy:h!==null,pathBusy:h===`path`,folderBusy:h===`folder`,onOpenChrome:()=>void te(),onCopyPath:()=>void ne(),onRevealFolder:()=>void re()}),R?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionNeedsChromeReload}):null,N?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionPortConflict.replace(`{{port}}`,String(T))}):null,x?(0,Z.jsx)(Le,{kind:`success`,message:x}):null,v?(0,Z.jsx)(Le,{kind:`error`,message:v}):null]})})}function $e(e){let t=(0,X.c)(41),{m:n,doctor:r,refetch:i,applyDoctor:a,installStream:o,embedded:s}=e,c=s===void 0?!1:s,[l,u]=(0,Y.useState)(`idle`),[d,f]=(0,Y.useState)(null),{progress:p,running:m,cancelling:h,run:g,reset:_,cancel:v}=o,y;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==_||t[5]!==g?(y=async()=>{u(`installing`),f(null),_();let e=await g({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){u(`installing`);return}if(e.error===`cancelled`){u(`idle`),f(null),_();return}u(`failed`),f(e.errorMessage??n.browserPlaywrightInstallFailed);return}e.payload&&a?.(e.payload),u(`installed`),f(e.payload?.executablePath?`${n.browserPlaywrightInstalled}: ${e.payload.executablePath}`:n.browserPlaywrightInstalled),await i()},t[0]=a,t[1]=n.browserPlaywrightInstallFailed,t[2]=n.browserPlaywrightInstalled,t[3]=i,t[4]=_,t[5]=g,t[6]=y):y=t[6];let b=y,S=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,C=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,w=r.kind===`ok`&&r.data.installed,E=l===`installing`||m,D;t[7]===b?D=t[8]:(D=()=>void b(),t[7]=b,t[8]=D);let k;t[9]!==w||t[10]!==E||t[11]!==l?(k=E?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):w?(0,Z.jsx)(T,{className:`size-3.5`}):l===`installed`?(0,Z.jsx)(V,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(O,{className:`size-3.5`}),t[9]=w,t[10]=E,t[11]=l,t[12]=k):k=t[12];let A=E?n.browserPlaywrightInstalling:w?n.browserReinstall:n.browserPlaywrightInstall,j;t[13]!==E||t[14]!==D||t[15]!==k||t[16]!==A?(j=(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:E,onClick:D,children:[k,A]}),t[13]=E,t[14]=D,t[15]=k,t[16]=A,t[17]=j):j=t[17];let M;t[18]===n.browserPlaywrightManualInstall?M=t[19]:(M=(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=M);let N;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(`code`,{className:`mt-2 block w-fit rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg`,children:`node node_modules/playwright-core/cli.js install chromium`}),t[20]=N):N=t[20];let P;t[21]===M?P=t[22]:(P=(0,Z.jsxs)(`div`,{className:`text-xs`,children:[M,N]}),t[21]=M,t[22]=P);let F;t[23]!==v||t[24]!==h||t[25]!==n||t[26]!==p||t[27]!==m?(F=m?(0,Z.jsx)(Ve,{m:n,progress:p,showLogs:!0,cancelling:h,onCancel:()=>void v()}):null,t[23]=v,t[24]=h,t[25]=n,t[26]=p,t[27]=m,t[28]=F):F=t[28];let I;t[29]!==d||t[30]!==l?(I=d?(0,Z.jsx)(Le,{kind:l===`failed`?`error`:`success`,message:d}):null,t[29]=d,t[30]=l,t[31]=I):I=t[31];let L;return t[32]!==c||t[33]!==n||t[34]!==C||t[35]!==S||t[36]!==F||t[37]!==I||t[38]!==j||t[39]!==P?(L=(0,Z.jsxs)(Fe,{icon:x,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:S,statusDetail:C,m:n,embedded:c,primaryAction:j,children:[P,F,I]}),t[32]=c,t[33]=n,t[34]=C,t[35]=S,t[36]=F,t[37]=I,t[38]=j,t[39]=P,t[40]=L):L=t[40],L}async function et(e){let t=await u(e),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1){let e=typeof n.error==`string`?n.error:n.error?.message;throw Error(e||`Request failed: ${t.status}`)}if(n.payload===void 0)throw Error(`Empty payload`);return n.payload}async function $(e,t){let n=await u(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1){let e=typeof r.error==`string`?r.error:r.error?.message;throw Error(e||`Request failed: ${n.status}`)}if(r.payload===void 0)throw Error(`Empty payload`);return r.payload}var tt={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function nt(e,t){switch(t.type){case`playwright`:return{...e,playwright:t.state};case`cloak`:return{...e,cloak:t.state};case`extension`:return{...e,extension:t.state};case`extension-artifacts`:return{...e,extensionArtifacts:t.state};case`playwright-idle`:return{...e,playwright:{kind:`idle`}};case`cloak-idle`:return{...e,cloak:{kind:`idle`}};case`extension-idle`:return{...e,extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};case`extension-start-probe`:return{...e,extension:e.extension.kind===`ok`?e.extension:{kind:`loading`}};case`extension-artifacts-start-probe`:return{...e,extensionArtifacts:e.extensionArtifacts.kind===`ok`?e.extensionArtifacts:{kind:`loading`}}}}function rt(e){let[t,n]=(0,Y.useReducer)(nt,tt),{playwright:r,cloak:i,extension:a,extensionArtifacts:o}=t,s=(0,Y.useCallback)(async()=>{n({type:`playwright`,state:{kind:`loading`}});try{n({type:`playwright`,state:{kind:`ok`,data:await et(c(`/api/browser/playwright/doctor`))}})}catch(e){n({type:`playwright`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[]),l=(0,Y.useCallback)(async t=>{n({type:`cloak`,state:{kind:`loading`}});let r=(t?.cacheDir??e.cacheDir??``).trim(),i=(t?.binaryPath??e.binaryPath??``).trim(),a=new URLSearchParams;r&&a.set(`cacheDir`,r),i&&a.set(`binaryPath`,i);try{let e=await et(c(`/api/browser/cloakbrowser/doctor${a.size?`?${a}`:``}`));return n({type:`cloak`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`cloak`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[e.binaryPath,e.cacheDir]),d=(0,Y.useCallback)(e=>{n({type:`playwright`,state:{kind:`ok`,data:e}})},[]),f=(0,Y.useCallback)(e=>{n({type:`cloak`,state:{kind:`ok`,data:e}})},[]),p=(0,Y.useCallback)(async()=>et(c(`/api/browser/cloakbrowser/status`)),[]),m=(0,Y.useCallback)(async()=>$(c(`/api/browser/cloakbrowser/launch`),{}),[]),h=e.browserEnabled===!0&&e.probeExtension===!0,g=e.browserEnabled===!0&&e.probeLocal===!0,_=e.browserEnabled===!0&&e.probeCloak===!0,{extensionHost:v,extensionPort:y}=e,b=(0,Y.useCallback)(async()=>{let e=new URLSearchParams({probe:`1`});v&&e.set(`host`,v),y!==void 0&&e.set(`port`,String(y)),n({type:`extension-start-probe`});try{let t=await u(c(`/api/browser/extension-status?${e}`),{signal:AbortSignal.timeout(3e3)}),r=await t.json().catch(()=>({}));if(!t.ok){n({type:`extension`,state:{kind:`error`,message:`HTTP ${t.status}`}});return}n({type:`extension`,state:{kind:`ok`,data:{running:r.running===!0,connected:r.connected===!0,backend:r.backend,artifacts:r.artifacts,bridgeHeld:r.bridgeHeld===!0,refCount:typeof r.refCount==`number`?r.refCount:void 0,manualBridge:r.manualBridge===!0,portConflict:r.portConflict===!0}}})}catch(e){n({type:`extension`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[v,y]),x=(0,Y.useCallback)(async()=>{n({type:`extension-artifacts-start-probe`});try{let e=await et(c(`/api/browser/extension/doctor`));return n({type:`extension-artifacts`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`extension-artifacts`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[]),S=(0,Y.useCallback)(async e=>{let t=(await $(c(`/api/browser/extension/install`),{force:e?.force??!1})).doctor;return n({type:`extension-artifacts`,state:{kind:`ok`,data:t}}),await b(),t},[b]),C=(0,Y.useCallback)(async()=>{await $(c(`/api/browser/extension/open`),{action:`chrome`})},[]),w=(0,Y.useCallback)(async()=>{await $(c(`/api/browser/extension/open`),{action:`folder`})},[]);(0,Y.useEffect)(()=>{if(!g){n({type:`playwright-idle`});return}s()},[g,s]),(0,Y.useEffect)(()=>{if(!_){n({type:`cloak-idle`});return}l()},[_,l]);let T=(0,Y.useRef)(h);T.current!==h&&(T.current=h,h||n({type:`extension-idle`})),(0,Y.useEffect)(()=>{if(!h)return;b(),x();let e=setInterval(()=>void b(),5e3);return()=>clearInterval(e)},[h,b,x]);let E=(0,Y.useCallback)(async e=>{await $(c(`/api/browser/extension/start`),{host:e?.host??v,port:e?.port??y}),await b()},[v,y,b]),D=(0,Y.useCallback)(async()=>{await $(c(`/api/browser/extension/stop`),{}),await b()},[b]),O=(0,Y.useCallback)(async()=>{await $(c(`/api/browser/extension/disconnect`),{}),await b()},[b]),k=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(!h||e.activeBackend!==`extension`){k.current=null;return}if(a.kind!==`ok`||a.data.running||a.data.bridgeHeld)return;let t=`${v}:${y??19820}`;k.current!==t&&(k.current=t,E({host:v,port:y}).catch(()=>{k.current=null}))},[h,a,v,y,e.activeBackend,E]),{playwright:r,cloak:i,extension:a,extensionArtifacts:o,refetchPlaywright:s,applyPlaywrightDoctor:d,refetchCloak:l,applyCloakDoctor:f,fetchCloakRuntimeStatus:p,launchCloak:m,refetchExtension:b,refetchExtensionArtifacts:x,installExtensionArtifacts:S,openExtensionChrome:C,revealExtensionFolder:w,pingCdp:(0,Y.useCallback)(async e=>$(c(`/api/browser/cdp/ping`),{cdpUrl:e}),[]),testCloud:(0,Y.useCallback)(async(e,t)=>$(c(`/api/browser/cloud/test-connection`),{provider:e,apiKey:t}),[]),launchCdp:(0,Y.useCallback)(async e=>$(c(`/api/browser/cdp/launch`),{executablePath:e}),[]),stopCdp:(0,Y.useCallback)(async e=>{await $(c(`/api/browser/cdp/stop`),{port:e})},[]),listCdpInstances:(0,Y.useCallback)(async()=>(await et(c(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var it=`
|
|
3
|
-
|
|
4
|
-
`,at=/\r\n/g,ot={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},st={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},ct=8;function lt(){return{phase:null,message:null,percent:null,lines:[]}}function ut(e,t){let n={phase:t.phase,message:t.message??t.line??e.message,percent:t.percent??e.percent,lines:e.lines};if(t.line){let r=[...e.lines,t.line];n.lines=r.length>ct?r.slice(-8):r}return n}async function dt(e,t,n){let r=e.getReader(),i=new TextDecoder,a=``,o=null,s=e=>{let n=``,r=``;for(let t of e.split(`
|
|
5
|
-
`)){let e=t.replace(/\r$/,``);e.startsWith(`event:`)?n=e.slice(6).trim():e.startsWith(`data:`)&&(r+=e.slice(5).trimStart())}if(r){if(n===`progress`){try{let e=JSON.parse(r);e&&typeof e==`object`&&typeof e.phase==`string`&&t(e)}catch{}return}if(n===`result`)try{let e=JSON.parse(r);o=e.ok?{ok:!0,payload:e.payload}:{ok:!1,error:String(e.error??`unknown`),message:typeof e.message==`string`?e.message:void 0,status:e.error===`busy`?409:e.error===`cancelled`?499:500}}catch{o={ok:!1,error:`parse`,status:0}}}};try{let e=async()=>{if(o!==null)return o;if(n?.aborted)return await r.cancel().catch(()=>{}),{ok:!1,error:`cancelled`,status:499};let{done:t,value:c}=await r.read();if(t)return o??{ok:!1,error:`no-result`,status:0};a+=i.decode(c,{stream:!0}),a=a.replace(at,`
|
|
6
|
-
`);let l=a.split(it);a=l.pop()??``;for(let e of l)e.length&&s(e);return e()},t=await e();if(t)return t}catch(e){if(n?.aborted||e instanceof DOMException&&e.name===`AbortError`)return{ok:!1,error:`cancelled`,status:499};throw e}finally{r.releaseLock()}return o||(n?.aborted?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`no-result`,status:0})}function ft(e){let[t,n]=(0,Y.useState)(lt),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),s=(0,Y.useRef)(!1),l=(0,Y.useRef)(null),d=(0,Y.useCallback)(()=>{s.current||n(lt())},[]),f=(0,Y.useCallback)(async()=>{if(s.current){o(!0);try{await u(c(st[e]),{method:`POST`}).catch(()=>{}),l.current?.abort()}finally{o(!1)}}},[e]);return{progress:t,running:r,cancelling:a,run:(0,Y.useCallback)(async t=>{if(s.current)return{ok:!1,error:`busy`,status:409,errorMessage:`An install for this browser type is already in progress.`};let r=new AbortController;l.current=r,s.current=!0,i(!0),n(lt());try{let i=await u(c(ot[e]),{method:`POST`,headers:{Accept:`text/event-stream`,...t.body===void 0?{}:{"Content-Type":`application/json`}},body:t.body===void 0?void 0:JSON.stringify(t.body),signal:r.signal});if(!i.ok||!i.body){let e=await i.text().catch(()=>``),t=`HTTP ${i.status}`;try{let n=JSON.parse(e);typeof n.message==`string`?t=n.message:typeof n.error==`string`&&(t=n.error)}catch{e&&(t=e.slice(0,500))}return{ok:!1,error:i.status===409?`busy`:`http`,status:i.status,errorMessage:t}}let a=await dt(i.body,e=>{n(t=>ut(t,e))},r.signal);return a.ok?a:a.error===`cancelled`?{...a,errorMessage:void 0}:{...a,errorMessage:a.message??(a.error===`busy`?`An install for this browser type is already in progress.`:t.fallbackError)}}catch(e){return r.signal.aborted||e instanceof DOMException&&e.name===`AbortError`?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`network`,errorMessage:e instanceof Error?e.message:t.fallbackError}}finally{l.current===r&&(l.current=null),s.current=!1,i(!1),o(!1)}},[e]),reset:d,cancel:f}}function pt(e){let t=(0,X.c)(150),{a:n,form:r,update:a,activeTab:s,setActiveTab:c}=e,l=o(ht),u=j(mt),d=ft(`playwright`),f=ft(`cloakbrowser`),p=r.browserEnabled&&(s===`overview`||s===`extension`),m=r.browserEnabled&&(s===`overview`||s===`local`),h=r.browserEnabled&&(s===`overview`||s===`cloakbrowser`),_;t[0]!==r.browserBackend||t[1]!==r.browserCloakBinaryPath||t[2]!==r.browserCloakCacheDir||t[3]!==r.browserEnabled||t[4]!==r.browserExtensionHost||t[5]!==r.browserExtensionPort||t[6]!==h||t[7]!==p||t[8]!==m?(_={cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,browserEnabled:r.browserEnabled,activeBackend:r.browserBackend,probeExtension:p,probeLocal:m,probeCloak:h,extensionHost:r.browserExtensionHost,extensionPort:r.browserExtensionPort},t[0]=r.browserBackend,t[1]=r.browserCloakBinaryPath,t[2]=r.browserCloakCacheDir,t[3]=r.browserEnabled,t[4]=r.browserExtensionHost,t[5]=r.browserExtensionPort,t[6]=h,t[7]=p,t[8]=m,t[9]=_):_=t[9];let v=rt(_),y;t[10]===v.playwright?y=t[11]:(y=Ee(v.playwright),t[10]=v.playwright,t[11]=y);let b=y,S;t[12]===v.cloak?S=t[13]:(S=Ee(v.cloak),t[12]=v.cloak,t[13]=S);let C=S,T;t[14]===v.extension?T=t[15]:(T=Oe(v.extension),t[14]=v.extension,t[15]=T);let E=T,D;t[16]!==n||t[17]!==v.extension?(D=ke(v.extension,n),t[16]=n,t[17]=v.extension,t[18]=D):D=t[18];let O=D,A;t[19]!==n||t[20]!==C||t[21]!==E||t[22]!==O||t[23]!==b||t[24]!==u?(A=[{value:`extension`,icon:w,name:n.browserBackendExtension,tagline:n.browserModeExtTagline,status:E,statusLabel:O},{value:`local`,icon:x,name:n.browserBackendLocal,tagline:n.browserModeLocalTagline,status:b,statusLabel:De(b,n)},{value:`cloakbrowser`,icon:R,name:n.browserBackendCloakBrowser,tagline:n.browserModeCloakTagline,status:C,statusLabel:De(C,n)},{value:`cdp`,icon:k,name:n.browserBackendCdp,tagline:n.browserModeCdpTagline},{value:`cloud`,icon:M,name:n.browserBackendCloud,tagline:n.browserModeCloudTagline}].filter(e=>pe(e.value,u)),t[19]=n,t[20]=C,t[21]=E,t[22]=O,t[23]=b,t[24]=u,t[25]=A):A=t[25];let N=A,P;t[26]!==c||t[27]!==a?(P=e=>{a({browserEnabled:!0,browserBackend:e}),c(e)},t[26]=c,t[27]=a,t[28]=P):P=t[28];let F=P,I=!r.browserEnabled&&`pointer-events-none opacity-40`,L;t[29]===I?L=t[30]:(L=i(`flex flex-col gap-5 transition-opacity`,I),t[29]=I,t[30]=L);let z=!r.browserEnabled,B;t[31]!==n||t[32]!==s||t[33]!==v.disconnectExtension||t[34]!==v.extension||t[35]!==v.extensionArtifacts||t[36]!==v.installExtensionArtifacts||t[37]!==v.openExtensionChrome||t[38]!==v.refetchExtensionArtifacts||t[39]!==v.revealExtensionFolder||t[40]!==v.startExtensionBridge||t[41]!==v.stopExtensionBridge||t[42]!==r.browserExtensionConnectionTimeout||t[43]!==r.browserExtensionHost||t[44]!==r.browserExtensionPort||t[45]!==a?(B=s===`extension`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Qe,{embedded:!0,m:n,probe:v.extension,artifacts:v.extensionArtifacts,form:{port:r.browserExtensionPort,host:r.browserExtensionHost,connectionTimeoutMs:r.browserExtensionConnectionTimeout},onChange:e=>a({...e.port===void 0?{}:{browserExtensionPort:e.port},...e.host===void 0?{}:{browserExtensionHost:e.host},...e.connectionTimeoutMs===void 0?{}:{browserExtensionConnectionTimeout:e.connectionTimeoutMs}}),startBridge:v.startExtensionBridge,stopBridge:v.stopExtensionBridge,disconnectExtension:v.disconnectExtension,installArtifacts:v.installExtensionArtifacts,refetchArtifacts:v.refetchExtensionArtifacts,openExtensionChrome:v.openExtensionChrome,revealExtensionFolder:v.revealExtensionFolder})}):null,t[31]=n,t[32]=s,t[33]=v.disconnectExtension,t[34]=v.extension,t[35]=v.extensionArtifacts,t[36]=v.installExtensionArtifacts,t[37]=v.openExtensionChrome,t[38]=v.refetchExtensionArtifacts,t[39]=v.revealExtensionFolder,t[40]=v.startExtensionBridge,t[41]=v.stopExtensionBridge,t[42]=r.browserExtensionConnectionTimeout,t[43]=r.browserExtensionHost,t[44]=r.browserExtensionPort,t[45]=a,t[46]=B):B=t[46];let V;t[47]!==n||t[48]!==s||t[49]!==v.applyPlaywrightDoctor||t[50]!==v.playwright||t[51]!==v.refetchPlaywright||t[52]!==d?(V=s===`local`?(0,Z.jsx)(q,{children:(0,Z.jsx)($e,{embedded:!0,m:n,doctor:v.playwright,refetch:v.refetchPlaywright,applyDoctor:v.applyPlaywrightDoctor,installStream:d})}):null,t[47]=n,t[48]=s,t[49]=v.applyPlaywrightDoctor,t[50]=v.playwright,t[51]=v.refetchPlaywright,t[52]=d,t[53]=V):V=t[53];let H;t[54]!==n||t[55]!==s||t[56]!==f||t[57]!==v.applyCloakDoctor||t[58]!==v.cloak||t[59]!==v.fetchCloakRuntimeStatus||t[60]!==v.launchCloak||t[61]!==v.refetchCloak||t[62]!==r.browserCloakBinaryPath||t[63]!==r.browserCloakCacheDir||t[64]!==r.browserCloakExtraArgs||t[65]!==r.browserCloakFingerprintPlatform||t[66]!==r.browserCloakKeepOpen||t[67]!==r.browserCloakLocale||t[68]!==r.browserCloakTemporaryProfile||t[69]!==r.browserCloakTimezone||t[70]!==r.browserCloakWebrtcIp||t[71]!==r.browserHumanPreset||t[72]!==r.browserHumanize||t[73]!==a?(H=s===`cloakbrowser`?(0,Z.jsx)(q,{children:(0,Z.jsx)(We,{embedded:!0,m:n,doctor:v.cloak,refetch:v.refetchCloak,applyDoctor:v.applyCloakDoctor,installStream:f,fetchRuntimeStatus:v.fetchCloakRuntimeStatus,launchCloak:v.launchCloak,form:{cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,keepOpen:r.browserCloakKeepOpen,temporaryProfile:r.browserCloakTemporaryProfile,humanize:r.browserHumanize,humanPreset:r.browserHumanPreset,timezone:r.browserCloakTimezone,locale:r.browserCloakLocale,webrtcIp:r.browserCloakWebrtcIp,fingerprintPlatform:r.browserCloakFingerprintPlatform,extraArgs:r.browserCloakExtraArgs},onChange:e=>a({...e.cacheDir===void 0?{}:{browserCloakCacheDir:e.cacheDir},...e.binaryPath===void 0?{}:{browserCloakBinaryPath:e.binaryPath},...e.keepOpen===void 0?{}:{browserCloakKeepOpen:e.keepOpen},...e.temporaryProfile===void 0?{}:{browserCloakTemporaryProfile:e.temporaryProfile},...e.humanize===void 0?{}:{browserHumanize:e.humanize},...e.humanPreset===void 0?{}:{browserHumanPreset:e.humanPreset},...e.timezone===void 0?{}:{browserCloakTimezone:e.timezone},...e.locale===void 0?{}:{browserCloakLocale:e.locale},...e.webrtcIp===void 0?{}:{browserCloakWebrtcIp:e.webrtcIp},...e.fingerprintPlatform===void 0?{}:{browserCloakFingerprintPlatform:e.fingerprintPlatform},...e.extraArgs===void 0?{}:{browserCloakExtraArgs:e.extraArgs}})})}):null,t[54]=n,t[55]=s,t[56]=f,t[57]=v.applyCloakDoctor,t[58]=v.cloak,t[59]=v.fetchCloakRuntimeStatus,t[60]=v.launchCloak,t[61]=v.refetchCloak,t[62]=r.browserCloakBinaryPath,t[63]=r.browserCloakCacheDir,t[64]=r.browserCloakExtraArgs,t[65]=r.browserCloakFingerprintPlatform,t[66]=r.browserCloakKeepOpen,t[67]=r.browserCloakLocale,t[68]=r.browserCloakTemporaryProfile,t[69]=r.browserCloakTimezone,t[70]=r.browserCloakWebrtcIp,t[71]=r.browserHumanPreset,t[72]=r.browserHumanize,t[73]=a,t[74]=H):H=t[74];let U;t[75]!==n||t[76]!==s||t[77]!==v.launchCdp||t[78]!==v.listCdpInstances||t[79]!==v.pingCdp||t[80]!==v.stopCdp||t[81]!==r.browserCdpUrl||t[82]!==a?(U=s===`cdp`?(0,Z.jsx)(q,{children:(0,Z.jsx)(ze,{embedded:!0,m:n,cdpUrl:r.browserCdpUrl,onCdpUrlChange:e=>a({browserCdpUrl:e}),launch:v.launchCdp,stop:v.stopCdp,listInstances:v.listCdpInstances,ping:v.pingCdp})}):null,t[75]=n,t[76]=s,t[77]=v.launchCdp,t[78]=v.listCdpInstances,t[79]=v.pingCdp,t[80]=v.stopCdp,t[81]=r.browserCdpUrl,t[82]=a,t[83]=U):U=t[83];let ee;t[84]!==n||t[85]!==s||t[86]!==v.testCloud||t[87]!==r.browserCloudApiKey||t[88]!==r.browserCloudProjectId||t[89]!==r.browserCloudProvider||t[90]!==r.browserCloudRegion||t[91]!==a?(ee=s===`cloud`?(0,Z.jsx)(q,{children:(0,Z.jsx)(qe,{embedded:!0,m:n,form:{provider:r.browserCloudProvider,apiKey:r.browserCloudApiKey,projectId:r.browserCloudProjectId,region:r.browserCloudRegion},onChange:e=>a({...e.provider===void 0?{}:{browserCloudProvider:e.provider},...e.apiKey===void 0?{}:{browserCloudApiKey:e.apiKey},...e.projectId===void 0?{}:{browserCloudProjectId:e.projectId},...e.region===void 0?{}:{browserCloudRegion:e.region}}),testCloud:v.testCloud})}):null,t[84]=n,t[85]=s,t[86]=v.testCloud,t[87]=r.browserCloudApiKey,t[88]=r.browserCloudProjectId,t[89]=r.browserCloudProvider,t[90]=r.browserCloudRegion,t[91]=a,t[92]=ee):ee=t[92];let W;t[93]!==B||t[94]!==V||t[95]!==H||t[96]!==U||t[97]!==ee||t[98]!==L||t[99]!==z?(W=(0,Z.jsxs)(`div`,{className:L,"aria-hidden":z,children:[B,V,H,U,ee]}),t[93]=B,t[94]=V,t[95]=H,t[96]=U,t[97]=ee,t[98]=L,t[99]=z,t[100]=W):W=t[100];let G=W;if(s===`overview`){let e;t[101]!==n||t[102]!==r.browserEnabled||t[103]!==F?(e=r.browserEnabled?null:(0,Z.jsx)(we,{m:n,onStart:F}),t[101]=n,t[102]=r.browserEnabled,t[103]=F,t[104]=e):e=t[104];let o;t[105]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,"aria-hidden":!0,children:(0,Z.jsx)(g,{className:`size-4`,strokeWidth:1.75})}),t[105]=o):o=t[105];let s;t[106]===a?s=t[107]:(s=e=>a({browserEnabled:e.target.checked}),t[106]=a,t[107]=s);let u;t[108]!==r.browserEnabled||t[109]!==s?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserEnabled,onChange:s}),t[108]=r.browserEnabled,t[109]=s,t[110]=u):u=t[110];let d;t[111]===n.browserEnabledOn?d=t[112]:(d=(0,Z.jsx)(`span`,{children:n.browserEnabledOn}),t[111]=n.browserEnabledOn,t[112]=d);let f;t[113]!==u||t[114]!==d?(f=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[u,d]}),t[113]=u,t[114]=d,t[115]=f):f=t[115];let p;t[116]!==n.desc.browserEnabled||t[117]!==n.label.browserEnabled||t[118]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[o,(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Q,{label:n.label.browserEnabled,description:n.desc.browserEnabled,children:f})})]}),t[116]=n.desc.browserEnabled,t[117]=n.label.browserEnabled,t[118]=f,t[119]=p):p=t[119];let m;t[120]!==n.browserDocsLink||t[121]!==l?(m=(0,Z.jsx)(Se,{language:l,label:n.browserDocsLink,className:`shrink-0 pt-1`}),t[120]=n.browserDocsLink,t[121]=l,t[122]=m):m=t[122];let h;t[123]!==p||t[124]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[123]=p,t[124]=m,t[125]=h):h=t[125];let _;t[126]!==n||t[127]!==r.browserBackend||t[128]!==r.browserEnabled||t[129]!==N||t[130]!==c||t[131]!==a?(_=r.browserEnabled?(0,Z.jsx)(`div`,{id:ye(`connection`),className:i(`scroll-mt-24 transition-opacity`,!r.browserEnabled&&`pointer-events-none opacity-40`),children:(0,Z.jsx)(_e,{m:n,value:r.browserBackend,onChange:e=>a({browserBackend:e}),onOpenConfig:c,options:N})}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.browserDisabledHint}),t[126]=n,t[127]=r.browserBackend,t[128]=r.browserEnabled,t[129]=N,t[130]=c,t[131]=a,t[132]=_):_=t[132];let v;t[133]!==h||t[134]!==_?(v=(0,Z.jsx)(q,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,_]})}),t[133]=h,t[134]=_,t[135]=v):v=t[135];let y=!r.browserEnabled&&`pointer-events-none opacity-40`,b;t[136]===y?b=t[137]:(b=i(`transition-opacity`,y),t[136]=y,t[137]=b);let x=!r.browserEnabled,S;t[138]!==n||t[139]!==r||t[140]!==a?(S=(0,Z.jsx)(xe,{a:n,form:r,update:a}),t[138]=n,t[139]=r,t[140]=a,t[141]=S):S=t[141];let C;t[142]!==b||t[143]!==x||t[144]!==S?(C=(0,Z.jsx)(ae,{children:(0,Z.jsx)(`div`,{className:b,"aria-hidden":x,children:S})}),t[142]=b,t[143]=x,t[144]=S,t[145]=C):C=t[145];let w;return t[146]!==e||t[147]!==v||t[148]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e,v,C]}),t[146]=e,t[147]=v,t[148]=C,t[149]=w):w=t[149],w}return Pe(s)?G:null}function mt(e){return e.mode}function ht(e){return e.language}function gt(e){let t=(0,X.c)(57),{sectionId:n,intro:r,vm:i,children:s,tabbed:c}=e,l=c===void 0?!1:c,u=o(_t),d;t[0]===u?d=t[1]:(d=a(u),t[0]=u,t[1]=d);let f=d,m=f.agentSettings,h=f.settingsSections[n]??n;if(!i.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(v,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===h?n=t[4]:(n=(0,Z.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:h}),t[3]=h,t[4]=n);let r;t[5]===m.needToken?r=t[6]:(r=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:m.needToken}),t[5]=m.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,Z.jsx)(le,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,Z.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(i.loading){let e,n;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),n=(0,Z.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),t[10]=e,t[11]=n):(e=t[10],n=t[11]);let r;return t[12]===f.logs.loading?r=t[13]:(r=(0,Z.jsxs)(le,{gap:`gap-0`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[e,n,(0,Z.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:f.logs.loading})]}),t[12]=f.logs.loading,t[13]=r),r}if(!i.form){let e=i.error??i.fetchError??m.loadError,n;t[14]===e?n=t[15]:(n=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[14]=e,t[15]=n);let r;t[16]===i?r=t[17]:(r=()=>void i.mutate(),t[16]=i,t[17]=r);let a;t[18]!==f.logs.refresh||t[19]!==r?(a=(0,Z.jsx)(p,{type:`button`,variant:`secondary`,onClick:r,children:f.logs.refresh}),t[18]=f.logs.refresh,t[19]=r,t[20]=a):a=t[20];let o;return t[21]!==n||t[22]!==a?(o=(0,Z.jsxs)(le,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[21]=n,t[22]=a,t[23]=o):o=t[23],o}let g=l?void 0:r,_;t[24]===m.sectionDesc?_=t[25]:(_=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:m.sectionDesc}),t[24]=m.sectionDesc,t[25]=_);let y;t[26]!==m.saved||t[27]!==i.dirty||t[28]!==i.saveOk?(y=i.saveOk&&!i.dirty?(0,Z.jsx)(`span`,{className:`text-sm text-fg-muted`,role:`status`,children:m.saved}):null,t[26]=m.saved,t[27]=i.dirty,t[28]=i.saveOk,t[29]=y):y=t[29];let b=!i.dirty||i.saving,x;t[30]!==m.discard||t[31]!==b||t[32]!==i.discard?(x=(0,Z.jsx)(p,{type:`button`,variant:`secondary`,disabled:b,onClick:i.discard,children:m.discard}),t[30]=m.discard,t[31]=b,t[32]=i.discard,t[33]=x):x=t[33];let S=!i.dirty||i.saving,C;t[34]===i?C=t[35]:(C=()=>void i.save(),t[34]=i,t[35]=C);let w=i.saving?m.saving:m.save,T;t[36]!==S||t[37]!==C||t[38]!==w?(T=(0,Z.jsx)(p,{type:`button`,variant:`primary`,disabled:S,onClick:C,children:w}),t[36]=S,t[37]=C,t[38]=w,t[39]=T):T=t[39];let E;t[40]!==T||t[41]!==y||t[42]!==x?(E=(0,Z.jsxs)(Z.Fragment,{children:[y,x,T]}),t[40]=T,t[41]=y,t[42]=x,t[43]=E):E=t[43];let D;t[44]!==h||t[45]!==E||t[46]!==g||t[47]!==_?(D=(0,Z.jsx)(se,{title:h,subtitle:g,meta:_,actions:E}),t[44]=h,t[45]=E,t[46]=g,t[47]=_,t[48]=D):D=t[48];let O;t[49]===i.error?O=t[50]:(O=i.error?(0,Z.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:i.error}):null,t[49]=i.error,t[50]=O);let k;t[51]===s?k=t[52]:(k=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:s}),t[51]=s,t[52]=k);let A;return t[53]!==D||t[54]!==O||t[55]!==k?(A=(0,Z.jsxs)(le,{gap:`gap-6`,children:[D,O,k]}),t[53]=D,t[54]=O,t[55]=k,t[56]=A):A=t[56],A}function _t(e){return e.language}var vt={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},yt={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},bt={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},xt={summaryModel:``},St={enabled:!1,memoryNudgeInterval:10,skillNudgeInterval:10,maxToolRounds:8,maxHistoryMessages:80,maxDurationMs:12e4},Ct={model:``,maxLength:void 0};function wt(e){if(!e)return``;if(typeof e==`string`)return e;if(typeof e==`object`&&!Array.isArray(e)){let t=e.primary;return typeof t==`string`?t:``}return``}function Tt(e){if(typeof e!=`object`||!e||!(`fallbacks`in e))return[];let t=e.fallbacks;return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}function Et(e){return e===!0||e===`true`||e===1}function Dt(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!0,browserHeadless:!1,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserBackend:`extension`,browserCloudProvider:`local`,browserCloudApiKey:``,browserCloudProjectId:``,browserCloudRegion:``,browserCdpUrl:``,browserExtensionPort:void 0,browserExtensionHost:`127.0.0.1`,browserExtensionConnectionTimeout:void 0,browserCloakKeepOpen:!0,browserCloakTemporaryProfile:!1,browserCloakCacheDir:``,browserCloakBinaryPath:``,browserCloakTimezone:``,browserCloakLocale:``,browserCloakWebrtcIp:``,browserCloakFingerprintPlatform:``,browserCloakExtraArgs:``,browserHumanize:!0,browserHumanPreset:`careful`,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};let n=t,r=Et(n.enabled),i=n.headless,a=i===!0||i===`true`||i===1,o=Et(n.allowPrivateUrls),s=typeof n.commandTimeout==`number`&&Number.isFinite(n.commandTimeout)&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,c=n.backend,l=c===`local`||c===`cdp`||c===`cloud`||c===`extension`||c===`cloakbrowser`?c:`extension`,u=n.cloudProvider,d=u===`browserbase`||u===`browser-use`?u:`local`,f=typeof n.cloud==`object`&&n.cloud&&!Array.isArray(n.cloud)?n.cloud:{},p=typeof f.apiKey==`string`?f.apiKey:``,m=typeof f.projectId==`string`?f.projectId:``,h=typeof f.region==`string`?f.region:``,g=typeof n.cdpUrl==`string`?n.cdpUrl:``,_=typeof n.extension==`object`&&n.extension&&!Array.isArray(n.extension)?n.extension:{},v=typeof _.port==`number`&&Number.isFinite(_.port)&&_.port>=1024&&_.port<=65535?Math.floor(_.port):void 0,y=typeof _.host==`string`&&_.host?_.host:`127.0.0.1`,b=typeof _.connectionTimeout==`number`&&Number.isFinite(_.connectionTimeout)&&_.connectionTimeout>=1e3?Math.floor(_.connectionTimeout):void 0,x=typeof n.cloakbrowser==`object`&&n.cloakbrowser&&!Array.isArray(n.cloakbrowser)?n.cloakbrowser:{},S=n.humanPreset==="default"?`default`:`careful`,C=n.dialogPolicy,w=C===`must_respond`||C===`auto_accept`?C:`auto_dismiss`,T=typeof n.dialogTimeoutSeconds==`number`&&Number.isFinite(n.dialogTimeoutSeconds)&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0;return{browserEnabled:r,browserHeadless:a,browserAllowPrivateUrls:o,browserCommandTimeout:s,browserBackend:l,browserCloudProvider:d,browserCloudApiKey:p,browserCloudProjectId:m,browserCloudRegion:h,browserCdpUrl:g,browserExtensionPort:v,browserExtensionHost:y,browserExtensionConnectionTimeout:b,browserCloakKeepOpen:x.keepOpen!==!1,browserCloakTemporaryProfile:x.temporaryProfile===!0,browserCloakCacheDir:typeof x.cacheDir==`string`?x.cacheDir:``,browserCloakBinaryPath:typeof x.binaryPath==`string`?x.binaryPath:``,browserCloakTimezone:typeof x.timezone==`string`?x.timezone:``,browserCloakLocale:typeof x.locale==`string`?x.locale:``,browserCloakWebrtcIp:typeof x.webrtcIp==`string`?x.webrtcIp:``,browserCloakFingerprintPlatform:typeof x.fingerprintPlatform==`string`?x.fingerprintPlatform:``,browserCloakExtraArgs:Array.isArray(x.extraArgs)?x.extraArgs.filter(e=>typeof e==`string`&&e.trim().length>0).join(`
|
|
7
|
-
`):``,browserHumanize:n.humanize!==!1,browserHumanPreset:S,browserDialogPolicy:w,browserDialogTimeout:T}}function Ot(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...vt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:vt.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):vt.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:vt.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):vt.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):vt.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:vt.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):vt.retentionWindow}}function kt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...yt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:yt.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):yt.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:yt.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:yt.tailKeepRatio}}function At(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...bt};let t=e,n=t.provider,r=n===`none`||n===`stub`?n:``,i=t.injectionFrequency,a=i===`every-turn`||i===`first-turn`?i:``;return{enabled:typeof t.enabled==`boolean`?t.enabled:bt.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:bt.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:bt.userProfileEnabled,provider:r,injectionFrequency:a,memoryCharLimit:typeof t.memoryCharLimit==`number`&&t.memoryCharLimit>0?Math.floor(t.memoryCharLimit):void 0,userCharLimit:typeof t.userCharLimit==`number`&&t.userCharLimit>0?Math.floor(t.userCharLimit):void 0,contextCadence:typeof t.contextCadence==`number`&&t.contextCadence>=1?Math.floor(t.contextCadence):void 0,dialecticCadence:typeof t.dialecticCadence==`number`&&t.dialecticCadence>=1?Math.floor(t.dialecticCadence):void 0}}function jt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...xt};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function Mt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...St};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:St.enabled,memoryNudgeInterval:typeof t.memoryNudgeInterval==`number`&&t.memoryNudgeInterval>=0?Math.floor(t.memoryNudgeInterval):St.memoryNudgeInterval,skillNudgeInterval:typeof t.skillNudgeInterval==`number`&&t.skillNudgeInterval>=0?Math.floor(t.skillNudgeInterval):St.skillNudgeInterval,maxToolRounds:typeof t.maxToolRounds==`number`&&t.maxToolRounds>=1&&t.maxToolRounds<=32?Math.floor(t.maxToolRounds):St.maxToolRounds,maxHistoryMessages:typeof t.maxHistoryMessages==`number`&&t.maxHistoryMessages>=10&&t.maxHistoryMessages<=200?Math.floor(t.maxHistoryMessages):St.maxHistoryMessages,maxDurationMs:typeof t.maxDurationMs==`number`&&t.maxDurationMs>=3e4&&t.maxDurationMs<=6e5?Math.floor(t.maxDurationMs):St.maxDurationMs}}function Nt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Ct};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function Pt(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return{enabled:t};let n=e;return{enabled:typeof n.enabled==`boolean`?n.enabled:t}}function Ft(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function It(e){if(e==null)return``;if(typeof e==`string`){let t=e.trim();if(!t)return``;try{let e=JSON.parse(t);if(typeof e==`object`&&e&&!Array.isArray(e))return JSON.stringify(e,null,2)}catch{return t}return``}if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function Lt(e){let t=e.imageGenerationModelTimeoutMs;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return Math.floor(t);let n=e.imageGenerationModel;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.timeoutMs;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.floor(e)}return null}function Rt(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function zt(e){let t={},n=t.models&&typeof t.models==`object`&&!Array.isArray(t.models)?t.models:{},r=n.chat,i=t.modelFallbacks,a=Array.isArray(i)&&i.every(e=>typeof e==`string`)?i:Tt(r),o=t.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:Tt(t.imageModel),c=t.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:Tt(t.imageGenerationModel),u=Dt((e&&typeof e==`object`&&!Array.isArray(e)?e:{}).browser),d=typeof t.maxTaskDurationMs==`number`&&Number.isFinite(t.maxTaskDurationMs)?t.maxTaskDurationMs:void 0,f=d===void 0?void 0:Math.round(d/6e4);return{model:wt(r),modelFallbacks:a,imageModel:wt(t.imageModel),imageModelFallbacks:s,imageGenerationModel:wt(t.imageGenerationModel),imageGenerationModelFallbacks:l,imageGenerationModelTimeoutMs:Lt(t),imageGenerationModelAutoProviderFallback:Rt(t),mediaMaxMb:typeof t.mediaMaxMb==`number`&&!Number.isNaN(t.mediaMaxMb)?t.mediaMaxMb:void 0,maxTokens:typeof t.maxTokens==`number`?t.maxTokens:8192,temperature:typeof t.temperature==`number`?t.temperature:.7,maxToolIterations:typeof t.maxToolIterations==`number`?t.maxToolIterations:20,maxTaskDurationMinutes:f,maxRequestsPerTurn:typeof t.maxRequestsPerTurn==`number`?t.maxRequestsPerTurn:50,maxToolFailuresPerTurn:typeof t.maxToolFailuresPerTurn==`number`?t.maxToolFailuresPerTurn:3,workspace:typeof t.workspace==`string`?t.workspace:`~/.xopc/workspace`,...u,thinkingDefault:typeof t.thinkingDefault==`string`?t.thinkingDefault:`medium`,reasoningDefault:typeof t.reasoningDefault==`string`?t.reasoningDefault:`stream`,verboseDefault:typeof t.verboseDefault==`string`?t.verboseDefault:`full`,compaction:Ot(t.compaction),pruning:kt(t.pruning),memory:At(t.memory),sessionSearch:jt(t.sessionSearch),backgroundReview:Mt(t.backgroundReview),webExtract:Nt(t.webExtract),delegate:Pt(t.delegate,!1),executeCode:Pt(t.executeCode,!1),systemPromptOverride:typeof t.systemPromptOverride==`string`?t.systemPromptOverride:``,skillsAllowlist:Ft(t.skills),toolsDisable:(()=>{let e=t.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let n=e.disable;return Ft(n)})(),typedModels:de(n),paramsJson:It(t.params)}}function Bt(e){return{enabled:e.browserEnabled,headless:e.browserHeadless,allowPrivateUrls:e.browserAllowPrivateUrls,...e.browserCommandTimeout===void 0?{}:{commandTimeout:e.browserCommandTimeout},backend:e.browserBackend,...e.browserCloudProvider===`local`?{}:{cloudProvider:e.browserCloudProvider},...e.browserBackend===`cloud`?{cloud:{...e.browserCloudApiKey.trim()?{apiKey:e.browserCloudApiKey.trim()}:{},...e.browserCloudProjectId.trim()?{projectId:e.browserCloudProjectId.trim()}:{},...e.browserCloudRegion.trim()?{region:e.browserCloudRegion.trim()}:{}}}:{},...e.browserCdpUrl.trim()?{cdpUrl:e.browserCdpUrl.trim()}:{},...e.browserBackend===`extension`?{extension:{...e.browserExtensionPort===void 0?{}:{port:e.browserExtensionPort},...e.browserExtensionHost.trim()?{host:e.browserExtensionHost.trim()}:{},...e.browserExtensionConnectionTimeout===void 0?{}:{connectionTimeout:e.browserExtensionConnectionTimeout}}}:{},...e.browserBackend===`cloakbrowser`?{cloakbrowser:{keepOpen:e.browserCloakKeepOpen,temporaryProfile:e.browserCloakTemporaryProfile,...e.browserCloakCacheDir.trim()?{cacheDir:e.browserCloakCacheDir.trim()}:{},...e.browserCloakBinaryPath.trim()?{binaryPath:e.browserCloakBinaryPath.trim()}:{},...e.browserCloakTimezone.trim()?{timezone:e.browserCloakTimezone.trim()}:{},...e.browserCloakLocale.trim()?{locale:e.browserCloakLocale.trim()}:{},...e.browserCloakWebrtcIp.trim()?{webrtcIp:e.browserCloakWebrtcIp.trim()}:{},...e.browserCloakFingerprintPlatform.trim()?{fingerprintPlatform:e.browserCloakFingerprintPlatform.trim()}:{},...(()=>{let t=e.browserCloakExtraArgs.split(`
|
|
8
|
-
`).map(e=>e.trim()).filter(Boolean);return t.length>0?{extraArgs:t}:{}})()},humanize:e.browserHumanize,humanPreset:e.browserHumanPreset}:{},...e.browserDialogPolicy===`auto_dismiss`?{}:{dialogPolicy:e.browserDialogPolicy},...e.browserDialogTimeout===void 0?{}:{dialogTimeoutSeconds:e.browserDialogTimeout}}}async function Vt(e){await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:Bt(e)})}),z()}var Ht=P();function Ut(e,t={}){let n=!!s(e=>e.token),[r,i]=(0,Y.useReducer)(Ht,{form:null,baseline:null}),a=r.form,o=r.baseline,[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),m=(0,Y.useRef)(!1),h=(0,Y.useRef)(null),{data:g,error:_,isLoading:v,mutate:y}=C(n);U({enabled:n,parsed:(0,Y.useMemo)(()=>g?.payload?.config===void 0?null:zt(g.payload.config),[g]),dirty:m.current,trackedParsedRef:h,dispatch:i,onResetDirty:()=>{m.current=!1}});let b=!!(n&&v&&g===void 0&&!_),x=_ instanceof Error?_.message:_?String(_):null,S=(0,Y.useMemo)(()=>!a||!o?!1:JSON.stringify(a)!==JSON.stringify(o),[a,o]);return{hasToken:n,loading:b,fetchError:x,form:a,update:(0,Y.useCallback)(e=>{m.current=!0,p(!1),i({type:`patch`,patch:e})},[]),dirty:S,saving:c,saveOk:f,error:u,setError:d,save:(0,Y.useCallback)(async()=>{if(!a||c)return!1;l(!0),d(null),p(!1);try{return await Vt(a),m.current=!1,i({type:`saved`,value:a}),p(!0),y(),!0}catch(t){return d(t instanceof Error?t.message:e.saveError),!1}finally{l(!1)}},[e.saveError,a,y,c]),discard:(0,Y.useCallback)(()=>{m.current=!1,i({type:`discard`}),p(!1),d(null)},[]),mutate:y}}function Wt(e,t){return e.browserTabs[t]}function Gt(){let e=(0,X.c)(43),t=o(qt),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.agentSettings,s=r.chat,c=j(Kt),l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l={saveScope:`browser`},e[2]=l):l=e[2];let u=Ut(i,l),[d,f]=D(),p;e[3]===c?p=e[4]:(p=he(Ae,c),e[3]=c,e[4]=p);let m=p,h;e[5]===d?h=e[6]:(h=be(d.get(`focus`)),e[5]=d,e[6]=h);let g=h,_;e[7]!==g||e[8]!==d?(_=g?Me[g]??Ne(d.get(`tab`)):Ne(d.get(`tab`)),e[7]=g,e[8]=d,e[9]=_):_=e[9];let v=_,b;bb0:{if(!u.form){b=null;break bb0}let t;e[10]!==i||e[11]!==s||e[12]!==u.form||e[13]!==u.update?(t={form:u.form,update:u.update,a:i,chat:s},e[10]=i,e[11]=s,e[12]=u.form,e[13]=u.update,e[14]=t):t=e[14],b=t}let x=b,S;e[15]===f?S=e[16]:(S=e=>{f(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[15]=f,e[16]=S);let C=S;me(v,C);let w,T;e[17]!==g||e[18]!==d||e[19]!==f?(w=()=>{if(!g)return;let e=Me[g]??Ne(d.get(`tab`));f(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0});let t=g===`runtime`||g===`security`?ye(g):null;if(!t)return;let n=window.setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:`smooth`,block:`start`})},80);return()=>window.clearTimeout(n)},T=[g,d,f],e[17]=g,e[18]=d,e[19]=f,e[20]=w,e[21]=T):(w=e[20],T=e[21]),(0,Y.useEffect)(w,T);let E;if(e[22]!==i||e[23]!==m){let t;e[25]===i?t=e[26]:(t=e=>({id:e,label:Wt(i,e)}),e[25]=i,e[26]=t),E=m.map(t),e[22]=i,e[23]=m,e[24]=E}else E=e[24];let O=E,k;e[27]!==v||e[28]!==i.browserTabsAria||e[29]!==C||e[30]!==O?(k=(0,Z.jsx)(y,{items:O,activeTab:v,onChange:C,ariaLabel:i.browserTabsAria,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`}),e[27]=v,e[28]=i.browserTabsAria,e[29]=C,e[30]=O,e[31]=k):k=e[31];let A;e[32]!==v||e[33]!==x||e[34]!==C?(A=x?(0,Z.jsx)(pt,{...x,activeTab:v,setActiveTab:C}):null,e[32]=v,e[33]=x,e[34]=C,e[35]=A):A=e[35];let M;e[36]!==v||e[37]!==A?(M=(0,Z.jsx)(ce,{id:v,activeTab:v,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`,showHeading:!1,framed:!1,children:A}),e[36]=v,e[37]=A,e[38]=M):M=e[38];let N;return e[39]!==k||e[40]!==M||e[41]!==u?(N=(0,Z.jsxs)(gt,{sectionId:`agent-browser`,intro:``,vm:u,tabbed:!0,children:[k,M]}),e[39]=k,e[40]=M,e[41]=u,e[42]=N):N=e[42],N}function Kt(e){return e.mode}function qt(e){return e.language}export{Gt as AgentBrowserSettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-avfvyZuQ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s}from"./fetch-Dtpbbe0s.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{$a as l,Ba as u,Bn as d,Ha as f,Ks as p,Mo as m,Na as h,Po as g,Rc as _,To as v,Ua as y,aa as b,ba as x,ea as S,ht as C,ia as w,ms as T,na as E,oa as D,ra as O,ta as k,xc as A,ya as j,zs as M}from"./index-T0SaNd5a.js";import{n as N,t as P}from"./settings-form-section-BFxBNxOG.js";import{n as F,t as I}from"./settings-page-layout-CLx4o2PN.js";import{a as L,i as R,o as z,t as B}from"./typed-models-lib-bpzZjiVF.js";import{a as ee,i as te,n as ne,o as V,r as re,s as ie,t as ae}from"./capability-presets-api-CEJ44WCU.js";var H=n(),U=e(t(),1),W=r();function oe(e){return e.name||e.directoryId}function se(e){let t=(0,H.c)(57),{mode:n,selected:r,catalog:a,loading:o,disabled:s,onModeChange:c,onSelectedChange:l,labels:d}=e,f=n===`allowlist`||n===`denylist`,p;t[0]===a?p=t[1]:(p=a.map(oe).filter(Boolean),t[0]=a,t[1]=p);let m=p,h;bb0:{if(n===`inherit`){h=d.inheritSummary;break bb0}if(n===`all`){h=d.allSummary;break bb0}if(n===`off`){h=d.offSummary;break bb0}let e=n===`allowlist`?d.allowSummary:d.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],h=i}let g=h,_;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,W.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),t[5]=_):_=t[5];let v;t[6]===d.overrideSummaryTitle?v=t[7]:(v=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[_,d.overrideSummaryTitle]}),t[6]=d.overrideSummaryTitle,t[7]=v);let y;t[8]===g?y=t[9]:(y=(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:g}),t[8]=g,t[9]=y);let b;t[10]!==v||t[11]!==y?(b=(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/50 px-3 py-2`,children:[v,y]}),t[10]=v,t[11]=y,t[12]=b):b=t[12];let x;t[13]===d.modeLabel?x=t[14]:(x=(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:d.modeLabel}),t[13]=d.modeLabel,t[14]=x);let S;t[15]===d.modeInherit?S=t[16]:(S=[`inherit`,d.modeInherit],t[15]=d.modeInherit,t[16]=S);let C;t[17]===d.modeAll?C=t[18]:(C=[`all`,d.modeAll],t[17]=d.modeAll,t[18]=C);let w;t[19]===d.modeAllowlist?w=t[20]:(w=[`allowlist`,d.modeAllowlist],t[19]=d.modeAllowlist,t[20]=w);let T;t[21]===d.modeDenylist?T=t[22]:(T=[`denylist`,d.modeDenylist],t[21]=d.modeDenylist,t[22]=T);let E;t[23]===d.modeOff?E=t[24]:(E=[`off`,d.modeOff],t[23]=d.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,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:O.map(e=>{let[t,r]=e;return(0,W.jsx)(`button`,{type:`button`,className:i(`rounded-lg border px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`border-accent/35 bg-accent-soft text-accent-fg`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge 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 j;t[36]!==k||t[37]!==x?(j=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[x,k]}),t[36]=k,t[37]=x,t[38]=j):j=t[38];let M;t[39]!==a||t[40]!==m||t[41]!==s||t[42]!==d.catalogLoading||t[43]!==d.emptyCatalog||t[44]!==d.noDescription||t[45]!==d.quickActionsLabel||t[46]!==d.quickClear||t[47]!==d.quickSelectAll||t[48]!==o||t[49]!==l||t[50]!==f||t[51]!==r?(M=f?(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:d.quickActionsLabel}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:s||o||m.length===0,onClick:()=>l(new Set(m)),children:d.quickSelectAll}),(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:s||o||r.size===0,onClick:()=>l(new Set),children:d.quickClear})]})]}),o?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.catalogLoading}):a.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.emptyCatalog}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:a.map(e=>{let t=oe(e),n=r.has(t),a=typeof e.description==`string`?e.description.trim():``,o=a||d.noDescription;return(0,W.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 dark:border-edge-subtle`,children:(0,W.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,W.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,W.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,W.jsx)(`p`,{className:i(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!a&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})]}):null,t[39]=a,t[40]=m,t[41]=s,t[42]=d.catalogLoading,t[43]=d.emptyCatalog,t[44]=d.noDescription,t[45]=d.quickActionsLabel,t[46]=d.quickClear,t[47]=d.quickSelectAll,t[48]=o,t[49]=l,t[50]=f,t[51]=r,t[52]=M):M=t[52];let N;return t[53]!==j||t[54]!==M||t[55]!==b?(N=(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[b,j,M]}),t[53]=j,t[54]=M,t[55]=b,t[56]=N):N=t[56],N}var G=[`write_file`,`edit_file`,`shell`,`execute_code`],K=[`shell`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],q=[`send_message`,`send_media`,`text_to_speech`,`create_share`],J=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],Y=[...G,...q],X=[`read_file`,`write_file`,`edit_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],ce=[`send_message`,`send_media`];function le(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]=i);return n}function ue(e){let t=(0,H.c)(92),{builtinToolIds:n,toolModes:r,onChange:a,disabled:o,getToolDescription:s,getGroupTitle:c,labels:l}=e,d;t[0]===n?d=t[1]:(d=new Set(n),t[0]=n,t[1]=d);let f=d,p;t[2]!==f||t[3]!==r?(p=Object.entries(r).filter(e=>{let[t]=e;return f.has(t)}).toSorted(Z),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 ee){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=V(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,_;t[12]!==a||t[13]!==r?(_=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]=t,a(n)},t[12]=a,t[13]=r,t[14]=_):_=t[14];let v=_,y;t[15]!==f||t[16]!==a?(y=e=>{a(le(f,e))},t[15]=f,t[16]=a,t[17]=y):y=t[17];let b=y;if(n.length===0){let e;return t[18]===l.emptyBuiltin?e=t[19]:(e=(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[18]=l.emptyBuiltin,t[19]=e),e}let x;t[20]===l.quickActionsLabel?x=t[21]:(x=(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[20]=l.quickActionsLabel,t[21]=x);let S;t[22]===a?S=t[23]:(S=()=>a({}),t[22]=a,t[23]=S);let C;t[24]!==o||t[25]!==l.quickClearOverrides||t[26]!==S?(C=(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:o,onClick:S,children:l.quickClearOverrides}),t[24]=o,t[25]=l.quickClearOverrides,t[26]=S,t[27]=C):C=t[27];let w;t[28]===b?w=t[29]:(w=()=>b([[G,`deny`]]),t[28]=b,t[29]=w);let T;t[30]!==o||t[31]!==l.quickReadOnlyWorkspace||t[32]!==w?(T=(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:o,onClick:w,children:l.quickReadOnlyWorkspace}),t[30]=o,t[31]=l.quickReadOnlyWorkspace,t[32]=w,t[33]=T):T=t[33];let E;t[34]===b?E=t[35]:(E=()=>b([[K,`deny`]]),t[34]=b,t[35]=E);let D;t[36]!==o||t[37]!==l.quickHighRiskOff||t[38]!==E?(D=(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:o,onClick:E,children:l.quickHighRiskOff}),t[36]=o,t[37]=l.quickHighRiskOff,t[38]=E,t[39]=D):D=t[39];let O;t[40]===b?O=t[41]:(O=()=>b([[q,`deny`]]),t[40]=b,t[41]=O);let k;t[42]!==o||t[43]!==l.quickNoOutbound||t[44]!==O?(k=(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:o,onClick:O,children:l.quickNoOutbound}),t[42]=o,t[43]=l.quickNoOutbound,t[44]=O,t[45]=k):k=t[45];let A;t[46]===b?A=t[47]:(A=()=>b([[J,`allow`],[Y,`deny`]]),t[46]=b,t[47]=A);let j;t[48]!==o||t[49]!==l.quickResearchMode||t[50]!==A?(j=(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:o,onClick:A,children:l.quickResearchMode}),t[48]=o,t[49]=l.quickResearchMode,t[50]=A,t[51]=j):j=t[51];let M;t[52]===b?M=t[53]:(M=()=>b([[X,`allow`],[ce,`deny`]]),t[52]=b,t[53]=M);let N;t[54]!==o||t[55]!==l.quickCodingMode||t[56]!==M?(N=(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:o,onClick:M,children:l.quickCodingMode}),t[54]=o,t[55]=l.quickCodingMode,t[56]=M,t[57]=N):N=t[57];let P;t[58]!==D||t[59]!==k||t[60]!==j||t[61]!==N||t[62]!==C||t[63]!==T?(P=(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[C,T,D,k,j,N]}),t[58]=D,t[59]=k,t[60]=j,t[61]=N,t[62]=C,t[63]=T,t[64]=P):P=t[64];let F;t[65]!==P||t[66]!==x?(F=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[x,P]}),t[65]=P,t[66]=x,t[67]=F):F=t[67];let I;t[68]===l.overrideSummaryTitle?I=t[69]:(I=(0,W.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[68]=l.overrideSummaryTitle,t[69]=I);let L;t[70]!==l.modeAllow||t[71]!==l.modeDeny||t[72]!==l.noOverrides||t[73]!==m?(L=m.length>0?(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:m.map(e=>{let[t,n]=e;return(0,W.jsxs)(`span`,{className:i(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,W.jsx)(`span`,{className:`font-sans opacity-80`,children:n===`allow`?l.modeAllow:l.modeDeny})]},t)})}):(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[70]=l.modeAllow,t[71]=l.modeDeny,t[72]=l.noOverrides,t[73]=m,t[74]=L):L=t[74];let R;t[75]!==I||t[76]!==L?(R=(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/50 px-3 py-2`,children:[I,L]}),t[75]=I,t[76]=L,t[77]=R):R=t[77];let B;t[78]!==o||t[79]!==c||t[80]!==s||t[81]!==g||t[82]!==l.inheritedMode||t[83]!==l.modeAllow||t[84]!==l.modeDeny||t[85]!==v||t[86]!==r?(B=(0,W.jsx)(`div`,{className:`flex flex-col gap-5`,children:g.map(e=>{let{key:t,ids:n}=e;return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=Object.prototype.hasOwnProperty.call(r,e)?r[e]:`inherit`;return(0,W.jsx)(`li`,{className:i(`rounded-xl border px-3 py-2.5 transition-colors dark:border-edge-subtle`,n===`inherit`?`border-edge-subtle bg-surface-panel/40`:`border-edge bg-surface-panel`),children:(0,W.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,W.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`deny`].map(t=>(0,W.jsx)(`button`,{type:`button`,className:i(`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`,n===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:o,onClick:()=>v(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:l.modeDeny},t))})]})},e)})})]},t)})}),t[78]=o,t[79]=c,t[80]=s,t[81]=g,t[82]=l.inheritedMode,t[83]=l.modeAllow,t[84]=l.modeDeny,t[85]=v,t[86]=r,t[87]=B):B=t[87];let te;return t[88]!==F||t[89]!==R||t[90]!==B?(te=(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[F,R,B]}),t[88]=F,t[89]=R,t[90]=B,t[91]=te):te=t[91],te}function Z(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}var de=[{id:`overview`,icon:p},{id:`models`,icon:T},{id:`tools`,icon:y},{id:`skills`,icon:m},{id:`impact`,icon:M}];function fe(e){return R(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function pe(e){return Object.fromEntries(Object.entries(e?.tools?.builtin??{}).map(([e,t])=>[e,t.mode===`allow`?`allow`:`deny`]))}function Q(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function me(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,version:String(e?.version??1),modelRows:fe(e),toolModes:pe(e),skillMode:e?.skills?.mode??`inherit`,skillPick:Q(e)}}function he(e,t){let n=B(e.modelRows);return n?.roles?{...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},roles:n.roles}:null}function $(e){let t=Object.fromEntries(Object.entries(e.toolModes).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,{mode:t}]));return Object.keys(t).length>0?{builtin:t}:null}function ge(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 _e(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),version:Number(e.version),models:he(e,t),tools:$(e),skills:ge(e)}}function ve(e){return e?{id:e.id,name:e.name,description:e.description??``,version:e.version,models:e.models?.roles?{...e.models.defaultRole?{defaultRole:e.models.defaultRole}:{},roles:e.models.roles}:null,tools:e.tools?.builtin&&Object.keys(e.tools.builtin).length>0?{builtin:e.tools.builtin}:null,skills:e.skills??{mode:`all`}}:null}function ye(e){return[e.models?.roles?`${Object.keys(e.models.roles).length} model roles`:``,e.tools?.builtin?`${Object.keys(e.tools.builtin).length} tool access settings`:``,e.skills?`skills: ${e.skills.mode}`:``].filter(Boolean).join(` · `)||`No shared settings yet`}function be(e){return e===`safe-coder`?{id:`safe-coder`,name:`Safe Coder`,description:`Shared settings for coding agents: code-oriented model roles, careful shell usage, and focused engineering skills.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Complex implementation and planning`},{id:`code`,model:``,fallbacks:[],description:`Code edits and tests`},{id:`review`,model:``,fallbacks:[],description:`Review and risk checks`}],toolModes:{shell:`deny`,send_message:`deny`,send_media:`deny`},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`])}:e===`read-only`?{id:`read-only-research`,name:`Read-only Research`,description:`Shared settings for reading, searching, and summarizing without modifying files or running shell commands.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Synthesis and long-context reading`},{id:`fast`,model:``,fallbacks:[],description:`Quick summaries`}],toolModes:{write_file:`deny`,edit_file:`deny`,shell:`deny`,send_message:`deny`,send_media:`deny`},skillMode:`all`,skillPick:new Set}:e===`low-cost`?{id:`low-cost-assistant`,name:`Low-cost Assistant`,description:`Shared settings for lightweight agents that should prefer faster or cheaper model roles.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Default low-cost model`},{id:`fast`,model:``,fallbacks:[],description:`Low-latency replies`},{id:`cheap`,model:``,fallbacks:[],description:`Batch or summary work`}],toolModes:{},skillMode:`inherit`,skillPick:new Set}:{id:``,name:``,description:``,version:`1`,modelRows:[],toolModes:{},skillMode:`inherit`,skillPick:new Set}}function xe(){let e=a(o(e=>e.language)),t=e.capabilityPresetsSettings,n=!!s(e=>e.token),{data:r,error:A,isLoading:R,mutate:z}=c(n?`settings-capability-presets`:null,re,{revalidateOnFocus:!1}),{data:B=[],isLoading:ee}=c(n?`settings-capability-presets-skills-catalog`:null,d,{revalidateOnFocus:!1}),[V,H]=_(),[oe,G]=(0,U.useState)(``),[K,q]=(0,U.useState)(`overview`),[J,Y]=(0,U.useState)(()=>be(`blank`)),[X,ce]=(0,U.useState)(!1),[le,Z]=(0,U.useState)(null),fe=r?.presets??[],pe=r?.defaultPresetId??`default`,Q=fe.find(e=>e.id===pe)??null,he=fe.filter(e=>e.id!==pe),$=(0,U.useMemo)(()=>fe.find(e=>e.id===oe)??fe[0]??null,[fe,oe]),ge=!$||J.id.trim()!==$.id,xe=!!($&&$.id===pe),Ce=JSON.stringify(_e(J,$))!==JSON.stringify(ve($)),we=le??(A instanceof Error?A.message:null),Te=V.get(`action`)===`new`||!!V.get(`preset`),Ee=ge?t.newPreset:$?.name??t.editorTitle,De=t=>e.agentsSettings.toolsDisableGroups[t],Oe=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,U.useEffect)(()=>{if(!r||X)return;if(V.get(`action`)===`new`){let e=V.get(`starter`);G(``),Y(be(e===`safe-coder`||e===`read-only`||e===`low-cost`?e:`blank`)),q(`overview`);return}let e=V.get(`preset`)?.trim(),t=e?r.presets.find(t=>t.id===e):null;if(t){G(t.id),Y(me(t)),q(V.get(`tab`)??`overview`);return}$&&(G($.id),Y(e=>e.id===$.id?e:me($)))},[X,r,V,$]);function ke(e){G(e.id),Y(me(e)),H({preset:e.id},{replace:!0}),q(`overview`)}function Ae(e){let t=be(e);G(``),Y(t),Z(null),H(e===`blank`?{action:`new`}:{action:`new`,starter:e},{replace:!0}),q(`overview`)}function je(){H({},{replace:!0}),Z(null),Y(me($)),q(`overview`)}async function Me(){let e=L(J.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){Z(e),q(`models`);return}ce(!0),Z(null);try{if(ge){let e=await ae({id:J.id.trim(),name:J.name.trim(),...J.description.trim()?{description:J.description.trim()}:{}}),t=e.presets,n=_e(J,null);(n.models||n.tools||n.skills)&&(t=await te(e.presetId,{version:n.version,models:n.models,tools:n.tools,skills:n.skills})),await z(t,{revalidate:!1}),G(e.presetId),H({preset:e.presetId},{replace:!0})}else if($){let e=_e(J,$);await z(await te($.id,{name:e.name,description:e.description||null,version:e.version,models:e.models,tools:e.tools,skills:e.skills}),{revalidate:!1})}}catch(e){Z(e instanceof Error?e.message:t.saveError)}finally{ce(!1)}}async function Ne(){if($){ce(!0),Z(null);try{let e=await ne($.id);await z(e,{revalidate:!1});let t=e.presets[0]??null;G(t?.id??``),Y(me(t)),H(t?{preset:t.id}:{},{replace:!0})}catch(e){Z(e instanceof Error?e.message:t.saveError)}finally{ce(!1)}}}return n?(0,W.jsxs)(I,{gap:`gap-5`,className:`pb-24`,children:[(0,W.jsx)(F,{title:t.title,subtitle:t.subtitle,actions:(0,W.jsxs)(u,{type:`button`,onClick:()=>Ae(`blank`),disabled:X,children:[(0,W.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})}),we?(0,W.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:we}):null,R?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:g,title:t.newPreset,subtitle:t.editorHint}),(0,W.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:[`blank`,`safe-coder`,`read-only`,`low-cost`].map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`min-h-28 rounded-lg border border-edge-subtle bg-surface-panel px-4 py-3 text-left text-sm 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:()=>Ae(e),children:[(0,W.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),(0,W.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})]}),Q?(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:T,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>ke(Q),className:`group rounded-lg border border-accent/25 bg-accent/5 px-4 py-3 text-left text-fg transition-colors hover:border-accent/40 hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Q.name}),(0,W.jsx)(`span`,{className:`rounded-full border border-accent/25 bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Q.id})]}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full border border-edge-subtle bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),Q.description?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Q.description}):null,(0,W.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:ye(Q)})]})]}):null,(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:T,title:t.listTitle,subtitle:t.listHint}),he.length===0?(0,W.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-4 text-sm text-fg-muted`,children:t.empty}):(0,W.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:he.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>ke(e),className:`group min-h-36 rounded-lg border border-edge-subtle bg-surface-panel px-4 py-3 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`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,W.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full border border-edge-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,W.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:ye(e)})]},e.id))})]})]}),(0,W.jsx)(b,{open:Te,onOpenChange:e=>{e||je()},children:(0,W.jsxs)(w,{children:[(0,W.jsx)(O,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,x)}),(0,W.jsx)(k,{className:i(`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`,j),onOpenAutoFocus:e=>e.preventDefault(),children:(0,W.jsxs)(C,{layer:`modal`,children:[(0,W.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,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(D,{className:`truncate text-base font-semibold text-fg`,children:Ee}),(0,W.jsx)(E,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:ge?t.editorHint:J.id})]}),(0,W.jsx)(S,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:i(h,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,W.jsx)(f,{className:`size-4`,"aria-hidden":!0})})})]}),we?(0,W.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:we}):null,(0,W.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:de.map(({id:e,icon:n})=>(0,W.jsxs)(`button`,{type:`button`,className:i(`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`,K===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>q(e),children:[(0,W.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[K===`overview`?(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:p,title:t.overviewTitle,subtitle:t.overviewHint}),(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,W.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:X||!ge,onChange:e=>Y(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,W.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.version,disabled:X,inputMode:`numeric`,onChange:e=>Y(t=>({...t,version:e.target.value}))})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,W.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:X,onChange:e=>Y(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,W.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:X,onChange:e=>Y(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,W.jsx)(Se,{icon:T,label:t.modelsTitle,value:String(J.modelRows.length)}),(0,W.jsx)(Se,{icon:y,label:t.toolsTitle,value:String(Object.keys(J.toolModes).length)}),(0,W.jsx)(Se,{icon:m,label:t.skillsTitle,value:t.skillModeLabels[J.skillMode]})]})]}):null,K===`models`?(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:T,title:t.modelsTitle,subtitle:t.modelsHint}),(0,W.jsx)(ie,{rows:J.modelRows,onChange:e=>Y(t=>({...t,modelRows:e})),disabled:X,defaultRole:$?.models?.defaultRole,chat:e.chat,labels:{id:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,add:t.addModelRole,remove:t.removeModelRole,recommendedTitle:t.modelRecommendedTitle,customTitle:t.modelCustomTitle,defaultBadge:t.modelDefaultBadge,addPurpose:t.addModelPurpose,noCustomRoles:t.noCustomModelRoles,idPlaceholder:`deep`,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}})]}):null,K===`tools`?(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:y,title:t.toolsTitle,subtitle:t.toolsHint}),(0,W.jsx)(ue,{builtinToolIds:r?.builtinToolIds??[],toolModes:J.toolModes,onChange:e=>Y(t=>({...t,toolModes:e})),disabled:X,getToolDescription:Oe,getGroupTitle:De,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,modeDeny:t.toolModes.deny}})]}):null,K===`skills`?(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:m,title:t.skillsTitle,subtitle:t.skillsHint}),(0,W.jsx)(se,{mode:J.skillMode,selected:J.skillPick,catalog:B,loading:ee,disabled:X,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,K===`impact`?(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:M,title:t.usageTitle,subtitle:t.usageHint}),$?.usage.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:$.usage.map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId})]},e.agentId))}):(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,W.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,W.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,W.jsx)(`div`,{className:`font-medium text-fg`,children:Ce?t.unsavedTitle:t.noUnsavedTitle}),(0,W.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Ce?($?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String($?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ce?(0,W.jsx)(u,{type:`button`,variant:`secondary`,disabled:X,onClick:()=>Y(me($)),children:t.discard}):null,$&&!xe?(0,W.jsxs)(u,{type:`button`,variant:`secondary`,disabled:X,onClick:()=>void Ne(),children:[(0,W.jsx)(l,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,W.jsxs)(u,{type:`button`,disabled:X||!J.id.trim()||!J.name.trim()||!Ce,onClick:()=>void Me(),children:[(0,W.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})})]})})]}):(0,W.jsxs)(I,{gap:`gap-3`,children:[(0,W.jsx)(F,{title:t.title}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function Se(e){let t=(0,H.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,W.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,W.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,W.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,W.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}export{xe as CapabilityPresetsSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-avfvyZuQ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-Dtpbbe0s.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$n as f,Ba as p,Bs as m,Ha as h,Ic as g,Lc as _,Na as v,Ni as y,Qa as b,U as x,Wr as S,aa as C,ba as w,ea as T,er as E,ia as D,jo as O,lc as k,na as A,ns as j,oa as ee,ra as te,sa as M,so as N,ta as P,tr as F,ya as I,yo as ne}from"./index-T0SaNd5a.js";import{t as re}from"./schema-form-Cc-IOydE.js";import{t as L}from"./browser-BLJWD7WI.js";import{n as ie,t as ae}from"./settings-page-layout-CLx4o2PN.js";import{t as oe}from"./use-channel-catalog-BCjZLZ3O.js";var R=n(),se=e(L(),1),z=e(t(),1),B=r();function V(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}async function H(e){let t=await u(c(`/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 U(e){return e?.type===`poll`&&e.phase===`done`}function W(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function G(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function ce(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function le({entry:e,locale:t,messages:n,onChanged:r,autoStartPrimary:a=!1,compact:o=!1}){let s=(0,z.useMemo)(()=>V(e),[e]),c=(0,z.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[l,u]=(0,z.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,z.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,z.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await H({channelId:e.id,actionId:n,locale:t,input:i});u(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){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,z.useEffect)(()=>{!a||!s||s[1].result!==`qr`||l.payload||l.busy||l.error||d(s[0])},[a,s,d,l.busy,l.error,l.payload]),(0,z.useEffect)(()=>{let t=G(l.payload,e.id);if(!t){u(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return u(e=>e.generatedQr?{...e,generatedQr:null}:e),se.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,l.payload]),(0,z.useEffect)(()=>{let n=l.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||H({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:U(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),U(e)&&window.clearInterval(a))}).catch(e=>{i||u(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,l.poll]);let f=s?.[1].label??(e.configured?n.reconnect:n.connect),h=e.actions?.[`doctor.run`]?.label??n.diagnose,g=W(l.payload),_=G(l.payload,e.id),v=_?l.generatedQr:ce(l.payload),y=s?.[1].result===`qr`&&(a||l.busy||l.payload?.type===`qr`||l.payload?.type===`poll`),b=l.busy||!!(_&&!v),x=l.payload?.type===`form`?l.payload:null,S=l.payload?.type===`diagnostics`?l.payload.checks:null;return(0,B.jsxs)(`div`,{className:o?`space-y-3`:`rounded-lg border border-edge-subtle bg-surface-panel p-4`,children:[(0,B.jsxs)(`div`,{className:i(`flex flex-wrap items-start gap-3`,o?`justify-end`:`justify-between`),children:[o?null:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[s?(0,B.jsxs)(p,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(s[0]),children:[l.busy?(0,B.jsx)(j,{className:`size-4 animate-spin`}):(0,B.jsx)(O,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,B.jsxs)(p,{type:`button`,variant:`secondary`,disabled:l.busy,onClick:()=>void d(`doctor.run`),children:[(0,B.jsx)(N,{className:`size-4`}),h]}):null]})]}),g?(0,B.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:g}):null,l.error?(0,B.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:l.error}):null,y?(0,B.jsxs)(`div`,{className:i(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg border border-edge-subtle bg-surface-base px-3 py-3`,o?`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,B.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:v?(0,B.jsx)(`img`,{src:v,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,B.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base text-fg-muted`,children:(0,B.jsx)(j,{className:i(`size-6`,b&&`animate-spin`)})})}),(0,B.jsxs)(`div`,{className:i(`min-w-0 max-w-sm text-sm text-fg-muted`,o&&`w-full sm:w-auto`),children:[(0,B.jsx)(`p`,{className:`line-clamp-3`,children:v?n.waitingConfirmation:n.loading}),_?(0,B.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:_,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,B.jsx)(m,{className:`size-3.5`})]}):null]})]}):null,l.payload?.type===`poll`&&l.payload.phase===`done`?(0,B.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-sm`,children:[(0,B.jsx)(k,{className:l.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,B.jsx)(`span`,{className:l.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:l.payload.message??(l.payload.ok?n.complete:n.failed)})]}):null,x?(0,B.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,B.jsx)(re,{schema:x.schema,values:l.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:l.busy,labels:c}),(0,B.jsx)(p,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(x.submitAction,l.formDraft),children:n.saveSetup})]}):null,S?(0,B.jsx)(`div`,{className:`mt-4 space-y-2`,children:S.map((e,t)=>(0,B.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base px-3 py-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,B.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,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}function ue(e,t=!1){return e===`drawer`?i(`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`,I):i(`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)]`,I,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function de(e){let t=(0,R.c)(30),{presentation:n,open:r,onOpenChange:a,title:o,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:m,headerExtra:g}=e,_=m===void 0?!1:m,y=n===`drawer`,b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,B.jsx)(te,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),t[0]=b):b=t[0];let x;t[1]!==n||t[2]!==_?(x=ue(n,_),t[1]=n,t[2]=_,t[3]=x):x=t[3];let S;t[4]===c?S=t[5]:(S=c?(0,B.jsx)(ee,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=S);let E;t[6]===l?E=t[7]:(E=l?(0,B.jsx)(A,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=E);let O;t[8]!==u||t[9]!==s||t[10]!==g||t[11]!==y||t[12]!==o?(O=y?(0,B.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[o?(0,B.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:o}):null,s?(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,B.jsx)(T,{asChild:!0,children:(0,B.jsx)(p,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,B.jsx)(h,{className:`size-5`,strokeWidth:1.75})})})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(T,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,className:i(v,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,B.jsx)(h,{className:`size-4`})})}),g]}),t[8]=u,t[9]=s,t[10]=g,t[11]=y,t[12]=o,t[13]=O):O=t[13];let k=y?`px-4 py-4`:`p-6`,j;t[14]===k?j=t[15]:(j=i(`min-h-0 flex-1 overflow-y-auto`,k),t[14]=k,t[15]=j);let M;t[16]!==d||t[17]!==j?(M=(0,B.jsx)(`div`,{className:j,children:d}),t[16]=d,t[17]=j,t[18]=M):M=t[18];let N;t[19]!==f||t[20]!==x||t[21]!==S||t[22]!==E||t[23]!==O||t[24]!==M?(N=(0,B.jsxs)(D,{children:[b,(0,B.jsxs)(P,{className:x,onOpenAutoFocus:fe,children:[S,E,O,M,f]})]}),t[19]=f,t[20]=x,t[21]=S,t[22]=E,t[23]=O,t[24]=M,t[25]=N):N=t[25];let F;return t[26]!==a||t[27]!==r||t[28]!==N?(F=(0,B.jsx)(C,{open:r,onOpenChange:a,children:N}),t[26]=a,t[27]=r,t[28]=N,t[29]=F):F=t[29],F}function fe(e){return e.preventDefault()}var pe=(0,z.memo)(function(e){let t=(0,R.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,B.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,B.jsx)(S,{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,B.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 me(e){let t=(0,R.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,B.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,B.jsx)(p,{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,m;t[7]!==n.discard||t[8]!==o||t[9]!==f?(m=(0,B.jsx)(p,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=m):m=t[10];let h=!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]!==h||t[14]!==g||t[15]!==_?(v=(0,B.jsx)(p,{type:`button`,variant:`primary`,disabled:h,onClick:g,children:_}),t[13]=h,t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==d||t[18]!==m||t[19]!==v?(y=(0,B.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,m,v]}),t[17]=d,t[18]=m,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==y||t[22]!==u?(b=(0,B.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 he(e){return e?c(`/api/channels/${encodeURIComponent(e)}/config`):null}async function ge(e){return(await l(c(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var _e=[`enabled`];async function ve(){return(await l(c(`/api/config`))).payload?.config?.channels??{}}function K(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function q(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function J(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 ye(e,t){let n=J(e);return n.state===`needs_setup`?t.hubStatusNeedsSetup:n.state===`error`?t.hubStatusError:n.enabled&&n.ready&&e.runtime===`loaded`?t.hubStatusRunning:n.enabled&&n.ready?t.hubStatusEnabled:n.ready?t.hubStatusConfigured:t.hubStatusNotConfigured}function be(e){let t=J(e);return t.state===`needs_setup`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:t.state===`error`?`bg-red-500/10 text-red-700 dark:text-red-300`:t.enabled&&t.ready&&e.runtime===`loaded`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:t.enabled||t.ready?`bg-accent-soft text-accent`:`bg-surface-hover text-fg-muted`}function xe(e){if(!e)return[];let t=e.uiHints??{},n=Y(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=J(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Y(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!_e.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!_e.includes(e))}function Y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Se(e,t){let n={...X(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(!Y(r)||!Y(r[n]))break;let o=Y(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...X(r[n]),properties:{}}),e===t.length-1){o[n]=X(r[n]);break}i=r[n],a=o[n]}}return n}function Z(e){let t=e.properties;if(!Y(t))return!1;for(let[e,n]of Object.entries(t))Y(n)&&n.type===`object`&&Z(n)&&delete t[e];return Object.keys(t).length===0}function Ce(e,t){let n=X(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Y(i))break;if(e===t.length-1){delete i[n];break}if(!Y(i[n]))break;r=i[n]}}return Z(n),n}function we(e){return e.type===`object`&&Y(e.properties)&&Object.keys(e.properties).length>0}function Q(e,t){let n=e;for(let e of t.split(`.`)){if(!Y(n))return;n=n[e]}return n}function $(e){let t=e.accounts;return Y(t)?Object.values(t).filter(e=>Y(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Te(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 Ee(e,t,n){let r=[],i=J(e);if(i.issues.length>0&&r.push(Ae(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Te(e,Q(t,e),n);i&&r.push(i)}let a=$(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function De(e,t){let n=J(e),r=V(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 Oe(e,t){let n=V(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function ke(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 Ae(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 je({entry:e}){let t=s(e=>e.token),[n,r]=(0,z.useState)(!1),i=(0,z.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(c(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${K(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,B.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,B.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,B.jsx)(y,{sourceChannel:e.id,className:`size-7`})})}function Me(e){let t=(0,R.c)(16),{checked:n,disabled:r,onToggle:a,label:o}=e,s;t[0]===a?s=t[1]:(s=e=>{e.stopPropagation(),a()},t[0]=a,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=i(`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=i(`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,B.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==o||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,B.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":o,disabled:r,onClick:s,className:u,children:p}),t[9]=n,t[10]=r,t[11]=o,t[12]=s,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function Ne(e){let t=(0,R.c)(70),{entry:n,config:r,busy:a,ch:o,onOpen:s,onToggle:c}=e,l;t[0]===n?l=t[1]:(l=J(n),t[0]=n,t[1]=l);let u=l,d,f,m,h,g,_,v;if(t[2]!==a||t[3]!==o||t[4]!==r||t[5]!==n||t[6]!==s||t[7]!==c||t[8]!==u.enabled||t[9]!==u.ready){let e=Ee(n,r,o),l=ke(n,o);d=!u.enabled&&u.ready,_=`flex min-h-[15.5rem] flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-surface transition-colors hover:border-edge`;let p;t[17]===n?p=t[18]:(p=(0,B.jsx)(je,{entry:n}),t[17]=n,t[18]=p);let y;t[19]===n.label?y=t[20]:(y=(0,B.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[19]=n.label,t[20]=y);let b;t[21]===n?b=t[22]:(b=i(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,be(n)),t[21]=n,t[22]=b);let x;t[23]!==o||t[24]!==n?(x=ye(n,o),t[23]=o,t[24]=n,t[25]=x):x=t[25];let S;t[26]!==b||t[27]!==x?(S=(0,B.jsx)(`span`,{className:b,children:x}),t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;t[29]!==S||t[30]!==y?(C=(0,B.jsxs)(`div`,{className:`min-w-0`,children:[y,S]}),t[29]=S,t[30]=y,t[31]=C):C=t[31];let w;t[32]!==C||t[33]!==p?(w=(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[p,C]}),t[32]=C,t[33]=p,t[34]=w):w=t[34];let T=u.enabled,E;t[35]!==o.toggleChannel||t[36]!==n.label?(E=o.toggleChannel.replace(`{{channel}}`,n.label),t[35]=o.toggleChannel,t[36]=n.label,t[37]=E):E=t[37];let D;t[38]!==a||t[39]!==c||t[40]!==u.enabled||t[41]!==E?(D=(0,B.jsx)(Me,{checked:T,disabled:a,label:E,onToggle:c}),t[38]=a,t[39]=c,t[40]=u.enabled,t[41]=E,t[42]=D):D=t[42],t[43]!==w||t[44]!==D?(v=(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[w,D]}),t[43]=w,t[44]=D,t[45]=v):v=t[45],f=`button`,m=s,h=`mt-5 min-h-[6.25rem] text-left`,g=u.ready?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,B.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(Fe)}):null]}):(0,B.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base px-3 py-3`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.cardSetupTitle}),(0,B.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Oe(n,o)}),l.length>0?(0,B.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:l.map(Pe)}):null]}),t[2]=a,t[3]=o,t[4]=r,t[5]=n,t[6]=s,t[7]=c,t[8]=u.enabled,t[9]=u.ready,t[10]=d,t[11]=f,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v}else d=t[10],f=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=t[16];let y;t[46]!==o.cardAdapterLabel||t[47]!==n.description||t[48]!==u.ready?(y=!u.ready&&n.description?(0,B.jsxs)(`p`,{className:`mt-3 truncate text-xs text-fg-subtle`,title:n.description,children:[o.cardAdapterLabel,`: `,n.description]}):null,t[46]=o.cardAdapterLabel,t[47]=n.description,t[48]=u.ready,t[49]=y):y=t[49];let b;t[50]!==f||t[51]!==m||t[52]!==h||t[53]!==g||t[54]!==y?(b=(0,B.jsxs)(`button`,{type:f,onClick:m,className:h,children:[g,y]}),t[50]=f,t[51]=m,t[52]=h,t[53]=g,t[54]=y,t[55]=b):b=t[55];let x=d?c:s,S;t[56]===a?S=t[57]:(S=a?(0,B.jsx)(j,{className:`size-4 animate-spin`}):null,t[56]=a,t[57]=S);let C;t[58]!==o||t[59]!==n?(C=De(n,o),t[58]=o,t[59]=n,t[60]=C):C=t[60];let w;t[61]!==x||t[62]!==S||t[63]!==C?(w=(0,B.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,B.jsxs)(p,{type:`button`,variant:`primary`,className:`w-full rounded-2xl py-2.5`,onClick:x,children:[S,C]})}),t[61]=x,t[62]=S,t[63]=C,t[64]=w):w=t[64];let T;return t[65]!==w||t[66]!==_||t[67]!==v||t[68]!==b?(T=(0,B.jsxs)(`article`,{className:_,children:[v,b,w]}),t[65]=w,t[66]=_,t[67]=v,t[68]=b,t[69]=T):T=t[69],T}function Pe(e){return(0,B.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function Fe(e){return(0,B.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function Ie(e){let t=(0,R.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=J(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,B.jsx)(b,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,B.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,B.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,B.jsx)(`li`,{children:Ae(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,B.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,B.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,B.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,B.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function Le(){let e=o(e=>e.language),t=a(e),n=s(e=>!!e.token),r=g(),{channelId:l}=_(),p=F(l),h=oe(n,e),v=h.entries,{data:y={},mutate:b}=d(n?`channels-config-map`:null,ve,{revalidateOnFocus:!1}),S=M(e=>e.setPageHeader),C=M(e=>e.clearPageHeader),w=(0,z.useMemo)(()=>v.find(e=>e.id===p),[p,v]),T=w?q(w):null,{data:D,mutate:O}=d(n&&T?he(T):null,()=>ge(T)),[k,A]=(0,z.useState)(null),[j,ee]=(0,z.useState)(!1),[te,N]=(0,z.useState)(null),[P,I]=(0,z.useState)(null),L=k??D??{},R=t.channelsSettings,se=(0,z.useMemo)(()=>w?.configSchema??{type:`object`,properties:{}},[w?.configSchema]),H=(0,z.useMemo)(()=>Ce(se,_e),[se]),U=(0,z.useMemo)(()=>xe(w),[w]),W=(0,z.useMemo)(()=>Se(H,U),[U,H]),G=(0,z.useMemo)(()=>Ce(H,U),[U,H]),ce=(0,z.useMemo)(()=>we(W),[W]),ue=(0,z.useMemo)(()=>({defaultBooleanLabel:R.schemaBooleanDefault,unsupportedArrayType:R.schemaUnsupportedArrayType,arrayAddPlaceholder:R.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>R.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[R]),fe=(0,z.useMemo)(()=>n?(0,B.jsx)(pe,{ch:R,refreshing:h.isValidating,saveOk:!1,onRefresh:()=>void h.mutate()}):null,[h,R,n]);(0,z.useLayoutEffect)(()=>(S({startExtra:null,main:(0,B.jsx)(`div`,{className:`min-w-0`,children:(0,B.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:fe}),()=>C()),[C,fe,t.settingsSections.channels,S]);let K=(0,z.useCallback)(e=>{r(E(e)),A(null),I(null)},[r]),Y=(0,z.useCallback)(()=>{r(f),A(null),I(null)},[r]),X=(0,z.useCallback)(async()=>{if(!w||!k)return!1;let e=q(w);ee(!0),I(null);try{let t=await u(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[e]:k}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return await O(k,!1),await b(),await h.mutate(),A(null),!0}catch(e){return I(e instanceof Error?e.message:String(e)),!1}finally{ee(!1)}},[w,h,k,b,O]),Z=(0,z.useCallback)(async e=>{let t=J(e),n=q(e),r=w?.id===e.id?k:null;if(!t.enabled&&!t.ready&&!r){K(e.id);return}N(e.id),I(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await u(c(`/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 b(),w?.id===e.id&&(await O(),A(null))}catch(e){I(e instanceof Error?e.message:String(e))}finally{N(null)}},[w?.id,h,k,b,O,K]),Q=w?.ui?.modal,$=Q?.placement!==`replace-config`;return n?(0,B.jsxs)(ae,{gap:`gap-4`,children:[h.isLoading?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:R.loadingChannels}):h.error?(0,B.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(h.error)}):(0,B.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:v.map(e=>(0,B.jsx)(Ne,{entry:e,config:y[q(e)]?.config,busy:te===e.id,ch:R,onOpen:()=>K(e.id),onToggle:()=>void Z(e)},e.id))}),P?(0,B.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:P}):null,(0,B.jsx)(de,{presentation:`modal`,open:!!w,onOpenChange:e=>{e||Y()},closeAriaLabel:R.close,srTitle:w?.label??R.selectChannel,srDescription:w?.description,wide:!0,footer:w?(0,B.jsx)(me,{ch:R,dirty:!!k,saving:j,onCancel:Y,onDiscard:()=>A(null),onSave:X}):null,children:w?(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-3`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,B.jsx)(je,{entry:w}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:w.label}),(0,B.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,be(w)),children:ye(w,R)})]}),(0,B.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,B.jsx)(`span`,{className:`min-w-0 truncate`,children:V(w)?.[1].result===`qr`?R.scanLoginHint.replace(`{{channel}}`,w.label):w.description}),w.docsPath?(0,B.jsxs)(`a`,{href:w.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[R.docs,(0,B.jsx)(m,{className:`size-3.5`})]}):null]})]})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,B.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:R.enabledLabel}),(0,B.jsx)(Me,{checked:J(w).enabled,disabled:te===w.id,label:R.toggleChannel.replace(`{{channel}}`,w.label),onToggle:()=>void Z(w)})]})]})}),(0,B.jsx)(Ie,{entry:w,ch:R}),Q?.entrypoint&&Q.placement===`before-config`?(0,B.jsx)(x,{extensionId:w.extensionId,extensionName:w.label,entrypoint:Q.entrypoint,permissions:Q.permissions,minHeight:Q.minHeight,maxHeight:Q.maxHeight,initialData:{channelId:w.id,entry:w,config:L}}):null,Q?.placement===`replace-config`?null:(0,B.jsx)(le,{entry:w,locale:e,messages:R,autoStartPrimary:!0,compact:!0,onChanged:async()=>{await O(),await h.mutate(),await b()}},w.id),Q?.entrypoint&&Q.placement!==`before-config`?(0,B.jsx)(x,{extensionId:w.extensionId,extensionName:w.label,entrypoint:Q.entrypoint,permissions:Q.permissions,minHeight:Q.minHeight,maxHeight:Q.maxHeight,initialData:{channelId:w.id,entry:w,config:L}}):null,$&&ce?(0,B.jsxs)(`section`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:R.basicConfiguration}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:R.basicConfigurationHint})]}),(0,B.jsx)(re,{schema:W,values:L,onChange:e=>A(e),disabled:j,labels:ue})]}):null,$&&we(G)?(0,B.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,B.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,B.jsx)(ne,{className:`size-4 text-fg-muted`}),R.advancedConfiguration]}),(0,B.jsx)(`div`,{className:`border-t border-edge-subtle p-4`,children:(0,B.jsx)(re,{schema:G,values:L,onChange:e=>A(e),disabled:j,labels:ue})})]}):null,P?(0,B.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:P}):null]}):null})]}):(0,B.jsxs)(ae,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,B.jsx)(ie,{title:t.settingsSections.channels}),(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:R.tokenRequired})]})}export{Le as ChannelsSettingsPanel};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-avfvyZuQ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-Dtpbbe0s.js";import{r as u}from"./toast-z0toXu32.js";import{$a as d,As as f,Ba as p,Bo as m,Fo as h,Go as g,H as _,Ha as v,Is as y,Lo as b,Mi as x,Pa as S,Po as C,Rc as w,So as T,Ua as E,Wr as D,Ws as O,aa as ee,ba as k,ea as A,ec as j,ga as M,go as N,hs as te,ia as ne,ja as P,ji as F,ka as re,lc as I,mc as ie,na as L,ns as R,oa as z,ra as B,sa as ae,ta as oe,va as V,ya as se,za as H}from"./index-T0SaNd5a.js";import{n as ce,t as le}from"./settings-form-section-BFxBNxOG.js";import{i as ue,n as de,o as fe,r as pe,t as me}from"./dist-wO9a2_ID.js";var U=e(t(),1),W=n(),G=r(),K=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`,he=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function ge(e,t){return t.some(t=>t.connectorId===e.id)}function q(e,t){return t[e]??e}function J(e,t){return t.connectorCategoryTemplate.replace(`{{category}}`,q(e,t.connectorCategoryLabels))}function _e(){let e=(0,W.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 dark:border-edge-subtle`,"aria-hidden":!0,children:(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:i(`h-4 min-w-0 flex-1`,K)}),(0,G.jsx)(`div`,{className:i(`h-8 w-[4.5rem] shrink-0 rounded-lg`,K)})]}),(0,G.jsx)(`div`,{className:i(`h-3 w-full`,K)}),(0,G.jsx)(`div`,{className:i(`h-3 w-[88%]`,K)})]})})}),e[0]=t):t=e[0],t}function ve(){let e=(0,W.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,G.jsx)(`div`,{className:i(`h-4 w-48 max-w-full`,K)}),(0,G.jsx)(`div`,{className:i(`h-3 w-72 max-w-full`,K)})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[t,(0,G.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,G.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,K)}),(0,G.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,K)})]})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[n,(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,G.jsx)(`div`,{className:i(`h-8 w-20 rounded-md`,K)}),(0,G.jsx)(`div`,{className:i(`h-8 w-24 rounded-md`,K)}),(0,G.jsx)(`div`,{className:i(`h-8 w-28 rounded-md`,K)})]}),(0,G.jsx)(`div`,{className:i(`mt-3 h-20 rounded-xl`,K)})]}),e[2]=r):r=e[2],r}function ye(e){let t=(0,W.c)(52),{connector:n,installed:r,onInstall:a,t:o}=e,s;t[0]!==n.category||t[1]!==o?(s=J(n.category,o),t[0]=n.category,t[1]=o,t[2]=s):s=t[2];let c=s,l,u,d,f,m,h;if(t[3]!==c||t[4]!==n||t[5]!==r||t[6]!==a||t[7]!==o.install||t[8]!==o.installedBadge){let e=n.capabilities.slice(0,4),s=Math.max(0,n.capabilities.length-e.length),_;t[15]!==n||t[16]!==a||t[17]!==o.install?(_=e=>(0,G.jsxs)(p,{type:`button`,variant:`primary`,className:i(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>a(n),children:[(0,G.jsx)(g,{className:`size-4`}),o.install]}),t[15]=n,t[16]=a,t[17]=o.install,t[18]=_):_=t[18],l=_,h=`group flex min-h-[9.5rem] flex-col rounded-lg border border-edge bg-surface-panel p-4 shadow-surface transition-colors hover:border-accent/50 focus-within:border-accent/50`,u=`flex min-w-0 flex-1 flex-col`;let v;t[19]===n.displayName?v=t[20]:(v=(0,G.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[19]=n.displayName,t[20]=v);let y;t[21]===c?y=t[22]:(y=(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:c}),t[21]=c,t[22]=y);let b;t[23]!==v||t[24]!==y?(b=(0,G.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[v,y]})}),t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==r||t[27]!==l?(x=r?null:(0,G.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:l()}),t[26]=r,t[27]=l,t[28]=x):x=t[28];let S;t[29]!==r||t[30]!==o.installedBadge?(S=r?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,G.jsx)(I,{className:`size-3`,"aria-hidden":!0}),o.installedBadge]}):null,t[29]=r,t[30]=o.installedBadge,t[31]=S):S=t[31];let C;t[32]!==x||t[33]!==S?(C=(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[x,S]}),t[32]=x,t[33]=S,t[34]=C):C=t[34],t[35]!==b||t[36]!==C?(d=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,C]}),t[35]=b,t[36]=C,t[37]=d):d=t[37],t[38]===n.description?f=t[39]:(f=(0,G.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[38]=n.description,t[39]=f),m=e.length>0?(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[e.map(be),s>0?(0,G.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,s]}):null]}):null,t[3]=c,t[4]=n,t[5]=r,t[6]=a,t[7]=o.install,t[8]=o.installedBadge,t[9]=l,t[10]=u,t[11]=d,t[12]=f,t[13]=m,t[14]=h}else l=t[9],u=t[10],d=t[11],f=t[12],m=t[13],h=t[14];let _;t[40]!==u||t[41]!==d||t[42]!==f||t[43]!==m?(_=(0,G.jsxs)(`div`,{className:u,children:[d,f,m]}),t[40]=u,t[41]=d,t[42]=f,t[43]=m,t[44]=_):_=t[44];let v;t[45]!==r||t[46]!==l?(v=r?null:(0,G.jsx)(`div`,{className:`mt-4 flex items-center justify-end border-t border-edge pt-3 sm:hidden`,children:l(`w-full`)}),t[45]=r,t[46]=l,t[47]=v):v=t[47];let y;return t[48]!==h||t[49]!==_||t[50]!==v?(y=(0,G.jsxs)(`div`,{className:h,children:[_,v]}),t[48]=h,t[49]=_,t[50]=v,t[51]=y):y=t[51],y}function be(e){return(0,G.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e)}var xe=(0,U.memo)(function(e){let t=(0,W.c)(19),{loading:n,searchQuery:r,setSearchQuery:i,onReloadClick:a,onAddCustomServer:o,searchPlaceholder:s,addLabel:c,reloadLabel:l}=e,u;t[0]!==n||t[1]!==a||t[2]!==l?(u=(0,G.jsx)(D,{className:`size-9 shrink-0 p-0`,loading:n,label:l,title:l,onClick:a}),t[0]=n,t[1]=a,t[2]=l,t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,G.jsx)(T,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i(e.currentTarget.value),t[5]=i,t[6]=f);let m;t[7]!==s||t[8]!==r||t[9]!==f?(m=(0,G.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-base py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,G.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:r,onChange:f,placeholder:s,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),t[7]=s,t[8]=r,t[9]=f,t[10]=m):m=t[10];let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,G.jsx)(C,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=h):h=t[11];let g;t[12]!==c||t[13]!==o?(g=(0,G.jsxs)(p,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:o,children:[h,c]}),t[12]=c,t[13]=o,t[14]=g):g=t[14];let _;return t[15]!==u||t[16]!==m||t[17]!==g?(_=(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,m,g]}),t[15]=u,t[16]=m,t[17]=g,t[18]=_):_=t[18],_}),Se=/^([^:=]+)[:=](.*)$/;function Y(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}))}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Se.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function Ce(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function we(e){if(!e||typeof e!=`object`)return[{key:``,value:``}];let t=Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}));return t.length>0?t:[{key:``,value:``}]}function Te(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function Ee(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=(t&&typeof t==`object`?t:{}).servers,r={};if(!n||typeof n!=`object`||Array.isArray(n))return r;for(let[e,t]of Object.entries(n))!t||typeof t!=`object`||Array.isArray(t)||Te(t)&&(r[e]=t);return r}function De(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function Oe(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function ke(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=De(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=Oe(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=Ce(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function Ae(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:we(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function je(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function Me(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=t&&typeof t==`object`?t:{},r=n.servers,i=r&&typeof r==`object`&&!Array.isArray(r)?Object.entries(r).flatMap(([e,t])=>!t||typeof t!=`object`||Array.isArray(t)||Te(t)?[]:[Ae(e,t)]).sort((e,t)=>e.id.localeCompare(t.id)):[],a=typeof n.sessionIdleTtlMs==`number`?n.sessionIdleTtlMs:void 0;return{sessionIdleTtlMinutes:a==null?void 0:a===0?0:Math.round(a/6e4),servers:i}}function Ne(e){return ke(e)}async function Pe(e,t={}){let n={};for(let r of e.servers){let e=r.id.trim();if(e){if(t[e])throw Error(`Server id "${e}" is reserved by an installed connector.`);n[e]=ke(r)}}let r={servers:{...t,...n}};e.sessionIdleTtlMinutes!=null&&Number.isFinite(e.sessionIdleTtlMinutes)&&(r.sessionIdleTtlMs=e.sessionIdleTtlMinutes===0?0:Math.round(e.sessionIdleTtlMinutes*6e4)),await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),F()}function Fe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function Ie(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.uri!=`string`||typeof e.name!=`string`)continue;let r=e.uri.trim(),i=e.name.trim();!r||!i||t.push({uri:r,name:i,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,mimeType:typeof e.mimeType==`string`&&e.mimeType.trim()?e.mimeType.trim():void 0})}return t}function Le(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();r&&t.push({name:r,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,argumentCount:typeof e.argumentCount==`number`?e.argumentCount:0})}return t}async function Re(e,t){let n=await l(c(`/api/mcp/servers/${encodeURIComponent(e)}/test`),{method:`POST`,body:t?JSON.stringify({server:t}):void 0});if(!n.payload)throw Error(n.error??`MCP test failed`);let r=Fe(n.payload.tools),i=Ie(n.payload.resources),a=Le(n.payload.prompts);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,resourceCount:typeof n.payload.resourceCount==`number`?n.payload.resourceCount:i.length,promptCount:typeof n.payload.promptCount==`number`?n.payload.promptCount:a.length,tools:r,resources:i,prompts:a}}function ze(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function Be(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>600))return n*1e3}function Ve(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function X(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function He({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(null),[f,h]=(0,U.useState)(null),g=Ve(e),_=(0,U.useCallback)(async()=>{o(!0),h(null);try{let t=await Re(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){h(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),v=(0,U.useCallback)(async()=>{c(!0),h(null);try{await i()}catch(e){h(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,G.jsx)(`span`,{className:`rounded-full border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,G.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),g?(0,G.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-fg-subtle`,title:g,children:g}):null]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(p,{variant:`secondary`,disabled:a,onClick:()=>void _(),children:[a?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(b,{className:`size-4`}),t.testConnection]}),(0,G.jsxs)(p,{variant:`secondary`,onClick:r,children:[(0,G.jsx)(m,{className:`size-4`}),n.editCustomServer]}),(0,G.jsxs)(p,{variant:`ghost`,disabled:s,onClick:()=>void v(),children:[s?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(d,{className:`size-4`}),t.removeServer]})]})]}),f?(0,G.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:f}):null,l?(0,G.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:X(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]})}function Z(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function Ue(){return Z(await l(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function We(){return Z(await l(c(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function Ge(){return Z(await l(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var Ke=new Map,qe=300*1e3;async function Je(e,t=`all`,n){let r=e.trim(),i=t.trim()||`all`,a=n?.browse??!1,o=Math.max(n?.page??1,1),s=Math.max(n?.pageSize??24,1),u=`${i}:${r}:${a?`browse`:`search`}:${o}:${s}`,d=Date.now(),f=Ke.get(u);if(f&&f.expiresAt>d)return f.promise;let p=new URLSearchParams;r&&p.set(`q`,r),i!==`all`&&p.set(`source`,i),a&&p.set(`browse`,`1`),p.set(`page`,String(o)),p.set(`pageSize`,String(s));let m=l(c(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Z(e,`Could not search connector registries.`),n=Math.max(0,...(t.results??[]).map(e=>e.totalPages??0))||void 0;return{connectors:t.connectors,totalPages:n}});Ke.set(u,{expiresAt:d+qe,promise:m});try{return await m}catch(e){throw Ke.delete(u),e}}async function Ye(e){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Xe(e,t){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Ze(e,t){let n=await l(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return F(),Z(n,`Could not install connector.`).instance}async function Qe(e){await l(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),F()}async function $e(e){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function et(){return Z(await l(c(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function tt(e){return Z(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/authorize`),{method:`POST`}),`Could not start Composio authorization.`).oauth}async function nt(e){return Z(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function rt(e,t){let n=await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return F(),Z(n,`Could not update Composio scope.`).scope}async function it(e){return Z(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function at(e=50){return Z(await l(c(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}function ot(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function st(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||ot(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
|
|
2
|
-
`).toLowerCase().includes(r)}function ct(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function lt(e){let t=(0,W.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:a,searchEmptyLabel:o}=e,[s,c]=(0,U.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>st(e,s,r),t[4]=s,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=s,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===s?d=t[8]:(d=s.trim(),t[7]=s,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,G.jsx)(T,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,H),h=e=>c(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let g;t[12]!==s||t[13]!==a?(g=(0,G.jsxs)(`div`,{className:`relative`,children:[p,(0,G.jsx)(`input`,{type:`search`,value:s,placeholder:a,"aria-label":a,className:m,onChange:h})]}),t[12]=s,t[13]=a,t[14]=g):g=t[14];let _;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(_=f?(0,G.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,G.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[g,_]}),t[19]=g,t[20]=_,t[21]=v):v=t[21];let y;t[22]!==u||t[23]!==o||t[24]!==r?(y=(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o}):(0,G.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||ct(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,G.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,G.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=o,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function ut(e){let t=(0,W.c)(38),{open:n,onOpenChange:r,serverId:a,title:o,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:m}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,G.jsx)(B,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,k)}),t[0]=h):h=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(`fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,se,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,G.jsx)(E,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=_):_=t[2];let y;t[3]===o?y=t[4]:(y=(0,G.jsxs)(z,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[_,o]}),t[3]=o,t[4]=y);let b;t[5]!==a||t[6]!==s||t[7]!==f.length?(b=s.replace(`{{serverId}}`,a).replace(`{{count}}`,String(f.length)),t[5]=a,t[6]=s,t[7]=f.length,t[8]=b):b=t[8];let x;t[9]===b?x=t[10]:(x=(0,G.jsx)(L,{className:`mt-1 text-sm text-fg-muted`,children:b}),t[9]=b,t[10]=x);let S;t[11]!==y||t[12]!==x?(S=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[y,x]}),t[11]=y,t[12]=x,t[13]=S):S=t[13];let C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,G.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t[14]=C):C=t[14];let w;t[15]===d?w=t[16]:(w=(0,G.jsx)(A,{asChild:!0,children:(0,G.jsx)(p,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:C})}),t[15]=d,t[16]=w);let T;t[17]!==S||t[18]!==w?(T=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[S,w]}),t[17]=S,t[18]=w,t[19]=T):T=t[19];let D;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==a||t[25]!==m||t[26]!==f?(D=f.length>0?(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)(lt,{tools:f,stripPrefix:m,searchPlaceholder:c,searchEmptyLabel:l},`${a}-${n?`open`:`closed`}`)}):(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=a,t[25]=m,t[26]=f,t[27]=D):D=t[27];let O;t[28]===d?O=t[29]:(O=(0,G.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,G.jsx)(A,{asChild:!0,children:(0,G.jsx)(p,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=O);let j;t[30]!==T||t[31]!==D||t[32]!==O?(j=(0,G.jsxs)(ne,{children:[h,(0,G.jsxs)(oe,{className:g,children:[T,D,O]})]}),t[30]=T,t[31]=D,t[32]=O,t[33]=j):j=t[33];let M;return t[34]!==r||t[35]!==n||t[36]!==j?(M=(0,G.jsx)(ee,{open:n,onOpenChange:r,children:j}),t[34]=r,t[35]=n,t[36]=j,t[37]=M):M=t[37],M}var dt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H);function ft(e){return e.materialized.type===`composio`?e.connectorId.replace(/^composio-/,``):null}function pt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function mt({instance:e,t}){let n=ft(e),[r,a]=(0,U.useState)([]),[o,s]=(0,U.useState)([]),[c,l]=(0,U.useState)([]),[u,d]=(0,U.useState)(`read`),[f,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(null),_=(0,U.useCallback)(async()=>{if(!(!n||n===`api-key`)){m(!0),g(null);try{let[e,t,r,i]=await Promise.all([et().catch(()=>[]),it(n).catch(()=>[]),at(20).catch(()=>[]),nt(n).catch(()=>`read`)]);a(e.filter(e=>e.toolkit.toLowerCase()===n.toLowerCase())),s(t),l(r.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===n.toLowerCase())),d(i)}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}}},[n]);(0,U.useEffect)(()=>{_()},[_]);let v=(0,U.useCallback)(async()=>{if(n){m(!0),g(null);try{let e=await tt(n);window.open(e.connectUrl,`_blank`,`noopener,noreferrer`)}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}}},[n]),y=(0,U.useCallback)(async e=>{if(n){d(e);try{await rt(n,e),await _()}catch(e){g(e instanceof Error?e.message:String(e))}}},[_,n]);return n?n===`api-key`?(0,G.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,G.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium text-fg`,children:X(t.composioToolkitTitle,{toolkit:n})}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsxs)(M,{className:i(dt,`h-9 w-28 py-1`),value:u,onChange:e=>void y(e.currentTarget.value),children:[(0,G.jsx)(V,{value:`read`,children:t.composioScopeRead}),(0,G.jsx)(V,{value:`write`,children:t.composioScopeWrite}),(0,G.jsx)(V,{value:`admin`,children:t.composioScopeAdmin})]}),(0,G.jsxs)(p,{variant:`secondary`,disabled:f,onClick:()=>void v(),children:[f?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(te,{className:`size-4`}),t.connectOAuth]}),(0,G.jsx)(p,{variant:`ghost`,disabled:f,onClick:()=>void _(),children:t.refresh})]})]}),h?(0,G.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h}):null,(0,G.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),r.length?r.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,G.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.id}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.status})]},e.id)):(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),o.length?o.slice(0,8).map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,G.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[pt(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),c.length?c.slice(0,5).map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,G.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]}):null}function ht(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function gt({instance:e,onChanged:t,t:n,mcp:r}){let[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(null),[f,m]=(0,U.useState)(`health`),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(null),x=(0,U.useCallback)(async()=>{o(!0),v(null);try{let n=await $e(e.instanceId);u(n),n.toolCount>0&&m(`tools`),await t()}catch(e){v(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.instanceId,t]),S=(0,U.useCallback)(async()=>{c(!0),v(null);try{await Qe(e.instanceId),await t()}catch(e){v(e instanceof Error?e.message:String(e)),c(!1)}},[e.instanceId,t]),C=l?l.toolCount:e.usage.lastToolCount;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.displayName}),(0,G.jsx)(`span`,{className:`rounded-full border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.catalogBadge})]}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.materialized.type===`mcp`?X(n.mcpServerRuntime,{serverId:e.materialized.serverId}):X(n.runtimeLabel,{runtime:e.materialized.type})})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[e.materialized.type===`mcp`?(0,G.jsxs)(p,{variant:`secondary`,disabled:a,onClick:()=>void x(),children:[a?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(b,{className:`size-4`}),n.test]}):null,(0,G.jsxs)(p,{variant:`ghost`,disabled:s,onClick:()=>void S(),children:[s?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(d,{className:`size-4`}),n.remove]})]})]}),_?(0,G.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:_}):null,(0,G.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[[`health`,N,n.detailHealth],[`tools`,E,`${n.detailTools} ${l?l.toolCount:e.usage.lastToolCount??``}`],[`resources`,O,`${n.detailResources} ${l?l.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,y,`${n.detailPrompts} ${l?l.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,te,n.detailPermissions]].map(([e,t,n])=>(0,G.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,f===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>m(e),children:[(0,G.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,G.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[f===`health`?(0,G.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,G.jsxs)(`p`,{children:[n.statusLabel,` `,(0,G.jsx)(`span`,{className:l?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:ht(l?.status??e.usage.lastHealthStatus,n)})]}),(0,G.jsxs)(`p`,{children:[n.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():n.never]}),l?.action?(0,G.jsx)(`p`,{children:l.action}):null]}):null,f===`tools`?l?.tools.length?(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:X(n.toolsAvailable,{count:String(l.tools.length)})}),(0,G.jsx)(p,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>g(!0),children:r.viewAllTools})]}),l.tools.slice(0,8).map(e=>(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.shortName??e.name}),e.description?(0,G.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.description}):null]},e.name))]}):(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`p`,{className:`text-fg-muted`,children:C?X(n.toolsLastCheckSummary,{count:String(C)}):n.toolsRunTestHint}),(0,G.jsxs)(p,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void x(),children:[a?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(b,{className:`size-4`}),n.test]})]}):null,f===`resources`?l?.resources.length?(0,G.jsx)(`div`,{className:`grid gap-2`,children:l.resources.slice(0,8).map(e=>(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.title??e.name}),(0,G.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.uri})]},e.uri))}):(0,G.jsx)(`p`,{className:`text-fg-muted`,children:n.resourcesRunTestHint}):null,f===`prompts`?l?.prompts.length?(0,G.jsx)(`div`,{className:`grid gap-2`,children:l.prompts.slice(0,8).map(e=>(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.title??e.name}),e.description?(0,G.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.description}):null]},e.name))}):(0,G.jsx)(`p`,{className:`text-fg-muted`,children:n.promptsRunTestHint}):null,f===`permissions`?(0,G.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,G.jsx)(`p`,{children:X(n.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,G.jsx)(`p`,{children:e.materialized.type===`mcp`?X(n.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):X(n.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,G.jsx)(`p`,{children:e.materialized.type===`mcp`?n.mcpPolicyHint:n.connectorPolicyHint})]}):null]}),e.materialized.type===`composio`?(0,G.jsx)(mt,{instance:e,t:n}):null]}),e.materialized.type===`mcp`?(0,G.jsx)(ut,{open:h,onOpenChange:g,serverId:e.materialized.serverId,title:X(n.installedToolsDialogTitle,{name:e.displayName}),subtitle:n.installedToolsDialogSubtitle,searchPlaceholder:r.toolsDialogSearchPlaceholder,searchEmptyLabel:r.toolsDialogSearchEmpty,emptyLabel:n.toolsRunTestHint,closeLabel:r.toolsDialogClose,tools:l?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}var _t=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H),vt=i(_t,`min-h-28 font-mono`);function yt(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function bt(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function xt(e){let t={};for(let n of e.setup.secrets??[])t[n.key]=``;let n={};for(let t of e.setup.config??[])n[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:t,config:n,installing:!1,error:null,result:null,health:null,oauth:{flow:null,connected:e.auth.mode!==`oauth`}}}function St({draft:e,onChange:t,onClose:n,onInstalled:r,t:a}){let{connector:o}=e,s=e.result?`complete`:e.installing?`health`:`configure`,c=[{id:`configure`,label:a.installStepConfigure},{id:`health`,label:a.installStepHealth},{id:`complete`,label:a.installStepComplete}],l=(0,U.useCallback)(async()=>{t({...e,installing:!0,error:null});try{let n=await Ye(o.id);window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),t({...e,installing:!1,error:null,oauth:{flow:n,connected:!1}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o.id,e,t]),u=(0,U.useCallback)(async()=>{if(e.oauth.flow){t({...e,installing:!0,error:null});try{await Xe(o.id,e.oauth.flow.deviceCode),t({...e,installing:!1,error:null,oauth:{...e.oauth,connected:!0}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}}},[o.id,e,t]),d=(0,U.useCallback)(async()=>{t({...e,installing:!0,error:null,result:null,health:null});try{if(o.auth.mode===`oauth`&&!e.oauth.connected)throw Error(a.oauthRequiredBeforeInstall);let n={};for(let t of o.setup.config??[]){let r=bt(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let i=await Ze(o.id,{secrets:e.secrets,config:n,definition:o.source===`registry`?o:void 0}),s=null;try{s=await $e(i.instanceId)}catch{s=null}t({...e,installing:!1,result:i,health:s}),await r()}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o,e,t,r,a.oauthRequiredBeforeInstall]);return(0,G.jsx)(ee,{open:!0,onOpenChange:e=>{e||n()},children:(0,G.jsxs)(ne,{children:[(0,G.jsx)(B,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,G.jsxs)(oe,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex max-h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(z,{className:`text-base font-semibold text-fg`,children:X(a.installDialogTitle,{name:o.displayName})}),(0,G.jsx)(L,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:o.description})]}),(0,G.jsx)(A,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,S.focusRingPanel),"aria-label":a.modalClose,children:[(0,G.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,G.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,G.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":a.installProgressAria,children:c.map((e,t)=>{let n=c.findIndex(e=>e.id===s);return(0,G.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,G.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.auth.mode===`oauth`?(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,G.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:a.oauthTitle}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.oauthHint}),e.oauth.flow?(0,G.jsxs)(`div`,{className:`mt-3 rounded-xl bg-surface-base p-3 text-sm text-fg-muted`,children:[(0,G.jsx)(`p`,{children:X(a.oauthOpenCodePrefix,{url:e.oauth.flow.verificationUri})}),(0,G.jsx)(`p`,{className:`mt-2 font-mono text-lg font-semibold tracking-widest text-fg`,children:e.oauth.flow.userCode})]}):null,e.oauth.connected?(0,G.jsx)(`p`,{className:`mt-3 rounded-xl bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700`,children:a.oauthConnected}):null,(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,G.jsxs)(p,{variant:`secondary`,disabled:e.installing,onClick:()=>void l(),children:[e.installing&&!e.oauth.flow?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(b,{className:`size-4`}),a.oauthConnectButton]}),(0,G.jsxs)(p,{variant:`primary`,disabled:e.installing||!e.oauth.flow,onClick:()=>void u(),children:[e.installing&&e.oauth.flow?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(I,{className:`size-4`}),a.oauthAuthorizedButton]})]})]}):null,(o.setup.secrets??[]).map(n=>(0,G.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,G.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,G.jsx)(re,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:a.secretInputLabels,placeholder:n.required?a.requiredPlaceholder:a.optionalPlaceholder})]},n.key)),(o.setup.config??[]).map(n=>(0,G.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,G.jsx)(`textarea`,{className:vt,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,G.jsx)(`input`,{className:_t,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,G.jsx)(R,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),a.installingTitle]}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.installingHint})]}):null,e.error?(0,G.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,e.result?(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium text-fg`,children:X(a.installedAs,{target:e.result.materialized.type===`mcp`?e.result.materialized.serverId:e.result.instanceId})}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:X(a.runtimeLabel,{runtime:e.result.materialized.type.toUpperCase()})})]}),(0,G.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?a.healthStatusHealthy:yt(e.health?.status,a)})]}),e.health?(0,G.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,G.jsx)(`div`,{children:a.toolsMetric})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,G.jsx)(`div`,{children:a.resourcesMetric})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,G.jsx)(`div`,{children:a.promptsMetric})]})]}):(0,G.jsx)(`p`,{className:`mt-3`,children:a.installedWithoutHealth}),e.health?.action?(0,G.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,G.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,G.jsxs)(p,{variant:`primary`,disabled:!!e.result||e.installing||o.auth.mode===`oauth`&&!e.oauth.connected,onClick:()=>void d(),children:[e.installing?(0,G.jsx)(R,{className:`size-4 animate-spin`}):e.result?(0,G.jsx)(I,{className:`size-4`}):(0,G.jsx)(g,{className:`size-4`}),e.result?a.installedBadge:a.install]})})]})]})})}function Ct(e,t){let n=e.length+1,r=`server-${n}`,i=new Set([...e.map(e=>e.id.trim()),...t]);for(;i.has(r);)n+=1,r=`server-${n}`;return je(r)}function wt(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.description,e.category,e.kind,e.source,...e.tags??[]].some(e=>e.toLowerCase().includes(n)):!0}function Tt(e,t,n){return e.filter(e=>wt(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Et(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.connectorId,e.instanceId,e.status,e.connectionStatus??``,e.materialized.type,e.materialized.type===`mcp`?e.materialized.serverId:e.materialized.id].some(e=>e.toLowerCase().includes(n)):!0}function Dt(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function Ot(e,t,n){let r=e.key.trim();if(r)return`key:${r}`;let i=e.value.trim();return i?`value:${i}`:`empty:${n.slice(0,t).filter(e=>!e.key.trim()&&!e.value.trim()).length}`}function kt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H)}function At({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:a,pasteFailed:o,keyPlaceholder:s,valuePlaceholder:c,headers:l,onChange:u}){let f=(e,t)=>{u(l.map((n,r)=>r===e?{...n,...t}:n))},m=()=>{u([...l,{key:``,value:``}])},h=e=>{let t=l.filter((t,n)=>n!==e);u(t.length>0?t:[{key:``,value:``}])},g=async()=>{try{let e=await P();if(!e){window.alert(o);return}let t=Y(e);if(!t?.length){window.alert(o);return}u(t)}catch{window.alert(o)}};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,G.jsx)(`span`,{children:e}),t?(0,G.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,G.jsxs)(p,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void g(),children:[(0,G.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),a]})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{className:i(kt(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:s,onChange:e=>f(t,{key:e.target.value})}),(0,G.jsx)(`input`,{className:i(kt(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:c,onChange:e=>f(t,{value:e.target.value})}),(0,G.jsx)(p,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:l.length<=1&&!e.key&&!e.value,onClick:()=>h(t),"aria-label":r,children:(0,G.jsx)(d,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},Ot(e,t,l)))}),(0,G.jsxs)(`button`,{type:`button`,className:i(`self-start text-sm text-accent hover:underline`,S.press),onClick:m,children:[`+ `,n]})]})}var jt=[`stdio`,`sse`,`streamable-http`];function Q(e){let t=(0,W.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,G.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,G.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,G.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function $(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H)}function Mt(e){let t=(0,W.c)(67),{row:n,t:r,onUpdate:a,idConflictMessage:o}=e,s=r.transportLabel,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=$(),t[0]=c):c=t[0];let l=n.transport,u;t[1]===a?u=t[2]:(u=e=>a({transport:e.target.value}),t[1]=a,t[2]=u);let d;t[3]===r.transportLabels?d=t[4]:(d=jt.map(e=>(0,G.jsx)(V,{value:e,children:r.transportLabels[e]},e)),t[3]=r.transportLabels,t[4]=d);let f;t[5]!==n.transport||t[6]!==u||t[7]!==d?(f=(0,G.jsx)(M,{className:c,value:l,onChange:u,children:d}),t[5]=n.transport,t[6]=u,t[7]=d,t[8]=f):f=t[8];let p;t[9]!==r.transportLabel||t[10]!==f?(p=(0,G.jsx)(Q,{label:s,required:!0,children:f}),t[9]=r.transportLabel,t[10]=f,t[11]=p):p=t[11];let m=r.serverIdLabel,h;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(h=$(),t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=e=>a({id:e.target.value}),t[13]=a,t[14]=g);let _;t[15]!==n.id||t[16]!==r.serverIdPlaceholder||t[17]!==g?(_=(0,G.jsx)(`input`,{className:h,value:n.id,placeholder:r.serverIdPlaceholder,onChange:g}),t[15]=n.id,t[16]=r.serverIdPlaceholder,t[17]=g,t[18]=_):_=t[18];let v;t[19]===o?v=t[20]:(v=o?(0,G.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:o}):null,t[19]=o,t[20]=v);let y;t[21]!==r.serverIdLabel||t[22]!==_||t[23]!==v?(y=(0,G.jsxs)(Q,{label:m,required:!0,children:[_,v]}),t[21]=r.serverIdLabel,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==a||t[26]!==n.argsText||t[27]!==n.command||t[28]!==n.cwd||t[29]!==n.envJson||t[30]!==n.headers||t[31]!==n.transport||t[32]!==n.url||t[33]!==r.addHeader||t[34]!==r.argsHint||t[35]!==r.argsLabel||t[36]!==r.commandLabel||t[37]!==r.cwdLabel||t[38]!==r.envHint||t[39]!==r.envLabel||t[40]!==r.headerKeyPlaceholder||t[41]!==r.headerValuePlaceholder||t[42]!==r.headersLabel||t[43]!==r.optionalSuffix||t[44]!==r.pasteHeaders||t[45]!==r.pasteHeadersFailed||t[46]!==r.removeHeader||t[47]!==r.urlLabel?(b=n.transport===`stdio`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Q,{label:r.commandLabel,required:!0,children:(0,G.jsx)(`input`,{className:$(),value:n.command,onChange:e=>a({command:e.target.value})})}),(0,G.jsx)(Q,{label:r.argsLabel,description:r.argsHint,children:(0,G.jsx)(`input`,{className:$(),value:n.argsText,onChange:e=>a({argsText:e.target.value})})}),(0,G.jsx)(Q,{label:r.cwdLabel,children:(0,G.jsx)(`input`,{className:$(),value:n.cwd,onChange:e=>a({cwd:e.target.value})})}),(0,G.jsx)(Q,{label:r.envLabel,description:r.envHint,children:(0,G.jsx)(`textarea`,{className:i($(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>a({envJson:e.target.value})})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`md:col-span-2`,children:(0,G.jsx)(Q,{label:r.urlLabel,required:!0,children:(0,G.jsx)(`input`,{className:i($(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>a({url:e.target.value})})})}),(0,G.jsx)(At,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>a({headers:e})})]}),t[25]=a,t[26]=n.argsText,t[27]=n.command,t[28]=n.cwd,t[29]=n.envJson,t[30]=n.headers,t[31]=n.transport,t[32]=n.url,t[33]=r.addHeader,t[34]=r.argsHint,t[35]=r.argsLabel,t[36]=r.commandLabel,t[37]=r.cwdLabel,t[38]=r.envHint,t[39]=r.envLabel,t[40]=r.headerKeyPlaceholder,t[41]=r.headerValuePlaceholder,t[42]=r.headersLabel,t[43]=r.optionalSuffix,t[44]=r.pasteHeaders,t[45]=r.pasteHeadersFailed,t[46]=r.removeHeader,t[47]=r.urlLabel,t[48]=b):b=t[48];let x=r.timeoutLabel,S=r.timeoutHint,C;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(C=$(),t[49]=C):C=t[49];let w;t[50]===n?w=t[51]:(w=ze(n),t[50]=n,t[51]=w);let T;t[52]===a?T=t[53]:(T=e=>a({connectionTimeoutMs:Be(e.target.value)}),t[52]=a,t[53]=T);let E;t[54]!==r.timeoutPlaceholder||t[55]!==w||t[56]!==T?(E=(0,G.jsx)(`input`,{type:`number`,min:1,max:600,className:C,value:w,placeholder:r.timeoutPlaceholder,onChange:T}),t[54]=r.timeoutPlaceholder,t[55]=w,t[56]=T,t[57]=E):E=t[57];let D;t[58]!==r.timeoutHint||t[59]!==r.timeoutLabel||t[60]!==E?(D=(0,G.jsx)(Q,{label:x,description:S,children:E}),t[58]=r.timeoutHint,t[59]=r.timeoutLabel,t[60]=E,t[61]=D):D=t[61];let O;return t[62]!==y||t[63]!==b||t[64]!==D||t[65]!==p?(O=(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[p,y,b,D]}),t[62]=y,t[63]=b,t[64]=D,t[65]=p,t[66]=O):O=t[66],O}function Nt({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:a,config:o,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:d}){let[f,m]=(0,U.useState)(n),[h,g]=(0,U.useState)(!1),[_,y]=(0,U.useState)(!1),[x,C]=(0,U.useState)(null),[w,T]=(0,U.useState)({status:`idle`}),[D,O]=(0,U.useState)(null),k=n.id.trim(),j=f.id.trim()!==k&&s.has(f.id.trim())||s.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,M=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,N=f.id.trim().length>0&&!j&&!M&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),te=(0,U.useCallback)(async()=>{if(f.id.trim()){y(!0),C(null),T({status:`loading`});try{T({status:`ok`,tools:(await Re(f.id.trim(),Ne(f))).tools})}catch(e){T({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{y(!1)}}},[f]),P=(0,U.useCallback)(async()=>{if(!(!N||h)){g(!0),C(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await Pe({sessionIdleTtlMinutes:a,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Ee(o)),await d(),u()}catch(e){C(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[N,o,r,n.clientKey,t,u,d,k,f,h,a]);return e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ee,{open:e,onOpenChange:e=>{e||u()},children:(0,G.jsxs)(ne,{children:[(0,G.jsx)(B,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,G.jsxs)(oe,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(z,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,G.jsx)(L,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,G.jsx)(A,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,S.focusRingPanel),"aria-label":l.modalClose,children:[(0,G.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,G.jsx)(Mt,{row:f,t:c,onUpdate:e=>{m(t=>({...t,...e})),C(null)},idConflictMessage:j??M}),w.status===`ok`?(0,G.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base px-3 py-2.5`,children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,G.jsx)(E,{className:`size-4 text-accent`,"aria-hidden":!0}),w.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(w.tools.length))]}),w.tools.length>0?(0,G.jsx)(p,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>O(w.tools),children:c.viewAllTools}):null]})}):null,w.status===`error`?(0,G.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:w.message}):null,x?(0,G.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:x}):null]})}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,G.jsxs)(p,{variant:`secondary`,disabled:!f.id.trim()||_,onClick:()=>void te(),children:[_?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(b,{className:`size-4`}),c.testConnection]}),(0,G.jsx)(A,{asChild:!0,children:(0,G.jsx)(p,{variant:`secondary`,children:l.modalCancel})}),(0,G.jsxs)(p,{variant:`primary`,disabled:!N||h,onClick:()=>void P(),children:[h?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(I,{className:`size-4`}),h?c.saving:l.modalSave]})]})]})]})}),D?(0,G.jsx)(ut,{open:!0,onOpenChange:e=>{e||O(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:D,stripPrefix:`${f.id.trim()}__`}):null]}):null}var Pt=`mprov`,Ft=`smithery`,It=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H);function Lt(){let e=a(o(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=s(e=>e.token),c=!!r,[l,d]=w(),m=l.get(Pt)?.trim()||Ft,[g,v]=(0,U.useState)(`marketplace`),[y,b]=(0,U.useState)({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!0,error:null}),[C,T]=(0,U.useState)(!1),[E,D]=(0,U.useState)(1),[O,ee]=(0,U.useState)(void 0),[k,A]=(0,U.useState)(``),[j,M]=(0,U.useState)(m),[N,te]=(0,U.useState)(`name`),[ne,P]=(0,U.useState)(null),[F,re]=(0,U.useState)(null),[I,L]=(0,U.useState)(void 0),[z,B]=(0,U.useState)(!1),[oe,V]=(0,U.useState)(!1),{data:se,mutate:H}=x(c),W=se?.payload?.config,K=(0,U.useMemo)(()=>W===void 0?null:Me(W),[W]),q=K?.servers??[];(0,U.useEffect)(()=>{K&&L(K.sessionIdleTtlMinutes)},[K]);let J=(0,U.useCallback)(async()=>{if(!r){b({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:null});return}b(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Ue(),Ge(),We()]);b(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,registries:n,loading:!1,error:null}))}catch(e){b({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,U.useEffect)(()=>{J()},[J]);let be=l.toString(),Se=(0,U.useRef)(be);(0,U.useEffect)(()=>{Se.current!==be&&(Se.current=be,M(l.get(Pt)?.trim()||Ft))},[l,be]);let Y=(0,U.useMemo)(()=>y.registries.map(e=>e.id),[y.registries]);(0,U.useEffect)(()=>{if(Y.length===0||Y.includes(j))return;let e=Y.includes(Ft)?Ft:Y[0];e&&M(e)},[j,Y]),(0,U.useEffect)(()=>{if(!j||j===l.get(Pt))return;let e=new URLSearchParams(l);e.set(Pt,j),Se.current=e.toString(),d(e,{replace:!0})},[j,l,d]);let Ce=(0,U.useCallback)(async e=>{let t=k.trim(),n=e?.browse??!1,r=Math.max(e?.page??1,1),i=e?.append??!1;if(!(!c||!t&&!n)){T(!0),i?b(e=>({...e,error:null})):(D(1),ee(void 0),b(e=>({...e,registryCatalog:[],error:null})));try{let e=await Je(t,j,{browse:n,page:r});D(r),ee(e.totalPages),b(t=>({...t,registryCatalog:i?[...t.registryCatalog,...e.connectors].filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t):e.connectors}))}catch(e){b(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{T(!1)}}},[c,k,j]);(0,U.useEffect)(()=>{if(g!==`marketplace`)return;let e=window.setTimeout(()=>{k.trim()?Ce():j&&Ce({browse:!0})},k.trim()?350:0);return()=>window.clearTimeout(e)},[j,k,Ce,y.loading,g]);let we=(0,U.useMemo)(()=>new Set(y.instances.map(e=>e.connectorId)),[y.instances]),Te=(0,U.useMemo)(()=>new Set(y.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[y.instances]),De=(0,U.useCallback)(async e=>{if(!K||W===void 0)return;let t=q.filter(t=>t.clientKey!==e.clientKey);await Pe({sessionIdleTtlMinutes:K.sessionIdleTtlMinutes,servers:t},Ee(W)),await H(),await J()},[W,q,J,K,H]),Oe=(0,U.useCallback)(()=>{re({mode:`add`,row:Ct(q,Te)})},[q,Te]),ke=(0,U.useCallback)(async()=>{if(!(!K||W===void 0||z)){B(!0),V(!1);try{await Pe({sessionIdleTtlMinutes:I,servers:q},Ee(W)),await H(),V(!0),u({type:`success`,title:n.saved})}finally{B(!1)}}},[W,q,K,H,I,z]),Ae=ae(e=>e.setPageHeader),je=ae(e=>e.clearPageHeader),Ne=(0,U.useMemo)(()=>(0,G.jsx)(xe,{loading:y.loading||C,searchQuery:k,setSearchQuery:A,onReloadClick:J,onAddCustomServer:Oe,searchPlaceholder:g===`marketplace`?t.marketplaceSearchPlaceholder:g===`builtin`?t.builtinSearchPlaceholder:g===`user`?t.userSearchPlaceholder:t.configSearchPlaceholder,addLabel:t.addCustomServer,reloadLabel:t.reload}),[t,J,Oe,C,k,y.loading,g]);(0,U.useLayoutEffect)(()=>(Ae({startExtra:null,main:(0,G.jsx)(`div`,{className:`min-w-0`,children:(0,G.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ne}),()=>je()),[je,t.title,Ne,Ae]);let Fe=y.instances.length+q.length,Ie=(0,U.useMemo)(()=>Tt(y.catalog.filter(e=>e.source===`builtin`),k,N),[N,k,y.catalog]),Le=(0,U.useMemo)(()=>Tt(y.registryCatalog,k,N),[N,k,y.registryCatalog]),Re=g===`marketplace`&&!!(O&&E<O),ze=(0,U.useMemo)(()=>y.instances.filter(e=>Et(e,k)),[k,y.instances]),Be=(0,U.useMemo)(()=>q.filter(e=>Dt(e,k)),[q,k]),Ve=ze.length+Be.length,X=[{id:`marketplace`,label:t.tabMarketplace},{id:`builtin`,label:t.tabBuiltin,count:Ie.length},{id:`user`,label:t.tabUser,count:Fe},{id:`config`,label:t.tabConfig}];return(0,G.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,G.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[c?null:(0,G.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,G.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,G.jsx)(_,{items:X,activeTab:g,onChange:v,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`}),(0,G.jsxs)(`div`,{className:`flex min-h-9 min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[g===`marketplace`?(0,G.jsx)(`div`,{className:`inline-flex h-9 max-w-full shrink-0 overflow-x-auto rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,role:`group`,"aria-label":t.registrySourceAria,children:y.registries.map(e=>(0,G.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,S.focusRingPanel,j===e.id?`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`:`text-fg-muted hover:text-fg`),"aria-pressed":j===e.id,onClick:()=>M(e.id),children:e.displayName},e.id))}):null,g!==`user`&&g!==`config`?(0,G.jsxs)(ue,{children:[(0,G.jsx)(fe,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,S.transition,S.focusRingPanel),children:[(0,G.jsx)(f,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:N===`name`?t.sortName:t.sortSource}),(0,G.jsx)(ie,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,G.jsx)(pe,{children:(0,G.jsxs)(me,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,G.jsx)(de,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>te(`name`),children:t.sortName}),(0,G.jsx)(de,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>te(`source`),children:t.sortSource})]})})]}):null]})]}),y.error?(0,G.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:y.error}):null,g===`user`&&c?(0,G.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.installedTitle}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.installedHint})]}),y.loading?(0,G.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:he.slice(0,3).map(e=>(0,G.jsx)(ve,{},e))}):Fe===0||Ve===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:Fe===0?t.installedEmpty:t.userEmpty}):(0,G.jsxs)(`div`,{className:`grid gap-3`,children:[ze.map(e=>(0,G.jsx)(gt,{instance:e,onChanged:J,t,mcp:n},e.instanceId)),Be.map(e=>(0,G.jsx)(He,{row:e,t:n,cs:t,onEdit:()=>re({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>De(e)},e.clientKey))]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,g===`config`&&c?(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,G.jsxs)(le,{children:[(0,G.jsx)(ce,{icon:h,title:n.globalTitle,subtitle:n.globalHint}),(0,G.jsx)(`div`,{className:`max-w-xl`,children:(0,G.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.idleTtlLabel}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:0,className:i(It,`w-40 flex-none`),value:I??``,placeholder:n.idleTtlPlaceholder,onChange:e=>{let t=e.target.value.trim();L(t===``?void 0:Number.parseInt(t,10)),V(!1)}}),(0,G.jsxs)(p,{variant:`secondary`,disabled:z,onClick:()=>void ke(),children:[z?(0,G.jsx)(R,{className:`size-4 animate-spin`}):null,n.save]})]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.idleTtlHint})]})})]})}):null,g===`marketplace`&&c?(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:C&&Le.length===0?(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:he.map(e=>(0,G.jsx)(_e,{},e))}):k.trim()&&Le.length===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}):!k.trim()&&Le.length===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceStartHint}):(0,G.jsxs)(`div`,{className:`relative`,children:[C?(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":t.loading,children:(0,G.jsx)(R,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Le.map(e=>(0,G.jsx)(ye,{connector:e,installed:we.has(e.id)||ge(e,y.instances),onInstall:e=>P(xt(e)),t},e.id))}),Re?(0,G.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,G.jsxs)(p,{type:`button`,variant:`secondary`,disabled:C,onClick:()=>void Ce({browse:!k.trim(),page:E+1,append:!0}),children:[C?(0,G.jsx)(R,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})}):null,g===`builtin`&&c?(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:y.loading?(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:he.map(e=>(0,G.jsx)(_e,{},e))}):Ie.length===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.builtinEmpty}):(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Ie.map(e=>(0,G.jsx)(ye,{connector:e,installed:we.has(e.id)||ge(e,y.instances),onInstall:e=>P(xt(e)),t},e.id))})}):null]}),ne?(0,G.jsx)(St,{draft:ne,onChange:P,onClose:()=>P(null),t,onInstalled:async()=>{await J(),await H(),v(`user`)}}):null,F?(0,G.jsx)(Nt,{open:!0,mode:F.mode,initialRow:F.row,existingCustomServers:q,sessionIdleTtlMinutes:I,config:W,managedServerIds:Te,t:n,cs:t,onClose:()=>re(null),onSaved:async()=>{await H(),await J(),v(`user`)}},`${F.mode}-${F.row.clientKey}`):null]})})}export{Lt as ConnectorsPage};
|