@xopcai/xopc 0.0.113 → 0.0.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CBlklyNr.js → agent-avatar-dicebear-Fp-p7bP1.js} +1 -1
- package/dist/gateway/static/root/assets/agent-browser-settings-page-CWh7trjd.js +6 -0
- package/dist/gateway/static/root/assets/agent-defaults-tabbed-page-kC8OuLoj.js +1 -0
- package/dist/gateway/static/root/assets/agents-DJWG26Si.js +71 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-28E_WfMe.js → app-management-settings-panel-v24i25Oj.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Do1z0XgJ.js → appearance-settings-ycbdJRuZ.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-0V3DXZ7J.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BAFlsov_.js → archive-plugin-CJzSADJo.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-V3qGPC3x.js → attachment-load-BTAB4zGS.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-DT8NvA6W.js → binary-plugins-DXR1-mct.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CdLMEcHd.js → block-editor-CzQri9h2.js} +44 -44
- package/dist/gateway/static/root/assets/channels-settings-CIKOkYdO.js +1 -0
- package/dist/gateway/static/root/assets/{config-api-Bf5mjpu7.js → config-api-DRqjEvAx.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-settings-ClrDS5jH.js +2 -0
- package/dist/gateway/static/root/assets/{cron-api--pAB_rps.js → cron-api-BXaZXv1o.js} +1 -1
- package/dist/gateway/static/root/assets/cron-page-Chi_4u4P.js +3 -0
- package/dist/gateway/static/root/assets/dreaming-settings-B0_rs2tj.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-BGhE7msg.js → extension-debug-page-DSkqMYo7.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CvpI45WG.js → extension-page-h2dGDbMN.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DAmR5FUe.js → extension-settings-page-hN99RhOi.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-NZmjSXLl.js → fetch-D9QqUtzZ.js} +1 -1
- package/dist/gateway/static/root/assets/{format-interval-label-qhth3BMV.js → format-interval-label-D6E687rG.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-CaXBt-9R.js → gateway-config-api-CLt_SKTC.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DphpbLBc.js → gateway-settings-1PDi4lI0.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-Be1omjh3.js → gateway-startup-retry-N7Z_sz7p.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-D_wwXL-t.js +1 -0
- package/dist/gateway/static/root/assets/goals-page-DZ2toZ8y.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-ceEBjnfc.js → goals-settings-LFlwtIKE.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-config-api-BzO6G4fD.js → heartbeat-config-api-DGPadTw-.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DCST9-du.js → heartbeat-settings-BHHAs8ZX.js} +1 -1
- package/dist/gateway/static/root/assets/index-DefIdW9q.js +122 -0
- package/dist/gateway/static/root/assets/index-DzmWBkq-.css +1 -0
- package/dist/gateway/static/root/assets/{interval-presets-DJmshV8n.js → interval-presets-CEklPQ_r.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-9AUUlQ5Q.js → keyboard-shortcuts-settings-Ce_aQ8Iv.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-j_D2QTuQ.js +2 -0
- package/dist/gateway/static/root/assets/{markdown-split-CYYELqAr.js → markdown-split-BMz3xPXO.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BEcMR2M8.js → media-plugins-BalOSoz9.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BN_WiUg0.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-CMH_TmZz.js +2 -0
- package/dist/gateway/static/root/assets/note-detail-page-O18BrQPq.js +2 -0
- package/dist/gateway/static/root/assets/{note-image-lightbox-DNAoPcmm.js → note-image-lightbox-C5D1Q5mY.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-B_ZYCmY9.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BPLz0AIv.js → preview-open-alternatives-CYFR5U9l.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CwKgWixY.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-CrWwWRVK.js → save-bar-controls-BQ79Z5IP.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-CF2sadvN.js → schedule-field-Bgk6Emue.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Di5cKjYE.js → schema-form-DzS36TMa.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-C4fcD-7B.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-Ad2OJ86w.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-Chh282jW.js → settings-collapsible-section-CdjFnSAy.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-Dq-83cQd.js → settings-form-section-DZLy_exu.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-D2BMY5wo.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-aWwxl_E1.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-0FXYnSUA.js → share-preview-page-_qRDr4g_.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DUE83uIf.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-mWKJcrog.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-0Sx1Q58n.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-W1pTcojB.js → system-settings-panel-hqaBF5aG.js} +1 -1
- package/dist/gateway/static/root/assets/{use-agent-defaults-form-BVRvkK7m.js → use-agent-defaults-form-zbVIQLOA.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CgJibfMM.js → use-channel-catalog-CbXq97rT.js} +1 -1
- package/dist/gateway/static/root/assets/{use-settings-tab-guard-Bw_qkRQE.js → use-settings-tab-guard-DwS3drWK.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-D6HR0hR2.js +1 -0
- package/dist/gateway/static/root/assets/{voice-player-store-C7lziaAx.js → voice-player-store-DSuOd9zy.js} +1 -1
- package/dist/gateway/static/root/assets/workflow-page.utils-C0Uq3xyq.js +1 -0
- package/dist/gateway/static/root/assets/workflows-page-DW0fmWhQ.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 +8 -0
- package/dist/src/agent/agent-manager.js +57 -22
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/bootstrap/project-agents-context.d.ts +2 -0
- package/dist/src/agent/bootstrap/project-agents-context.js +32 -0
- package/dist/src/agent/bootstrap/project-agents-context.js.map +1 -0
- package/dist/src/agent/goals/persistent-goal-service.js +2 -4
- package/dist/src/agent/goals/persistent-goal-service.js.map +1 -1
- package/dist/src/agent/inbound/inbound-loop.js +5 -1
- package/dist/src/agent/inbound/inbound-loop.js.map +1 -1
- package/dist/src/agent/inbound/turn-dispatcher.d.ts +2 -2
- package/dist/src/agent/inbound/turn-dispatcher.js +2 -2
- package/dist/src/agent/inbound/turn-dispatcher.js.map +1 -1
- package/dist/src/agent/mcp/bundle-mcp-materialize.d.ts +27 -0
- package/dist/src/agent/mcp/bundle-mcp-materialize.js +49 -1
- package/dist/src/agent/mcp/bundle-mcp-materialize.js.map +1 -1
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +78 -3
- package/dist/src/agent/mcp/bundle-mcp-runtime.js.map +1 -1
- package/dist/src/agent/mcp/bundle-mcp-types.d.ts +19 -0
- package/dist/src/agent/service/btw-query.js +11 -3
- package/dist/src/agent/service/btw-query.js.map +1 -1
- package/dist/src/agent/service/parse-outbound-session-key.js +13 -8
- package/dist/src/agent/service/parse-outbound-session-key.js.map +1 -1
- package/dist/src/agent/service/process-direct-one-shot.d.ts +2 -2
- package/dist/src/agent/service/process-direct-one-shot.js +1 -1
- package/dist/src/agent/service/process-direct-one-shot.js.map +1 -1
- package/dist/src/agent/service/process-direct-streaming.d.ts +2 -2
- package/dist/src/agent/service/process-direct-streaming.js +1 -1
- package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
- package/dist/src/agent/service.d.ts +1 -1
- package/dist/src/agent/service.js +9 -5
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/service.types.d.ts +5 -0
- package/dist/src/agent/skills/filesystem-watcher.js +4 -3
- package/dist/src/agent/skills/filesystem-watcher.js.map +1 -1
- package/dist/src/agent/skills/index.js +2 -1
- package/dist/src/agent/skills/index.js.map +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +2 -1
- package/dist/src/agent/skills/skill-manage-ops.js.map +1 -1
- package/dist/src/agent/skills/types.d.ts +1 -1
- package/dist/src/agent/skills/watcher.js +2 -5
- package/dist/src/agent/skills/watcher.js.map +1 -1
- package/dist/src/agent/skills/workspace-skills-dir.d.ts +1 -0
- package/dist/src/agent/skills/workspace-skills-dir.js +11 -0
- package/dist/src/agent/skills/workspace-skills-dir.js.map +1 -0
- package/dist/src/agent/tool-manuals/browser.d.ts +1 -1
- package/dist/src/agent/tool-manuals/browser.js +62 -3
- package/dist/src/agent/tool-manuals/browser.js.map +1 -1
- package/dist/src/agent/tools/browser/tool/browser-use-tool.d.ts +4 -1
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js +13 -4
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js.map +1 -1
- package/dist/src/agent/tools/browser/tool/schemas.d.ts +0 -2
- package/dist/src/agent/tools/browser/tool/schemas.js +1 -2
- package/dist/src/agent/tools/browser/tool/schemas.js.map +1 -1
- package/dist/src/agent/tools/factory.js +1 -10
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/skill-manage-tool.js +1 -1
- package/dist/src/agent/tools/skill-manage-tool.js.map +1 -1
- package/dist/src/agent/workflow/subagent-runner.js +18 -1
- package/dist/src/agent/workflow/subagent-runner.js.map +1 -1
- package/dist/src/browser/actions/extension-registry-bridge.js +91 -7
- package/dist/src/browser/actions/extension-registry-bridge.js.map +1 -1
- package/dist/src/browser/actions/registry.js +383 -7
- package/dist/src/browser/actions/registry.js.map +1 -1
- package/dist/src/browser/actions/types.d.ts +11 -3
- package/dist/src/browser/index.js +2 -2
- package/dist/src/browser/pipeline/output.d.ts +18 -16
- package/dist/src/browser/pipeline/output.js +28 -20
- package/dist/src/browser/pipeline/output.js.map +1 -1
- package/dist/src/browser/pipeline/runner.d.ts +7 -14
- package/dist/src/browser/pipeline/runner.js +349 -102
- package/dist/src/browser/pipeline/runner.js.map +1 -1
- package/dist/src/browser/pipeline/schema.d.ts +1 -0
- package/dist/src/browser/pipeline/schema.js +35 -58
- package/dist/src/browser/pipeline/schema.js.map +1 -1
- package/dist/src/browser/pipeline/source.d.ts +2 -0
- package/dist/src/browser/pipeline/source.js +10 -1
- package/dist/src/browser/pipeline/source.js.map +1 -1
- package/dist/src/browser/pipeline/template.d.ts +10 -2
- package/dist/src/browser/pipeline/template.js +50 -8
- package/dist/src/browser/pipeline/template.js.map +1 -1
- package/dist/src/chat-commands/builtins/config.js +3 -5
- package/dist/src/chat-commands/builtins/config.js.map +1 -1
- package/dist/src/chat-commands/context.d.ts +5 -0
- package/dist/src/chat-commands/context.js +18 -9
- package/dist/src/chat-commands/context.js.map +1 -1
- package/dist/src/chat-commands/index.d.ts +1 -1
- package/dist/src/chat-commands/index.js +2 -2
- package/dist/src/chat-commands/index.js.map +1 -1
- package/dist/src/chat-commands/processor.js +22 -21
- package/dist/src/chat-commands/processor.js.map +1 -1
- package/dist/src/chat-commands/session-key.d.ts +3 -15
- package/dist/src/chat-commands/session-key.js +3 -49
- package/dist/src/chat-commands/session-key.js.map +1 -1
- package/dist/src/chat-commands/types.d.ts +4 -0
- package/dist/src/cli/commands/browser-cli-helpers.js +11 -5
- package/dist/src/cli/commands/browser-cli-helpers.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/session-integrity.js +8 -8
- package/dist/src/cli/commands/doctor/checks/session-integrity.js.map +1 -1
- package/dist/src/config/rules.js +5 -0
- package/dist/src/config/rules.js.map +1 -1
- package/dist/src/connectors/builtin-catalog.js +180 -1
- package/dist/src/connectors/builtin-catalog.js.map +1 -1
- package/dist/src/connectors/health.js +18 -9
- package/dist/src/connectors/health.js.map +1 -1
- package/dist/src/connectors/types.d.ts +19 -0
- package/dist/src/connectors/usage.js +12 -4
- package/dist/src/connectors/usage.js.map +1 -1
- package/dist/src/extensions/types/tui.d.ts +2 -0
- package/dist/src/gateway/heartbeat/service.js +13 -1
- package/dist/src/gateway/heartbeat/service.js.map +1 -1
- package/dist/src/gateway/hono/app.js +13 -4
- package/dist/src/gateway/hono/app.js.map +1 -1
- package/dist/src/gateway/hono/oauth-async.js +1 -1
- package/dist/src/gateway/hono/routes/agent-stream.js +6 -6
- package/dist/src/gateway/hono/routes/agent-stream.js.map +1 -1
- package/dist/src/gateway/hono/routes/config-patch/gateway.d.ts +1 -1
- package/dist/src/gateway/hono/routes/config-patch/gateway.js +6 -0
- package/dist/src/gateway/hono/routes/config-patch/gateway.js.map +1 -1
- package/dist/src/gateway/hono/routes/goals.js +16 -3
- package/dist/src/gateway/hono/routes/goals.js.map +1 -1
- package/dist/src/gateway/hono/routes/logs.js +1 -0
- package/dist/src/gateway/hono/routes/logs.js.map +1 -1
- package/dist/src/gateway/hono/routes/mcp.js +27 -8
- package/dist/src/gateway/hono/routes/mcp.js.map +1 -1
- package/dist/src/gateway/hono/routes/notes.js +14 -2
- package/dist/src/gateway/hono/routes/notes.js.map +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +62 -4
- package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +3 -66
- package/dist/src/gateway/hono/routes/workspace.js.map +1 -1
- package/dist/src/gateway/hono/sse.d.ts +2 -2
- package/dist/src/gateway/hono/sse.js +7 -15
- package/dist/src/gateway/hono/sse.js.map +1 -1
- package/dist/src/gateway/resolve-webchat-session-key.d.ts +2 -6
- package/dist/src/gateway/resolve-webchat-session-key.js +5 -31
- package/dist/src/gateway/resolve-webchat-session-key.js.map +1 -1
- package/dist/src/gateway/service/agent-runner.d.ts +2 -3
- package/dist/src/gateway/service/agent-runner.js +9 -22
- package/dist/src/gateway/service/agent-runner.js.map +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +9 -7
- package/dist/src/gateway/service/run-gateway-agent.js.map +1 -1
- package/dist/src/gateway/service/sessions-api.d.ts +9 -0
- package/dist/src/gateway/service/sessions-api.js +11 -0
- package/dist/src/gateway/service/sessions-api.js.map +1 -1
- package/dist/src/gateway/service.d.ts +1 -1
- package/dist/src/gateway/service.js +19 -5
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/gateway/workspace-file-search.d.ts +9 -0
- package/dist/src/gateway/workspace-file-search.js +76 -0
- package/dist/src/gateway/workspace-file-search.js.map +1 -0
- package/dist/src/goals/goal-notifications.d.ts +2 -0
- package/dist/src/goals/goal-notifications.js +16 -11
- package/dist/src/goals/goal-notifications.js.map +1 -1
- package/dist/src/goals/goal-service.js +1 -6
- package/dist/src/goals/goal-service.js.map +1 -1
- package/dist/src/project-trust/trust-store.js +2 -0
- package/dist/src/project-trust/trust-store.js.map +1 -1
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/index.js +2 -2
- package/dist/src/session/init-session-turn.js +6 -9
- package/dist/src/session/init-session-turn.js.map +1 -1
- package/dist/src/session/manager.d.ts +5 -1
- package/dist/src/session/manager.js +5 -2
- package/dist/src/session/manager.js.map +1 -1
- package/dist/src/session/reset-type.d.ts +0 -2
- package/dist/src/session/reset-type.js +3 -9
- package/dist/src/session/reset-type.js.map +1 -1
- package/dist/src/session/resolve-session.js +9 -20
- package/dist/src/session/resolve-session.js.map +1 -1
- package/dist/src/session/store.d.ts +11 -3
- package/dist/src/session/store.js +29 -13
- package/dist/src/session/store.js.map +1 -1
- package/dist/src/session/types.d.ts +2 -4
- package/dist/src/session/types.js.map +1 -1
- package/dist/src/storage/sqlite/index.d.ts +2 -2
- package/dist/src/storage/sqlite/index.js +3 -3
- package/dist/src/storage/sqlite/migrations/010_session_id_identity.sql +30 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +2 -2
- package/dist/src/storage/sqlite/migrations/runner.js +4 -4
- package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +2 -2
- package/dist/src/storage/sqlite/row-mappers.d.ts +4 -4
- package/dist/src/storage/sqlite/row-mappers.js +11 -14
- package/dist/src/storage/sqlite/row-mappers.js.map +1 -1
- package/dist/src/storage/sqlite/schema.js +3 -3
- package/dist/src/storage/sqlite/schema.js.map +1 -1
- package/dist/src/storage/sqlite/schema.sql +37 -10
- package/dist/src/storage/sqlite/session-metadata.d.ts +2 -7
- package/dist/src/storage/sqlite/session-metadata.js +18 -72
- package/dist/src/storage/sqlite/session-metadata.js.map +1 -1
- package/dist/src/storage/sqlite/session-repository.d.ts +6 -5
- package/dist/src/storage/sqlite/session-repository.js +34 -40
- package/dist/src/storage/sqlite/session-repository.js.map +1 -1
- package/dist/src/storage/sqlite/transcript-repository.d.ts +2 -2
- package/dist/src/storage/sqlite/transcript-repository.js +52 -52
- package/dist/src/storage/sqlite/transcript-repository.js.map +1 -1
- package/dist/src/tui/backends/embedded-backend.d.ts +11 -4
- package/dist/src/tui/backends/embedded-backend.js +27 -1
- package/dist/src/tui/backends/embedded-backend.js.map +1 -1
- package/dist/src/tui/backends/gateway-sse-backend.d.ts +4 -1
- package/dist/src/tui/backends/gateway-sse-backend.js +21 -2
- package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
- package/dist/src/tui/extension-host/autocomplete.js +13 -10
- package/dist/src/tui/extension-host/autocomplete.js.map +1 -1
- package/dist/src/tui/extension-host/runtime.d.ts +7 -0
- package/dist/src/tui/extension-host/runtime.js +6 -4
- package/dist/src/tui/extension-host/runtime.js.map +1 -1
- package/dist/src/tui/tui-backend.d.ts +9 -0
- package/dist/src/tui/tui-commands.js +85 -6
- package/dist/src/tui/tui-commands.js.map +1 -1
- package/dist/src/tui/tui-file-autocomplete.d.ts +5 -0
- package/dist/src/tui/tui-file-autocomplete.js +26 -0
- package/dist/src/tui/tui-file-autocomplete.js.map +1 -0
- package/dist/src/tui/tui-picker-overlay.js +1 -1
- package/dist/src/tui/tui.js +29 -11
- package/dist/src/tui/tui.js.map +1 -1
- package/dist/src/utils/logger/context.d.ts +2 -2
- package/dist/src/utils/logger/context.js +2 -1
- package/dist/src/utils/logger/context.js.map +1 -1
- package/dist/src/utils/logger/log-store.js +1 -0
- package/dist/src/utils/logger/log-store.js.map +1 -1
- package/dist/src/utils/logger/pino-record.js +3 -0
- package/dist/src/utils/logger/pino-record.js.map +1 -1
- package/dist/src/utils/logger/types.d.ts +5 -0
- package/dist/src/utils/logger/types.js.map +1 -1
- package/dist/src/workflows/service/workflow-session-bridge.js +13 -1
- package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agent-browser-settings-page-rGbKc2Hh.js +0 -6
- package/dist/gateway/static/root/assets/agent-defaults-tabbed-page-CtwVbjOA.js +0 -1
- package/dist/gateway/static/root/assets/agents-CCBmGcwc.js +0 -71
- package/dist/gateway/static/root/assets/apps-page-xwCsJS15.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-C044DcYk.js +0 -1
- package/dist/gateway/static/root/assets/connectors-settings-8VEWUOTj.js +0 -2
- package/dist/gateway/static/root/assets/cron-page-DqmNGNOy.js +0 -3
- package/dist/gateway/static/root/assets/dreaming-settings-6UZE1FSK.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-bv0VRDaf.js +0 -1
- package/dist/gateway/static/root/assets/goals-page-1Ywnt4Cb.js +0 -2
- package/dist/gateway/static/root/assets/index-Cxm6xsps.js +0 -122
- package/dist/gateway/static/root/assets/index-b_R4tKqt.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-B_wrxhee.js +0 -2
- package/dist/gateway/static/root/assets/messages-CkT-lcgP.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-D0JDSbNu.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-page-DpFV-EO6.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-CdkjTch8.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DSYVAi96.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CenkcVjF.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-D9sva86V.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-DL35U0x0.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Ctwbp9Er.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DIM3JNsr.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DAlNaNzL.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CLrHVzAt.js +0 -2
- package/dist/gateway/static/root/assets/voice-api-key-field-vYAO71Gn.js +0 -1
- package/dist/gateway/static/root/assets/workflow-page.utils-sgHjOXOm.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-DYyOTmFx.js +0 -18
|
@@ -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-JdwAhgNB.js";import{t as a}from"./messages-CkT-lcgP.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l,t as u}from"./fetch-NZmjSXLl.js";import{a as d,i as f}from"./vendor-swr-BIWyz7Rc.js";import{$r as p,Ar as m,B as h,Dr as g,Ds as _,Ea as v,Er as y,Hi as b,Jr as x,Nt as S,Or as C,Pa as w,Qo as T,Qr as E,Ss as D,Xr as O,Yr as k,Zr as A,gs as j,ii as M,is as N,ji as P,ki as F,ko as I,kr as L,la as R,pa as z,qa as B,zn as ee}from"./index-Cxm6xsps.js";var V=e(t(),1),H=n();function U(e){return e===`builtin`||e===`user`?e:`marketplace`}async function W(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function te(e){let t=await u(c(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function G(e){let t=await u(c(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function K(e){let t=await u(c(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function q(e){let t=await u(c(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var J=r();function Y(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var X={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function ne({className:e}){let t=a(o(e=>e.language)).appsPage,n=s(e=>!!e.token),r=g(),{mutate:u}=d(),[p,m]=(0,V.useReducer)(h,X),{q:_,debounced:v,detailPkg:y,rowBusy:x,actionError:C,restartHint:E}=p,D=n?`marketplace-${v}`:null;(0,V.useEffect)(()=>{let e=window.setTimeout(()=>m({type:`patch`,patch:{debounced:_.trim()}}),300);return()=>window.clearTimeout(e)},[_]);let{data:O,isLoading:k,error:A}=f(D,async()=>l(v.length>0?c(`/api/marketplace?q=${encodeURIComponent(v)}`):c(`/api/marketplace`)),{revalidateOnFocus:!1}),j=(0,V.useCallback)(()=>{u(`gateway-extensions-list`),S()},[u]),M=(0,V.useCallback)(async(e,n)=>{m({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await G({name:e,overwrite:n});j(),r.requiresGatewayRestart&&m({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw m({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{m({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,j]),N=(0,V.useCallback)(async e=>{m({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await q(e);j(),n.requiresGatewayRestart&&m({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw m({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{m({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,j]),P=O?.extensions??[];return(0,J.jsxs)(`div`,{className:i(`flex flex-col gap-4`,e),children:[(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(z,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,value:_,onChange:e=>m({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),A?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:A instanceof Error?A.message:t.marketplaceLoadFailed}):null,C?(0,J.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null,E?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:E}):null,k&&!O?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:P.length===0?(0,J.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):P.map(e=>{let n=Y(r,e.id),a=x===e.id;return(0,J.jsx)(`li`,{className:`list-none`,children:(0,J.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>m({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),m({type:`patch`,patch:{detailPkg:e.id}}))},className:i(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl border border-edge bg-surface-base p-4 text-left shadow-surface`,`transition-[transform,background-color,border-color,box-shadow] duration-150 ease-out`,`hover:border-edge-subtle hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,J.jsx)(T,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,J.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,J.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,J.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,J.jsx)(w,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,J.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,J.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,J.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,J.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&N(e.id).catch(()=>{})},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[a?(0,J.jsx)(B,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(b,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,J.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{M(e.id,!1).catch(()=>{})},className:i(`inline-flex w-full items-center justify-center rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white`,`shadow-surface transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:pointer-events-none disabled:opacity-50`),children:[a?(0,J.jsx)(B,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),y?(0,J.jsx)(re,{packageName:y,copy:t,extensions:r,onClose:()=>m({type:`patch`,patch:{detailPkg:null}}),onInstall:M,onUninstall:N}):null]})}function re(e){let t=(0,H.c)(61),{packageName:n,copy:r,extensions:a,onClose:o,onInstall:c,onUninstall:l}=e,[u,d]=(0,V.useState)(!1),m=s(se)?`ext-mp-detail-${n}`:null,h;t[0]===n?h=t[1]:(h=async()=>te(n),t[0]=n,t[1]=h);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},t[2]=g):g=t[2];let{data:_,error:v,isLoading:y}=f(m,h,g),S;t[3]!==a||t[4]!==n?(S=Y(a,n),t[3]=a,t[4]=n,t[5]=S):S=t[5];let C=S,w=C===`user`,T;t[6]!==r.marketplaceNoReadme||t[7]!==_?(T=_?.readme?.trim()||(_?.description?.trim()?`### ${_.name}\n\n${_.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=_,t[8]=T):T=t[8];let k=T,M;t[9]===o?M=t[10]:(M=e=>!e&&o(),t[9]=o,t[10]=M);let N;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,J.jsx)(O,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=N):N=t[11];let F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,J.jsx)(j,{className:`size-5`}),t[12]=F):F=t[12];let I;t[13]!==r.detailBack||t[14]!==o?(I=(0,J.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:F}),t[13]=r.detailBack,t[14]=o,t[15]=I):I=t[15];let L;t[16]===r.marketplaceDetailTitle?L=t[17]:(L=(0,J.jsx)(p,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=L);let R;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,J.jsx)(P,{className:`size-5`}),t[18]=R):R=t[18];let z;t[19]!==r.detailClose||t[20]!==o?(z=(0,J.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:R}),t[19]=r.detailClose,t[20]=o,t[21]=z):z=t[21];let U;t[22]!==z||t[23]!==I||t[24]!==L?(U=(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[I,L,z]}),t[22]=z,t[23]=I,t[24]=L,t[25]=U):U=t[25];let W;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==_||t[32]!==v||t[33]!==y||t[34]!==k?(W=y&&!_?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):v?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):_?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:_.name}),(0,J.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,J.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:_.id})}),(0,J.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,J.jsx)(`dd`,{children:_.author.username})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,J.jsx)(`dd`,{children:_.latestVersion.version})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,J.jsx)(`dd`,{children:_.downloads})]})]}),_.readme?.trim()?(0,J.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,J.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,J.jsx)(ee,{content:k})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=_,t[32]=v,t[33]=y,t[34]=k,t[35]=W):W=t[35];let G;t[36]===W?G=t[37]:(G=(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:W}),t[36]=W,t[37]=G);let K;t[38]!==u||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==_||t[47]!==C||t[48]!==o||t[49]!==c||t[50]!==l||t[51]!==n||t[52]!==w?(K=_?(0,J.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:C===`bundled`?(0,J.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,J.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,J.jsx)(D,{to:`/apps?tab=builtin`,onClick:o,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{w&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),c(n,w).catch(ae).finally(()=>d(!1)))},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[u?(0,J.jsx)(B,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,w?r.marketplaceReinstall:r.marketplaceInstall]}),w?(0,J.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),l(n).then(()=>o()).catch(ie).finally(()=>d(!1)))},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,J.jsx)(b,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=u,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=_,t[47]=C,t[48]=o,t[49]=c,t[50]=l,t[51]=n,t[52]=w,t[53]=K):K=t[53];let q;t[54]!==U||t[55]!==G||t[56]!==K?(q=(0,J.jsxs)(A,{children:[N,(0,J.jsxs)(x,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:oe,children:[U,G,K]})]}),t[54]=U,t[55]=G,t[56]=K,t[57]=q):q=t[57];let X;return t[58]!==q||t[59]!==M?(X=(0,J.jsx)(E,{defaultOpen:!0,onOpenChange:M,children:q}),t[58]=q,t[59]=M,t[60]=X):X=t[60],X}function ie(){}function ae(){}function oe(e){return e.preventDefault()}function se(e){return!!e.token}function ce(){let e=o(e=>e.language),t=a(e),n=M(e=>e.setPageHeader),r=M(e=>e.clearPageHeader),s=g(),c=C(),[l,u]=_(),d=U(l.get(`tab`)),f=l.get(`q`)??``,[p,m]=(0,V.useState)(d),[h,v]=(0,V.useState)(f),[y,b]=(0,V.useState)(null),x=l.toString(),S=(0,V.useRef)(x);if(S.current!==x){S.current=x;let e=U(l.get(`tab`)),t=l.get(`q`)??``;m(t=>t===e?t:e),v(e=>e===t?e:t)}(0,V.useEffect)(()=>{u(e=>{let t=new URLSearchParams(e),n=h.trim();return n?t.set(`q`,n):t.delete(`q`),p===`marketplace`?t.delete(`tab`):t.set(`tab`,p),t.toString()===e.toString()?e:t},{replace:!0})},[p,h,u]);let w=(0,V.useMemo)(()=>s.filter(e=>e.source===`bundled`),[s]),T=(0,V.useMemo)(()=>s.filter(e=>e.source!==`bundled`),[s]),E=p===`builtin`?w:T,D=(0,V.useMemo)(()=>{let t=h.trim().toLowerCase(),n=E;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[E,h,e]);if((0,V.useEffect)(()=>{b(e=>{if(!e)return e;let t=s.find(t=>t.id===e.id);return t?Z(e)===Z(t)&&e.active===t.active?e:t:null})},[s]),(0,V.useLayoutEffect)(()=>(n({startExtra:null,main:(0,J.jsx)(`div`,{className:`min-w-0`,children:(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.appsPage.title})}),end:null}),()=>r()),[r,t.appsPage.title,n]),c&&p!==`marketplace`)return(0,J.jsx)(pe,{});let O=p!==`marketplace`&&E.length>0;return(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,J.jsxs)(`div`,{className:`mb-5 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,J.jsxs)(`div`,{className:`flex flex-wrap gap-x-1 gap-y-1`,role:`tablist`,"aria-label":t.appsPage.appsNavAria,children:[(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":p===`marketplace`,className:i(`relative max-w-full rounded-md px-3 py-2 text-left text-sm font-medium transition-colors sm:text-center`,p===`marketplace`?`text-fg`:`text-fg-muted hover:text-fg`,p===`marketplace`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>m(`marketplace`),children:t.appsPage.tabMarketplace}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":p===`builtin`,className:i(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,p===`builtin`?`text-fg`:`text-fg-muted hover:text-fg`,p===`builtin`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>m(`builtin`),children:[t.appsPage.tabBuiltin,(0,J.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,w.length,`)`]})]}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":p===`user`,className:i(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,p===`user`?`text-fg`:`text-fg-muted hover:text-fg`,p===`user`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>m(`user`),children:[t.appsPage.tabUser,(0,J.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,T.length,`)`]})]})]}),O?(0,J.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,J.jsx)(z,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,value:h,onChange:e=>v(e.target.value),placeholder:t.appsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),p===`marketplace`?(0,J.jsx)(ne,{}):p===`builtin`&&w.length===0?(0,J.jsx)(he,{message:t.appsPage.emptyBuiltin}):p===`user`&&T.length===0?(0,J.jsx)(he,{message:t.appsPage.emptyUser}):D.length===0?(0,J.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-hover/30 px-4 py-8 text-center text-sm text-fg-muted dark:bg-surface-hover/15`,children:t.appsPage.noSearchResults}):(0,J.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:D.map(e=>(0,J.jsx)(de,{extension:e,copy:t.appsPage,showSourceBadge:p===`user`,onOpen:()=>b(e)},e.id))})]}),y?(0,J.jsx)(fe,{extension:y,copy:t.appsPage,onClose:()=>b(null)},y.id):null]})}function Z(e){return e.activationEligible??e.active}function Q(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function le(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function ue(e,t){let n=Z(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function de(e){let t=(0,H.c)(45),{extension:n,copy:r,showSourceBadge:a,onOpen:o}=e,s;t[0]===n?s=t[1]:(s=Z(n),t[0]=n,t[1]=s);let c=s,l=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`group flex w-full flex-col rounded-xl border border-edge bg-surface-base p-4 text-left shadow-sm transition-colors`,`hover:border-edge-subtle hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=u):u=t[2];let d=n.name||n.id,f;t[3]===d?f=t[4]:(f=d.charAt(0).toUpperCase(),t[3]=d,t[4]=f);let p;t[5]===f?p=t[6]:(p=(0,J.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:f}),t[5]=f,t[6]=p);let m;t[7]===n.name?m=t[8]:(m=(0,J.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=m);let h;t[9]===n.version?h=t[10]:(h=n.version?(0,J.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=h);let g;t[11]!==m||t[12]!==h?(g=(0,J.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==r.statusEnabled||t[15]!==c?(_=c?(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,J.jsx)(N,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,J.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,J.jsx)(v,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=c,t[16]=_):_=t[16];let y;t[17]!==g||t[18]!==_?(y=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=y):y=t[19];let b;t[20]!==r.cardNoDescription||t[21]!==n.description?(b=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=b):b=t[22];let x;t[23]===b?x=t[24]:(x=(0,J.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:b}),t[23]=b,t[24]=x);let S=n.hasUi?r.badgeKindUi:r.badgeKindBackend,C;t[25]!==S||t[26]!==l?(C=(0,J.jsx)(`span`,{title:l,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:S}),t[25]=S,t[26]=l,t[27]=C):C=t[27];let w;t[28]!==r||t[29]!==n||t[30]!==a?(w=n.source===`bundled`?(0,J.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):a?(0,J.jsx)(`span`,{title:Q(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:le(n,r)}):null,t[28]=r,t[29]=n,t[30]=a,t[31]=w):w=t[31];let T;t[32]!==C||t[33]!==w?(T=(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[C,w]}),t[32]=C,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==y||t[36]!==x||t[37]!==T?(E=(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[y,x,T]}),t[35]=y,t[36]=x,t[37]=T,t[38]=E):E=t[38];let D;t[39]!==E||t[40]!==p?(D=(0,J.jsxs)(`div`,{className:`flex gap-3`,children:[p,E]}),t[39]=E,t[40]=p,t[41]=D):D=t[41];let O;return t[42]!==o||t[43]!==D?(O=(0,J.jsx)(`button`,{type:`button`,onClick:o,className:u,children:D}),t[42]=o,t[43]=D,t[44]=O):O=t[44],O}function fe({extension:e,copy:t,onClose:n}){let{mutate:r}=d(),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),f=e.activationEligible===!0,h=(0,V.useCallback)(async()=>{if(e.source===`bundled`){c(null),u(!1),o(!0);try{let{requiresGatewayRestart:t}=await K({extensionId:e.id,enabled:!f});await r(`gateway-extensions-list`),S(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{o(!1)}}},[f,t.builtinToggleFailed,e.id,e.source,r]),g=e.ui?.contributions?.pages??[],_=e.ui?.contributions?.settingsPanels??[],v=e.ui?.contributions?.chatWidgets??[],b=e.ui?.contributions?.sidebarPanels??[],C=g.find(e=>e.showInNav)??g[0],w=_[0],T=C?y(e.id,C):null,M=w?`/settings/ext/${e.id}/${w.id}`:e.hasConfigSchema||L(e)?`/settings/ext/${e.id}`:null;return(0,J.jsx)(E,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,J.jsxs)(A,{children:[(0,J.jsx)(O,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,J.jsxs)(x,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,J.jsx)(j,{className:`size-5`})}),(0,J.jsx)(p,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,J.jsxs)(k,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,J.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,J.jsx)(P,{className:`size-5`})})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,J.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,J.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,Q(e,t)]}),e.version?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,J.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,J.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:ue(e,t)}),e.source===`bundled`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,J.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-hover/40 p-3 dark:bg-surface-hover/20`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,J.jsx)(F,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void h(),className:`shrink-0 py-1.5 text-xs`,children:a?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(B,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):f?t.builtinToggleDisable:t.builtinToggleEnable})]}),s?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:s}):null,l?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,J.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(g.length>0||_.length>0||v.length>0)?(0,J.jsxs)(`section`,{className:`mt-8`,children:[(0,J.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,J.jsx)($,{template:t.badgePages,count:g.length,hidden:g.length===0}),(0,J.jsx)($,{template:t.badgeSettings,count:_.length,hidden:_.length===0}),(0,J.jsx)($,{template:t.badgeWidgets,count:v.length,hidden:v.length===0}),(0,J.jsx)($,{template:t.badgeSidebar,count:b.length,hidden:b.length===0})]})]}):null,m(e)&&(T||M)?(0,J.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[T?(0,J.jsxs)(D,{to:T,onClick:n,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,J.jsx)(I,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,M?(0,J.jsxs)(D,{to:M,onClick:n,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,J.jsx)(R,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,J.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function $(e){let t=(0,H.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,J.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function pe(){let e=(0,H.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,J.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,J.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,J.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[t,n,r,(0,J.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(me)})]})}),e[4]=a):a=e[4],a}function me(e){return(0,J.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge bg-surface-base`},e)}function he(e){let t=(0,H.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,J.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-dashed border-edge-subtle bg-surface-hover/40 px-4 py-12 text-center dark:bg-surface-hover/20`,children:(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ce as AppsPage};
|
|
@@ -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-JdwAhgNB.js";import{t as a}from"./messages-CkT-lcgP.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l,t as u}from"./fetch-NZmjSXLl.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$r as f,$t as p,Ca as m,Es as h,Jr as g,Qi as _,Qr as v,Qt as y,Tr as b,Ts as x,Xr as S,Yr as C,Zo as w,Zr as T,_n as E,b as D,ba as O,bi as k,en as A,gn as j,ii as M,ji as N,ki as P,ko as F,qa as I,qr as L,ua as ee}from"./index-Cxm6xsps.js";import{t as R}from"./schema-form-Di5cKjYE.js";import{t as z}from"./browser-BLJWD7WI.js";import{t as te}from"./use-channel-catalog-CgJibfMM.js";var B=n(),V=e(z(),1),H=e(t(),1),U=r();function W(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 G(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 K(e){return e?.type===`poll`&&e.phase===`done`}function q(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function J(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function Y(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ne({entry:e,locale:t,messages:n,onChanged:r,autoStartPrimary:a=!1,compact:o=!1}){let s=(0,H.useMemo)(()=>W(e),[e]),c=(0,H.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,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,H.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await G({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,H.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,H.useEffect)(()=>{let t=J(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),V.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,l.payload]),(0,H.useEffect)(()=>{let n=l.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||G({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:K(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),K(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),p=e.actions?.[`doctor.run`]?.label??n.diagnose,h=q(l.payload),g=J(l.payload,e.id),v=g?l.generatedQr:Y(l.payload),y=l.payload?.type===`form`?l.payload:null,b=l.payload?.type===`diagnostics`?l.payload.checks:null;return(0,U.jsxs)(`div`,{className:o?`space-y-3`:`rounded-lg border border-edge-subtle bg-surface-panel p-4`,children:[(0,U.jsxs)(`div`,{className:i(`flex flex-wrap items-start gap-3`,o?`justify-end`:`justify-between`),children:[o?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[s?(0,U.jsxs)(P,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(s[0]),children:[l.busy?(0,U.jsx)(I,{className:`size-4 animate-spin`}):(0,U.jsx)(m,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(P,{type:`button`,variant:`secondary`,disabled:l.busy,onClick:()=>void d(`doctor.run`),children:[(0,U.jsx)(_,{className:`size-4`}),p]}):null]})]}),h?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:h}):null,l.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:l.error}):null,v?(0,U.jsxs)(`div`,{className:i(`flex flex-wrap items-start gap-4`,o?`justify-center`:`mt-4`),children:[(0,U.jsx)(`div`,{className:`rounded-lg border border-edge bg-white p-3`,children:(0,U.jsx)(`img`,{src:v,alt:`${e.label} setup QR`,className:`h-52 w-52 object-contain`})}),(0,U.jsxs)(`div`,{className:i(`max-w-sm text-sm text-fg-muted`,o&&`w-full text-center`),children:[(0,U.jsx)(`p`,{children:n.waitingConfirmation}),g?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:g,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(F,{className:`size-3.5`})]}):null]})]}):null,l.payload?.type===`poll`&&l.payload.phase===`done`?(0,U.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,U.jsx)(w,{className:l.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.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,y?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(R,{schema:y.schema,values:l.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:l.busy,labels:c}),(0,U.jsx)(P,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(y.submitAction,l.formDraft),children:n.saveSetup})]}):null,b?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base px-3 py-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}function re(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`,j):i(`fixed left-1/2 top-1/2 flex max-h-[min(90vh,52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`max-h-[min(90vh,48rem)] w-[min(calc(100%-2rem),36rem)]`,j,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function ie(e){let t=(0,B.c)(30),{presentation:n,open:r,onOpenChange:a,title:o,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:p,wide:m,headerExtra:h}=e,_=m===void 0?!1:m,y=n===`drawer`,b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,U.jsx)(S,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,E)}),t[0]=b):b=t[0];let x;t[1]!==n||t[2]!==_?(x=re(n,_),t[1]=n,t[2]=_,t[3]=x):x=t[3];let w;t[4]===c?w=t[5]:(w=c?(0,U.jsx)(f,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=w);let D;t[6]===l?D=t[7]:(D=l?(0,U.jsx)(C,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=D);let O;t[8]!==u||t[9]!==s||t[10]!==h||t[11]!==y||t[12]!==o?(O=y?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[o?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:o}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(L,{asChild:!0,children:(0,U.jsx)(P,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(N,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(L,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:i(k,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(N,{className:`size-4`})})}),h]}),t[8]=u,t[9]=s,t[10]=h,t[11]=y,t[12]=o,t[13]=O):O=t[13];let A=y?`px-4 py-4`:`p-6`,j;t[14]===A?j=t[15]:(j=i(`min-h-0 flex-1 overflow-y-auto`,A),t[14]=A,t[15]=j);let M;t[16]!==d||t[17]!==j?(M=(0,U.jsx)(`div`,{className:j,children:d}),t[16]=d,t[17]=j,t[18]=M):M=t[18];let F;t[19]!==p||t[20]!==x||t[21]!==w||t[22]!==D||t[23]!==O||t[24]!==M?(F=(0,U.jsxs)(T,{children:[b,(0,U.jsxs)(g,{className:x,onOpenAutoFocus:X,children:[w,D,O,M,p]})]}),t[19]=p,t[20]=x,t[21]=w,t[22]=D,t[23]=O,t[24]=M,t[25]=F):F=t[25];let I;return t[26]!==a||t[27]!==r||t[28]!==F?(I=(0,U.jsx)(v,{open:r,onOpenChange:a,children:F}),t[26]=a,t[27]=r,t[28]=F,t[29]=I):I=t[29],I}function X(e){return e.preventDefault()}var ae=(0,H.memo)(function(e){let t=(0,B.c)(15),{ch:n,refreshing:r,saveOk:a,onRefresh:o}=e,s;t[0]!==n.saved||t[1]!==a?(s=a?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=a,t[2]=s):s=t[2];let c=n.refresh,l=n.refresh,u=r&&`animate-spin`,d;t[3]===u?d=t[4]:(d=i(`size-4`,u),t[3]=u,t[4]=d);let f;t[5]===d?f=t[6]:(f=(0,U.jsx)(O,{className:d,"aria-hidden":!0}),t[5]=d,t[6]=f);let p;t[7]!==n.refresh||t[8]!==o||t[9]!==r||t[10]!==f?(p=(0,U.jsx)(P,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:c,"aria-label":l,onClick:o,children:f}),t[7]=n.refresh,t[8]=o,t[9]=r,t[10]=f,t[11]=p):p=t[11];let m;return t[12]!==s||t[13]!==p?(m=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[s,p]}),t[12]=s,t[13]=p,t[14]=m):m=t[14],m});function oe(e){let t=(0,B.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(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,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.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]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(P,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function se(e){return e?c(`/api/channels/${encodeURIComponent(e)}/config`):null}async function ce(e){return(await l(c(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}async function le(){return(await l(c(`/api/config`))).payload?.config?.channels??{}}function ue(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function de(e,t){return e.enabled&&e.runtime===`loaded`?t.hubStatusRunning:e.enabled?t.hubStatusEnabled:e.configured?t.hubStatusConfigured:t.hubStatusNotConfigured}function fe(e){return e.enabled&&e.runtime===`loaded`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e.enabled||e.configured?`bg-accent-soft text-accent`:`bg-surface-hover text-fg-muted`}function pe(e){if(!e)return[`enabled`];let t=e.uiHints??{},n=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e);return n.length>0?n:[`enabled`]}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function me(e,t){let n={...Q(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(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Q(r[n]),properties:{}}),e===t.length-1){o[n]=Q(r[n]);break}i=r[n],a=o[n]}}return n}function $(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&$(n)&&delete t[e];return Object.keys(t).length===0}function he(e,t){let n=Q(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return $(n),n}function ge(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function _e(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function ve(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function ye(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 be(e,t,n){let r=[];if(t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=ye(e,_e(t,e),n);i&&r.push(i)}let a=ve(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):e.configured?[n.hubStatusConfigured]:[]}function xe(e,t){let n=W(e);return n?.[1].label?n[1].label:e.configured?t.manageChannel:t.startConfiguration}function Se(e,t){let n=W(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function Ce(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 we({entry:e}){let t=s(e=>e.token),[n,r]=(0,H.useState)(!1),i=(0,H.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(c(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${ue(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(b,{sourceChannel:e.id,className:`size-7`})})}function Te(e){let t=(0,B.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,U.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,U.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 Ee(e){let t=(0,B.c)(65),{entry:n,config:r,busy:a,ch:o,onOpen:s,onToggle:c}=e,l,u,d,f,p,m;if(t[0]!==a||t[1]!==o||t[2]!==r||t[3]!==n||t[4]!==s||t[5]!==c){let e=be(n,r,o),h=Ce(n,o);p=`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 g;t[12]===n?g=t[13]:(g=(0,U.jsx)(we,{entry:n}),t[12]=n,t[13]=g);let _;t[14]===n.label?_=t[15]:(_=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[14]=n.label,t[15]=_);let v;t[16]===n?v=t[17]:(v=i(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,fe(n)),t[16]=n,t[17]=v);let y;t[18]!==o||t[19]!==n?(y=de(n,o),t[18]=o,t[19]=n,t[20]=y):y=t[20];let b;t[21]!==y||t[22]!==v?(b=(0,U.jsx)(`span`,{className:v,children:y}),t[21]=y,t[22]=v,t[23]=b):b=t[23];let x;t[24]!==b||t[25]!==_?(x=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[_,b]}),t[24]=b,t[25]=_,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==g?(S=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[g,x]}),t[27]=x,t[28]=g,t[29]=S):S=t[29];let C=n.enabled===!0,w;t[30]!==o.toggleChannel||t[31]!==n.label?(w=o.toggleChannel.replace(`{{channel}}`,n.label),t[30]=o.toggleChannel,t[31]=n.label,t[32]=w):w=t[32];let T;t[33]!==a||t[34]!==c||t[35]!==C||t[36]!==w?(T=(0,U.jsx)(Te,{checked:C,disabled:a,label:w,onToggle:c}),t[33]=a,t[34]=c,t[35]=C,t[36]=w,t[37]=T):T=t[37],t[38]!==S||t[39]!==T?(m=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[S,T]}),t[38]=S,t[39]=T,t[40]=m):m=t[40],l=`button`,u=s,d=`mt-5 min-h-[6.25rem] text-left`,f=n.configured?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(Oe)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base px-3 py-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:Se(n,o)}),h.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:h.map(De)}):null]}),t[0]=a,t[1]=o,t[2]=r,t[3]=n,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];let h;t[41]!==o.cardAdapterLabel||t[42]!==n.configured||t[43]!==n.description?(h=!n.configured&&n.description?(0,U.jsxs)(`p`,{className:`mt-3 truncate text-xs text-fg-subtle`,title:n.description,children:[o.cardAdapterLabel,`: `,n.description]}):null,t[41]=o.cardAdapterLabel,t[42]=n.configured,t[43]=n.description,t[44]=h):h=t[44];let g;t[45]!==l||t[46]!==u||t[47]!==d||t[48]!==f||t[49]!==h?(g=(0,U.jsxs)(`button`,{type:l,onClick:u,className:d,children:[f,h]}),t[45]=l,t[46]=u,t[47]=d,t[48]=f,t[49]=h,t[50]=g):g=t[50];let _;t[51]===a?_=t[52]:(_=a?(0,U.jsx)(I,{className:`size-4 animate-spin`}):null,t[51]=a,t[52]=_);let v;t[53]!==o||t[54]!==n?(v=xe(n,o),t[53]=o,t[54]=n,t[55]=v):v=t[55];let y;t[56]!==s||t[57]!==v||t[58]!==_?(y=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(P,{type:`button`,variant:`primary`,className:`w-full rounded-2xl py-2.5`,onClick:s,children:[_,v]})}),t[56]=s,t[57]=v,t[58]=_,t[59]=y):y=t[59];let b;return t[60]!==y||t[61]!==p||t[62]!==m||t[63]!==g?(b=(0,U.jsxs)(`article`,{className:p,children:[m,g,y]}),t[60]=y,t[61]=p,t[62]=m,t[63]=g,t[64]=b):b=t[64],b}function De(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function Oe(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function ke(){let e=o(e=>e.language),t=a(e),n=s(e=>!!e.token),r=x(),{channelId:l}=h(),f=A(l),m=te(n,e),g=m.entries,{data:_={},mutate:v}=d(n?`channels-config-map`:null,le,{revalidateOnFocus:!1}),b=M(e=>e.setPageHeader),S=M(e=>e.clearPageHeader),C=(0,H.useMemo)(()=>g.find(e=>e.id===f),[f,g]),{data:w,mutate:T}=d(n&&C?se(C.id):null,()=>ce(C.id)),[E,O]=(0,H.useState)(null),[k,j]=(0,H.useState)(!1),[N,P]=(0,H.useState)(null),[I,L]=(0,H.useState)(null),z=E??w??{},B=t.channelsSettings,V=(0,H.useMemo)(()=>C?.configSchema??{type:`object`,properties:{}},[C?.configSchema]),G=(0,H.useMemo)(()=>pe(C),[C]),K=(0,H.useMemo)(()=>me(V,G),[G,V]),q=(0,H.useMemo)(()=>he(V,G),[G,V]),J=(0,H.useMemo)(()=>({defaultBooleanLabel:B.schemaBooleanDefault,unsupportedArrayType:B.schemaUnsupportedArrayType,arrayAddPlaceholder:B.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>B.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[B]),Y=(0,H.useMemo)(()=>n?(0,U.jsx)(ae,{ch:B,refreshing:m.isValidating,saveOk:!1,onRefresh:()=>void m.mutate()}):null,[m,B,n]);(0,H.useLayoutEffect)(()=>(b({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Y}),()=>S()),[S,Y,t.settingsSections.channels,b]);let re=(0,H.useCallback)(e=>{r(p(e)),O(null),L(null)},[r]),X=(0,H.useCallback)(()=>{r(y),O(null),L(null)},[r]),ue=(0,H.useCallback)(async()=>{if(!C||!E)return!1;j(!0),L(null);try{let e=await u(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[C.id]:E}})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error?.message??e.statusText)}return await T(E,!1),await v(),await m.mutate(),O(null),!0}catch(e){return L(e instanceof Error?e.message:String(e)),!1}finally{j(!1)}},[C,m,E,v,T]),Z=(0,H.useCallback)(async e=>{P(e.id),L(null);try{let t=await u(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[e.id]:{enabled:e.enabled!==!0}}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await m.mutate(),await v(),C?.id===e.id&&await T()}catch(e){L(e instanceof Error?e.message:String(e))}finally{P(null)}},[C?.id,m,v,T]),Q=C?.ui?.modal,$=Q?.placement!==`replace-config`;return n?(0,U.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-6`,children:[m.isLoading?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:B.loadingChannels}):m.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(m.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,U.jsx)(Ee,{entry:e,config:_[e.id]?.config,busy:N===e.id,ch:B,onOpen:()=>re(e.id),onToggle:()=>void Z(e)},e.id))}),I?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:I}):null,(0,U.jsx)(ie,{presentation:`modal`,open:!!C,onOpenChange:e=>{e||X()},closeAriaLabel:B.close,srTitle:C?.label??B.selectChannel,srDescription:C?.description,wide:!0,footer:C?(0,U.jsx)(oe,{ch:B,dirty:!!E,saving:k,onCancel:X,onDiscard:()=>O(null),onSave:ue}):null,children:C?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-3`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(we,{entry:C}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:C.label}),(0,U.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,fe(C)),children:de(C,B)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:W(C)?.[1].result===`qr`?B.scanLoginHint.replace(`{{channel}}`,C.label):C.description}),C.docsPath?(0,U.jsxs)(`a`,{href:C.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[B.docs,(0,U.jsx)(F,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:B.enabledLabel}),(0,U.jsx)(Te,{checked:C.enabled===!0,disabled:N===C.id,label:B.toggleChannel.replace(`{{channel}}`,C.label),onToggle:()=>void Z(C)})]})]})}),Q?.entrypoint&&Q.placement===`before-config`?(0,U.jsx)(D,{extensionId:C.extensionId,extensionName:C.label,entrypoint:Q.entrypoint,permissions:Q.permissions,minHeight:Q.minHeight,maxHeight:Q.maxHeight,initialData:{channelId:C.id,entry:C,config:z}}):null,Q?.placement===`replace-config`?null:(0,U.jsx)(ne,{entry:C,locale:e,messages:B,autoStartPrimary:!0,compact:!0,onChanged:async()=>{await T(),await m.mutate(),await v()}},C.id),Q?.entrypoint&&Q.placement!==`before-config`?(0,U.jsx)(D,{extensionId:C.extensionId,extensionName:C.label,entrypoint:Q.entrypoint,permissions:Q.permissions,minHeight:Q.minHeight,maxHeight:Q.maxHeight,initialData:{channelId:C.id,entry:C,config:z}}):null,$?(0,U.jsxs)(`section`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:B.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:B.basicConfigurationHint})]}),(0,U.jsx)(R,{schema:K,values:z,onChange:e=>O(e),disabled:k,labels:J})]}):null,$&&ge(q)?(0,U.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(ee,{className:`size-4 text-fg-muted`}),B.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`border-t border-edge-subtle p-4`,children:(0,U.jsx)(R,{schema:q,values:z,onChange:e=>O(e),disabled:k,labels:J})})]}):null,I?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:I}):null]}):null})]}):(0,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:B.tokenRequired})})}export{ke 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-JdwAhgNB.js";import{t as a}from"./messages-CkT-lcgP.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l}from"./fetch-NZmjSXLl.js";import{r as u}from"./toast-z0toXu32.js";import{$r as d,Da as f,Ea as p,Fa as m,Hi as h,Ho as g,Jr as _,Ma as v,Mi as y,Oi as b,Qr as x,Xr as S,Yr as C,Zo as w,Zr as T,_n as E,br as D,gi as O,gn as k,ji as A,ka as j,ki as M,os as N,pa as P,qa as F,qr as I,vi as L,xi as R,yr as z}from"./index-Cxm6xsps.js";import{n as ee,t as te}from"./settings-form-section-Dq-83cQd.js";var B=e(t(),1),V=n(),ne=/^([^:=]+)[:=](.*)$/;function re(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=ne.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function ie(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 ae(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 H(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 U(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)||H(t)&&(r[e]=t);return r}function oe(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function se(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 W(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=oe(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=se(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=ie(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function ce(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:ae(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function le(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function ue(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)||H(t)?[]:[ce(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 de(e){return W(e)}async function G(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]=W(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})}),z()}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}async function K(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);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,tools:r}}function pe(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function me(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 he(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 le(r)}var q=r();function ge(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 J(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b)}function _e({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:a,pasteFailed:o,keyPlaceholder:s,valuePlaceholder:c,headers:l,onChange:u}){let d=(e,t)=>{u(l.map((n,r)=>r===e?{...n,...t}:n))},f=()=>{u([...l,{key:``,value:``}])},p=e=>{let t=l.filter((t,n)=>n!==e);u(t.length>0?t:[{key:``,value:``}])},m=async()=>{try{let e=await L();if(!e){window.alert(o);return}let t=re(e);if(!t?.length){window.alert(o);return}u(t)}catch{window.alert(o)}};return(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,q.jsx)(`span`,{children:e}),t?(0,q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,q.jsxs)(M,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void m(),children:[(0,q.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),a]})]}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{className:i(J(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:s,onChange:e=>d(t,{key:e.target.value})}),(0,q.jsx)(`input`,{className:i(J(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:c,onChange:e=>d(t,{value:e.target.value})}),(0,q.jsx)(M,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:l.length<=1&&!e.key&&!e.value,onClick:()=>p(t),"aria-label":r,children:(0,q.jsx)(h,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},ge(e,t,l)))}),(0,q.jsxs)(`button`,{type:`button`,className:i(`self-start text-sm text-accent hover:underline`,R.press),onClick:f,children:[`+ `,n]})]})}var ve=[`stdio`,`sse`,`streamable-http`];function Y(e){let t=(0,V.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,q.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,q.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,q.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,q.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 X(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b)}function ye(e){let t=(0,V.c)(67),{row:n,t:r,onUpdate:a,idConflictMessage:o}=e,s=r.transportLabel,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=X(),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=ve.map(e=>(0,q.jsx)(`option`,{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,q.jsx)(`select`,{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,q.jsx)(Y,{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=X(),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,q.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,q.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,q.jsxs)(Y,{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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:r.commandLabel,required:!0,children:(0,q.jsx)(`input`,{className:X(),value:n.command,onChange:e=>a({command:e.target.value})})}),(0,q.jsx)(Y,{label:r.argsLabel,description:r.argsHint,children:(0,q.jsx)(`input`,{className:X(),value:n.argsText,onChange:e=>a({argsText:e.target.value})})}),(0,q.jsx)(Y,{label:r.cwdLabel,children:(0,q.jsx)(`input`,{className:X(),value:n.cwd,onChange:e=>a({cwd:e.target.value})})}),(0,q.jsx)(Y,{label:r.envLabel,description:r.envHint,children:(0,q.jsx)(`textarea`,{className:i(X(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>a({envJson:e.target.value})})})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`md:col-span-2`,children:(0,q.jsx)(Y,{label:r.urlLabel,required:!0,children:(0,q.jsx)(`input`,{className:i(X(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>a({url:e.target.value})})})}),(0,q.jsx)(_e,{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=X(),t[49]=C):C=t[49];let w;t[50]===n?w=t[51]:(w=pe(n),t[50]=n,t[51]=w);let T;t[52]===a?T=t[53]:(T=e=>a({connectionTimeoutMs:me(e.target.value)}),t[52]=a,t[53]=T);let E;t[54]!==r.timeoutPlaceholder||t[55]!==w||t[56]!==T?(E=(0,q.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,q.jsx)(Y,{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,q.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 be(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function xe(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||be(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
|
|
2
|
-
`).toLowerCase().includes(r)}function Se(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Ce(e){let t=(0,V.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:a,searchEmptyLabel:o}=e,[s,c]=(0,B.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>xe(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,q.jsx)(P,{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`,b),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,q.jsxs)(`div`,{className:`relative`,children:[p,(0,q.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,q.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,q.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,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o}):(0,q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||Se(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,q.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,q.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,q.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 x;return t[26]!==v||t[27]!==y?(x=(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=x):x=t[28],x}function we(e){let t=(0,V.c)(38),{open:n,onOpenChange:r,serverId:a,title:o,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:f,tools:p,stripPrefix:m}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,q.jsx)(S,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,E)}),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`,k,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,q.jsx)(y,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=v):v=t[2];let b;t[3]===o?b=t[4]:(b=(0,q.jsxs)(d,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[v,o]}),t[3]=o,t[4]=b);let w;t[5]!==a||t[6]!==s||t[7]!==p.length?(w=s.replace(`{{serverId}}`,a).replace(`{{count}}`,String(p.length)),t[5]=a,t[6]=s,t[7]=p.length,t[8]=w):w=t[8];let D;t[9]===w?D=t[10]:(D=(0,q.jsx)(C,{className:`mt-1 text-sm text-fg-muted`,children:w}),t[9]=w,t[10]=D);let O;t[11]!==b||t[12]!==D?(O=(0,q.jsxs)(`div`,{className:`min-w-0`,children:[b,D]}),t[11]=b,t[12]=D,t[13]=O):O=t[13];let j;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,q.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t[14]=j):j=t[14];let N;t[15]===f?N=t[16]:(N=(0,q.jsx)(I,{asChild:!0,children:(0,q.jsx)(M,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":f,children:j})}),t[15]=f,t[16]=N);let P;t[17]!==O||t[18]!==N?(P=(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[O,N]}),t[17]=O,t[18]=N,t[19]=P):P=t[19];let F;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==a||t[25]!==m||t[26]!==p?(F=p.length>0?(0,q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,q.jsx)(Ce,{tools:p,stripPrefix:m,searchPlaceholder:c,searchEmptyLabel:l},`${a}-${n?`open`:`closed`}`)}):(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,q.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]=p,t[27]=F):F=t[27];let L;t[28]===f?L=t[29]:(L=(0,q.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,q.jsx)(I,{asChild:!0,children:(0,q.jsx)(M,{type:`button`,variant:`secondary`,children:f})})}),t[28]=f,t[29]=L);let R;t[30]!==P||t[31]!==F||t[32]!==L?(R=(0,q.jsxs)(T,{children:[h,(0,q.jsxs)(_,{className:g,children:[P,F,L]})]}),t[30]=P,t[31]=F,t[32]=L,t[33]=R):R=t[33];let z;return t[34]!==r||t[35]!==n||t[36]!==R?(z=(0,q.jsx)(x,{open:n,onOpenChange:r,children:R}),t[34]=r,t[35]=n,t[36]=R,t[37]=z):z=t[37],z}function Te({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:o,t:s,cs:c,onClose:l,onSaved:u}){let[d,f]=(0,B.useState)(n),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(null),[b,x]=(0,B.useState)({status:`idle`}),[S,C]=(0,B.useState)(null),T=n.id.trim(),E=d.id.trim()!==T&&o.has(d.id.trim())||o.has(d.id.trim())&&t===`add`?s.reservedServerId:void 0,D=d.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===d.id.trim())?c.duplicateServerId:void 0,O=d.id.trim().length>0&&!E&&!D&&(d.transport===`stdio`?d.command.trim().length>0:d.url.trim().length>0),k=(0,B.useCallback)(async()=>{if(d.id.trim()){g(!0),v(null),x({status:`loading`});try{x({status:`ok`,tools:(await K(d.id.trim(),de(d))).tools})}catch(e){x({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{g(!1)}}},[d]),A=(0,B.useCallback)(async()=>{if(!(!O||p)){m(!0),v(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(d),await G({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},U(a)),await u(),l()}catch(e){v(e instanceof Error?e.message:String(e))}finally{m(!1)}}},[O,a,r,n.clientKey,t,l,u,T,d,p,i]);return e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/35 px-4 py-8`,children:(0,q.jsxs)(`div`,{className:`max-h-full w-full max-w-2xl overflow-auto rounded-3xl border border-edge bg-surface-base p-5 shadow-2xl`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:t===`add`?c.addCustomServerTitle:c.editCustomServerTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?c.addCustomServerHint:c.editCustomServerHint})]}),(0,q.jsx)(M,{variant:`ghost`,onClick:l,children:c.modalClose})]}),(0,q.jsxs)(`div`,{className:`mt-5 flex flex-col gap-4`,children:[(0,q.jsx)(ye,{row:d,t:s,onUpdate:e=>{f(t=>({...t,...e})),v(null)},idConflictMessage:E??D}),b.status===`ok`?(0,q.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,q.jsx)(y,{className:`size-4 text-accent`,"aria-hidden":!0}),b.tools.length===0?s.toolsEmpty:s.toolsTitle.replace(`{{count}}`,String(b.tools.length))]}),b.tools.length>0?(0,q.jsx)(M,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>C(b.tools),children:s.viewAllTools}):null]})}):null,b.status===`error`?(0,q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:b.message}):null,_?(0,q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:_}):null]}),(0,q.jsxs)(`div`,{className:`mt-5 flex flex-wrap justify-end gap-2`,children:[(0,q.jsxs)(M,{variant:`secondary`,disabled:!d.id.trim()||h,onClick:()=>void k(),children:[h?(0,q.jsx)(F,{className:`size-4 animate-spin`}):(0,q.jsx)(j,{className:`size-4`}),s.testConnection]}),(0,q.jsx)(M,{variant:`secondary`,onClick:l,children:c.modalCancel}),(0,q.jsxs)(M,{variant:`primary`,disabled:!O||p,onClick:()=>void A(),children:[p?(0,q.jsx)(F,{className:`size-4 animate-spin`}):(0,q.jsx)(w,{className:`size-4`}),p?s.saving:c.modalSave]})]})]})}),S?(0,q.jsx)(we,{open:!0,onOpenChange:e=>{e||C(null)},serverId:d.id,title:s.toolsDialogTitle,subtitle:s.toolsDialogSubtitle,searchPlaceholder:s.toolsDialogSearchPlaceholder,searchEmptyLabel:s.toolsDialogSearchEmpty,emptyLabel:s.toolsEmpty,closeLabel:s.toolsDialogClose,tools:S,stripPrefix:`${d.id.trim()}__`}):null]}):null}function Ee(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 Z(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function De(){return Z(await l(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function Oe(){return Z(await l(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function ke(e){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Ae(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 je(e,t){let n=await l(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return z(),Z(n,`Could not install connector.`).instance}async function Me(e){await l(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),z()}async function Q(e){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}var $=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b),Ne=i($,`min-h-28 font-mono`);function Pe(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 Fe(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 Ie(e,t){return t.some(t=>t.connectorId===e.id)}function Le(e){let t=(0,V.c)(32),{connector:n,installed:r,onInstall:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,q.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-accent-fg`,children:(0,q.jsx)(N,{className:`size-5`,"aria-hidden":!0})}),t[0]=a):a=t[0];let o;t[1]===n.displayName?o=t[2]:(o=(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.displayName}),t[1]=n.displayName,t[2]=o);let s;t[3]===n.category?s=t[4]:(s=(0,q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:n.category}),t[3]=n.category,t[4]=s);let c;t[5]!==o||t[6]!==s?(c=(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;t[8]===n.description?l=t[9]:(l=(0,q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:n.description}),t[8]=n.description,t[9]=l);let u;t[10]!==c||t[11]!==l?(u=(0,q.jsxs)(`div`,{className:`flex min-w-0 gap-3`,children:[a,(0,q.jsxs)(`div`,{className:`min-w-0`,children:[c,l]})]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d=r?`secondary`:`primary`,f;t[13]!==n||t[14]!==i?(f=()=>i(n),t[13]=n,t[14]=i,t[15]=f):f=t[15];let p;t[16]===r?p=t[17]:(p=r?(0,q.jsx)(w,{className:`size-4`}):(0,q.jsx)(m,{className:`size-4`}),t[16]=r,t[17]=p);let h=r?`Installed`:`Install`,g;t[18]!==r||t[19]!==h||t[20]!==d||t[21]!==f||t[22]!==p?(g=(0,q.jsxs)(M,{variant:d,disabled:r,onClick:f,children:[p,h]}),t[18]=r,t[19]=h,t[20]=d,t[21]=f,t[22]=p,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==u?(_=(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[u,g]}),t[24]=g,t[25]=u,t[26]=_):_=t[26];let v;t[27]===n.tags?v=t[28]:(v=n.tags?.length?(0,q.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:n.tags.map(Re)}):null,t[27]=n.tags,t[28]=v);let y;return t[29]!==_||t[30]!==v?(y=(0,q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,children:[_,v]}),t[29]=_,t[30]=v,t[31]=y):y=t[31],y}function Re(e){return(0,q.jsx)(`span`,{className:`rounded-full border border-edge px-2 py-0.5 text-[11px] text-fg-subtle`,children:e},e)}function ze({draft:e,onChange:t,onClose:n,onInstalled:r}){let{connector:i}=e,a=(0,B.useCallback)(async()=>{t({...e,installing:!0,error:null});try{let n=await ke(i.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)})}},[i.id,e,t]),o=(0,B.useCallback)(async()=>{if(e.oauth.flow){t({...e,installing:!0,error:null});try{await Ae(i.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)})}}},[i.id,e,t]),s=(0,B.useCallback)(async()=>{t({...e,installing:!0,error:null,result:null,health:null});try{if(i.auth.mode===`oauth`&&!e.oauth.connected)throw Error(`Connect GitHub OAuth before installing this connector.`);let n={};for(let t of i.setup.config??[]){let r=Pe(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let a=await je(i.id,{secrets:e.secrets,config:n}),o=null;try{o=await Q(a.instanceId)}catch{o=null}t({...e,installing:!1,result:a,health:o}),await r()}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[i.auth.mode,i.id,i.setup.config,e,t,r]);return(0,q.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/35 px-4 py-8`,children:(0,q.jsxs)(`div`,{className:`max-h-full w-full max-w-2xl overflow-auto rounded-3xl border border-edge bg-surface-base p-5 shadow-2xl`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`h2`,{className:`text-lg font-semibold text-fg`,children:[`Install `,i.displayName]}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.description})]}),(0,q.jsx)(M,{variant:`ghost`,onClick:n,children:`Close`})]}),(0,q.jsxs)(`div`,{className:`mt-5 flex flex-col gap-4`,children:[i.auth.mode===`oauth`?(0,q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:`Connect with GitHub`}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:`Authorize xopc in GitHub, then return here to finish the connection.`}),e.oauth.flow?(0,q.jsxs)(`div`,{className:`mt-3 rounded-xl bg-surface-base p-3 text-sm text-fg-muted`,children:[(0,q.jsxs)(`p`,{children:[`Open `,(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:e.oauth.flow.verificationUri}),` and enter this code:`]}),(0,q.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,q.jsx)(`p`,{className:`mt-3 rounded-xl bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700`,children:`GitHub connected. You can install this connector now.`}):null,(0,q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,q.jsxs)(M,{variant:`secondary`,disabled:e.installing,onClick:()=>void a(),children:[e.installing&&!e.oauth.flow?(0,q.jsx)(F,{className:`size-4 animate-spin`}):(0,q.jsx)(j,{className:`size-4`}),`Connect GitHub`]}),(0,q.jsxs)(M,{variant:`primary`,disabled:e.installing||!e.oauth.flow,onClick:()=>void o(),children:[e.installing&&e.oauth.flow?(0,q.jsx)(F,{className:`size-4 animate-spin`}):(0,q.jsx)(w,{className:`size-4`}),`I authorized GitHub`]})]})]}):null,(i.setup.secrets??[]).map(n=>(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,q.jsx)(O,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:{show:`Show`,hide:`Hide`,copy:`Copy`,copied:`Copied`},placeholder:n.required?`Required`:`Optional`})]},n.key)),(i.setup.config??[]).map(n=>(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,q.jsx)(`textarea`,{className:Ne,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,q.jsx)(`input`,{className:$,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.error?(0,q.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,q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-3 text-sm text-fg-muted`,children:[(0,q.jsxs)(`p`,{className:`font-medium text-fg`,children:[`Installed as `,e.result.materialized.serverId]}),e.health?(0,q.jsxs)(`p`,{className:`mt-1`,children:[e.health.toolCount,` tools discovered.`]}):(0,q.jsx)(`p`,{className:`mt-1`,children:`Installed. Tool preview can be tested from Installed.`})]}):null]}),(0,q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,q.jsx)(M,{variant:`secondary`,onClick:n,children:`Done`}),(0,q.jsxs)(M,{variant:`primary`,disabled:e.installing||i.auth.mode===`oauth`&&!e.oauth.connected,onClick:()=>void s(),children:[e.installing?(0,q.jsx)(F,{className:`size-4 animate-spin`}):(0,q.jsx)(m,{className:`size-4`}),`Install`]})]})]})})}function Be({instance:e,onChanged:t}){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),u=(0,B.useCallback)(async()=>{r(!0),l(null);try{s(await Q(e.instanceId)),await t()}catch(e){l(e instanceof Error?e.message:String(e))}finally{r(!1)}},[e.instanceId,t]),d=(0,B.useCallback)(async()=>{a(!0),l(null);try{await Me(e.instanceId),await t()}catch(e){l(e instanceof Error?e.message:String(e)),a(!1)}},[e.instanceId,t]);return(0,q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.displayName}),(0,q.jsx)(`span`,{className:`rounded-full border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:`catalog`})]}),(0,q.jsxs)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:[`MCP server: `,e.materialized.serverId]})]}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsxs)(M,{variant:`secondary`,disabled:n,onClick:()=>void u(),children:[n?(0,q.jsx)(F,{className:`size-4 animate-spin`}):(0,q.jsx)(j,{className:`size-4`}),`Test`]}),(0,q.jsxs)(M,{variant:`ghost`,disabled:i,onClick:()=>void d(),children:[i?(0,q.jsx)(F,{className:`size-4 animate-spin`}):(0,q.jsx)(h,{className:`size-4`}),`Remove`]})]})]}),c?(0,q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:c}):null,o?(0,q.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[o.toolCount,` tools discovered.`]}):null]})}function Ve({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(null),p=Ee(e),m=(0,B.useCallback)(async()=>{o(!0),f(null);try{u((await K(e.id.trim())).toolCount)}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),g=(0,B.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,q.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,q.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]})]}),p?(0,q.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-fg-subtle`,title:p,children:p}):null]}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsxs)(M,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,q.jsx)(F,{className:`size-4 animate-spin`}):(0,q.jsx)(j,{className:`size-4`}),t.testConnection]}),(0,q.jsxs)(M,{variant:`secondary`,onClick:r,children:[(0,q.jsx)(v,{className:`size-4`}),n.editCustomServer]}),(0,q.jsxs)(M,{variant:`ghost`,disabled:s,onClick:()=>void g(),children:[s?(0,q.jsx)(F,{className:`size-4 animate-spin`}):(0,q.jsx)(h,{className:`size-4`}),t.removeServer]})]})]}),d?(0,q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l==null?null:(0,q.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[l,` tools discovered.`]})]})}function He(){let e=a(o(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=s(e=>e.token),i=!!r,[c,l]=(0,B.useState)(`installed`),[d,m]=(0,B.useState)({catalog:[],instances:[],loading:!0,error:null}),[h,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(void 0),[x,S]=(0,B.useState)(!1),[C,w]=(0,B.useState)(!1),{data:T,mutate:E}=D(i),O=T?.payload?.config,k=(0,B.useMemo)(()=>O===void 0?null:ue(O),[O]),A=k?.servers??[];(0,B.useEffect)(()=>{k&&b(k.sessionIdleTtlMinutes)},[k]);let j=(0,B.useCallback)(async()=>{if(!r){m({catalog:[],instances:[],loading:!1,error:null});return}m(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([De(),Oe()]);m({catalog:e,instances:t,loading:!1,error:null})}catch(e){m({catalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,B.useEffect)(()=>{j()},[j]);let N=(0,B.useMemo)(()=>new Set(d.instances.map(e=>e.connectorId)),[d.instances]),P=(0,B.useMemo)(()=>new Set(d.instances.map(e=>e.materialized.serverId)),[d.instances]),I=(0,B.useCallback)(async e=>{if(!k||O===void 0)return;let t=A.filter(t=>t.clientKey!==e.clientKey);await G({sessionIdleTtlMinutes:k.sessionIdleTtlMinutes,servers:t},U(O)),await E(),await j()},[O,A,j,k,E]),L=(0,B.useCallback)(async()=>{if(!(!k||O===void 0||x)){S(!0),w(!1);try{await G({sessionIdleTtlMinutes:y,servers:A},U(O)),await E(),w(!0),u({type:`success`,title:n.saved})}finally{S(!1)}}},[O,A,k,E,y,x]),R=d.instances.length+A.length;return(0,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-5 px-4 py-8`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:t.title}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.subtitle})]}),i?null:(0,q.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`installed`,`discover`].map(e=>(0,q.jsx)(M,{variant:c===e?`primary`:`secondary`,onClick:()=>l(e),children:e===`installed`?t.tabInstalled:t.tabDiscover},e))}),d.loading&&i?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,q.jsx)(F,{className:`size-4 animate-spin`}),t.loading]}):null,d.error?(0,q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d.error}):null,c===`installed`&&i?(0,q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,q.jsxs)(te,{children:[(0,q.jsx)(ee,{icon:f,title:n.globalTitle,subtitle:n.globalHint}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-end`,children:[(0,q.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.idleTtlLabel}),(0,q.jsx)(`input`,{type:`number`,min:0,className:$,value:y??``,placeholder:n.idleTtlPlaceholder,onChange:e=>{let t=e.target.value.trim();b(t===``?void 0:Number.parseInt(t,10)),w(!1)}}),(0,q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.idleTtlHint})]}),(0,q.jsxs)(M,{variant:`secondary`,disabled:x,onClick:()=>void L(),children:[x?(0,q.jsx)(F,{className:`size-4 animate-spin`}):null,n.save]})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.installedTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.installedHint})]}),(0,q.jsxs)(M,{variant:`primary`,onClick:()=>v({mode:`add`,row:he(A,P)}),children:[(0,q.jsx)(p,{className:`size-4`}),t.addCustomServer]})]}),R===0?(0,q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.installedEmpty}):(0,q.jsxs)(`div`,{className:`grid gap-3`,children:[d.instances.map(e=>(0,q.jsx)(Be,{instance:e,onChanged:j},e.instanceId)),A.map(e=>(0,q.jsx)(Ve,{row:e,t:n,cs:t,onEdit:()=>v({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>I(e)},e.clientKey))]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,c===`discover`&&i?(0,q.jsxs)(`div`,{className:`grid gap-3`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.catalogHint}),d.catalog.map(e=>(0,q.jsx)(Le,{connector:e,installed:N.has(e.id)||Ie(e,d.instances),onInstall:e=>g(Fe(e))},e.id))]}):null,h?(0,q.jsx)(ze,{draft:h,onChange:g,onClose:()=>g(null),onInstalled:async()=>{await j(),await E(),g(null),l(`installed`)}}):null,_?(0,q.jsx)(Te,{open:!0,mode:_.mode,initialRow:_.row,existingCustomServers:A,sessionIdleTtlMinutes:y,config:O,managedServerIds:P,t:n,cs:t,onClose:()=>v(null),onSaved:async()=>{await E(),await j(),l(`installed`)}},`${_.mode}-${_.row.clientKey}`):null]})}export{He as ConnectorsSettingsPanel};
|
|
@@ -1,3 +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-JdwAhgNB.js";import{t as a}from"./messages-CkT-lcgP.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{i as s}from"./theme-store-CD2wtgZV.js";import{c,i as l,n as u,t as d}from"./fetch-NZmjSXLl.js";import{r as f}from"./toast-z0toXu32.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{$r as m,B as h,Bo as g,Cr as _,Di as v,Ds as y,Ea as b,Fo as x,Ft as S,H as C,Ha as w,Hi as T,Jr as E,Kr as D,L as O,Oa as k,Oi as A,Oo as j,Qr as M,Ss as N,Ti as P,U as F,V as I,Xr as L,Yr as R,Zr as z,_i as B,_r as V,as as H,ba as U,bo as W,br as G,ii as ee,is as K,ji as te,jo as ne,k as re,ki as q,o as ie,oi as ae,pa as oe,qa as se,qr as ce,ra as le,ro as ue,rs as de,ta as fe,ts as J,ua as pe,uo as me,vr as he,wi as ge,wr as _e,xi as ve,yr as ye,zn as be}from"./index-Cxm6xsps.js";import{t as xe}from"./markdown-editor-AssmZFx4.js";import{t as Se}from"./settings-advanced-gate-D9sva86V.js";import{n as Ce,t as we}from"./settings-form-section-Dq-83cQd.js";import{C as Y,S as Te,T as Ee,_ as De,a as Oe,b as ke,c as Ae,d as je,f as Me,g as Ne,h as Pe,i as Fe,l as Ie,m as Le,n as Re,o as ze,p as Be,r as Ve,s as He,t as Ue,u as We,v as Ge,w as Ke,x as qe,y as Je}from"./cron-api--pAB_rps.js";import{t as Ye}from"./cron-dreaming-jobs-nCMWCf0p.js";import{r as Xe}from"./interval-presets-DJmshV8n.js";import{t as Ze}from"./format-interval-label-qhth3BMV.js";import{t as Qe}from"./heartbeat-config-api-BzO6G4fD.js";import{h as $e,m as et,t as tt}from"./workflow-page.utils-sgHjOXOm.js";import{i as nt,n as rt,o as it,r as at,t as ot}from"./dist-By6Rh2ee.js";var X=e(t(),1),Z=n(),Q=r();function st(e){let t=(0,Z.c)(25),{open:n,onOpenChange:r,action:i,c:a,onDismiss:o,onConfirm:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(L,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim`}),t[0]=c):c=t[0];let l=i===`delete`?a.delete:a.runNow,u;t[1]===l?u=t[2]:(u=(0,Q.jsx)(m,{className:`text-base font-semibold text-fg`,children:l}),t[1]=l,t[2]=u);let d=i===`delete`?a.confirmDelete:a.confirmRun,f;t[3]===d?f=t[4]:(f=(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:d}),t[3]=d,t[4]=f);let p;t[5]!==a.cancel||t[6]!==o?(p=(0,Q.jsx)(q,{type:`button`,variant:`secondary`,onClick:o,children:a.cancel}),t[5]=a.cancel,t[6]=o,t[7]=p):p=t[7];let h=i===`delete`?`bg-red-600 hover:bg-red-700`:void 0,g;t[8]===s?g=t[9]:(g=()=>void s(),t[8]=s,t[9]=g);let _=i===`delete`?a.delete:a.runNow,v;t[10]!==h||t[11]!==g||t[12]!==_?(v=(0,Q.jsx)(q,{type:`button`,variant:`primary`,className:h,onClick:g,children:_}),t[10]=h,t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]!==v||t[15]!==p?(y=(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[p,v]}),t[14]=v,t[15]=p,t[16]=y):y=t[16];let b;t[17]!==y||t[18]!==u||t[19]!==f?(b=(0,Q.jsxs)(z,{children:[c,(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center p-4 pointer-events-none`,children:(0,Q.jsxs)(E,{className:`xopc-dialog-content-pane pointer-events-auto relative w-full max-w-md rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,children:[u,f,y]})})]}),t[17]=y,t[18]=u,t[19]=f,t[20]=b):b=t[20];let x;return t[21]!==r||t[22]!==n||t[23]!==b?(x=(0,Q.jsx)(M,{open:n,onOpenChange:r,children:b}),t[21]=r,t[22]=n,t[23]=b,t[24]=x):x=t[24],x}var ct={enabled:!0,maxConcurrentJobs:5,historyRetentionDays:7,enableMetrics:!0};function lt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ut(e){let t=lt(e)?e:{},n=lt(t.cron)?t.cron:{};return{enabled:n.enabled!==!1,maxConcurrentJobs:typeof n.maxConcurrentJobs==`number`&&Number.isFinite(n.maxConcurrentJobs)?Math.max(1,Math.min(100,Math.floor(n.maxConcurrentJobs))):ct.maxConcurrentJobs,historyRetentionDays:typeof n.historyRetentionDays==`number`&&Number.isFinite(n.historyRetentionDays)?Math.max(1,Math.min(365,Math.floor(n.historyRetentionDays))):ct.historyRetentionDays,enableMetrics:n.enableMetrics!==!1}}async function dt(e){await u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({cron:e})}),ye()}function ft(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,A,`dark:border-edge`)}function pt(){return{form:null,baseline:null,saving:!1,error:null,saveOk:!1,dirty:!1}}function mt(e,t){switch(t.type){case`sync`:return{...e,form:structuredClone(t.parsed),baseline:structuredClone(t.parsed),saveOk:!1,dirty:!1};case`patch`:return e.form?{...e,form:{...e.form,...t.patch},dirty:!0,saveOk:!1}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline),dirty:!1}:e;case`saveStart`:return{...e,saving:!0,error:null};case`saveSuccess`:return e.form?{...e,saving:!1,baseline:structuredClone(e.form),dirty:!1,saveOk:!0}:{...e,saving:!1};case`saveError`:return{...e,saving:!1,error:t.error};case`clearSaveOk`:return{...e,saveOk:!1}}}function ht({hasToken:e}){let t=a(o(e=>e.language)).cron.globals,{data:n,isLoading:r}=G(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(ut(n.payload.config)),[n]),[s,c]=(0,X.useReducer)(mt,void 0,pt),l=(0,X.useRef)(null);(0,X.useEffect)(()=>{!e||i===null||s.dirty||l.current===i||(l.current=i,c({type:`sync`,parsed:i}))},[e,i,s.dirty]);let u=(0,X.useMemo)(()=>!!(s.form&&s.baseline&&JSON.stringify(s.form)!==JSON.stringify(s.baseline)),[s.form,s.baseline]),d=(0,X.useCallback)(e=>{c({type:`patch`,patch:e})},[]),p=(0,X.useCallback)(async()=>{if(!(!s.form||s.saving)){c({type:`saveStart`});try{await dt(s.form),c({type:`saveSuccess`}),f({type:`success`,title:t.saved})}catch(e){c({type:`saveError`,error:e instanceof Error?e.message:t.saveError})}}},[t.saveError,s.form,s.saving]);return!e||!s.form?r?(0,Q.jsx)(we,{children:(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Q.jsx)(se,{className:`size-4 animate-spin`}),t.loading]})}):null:(0,Q.jsxs)(we,{children:[(0,Q.jsx)(Ce,{icon:g,title:t.title,subtitle:t.hint}),(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-end gap-2`,children:[(0,Q.jsx)(q,{type:`button`,variant:`secondary`,disabled:!u||s.saving,onClick:()=>c({type:`discard`}),children:t.discard}),(0,Q.jsx)(q,{type:`button`,variant:`primary`,disabled:!u||s.saving,onClick:()=>void p(),children:s.saving?t.saving:t.save})]}),s.error?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg sm:col-span-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:s.form.enabled,onChange:e=>d({enabled:e.target.checked})}),t.enabled]}),(0,Q.jsxs)(Se,{children:[(0,Q.jsx)(gt,{label:t.maxConcurrent,value:s.form.maxConcurrentJobs,min:1,max:100,disabled:!s.form.enabled,onChange:e=>d({maxConcurrentJobs:e})}),(0,Q.jsx)(gt,{label:t.retentionDays,value:s.form.historyRetentionDays,min:1,max:365,disabled:!s.form.enabled,onChange:e=>d({historyRetentionDays:e})}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:s.form.enableMetrics,disabled:!s.form.enabled,onChange:e=>d({enableMetrics:e.target.checked})}),t.metrics]})]})]})]})}function gt(e){let t=(0,Z.c)(13),{label:n,value:r,min:a,max:o,disabled:s,text:c,onChange:l,onTextChange:u}=e,d;t[0]===n?d=t[1]:(d=(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=d);let f;t[2]!==s||t[3]!==o||t[4]!==a||t[5]!==l||t[6]!==u||t[7]!==c||t[8]!==r?(f=c?(0,Q.jsx)(`input`,{className:i(ft(),`font-mono text-xs`),value:String(r),disabled:s,onChange:e=>u?.(e.target.value)}):(0,Q.jsx)(`input`,{type:`number`,min:a,max:o,disabled:s,className:i(ft(),`max-w-xs font-mono text-xs`),value:typeof r==`number`?r:0,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&l&&a!==void 0&&o!==void 0&&l(Math.max(a,Math.min(o,Math.floor(t))))}}),t[2]=s,t[3]=o,t[4]=a,t[5]=l,t[6]=u,t[7]=c,t[8]=r,t[9]=f):f=t[9];let p;return t[10]!==d||t[11]!==f?(p=(0,Q.jsxs)(`div`,{children:[d,f]}),t[10]=d,t[11]=f,t[12]=p):p=t[12],p}var _t=`*/5 * * * *`;function vt(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function yt(e){let t=vt(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t}function bt(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function xt(e){let t=e?.trim();t&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:t},bubbles:!0}))}function St(e){let t=e?.trim();t&&(window.location.hash=`/workflows?run=${encodeURIComponent(t)}`)}function Ct(e){return i(`w-full rounded-md border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-disabled`,ge,e&&`cursor-not-allowed opacity-60`)}function wt(){return i(v,P)}var Tt=i(v,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`),Et=i(v,`w-auto min-w-[9rem] max-w-[14rem] shrink-0 text-xs`);function Dt(e){return e===`settings`?`settings`:e===`system`||e===`systemTasks`?`systemTasks`:e===`history`?`history`:`myTasks`}function Ot(e){return e===`myTasks`?null:e===`systemTasks`?`system`:e===`history`?`history`:`settings`}var kt=34,At=62,jt=46;function $(e){return Math.max(kt,Math.min(At,e))}function Mt(e){switch(e){case`success`:return`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`;case`failed`:return`bg-red-500/15 text-red-800 dark:text-red-300`;case`running`:return`bg-accent/15 text-accent`;case`cancelled`:return`bg-surface-hover text-fg-muted`;default:return`bg-surface-hover text-fg-muted`}}function Nt(e,t){return e.payload.kind===`workflowRun`?t.taskKindWorkflowRun:e.payload.kind===`agentTurn`?t.taskKindMessage:t.modeDirectOption}function Pt(e){return e.length===0?null:e.find(e=>e.status===`failed`)?.id??e[0]?.id??null}function Ft(e){let t=(0,Z.c)(56),{row:n,expanded:r,onToggle:a,c:o,statusLabels:s}=e,c=n.error||n.summary||n.output||``,l;t[0]===c?l=t[1]:(l=c.trim(),t[0]=c,t[1]=l);let u=l,d=u.length>0,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`div`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover`,children:(0,Q.jsx)(g,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0})}),t[2]=f):f=t[2];let p=n.startedAt,m;t[3]===n.startedAt?m=t[4]:(m=Y(n.startedAt),t[3]=n.startedAt,t[4]=m);let h;t[5]!==n.startedAt||t[6]!==m?(h=(0,Q.jsx)(`time`,{className:`text-sm font-medium text-fg`,dateTime:p,children:m}),t[5]=n.startedAt,t[6]=m,t[7]=h):h=t[7];let _;t[8]===n.status?_=t[9]:(_=i(`inline-flex rounded-md px-2 py-0.5 text-xs font-medium`,Mt(n.status)),t[8]=n.status,t[9]=_);let v;t[10]!==n.status||t[11]!==s?(v=De(n.status,s),t[10]=n.status,t[11]=s,t[12]=v):v=t[12];let y;t[13]!==_||t[14]!==v?(y=(0,Q.jsx)(`span`,{className:_,children:v}),t[13]=_,t[14]=v,t[15]=y):y=t[15];let b;t[16]===n.duration?b=t[17]:(b=Je(n.duration),t[16]=n.duration,t[17]=b);let x;t[18]===b?x=t[19]:(x=(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:b}),t[18]=b,t[19]=x);let S;t[20]!==x||t[21]!==h||t[22]!==y?(S=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[h,y,x]}),t[20]=x,t[21]=h,t[22]=y,t[23]=S):S=t[23];let C;t[24]!==u||t[25]!==r||t[26]!==d?(C=!r&&d?(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:u}):null,t[24]=u,t[25]=r,t[26]=d,t[27]=C):C=t[27];let T;t[28]!==u||t[29]!==r||t[30]!==d?(T=r&&d?(0,Q.jsx)(`pre`,{className:`mt-2 max-h-40 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-edge-subtle bg-surface-panel/80 p-2.5 font-mono text-xs leading-relaxed text-fg-muted`,children:u}):null,t[28]=u,t[29]=r,t[30]=d,t[31]=T):T=t[31];let E;t[32]!==S||t[33]!==C||t[34]!==T?(E=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-3`,children:[f,(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C,T]})]}),t[32]=S,t[33]=C,t[34]=T,t[35]=E):E=t[35];let D;t[36]!==o||t[37]!==r||t[38]!==d||t[39]!==a?(D=d?(0,Q.jsxs)(q,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:a,children:[(0,Q.jsx)(de,{className:i(`size-3.5 transition-transform`,r&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0}),r?o.detailCollapseRun:o.detailExpandRun]}):null,t[36]=o,t[37]=r,t[38]=d,t[39]=a,t[40]=D):D=t[40];let O;t[41]!==o||t[42]!==n.workflowRunId?(O=n.workflowRunId?.trim()?(0,Q.jsxs)(q,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,title:o.openWorkflowTitle,onClick:()=>St(n.workflowRunId),children:[(0,Q.jsx)(W,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),o.openWorkflow]}):null,t[41]=o,t[42]=n.workflowRunId,t[43]=O):O=t[43];let k;t[44]!==o||t[45]!==n.sessionKey?(k=n.sessionKey?.trim()?(0,Q.jsxs)(q,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,title:o.openChatTitle,onClick:()=>xt(n.sessionKey),children:[(0,Q.jsx)(w,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),o.openChat]}):null,t[44]=o,t[45]=n.sessionKey,t[46]=k):k=t[46];let A;t[47]!==O||t[48]!==k?(A=(0,Q.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[O,k]}),t[47]=O,t[48]=k,t[49]=A):A=t[49];let j;t[50]!==D||t[51]!==A?(j=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-edge-subtle px-3 py-2 dark:border-edge-subtle`,children:[D,A]}),t[50]=D,t[51]=A,t[52]=j):j=t[52];let M;return t[53]!==E||t[54]!==j?(M=(0,Q.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:[E,j]}),t[53]=E,t[54]=j,t[55]=M):M=t[55],M}function It(e){let t=(0,Z.c)(13),{icon:n,label:r,value:a,valueClassName:o}=e,s;t[0]===n?s=t[1]:(s=(0,Q.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=s);let c;t[2]!==r||t[3]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:[s,r]}),t[2]=r,t[3]=s,t[4]=c):c=t[4];let l;t[5]===o?l=t[6]:(l=i(`mt-1 truncate text-sm font-medium text-fg`,o),t[5]=o,t[6]=l);let u;t[7]!==l||t[8]!==a?(u=(0,Q.jsx)(`p`,{className:l,children:a}),t[7]=l,t[8]=a,t[9]=u):u=t[9];let d;return t[10]!==c||t[11]!==u?(d=(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-edge-subtle bg-surface-base/80 px-3 py-2.5 dark:border-edge-subtle`,children:[c,u]}),t[10]=c,t[11]=u,t[12]=d):d=t[12],d}function Lt({open:e,onDismiss:t,detailJob:n,detailLoading:r,actionNotice:a,detailHistory:o,c:s,localeTag:c,scheduleBadgeLabels:l,chatWorkingDirNotSet:u,statusLabels:d,onEdit:f,onRunNow:p,onToggle:h,onDelete:_}){let[v,y]=(0,X.useState)(null),[b,S]=(0,X.useState)(!1),[C,D]=(0,X.useState)(jt),[O,A]=(0,X.useState)(!1),j=(0,X.useRef)(null),N=(0,X.useMemo)(()=>{let e=0,t=0;for(let n of o)n.status===`success`&&(e+=1),n.status===`failed`&&(t+=1);return{success:e,failed:t}},[o]),P=o[0]??null;(0,X.useEffect)(()=>{if(!e){y(null),S(!1);return}y(Pt(o))},[e,n?.id,o]);let F=(0,X.useCallback)(async()=>{n?.schedule&&await B(Ke(n.schedule))&&(S(!0),window.setTimeout(()=>S(!1),1500))},[n?.schedule]),I=n?Te(n,c,l):`—`,R=(0,X.useCallback)(e=>{e.preventDefault();let t=j.current;if(!t)return;let n=t.getBoundingClientRect(),r=e.currentTarget,i=e.pointerId;r.setPointerCapture(i),A(!0);let a=e=>{D($((e-n.left)/n.width*100))};a(e.clientX);let o=e=>{a(e.clientX)},s=()=>{try{r.releasePointerCapture(i)}catch{}A(!1),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[]),V=(0,X.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),D(e=>$(e-4))):e.key===`ArrowRight`?(e.preventDefault(),D(e=>$(e+4))):e.key===`Home`?(e.preventDefault(),D(kt)):e.key===`End`&&(e.preventDefault(),D(At))},[]);return(0,Q.jsx)(M,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(z,{children:[(0,Q.jsx)(L,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,Q.jsxs)(E,{className:i(`xopc-dialog-content-pane pointer-events-auto relative flex h-[min(86vh,46rem)] w-full max-w-6xl flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,`dark:border-edge`),"aria-describedby":void 0,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(m,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n?.name?.trim()||n?.id||`—`}),n?(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:I}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n?(0,Q.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n.enabled,"aria-label":n.enabled?s.enabled:s.disabled,className:i(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,n.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`),onClick:()=>h(n,!n.enabled),children:(0,Q.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})}):null,(0,Q.jsx)(ce,{asChild:!0,children:(0,Q.jsx)(q,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:(0,Q.jsx)(te,{className:`size-5`,strokeWidth:1.75})})})]})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4 lg:overflow-hidden`,children:r?(0,Q.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,Q.jsx)(se,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):n?(0,Q.jsxs)(`div`,{className:`flex min-h-full flex-col gap-4 lg:h-full lg:min-h-0`,children:[a?(0,Q.jsx)(`div`,{className:i(`rounded-xl border px-3 py-2 text-sm`,a.kind===`error`?`border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900/50 dark:bg-amber-950/40 dark:text-amber-100`:`border-accent/25 bg-accent/5 text-fg dark:border-accent/30 dark:bg-accent/10`),role:`alert`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsx)(`p`,{children:a.message}),a.sessionKey?(0,Q.jsxs)(q,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 gap-1.5 px-2.5 text-xs`,onClick:()=>xt(a.sessionKey),children:[(0,Q.jsx)(w,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),s.openChat]}):null]})}):null,(0,Q.jsxs)(`div`,{ref:j,className:`grid min-h-0 grid-cols-1 gap-4 lg:flex-1 lg:[grid-template-columns:minmax(0,var(--cron-detail-config-pane))_0.75rem_minmax(23rem,1fr)] lg:gap-0`,style:{"--cron-detail-config-pane":`${C}%`},children:[(0,Q.jsx)(`div`,{className:`rounded-2xl border border-edge bg-surface-base/35 p-4 lg:min-h-0 lg:overflow-y-auto`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.scheduleLabel}),(0,Q.jsxs)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base/80 px-3 py-3 dark:border-edge-subtle`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-sm font-medium leading-relaxed text-fg`,children:I}),(0,Q.jsx)(q,{type:`button`,variant:`secondary`,className:`size-8 shrink-0 p-0`,title:s.detailCopySchedule,"aria-label":s.detailCopySchedule,onClick:()=>void F(),children:b?(0,Q.jsx)(K,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75}):(0,Q.jsx)(x,{className:`size-3.5`,strokeWidth:1.75})})]}),(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`span`,{className:`font-medium text-fg-subtle`,children:[s.detailCronTechnical,`: `]}),(0,Q.jsx)(`code`,{className:`font-mono`,children:Ke(n.schedule)})]})]})]}),(0,Q.jsxs)(`section`,{"aria-label":s.statsRegion,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Q.jsx)(It,{icon:H,label:s.nextRun,value:n.nextRunAtMs?ke(new Date(n.nextRunAtMs).toISOString(),s.timeLabels):`—`}),(0,Q.jsx)(It,{icon:g,label:s.detailLastRun,value:P?De(P.status,d):s.detailNoRecentRuns,valueClassName:P?.status===`failed`?`text-red-700 dark:text-red-300`:P?.status===`success`?`text-emerald-800 dark:text-emerald-300`:void 0})]}),o.length>0?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:s.detailRunCount.replace(`{{success}}`,String(N.success)).replace(`{{failed}}`,String(N.failed))}):null]}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.detailWhatItDoes}),(0,Q.jsxs)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base/80 p-3 dark:border-edge-subtle`,children:[(0,Q.jsx)(`div`,{className:`mb-2 inline-flex rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:Nt(n,s)}),(0,Q.jsx)(`div`,{className:`min-w-0 break-words text-fg [&_.markdown-body]:text-sm [&_.markdown-body]:leading-relaxed`,children:(0,Q.jsx)(be,{content:Fe(n),compact:!0,className:`text-sm`})})]})]}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(pe,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.detailRunSettings})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:s.detailRunSettingsHint}),(0,Q.jsxs)(`dl`,{className:`mt-3 grid gap-3 rounded-xl border border-edge-subtle bg-surface-base/80 px-3 py-3 text-sm dark:border-edge-subtle`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:s.mode}),(0,Q.jsx)(`dd`,{className:`mt-1 text-fg`,children:n.sessionTarget===`isolated`?s.modeAgentOption:s.modeDirectOption})]}),n.sessionTarget===`isolated`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:s.agentProfile}),(0,Q.jsx)(`dd`,{className:`mt-1 font-mono text-sm text-fg`,children:n.agentId?.trim()?n.agentId.trim():s.agentProfileDefault})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:s.workingDirectoryLabel}),(0,Q.jsx)(`dd`,{className:`mt-1 break-all font-mono text-xs text-fg`,children:n.workingDirectory?.trim()?n.workingDirectory.trim():u})]})]}):null,n.delivery?.channel===`local`||n.sessionTarget===`isolated`&&!n.delivery?.to?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:s.deliveryTarget}),(0,Q.jsx)(`dd`,{className:`mt-1 text-fg`,children:n.delivery?.channel===`local`?s.deliveryTargetLocalChannel:s.deliveryLocalOnly})]}):n.delivery?.to?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:s.deliveryTarget}),(0,Q.jsxs)(`dd`,{className:`mt-1 break-words text-fg`,children:[(0,Q.jsx)(`code`,{className:`text-xs`,children:n.delivery?.channel??``}),` → `,Ge(n,s.channelLocal)]})]}):null,n.model?.trim()?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:s.model}),(0,Q.jsx)(`dd`,{className:`mt-1 font-mono text-sm text-fg`,children:n.model.trim()})]}):null]})]})]})}),(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":s.detailResizeColumns,"aria-valuemin":kt,"aria-valuemax":At,"aria-valuenow":Math.round(C),tabIndex:0,onPointerDown:R,onKeyDown:V,className:i(`group hidden h-full cursor-col-resize touch-none select-none items-stretch justify-center rounded-lg outline-none lg:flex`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),children:(0,Q.jsx)(`span`,{className:i(`h-full w-px bg-edge-subtle transition-colors duration-150`,`group-hover:bg-edge`,O&&`bg-edge`)})}),(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base/35 p-4 lg:min-h-0 lg:overflow-y-auto`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.detailRunHistory}),o.length>0?(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:o.length}):null]}),o.length===0?(0,Q.jsxs)(`div`,{className:`mt-2 rounded-xl border border-dashed border-edge-subtle px-4 py-8 text-center dark:border-edge-subtle`,children:[(0,Q.jsx)(g,{className:`mx-auto size-8 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:s.noRunsYet})]}):(0,Q.jsx)(`ul`,{className:`mt-2 space-y-2`,children:o.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(Ft,{row:e,expanded:v===e.id,onToggle:()=>y(t=>t===e.id?null:e.id),c:s,statusLabels:d})},e.id))})]})]})]}):null}),n&&!r?(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(q,{type:`button`,className:`gap-1.5`,onClick:()=>p(n),children:[(0,Q.jsx)(k,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),s.runNow]}),(0,Q.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>f(n),children:s.edit}),(0,Q.jsxs)(q,{type:`button`,variant:`secondary`,className:`ml-auto text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:()=>_(n),children:[(0,Q.jsx)(T,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),s.delete]})]})}):null]})})]})})}function Rt(e){if(!e.trim())return null;try{return JSON.parse(e)}catch{return null}}function zt(e){return typeof e.message==`string`&&e.message.trim()?e.message:typeof e.error==`string`&&e.error.trim()?e.error:e.error&&typeof e.error==`object`&&typeof e.error.message==`string`?e.error.message:`AI suggestion failed`}function Bt(e,t={}){let n=Rt(e.split(`
|
|
2
|
-
`).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
|
|
3
|
-
`));if(!n)return null;if(n.type===`text_delta`&&typeof n.delta==`string`)return t.onDelta?.(n.delta),null;if(n.type===`thinking_delta`&&typeof n.delta==`string`)return t.onThinkingDelta?.(n.delta),null;if(n.type===`done`&&typeof n.text==`string`)return n.text;if(n.type===`error`)throw Error(zt(n));return null}async function Vt(e,t={}){let n=await d(l(`/api/ai/text-assist`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify(e)});if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message;throw Error(t||`AI suggestion failed (${n.status})`)}if(!n.body){let e=await n.json().catch(()=>null);if(e?.text)return e;throw Error(`AI suggestion stream is empty`)}let r=n.body.getReader(),i=new TextDecoder,a=``,o=``,s=``;for(;;){let{done:e,value:n}=await r.read();if(n){a+=i.decode(n,{stream:!e});let r=a.split(/\r?\n\r?\n/);a=r.pop()??``;for(let e of r){let n=Bt(e,{onDelta:e=>{o+=e,t.onDelta?.(e)},onThinkingDelta:e=>{s+=e,t.onThinkingDelta?.(e)}});n!==null&&(o=n)}}if(e)break}if(a.trim()){let e=Bt(a,{onDelta:e=>{o+=e,t.onDelta?.(e)},onThinkingDelta:e=>{s+=e,t.onThinkingDelta?.(e)}});e!==null&&(o=e)}let c=o.trim();if(!c)throw Error(`AI returned an empty suggestion`);return{text:c,thinking:s.trim()||void 0}}function Ht(){let[e,t]=(0,X.useState)(``),[n,r]=(0,X.useState)(``),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(null);return{suggestion:e,thinking:n,loading:i,error:o,generate:(0,X.useCallback)(async e=>{a(!0),s(null),t(``),r(``);try{let n=await Vt(e,{onDelta:e=>{t(t=>t+e)},onThinkingDelta:e=>{r(t=>t+e)}});return t(n.text),r(n.thinking??``),n.text}catch(e){return s(e instanceof Error?e.message:`AI suggestion failed`),null}finally{a(!1)}},[]),reset:(0,X.useCallback)(()=>{t(``),r(``),s(null),a(!1)},[])}}var Ut=5;function Wt(e){return e.startsWith(`zh`)?{title:`AI 优化文案`,buttonTitle:`优化文案`,current:`当前内容`,suggestion:`AI 建议`,editedSuggestion:`审核并编辑建议`,thinking:`模型思考`,thinkingLoading:`思考中`,edit:`编辑`,preview:`预览`,loading:`正在生成建议...`,empty:`暂无内容`,regenerate:`重新生成`,applyCurrent:`应用当前内容`,replace:`替换`,append:`追加`,cancel:`取消`,close:`关闭`}:{title:`AI text assist`,buttonTitle:`Improve text`,current:`Current`,suggestion:`Suggestion`,editedSuggestion:`Review and edit suggestion`,thinking:`Model thinking`,thinkingLoading:`Thinking`,edit:`Edit`,preview:`Preview`,loading:`Generating suggestion...`,empty:`No content`,regenerate:`Regenerate`,applyCurrent:`Apply current`,replace:`Replace`,append:`Append`,cancel:`Cancel`,close:`Close`}}function Gt(e){let t=(0,Z.c)(228),{value:n,onApply:r,fieldId:a,fieldLabel:o,scenario:s,format:c,intent:l,locale:u,context:d,disabled:f,className:p,showLabel:h}=e,g=s===void 0?`generic.text`:s,_=c===void 0?`plain`:c,v=l===void 0?`improve`:l,y=h===void 0?!0:h,[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(n),[w,T]=(0,X.useState)(`preview`),[D,O]=(0,X.useState)(``),[k,A]=(0,X.useState)(`edit`),[N,P]=(0,X.useState)(!0),F=(0,X.useRef)(null),I=(0,X.useRef)(!0),{suggestion:R,thinking:B,loading:V,error:H,generate:W,reset:G}=Ht(),ee;t[0]===u?ee=t[1]:(ee=Wt(u),t[0]=u,t[1]=ee);let K=ee,ne;t[2]!==V||t[3]!==B?(ne=V&&B.trim().length>0,t[2]=V,t[3]=B,t[4]=ne):ne=t[4];let re=ne,ie,ae;t[5]!==b||t[6]!==n?(ie=()=>{b||C(n)},ae=[b,n],t[5]=b,t[6]=n,t[7]=ie,t[8]=ae):(ie=t[7],ae=t[8]),(0,X.useEffect)(ie,ae);let oe,se;t[9]===R?(oe=t[10],se=t[11]):(se=()=>{O(R)},oe=[R],t[9]=R,t[10]=oe,t[11]=se),(0,X.useEffect)(se,oe);let ue,J;t[12]===B?(ue=t[13],J=t[14]):(ue=()=>{B.trim()&&P(!0)},J=[B],t[12]=B,t[13]=ue,t[14]=J),(0,X.useEffect)(ue,J);let pe;t[15]!==re||t[16]!==N?(pe=()=>{let e=F.current;!e||!re||!N||I.current&&(e.scrollTop=e.scrollHeight)},t[15]=re,t[16]=N,t[17]=pe):pe=t[17];let me;t[18]!==re||t[19]!==B||t[20]!==N?(me=[re,B,N],t[18]=re,t[19]=B,t[20]=N,t[21]=me):me=t[21],(0,X.useLayoutEffect)(pe,me);let he;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(he=()=>{let e=F.current;e&&(I.current=e.scrollHeight-e.scrollTop-e.clientHeight<=Ut)},t[22]=he):he=t[22];let ge=he,_e;t[23]!==d||t[24]!==a||t[25]!==o||t[26]!==_||t[27]!==W||t[28]!==v||t[29]!==u||t[30]!==g?(_e=async e=>{A(`edit`),P(!0),I.current=!0,await W({intent:v,scenario:g,input:e,locale:u,field:{id:a,label:o,format:_},context:d})},t[23]=d,t[24]=a,t[25]=o,t[26]=_,t[27]=W,t[28]=v,t[29]=u,t[30]=g,t[31]=_e):_e=t[31];let ve=_e,ye;t[32]!==ve||t[33]!==n?(ye=async()=>{C(n),T(`preview`),x(!0),await ve(n)},t[32]=ve,t[33]=n,t[34]=ye):ye=t[34];let xe=ye,Se;t[35]!==S||t[36]!==ve?(Se=async()=>{await ve(S)},t[35]=S,t[36]=ve,t[37]=Se):Se=t[37];let Ce=Se,we;t[38]!==G||t[39]!==n?(we=()=>{x(!1),C(n),T(`preview`),O(``),A(`edit`),P(!0),G()},t[38]=G,t[39]=n,t[40]=we):we=t[40];let Y=we,Te;t[41]!==Y||t[42]!==S||t[43]!==r?(Te=()=>{r(S),Y()},t[41]=Y,t[42]=S,t[43]=r,t[44]=Te):Te=t[44];let Ee=Te,De;t[45]!==Y||t[46]!==D||t[47]!==r?(De=()=>{D.trim()&&(r(D),Y())},t[45]=Y,t[46]=D,t[47]=r,t[48]=De):De=t[48];let Oe=De,ke;t[49]!==Y||t[50]!==S||t[51]!==D||t[52]!==r?(ke=()=>{if(!D.trim())return;let e=S.trimEnd();r(e?`${e}\n\n${D}`:D),Y()},t[49]=Y,t[50]=S,t[51]=D,t[52]=r,t[53]=ke):ke=t[53];let Ae=ke,je;t[54]!==D||t[55]!==H||t[56]!==V?(je=!V&&!H&&D.trim().length>0,t[54]=D,t[55]=H,t[56]=V,t[57]=je):je=t[57];let Me=je,Ne=S!==n,Pe=!y&&`size-7 p-0`,Fe;t[58]!==p||t[59]!==Pe?(Fe=i(`h-7 gap-1 px-2 text-xs`,Pe,p),t[58]=p,t[59]=Pe,t[60]=Fe):Fe=t[60];let Ie=f||V,Le;t[61]===xe?Le=t[62]:(Le=()=>void xe(),t[61]=xe,t[62]=Le);let Re;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,Q.jsx)(le,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[63]=Re):Re=t[63];let ze=y?K.buttonTitle:null,Be;t[64]!==K.buttonTitle||t[65]!==Fe||t[66]!==Ie||t[67]!==Le||t[68]!==ze?(Be=(0,Q.jsxs)(q,{type:`button`,variant:`ghost`,className:Fe,title:K.buttonTitle,"aria-label":K.buttonTitle,disabled:Ie,onClick:Le,children:[Re,ze]}),t[64]=K.buttonTitle,t[65]=Fe,t[66]=Ie,t[67]=Le,t[68]=ze,t[69]=Be):Be=t[69];let Ve;t[70]===Y?Ve=t[71]:(Ve=e=>e?x(!0):Y(),t[70]=Y,t[71]=Ve);let He;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(He=(0,Q.jsx)(L,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim`}),t[72]=He):He=t[72];let Ue;t[73]===K.title?Ue=t[74]:(Ue=(0,Q.jsx)(m,{className:`text-base font-semibold text-fg`,children:K.title}),t[73]=K.title,t[74]=Ue);let We;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,Q.jsx)(te,{className:`size-5`,strokeWidth:1.75}),t[75]=We):We=t[75];let Ge;t[76]===K.close?Ge=t[77]:(Ge=(0,Q.jsx)(ce,{asChild:!0,children:(0,Q.jsx)(q,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":K.close,children:We})}),t[76]=K.close,t[77]=Ge);let Ke;t[78]!==Ue||t[79]!==Ge?(Ke=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[Ue,Ge]}),t[78]=Ue,t[79]=Ge,t[80]=Ke):Ke=t[80];let qe;t[81]===K.current?qe=t[82]:(qe=(0,Q.jsx)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:K.current}),t[81]=K.current,t[82]=qe);let Je=w===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,Ye;t[83]===Je?Ye=t[84]:(Ye=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,Je),t[83]=Je,t[84]=Ye);let Xe,Ze;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=()=>T(`edit`),Ze=(0,Q.jsx)(fe,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[85]=Xe,t[86]=Ze):(Xe=t[85],Ze=t[86]);let Qe;t[87]!==K.edit||t[88]!==Ye?(Qe=(0,Q.jsxs)(`button`,{type:`button`,className:Ye,onClick:Xe,children:[Ze,K.edit]}),t[87]=K.edit,t[88]=Ye,t[89]=Qe):Qe=t[89];let $e=w===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,et;t[90]===$e?et=t[91]:(et=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,$e),t[90]=$e,t[91]=et);let tt,nt;t[92]===Symbol.for(`react.memo_cache_sentinel`)?(tt=()=>T(`preview`),nt=(0,Q.jsx)(j,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[92]=tt,t[93]=nt):(tt=t[92],nt=t[93]);let rt;t[94]!==K.preview||t[95]!==et?(rt=(0,Q.jsxs)(`button`,{type:`button`,className:et,onClick:tt,children:[nt,K.preview]}),t[94]=K.preview,t[95]=et,t[96]=rt):rt=t[96];let it;t[97]!==Qe||t[98]!==rt?(it=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[Qe,rt]}),t[97]=Qe,t[98]=rt,t[99]=it):it=t[99];let at;t[100]!==qe||t[101]!==it?(at=(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[qe,it]}),t[100]=qe,t[101]=it,t[102]=at):at=t[102];let ot;t[103]!==S||t[104]!==w||t[105]!==_||t[106]!==K.current||t[107]!==K.empty?(ot=w===`preview`?(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:_===`markdown`?(0,Q.jsx)(be,{content:S||K.empty,compact:!0,className:`text-sm`}):(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:S||K.empty})}):(0,Q.jsx)(`textarea`,{className:`min-h-0 flex-1 resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25`,value:S,onChange:e=>C(e.currentTarget.value),placeholder:K.empty,"aria-label":K.current}),t[103]=S,t[104]=w,t[105]=_,t[106]=K.current,t[107]=K.empty,t[108]=ot):ot=t[108];let st;t[109]!==at||t[110]!==ot?(st=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[at,ot]}),t[109]=at,t[110]=ot,t[111]=st):st=t[111];let ct;t[112]===K.editedSuggestion?ct=t[113]:(ct=(0,Q.jsx)(`span`,{children:K.editedSuggestion}),t[112]=K.editedSuggestion,t[113]=ct);let lt;t[114]!==K.loading||t[115]!==V?(lt=V?(0,Q.jsx)(`span`,{className:`ml-2 font-normal`,children:K.loading}):null,t[114]=K.loading,t[115]=V,t[116]=lt):lt=t[116];let ut;t[117]!==ct||t[118]!==lt?(ut=(0,Q.jsxs)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:[ct,lt]}),t[117]=ct,t[118]=lt,t[119]=ut):ut=t[119];let dt=k===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,ft;t[120]===dt?ft=t[121]:(ft=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,dt),t[120]=dt,t[121]=ft);let pt,mt;t[122]===Symbol.for(`react.memo_cache_sentinel`)?(pt=()=>A(`edit`),mt=(0,Q.jsx)(fe,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[122]=pt,t[123]=mt):(pt=t[122],mt=t[123]);let ht;t[124]!==K.edit||t[125]!==ft?(ht=(0,Q.jsxs)(`button`,{type:`button`,className:ft,onClick:pt,children:[mt,K.edit]}),t[124]=K.edit,t[125]=ft,t[126]=ht):ht=t[126];let gt=k===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,_t;t[127]===gt?_t=t[128]:(_t=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,gt),t[127]=gt,t[128]=_t);let vt,yt;t[129]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>A(`preview`),yt=(0,Q.jsx)(j,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[129]=vt,t[130]=yt):(vt=t[129],yt=t[130]);let bt;t[131]!==K.preview||t[132]!==_t?(bt=(0,Q.jsxs)(`button`,{type:`button`,className:_t,onClick:vt,children:[yt,K.preview]}),t[131]=K.preview,t[132]=_t,t[133]=bt):bt=t[133];let xt;t[134]!==ht||t[135]!==bt?(xt=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[ht,bt]}),t[134]=ht,t[135]=bt,t[136]=xt):xt=t[136];let St;t[137]!==ut||t[138]!==xt?(St=(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[ut,xt]}),t[137]=ut,t[138]=xt,t[139]=St):St=t[139];let Ct=re?`opacity-100`:`pointer-events-none opacity-0`,wt;t[140]===Ct?wt=t[141]:(wt=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Ct),t[140]=Ct,t[141]=wt);let Tt=!re,Et;t[142]===Symbol.for(`react.memo_cache_sentinel`)?(Et=()=>P(Kt),t[142]=Et):Et=t[142];let Dt;t[143]!==K.thinkingLoading||t[144]!==V?(Dt=V?(0,Q.jsxs)(`span`,{className:`ml-1 font-normal`,children:[`· `,K.thinkingLoading]}):null,t[143]=K.thinkingLoading,t[144]=V,t[145]=Dt):Dt=t[145];let Ot;t[146]!==K.thinking||t[147]!==Dt?(Ot=(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[K.thinking,Dt]}),t[146]=K.thinking,t[147]=Dt,t[148]=Ot):Ot=t[148];let kt=N&&`rotate-180`,At;t[149]===kt?At=t[150]:(At=i(`size-3.5 shrink-0 transition-transform`,kt),t[149]=kt,t[150]=At);let jt;t[151]===At?jt=t[152]:(jt=(0,Q.jsx)(de,{className:At,strokeWidth:1.75,"aria-hidden":!0}),t[151]=At,t[152]=jt);let $;t[153]!==Ot||t[154]!==jt?($=(0,Q.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center justify-between gap-2 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:text-fg`,onClick:Et,children:[Ot,jt]}),t[153]=Ot,t[154]=jt,t[155]=$):$=t[155];let Mt;t[156]!==B||t[157]!==N?(Mt=N?(0,Q.jsx)(`pre`,{ref:F,className:`min-h-0 flex-1 overflow-auto border-t border-edge px-2.5 py-2 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,onScroll:ge,children:B}):null,t[156]=B,t[157]=N,t[158]=Mt):Mt=t[158];let Nt;t[159]!==$||t[160]!==Mt?(Nt=(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col rounded-lg border border-edge bg-surface-muted/70`,children:[$,Mt]}),t[159]=$,t[160]=Mt,t[161]=Nt):Nt=t[161];let Pt;t[162]!==wt||t[163]!==Tt||t[164]!==Nt?(Pt=(0,Q.jsx)(`div`,{className:wt,"aria-hidden":Tt,children:Nt}),t[162]=wt,t[163]=Tt,t[164]=Nt,t[165]=Pt):Pt=t[165];let Ft=re?`pointer-events-none opacity-0`:`opacity-100`,It;t[166]===Ft?It=t[167]:(It=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Ft),t[166]=Ft,t[167]=It);let Lt;t[168]!==D||t[169]!==H||t[170]!==_||t[171]!==K.empty||t[172]!==K.loading||t[173]!==K.suggestion||t[174]!==V||t[175]!==k?(Lt=H?(0,Q.jsx)(`pre`,{className:`h-full min-h-0 overflow-auto whitespace-pre-wrap rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg-muted`,children:H}):k===`preview`?(0,Q.jsx)(`div`,{className:`h-full min-h-0 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:V&&!D.trim()?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:K.loading}):_===`markdown`?(0,Q.jsx)(be,{content:D||K.empty,compact:!0,className:`text-sm`}):(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:D||K.empty})}):(0,Q.jsx)(`textarea`,{className:`h-full min-h-0 w-full resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25 disabled:text-fg-muted`,value:D,onChange:e=>O(e.currentTarget.value),disabled:V,placeholder:V?K.loading:K.empty,"aria-label":K.suggestion}),t[168]=D,t[169]=H,t[170]=_,t[171]=K.empty,t[172]=K.loading,t[173]=K.suggestion,t[174]=V,t[175]=k,t[176]=Lt):Lt=t[176];let Rt;t[177]!==It||t[178]!==Lt?(Rt=(0,Q.jsx)(`div`,{className:It,children:Lt}),t[177]=It,t[178]=Lt,t[179]=Rt):Rt=t[179];let zt;t[180]!==Pt||t[181]!==Rt?(zt=(0,Q.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[Pt,Rt]}),t[180]=Pt,t[181]=Rt,t[182]=zt):zt=t[182];let Bt;t[183]!==St||t[184]!==zt?(Bt=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[St,zt]}),t[183]=St,t[184]=zt,t[185]=Bt):Bt=t[185];let Vt;t[186]!==st||t[187]!==Bt?(Vt=(0,Q.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-3 overflow-hidden p-4 md:grid-cols-2`,children:[st,Bt]}),t[186]=st,t[187]=Bt,t[188]=Vt):Vt=t[188];let Gt;t[189]!==Y||t[190]!==K.cancel?(Gt=(0,Q.jsx)(q,{type:`button`,variant:`secondary`,onClick:Y,children:K.cancel}),t[189]=Y,t[190]=K.cancel,t[191]=Gt):Gt=t[191];let Jt=!Ne,Yt;t[192]!==Ee||t[193]!==K.applyCurrent||t[194]!==Jt?(Yt=(0,Q.jsx)(q,{type:`button`,variant:`secondary`,disabled:Jt,onClick:Ee,children:K.applyCurrent}),t[192]=Ee,t[193]=K.applyCurrent,t[194]=Jt,t[195]=Yt):Yt=t[195];let Xt;t[196]===Ce?Xt=t[197]:(Xt=()=>void Ce(),t[196]=Ce,t[197]=Xt);let Zt;t[198]===Symbol.for(`react.memo_cache_sentinel`)?(Zt=(0,Q.jsx)(U,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[198]=Zt):Zt=t[198];let Qt;t[199]!==K.regenerate||t[200]!==V||t[201]!==Xt?(Qt=(0,Q.jsxs)(q,{type:`button`,variant:`secondary`,disabled:V,onClick:Xt,children:[Zt,K.regenerate]}),t[199]=K.regenerate,t[200]=V,t[201]=Xt,t[202]=Qt):Qt=t[202];let $t=!Me,en;t[203]!==Ae||t[204]!==K.append||t[205]!==$t?(en=(0,Q.jsx)(q,{type:`button`,variant:`secondary`,disabled:$t,onClick:Ae,children:K.append}),t[203]=Ae,t[204]=K.append,t[205]=$t,t[206]=en):en=t[206];let tn=!Me,nn;t[207]!==Oe||t[208]!==K.replace||t[209]!==tn?(nn=(0,Q.jsx)(q,{type:`button`,variant:`primary`,disabled:tn,onClick:Oe,children:K.replace}),t[207]=Oe,t[208]=K.replace,t[209]=tn,t[210]=nn):nn=t[210];let rn;t[211]!==Gt||t[212]!==Yt||t[213]!==Qt||t[214]!==en||t[215]!==nn?(rn=(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[Gt,Yt,Qt,en,nn]}),t[211]=Gt,t[212]=Yt,t[213]=Qt,t[214]=en,t[215]=nn,t[216]=rn):rn=t[216];let an;t[217]!==Ke||t[218]!==Vt||t[219]!==rn?(an=(0,Q.jsxs)(z,{children:[He,(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[80] flex items-center justify-center p-4 pointer-events-none`,children:(0,Q.jsxs)(E,{className:`xopc-dialog-content-pane pointer-events-auto flex h-[min(78vh,38rem)] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,onOpenAutoFocus:qt,children:[Ke,Vt,rn]})})]}),t[217]=Ke,t[218]=Vt,t[219]=rn,t[220]=an):an=t[220];let on;t[221]!==b||t[222]!==Ve||t[223]!==an?(on=(0,Q.jsx)(M,{open:b,onOpenChange:Ve,children:an}),t[221]=b,t[222]=Ve,t[223]=an,t[224]=on):on=t[224];let sn;return t[225]!==Be||t[226]!==on?(sn=(0,Q.jsxs)(Q.Fragment,{children:[Be,on]}),t[225]=Be,t[226]=on,t[227]=sn):sn=t[227],sn}function Kt(e){return!e}function qt(e){return e.preventDefault()}function Jt(e){let t=(0,Z.c)(31),{value:n,onChange:r,disabled:i,wd:a,placeholder:o,title:s,maxWidthClass:c,clearLabel:l,onClear:u}=e,d;t[0]!==r||t[1]!==n?(d={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=d):d=t[2];let f=I(d),p;t[3]===n?p=t[4]:(p=n.trim(),t[3]=n,t[4]=p);let m=p,h=s??(m?`${m}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`),g=i||f.picking,_=o??a.notSet,v;t[5]!==c||t[6]!==f.pick||t[7]!==h||t[8]!==g||t[9]!==_||t[10]!==n?(v=(0,Q.jsx)(C,{value:n,onPick:f.pick,disabled:g,placeholder:_,title:h,maxWidthClass:c}),t[5]=c,t[6]=f.pick,t[7]=h,t[8]=g,t[9]=_,t[10]=n,t[11]=v):v=t[11];let y;t[12]!==l||t[13]!==i||t[14]!==u||t[15]!==f.picking||t[16]!==m?(y=l&&m&&u?(0,Q.jsx)(`button`,{type:`button`,disabled:i||f.picking,className:`text-xs font-medium text-accent hover:underline disabled:opacity-50`,onClick:u,children:l}):null,t[12]=l,t[13]=i,t[14]=u,t[15]=f.picking,t[16]=m,t[17]=y):y=t[17];let b;t[18]!==v||t[19]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[18]=v,t[19]=y,t[20]=b):b=t[20];let x;t[21]!==f.confirmPick||t[22]!==f.hasNativePicker||t[23]!==f.modalOpen||t[24]!==f.setModalOpen||t[25]!==m||t[26]!==a?(x=f.hasNativePicker?null:(0,Q.jsx)(O,{open:f.modalOpen,onOpenChange:f.setModalOpen,initialAbsolutePath:m||void 0,onConfirm:f.confirmPick,wd:a}),t[21]=f.confirmPick,t[22]=f.hasNativePicker,t[23]=f.modalOpen,t[24]=f.setModalOpen,t[25]=m,t[26]=a,t[27]=x):x=t[27];let S;return t[28]!==b||t[29]!==x?(S=(0,Q.jsxs)(Q.Fragment,{children:[b,x]}),t[28]=b,t[29]=x,t[30]=S):S=t[30],S}function Yt(e,t){return e[t]??t}function Xt(e,t){let n=ie[e]??[];if(n.length===0)return{};let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{},i={};for(let e of n){let t=r[e.key];t!=null&&(i[e.key]=String(t))}return i}function Zt(e,t){return(ie[e]??[]).every(e=>!e.required||!!t[e.key]?.trim())}function Qt(e){let t=(0,Z.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,Q.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function $t(e){let t=(0,Z.c)(34),{workflowName:n,language:r,argValues:o,onArgValuesChange:s,goal:c,onGoalChange:l,examplePrompts:u,showGoal:d,inputClassName:f,aiAssist:p}=e,m;t[0]===u?m=t[1]:(m=u===void 0?[]:u,t[0]=u,t[1]=m);let h=m,g=d===void 0?!0:d,_,v,y,b,x,S,C;if(t[2]!==p||t[3]!==o||t[4]!==h||t[5]!==c||t[6]!==f||t[7]!==r||t[8]!==s||t[9]!==l||t[10]!==g||t[11]!==n){y=a(r).workflows;let e=ie[n]??[];v=e.length>0;let u=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,f),d;t[19]!==o||t[20]!==s||t[21]!==l?(d=e=>{et(e,l,e=>{s(e(o))})},t[19]=o,t[20]=s,t[21]=l,t[22]=d):d=t[22],_=d,b=`flex flex-col gap-3`,x=e.map(e=>{let t=Yt(y.args,e.labelKey),a=Yt(y.args,e.placeholderKey),c=o[e.key]??``;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[t,e.required?` *`:``]}),e.multiline&&p?(0,Q.jsx)(Gt,{value:c,onApply:t=>s({...o,[e.key]:t}),fieldId:`workflow.arg.${e.key}`,fieldLabel:t,scenario:`workflow.arg`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o,fieldKey:e.key},disabled:p.disabled,showLabel:!1}):null]}),e.multiline?(0,Q.jsx)(`textarea`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:i(u,`min-h-20 resize-y`)}):(0,Q.jsx)(`input`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:u})]},e.key)}),S=v&&h.length>0?(0,Q.jsx)(Qt,{examples:h,labels:y,onSelect:_}):null,C=g?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:y.goalLabel}),p?(0,Q.jsx)(Gt,{value:c,onApply:l,fieldId:`workflow.goal`,fieldLabel:y.goalLabel,scenario:`cron.workflowGoal`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o},disabled:p.disabled,showLabel:!1}):null]}),(0,Q.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:y.goalPlaceholder,className:i(u,`min-h-20 resize-y`)})]}):null,t[2]=p,t[3]=o,t[4]=h,t[5]=c,t[6]=f,t[7]=r,t[8]=s,t[9]=l,t[10]=g,t[11]=n,t[12]=_,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S,t[18]=C}else _=t[12],v=t[13],y=t[14],b=t[15],x=t[16],S=t[17],C=t[18];let w;t[23]!==_||t[24]!==h||t[25]!==v||t[26]!==y?(w=!v&&h.length>0?(0,Q.jsx)(Qt,{examples:h,labels:y,onSelect:_}):null,t[23]=_,t[24]=h,t[25]=v,t[26]=y,t[27]=w):w=t[27];let T;return t[28]!==b||t[29]!==x||t[30]!==S||t[31]!==C||t[32]!==w?(T=(0,Q.jsxs)(`div`,{className:b,children:[x,S,C,w]}),t[28]=b,t[29]=x,t[30]=S,t[31]=C,t[32]=w,t[33]=T):T=t[33],T}var en=42,tn=68,nn=56;function rn(e){return Math.max(en,Math.min(tn,e))}function an(e){let t=(0,Z.c)(10),{title:n,children:r,className:a}=e,o;t[0]===a?o=t[1]:(o=i(`rounded-2xl border border-edge bg-surface-base/35 p-4`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=n?(0,Q.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-fg`,children:n}):null,t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:r}),t[4]=r,t[5]=c);let l;return t[6]!==o||t[7]!==s||t[8]!==c?(l=(0,Q.jsxs)(`section`,{className:o,children:[s,c]}),t[6]=o,t[7]=s,t[8]=c,t[9]=l):l=t[9],l}function on(e){let t=(0,Z.c)(301),{open:n,onRequestClose:r,c:a,chatM:s,agentsMessages:c,isDark:l,channels:u,sessionChatIds:d,cronAgentSelectOptions:f,defaultModelResolver:p,formMode:h,formJobId:g,formName:_,onFormNameChange:v,formSchedule:y,onFormScheduleChange:b,formSubmitting:x,formTaskKind:C,onFormTaskKindChange:w,workflowDefinitions:T,workflowDefinitionsLoading:D,formWorkflowDefinitionId:O,onFormWorkflowDefinitionIdChange:k,formWorkflowGoal:A,onFormWorkflowGoalChange:N,formWorkflowArgValues:P,onFormWorkflowArgValuesChange:I,formSessionTarget:R,onFormSessionTargetChange:B,formAgentLocalOnly:V,onFormAgentLocalOnlyChange:H,formModel:W,onFormModelUserChange:G,formAgentId:ee,onFormAgentIdChange:K,formWorkingDirectory:ne,onFormWorkingDirectoryChange:re,formChannel:ie,onFormChannelChange:ae,formChatId:oe,onFormChatIdChange:se,formMessage:le,onFormMessageChange:ue,formMessageMdMode:de,onSetMessageMdMode:J,messageEditorNonce:pe,needsDeliveryChat:me,showChannelPicker:he,canSubmit:ge,onSubmit:_e,onRefreshRecipients:ve}=e,ye=o(fn),[Se,Ce]=(0,X.useState)(nn),[we,Y]=(0,X.useState)(!1),[Te,Ee]=(0,X.useState)(0),De=(0,X.useRef)(null),Oe,ke;if(t[0]!==O||t[1]!==ye||t[2]!==T){let e;t[5]===O?e=t[6]:(e=e=>e.id===O.trim(),t[5]=O,t[6]=e),Oe=T.find(e),ke=Oe?$e(Oe,ye):null,t[0]=O,t[1]=ye,t[2]=T,t[3]=Oe,t[4]=ke}else Oe=t[3],ke=t[4];let Ae=ke,je;t[7]!==y.everyMs||t[8]!==y.kind?(je=y.kind===`every`?Math.max(1,Math.round(y.everyMs/6e4)):60,t[7]=y.everyMs,t[8]=y.kind,t[9]=je):je=t[9];let Me=je,Ne;t[10]!==y.at||t[11]!==y.kind?(Ne=y.kind===`at`&&y.at?new Date(y.at).toISOString().slice(0,16):``,t[10]=y.at,t[11]=y.kind,t[12]=Ne):Ne=t[12];let Pe=Ne,Fe;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=e=>{e.preventDefault();let t=De.current;if(!t)return;let n=t.getBoundingClientRect(),r=e.currentTarget,i=e.pointerId;r.setPointerCapture(i),Y(!0);let a=e=>{Ce(rn((e-n.left)/n.width*100))};a(e.clientX);let o=e=>{a(e.clientX)},s=()=>{try{r.releasePointerCapture(i)}catch{}Y(!1),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},t[13]=Fe):Fe=t[13];let Ie=Fe,Le;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(Le=e=>{e.key===`ArrowLeft`?(e.preventDefault(),Ce(dn)):e.key===`ArrowRight`?(e.preventDefault(),Ce(un)):e.key===`Home`?(e.preventDefault(),Ce(en)):e.key===`End`&&(e.preventDefault(),Ce(tn))},t[14]=Le):Le=t[14];let Re=Le,ze;t[15]===a.agentProfile?ze=t[16]:(ze=(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),t[15]=a.agentProfile,t[16]=ze);let Be;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(Be=wt(),t[17]=Be):Be=t[17];let Ve;t[18]===K?Ve=t[19]:(Ve=e=>K(e.target.value),t[18]=K,t[19]=Ve);let He;t[20]===a.agentProfileDefault?He=t[21]:(He=(0,Q.jsx)(`option`,{value:``,children:a.agentProfileDefault}),t[20]=a.agentProfileDefault,t[21]=He);let Ue;if(t[22]!==c||t[23]!==f){let e;t[25]===c?e=t[26]:(e=e=>(0,Q.jsx)(`option`,{value:e.id,children:`${e.id} - ${S(e,c)}`},e.id),t[25]=c,t[26]=e),Ue=f.map(e),t[22]=c,t[23]=f,t[24]=Ue}else Ue=t[24];let We;t[27]!==ee||t[28]!==x||t[29]!==Ve||t[30]!==He||t[31]!==Ue?(We=(0,Q.jsxs)(`select`,{className:Be,value:ee,disabled:x,onChange:Ve,children:[He,Ue]}),t[27]=ee,t[28]=x,t[29]=Ve,t[30]=He,t[31]=Ue,t[32]=We):We=t[32];let Ge;t[33]===a.agentProfileHint?Ge=t[34]:(Ge=(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.agentProfileHint}),t[33]=a.agentProfileHint,t[34]=Ge);let Je;t[35]!==We||t[36]!==Ge||t[37]!==ze?(Je=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[ze,We,Ge]}),t[35]=We,t[36]=Ge,t[37]=ze,t[38]=Je):Je=t[38];let Ye=Je,Ze;t[39]!==a.channel||t[40]!==a.channelLocal||t[41]!==a.enterManuallyOrSelect||t[42]!==a.lastActiveLabels||t[43]!==a.noRecentChats||t[44]!==a.noRecentChatsOption||t[45]!==a.recipient||t[46]!==a.recipientPlaceholder||t[47]!==a.refreshList||t[48]!==a.refreshRecipientHint||t[49]!==a.selectRecipient||t[50]!==a.workflowDeliveryHint||t[51]!==u||t[52]!==ie||t[53]!==oe||t[54]!==C||t[55]!==me||t[56]!==ae||t[57]!==se||t[58]!==ve||t[59]!==d||t[60]!==he?(Ze=he?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.channel}),(0,Q.jsxs)(`select`,{className:wt(),value:ie,onChange:e=>ae(e.target.value),children:[(0,Q.jsx)(`option`,{value:`local`,children:a.channelLocal}),u.map(ln)]})]}),me?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.recipient}),(0,Q.jsxs)(q,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:a.refreshRecipientHint,onClick:()=>void ve(),children:[(0,Q.jsx)(U,{className:`size-3.5`,strokeWidth:1.75}),a.refreshList]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,className:i(Ct(),`min-w-0 w-full sm:flex-1`),value:oe,onChange:e=>se(e.target.value),placeholder:a.recipientPlaceholder}),(0,Q.jsxs)(`select`,{className:Tt,value:oe,onChange:e=>{let t=e.target.value;t&&se(t)},children:[(0,Q.jsx)(`option`,{value:``,children:a.selectRecipient}),d.length>0?d.map(e=>(0,Q.jsx)(`option`,{value:e.chatId,children:qe(e,a.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,Q.jsx)(`option`,{value:``,disabled:!0,children:a.noRecentChatsOption})]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:C===`workflowRun`?a.workflowDeliveryHint:d.length>0?a.enterManuallyOrSelect:a.noRecentChats})]}):null]}):null,t[39]=a.channel,t[40]=a.channelLocal,t[41]=a.enterManuallyOrSelect,t[42]=a.lastActiveLabels,t[43]=a.noRecentChats,t[44]=a.noRecentChatsOption,t[45]=a.recipient,t[46]=a.recipientPlaceholder,t[47]=a.refreshList,t[48]=a.refreshRecipientHint,t[49]=a.selectRecipient,t[50]=a.workflowDeliveryHint,t[51]=u,t[52]=ie,t[53]=oe,t[54]=C,t[55]=me,t[56]=ae,t[57]=se,t[58]=ve,t[59]=d,t[60]=he,t[61]=Ze):Ze=t[61];let Qe=Ze,et;t[62]===a.schedule?et=t[63]:(et=(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.schedule}),t[62]=a.schedule,t[63]=et);let tt;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(tt=wt(),t[64]=tt):tt=t[64];let nt;t[65]===b?nt=t[66]:(nt=e=>{let t=e.target.value;b(t===`cron`?{kind:`cron`,expr:`*/5 * * * *`}:t===`at`?{kind:`at`,at:new Date(Date.now()+36e5).toISOString()}:{kind:`every`,everyMs:36e5})},t[65]=b,t[66]=nt);let rt,it,at;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(rt=(0,Q.jsx)(`option`,{value:`cron`,children:`Cron`}),it=(0,Q.jsx)(`option`,{value:`at`,children:`One-time`}),at=(0,Q.jsx)(`option`,{value:`every`,children:`Interval`}),t[67]=rt,t[68]=it,t[69]=at):(rt=t[67],it=t[68],at=t[69]);let ot;t[70]!==y.kind||t[71]!==x||t[72]!==nt?(ot=(0,Q.jsxs)(`select`,{className:tt,value:y.kind,disabled:x,onChange:nt,children:[rt,it,at]}),t[70]=y.kind,t[71]=x,t[72]=nt,t[73]=ot):ot=t[73];let st;t[74]!==et||t[75]!==ot?(st=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[et,ot]}),t[74]=et,t[75]=ot,t[76]=st):st=t[76];let ct;t[77]!==Pe||t[78]!==a.nextRun||t[79]!==a.scheduleBadge||t[80]!==a.schedulePicker||t[81]!==y||t[82]!==x||t[83]!==Me||t[84]!==b?(ct=y.kind===`cron`?(0,Q.jsx)(Xe,{value:y.expr,onChange:e=>b({...y,expr:e}),disabled:x,labels:a.schedulePicker}):y.kind===`at`?(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.nextRun}),(0,Q.jsx)(`input`,{type:`datetime-local`,className:Ct(x),value:Pe,disabled:x,onChange:e=>{let t=new Date(e.target.value).getTime();b({kind:`at`,at:Number.isFinite(t)?new Date(t).toISOString():``})}})]}):(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.scheduleBadge.everyNMinutes.replace(`{{n}}`,``)}),(0,Q.jsx)(`input`,{type:`number`,min:1,step:1,className:Ct(x),value:Me,disabled:x,onChange:e=>{let t=Number.parseInt(e.target.value,10);b({kind:`every`,everyMs:Math.max(1,Number.isFinite(t)?t:1)*6e4})}})]}),t[77]=Pe,t[78]=a.nextRun,t[79]=a.scheduleBadge,t[80]=a.schedulePicker,t[81]=y,t[82]=x,t[83]=Me,t[84]=b,t[85]=ct):ct=t[85];let lt;t[86]!==st||t[87]!==ct?(lt=(0,Q.jsxs)(Q.Fragment,{children:[st,ct]}),t[86]=st,t[87]=ct,t[88]=lt):lt=t[88];let ut=lt,dt;t[89]===a.message?dt=t[90]:(dt=(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.message}),t[89]=a.message,t[90]=dt);let ft;t[91]!==ue||t[92]!==J?(ft=e=>{ue(e),Ee(cn),J(`edit`)},t[91]=ue,t[92]=J,t[93]=ft):ft=t[93];let pt=a.message,mt;t[94]===y?mt=t[95]:(mt=Ke(y),t[94]=y,t[95]=mt);let ht;t[96]!==ie||t[97]!==_||t[98]!==R||t[99]!==C||t[100]!==mt?(ht={page:`cron`,taskKind:C,cronName:_,scheduleSummary:mt,sessionTarget:R,deliveryChannel:ie},t[96]=ie,t[97]=_,t[98]=R,t[99]=C,t[100]=mt,t[101]=ht):ht=t[101];let gt;t[102]!==a.message||t[103]!==le||t[104]!==x||t[105]!==ye||t[106]!==ft||t[107]!==ht?(gt=(0,Q.jsx)(Gt,{value:le,onApply:ft,fieldId:`cron.message`,fieldLabel:pt,scenario:`cron.message`,format:`markdown`,locale:ye,context:ht,disabled:x}),t[102]=a.message,t[103]=le,t[104]=x,t[105]=ye,t[106]=ft,t[107]=ht,t[108]=gt):gt=t[108];let _t=de===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`,vt;t[109]===_t?vt=t[110]:(vt=i(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,_t),t[109]=_t,t[110]=vt);let yt;t[111]===J?yt=t[112]:(yt=()=>J(`edit`),t[111]=J,t[112]=yt);let bt;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(bt=(0,Q.jsx)(fe,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[113]=bt):bt=t[113];let xt;t[114]!==a.messageEdit||t[115]!==vt||t[116]!==yt?(xt=(0,Q.jsxs)(`button`,{type:`button`,className:vt,onClick:yt,children:[bt,a.messageEdit]}),t[114]=a.messageEdit,t[115]=vt,t[116]=yt,t[117]=xt):xt=t[117];let St=de===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`,Et;t[118]===St?Et=t[119]:(Et=i(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,St),t[118]=St,t[119]=Et);let Dt;t[120]===J?Dt=t[121]:(Dt=()=>J(`preview`),t[120]=J,t[121]=Dt);let Ot;t[122]===Symbol.for(`react.memo_cache_sentinel`)?(Ot=(0,Q.jsx)(j,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[122]=Ot):Ot=t[122];let kt;t[123]!==a.messagePreview||t[124]!==Et||t[125]!==Dt?(kt=(0,Q.jsxs)(`button`,{type:`button`,className:Et,onClick:Dt,children:[Ot,a.messagePreview]}),t[123]=a.messagePreview,t[124]=Et,t[125]=Dt,t[126]=kt):kt=t[126];let At;t[127]!==xt||t[128]!==kt?(At=(0,Q.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-base p-0.5 dark:border-edge`,children:[xt,kt]}),t[127]=xt,t[128]=kt,t[129]=At):At=t[129];let jt;t[130]!==gt||t[131]!==At?(jt=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[gt,At]}),t[130]=gt,t[131]=At,t[132]=jt):jt=t[132];let $;t[133]!==dt||t[134]!==jt?($=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[dt,jt]}),t[133]=dt,t[134]=jt,t[135]=$):$=t[135];let Mt=x&&`pointer-events-none opacity-60`,Nt;t[136]===Mt?Nt=t[137]:(Nt=i(`overflow-hidden rounded-md border border-edge bg-surface-base dark:border-edge`,Mt),t[136]=Mt,t[137]=Nt);let Pt;t[138]!==Te||t[139]!==a.messagePlaceholder||t[140]!==g||t[141]!==le||t[142]!==de||t[143]!==l||t[144]!==pe||t[145]!==ue?(Pt=de===`edit`?(0,Q.jsx)(xe,{initialContent:le,onChange:ue,isDark:l,className:`h-[min(22rem,44vh)] min-h-[16rem]`},`cron-msg-${g??`new`}-${pe}-${Te}`):(0,Q.jsx)(`div`,{className:`h-[min(22rem,44vh)] min-h-[16rem] max-h-[min(26rem,52vh)] overflow-y-auto px-3 py-2`,children:le.trim()?(0,Q.jsx)(be,{content:le,compact:!0,className:`text-sm`}):(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.messagePlaceholder})}),t[138]=Te,t[139]=a.messagePlaceholder,t[140]=g,t[141]=le,t[142]=de,t[143]=l,t[144]=pe,t[145]=ue,t[146]=Pt):Pt=t[146];let Ft;t[147]!==Nt||t[148]!==Pt?(Ft=(0,Q.jsx)(`div`,{className:Nt,children:Pt}),t[147]=Nt,t[148]=Pt,t[149]=Ft):Ft=t[149];let It;t[150]===a.messageMarkdownHint?It=t[151]:(It=(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.messageMarkdownHint}),t[150]=a.messageMarkdownHint,t[151]=It);let Lt;t[152]!==$||t[153]!==Ft||t[154]!==It?(Lt=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[$,Ft,It]}),t[152]=$,t[153]=Ft,t[154]=It,t[155]=Lt):Lt=t[155];let Rt=Lt,zt;t[156]===r?zt=t[157]:(zt=e=>!e&&r(),t[156]=r,t[157]=zt);let Bt;t[158]===Symbol.for(`react.memo_cache_sentinel`)?(Bt=(0,Q.jsx)(L,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[158]=Bt):Bt=t[158];let Vt=h===`edit`?a.editJob:a.addJob,Ht;t[159]===Vt?Ht=t[160]:(Ht=(0,Q.jsx)(m,{className:`text-base font-semibold text-fg`,children:Vt}),t[159]=Vt,t[160]=Ht);let Ut;t[161]===Symbol.for(`react.memo_cache_sentinel`)?(Ut=(0,Q.jsx)(te,{className:`size-5`,strokeWidth:1.75}),t[161]=Ut):Ut=t[161];let Wt;t[162]===a.close?Wt=t[163]:(Wt=(0,Q.jsx)(ce,{asChild:!0,children:(0,Q.jsx)(q,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":a.close,children:Ut})}),t[162]=a.close,t[163]=Wt);let Kt;t[164]!==Ht||t[165]!==Wt?(Kt=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[Ht,Wt]}),t[164]=Ht,t[165]=Wt,t[166]=Kt):Kt=t[166];let qt=!we&&`lg:transition-[grid-template-columns] lg:duration-200 lg:ease-out`,Yt;t[167]===qt?Yt=t[168]:(Yt=i(`grid min-h-full grid-cols-1 gap-4 lg:h-full lg:min-h-0 lg:[grid-template-columns:minmax(0,var(--cron-form-primary-pane))_0.75rem_minmax(22rem,1fr)] lg:gap-0`,qt),t[167]=qt,t[168]=Yt);let Xt=`${Se}%`,Zt;t[169]===Xt?Zt=t[170]:(Zt={"--cron-form-primary-pane":Xt},t[169]=Xt,t[170]=Zt);let Qt=Zt,on;t[171]===a.name?on=t[172]:(on=(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.name}),t[171]=a.name,t[172]=on);let pn;t[173]===Symbol.for(`react.memo_cache_sentinel`)?(pn=Ct(),t[173]=pn):pn=t[173];let mn;t[174]===v?mn=t[175]:(mn=e=>v(e.target.value),t[174]=v,t[175]=mn);let hn;t[176]!==a.namePlaceholder||t[177]!==_||t[178]!==mn?(hn=(0,Q.jsx)(`input`,{type:`text`,className:pn,value:_,onChange:mn,placeholder:a.namePlaceholder}),t[176]=a.namePlaceholder,t[177]=_,t[178]=mn,t[179]=hn):hn=t[179];let gn;t[180]!==on||t[181]!==hn?(gn=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[on,hn]}),t[180]=on,t[181]=hn,t[182]=gn):gn=t[182];let _n;t[183]===a.taskKind?_n=t[184]:(_n=(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.taskKind}),t[183]=a.taskKind,t[184]=_n);let vn;t[185]===Symbol.for(`react.memo_cache_sentinel`)?(vn=wt(),t[185]=vn):vn=t[185];let yn;t[186]===w?yn=t[187]:(yn=e=>w(e.target.value),t[186]=w,t[187]=yn);let bn;t[188]===a.taskKindMessage?bn=t[189]:(bn=(0,Q.jsx)(`option`,{value:`message`,children:a.taskKindMessage}),t[188]=a.taskKindMessage,t[189]=bn);let xn;t[190]===a.taskKindWorkflowRun?xn=t[191]:(xn=(0,Q.jsx)(`option`,{value:`workflowRun`,children:a.taskKindWorkflowRun}),t[190]=a.taskKindWorkflowRun,t[191]=xn);let Sn;t[192]!==x||t[193]!==C||t[194]!==yn||t[195]!==bn||t[196]!==xn?(Sn=(0,Q.jsxs)(`select`,{className:vn,value:C,disabled:x,onChange:yn,children:[bn,xn]}),t[192]=x,t[193]=C,t[194]=yn,t[195]=bn,t[196]=xn,t[197]=Sn):Sn=t[197];let Cn;t[198]!==_n||t[199]!==Sn?(Cn=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[_n,Sn]}),t[198]=_n,t[199]=Sn,t[200]=Cn):Cn=t[200];let wn;t[201]!==ut||t[202]!==gn||t[203]!==Cn?(wn=(0,Q.jsxs)(an,{children:[gn,ut,Cn]}),t[201]=ut,t[202]=gn,t[203]=Cn,t[204]=wn):wn=t[204];let Tn;t[205]!==a.message||t[206]!==a.workflowDefinition||t[207]!==a.workflowDefinitionCustom||t[208]!==a.workflowDefinitionMissing||t[209]!==a.workflowDefinitionPlaceholder||t[210]!==a.workflowDefinitionsEmpty||t[211]!==a.workflowDefinitionsLoading||t[212]!==_||t[213]!==y||t[214]!==x||t[215]!==C||t[216]!==P||t[217]!==O||t[218]!==A||t[219]!==ye||t[220]!==Rt||t[221]!==I||t[222]!==k||t[223]!==N||t[224]!==Oe||t[225]!==Ae||t[226]!==T||t[227]!==D?(Tn=C===`workflowRun`?(0,Q.jsxs)(an,{title:a.workflowDefinition,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.workflowDefinition}),(0,Q.jsxs)(`select`,{className:wt(),value:O,disabled:x||D,onChange:e=>k(e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:D?a.workflowDefinitionsLoading:a.workflowDefinitionPlaceholder}),O.trim()&&!T.some(e=>e.id===O.trim())?(0,Q.jsx)(`option`,{value:O,children:O}):null,T.map(e=>(0,Q.jsxs)(`option`,{value:e.id,children:[e.title,e.metadata.source===`user`?` (${a.workflowDefinitionCustom})`:``]},e.id))]}),!D&&T.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workflowDefinitionsEmpty}):null,Ae?(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:Ae.description}):O.trim()&&!Oe?(0,Q.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:a.workflowDefinitionMissing}):null]}),O.trim()?(0,Q.jsx)($t,{workflowName:O.trim(),language:ye,argValues:P,onArgValuesChange:I,goal:A,onGoalChange:N,examplePrompts:Ae?.examplePrompts??[],inputClassName:Ct(),aiAssist:{disabled:x,context:{page:`cron`,taskKind:C,cronName:_,scheduleSummary:Ke(y),workflowDefinitionId:O.trim(),workflowDescription:Ae?.description??``}}}):null]}):(0,Q.jsx)(an,{title:a.message,children:Rt}),t[205]=a.message,t[206]=a.workflowDefinition,t[207]=a.workflowDefinitionCustom,t[208]=a.workflowDefinitionMissing,t[209]=a.workflowDefinitionPlaceholder,t[210]=a.workflowDefinitionsEmpty,t[211]=a.workflowDefinitionsLoading,t[212]=_,t[213]=y,t[214]=x,t[215]=C,t[216]=P,t[217]=O,t[218]=A,t[219]=ye,t[220]=Rt,t[221]=I,t[222]=k,t[223]=N,t[224]=Oe,t[225]=Ae,t[226]=T,t[227]=D,t[228]=Tn):Tn=t[228];let En;t[229]!==wn||t[230]!==Tn?(En=(0,Q.jsx)(`div`,{className:`lg:min-h-0 lg:overflow-y-auto`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[wn,Tn]})}),t[229]=wn,t[230]=Tn,t[231]=En):En=t[231];let Dn=a.detailResizeColumns,On;t[232]===Se?On=t[233]:(On=Math.round(Se),t[232]=Se,t[233]=On);let kn;t[234]===Symbol.for(`react.memo_cache_sentinel`)?(kn=i(`group hidden h-full cursor-col-resize touch-none select-none items-stretch justify-center rounded-lg outline-none lg:flex`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[234]=kn):kn=t[234];let An=we&&`bg-edge`,jn;t[235]===An?jn=t[236]:(jn=i(`h-full w-px bg-edge-subtle transition-colors duration-150`,`group-hover:bg-edge`,An),t[235]=An,t[236]=jn);let Mn;t[237]===jn?Mn=t[238]:(Mn=(0,Q.jsx)(`span`,{className:jn}),t[237]=jn,t[238]=Mn);let Nn;t[239]!==a.detailResizeColumns||t[240]!==On||t[241]!==Mn?(Nn=(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":Dn,"aria-valuemin":en,"aria-valuemax":tn,"aria-valuenow":On,tabIndex:0,onPointerDown:Ie,onKeyDown:Re,className:kn,children:Mn}),t[239]=a.detailResizeColumns,t[240]=On,t[241]=Mn,t[242]=Nn):Nn=t[242];let Pn;t[243]!==Ye||t[244]!==a.agentLocalOnly||t[245]!==a.agentLocalOnlyHint||t[246]!==a.detailRunSettings||t[247]!==a.mode||t[248]!==a.modeAgent||t[249]!==a.modeAgentOption||t[250]!==a.modeDirect||t[251]!==a.modeDirectOption||t[252]!==a.model||t[253]!==a.workflowLocalOnly||t[254]!==a.workflowLocalOnlyHint||t[255]!==a.workingDirectoryHint||t[256]!==a.workingDirectoryLabel||t[257]!==a.workingDirectoryReset||t[258]!==s||t[259]!==p||t[260]!==V||t[261]!==W||t[262]!==R||t[263]!==x||t[264]!==C||t[265]!==ne||t[266]!==H||t[267]!==G||t[268]!==B||t[269]!==re?(Pn=C===`message`?(0,Q.jsxs)(an,{title:a.detailRunSettings,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.mode}),(0,Q.jsxs)(`select`,{className:wt(),value:R,onChange:e=>{let t=e.target.value;B(t,p,W.trim())},children:[(0,Q.jsx)(`option`,{value:`main`,children:a.modeDirectOption}),(0,Q.jsx)(`option`,{value:`isolated`,children:a.modeAgentOption})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:R===`main`?a.modeDirect:a.modeAgent})]}),R===`isolated`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.model}),(0,Q.jsx)(F,{value:W,placeholder:s.modelPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:s.modelNoMatches,className:`w-full max-w-none min-w-0`,popoverContentClassName:`z-[70]`,onChange:G})]}),Ye,(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.workingDirectoryLabel}),(0,Q.jsx)(Jt,{value:ne,onChange:re,disabled:x,wd:s.workingDirectory,placeholder:s.workingDirectory.notSet,maxWidthClass:`max-w-[min(18rem,52vw)]`,clearLabel:a.workingDirectoryReset,onClear:()=>re(``)}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workingDirectoryHint})]}),(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md bg-surface-hover/45 px-3 py-2 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:i(`ui-checkbox`,`mt-0.5`),checked:V,onChange:e=>H(e.target.checked),"aria-label":a.agentLocalOnly}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.agentLocalOnly}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.agentLocalOnlyHint})]})]})]}):null]}):(0,Q.jsxs)(an,{title:a.detailRunSettings,children:[Ye,(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md bg-surface-hover/45 px-3 py-2 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:i(`ui-checkbox`,`mt-0.5`),checked:V,onChange:e=>H(e.target.checked),"aria-label":a.workflowLocalOnly}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.workflowLocalOnly}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.workflowLocalOnlyHint})]})]})]}),t[243]=Ye,t[244]=a.agentLocalOnly,t[245]=a.agentLocalOnlyHint,t[246]=a.detailRunSettings,t[247]=a.mode,t[248]=a.modeAgent,t[249]=a.modeAgentOption,t[250]=a.modeDirect,t[251]=a.modeDirectOption,t[252]=a.model,t[253]=a.workflowLocalOnly,t[254]=a.workflowLocalOnlyHint,t[255]=a.workingDirectoryHint,t[256]=a.workingDirectoryLabel,t[257]=a.workingDirectoryReset,t[258]=s,t[259]=p,t[260]=V,t[261]=W,t[262]=R,t[263]=x,t[264]=C,t[265]=ne,t[266]=H,t[267]=G,t[268]=B,t[269]=re,t[270]=Pn):Pn=t[270];let Fn;t[271]!==a.deliveryTarget||t[272]!==Qe?(Fn=Qe?(0,Q.jsx)(an,{title:a.deliveryTarget,children:Qe}):null,t[271]=a.deliveryTarget,t[272]=Qe,t[273]=Fn):Fn=t[273];let In;t[274]!==Pn||t[275]!==Fn?(In=(0,Q.jsx)(`aside`,{className:`lg:min-h-0 lg:overflow-y-auto`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[Pn,Fn]})}),t[274]=Pn,t[275]=Fn,t[276]=In):In=t[276];let Ln;t[277]!==Yt||t[278]!==Qt||t[279]!==En||t[280]!==Nn||t[281]!==In?(Ln=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4 lg:overflow-hidden`,children:(0,Q.jsxs)(`div`,{ref:De,className:Yt,style:Qt,children:[En,Nn,In]})}),t[277]=Yt,t[278]=Qt,t[279]=En,t[280]=Nn,t[281]=In,t[282]=Ln):Ln=t[282];let Rn;t[283]!==a.cancel||t[284]!==r?(Rn=(0,Q.jsx)(q,{type:`button`,variant:`secondary`,onClick:r,children:a.cancel}),t[283]=a.cancel,t[284]=r,t[285]=Rn):Rn=t[285];let zn=x||!ge,Bn=x?a.loading:h===`edit`?a.save:a.create,Vn;t[286]!==_e||t[287]!==zn||t[288]!==Bn?(Vn=(0,Q.jsx)(q,{type:`button`,variant:`primary`,disabled:zn,onClick:_e,children:Bn}),t[286]=_e,t[287]=zn,t[288]=Bn,t[289]=Vn):Vn=t[289];let Hn;t[290]!==Rn||t[291]!==Vn?(Hn=(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[Rn,Vn]}),t[290]=Rn,t[291]=Vn,t[292]=Hn):Hn=t[292];let Un;t[293]!==Kt||t[294]!==Ln||t[295]!==Hn?(Un=(0,Q.jsxs)(z,{children:[Bt,(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,Q.jsxs)(E,{className:`xopc-dialog-content-pane pointer-events-auto relative flex h-[min(86vh,46rem)] w-full max-w-6xl flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,onOpenAutoFocus:sn,children:[Kt,Ln,Hn]})})]}),t[293]=Kt,t[294]=Ln,t[295]=Hn,t[296]=Un):Un=t[296];let Wn;return t[297]!==n||t[298]!==zt||t[299]!==Un?(Wn=(0,Q.jsx)(M,{open:n,onOpenChange:zt,children:Un}),t[297]=n,t[298]=zt,t[299]=Un,t[300]=Wn):Wn=t[300],Wn}function sn(e){return e.preventDefault()}function cn(e){return e+1}function ln(e){return(0,Q.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function un(e){return rn(e+4)}function dn(e){return rn(e-4)}function fn(e){return e.language}function pn(e){let t=(0,Z.c)(76),{c:n,mainTab:r,onMainTabChange:a,jobSort:o,onJobSortChange:s,historyRange:c,onHistoryRangeChange:l,historyJobFilter:u,onHistoryJobFilterChange:d,historyStatusFilter:f,onHistoryStatusFilterChange:p,jobs:m}=e,h=n.title,g=r===`myTasks`,v=r===`myTasks`?`text-fg`:`text-fg-muted hover:text-fg`,y;t[0]===v?y=t[1]:(y=i(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,v),t[0]=v,t[1]=y);let b;t[2]===a?b=t[3]:(b=()=>a(`myTasks`),t[2]=a,t[3]=b);let x;t[4]!==n.tabMyTasks||t[5]!==g||t[6]!==y||t[7]!==b?(x=(0,Q.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":g,className:y,onClick:b,children:n.tabMyTasks}),t[4]=n.tabMyTasks,t[5]=g,t[6]=y,t[7]=b,t[8]=x):x=t[8];let S=r===`systemTasks`,C=r===`systemTasks`?`text-fg`:`text-fg-muted hover:text-fg`,w;t[9]===C?w=t[10]:(w=i(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,C),t[9]=C,t[10]=w);let T;t[11]===a?T=t[12]:(T=()=>a(`systemTasks`),t[11]=a,t[12]=T);let E;t[13]!==n.tabSystemTasks||t[14]!==T||t[15]!==S||t[16]!==w?(E=(0,Q.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":S,className:w,onClick:T,children:n.tabSystemTasks}),t[13]=n.tabSystemTasks,t[14]=T,t[15]=S,t[16]=w,t[17]=E):E=t[17];let D=r===`history`,O=r===`history`?`text-fg`:`text-fg-muted hover:text-fg`,k;t[18]===O?k=t[19]:(k=i(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,O),t[18]=O,t[19]=k);let A;t[20]===a?A=t[21]:(A=()=>a(`history`),t[20]=a,t[21]=A);let j;t[22]!==n.tabRunHistory||t[23]!==D||t[24]!==k||t[25]!==A?(j=(0,Q.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":D,className:k,onClick:A,children:n.tabRunHistory}),t[22]=n.tabRunHistory,t[23]=D,t[24]=k,t[25]=A,t[26]=j):j=t[26];let M=r===`settings`,N=r===`settings`?`text-fg`:`text-fg-muted hover:text-fg`,P;t[27]===N?P=t[28]:(P=i(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,N),t[27]=N,t[28]=P);let F;t[29]===a?F=t[30]:(F=()=>a(`settings`),t[29]=a,t[30]=F);let I;t[31]!==n.globals.title||t[32]!==M||t[33]!==P||t[34]!==F?(I=(0,Q.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":M,className:P,onClick:F,children:n.globals.title}),t[31]=n.globals.title,t[32]=M,t[33]=P,t[34]=F,t[35]=I):I=t[35];let L;t[36]!==n.title||t[37]!==E||t[38]!==j||t[39]!==I||t[40]!==x?(L=(0,Q.jsxs)(`div`,{className:`flex gap-1`,role:`tablist`,"aria-label":h,children:[x,E,j,I]}),t[36]=n.title,t[37]=E,t[38]=j,t[39]=I,t[40]=x,t[41]=L):L=t[41];let R=r===`history`?`flex-nowrap overflow-x-auto pb-0.5 sm:justify-end`:`flex-wrap sm:justify-end`,z;t[42]===R?z=t[43]:(z=i(`flex min-w-0 items-center gap-2`,R),t[42]=R,t[43]=z);let B;t[44]!==n.sortCreatedAsc||t[45]!==n.sortCreatedDesc||t[46]!==o||t[47]!==r||t[48]!==s?(B=r===`myTasks`||r===`systemTasks`?(0,Q.jsxs)(`select`,{className:Et,value:o,onChange:e=>s(e.target.value),"aria-label":n.sortCreatedDesc,children:[(0,Q.jsx)(`option`,{value:`created_desc`,children:n.sortCreatedDesc}),(0,Q.jsx)(`option`,{value:`created_asc`,children:n.sortCreatedAsc})]}):null,t[44]=n.sortCreatedAsc,t[45]=n.sortCreatedDesc,t[46]=o,t[47]=r,t[48]=s,t[49]=B):B=t[49];let V;t[50]!==n.execStatusCancelled||t[51]!==n.execStatusFailed||t[52]!==n.execStatusRunning||t[53]!==n.execStatusSuccess||t[54]!==n.filterAllStatuses||t[55]!==n.filterAllTasks||t[56]!==n.historyRangeDay||t[57]!==n.historyRangeMonth||t[58]!==n.historyRangeWeek||t[59]!==n.runHistoryTitle||t[60]!==u||t[61]!==c||t[62]!==f||t[63]!==m||t[64]!==r||t[65]!==d||t[66]!==l||t[67]!==p?(V=r===`history`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:i(_e,`shrink-0`),role:`group`,"aria-label":n.runHistoryTitle,children:[`day`,`week`,`month`].map(e=>(0,Q.jsx)(`button`,{type:`button`,className:i(_,`px-2.5 py-1`,c===e&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,c===e&&`text-fg`),onClick:()=>l(e),children:e===`day`?n.historyRangeDay:e===`week`?n.historyRangeWeek:n.historyRangeMonth},e))}),(0,Q.jsxs)(`select`,{className:Et,value:u,onChange:e=>d(e.target.value),"aria-label":n.filterAllTasks,children:[(0,Q.jsx)(`option`,{value:``,children:n.filterAllTasks}),m.map(mn)]}),(0,Q.jsxs)(`select`,{className:Et,value:f,onChange:e=>p(e.target.value),"aria-label":n.filterAllStatuses,children:[(0,Q.jsx)(`option`,{value:``,children:n.filterAllStatuses}),(0,Q.jsx)(`option`,{value:`success`,children:n.execStatusSuccess}),(0,Q.jsx)(`option`,{value:`failed`,children:n.execStatusFailed}),(0,Q.jsx)(`option`,{value:`cancelled`,children:n.execStatusCancelled}),(0,Q.jsx)(`option`,{value:`running`,children:n.execStatusRunning})]})]}):null,t[50]=n.execStatusCancelled,t[51]=n.execStatusFailed,t[52]=n.execStatusRunning,t[53]=n.execStatusSuccess,t[54]=n.filterAllStatuses,t[55]=n.filterAllTasks,t[56]=n.historyRangeDay,t[57]=n.historyRangeMonth,t[58]=n.historyRangeWeek,t[59]=n.runHistoryTitle,t[60]=u,t[61]=c,t[62]=f,t[63]=m,t[64]=r,t[65]=d,t[66]=l,t[67]=p,t[68]=V):V=t[68];let H;t[69]!==z||t[70]!==B||t[71]!==V?(H=(0,Q.jsxs)(`div`,{className:z,children:[B,V]}),t[69]=z,t[70]=B,t[71]=V,t[72]=H):H=t[72];let U;return t[73]!==L||t[74]!==H?(U=(0,Q.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:[L,H]}),t[73]=L,t[74]=H,t[75]=U):U=t[75],U}function mn(e){return(0,Q.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id)}function hn(e){let t=(0,Z.c)(23),{c:n,loading:r,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}=e,l=r||a,u=n.refresh,d=n.refresh,f;t[0]===o?f=t[1]:(f=()=>void o(),t[0]=o,t[1]=f);let p=l&&`animate-spin`,m;t[2]===p?m=t[3]:(m=i(`size-4`,p),t[2]=p,t[3]=m);let h;t[4]===m?h=t[5]:(h=(0,Q.jsx)(U,{className:m,strokeWidth:1.75}),t[4]=m,t[5]=h);let g;t[6]!==l||t[7]!==n.refresh||t[8]!==f||t[9]!==h?(g=(0,Q.jsx)(q,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:l,title:u,"aria-label":d,onClick:f,children:h}),t[6]=l,t[7]=n.refresh,t[8]=f,t[9]=h,t[10]=g):g=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(ue,{className:`size-4`,strokeWidth:1.75}),t[11]=_):_=t[11];let v;t[12]!==n.fromTemplate||t[13]!==s?(v=(0,Q.jsxs)(q,{type:`button`,variant:`secondary`,className:`gap-2`,onClick:s,children:[_,n.fromTemplate]}),t[12]=n.fromTemplate,t[13]=s,t[14]=v):v=t[14];let y;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(b,{className:`size-4`,strokeWidth:1.75}),t[15]=y):y=t[15];let x;t[16]!==n.addJob||t[17]!==c?(x=(0,Q.jsxs)(q,{type:`button`,variant:`primary`,className:`gap-2`,onClick:c,children:[y,n.addJob]}),t[16]=n.addJob,t[17]=c,t[18]=x):x=t[18];let S;return t[19]!==x||t[20]!==g||t[21]!==v?(S=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[g,v,x]}),t[19]=x,t[20]=g,t[21]=v,t[22]=S):S=t[22],S}function gn(e){let t=(0,Z.c)(46),{c:n,runHistoryLoading:r,runHistory:a,filteredRunHistory:o,jobs:s,onRefreshHistory:c,onOpenJobDetail:l,statusLabels:u}=e,d;t[0]===n.tabRunHistory?d=t[1]:(d=(0,Q.jsx)(`h2`,{id:`cron-history-panel`,className:`sr-only`,children:n.tabRunHistory}),t[0]=n.tabRunHistory,t[1]=d);let f;t[2]===n.runHistoryHint?f=t[3]:(f=(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.runHistoryHint}),t[2]=n.runHistoryHint,t[3]=f);let p;t[4]!==d||t[5]!==f?(p=(0,Q.jsxs)(`div`,{children:[d,f]}),t[4]=d,t[5]=f,t[6]=p):p=t[6];let m=n.refresh,h=n.refresh,_;t[7]===c?_=t[8]:(_=()=>void c(),t[7]=c,t[8]=_);let v=r&&`animate-spin`,y;t[9]===v?y=t[10]:(y=i(`size-4`,v),t[9]=v,t[10]=y);let b;t[11]===y?b=t[12]:(b=(0,Q.jsx)(U,{className:y,strokeWidth:1.75}),t[11]=y,t[12]=b);let x;t[13]!==n.refresh||t[14]!==r||t[15]!==_||t[16]!==b?(x=(0,Q.jsx)(q,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:m,"aria-label":h,onClick:_,children:b}),t[13]=n.refresh,t[14]=r,t[15]=_,t[16]=b,t[17]=x):x=t[17];let S;t[18]!==x||t[19]!==p?(S=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[p,x]}),t[18]=x,t[19]=p,t[20]=S):S=t[20];let C;t[21]!==n.colChat||t[22]!==n.colDetail||t[23]!==n.colDuration||t[24]!==n.colJob||t[25]!==n.colStarted||t[26]!==n.colWorkflow||t[27]!==n.emptyHistoryHint||t[28]!==n.emptyHistoryTitle||t[29]!==n.noRunsYet||t[30]!==n.openChat||t[31]!==n.openChatTitle||t[32]!==n.openWorkflow||t[33]!==n.openWorkflowTitle||t[34]!==n.runHistoryHint||t[35]!==n.status||t[36]!==o||t[37]!==s||t[38]!==l||t[39]!==a||t[40]!==r||t[41]!==u?(C=r&&a.length===0?(0,Q.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,Q.jsx)(se,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):o.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center rounded-2xl border border-dashed border-edge-subtle px-6 py-16 text-center dark:border-edge-subtle`,children:[(0,Q.jsx)(g,{className:`mb-4 size-14 text-fg-disabled`,strokeWidth:1.1,"aria-hidden":!0}),(0,Q.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:a.length===0?n.emptyHistoryTitle:n.noRunsYet}),(0,Q.jsx)(`p`,{className:`mt-2 max-w-sm text-sm text-fg-muted`,children:a.length===0?n.emptyHistoryHint:n.runHistoryHint})]}):(0,Q.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:(0,Q.jsxs)(`table`,{className:`w-full min-w-[700px] border-collapse text-left text-sm`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{className:`border-b border-edge text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colStarted}),(0,Q.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colJob}),(0,Q.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.status}),(0,Q.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDuration}),(0,Q.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDetail}),(0,Q.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colWorkflow}),(0,Q.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colChat})]})}),(0,Q.jsx)(`tbody`,{children:o.map(e=>(0,Q.jsxs)(`tr`,{className:`border-b border-edge/60 last:border-0`,children:[(0,Q.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg`,children:(0,Q.jsx)(`time`,{dateTime:e.startedAt,children:Y(e.startedAt)})}),(0,Q.jsx)(`td`,{className:`max-w-[10rem] truncate px-3 py-2.5`,children:s.some(t=>t.id===e.jobId)?(0,Q.jsx)(`button`,{type:`button`,className:`text-left text-accent hover:underline`,onClick:()=>{let t=s.find(t=>t.id===e.jobId);t&&l(t)},children:e.jobName||e.jobId}):(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:e.jobName||e.jobId})}),(0,Q.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,Q.jsx)(`span`,{className:i(`inline-flex rounded-md px-2 py-0.5 text-xs font-medium`,e.status===`success`&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`,e.status===`failed`&&`bg-red-500/15 text-red-800 dark:text-red-300`,e.status===`running`&&`bg-accent/15 text-accent`,e.status===`cancelled`&&`bg-surface-hover text-fg-muted`),children:De(e.status,u)})}),(0,Q.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg-muted`,children:Je(e.duration)}),(0,Q.jsx)(`td`,{className:`max-w-xs truncate px-3 py-2.5 text-fg-muted`,title:e.summary||e.error||``,children:Ee(e.summary||e.error,96)}),(0,Q.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5`,children:e.workflowRunId?.trim()?(0,Q.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openWorkflowTitle,"aria-label":n.openWorkflowTitle,onClick:()=>St(e.workflowRunId),children:n.openWorkflow}):(0,Q.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})}),(0,Q.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5`,children:e.sessionKey?.trim()?(0,Q.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openChatTitle,"aria-label":n.openChatTitle,onClick:()=>xt(e.sessionKey),children:n.openChat}):(0,Q.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})})]},e.id))})]})}),t[21]=n.colChat,t[22]=n.colDetail,t[23]=n.colDuration,t[24]=n.colJob,t[25]=n.colStarted,t[26]=n.colWorkflow,t[27]=n.emptyHistoryHint,t[28]=n.emptyHistoryTitle,t[29]=n.noRunsYet,t[30]=n.openChat,t[31]=n.openChatTitle,t[32]=n.openWorkflow,t[33]=n.openWorkflowTitle,t[34]=n.runHistoryHint,t[35]=n.status,t[36]=o,t[37]=s,t[38]=l,t[39]=a,t[40]=r,t[41]=u,t[42]=C):C=t[42];let w;return t[43]!==S||t[44]!==C?(w=(0,Q.jsxs)(`section`,{"aria-labelledby":`cron-history-panel`,className:`flex flex-col gap-3`,children:[S,C]}),t[43]=S,t[44]=C,t[45]=w):w=t[45],w}function _n(e){let t=(0,Z.c)(77),{job:n,c:r,localeTag:a,scheduleBadgeLabels:o,absorbCardClickJobIdRef:s,scheduleAbsorbNextMenuCardClick:c,onOpenDetail:l,onToggle:u,onEdit:d,onRunNow:f,onDelete:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`flex h-full min-h-0 cursor-pointer flex-col rounded-xl border border-edge-subtle bg-surface-base text-left transition-colors duration-150 ease-out dark:border-edge-subtle`,`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-panel`),t[0]=m):m=t[0];let h,_;t[1]!==s||t[2]!==n||t[3]!==l?(h=()=>{if(s.current===n.id){s.current=null;return}l(n)},_=e=>{if(e.key===`Enter`||e.key===` `){if(e.preventDefault(),s.current===n.id){s.current=null;return}l(n)}},t[1]=s,t[2]=n,t[3]=l,t[4]=h,t[5]=_):(h=t[4],_=t[5]);let v=n.enabled,y=n.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`,b;t[6]===y?b=t[7]:(b=i(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,y),t[6]=y,t[7]=b);let x;t[8]!==n||t[9]!==u?(x=e=>{e.stopPropagation(),u(n,!n.enabled)},t[8]=n,t[9]=u,t[10]=x):x=t[10];let S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[11]=S):S=t[11];let C;t[12]!==n.enabled||t[13]!==b||t[14]!==x?(C=(0,Q.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":v,className:b,onClick:x,children:S}),t[12]=n.enabled,t[13]=b,t[14]=x,t[15]=C):C=t[15];let w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(ne,{className:`size-4`,strokeWidth:1.75}),t[16]=w):w=t[16];let T;t[17]===r.jobCardMenuAria?T=t[18]:(T=(0,Q.jsx)(it,{asChild:!0,children:(0,Q.jsx)(q,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":r.jobCardMenuAria,onClick:yn,children:w})}),t[17]=r.jobCardMenuAria,t[18]=T);let E;t[19]!==n||t[20]!==d||t[21]!==c?(E=()=>{c(n.id),d(n)},t[19]=n,t[20]=d,t[21]=c,t[22]=E):E=t[22];let D;t[23]!==r.edit||t[24]!==E?(D=(0,Q.jsx)(rt,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:E,children:r.edit}),t[23]=r.edit,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==n||t[27]!==f||t[28]!==c?(O=()=>{c(n.id),f(n)},t[26]=n,t[27]=f,t[28]=c,t[29]=O):O=t[29];let k;t[30]!==r.runNow||t[31]!==O?(k=(0,Q.jsx)(rt,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:O,children:r.runNow}),t[30]=r.runNow,t[31]=O,t[32]=k):k=t[32];let A;t[33]!==n||t[34]!==p||t[35]!==c?(A=()=>{c(n.id),p(n)},t[33]=n,t[34]=p,t[35]=c,t[36]=A):A=t[36];let j;t[37]!==r.delete||t[38]!==A?(j=(0,Q.jsx)(rt,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-red-600 outline-none data-highlighted:bg-red-500/10 dark:text-red-400`,onSelect:A,children:r.delete}),t[37]=r.delete,t[38]=A,t[39]=j):j=t[39];let M;t[40]!==D||t[41]!==k||t[42]!==j?(M=(0,Q.jsx)(at,{children:(0,Q.jsxs)(ot,{className:`z-50 min-w-[10rem] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,sideOffset:4,align:`end`,onCloseAutoFocus:vn,children:[D,k,j]})}),t[40]=D,t[41]=k,t[42]=j,t[43]=M):M=t[43];let N;t[44]!==T||t[45]!==M?(N=(0,Q.jsxs)(nt,{children:[T,M]}),t[44]=T,t[45]=M,t[46]=N):N=t[46];let P;t[47]!==N||t[48]!==C?(P=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2 px-4 pt-3`,children:[C,N]}),t[47]=N,t[48]=C,t[49]=P):P=t[49];let F=n.name||n.id,I;t[50]===F?I=t[51]:(I=(0,Q.jsx)(`h3`,{className:`line-clamp-2 font-semibold text-fg`,children:F}),t[50]=F,t[51]=I);let L;t[52]===n?L=t[53]:(L=Fe(n),t[52]=n,t[53]=L);let R;t[54]===n?R=t[55]:(R=Fe(n),t[54]=n,t[55]=R);let z;t[56]===R?z=t[57]:(z=(0,Q.jsx)(be,{content:R,compact:!0}),t[56]=R,t[57]=z);let B;t[58]!==L||t[59]!==z?(B=(0,Q.jsx)(`div`,{className:`max-h-[4.5rem] overflow-hidden text-sm text-fg-muted [&_.markdown-body]:text-sm [&_.markdown-body]:leading-snug`,title:L,children:z}),t[58]=L,t[59]=z,t[60]=B):B=t[60];let V;t[61]!==I||t[62]!==B?(V=(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 px-4 pb-3 pt-2`,children:[I,B]}),t[61]=I,t[62]=B,t[63]=V):V=t[63];let H;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Q.jsx)(g,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[64]=H):H=t[64];let U;t[65]!==n||t[66]!==a||t[67]!==o?(U=Te(n,a,o),t[65]=n,t[66]=a,t[67]=o,t[68]=U):U=t[68];let W;t[69]===U?W=t[70]:(W=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t border-edge-subtle/90 px-4 py-2.5 text-xs text-fg-muted dark:border-edge-subtle`,children:[H,(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:U})]}),t[69]=U,t[70]=W);let G;return t[71]!==h||t[72]!==P||t[73]!==V||t[74]!==_||t[75]!==W?(G=(0,Q.jsxs)(`article`,{role:`button`,tabIndex:0,className:m,onClick:h,onKeyDown:_,children:[P,V,W]}),t[71]=h,t[72]=P,t[73]=V,t[74]=_,t[75]=W,t[76]=G):G=t[76],G}function vn(e){return e.preventDefault()}function yn(e){return e.stopPropagation()}function bn(e){let t=(0,Z.c)(134),{c:n,language:r,localeTag:o,scheduleBadgeLabels:s,loading:c,sortedSystemJobs:l,heartbeat:u,keepAwake:d,wakeSupported:f,onWakeUnsupportedClick:p,onKeepAwakeToggle:m,absorbCardClickJobIdRef:h,scheduleAbsorbNextMenuCardClick:g,onOpenDetail:_,onToggle:v,onEdit:y,onRunNow:b,onDelete:x}=e,S,C,w,T,E,D,O,k,A,j,M,P;if(t[0]!==n.disabled||t[1]!==n.enabled||t[2]!==n.keepAwake||t[3]!==n.systemHeartbeatEvery||t[4]!==n.systemHeartbeatHint||t[5]!==n.systemHeartbeatInterval||t[6]!==n.systemHeartbeatSettingsLink||t[7]!==n.systemHeartbeatStatus||t[8]!==n.systemHeartbeatTitle||t[9]!==n.systemTasksIntro||t[10]!==n.tabSystemTasks||t[11]!==n.wakeBanner||t[12]!==n.wakeLockUnavailable||t[13]!==u.enabled||t[14]!==u.intervalMs||t[15]!==d||t[16]!==r||t[17]!==o||t[18]!==m||t[19]!==p||t[20]!==f){let e=Ze(u.intervalMs,o,a(r).heartbeatSettings.intervalPresets);M=`cron-system-tasks-panel`,P=`flex flex-col gap-4`,t[33]===n.tabSystemTasks?C=t[34]:(C=(0,Q.jsx)(`h2`,{id:`cron-system-tasks-panel`,className:`sr-only`,children:n.tabSystemTasks}),t[33]=n.tabSystemTasks,t[34]=C),t[35]===n.systemTasksIntro?w=t[36]:(w=(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.systemTasksIntro}),t[35]=n.systemTasksIntro,t[36]=w);let s;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(me,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[37]=s):s=t[37];let c;t[38]===n.wakeBanner?c=t[39]:(c=(0,Q.jsxs)(`div`,{className:`flex gap-3 text-sm text-fg`,children:[s,(0,Q.jsx)(`p`,{className:`text-pretty text-fg-muted`,children:n.wakeBanner})]}),t[38]=n.wakeBanner,t[39]=c);let l;t[40]===n.keepAwake?l=t[41]:(l=(0,Q.jsx)(`span`,{className:`text-sm text-fg`,children:n.keepAwake}),t[40]=n.keepAwake,t[41]=l);let h=!f,g=f?void 0:n.wakeLockUnavailable,_=d?`justify-end bg-accent`:`justify-start bg-surface-hover`,v=!f&&`cursor-not-allowed opacity-50`,y;t[42]!==_||t[43]!==v?(y=i(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,_,v),t[42]=_,t[43]=v,t[44]=y):y=t[44];let b;t[45]!==m||t[46]!==p||t[47]!==f?(b=()=>{f?m():p()},t[45]=m,t[46]=p,t[47]=f,t[48]=b):b=t[48];let x;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[49]=x):x=t[49];let F;t[50]!==d||t[51]!==h||t[52]!==g||t[53]!==y||t[54]!==b?(F=(0,Q.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":d,disabled:h,title:g,className:y,onClick:b,children:x}),t[50]=d,t[51]=h,t[52]=g,t[53]=y,t[54]=b,t[55]=F):F=t[55];let I;t[56]!==l||t[57]!==F?(I=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:pl-4`,children:[l,F]}),t[56]=l,t[57]=F,t[58]=I):I=t[58],t[59]!==c||t[60]!==I?(T=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10 sm:flex-row sm:items-center sm:justify-between`,children:[c,I]}),t[59]=c,t[60]=I,t[61]=T):T=t[61],A=`rounded-xl border border-edge bg-surface-base p-4 dark:bg-surface-hover/20`;let L;t[62]===n.systemHeartbeatTitle?L=t[63]:(L=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemHeartbeatTitle}),t[62]=n.systemHeartbeatTitle,t[63]=L);let R;t[64]===n.systemHeartbeatHint?R=t[65]:(R=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.systemHeartbeatHint}),t[64]=n.systemHeartbeatHint,t[65]=R);let z;t[66]!==L||t[67]!==R?(z=(0,Q.jsxs)(`div`,{children:[L,R]}),t[66]=L,t[67]=R,t[68]=z):z=t[68];let B;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(J,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[69]=B):B=t[69];let V;t[70]===n.systemHeartbeatSettingsLink?V=t[71]:(V=(0,Q.jsx)(q,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,Q.jsxs)(N,{to:`/settings/heartbeat`,children:[n.systemHeartbeatSettingsLink,B]})}),t[70]=n.systemHeartbeatSettingsLink,t[71]=V),t[72]!==z||t[73]!==V?(j=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between`,children:[z,V]}),t[72]=z,t[73]=V,t[74]=j):j=t[74],O=`mt-3 grid gap-2 text-sm sm:grid-cols-2`;let H;t[75]===n.systemHeartbeatStatus?H=t[76]:(H=(0,Q.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatStatus}),t[75]=n.systemHeartbeatStatus,t[76]=H);let U=u.enabled?n.enabled:n.disabled,W;t[77]===U?W=t[78]:(W=(0,Q.jsx)(`dd`,{className:`text-fg`,children:U}),t[77]=U,t[78]=W),t[79]!==H||t[80]!==W?(k=(0,Q.jsxs)(`div`,{children:[H,W]}),t[79]=H,t[80]=W,t[81]=k):k=t[81],t[82]===n.systemHeartbeatInterval?D=t[83]:(D=(0,Q.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatInterval}),t[82]=n.systemHeartbeatInterval,t[83]=D),S=`text-fg`;let G;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(G=/\{\{value\}\}/g,t[84]=G):G=t[84],E=n.systemHeartbeatEvery.replace(G,e),t[0]=n.disabled,t[1]=n.enabled,t[2]=n.keepAwake,t[3]=n.systemHeartbeatEvery,t[4]=n.systemHeartbeatHint,t[5]=n.systemHeartbeatInterval,t[6]=n.systemHeartbeatSettingsLink,t[7]=n.systemHeartbeatStatus,t[8]=n.systemHeartbeatTitle,t[9]=n.systemTasksIntro,t[10]=n.tabSystemTasks,t[11]=n.wakeBanner,t[12]=n.wakeLockUnavailable,t[13]=u.enabled,t[14]=u.intervalMs,t[15]=d,t[16]=r,t[17]=o,t[18]=m,t[19]=p,t[20]=f,t[21]=S,t[22]=C,t[23]=w,t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A,t[30]=j,t[31]=M,t[32]=P}else S=t[21],C=t[22],w=t[23],T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29],j=t[30],M=t[31],P=t[32];let F;t[85]!==S||t[86]!==E?(F=(0,Q.jsx)(`dd`,{className:S,children:E}),t[85]=S,t[86]=E,t[87]=F):F=t[87];let I;t[88]!==F||t[89]!==D?(I=(0,Q.jsxs)(`div`,{children:[D,F]}),t[88]=F,t[89]=D,t[90]=I):I=t[90];let L;t[91]!==I||t[92]!==O||t[93]!==k?(L=(0,Q.jsxs)(`dl`,{className:O,children:[k,I]}),t[91]=I,t[92]=O,t[93]=k,t[94]=L):L=t[94];let R;t[95]!==L||t[96]!==A||t[97]!==j?(R=(0,Q.jsxs)(`div`,{className:A,children:[j,L]}),t[95]=L,t[96]=A,t[97]=j,t[98]=R):R=t[98];let z;t[99]===n.systemDreamingTitle?z=t[100]:(z=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemDreamingTitle}),t[99]=n.systemDreamingTitle,t[100]=z);let B;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(J,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[101]=B):B=t[101];let V;t[102]===n.systemDreamingSettingsLink?V=t[103]:(V=(0,Q.jsx)(q,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,Q.jsxs)(N,{to:`/settings/dreams`,children:[n.systemDreamingSettingsLink,B]})}),t[102]=n.systemDreamingSettingsLink,t[103]=V);let H;t[104]!==z||t[105]!==V?(H=(0,Q.jsxs)(`div`,{className:`mb-2 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[z,V]}),t[104]=z,t[105]=V,t[106]=H):H=t[106];let U;t[107]===n.systemDreamingHint?U=t[108]:(U=(0,Q.jsx)(`p`,{className:`mb-3 text-xs text-fg-muted`,children:n.systemDreamingHint}),t[107]=n.systemDreamingHint,t[108]=U);let W;t[109]!==h||t[110]!==n||t[111]!==c||t[112]!==o||t[113]!==x||t[114]!==y||t[115]!==_||t[116]!==b||t[117]!==v||t[118]!==g||t[119]!==s||t[120]!==l?(W=c&&l.length===0?(0,Q.jsx)(`div`,{className:`flex justify-center py-12`,"aria-busy":`true`,children:(0,Q.jsx)(se,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):l.length===0?(0,Q.jsx)(`p`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/30 px-3 py-4 text-sm text-fg-muted dark:border-edge-subtle`,children:n.systemDreamingEmpty}):(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,children:l.map(e=>(0,Q.jsx)(_n,{job:e,c:n,localeTag:o,scheduleBadgeLabels:s,absorbCardClickJobIdRef:h,scheduleAbsorbNextMenuCardClick:g,onOpenDetail:_,onToggle:v,onEdit:y,onRunNow:b,onDelete:x},e.id))}),t[109]=h,t[110]=n,t[111]=c,t[112]=o,t[113]=x,t[114]=y,t[115]=_,t[116]=b,t[117]=v,t[118]=g,t[119]=s,t[120]=l,t[121]=W):W=t[121];let G;t[122]!==H||t[123]!==U||t[124]!==W?(G=(0,Q.jsxs)(`div`,{children:[H,U,W]}),t[122]=H,t[123]=U,t[124]=W,t[125]=G):G=t[125];let ee;return t[126]!==C||t[127]!==w||t[128]!==T||t[129]!==R||t[130]!==G||t[131]!==M||t[132]!==P?(ee=(0,Q.jsxs)(`section`,{"aria-labelledby":M,className:P,children:[C,w,T,R,G]}),t[126]=C,t[127]=w,t[128]=T,t[129]=R,t[130]=G,t[131]=M,t[132]=P,t[133]=ee):ee=t[133],ee}function xn(e,t){let n=e.templates;if(!n||typeof n!=`object`)return;let r=n[t];if(!r||typeof r!=`object`)return;let i=r.title?.trim(),a=r.prompt?.trim();if(!(!i||!a))return{title:i,description:(r.description??``).trim(),prompt:a}}var Sn=[`daily`,`monitoring`,`reports`,`automation`],Cn=[{templateId:`morning_briefing`,category:`daily`,defaultSchedule:`0 7 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`standup_prep`,category:`daily`,defaultSchedule:`0 8 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`meeting_prep`,category:`daily`,defaultSchedule:`0 9 * * 1-5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`meeting_prep`},{templateId:`end_of_day_wrap_up`,category:`daily`,defaultSchedule:`0 18 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`inbox_triage`,category:`daily`,defaultSchedule:`30 8 * * 1-5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`inbox_triage`},{templateId:`competitor_watch`,category:`monitoring`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`competitor_scan`},{templateId:`trending_topics_monitor`,category:`monitoring`,defaultSchedule:`0 10 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`tech_radar_stack`,category:`monitoring`,defaultSchedule:`0 11 * * 3`,defaultSessionTarget:`isolated`},{templateId:`dependency_check_audit`,category:`monitoring`,defaultSchedule:`0 9 * * 0`,defaultSessionTarget:`isolated`},{templateId:`weekly_review`,category:`reports`,defaultSchedule:`0 17 * * 5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`weekly_review`},{templateId:`code_quality_report`,category:`reports`,defaultSchedule:`0 14 * * 1`,defaultSessionTarget:`isolated`},{templateId:`git_activity_summary`,category:`reports`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`},{templateId:`user_feedback_digest`,category:`reports`,defaultSchedule:`0 16 * * 5`,defaultSessionTarget:`isolated`},{templateId:`content_repurpose`,category:`reports`,defaultSchedule:`0 11 * * 4`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`content_repurpose`},{templateId:`stale_todo_or_issue_sweep`,category:`automation`,defaultSchedule:`0 10 * * 2`,defaultSessionTarget:`isolated`},{templateId:`release_notes_or_changelog_draft`,category:`automation`,defaultSchedule:`0 10 * * 4`,defaultSessionTarget:`isolated`},{templateId:`client_proposal`,category:`automation`,defaultSchedule:`0 10 * * 2`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`client_proposal`},{templateId:`offer_design`,category:`automation`,defaultSchedule:`0 14 1 * *`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`offer_design`},{templateId:`decision_compare`,category:`automation`,defaultSchedule:`0 15 * * 3`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`decision_compare`},{templateId:`workspace_cleanup_suggestions`,category:`automation`,defaultSchedule:`30 18 * * 5`,defaultSessionTarget:`isolated`},{templateId:`smoke_or_ci_health_reminder`,category:`automation`,defaultSchedule:`0 8 * * 1`,defaultSessionTarget:`isolated`}];function wn(e){return Cn.find(t=>t.templateId===e)}function Tn(e,t,n){let r=t.trim().toLowerCase();return Cn.filter(t=>{if(n!==`all`&&t.category!==n)return!1;if(!r)return!0;let i=xn(e,t.templateId);return[t.templateId,i?.title,i?.description,e.templateCategories[t.category]].filter(Boolean).join(` `).toLowerCase().includes(r)})}function En(e){let t=new Map;for(let n of e){let e=t.get(n.category)??[];e.push(n),t.set(n.category,e)}return Sn.flatMap(e=>{let n=t.get(e);return n?.length?[{category:e,items:n}]:[]})}function Dn(e){let t=(0,Z.c)(23),{template:n,cron:r,localeTag:a,scheduleBadgeLabels:o,onSelectTemplate:s}=e,c;t[0]!==r||t[1]!==n.templateId?(c=xn(r,n.templateId),t[0]=r,t[1]=n.templateId,t[2]=c):c=t[2];let l=c;if(!l)return null;let u;t[3]!==a||t[4]!==o||t[5]!==n.defaultSchedule?(u=Te({schedule:Ve(n.defaultSchedule),nextRunAtMs:void 0},a,o),t[3]=a,t[4]=o,t[5]=n.defaultSchedule,t[6]=u):u=t[6];let d=u,f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=i(`flex h-full flex-col gap-1.5 rounded-xl border border-edge-subtle bg-surface-base p-4 text-left transition-colors`,`hover:border-accent/40 hover:bg-surface-hover`,ve.focusRingPanel),t[7]=f):f=t[7];let p;t[8]!==s||t[9]!==n.templateId?(p=()=>s(n.templateId),t[8]=s,t[9]=n.templateId,t[10]=p):p=t[10];let m=`${r.templateCategories[n.category]} — ${l.title}`,h;t[11]===l.title?h=t[12]:(h=(0,Q.jsx)(`span`,{className:`font-semibold text-fg`,children:l.title}),t[11]=l.title,t[12]=h);let g;t[13]===l.description?g=t[14]:(g=(0,Q.jsx)(`span`,{className:`line-clamp-2 text-sm text-fg-muted`,children:l.description}),t[13]=l.description,t[14]=g);let _;t[15]===d?_=t[16]:(_=(0,Q.jsx)(`span`,{className:`mt-auto flex items-center gap-1 pt-1 text-xs text-fg-muted`,children:(0,Q.jsx)(`span`,{className:`tabular-nums`,children:d})}),t[15]=d,t[16]=_);let v;return t[17]!==p||t[18]!==m||t[19]!==h||t[20]!==g||t[21]!==_?(v=(0,Q.jsxs)(`button`,{type:`button`,className:f,onClick:p,"aria-label":m,children:[h,g,_]}),t[17]=p,t[18]=m,t[19]=h,t[20]=g,t[21]=_,t[22]=v):v=t[22],v}function On(e){let t=(0,Z.c)(49),{cron:n,localeTag:r,scheduleBadgeLabels:a,categoryFilter:o,onCategoryFilterChange:s,onSelectTemplate:c,variant:l}=e,u=l===void 0?`embedded`:l,[d,f]=(0,X.useState)(``),p;t[0]!==o||t[1]!==n||t[2]!==d?(p=Tn(n,d,o),t[0]=o,t[1]=n,t[2]=d,t[3]=p):p=t[3];let m=p,h;t[4]===m?h=t[5]:(h=En(m),t[4]=m,t[5]=h);let g=h,_;t[6]!==o||t[7]!==d?(_=o===`all`&&!d.trim(),t[6]=o,t[7]=d,t[8]=_):_=t[8];let v=_,y;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(oe,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=y):y=t[9];let b;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>f(e.target.value),t[10]=b):b=t[10];let x=n.templateSearchPlaceholder,S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=i(`h-10 w-full rounded-xl border border-edge bg-surface-base py-2 pl-10 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,ve.focusRingPanel),t[11]=S):S=t[11];let C;t[12]!==n.templateSearchPlaceholder||t[13]!==d?(C=(0,Q.jsxs)(`div`,{className:`relative`,children:[y,(0,Q.jsx)(`input`,{value:d,onChange:b,placeholder:x,className:S})]}),t[12]=n.templateSearchPlaceholder,t[13]=d,t[14]=C):C=t[14];let w=n.fromTemplate,T=o===`all`?`secondary`:`ghost`,E;t[15]===s?E=t[16]:(E=()=>s(`all`),t[15]=s,t[16]=E);let D;t[17]!==n.templateFilterAll||t[18]!==T||t[19]!==E?(D=(0,Q.jsx)(q,{type:`button`,variant:T,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:E,children:n.templateFilterAll}),t[17]=n.templateFilterAll,t[18]=T,t[19]=E,t[20]=D):D=t[20];let O;t[21]!==o||t[22]!==n.templateCategories||t[23]!==s?(O=Sn.map(e=>(0,Q.jsx)(q,{type:`button`,variant:o===e?`secondary`:`ghost`,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:()=>s(e),children:n.templateCategories[e]},e)),t[21]=o,t[22]=n.templateCategories,t[23]=s,t[24]=O):O=t[24];let k;t[25]!==n.fromTemplate||t[26]!==D||t[27]!==O?(k=(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":w,children:[D,O]}),t[25]=n.fromTemplate,t[26]=D,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==k||t[30]!==C?(A=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4`,children:[C,k]}),t[29]=k,t[30]=C,t[31]=A):A=t[31];let j=A,M;t[32]!==n||t[33]!==m||t[34]!==g||t[35]!==r||t[36]!==c||t[37]!==a||t[38]!==v||t[39]!==u?(M=m.length===0?(0,Q.jsx)(`div`,{className:i(`text-center text-sm text-fg-muted`,u===`dialog`&&`flex h-full flex-col items-center justify-center px-4 py-12`),children:n.templatesEmptyHint}):v?(0,Q.jsx)(`div`,{className:`flex flex-col gap-6 pb-1`,children:g.map(e=>(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n.templateCategories[e.category]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:e.items.map(e=>(0,Q.jsx)(Dn,{template:e,cron:n,localeTag:r,scheduleBadgeLabels:a,onSelectTemplate:c},e.templateId))})]},e.category))}):(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 pb-1 sm:grid-cols-2 xl:grid-cols-3`,children:m.map(e=>(0,Q.jsx)(Dn,{template:e,cron:n,localeTag:r,scheduleBadgeLabels:a,onSelectTemplate:c},e.templateId))}),t[32]=n,t[33]=m,t[34]=g,t[35]=r,t[36]=c,t[37]=a,t[38]=v,t[39]=u,t[40]=M):M=t[40];let N=M;if(u===`dialog`){let e;t[41]===N?e=t[42]:(e=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:N}),t[41]=N,t[42]=e);let n;return t[43]!==j||t[44]!==e?(n=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4`,children:[j,e]}),t[43]=j,t[44]=e,t[45]=n):n=t[45],n}let P;return t[46]!==j||t[47]!==N?(P=(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[j,N]}),t[46]=j,t[47]=N,t[48]=P):P=t[48],P}function kn(e){let t=(0,Z.c)(49),{c:n,localeTag:r,scheduleBadgeLabels:a,loading:o,jobsCount:s,sortedJobs:c,templateCategoryFilter:l,onTemplateCategoryFilterChange:u,onSelectTemplate:d,keepAwake:f,wakeSupported:p,onWakeUnsupportedClick:m,onKeepAwakeToggle:h,absorbCardClickJobIdRef:g,scheduleAbsorbNextMenuCardClick:_,onOpenDetail:v,onToggle:y,onEdit:b,onAddJob:x,onRunNow:S,onDelete:C}=e,w;t[0]===n.tabMyTasks?w=t[1]:(w=(0,Q.jsx)(`h2`,{id:`cron-tasks-panel`,className:`sr-only`,children:n.tabMyTasks}),t[0]=n.tabMyTasks,t[1]=w);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(me,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=T):T=t[2];let E;t[3]===n.wakeBanner?E=t[4]:(E=(0,Q.jsxs)(`div`,{className:`flex gap-3 text-sm text-fg`,children:[T,(0,Q.jsx)(`p`,{className:`text-pretty text-fg-muted`,children:n.wakeBanner})]}),t[3]=n.wakeBanner,t[4]=E);let D;t[5]===n.keepAwake?D=t[6]:(D=(0,Q.jsx)(`span`,{className:`text-sm text-fg`,children:n.keepAwake}),t[5]=n.keepAwake,t[6]=D);let O=!p,k=p?void 0:n.wakeLockUnavailable,A=f?`justify-end bg-accent`:`justify-start bg-surface-hover`,j=!p&&`cursor-not-allowed opacity-50`,M;t[7]!==A||t[8]!==j?(M=i(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,A,j),t[7]=A,t[8]=j,t[9]=M):M=t[9];let N;t[10]!==h||t[11]!==m||t[12]!==p?(N=()=>{p?h():m()},t[10]=h,t[11]=m,t[12]=p,t[13]=N):N=t[13];let P;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Q.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[14]=P):P=t[14];let F;t[15]!==f||t[16]!==N||t[17]!==O||t[18]!==k||t[19]!==M?(F=(0,Q.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":f,disabled:O,title:k,className:M,onClick:N,children:P}),t[15]=f,t[16]=N,t[17]=O,t[18]=k,t[19]=M,t[20]=F):F=t[20];let I;t[21]!==F||t[22]!==D?(I=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:pl-4`,children:[D,F]}),t[21]=F,t[22]=D,t[23]=I):I=t[23];let L;t[24]!==I||t[25]!==E?(L=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10 sm:flex-row sm:items-center sm:justify-between`,children:[E,I]}),t[24]=I,t[25]=E,t[26]=L):L=t[26];let R;t[27]!==g||t[28]!==n||t[29]!==s||t[30]!==o||t[31]!==r||t[32]!==x||t[33]!==C||t[34]!==b||t[35]!==v||t[36]!==S||t[37]!==d||t[38]!==u||t[39]!==y||t[40]!==_||t[41]!==a||t[42]!==c||t[43]!==l?(R=o&&s===0?(0,Q.jsx)(`div`,{className:`flex justify-center py-16`,"aria-busy":`true`,children:(0,Q.jsx)(se,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):s===0?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6 rounded-2xl bg-surface-base px-4 py-8 dark:bg-surface-hover/25 sm:px-6 sm:py-10`,children:[(0,Q.jsx)(`div`,{className:`w-full max-w-6xl`,children:(0,Q.jsx)(On,{cron:n,localeTag:r,scheduleBadgeLabels:a,categoryFilter:l,onCategoryFilterChange:u,onSelectTemplate:d})}),(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsx)(q,{type:`button`,variant:`primary`,onClick:x,children:n.emptyStateCta})})]}):(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,children:c.map(e=>(0,Q.jsx)(_n,{job:e,c:n,localeTag:r,scheduleBadgeLabels:a,absorbCardClickJobIdRef:g,scheduleAbsorbNextMenuCardClick:_,onOpenDetail:e=>void v(e),onToggle:(e,t)=>void y(e,t),onEdit:b,onRunNow:S,onDelete:C},e.id))}),t[27]=g,t[28]=n,t[29]=s,t[30]=o,t[31]=r,t[32]=x,t[33]=C,t[34]=b,t[35]=v,t[36]=S,t[37]=d,t[38]=u,t[39]=y,t[40]=_,t[41]=a,t[42]=c,t[43]=l,t[44]=R):R=t[44];let z;return t[45]!==w||t[46]!==L||t[47]!==R?(z=(0,Q.jsxs)(`section`,{"aria-labelledby":`cron-tasks-panel`,className:`flex flex-col gap-4`,children:[w,L,R]}),t[45]=w,t[46]=L,t[47]=R,t[48]=z):z=t[48],z}function An(e){let t=(0,Z.c)(29),{open:n,onOpenChange:r,c:a,localeTag:o,scheduleBadgeLabels:s,categoryFilter:c,onCategoryFilterChange:l,onSelectTemplate:u}=e,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(L,{className:`xopc-dialog-overlay fixed inset-0 z-[62] bg-scrim`}),t[0]=d):d=t[0];let f;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(f=i(`xopc-dialog-content-pane pointer-events-auto relative flex h-[min(90vh,840px)] w-full max-w-5xl flex-col`,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,ve.focusRingPanel),t[1]=f):f=t[1];let p;t[2]===a.fromTemplate?p=t[3]:(p=(0,Q.jsx)(m,{className:`text-lg font-semibold text-fg`,children:a.fromTemplate}),t[2]=a.fromTemplate,t[3]=p);let h;t[4]===a.templatePickerHint?h=t[5]:(h=(0,Q.jsx)(R,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:a.templatePickerHint}),t[4]=a.templatePickerHint,t[5]=h);let g;t[6]!==p||t[7]!==h?(g=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8];let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(te,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=_):_=t[9];let v;t[10]===a.close?v=t[11]:(v=(0,Q.jsx)(ce,{asChild:!0,children:(0,Q.jsx)(q,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":a.close,children:_})}),t[10]=a.close,t[11]=v);let y;t[12]!==g||t[13]!==v?(y=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge-subtle px-6 py-5`,children:[g,v]}),t[12]=g,t[13]=v,t[14]=y):y=t[14];let b;t[15]!==a||t[16]!==c||t[17]!==o||t[18]!==l||t[19]!==u||t[20]!==s?(b=(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-6 py-5`,children:(0,Q.jsx)(On,{variant:`dialog`,cron:a,localeTag:o,scheduleBadgeLabels:s,categoryFilter:c,onCategoryFilterChange:l,onSelectTemplate:u})}),t[15]=a,t[16]=c,t[17]=o,t[18]=l,t[19]=u,t[20]=s,t[21]=b):b=t[21];let x;t[22]!==y||t[23]!==b?(x=(0,Q.jsxs)(z,{children:[d,(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[62] flex items-center justify-center p-4 pointer-events-none`,children:(0,Q.jsxs)(E,{className:f,onOpenAutoFocus:jn,children:[y,b]})})]}),t[22]=y,t[23]=b,t[24]=x):x=t[24];let S;return t[25]!==r||t[26]!==n||t[27]!==x?(S=(0,Q.jsx)(M,{open:n,onOpenChange:r,children:x}),t[25]=r,t[26]=n,t[27]=x,t[28]=S):S=t[28],S}function jn(e){return e.preventDefault()}function Mn(){return{formOpen:!1,formMode:`add`,formJobId:null,formName:``,formSchedule:Ve(_t),formChannel:`local`,formChatId:``,formMessage:``,formMessageMdMode:`edit`,formTaskKind:`message`,formWorkflowDefinitionId:``,formWorkflowGoal:``,formWorkflowArgValues:{},messageEditorNonce:0,formSessionTarget:`main`,formAgentId:``,formAgentLocalOnly:!1,formWorkingDirectory:``,formModel:``,formSubmitting:!1}}function Nn(e,t){switch(t.type){case`patch`:return{...e,...t.patch};case`replace`:return t.state;case`setMessageMdMode`:return{...e,formMessageMdMode:t.mode,messageEditorNonce:t.mode===`edit`?e.messageEditorNonce+1:e.messageEditorNonce}}}function Pn(e,t){let n=Mn();if(n.formOpen=!0,n.formMode=e?`edit`:`add`,n.formJobId=e?.id??null,!e)return n.formModel=t(),n;if(n.formName=e.name||``,n.formSchedule=e.schedule,n.formMessage=Fe(e)??``,e.payload.kind===`workflowRun`){n.formTaskKind=`workflowRun`,n.formWorkflowDefinitionId=e.payload.definitionId,n.formWorkflowGoal=e.payload.goal||``,n.formWorkflowArgValues=Xt(e.payload.definitionId,e.payload.inputEnvelope?.payload??e.payload.input??{});let t=e.payload.agentId?.trim().toLowerCase();t&&(n.formAgentId=t)}n.formSessionTarget=e.sessionTarget===`isolated`?`isolated`:`main`,n.formAgentId=(e.sessionTarget||`main`)===`isolated`&&e.agentId?.trim()?e.agentId.trim().toLowerCase():``,n.formWorkingDirectory=(e.sessionTarget||`main`)===`isolated`&&e.workingDirectory?.trim()?e.workingDirectory.trim():``;let r=e.payload?.kind===`agentTurn`&&e.payload.model?.trim()?e.payload.model.trim():``;n.formModel=e.model?.trim()||r||t();let i=e.delivery?.channel===`local`;return n.formAgentLocalOnly=(e.sessionTarget||`main`)===`isolated`&&!i&&(!e.delivery?.to||e.delivery.mode===`none`),i?(n.formChannel=`local`,n.formChatId=``):e.delivery&&e.delivery.mode!==`none`&&e.delivery.to?(n.formChannel=e.delivery.channel||`telegram`,n.formChatId=e.delivery.to||``):(n.formChannel=`telegram`,n.formChatId=``),n.formMessageMdMode=`edit`,n.messageEditorNonce=1,n}function Fn(e){let{m:t,defaultModelForForm:n,channels:r,chatAgents:i}=e,[a,o]=(0,X.useReducer)(Nn,void 0,Mn),s=(0,X.useRef)(!1),c=(0,X.useMemo)(()=>new Set([`local`,...r.map(e=>e.name)]),[r]);if(a.formOpen&&a.formMode===`add`&&!c.has(a.formChannel)&&o({type:`patch`,patch:{formChannel:`local`}}),a.formOpen&&a.formMode===`add`&&!s.current){let e=n();e&&e!==a.formModel&&o({type:`patch`,patch:{formModel:e}})}let l=D(()=>je(a.formChannel),[a.formChannel],{enabled:a.formOpen&&a.formChannel!==`local`,initial:[],errorData:[]}),u=a.formChannel===`local`?[]:l.data,d=(0,X.useMemo)(()=>{let e=new Set(i.map(e=>e.id)),t=[...i],n=a.formAgentId.trim().toLowerCase();return n&&!e.has(n)&&t.push({id:n}),t},[i,a.formAgentId]),f=a.formChannel!==`local`&&(a.formTaskKind===`message`&&(a.formSessionTarget===`main`||a.formSessionTarget===`isolated`&&!a.formAgentLocalOnly)||a.formTaskKind===`workflowRun`&&!a.formAgentLocalOnly),p=a.formTaskKind===`workflowRun`?!a.formAgentLocalOnly:a.formTaskKind===`message`&&(a.formSessionTarget===`main`||a.formSessionTarget===`isolated`&&!a.formAgentLocalOnly),m=a.formTaskKind===`workflowRun`?!!a.formWorkflowDefinitionId.trim()&&Zt(a.formWorkflowDefinitionId.trim(),a.formWorkflowArgValues):!!a.formMessage.trim(),h=a.formSchedule.kind===`cron`?!!a.formSchedule.expr.trim():a.formSchedule.kind===`at`?!!a.formSchedule.at.trim():Number.isFinite(a.formSchedule.everyMs)&&a.formSchedule.everyMs>0,g=!!a.formName.trim()&&h&&m&&(!f||!!a.formChatId.trim()),_=(0,X.useCallback)(e=>{s.current=!1,o({type:`replace`,state:Pn(e,n)})},[n]),v=(0,X.useCallback)(e=>{o({type:`setMessageMdMode`,mode:e})},[]),y=(0,X.useCallback)(e=>{let r=wn(e),i=r?xn(t.cron,e):void 0;if(!r||!i)return!1;let a=r.taskKind===`workflowRun`&&!!r.workflowDefinitionId;return s.current=!1,o({type:`replace`,state:{...Mn(),formOpen:!0,formMode:`add`,formName:i.title,formSchedule:Ve(r.defaultSchedule),formMessage:a?``:i.prompt,formTaskKind:a?`workflowRun`:`message`,formWorkflowDefinitionId:a?r.workflowDefinitionId:``,formWorkflowGoal:a?i.description:``,formSessionTarget:r.defaultSessionTarget,formModel:n(),formAgentLocalOnly:a,messageEditorNonce:1}}),!0},[n,t.cron]),b=(0,X.useCallback)(()=>{s.current=!1,o({type:`replace`,state:Mn()})},[]),x=(0,X.useCallback)((e,t,n)=>{let r={formSessionTarget:e};e===`main`?(r.formAgentLocalOnly=!1,r.formAgentId=``,r.formWorkingDirectory=``):e===`isolated`&&!n&&(r.formModel=t()),o({type:`patch`,patch:r})},[]),S=(0,X.useCallback)(e=>{o({type:`patch`,patch:{formChannel:e,formChatId:``,...e===`local`?{formAgentLocalOnly:!1}:{}}})},[]),C=(0,X.useCallback)(e=>{s.current=!0,o({type:`patch`,patch:{formModel:e}})},[]),w=(0,X.useCallback)(()=>{je(a.formChannel).then(l.setData)},[a.formChannel,l.setData]),T=(0,X.useCallback)(e=>{o({type:`patch`,patch:e})},[]);return{formOpen:a.formOpen,formMode:a.formMode,formJobId:a.formJobId,formName:a.formName,formSchedule:a.formSchedule,formChannel:a.formChannel,formChatId:a.formChatId,formMessage:a.formMessage,formMessageMdMode:a.formMessageMdMode,formTaskKind:a.formTaskKind,formWorkflowDefinitionId:a.formWorkflowDefinitionId,formWorkflowGoal:a.formWorkflowGoal,formWorkflowArgValues:a.formWorkflowArgValues,messageEditorNonce:a.messageEditorNonce,formSessionTarget:a.formSessionTarget,formAgentId:a.formAgentId,formAgentLocalOnly:a.formAgentLocalOnly,formWorkingDirectory:a.formWorkingDirectory,formModel:a.formModel,formSubmitting:a.formSubmitting,sessionChatIds:u,setFormName:e=>T({formName:e}),setFormSchedule:e=>T({formSchedule:e}),setFormChatId:e=>T({formChatId:e}),setFormMessage:e=>T({formMessage:e}),setFormTaskKind:e=>T(e===`workflowRun`?{formTaskKind:e,formSessionTarget:`isolated`,formAgentLocalOnly:!1}:{formTaskKind:e}),setFormWorkflowDefinitionId:e=>T({formWorkflowDefinitionId:e,formWorkflowArgValues:{}}),setFormWorkflowGoal:e=>T({formWorkflowGoal:e}),setFormWorkflowArgValues:e=>T({formWorkflowArgValues:e}),setFormAgentId:e=>T({formAgentId:e}),setFormAgentLocalOnly:e=>T({formAgentLocalOnly:e}),setFormWorkingDirectory:e=>T({formWorkingDirectory:e}),setFormSubmitting:e=>T({formSubmitting:e}),canSubmit:g,needsDeliveryChat:f,showChannelPicker:p,cronAgentSelectOptions:d,openForm:_,closeForm:b,applyCronTemplate:y,setMessageMdMode:v,handleFormSessionTargetChange:x,handleFormChannelChange:S,handleFormModelUserChange:C,refreshRecipientsList:w}}function In(e){let{onUnavailable:t}=e,[n,r]=(0,X.useState)(!1),i=(0,X.useRef)(null),a=(0,X.useRef)(`none`),o=(0,X.useRef)(n),s=typeof navigator<`u`&&`wakeLock`in navigator,c=s||ae(),l=(0,X.useCallback)(async()=>{if(a.current===`electron`){try{await window.electronAPI?.cron?.setDisplaySleepPrevented?.(!1)}catch{}a.current=`none`;return}try{await i.current?.release()}catch{}i.current=null,a.current=`none`},[]),u=(0,X.useCallback)(async()=>{let e=typeof window<`u`?window.electronAPI?.cron?.setDisplaySleepPrevented:void 0;if(e)try{await e(!0),a.current=`electron`;return}catch{t(),r(!1);return}if(s)try{let e=await navigator.wakeLock.request(`screen`);i.current=e,a.current=`navigator`,e.addEventListener(`release`,()=>{i.current=null,a.current=`none`})}catch{t(),r(!1)}},[t,s]);return o.current=n,(0,X.useEffect)(()=>{if(!n){l();return}u();let e=()=>{document.visibilityState===`visible`&&o.current&&u()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),l()}},[n,u,l]),{keepAwake:n,setKeepAwake:r,featureAvailable:c}}function Ln(e){let{hasToken:t,failMessages:n,isHistoryTab:r}=e,[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)([]),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)([]),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)([]),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(null),w=(0,X.useCallback)(async()=>{x(!0),C(null);try{a(await Me())}catch(e){C(e instanceof Error?e.message:n.failedToLoadJobs)}finally{x(!1)}},[n.failedToLoadJobs]),T=(0,X.useCallback)(async()=>{try{let[e,t,n,r,i]=await Promise.all([ze(),We(),He(),he(),V().catch(()=>null)]);s(e),l(t),d(n.model||``),h(r.payload?.config??null),i&&p(i.items)}catch{}},[]),E=(0,X.useCallback)(async()=>{y(!0);try{_(await Oe(400))}catch{}finally{y(!1)}},[]);return(0,X.useEffect)(()=>{t&&(w(),T())},[t,w,T]),(0,X.useEffect)(()=>{if(!t)return;let e=()=>{he().then(e=>{h(e.payload?.config??null)})};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[t]),(0,X.useEffect)(()=>{!t||!r||E()},[t,r,E]),{jobs:i,channels:o,availableModels:c,defaultModel:u,chatAgents:f,gatewayConfigRaw:m,runHistory:g,runHistoryLoading:v,loading:b,error:S,setError:C,userCronJobs:(0,X.useMemo)(()=>i.filter(e=>!Ye(e)),[i]),systemCronJobs:(0,X.useMemo)(()=>i.filter(e=>Ye(e)),[i]),heartbeatFromConfig:(0,X.useMemo)(()=>Qe(m),[m]),loadJobs:w,loadAux:T,loadRunHistoryOnly:E,refreshAll:(0,X.useCallback)(()=>{w(),T(),E()},[w,T,E])}}function Rn(e,t){let n=[...e];return n.sort((e,n)=>{let r=e.createdAtMs,i=n.createdAtMs;return t===`created_desc`?i-r:r-i}),n}function zn(e,t,n,r){let i=new Date,a=t===`day`?vt(i):t===`week`?yt(i):bt(i);return e.filter(e=>!(new Date(e.startedAt)<a||n&&e.jobId!==n||r&&e.status!==r))}var Bn={mainTab:`myTasks`,jobSort:`created_desc`,historyRange:`day`,historyJobFilter:``,historyStatusFilter:``,detailOpen:!1,detailJob:null,detailHistory:[],detailLoading:!1,detailActionNotice:null,confirmOpen:!1,templatePickerOpen:!1,templateCategoryFilter:`all`};function Vn(){let e=o(e=>e.language),t=a(e),n=t.cron,r=t.chat,i=c(e=>e.token),l=!!i,u=s(e=>e.resolved)===`dark`,d=e===`zh`?`zh-CN`:`en-US`,[f,m]=y(),[g,_]=(0,X.useReducer)(h,f,e=>({...Bn,mainTab:Dt(e.get(`tab`))})),{mainTab:v,jobSort:b,historyRange:x,historyJobFilter:S,historyStatusFilter:C,detailOpen:w,detailJob:T,detailHistory:E,detailLoading:D,detailActionNotice:O,confirmOpen:k,templatePickerOpen:A,templateCategoryFilter:j}=g,M=Dt(f.get(`tab`));(0,X.useEffect)(()=>{M!==v&&_({type:`patch`,patch:{mainTab:M}})},[M,v]);let N=(0,X.useCallback)(e=>{_({type:`patch`,patch:{mainTab:e}}),m(t=>{let n=new URLSearchParams(t),r=Ot(e);return r?n.set(`tab`,r):n.delete(`tab`),n},{replace:!0})},[m]),P=Ln({hasToken:l,failMessages:{failedToLoadJobs:n.failedToLoadJobs},isHistoryTab:v===`history`}),{setError:F}=P,I=In({onUnavailable:()=>F(n.wakeLockUnavailable)}),L=(0,X.useCallback)(()=>P.defaultModel||(P.availableModels.length>0?P.availableModels[0].id:``),[P.defaultModel,P.availableModels]),R=Fn({m:t,defaultModelForForm:L,channels:P.channels,chatAgents:P.chatAgents}),z=p(l&&R.formOpen?[`workflow-definitions-cron`,i]:null,re,{revalidateOnFocus:!1}),B=z.data??[],V=(0,X.useRef)(null),H=(0,X.useRef)(null),U=(0,X.useCallback)((e,t)=>{V.current=e,H.current=t,_({type:`patch`,patch:{confirmOpen:!0}})},[]),W=(0,X.useCallback)(()=>{_({type:`patch`,patch:{confirmOpen:!1}}),H.current=null,V.current=null},[]),G=(0,X.useRef)(null),ee=(0,X.useCallback)(e=>{G.current=e,window.setTimeout(()=>{G.current===e&&(G.current=null)},400)},[]),K=(0,X.useCallback)(e=>{R.applyCronTemplate(e)&&_({type:`patch`,patch:{templatePickerOpen:!1}})},[R]),te=async()=>{if(!R.formName.trim()){F(n.nameRequired);return}if(R.formSchedule.kind===`cron`&&!R.formSchedule.expr.trim()||R.formSchedule.kind===`at`&&!R.formSchedule.at.trim()||R.formSchedule.kind===`every`&&(!Number.isFinite(R.formSchedule.everyMs)||R.formSchedule.everyMs<=0)){F(n.scheduleRequired);return}if(R.formTaskKind===`message`&&!R.formMessage.trim()){F(n.scheduleRequired);return}if(R.formTaskKind===`workflowRun`&&!R.formWorkflowDefinitionId.trim()){F(n.workflowDefinitionRequired);return}if(R.formTaskKind===`workflowRun`&&!Zt(R.formWorkflowDefinitionId.trim(),R.formWorkflowArgValues)){F(n.workflowArgsRequired);return}if(R.needsDeliveryChat&&!R.formChatId.trim()){F(n.chatIdRequired);return}R.setFormSubmitting(!0),F(null);try{let e=R.formMessage.trim(),t=R.formModel.trim(),n=R.formAgentId.trim().toLowerCase(),r=R.formWorkingDirectory.trim(),i=R.formTaskKind===`workflowRun`,a=R.formTaskKind===`message`&&R.formSessionTarget===`isolated`,o=i?`isolated`:R.formSessionTarget,s;s=i?R.formAgentLocalOnly?{mode:`none`}:R.formChannel===`local`?{mode:`announce`,channel:`local`}:{mode:`announce`,channel:R.formChannel,to:R.formChatId.trim()}:R.formSessionTarget===`isolated`&&R.formAgentLocalOnly?{mode:`none`}:R.formChannel===`local`?{mode:`announce`,channel:`local`}:{mode:`announce`,channel:R.formChannel,to:R.formChatId.trim()};let c;if(i){let e=R.formWorkflowDefinitionId.trim(),t=tt(R.formWorkflowArgValues);c={kind:`workflowRun`,definitionId:e,...t===void 0?{}:{inputEnvelope:{payload:t}},...R.formWorkflowGoal.trim()?{goal:R.formWorkflowGoal.trim()}:{},...n?{agentId:n}:{}}}else c=a?{kind:`agentTurn`,message:e,...t?{model:t}:{}}:{kind:`systemEvent`,text:e};let l=o===`main`?null:n||null,u={name:R.formName.trim(),schedule:R.formSchedule,sessionTarget:o,delivery:s,payload:c,...R.formMode===`edit`?{...l?{agentId:l}:{},...a&&r?{workingDirectory:r}:{}}:{...o===`isolated`&&n?{agentId:n}:{},...a&&r?{workingDirectory:r}:{}}};if(R.formMode===`edit`&&R.formJobId)await Ne(R.formJobId,u);else{let{schedule:e,agentId:t,workingDirectory:n,...r}=u;await Re(e,{...r,...t==null?{}:{agentId:t},...n?{workingDirectory:n}:{}})}R.closeForm(),await P.loadJobs()}catch(e){F(e instanceof Error?e.message:R.formMode===`edit`?n.failedToUpdateJob:n.failedToCreateJob)}finally{R.setFormSubmitting(!1)}},ne=async e=>{_({type:`patch`,patch:{detailOpen:!0,detailJob:e,detailLoading:!0,detailHistory:[],detailActionNotice:null}});try{let t=await Ie(e.id);t&&_({type:`patch`,patch:{detailJob:t,detailHistory:await Ae(e.id,20)}})}catch{}finally{_({type:`patch`,patch:{detailLoading:!1}})}},q=(0,X.useCallback)(()=>{_({type:`patch`,patch:{detailOpen:!1,detailJob:null,detailActionNotice:null}})},[]),ie=(0,X.useCallback)(()=>{_({type:`patch`,patch:{templateCategoryFilter:`all`,templatePickerOpen:!0}})},[]),ae=async(e,t)=>{try{await Pe(e.id,t),T?.id===e.id&&_({type:`patch`,patch:{detailJob:{...T,enabled:t}}}),await Promise.all([P.loadJobs(),P.loadAux()])}catch(e){F(e instanceof Error?e.message:n.failedToToggleJob)}},oe=async()=>{let e=H.current,t=V.current;if(!(!e||!t)){W();try{if(t===`run`){let t=await Le(e);T?.id===e&&_({type:`patch`,patch:{detailJob:t.job??await Ie(e),detailHistory:t.history??await Ae(e,20),detailActionNotice:{kind:`info`,message:n.runStarted}}})}else await Be(e),T?.id===e&&_({type:`patch`,patch:{detailOpen:!1,detailJob:null}});await Promise.all([P.loadJobs(),P.loadAux(),P.loadRunHistoryOnly()])}catch(r){let i=r instanceof Error?r.message:n.actionFailed;if(t===`run`&&T?.id===e){let t=await Ie(e).catch(()=>null),a=await Ae(e,20).catch(()=>E),o=r instanceof Ue&&r.code===`job_already_running`?r.runningSessionKey||t?.state?.runningSessionKey||a.find(e=>e.status===`running`)?.sessionKey:t?.state?.runningSessionKey||a.find(e=>e.status===`running`)?.sessionKey;_({type:`patch`,patch:{...t?{detailJob:t}:{},detailHistory:a,detailActionNotice:{kind:`error`,message:i.includes(`already running`)?n.jobAlreadyRunning:i,...o?{sessionKey:o}:{}}}})}else F(i)}}};(0,X.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(R.formOpen?R.closeForm():w&&_({type:`patch`,patch:{detailOpen:!1,detailJob:null}}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[R,w]);let se=(0,X.useMemo)(()=>({running:n.execStatusRunning,success:n.execStatusSuccess,failed:n.execStatusFailed,cancelled:n.execStatusCancelled}),[n.execStatusCancelled,n.execStatusFailed,n.execStatusRunning,n.execStatusSuccess]),ce=(0,X.useMemo)(()=>Rn(P.userCronJobs,b),[P.userCronJobs,b]),le=(0,X.useMemo)(()=>Rn(P.systemCronJobs,b),[P.systemCronJobs,b]),ue=(0,X.useMemo)(()=>zn(P.runHistory,x,S,C),[P.runHistory,x,S,C]),de=n.scheduleBadge;return l?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Hn,{hasToken:l,c:n,loading:P.loading,runHistoryLoading:P.runHistoryLoading,onRefresh:P.refreshAll,onOpenTemplatePicker:ie,onAddJob:()=>R.openForm()}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6 sm:px-8`,children:[P.error?(0,Q.jsx)(`div`,{className:`rounded-xl 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`,role:`alert`,children:P.error}):null,(0,Q.jsx)(pn,{c:n,mainTab:v,onMainTabChange:N,jobSort:b,onJobSortChange:e=>_({type:`patch`,patch:{jobSort:e}}),historyRange:x,onHistoryRangeChange:e=>_({type:`patch`,patch:{historyRange:e}}),historyJobFilter:S,onHistoryJobFilterChange:e=>_({type:`patch`,patch:{historyJobFilter:e}}),historyStatusFilter:C,onHistoryStatusFilterChange:e=>_({type:`patch`,patch:{historyStatusFilter:e}}),jobs:P.jobs}),v===`myTasks`?(0,Q.jsx)(kn,{c:n,localeTag:d,scheduleBadgeLabels:de,loading:P.loading,jobsCount:P.userCronJobs.length,sortedJobs:ce,templateCategoryFilter:j,onTemplateCategoryFilterChange:e=>_({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:K,keepAwake:I.keepAwake,wakeSupported:I.featureAvailable,onWakeUnsupportedClick:()=>F(n.wakeLockUnavailable),onKeepAwakeToggle:()=>I.setKeepAwake(e=>!e),absorbCardClickJobIdRef:G,scheduleAbsorbNextMenuCardClick:ee,onOpenDetail:e=>void ne(e),onToggle:(e,t)=>void ae(e,t),onEdit:e=>R.openForm(e),onAddJob:()=>R.openForm(),onRunNow:e=>U(`run`,e.id),onDelete:e=>U(`delete`,e.id)}):v===`systemTasks`?(0,Q.jsx)(bn,{c:n,language:e,localeTag:d,scheduleBadgeLabels:de,loading:P.loading,sortedSystemJobs:le,heartbeat:P.heartbeatFromConfig,keepAwake:I.keepAwake,wakeSupported:I.featureAvailable,onWakeUnsupportedClick:()=>F(n.wakeLockUnavailable),onKeepAwakeToggle:()=>I.setKeepAwake(e=>!e),absorbCardClickJobIdRef:G,scheduleAbsorbNextMenuCardClick:ee,onOpenDetail:e=>void ne(e),onToggle:(e,t)=>void ae(e,t),onEdit:e=>R.openForm(e),onRunNow:e=>U(`run`,e.id),onDelete:e=>U(`delete`,e.id)}):v===`history`?(0,Q.jsx)(gn,{c:n,runHistoryLoading:P.runHistoryLoading,runHistory:P.runHistory,filteredRunHistory:ue,jobs:P.jobs,onRefreshHistory:()=>void P.loadRunHistoryOnly(),onOpenJobDetail:e=>void ne(e),statusLabels:se}):(0,Q.jsx)(ht,{hasToken:l})]}),(0,Q.jsx)(on,{open:R.formOpen,onRequestClose:R.closeForm,c:n,chatM:r,agentsMessages:t.agentsSettings,isDark:u,channels:P.channels,sessionChatIds:R.sessionChatIds,cronAgentSelectOptions:R.cronAgentSelectOptions,defaultModelResolver:L,formMode:R.formMode,formJobId:R.formJobId,formName:R.formName,onFormNameChange:R.setFormName,formSchedule:R.formSchedule,onFormScheduleChange:R.setFormSchedule,formSubmitting:R.formSubmitting,formTaskKind:R.formTaskKind,onFormTaskKindChange:R.setFormTaskKind,workflowDefinitions:B,workflowDefinitionsLoading:z.isLoading,formWorkflowDefinitionId:R.formWorkflowDefinitionId,onFormWorkflowDefinitionIdChange:R.setFormWorkflowDefinitionId,formWorkflowGoal:R.formWorkflowGoal,onFormWorkflowGoalChange:R.setFormWorkflowGoal,formWorkflowArgValues:R.formWorkflowArgValues,onFormWorkflowArgValuesChange:R.setFormWorkflowArgValues,formSessionTarget:R.formSessionTarget,onFormSessionTargetChange:R.handleFormSessionTargetChange,formAgentLocalOnly:R.formAgentLocalOnly,onFormAgentLocalOnlyChange:R.setFormAgentLocalOnly,formModel:R.formModel,onFormModelUserChange:R.handleFormModelUserChange,formAgentId:R.formAgentId,onFormAgentIdChange:R.setFormAgentId,formWorkingDirectory:R.formWorkingDirectory,onFormWorkingDirectoryChange:R.setFormWorkingDirectory,formChannel:R.formChannel,onFormChannelChange:R.handleFormChannelChange,formChatId:R.formChatId,onFormChatIdChange:R.setFormChatId,formMessage:R.formMessage,onFormMessageChange:R.setFormMessage,formMessageMdMode:R.formMessageMdMode,onSetMessageMdMode:R.setMessageMdMode,messageEditorNonce:R.messageEditorNonce,needsDeliveryChat:R.needsDeliveryChat,showChannelPicker:R.showChannelPicker,canSubmit:R.canSubmit,onSubmit:()=>void te(),onRefreshRecipients:R.refreshRecipientsList}),(0,Q.jsx)(An,{open:A,onOpenChange:e=>{_({type:`patch`,patch:{templatePickerOpen:e,...e?{templateCategoryFilter:`all`}:{}}})},c:n,localeTag:d,scheduleBadgeLabels:de,categoryFilter:j,onCategoryFilterChange:e=>_({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:K}),(0,Q.jsx)(Lt,{open:w,onDismiss:q,detailJob:T,detailLoading:D,actionNotice:O,detailHistory:E,c:n,localeTag:d,scheduleBadgeLabels:de,chatWorkingDirNotSet:r.workingDirectory.notSet,statusLabels:se,onEdit:e=>{R.openForm(e),window.requestAnimationFrame(()=>q())},onRunNow:e=>U(`run`,e.id),onToggle:(e,t)=>void ae(e,t),onDelete:e=>U(`delete`,e.id)}),(0,Q.jsx)(st,{open:k,onOpenChange:e=>_({type:`patch`,patch:{confirmOpen:e}}),action:V.current,c:n,onDismiss:W,onConfirm:oe})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Hn,{hasToken:l,c:n,loading:P.loading,runHistoryLoading:P.runHistoryLoading,onRefresh:P.refreshAll,onOpenTemplatePicker:ie,onAddJob:()=>R.openForm()}),(0,Q.jsx)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-16 text-center text-sm text-fg-muted sm:px-8`,children:n.needToken})]})}function Hn(e){let t=(0,Z.c)(14),{hasToken:n,c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}=e,l=ee(Wn),u=ee(Un),d;t[0]!==r||t[1]!==i||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==a?(d=(0,Q.jsx)(hn,{c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}),t[0]=r,t[1]=i,t[2]=c,t[3]=s,t[4]=o,t[5]=a,t[6]=d):d=t[6];let f=d,p,m;return t[7]!==r.title||t[8]!==u||t[9]!==f||t[10]!==n||t[11]!==l?(p=()=>n?(l({startExtra:null,main:(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r.title})}),end:f}),()=>u()):(u(),()=>u()),m=[r.title,u,f,n,l],t[7]=r.title,t[8]=u,t[9]=f,t[10]=n,t[11]=l,t[12]=p,t[13]=m):(p=t[12],m=t[13]),(0,X.useLayoutEffect)(p,m),null}function Un(e){return e.clearPageHeader}function Wn(e){return e.setPageHeader}export{Vn as CronPage};
|