@xopcai/xopc 0.0.94 → 0.0.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/feishu/src/workflow-progress.js +1 -1
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/src/routing-integration.js +2 -2
- package/dist/extensions/telegram/src/workflow-progress.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/api/api.js +2 -2
- package/dist/extensions/weixin/src/auth/accounts.js +1 -1
- package/dist/extensions/weixin/src/cdn/upload.js +1 -1
- package/dist/extensions/weixin/src/media/data-url.js +1 -1
- package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
- package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
- package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
- package/dist/extensions/weixin/src/plugin.js +1 -1
- package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
- package/dist/extensions/weixin/src/workflow-progress.js +1 -1
- package/dist/gateway/static/root/assets/{agents-OqhbJkMf.js → agents-DmIuSaOE.js} +3 -3
- package/dist/gateway/static/root/assets/{apps-page-OHXW9XP8.js → apps-page-DFcHBxLw.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-4N2R-jof.js → channels-settings-DDUf55C5.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-status-swr-Bv6f9kDq.js → channels-status-swr-BxF-_nzD.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-api-BtaQaHJq.js → cron-api-DylQtnb_.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-page-Dah32HJK.js → cron-page-BO0d9Pf-.js} +1 -1
- package/dist/gateway/static/root/assets/{dist-BJfD9Qvs.js → dist-BskF0qDS.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DnYuMzmH.js → extension-debug-page-BcZdTdjJ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CJfc-6XV.js → extension-page-D2iuDa1D.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BxdfYQMG.js → extension-settings-page-BKpQCgLc.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-B0aeeY0q.js → fetch-CtNDpjij.js} +1 -1
- package/dist/gateway/static/root/assets/{field-primitives-DOLHwowi.js → field-primitives-2PekrGZF.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-config-api-Bj2INAf5.js → heartbeat-config-api-D3D7SW8A.js} +1 -1
- package/dist/gateway/static/root/assets/index-BvEhL9RQ.css +1 -0
- package/dist/gateway/static/root/assets/{index-DuQ1XPoA.js → index-Db9fd_X4.js} +74 -74
- package/dist/gateway/static/root/assets/{logs-page-AsOgLNJE.js → logs-page-B3I1a26m.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-page-24J4mVP-.js → note-detail-page-BOizhtJ8.js} +54 -53
- package/dist/gateway/static/root/assets/{note-detail-page-B91pLkEI.css → note-detail-page-D4ZIVQbk.css} +1 -1
- package/dist/gateway/static/root/assets/{note-time-JBszYV3s.js → note-time-CjUGtqKr.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-BB8-I0Of.js +1 -0
- package/dist/gateway/static/root/assets/{sessions-page-DX9huWsA.js → sessions-page-BcH-1K9i.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-advanced-gate-DWvhsTuz.js → settings-advanced-gate-Czn8nnjN.js} +2 -2
- package/dist/gateway/static/root/assets/{settings-form-section-CxMjaMiy.js → settings-form-section-ZZWDwgVe.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-BX8c_zrN.js +3 -0
- package/dist/gateway/static/root/assets/share-preview-page-Ch3_6Qah.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page-CGKGKfwe.js → skills-page-WO0bbJ54.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-Cg_SuBw0.js → theme-store-XxRFRZDX.js} +1 -1
- package/dist/gateway/static/root/assets/url-6zpynn1R.js +3 -0
- package/dist/gateway/static/root/assets/{utils-BmlcxR2j.js → utils-uTYKh54l.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DaGm2N4J.js → voice-api-key-field-BIAYHRs-.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-page.utils-D0vsIGHD.js → workflow-page.utils-BbWhqD36.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-BFCrD3nw.js → workflows-page-D4RIF7E1.js} +2 -2
- package/dist/gateway/static/root/index.html +5 -5
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +15 -9
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/agent-scope.d.ts +0 -1
- package/dist/src/agent/agent-scope.js +2 -5
- package/dist/src/agent/agent-scope.js.map +1 -1
- package/dist/src/agent/bootstrap/bootstrap-cache.d.ts +3 -0
- package/dist/src/agent/bootstrap/bootstrap-cache.js +13 -3
- package/dist/src/agent/bootstrap/bootstrap-cache.js.map +1 -1
- package/dist/src/agent/bootstrap/bootstrap-files.d.ts +6 -0
- package/dist/src/agent/bootstrap/bootstrap-files.js +35 -12
- package/dist/src/agent/bootstrap/bootstrap-files.js.map +1 -1
- package/dist/src/agent/bootstrap/load-bootstrap-files.d.ts +5 -2
- package/dist/src/agent/bootstrap/load-bootstrap-files.js +12 -3
- package/dist/src/agent/bootstrap/load-bootstrap-files.js.map +1 -1
- package/dist/src/agent/context/workspace-seed.js +8 -4
- package/dist/src/agent/context/workspace-seed.js.map +1 -1
- package/dist/src/agent/context/workspace-state.d.ts +52 -0
- package/dist/src/agent/context/workspace-state.js +101 -0
- package/dist/src/agent/context/workspace-state.js.map +1 -0
- package/dist/src/agent/embedded/index.d.ts +2 -2
- package/dist/src/agent/embedded/index.js +3 -3
- package/dist/src/agent/embedded/run-turn.js +0 -3
- package/dist/src/agent/embedded/run-turn.js.map +1 -1
- package/dist/src/agent/embedded/session-manager-init.d.ts +0 -17
- package/dist/src/agent/embedded/session-manager-init.js +1 -36
- package/dist/src/agent/embedded/session-manager-init.js.map +1 -1
- package/dist/src/agent/embedded/session-runner.d.ts +3 -12
- package/dist/src/agent/embedded/session-runner.js +12 -26
- package/dist/src/agent/embedded/session-runner.js.map +1 -1
- package/dist/src/agent/embedded/session-tool-result-guard.js +2 -4
- package/dist/src/agent/embedded/session-tool-result-guard.js.map +1 -1
- package/dist/src/agent/embedded/sqlite-hydrating-session-manager.d.ts +10 -0
- package/dist/src/agent/embedded/sqlite-hydrating-session-manager.js +34 -0
- package/dist/src/agent/embedded/sqlite-hydrating-session-manager.js.map +1 -0
- package/dist/src/agent/goals/goal-run-store.js +4 -4
- package/dist/src/agent/goals/persistent-goal-service.js +8 -15
- package/dist/src/agent/goals/persistent-goal-service.js.map +1 -1
- package/dist/src/agent/goals/post-turn.js +2 -2
- package/dist/src/agent/image/load-image-media.js +2 -2
- package/dist/src/agent/ipc/bus.js +1 -1
- package/dist/src/agent/ipc/inbox.js +2 -2
- package/dist/src/agent/ipc/socket.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-materialize.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +2 -2
- package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
- package/dist/src/agent/mcp/mcp-transport.js +1 -1
- package/dist/src/agent/memory/builtin-memory-store.js +1 -1
- package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
- package/dist/src/agent/memory/dreaming/events.js +1 -1
- package/dist/src/agent/memory/dreaming/last-run.js +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
- package/dist/src/agent/memory/dreaming/preview.js +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
- package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
- package/dist/src/agent/memory/dreaming/utils.js +1 -1
- package/dist/src/agent/memory/plugin-discovery.js +1 -1
- package/dist/src/agent/models/manager.js +1 -1
- package/dist/src/agent/prompt/memory/index.d.ts +1 -0
- package/dist/src/agent/prompt/memory/index.js +34 -80
- package/dist/src/agent/prompt/memory/index.js.map +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
- package/dist/src/agent/reply/post-compaction-context.js +1 -1
- package/dist/src/agent/reply/workspace-boundary-read.js +1 -1
- package/dist/src/agent/sandbox/path-policy.js +2 -2
- package/dist/src/agent/service/build-direct-message-content.js +1 -1
- package/dist/src/agent/service/process-direct-one-shot.js +8 -17
- package/dist/src/agent/service/process-direct-one-shot.js.map +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +14 -23
- package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
- package/dist/src/agent/service.js +7 -11
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/config.js +1 -1
- package/dist/src/agent/skills/hub-hash.js +2 -2
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +3 -3
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/scanner.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/skills/skill-manager.js +1 -1
- package/dist/src/agent/tools/dreaming-tool.js +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +1 -1
- package/dist/src/agent/tools/index.d.ts +0 -1
- package/dist/src/agent/tools/index.js +1 -2
- package/dist/src/agent/tools/send-media.js +1 -1
- package/dist/src/agent/tools/session-search-tool.d.ts +0 -1
- package/dist/src/agent/tools/session-search-tool.js +11 -6
- package/dist/src/agent/tools/session-search-tool.js.map +1 -1
- package/dist/src/agent/tools/skill-manage-tool.js +1 -1
- package/dist/src/agent/tools/workflow-tool.js +1 -1
- package/dist/src/agent/tools/write.js +1 -1
- package/dist/src/agent/workflow/catalog.js +1 -1
- package/dist/src/auth/credentials.js +3 -3
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/browser/cache-dir-policy.js +1 -1
- package/dist/src/browser/cdp-local-launcher.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +4 -4
- package/dist/src/browser/providers/cloakbrowser.js +4 -4
- package/dist/src/browser/providers/playwright-doctor.js +1 -1
- package/dist/src/browser/stealth.js +1 -1
- package/dist/src/channels/attachments/inbound-persist.js +1 -1
- package/dist/src/channels/attachments/outbound-tts-persist.js +1 -1
- package/dist/src/channels/outbound/persist-store.js +1 -1
- package/dist/src/channels/pairing/allow-from-file.js +1 -1
- package/dist/src/channels/pairing/pairing-store.js +2 -2
- package/dist/src/chat-commands/agent-edit.js +2 -2
- package/dist/src/chat-commands/builtins/config.js +2 -2
- package/dist/src/chat-commands/context.js +1 -1
- package/dist/src/cli/commands/config.js +1 -1
- package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/doctor/checks/session-integrity.js +32 -95
- package/dist/src/cli/commands/doctor/checks/session-integrity.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
- package/dist/src/cli/commands/doctor/checks/workspace-status.js +1 -1
- package/dist/src/cli/commands/extension-dev.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/extension-pack.js +1 -1
- package/dist/src/cli/commands/gateway/logs.js +1 -1
- package/dist/src/cli/commands/image.js +1 -1
- package/dist/src/cli/commands/init.js +5 -7
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +2 -2
- package/dist/src/commands/agents.config.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/gateway-bind.js +1 -1
- package/dist/src/config/index.js +7 -8
- package/dist/src/config/index.js.map +1 -1
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +2 -2
- package/dist/src/config/paths-state.d.ts +3 -0
- package/dist/src/config/paths-state.js +7 -3
- package/dist/src/config/paths-state.js.map +1 -1
- package/dist/src/config/paths.d.ts +5 -35
- package/dist/src/config/paths.js +6 -50
- package/dist/src/config/paths.js.map +1 -1
- package/dist/src/config/profile.js +2 -2
- package/dist/src/config/schema.d.ts +15 -0
- package/dist/src/config/schema.js +11 -0
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/config/workspace-path.js +1 -1
- package/dist/src/cron/execution-types.d.ts +42 -0
- package/dist/src/cron/executor.js +2 -2
- package/dist/src/cron/persistence.js +1 -1
- package/dist/src/cron/run-log-store.d.ts +4 -8
- package/dist/src/cron/run-log-store.js +26 -78
- package/dist/src/cron/run-log-store.js.map +1 -1
- package/dist/src/cron/service.d.ts +3 -3
- package/dist/src/cron/service.js +2 -2
- package/dist/src/cron/service.js.map +1 -1
- package/dist/src/cron/types.d.ts +1 -42
- package/dist/src/daemon/constants.js +1 -1
- package/dist/src/daemon/install-plan.js +2 -2
- package/dist/src/daemon/launchd.js +2 -2
- package/dist/src/daemon/schtasks.js +2 -2
- package/dist/src/daemon/systemd.js +2 -2
- package/dist/src/extensions/bundle-mcp.js +1 -1
- package/dist/src/extensions/discover-extensions.js +1 -1
- package/dist/src/extensions/health.js +1 -1
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/extensions/lockfile.js +2 -2
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agents-admin.js +8 -3
- package/dist/src/gateway/agents-admin.js.map +1 -1
- package/dist/src/gateway/file-path-classifier.d.ts +0 -1
- package/dist/src/gateway/file-path-classifier.js +2 -8
- package/dist/src/gateway/file-path-classifier.js.map +1 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/lib/extension-store.js +2 -2
- package/dist/src/gateway/hono/lib/static-ui.js +2 -2
- package/dist/src/gateway/hono/oauth.js +1 -1
- package/dist/src/gateway/hono/routes/agents.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/dreaming.js +1 -1
- package/dist/src/gateway/hono/routes/host-fs.js +2 -2
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/shares.js +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +2 -2
- package/dist/src/gateway/lock.js +3 -3
- package/dist/src/gateway/ports.js +1 -1
- package/dist/src/gateway/service/agent-runner.js +2 -2
- package/dist/src/gateway/service/marketplace-service.js +2 -2
- package/dist/src/gateway/service.js +5 -1
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/gateway/session-reset-service.d.ts +1 -1
- package/dist/src/gateway/session-reset-service.js +1 -1
- package/dist/src/gateway/session-reset-service.js.map +1 -1
- package/dist/src/gateway/workspace-fs-file-list.js +1 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/infra/brew.js +1 -1
- package/dist/src/infra/node-sqlite.d.ts +1 -0
- package/dist/src/infra/node-sqlite.js +17 -0
- package/dist/src/infra/node-sqlite.js.map +1 -0
- package/dist/src/infra/package-json.js +1 -1
- package/dist/src/infra/package-update-steps.js +1 -1
- package/dist/src/infra/path-env.js +2 -2
- package/dist/src/infra/restart.js +2 -2
- package/dist/src/infra/sqlite-errors.d.ts +1 -0
- package/dist/src/infra/sqlite-errors.js +77 -0
- package/dist/src/infra/sqlite-errors.js.map +1 -0
- package/dist/src/infra/stable-node-path.js +1 -1
- package/dist/src/infra/unhandled-rejections.d.ts +1 -0
- package/dist/src/infra/unhandled-rejections.js +25 -0
- package/dist/src/infra/unhandled-rejections.js.map +1 -0
- package/dist/src/infra/update-check.js +1 -1
- package/dist/src/infra/update-global.js +1 -1
- package/dist/src/infra/update-lock.js +3 -3
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/infra/update-startup.js +2 -2
- package/dist/src/infra/warning-filter.d.ts +7 -0
- package/dist/src/infra/warning-filter.js +59 -0
- package/dist/src/infra/warning-filter.js.map +1 -0
- package/dist/src/infra/write-file-atomic.js +2 -2
- package/dist/src/notes/store.d.ts +3 -9
- package/dist/src/notes/store.js +22 -196
- package/dist/src/notes/store.js.map +1 -1
- package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/session/config-store.d.ts +6 -75
- package/dist/src/session/config-store.js +38 -144
- package/dist/src/session/config-store.js.map +1 -1
- package/dist/src/session/config-types.d.ts +15 -0
- package/dist/src/session/config-types.js +1 -0
- package/dist/src/session/index.d.ts +1 -3
- package/dist/src/session/index.js +3 -5
- package/dist/src/session/init-session-turn.d.ts +0 -6
- package/dist/src/session/init-session-turn.js +18 -18
- package/dist/src/session/init-session-turn.js.map +1 -1
- package/dist/src/session/lifecycle-timestamps.d.ts +5 -2
- package/dist/src/session/lifecycle-timestamps.js.map +1 -1
- package/dist/src/session/{parity/load-jsonl-entries.js → load-jsonl-entries.js} +1 -1
- package/dist/src/session/load-jsonl-entries.js.map +1 -0
- package/dist/src/session/manager.d.ts +5 -3
- package/dist/src/session/manager.js +1 -5
- package/dist/src/session/manager.js.map +1 -1
- package/dist/src/session/resolve-session.d.ts +3 -6
- package/dist/src/session/resolve-session.js +26 -31
- package/dist/src/session/resolve-session.js.map +1 -1
- package/dist/src/session/session-context-for-llm.js +5 -1
- package/dist/src/session/session-context-for-llm.js.map +1 -1
- package/dist/src/session/session-id.js +12 -0
- package/dist/src/session/session-id.js.map +1 -0
- package/dist/src/session/session-title.js +2 -2
- package/dist/src/session/session-workspace.d.ts +1 -1
- package/dist/src/session/session-workspace.js.map +1 -1
- package/dist/src/session/store.d.ts +14 -63
- package/dist/src/session/store.js +172 -847
- package/dist/src/session/store.js.map +1 -1
- package/dist/src/session/stored-rows-to-file-entries.d.ts +11 -0
- package/dist/src/session/stored-rows-to-file-entries.js +95 -0
- package/dist/src/session/stored-rows-to-file-entries.js.map +1 -0
- package/dist/src/session/transcript-events.d.ts +1 -2
- package/dist/src/session/transcript-events.js +5 -12
- package/dist/src/session/transcript-events.js.map +1 -1
- package/dist/src/session/transcript-format.d.ts +1 -1
- package/dist/src/session/transcript-format.js.map +1 -1
- package/dist/src/session/transcript-stats.d.ts +1 -0
- package/dist/src/session/transcript-stats.js +10 -0
- package/dist/src/session/transcript-stats.js.map +1 -0
- package/dist/src/share/share-auto.js +2 -2
- package/dist/src/share/share-store.js +3 -3
- package/dist/src/share/share-thumbnail.js +2 -2
- package/dist/src/share/share-zip.js +1 -1
- package/dist/src/share/site-share-store.js +3 -3
- package/dist/src/share/site-static-serve.js +1 -1
- package/dist/src/storage/sqlite/config-repository.d.ts +6 -0
- package/dist/src/storage/sqlite/config-repository.js +56 -0
- package/dist/src/storage/sqlite/config-repository.js.map +1 -0
- package/dist/src/storage/sqlite/connection.d.ts +38 -0
- package/dist/src/storage/sqlite/connection.js +258 -0
- package/dist/src/storage/sqlite/connection.js.map +1 -0
- package/dist/src/storage/sqlite/cron-run-repository.d.ts +5 -0
- package/dist/src/storage/sqlite/cron-run-repository.js +97 -0
- package/dist/src/storage/sqlite/cron-run-repository.js.map +1 -0
- package/dist/src/storage/sqlite/fts.d.ts +2 -0
- package/dist/src/storage/sqlite/fts.js +11 -0
- package/dist/src/storage/sqlite/fts.js.map +1 -0
- package/dist/src/storage/sqlite/index.d.ts +12 -0
- package/dist/src/storage/sqlite/index.js +13 -0
- package/dist/src/storage/sqlite/memory-index-repository.d.ts +18 -0
- package/dist/src/storage/sqlite/memory-index-repository.js +132 -0
- package/dist/src/storage/sqlite/memory-index-repository.js.map +1 -0
- package/dist/src/storage/sqlite/notes-repository.d.ts +11 -0
- package/dist/src/storage/sqlite/notes-repository.js +191 -0
- package/dist/src/storage/sqlite/notes-repository.js.map +1 -0
- package/dist/src/storage/sqlite/paths.d.ts +1 -0
- package/dist/src/storage/sqlite/paths.js +7 -0
- package/dist/src/storage/sqlite/paths.js.map +1 -0
- package/dist/src/storage/sqlite/row-mappers.d.ts +82 -0
- package/dist/src/storage/sqlite/row-mappers.js +164 -0
- package/dist/src/storage/sqlite/row-mappers.js.map +1 -0
- package/dist/src/storage/sqlite/schema.d.ts +5 -0
- package/dist/src/storage/sqlite/schema.js +43 -0
- package/dist/src/storage/sqlite/schema.js.map +1 -0
- package/dist/src/storage/sqlite/schema.sql +195 -0
- package/dist/src/storage/sqlite/session-metadata.d.ts +8 -0
- package/dist/src/storage/sqlite/session-metadata.js +83 -0
- package/dist/src/storage/sqlite/session-metadata.js.map +1 -0
- package/dist/src/storage/sqlite/session-repository.d.ts +29 -0
- package/dist/src/storage/sqlite/session-repository.js +268 -0
- package/dist/src/storage/sqlite/session-repository.js.map +1 -0
- package/dist/src/storage/sqlite/transaction.d.ts +11 -0
- package/dist/src/storage/sqlite/transaction.js +115 -0
- package/dist/src/storage/sqlite/transaction.js.map +1 -0
- package/dist/src/storage/sqlite/transcript-repository.d.ts +34 -0
- package/dist/src/storage/sqlite/transcript-repository.js +241 -0
- package/dist/src/storage/sqlite/transcript-repository.js.map +1 -0
- package/dist/src/tui/clipboard-image.js +3 -3
- package/dist/src/tui/theme-manager.js +1 -1
- package/dist/src/tui/tui-keybindings-file.js +1 -1
- package/dist/src/tui/tui-scoped-models.js +2 -2
- package/dist/src/tui/tui-settings.js +1 -1
- package/dist/src/tui/tui.js +3 -3
- package/dist/src/tunnel/frpc-binary.js +3 -3
- package/dist/src/tunnel/frpc-config.js +1 -1
- package/dist/src/tunnel/frpc-extract.js +1 -1
- package/dist/src/tunnel/tunnel-state.js +1 -1
- package/dist/src/utils/logger/audit.js +1 -1
- package/dist/src/utils/logger/log-store.js +1 -1
- package/dist/src/utils/logger/rotation.js +1 -1
- package/dist/src/voice/tts/audio.js +1 -1
- package/dist/src/voice/tts/providers/edge-speech.js +2 -2
- package/dist/src/workflows/service/workflow-session-bridge.js +41 -64
- package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
- package/dist/src/workflows/store/event-store.js +1 -1
- package/dist/src/workflows/store/run-store.js +1 -1
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/index-Bj_l8QDp.css +0 -1
- package/dist/gateway/static/root/assets/notes-page-BApAirFB.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-4VmUTzQs.js +0 -3
- package/dist/gateway/static/root/assets/share-preview-page-IX0TJvRd.js +0 -2
- package/dist/gateway/static/root/assets/url-BHHmdJYc.js +0 -3
- package/dist/src/agent/embedded/session-manager-cache.d.ts +0 -19
- package/dist/src/agent/embedded/session-manager-cache.js +0 -48
- package/dist/src/agent/embedded/session-manager-cache.js.map +0 -1
- package/dist/src/session/parity/artifacts.d.ts +0 -16
- package/dist/src/session/parity/artifacts.js +0 -80
- package/dist/src/session/parity/artifacts.js.map +0 -1
- package/dist/src/session/parity/jsonl-transcript-io.d.ts +0 -54
- package/dist/src/session/parity/jsonl-transcript-io.js +0 -236
- package/dist/src/session/parity/jsonl-transcript-io.js.map +0 -1
- package/dist/src/session/parity/load-jsonl-entries.js.map +0 -1
- package/dist/src/session/parity/session-id.js +0 -18
- package/dist/src/session/parity/session-id.js.map +0 -1
- package/dist/src/session/parity/sessions-json-cache.d.ts +0 -14
- package/dist/src/session/parity/sessions-json-cache.js +0 -98
- package/dist/src/session/parity/sessions-json-cache.js.map +0 -1
- package/dist/src/session/parity/sessions-json-file-read.d.ts +0 -6
- package/dist/src/session/parity/sessions-json-file-read.js +0 -19
- package/dist/src/session/parity/sessions-json-file-read.js.map +0 -1
- package/dist/src/session/parity/sessions-json-file.d.ts +0 -11
- package/dist/src/session/parity/sessions-json-file.js +0 -52
- package/dist/src/session/parity/sessions-json-file.js.map +0 -1
- package/dist/src/session/parity/sessions-json-patch.d.ts +0 -14
- package/dist/src/session/parity/sessions-json-patch.js +0 -40
- package/dist/src/session/parity/sessions-json-patch.js.map +0 -1
- package/dist/src/session/parity/transcript-file-lock.d.ts +0 -22
- package/dist/src/session/parity/transcript-file-lock.js +0 -142
- package/dist/src/session/parity/transcript-file-lock.js.map +0 -1
- package/dist/src/session/parity/transcript-pagination.d.ts +0 -29
- package/dist/src/session/parity/transcript-pagination.js +0 -132
- package/dist/src/session/parity/transcript-pagination.js.map +0 -1
- package/dist/src/session/parity/transcript-paths.d.ts +0 -13
- package/dist/src/session/parity/transcript-paths.js +0 -64
- package/dist/src/session/parity/transcript-paths.js.map +0 -1
- package/dist/src/session/parity/xopc-session-disk-entry.d.ts +0 -22
- package/dist/src/session/search-index-cache.d.ts +0 -6
- package/dist/src/session/search-index-cache.js +0 -44
- package/dist/src/session/search-index-cache.js.map +0 -1
- package/dist/src/session/search-index.d.ts +0 -20
- package/dist/src/session/search-index.js +0 -124
- package/dist/src/session/search-index.js.map +0 -1
- /package/dist/src/{session/parity/xopc-session-disk-entry.js → cron/execution-types.js} +0 -0
- /package/dist/src/session/{parity/load-jsonl-entries.d.ts → load-jsonl-entries.d.ts} +0 -0
- /package/dist/src/session/{parity/session-id.d.ts → session-id.d.ts} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./url-6zpynn1R.js";import{a as u,i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{t as p}from"./circle-check-C23XjkUj.js";import{t as m}from"./copy-Dv6d4Dvw.js";import{i as h}from"./theme-store-XxRFRZDX.js";import{a as g,n as _,t as v}from"./fetch-CtNDpjij.js";import{r as y}from"./toast-z0toXu32.js";import{$ as b,$a as x,$i as S,$o as C,$r as w,Ai as T,An as E,Ao as D,Ar as O,Bi as k,Bo as A,Br as j,Ca as M,Ci as N,Cn as P,Cr as F,Da as I,Dn as L,Dr as R,Ea as z,En as B,Er as V,Fo as H,G as U,Ga as W,H as G,Ha as ee,Hi as K,I as q,J as te,Jo as ne,Jr as re,K as ie,Ki as ae,Kr as oe,M as se,Mn as ce,Mo as le,Mr as ue,N as de,No as fe,Nr as pe,Nt as me,Oa as J,Oi as he,On as ge,Oo as _e,Or as ve,Q as ye,Qi as be,Qo as xe,Qr as Se,Qt as Ce,Ri as we,Rn as Te,Sa as Ee,Sn as De,So as Oe,Sr as ke,Tn as Ae,Tr as je,U as Me,Ui as Ne,V as Pe,W as Fe,Wa as Ie,Wr as Le,X as Re,Xr as ze,Y as Be,Ya as Ve,Yi as He,Yo as Ue,Yr as We,Z as Ge,Zr as Ke,_n as qe,ai as Je,an as Ye,ao as Xe,bn as Ze,bo as Qe,ca as $e,ci as et,cn as tt,di as Y,dn as nt,dr as rt,ea as it,ei as at,et as ot,fn as st,ga as ct,gi as lt,gn as ut,ha as dt,hn as ft,ii as pt,in as mt,io as ht,j as gt,jn as _t,jr as vt,k as yt,ki as bt,kn as xt,ko as St,kr as Ct,la as wt,li as Tt,ln as Et,lo as Dt,mi as Ot,mn as kt,na as At,ni as jt,oa as Mt,oi as Nt,on as Pt,pa as Ft,pi as It,pn as Lt,q as Rt,qi as zt,qo as Bt,qr as Vt,qt as Ht,sa as Ut,si as Wt,sn as Gt,ti as Kt,tt as qt,ua as Jt,ui as X,un as Yt,ur as Xt,va as Zt,vn as Qt,vr as $t,wi as en,wn as tn,wr as nn,x as rn,xn as an,ya as on,yn as sn,yo as cn,zi as ln}from"./index-Db9fd_X4.js";import{a as un,c as dn,d as fn,l as pn,n as mn,o as hn,r as gn,s as _n,t as vn,u as yn}from"./voice-api-key-field-BIAYHRs-.js";import{a as bn,i as xn,r as Sn}from"./utils-uTYKh54l.js";import{n as Cn,r as wn,t as Tn}from"./settings-form-section-ZZWDwgVe.js";import{i as En,l as Dn,p as On,t as kn}from"./settings-advanced-gate-Czn8nnjN.js";import{l as An}from"./cron-api-DylQtnb_.js";import{a as jn,c as Mn,d as Nn,f as Pn,h as Fn,i as In,l as Ln,m as Rn,n as zn,o as Bn,p as Vn,r as Hn,s as Un,t as Wn,u as Gn}from"./agents-DmIuSaOE.js";import{m as Kn,n as qn,r as Jn,t as Yn}from"./channels-status-swr-BxF-_nzD.js";import{a as Xn,i as Zn,n as Qn,o as $n,r as er,s as tr,t as nr}from"./heartbeat-config-api-D3D7SW8A.js";var Z=e(t(),1),Q=n(),rr=[{id:`lightChat`,steps:[{path:`/settings/credentials?tab=providers`,labelKey:`stepProviders`},{path:`/settings/agent-defaults`,labelKey:`stepDefaultModel`}]},{id:`multiChannel`,steps:[{path:`/settings/credentials?tab=providers`,labelKey:`stepProviders`},{path:`/settings/agent-defaults`,labelKey:`stepDefaultModel`},{path:`/channels`,labelKey:`stepChannel`},{path:`/agents`,labelKey:`stepPresets`}]},{id:`automation`,steps:[{path:`/settings/credentials?tab=providers`,labelKey:`stepProviders`},{path:`/skills`,labelKey:`stepSkills`},{path:`/cron`,labelKey:`stepCron`}]}],ir=`xopc-scenario-presets-dismissed`;function ar(){try{return localStorage.getItem(ir)===`true`}catch{return!1}}function or(){try{localStorage.setItem(ir,`true`)}catch{}}var $=r();function sr(e,t){return t[e.labelKey]??e.labelKey}function cr(){let e=(0,Q.c)(5),t=s(a(lr)).setupStatus.scenarios,[n,r]=(0,Z.useState)(ar);if(n)return null;let i,o,c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=Y(`inline-flex shrink-0 items-center gap-1 rounded-lg px-2 py-1.5 text-xs font-medium text-fg-muted`,`hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,jt.press),o=()=>{or(),r(!0)},c=(0,$.jsx)(It,{className:`size-3.5`,"aria-hidden":!0}),e[0]=i,e[1]=o,e[2]=c):(i=e[0],o=e[1],c=e[2]);let l=rr.map(e=>{let n=t.presets[e.id];return(0,$.jsxs)(`article`,{className:`flex flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.description}),(0,$.jsx)(`ol`,{className:`mt-3 flex flex-col gap-1`,children:e.steps.map((n,r)=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(ne,{to:n.path,className:Y(`text-xs font-medium text-accent-fg hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent rounded`),children:[r+1,`. `,sr(n,t.steps)]})},`${e.id}-${n.labelKey}`))})]},e.id)}),u;return e[3]===l?u=e[4]:(u=(0,$.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:l}),e[3]=l,e[4]=u),(0,$.jsxs)(Tn,{children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsx)(Cn,{icon:we,title:t.title,subtitle:t.subtitle}),(0,$.jsxs)(`button`,{type:`button`,className:i,onClick:o,children:[c,t.dismiss]})]}),u]})}function lr(e){return e.language}function ur(e){if(!e||typeof e!=`object`)return 0;let t=e.providers;return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&at(e)).length}function dr(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults;if(!n||typeof n!=`object`||Array.isArray(n))return``;let r=n.model;return typeof r==`string`?r.trim():``}function fr(e){let t=Kn(e);return t.telegram.enabled&&xn(t.telegram)||t.weixin.enabled&&bn(t.weixin)||t.feishu.enabled&&Sn(t.feishu)||xn(t.telegram)||bn(t.weixin)||Sn(t.feishu)}function pr(e){let t=ur(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=dr(e.config),o=a.length>0,s=e.hasToken&&e.sseConnected,c=fr(e.config),l=e.skillCount>0,u=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing},{id:`presets`,done:e.presetsDone,optional:!0,detail:e.presetsDone?e.labels.presetsConfigured:e.labels.presetsMissing}],d=u.filter(e=>!e.optional).every(e=>e.done),f=u.every(e=>e.done);return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,presetsDone:e.presetsDone,agentCount:e.agentCount,checklist:u,requiredComplete:d,allComplete:f}}function mr(){try{return localStorage.getItem(Rn)===`true`}catch{return!1}}function hr(e,t){return mr()?!0:!e||e.length===0?!1:!(e.length<=1&&e.every(e=>e.id===t))}function gr(){let e=(0,Q.c)(50),t=g(br),n=a(yr),r;e[0]===n?r=e[1]:(r=s(n),e[0]=n,e[1]=r);let i=r.setupStatus.labels,o=qt(vr),{data:c,error:l,isLoading:u,mutate:f}=rt(!!t),p;e[2]!==n||e[3]!==t?(p=t?[`setup-checklist-skills`,n]:null,e[2]=n,e[3]=t,e[4]=p):p=e[4];let m;e[5]===n?m=e[6]:(m=()=>Ht(n),e[5]=n,e[6]=m);let h;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},e[7]=h):h=e[7];let{data:_,error:v,isLoading:y,mutate:x}=d(p,m,h),S;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!1},e[8]=S):S=e[8];let{data:C,error:w,isLoading:T,mutate:E}=d(t?`setup-checklist-provider-meta`:null,G,S),D;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(D={revalidateOnFocus:!1},e[9]=D):D=e[9];let{data:O,error:k,isLoading:A,mutate:j}=d(t?`setup-checklist-agents`:null,me,D),M;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(M={revalidateOnFocus:!1},e[10]=M):M=e[10],d(t?b:null,ot,M);let N=!t||!u&&!y&&!T&&!A,P=!!(l||v||w||k),F;bb0:{if(!t||!N){F=null;break bb0}let n=_?.catalog?.length??0,r;if(e[11]!==O?.agents||e[12]!==O?.defaultId||e[13]!==c?.payload?.config||e[14]!==i.channelConfigured||e[15]!==i.channelMissing||e[16]!==i.gatewayOffline||e[17]!==i.gatewayOnline||e[18]!==i.modelConfigured||e[19]!==i.modelMissing||e[20]!==i.presetsConfigured||e[21]!==i.presetsMissing||e[22]!==i.providersConfigured||e[23]!==i.providersMetaReady||e[24]!==i.providersMissing||e[25]!==i.skillsConfigured||e[26]!==i.skillsMissing||e[27]!==C||e[28]!==n||e[29]!==o||e[30]!==t){let a=C?.filter(_r).length??0,s=C?.length??0,l=O?.agents.length??0,u=hr(O?.agents,O?.defaultId),d;e[32]===i.providersConfigured?d=e[33]:(d=e=>i.providersConfigured.replace(`{{count}}`,String(e)),e[32]=i.providersConfigured,e[33]=d);let f;e[34]===i.providersMetaReady?f=e[35]:(f=(e,t)=>i.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[34]=i.providersMetaReady,e[35]=f);let p;e[36]===i.modelConfigured?p=e[37]:(p=e=>i.modelConfigured.replace(`{{model}}`,e),e[36]=i.modelConfigured,e[37]=p);let m;e[38]===i.skillsConfigured?m=e[39]:(m=e=>i.skillsConfigured.replace(`{{count}}`,String(e)),e[38]=i.skillsConfigured,e[39]=m),r=pr({hasToken:!!t,sseConnected:o,config:c?.payload?.config,skillCount:n,providerMeta:s>0?{configured:a,total:s}:null,presetsDone:u,agentCount:l,labels:{gatewayOnline:i.gatewayOnline,gatewayOffline:i.gatewayOffline,providersConfigured:d,providersMetaReady:f,providersMissing:i.providersMissing,modelConfigured:p,modelMissing:i.modelMissing,channelConfigured:i.channelConfigured,channelMissing:i.channelMissing,skillsConfigured:m,skillsMissing:i.skillsMissing,presetsConfigured:i.presetsConfigured.replace(`{{count}}`,String(l)),presetsMissing:i.presetsMissing}}),e[11]=O?.agents,e[12]=O?.defaultId,e[13]=c?.payload?.config,e[14]=i.channelConfigured,e[15]=i.channelMissing,e[16]=i.gatewayOffline,e[17]=i.gatewayOnline,e[18]=i.modelConfigured,e[19]=i.modelMissing,e[20]=i.presetsConfigured,e[21]=i.presetsMissing,e[22]=i.providersConfigured,e[23]=i.providersMetaReady,e[24]=i.providersMissing,e[25]=i.skillsConfigured,e[26]=i.skillsMissing,e[27]=C,e[28]=n,e[29]=o,e[30]=t,e[31]=r}else r=e[31];F=r}let I=F,L;e[40]!==j||e[41]!==f||e[42]!==E||e[43]!==x?(L=async()=>{await Promise.all([f(),x(),E(),j()])},e[40]=j,e[41]=f,e[42]=E,e[43]=x,e[44]=L):L=e[44];let R=L,z;return e[45]!==P||e[46]!==N||e[47]!==R||e[48]!==I?(z={ready:N,error:P,snapshot:I,refresh:R},e[45]=P,e[46]=N,e[47]=R,e[48]=I,e[49]=z):z=e[49],z}function _r(e){return e.configured}function vr(e){return e.connectionState===`connected`}function yr(e){return e.language}function br(e){return e.token}var xr={gateway:`/settings/gateway`,provider:`/settings/credentials`,defaultModel:`/settings/agent-defaults`,channel:`/channels`,skill:`/skills`,presets:`/agents`};function Sr(e){let t=(0,Q.c)(5),{ok:n,label:r}=e,i=n?`bg-success-soft text-success`:`bg-surface-hover text-fg-muted`,a;t[0]===i?a=t[1]:(a=Y(`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,$.jsx)(`span`,{className:a,children:r}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function Cr(){let e=(0,Q.c)(7),t=s(a(wr)).setupStatus,{ready:n,error:r,snapshot:i,refresh:o}=gr(),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(`inline-flex shrink-0 items-center gap-2 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`,jt.press),e[0]=c):c=e[0];let l;e[1]===o?l=e[2]:(l=()=>void o(),e[1]=o,e[2]=l);let u=!n&&`animate-spin`,d;e[3]===u?d=e[4]:(d=Y(`size-4`,u),e[3]=u,e[4]=d);let f;return e[5]===d?f=e[6]:(f=(0,$.jsx)(At,{className:d,"aria-hidden":!0}),e[5]=d,e[6]=f),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.subtitle})]}),(0,$.jsxs)(`button`,{type:`button`,className:c,onClick:l,disabled:!n,children:[f,t.refresh]})]}),r?(0,$.jsx)(`p`,{className:`rounded-xl border border-red-300/40 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:t.loadError}):null,!n||!i?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,"aria-busy":!0,children:[(0,$.jsx)(J,{className:`size-4 animate-spin`,"aria-hidden":!0}),t.loading]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Cn,{icon:fe,title:t.summaryTitle,subtitle:t.summarySubtitle}),(0,$.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.summaryGateway}),(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(Sr,{ok:i.gatewayConnected,label:i.gatewayConnected?t.statusOnline:t.statusOffline})})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.summaryProviders}),(0,$.jsx)(`p`,{className:`mt-2 truncate text-sm font-medium text-fg`,children:i.providerConfigured?i.providerMetaTotal>0?t.labels.providersMetaReady.replace(`{{configured}}`,String(i.providerMetaConfigured)).replace(`{{total}}`,String(i.providerMetaTotal)):t.labels.providersConfigured.replace(`{{count}}`,String(i.providerCount)):t.labels.providersMissing})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.summaryModel}),(0,$.jsx)(`p`,{className:`mt-2 truncate text-sm font-medium text-fg`,children:i.defaultModelConfigured?i.defaultModel:t.labels.modelMissing})]})]}),i.requiredComplete?(0,$.jsx)(`p`,{className:`mt-4 text-sm text-success`,children:t.requiredCompleteMessage}):(0,$.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.requiredIncompleteMessage})]}),(0,$.jsx)(cr,{}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Cn,{icon:Oe,title:t.checklistTitle,subtitle:t.checklistSubtitle}),(0,$.jsx)(`ul`,{className:`mt-4 flex flex-col gap-1`,children:i.checklist.map(e=>{let n=t.items[e.id];return(0,$.jsx)(`li`,{children:(0,$.jsxs)(ne,{to:xr[e.id],className:Y(`flex items-center gap-3 rounded-xl px-3 py-3 transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:Y(`flex size-6 shrink-0 items-center justify-center rounded-full border`,e.done?`border-success/40 bg-success-soft text-success`:`border-edge bg-surface-panel text-fg-subtle`),"aria-hidden":!0,children:e.done?(0,$.jsx)(fe,{className:`size-3.5`,strokeWidth:2.5}):null}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.title}),e.optional?(0,$.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:t.optionalBadge}):null]}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:n.description}),e.detail?(0,$.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:e.detail}):null]}),(0,$.jsx)(D,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]})},e.id)})})]})]})]})}function wr(e){return e.language}function Tr(e,t){let n=!1,r=0,i=t;for(let t of e.values())t.dirty&&(n=!0,r+=1),t.saving&&(i=!0);return{anyDirty:n,dirtyCount:r,anySaving:i}}var Er=i((e,t)=>({sections:new Map,saveAllInFlight:!1,anyDirty:!1,dirtyCount:0,anySaving:!1,registerSection:t=>{e(e=>{let n=new Map(e.sections);return n.set(t.id,t),{sections:n,...Tr(n,e.saveAllInFlight)}})},unregisterSection:t=>{e(e=>{if(!e.sections.has(t))return e;let n=new Map(e.sections);return n.delete(t),{sections:n,...Tr(n,e.saveAllInFlight)}})},saveAll:async()=>{let n=Array.from(t().sections.values()).filter(e=>e.dirty);if(n.length===0)return{ok:!0,saved:0,failures:[]};e(e=>({saveAllInFlight:!0,...Tr(e.sections,!0)}));let r=[],i=0;try{let e=await Promise.all(n.map(async e=>{try{let t=await e.save();return{id:e.id,result:t}}catch(t){return{id:e.id,result:{ok:!1,error:t instanceof Error?t.message:String(t)}}}}));for(let{id:t,result:n}of e)n.ok?i+=1:r.push({id:t,error:n.error??`Save failed`})}finally{e(e=>({saveAllInFlight:!1,...Tr(e.sections,!1)}))}return{ok:r.length===0,saved:i,failures:r}},discardAll:()=>{for(let e of t().sections.values())e.dirty&&e.discard()}}));function Dr({id:e,dirty:t,saving:n,save:r,discard:i}){let a=(0,Z.useRef)(r),o=(0,Z.useRef)(i);a.current=r,o.current=i;let s=Er(e=>e.registerSection),c=Er(e=>e.unregisterSection);(0,Z.useEffect)(()=>(s({id:e,dirty:t,saving:n,save:async()=>{try{return await a.current(),{ok:!0}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},discard:()=>o.current()}),()=>c(e)),[e,t,n,s,c])}function Or(e){let t=(0,Q.c)(26),{showLabel:n,hideLabel:r,icon:i,hint:a,children:o,className:s,defaultOpen:c,advancedOnly:l}=e,u=l===void 0?!1:l,[d,f]=(0,Z.useState)(c??!1),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>f(e.currentTarget.open),t[0]=p):p=t[0];let m;t[1]===s?m=t[2]:(m=Y(`group rounded-2xl bg-surface-base open:pb-1`,s),t[1]=s,t[2]=m);let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(le,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[3]=h):h=t[3];let g;t[4]===i?g=t[5]:(g=i?(0,$.jsx)(i,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[4]=i,t[5]=g);let _;t[6]===n?_=t[7]:(_=(0,$.jsx)(`span`,{className:`group-open:hidden`,children:n}),t[6]=n,t[7]=_);let v;t[8]===r?v=t[9]:(v=(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:r}),t[8]=r,t[9]=v);let y;t[10]!==g||t[11]!==_||t[12]!==v?(y=(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-2xl px-4 py-3.5 text-sm font-medium text-fg transition-colors hover:text-fg group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:[h,g,_,v]}),t[10]=g,t[11]=_,t[12]=v,t[13]=y):y=t[13];let b;t[14]===a?b=t[15]:(b=a?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[14]=a,t[15]=b);let x;t[16]!==o||t[17]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[b,o]}),t[16]=o,t[17]=b,t[18]=x):x=t[18];let S;t[19]!==d||t[20]!==x||t[21]!==m||t[22]!==y?(S=(0,$.jsxs)(`details`,{open:d,onToggle:p,className:m,children:[y,x]}),t[19]=d,t[20]=x,t[21]=m,t[22]=y,t[23]=S):S=t[23];let C=S;if(u){let e;return t[24]===C?e=t[25]:(e=(0,$.jsx)(kn,{children:C}),t[24]=C,t[25]=e),e}return C}async function kr(){let e=await v(l(`/api/image/providers`));if(!e.ok)throw Error(`Image providers: HTTP ${e.status}`);return(await e.json()).payload?.providers??[]}function Ar(e){let t=new Set,n=[];for(let r of e){let e=r.models.length>0?r.models:r.defaultModel?[r.defaultModel]:[];for(let i of e){let e=`${r.id}/${i}`;t.has(e)||(t.add(e),n.push(e))}}return n}function jr(e,t){let n=Ar(e.filter(e=>e.configured===!0));return!t||n.includes(t)?n:[t,...n]}function Mr(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=n.split(/[/\s]+/).filter(Boolean);return e.filter(e=>{let t=e.toLowerCase();return r.every(e=>t.includes(e))})}var Nr=`image-generation-providers`;function Pr(e){let t=(0,Q.c)(80),{value:n,disabled:r,placeholder:i,searchPlaceholder:a,noMatches:o,registryEmptyHint:s,outOfFilterNote:c,className:l,onChange:u}=e,[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(``),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},t[0]=g):g=t[0];let{data:_,isLoading:v,error:y}=d(Nr,kr,g),b;t[1]===n?b=t[2]:(b=n.trim(),t[1]=n,t[2]=b);let x=b,S;t[3]===_?S=t[4]:(S=Ar((_??[]).filter(Lr)),t[3]=_,t[4]=S);let C=S,w;t[5]===_?w=t[6]:(w=_??[],t[5]=_,t[6]=w);let T;t[7]!==w||t[8]!==x?(T=jr(w,x),t[7]=w,t[8]=x,t[9]=T):T=t[9];let E=T,D;t[10]!==E||t[11]!==m?(D=Mr(E,m),t[10]=E,t[11]=m,t[12]=D):D=t[12];let k=D,A;t[13]!==C||t[14]!==c||t[15]!==x?(A=!!c&&!!x&&!C.includes(x),t[13]=C,t[14]=c,t[15]=x,t[16]=A):A=t[16];let j=A,M;t[17]!==i||t[18]!==n?(M=n.trim()?n:i,t[17]=i,t[18]=n,t[19]=M):M=t[19];let N=M,P;t[20]!==i||t[21]!==n?(P=n.trim()||i,t[20]=i,t[21]=n,t[22]=P):P=t[22];let F=P,I;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>{p(e),e||h(``)},t[23]=I):I=t[23];let L=I,R=r||v,z=v?`…`:F,B;t[24]===l?B=t[25]:(B=Y(pt,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-left text-sm font-normal text-fg`,jt.transition,jt.press,`hover:border-edge hover:bg-surface-hover/45`,Wt,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,l),t[24]=l,t[25]=B);let V=v?`…`:N,H;t[26]===V?H=t[27]:(H=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:V}),t[26]=V,t[27]=H);let U;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(St,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[28]=U):U=t[28];let W;t[29]!==f||t[30]!==R||t[31]!==z||t[32]!==B||t[33]!==H?(W=(0,$.jsx)(pe,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,disabled:R,title:z,className:B,"aria-haspopup":`listbox`,"aria-expanded":f,children:[H,U]})}),t[29]=f,t[30]=R,t[31]=z,t[32]=B,t[33]=H,t[34]=W):W=t[34];let G;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(G=Y(`w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,an),t[35]=G):G=t[35];let ee;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ee=Y(`mb-1 w-full rounded-lg border border-edge-subtle bg-surface-base px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-disabled dark:bg-surface-hover/40`,Je),t[36]=ee):ee=t[36];let K;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>h(e.target.value),t[37]=K):K=t[37];let q;t[38]!==m||t[39]!==a?(q=(0,$.jsx)(`input`,{type:`search`,className:ee,placeholder:a,value:m,onChange:K,onKeyDown:Fr}),t[38]=m,t[39]=a,t[40]=q):q=t[40];let te;t[41]===y?te=t[42]:(te=y?(0,$.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:y instanceof Error?y.message:`Failed to load image providers`}):null,t[41]=y,t[42]=te);let ne;t[43]!==E||t[44]!==y||t[45]!==v||t[46]!==o||t[47]!==s?(ne=!y&&E.length===0&&!v?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:s??o}):null,t[43]=E,t[44]=y,t[45]=v,t[46]=o,t[47]=s,t[48]=ne):ne=t[48];let re;t[49]!==E||t[50]!==y||t[51]!==k.length||t[52]!==o?(re=!y&&E.length>0&&k.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:o}):null,t[49]=E,t[50]=y,t[51]=k.length,t[52]=o,t[53]=re):re=t[53];let ie;if(t[54]!==k||t[55]!==u||t[56]!==n){let e;t[58]!==u||t[59]!==n?(e=e=>(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e===n,className:Y(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,jt.press,e===n&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{u(e),p(!1),h(``)},children:[(0,$.jsx)(fe,{className:Y(`size-4 shrink-0`,e!==n&&`invisible`),"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e})]},e),t[58]=u,t[59]=n,t[60]=e):e=t[60],ie=k.map(e),t[54]=k,t[55]=u,t[56]=n,t[57]=ie}else ie=t[57];let ae;t[61]!==a||t[62]!==te||t[63]!==ne||t[64]!==re||t[65]!==ie?(ae=(0,$.jsxs)(`div`,{className:`max-h-60 overflow-auto`,role:`listbox`,"aria-label":a,children:[te,ne,re,ie]}),t[61]=a,t[62]=te,t[63]=ne,t[64]=re,t[65]=ie,t[66]=ae):ae=t[66];let oe;t[67]!==q||t[68]!==ae?(oe=(0,$.jsx)(vt,{children:(0,$.jsxs)(O,{className:G,side:`bottom`,sideOffset:4,align:`end`,onOpenAutoFocus:Ir,children:[q,ae]})}),t[67]=q,t[68]=ae,t[69]=oe):oe=t[69];let se;t[70]!==f||t[71]!==W||t[72]!==oe?(se=(0,$.jsxs)(ue,{open:f,onOpenChange:L,modal:!1,children:[W,oe]}),t[70]=f,t[71]=W,t[72]=oe,t[73]=se):se=t[73];let ce;t[74]!==c||t[75]!==j?(ce=j?(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400/90`,children:c}):null,t[74]=c,t[75]=j,t[76]=ce):ce=t[76];let le;return t[77]!==se||t[78]!==ce?(le=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[se,ce]}),t[77]=se,t[78]=ce,t[79]=le):le=t[79],le}function Fr(e){return e.stopPropagation()}function Ir(e){return e.preventDefault()}function Lr(e){return e.configured===!0}function Rr(e,t,n){let r=e.trim();return r?`model:${r}`:`empty:${n.slice(0,t).filter(e=>!e.trim()).length}`}function zr(e){let t=(0,Q.c)(37),{a:n,chat:r,form:i,update:a}=e,o;t[0]!==n.cardModelsSubtitle||t[1]!==n.cardModelsTitle?(o=(0,$.jsx)(Cn,{icon:W,title:n.cardModelsTitle,subtitle:n.cardModelsSubtitle}),t[0]=n.cardModelsSubtitle,t[1]=n.cardModelsTitle,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=e=>a({imageModel:e}),t[3]=a,t[4]=s);let c;t[5]!==n.visionOutOfFilterNote||t[6]!==n.visionRegistryEmpty||t[7]!==r.modelNoMatches||t[8]!==r.modelPlaceholder||t[9]!==r.modelSearchPlaceholder||t[10]!==i.imageModel||t[11]!==s?(c=(0,$.jsx)(q,{value:i.imageModel,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,capabilitiesFilter:`vision`,registryEmptyHint:n.visionRegistryEmpty,outOfFilterNote:n.visionOutOfFilterNote,onChange:s}),t[5]=n.visionOutOfFilterNote,t[6]=n.visionRegistryEmpty,t[7]=r.modelNoMatches,t[8]=r.modelPlaceholder,t[9]=r.modelSearchPlaceholder,t[10]=i.imageModel,t[11]=s,t[12]=c):c=t[12];let l;t[13]!==n.desc.imageModel||t[14]!==n.label.imageModel||t[15]!==c?(l=(0,$.jsx)(Mn,{label:n.label.imageModel,description:n.desc.imageModel,children:c}),t[13]=n.desc.imageModel,t[14]=n.label.imageModel,t[15]=c,t[16]=l):l=t[16];let u;t[17]===a?u=t[18]:(u=e=>a({imageGenerationModel:e}),t[17]=a,t[18]=u);let d;t[19]!==n.imageGenOutOfFilterNote||t[20]!==n.imageGenRegistryEmpty||t[21]!==r.modelNoMatches||t[22]!==r.modelPlaceholder||t[23]!==r.modelSearchPlaceholder||t[24]!==i.imageGenerationModel||t[25]!==u?(d=(0,$.jsx)(Pr,{value:i.imageGenerationModel,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,registryEmptyHint:n.imageGenRegistryEmpty,outOfFilterNote:n.imageGenOutOfFilterNote,onChange:u}),t[19]=n.imageGenOutOfFilterNote,t[20]=n.imageGenRegistryEmpty,t[21]=r.modelNoMatches,t[22]=r.modelPlaceholder,t[23]=r.modelSearchPlaceholder,t[24]=i.imageGenerationModel,t[25]=u,t[26]=d):d=t[26];let f;t[27]!==n.desc.imageGenerationModel||t[28]!==n.label.imageGenerationModel||t[29]!==d?(f=(0,$.jsx)(Mn,{label:n.label.imageGenerationModel,description:n.desc.imageGenerationModel,children:d}),t[27]=n.desc.imageGenerationModel,t[28]=n.label.imageGenerationModel,t[29]=d,t[30]=f):f=t[30];let p;t[31]!==l||t[32]!==f?(p=(0,$.jsxs)(`div`,{className:`mt-4 flex flex-col gap-5`,children:[l,f]}),t[31]=l,t[32]=f,t[33]=p):p=t[33];let m;return t[34]!==o||t[35]!==p?(m=(0,$.jsxs)(Tn,{children:[o,p]}),t[34]=o,t[35]=p,t[36]=m):m=t[36],m}function Br(e){let t=(0,Q.c)(45),{a:n,chat:r,form:i,update:a}=e,o=n.label.imageModelFallbacks,s=n.desc.imageModelFallbacks,c;t[0]!==n.removeModelFallback||t[1]!==n.visionOutOfFilterNote||t[2]!==n.visionRegistryEmpty||t[3]!==r||t[4]!==i.imageModelFallbacks||t[5]!==a?(c=i.imageModelFallbacks.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(q,{value:e,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,capabilitiesFilter:`vision`,registryEmptyHint:n.visionRegistryEmpty,outOfFilterNote:n.visionOutOfFilterNote,onChange:e=>{let n=[...i.imageModelFallbacks];n[t]=e,a({imageModelFallbacks:n})}})}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":n.removeModelFallback,onClick:()=>a({imageModelFallbacks:i.imageModelFallbacks.filter((e,n)=>n!==t)}),children:(0,$.jsx)(en,{className:`size-4`,strokeWidth:1.75})})]},Rr(e,t,i.imageModelFallbacks))),t[0]=n.removeModelFallback,t[1]=n.visionOutOfFilterNote,t[2]=n.visionRegistryEmpty,t[3]=r,t[4]=i.imageModelFallbacks,t[5]=a,t[6]=c):c=t[6];let l;t[7]!==i.imageModelFallbacks||t[8]!==a?(l=()=>a({imageModelFallbacks:[...i.imageModelFallbacks,``]}),t[7]=i.imageModelFallbacks,t[8]=a,t[9]=l):l=t[9];let u;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Ut,{className:`size-4 shrink-0`,strokeWidth:1.75}),t[10]=u):u=t[10];let d;t[11]!==n.addModelFallback||t[12]!==l?(d=(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:l,children:[u,n.addModelFallback]}),t[11]=n.addModelFallback,t[12]=l,t[13]=d):d=t[13];let f;t[14]!==c||t[15]!==d?(f=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[c,d]}),t[14]=c,t[15]=d,t[16]=f):f=t[16];let p;t[17]!==n.desc.imageModelFallbacks||t[18]!==n.label.imageModelFallbacks||t[19]!==f?(p=(0,$.jsx)(Mn,{label:o,description:s,children:f}),t[17]=n.desc.imageModelFallbacks,t[18]=n.label.imageModelFallbacks,t[19]=f,t[20]=p):p=t[20];let m=n.label.imageGenerationModelFallbacks,h=n.desc.imageGenerationModelFallbacks,g;t[21]!==n.imageGenOutOfFilterNote||t[22]!==n.imageGenRegistryEmpty||t[23]!==n.removeModelFallback||t[24]!==r||t[25]!==i.imageGenerationModelFallbacks||t[26]!==a?(g=i.imageGenerationModelFallbacks.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(Pr,{value:e,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,registryEmptyHint:n.imageGenRegistryEmpty,outOfFilterNote:n.imageGenOutOfFilterNote,onChange:e=>{let n=[...i.imageGenerationModelFallbacks];n[t]=e,a({imageGenerationModelFallbacks:n})}})}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":n.removeModelFallback,onClick:()=>a({imageGenerationModelFallbacks:i.imageGenerationModelFallbacks.filter((e,n)=>n!==t)}),children:(0,$.jsx)(en,{className:`size-4`,strokeWidth:1.75})})]},Rr(e,t,i.imageGenerationModelFallbacks))),t[21]=n.imageGenOutOfFilterNote,t[22]=n.imageGenRegistryEmpty,t[23]=n.removeModelFallback,t[24]=r,t[25]=i.imageGenerationModelFallbacks,t[26]=a,t[27]=g):g=t[27];let _;t[28]!==i.imageGenerationModelFallbacks||t[29]!==a?(_=()=>a({imageGenerationModelFallbacks:[...i.imageGenerationModelFallbacks,``]}),t[28]=i.imageGenerationModelFallbacks,t[29]=a,t[30]=_):_=t[30];let v;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Ut,{className:`size-4 shrink-0`,strokeWidth:1.75}),t[31]=v):v=t[31];let y;t[32]!==n.addModelFallback||t[33]!==_?(y=(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:_,children:[v,n.addModelFallback]}),t[32]=n.addModelFallback,t[33]=_,t[34]=y):y=t[34];let b;t[35]!==g||t[36]!==y?(b=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[g,y]}),t[35]=g,t[36]=y,t[37]=b):b=t[37];let x;t[38]!==n.desc.imageGenerationModelFallbacks||t[39]!==n.label.imageGenerationModelFallbacks||t[40]!==b?(x=(0,$.jsx)(Mn,{label:m,description:h,children:b}),t[38]=n.desc.imageGenerationModelFallbacks,t[39]=n.label.imageGenerationModelFallbacks,t[40]=b,t[41]=x):x=t[41];let S;return t[42]!==x||t[43]!==p?(S=(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[p,x]}),t[42]=x,t[43]=p,t[44]=S):S=t[44],S}function Vr(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt)}var Hr=()=>l(fn);function Ur(e){return{imageModel:e.imageModel,imageModelFallbacks:e.imageModelFallbacks,imageGenerationModel:e.imageGenerationModel,imageGenerationModelFallbacks:e.imageGenerationModelFallbacks,imageGenerationModelTimeoutMs:e.imageGenerationModelTimeoutMs,imageGenerationModelAutoProviderFallback:e.imageGenerationModelAutoProviderFallback}}function Wr(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}var Gr=gt(),Kr={loading:!0,saving:!1,savedFlash:!1,error:void 0};function qr({embedded:e=!1}={}){let t=a(e=>e.language),n=s(t),r=n.imageModelsSettings,i=!!g(e=>e.token),[o,c]=(0,Z.useReducer)(Gr,{form:null,baseline:null}),l=o.form,u=o.baseline,[f,p]=(0,Z.useReducer)(de,Kr),{loading:m,saving:h,savedFlash:_,error:v}=f,y=$t(),b=(0,Z.useMemo)(()=>new Set(y.map(e=>e.id)),[y]),x=(0,Z.useCallback)(async()=>{if(i){p({type:`patch`,patch:{loading:!0,error:void 0}});try{let e=await Nn();c({type:`sync`,value:structuredClone(e)})}catch(e){p({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{p({type:`patch`,patch:{loading:!1}})}}},[i]);(0,Z.useEffect)(()=>{x()},[x]);let C=(0,Z.useCallback)(e=>{c({type:`patch`,patch:e})},[]),{data:w=[]}=d(i?Hr():null,yn,{revalidateOnFocus:!1}),T=w.some(e=>e.configured),E=rt(i),D=dn(w),O=(0,Z.useMemo)(()=>!l||!u?!1:JSON.stringify(Ur(l))!==JSON.stringify(Ur(u)),[l,u]),k=O||D.credDirty;(0,Z.useEffect)(()=>{if(!k)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[k]);let A=(0,Z.useCallback)(async()=>{if(l){p({type:`patch`,patch:{saving:!0,error:void 0}});try{try{Pn(l.paramsJson)}catch(e){p({type:`patch`,patch:{error:e instanceof SyntaxError?n.agentSettings.advanced.paramsInvalidJson:e instanceof Error?e.message:n.agentSettings.advanced.paramsInvalidJson}});return}let e=[];O&&e.push(Vn(l).then(()=>{c({type:`saved`,value:structuredClone(l)}),E.mutate?.()})),D.credDirty&&e.push(D.saveCredentials(r.credentialsSaveError)),await Promise.all(e),p({type:`patch`,patch:{savedFlash:!0}}),window.setTimeout(()=>p({type:`patch`,patch:{savedFlash:!1}}),1500)}catch(e){p({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{p({type:`patch`,patch:{saving:!1}})}}},[l,O,E,n.agentSettings,D,r.credentialsSaveError]),j=(0,Z.useCallback)(()=>{u&&(c({type:`discard`}),D.credDirty&&D.onDiscardCredentials(),p({type:`patch`,patch:{error:void 0,savedFlash:!1}}))},[u,D]);Dr({id:`image-models`,dirty:k,saving:h,save:A,discard:j});let M=(0,Z.useMemo)(()=>Wr(r),[r]),N=(0,Z.useMemo)(()=>({getApiKey:n.providersSettings.getApiKey,getApiKeyIntl:n.providersSettings.getApiKeyIntl,getApiKeyCn:n.providersSettings.getApiKeyCn}),[n.providersSettings]),P=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,F=e?`w-full text-sm text-fg-muted`:`mx-auto w-full max-w-app-main px-4 py-8 text-sm text-fg-muted`,I=e?`flex w-full items-center gap-2 text-sm text-fg-muted`:`mx-auto flex w-full max-w-app-main items-center gap-2 px-4 py-8 text-sm text-fg-muted`;return i?m||!l?(0,$.jsxs)(`div`,{className:I,children:[(0,$.jsx)(J,{className:`size-4 animate-spin`}),` Loading…`]}):(0,$.jsxs)(`div`,{className:P,children:[e?null:(0,$.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[_?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:r.saved}):null,(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:j,disabled:!k||h,children:r.discard}),(0,$.jsxs)(X,{type:`button`,variant:`primary`,onClick:()=>void A(),disabled:!k||h,children:[h?(0,$.jsx)(J,{className:`size-3.5 animate-spin`}):(0,$.jsx)(S,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`ml-1.5`,children:h?r.saving:r.save})]})]})]}),v?(0,$.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:v}):null,(0,$.jsx)(zr,{form:l,update:C,a:n.agentSettings,chat:n.chat}),(0,$.jsx)(Or,{advancedOnly:!0,showLabel:r.fallbackChainsTitle,hideLabel:r.fallbackChainsTitle,children:(0,$.jsx)(Br,{form:l,update:C,a:n.agentSettings,chat:n.chat})}),(0,$.jsx)(Or,{advancedOnly:!0,showLabel:r.runtimeTuningTitle,hideLabel:r.runtimeTuningTitle,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,children:r.timeoutLabel}),(0,$.jsx)(`input`,{type:`number`,min:0,step:1e3,className:Y(Vr(),`max-w-48`),value:l.imageGenerationModelTimeoutMs??``,placeholder:`120000`,onChange:e=>{let t=e.target.value.trim(),n=t===``?null:Math.max(0,Math.floor(Number(t)));C({imageGenerationModelTimeoutMs:n&&n>0?n:null})}}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.timeoutHint})]}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:l.imageGenerationModelAutoProviderFallback,onChange:e=>C({imageGenerationModelAutoProviderFallback:e.target.checked}),"aria-label":r.autoFallbackLabel}),(0,$.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:r.autoFallbackLabel}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:r.autoFallbackHint})]})]})]})}),(0,$.jsx)(Or,{advancedOnly:!0,icon:zt,showLabel:r.providersTitle,hideLabel:r.providersTitle,defaultOpen:T,children:w.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.providersEmpty}):(0,$.jsx)(pn,{summaries:w,credDraft:D.credDraft,credBaseline:D.credBaseline,credDirty:D.credDirty,credSaving:D.credSaving,credError:D.credError,credSavedFlash:D.credSavedFlash,credNoopFlash:D.credNoopFlash,updateCredRow:D.updateCredRow,onDiscardCredentials:D.onDiscardCredentials,onSaveCredentials:()=>void D.saveCredentials(r.credentialsSaveError),extensionIds:b,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:t,apiKeyLinkLabels:N,messages:M})})]}):(0,$.jsx)(`div`,{className:F,children:t===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var Jr=Nt;function Yr(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function Xr(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Zr(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt,`dark:border-edge`)}function Qr(){return Y(et,Nt)}var $r=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],ei=[{id:`whisper-1`,name:`Whisper-1`}],ti=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],ni=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],ri=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],ii=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],ai=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],oi=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],si=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],ci=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],li=[{id:`openai`,capability:`tts`,displayName:`OpenAI`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`messages.tts.providers.openai`}},{id:`alibaba`,capability:`tts`,displayName:`Alibaba DashScope`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`messages.tts.providers.alibaba`}},{id:`minimax`,capability:`tts`,displayName:`MiniMax`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`messages.tts.providers.minimax`}},{id:`edge`,capability:`tts`,displayName:`Microsoft Edge`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!1,configPath:`messages.tts.providers.edge`}},{id:`tts-local-cli`,capability:`tts`,displayName:`Local CLI`,aliases:[`cli`,`local-cli`],configured:!1,fields:[],diagnostics:{requiresApiKey:!1,configPath:`messages.tts.providers.tts-local-cli`}}],ui=[{id:`alibaba`,capability:`stt`,displayName:`Alibaba DashScope`,aliases:[`dashscope`,`paraformer`],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`tools.media.audio.providers.alibaba`}},{id:`openai`,capability:`stt`,displayName:`OpenAI Whisper`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`tools.media.audio.providers.openai`}}];function di(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function fi(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function pi(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function mi(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function hi(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function gi(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function _i({embedded:e=!1}={}){let t=a(e=>e.language),n=s(t),r=n.voiceSettings,i=!!g(e=>e.token),[o,c]=(0,Z.useReducer)(gi,{form:null,baseline:null}),u=o.form,f=o.baseline,[p,m]=(0,Z.useState)(null),[h,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(!1),S=(0,Z.useRef)(!1),C=(0,Z.useRef)({parsed:null,models:void 0}),{data:w,error:T,isLoading:E,mutate:D}=rt(i),{data:O,error:k,isLoading:A,mutate:j}=d(i?l(`/api/voice/models`):null,mn,{revalidateOnFocus:!1}),{data:M,error:N,isLoading:P}=d(i?l(`/api/voice/providers`):null,gn,{revalidateOnFocus:!1}),{data:F,error:I,isLoading:L}=d(i?l(`/api/voice/stt-providers`):null,un,{revalidateOnFocus:!1}),R=(0,Z.useMemo)(()=>M?.providers??li,[M]),z=(0,Z.useMemo)(()=>F?.providers??ui,[F]),B=(0,Z.useMemo)(()=>w?.payload?.config===void 0?null:hn(w.payload.config),[w]),V=(0,Z.useMemo)(()=>!u||!f?!1:JSON.stringify(u)!==JSON.stringify(f),[u,f]);i?B!==null&&O!==void 0&&!S.current&&(C.current.parsed!==B||C.current.models!==O)&&(C.current={parsed:B,models:O},c({type:`sync`,value:B}),m(O),x(!1)):(C.current.parsed!==null||C.current.models!==void 0)&&(C.current={parsed:null,models:void 0},c({type:`reset`}),m(null),S.current=!1);let H=!!(i&&(B===null||O===void 0||M===void 0||F===void 0)&&(E||A||P||L)),U=T instanceof Error?T.message:T?String(T):k instanceof Error?k.message:k?String(k):N instanceof Error?N.message:N?String(N):I instanceof Error?I.message:I?String(I):null,W=(0,Z.useCallback)(e=>{S.current=!0,c({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),G=(0,Z.useCallback)(e=>{S.current=!0,c({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),ee=(0,Z.useCallback)(e=>{S.current=!0,c({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),K=(0,Z.useCallback)(e=>{S.current=!0,c({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!0,order:[`alibaba`,`openai`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),q=(0,Z.useCallback)(e=>{S.current=!0,c({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),te=(0,Z.useCallback)(e=>{S.current=!0,c({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),ne=(0,Z.useCallback)(e=>{S.current=!0,c({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),re=(0,Z.useCallback)(e=>{S.current=!0,c({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),ie=(0,Z.useCallback)(e=>{S.current=!0,c({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),ae=(0,Z.useCallback)(e=>{S.current=!0,c({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]),oe=(0,Z.useCallback)(async()=>{if(!(!u||h)){_(!0),y(null),x(!1);try{await _n(u),c({type:`saved`,value:u}),S.current=!1,x(!0),window.setTimeout(()=>x(!1),2500)}catch(e){y(e instanceof Error?e.message:r.saveError)}finally{_(!1)}}},[u,h,r.saveError]),se=(0,Z.useCallback)(()=>{f&&(S.current=!1,c({type:`discard`}),y(null),x(!1))},[f]);Dr({id:`voice`,dirty:V,saving:h,save:oe,discard:se});let ce=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,le=e?`flex flex-col gap-3`:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`;if(!i)return(0,$.jsxs)(`div`,{className:le,children:[e?null:(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.settingsSections.voice}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]});if(H)return(0,$.jsx)(`div`,{className:le,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(J,{className:`size-4 animate-spin`}),r.loading]})});if(!u||p===null)return(0,$.jsxs)(`div`,{className:le,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:v??U??r.loadError}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>{D(),j()},children:r.retry})]});let ue=u.stt,de=u.tts,fe=pi(r);return(0,$.jsxs)(`div`,{className:ce,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[e?(0,$.jsx)(`div`,{className:`min-w-0`,"aria-hidden":!0}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.settingsSections.voice}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,$.jsxs)(`a`,{href:Le(t,`voice`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[r.docsLink,(0,$.jsx)(Dt,{className:`size-3.5`})]})]}),e?null:(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[b?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:r.saved}):null,(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:!V||h,onClick:se,children:r.discard}),(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!V||h,onClick:()=>void oe(),children:h?r.saving:r.save})]})]}),V&&!e?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,v?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(vi,{v:r,apiKeyLabels:fe,stt:ue,models:p,sttProviders:z,updateStt:W,updateSttAlibaba:G,updateSttOpenai:ee,updateSttFallback:K}),(0,$.jsx)(Ci,{v:r,apiKeyLabels:fe,tts:de,models:p,ttsProviders:R,updateTts:q,updateTtsAlibaba:te,updateTtsOpenai:ne,updateTtsEdge:re,updateTtsMinimax:ie,updateTtsLocalCli:ae})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,$.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,$.jsx)(`strong`,{className:`text-accent`,children:r.notes.title}),` `,r.notes.duration]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:r.notes.envVars})]})]})}function vi(e){let t=(0,Q.c)(60),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttAlibaba:c,updateSttOpenai:l,updateSttFallback:u}=e,d=a?.stt?.alibaba?.length?a.stt.alibaba:$r,f=a?.stt?.openai?.length?a.stt.openai:ei,p;if(t[0]!==i.provider||t[1]!==o){let e=new Set;p=[];for(let t of o)e.has(t.id)||(e.add(t.id),p.push(t));if(i.provider&&!e.has(i.provider)){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3];let n;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=[{key:`apiKey`,label:`API Key`,type:`password`,secret:!0},{key:`model`,label:`Model`,type:`string`}],t[4]=n):n=t[4];let r=`tools.media.audio.providers.${i.provider}`,a;t[5]===r?a=t[6]:(a={requiresApiKey:!0,configPath:r},t[5]=r,t[6]=a);let o;t[7]!==i.provider||t[8]!==a?(o={id:i.provider,capability:`stt`,displayName:i.provider,aliases:e,configured:!1,fields:n,diagnostics:a},t[7]=i.provider,t[8]=a,t[9]=o):o=t[9],p.push(o)}t[0]=i.provider,t[1]=o,t[2]=p}else p=t[2];let m=p,h,g,_,v,y;if(t[10]!==d||t[11]!==r||t[12]!==f||t[13]!==m||t[14]!==i||t[15]!==s||t[16]!==c||t[17]!==u||t[18]!==l||t[19]!==n){let e=m.find(e=>e.id===i.provider),a=i.providers?.[i.provider],o=typeof a?.apiKey==`string`?a.apiKey:``,p=typeof a?.model==`string`?a.model:``,b={...i.provider===`alibaba`?i.alibaba??{}:{},...i.provider===`openai`?i.openai??{}:{},...a??{}},x=(e?.fields??[]).filter(Si),S;t[25]!==i.provider||t[26]!==i.providers||t[27]!==s?(S=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[25]=i.provider,t[26]=i.providers,t[27]=s,t[28]=S):S=t[28];let C=S;v=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let w;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(Ee,{className:`size-4 text-accent`,strokeWidth:1.75}),t[29]=w):w=t[29];let T;t[30]===n.stt.title?T=t[31]:(T=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[w,n.stt.title]}),t[30]=n.stt.title,t[31]=T);let E;t[32]===n.stt.description?E=t[33]:(E=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[32]=n.stt.description,t[33]=E),t[34]!==T||t[35]!==E?(y=(0,$.jsxs)(`div`,{className:`mb-4`,children:[T,E]}),t[34]=T,t[35]=E,t[36]=y):y=t[36],h=`space-y-4`;let D;t[37]===n.stt.enable?D=t[38]:(D=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.enable}),t[37]=n.stt.enable,t[38]=D);let O;t[39]===n.stt.enableDesc?O=t[40]:(O=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.enableDesc}),t[39]=n.stt.enableDesc,t[40]=O);let k;t[41]!==D||t[42]!==O?(k=(0,$.jsxs)(`div`,{children:[D,O]}),t[41]=D,t[42]=O,t[43]=k):k=t[43];let A;t[44]===s?A=t[45]:(A=e=>s({enabled:e.target.checked}),t[44]=s,t[45]=A);let j;t[46]!==i.enabled||t[47]!==A?(j=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.enabled,onChange:A}),t[46]=i.enabled,t[47]=A,t[48]=j):j=t[48],t[49]!==k||t[50]!==j?(g=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[k,j]}),t[49]=k,t[50]=j,t[51]=g):g=t[51],_=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jr),children:[(0,$.jsx)(Ai,{children:n.stt.provider}),(0,$.jsx)(`select`,{className:Qr(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:m.map(e=>(0,$.jsxs)(`option`,{value:e.id,children:[di(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jr),children:[(0,$.jsx)(Ai,{children:n.stt.model}),i.provider===`alibaba`?(0,$.jsx)(`select`,{className:Qr(),value:i.alibaba?.model??``,onChange:e=>c({model:e.target.value}),children:d.map(xi)}):i.provider===`openai`?(0,$.jsx)(`select`,{className:Qr(),value:i.openai?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(bi)}):i.provider===`groq`?(0,$.jsx)(`select`,{className:Qr(),value:p||ti[0].id,onChange:e=>C({model:e.target.value}),children:ti.map(yi)}):(0,$.jsx)(`input`,{className:Zr(),value:p,onChange:e=>C({model:e.target.value}),placeholder:i.provider})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jr),children:[(0,$.jsx)(Ai,{children:n.stt.apiKey}),(0,$.jsx)(vn,{kind:`stt`,providerId:i.provider,fieldId:`voice-stt-${i.provider}-api-key`,value:i.provider===`alibaba`?i.alibaba?.apiKey??``:i.provider===`openai`?i.openai?.apiKey??``:o,onChange:e=>{i.provider===`alibaba`?c({apiKey:e}):i.provider===`openai`?l({apiKey:e}):C({apiKey:e})},labels:r,placeholder:i.provider===`groq`?`gsk_...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Yr(i.provider)?` ${Yr(i.provider)}`:``]})]})]}),x.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:x.map(e=>(0,$.jsx)(Oi,{field:e,value:mi(b,e),onChange:t=>C({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Jr},e.key))}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!0,onChange:e=>u({enabled:e.target.checked})})]})]}):null,t[10]=d,t[11]=r,t[12]=f,t[13]=m,t[14]=i,t[15]=s,t[16]=c,t[17]=u,t[18]=l,t[19]=n,t[20]=h,t[21]=g,t[22]=_,t[23]=v,t[24]=y}else h=t[20],g=t[21],_=t[22],v=t[23],y=t[24];let b;t[52]!==h||t[53]!==g||t[54]!==_?(b=(0,$.jsxs)(`div`,{className:h,children:[g,_]}),t[52]=h,t[53]=g,t[54]=_,t[55]=b):b=t[55];let x;return t[56]!==v||t[57]!==y||t[58]!==b?(x=(0,$.jsxs)(`section`,{className:v,children:[y,b]}),t[56]=v,t[57]=y,t[58]=b,t[59]=x):x=t[59],x}function yi(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function bi(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function xi(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Si(e){return e.key!==`apiKey`&&e.key!==`model`}function Ci(e){let t=(0,Q.c)(76),{v:n,apiKeyLabels:r,tts:i,models:a,ttsProviders:o,updateTts:s,updateTtsAlibaba:c,updateTtsOpenai:l,updateTtsEdge:u,updateTtsMinimax:d,updateTtsLocalCli:f}=e,p;t[0]===n?p=t[1]:(p=e=>e===`off`?n.tts.triggerDescOff:e===`always`?n.tts.triggerDescAlways:e===`inbound`?n.tts.triggerDescInbound:e===`tagged`?n.tts.triggerDescTagged:``,t[0]=n,t[1]=p);let m=p,h=a?.tts?.openai?.length?a.tts.openai:ni,g=a?.ttsVoices?.openai?.length?a.ttsVoices.openai:ri,_=a?.tts?.alibaba?.length?a.tts.alibaba:ii,v=a?.ttsVoices?.alibaba?.length?a.ttsVoices.alibaba:ai,y=a?.ttsVoices?.edge?.length?a.ttsVoices.edge:oi,b=a?.tts?.minimax?.length?a.tts.minimax:si,x=a?.ttsVoices?.minimax?.length?a.ttsVoices.minimax:ci,S;if(t[2]!==i.provider||t[3]!==o){let e=new Set;S=[];for(let t of o)e.has(t.id)||(e.add(t.id),S.push(t));if(i.provider&&!e.has(i.provider)){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[5]=e):e=t[5];let n;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(n=[{key:`apiKey`,label:`API Key`,type:`password`,secret:!0},{key:`model`,label:`Model`,type:`string`},{key:`voice`,label:`Voice`,type:`string`}],t[6]=n):n=t[6];let r=`messages.tts.providers.${i.provider}`,a;t[7]===r?a=t[8]:(a={requiresApiKey:!0,configPath:r},t[7]=r,t[8]=a);let o;t[9]!==a||t[10]!==i.provider?(o={id:i.provider,capability:`tts`,displayName:i.provider,aliases:e,configured:!1,fields:n,diagnostics:a},t[9]=a,t[10]=i.provider,t[11]=o):o=t[11],S.push(o)}t[2]=i.provider,t[3]=o,t[4]=S}else S=t[4];let C=S,w,T,E,D,O;if(t[12]!==r||t[13]!==C||t[14]!==m||t[15]!==i||t[16]!==_||t[17]!==b||t[18]!==h||t[19]!==v||t[20]!==y||t[21]!==x||t[22]!==g||t[23]!==s||t[24]!==c||t[25]!==u||t[26]!==f||t[27]!==d||t[28]!==l||t[29]!==n){let e=C.find(e=>e.id===i.provider),a=i.providers?.[i.provider],o={...i.provider===`openai`?i.openai??{}:{},...i.provider===`alibaba`?i.alibaba??{}:{},...i.provider===`edge`?i.edge??{}:{},...i.provider===`minimax`?i.minimax??{}:{},...i.provider===`tts-local-cli`?i[`tts-local-cli`]??{}:{},...a??{}},p=(e?.fields??[]).filter(Di),S;t[35]!==i.provider||t[36]!==i.providers||t[37]!==s?(S=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[35]=i.provider,t[36]=i.providers,t[37]=s,t[38]=S):S=t[38];let k=S,A;t[39]!==i.provider||t[40]!==k||t[41]!==u||t[42]!==d||t[43]!==l?(A=(e,t)=>{let n={[e.key]:t};k(n),i.provider===`openai`&&e.key===`baseUrl`?l(n):i.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?d(n):i.provider===`edge`&&e.key===`lang`&&u(n)},t[39]=i.provider,t[40]=k,t[41]=u,t[42]=d,t[43]=l,t[44]=A):A=t[44];let j=A;D=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let M;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(lt,{className:`size-4 text-accent`,strokeWidth:1.75}),t[45]=M):M=t[45];let N;t[46]===n.tts.title?N=t[47]:(N=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[M,n.tts.title]}),t[46]=n.tts.title,t[47]=N);let P;t[48]===n.tts.description?P=t[49]:(P=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.tts.description}),t[48]=n.tts.description,t[49]=P),t[50]!==N||t[51]!==P?(O=(0,$.jsxs)(`div`,{className:`mb-4`,children:[N,P]}),t[50]=N,t[51]=P,t[52]=O):O=t[52],w=`space-y-4`;let F;t[53]===n.tts.enable?F=t[54]:(F=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.tts.enable}),t[53]=n.tts.enable,t[54]=F);let I;t[55]===n.tts.enableDesc?I=t[56]:(I=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.tts.enableDesc}),t[55]=n.tts.enableDesc,t[56]=I);let L;t[57]!==F||t[58]!==I?(L=(0,$.jsxs)(`div`,{children:[F,I]}),t[57]=F,t[58]=I,t[59]=L):L=t[59];let R;t[60]===s?R=t[61]:(R=e=>s({enabled:e.target.checked}),t[60]=s,t[61]=R);let z;t[62]!==R||t[63]!==i.enabled?(z=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.enabled,onChange:R}),t[62]=R,t[63]=i.enabled,t[64]=z):z=t[64],t[65]!==L||t[66]!==z?(T=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[L,z]}),t[65]=L,t[66]=z,t[67]=T):T=t[67],E=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jr),children:[(0,$.jsx)(Ai,{children:n.tts.trigger}),(0,$.jsxs)(`select`,{className:Qr(),value:i.trigger,onChange:e=>s({trigger:e.target.value}),children:[(0,$.jsx)(`option`,{value:`off`,children:n.tts.triggerOff}),(0,$.jsx)(`option`,{value:`always`,children:n.tts.triggerAlways}),(0,$.jsx)(`option`,{value:`inbound`,children:n.tts.triggerInbound}),(0,$.jsx)(`option`,{value:`tagged`,children:n.tts.triggerTagged})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:m(i.trigger)})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jr),children:[(0,$.jsx)(Ai,{children:n.tts.provider}),(0,$.jsx)(`select`,{className:Qr(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:C.map(e=>(0,$.jsx)(`option`,{value:e.id,children:fi(e.id,n)},e.id))})]})]}),i.provider===`openai`||i.provider===`alibaba`||i.provider===`minimax`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jr),children:[(0,$.jsx)(Ai,{children:n.stt.apiKey}),(0,$.jsx)(vn,{kind:`tts`,providerId:i.provider,fieldId:`voice-tts-${i.provider}-api-key`,value:i.provider===`openai`?i.openai?.apiKey??``:i.provider===`alibaba`?i.alibaba?.apiKey??``:i.minimax?.apiKey??``,onChange:e=>{i.provider===`openai`?l({apiKey:e}):i.provider===`alibaba`?c({apiKey:e}):d({apiKey:e})},labels:r,placeholder:i.provider===`minimax`?`eyJ...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Xr(i.provider)?` ${Xr(i.provider)}`:``]})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jr),children:[(0,$.jsx)(Ai,{children:n.stt.model}),(0,$.jsx)(`select`,{className:Qr(),value:i.provider===`openai`?i.openai?.model??``:i.provider===`alibaba`?i.alibaba?.model??``:i.minimax?.model??``,onChange:e=>{i.provider===`openai`?l({model:e.target.value}):i.provider===`alibaba`?c({model:e.target.value}):d({model:e.target.value})},children:(i.provider===`openai`?h:i.provider===`alibaba`?_:b).map(Ei)})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jr),children:[(0,$.jsx)(Ai,{children:n.tts.voice}),(0,$.jsx)(`select`,{className:Qr(),value:i.provider===`openai`?i.openai?.voice??``:i.provider===`alibaba`?i.alibaba?.voice??``:i.minimax?.voice??``,onChange:e=>{i.provider===`openai`?l({voice:e.target.value}):i.provider===`alibaba`?c({voice:e.target.value}):d({voice:e.target.value})},children:(i.provider===`openai`?g:i.provider===`alibaba`?v:x).map(Ti)})]})]}):null,i.provider===`edge`?(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jr),children:[(0,$.jsx)(Ai,{children:n.tts.voice}),(0,$.jsx)(`select`,{className:Qr(),value:i.edge?.voice??``,onChange:e=>u({voice:e.target.value}),children:y.map(wi)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.edgeHint})]}):null,i.provider===`tts-local-cli`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(Ai,{children:n.tts.localCli.command}),(0,$.jsx)(`input`,{className:Y(Zr(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:i[`tts-local-cli`]?.command??``,onChange:e=>f({command:e.target.value}),placeholder:n.tts.localCli.commandPlaceholder}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.localCli.commandDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Ai,{children:n.tts.localCli.cwd}),(0,$.jsx)(`input`,{className:Y(Zr(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:i[`tts-local-cli`]?.cwd??``,onChange:e=>f({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.localCli.cwdDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Ai,{children:n.tts.localCli.outputFormat}),(0,$.jsxs)(`select`,{className:Qr(),value:i[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>f({outputFormat:e.target.value}),children:[(0,$.jsx)(`option`,{value:`wav`,children:`wav`}),(0,$.jsx)(`option`,{value:`mp3`,children:`mp3`}),(0,$.jsx)(`option`,{value:`opus`,children:`opus`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.localCli.outputFormatDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(Ai,{children:n.tts.localCli.timeoutMs}),(0,$.jsx)(`input`,{className:Zr(),type:`number`,min:0,step:1e3,value:typeof i[`tts-local-cli`]?.timeoutMs==`number`?String(i[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){f({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&f({timeoutMs:n})},placeholder:`30000`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.localCli.timeoutMsDesc})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:n.tts.localCli.hint})]}):null,p.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:p.map(e=>(0,$.jsx)(Oi,{field:e,value:mi(o,e),onChange:t=>j(e,t),className:e.type===`textarea`?`sm:col-span-2`:Jr},e.key))}):null]}):null,t[12]=r,t[13]=C,t[14]=m,t[15]=i,t[16]=_,t[17]=b,t[18]=h,t[19]=v,t[20]=y,t[21]=x,t[22]=g,t[23]=s,t[24]=c,t[25]=u,t[26]=f,t[27]=d,t[28]=l,t[29]=n,t[30]=w,t[31]=T,t[32]=E,t[33]=D,t[34]=O}else w=t[30],T=t[31],E=t[32],D=t[33],O=t[34];let k;t[68]!==w||t[69]!==T||t[70]!==E?(k=(0,$.jsxs)(`div`,{className:w,children:[T,E]}),t[68]=w,t[69]=T,t[70]=E,t[71]=k):k=t[71];let A;return t[72]!==D||t[73]!==O||t[74]!==k?(A=(0,$.jsxs)(`section`,{className:D,children:[O,k]}),t[72]=D,t[73]=O,t[74]=k,t[75]=A):A=t[75],A}function wi(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Ti(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Ei(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Di(e){return![`apiKey`,`model`,`voice`].includes(e.key)}function Oi(e){let t=(0,Q.c)(36),{field:n,value:r,onChange:i,className:a}=e,o=`voice-schema-field-${n.key}`,s=n.description;if(n.type===`boolean`){let e;t[0]===a?e=t[1]:(e=Y(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,a),t[0]=a,t[1]=e);let o;t[2]===n.label?o=t[3]:(o=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=o);let c;t[4]===s?c=t[5]:(c=s?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:s}):null,t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,$.jsxs)(`span`,{children:[o,c]}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u=!!r,d;t[9]!==n||t[10]!==i?(d=e=>i(hi(n,e.target.checked)),t[9]=n,t[10]=i,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==e||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`label`,{className:e,children:[l,f]}),t[15]=e,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}let c=typeof r==`boolean`?``:String(r),l;t[19]===a?l=t[20]:(l=Y(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=l);let u;t[21]===n.label?u=t[22]:(u=(0,$.jsx)(Ai,{children:n.label}),t[21]=n.label,t[22]=u);let d;t[23]!==a||t[24]!==n||t[25]!==c||t[26]!==o||t[27]!==i?(d=n.type===`select`?(0,$.jsx)(`select`,{id:o,className:Qr(),value:c,required:n.required,onChange:e=>i(hi(n,e.target.value)),children:(n.options??[]).map(ki)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:Y(Zr(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(hi(n,e.target.value))}):n.type===`password`?(0,$.jsx)(Ke,{id:o,className:a,value:c,onChange:e=>i(hi(n,e)),placeholder:n.placeholder,labels:re}):(0,$.jsx)(`input`,{id:o,className:Zr(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(hi(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=c,t[26]=o,t[27]=i,t[28]=d):d=t[28];let f;t[29]===s?f=t[30]:(f=s?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:s}):null,t[29]=s,t[30]=f);let p;return t[31]!==l||t[32]!==u||t[33]!==d||t[34]!==f?(p=(0,$.jsxs)(`div`,{className:l,children:[u,d,f]}),t[31]=l,t[32]=u,t[33]=d,t[34]=f,t[35]=p):p=t[35],p}function ki(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Ai(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function ji(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function Mi(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await _(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),Xt()}async function Ni(e){let t=await _(l(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function Pi(e){let t=(0,Q.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Fi(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt,`dark:border-edge`)}function Ii(){return Y(et,Nt)}var Li=[`brave`,`tavily`,`bing`,`searxng`];function Ri(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var zi=gt();function Bi({embedded:e=!1}={}){let t=a(e=>e.language),n=s(t),r=n.webSearchSettings,i=n.logs,o=!!g(e=>e.token),[c,l]=(0,Z.useReducer)(zi,{form:null,baseline:null}),u=c.form,d=c.baseline,[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(!1),b=(0,Z.useRef)(null),{data:x,error:S,isLoading:C,mutate:w}=rt(o);se({enabled:o,parsed:(0,Z.useMemo)(()=>x?.payload?.config===void 0?null:ji(x.payload.config),[x]),dirty:y.current,trackedParsedRef:b,dispatch:l,onResetDirty:()=>{y.current=!1}});let T=!!(o&&C&&x===void 0&&!S),E=S instanceof Error?S.message:S?String(S):null,D=(0,Z.useMemo)(()=>!u||!d?!1:JSON.stringify(u)!==JSON.stringify(d),[u,d]),O=(0,Z.useCallback)(e=>{y.current=!0,l({type:`patch`,patch:e})},[]),k=(0,Z.useCallback)(async()=>{if(!(!u||f)){p(!0),h(null),v(!1);try{await Mi(u),y.current=!1,l({type:`saved`,value:u}),v(!0),window.setTimeout(()=>v(!1),2500)}catch(e){h(e instanceof Error?e.message:r.saveError)}finally{p(!1)}}},[u,f,r.saveError]),j=(0,Z.useCallback)(()=>{d&&(y.current=!1,l({type:`discard`}),h(null),v(!1))},[d]);Dr({id:`search`,dirty:D,saving:f,save:k,discard:j});let M=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,N=e?`flex flex-col gap-3`:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`;return o?T?(0,$.jsxs)(`div`,{className:Y(N,`items-center`),children:[(0,$.jsx)(J,{className:`size-8 animate-spin text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.loading})]}):u?(0,$.jsxs)(`div`,{className:M,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[e?(0,$.jsx)(`div`,{className:`min-w-0`,"aria-hidden":!0}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,$.jsxs)(`a`,{href:Le(t,`gateway`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[r.docsLink,(0,$.jsx)(Dt,{className:`size-3.5`})]})]}),e?null:(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[_?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:r.saved}):null,(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:!D||f,onClick:j,children:r.discard}),(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!D||f,onClick:()=>void k(),children:f?r.saving:r.save})]})]}),D&&!e?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,m?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Cn,{icon:He,title:r.sectionRegion,subtitle:r.sectionRegionHint}),(0,$.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,$.jsx)(Pi,{label:r.regionLabel,description:r.regionDesc,children:(0,$.jsxs)(`select`,{className:Ii(),value:u.regionMode,onChange:e=>O({regionMode:e.target.value}),children:[(0,$.jsx)(`option`,{value:`auto`,children:r.regionAuto}),(0,$.jsx)(`option`,{value:`cn`,children:r.regionCn}),(0,$.jsx)(`option`,{value:`global`,children:r.regionGlobal})]})})})]}),(0,$.jsx)(kn,{children:(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Cn,{icon:A,title:r.sectionBlocklist,subtitle:r.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:u.blocklistEnabled,onChange:e=>O({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:r.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.blocklistEnabledDesc})]})]}),(0,$.jsx)(Pi,{label:r.blocklistDomains,description:r.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:Y(Fi(),`min-h-[6rem] font-mono text-xs`),value:u.blocklistDomains.join(`
|
|
2
|
+
`),placeholder:r.blocklistDomainsPlaceholder,disabled:!u.blocklistEnabled,onChange:e=>{O({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Cn,{icon:He,title:r.sectionSearch,subtitle:r.sectionSearchHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,$.jsx)(Pi,{label:r.maxResultsLabel,description:r.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:Fi(),value:u.maxResults,onChange:e=>O({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.providersTitle}),u.providers.map((e,t)=>(0,$.jsx)(Vi,{row:e,providerIndex:t,labels:r,secretLabels:We(n.providersSettings),onChange:e=>{let n=[...u.providers];n[t]=e,O({providers:n})},onRemove:()=>{O({providers:u.providers.filter((e,n)=>n!==t)})}},`${e.type}:${e.url}:${e.apiKey}:${e.disabled}`)),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>O({providers:[...u.providers,Ri()]}),children:[(0,$.jsx)(Ut,{className:`size-4`}),r.addProvider]})]})]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r.footerHint})]}):(0,$.jsxs)(`div`,{className:N,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m??E??r.loadError}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>void w(),children:i.refresh})]}):(0,$.jsxs)(`div`,{className:N,children:[e?null:(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:r.title}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]})}function Vi(e){let t=(0,Q.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>Ni(r).then(Hi),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(Ii(),`min-w-[8rem]`),t[2]=u):u=t[2];let d=n.type,f;t[3]!==o||t[4]!==n?(f=e=>o({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=o,t[4]=n,t[5]=f):f=t[5];let p;t[6]===i.providerTypes?p=t[7]:(p=Li.map(e=>(0,$.jsx)(`option`,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=p);let m;t[8]!==n.type||t[9]!==f||t[10]!==p?(m=(0,$.jsx)(`select`,{className:u,value:d,onChange:f,children:p}),t[8]=n.type,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]!==o||t[13]!==n?(h=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=h):h=t[14];let g;t[15]!==n.disabled||t[16]!==h?(g=(0,$.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:h}),t[15]=n.disabled,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==i.disabled||t[19]!==g?(_=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[g,i.disabled]}),t[18]=i.disabled,t[19]=g,t[20]=_):_=t[20];let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(en,{className:`size-4`}),t[21]=v):v=t[21];let y;t[22]===s?y=t[23]:(y=(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:v}),t[22]=s,t[23]=y);let b;t[24]!==y||t[25]!==_?(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_,y]}),t[24]=y,t[25]=_,t[26]=b):b=t[26];let x;t[27]!==b||t[28]!==m?(x=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[m,b]}),t[27]=b,t[28]=m,t[29]=x):x=t[29];let S;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==o||t[33]!==n?(S=n.type===`searxng`?(0,$.jsx)(Pi,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Fi(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.urlDesc,t[31]=i.urlLabel,t[32]=o,t[33]=n,t[34]=S):S=t[34];let C;t[35]!==o||t[36]!==n?(C=e=>o({...n,apiKey:e}),t[35]=o,t[36]=n,t[37]=C):C=t[37];let w;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==l||t[42]!==n.apiKey||t[43]!==a||t[44]!==C?(w=(0,$.jsx)(Ke,{value:n.apiKey,onChange:C,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[38]=i.keyPlaceholder,t[39]=i.keyPlaceholderMasked,t[40]=i.saveError,t[41]=l,t[42]=n.apiKey,t[43]=a,t[44]=C,t[45]=w):w=t[45];let T;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==w?(T=(0,$.jsx)(Pi,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:w}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=w,t[49]=T):T=t[49];let E;return t[50]!==x||t[51]!==S||t[52]!==T?(E=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel/60 p-4 dark:border-edge-subtle`,children:[x,S,T]}),t[50]=x,t[51]=S,t[52]=T,t[53]=E):E=t[53],E}function Hi(e){return e.apiKey??null}function Ui(){let e=(0,Q.c)(26),t=s(a(Yi)).modelsHub.saveBar,n=Er(Ji),r=Er(qi),i=Er(Ki),o=Er(Gi),c=Er(Wi),l;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],e[0]=l):l=e[0];let[u,d]=(0,Z.useState)(l),[f,p]=(0,Z.useState)(!1);if(!n&&u.length===0&&!f)return null;let m;e[1]===o?m=e[2]:(m=async()=>{d([]),p(!1);let e=await o();e.ok&&e.saved>0?(p(!0),window.setTimeout(()=>p(!1),2500)):e.ok||d(e.failures)},e[1]=o,e[2]=m);let h=m,g;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=Y(`sticky top-0 z-10 -mx-4 flex flex-col gap-2 border-b border-edge-subtle bg-surface-base/85 px-4 py-2 backdrop-blur`,`sm:flex-row sm:items-center sm:justify-between`),e[3]=g):g=e[3];let _=u.length>0?(0,$.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,role:`alert`,children:t.failuresSummary.replace(`{{count}}`,String(u.length))}):null,v=!n||r,y;e[4]===c?y=e[5]:(y=()=>c(),e[4]=c,e[5]=y);let b;e[6]!==t.discardAll||e[7]!==v||e[8]!==y?(b=(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:v,onClick:y,children:t.discardAll}),e[6]=t.discardAll,e[7]=v,e[8]=y,e[9]=b):b=e[9];let x=!n||r,S;e[10]===h?S=e[11]:(S=()=>void h(),e[10]=h,e[11]=S);let C;e[12]===r?C=e[13]:(C=r?(0,$.jsx)(J,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,e[12]=r,e[13]=C);let w=r?`ml-1.5`:void 0,T;e[14]!==t.saveAll||e[15]!==w?(T=(0,$.jsx)(`span`,{className:w,children:t.saveAll}),e[14]=t.saveAll,e[15]=w,e[16]=T):T=e[16];let E;e[17]!==C||e[18]!==T||e[19]!==x||e[20]!==S?(E=(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:x,onClick:S,children:[C,T]}),e[17]=C,e[18]=T,e[19]=x,e[20]=S,e[21]=E):E=e[21];let D;return e[22]!==E||e[23]!==_||e[24]!==b?(D=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[_,b,E]}),e[22]=E,e[23]=_,e[24]=b,e[25]=D):D=e[25],(0,$.jsxs)(`div`,{className:g,role:`region`,"aria-label":t.title,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?t.dirtySummary.replace(`{{count}}`,String(i)):f?t.savedSummary:t.cleanSummary}),D]})}function Wi(e){return e.discardAll}function Gi(e){return e.saveAll}function Ki(e){return e.dirtyCount}function qi(e){return e.anySaving}function Ji(e){return e.anyDirty}function Yi(e){return e.language}var Xi=[{value:`openai-completions`,label:`OpenAI Completions`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic-messages`,label:`Anthropic Messages`},{value:`google-generative-ai`,label:`Google Generative AI`},{value:`azure-openai-responses`,label:`Azure OpenAI`},{value:`bedrock-converse-stream`,label:`AWS Bedrock`},{value:`openai-codex-responses`,label:`OpenAI Codex`},{value:`google-gemini-cli`,label:`Google Gemini CLI`},{value:`google-vertex`,label:`Google Vertex AI`}];function Zi(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;return typeof e==`string`?e:void 0}}function Qi(e){if(!e||typeof e!=`object`)return{providers:{}};let t=e,n=t.providers;return n&&typeof n==`object`&&!Array.isArray(n)?e:{...t,providers:{}}}async function $i(){let e=await v(l(`/api/models-json`)),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok||!t.payload)throw Error(Zi(t)||`HTTP ${e.status}`);return{...t.payload,config:Qi(t.payload.config)}}async function ea(e){let t=await v(l(`/api/models-json`),{method:`PATCH`,body:JSON.stringify({config:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(Zi(n)||`HTTP ${t.status}`);return await Be(),n.payload}function ta(e,t,n){return{id:e,name:t||e,input:[`text`],contextWindow:128e3,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},...n}}function na(){let e=(0,Q.c)(31),t=g(sa),n=!!t,{data:r,isLoading:i}=rt(n),a;e[0]===n?a=e[1]:(a=n?l(`/api/providers/meta`):null,e[0]=n,e[1]=a);let o;e[2]===t?o=e[3]:(o=async e=>{let{payload:n}=await(await fetch(e,{headers:{Authorization:`Bearer ${t}`}})).json();return n?.providers??[]},e[2]=t,e[3]=o);let s;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},e[4]=s):s=e[4];let{data:c,isLoading:u}=d(a,o,s),f;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},e[5]=f):f=e[5];let{data:p,isLoading:m}=d(n?b:null,oa,f),h;e[6]===p?h=e[7]:(h=p===void 0?[]:p,e[6]=p,e[7]=h);let _=h,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[8]=v):v=e[8];let{data:y}=d(n?te:null,aa,v),x;bb0:{if(!c||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],x=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==c||e[12]!==_?(t=Fe(c,ie(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=c,e[12]=_,e[13]=t):t=e[13],x=t}let S=x,C;bb1:{if(!y){C=null;break bb1}let t;e[14]===y.config?t=e[15]:(t=Qi(y.config),e[14]=y.config,e[15]=t),C=t}let w=C,T;if(e[16]!==S||e[17]!==w||e[18]!==c||e[19]!==_){T=[];let t=new Set((c??[]).filter(ia).map(ra)),n;e[21]===w?n=e[22]:(n=new Set(w?Object.keys(w.providers):[]),e[21]=w,e[22]=n);let r=n;for(let e of S){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?w.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;T.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(w){let t;e[23]===w.providers?t=e[24]:(t=Object.entries(w.providers),e[23]=w.providers,e[24]=t);for(let[e,n]of t)T.some(t=>t.id===e)||T.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=S,e[17]=w,e[18]=c,e[19]=_,e[20]=T}else T=e[20];let E=T,D=i||u||m,O;return e[25]!==S||e[26]!==E||e[27]!==w||e[28]!==D||e[29]!==_?(O={cards:E,loading:D,builtinRows:S,customConfig:w,allModels:_},e[25]=S,e[26]=E,e[27]=w,e[28]=D,e[29]=_,e[30]=O):O=e[30],O}function ra(e){return e.id}function ia(e){return e.configured}function aa(){return $i()}function oa(){return ot()}function sa(e){return e.token}function ca(e){let t=(0,Q.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=na();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`h-6 w-48 animate-pulse rounded bg-surface-hover`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(ua)})]}),t[1]=n):n=t[1],n}let s;if(t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==i){let e=a.filter(la),o=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,c;t[7]===o?c=t[8]:(c=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o}),t[7]=o,t[8]=c);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ut,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==r?(u=(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:r,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=r,t[12]=u):u=t[12];let d;t[13]!==c||t[14]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,$.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge-subtle bg-surface-panel/40 px-6 py-10 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,$.jsx)(Ut,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,$.jsx)(da,{card:e,labels:n,onManage:()=>i(e.id,e.isCustom)},e.id))})]}),t[2]=a,t[3]=n,t[4]=r,t[5]=i,t[6]=s}else s=t[6];return s}function la(e){return e.configured}function ua(e){return(0,$.jsx)(`div`,{className:`h-32 animate-pulse rounded-2xl bg-surface-hover`},e)}function da(e){let t=(0,Q.c)(28),{card:n,labels:r,onManage:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=Y(`group relative flex flex-col justify-between rounded-2xl border border-edge-subtle bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,jt.pressCard),t[0]=a):a=t[0];let o;t[1]===n.name?o=t[2]:(o=(0,$.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=o);let s;t[3]!==n.isCustom||t[4]!==r.custom?(s=n.isCustom?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:r.custom}):null,t[3]=n.isCustom,t[4]=r.custom,t[5]=s):s=t[5];let c;t[6]!==o||t[7]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(p,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]===c?u=t[11]:(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[c,l]}),t[10]=c,t[11]=u);let d;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(d=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=d):d=t[15];let f;t[16]===d?f=t[17]:(f=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:d}),t[16]=d,t[17]=f);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(ae,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[m,r.manage]}),t[19]=r.manage,t[20]=h);let g;t[21]!==h||t[22]!==f?(g=(0,$.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[f,h]}),t[21]=h,t[22]=f,t[23]=g):g=t[23];let _;return t[24]!==i||t[25]!==g||t[26]!==u?(_=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:a,children:[u,g]}),t[24]=i,t[25]=g,t[26]=u,t[27]=_):_=t[27],_}async function fa(e){let t=await v(l(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${t.status}`)}return(await t.json()).payload}async function pa(e){let t=await v(l(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function ma(e,t){let n=await v(l(`/api/auth/oauth-async/${encodeURIComponent(e)}/code`),{method:`POST`,body:JSON.stringify({code:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${n.status}`)}}async function ha(e){let t=await v(l(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function ga(e){let t=await v(l(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function _a(e){let t=await v(l(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var va=[`common`,`specialty`,`enterprise`,`oauth`,`extension`];function ya(e){let t=new Map;for(let e of va)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}var ba={ollama:{baseUrl:`http://localhost:11434/v1`,api:`openai-completions`,apiKey:`ollama`},lmstudio:{baseUrl:`http://localhost:1234/v1`,api:`openai-completions`,apiKey:`lmstudio`},openrouter:{baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`,apiKey:``},zhipuCn:{baseUrl:`https://open.bigmodel.cn/api/coding/paas/v4`,api:`openai-completions`,apiKey:`ZHIPU_API_KEY`},zaiGeneral:{baseUrl:`https://api.z.ai/api/paas/v4`,api:`openai-completions`,apiKey:`ZAI_API_KEY`}};function xa(e){return e===`openrouter`?`openrouter`:e===`zhipuCn`?`zhipu-cn`:e===`zaiGeneral`?`zai`:e}var Sa=[{value:`text`,labelKey:`inputTextOnly`},{value:`text,image`,labelKey:`inputTextVision`}];function Ca(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt,`dark:border-edge`)}function wa(){return Y(et,Nt)}function Ta(e){return(e.input||[`text`]).includes(`image`)?`text,image`:`text`}function Ea(e){return e===`text,image`?[`text`,`image`]:[`text`]}function Da(e){let t=(0,Q.c)(21),{open:n,onOpenChange:r,builtinRows:i,customConfig:a,labels:o,language:s,onSaved:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={type:`pick`},t[0]=l):l=t[0];let[u,d]=(0,Z.useState)(l),[f,p]=(0,Z.useState)(``),m;t[1]===r?m=t[2]:(m=e=>{e||window.setTimeout(()=>{d({type:`pick`}),p(``)},200),r(e)},t[1]=r,t[2]=m);let h=m,g;t[3]!==h||t[4]!==c?(g=()=>{c(),h(!1)},t[3]=h,t[4]=c,t[5]=g):g=t[5];let _=g,v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(V,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Ze)}),t[6]=v):v=t[6];let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=Y(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,sn),t[7]=y):y=t[7];let b;t[8]!==i||t[9]!==a||t[10]!==_||t[11]!==o||t[12]!==s||t[13]!==f||t[14]!==u.providerId||t[15]!==u.type?(b=(0,$.jsxs)(R,{children:[v,(0,$.jsx)(nn,{className:y,children:u.type===`pick`?(0,$.jsx)(ka,{builtinRows:i,searchQuery:f,onSearchChange:p,labels:o,onPickBuiltin:e=>d({type:`builtin`,providerId:e}),onPickCustom:()=>d({type:`custom`})}):u.type===`builtin`?(0,$.jsx)(Aa,{providerId:u.providerId,builtinRows:i,labels:o,language:s,onBack:()=>d({type:`pick`}),onSaved:_}):(0,$.jsx)(Na,{customConfig:a,labels:o,language:s,onBack:()=>d({type:`pick`}),onSaved:_})})]}),t[8]=i,t[9]=a,t[10]=_,t[11]=o,t[12]=s,t[13]=f,t[14]=u.providerId,t[15]=u.type,t[16]=b):b=t[16];let x;return t[17]!==h||t[18]!==n||t[19]!==b?(x=(0,$.jsx)(ve,{open:n,onOpenChange:h,children:b}),t[17]=h,t[18]=n,t[19]=b,t[20]=x):x=t[20],x}function Oa(e){let t=(0,Q.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,jt.press),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(It,{className:`size-4`,"aria-hidden":!0}),t[1]=i):i=t[1];let a;return t[2]===n?a=t[3]:(a=(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:i})}),t[2]=n,t[3]=a),a}function ka(e){let t=(0,Q.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:i,labels:a,onPickBuiltin:o,onPickCustom:s}=e,c;t[0]===r?c=t[1]:(c=r.trim().toLowerCase(),t[0]=r,t[1]=c);let l=c,u;bb0:{if(!l){u=n;break bb0}let e;if(t[2]!==n||t[3]!==l){let r;t[5]===l?r=t[6]:(r=e=>{let t=Re[e.id]?.aliases??[];return e.id.toLowerCase().includes(l)||e.name.toLowerCase().includes(l)||t.some(e=>e.toLowerCase().includes(l))},t[5]=l,t[6]=r),e=n.filter(r),t[2]=n,t[3]=l,t[4]=e}else e=t[4];u=e}let d=u,f;t[7]===d?f=t[8]:(f=ya(d),t[7]=d,t[8]=f);let m=f,h;t[9]===a.step1Title?h=t[10]:(h=(0,$.jsx)(Ct,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:a.step1Title}),t[9]=a.step1Title,t[10]=h);let g;t[11]===a.close?g=t[12]:(g=(0,$.jsx)(Oa,{label:a.close}),t[11]=a.close,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(He,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]===i?y=t[18]:(y=e=>i(e.target.value),t[17]=i,t[18]=y);let b=a.searchPlaceholder,S;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=Y(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,Tt),t[19]=S):S=t[19];let C;t[20]!==a.searchPlaceholder||t[21]!==r||t[22]!==y?(C=(0,$.jsx)(`div`,{className:`px-5 pt-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[v,(0,$.jsx)(`input`,{type:`search`,value:r,onChange:y,placeholder:b,autoComplete:`off`,autoFocus:!0,className:S})]})}),t[20]=a.searchPlaceholder,t[21]=r,t[22]=y,t[23]=C):C=t[23];let w;t[24]!==a.addCustom||t[25]!==a.customDescription||t[26]!==s||t[27]!==l?(w=l?null:(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:Y(`mb-3 flex w-full items-center gap-3 rounded-xl border border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,jt.press),children:[(0,$.jsx)(x,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.addCustom}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:a.customDescription})]}),(0,$.jsx)(D,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=a.addCustom,t[25]=a.customDescription,t[26]=s,t[27]=l,t[28]=w):w=t[28];let T;t[29]!==d.length||t[30]!==m||t[31]!==a.categories||t[32]!==a.noResults||t[33]!==o?(T=d.length===0?(0,$.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:a.noResults}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:va.map(e=>{let t=m.get(e)??[];return t.length===0?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:a.categories[e]??e}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),className:Y(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2.5 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,jt.press),children:[(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,$.jsx)(p,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null]},e.id))})]},e)})}),t[29]=d.length,t[30]=m,t[31]=a.categories,t[32]=a.noResults,t[33]=o,t[34]=T):T=t[34];let E;t[35]!==w||t[36]!==T?(E=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[w,T]}),t[35]=w,t[36]=T,t[37]=E):E=t[37];let O;return t[38]!==C||t[39]!==E||t[40]!==_?(O=(0,$.jsxs)($.Fragment,{children:[_,C,E]}),t[38]=C,t[39]=E,t[40]=_,t[41]=O):O=t[41],O}function Aa({providerId:e,builtinRows:t,labels:n,language:r,onBack:i,onSaved:a}){let o=t.find(t=>t.id===e),c=Re[e],[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),v=(0,Z.useRef)(null),y=s(r).providersSettings,b=We(y),x=(0,Z.useMemo)(()=>Ge(e,r),[e,r]),S=o?.supportsApiKey!==!1,C=o?.supportsOAuth===!0,[w,T]=(0,Z.useState)(null),[E,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(`idle`),[j,M]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(``),L=k===`waiting`||k===`waiting_code`;(0,Z.useEffect)(()=>{if(!w||!L)return;let e=window.setInterval(()=>{(async()=>{try{let t=await pa(w);t.status===`waiting_auth`||t.status===`waiting_code`?(A(t.status===`waiting_code`?`waiting_code`:`waiting`),O(t.message??null),M(t.authUrl??null),P(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),A(`success`),O(t.message??y.saved),window.setTimeout(a,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),A(`error`),O(t.error??t.message??y.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[w,L,a,y.revokeFailed,y.saved]),(0,Z.useEffect)(()=>()=>{w&&ga(w).catch(()=>{})},[w]);let R=async()=>{A(`waiting`),O(y.oauthStarting),h(null);try{T((await fa(e)).sessionId)}catch(e){A(`error`),O(e instanceof Error?e.message:y.revokeFailed)}},z=async()=>{if(w){try{await ha(w)}catch{}A(`idle`),O(null),T(null),M(null),P(null)}},B=async()=>{if(!(!w||!F.trim()))try{await ma(w,F.trim()),I(``),O(y.oauthProcessingCode)}catch(e){A(`error`),O(e instanceof Error?e.message:y.revokeFailed)}},V=async()=>{let t=l.trim();if(!(!t||!S)){f(!0),h(null);try{await U({[e]:t}),_(!0),window.setTimeout(a,600)}catch(e){h(e instanceof Error?e.message:n.saveError)}finally{f(!1)}}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,jt.press),"aria-label":n.back,children:(0,$.jsx)(D,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(Ct,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o?.name??e}),(0,$.jsx)(Oa,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[c?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.description}):null,S?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(Ke,{id:`builtin-api-key`,value:l,onChange:u,placeholder:n.apiKeyPlaceholder,labels:b,inputRef:v,onKeyDown:e=>{e.key===`Enter`&&V()}})]}):null,C?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:y.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:y.oauthHint})]}),(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:L,onClick:()=>void R(),children:[L?(0,$.jsx)(J,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,y.oauth]})]}),E?(0,$.jsx)(`p`,{className:Y(`text-xs`,k===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:E}):null,k===`waiting`||k===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[j?(0,$.jsxs)(`a`,{href:j,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[y.openAuthPage,(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>void z(),children:y.cancelOAuth})]}):null,N?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:N}):null,k===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:F,onChange:e=>I(e.target.value),onKeyDown:e=>e.key===`Enter`&&void B(),placeholder:y.pasteRedirectUrl,className:Y(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Tt)}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void B(),children:y.submitCode})]}):null]}):null,x.length>0&&S?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:x.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[ye(e,n),(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,m?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),S?(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!l.trim()||d||g,onClick:()=>void V(),children:g?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):d?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(J,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function ja(e=`custom`){if(e!==`custom`&&ba[e]){let t=ba[e];return{preset:e,providerId:xa(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function Ma(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:ba[t.key]?{...ja(t.key),modelIds:e.modelIds}:e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function Na({customConfig:e,labels:t,language:n,onBack:r,onSaved:i}){let[a,o]=(0,Z.useReducer)(Ma,void 0,()=>ja()),[c,l]=(0,Z.useState)(!1),u=We(s(n).providersSettings),{preset:d,providerId:f,baseUrl:p,api:m,apiKey:h,modelIds:g,error:_}=a,v=async()=>{let n=f.trim(),r=p.trim();if(!n){o({type:`setError`,value:t.providerIdRequired});return}if(!r){o({type:`setError`,value:t.baseUrlRequired});return}let a=g.map(e=>e.trim()).filter(Boolean);l(!0),o({type:`setError`,value:null});try{let t=e?.providers??{},o={baseUrl:r,api:m,apiKey:h.trim()||void 0,models:a.map(e=>({id:e}))};await ea({providers:{...t,[n]:o}}),i()}catch(e){o({type:`setError`,value:e instanceof Error?e.message:t.saveError})}finally{l(!1)}},y=f.trim()&&p.trim();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:r,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,jt.press),"aria-label":t.back,children:(0,$.jsx)(D,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(Ct,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:t.step2CustomTitle}),(0,$.jsx)(Oa,{label:t.close})]}),(0,$.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.customDescription}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:t.presetLabel}),(0,$.jsxs)(`select`,{id:`custom-preset`,value:d,onChange:e=>o({type:`applyPreset`,key:e.target.value}),className:wa(),children:[(0,$.jsx)(`option`,{value:`custom`,children:t.presetCustom}),(0,$.jsx)(`option`,{value:`ollama`,children:t.presetOllama}),(0,$.jsx)(`option`,{value:`lmstudio`,children:t.presetLmStudio}),(0,$.jsx)(`option`,{value:`openrouter`,children:t.presetOpenRouter}),(0,$.jsx)(`option`,{value:`zhipuCn`,children:t.presetZhipuCn}),(0,$.jsx)(`option`,{value:`zaiGeneral`,children:t.presetZaiGeneral})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:t.providerIdLabel}),(0,$.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,autoFocus:!0,value:f,onChange:e=>o({type:`setProviderId`,value:e.target.value}),placeholder:t.providerIdPlaceholder,className:Y(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Tt)})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:t.baseUrlLabel}),(0,$.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:p,onChange:e=>o({type:`setBaseUrl`,value:e.target.value}),placeholder:t.baseUrlPlaceholder,className:Y(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Tt)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:t.apiTypeLabel}),(0,$.jsx)(`select`,{id:`custom-api-type`,value:m,onChange:e=>o({type:`setApi`,value:e.target.value}),className:wa(),children:Xi.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:t.apiKeyLabel}),(0,$.jsx)(Ke,{id:`custom-api-key`,value:h,onChange:e=>o({type:`setApiKey`,value:e}),placeholder:t.apiKeyPlaceholder,labels:u})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.modelIdLabel}),g.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>o({type:`updateModelId`,index:n,value:e.target.value}),placeholder:t.modelIdPlaceholder,className:Y(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Tt)}),g.length>1?(0,$.jsx)(`button`,{type:`button`,onClick:()=>o({type:`removeModelSlot`,index:n}),className:Y(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,jt.press),children:(0,$.jsx)(It,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${n}`)),(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>o({type:`addModelSlot`}),children:[(0,$.jsx)(Ut,{className:`size-3.5`,"aria-hidden":!0}),t.addModel]})]}),_?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:_}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:r,children:t.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!y||c,onClick:()=>void v(),children:c?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(J,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),t.saving]}):t.save})]})]})}function Pa(e){let t=(0,Q.c)(156),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c;t[0]===n?c=t[1]:(c=()=>n?{...n}:ta(``),t[0]=n,t[1]=c);let[l,u]=(0,Z.useState)(c),[d,f]=(0,Z.useState)(Fa),p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(e,t)=>{u(n=>({...n,[e]:t})),f(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=p):p=t[2];let m=p,h;t[3]!==l.contextWindow||t[4]!==l.id||t[5]!==l.maxTokens||t[6]!==s.modelIdRequired||t[7]!==s.mustBePositive?(h=()=>{let e=new Map;return(l.id||``).trim()||e.set(`id`,s.modelIdRequired),l.contextWindow!==void 0&&l.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),l.maxTokens!==void 0&&l.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),f(e),e.size===0},t[3]=l.contextWindow,t[4]=l.id,t[5]=l.maxTokens,t[6]=s.modelIdRequired,t[7]=s.mustBePositive,t[8]=h):h=t[8];let g=h,_;t[9]!==l||t[10]!==o||t[11]!==a||t[12]!==g?(_=()=>{if(!g())return;let e=(l.id||``).trim();a({...l,id:e,name:l.name?.trim()||e,reasoning:l.reasoning||!1,input:l.input||[`text`],contextWindow:l.contextWindow??128e3,maxTokens:l.maxTokens??16384,cost:{input:l.cost?.input??0,output:l.cost?.output??0,cacheRead:l.cost?.cacheRead??0,cacheWrite:l.cost?.cacheWrite??0}}),o()},t[9]=l,t[10]=o,t[11]=a,t[12]=g,t[13]=_):_=t[13];let v=_,y=l,b;t[14]===y?b=t[15]:(b=Ta(y),t[14]=y,t[15]=b);let x=b,S=r?s.addModelTitle:s.editModelTitle,C;t[16]===S?C=t[17]:(C=(0,$.jsx)(Ct,{className:`text-base font-semibold text-fg`,children:S}),t[16]=S,t[17]=C);let w;t[18]!==s.modelProviderLabel||t[19]!==i?(w=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[18]=s.modelProviderLabel,t[19]=i,t[20]=w):w=t[20];let T;t[21]!==C||t[22]!==w?(T=(0,$.jsxs)(`div`,{children:[C,w]}),t[21]=C,t[22]=w,t[23]=T):T=t[23];let E;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(E=Y(Kt,`p-1.5 hover:bg-surface-base`),t[24]=E):E=t[24];let D;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(It,{className:`size-4`}),t[25]=D):D=t[25];let O;t[26]===s.close?O=t[27]:(O=(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:E,"aria-label":s.close,children:D})}),t[26]=s.close,t[27]=O);let k;t[28]!==T||t[29]!==O?(k=(0,$.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[T,O]}),t[28]=T,t[29]=O,t[30]=k):k=t[30];let A;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=A):A=t[31];let j;t[32]===s.modelId?j=t[33]:(j=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,A]}),t[32]=s.modelId,t[33]=j);let M;t[34]===d?M=t[35]:(M=Y(Ca(),d.has(`id`)&&`border-red-500`),t[34]=d,t[35]=M);let N=l.id||``,P;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>m(`id`,e.target.value),t[36]=P):P=t[36];let I=!r,L;t[37]!==M||t[38]!==N||t[39]!==I?(L=(0,$.jsx)(`input`,{className:M,value:N,onChange:P,placeholder:`e.g. llama3.1:8b`,disabled:I}),t[37]=M,t[38]=N,t[39]=I,t[40]=L):L=t[40];let R;t[41]===d?R=t[42]:(R=d.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:d.get(`id`)}):null,t[41]=d,t[42]=R);let z;t[43]!==j||t[44]!==L||t[45]!==R?(z=(0,$.jsxs)(`div`,{children:[j,L,R]}),t[43]=j,t[44]=L,t[45]=R,t[46]=z):z=t[46];let B;t[47]===s.displayName?B=t[48]:(B=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[47]=s.displayName,t[48]=B);let V;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(V=Ca(),t[49]=V):V=t[49];let H=l.name||``,U;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>m(`name`,e.target.value),t[50]=U):U=t[50];let W;t[51]===H?W=t[52]:(W=(0,$.jsx)(`input`,{className:V,value:H,onChange:U}),t[51]=H,t[52]=W);let G;t[53]!==B||t[54]!==W?(G=(0,$.jsxs)(`div`,{children:[B,W]}),t[53]=B,t[54]=W,t[55]=G):G=t[55];let ee;t[56]===s.inputTypes?ee=t[57]:(ee=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[56]=s.inputTypes,t[57]=ee);let K;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(K=wa(),t[58]=K):K=t[58];let q;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(q=e=>m(`input`,Ea(e.target.value)),t[59]=q):q=t[59];let te;t[60]===s?te=t[61]:(te=Sa.map(e=>(0,$.jsx)(`option`,{value:e.value,children:s[e.labelKey]},e.value)),t[60]=s,t[61]=te);let ne;t[62]!==x||t[63]!==te?(ne=(0,$.jsx)(`select`,{className:K,value:x,onChange:q,children:te}),t[62]=x,t[63]=te,t[64]=ne):ne=t[64];let re;t[65]!==ee||t[66]!==ne?(re=(0,$.jsxs)(`div`,{children:[ee,ne]}),t[65]=ee,t[66]=ne,t[67]=re):re=t[67];let ie=l.reasoning||!1,ae;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>m(`reasoning`,e.target.checked),t[68]=ae):ae=t[68];let oe;t[69]===ie?oe=t[70]:(oe=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:ie,onChange:ae}),t[69]=ie,t[70]=oe);let se;t[71]!==s.reasoning||t[72]!==oe?(se=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[oe,s.reasoning]}),t[71]=s.reasoning,t[72]=oe,t[73]=se):se=t[73];let ce;t[74]!==re||t[75]!==se?(ce=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[re,se]}),t[74]=re,t[75]=se,t[76]=ce):ce=t[76];let le;t[77]===s.contextWindow?le=t[78]:(le=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[77]=s.contextWindow,t[78]=le);let ue;t[79]===d?ue=t[80]:(ue=Y(Ca(),d.has(`contextWindow`)&&`border-red-500`),t[79]=d,t[80]=ue);let de=l.contextWindow??128e3,fe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>m(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=fe):fe=t[81];let pe;t[82]!==ue||t[83]!==de?(pe=(0,$.jsx)(`input`,{type:`number`,min:1,className:ue,value:de,onChange:fe}),t[82]=ue,t[83]=de,t[84]=pe):pe=t[84];let me;t[85]===d?me=t[86]:(me=d.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:d.get(`contextWindow`)}):null,t[85]=d,t[86]=me);let J;t[87]!==le||t[88]!==pe||t[89]!==me?(J=(0,$.jsxs)(`div`,{children:[le,pe,me]}),t[87]=le,t[88]=pe,t[89]=me,t[90]=J):J=t[90];let he;t[91]===s.maxOutputTokens?he=t[92]:(he=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[91]=s.maxOutputTokens,t[92]=he);let ge;t[93]===d?ge=t[94]:(ge=Y(Ca(),d.has(`maxTokens`)&&`border-red-500`),t[93]=d,t[94]=ge);let _e=l.maxTokens??16384,ve;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>m(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=ve):ve=t[95];let ye;t[96]!==ge||t[97]!==_e?(ye=(0,$.jsx)(`input`,{type:`number`,min:1,className:ge,value:_e,onChange:ve}),t[96]=ge,t[97]=_e,t[98]=ye):ye=t[98];let be;t[99]===d?be=t[100]:(be=d.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:d.get(`maxTokens`)}):null,t[99]=d,t[100]=be);let xe;t[101]!==he||t[102]!==ye||t[103]!==be?(xe=(0,$.jsxs)(`div`,{children:[he,ye,be]}),t[101]=he,t[102]=ye,t[103]=be,t[104]=xe):xe=t[104];let Se;t[105]!==J||t[106]!==xe?(Se=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[J,xe]}),t[105]=J,t[106]=xe,t[107]=Se):Se=t[107];let Ce;t[108]===s.costSection?Ce=t[109]:(Ce=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[108]=s.costSection,t[109]=Ce);let we;t[110]===s.costInput?we=t[111]:(we=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[110]=s.costInput,t[111]=we);let Te;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Te=Ca(),t[112]=Te):Te=t[112];let Ee=l.cost?.input??0,De;t[113]===l.cost?De=t[114]:(De=e=>m(`cost`,{...l.cost,input:parseFloat(e.target.value)||0,output:l.cost?.output??0,cacheRead:l.cost?.cacheRead??0,cacheWrite:l.cost?.cacheWrite??0}),t[113]=l.cost,t[114]=De);let Oe;t[115]!==Ee||t[116]!==De?(Oe=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Te,value:Ee,onChange:De}),t[115]=Ee,t[116]=De,t[117]=Oe):Oe=t[117];let ke;t[118]!==we||t[119]!==Oe?(ke=(0,$.jsxs)(`div`,{children:[we,Oe]}),t[118]=we,t[119]=Oe,t[120]=ke):ke=t[120];let Ae;t[121]===s.costOutput?Ae=t[122]:(Ae=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[121]=s.costOutput,t[122]=Ae);let je;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(je=Ca(),t[123]=je):je=t[123];let Me=l.cost?.output??0,Ne;t[124]===l.cost?Ne=t[125]:(Ne=e=>m(`cost`,{...l.cost,input:l.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:l.cost?.cacheRead??0,cacheWrite:l.cost?.cacheWrite??0}),t[124]=l.cost,t[125]=Ne);let Pe;t[126]!==Me||t[127]!==Ne?(Pe=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:je,value:Me,onChange:Ne}),t[126]=Me,t[127]=Ne,t[128]=Pe):Pe=t[128];let Fe;t[129]!==Ae||t[130]!==Pe?(Fe=(0,$.jsxs)(`div`,{children:[Ae,Pe]}),t[129]=Ae,t[130]=Pe,t[131]=Fe):Fe=t[131];let Ie;t[132]!==ke||t[133]!==Fe?(Ie=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[ke,Fe]}),t[132]=ke,t[133]=Fe,t[134]=Ie):Ie=t[134];let Le;t[135]!==Ce||t[136]!==Ie?(Le=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Ce,Ie]}),t[135]=Ce,t[136]=Ie,t[137]=Le):Le=t[137];let Re;t[138]!==z||t[139]!==G||t[140]!==ce||t[141]!==Se||t[142]!==Le?(Re=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[z,G,ce,Se,Le]}),t[138]=z,t[139]=G,t[140]=ce,t[141]=Se,t[142]=Le,t[143]=Re):Re=t[143];let ze;t[144]===s.cancel?ze=t[145]:(ze=(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`secondary`,children:s.cancel})}),t[144]=s.cancel,t[145]=ze);let Be=r?s.addModelConfirm:s.saveModelConfirm,Ve;t[146]!==v||t[147]!==Be?(Ve=(0,$.jsx)(X,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:v,children:Be}),t[146]=v,t[147]=Be,t[148]=Ve):Ve=t[148];let He;t[149]!==ze||t[150]!==Ve?(He=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[ze,Ve]}),t[149]=ze,t[150]=Ve,t[151]=He):He=t[151];let Ue;return t[152]!==k||t[153]!==Re||t[154]!==He?(Ue=(0,$.jsxs)($.Fragment,{children:[k,Re,He]}),t[152]=k,t[153]=Re,t[154]=He,t[155]=Ue):Ue=t[155],Ue}function Fa(){return new Map}function Ia(e){let t=(0,Q.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(V,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Ze)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,sn,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=u):u=t[1];let d;t[2]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(d=n?(0,$.jsx)(Pa,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=d):d=t[9];let f;t[10]===d?f=t[11]:(f=(0,$.jsxs)(R,{children:[l,(0,$.jsx)(nn,{className:u,onOpenAutoFocus:La,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(ve,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function La(e){return e.preventDefault()}function Ra(e){let t=(0,Q.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>Rt(n).then(za),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,$.jsx)(Ke,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function za(e){return e.apiKey??null}function Ba(e){let t=(0,Q.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(V,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Ze)}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=Y(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,sn),t[1]=p):p=t[1];let m;t[2]!==c||t[3]!==o||t[4]!==s||t[5]!==a||t[6]!==l||t[7]!==u||t[8]!==r||t[9]!==d||t[10]!==i?(m=(0,$.jsxs)(R,{children:[f,(0,$.jsx)(nn,{className:p,children:a?(0,$.jsx)(Ha,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d}):(0,$.jsx)(Va,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d})})]}),t[2]=c,t[3]=o,t[4]=s,t[5]=a,t[6]=l,t[7]=u,t[8]=r,t[9]=d,t[10]=i,t[11]=m):m=t[11];let h;return t[12]!==r||t[13]!==n||t[14]!==m?(h=(0,$.jsx)(ve,{open:n,onOpenChange:r,children:m}),t[12]=r,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function Va({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let c=t.find(t=>t.id===e),l=Re[e],u=n.filter(t=>t.provider===e),[d,f]=(0,Z.useState)(c?.apiKey??``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(!1),S=s(i).providersSettings,C=c?.supportsApiKey!==!1,w=c?.supportsOAuth===!0,T=c?.authMode===`oauth`&&c.authStatus===`connected`,E=c?.configured===!0&&c.activeKeySource!==`env`&&c.activeKeySource!==`extension`&&c.activeKeySource!==`models_json`,[D,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(`idle`),[N,P]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(null),[R,B]=(0,Z.useState)(``),V=j===`waiting`||j===`waiting_code`,H=(0,Z.useMemo)(()=>Ge(e,i),[e,i]),W=d!==(c?.apiKey??``),G=async()=>{let t=d.trim();if(!(!t||!C||Me(t))){h(!0),y(null);try{await U({[e]:t}),_(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){y(e instanceof Error?e.message:r.saveError)}finally{h(!1)}}};(0,Z.useEffect)(()=>{if(!D||!V)return;let e=window.setInterval(()=>{(async()=>{try{let t=await pa(D);t.status===`waiting_auth`||t.status===`waiting_code`?(M(t.status===`waiting_code`?`waiting_code`:`waiting`),A(t.message??null),P(t.authUrl??null),L(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),M(`success`),A(t.message??S.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),M(`error`),A(t.error??t.message??S.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[D,V,a,o,S.revokeFailed,S.saved]),(0,Z.useEffect)(()=>()=>{D&&ga(D).catch(()=>{})},[D]);let ee=async()=>{try{await Pe(e),o(),a()}catch{}},K=async()=>{M(`waiting`),A(S.oauthStarting),y(null);try{O((await fa(e)).sessionId)}catch(e){M(`error`),A(e instanceof Error?e.message:S.revokeFailed)}},q=async()=>{if(D){try{await ha(D)}catch{}M(`idle`),A(null),O(null),P(null),L(null)}},te=async()=>{if(!(!D||!R.trim()))try{await ma(D,R.trim()),B(``),A(S.oauthProcessingCode)}catch(e){M(`error`),A(e instanceof Error?e.message:S.revokeFailed)}},re=async()=>{try{await _a(e),o(),a()}catch(e){y(e instanceof Error?e.message:S.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(Ct,{className:`text-base font-semibold text-fg`,children:c?.name??e}),(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,jt.press),children:(0,$.jsx)(It,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[l?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.description}):null,c?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:c.baseUrl})]}):c?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,C?(0,$.jsx)(Ra,{providerId:e,inputId:`manage-api-key`,value:d,onChange:e=>{f(e),_(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):c?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),c?.extensionId?(0,$.jsxs)(ne,{to:`/settings/ext/${encodeURIComponent(c.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(Dt,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,w?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:S.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:T?S.sourceOauth:S.oauthHint})]}),T?(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void re(),children:S.revoke}):(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:V,onClick:()=>void K(),children:[V?(0,$.jsx)(J,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(z,{className:`size-3.5`,"aria-hidden":!0}),S.oauth]})]}),k?(0,$.jsx)(`p`,{className:Y(`text-xs`,j===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:k}):null,j===`waiting`||j===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[N?(0,$.jsxs)(`a`,{href:N,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[(0,$.jsx)(Dt,{className:`size-4`,"aria-hidden":!0}),S.openAuthPage]}):null,(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>void q(),children:S.cancelOAuth})]}):null,I?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:I}):null,j===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:R,onChange:e=>B(e.target.value),onKeyDown:e=>e.key===`Enter`&&void te(),placeholder:S.pasteRedirectUrl,className:Y(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Tt)}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void te(),children:S.submitCode})]}):null]}):null,H.length>0&&C?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:H.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[ye(e,r),(0,$.jsx)(Dt,{className:`size-3`,"aria-hidden":!0})]},e))}):null,u.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,u.length,`)`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.map(e=>(0,$.jsx)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:e.id.includes(`/`)?e.id.split(`/`).pop():e.id},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),v?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[E?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>x(!0),children:[(0,$.jsx)(en,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:C&&W&&!Me(d.trim())?(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!d.trim()||m||g,onClick:()=>void G(),children:g?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):m?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(J,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(rn,{open:b,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,c?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void ee(),onCancel:()=>x(!1)})]})}function Ha({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let o=s(r).modelsSettings,c=t?.providers[e],[l,u]=(0,Z.useState)(c?.baseUrl??``),[d,f]=(0,Z.useState)(c?.apiKey??``),[p,m]=(0,Z.useState)(c?.models??[]),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),D=n=>{if(!t)return null;let r=d.trim(),i={...c,baseUrl:l.trim()||void 0,apiKey:Me(r)?c?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},O=async()=>{let e=D({models:p});if(e){g(!0),v(null);try{await ea(e),a(),i()}catch(e){v(e instanceof Error?e.message:n.saveError)}finally{g(!1)}}},k=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await ea({providers:r}),a(),i()}catch{}},A=(e,t)=>{E({model:e,isNew:t}),w(!0)},j=async e=>{if(!T)return;let t=T.isNew?[...p,e]:p.map(t=>t.id===e.id?e:t);m(t);let r=D({models:t});if(r)try{await ea(r),a()}catch(e){v(e instanceof Error?e.message:n.saveError)}},M=async e=>{let t=p.filter(t=>t.id!==e);m(t),S(null);let r=D({models:t});if(r)try{await ea(r),a()}catch(e){v(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ct,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,jt.press),children:(0,$.jsx)(It,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:l,onChange:e=>u(e.target.value),className:Y(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Tt)})]}),(0,$.jsx)(Ra,{providerId:e,inputId:`manage-custom-api-key`,value:d,onChange:f,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[o.modelsSection,p.length>0?` (${p.length})`:``]}),(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>A(null,!0),children:[(0,$.jsx)(Ut,{className:`size-3.5`,"aria-hidden":!0}),o.addModel]})]}),p.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:p.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,jt.press),onClick:()=>A(e,!1),"aria-label":o.editModel,children:(0,$.jsx)(Ft,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,jt.press),onClick:()=>S(e.id),"aria-label":o.removeModel,children:(0,$.jsx)(en,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),_?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:_}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>b(!0),children:[(0,$.jsx)(en,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:h,onClick:()=>void O(),children:h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(J,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(rn,{open:y,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void k(),onCancel:()=>b(!1)}),(0,$.jsx)(rn,{open:x!==null,title:o.removeModel,description:o.removeModelConfirm.replace(`{{id}}`,x??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{x&&M(x)},onCancel:()=>S(null)}),(0,$.jsx)(Ia,{open:C,onOpenChange:e=>{w(e),e||E(null)},providerId:e,model:T?.model??null,isNew:T?.isNew??!1,onSave:e=>void j(e),m:o})]})}var Ua=[`services`,`image-models`,`voice`,`search`];function Wa(e){let t=(e??``).trim();return Ua.includes(t)?t:`services`}function Ga(){let e=(0,Q.c)(72),t=a(qa),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n,i=r.modelsHub,[o,c]=C(),l;e[2]===o?l=e[3]:(l=Wa(o.get(`tab`)),e[2]=o,e[3]=l);let u=l,[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),h=na(),g;e[4]!==i.servicesHint||e[5]!==i.tabs.services?(g={id:`services`,icon:$e,label:i.tabs.services,hint:i.servicesHint},e[4]=i.servicesHint,e[5]=i.tabs.services,e[6]=g):g=e[6];let _;e[7]!==i.imageModelsHint||e[8]!==i.tabs.imageModels?(_={id:`image-models`,icon:W,label:i.tabs.imageModels,hint:i.imageModelsHint},e[7]=i.imageModelsHint,e[8]=i.tabs.imageModels,e[9]=_):_=e[9];let v;e[10]!==i.tabs.voice||e[11]!==i.voiceHint?(v={id:`voice`,icon:Ee,label:i.tabs.voice,hint:i.voiceHint},e[10]=i.tabs.voice,e[11]=i.voiceHint,e[12]=v):v=e[12];let y;e[13]!==i.searchHint||e[14]!==i.tabs.search?(y={id:`search`,icon:He,label:i.tabs.search,hint:i.searchHint},e[13]=i.searchHint,e[14]=i.tabs.search,e[15]=y):y=e[15];let b;e[16]!==g||e[17]!==_||e[18]!==v||e[19]!==y?(b=[g,_,v,y],e[16]=g,e[17]=_,e[18]=v,e[19]=y,e[20]=b):b=e[20];let x=b,S;e[21]===c?S=e[22]:(S=e=>{c(t=>{let n=new URLSearchParams(t);return e===`services`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[21]=c,e[22]=S);let w=S,T=Ka,E;e[23]===r.settingsSections.credentials?E=e[24]:(E=(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.settingsSections.credentials}),e[23]=r.settingsSections.credentials,e[24]=E);let D;e[25]===i.subtitle?D=e[26]:(D=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.subtitle}),e[25]=i.subtitle,e[26]=D);let O;e[27]===t?O=e[28]:(O=Le(t,`configuration`),e[27]=t,e[28]=O);let k;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(Dt,{className:`size-3.5`,"aria-hidden":!0}),e[29]=k):k=e[29];let A;e[30]!==i.docsLink||e[31]!==O?(A=(0,$.jsxs)(`a`,{href:O,target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[i.docsLink,k]}),e[30]=i.docsLink,e[31]=O,e[32]=A):A=e[32];let j;e[33]!==A||e[34]!==E||e[35]!==D?(j=(0,$.jsx)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[E,D,A]})}),e[33]=A,e[34]=E,e[35]=D,e[36]=j):j=e[36];let M;e[37]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(Ui,{}),e[37]=M):M=e[37];let N=i.tabsAria,P;e[38]!==u||e[39]!==w?(P=e=>{e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),w(Ua[(Ua.indexOf(u)+(e.key===`ArrowRight`?1:-1)+Ua.length)%Ua.length]))},e[38]=u,e[39]=w,e[40]=P):P=e[40];let F;e[41]!==u||e[42]!==w||e[43]!==x?(F=x.map(e=>{let{id:t,icon:n,label:r}=e,i=t===u;return(0,$.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":i,id:`hub-tab-${t}`,"aria-controls":`hub-panel-${t}`,className:Y(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,jt.press,i?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>w(t),children:[(0,$.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r})]},t)}),e[41]=u,e[42]=w,e[43]=x,e[44]=F):F=e[44];let I;e[45]!==i.tabsAria||e[46]!==P||e[47]!==F?(I=(0,$.jsx)(`div`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,"aria-label":N,onKeyDown:P,children:F}),e[45]=i.tabsAria,e[46]=P,e[47]=F,e[48]=I):I=e[48];let L;e[49]!==u||e[50]!==i.connectedProviders||e[51]!==x?(L=x.map(e=>(0,$.jsx)(Ya,{id:e.id,activeTab:u,hint:e.hint,children:e.id===`services`?(0,$.jsx)(ca,{labels:i.connectedProviders,onAdd:()=>f(!0),onManage:(e,t)=>m({providerId:e,isCustom:t})}):(0,$.jsx)(Ja,{tab:e.id})},e.id)),e[49]=u,e[50]=i.connectedProviders,e[51]=x,e[52]=L):L=e[52];let R;e[53]!==d||e[54]!==i.addProviderDialog||e[55]!==t||e[56]!==h.builtinRows||e[57]!==h.customConfig?(R=(0,$.jsx)(Da,{open:d,onOpenChange:f,builtinRows:h.builtinRows,customConfig:h.customConfig,labels:i.addProviderDialog,language:t,onSaved:T}),e[53]=d,e[54]=i.addProviderDialog,e[55]=t,e[56]=h.builtinRows,e[57]=h.customConfig,e[58]=R):R=e[58];let z;e[59]!==i.manageProviderDialog||e[60]!==t||e[61]!==p||e[62]!==h.allModels||e[63]!==h.builtinRows||e[64]!==h.customConfig?(z=p?(0,$.jsx)(Ba,{open:!0,onOpenChange:e=>{e||m(null)},providerId:p.providerId,isCustom:p.isCustom,builtinRows:h.builtinRows,customConfig:h.customConfig,allModels:h.allModels,labels:i.manageProviderDialog,language:t,onSaved:T}):null,e[59]=i.manageProviderDialog,e[60]=t,e[61]=p,e[62]=h.allModels,e[63]=h.builtinRows,e[64]=h.customConfig,e[65]=z):z=e[65];let B;return e[66]!==j||e[67]!==I||e[68]!==L||e[69]!==R||e[70]!==z?(B=(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-4 px-4 py-6`,children:[j,M,I,L,R,z]}),e[66]=j,e[67]=I,e[68]=L,e[69]=R,e[70]=z,e[71]=B):B=e[71],B}function Ka(){Be()}function qa(e){return e.language}function Ja(e){let t=(0,Q.c)(3),{tab:n}=e;switch(n){case`services`:return null;case`image-models`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(qr,{embedded:!0}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_i,{embedded:!0}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Bi,{embedded:!0}),t[2]=e):e=t[2],e}}}function Ya({id:e,activeTab:t,hint:n,children:r}){let i=e===t,a=(0,Z.useRef)(i);return i&&(a.current=!0),a.current?(0,$.jsxs)(`div`,{role:`tabpanel`,id:`hub-panel-${e}`,"aria-labelledby":`hub-tab-${e}`,hidden:!i,className:Y(i?`flex min-w-0 flex-col gap-3`:void 0),children:[i?(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}function Xa(){return Y(`rounded-xl border border-edge-subtle bg-surface-base px-4 py-1 sm:px-5`)}var Za={default:{light:{canvas:`#f5f5f7`,panel:`#ffffff`,accent:`#2563eb`,fg:`#1d1d1f`,muted:`#d2d2d7`},dark:{canvas:`#1c1c1e`,panel:`#2c2c2e`,accent:`#3b82f6`,fg:`#f5f5f7`,muted:`#48484a`}},emerald:{light:{canvas:`#f0fdf4`,panel:`#ffffff`,accent:`#059669`,fg:`#052e16`,muted:`#86efac`},dark:{canvas:`#000000`,panel:`#0a0a0a`,accent:`#10b981`,fg:`#d1fae5`,muted:`#134e2a`}},mono:{light:{canvas:`#ffffff`,panel:`#f5f5f5`,accent:`#111111`,fg:`#111111`,muted:`#e5e7eb`},dark:{canvas:`#101010`,panel:`#1a1a1a`,accent:`#737373`,fg:`#fafafa`,muted:`#333333`}},clay:{light:{canvas:`#fffaf0`,panel:`#ffffff`,accent:`#1a3a3a`,fg:`#0a0a0a`,muted:`#e5e5e5`},dark:{canvas:`#0a1a1a`,panel:`#1a2a2a`,accent:`#ffb084`,fg:`#fffaf0`,muted:`#2a3a3a`}}};function Qa(e){let t=(0,Q.c)(24),{canvas:n,panel:r,accent:i,fg:a,muted:o}=e,s;t[0]===n?s=t[1]:(s={backgroundColor:n},t[0]=n,t[1]=s);let c;t[2]!==o||t[3]!==r?(c={backgroundColor:r,borderColor:o},t[2]=o,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,$.jsx)(`div`,{className:`size-1 shrink-0 rounded-full`,style:{backgroundColor:i}}),t[5]=i,t[6]=l);let u;t[7]===a?u=t[8]:(u=(0,$.jsx)(`div`,{className:`h-1 min-w-0 flex-1 rounded-full`,style:{backgroundColor:a,opacity:.85}}),t[7]=a,t[8]=u);let d;t[9]!==l||t[10]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11];let f;t[12]===o?f=t[13]:(f=(0,$.jsx)(`div`,{className:`h-1 w-2/3 max-w-[70%] rounded-full`,style:{backgroundColor:o}}),t[12]=o,t[13]=f);let p;t[14]===o?p=t[15]:(p=(0,$.jsx)(`div`,{className:`size-1/2 max-w-[55%] rounded-full`,style:{backgroundColor:o}}),t[14]=o,t[15]=p);let m;t[16]!==c||t[17]!==d||t[18]!==f||t[19]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-sm border p-1`,style:c,children:[d,f,p]}),t[16]=c,t[17]=d,t[18]=f,t[19]=p,t[20]=m):m=t[20];let h;return t[21]!==s||t[22]!==m?(h=(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col justify-center gap-1 p-1.5`,style:s,children:m}),t[21]=s,t[22]=m,t[23]=h):h=t[23],h}function $a(e){let t=(0,Q.c)(8),{scheme:n}=e,{light:r,dark:i}=Za[n],a;t[0]===r?a=t[1]:(a=(0,$.jsx)(Qa,{...r}),t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`div`,{className:`w-px shrink-0 bg-black/12 dark:bg-white/12`,"aria-hidden":!0}),t[2]=o):o=t[2];let s;t[3]===i?s=t[4]:(s=(0,$.jsx)(Qa,{...i}),t[3]=i,t[4]=s);let c;return t[5]!==a||t[6]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-11 w-full overflow-hidden rounded-md border border-edge-subtle`,children:[a,o,s]}),t[5]=a,t[6]=s,t[7]=c):c=t[7],c}var eo=[{value:`default`,labelKey:`colorSchemeDefault`},{value:`emerald`,labelKey:`colorSchemeLightGreen`},{value:`mono`,labelKey:`colorSchemeModernMono`},{value:`clay`,labelKey:`colorSchemeClay`}];function to(){let e=(0,Q.c)(18),t=a(io),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.appearanceSettings,i=h(ro),o=h(no),c;e[2]===r.colorSchemeTitle?c=e[3]:(c=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r.colorSchemeTitle}),e[2]=r.colorSchemeTitle,e[3]=c);let l;e[4]===r.colorSchemeDescription?l=e[5]:(l=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:r.colorSchemeDescription}),e[4]=r.colorSchemeDescription,e[5]=l);let u;e[6]!==c||e[7]!==l?(u=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[c,l]}),e[6]=c,e[7]=l,e[8]=u):u=e[8];let d;e[9]!==r||e[10]!==i||e[11]!==o?(d=eo.map(e=>{let{value:t,labelKey:n}=e,a=i===t;return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":a,onClick:()=>o(t),className:Y(`flex flex-col gap-2 rounded-xl border-2 p-2.5 text-left transition-[border-color,box-shadow,transform] duration-150`,jt.pressCard,a?`border-accent shadow-[0_0_0_1px_var(--color-accent)]`:`border-edge-subtle hover:border-edge`),children:[(0,$.jsx)($a,{scheme:t}),(0,$.jsx)(`span`,{className:Y(`text-xs font-medium leading-none`,a?`text-accent-fg`:`text-fg-muted`),children:r[n]})]},t)}),e[9]=r,e[10]=i,e[11]=o,e[12]=d):d=e[12];let f;e[13]===d?f=e[14]:(f=(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:d}),e[13]=d,e[14]=f);let p;return e[15]!==u||e[16]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-b border-edge-subtle py-3.5 last:border-b-0 sm:py-4`,children:[u,f]}),e[15]=u,e[16]=f,e[17]=p):p=e[17],p}function no(e){return e.setColorScheme}function ro(e){return e.colorScheme}function io(e){return e.language}function ao(){let e=(0,Q.c)(27),t=a(co),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.appearanceSettings,i=yt(so),o=yt(oo),c;e[2]===r.developerGroupTitle?c=e[3]:(c=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r.developerGroupTitle}),e[2]=r.developerGroupTitle,e[3]=c);let l;e[4]===r.developerGroupDescription?l=e[5]:(l=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:r.developerGroupDescription}),e[4]=r.developerGroupDescription,e[5]=l);let u;e[6]!==c||e[7]!==l?(u=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[c,l]}),e[6]=c,e[7]=l,e[8]=u):u=e[8];let d;e[9]===r.showRawToolDataTitle?d=e[10]:(d=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.showRawToolDataTitle}),e[9]=r.showRawToolDataTitle,e[10]=d);let f;e[11]===r.showRawToolDataDescription?f=e[12]:(f=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.showRawToolDataDescription}),e[11]=r.showRawToolDataDescription,e[12]=f);let p;e[13]!==d||e[14]!==f?(p=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[d,f]}),e[13]=d,e[14]=f,e[15]=p):p=e[15];let m;e[16]===o?m=e[17]:(m=e=>o(e.target.checked),e[16]=o,e[17]=m);let h;e[18]!==i||e[19]!==m?(h=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i,onChange:m}),e[18]=i,e[19]=m,e[20]=h):h=e[20];let g;e[21]!==p||e[22]!==h?(g=(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[p,h]}),e[21]=p,e[22]=h,e[23]=g):g=e[23];let _;return e[24]!==u||e[25]!==g?(_=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 py-3.5 sm:py-4`,children:[u,g]}),e[24]=u,e[25]=g,e[26]=_):_=e[26],_}function oo(e){return e.setShowRawToolData}function so(e){return e.showRawToolData}function co(e){return e.language}function lo(){let e=(0,Q.c)(33),t=a(uo),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.appearanceSettings,i;e[2]===r.pageTitle?i=e[3]:(i=(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:r.pageTitle}),e[2]=r.pageTitle,e[3]=i);let o;e[4]===r.subtitle?o=e[5]:(o=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.subtitle}),e[4]=r.subtitle,e[5]=o);let c;e[6]!==i||e[7]!==o?(c=(0,$.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[i,o]}),e[6]=i,e[7]=o,e[8]=c):c=e[8];let l;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=Xa(),e[9]=l):l=e[9];let u;e[10]===r.languageTitle?u=e[11]:(u=(0,$.jsx)(`h2`,{id:`pref-language-heading`,className:`sr-only`,children:r.languageTitle}),e[10]=r.languageTitle,e[11]=u);let d;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(Vt,{variant:`page`,sections:[`language`]}),e[12]=d):d=e[12];let f;e[13]===u?f=e[14]:(f=(0,$.jsxs)(`section`,{className:l,"aria-labelledby":`pref-language-heading`,children:[u,d]}),e[13]=u,e[14]=f);let p;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(p=Xa(),e[15]=p):p=e[15];let m;e[16]===r.themeTitle?m=e[17]:(m=(0,$.jsx)(`h2`,{id:`pref-appearance-heading`,className:`sr-only`,children:r.themeTitle}),e[16]=r.themeTitle,e[17]=m);let h,g;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Vt,{variant:`page`,sections:[`theme`,`font`]}),g=(0,$.jsx)(to,{}),e[18]=h,e[19]=g):(h=e[18],g=e[19]);let _;e[20]===m?_=e[21]:(_=(0,$.jsxs)(`section`,{className:p,"aria-labelledby":`pref-appearance-heading`,children:[m,h,g]}),e[20]=m,e[21]=_);let v;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(v=Xa(),e[22]=v):v=e[22];let y;e[23]===r.developerGroupTitle?y=e[24]:(y=(0,$.jsx)(`h2`,{id:`pref-developer-heading`,className:`sr-only`,children:r.developerGroupTitle}),e[23]=r.developerGroupTitle,e[24]=y);let b;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(ao,{}),e[25]=b):b=e[25];let x;e[26]===y?x=e[27]:(x=(0,$.jsx)(kn,{children:(0,$.jsxs)(`section`,{className:v,"aria-labelledby":`pref-developer-heading`,children:[y,b]})}),e[26]=y,e[27]=x);let S;return e[28]!==_||e[29]!==x||e[30]!==c||e[31]!==f?(S=(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[c,f,_,x]}),e[28]=_,e[29]=x,e[30]=c,e[31]=f,e[32]=S):S=e[32],S}function uo(e){return e.language}var fo=typeof navigator<`u`&&(navigator.platform?.includes(`Mac`)??navigator.userAgent.includes(`Mac`))?`⌘`:`Ctrl`;function po(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`kbd`,{className:`inline-flex min-w-[1.5rem] items-center justify-center rounded-md border border-edge-subtle bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs font-medium text-fg-muted shadow-[0_1px_0_0_var(--color-edge-subtle)]`,children:n}),t[0]=n,t[1]=r),r}function mo(e){let t=(0,Q.c)(14),{keys:n,label:r,note:i}=e,a;t[0]===r?a=t[1]:(a=(0,$.jsx)(`span`,{className:`text-sm text-fg`,children:r}),t[0]=r,t[1]=a);let o;t[2]===i?o=t[3]:(o=i&&(0,$.jsxs)(`span`,{className:`ml-1.5 text-xs text-fg-muted`,children:[`(`,i,`)`]}),t[2]=i,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===n?c=t[8]:(c=n.map(ho),t[7]=n,t[8]=c);let l;t[9]===c?l=t[10]:(l=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:c}),t[9]=c,t[10]=l);let u;return t[11]!==s||t[12]!==l?(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-2.5`,children:[s,l]}),t[11]=s,t[12]=l,t[13]=u):u=t[13],u}function ho(e){return(0,$.jsx)(po,{children:e},e)}function go(e){let t=(0,Q.c)(11),{title:n,shortcuts:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=Y(`rounded-xl border border-edge-subtle bg-surface-base px-4 sm:px-5`),t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,$.jsx)(`h2`,{className:`pb-1 pt-3.5 text-sm font-semibold text-fg sm:pt-4`,children:n}),t[1]=n,t[2]=a);let o;t[3]===r?o=t[4]:(o=r.map(_o),t[3]=r,t[4]=o);let s;t[5]===o?s=t[6]:(s=(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:o}),t[5]=o,t[6]=s);let c;return t[7]!==a||t[8]!==s||t[9]!==n?(c=(0,$.jsxs)(`section`,{className:i,"aria-label":n,children:[a,s]}),t[7]=a,t[8]=s,t[9]=n,t[10]=c):c=t[10],c}function _o(e){return(0,$.jsx)(mo,{...e},e.label)}function vo(){let e=(0,Q.c)(115),t=a(bo),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.keyboardShortcutsSettings,i;if(e[2]!==r.categoryChat||e[3]!==r.categoryEditor||e[4]!==r.categoryGlobal||e[5]!==r.categoryNavigation||e[6]!==r.chatForceSend||e[7]!==r.chatNewLine||e[8]!==r.chatSend||e[9]!==r.editorBulletList||e[10]!==r.editorHeading1||e[11]!==r.editorHeading2||e[12]!==r.editorHeading3||e[13]!==r.editorOrderedList||e[14]!==r.editorTaskList||e[15]!==r.globalCommandPalette||e[16]!==r.globalNewChat||e[17]!==r.globalOpenSettings||e[18]!==r.globalToggleWindow||e[19]!==r.navCloseDialog||e[20]!==r.navCommandPalette||e[21]!==r.navQuickCapture){if(i=[],j()){let t;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(t=[fo,`Shift`,`Space`],e[23]=t):t=e[23];let n;e[24]===r.globalToggleWindow?n=e[25]:(n={keys:t,label:r.globalToggleWindow},e[24]=r.globalToggleWindow,e[25]=n);let a;e[26]===Symbol.for(`react.memo_cache_sentinel`)?(a=[fo,`,`],e[26]=a):a=e[26];let o;e[27]===r.globalOpenSettings?o=e[28]:(o={keys:a,label:r.globalOpenSettings},e[27]=r.globalOpenSettings,e[28]=o);let s;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(s=[fo,`N`],e[29]=s):s=e[29];let c;e[30]===r.globalNewChat?c=e[31]:(c={keys:s,label:r.globalNewChat},e[30]=r.globalNewChat,e[31]=c);let l;e[32]===Symbol.for(`react.memo_cache_sentinel`)?(l=[fo,`K`],e[32]=l):l=e[32];let u;e[33]===r.globalCommandPalette?u=e[34]:(u={keys:l,label:r.globalCommandPalette},e[33]=r.globalCommandPalette,e[34]=u);let d;e[35]!==n||e[36]!==o||e[37]!==c||e[38]!==u?(d=[n,o,c,u],e[35]=n,e[36]=o,e[37]=c,e[38]=u,e[39]=d):d=e[39];let f;e[40]!==r.categoryGlobal||e[41]!==d?(f={title:r.categoryGlobal,shortcuts:d},e[40]=r.categoryGlobal,e[41]=d,e[42]=f):f=e[42],i.push(f)}let t;e[43]===Symbol.for(`react.memo_cache_sentinel`)?(t=[fo,`K`],e[43]=t):t=e[43];let n;e[44]===r.navCommandPalette?n=e[45]:(n={keys:t,label:r.navCommandPalette},e[44]=r.navCommandPalette,e[45]=n);let a;e[46]===Symbol.for(`react.memo_cache_sentinel`)?(a=[fo,`.`],e[46]=a):a=e[46];let o;e[47]===r.navQuickCapture?o=e[48]:(o={keys:a,label:r.navQuickCapture},e[47]=r.navQuickCapture,e[48]=o);let s;e[49]===Symbol.for(`react.memo_cache_sentinel`)?(s=[`Esc`],e[49]=s):s=e[49];let c;e[50]===r.navCloseDialog?c=e[51]:(c={keys:s,label:r.navCloseDialog},e[50]=r.navCloseDialog,e[51]=c);let l;e[52]!==n||e[53]!==o||e[54]!==c?(l=[n,o,c],e[52]=n,e[53]=o,e[54]=c,e[55]=l):l=e[55];let u;e[56]!==r.categoryNavigation||e[57]!==l?(u={title:r.categoryNavigation,shortcuts:l},e[56]=r.categoryNavigation,e[57]=l,e[58]=u):u=e[58],i.push(u);let d;e[59]===Symbol.for(`react.memo_cache_sentinel`)?(d=[`Enter`],e[59]=d):d=e[59];let f;e[60]===r.chatSend?f=e[61]:(f={keys:d,label:r.chatSend},e[60]=r.chatSend,e[61]=f);let p;e[62]===Symbol.for(`react.memo_cache_sentinel`)?(p=[`Shift`,`Enter`],e[62]=p):p=e[62];let m;e[63]===r.chatNewLine?m=e[64]:(m={keys:p,label:r.chatNewLine},e[63]=r.chatNewLine,e[64]=m);let h;e[65]===Symbol.for(`react.memo_cache_sentinel`)?(h=[fo,`Enter`],e[65]=h):h=e[65];let g;e[66]===r.chatForceSend?g=e[67]:(g={keys:h,label:r.chatForceSend},e[66]=r.chatForceSend,e[67]=g);let _;e[68]!==f||e[69]!==m||e[70]!==g?(_=[f,m,g],e[68]=f,e[69]=m,e[70]=g,e[71]=_):_=e[71];let v;e[72]!==r.categoryChat||e[73]!==_?(v={title:r.categoryChat,shortcuts:_},e[72]=r.categoryChat,e[73]=_,e[74]=v):v=e[74],i.push(v);let y;e[75]===Symbol.for(`react.memo_cache_sentinel`)?(y=[fo,`Shift`,`1`],e[75]=y):y=e[75];let b;e[76]===r.editorHeading1?b=e[77]:(b={keys:y,label:r.editorHeading1},e[76]=r.editorHeading1,e[77]=b);let x;e[78]===Symbol.for(`react.memo_cache_sentinel`)?(x=[fo,`Shift`,`2`],e[78]=x):x=e[78];let S;e[79]===r.editorHeading2?S=e[80]:(S={keys:x,label:r.editorHeading2},e[79]=r.editorHeading2,e[80]=S);let C;e[81]===Symbol.for(`react.memo_cache_sentinel`)?(C=[fo,`Shift`,`3`],e[81]=C):C=e[81];let w;e[82]===r.editorHeading3?w=e[83]:(w={keys:C,label:r.editorHeading3},e[82]=r.editorHeading3,e[83]=w);let T;e[84]===Symbol.for(`react.memo_cache_sentinel`)?(T=[fo,`Shift`,`8`],e[84]=T):T=e[84];let E;e[85]===r.editorBulletList?E=e[86]:(E={keys:T,label:r.editorBulletList},e[85]=r.editorBulletList,e[86]=E);let D;e[87]===Symbol.for(`react.memo_cache_sentinel`)?(D=[fo,`Shift`,`9`],e[87]=D):D=e[87];let O;e[88]===r.editorOrderedList?O=e[89]:(O={keys:D,label:r.editorOrderedList},e[88]=r.editorOrderedList,e[89]=O);let k;e[90]===Symbol.for(`react.memo_cache_sentinel`)?(k=[fo,`Shift`,`0`],e[90]=k):k=e[90];let A;e[91]===r.editorTaskList?A=e[92]:(A={keys:k,label:r.editorTaskList},e[91]=r.editorTaskList,e[92]=A);let M;e[93]!==b||e[94]!==S||e[95]!==w||e[96]!==E||e[97]!==O||e[98]!==A?(M=[b,S,w,E,O,A],e[93]=b,e[94]=S,e[95]=w,e[96]=E,e[97]=O,e[98]=A,e[99]=M):M=e[99];let N;e[100]!==r.categoryEditor||e[101]!==M?(N={title:r.categoryEditor,shortcuts:M},e[100]=r.categoryEditor,e[101]=M,e[102]=N):N=e[102],i.push(N),e[2]=r.categoryChat,e[3]=r.categoryEditor,e[4]=r.categoryGlobal,e[5]=r.categoryNavigation,e[6]=r.chatForceSend,e[7]=r.chatNewLine,e[8]=r.chatSend,e[9]=r.editorBulletList,e[10]=r.editorHeading1,e[11]=r.editorHeading2,e[12]=r.editorHeading3,e[13]=r.editorOrderedList,e[14]=r.editorTaskList,e[15]=r.globalCommandPalette,e[16]=r.globalNewChat,e[17]=r.globalOpenSettings,e[18]=r.globalToggleWindow,e[19]=r.navCloseDialog,e[20]=r.navCommandPalette,e[21]=r.navQuickCapture,e[22]=i}else i=e[22];let o;e[103]===r.pageTitle?o=e[104]:(o=(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:r.pageTitle}),e[103]=r.pageTitle,e[104]=o);let c;e[105]===r.subtitle?c=e[106]:(c=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.subtitle}),e[105]=r.subtitle,e[106]=c);let l;e[107]!==o||e[108]!==c?(l=(0,$.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[o,c]}),e[107]=o,e[108]=c,e[109]=l):l=e[109];let u;e[110]===i?u=e[111]:(u=i.map(yo),e[110]=i,e[111]=u);let d;return e[112]!==l||e[113]!==u?(d=(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[l,u]}),e[112]=l,e[113]=u,e[114]=d):d=e[114],d}function yo(e){return(0,$.jsx)(go,{...e},e.title)}function bo(e){return e.language}function xo(){return l(`/api/dreaming`)}async function So(){let e=await _(xo());if(!e.payload)throw Error(`Missing payload`);return e.payload}async function Co(e){await _(l(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e})})}async function wo(e=`deep`){let t=await _(l(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e})}),n=!!t.payload?.triggered,r=typeof t.payload?.jobId==`string`?t.payload.jobId:``;if(!n||!r)throw Error(`Failed to trigger`);return{triggered:n,jobId:r,phase:e}}async function To(e){let t=await _(l(`/api/dreaming/preview${typeof e==`number`&&Number.isFinite(e)?`?limit=${encodeURIComponent(String(e))}`:``}`));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function Eo(e=50){return(await _(l(`/api/dreaming/events${`?limit=${encodeURIComponent(String(e))}`}`))).payload?.events??[]}function Do(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Oo={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},ko={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},Ao={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},jo={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:Oo,deep:ko,rem:Ao};function Mo(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function No(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function Po(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function Fo(e){let t=Do(e)?e:{},n=Do(t.agents)?t.agents:{},r=Do(n.defaults)?n.defaults:{},i=Do(r.memory)?r.memory:{},a=Do(i.dreaming)?i.dreaming:{},o=Do(a.phases)?a.phases:{},s=Do(o.light)?o.light:{},c=Do(o.deep)?o.deep:{},l=Do(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():jo.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:Mo(typeof c.minScore==`number`?c.minScore:Number(c.minScore),jo.minScore),minRecallCount:Math.max(1,No(c.minRecallCount,jo.minRecallCount)),limit:No(c.limit,jo.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():Oo.cron,lookbackDays:Math.max(1,No(s.lookbackDays,Oo.lookbackDays)),limit:No(s.limit,Oo.limit),dedupeSimilarity:Mo(Po(s.dedupeSimilarity,Oo.dedupeSimilarity),Oo.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():ko.cron,minScore:Mo(Po(c.minScore,ko.minScore),ko.minScore),minRecallCount:Math.max(1,No(c.minRecallCount,ko.minRecallCount)),limit:No(c.limit,ko.limit),recencyHalfLifeDays:Math.max(1,Po(c.recencyHalfLifeDays,ko.recencyHalfLifeDays)),maxAgeDays:Math.max(1,Po(c.maxAgeDays,ko.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():Ao.cron,lookbackDays:Math.max(1,No(l.lookbackDays,Ao.lookbackDays)),limit:No(l.limit,Ao.limit),minPatternStrength:Mo(Po(l.minPatternStrength,Ao.minPatternStrength),Ao.minPatternStrength)}}}async function Io(e){let t=e.frequency.trim(),n=e.timezone.trim();await _(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({agents:{defaults:{memory:{dreaming:{enabled:!!e.enabled,frequency:t||null,timezone:n||null,phases:{light:{enabled:!!e.light.enabled,cron:e.light.cron.trim()||null,lookbackDays:Math.max(1,Math.floor(e.light.lookbackDays)),limit:Math.max(0,Math.floor(e.light.limit)),dedupeSimilarity:Mo(e.light.dedupeSimilarity,Oo.dedupeSimilarity)},deep:{enabled:!!e.deep.enabled,cron:e.deep.cron.trim()||null,minScore:Mo(e.deep.minScore,ko.minScore),minRecallCount:Math.max(1,Math.floor(e.deep.minRecallCount)),limit:Math.max(0,Math.floor(e.deep.limit)),recencyHalfLifeDays:Math.max(1,e.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,e.deep.maxAgeDays)},rem:{enabled:!!e.rem.enabled,cron:e.rem.cron.trim()||null,lookbackDays:Math.max(1,Math.floor(e.rem.lookbackDays)),limit:Math.max(0,Math.floor(e.rem.limit)),minPatternStrength:Mo(e.rem.minPatternStrength,Ao.minPatternStrength)}}}}}}})}),Xt()}var Lo=`p-4 sm:px-5`,Ro=`mb-3`,zo=`rounded-xl border border-edge-subtle bg-surface-panel/30 p-3 sm:p-4`,Bo=Y(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,Je);function Vo(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function Ho(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function Uo(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var Wo=Y(`h-9 min-w-0 flex-1 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm tabular-nums text-fg`,Je),Go=Y(et,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function Ko(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return String(e)}}function qo({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=En,minSeconds:a=1}){let o=(0,Z.useMemo)(()=>new Set(i),[i]),s=(0,Z.useMemo)(()=>o.has(e)?String(e):``,[o,e]),[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(e);u.current!==e&&(u.current=e,l(null));let d=Math.max(a,Math.round(e/1e3)),f=c===null?String(d):c;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`input`,{type:`number`,min:a,step:1,disabled:r,className:Wo,value:f,onChange:e=>{let n=e.target.value;l(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=a&&t(r*1e3)},onBlur:()=>{if(c===null)return;let e=parseInt(c,10);t(!Number.isFinite(e)||e<a?a*1e3:e*1e3),l(null)}}),(0,$.jsxs)(`select`,{className:Go,disabled:r,value:s,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),l(null))},children:[(0,$.jsx)(`option`,{value:``,children:n.presets.custom}),i.map(e=>(0,$.jsx)(`option`,{value:String(e),children:Ko(e,n.presets)},e))]})]})]})}var Jo=Y(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,Je),Yo=()=>({start:`09:00`,end:`22:00`,timezone:``});function Xo(e){let t=(0,Q.c)(55),{value:n,onChange:r,labels:i,disabled:a}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(Yo()),t[0]=r,t[1]=e);let n;return t[2]!==a||t[3]!==i.add||t[4]!==e?(n=(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`text-sm`,disabled:a,onClick:e,children:i.add}),t[2]=a,t[3]=i.add,t[4]=e,t[5]=n):n=t[5],n}let o;t[6]===i.start?o=t[7]:(o=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=o);let s;t[8]!==r||t[9]!==n?(s=e=>r({...n,start:e.target.value}),t[8]=r,t[9]=n,t[10]=s):s=t[10];let c;t[11]!==a||t[12]!==s||t[13]!==n.start?(c=(0,$.jsx)(`input`,{type:`time`,step:60,disabled:a,className:Jo,value:n.start,onChange:s}),t[11]=a,t[12]=s,t[13]=n.start,t[14]=c):c=t[14];let l;t[15]!==o||t[16]!==c?(l=(0,$.jsxs)(`label`,{className:`block min-w-0`,children:[o,c]}),t[15]=o,t[16]=c,t[17]=l):l=t[17];let u;t[18]===i.end?u=t[19]:(u=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[18]=i.end,t[19]=u);let d;t[20]!==r||t[21]!==n?(d=e=>r({...n,end:e.target.value}),t[20]=r,t[21]=n,t[22]=d):d=t[22];let f;t[23]!==a||t[24]!==d||t[25]!==n.end?(f=(0,$.jsx)(`input`,{type:`time`,step:60,disabled:a,className:Jo,value:n.end,onChange:d}),t[23]=a,t[24]=d,t[25]=n.end,t[26]=f):f=t[26];let p;t[27]!==u||t[28]!==f?(p=(0,$.jsxs)(`label`,{className:`block min-w-0`,children:[u,f]}),t[27]=u,t[28]=f,t[29]=p):p=t[29];let m;t[30]===i.timezone?m=t[31]:(m=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[30]=i.timezone,t[31]=m);let h;t[32]!==r||t[33]!==n?(h=e=>r({...n,timezone:e.target.value}),t[32]=r,t[33]=n,t[34]=h):h=t[34];let g;t[35]!==a||t[36]!==h||t[37]!==n.timezone?(g=(0,$.jsx)(`input`,{type:`text`,disabled:a,className:Jo,value:n.timezone,onChange:h,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[35]=a,t[36]=h,t[37]=n.timezone,t[38]=g):g=t[38];let _;t[39]!==g||t[40]!==m?(_=(0,$.jsxs)(`label`,{className:`block min-w-0`,children:[m,g]}),t[39]=g,t[40]=m,t[41]=_):_=t[41];let v;t[42]!==_||t[43]!==l||t[44]!==p?(v=(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[l,p,_]}),t[42]=_,t[43]=l,t[44]=p,t[45]=v):v=t[45];let y;t[46]===r?y=t[47]:(y=()=>r(null),t[46]=r,t[47]=y);let b;t[48]!==a||t[49]!==i.clear||t[50]!==y?(b=(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:a,onClick:y,children:i.clear}),t[48]=a,t[49]=i.clear,t[50]=y,t[51]=b):b=t[51];let x;return t[52]!==v||t[53]!==b?(x=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[v,b]}),t[52]=v,t[53]=b,t[54]=x):x=t[54],x}function Zo(e){let t=(0,Q.c)(34),{disabled:n,label:r,hint:i,className:a}=e,o;t[0]===a?o=t[1]:(o=Y(`flex flex-col gap-2`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=r?(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r}):null,t[2]=r,t[3]=s);let c;t[4]!==n||t[5]!==r||t[6]!==e.kind||t[7]!==e.labels||t[8]!==e.onChange||t[9]!==e.value?(c=e.kind===`cron`?(0,$.jsx)(tr,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n,showHeading:!r}):null,t[4]=n,t[5]=r,t[6]=e.kind,t[7]=e.labels,t[8]=e.onChange,t[9]=e.value,t[10]=c):c=t[10];let l;t[11]!==n||t[12]!==e.kind||t[13]!==e.labels||t[14]!==e.minSeconds||t[15]!==e.onChangeMs||t[16]!==e.presets||t[17]!==e.valueMs?(l=e.kind===`interval`?(0,$.jsx)(qo,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??En,minSeconds:e.minSeconds}):null,t[11]=n,t[12]=e.kind,t[13]=e.labels,t[14]=e.minSeconds,t[15]=e.onChangeMs,t[16]=e.presets,t[17]=e.valueMs,t[18]=l):l=t[18];let u;t[19]!==n||t[20]!==e.kind||t[21]!==e.labels||t[22]!==e.onChange||t[23]!==e.value?(u=e.kind===`active-hours`?(0,$.jsx)(Xo,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n}):null,t[19]=n,t[20]=e.kind,t[21]=e.labels,t[22]=e.onChange,t[23]=e.value,t[24]=u):u=t[24];let d;t[25]===i?d=t[26]:(d=i?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}):null,t[25]=i,t[26]=d);let f;return t[27]!==o||t[28]!==s||t[29]!==c||t[30]!==l||t[31]!==u||t[32]!==d?(f=(0,$.jsxs)(`div`,{className:o,children:[s,c,l,u,d]}),t[27]=o,t[28]=s,t[29]=c,t[30]=l,t[31]=u,t[32]=d,t[33]=f):f=t[33],f}var Qo=`text-xs font-medium text-fg-muted`,$o=`text-sm font-medium text-fg`;function es(e){let t=(0,Q.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{className:Qo,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,$.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function ts(e){let t=(0,Q.c)(11),{label:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=Y(`min-w-0`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`dt`,{className:Qo,children:n}),t[2]=n,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=Y($o,`mt-0.5`),t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=(0,$.jsx)(`dd`,{className:s,children:r}),t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==o||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:a,children:[o,c]}),t[7]=a,t[8]=o,t[9]=c,t[10]=l):l=t[10],l}function ns(e){let t=(0,Q.c)(5),{label:n,className:r}=e,i;t[0]===r?i=t[1]:(i=Y(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`h3`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function rs(e){let t=(0,Q.c)(38),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,onLabel:d,offLabel:f,cronLabel:p,children:m}=e,h;t[0]===n?h=t[1]:(h=(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=h);let g;t[2]===r?g=t[3]:(g=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=g);let _;t[4]===i?_=t[5]:(_=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[4]=i,t[5]=_);let v;t[6]!==g||t[7]!==_?(v=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[g,_]}),t[6]=g,t[7]=_,t[8]=v):v=t[8];let y;t[9]!==h||t[10]!==v?(y=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[h,v]}),t[9]=h,t[10]=v,t[11]=y):y=t[11];let b;t[12]===o?b=t[13]:(b=e=>o(e.target.checked),t[12]=o,t[13]=b);let x;t[14]!==u||t[15]!==a||t[16]!==b?(x=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:b}),t[14]=u,t[15]=a,t[16]=b,t[17]=x):x=t[17];let S=a?d:f,C;t[18]===S?C=t[19]:(C=(0,$.jsx)(`span`,{children:S}),t[18]=S,t[19]=C);let w;t[20]!==x||t[21]!==C?(w=(0,$.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[x,C]}),t[20]=x,t[21]=C,t[22]=w):w=t[22];let T;t[23]!==w||t[24]!==y?(T=(0,$.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 border-b border-edge-subtle/80 pb-2.5`,children:[y,w]}),t[23]=w,t[24]=y,t[25]=T):T=t[25];let E;t[26]!==s||t[27]!==p||t[28]!==u||t[29]!==c||t[30]!==l?(E=(0,$.jsx)(Zo,{kind:`cron`,className:`mb-2.5`,label:p,value:s,onChange:c,labels:l,disabled:u}),t[26]=s,t[27]=p,t[28]=u,t[29]=c,t[30]=l,t[31]=E):E=t[31];let D;t[32]===m?D=t[33]:(D=(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:m}),t[32]=m,t[33]=D);let O;return t[34]!==T||t[35]!==E||t[36]!==D?(O=(0,$.jsxs)(`div`,{className:zo,children:[T,E,D]}),t[34]=T,t[35]=E,t[36]=D,t[37]=O):O=t[37],O}function is(e){let t=(0,Q.c)(23),{icon:n,label:r,enabled:i,cron:a,scheduleSummary:o,details:s,t:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=Y(zo,`space-y-1`),t[0]=l):l=t[0];let u;t[1]===r?u=t[2]:(u=(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=u);let d=i?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,f;t[3]===d?f=t[4]:(f=Y(`ml-auto text-xs font-medium`,d),t[3]=d,t[4]=f);let p=i?c.on:c.off,m;t[5]!==f||t[6]!==p?(m=(0,$.jsx)(`span`,{className:f,children:p}),t[5]=f,t[6]=p,t[7]=m):m=t[7];let h;t[8]!==n||t[9]!==u||t[10]!==m?(h=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,u,m]}),t[8]=n,t[9]=u,t[10]=m,t[11]=h):h=t[11];let g;t[12]===o?g=t[13]:(g=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:o}),t[12]=o,t[13]=g);let _;t[14]===a?_=t[15]:(_=(0,$.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:a,children:a}),t[14]=a,t[15]=_);let v;t[16]===s?v=t[17]:(v=(0,$.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:s}),t[16]=s,t[17]=v);let y;return t[18]!==v||t[19]!==h||t[20]!==g||t[21]!==_?(y=(0,$.jsxs)(`div`,{className:l,children:[h,g,_,v]}),t[18]=v,t[19]=h,t[20]=g,t[21]=_,t[22]=y):y=t[22],y}function as(e){let t=(0,Q.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(ns,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,$.jsxs)(`details`,{className:`group rounded-lg border border-edge-subtle`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,$.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,$.jsx)(`pre`,{className:`max-h-40 overflow-auto border-t border-edge-subtle p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle/80 pt-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function os(e){let t=(0,Q.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,$.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,$.jsx)(ts,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=Ho(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,$.jsx)(ts,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,$.jsx)(ts,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,$.jsx)(ts,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,$.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,$.jsxs)(ts,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ts,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,$.jsx)(ts,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,$.jsx)(ts,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,$.jsx)(ts,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,$.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function ss(e){let t=(0,Q.c)(58),{t:n,schedulePickerLabels:r,hasToken:i,cfgForm:a,cfgBaseline:o,cfgSaving:s,cfgDirty:c,setCfgForm:l,setCfgOk:u,setCfgError:d,saveConfig:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=Y(`min-w-0`,Lo),t[0]=p):p=t[0];let m=!i||!a||s||!c,h;t[1]===f?h=t[2]:(h=()=>void f(),t[1]=f,t[2]=h);let g;t[3]===s?g=t[4]:(g=s?(0,$.jsx)(J,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[3]=s,t[4]=g);let _;t[5]!==n.saveConfig||t[6]!==m||t[7]!==h||t[8]!==g?(_=(0,$.jsxs)(X,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:m,onClick:h,children:[g,n.saveConfig]}),t[5]=n.saveConfig,t[6]=m,t[7]=h,t[8]=g,t[9]=_):_=t[9];let v=!i||!a||s||!c,y;t[10]!==o||t[11]!==d||t[12]!==l||t[13]!==u?(y=()=>{u(!1),d(null),l(o)},t[10]=o,t[11]=d,t[12]=l,t[13]=u,t[14]=y):y=t[14];let b;t[15]!==n.resetConfig||t[16]!==v||t[17]!==y?(b=(0,$.jsx)(X,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:v,onClick:y,children:n.resetConfig}),t[15]=n.resetConfig,t[16]=v,t[17]=y,t[18]=b):b=t[18];let x;t[19]!==_||t[20]!==b?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_,b]}),t[19]=_,t[20]=b,t[21]=x):x=t[21];let S;t[22]!==n.configHint||t[23]!==n.configTitle||t[24]!==x?(S=(0,$.jsx)(Cn,{className:Ro,icon:ae,title:n.configTitle,subtitle:n.configHint,trailing:x}),t[22]=n.configHint,t[23]=n.configTitle,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==a||t[27]!==s||t[28]!==i||t[29]!==r||t[30]!==l||t[31]!==n.configDeepHalfLife||t[32]!==n.configDeepLimit||t[33]!==n.configDeepMaxAge||t[34]!==n.configDeepMinRecallCount||t[35]!==n.configDeepMinScore||t[36]!==n.configFrequency||t[37]!==n.configLightDedupe||t[38]!==n.configLightLimit||t[39]!==n.configLightLookbackDays||t[40]!==n.configLoading||t[41]!==n.configPhaseCron||t[42]!==n.configPhaseDeep||t[43]!==n.configPhaseDeepHint||t[44]!==n.configPhaseLight||t[45]!==n.configPhaseLightHint||t[46]!==n.configPhaseRem||t[47]!==n.configPhaseRemHint||t[48]!==n.configRemLimit||t[49]!==n.configRemLookbackDays||t[50]!==n.configRemMinStrength||t[51]!==n.configTimezone||t[52]!==n.off||t[53]!==n.on?(C=a?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:zo,children:(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,$.jsx)(`div`,{className:`lg:col-span-9`,children:(0,$.jsx)(Zo,{kind:`cron`,label:n.configFrequency,value:a.frequency,onChange:e=>l(t=>t&&{...t,frequency:e}),labels:r,disabled:!i||s})}),(0,$.jsx)(es,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,$.jsx)(`input`,{className:Bo,value:a.timezone,disabled:!i||s,onChange:e=>l(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})}),(0,$.jsxs)(rs,{icon:(0,$.jsx)(T,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:a.light.enabled,onEnabledChange:e=>l(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:a.light.cron,onCronChange:e=>l(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!i||s,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,$.jsx)(es,{label:n.configLightLookbackDays,children:(0,$.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Bo,value:a.light.lookbackDays,disabled:!i||s,onChange:e=>l(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,$.jsx)(es,{label:n.configLightLimit,children:(0,$.jsx)(`input`,{type:`number`,step:`1`,min:0,className:Bo,value:a.light.limit,disabled:!i||s,onChange:e=>l(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,$.jsx)(es,{label:n.configLightDedupe,children:(0,$.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:Bo,value:a.light.dedupeSimilarity,disabled:!i||s,onChange:e=>l(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,$.jsxs)(rs,{icon:(0,$.jsx)(on,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:a.deep.enabled,onEnabledChange:e=>l(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:a.deep.cron,onCronChange:e=>l(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!i||s,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,$.jsx)(es,{label:n.configDeepMinScore,children:(0,$.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:Bo,value:a.deep.minScore,disabled:!i||s,onChange:e=>l(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,$.jsx)(es,{label:n.configDeepMinRecallCount,children:(0,$.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Bo,value:a.deep.minRecallCount,disabled:!i||s,onChange:e=>l(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,$.jsx)(es,{label:n.configDeepLimit,children:(0,$.jsx)(`input`,{type:`number`,step:`1`,min:0,className:Bo,value:a.deep.limit,disabled:!i||s,onChange:e=>l(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,$.jsx)(es,{label:n.configDeepHalfLife,children:(0,$.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Bo,value:a.deep.recencyHalfLifeDays,disabled:!i||s,onChange:e=>l(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,$.jsx)(es,{label:n.configDeepMaxAge,children:(0,$.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Bo,value:a.deep.maxAgeDays,disabled:!i||s,onChange:e=>l(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,$.jsxs)(rs,{icon:(0,$.jsx)(we,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:a.rem.enabled,onEnabledChange:e=>l(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:a.rem.cron,onCronChange:e=>l(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!i||s,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,$.jsx)(es,{label:n.configRemLookbackDays,children:(0,$.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Bo,value:a.rem.lookbackDays,disabled:!i||s,onChange:e=>l(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,$.jsx)(es,{label:n.configRemLimit,children:(0,$.jsx)(`input`,{type:`number`,step:`1`,min:0,className:Bo,value:a.rem.limit,disabled:!i||s,onChange:e=>l(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,$.jsx)(es,{label:n.configRemMinStrength,children:(0,$.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:Bo,value:a.rem.minPatternStrength,disabled:!i||s,onChange:e=>l(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading}),t[26]=a,t[27]=s,t[28]=i,t[29]=r,t[30]=l,t[31]=n.configDeepHalfLife,t[32]=n.configDeepLimit,t[33]=n.configDeepMaxAge,t[34]=n.configDeepMinRecallCount,t[35]=n.configDeepMinScore,t[36]=n.configFrequency,t[37]=n.configLightDedupe,t[38]=n.configLightLimit,t[39]=n.configLightLookbackDays,t[40]=n.configLoading,t[41]=n.configPhaseCron,t[42]=n.configPhaseDeep,t[43]=n.configPhaseDeepHint,t[44]=n.configPhaseLight,t[45]=n.configPhaseLightHint,t[46]=n.configPhaseRem,t[47]=n.configPhaseRemHint,t[48]=n.configRemLimit,t[49]=n.configRemLookbackDays,t[50]=n.configRemMinStrength,t[51]=n.configTimezone,t[52]=n.off,t[53]=n.on,t[54]=C):C=t[54];let w;return t[55]!==S||t[56]!==C?(w=(0,$.jsxs)(Tn,{className:p,children:[S,C]}),t[55]=S,t[56]=C,t[57]=w):w=t[57],w}function cs(e){let t=(0,Q.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,$.jsx)(J,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,$.jsxs)(X,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,$.jsx)(Cn,{className:Ro,icon:Bt,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(f=a?a.length>0?(0,$.jsx)(`div`,{className:`space-y-1.5`,children:a.map(ls)}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,$.jsxs)(Tn,{className:Lo,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function ls(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-xs`,children:[(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,$.jsx)(`span`,{className:Y(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,$.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,$.jsx)(`span`,{className:`text-fg-muted`,children:Ho(e.durationMs)}),(0,$.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:Vo(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function us(e){let t=(0,Q.c)(40),{t:n,cfgForm:r,dreamingEnabled:i,hasToken:a,cfgSaving:o,enableSaving:s,runPhase:c,setRunPhase:l,runBusy:u,doRunNow:d,doRefresh:f,setDreamingEnabled:p}=e,m;t[0]===n.title?m=t[1]:(m=(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=m);let h;t[2]===n.subtitle?h=t[3]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),t[2]=n.subtitle,t[3]=h);let g;t[4]!==m||t[5]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[4]=m,t[5]=h,t[6]=g):g=t[6];let _;t[7]!==r||t[8]!==o||t[9]!==i||t[10]!==s||t[11]!==a||t[12]!==p||t[13]!==n.configEnabled||t[14]!==n.off||t[15]!==n.on?(_=r?(0,$.jsxs)(`label`,{className:Y(`inline-flex cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,i?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:n.configEnabled}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,disabled:!a||o||s,onChange:e=>void p(e.target.checked)}),s?(0,$.jsx)(J,{className:`size-3.5 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(`span`,{className:Y(`text-xs font-semibold`,i?`text-emerald-600 dark:text-emerald-400`:``),children:r.enabled?n.on:n.off})]}):null,t[7]=r,t[8]=o,t[9]=i,t[10]=s,t[11]=a,t[12]=p,t[13]=n.configEnabled,t[14]=n.off,t[15]=n.on,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==i||t[19]!==a||t[20]!==u||t[21]!==c||t[22]!==l||t[23]!==n.runNow||t[24]!==n.runNowHint?(v=i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`select`,{className:`rounded-lg border border-edge bg-surface-panel px-2 py-1.5 text-xs text-fg`,value:c,onChange:e=>l(e.target.value),disabled:!a||u,children:[(0,$.jsx)(`option`,{value:`light`,children:`Light`}),(0,$.jsx)(`option`,{value:`deep`,children:`Deep`}),(0,$.jsx)(`option`,{value:`rem`,children:`REM`})]}),(0,$.jsxs)(X,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:!a||u,onClick:()=>void d(c),title:n.runNowHint,children:[u?(0,$.jsx)(J,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(wt,{className:`mr-2 size-4`,"aria-hidden":!0}),n.runNow]})]}):null,t[17]=d,t[18]=i,t[19]=a,t[20]=u,t[21]=c,t[22]=l,t[23]=n.runNow,t[24]=n.runNowHint,t[25]=v):v=t[25];let y=!a,b;t[26]===f?b=t[27]:(b=()=>void f(),t[26]=f,t[27]=b);let x;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(At,{className:`mr-2 size-4`,"aria-hidden":!0}),t[28]=x):x=t[28];let S;t[29]!==n.refresh||t[30]!==y||t[31]!==b?(S=(0,$.jsxs)(X,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:y,onClick:b,children:[x,n.refresh]}),t[29]=n.refresh,t[30]=y,t[31]=b,t[32]=S):S=t[32];let C;t[33]!==_||t[34]!==v||t[35]!==S?(C=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[_,v,S]}),t[33]=_,t[34]=v,t[35]=S,t[36]=C):C=t[36];let w;return t[37]!==C||t[38]!==g?(w=(0,$.jsxs)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[g,C]}),t[37]=C,t[38]=g,t[39]=w):w=t[39],w}function ds(e){let t=(0,Q.c)(30),{t:n,disabled:r,actionBusy:i,doAction:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=Y(`max-w-2xl`,Lo),t[0]=o):o=t[0];let s;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(s=(0,$.jsx)(Cn,{className:Ro,icon:Ot,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=s):s=t[3];let c;t[4]!==a||t[5]!==n.confirmResetStore?(c=()=>{confirm(n.confirmResetStore)&&a(`reset_store`)},t[4]=a,t[5]=n.confirmResetStore,t[6]=c):c=t[6];let l;t[7]===i?l=t[8]:(l=i===`reset_store`?(0,$.jsx)(J,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(en,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=i,t[8]=l);let u;t[9]!==r||t[10]!==n.resetStore||t[11]!==c||t[12]!==l?(u=(0,$.jsxs)(X,{variant:`secondary`,disabled:r,onClick:c,children:[l,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=c,t[12]=l,t[13]=u):u=t[13];let d;t[14]!==a||t[15]!==n.confirmClearLock?(d=()=>{confirm(n.confirmClearLock)&&a(`clear_lock`)},t[14]=a,t[15]=n.confirmClearLock,t[16]=d):d=t[16];let f;t[17]===i?f=t[18]:(f=i===`clear_lock`?(0,$.jsx)(J,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(I,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=i,t[18]=f);let p;t[19]!==r||t[20]!==n.clearLock||t[21]!==d||t[22]!==f?(p=(0,$.jsxs)(X,{variant:`secondary`,disabled:r,onClick:d,children:[f,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=d,t[22]=f,t[23]=p):p=t[23];let m;t[24]!==u||t[25]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[u,p]}),t[24]=u,t[25]=p,t[26]=m):m=t[26];let h;return t[27]!==s||t[28]!==m?(h=(0,$.jsxs)(Tn,{className:o,children:[s,m]}),t[27]=s,t[28]=m,t[29]=h):h=t[29],h}function fs(e){let t=(0,Q.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,$.jsx)(J,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,$.jsxs)(X,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,$.jsx)(Cn,{className:Ro,icon:be,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(f=a?a.length>0?(0,$.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/60 px-2.5 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,$.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,$.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,$.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,$.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,$.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,$.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,$.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,$.jsxs)(Tn,{className:Lo,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function ps(e){let t=(0,Q.c)(100),{t:n,data:r,isLoading:i,localeTag:a,scheduleBadgeLabels:o}=e,s;t[0]!==r||t[1]!==n?(s=r?Uo(r.lock,n):null,t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=s,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=Y(`min-w-0`,Lo),t[3]=l):l=t[3];let u;t[4]===i?u=t[5]:(u=i?(0,$.jsx)(J,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=i,t[5]=u);let d;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==u?(d=(0,$.jsx)(Cn,{className:Ro,icon:Bt,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:u}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=u,t[9]=d):d=t[9];let f;t[10]===n.subsectionSchedule?f=t[11]:(f=(0,$.jsx)(ns,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=f);let p=r?r.config.enabled?n.on:n.off:`—`,m;t[12]!==n.enabled||t[13]!==p?(m=(0,$.jsx)(ts,{label:n.enabled,children:p}),t[12]=n.enabled,t[13]=p,t[14]=m):m=t[14];let h=c?.className,g=c?c.text:`—`,_;t[15]!==h||t[16]!==g?(_=(0,$.jsx)(`span`,{className:h,children:g}),t[15]=h,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==n.lock||t[19]!==_?(v=(0,$.jsx)(ts,{label:n.lock,children:_}),t[18]=n.lock,t[19]=_,t[20]=v):v=t[20];let y=r&&r.config.timezone||`—`,b;t[21]!==n.timezone||t[22]!==y?(b=(0,$.jsx)(ts,{label:n.timezone,children:y}),t[21]=n.timezone,t[22]=y,t[23]=b):b=t[23];let x;t[24]!==r||t[25]!==a||t[26]!==o?(x=r?(0,$.jsx)(Fn,{kind:`cron`,expression:r.config.frequency,locale:a,labels:o,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=a,t[26]=o,t[27]=x):x=t[27];let S;t[28]===r?S=t[29]:(S=r?.config.frequency?(0,$.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=S);let C;t[30]!==n.schedule||t[31]!==x||t[32]!==S?(C=(0,$.jsxs)(ts,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[x,S]}),t[30]=n.schedule,t[31]=x,t[32]=S,t[33]=C):C=t[33];let w;t[34]!==v||t[35]!==b||t[36]!==C||t[37]!==m?(w=(0,$.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[m,v,b,C]}),t[34]=v,t[35]=b,t[36]=C,t[37]=m,t[38]=w):w=t[38];let E;t[39]!==w||t[40]!==f?(E=(0,$.jsxs)(`div`,{className:zo,children:[f,w]}),t[39]=w,t[40]=f,t[41]=E):E=t[41];let D;t[42]===n.subsectionStore?D=t[43]:(D=(0,$.jsx)(ns,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=D);let O=r?String(r.store.entryCount):`—`,k;t[44]!==n.storeEntries||t[45]!==O?(k=(0,$.jsx)(ts,{label:n.storeEntries,children:O}),t[44]=n.storeEntries,t[45]=O,t[46]=k):k=t[46];let A=r?String(r.store.promotedCount):`—`,j;t[47]!==n.storePromoted||t[48]!==A?(j=(0,$.jsx)(ts,{label:n.storePromoted,children:A}),t[47]=n.storePromoted,t[48]=A,t[49]=j):j=t[49];let M;t[50]===r?M=t[51]:(M=r?Vo(r.store.updatedAt):`—`,t[50]=r,t[51]=M);let N;t[52]!==n.storeUpdatedAt||t[53]!==M?(N=(0,$.jsx)(ts,{label:n.storeUpdatedAt,children:M}),t[52]=n.storeUpdatedAt,t[53]=M,t[54]=N):N=t[54];let P;t[55]===r?P=t[56]:(P=r?Vo(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=P);let F;t[57]!==n.storeLastPromotedAt||t[58]!==P?(F=(0,$.jsx)(ts,{label:n.storeLastPromotedAt,children:P}),t[57]=n.storeLastPromotedAt,t[58]=P,t[59]=F):F=t[59];let I;t[60]!==k||t[61]!==j||t[62]!==N||t[63]!==F?(I=(0,$.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[k,j,N,F]}),t[60]=k,t[61]=j,t[62]=N,t[63]=F,t[64]=I):I=t[64];let L;t[65]!==D||t[66]!==I?(L=(0,$.jsxs)(`div`,{className:zo,children:[D,I]}),t[65]=D,t[66]=I,t[67]=L):L=t[67];let R;t[68]!==r||t[69]!==a||t[70]!==o||t[71]!==n?(R=r?.config?.phases?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ns,{label:n.subsectionPhases,className:`mb-2`}),(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,$.jsx)(is,{icon:(0,$.jsx)(T,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:On(r.config.phases.light.cron,a,o,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,$.jsx)(is,{icon:(0,$.jsx)(on,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:On(r.config.phases.deep.cron,a,o,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls≥${r.config.phases.deep.minRecallCount}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,$.jsx)(is,{icon:(0,$.jsx)(we,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:On(r.config.phases.rem.cron,a,o,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=a,t[70]=o,t[71]=n,t[72]=R):R=t[72];let z;t[73]===n.subsectionLastRun?z=t[74]:(z=(0,$.jsx)(ns,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=z);let B;t[75]===n.lastRunBlockHint?B=t[76]:(B=(0,$.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=B);let V;t[77]!==r||t[78]!==n?(V=r?.lastRun?.exists?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,$.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,$.jsx)(`div`,{className:`rounded-lg border border-edge-subtle/80 bg-surface-panel/50 p-2.5`,children:(0,$.jsx)(os,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,$.jsxs)(`details`,{className:`group rounded-lg border border-edge-subtle`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,$.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,$.jsx)(`pre`,{className:`max-h-40 overflow-auto border-t border-edge-subtle p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=V):V=t[79];let H;t[80]!==z||t[81]!==B||t[82]!==V?(H=(0,$.jsxs)(`div`,{className:zo,children:[z,B,V]}),t[80]=z,t[81]=B,t[82]=V,t[83]=H):H=t[83];let U=r?.lightLastRun,W;t[84]!==n||t[85]!==U?(W=(0,$.jsx)(as,{label:n.subsectionLightLastRun,lastRun:U,t:n}),t[84]=n,t[85]=U,t[86]=W):W=t[86];let G=r?.remLastRun,ee;t[87]!==n||t[88]!==G?(ee=(0,$.jsx)(as,{label:n.subsectionRemLastRun,lastRun:G,t:n}),t[87]=n,t[88]=G,t[89]=ee):ee=t[89];let K;t[90]!==E||t[91]!==L||t[92]!==R||t[93]!==H||t[94]!==W||t[95]!==ee?(K=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[E,L,R,H,W,ee]}),t[90]=E,t[91]=L,t[92]=R,t[93]=H,t[94]=W,t[95]=ee,t[96]=K):K=t[96];let q;return t[97]!==K||t[98]!==d?(q=(0,$.jsxs)(Tn,{className:l,children:[d,K]}),t[97]=K,t[98]=d,t[99]=q):q=t[99],q}var ms=[`config`,`runtime`,`insights`,`maintenance`],hs={config:ae,runtime:Bt,insights:be,maintenance:Ot};function gs(e){return e&&ms.includes(e)?e:`config`}function _s(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function vs(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function ys(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var bs={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,enableSaving:!1,cfgOk:!1,cfgError:null,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null};function xs(){let e=a(e=>e.language),t=s(e),n=t.dreamingSettings,r=t.cron.schedulePicker,i=t.cron.scheduleBadge,o=e===`zh`?`zh-CN`:`en-US`,c=!!g(e=>e.token),[l,u]=C(),f=gs(l.get(`tab`)),p=(0,Z.useCallback)(e=>{u(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[u]),{data:m}=rt(c),[h,_]=(0,Z.useReducer)(de,bs),{actionBusy:v,actionError:y,actionOk:b,runBusy:x,runOk:S,runError:w,runPhase:T,cfgSaving:E,enableSaving:D,cfgOk:O,cfgError:k,previewLoading:A,previewError:j,previewItems:M,eventsLoading:N,eventsError:P,events:F}=h,[I,L]=(0,Z.useReducer)(ys,{form:null,baseline:null}),R=I.form,z=I.baseline,B=(0,Z.useRef)(!1),{data:V,error:H,isLoading:U,mutate:W}=d(c?xo():null,So,{revalidateOnFocus:!1}),G=(0,Z.useMemo)(()=>{let e=[];return H&&e.push(H instanceof Error?H.message:String(H)),y&&e.push(y),w&&e.push(w),j&&e.push(j),P&&e.push(P),k&&e.push(k),e},[H,y,w,j,P,k]),ee=(0,Z.useMemo)(()=>{let e=[];return O&&e.push(n.configSaved),S&&e.push(n.runQueued),b&&e.push(n.actionOk),e},[O,S,b,n]),K=(0,Z.useCallback)(async()=>{_({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await W()},[W]),q=(0,Z.useCallback)(async()=>{_({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{_({type:`patch`,patch:{previewItems:(await To(20)).items??[]}})}catch(e){_({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{previewLoading:!1}})}},[]),te=(0,Z.useCallback)(async()=>{_({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{_({type:`patch`,patch:{events:await Eo(50)}})}catch(e){_({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{eventsLoading:!1}})}},[]),ne=(0,Z.useCallback)(async(e=`deep`)=>{_({type:`patch`,patch:{runBusy:!0,runOk:!1,runError:null}});try{await wo(e),_({type:`patch`,patch:{runOk:!0}}),await W()}catch(e){_({type:`patch`,patch:{runError:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{runBusy:!1}})}},[W]),re=(0,Z.useCallback)(async e=>{_({type:`patch`,patch:{actionBusy:e,actionError:null,actionOk:!1}});try{await Co(e),_({type:`patch`,patch:{actionOk:!0}}),await W()}catch(e){_({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{actionBusy:null}})}},[W]),ie=!c||U||!!v,ae=(0,Z.useMemo)(()=>{let e=m?.payload?.config;return Fo(e??{})},[m]);(0,Z.useEffect)(()=>{if(!c){L({type:`reset`}),B.current=!1;return}B.current||L({type:`sync`,value:ae})},[ae,c]);let oe=(0,Z.useMemo)(()=>!R||!z?!1:JSON.stringify(R)!==JSON.stringify(z),[R,z]),se=(0,Z.useCallback)(async()=>{if(R){_({type:`patch`,patch:{cfgSaving:!0,cfgOk:!1,cfgError:null}});try{await Io(R),L({type:`saved`,value:R}),B.current=!1,_({type:`patch`,patch:{cfgOk:!0}}),await W()}catch(e){_({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{cfgSaving:!1}})}}},[R,W]),ce=(0,Z.useCallback)(async e=>{if(!R||!c)return;let t={...R,enabled:e},n=R;B.current=!0,L({type:`set`,value:t}),_({type:`patch`,patch:{enableSaving:!0,cfgOk:!1,cfgError:null}});try{await Io(t),L({type:`saved`,value:t}),B.current=!1,_({type:`patch`,patch:{cfgOk:!0}}),await W()}catch(e){L({type:`set`,value:n}),_({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{enableSaving:!1}})}},[R,c,W]);return(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-4 px-4 py-6`,children:[(0,$.jsx)(us,{t:n,cfgForm:R,dreamingEnabled:R?.enabled??ae.enabled,hasToken:c,cfgSaving:E,enableSaving:D,runPhase:T,setRunPhase:e=>_({type:`patch`,patch:{runPhase:e}}),runBusy:x,doRunNow:ne,doRefresh:K,setDreamingEnabled:ce}),G.length>0?(0,$.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-amber-500/20 bg-amber-500/5 px-4 py-3`,role:`alert`,children:G.map(e=>(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,ee.length>0?(0,$.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-emerald-500/20 bg-emerald-500/5 px-4 py-3`,role:`status`,children:ee.map(e=>(0,$.jsx)(`p`,{className:`text-sm text-emerald-800 dark:text-emerald-200/90`,children:e},e))}):null,(0,$.jsx)(Ss,{t:n,activeTab:f,onChange:p}),(0,$.jsx)(Cs,{t:n,id:`config`,activeTab:f,children:(0,$.jsx)(ss,{t:n,schedulePickerLabels:r,hasToken:c,cfgForm:R,cfgBaseline:z,cfgSaving:E,cfgDirty:oe,setCfgForm:e=>{B.current=!0;let t=typeof e==`function`?e(R):e;t&&L({type:`set`,value:t})},setCfgOk:e=>_({type:`patch`,patch:{cfgOk:e}}),setCfgError:e=>_({type:`patch`,patch:{cfgError:e}}),saveConfig:se})}),(0,$.jsx)(Cs,{t:n,id:`runtime`,activeTab:f,children:(0,$.jsx)(ps,{t:n,data:V,isLoading:U,localeTag:o,scheduleBadgeLabels:i})}),(0,$.jsx)(Cs,{t:n,id:`insights`,activeTab:f,children:(0,$.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,$.jsx)(fs,{t:n,hasToken:c,previewLoading:A,previewItems:M,loadPreview:q}),(0,$.jsx)(cs,{t:n,hasToken:c,eventsLoading:N,events:F,loadEvents:te})]})}),(0,$.jsx)(Cs,{t:n,id:`maintenance`,activeTab:f,children:(0,$.jsx)(ds,{t:n,disabled:ie,actionBusy:v,doAction:re})})]})}function Ss(e){let t=(0,Q.c)(11),{t:n,activeTab:r,onChange:i}=e,a=n.tabsAriaLabel,o;t[0]!==r||t[1]!==i?(o=e=>{e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),i(ms[(ms.indexOf(r)+(e.key===`ArrowRight`?1:-1)+ms.length)%ms.length]))},t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==r||t[4]!==i||t[5]!==n?(s=ms.map(e=>{let t=hs[e],a=e===r;return(0,$.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,id:`dreaming-settings-tab-${e}`,"aria-controls":`dreaming-settings-panel-${e}`,className:Y(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,jt.press,a?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>i(e),children:[(0,$.jsx)(t,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:_s(n,e)})]},e)}),t[3]=r,t[4]=i,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==n.tabsAriaLabel||t[8]!==o||t[9]!==s?(c=(0,$.jsx)(`nav`,{"aria-label":a,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,onKeyDown:o,children:s}),t[7]=n.tabsAriaLabel,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function Cs(e){let t=(0,Q.c)(18),{t:n,id:r,activeTab:i,children:a}=e;if(i!==r)return null;let o=`dreaming-settings-panel-${r}`,s=`dreaming-settings-tab-${r}`,c;t[0]!==r||t[1]!==n?(c=_s(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l;t[3]===c?l=t[4]:(l=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==r||t[6]!==n?(u=vs(n,r),t[5]=r,t[6]=n,t[7]=u):u=t[7];let d;t[8]===u?d=t[9]:(d=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}),t[8]=u,t[9]=d);let f;t[10]!==l||t[11]!==d?(f=(0,$.jsxs)(`div`,{className:`mb-5`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==a||t[14]!==o||t[15]!==s||t[16]!==f?(p=(0,$.jsxs)(`section`,{id:o,role:`tabpanel`,"aria-labelledby":s,className:`rounded-2xl border border-edge bg-surface-base px-4 py-5 sm:px-5`,children:[f,a]}),t[13]=a,t[14]=o,t[15]=s,t[16]=f,t[17]=p):p=t[17],p}var ws={maxTurns:20,judgeModelRef:``,checklistMode:!0,maxConsecutiveParseFailures:3,judgeTimeoutSec:60,checklistHistoryChars:24e3};function Ts(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Es(e){let t=Ts(e)?e:{},n=Ts(t.goals)?t.goals:{};return{maxTurns:typeof n.maxTurns==`number`&&Number.isFinite(n.maxTurns)?Math.max(1,Math.min(500,Math.floor(n.maxTurns))):ws.maxTurns,judgeModelRef:typeof n.judgeModelRef==`string`?n.judgeModelRef:``,checklistMode:n.checklistMode!==!1,maxConsecutiveParseFailures:typeof n.maxConsecutiveParseFailures==`number`&&Number.isFinite(n.maxConsecutiveParseFailures)?Math.max(1,Math.min(20,Math.floor(n.maxConsecutiveParseFailures))):ws.maxConsecutiveParseFailures,judgeTimeoutSec:typeof n.judgeTimeoutMs==`number`&&Number.isFinite(n.judgeTimeoutMs)?Math.max(5,Math.min(120,Math.round(n.judgeTimeoutMs/1e3))):ws.judgeTimeoutSec,checklistHistoryChars:typeof n.checklistHistoryChars==`number`&&Number.isFinite(n.checklistHistoryChars)?Math.max(0,Math.min(1e5,Math.floor(n.checklistHistoryChars))):ws.checklistHistoryChars}}async function Ds(e){await _(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({goals:{maxTurns:e.maxTurns,...e.judgeModelRef.trim()?{judgeModelRef:e.judgeModelRef.trim()}:{judgeModelRef:null},checklistMode:e.checklistMode,maxConsecutiveParseFailures:e.maxConsecutiveParseFailures,judgeTimeoutMs:e.judgeTimeoutSec*1e3,checklistHistoryChars:e.checklistHistoryChars}})}),Xt()}function Os(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,Tt,`dark:border-edge`)}function ks(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function As({hasToken:e}){let t=a(e=>e.language),n=s(t).goalsSettings,r=s(t).chat,{data:i,isLoading:o}=rt(e),c=(0,Z.useMemo)(()=>i?.payload?.config===void 0?null:Es(i.payload.config),[i]),[l,u]=(0,Z.useReducer)(ks,{form:null,baseline:null}),d=l.form,f=l.baseline,[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),_=(0,Z.useRef)(!1),v=(0,Z.useRef)(null);e?c!==null&&!_.current&&v.current!==c&&(v.current=c,u({type:`sync`,value:c})):v.current!==null&&(v.current=null,u({type:`reset`}),_.current=!1);let y=d&&f&&JSON.stringify(d)!==JSON.stringify(f),b=(0,Z.useCallback)(e=>{_.current=!0,u({type:`patch`,patch:e})},[]);return!e||!d?o?(0,$.jsx)(Tn,{children:(0,$.jsx)(J,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Cn,{icon:bt,title:n.title,subtitle:n.hint}),(0,$.jsxs)(`div`,{className:`mb-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:!y||p,onClick:()=>u({type:`discard`}),children:n.discard}),(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!y||p,onClick:()=>{(async()=>{m(!0),g(null);try{await Ds(d),_.current=!1,u({type:`saved`,value:d})}catch(e){g(e instanceof Error?e.message:n.saveError)}finally{m(!1)}})()},children:p?n.saving:n.save})]}),h?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.maxTurns}),(0,$.jsx)(`input`,{type:`number`,min:1,max:500,className:Os(),value:d.maxTurns,onChange:e=>b({maxTurns:Number(e.target.value)||20})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.judgeModelRef}),(0,$.jsx)(q,{value:d.judgeModelRef,placeholder:n.judgeModelRefPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,className:`w-full max-w-none min-w-0`,onChange:e=>b({judgeModelRef:e})}),d.judgeModelRef.trim()?(0,$.jsx)(`button`,{type:`button`,className:`mt-1 text-xs text-accent hover:underline`,onClick:()=>b({judgeModelRef:``}),children:n.judgeModelRefUseDefault}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.judgeModelRefHint})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg sm:col-span-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d.checklistMode,onChange:e=>b({checklistMode:e.target.checked})}),n.checklistMode]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.parseFailures}),(0,$.jsx)(`input`,{type:`number`,min:1,max:20,className:Os(),value:d.maxConsecutiveParseFailures,onChange:e=>b({maxConsecutiveParseFailures:Number(e.target.value)||3})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.judgeTimeoutSec}),(0,$.jsx)(`input`,{type:`number`,min:5,max:120,className:Os(),value:d.judgeTimeoutSec,onChange:e=>b({judgeTimeoutSec:Number(e.target.value)||60})})]}),(0,$.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.checklistHistoryChars}),(0,$.jsx)(`input`,{type:`number`,min:0,max:1e5,className:Os(),value:d.checklistHistoryChars,onChange:e=>b({checklistHistoryChars:Math.max(0,Math.min(1e5,Math.floor(Number(e.target.value)||0)))})}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.checklistHistoryCharsHint})]})]})]})}function js(){let e=(0,Q.c)(14),t=a(Ns),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.goalsSettingsPage,i=!!g(Ms),o;e[2]===r.title?o=e[3]:(o=(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:r.title}),e[2]=r.title,e[3]=o);let c;e[4]===r.subtitle?c=e[5]:(c=(0,$.jsx)(`p`,{className:`max-w-2xl text-sm text-fg-muted`,children:r.subtitle}),e[4]=r.subtitle,e[5]=c);let l;e[6]!==o||e[7]!==c?(l=(0,$.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[o,c]}),e[6]=o,e[7]=c,e[8]=l):l=e[8];let u;e[9]===i?u=e[10]:(u=(0,$.jsx)(As,{hasToken:i}),e[9]=i,e[10]=u);let d;return e[11]!==l||e[12]!==u?(d=(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6 sm:px-8`,children:[l,u]}),e[11]=l,e[12]=u,e[13]=d):d=e[13],d}function Ms(e){return e.token}function Ns(e){return e.language}var Ps={critical:3,warn:2,info:1};function Fs(){return l(`/api/doctor?security=true`)}function Is(e){return e.toSorted((e,t)=>Ps[t.severity]-Ps[e.severity]||e.checkId.localeCompare(t.checkId))}function Ls(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=Is((t.findings??[]).filter(e=>typeof e.checkId==`string`&&(e.severity===`critical`||e.severity===`warn`||e.severity===`info`)&&typeof e.title==`string`&&typeof e.detail==`string`));return{status:t.status,message:t.message,hints:Array.isArray(t.hints)?t.hints.filter(e=>typeof e==`string`):[],findings:n}}async function Rs(){return Ls(await _(Fs()))}function zs(e){let t=(0,Q.c)(40),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,o=a(Vs),c;t[0]===o?c=t[1]:(c=s(o),t[0]=o,t[1]=c);let l=c.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[Fs(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[5]=p):p=t[5];let{data:m,error:h,isLoading:g,isValidating:_,mutate:v}=d(u,Bs,p),y=m??null,b=h instanceof Error?h.message:h?String(h):null,x=g||_,S;t[6]===v?S=t[7]:(S=()=>{v(),f(Fs())},t[6]=v,t[7]=S);let C=S,w=!n||x,T;t[8]===x?T=t[9]:(T=x?(0,$.jsx)(J,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(At,{className:`size-3.5`,"aria-hidden":!0}),t[8]=x,t[9]=T);let E;t[10]===l.securityAuditRefresh?E=t[11]:(E=(0,$.jsx)(`span`,{className:`ml-1.5`,children:l.securityAuditRefresh}),t[10]=l.securityAuditRefresh,t[11]=E);let D;t[12]!==C||t[13]!==w||t[14]!==T||t[15]!==E?(D=(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:w,onClick:C,children:[T,E]}),t[12]=C,t[13]=w,t[14]=T,t[15]=E,t[16]=D):D=t[16];let O;t[17]!==l.securityAuditSubtitle||t[18]!==l.securityAuditTitle||t[19]!==D?(O=(0,$.jsx)(Cn,{icon:Ne,title:l.securityAuditTitle,subtitle:l.securityAuditSubtitle,trailing:D}),t[17]=l.securityAuditSubtitle,t[18]=l.securityAuditTitle,t[19]=D,t[20]=O):O=t[20];let k;t[21]===l.securityAuditSavedConfigHint?k=t[22]:(k=(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:l.securityAuditSavedConfigHint}),t[21]=l.securityAuditSavedConfigHint,t[22]=k);let A;t[23]!==b||t[24]!==l.securityAuditLoadError?(A=b?(0,$.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[l.securityAuditLoadError,`: `,b]}):null,t[23]=b,t[24]=l.securityAuditLoadError,t[25]=A):A=t[25];let j;t[26]!==y||t[27]!==b||t[28]!==l.securityAuditLoading||t[29]!==x?(j=!b&&x&&!y?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(J,{className:`size-4 animate-spin`,"aria-hidden":!0}),l.securityAuditLoading]}):null,t[26]=y,t[27]=b,t[28]=l.securityAuditLoading,t[29]=x,t[30]=j):j=t[30];let M;t[31]!==y||t[32]!==l?(M=y?(0,$.jsx)(Hs,{g:l,audit:y}):null,t[31]=y,t[32]=l,t[33]=M):M=t[33];let N;return t[34]!==O||t[35]!==k||t[36]!==A||t[37]!==j||t[38]!==M?(N=(0,$.jsxs)(Tn,{children:[O,k,A,j,M]}),t[34]=O,t[35]=k,t[36]=A,t[37]=j,t[38]=M,t[39]=N):N=t[39],N}function Bs(){return Rs()}function Vs(e){return e.language}function Hs(e){let t=(0,Q.c)(40),{g:n,audit:r}=e,i,a,o,s,c,l,u;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(a=Ks(n,r.status,r.findings),u=`space-y-4`,c=Y(`rounded-lg border px-3 py-2.5 text-sm`,a.bannerClass),l=`status`,s=`flex items-start gap-2`,i=a.icon,o=Y(`mt-0.5 size-4 shrink-0`,a.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u):(i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]);let d;t[10]!==i||t[11]!==o?(d=(0,$.jsx)(i,{className:o,"aria-hidden":!0}),t[10]=i,t[11]=o,t[12]=d):d=t[12];let f;t[13]===a.title?f=t[14]:(f=(0,$.jsx)(`p`,{className:`font-medium`,children:a.title}),t[13]=a.title,t[14]=f);let p;t[15]===r.message?p=t[16]:(p=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs opacity-90`,children:r.message}),t[15]=r.message,t[16]=p);let m;t[17]!==f||t[18]!==p?(m=(0,$.jsxs)(`div`,{children:[f,p]}),t[17]=f,t[18]=p,t[19]=m):m=t[19];let h;t[20]!==s||t[21]!==d||t[22]!==m?(h=(0,$.jsxs)(`div`,{className:s,children:[d,m]}),t[20]=s,t[21]=d,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==c||t[26]!==l?(g=(0,$.jsx)(`div`,{className:c,role:l,children:h}),t[24]=h,t[25]=c,t[26]=l,t[27]=g):g=t[27];let _;t[28]!==r.findings||t[29]!==r.status||t[30]!==n?(_=r.findings.length>0?(0,$.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,$.jsx)(Ws,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.securityAuditNoFindings}):null,t[28]=r.findings,t[29]=r.status,t[30]=n,t[31]=_):_=t[31];let v;t[32]!==r.hints||t[33]!==n?(v=r.hints.length>0?(0,$.jsxs)(`div`,{className:`space-y-1 border-t border-edge pt-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,$.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(Us)})]}):null,t[32]=r.hints,t[33]=n,t[34]=v):v=t[34];let y;return t[35]!==g||t[36]!==_||t[37]!==v||t[38]!==u?(y=(0,$.jsxs)(`div`,{className:u,children:[g,_,v]}),t[35]=g,t[36]=_,t[37]=v,t[38]=u,t[39]=y):y=t[39],y}function Us(e){return(0,$.jsx)(`li`,{className:`font-mono`,children:e},e)}function Ws(e){let t=(0,Q.c)(31),{g:n,finding:r}=e,i,a,o,s;if(t[0]!==r.severity){let e=Gs(r.severity);s=`rounded-lg border border-edge bg-surface-panel/50 px-3 py-2.5`,o=`flex items-start gap-2`,i=e.icon,a=Y(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=a,t[3]=o,t[4]=s}else i=t[1],a=t[2],o=t[3],s=t[4];let c;t[5]!==i||t[6]!==a?(c=(0,$.jsx)(i,{className:a,"aria-hidden":!0}),t[5]=i,t[6]=a,t[7]=c):c=t[7];let l;t[8]===r.title?l=t[9]:(l=(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.title}),t[8]=r.title,t[9]=l);let u;t[10]===r.checkId?u=t[11]:(u=(0,$.jsx)(`span`,{className:`font-mono text-[0.65rem] text-fg-subtle`,children:r.checkId}),t[10]=r.checkId,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===r.detail?f=t[16]:(f=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.detail}),t[15]=r.detail,t[16]=f);let p;t[17]!==r.remediation||t[18]!==n?(p=r.remediation?(0,$.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:n.securityAuditRemediation}),` `,r.remediation]}):null,t[17]=r.remediation,t[18]=n,t[19]=p):p=t[19];let m;t[20]!==d||t[21]!==f||t[22]!==p?(m=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[d,f,p]}),t[20]=d,t[21]=f,t[22]=p,t[23]=m):m=t[23];let h;t[24]!==m||t[25]!==o||t[26]!==c?(h=(0,$.jsxs)(`div`,{className:o,children:[c,m]}),t[24]=m,t[25]=o,t[26]=c,t[27]=h):h=t[27];let g;return t[28]!==h||t[29]!==s?(g=(0,$.jsx)(`li`,{className:s,children:h}),t[28]=h,t[29]=s,t[30]=g):g=t[30],g}function Gs(e){switch(e){case`critical`:return{icon:_e,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:N,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:Ie,iconClass:`text-fg-muted`}}}function Ks(e,t,n){let r=n.filter(e=>e.severity===`critical`).length,i=n.filter(e=>e.severity===`warn`).length;return t===`fail`||r>0?{icon:_e,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`border-red-200 bg-red-50 text-red-950 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:N,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`border-amber-200 bg-amber-50 text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:Ie,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`border-edge bg-surface-panel/60 text-fg`}:{icon:Ne,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`border-emerald-200 bg-emerald-50 text-emerald-950 dark:border-emerald-900/50 dark:bg-emerald-950/40 dark:text-emerald-100`}}function qs(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt,`dark:border-edge`)}var Js=[`network`,`access`,`updates`,`security`,`advanced`],Ys={network:Zt,access:ee,updates:At,security:K,advanced:k};function Xs(e){return e&&Js.includes(e)?e:`network`}function Zs(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function Qs(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function $s(e,t){switch(t.type){case`reset`:return{form:null,baseline:null,appliedBaseline:null};case`init-applied`:return{...e,appliedBaseline:structuredClone(t.value)};case`sync`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline)}:e;case`saved`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}}}var ec={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function tc(){let e=a(e=>e.language),t=s(e),n=t.gatewaySettings,[r,i]=C(),o=Ce(e=>e.mode),c=o===`advanced`,l=Xs(r.get(`tab`)),u=(0,Z.useMemo)(()=>Gn(Js,o),[o]),d=(0,Z.useCallback)(e=>{i(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[i]);Ln(l,d);let f=g(e=>e.token),p=g(e=>e.tokenExpired),m=g(e=>e.openTokenDialog),h=!!f,[_,v]=(0,Z.useReducer)($s,{form:null,baseline:null,appliedBaseline:null}),b=_.form,x=_.baseline,S=_.appliedBaseline,[w,T]=(0,Z.useReducer)(de,ec),{saving:E,error:D,saveOk:O,auditRefreshToken:k,restarting:A,restartConfirmOpen:j}=w,M=(0,Z.useRef)(!1),N=(0,Z.useRef)(null),P=(0,Z.useRef)(!1),{data:F,error:I,isLoading:L,mutate:R}=rt(h),z=(0,Z.useMemo)(()=>F?.payload?.config===void 0?null:structuredClone(In(F.payload.config)),[F]);h?z!==null&&(P.current||(P.current=!0,v({type:`init-applied`,value:z})),!M.current&&N.current!==z&&(N.current=z,v({type:`sync`,value:z}),T({type:`patch`,patch:{saveOk:!1}}))):(N.current!==null||P.current)&&(N.current=null,P.current=!1,v({type:`reset`}),M.current=!1);let B=!!(h&&L&&F===void 0&&!I),V=I instanceof Error?I.message:I?String(I):null,H=(0,Z.useMemo)(()=>!b||!x?!1:JSON.stringify(b)!==JSON.stringify(x),[b,x]),U=(0,Z.useMemo)(()=>!x||!S?!1:Hn(S,x),[S,x]),W=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),G=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),ee=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),K=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,bind:e})})},[]),q=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),te=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,port:e})})},[]),ne=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),re=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,maxSseConnections:e})})},[]),ie=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),ae=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),oe=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),se=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),ce=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),le=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),ue=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),fe=(0,Z.useCallback)(e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),pe=(0,Z.useCallback)(async()=>{if(!b||E)return;let e=Un(b);if(e){T({type:`patch`,patch:{error:e}});return}T({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await jn(b),M.current=!1,v({type:`saved`,value:b}),T({type:`patch`,patch:{saveOk:!0,auditRefreshToken:k+1}}),window.setTimeout(()=>T({type:`patch`,patch:{saveOk:!1}}),2500)}catch(e){T({type:`patch`,patch:{error:e instanceof Error?e.message:n.saveError}})}finally{T({type:`patch`,patch:{saving:!1}})}},[b,E,n.saveError]),me=(0,Z.useCallback)(()=>{x&&(M.current=!1,v({type:`discard`}),T({type:`patch`,patch:{error:null,saveOk:!1}}))},[x]),he=ze(n),ge=(0,Z.useCallback)(async()=>{if(!A){T({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await mt();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):y({type:`error`,title:n.restartGatewayFailed,message:e.message??``})}catch(e){y({type:`error`,title:n.restartGatewayFailed,message:e instanceof Error?e.message:String(e)})}finally{T({type:`patch`,patch:{restarting:!1}})}}},[A,n.restartGatewayFailed]);return h?B?(0,$.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(J,{className:`size-4 animate-spin`}),n.loading]})}):b?(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.gateway}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,$.jsxs)(`a`,{href:Le(e,`gateway`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[n.docsLink,(0,$.jsx)(Dt,{className:`size-3.5`})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[O?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:!H||E,onClick:me,children:n.discard}),(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!H||E,onClick:()=>void pe(),children:E?n.saving:n.save})]})]}),p?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-red-200 bg-red-50 px-4 py-3 dark:border-red-900/50 dark:bg-red-950/40`,role:`alert`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(_e,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,$.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:n.tokenExpired})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>m(),children:n.updateToken})})]}):null,H?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,D?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:D}):null,U?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-800 dark:bg-amber-950/40`,children:[(0,$.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:n.restartHint}),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1.5 border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300 dark:hover:bg-red-900/60`,disabled:A,onClick:()=>T({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[A?(0,$.jsx)(J,{className:`size-3.5 animate-spin`}):(0,$.jsx)(it,{className:`size-3.5`}),n.restartGatewayButton]})]}):null,(0,$.jsx)(rn,{open:j,title:n.restartGatewayButton,description:n.restartGatewayConfirm,confirmLabel:n.restartGatewayButton,cancelLabel:n.discard,destructive:!0,onConfirm:()=>void ge(),onCancel:()=>T({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,$.jsx)(nc,{g:n,activeTab:l,visibleTabs:u,onChange:d}),(0,$.jsxs)(rc,{g:n,id:`network`,activeTab:l,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:n.bindMode}),(0,$.jsxs)(`select`,{id:`gateway-bind-mode`,className:qs(),value:b.bind,onChange:e=>K(e.target.value),children:[(0,$.jsx)(`option`,{value:`loopback`,children:n.bindLoopback}),c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`option`,{value:`lan`,children:n.bindLan}),(0,$.jsx)(`option`,{value:`auto`,children:n.bindAuto}),(0,$.jsx)(`option`,{value:`custom`,children:n.bindCustom}),(0,$.jsx)(`option`,{value:`tailnet`,children:n.bindTailnet})]}):null]})]}),b.bind===`custom`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:n.customBindHost}),(0,$.jsx)(`input`,{id:`gateway-custom-bind-host`,className:Y(qs(),`font-mono text-xs`),value:b.customBindHost,onChange:e=>q(e.target.value),placeholder:n.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:n.listenPort}),(0,$.jsx)(`input`,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:Y(qs(),`font-mono text-xs`),value:b.port,onChange:e=>{let t=Number(e.target.value);te(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):b.port)}})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:n.listenHint})]}),(0,$.jsx)(kn,{children:(0,$.jsx)(cc,{g:n,origins:b.corsOrigins,onChange:ee})})]}),(0,$.jsxs)(rc,{g:n,id:`access`,activeTab:l,children:[b.auth.mode===`none`?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.authModeNone}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:n.authMode}),(0,$.jsxs)(`select`,{id:`gateway-auth-mode`,value:b.auth.mode,onChange:e=>W({mode:e.target.value}),className:qs(),children:[(0,$.jsx)(`option`,{value:`token`,children:n.authModeToken}),(0,$.jsx)(`option`,{value:`password`,children:n.authModePassword}),c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`option`,{value:`trusted-proxy`,children:n.authModeTrustedProxy}),(0,$.jsx)(`option`,{value:`none`,children:n.authModeNoneLabel})]}):null]})]}),(0,$.jsx)(kn,{children:b.auth.mode===`trusted-proxy`?(0,$.jsx)(ac,{g:n,form:b,onTrustedProxyChange:ce,onTrustedProxiesChange:se,onAllowRealIpFallbackChange:ue}):null}),b.auth.mode===`token`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(uc,{id:`gateway-access-token`,label:n.accessToken,help:n.tokenHelp,placeholder:n.tokenPlaceholder,value:b.auth.token,labels:he,reveal:()=>Bn(`token`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>W({token:e})}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>m(),children:n.changeToken})]}):null,b.auth.mode===`password`?(0,$.jsx)(uc,{id:`gateway-auth-password`,label:n.authPassword,help:n.authPasswordHelp,placeholder:n.authPasswordPlaceholder,value:b.auth.password,labels:he,reveal:()=>Bn(`password`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>W({password:e})}):null,(0,$.jsx)(kn,{children:b.auth.mode===`none`?null:(0,$.jsx)(lc,{g:n,rateLimit:b.auth.rateLimit,onChange:ne})})]}),(0,$.jsxs)(rc,{g:n,id:`updates`,activeTab:l,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:n.updateChannel}),(0,$.jsxs)(`select`,{id:`gateway-update-channel`,value:b.updateChannel,onChange:e=>G(e.target.value),className:qs(),children:[(0,$.jsx)(`option`,{value:`stable`,children:n.channelStable}),(0,$.jsx)(`option`,{value:`beta`,children:n.channelBeta}),(0,$.jsx)(`option`,{value:`dev`,children:n.channelDev})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateChannelHint})]}),(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.updateAutoSection}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateAutoSectionHint}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:b.updateCheckOnStart,onChange:e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:n.updateCheckOnStart}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateCheckOnStartHint})]})]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:b.updateAutoEnabled,onChange:e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:n.updateAutoEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateAutoEnabledHint})]})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:n.updateAutoStableDelayHours}),(0,$.jsx)(`input`,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!b.updateAutoEnabled,className:qs(),value:b.updateAutoStableDelayHours,onChange:e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableDelayHoursHint})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:n.updateAutoStableJitterHours}),(0,$.jsx)(`input`,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!b.updateAutoEnabled,className:qs(),value:b.updateAutoStableJitterHours,onChange:e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableJitterHoursHint})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:n.updateAutoBetaCheckIntervalHours}),(0,$.jsx)(`input`,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!b.updateAutoEnabled,className:qs(),value:b.updateAutoBetaCheckIntervalHours,onChange:e=>{M.current=!0,v({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoBetaCheckIntervalHoursHint})]})]})]})]}),(0,$.jsxs)(rc,{g:n,id:`security`,activeTab:l,children:[(0,$.jsx)(zs,{enabled:h,refreshToken:k}),(0,$.jsx)(ic,{g:n,form:b,onSecurityStrictChange:le,onDangerouslyAllowHostHeaderOriginFallbackChange:fe})]}),(0,$.jsx)(rc,{g:n,id:`advanced`,activeTab:l,children:(0,$.jsx)(oc,{g:n,form:b,onMaxSseConnectionsChange:re,onDeferModeChange:ie,onDeferIdsChange:ae,onSkipIdsChange:oe})})]}):(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:D??V??n.loadError}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>void R(),children:n.retry})]}):(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.gateway}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function nc(e){let t=(0,Q.c)(17),{g:n,activeTab:r,visibleTabs:i,onChange:a}=e,o=n.tabsAriaLabel,s;t[0]!==r||t[1]!==a||t[2]!==i?(s=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=i.indexOf(r);t<0||a(i[(t+(e.key===`ArrowRight`?1:-1)+i.length)%i.length])},t[0]=r,t[1]=a,t[2]=i,t[3]=s):s=t[3];let c;if(t[4]!==r||t[5]!==n||t[6]!==a||t[7]!==i){let e;t[9]!==r||t[10]!==n||t[11]!==a?(e=e=>{let t=Ys[e],i=e===r;return(0,$.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":i,"aria-controls":`gateway-settings-panel-${e}`,id:`gateway-settings-tab-${e}`,className:Y(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,jt.press,i?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>a(e),children:[(0,$.jsx)(t,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:Zs(n,e)})]},e)},t[9]=r,t[10]=n,t[11]=a,t[12]=e):e=t[12],c=i.map(e),t[4]=r,t[5]=n,t[6]=a,t[7]=i,t[8]=c}else c=t[8];let l;return t[13]!==n.tabsAriaLabel||t[14]!==s||t[15]!==c?(l=(0,$.jsx)(`nav`,{"aria-label":o,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,onKeyDown:s,children:c}),t[13]=n.tabsAriaLabel,t[14]=s,t[15]=c,t[16]=l):l=t[16],l}function rc(e){let t=(0,Q.c)(20),{g:n,id:r,activeTab:i,children:a}=e;if(i!==r)return null;let o=`gateway-settings-panel-${r}`,s=`gateway-settings-tab-${r}`,c;t[0]!==n||t[1]!==r?(c=Zs(n,r),t[0]=n,t[1]=r,t[2]=c):c=t[2];let l;t[3]===c?l=t[4]:(l=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==n||t[6]!==r?(u=Qs(n,r),t[5]=n,t[6]=r,t[7]=u):u=t[7];let d;t[8]===u?d=t[9]:(d=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}),t[8]=u,t[9]=d);let f;t[10]!==l||t[11]!==d?(f=(0,$.jsxs)(`div`,{className:`mb-5`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;t[13]===a?p=t[14]:(p=(0,$.jsx)(`div`,{className:`space-y-4`,children:a}),t[13]=a,t[14]=p);let m;return t[15]!==o||t[16]!==s||t[17]!==f||t[18]!==p?(m=(0,$.jsxs)(`section`,{id:o,role:`tabpanel`,"aria-labelledby":s,className:`rounded-2xl border border-edge bg-surface-base px-4 py-5 sm:px-5`,children:[f,p]}),t[15]=o,t[16]=s,t[17]=f,t[18]=p,t[19]=m):m=t[19],m}function ic(e){let t=(0,Q.c)(37),{g:n,form:r,onSecurityStrictChange:i,onDangerouslyAllowHostHeaderOriginFallbackChange:a}=e,o;t[0]===i?o=t[1]:(o=e=>i(e.target.checked),t[0]=i,t[1]=o);let s;t[2]!==r.securityStrict||t[3]!==o?(s=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.securityStrict,onChange:o}),t[2]=r.securityStrict,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.securityStrict?c=t[6]:(c=(0,$.jsx)(`span`,{className:`font-medium`,children:n.securityStrict}),t[5]=n.securityStrict,t[6]=c);let l;t[7]===n.securityStrictHint?l=t[8]:(l=(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.securityStrictHint}),t[7]=n.securityStrictHint,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,$.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==s||t[13]!==u?(d=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14];let f;t[15]===a?f=t[16]:(f=e=>a(e.target.checked),t[15]=a,t[16]=f);let p;t[17]!==r.dangerouslyAllowHostHeaderOriginFallback||t[18]!==f?(p=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.dangerouslyAllowHostHeaderOriginFallback,onChange:f}),t[17]=r.dangerouslyAllowHostHeaderOriginFallback,t[18]=f,t[19]=p):p=t[19];let m;t[20]===n.dangerouslyAllowHostHeaderOriginFallback?m=t[21]:(m=(0,$.jsx)(`span`,{className:`font-medium`,children:n.dangerouslyAllowHostHeaderOriginFallback}),t[20]=n.dangerouslyAllowHostHeaderOriginFallback,t[21]=m);let h;t[22]===n.dangerouslyAllowHostHeaderOriginFallbackHint?h=t[23]:(h=(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.dangerouslyAllowHostHeaderOriginFallbackHint}),t[22]=n.dangerouslyAllowHostHeaderOriginFallbackHint,t[23]=h);let g;t[24]!==h||t[25]!==m?(g=(0,$.jsxs)(`span`,{children:[m,h]}),t[24]=h,t[25]=m,t[26]=g):g=t[26];let _;t[27]!==g||t[28]!==p?(_=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[p,g]}),t[27]=g,t[28]=p,t[29]=_):_=t[29];let v;t[30]!==r.dangerouslyAllowHostHeaderOriginFallback||t[31]!==n.dangerouslyAllowHostHeaderOriginFallbackWarning?(v=r.dangerouslyAllowHostHeaderOriginFallback?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.dangerouslyAllowHostHeaderOriginFallbackWarning}):null,t[30]=r.dangerouslyAllowHostHeaderOriginFallback,t[31]=n.dangerouslyAllowHostHeaderOriginFallbackWarning,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v||t[35]!==d?(y=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[d,_,v]}),t[33]=_,t[34]=v,t[35]=d,t[36]=y):y=t[36],y}function ac(e){let t=(0,Q.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:a,onAllowRealIpFallbackChange:o}=e,s=r.auth.trustedProxy,c;t[0]===n.authModeTrustedProxyHint?c=t[1]:(c=(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.authModeTrustedProxyHint}),t[0]=n.authModeTrustedProxyHint,t[1]=c);let l;t[2]===n.trustedProxyUserHeader?l=t[3]:(l=(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-trusted-proxy-user-header`,children:n.trustedProxyUserHeader}),t[2]=n.trustedProxyUserHeader,t[3]=l);let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(qs(),`font-mono text-xs`),t[4]=u):u=t[4];let d;t[5]===i?d=t[6]:(d=e=>i({userHeader:e.target.value}),t[5]=i,t[6]=d);let f;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==d||t[9]!==s.userHeader?(f=(0,$.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:u,value:s.userHeader,onChange:d,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=d,t[9]=s.userHeader,t[10]=f):f=t[10];let p;t[11]===n.trustedProxyUserHeaderHint?p=t[12]:(p=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.trustedProxyUserHeaderHint}),t[11]=n.trustedProxyUserHeaderHint,t[12]=p);let m;t[13]!==l||t[14]!==f||t[15]!==p?(m=(0,$.jsxs)(`div`,{children:[l,f,p]}),t[13]=l,t[14]=f,t[15]=p,t[16]=m):m=t[16];let h;t[17]===i?h=t[18]:(h=e=>i({requiredHeaders:e}),t[17]=i,t[18]=h);let g;t[19]!==n.channelIdListEmpty||t[20]!==n.trustedProxyRequiredHeaders||t[21]!==n.trustedProxyRequiredHeadersHint||t[22]!==n.trustedProxyUserHeaderPlaceholder||t[23]!==h||t[24]!==s.requiredHeaders?(g=(0,$.jsx)(sc,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:s.requiredHeaders,maxItems:32,onChange:h}),t[19]=n.channelIdListEmpty,t[20]=n.trustedProxyRequiredHeaders,t[21]=n.trustedProxyRequiredHeadersHint,t[22]=n.trustedProxyUserHeaderPlaceholder,t[23]=h,t[24]=s.requiredHeaders,t[25]=g):g=t[25];let _;t[26]===i?_=t[27]:(_=e=>i({allowUsers:e}),t[26]=i,t[27]=_);let v;t[28]!==n.channelIdListEmpty||t[29]!==n.trustedProxyAllowUsers||t[30]!==n.trustedProxyAllowUsersHint||t[31]!==n.trustedProxyUserHeaderPlaceholder||t[32]!==_||t[33]!==s.allowUsers?(v=(0,$.jsx)(sc,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:s.allowUsers,maxItems:128,onChange:_}),t[28]=n.channelIdListEmpty,t[29]=n.trustedProxyAllowUsers,t[30]=n.trustedProxyAllowUsersHint,t[31]=n.trustedProxyUserHeaderPlaceholder,t[32]=_,t[33]=s.allowUsers,t[34]=v):v=t[34];let y;t[35]===i?y=t[36]:(y=e=>i({allowLoopback:e.target.checked}),t[35]=i,t[36]=y);let b;t[37]!==y||t[38]!==s.allowLoopback?(b=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:s.allowLoopback,onChange:y}),t[37]=y,t[38]=s.allowLoopback,t[39]=b):b=t[39];let x;t[40]===n.trustedProxyAllowLoopback?x=t[41]:(x=(0,$.jsx)(`span`,{className:`font-medium`,children:n.trustedProxyAllowLoopback}),t[40]=n.trustedProxyAllowLoopback,t[41]=x);let S;t[42]===n.trustedProxyAllowLoopbackHint?S=t[43]:(S=(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.trustedProxyAllowLoopbackHint}),t[42]=n.trustedProxyAllowLoopbackHint,t[43]=S);let C;t[44]!==x||t[45]!==S?(C=(0,$.jsxs)(`span`,{children:[x,S]}),t[44]=x,t[45]=S,t[46]=C):C=t[46];let w;t[47]!==b||t[48]!==C?(w=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[b,C]}),t[47]=b,t[48]=C,t[49]=w):w=t[49];let T;t[50]!==r.trustedProxies||t[51]!==n.trustedProxies||t[52]!==n.trustedProxiesEmpty||t[53]!==n.trustedProxiesHint||t[54]!==n.trustedProxiesPlaceholder||t[55]!==a?(T=(0,$.jsx)(sc,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:a}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=a,t[56]=T):T=t[56];let E;t[57]===o?E=t[58]:(E=e=>o(e.target.checked),t[57]=o,t[58]=E);let D;t[59]!==r.allowRealIpFallback||t[60]!==E?(D=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.allowRealIpFallback,onChange:E}),t[59]=r.allowRealIpFallback,t[60]=E,t[61]=D):D=t[61];let O;t[62]===n.allowRealIpFallback?O=t[63]:(O=(0,$.jsx)(`span`,{className:`font-medium`,children:n.allowRealIpFallback}),t[62]=n.allowRealIpFallback,t[63]=O);let k;t[64]===n.allowRealIpFallbackHint?k=t[65]:(k=(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.allowRealIpFallbackHint}),t[64]=n.allowRealIpFallbackHint,t[65]=k);let A;t[66]!==O||t[67]!==k?(A=(0,$.jsxs)(`span`,{children:[O,k]}),t[66]=O,t[67]=k,t[68]=A):A=t[68];let j;t[69]!==D||t[70]!==A?(j=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[D,A]}),t[69]=D,t[70]=A,t[71]=j):j=t[71];let M;return t[72]!==c||t[73]!==v||t[74]!==w||t[75]!==T||t[76]!==j||t[77]!==m||t[78]!==g?(M=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[c,m,g,v,w,T,j]}),t[72]=c,t[73]=v,t[74]=w,t[75]=T,t[76]=j,t[77]=m,t[78]=g,t[79]=M):M=t[79],M}function oc(e){let t=(0,Q.c)(58),{g:n,form:r,onMaxSseConnectionsChange:i,onDeferModeChange:a,onDeferIdsChange:o,onSkipIdsChange:s}=e,c;t[0]===n.maxSseConnections?c=t[1]:(c=(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-max-sse`,children:n.maxSseConnections}),t[0]=n.maxSseConnections,t[1]=c);let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=Y(qs(),`max-w-xs font-mono text-xs`),t[2]=l):l=t[2];let u;t[3]===i?u=t[4]:(u=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i(Math.max(1,Math.floor(t)))},t[3]=i,t[4]=u);let d;t[5]!==r.maxSseConnections||t[6]!==u?(d=(0,$.jsx)(`input`,{id:`gateway-max-sse`,type:`number`,min:1,className:l,value:r.maxSseConnections,onChange:u}),t[5]=r.maxSseConnections,t[6]=u,t[7]=d):d=t[7];let f;t[8]===n.maxSseConnectionsHint?f=t[9]:(f=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.maxSseConnectionsHint}),t[8]=n.maxSseConnectionsHint,t[9]=f);let p;t[10]!==c||t[11]!==d||t[12]!==f?(p=(0,$.jsxs)(`div`,{children:[c,d,f]}),t[10]=c,t[11]=d,t[12]=f,t[13]=p):p=t[13];let m;t[14]===n.channelConnectDeferMode?m=t[15]:(m=(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[14]=n.channelConnectDeferMode,t[15]=m);let h=r.channelConnectDeferMode,g;t[16]===a?g=t[17]:(g=e=>a(e.target.value),t[16]=a,t[17]=g);let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=qs(),t[18]=_):_=t[18];let v;t[19]===n.channelConnectDeferModeAuto?v=t[20]:(v=(0,$.jsx)(`option`,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[19]=n.channelConnectDeferModeAuto,t[20]=v);let y;t[21]===n.channelConnectDeferModeOff?y=t[22]:(y=(0,$.jsx)(`option`,{value:`off`,children:n.channelConnectDeferModeOff}),t[21]=n.channelConnectDeferModeOff,t[22]=y);let b;t[23]===n.channelConnectDeferModeExplicit?b=t[24]:(b=(0,$.jsx)(`option`,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[23]=n.channelConnectDeferModeExplicit,t[24]=b);let x;t[25]!==r.channelConnectDeferMode||t[26]!==v||t[27]!==y||t[28]!==b||t[29]!==g?(x=(0,$.jsxs)(`select`,{id:`gateway-channel-defer-mode`,value:h,onChange:g,className:_,children:[v,y,b]}),t[25]=r.channelConnectDeferMode,t[26]=v,t[27]=y,t[28]=b,t[29]=g,t[30]=x):x=t[30];let S;t[31]===n.channelConnectDeferModeHint?S=t[32]:(S=(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[31]=n.channelConnectDeferModeHint,t[32]=S);let C;t[33]!==x||t[34]!==S||t[35]!==m?(C=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[m,x,S]}),t[33]=x,t[34]=S,t[35]=m,t[36]=C):C=t[36];let w;t[37]!==r.channelConnectDeferIds||t[38]!==r.channelConnectDeferMode||t[39]!==n.channelConnectDeferIds||t[40]!==n.channelConnectDeferIdsHint||t[41]!==n.channelIdListEmpty||t[42]!==n.channelIdListPlaceholder||t[43]!==o?(w=r.channelConnectDeferMode===`explicit`?(0,$.jsx)(sc,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:o}):null,t[37]=r.channelConnectDeferIds,t[38]=r.channelConnectDeferMode,t[39]=n.channelConnectDeferIds,t[40]=n.channelConnectDeferIdsHint,t[41]=n.channelIdListEmpty,t[42]=n.channelIdListPlaceholder,t[43]=o,t[44]=w):w=t[44];let T;t[45]!==r.channelConnectDeferMode||t[46]!==r.channelConnectDeferSkipIds||t[47]!==n.channelConnectDeferSkipIds||t[48]!==n.channelConnectDeferSkipIdsHint||t[49]!==n.channelIdListEmpty||t[50]!==n.channelIdListPlaceholder||t[51]!==s?(T=r.channelConnectDeferMode===`off`?null:(0,$.jsx)(sc,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:s}),t[45]=r.channelConnectDeferMode,t[46]=r.channelConnectDeferSkipIds,t[47]=n.channelConnectDeferSkipIds,t[48]=n.channelConnectDeferSkipIdsHint,t[49]=n.channelIdListEmpty,t[50]=n.channelIdListPlaceholder,t[51]=s,t[52]=T):T=t[52];let E;return t[53]!==C||t[54]!==w||t[55]!==T||t[56]!==p?(E=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p,C,w,T]}),t[53]=C,t[54]=w,t[55]=T,t[56]=p,t[57]=E):E=t[57],E}function sc(e){let t=(0,Q.c)(25),{title:n,hint:r,emptyText:i,placeholder:a,values:o,maxItems:s,onChange:c,children:l}=e,u;t[0]!==s||t[1]!==c||t[2]!==o?(u=e=>{let t=e.trim();!t||o.includes(t)||o.length>=s||c([...o,t])},t[0]=s,t[1]=c,t[2]=o,t[3]=u):u=t[3];let d=u,f;t[4]===n?f=t[5]:(f=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[4]=n,t[5]=f);let p;t[6]===r?p=t[7]:(p=(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=p);let m;t[8]!==i||t[9]!==c||t[10]!==o?(m=o.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,(0,$.jsx)(`button`,{type:`button`,className:Y(`text-fg-muted hover:text-fg`,jt.press),"aria-label":`Remove ${e}`,onClick:()=>c(o.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=c,t[10]=o,t[11]=m):m=t[11];let h;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(h=Y(qs(),`font-mono text-xs`),t[12]=h):h=t[12];let g=o.length>=s,_;t[13]===d?_=t[14]:(_=e=>{e.key===`Enter`&&(e.preventDefault(),d(e.target.value),e.target.value=``)},t[13]=d,t[14]=_);let v;t[15]!==a||t[16]!==g||t[17]!==_?(v=(0,$.jsx)(`input`,{className:h,placeholder:a,disabled:g,onKeyDown:_}),t[15]=a,t[16]=g,t[17]=_,t[18]=v):v=t[18];let y;return t[19]!==l||t[20]!==f||t[21]!==p||t[22]!==m||t[23]!==v?(y=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[f,p,m,v,l]}),t[19]=l,t[20]=f,t[21]=p,t[22]=m,t[23]=v,t[24]=y):y=t[24],y}function cc(e){let t=(0,Q.c)(13),{g:n,origins:r,onChange:i}=e,a;t[0]===r?a=t[1]:(a=r.includes(`*`),t[0]=r,t[1]=a);let o=a,s;t[2]!==n.corsOriginsWildcardWarning||t[3]!==o?(s=o?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[2]=n.corsOriginsWildcardWarning,t[3]=o,t[4]=s):s=t[4];let c;return t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==i||t[10]!==r||t[11]!==s?(c=(0,$.jsx)(sc,{title:n.corsOrigins,hint:n.corsOriginsHint,emptyText:n.corsOriginsEmpty,placeholder:n.corsOriginsPlaceholder,values:r,maxItems:128,onChange:i,children:s}),t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=i,t[10]=r,t[11]=s,t[12]=c):c=t[12],c}function lc(e){let t=(0,Q.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.rateLimitTitle}),t[0]=n.rateLimitTitle,t[1]=a);let o;t[2]===n.rateLimitHint?o=t[3]:(o=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.rateLimitHint}),t[2]=n.rateLimitHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,$.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.rateLimitEnabled||t[13]!==l?(u=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.rateLimitEnabled]}),t[12]=n.rateLimitEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({exemptLoopback:e.target.checked}),t[15]=i,t[16]=f);let p;t[17]!==r.exemptLoopback||t[18]!==d||t[19]!==f?(p=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.exemptLoopback,disabled:d,onChange:f}),t[17]=r.exemptLoopback,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]!==n.rateLimitExemptLoopback||t[22]!==p?(m=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[p,n.rateLimitExemptLoopback]}),t[21]=n.rateLimitExemptLoopback,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.rateLimitMaxAttempts?h=t[25]:(h=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=qs(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,$.jsx)(`input`,{id:`gateway-rate-max`,type:`number`,min:1,className:g,value:r.maxAttempts,disabled:_,onChange:v}),t[29]=r.maxAttempts,t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]!==h||t[34]!==y?(b=(0,$.jsxs)(`div`,{children:[h,y]}),t[33]=h,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n.rateLimitWindowMinutes?x=t[37]:(x=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=qs(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,$.jsx)(`input`,{id:`gateway-rate-window`,type:`number`,min:1,className:S,value:C,disabled:w,onChange:T}),t[43]=C,t[44]=w,t[45]=T,t[46]=E):E=t[46];let D;t[47]!==x||t[48]!==E?(D=(0,$.jsxs)(`div`,{children:[x,E]}),t[47]=x,t[48]=E,t[49]=D):D=t[49];let O;t[50]===n.rateLimitBlockMinutes?O=t[51]:(O=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=qs(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,$.jsx)(`input`,{id:`gateway-rate-block`,type:`number`,min:1,className:k,value:A,disabled:j,onChange:M}),t[57]=A,t[58]=j,t[59]=M,t[60]=N):N=t[60];let P;t[61]!==O||t[62]!==N?(P=(0,$.jsxs)(`div`,{children:[O,N]}),t[61]=O,t[62]=N,t[63]=P):P=t[63];let F;t[64]!==b||t[65]!==D||t[66]!==P?(F=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b,D,P]}),t[64]=b,t[65]=D,t[66]=P,t[67]=F):F=t[67];let I;return t[68]!==m||t[69]!==s||t[70]!==F||t[71]!==u?(I=(0,$.jsxs)(`div`,{className:`space-y-3 border-t border-edge pt-4`,children:[s,u,m,F]}),t[68]=m,t[69]=s,t[70]=F,t[71]=u,t[72]=I):I=t[72],I}function uc(e){let t=(0,Q.c)(17),{id:n,label:r,help:i,placeholder:a,value:o,labels:s,reveal:c,loadFailedLabel:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==s||t[5]!==l||t[6]!==u||t[7]!==a||t[8]!==c||t[9]!==o?(f=(0,$.jsx)(Ke,{id:n,value:o,onChange:u,placeholder:a,labels:s,reveal:c,loadFailedLabel:l,inputClassName:`text-xs`}),t[3]=n,t[4]=s,t[5]=l,t[6]=u,t[7]=a,t[8]=c,t[9]=o,t[10]=f):f=t[10];let p;t[11]===i?p=t[12]:(p=(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}),t[11]=i,t[12]=p);let m;return t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[d,f,p]}),t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}function dc(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt,`dark:border-edge`)}function fc(){return Y(et,Nt)}var pc=[`schedule`,`delivery`,`prompt`,`document`],mc={schedule:cn,delivery:M,prompt:Ve,document:Xe};function hc(e){return e&&pc.includes(e)?e:`schedule`}function gc(e,t){return t===`schedule`?e.tabSchedule:t===`delivery`?e.tabDelivery:t===`prompt`?e.tabPrompt:e.tabDocument}function _c(e,t){return t===`schedule`?e.scheduleTabHint:t===`delivery`?e.deliveryTabHint:t===`prompt`?e.promptTabHint:e.documentTabHint}function vc(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function yc(e,t){switch(t.type){case`reset`:return{doc:``,baseline:``};case`sync`:return{doc:t.value,baseline:t.value};case`set`:return{...e,doc:t.value};case`discard`:return{...e,doc:e.baseline};case`saved`:return{doc:t.value,baseline:t.value}}}function bc(e){if(!e||typeof e!=`object`||Array.isArray(e))return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults;if(!n||typeof n!=`object`||Array.isArray(n))return``;let r=n.workspace;return typeof r==`string`?r:``}var xc={saving:!1,error:null,triggerLoading:!1,triggerOk:!1,triggerError:null};function Sc(){let e=a(e=>e.language),t=s(e),n=t.heartbeatSettings,r=!!g(e=>e.token),[i,o]=C(),c=hc(i.get(`tab`)),l=(0,Z.useCallback)(e=>{o(t=>{let n=new URLSearchParams(t);return e===`schedule`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[o]),[u,f]=(0,Z.useReducer)(vc,{form:null,baseline:null}),p=u.form,m=u.baseline,[h,_]=(0,Z.useReducer)(yc,{doc:``,baseline:``}),v=h.doc,y=h.baseline,[b,x]=(0,Z.useReducer)(de,xc),{saving:S,error:w,triggerLoading:T,triggerOk:E,triggerError:D}=b,O=(0,Z.useRef)(!1),k=(0,Z.useRef)(!1),{data:A,error:j,isLoading:M,mutate:N}=rt(r),{data:P,error:F,isLoading:I,mutate:L}=d(r?$n():null,Xn,{revalidateOnFocus:!1}),{data:R=[]}=d(r?Yn():null,qn,{revalidateOnFocus:!1}),z=(0,Z.useMemo)(()=>bc(A?.payload?.config),[A]),B=(0,Z.useMemo)(()=>nr(A?.payload?.config??{}),[A]),V=(0,Z.useMemo)(()=>!p||!m?!1:JSON.stringify(p)!==JSON.stringify(m),[p,m]),H=v!==y;(0,Z.useEffect)(()=>{if(!r){f({type:`reset`}),O.current=!1;return}A!==void 0&&(O.current||f({type:`sync`,value:B}))},[r,A,B]),(0,Z.useEffect)(()=>{if(!r){_({type:`reset`}),k.current=!1;return}P!==void 0&&(k.current||_({type:`sync`,value:P}))},[r,P]);let U=j instanceof Error?j.message:j?String(j):F instanceof Error?F.message:F?String(F):null,W=!!(r&&(A===void 0||P===void 0)&&!U&&(M||I)),G=p?.target.trim()??``,{data:ee,setData:K}=ke(()=>An(G),[r,G],{enabled:r&&G.length>0,initial:[],errorData:[]}),q=(0,Z.useCallback)(()=>{G&&An(G).then(K)},[G,K]),te=(0,Z.useCallback)(async()=>{x({type:`patch`,patch:{triggerLoading:!0,triggerOk:!1,triggerError:null}});try{await Zn(),x({type:`patch`,patch:{triggerOk:!0}}),window.setTimeout(()=>x({type:`patch`,patch:{triggerOk:!1}}),3e3)}catch(e){x({type:`patch`,patch:{triggerError:e instanceof Error?e.message:n.triggerError}})}finally{x({type:`patch`,patch:{triggerLoading:!1}})}},[n.triggerError]),ne=(0,Z.useCallback)(e=>{O.current=!0,f({type:`patch`,patch:e})},[]),re=V||H,ie=(0,Z.useCallback)(()=>{f({type:`discard`}),_({type:`discard`}),O.current=!1,k.current=!1,x({type:`patch`,patch:{error:null}})},[]);return Dr({id:`heartbeat`,dirty:re,saving:S,save:(0,Z.useCallback)(async()=>{if(!(!p||S)){x({type:`patch`,patch:{saving:!0,error:null}});try{V&&(await Qn(p),f({type:`saved`,value:p}),O.current=!1),H&&(await er(v),_({type:`saved`,value:v}),k.current=!1)}catch(e){let t=V?n.saveConfigError:n.saveDocError,r=e instanceof Error?e.message:t;throw x({type:`patch`,patch:{error:r}}),Error(r)}finally{x({type:`patch`,patch:{saving:!1}})}}},[V,H,v,p,n.saveConfigError,n.saveDocError,S]),discard:ie}),r?W?(0,$.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(J,{className:`size-4 animate-spin`}),n.loading]})}):p?(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-4 px-4 py-6`,"aria-busy":S,"data-has-baseline":m?`1`:`0`,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.heartbeat}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,$.jsxs)(`a`,{href:Le(e,`heartbeat`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[n.docsLink,(0,$.jsx)(Dt,{className:`size-3.5`})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`inline-flex items-center gap-2`,disabled:T,onClick:()=>void te(),children:[T?(0,$.jsx)(J,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(wt,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),T?n.triggering:n.triggerNow]}),E?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.triggered}):null]})]}),(0,$.jsx)(Ui,{}),z?(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.workspaceLabel,`: `,(0,$.jsx)(`span`,{className:`font-mono text-fg-muted`,children:z})]}):null,w?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null,D?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:D}):null,(0,$.jsx)(Cc,{h:n,activeTab:c,onChange:l}),(0,$.jsx)(wc,{h:n,id:`schedule`,activeTab:c,children:(0,$.jsx)(Tc,{h:n,form:p,update:ne})}),(0,$.jsx)(wc,{h:n,id:`delivery`,activeTab:c,children:(0,$.jsx)(Ec,{h:n,cron:t.cron,form:p,channels:R,sessionChatIds:ee,onRefreshChatIds:q,update:ne,inputClassName:dc,selectClassName:fc})}),(0,$.jsx)(wc,{h:n,id:`prompt`,activeTab:c,children:(0,$.jsx)(kc,{h:n,form:p,update:ne,inputClassName:dc})}),(0,$.jsxs)(wc,{h:n,id:`document`,activeTab:c,children:[(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:n.docHint}),(0,$.jsx)(`textarea`,{className:Y(dc(),`min-h-72 resize-y font-mono text-xs leading-relaxed`),value:v,onChange:e=>{k.current=!0,_({type:`set`,value:e.target.value})},spellCheck:!1,"aria-label":n.docSection,"data-doc-in-sync":v===y?`true`:`false`})]})]}):(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:w??U??n.loadError}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>{N(),L()},children:n.retry})]}):(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.heartbeat}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Cc(e){let t=(0,Q.c)(11),{h:n,activeTab:r,onChange:i}=e,a=n.tabsAriaLabel,o;t[0]!==r||t[1]!==i?(o=e=>{e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),i(pc[(pc.indexOf(r)+(e.key===`ArrowRight`?1:-1)+pc.length)%pc.length]))},t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==r||t[4]!==n||t[5]!==i?(s=pc.map(e=>{let t=mc[e],a=e===r;return(0,$.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,id:`heartbeat-settings-tab-${e}`,"aria-controls":`heartbeat-settings-panel-${e}`,className:Y(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,jt.press,a?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>i(e),children:[(0,$.jsx)(t,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:gc(n,e)})]},e)}),t[3]=r,t[4]=n,t[5]=i,t[6]=s):s=t[6];let c;return t[7]!==n.tabsAriaLabel||t[8]!==o||t[9]!==s?(c=(0,$.jsx)(`nav`,{"aria-label":a,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,onKeyDown:o,children:s}),t[7]=n.tabsAriaLabel,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function wc(e){let t=(0,Q.c)(20),{h:n,id:r,activeTab:i,children:a}=e;if(i!==r)return null;let o=`heartbeat-settings-panel-${r}`,s=`heartbeat-settings-tab-${r}`,c;t[0]!==n||t[1]!==r?(c=gc(n,r),t[0]=n,t[1]=r,t[2]=c):c=t[2];let l;t[3]===c?l=t[4]:(l=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==n||t[6]!==r?(u=_c(n,r),t[5]=n,t[6]=r,t[7]=u):u=t[7];let d;t[8]===u?d=t[9]:(d=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}),t[8]=u,t[9]=d);let f;t[10]!==l||t[11]!==d?(f=(0,$.jsxs)(`div`,{className:`mb-5`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;t[13]===a?p=t[14]:(p=(0,$.jsx)(`div`,{className:`space-y-4`,children:a}),t[13]=a,t[14]=p);let m;return t[15]!==o||t[16]!==s||t[17]!==f||t[18]!==p?(m=(0,$.jsxs)(`section`,{id:o,role:`tabpanel`,"aria-labelledby":s,className:`rounded-2xl border border-edge bg-surface-base px-4 py-5 sm:px-5`,children:[f,p]}),t[15]=o,t[16]=s,t[17]=f,t[18]=p,t[19]=m):m=t[19],m}function Tc(e){let t=(0,Q.c)(37),{h:n,form:r,update:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.enable||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.enable]}),t[5]=n.enable,t[6]=o,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=e=>i({intervalMs:e}),t[8]=i,t[9]=c);let l;t[10]!==n.intervalPresets||t[11]!==n.intervalSecondsLabel?(l={secondsLabel:n.intervalSecondsLabel,presets:n.intervalPresets},t[10]=n.intervalPresets,t[11]=n.intervalSecondsLabel,t[12]=l):l=t[12];let u=`${n.intervalHintPreset} ${n.intervalHint}`,d;t[13]!==r.intervalMs||t[14]!==n.interval||t[15]!==c||t[16]!==l||t[17]!==u?(d=(0,$.jsx)(Zo,{kind:`interval`,label:n.interval,valueMs:r.intervalMs,onChangeMs:c,labels:l,hint:u}),t[13]=r.intervalMs,t[14]=n.interval,t[15]=c,t[16]=l,t[17]=u,t[18]=d):d=t[18];let f;t[19]===i?f=t[20]:(f=e=>i({activeHours:e}),t[19]=i,t[20]=f);let p;t[21]!==n.activeEnd||t[22]!==n.activeStart||t[23]!==n.activeTimezone||t[24]!==n.addActiveHours||t[25]!==n.clearActiveHours?(p={start:n.activeStart,end:n.activeEnd,timezone:n.activeTimezone,add:n.addActiveHours,clear:n.clearActiveHours},t[21]=n.activeEnd,t[22]=n.activeStart,t[23]=n.activeTimezone,t[24]=n.addActiveHours,t[25]=n.clearActiveHours,t[26]=p):p=t[26];let m;t[27]!==r.activeHours||t[28]!==n.activeHoursHint||t[29]!==n.activeHoursTitle||t[30]!==f||t[31]!==p?(m=(0,$.jsx)(Zo,{kind:`active-hours`,label:n.activeHoursTitle,value:r.activeHours,onChange:f,labels:p,hint:n.activeHoursHint}),t[27]=r.activeHours,t[28]=n.activeHoursHint,t[29]=n.activeHoursTitle,t[30]=f,t[31]=p,t[32]=m):m=t[32];let h;return t[33]!==m||t[34]!==s||t[35]!==d?(h=(0,$.jsxs)($.Fragment,{children:[s,d,m]}),t[33]=m,t[34]=s,t[35]=d,t[36]=h):h=t[36],h}function Ec(e){let t=(0,Q.c)(51),{h:n,cron:r,form:i,channels:a,sessionChatIds:o,onRefreshChatIds:s,update:c,inputClassName:l,selectClassName:u}=e,d;t[0]===a?d=t[1]:(d=new Set(a.map(Oc)),t[0]=a,t[1]=d);let f=d,p;t[2]===i.target?p=t[3]:(p=i.target.trim(),t[2]=i.target,t[3]=p);let m=p,h=!!(m&&!f.has(m)),g;t[4]===n.deliveryHint?g=t[5]:(g=(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.deliveryHint}),t[4]=n.deliveryHint,t[5]=g);let _;t[6]===r.channel?_=t[7]:(_=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.channel}),t[6]=r.channel,t[7]=_);let v;t[8]===u?v=t[9]:(v=u(),t[8]=u,t[9]=v);let y;t[10]===c?y=t[11]:(y=e=>{c({target:e.target.value.trim(),targetChatId:``})},t[10]=c,t[11]=y);let b;t[12]===n.channelNone?b=t[13]:(b=(0,$.jsx)(`option`,{value:``,children:n.channelNone}),t[12]=n.channelNone,t[13]=b);let x;t[14]!==n.customChannelSuffix||t[15]!==h||t[16]!==m?(x=h?(0,$.jsxs)(`option`,{value:m,children:[m,` (`,n.customChannelSuffix,`)`]}):null,t[14]=n.customChannelSuffix,t[15]=h,t[16]=m,t[17]=x):x=t[17];let S;t[18]===a?S=t[19]:(S=a.map(Dc),t[18]=a,t[19]=S);let C;t[20]!==v||t[21]!==y||t[22]!==b||t[23]!==x||t[24]!==S||t[25]!==m?(C=(0,$.jsxs)(`select`,{className:v,value:m,onChange:y,children:[b,x,S]}),t[20]=v,t[21]=y,t[22]=b,t[23]=x,t[24]=S,t[25]=m,t[26]=C):C=t[26];let w;t[27]!==C||t[28]!==_?(w=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[_,C]}),t[27]=C,t[28]=_,t[29]=w):w=t[29];let T;t[30]!==r.enterManuallyOrSelect||t[31]!==r.lastActiveLabels||t[32]!==r.noRecentChats||t[33]!==r.noRecentChatsOption||t[34]!==r.recipient||t[35]!==r.recipientPlaceholder||t[36]!==r.refreshList||t[37]!==r.refreshRecipientHint||t[38]!==r.selectRecipient||t[39]!==i.targetChatId||t[40]!==l||t[41]!==s||t[42]!==u||t[43]!==o||t[44]!==m||t[45]!==c?(T=m?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.recipient}),(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:r.refreshRecipientHint,onClick:s,children:[(0,$.jsx)(At,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),r.refreshList]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,className:Y(l(),`min-w-0 flex-1`),value:i.targetChatId,onChange:e=>c({targetChatId:e.target.value}),placeholder:r.recipientPlaceholder,autoComplete:`off`}),(0,$.jsxs)(`select`,{className:Y(u(),`max-w-40 shrink-0 text-xs`),value:i.targetChatId,onChange:e=>{let t=e.target.value;t&&c({targetChatId:t})},children:[(0,$.jsx)(`option`,{value:``,children:r.selectRecipient}),o.length>0?o.map(e=>(0,$.jsx)(`option`,{value:e.chatId,children:Dn(e,r.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,$.jsx)(`option`,{value:``,disabled:!0,children:r.noRecentChatsOption})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.length>0?r.enterManuallyOrSelect:r.noRecentChats})]}):null,t[30]=r.enterManuallyOrSelect,t[31]=r.lastActiveLabels,t[32]=r.noRecentChats,t[33]=r.noRecentChatsOption,t[34]=r.recipient,t[35]=r.recipientPlaceholder,t[36]=r.refreshList,t[37]=r.refreshRecipientHint,t[38]=r.selectRecipient,t[39]=i.targetChatId,t[40]=l,t[41]=s,t[42]=u,t[43]=o,t[44]=m,t[45]=c,t[46]=T):T=t[46];let E;return t[47]!==w||t[48]!==T||t[49]!==g?(E=(0,$.jsxs)($.Fragment,{children:[g,w,T]}),t[47]=w,t[48]=T,t[49]=g,t[50]=E):E=t[50],E}function Dc(e){return(0,$.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Oc(e){return e.name}function kc(e){let t=(0,Q.c)(65),{h:n,form:r,update:i,inputClassName:a}=e,o;t[0]===i?o=t[1]:(o=e=>i({includeSystemPromptSection:e.target.checked}),t[0]=i,t[1]=o);let s;t[2]!==r.includeSystemPromptSection||t[3]!==o?(s=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.includeSystemPromptSection,onChange:o}),t[2]=r.includeSystemPromptSection,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.includeSystemPromptSectionHint?c=t[6]:(c=(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.includeSystemPromptSectionHint}),t[5]=n.includeSystemPromptSectionHint,t[6]=c);let l;t[7]!==n.includeSystemPromptSection||t[8]!==c?(l=(0,$.jsxs)(`span`,{children:[n.includeSystemPromptSection,c]}),t[7]=n.includeSystemPromptSection,t[8]=c,t[9]=l):l=t[9];let u;t[10]!==s||t[11]!==l?(u=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,l]}),t[10]=s,t[11]=l,t[12]=u):u=t[12];let d;t[13]===n.prompt?d=t[14]:(d=(0,$.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.prompt}),t[13]=n.prompt,t[14]=d);let f;t[15]===a?f=t[16]:(f=Y(a(),`min-h-36 resize-y font-mono text-xs`),t[15]=a,t[16]=f);let p;t[17]===i?p=t[18]:(p=e=>i({prompt:e.target.value}),t[17]=i,t[18]=p);let m;t[19]!==r.prompt||t[20]!==n.promptPlaceholder||t[21]!==f||t[22]!==p?(m=(0,$.jsx)(`textarea`,{className:f,value:r.prompt,onChange:p,placeholder:n.promptPlaceholder}),t[19]=r.prompt,t[20]=n.promptPlaceholder,t[21]=f,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.promptHint?h=t[25]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.promptHint}),t[24]=n.promptHint,t[25]=h);let g;t[26]!==h||t[27]!==d||t[28]!==m?(g=(0,$.jsxs)(`div`,{children:[d,m,h]}),t[26]=h,t[27]=d,t[28]=m,t[29]=g):g=t[29];let _;t[30]===n.ackMaxChars?_=t[31]:(_=(0,$.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.ackMaxChars}),t[30]=n.ackMaxChars,t[31]=_);let v;t[32]===a?v=t[33]:(v=a(),t[32]=a,t[33]=v);let y=r.ackMaxChars===``?``:r.ackMaxChars,b;t[34]===i?b=t[35]:(b=e=>{let t=e.target.value;if(t===``){i({ackMaxChars:``});return}let n=parseInt(t,10);i({ackMaxChars:Number.isFinite(n)?n:``})},t[34]=i,t[35]=b);let x;t[36]!==n.ackDefaultPlaceholder||t[37]!==v||t[38]!==y||t[39]!==b?(x=(0,$.jsx)(`input`,{type:`number`,min:1,className:v,value:y,onChange:b,placeholder:n.ackDefaultPlaceholder}),t[36]=n.ackDefaultPlaceholder,t[37]=v,t[38]=y,t[39]=b,t[40]=x):x=t[40];let S;t[41]===n.ackMaxCharsHint?S=t[42]:(S=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.ackMaxCharsHint}),t[41]=n.ackMaxCharsHint,t[42]=S);let C;t[43]!==_||t[44]!==x||t[45]!==S?(C=(0,$.jsxs)(`div`,{children:[_,x,S]}),t[43]=_,t[44]=x,t[45]=S,t[46]=C):C=t[46];let w;t[47]===i?w=t[48]:(w=e=>i({isolatedSession:e.target.checked}),t[47]=i,t[48]=w);let T;t[49]!==r.isolatedSession||t[50]!==w?(T=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.isolatedSession,onChange:w}),t[49]=r.isolatedSession,t[50]=w,t[51]=T):T=t[51];let E;t[52]===n.isolatedSessionHint?E=t[53]:(E=(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.isolatedSessionHint}),t[52]=n.isolatedSessionHint,t[53]=E);let D;t[54]!==n.isolatedSession||t[55]!==E?(D=(0,$.jsxs)(`span`,{children:[n.isolatedSession,E]}),t[54]=n.isolatedSession,t[55]=E,t[56]=D):D=t[56];let O;t[57]!==T||t[58]!==D?(O=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[T,D]}),t[57]=T,t[58]=D,t[59]=O):O=t[59];let k;return t[60]!==g||t[61]!==C||t[62]!==O||t[63]!==u?(k=(0,$.jsxs)($.Fragment,{children:[u,g,C,O]}),t[60]=g,t[61]=C,t[62]=O,t[63]=u,t[64]=k):k=t[64],k}function Ac(e,t){let{mutate:n}=u(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),l=(0,Z.useCallback)(async()=>{await Promise.all([n(`tunnel-pair-context`),n(`tunnel-pair`),n(`tunnel-status`),Xt()])},[n]);return{busy:r,error:a,confirmOpen:s,setConfirmOpen:c,runEnableLanPairing:(0,Z.useCallback)(async()=>{if(!(!e||r)){i(!0),o(null);try{let n=await tt();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await mt();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await Ye(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await Pt():n.context;if(!r?.pairingReady)throw Error(`LAN pairing is still not ready after restart`);return await l(),t?.(r),c(!1),r}catch(e){return o(e instanceof Error?e.message:`Enable LAN pairing failed`),null}finally{i(!1)}}},[r,e,t,l]),clearError:()=>o(null)}}function jc(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt,`dark:border-edge`)}function Mc(e){let t=(0,Q.c)(122),{pairQr:n,gatewayToken:r,streamlined:i,lanOnly:o,onRefreshQr:c}=e,l=i===void 0?!1:i,u=o===void 0?!1:o,d=a(Fc),f;t[0]===d?f=t[1]:(f=s(d),t[0]=d,t[1]=f);let p=f,m=p.tunnelSettings,h=u?p.remoteAccess.lan:null,g;t[2]!==p.clipboard.copyFailed||t[3]!==m.pairCopied||t[4]!==m.pairCopyLink?(g={copy:m.pairCopyLink,copied:m.pairCopied,copyFailed:p.clipboard.copyFailed},t[2]=p.clipboard.copyFailed,t[3]=m.pairCopied,t[4]=m.pairCopyLink,t[5]=g):g=t[5];let _=g,{tunnelActive:v,tunnelStatus:y,tunnelQr:b,pairContext:x,pairBaseUrl:S,setPairBaseUrl:C,applySuggestedPairUrl:w,applyCandidateUrl:T,resetPairBaseFromContext:E,baseOk:D,localhostWarn:O,pairingBlocked:k,deepLink:A,qrPayload:j,qrDataUrl:M,qrGenFailed:N,encoding:P}=n,F;t[6]===E?F=t[7]:(F=e=>{E(e.recommended.url)},t[6]=E,t[7]=F);let I=Ac(r,F),L,R,z,B,V;if(t[8]!==T||t[9]!==w||t[10]!==D||t[11]!==I||t[12]!==r||t[13]!==h||t[14]!==u||t[15]!==O||t[16]!==c||t[17]!==S||t[18]!==x?.candidates||t[19]!==x?.recommended||t[20]!==k||t[21]!==C||t[22]!==l||t[23]!==m.pairBaseUrlHint||t[24]!==m.pairBaseUrlLabel||t[25]!==m.pairBaseUrlPlaceholder||t[26]!==m.pairBlockedLoopbackBody||t[27]!==m.pairBlockedNextSteps||t[28]!==m.pairBlockedTitle||t[29]!==m.pairCandidatesTitle||t[30]!==m.pairEnableLanButton||t[31]!==m.pairEnableLanEnabling||t[32]!==m.pairEnableLanSecurityAuditLink||t[33]!==m.pairInvalidBaseUrl||t[34]!==m.pairLocalhostWarning||t[35]!==m.pairSelectCandidateHint||t[36]!==m.pairSelectCandidateTitle||t[37]!==m.pairSubtitle||t[38]!==m.pairSuggestedLanLabel||t[39]!==m.pairTitle||t[40]!==m.pairTunnelActive||t[41]!==m.pairTunnelLanUrl||t[42]!==m.pairTunnelPublicUrl||t[43]!==m.pairUseSuggestedUrl||t[44]!==m.pairWaitingForTunnel||t[45]!==m.refreshQr||t[46]!==v||t[47]!==b||t[48]!==y?.publicUrl){V=Symbol.for(`react.early_return_sentinel`);bb0:{let e=x?.candidates.filter(Pc)??[],n=u?(e.find(Nc)?.url??e[0]?.url??``).trim():x?.recommended.url?.trim()??``,i=(u||!v)&&e.length>1,a=function(t){if(e.length===0)return null;let n=t===`amber`?`text-amber-950 dark:text-amber-100`:`text-fg`,r=t===`amber`?`text-amber-950/80 dark:text-amber-200/90`:`text-fg-muted`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:Y(`text-xs font-medium`,r),children:i?m.pairSelectCandidateTitle:m.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:Y(`w-full rounded-md border px-2 py-1.5 text-left font-mono text-[11px] transition-colors`,t===`amber`?`border-amber-300/70 hover:bg-amber-100/80 dark:border-amber-800 dark:hover:bg-amber-950/50`:`border-edge hover:bg-surface-panel`,S.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>T(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),i?(0,$.jsx)(`p`,{className:Y(`mt-1 text-[11px] leading-relaxed`,r),children:m.pairSelectCandidateHint}):null]})};if(L=l&&!u,L&&!v){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ln,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===m.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,m.pairTitle]}),t[55]=m.pairTitle,t[56]=n);let r;t[57]===m.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:m.pairWaitingForTunnel}),t[57]=m.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(Tn,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],V=i;break bb0}let o=h?.pairTitle??m.pairTitle,s=u?h?.pairSubtitle??m.pairSubtitle:v?m.pairTunnelActive:m.pairSubtitle,d=!!(c&&(u||l&&v)),f=L?`mb-2`:`mb-3`,p;t[62]===f?p=t[63]:(p=Y(`flex flex-wrap items-start justify-between gap-2`,f),t[62]=f,t[63]=p);let g;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(ln,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=g):g=t[64];let _;t[65]===o?_=t[66]:(_=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[g,o]}),t[65]=o,t[66]=_);let E;t[67]!==L||t[68]!==s||t[69]!==m.pairSubtitle?(E=L?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:m.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:s}),t[67]=L,t[68]=s,t[69]=m.pairSubtitle,t[70]=E):E=t[70];let A;t[71]!==_||t[72]!==E?(A=(0,$.jsxs)(`div`,{children:[_,E]}),t[71]=_,t[72]=E,t[73]=A):A=t[73];let j;t[74]!==c||t[75]!==d||t[76]!==m.refreshQr?(j=d?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void c(),children:[(0,$.jsx)(At,{className:`size-4`}),m.refreshQr]}):null,t[74]=c,t[75]=d,t[76]=m.refreshQr,t[77]=j):j=t[77],t[78]!==p||t[79]!==A||t[80]!==j?(R=(0,$.jsxs)(`div`,{className:p,children:[A,j]}),t[78]=p,t[79]=A,t[80]=j,t[81]=R):R=t[81],z=k?(0,$.jsxs)(`div`,{className:`mb-3 space-y-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-3 dark:border-amber-900/50 dark:bg-amber-950/30`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-amber-950 dark:text-amber-100`,children:m.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:m.pairBlockedLoopbackBody})]}),n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-amber-950/80 dark:text-amber-200/90`,children:m.pairSuggestedLanLabel}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-amber-950 dark:text-amber-100`,children:n})]}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:w,children:m.pairUseSuggestedUrl})]}):null,e.length>0?a(`amber`):null,(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:(0,$.jsxs)(X,{type:`button`,className:`w-full sm:w-auto`,disabled:I.busy||!r,onClick:()=>I.setConfirmOpen(!0),children:[I.busy?(0,$.jsx)(J,{className:`size-3.5 animate-spin`}):null,I.busy?m.pairEnableLanEnabling:m.pairEnableLanButton]})}),I.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:I.error}):null,(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:u?h?.pairBlockedNextSteps??m.pairBlockedNextSteps:m.pairBlockedNextSteps}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ne,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:m.pairEnableLanSecurityAuditLink}),u&&h?.pairPublicTabLink?(0,$.jsx)(ne,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:h.pairPublicTabLink}):null]})]}):null,B=v&&!u?L?null:(0,$.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg border border-edge bg-surface-panel px-3 py-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:m.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:y?.publicUrl})]}),b?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:m.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:b.lanUrl})]}):null]}):(0,$.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`tunnel-mobile-pair-base`,children:m.pairBaseUrlLabel}),(0,$.jsx)(`input`,{id:`tunnel-mobile-pair-base`,className:Y(jc(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||m.pairBaseUrlPlaceholder,value:S,onChange:e=>C(e.target.value)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:m.pairBaseUrlHint}),!D&&S.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:m.pairInvalidBaseUrl}):null,O?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:m.pairLocalhostWarning}):null,i?a(`neutral`):null]})}t[8]=T,t[9]=w,t[10]=D,t[11]=I,t[12]=r,t[13]=h,t[14]=u,t[15]=O,t[16]=c,t[17]=S,t[18]=x?.candidates,t[19]=x?.recommended,t[20]=k,t[21]=C,t[22]=l,t[23]=m.pairBaseUrlHint,t[24]=m.pairBaseUrlLabel,t[25]=m.pairBaseUrlPlaceholder,t[26]=m.pairBlockedLoopbackBody,t[27]=m.pairBlockedNextSteps,t[28]=m.pairBlockedTitle,t[29]=m.pairCandidatesTitle,t[30]=m.pairEnableLanButton,t[31]=m.pairEnableLanEnabling,t[32]=m.pairEnableLanSecurityAuditLink,t[33]=m.pairInvalidBaseUrl,t[34]=m.pairLocalhostWarning,t[35]=m.pairSelectCandidateHint,t[36]=m.pairSelectCandidateTitle,t[37]=m.pairSubtitle,t[38]=m.pairSuggestedLanLabel,t[39]=m.pairTitle,t[40]=m.pairTunnelActive,t[41]=m.pairTunnelLanUrl,t[42]=m.pairTunnelPublicUrl,t[43]=m.pairUseSuggestedUrl,t[44]=m.pairWaitingForTunnel,t[45]=m.refreshQr,t[46]=v,t[47]=b,t[48]=y?.publicUrl,t[49]=L,t[50]=R,t[51]=z,t[52]=B,t[53]=V}else L=t[49],R=t[50],z=t[51],B=t[52],V=t[53];if(V!==Symbol.for(`react.early_return_sentinel`))return V;let H;t[82]===m.pairSecurityNote?H=t[83]:(H=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:m.pairSecurityNote}),t[82]=m.pairSecurityNote,t[83]=H);let U;t[84]!==_||t[85]!==A||t[86]!==P||t[87]!==k||t[88]!==M||t[89]!==N||t[90]!==m.pairEncoding||t[91]!==m.pairImageError||t[92]!==m.pairQrDisabled?(U=A?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[M&&!N?(0,$.jsx)(`img`,{src:M,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,P?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m.pairEncoding}):null,N?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:m.pairImageError}):null,(0,$.jsx)(ce,{text:A,labels:_})]}):k?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m.pairQrDisabled}):null,t[84]=_,t[85]=A,t[86]=P,t[87]=k,t[88]=M,t[89]=N,t[90]=m.pairEncoding,t[91]=m.pairImageError,t[92]=m.pairQrDisabled,t[93]=U):U=t[93];let W;t[94]!==L||t[95]!==j||t[96]!==m.deeplinkTitle?(W=j&&!L?(0,$.jsxs)(`details`,{className:`mt-3 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:m.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:j})]}):null,t[94]=L,t[95]=j,t[96]=m.deeplinkTitle,t[97]=W):W=t[97];let G;t[98]!==L||t[99]!==m.pairMobileProbeHint||t[100]!==m.pairSchemeHint?(G=L?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:m.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:m.pairMobileProbeHint})]}),t[98]=L,t[99]=m.pairMobileProbeHint,t[100]=m.pairSchemeHint,t[101]=G):G=t[101];let ee,K;t[102]===I?(ee=t[103],K=t[104]):(ee=()=>void I.runEnableLanPairing(),K=()=>{I.busy||I.setConfirmOpen(!1)},t[102]=I,t[103]=ee,t[104]=K);let q;t[105]!==I.confirmOpen||t[106]!==m.consentCancel||t[107]!==m.pairEnableLanButton||t[108]!==m.pairEnableLanConfirmBody||t[109]!==m.pairEnableLanConfirmTitle||t[110]!==ee||t[111]!==K?(q=(0,$.jsx)(rn,{open:I.confirmOpen,title:m.pairEnableLanConfirmTitle,description:m.pairEnableLanConfirmBody,confirmLabel:m.pairEnableLanButton,cancelLabel:m.consentCancel,onConfirm:ee,onCancel:K}),t[105]=I.confirmOpen,t[106]=m.consentCancel,t[107]=m.pairEnableLanButton,t[108]=m.pairEnableLanConfirmBody,t[109]=m.pairEnableLanConfirmTitle,t[110]=ee,t[111]=K,t[112]=q):q=t[112];let te;return t[113]!==H||t[114]!==U||t[115]!==W||t[116]!==G||t[117]!==q||t[118]!==R||t[119]!==z||t[120]!==B?(te=(0,$.jsx)(Tn,{children:(0,$.jsxs)($.Fragment,{children:[R,z,B,H,U,W,G,q]})}),t[113]=H,t[114]=U,t[115]=W,t[116]=G,t[117]=q,t[118]=R,t[119]=z,t[120]=B,t[121]=te):te=t[121],te}function Nc(e){return e.reachable}function Pc(e){return e.kind===`lan`}function Fc(e){return e.language}function Ic(e){let t=(0,Q.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:s,cancelLabel:c,onConfirm:l,onCancel:u}=e,[d,f]=(0,Z.useState)(!1),p;t[0]===u?p=t[1]:(p=e=>{e||(f(!1),u())},t[0]=u,t[1]=p);let m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(V,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Ze)}),t[2]=m):m=t[2];let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=Y(`fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`,sn),t[3]=h):h=t[3];let g;t[4]===r?g=t[5]:(g=(0,$.jsx)(Ct,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=g);let _;t[6]===i?_=t[7]:(_=(0,$.jsx)(je,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=_);let v;t[8]===a?v=t[9]:(v=a.map(Lc),t[8]=a,t[9]=v);let y;t[10]===v?y=t[11]:(y=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:v}),t[10]=v,t[11]=y);let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>f(e.target.checked),t[12]=b):b=t[12];let x;t[13]===d?x=t[14]:(x=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:d,onChange:b}),t[13]=d,t[14]=x);let S;t[15]===o?S=t[16]:(S=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=S);let C;t[17]!==S||t[18]!==x?(C=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[x,S]}),t[17]=S,t[18]=x,t[19]=C):C=t[19];let w;t[20]!==c||t[21]!==u?(w=(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:u,children:c}),t[20]=c,t[21]=u,t[22]=w):w=t[22];let T=!d,E;t[23]!==s||t[24]!==l||t[25]!==T?(E=(0,$.jsx)(X,{type:`button`,disabled:T,onClick:l,children:s}),t[23]=s,t[24]=l,t[25]=T,t[26]=E):E=t[26];let D;t[27]!==w||t[28]!==E?(D=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[w,E]}),t[27]=w,t[28]=E,t[29]=D):D=t[29];let O;t[30]!==C||t[31]!==D||t[32]!==g||t[33]!==_||t[34]!==y?(O=(0,$.jsxs)(R,{children:[m,(0,$.jsxs)(nn,{className:h,onOpenAutoFocus:Rc,children:[g,_,y,C,D]})]}),t[30]=C,t[31]=D,t[32]=g,t[33]=_,t[34]=y,t[35]=O):O=t[35];let k;return t[36]!==n||t[37]!==p||t[38]!==O?(k=(0,$.jsx)(ve,{open:n,onOpenChange:p,children:O}),t[36]=n,t[37]=p,t[38]=O,t[39]=k):k=t[39],k}function Lc(e){return(0,$.jsx)(`li`,{children:e},e)}function Rc(e){return e.preventDefault()}function zc(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Bc=[`preparing_frpc`,`registering`,`starting_frpc`];function Vc(e){return e?e===`reconnecting_frpc`?Bc.indexOf(`starting_frpc`):Bc.indexOf(e):-1}function Hc(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Bc.indexOf(e),i=Vc(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Uc(e,t,n){let r=n.startProgress;return Hc(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function Wc(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Gc(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Kc(e){let t=(0,Q.c)(31),{status:n,t:r}=e,[,i]=(0,Z.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(qc),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let o=n.startProgress?.startedAt,s;if(t[3]!==n.state||t[4]!==o?(s=[n.state,o],t[3]=n.state,t[4]=o,t[5]=s):s=t[5],(0,Z.useEffect)(a,s),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let c,l,u,d,f;if(t[6]!==n||t[7]!==r){let e=Gc(n.startProgress?.startedAt);c=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,l=`mt-3 space-y-3 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-3`;let i;t[13]===r.startProgressTitle?i=t[14]:(i=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=i);let a;t[15]===r.startProgressHint?a=t[16]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=a),t[17]!==i||t[18]!==a?(u=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=u):u=t[19];let o=Bc.map(e=>{let t=Hc(e,n),i=Uc(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(fe,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(J,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(Oe,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:Y(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Wc(r,e)}),i?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:i}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:Y(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[zc(n.frpcDownload.bytesReceived),` /`,` `,zc(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===o?d=t[21]:(d=(0,$.jsx)(`ol`,{className:`space-y-2`,children:o}),t[20]=o,t[21]=d),f=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f}else c=t[8],l=t[9],u=t[10],d=t[11],f=t[12];let p;t[22]!==c||t[23]!==r.publicUrlPendingNotice?(p=c?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=c,t[23]=r.publicUrlPendingNotice,t[24]=p):p=t[24];let m;return t[25]!==l||t[26]!==u||t[27]!==d||t[28]!==f||t[29]!==p?(m=(0,$.jsxs)(`div`,{className:l,children:[u,d,f,p]}),t[25]=l,t[26]=u,t[27]=d,t[28]=f,t[29]=p,t[30]=m):m=t[30],m}function qc(e){return e+1}function Jc(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function Yc(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function Xc(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function Zc(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Qc(e){let t=(0,Q.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:s,showConsentExpired:c,copyLabels:l,startDisabled:u,startDisabledReason:d,stepLabel:f,onStart:p,onStop:m}=e,h=u===void 0?!1:u,g,_,v,y,b,S,C;t[0]!==r||t[1]!==o?(C=Yc(r),g=r.enabled||o,_=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=Y(wn(),`space-y-4`),t[9]=S):S=t[9],b=`flex flex-wrap items-start justify-between gap-3`,y=`flex items-center gap-2`,v=Y(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Xc(C)),t[0]=r,t[1]=o,t[2]=g,t[3]=_,t[4]=v,t[5]=y,t[6]=b,t[7]=S,t[8]=C):(g=t[2],_=t[3],v=t[4],y=t[5],b=t[6],S=t[7],C=t[8]);let w=C===`connected`&&`bg-emerald-500`,T=C===`progress`&&`bg-amber-500 animate-pulse`,E=C===`error`&&`bg-red-500`,D=C===`off`&&`bg-fg-subtle`,O;t[10]!==w||t[11]!==T||t[12]!==E||t[13]!==D?(O=Y(`size-1.5 rounded-full`,w,T,E,D),t[10]=w,t[11]=T,t[12]=E,t[13]=D,t[14]=O):O=t[14];let k;t[15]===O?k=t[16]:(k=(0,$.jsx)(`span`,{className:O,"aria-hidden":!0}),t[15]=O,t[16]=k);let A;t[17]!==i||t[18]!==r||t[19]!==n?(A=i&&!r.enabled?n.loading:Jc(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=A):A=t[20];let j;t[21]!==k||t[22]!==A||t[23]!==v?(j=(0,$.jsxs)(`span`,{className:v,children:[k,A]}),t[21]=k,t[22]=A,t[23]=v,t[24]=j):j=t[24];let M;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(M=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Zc(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=M):M=t[28];let P;t[29]!==j||t[30]!==M||t[31]!==y?(P=(0,$.jsxs)(`div`,{className:y,children:[j,M]}),t[29]=j,t[30]=M,t[31]=y,t[32]=P):P=t[32];let F;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(x,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=F):F=t[33];let I;t[34]!==P||t[35]!==b?(I=(0,$.jsxs)(`div`,{className:b,children:[P,F]}),t[34]=P,t[35]=b,t[36]=I):I=t[36];let L;t[37]===a?L=t[38]:(L=a?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a instanceof Error?a.message:String(a)}):null,t[37]=a,t[38]=L);let R;t[39]!==c||t[40]!==n.consentExpiredBanner?(R=c?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=c,t[40]=n.consentExpiredBanner,t[41]=R):R=t[41];let z;t[42]!==g||t[43]!==l||t[44]!==p||t[45]!==m||t[46]!==_||t[47]!==r||t[48]!==h||t[49]!==d||t[50]!==o||t[51]!==f||t[52]!==s||t[53]!==n?(z=g?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-3`,children:(0,$.jsx)(ce,{label:n.publicUrlLabel,text:r.publicUrl,labels:l})}):null,_?(0,$.jsx)(Kc,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:s,onClick:m,children:[s?(0,$.jsx)(J,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(X,{type:`button`,disabled:o,onClick:p,children:[o?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(Mt,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[f?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:f}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(N,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),h&&d?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:d}):null,(0,$.jsxs)(X,{type:`button`,disabled:o||h,onClick:p,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(Mt,{className:`size-4`}),n.start]})]}),t[42]=g,t[43]=l,t[44]=p,t[45]=m,t[46]=_,t[47]=r,t[48]=h,t[49]=d,t[50]=o,t[51]=f,t[52]=s,t[53]=n,t[54]=z):z=t[54];let B;return t[55]!==I||t[56]!==L||t[57]!==R||t[58]!==z||t[59]!==S?(B=(0,$.jsxs)(`section`,{className:S,children:[I,L,R,z]}),t[55]=I,t[56]=L,t[57]=R,t[58]=z,t[59]=S,t[60]=B):B=t[60],B}var $c=`https://console.xopc.ai/keys/tunnel`,el={reconfiguring:!1};function tl(e){let t=(0,Q.c)(84),{t:n,brokerSecretFromEnv:r,brokerSecretMissing:i,brokerSecretConfiguredInConfig:a,brokerSecretMaskedValue:o,brokerSecretDraft:s,savingBrokerSecret:c,brokerSecretNotice:l,copyFailedLabel:u,onDraftChange:d,onSave:f,onClear:p,sectionRef:m}=e,h=(0,Z.useId)(),g=i&&!r,_=!g,[v,y]=(0,Z.useReducer)(de,el),{reconfiguring:b}=v,x;t[0]!==a||t[1]!==s||t[2]!==r||t[3]!==b?(x=a&&!r&&!b&&!s.trim(),t[0]=a,t[1]=s,t[2]=r,t[3]=b,t[4]=x):x=t[4];let S=x,C;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(C={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[5]=n.copied,t[6]=n.copyKey,t[7]=n.hideKey,t[8]=n.showKey,t[9]=C):C=t[9];let w=C,T;t[10]===s?T=t[11]:(T=s.trim().length>0&&!Me(s.trim()),t[10]=s,t[11]=T);let E=T,D;t[12]===d?D=t[13]:(D=()=>{y({type:`patch`,patch:{reconfiguring:!1}}),d(``)},t[12]=d,t[13]=D);let O=D,k=g&&`ring-1 ring-amber-500/30`,A;t[14]===k?A=t[15]:(A=Y(k),t[14]=k,t[15]=A);let j=_?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:g?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,M;t[16]===j?M=t[17]:(M=Y(`flex size-9 shrink-0 items-center justify-center rounded-lg`,j),t[16]=j,t[17]=M);let N;t[18]===_?N=t[19]:(N=_?(0,$.jsx)(fe,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(ee,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=_,t[19]=N);let P;t[20]!==M||t[21]!==N?(P=(0,$.jsx)(`span`,{className:M,children:N}),t[20]=M,t[21]=N,t[22]=P):P=t[22];let F=_?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,I;t[23]===F?I=t[24]:(I=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:F}),t[23]=F,t[24]=I);let L=_?n.brokerSecretReadyHint:n.brokerSecretHint,R;t[25]===L?R=t[26]:(R=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:L}),t[25]=L,t[26]=R);let z;t[27]!==g||t[28]!==n.brokerSecretMissingHint?(z=g?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=g,t[28]=n.brokerSecretMissingHint,t[29]=z):z=t[29];let B;t[30]!==I||t[31]!==R||t[32]!==z?(B=(0,$.jsxs)(`div`,{children:[I,R,z]}),t[30]=I,t[31]=R,t[32]=z,t[33]=B):B=t[33];let V;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(Dt,{className:`size-3`,"aria-hidden":!0}),t[34]=V):V=t[34];let H;t[35]===n.brokerSecretConsoleLink?H=t[36]:(H=(0,$.jsxs)(`a`,{href:$c,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,V]}),t[35]=n.brokerSecretConsoleLink,t[36]=H);let U;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(U=r?(0,$.jsx)(`p`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-xs text-fg-muted`,children:n.brokerSecretEnvHint}):null,t[37]=r,t[38]=n.brokerSecretEnvHint,t[39]=U):U=t[39];let W;t[40]!==a||t[41]!==s||t[42]!==r||t[43]!==o||t[44]!==E||t[45]!==O||t[46]!==u||t[47]!==h||t[48]!==g||t[49]!==p||t[50]!==d||t[51]!==f||t[52]!==b||t[53]!==c||t[54]!==w||t[55]!==S||t[56]!==n.brokerSecretCancelReconfigure||t[57]!==n.brokerSecretClear||t[58]!==n.brokerSecretMaskedHelp||t[59]!==n.brokerSecretNotInConfigFile||t[60]!==n.brokerSecretPlaceholder||t[61]!==n.brokerSecretReconfigure||t[62]!==n.brokerSecretRevealFailed||t[63]!==n.brokerSecretSave||t[64]!==n.brokerSecretSaveAndContinue||t[65]!==n.brokerSecretTitle?(W=S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:h,children:n.brokerSecretTitle}),(0,$.jsx)(Ke,{id:h,value:o,labels:w,reveal:nl,loadFailedLabel:u||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>{y({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:c,onClick:p,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:h,children:n.brokerSecretTitle}),(0,$.jsx)(Ke,{id:h,value:s,onChange:d,placeholder:n.brokerSecretPlaceholder,labels:w,disabled:c}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(X,{type:`button`,disabled:c||!E,onClick:f,children:[c?(0,$.jsx)(J,{className:`size-4 animate-spin`}):null,g?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),a||r?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:c,onClick:p,children:n.brokerSecretClear}):null,b?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:c,onClick:O,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=a,t[41]=s,t[42]=r,t[43]=o,t[44]=E,t[45]=O,t[46]=u,t[47]=h,t[48]=g,t[49]=p,t[50]=d,t[51]=f,t[52]=b,t[53]=c,t[54]=w,t[55]=S,t[56]=n.brokerSecretCancelReconfigure,t[57]=n.brokerSecretClear,t[58]=n.brokerSecretMaskedHelp,t[59]=n.brokerSecretNotInConfigFile,t[60]=n.brokerSecretPlaceholder,t[61]=n.brokerSecretReconfigure,t[62]=n.brokerSecretRevealFailed,t[63]=n.brokerSecretSave,t[64]=n.brokerSecretSaveAndContinue,t[65]=n.brokerSecretTitle,t[66]=W):W=t[66];let G;t[67]===l?G=t[68]:(G=l?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:l}):null,t[67]=l,t[68]=G);let K;t[69]!==B||t[70]!==H||t[71]!==U||t[72]!==W||t[73]!==G?(K=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[B,H,U,W,G]}),t[69]=B,t[70]=H,t[71]=U,t[72]=W,t[73]=G,t[74]=K):K=t[74];let q;t[75]!==P||t[76]!==K?(q=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[P,K]}),t[75]=P,t[76]=K,t[77]=q):q=t[77];let te;t[78]!==q||t[79]!==A?(te=(0,$.jsx)(Tn,{className:A,children:q}),t[78]=q,t[79]=A,t[80]=te):te=t[80];let ne;return t[81]!==m||t[82]!==te?(ne=(0,$.jsx)(`div`,{ref:m,id:`tunnel-broker-secret-setup`,children:te}),t[81]=m,t[82]=te,t[83]=ne):ne=t[83],ne}function nl(){return kt().then(rl)}function rl(e){return e.registrationSecret??null}function il(e){let t=(0,Q.c)(10),{language:n,label:r,section:i,className:a}=e,o;t[0]!==n||t[1]!==i?(o=oe(n,i),t[0]=n,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=Y(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a),t[3]=a,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Dt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=c):c=t[5];let l;return t[6]!==r||t[7]!==o||t[8]!==s?(l=(0,$.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:s,children:[r,c]}),t[6]=r,t[7]=o,t[8]=s,t[9]=l):l=t[9],l}var al=e(Jn(),1),ol={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function sl(e){return al.toDataURL(e,ol)}function cl(e){let t=e?.candidates??[],n=t.find(e=>e.kind===`lan`&&e.reachable),r=t.find(e=>e.kind===`lan`);return(n??r)?.url?.trim()??``}function ll(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function ul(e,t){return e?t?cl(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function dl(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=u(),a=(0,Z.useRef)(!1),{data:s}=d(r?`tunnel-status`:null,nt,{refreshInterval:6e4}),{data:l,mutate:f}=d(r?`tunnel-pair-context`:null,Et,{refreshInterval:6e4});(0,Z.useEffect)(()=>{let e=()=>{i(`tunnel-status`),i(`tunnel-qr`),i(`tunnel-pair`),i(`tunnel-pair-context`)};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[i]);let p=s?.state===`connected`&&!!s.publicUrl?.trim(),m=p&&!n,{data:h,mutate:g}=d(m&&r?`tunnel-qr`:null,Yt,{refreshInterval:4*6e4}),{data:_,mutate:v}=d(!m&&r&&l?.pairingReady?`tunnel-pair`:null,Gt,{refreshInterval:4*6e4}),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(l!==C.pairContext||n!==C.preferLan)){w({pairContext:l,preferLan:n});let e=ul(l,n);y!==e&&b(e)}let T=(0,Z.useCallback)(e=>{a.current=!0,b(e)},[]),E=(0,Z.useCallback)(()=>{let e=ul(l,n);e&&(a.current=!0,b(e))},[l,n]),D=(0,Z.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,b(t))},[]),O=(0,Z.useCallback)(e=>{a.current=!1,b(e?.trim()||ul(l,n))},[l,n]),k=y.trim(),A=(0,Z.useMemo)(()=>{try{let e=new URL(k);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[k]),j=A&&c(k),M=!m&&!!(l&&!l.pairingReady&&l.blockReason===`GATEWAY_LOOPBACK_ONLY`),N=!m&&A&&!j&&!!_?.pairingSecret&&(l?.pairingReady===!0||!M),P=(0,Z.useMemo)(()=>{let e=cl(l);return n?e||(k&&!ll(l,k)?k:``):k},[l,n,k]),F=(0,Z.useMemo)(()=>{if(!e)return``;if(x.trim())return x.trim();if(m&&h?.qrPayload?.trim())return h.qrPayload.trim();if(!N||!_?.pairingSecret)return``;let t=l?.candidates.find(e=>e.kind===`tunnel`&&e.reachable),r=l?.candidates.find(e=>e.kind===`lan`&&e.reachable),i=n?P:t?.url??k;return i?o({baseUrl:i,pairingSecret:_.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,P,_?.pairingSecret,N,x,n,k,m,h?.qrPayload,l?.candidates]),I=ke(()=>sl(F),[F],{enabled:!!F,initial:null,errorData:null}),L=F?I.data:null,R=!!(F&&I.error!==null&&!I.loading);return{tunnelActive:p,tunnelStatus:s,tunnelQr:h,pairContext:l,pairBaseUrl:y,setPairBaseUrl:T,applySuggestedPairUrl:E,applyCandidateUrl:D,baseOk:A,localhostWarn:j,pairingBlocked:M,deepLink:F,qrPayload:F,qrDataUrl:L,qrGenFailed:R,encoding:!!(F&&!L&&!R),refreshQr:(0,Z.useCallback)(async e=>{if(e?.trim()){S(e.trim()),g({qrPayload:e.trim(),publicUrl:s?.publicUrl??``,lanUrl:h?.lanUrl??null},!1);return}S(``),await f(),m?await g():l?.pairingReady&&await v()},[v,f,g,l?.pairingReady,h?.lanUrl,s?.publicUrl,m]),resetPairBaseFromContext:O}}var fl={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function pl({embedded:e=!1}){let t=a(e=>e.language),n=s(t).tunnelSettings,r=g(e=>e.token),i=!!r,[o,c]=(0,Z.useReducer)(de,fl),{actionError:l,starting:u,stopping:f,savingAutoStart:p,consentOpen:m,autoStartConfirmOpen:h,releaseConfirmOpen:_,releasing:v,brokerSecretDraft:y,savingBrokerSecret:b,brokerSecretNotice:S}=o,C=(0,Z.useRef)(null),w=dl(r??``),{data:T}=rt(i),{data:E,error:D,isLoading:O,mutate:k}=d(i?`tunnel-status`:null,nt,{refreshInterval:e=>u?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),A=(0,Z.useMemo)(()=>{let e=T?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return E?.config?.autoStart===!0},[T,E?.config?.autoStart]),j=(0,Z.useMemo)(()=>{let e=T?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[T]),M=Me(j),N=E?.registrationSecret?.source===`env`,P=E?.registrationSecret?.source===`missing`,F=E?.registrationSecret?.configured===!0;(0,Z.useEffect)(()=>{let e=()=>{k()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[k]);let I=(0,Z.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),L=(0,Z.useCallback)(async()=>{c({type:`patch`,patch:{actionError:null}}),c({type:`patch`,patch:{starting:!0}});try{let e=await ft();await k(),Xt(),await w.refreshQr(e.qrPayload)}catch(e){c({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{starting:!1}})}},[k,w.refreshQr]),R=(0,Z.useCallback)(()=>{if(!F){c({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),C.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(E?.consentRequired){c({type:`patch`,patch:{consentOpen:!0}});return}L()},[F,E?.consentRequired,L,n.brokerSecretRequiredBeforeStart]),z=(0,Z.useCallback)(async()=>{c({type:`patch`,patch:{consentOpen:!1}}),c({type:`patch`,patch:{actionError:null}});try{await Lt(),await Promise.all([k(),L()])}catch(e){c({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[k,L]),B=(0,Z.useCallback)(async()=>{c({type:`patch`,patch:{actionError:null}}),c({type:`patch`,patch:{stopping:!0}});try{await ut(),await Promise.all([w.refreshQr(),k()]),Xt()}catch(e){c({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{stopping:!1}})}},[k,w.refreshQr]),V=(0,Z.useCallback)(async e=>{c({type:`patch`,patch:{savingAutoStart:!0}}),c({type:`patch`,patch:{actionError:null}});try{await st({autoStart:e}),Xt()}catch(e){c({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{savingAutoStart:!1}})}},[]),H=(0,Z.useCallback)(()=>{if(A){V(!1);return}if(E?.consentRequired){c({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!E?.canAutoStart){c({type:`patch`,patch:{actionError:n.autoStartHint}});return}c({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[V,E?.canAutoStart,E?.consentRequired,n,A]),U=(0,Z.useCallback)(async()=>{let e=y.trim();if(e){c({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await st({registrationSecret:e}),c({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),Xt(),await k(),c({type:`patch`,patch:{actionError:null}})}catch(e){c({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[y,k,n.brokerSecretSaved]),W=(0,Z.useCallback)(async()=>{c({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await st({registrationSecret:null}),c({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),Xt(),await k()}catch(e){c({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{savingBrokerSecret:!1}})}},[k,n.brokerSecretCleared]),G=(0,Z.useCallback)(async()=>{c({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await ut({release:!0}),await Promise.all([w.refreshQr(),k()]),Xt()}catch(e){c({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{releasing:!1}})}},[k,w.refreshQr]),ee=(0,Z.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:s(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!i)return(0,$.jsx)(`div`,{className:e?void 0:`mx-auto w-full max-w-app-main px-4 py-8`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let K=E??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:A,brokerUrl:`https://frp.xopc.ai/api`}},q=E?.consentRequired&&(K.enabled||A||E?.consent?.acceptedAt),te=(0,$.jsx)(tl,{t:n,brokerSecretFromEnv:N,brokerSecretMissing:P,brokerSecretConfiguredInConfig:M,brokerSecretMaskedValue:M?j:``,brokerSecretDraft:y,savingBrokerSecret:b,brokerSecretNotice:S,copyFailedLabel:s(t).clipboard.copyFailed,onDraftChange:e=>c({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void U(),onClear:()=>void W(),sectionRef:C}),ne=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ic,{open:m,title:n.consentTitle,intro:n.consentIntro,bullets:I,checkboxLabel:n.consentCheckbox,confirmLabel:q?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void z(),onCancel:()=>c({type:`patch`,patch:{consentOpen:!1}})},m?`consent-open`:`consent-closed`),(0,$.jsx)(rn,{open:h,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{c({type:`patch`,patch:{autoStartConfirmOpen:!1}}),V(!0)},onCancel:()=>c({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(rn,{open:_,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void G(),onCancel:()=>c({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[l?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:l}):null,te,(0,$.jsx)(Qc,{t:n,status:K,isLoading:O,statusErr:D,starting:u,stopping:f,showConsentExpired:!!q,copyLabels:ee,startDisabled:!F,startDisabledReason:F?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:R,onStop:()=>void B()}),(0,$.jsx)(Mc,{pairQr:w,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void w.refreshQr()}),(0,$.jsxs)(Or,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:Y(`flex items-center gap-3 text-sm text-fg`,!A&&!E?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:A,disabled:p||!A&&!E?.canAutoStart,onChange:H}),n.autoStart]}),!E?.canAutoStart&&!A?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,K.subdomain||K.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:v||f,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>c({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[v?(0,$.jsx)(J,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(Or,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(x,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(il,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),ne]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),l?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:l}):null,te,(0,$.jsx)(Qc,{t:n,status:K,isLoading:O,statusErr:D,starting:u,stopping:f,showConsentExpired:!!q,copyLabels:ee,startDisabled:!F,startDisabledReason:F?void 0:n.brokerSecretRequiredBeforeStart,onStart:R,onStop:()=>void B()}),(0,$.jsx)(Mc,{pairQr:w,gatewayToken:r??``}),K.subdomain||K.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:v||f,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>c({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[v?(0,$.jsx)(J,{className:`size-4 animate-spin`}):null,n.release]})}):null,K.subdomain||K.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(Tn,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:Y(`flex items-center gap-3 text-sm text-fg`,!A&&!E?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:A,disabled:p||!A&&!E?.canAutoStart,onChange:H}),n.autoStart]}),!E?.canAutoStart&&!A?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(x,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(il,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),ne]})}async function ml(){let e=await v(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function hl(e=`serve`){let t=await v(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function gl(){let e=await v(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var _l=`https://tailscale.com/download`;function vl(e){let t=(0,Q.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:_l,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function yl({embedded:e=!1}){let t=a(e=>e.language),n=s(t).remoteAccess.tailscale,r=(0,Z.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:s(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!g(e=>e.token),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),{data:f,mutate:p,isLoading:m}=d(i?`exposure-status`:null,ml,{refreshInterval:3e4}),h=f?.tailscale.hostname,_=f?.tailscale.active===!0,v=f?.tailscale.cliAvailable!==!1,y=h?`https://${h}/`:null,b=(0,Z.useCallback)(async()=>{c(!0),u(null);try{await hl(`serve`),await p()}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}},[p]),S=(0,Z.useCallback)(async()=>{c(!0),u(null);try{await gl(),await p()}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}},[p]);if(!i)return null;let C=(0,$.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,$.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,$.jsxs)(`span`,{children:[n.stepInstallBefore,(0,$.jsx)(vl,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,$.jsx)(`span`,{children:n.stepEnable})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,$.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&f?.tailscale.cliAvailable===!1?(0,$.jsxs)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,$.jsx)(vl,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,m&&!f?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Tn,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_?n.statusActive:n.statusOff}),y?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(ce,{text:y,labels:r})}):null,l?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:l}):null,(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_?(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void S(),children:[o?(0,$.jsx)(J,{className:`mr-1 h-4 w-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(X,{type:`button`,disabled:o||!v,onClick:()=>void b(),children:[o?(0,$.jsx)(J,{className:`mr-1 h-4 w-4 animate-spin`}):(0,$.jsx)(Mt,{className:`mr-1 h-4 w-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)(il,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?C:(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Cn,{icon:x,title:n.title,subtitle:n.subtitle}),C]})}function bl(){let e=(0,Q.c)(26),t=a(Sl),n=g(xl),r;e[0]===t?r=e[1]:(r=s(t),e[0]=t,e[1]=r);let i=r.remoteAccess.lan,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o={preferLan:!0},e[2]=o):o=e[2];let c=dl(n??``,o),l;e[3]!==i.subtitle||e[4]!==i.title?(l=(0,$.jsx)(Cn,{icon:zt,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=l):l=e[5];let u;e[6]===i.body?u=e[7]:(u=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.body}),e[6]=i.body,e[7]=u);let d;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(Dt,{className:`size-3.5`,"aria-hidden":!0}),e[8]=d):d=e[8];let f;e[9]===i.link?f=e[10]:(f=(0,$.jsxs)(ne,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[i.link,d]}),e[9]=i.link,e[10]=f);let p;e[11]!==u||e[12]!==f?(p=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[u,f]}),e[11]=u,e[12]=f,e[13]=p):p=e[13];let m;e[14]!==l||e[15]!==p?(m=(0,$.jsxs)(Tn,{children:[l,p]}),e[14]=l,e[15]=p,e[16]=m):m=e[16];let h=n??``,_;e[17]===c?_=e[18]:(_=()=>void c.refreshQr(),e[17]=c,e[18]=_);let v;e[19]!==c||e[20]!==h||e[21]!==_?(v=(0,$.jsx)(Mc,{pairQr:c,gatewayToken:h,lanOnly:!0,onRefreshQr:_}),e[19]=c,e[20]=h,e[21]=_,e[22]=v):v=e[22];let y;return e[23]!==v||e[24]!==m?(y=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[m,v]}),e[23]=v,e[24]=m,e[25]=y):y=e[25],y}function xl(e){return e.token}function Sl(e){return e.language}function Cl(e){let t=(0,Q.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=a(wl),o;t[0]===i?o=t[1]:(o=s(i),t[0]=i,t[1]=o);let c=o.remoteAccess.ssh,[l,u]=(0,Z.useState)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=async()=>{await Se(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(u(!0),setTimeout(()=>u(!1),2e3))},t[2]=d):d=t[2];let f=d,p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=p):p=t[3];let h,g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>void f(),g=(0,$.jsx)(m,{className:`mr-1 h-4 w-4`}),t[4]=h,t[5]=g):(h=t[4],g=t[5]);let _=l?c.copied:c.copy,v;t[6]===_?v=t[7]:(v=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(X,{type:`button`,variant:`ghost`,onClick:h,children:[g,_]})}),t[6]=_,t[7]=v);let y;t[8]!==r||t[9]!==c.hint?(y=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:c.hint}):null,t[8]=r,t[9]=c.hint,t[10]=y):y=t[10];let b;t[11]!==v||t[12]!==y?(b=(0,$.jsxs)($.Fragment,{children:[p,v,y]}),t[11]=v,t[12]=y,t[13]=b):b=t[13];let x=b;if(r){let e;t[14]!==c.subtitle||t[15]!==c.title?(e=(0,$.jsx)(Cn,{icon:he,title:c.title,subtitle:c.subtitle}),t[14]=c.subtitle,t[15]=c.title,t[16]=e):e=t[16];let n;t[17]===x?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:x}),t[17]=x,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(Tn,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let S;t[22]!==c.subtitle||t[23]!==c.title?(S=(0,$.jsx)(Cn,{icon:he,title:c.title,subtitle:c.subtitle}),t[22]=c.subtitle,t[23]=c.title,t[24]=S):S=t[24];let C;t[25]===x?C=t[26]:(C=(0,$.jsx)(`div`,{className:`mt-4`,children:x}),t[25]=x,t[26]=C);let w;return t[27]!==S||t[28]!==C?(w=(0,$.jsxs)(Tn,{children:[S,C]}),t[27]=S,t[28]=C,t[29]=w):w=t[29],w}function wl(e){return e.language}function Tl(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Cl,{embedded:!0}),e[0]=t):t=e[0],t}function El(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function Dl(e){let t=(0,Q.c)(5),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=Y(`rounded-full px-2 py-0.5 text-[11px] font-medium`,El(r)),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`span`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Ol(e){let t=(0,Q.c)(32),{onOpenTab:n}=e,r=a(jl),i;t[0]===r?i=t[1]:(i=s(r),t[0]=r,t[1]=i);let o=i.remoteAccess.guide,c=!!g(Al),l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:3e4},t[2]=l):l=t[2];let{data:u}=d(c?`exposure-status`:null,ml,l),f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f={refreshInterval:15e3},t[3]=f):f=t[3];let{data:p}=d(c?`tunnel-status`:null,nt,f),m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m={refreshInterval:6e4},t[4]=m):m=t[4];let{data:h}=d(c?`tunnel-pair-context`:null,Et,m);if(!c)return null;let _=u?.tailscale.active===!0,v=p?.state,y=p?.enabled&&v===`connected`,b=p?.enabled&&(v===`connecting`||v===`reconnecting`||!!p?.startProgress||!!p?.frpcDownload),S=(h?.candidates??[]).some(kl),C=_?`active`:`off`,w=_?o.statusActive:o.statusOff,T;t[5]!==o.tailscaleCardTitle||t[6]!==C||t[7]!==w?(T={tab:`tailscale`,icon:x,title:o.tailscaleCardTitle,kind:C,statusLabel:w},t[5]=o.tailscaleCardTitle,t[6]=C,t[7]=w,t[8]=T):T=t[8];let E=y?`active`:b?`connecting`:`off`,D=y?o.statusActive:b?o.statusConnecting:o.statusOff,O;t[9]!==o.publicCardTitle||t[10]!==E||t[11]!==D?(O={tab:`public`,icon:Zt,title:o.publicCardTitle,kind:E,statusLabel:D},t[9]=o.publicCardTitle,t[10]=E,t[11]=D,t[12]=O):O=t[12];let k=S?`active`:`off`,A=S?o.statusActive:o.statusOff,j;t[13]!==o.reverseProxyCardTitle||t[14]!==k||t[15]!==A?(j={tab:`reverse-proxy`,icon:K,title:o.reverseProxyCardTitle,kind:k,statusLabel:A},t[13]=o.reverseProxyCardTitle,t[14]=k,t[15]=A,t[16]=j):j=t[16];let M;t[17]!==o.sshCardStatus||t[18]!==o.sshCardTitle?(M={tab:`ssh`,icon:he,title:o.sshCardTitle,kind:`off`,statusLabel:o.sshCardStatus},t[17]=o.sshCardStatus,t[18]=o.sshCardTitle,t[19]=M):M=t[19];let N;t[20]!==o.lanCardStatus||t[21]!==o.lanCardTitle?(N={tab:`lan`,icon:zt,title:o.lanCardTitle,kind:`off`,statusLabel:o.lanCardStatus},t[20]=o.lanCardStatus,t[21]=o.lanCardTitle,t[22]=N):N=t[22];let P;t[23]!==O||t[24]!==j||t[25]!==M||t[26]!==N||t[27]!==T?(P=[T,O,j,M,N],t[23]=O,t[24]=j,t[25]=M,t[26]=N,t[27]=T,t[28]=P):P=t[28];let F=P,I;return t[29]!==F||t[30]!==n?(I=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:F.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:Y(`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-base px-3 py-2.5 text-left transition-colors`,`hover:border-edge hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(Dl,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=F,t[30]=n,t[31]=I):I=t[31],I}function kl(e){return e.kind===`reverse-proxy`}function Al(e){return e.token}function jl(e){return e.language}function Ml(e){let t=(0,Q.c)(26),{title:n,description:r,recommended:i,icon:a,onOpen:o,openLabel:s,recommendedLabel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=Y(`group flex w-full flex-col rounded-2xl bg-surface-base px-4 py-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=l):l=t[0];let u;t[1]===a?u=t[2]:(u=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=u);let d;t[3]===n?d=t[4]:(d=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=d);let f;t[5]!==i||t[6]!==c?(f=i&&c?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:c}):null,t[5]=i,t[6]=c,t[7]=f):f=t[7];let p;t[8]!==d||t[9]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10];let m;t[11]===r?m=t[12]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=m);let h;t[13]!==p||t[14]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[p,m]}),t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(D,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=g):g=t[16];let _;t[17]!==u||t[18]!==h?(_=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[u,h,g]}),t[17]=u,t[18]=h,t[19]=_):_=t[19];let v;t[20]===s?v=t[21]:(v=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:s}),t[20]=s,t[21]=v);let y;return t[22]!==o||t[23]!==v||t[24]!==_?(y=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:l,children:[_,v]}),t[22]=o,t[23]=v,t[24]=_,t[25]=y):y=t[25],y}function Nl(e){let t=(0,Q.c)(83),{onOpenTab:n}=e,r=a(Il),i;t[0]===r?i=t[1]:(i=s(r),t[0]=r,t[1]=i);let o=i.remoteAccess,c=o.guide,l=!!g(Fl),u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u={refreshInterval:3e4},t[2]=u):u=t[2];let{data:f}=d(l?`exposure-status`:null,ml,u),p;t[3]===f?.conflicts?p=t[4]:(p=f?.conflicts??[],t[3]=f?.conflicts,t[4]=p);let m=p;if(!l){let e;return t[5]===c.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.needToken}),t[5]=c.needToken,t[6]=e),e}let h;t[7]===n?h=t[8]:(h=(0,$.jsx)(Ol,{onOpenTab:n}),t[7]=n,t[8]=h);let _;t[9]!==m||t[10]!==c.conflictsHint||t[11]!==c.conflictsTitle?(_=m.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:c.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:c.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:m.map(Pl)})]}):null,t[9]=m,t[10]=c.conflictsHint,t[11]=c.conflictsTitle,t[12]=_):_=t[12];let v;t[13]===c.pickMethod?v=t[14]:(v=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c.pickMethod}),t[13]=c.pickMethod,t[14]=v);let y;t[15]===n?y=t[16]:(y=()=>n(`tailscale`),t[15]=n,t[16]=y);let b;t[17]!==c.configure||t[18]!==c.recommended||t[19]!==c.tailscaleCardDesc||t[20]!==c.tailscaleCardTitle||t[21]!==y?(b=(0,$.jsx)(Ml,{icon:x,title:c.tailscaleCardTitle,description:c.tailscaleCardDesc,recommended:!0,recommendedLabel:c.recommended,openLabel:c.configure,onOpen:y}),t[17]=c.configure,t[18]=c.recommended,t[19]=c.tailscaleCardDesc,t[20]=c.tailscaleCardTitle,t[21]=y,t[22]=b):b=t[22];let S;t[23]===n?S=t[24]:(S=()=>n(`public`),t[23]=n,t[24]=S);let C;t[25]!==c.configure||t[26]!==c.publicCardDesc||t[27]!==c.publicCardTitle||t[28]!==S?(C=(0,$.jsx)(Ml,{icon:Zt,title:c.publicCardTitle,description:c.publicCardDesc,openLabel:c.configure,onOpen:S}),t[25]=c.configure,t[26]=c.publicCardDesc,t[27]=c.publicCardTitle,t[28]=S,t[29]=C):C=t[29];let w;t[30]===n?w=t[31]:(w=()=>n(`reverse-proxy`),t[30]=n,t[31]=w);let T;t[32]!==c.configure||t[33]!==c.reverseProxyCardDesc||t[34]!==c.reverseProxyCardTitle||t[35]!==w?(T=(0,$.jsx)(Ml,{icon:K,title:c.reverseProxyCardTitle,description:c.reverseProxyCardDesc,openLabel:c.configure,onOpen:w}),t[32]=c.configure,t[33]=c.reverseProxyCardDesc,t[34]=c.reverseProxyCardTitle,t[35]=w,t[36]=T):T=t[36];let E;t[37]===n?E=t[38]:(E=()=>n(`ssh`),t[37]=n,t[38]=E);let D;t[39]!==c.configure||t[40]!==c.sshCardDesc||t[41]!==c.sshCardTitle||t[42]!==E?(D=(0,$.jsx)(Ml,{icon:he,title:c.sshCardTitle,description:c.sshCardDesc,openLabel:c.configure,onOpen:E}),t[39]=c.configure,t[40]=c.sshCardDesc,t[41]=c.sshCardTitle,t[42]=E,t[43]=D):D=t[43];let O;t[44]===n?O=t[45]:(O=()=>n(`lan`),t[44]=n,t[45]=O);let k;t[46]!==c.configure||t[47]!==c.lanCardDesc||t[48]!==c.lanCardTitle||t[49]!==O?(k=(0,$.jsx)(Ml,{icon:zt,title:c.lanCardTitle,description:c.lanCardDesc,openLabel:c.configure,onOpen:O}),t[46]=c.configure,t[47]=c.lanCardDesc,t[48]=c.lanCardTitle,t[49]=O,t[50]=k):k=t[50];let A;t[51]!==C||t[52]!==T||t[53]!==D||t[54]!==k||t[55]!==b?(A=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[b,C,T,D,k]}),t[51]=C,t[52]=T,t[53]=D,t[54]=k,t[55]=b,t[56]=A):A=t[56];let j;t[57]!==A||t[58]!==v?(j=(0,$.jsxs)(`div`,{children:[v,A]}),t[57]=A,t[58]=v,t[59]=j):j=t[59];let M;t[60]===c.oneAtATimeHint?M=t[61]:(M=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:c.oneAtATimeHint}),t[60]=c.oneAtATimeHint,t[61]=M);let N;t[62]===o.advanced.proxyTitle?N=t[63]:(N=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.advanced.proxyTitle}),t[62]=o.advanced.proxyTitle,t[63]=N);let P;t[64]===o.advanced.proxyBody?P=t[65]:(P=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o.advanced.proxyBody}),t[64]=o.advanced.proxyBody,t[65]=P);let F;t[66]!==r||t[67]!==o.advanced.proxyDocs?(F=(0,$.jsx)(il,{language:r,label:o.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=o.advanced.proxyDocs,t[68]=F):F=t[68];let I;t[69]!==N||t[70]!==P||t[71]!==F?(I=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-4 py-3`,children:[N,P,F]}),t[69]=N,t[70]=P,t[71]=F,t[72]=I):I=t[72];let L;t[73]!==c.docsLink||t[74]!==r?(L=(0,$.jsx)(il,{language:r,label:c.docsLink}),t[73]=c.docsLink,t[74]=r,t[75]=L):L=t[75];let R;return t[76]!==j||t[77]!==M||t[78]!==I||t[79]!==L||t[80]!==h||t[81]!==_?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[h,_,j,M,I,L]}),t[76]=j,t[77]=M,t[78]=I,t[79]=L,t[80]=h,t[81]=_,t[82]=R):R=t[82],R}function Pl(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Fl(e){return e.token}function Il(e){return e.language}async function Ll(e){let t=await v(l(`/api/tunnel/pair/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function Rl(e){await _(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function zl(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function Bl(){return(0,Z.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||zl(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function Vl(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt,`dark:border-edge`)}function Hl(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Ul(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function Wl(){let e=a(e=>e.language),t=s(e).remoteAccess.reverseProxy,n=!!g(e=>e.token),r=Bl(),{mutate:i}=u(),{data:c,mutate:l}=d(n?`tunnel-pair-context`:null,Et,{refreshInterval:6e4}),f=Hl(c),[p,m]=(0,Z.useState)(``),[h,_]=(0,Z.useState)({busy:!1,result:null}),[v,y]=(0,Z.useState)({busy:!1,error:null});(0,Z.useEffect)(()=>{p||(f?m(f):r&&m(r))},[f,r,p]);let b=(0,Z.useMemo)(()=>p.trim()||(f??r??``),[f,r,p]),S=!f&&!!r&&b===r,C=Ul(c),{data:w,mutate:T}=d(n&&b?[`reverse-proxy-pair`,b]:null,()=>Gt(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),E=(0,Z.useMemo)(()=>!b||!w?.pairingSecret?``:o({baseUrl:b,pairingSecret:w.pairingSecret,lanUrl:C}),[b,C,w?.pairingSecret]),D=ke(()=>sl(E),[E],{enabled:!!E,initial:null,errorData:null}),O=(0,Z.useCallback)(async()=>{let e=p.trim()||b;if(e){_({busy:!0,result:null});try{_({busy:!1,result:await Ll(e)})}catch(e){_({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[p,b]),k=(0,Z.useCallback)(async()=>{let e=b.trim();if(e){y({busy:!0,error:null});try{await Rl(e),await l(),await i(`tunnel-pair-context`),y({busy:!1,error:null})}catch(e){y({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[b,i,l]),A=(0,Z.useCallback)(async()=>{y({busy:!0,error:null});try{await Rl(null),await l(),await i(`tunnel-pair-context`),m(``),_({busy:!1,result:null}),y({busy:!1,error:null})}catch(e){y({busy:!1,error:e instanceof Error?e.message:String(e)})}},[i,l]),j=(0,Z.useCallback)(async()=>{await T()},[T]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Cn,{icon:x,title:t.title,subtitle:t.subtitle}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:t.urlLabel}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[(0,$.jsx)(`input`,{id:`reverse-proxy-url`,className:Y(Vl(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:p,onChange:e=>{m(e.target.value),_({busy:!1,result:null})}}),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void O(),disabled:h.busy||!p.trim(),children:[h.busy?(0,$.jsx)(J,{className:`size-3.5 animate-spin`}):null,h.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),S&&r?(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent-soft/50 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:t.autoDetectedTitle}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:r}),(0,$.jsx)(`p`,{className:`mt-1`,children:t.autoDetectedHint})]}):null,h.result?(0,$.jsx)(Gl,{result:h.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[b&&f!==b?(0,$.jsxs)(X,{type:`button`,onClick:()=>void k(),disabled:v.busy,children:[v.busy?(0,$.jsx)(J,{className:`size-3.5 animate-spin`}):null,v.busy?t.saving:t.saveAsDefault]}):null,f?(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>void A(),disabled:v.busy,children:t.clear}):null]}),v.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:v.error}):null,(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100`,children:t.certWarning})]})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:t.qrTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.qrSubtitle})]}),E?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void j(),children:[(0,$.jsx)(At,{className:`size-4`}),t.refreshQr]}):null]}),b?w?.pairingSecret?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[(0,$.jsxs)(`div`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`baseUrl:`}),` `,b,C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,C]}):null]}),D.data?(0,$.jsx)(`img`,{src:D.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):D.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(ce,{text:E,labels:{copy:t.copyLink,copied:t.copied,copyFailed:s(e).clipboard.copyFailed}})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.mintingSecret}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUrlYet})]})]}):null}function Gl(e){let t=(0,Q.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,$.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,$.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.mobileReady||t[5]!==n.mobilePairing?(a=n.mobilePairing?(0,$.jsxs)($.Fragment,{children:[` · `,(0,$.jsx)(`span`,{children:r.mobileReady})]}):null,t[4]=r.mobileReady,t[5]=n.mobilePairing,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,$.jsxs)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,$.jsxs)($.Fragment,{children:[` — `,(0,$.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-900 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}var Kl=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function ql(e){return e&&Kl.includes(e)?e:`guide`}function Jl(e,t){return e.tabs[t]}function Yl(e,t){return e.tabIntro[t]}function Xl(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function Zl(e){let t=(0,Q.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Nl,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(yl,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pl,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Wl,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Tl,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(bl,{}),t[6]=e):e=t[6],e}}}function Ql(){let e=(0,Q.c)(2),t=a(eu),n=s(t).remoteAccess,r=!!g($l),[i,o]=C(),c=ql(i.get(`tab`)),l;e[0]===o?l=e[1]:(l=e=>{o(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=o,e[1]=l);let u=l,d=Yl(n,c);return(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-5 px-4 py-8`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.pageTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.pageSubtitle}),(0,$.jsx)(il,{language:t,label:n.docsLink,section:Xl(c),className:`mt-1`})]}),r?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,role:`tablist`,"aria-label":n.tabsAria,onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=Kl[(Kl.indexOf(c)+(e.key===`ArrowRight`?1:-1)+Kl.length)%Kl.length];u(t)},children:[(0,$.jsx)(`div`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,children:Kl.map(e=>{let t=e===c;return(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,id:`remote-access-tab-${e}`,"aria-controls":`remote-access-panel-${e}`,className:Y(`shrink-0 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,t?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>u(e),children:Jl(n,e)},e)})}),c===`public`?null:(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:d}),(0,$.jsx)(`div`,{role:`tabpanel`,id:`remote-access-panel-${c}`,"aria-labelledby":`remote-access-tab-${c}`,className:`min-w-0`,children:(0,$.jsx)(Zl,{tab:c,onOpenTab:u})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function $l(e){return e.token}function eu(e){return e.language}var tu={enabled:!0,defaultTtlHours:24,maxTtlDays:7,maxActiveShares:100,maxFileSizeMb:100,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`]},nu=36e5,ru=864e5,iu=1048576;function au(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ou(e,t=32){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function su(e){let t=au(e)?e:{},n=au(t.gateway)?t.gateway:{},r=au(n.share)?n.share:{},i=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):tu.defaultTtlHours*nu,a=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):tu.maxTtlDays*ru,o=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):tu.maxFileSizeMb*iu;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(i/nu)),maxTtlDays:Math.max(1,Math.round(a/ru)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):tu.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(o/iu)),inlinePreviewMimes:ou(r.inlinePreviewMimes,32).length?ou(r.inlinePreviewMimes,32):[...tu.inlinePreviewMimes]}}function cu(e){let t=e.defaultTtlHours*nu,n=e.maxTtlDays*ru;return t<6e4||t>6048e5?`Default share TTL must be between 1 minute and 7 days.`:n<6e4||n>2592e6?`Maximum share TTL must be between 1 minute and 30 days.`:t>n?`Default TTL cannot exceed maximum TTL.`:e.maxFileSizeMb<1||e.maxFileSizeMb>10240?`Maximum file size must be between 1 MB and 10 GB.`:null}async function lu(e){let t=cu(e);if(t)throw Error(t);await _(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*nu,maxTtlMs:e.maxTtlDays*ru,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*iu,inlinePreviewMimes:e.inlinePreviewMimes}}})}),Xt()}function uu(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt,`dark:border-edge`)}function du({hasToken:e}){let t=s(a(e=>e.language)).sharesSettings,{data:n,isLoading:r}=rt(e),i=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(su(n.payload.config)),[n]),o=(0,Z.useRef)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),g=c??i,_=i,v=(0,Z.useMemo)(()=>!g||!_?!1:JSON.stringify(g)!==JSON.stringify(_),[g,_]),y=(0,Z.useCallback)(e=>{o.current=!0,l(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),b=(0,Z.useCallback)(async()=>{if(!(!g||u)){d(!0),p(null),h(!1);try{await lu(g),o.current=!1,l(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){p(e instanceof Error?e.message:t.policySaveError)}finally{d(!1)}}},[g,u,t.policySaveError]),x=(0,Z.useCallback)(()=>{o.current=!1,l(null),p(null),h(!1)},[]);return!e||!g?r?(0,$.jsx)(Tn,{children:(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(J,{className:`size-4 animate-spin`}),t.policyLoading]})}):null:(0,$.jsxs)(Tn,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[m?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:!v||u,onClick:x,children:t.policyDiscard}),(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!v||u,onClick:()=>void b(),children:u?t.policySaving:t.policySave})]})]}),v?(0,$.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,f?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:f}):null,(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,$.jsx)(fu,{t,form:g,onChange:y})]})}function fu(e){let t=(0,Q.c)(56),{t:n,form:r,onChange:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.policyEnabled||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.policyEnabled]}),t[5]=n.policyEnabled,t[6]=o,t[7]=s):s=t[7];let c=!r.enabled,l;t[8]===i?l=t[9]:(l=e=>i({defaultTtlHours:e}),t[8]=i,t[9]=l);let u;t[10]!==r.defaultTtlHours||t[11]!==n.policyDefaultTtlHint||t[12]!==n.policyDefaultTtlHours||t[13]!==c||t[14]!==l?(u=(0,$.jsx)(pu,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:c,onChange:l}),t[10]=r.defaultTtlHours,t[11]=n.policyDefaultTtlHint,t[12]=n.policyDefaultTtlHours,t[13]=c,t[14]=l,t[15]=u):u=t[15];let d=!r.enabled,f;t[16]===i?f=t[17]:(f=e=>i({maxTtlDays:e}),t[16]=i,t[17]=f);let p;t[18]!==r.maxTtlDays||t[19]!==n.policyMaxTtlDays||t[20]!==n.policyMaxTtlHint||t[21]!==d||t[22]!==f?(p=(0,$.jsx)(pu,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:d,onChange:f}),t[18]=r.maxTtlDays,t[19]=n.policyMaxTtlDays,t[20]=n.policyMaxTtlHint,t[21]=d,t[22]=f,t[23]=p):p=t[23];let m=!r.enabled,h;t[24]===i?h=t[25]:(h=e=>i({maxActiveShares:e}),t[24]=i,t[25]=h);let g;t[26]!==r.maxActiveShares||t[27]!==n.policyMaxActiveShares||t[28]!==n.policyMaxActiveSharesHint||t[29]!==m||t[30]!==h?(g=(0,$.jsx)(pu,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:m,onChange:h}),t[26]=r.maxActiveShares,t[27]=n.policyMaxActiveShares,t[28]=n.policyMaxActiveSharesHint,t[29]=m,t[30]=h,t[31]=g):g=t[31];let _=!r.enabled,v;t[32]===i?v=t[33]:(v=e=>i({maxFileSizeMb:e}),t[32]=i,t[33]=v);let y;t[34]!==r.maxFileSizeMb||t[35]!==n.policyMaxFileSizeHint||t[36]!==n.policyMaxFileSizeMb||t[37]!==_||t[38]!==v?(y=(0,$.jsx)(pu,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:_,onChange:v}),t[34]=r.maxFileSizeMb,t[35]=n.policyMaxFileSizeHint,t[36]=n.policyMaxFileSizeMb,t[37]=_,t[38]=v,t[39]=y):y=t[39];let b;t[40]!==g||t[41]!==y||t[42]!==u||t[43]!==p?(b=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[u,p,g,y]}),t[40]=g,t[41]=y,t[42]=u,t[43]=p,t[44]=b):b=t[44];let x=!r.enabled,S;t[45]===i?S=t[46]:(S=e=>i({inlinePreviewMimes:e}),t[45]=i,t[46]=S);let C;t[47]!==r.inlinePreviewMimes||t[48]!==n||t[49]!==x||t[50]!==S?(C=(0,$.jsx)(mu,{t:n,values:r.inlinePreviewMimes,disabled:x,onChange:S}),t[47]=r.inlinePreviewMimes,t[48]=n,t[49]=x,t[50]=S,t[51]=C):C=t[51];let w;return t[52]!==b||t[53]!==C||t[54]!==s?(w=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[s,b,C]}),t[52]=b,t[53]=C,t[54]=s,t[55]=w):w=t[55],w}function pu(e){let t=(0,Q.c)(21),{id:n,label:r,hint:i,value:a,min:o,max:s,disabled:c,onChange:l}=e,u;t[0]!==n||t[1]!==r?(u=(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=Y(uu(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let f;t[4]!==s||t[5]!==o||t[6]!==l?(f=e=>{let t=Number(e.target.value);Number.isFinite(t)&&l(Math.max(o,Math.min(s,Math.floor(t))))},t[4]=s,t[5]=o,t[6]=l,t[7]=f):f=t[7];let p;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==f||t[13]!==a?(p=(0,$.jsx)(`input`,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:f}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=f,t[13]=a,t[14]=p):p=t[14];let m;t[15]===i?m=t[16]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=m);let h;return t[17]!==u||t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`div`,{children:[u,p,m]}),t[17]=u,t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function mu(e){let t=(0,Q.c)(25),{t:n,values:r,disabled:i,onChange:a}=e,o;t[0]!==a||t[1]!==r?(o=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||a([...r,t])},t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===n.policyInlinePreviewMimes?c=t[4]:(c=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=c);let l;t[5]===n.policyInlinePreviewMimesHint?l=t[6]:(l=(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=l);let u;t[7]!==i||t[8]!==a||t[9]!==r?(u=r.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,i?null:(0,$.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>a(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=a,t[9]=r,t[10]=u):u=t[10];let d;t[11]===u?d=t[12]:(d=(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=d);let f;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(f=Y(uu(),`font-mono text-xs`),t[13]=f):f=t[13];let p=i||r.length>=32,m;t[14]===s?m=t[15]:(m=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=m);let h;t[16]!==n.policyMimePlaceholder||t[17]!==p||t[18]!==m?(h=(0,$.jsx)(`input`,{className:f,placeholder:n.policyMimePlaceholder,disabled:p,onKeyDown:m}),t[16]=n.policyMimePlaceholder,t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;return t[20]!==c||t[21]!==l||t[22]!==d||t[23]!==h?(g=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[c,l,d,h]}),t[20]=c,t[21]=l,t[22]=d,t[23]=h,t[24]=g):g=t[24],g}function hu(e){let t=(0,Q.c)(99),{open:n,onOpenChange:r,onConfirm:i,initialPath:o,selectKind:c,sessionKey:l,agentId:u}=e,f=c===void 0?`any`:c,p=a(vu),m;t[0]===p?m=t[1]:(m=s(p),t[0]=p,t[1]=m);let h=m,_=h.workspace,v=h.sharesSettings,y=De(_u),{data:b}=d(g(gu)?`picker-agents-list`:null,me),x;bb0:{let e;t[2]===u?e=t[3]:(e=u?.trim(),t[2]=u,t[3]=e);let n=e;if(n){x=n;break bb0}let r;t[4]===y?r=t[5]:(r=y.trim(),t[4]=y,t[5]=r);let i=r;if(i){x=i;break bb0}if(b?.defaultId){x=b.defaultId;break bb0}if(b?.agents?.[0]?.id){x=b.agents[0].id;break bb0}x=``}let S=x,[C,w]=(0,Z.useState)(S),T,E;t[6]===S?(T=t[7],E=t[8]):(T=()=>{w(S)},E=[S],t[6]=S,t[7]=T,t[8]=E),(0,Z.useEffect)(T,E);let{tree:D,loading:O,error:k,loadRoot:A,loadChildren:j,reset:M}=P(C,l??null),N;t[9]===o?N=t[10]:(N=o?{path:o,isDirectory:!1}:null,t[9]=o,t[10]=N);let[I,L]=(0,Z.useState)(N),z;t[11]!==o||t[12]!==A||t[13]!==n||t[14]!==M?(z=()=>{if(!n){M(),L(o?{path:o,isDirectory:!1}:null);return}A()},t[11]=o,t[12]=A,t[13]=n,t[14]=M,t[15]=z):z=t[15];let B;t[16]!==o||t[17]!==A||t[18]!==n||t[19]!==C||t[20]!==M||t[21]!==l?(B=[n,C,l,A,M,o],t[16]=o,t[17]=A,t[18]=n,t[19]=C,t[20]=M,t[21]=l,t[22]=B):B=t[22],(0,Z.useEffect)(z,B);let H;t[23]===j?H=t[24]:(H=e=>{j(e)},t[23]=j,t[24]=H);let U=H,W=I!==null&&(f===`any`||f===`file`&&!I.isDirectory||f===`directory`&&I.isDirectory),G;bb1:{if(!I){G=v.pickerHintNone;break bb1}if(f===`file`&&I.isDirectory){G=v.pickerHintNeedsFile;break bb1}if(f===`directory`&&!I.isDirectory){G=v.pickerHintNeedsDirectory;break bb1}G=`${I.isDirectory?`📁`:`📄`} ${I.path}`}let ee=G,K;t[25]===b?.agents?K=t[26]:(K=b?.agents??[],t[25]=b?.agents,t[26]=K);let q=K,te;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(V,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[27]=te):te=t[27];let ne;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(ne=Y(`fixed left-1/2 top-1/2 z-[71] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`flex h-[min(28rem,calc(100vh-3rem))] flex-col overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-popover outline-none`),t[28]=ne):ne=t[28];let re;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(ht,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[29]=re):re=t[29];let ie;t[30]===v.pickerTitle?ie=t[31]:(ie=(0,$.jsx)(Ct,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:v.pickerTitle}),t[30]=v.pickerTitle,t[31]=ie);let ae=h.cron.refresh,oe=h.cron.refresh,se;t[32]===A?se=t[33]:(se=()=>void A(),t[32]=A,t[33]=se);let ce=O&&`animate-spin`,le;t[34]===ce?le=t[35]:(le=Y(`size-4`,ce),t[34]=ce,t[35]=le);let ue;t[36]===le?ue=t[37]:(ue=(0,$.jsx)(At,{className:le,"aria-hidden":!0}),t[36]=le,t[37]=ue);let de;t[38]!==O||t[39]!==h.cron.refresh||t[40]!==se||t[41]!==ue?(de=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:ae,"aria-label":oe,disabled:O,onClick:se,children:ue}),t[38]=O,t[39]=h.cron.refresh,t[40]=se,t[41]=ue,t[42]=de):de=t[42];let fe;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(It,{className:`size-4`}),t[43]=fe):fe=t[43];let pe;t[44]===_.close?pe=t[45]:(pe=(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":_.close,children:fe})}),t[44]=_.close,t[45]=pe);let he;t[46]!==ie||t[47]!==de||t[48]!==pe?(he=(0,$.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[re,ie,de,pe]}),t[46]=ie,t[47]=de,t[48]=pe,t[49]=he):he=t[49];let ge;t[50]!==q||t[51]!==b?.defaultId||t[52]!==C||t[53]!==v.pickerAgentLabel?(ge=q.length>0?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,$.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:v.pickerAgentLabel}),(0,$.jsx)(`select`,{id:`picker-agent-select`,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:C,onChange:e=>{w(e.target.value),L(null)},children:q.map(e=>(0,$.jsxs)(`option`,{value:e.id,children:[e.name||e.id,e.id===b?.defaultId?` ★`:``]},e.id))})]}):null,t[50]=q,t[51]=b?.defaultId,t[52]=C,t[53]=v.pickerAgentLabel,t[54]=ge):ge=t[54];let _e;t[55]!==k||t[56]!==_.loadError?(_e=k?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[_.loadError,`: `,k]}):null,t[55]=k,t[56]=_.loadError,t[57]=_e):_e=t[57];let ye;t[58]!==U||t[59]!==O||t[60]!==I?.path||t[61]!==_.emptyDir||t[62]!==_.title||t[63]!==D?(ye=O&&D.length===0?(0,$.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(J,{className:`size-4 animate-spin`}),_.title,`…`]}):(0,$.jsx)(Te,{tree:D,selectedPath:I?.path??null,onSelectFile:e=>L({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>L({path:e,isDirectory:t}),onExpandDir:U,onAction:void 0,emptyHint:_.emptyDir}),t[58]=U,t[59]=O,t[60]=I?.path,t[61]=_.emptyDir,t[62]=_.title,t[63]=D,t[64]=ye):ye=t[64];let be;t[65]!==_e||t[66]!==ye?(be=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[_e,ye]}),t[65]=_e,t[66]=ye,t[67]=be):be=t[67];let xe;t[68]===ee?xe=t[69]:(xe=(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:ee}),t[68]=ee,t[69]=xe);let Se;t[70]===r?Se=t[71]:(Se=()=>r(!1),t[70]=r,t[71]=Se);let Ce;t[72]!==v.cancel||t[73]!==Se?(Ce=(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:Se,children:v.cancel}),t[72]=v.cancel,t[73]=Se,t[74]=Ce):Ce=t[74];let we=!W,Ee;t[75]!==i||t[76]!==r||t[77]!==C||t[78]!==I?(Ee=()=>{I&&(i({...I,agentId:C}),r(!1))},t[75]=i,t[76]=r,t[77]=C,t[78]=I,t[79]=Ee):Ee=t[79];let Oe;t[80]!==v.pickerConfirm||t[81]!==we||t[82]!==Ee?(Oe=(0,$.jsx)(X,{type:`button`,disabled:we,onClick:Ee,children:v.pickerConfirm}),t[80]=v.pickerConfirm,t[81]=we,t[82]=Ee,t[83]=Oe):Oe=t[83];let ke;t[84]!==Ce||t[85]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Ce,Oe]}),t[84]=Ce,t[85]=Oe,t[86]=ke):ke=t[86];let Ae;t[87]!==xe||t[88]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[xe,ke]}),t[87]=xe,t[88]=ke,t[89]=Ae):Ae=t[89];let je;t[90]!==he||t[91]!==ge||t[92]!==be||t[93]!==Ae?(je=(0,$.jsxs)(R,{children:[te,(0,$.jsxs)(nn,{className:ne,children:[he,ge,be,Ae]})]}),t[90]=he,t[91]=ge,t[92]=be,t[93]=Ae,t[94]=je):je=t[94];let Me;return t[95]!==r||t[96]!==n||t[97]!==je?(Me=(0,$.jsx)(ve,{open:n,onOpenChange:r,children:je}),t[95]=r,t[96]=n,t[97]=je,t[98]=Me):Me=t[98],Me}function gu(e){return e.token}function _u(e){return e.agentId}function vu(e){return e.language}var yu=[`shares`,`policy`];function bu(e){let t=(e??``).trim();return yu.includes(t)?t:`shares`}function xu(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Su(e,t){let n=new Date(e).getTime()-Date.now(),r=Math.abs(n),i=n<0;if(r<6e4)return t===`zh`?`刚刚`:`just now`;let a=Math.floor(r/6e4);if(a<60){let e=t===`zh`?`${a} 分钟`:`${a}m`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let o=Math.floor(a/60);if(o<24){let e=t===`zh`?`${o} 小时`:`${o}h`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let s=Math.floor(o/24),c=t===`zh`?`${s} 天`:`${s}d`;return i?t===`zh`?`${c}前`:`${c} ago`:c}var Cu=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`}];function wu(){let e=(0,Q.c)(44),t=a(Eu),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.sharesSettings,i=!!g(Tu),[o,c]=C(),l;e[2]===o?l=e[3]:(l=bu(o.get(`tab`)),e[2]=o,e[3]=l);let u=l,d;e[4]===c?d=e[5]:(d=e=>{c(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[4]=c,e[5]=d);let f=d;if(!i){let t;return e[6]===r.needToken?t=e[7]:(t=(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})}),e[6]=r.needToken,e[7]=t),t}let p;e[8]!==r.tabPolicy||e[9]!==r.tabShares?(p={shares:r.tabShares,policy:r.tabPolicy},e[8]=r.tabPolicy,e[9]=r.tabShares,e[10]=p):p=e[10];let m=p,h;e[11]===r.title?h=e[12]:(h=(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:r.title}),e[11]=r.title,e[12]=h);let _;e[13]===r.subtitle?_=e[14]:(_=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),e[13]=r.subtitle,e[14]=_);let v;e[15]!==h||e[16]!==_?(v=(0,$.jsxs)(`div`,{children:[h,_]}),e[15]=h,e[16]=_,e[17]=v):v=e[17];let y=r.tabsAria,b;e[18]!==u||e[19]!==f?(b=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=yu[(yu.indexOf(u)+(e.key===`ArrowRight`?1:-1)+yu.length)%yu.length];f(t)},e[18]=u,e[19]=f,e[20]=b):b=e[20];let x;e[21]!==u||e[22]!==f||e[23]!==m?(x=yu.map(e=>{let t=e===u;return(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,id:`shares-tab-${e}`,"aria-controls":`shares-panel-${e}`,className:Y(`shrink-0 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,jt.press,t?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>f(e),children:m[e]},e)}),e[21]=u,e[22]=f,e[23]=m,e[24]=x):x=e[24];let S;e[25]===x?S=e[26]:(S=(0,$.jsx)(`div`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,children:x}),e[25]=x,e[26]=S);let w=`shares-panel-${u}`,T=`shares-tab-${u}`,E;e[27]!==u||e[28]!==i||e[29]!==t||e[30]!==r?(E=u===`shares`?(0,$.jsx)(Du,{t:r,language:t}):(0,$.jsx)(du,{hasToken:i}),e[27]=u,e[28]=i,e[29]=t,e[30]=r,e[31]=E):E=e[31];let D;e[32]!==w||e[33]!==T||e[34]!==E?(D=(0,$.jsx)(`div`,{role:`tabpanel`,id:w,"aria-labelledby":T,className:`min-w-0`,children:E}),e[32]=w,e[33]=T,e[34]=E,e[35]=D):D=e[35];let O;e[36]!==r.tabsAria||e[37]!==S||e[38]!==D||e[39]!==b?(O=(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,role:`tablist`,"aria-label":y,onKeyDown:b,children:[S,D]}),e[36]=r.tabsAria,e[37]=S,e[38]=D,e[39]=b,e[40]=O):O=e[40];let k;return e[41]!==O||e[42]!==v?(k=(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[v,O]}),e[41]=O,e[42]=v,e[43]=k):k=e[43],k}function Tu(e){return e.token}function Eu(e){return e.language}function Du(e){let t=(0,Q.c)(60),{t:n,language:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:3e4},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,mutate:c}=d(`shares-list`,L,i),l;t[1]===a?.payload?.shares?l=t[2]:(l=a?.payload?.shares??[],t[1]=a?.payload?.shares,t[2]=l);let u=l,[f,p]=(0,Z.useState)(!1),m;bb0:{if(f){m=u;break bb0}let e;t[3]===u?e=t[4]:(e=u.filter(ju),t[3]=u,t[4]=e),m=e}let h=m,g;t[5]===u?g=t[6]:(g=u.filter(Au),t[5]=u,t[6]=g);let _=g.length,v;t[7]===u?v=t[8]:(v=u.filter(ku),t[7]=u,t[8]=v);let y=v.length,b;t[9]===c?b=t[10]:(b=()=>void c(),t[9]=c,t[10]=b);let x;t[11]!==n||t[12]!==b?(x=(0,$.jsx)(Nu,{t:n,onCreated:b}),t[11]=n,t[12]=b,t[13]=x):x=t[13];let S=f?n.allSharesTitle:n.listTitle,C;t[14]===_?C=t[15]:(C=_>0&&(0,$.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,_,`)`]}),t[14]=_,t[15]=C);let w;t[16]!==S||t[17]!==C?(w=(0,$.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[S,C]}),t[16]=S,t[17]=C,t[18]=w):w=t[18];let T;t[19]===c?T=t[20]:(T=()=>void c(),t[19]=c,t[20]=T);let E=s&&`animate-spin`,D;t[21]===E?D=t[22]:(D=Y(`size-3.5`,E),t[21]=E,t[22]=D);let O;t[23]===D?O=t[24]:(O=(0,$.jsx)(At,{className:D}),t[23]=D,t[24]=O);let k;t[25]!==s||t[26]!==T||t[27]!==O?(k=(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:T,disabled:s,children:O}),t[25]=s,t[26]=T,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==y||t[30]!==f||t[31]!==n.hideExpired||t[32]!==n.showExpired?(A=y>0&&(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>p(Ou),children:f?n.hideExpired:n.showExpired}),t[29]=y,t[30]=f,t[31]=n.hideExpired,t[32]=n.showExpired,t[33]=A):A=t[33];let j;t[34]!==k||t[35]!==A?(j=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[k,A]}),t[34]=k,t[35]=A,t[36]=j):j=t[36];let M;t[37]!==w||t[38]!==j?(M=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[w,j]}),t[37]=w,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==a||t[41]!==o||t[42]!==h||t[43]!==s||t[44]!==r||t[45]!==c||t[46]!==n?(N=s&&!a?(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(J,{className:`size-4 animate-spin`}),n.loading]}):o?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,$.jsx)(`span`,{children:n.error}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):h.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:h.map(e=>(0,$.jsx)(Fu,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[40]=a,t[41]=o,t[42]=h,t[43]=s,t[44]=r,t[45]=c,t[46]=n,t[47]=N):N=t[47];let P;t[48]!==y||t[49]!==c||t[50]!==f||t[51]!==n?(P=y>0&&f&&(0,$.jsx)(Iu,{t:n,onCleaned:()=>void c()}),t[48]=y,t[49]=c,t[50]=f,t[51]=n,t[52]=P):P=t[52];let F;t[53]!==M||t[54]!==N||t[55]!==P?(F=(0,$.jsxs)(Tn,{children:[M,N,P]}),t[53]=M,t[54]=N,t[55]=P,t[56]=F):F=t[56];let I;return t[57]!==F||t[58]!==x?(I=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[x,F]}),t[57]=F,t[58]=x,t[59]=I):I=t[59],I}function Ou(e){return!e}function ku(e){return e.expired||e.revoked}function Au(e){return!e.expired&&!e.revoked}function ju(e){return!e.expired&&!e.revoked}var Mu={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function Nu({t:e,onCreated:t}){let[n,r]=(0,Z.useReducer)(de,Mu),{expanded:i,path:a,isDirectory:o,agentId:s,ttlMs:c,maxViews:l,description:u,directoryMode:d,creating:f,result:p,errorMsg:m,resultDialogOpen:h,pickerOpen:g}=n,_=(0,Z.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await Ae({path:a.trim(),ttlMs:c,maxViews:l,description:u.trim()||void 0,...s?{agentId:s}:{},...o?{kind:`directory`,directoryMode:d}:{}})).payload,resultDialogOpen:!0}}),t()}catch(e){r({type:`patch`,patch:{errorMsg:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{creating:!1}})}}},[a,o,s,c,l,u,d,t]),v=(0,Z.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,$.jsxs)(Tn,{children:[(0,$.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:Y(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,a?`text-fg`:`text-fg-subtle`),children:a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:o?`📁`:`📄`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,$.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,$.jsxs)(X,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,$.jsx)(Xe,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),o?(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,$.jsxs)(`select`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:d,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,$.jsx)(`option`,{value:`browse`,children:e.directoryModeBrowse}),(0,$.jsx)(`option`,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,$.jsx)(`select`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:c,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Cu.map(t=>(0,$.jsx)(`option`,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,$.jsxs)(`select`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:l??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,$.jsx)(`option`,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,$.jsx)(`option`,{value:`1`,children:`1`}),(0,$.jsx)(`option`,{value:`5`,children:`5`}),(0,$.jsx)(`option`,{value:`10`,children:`10`}),(0,$.jsx)(`option`,{value:`50`,children:`50`}),(0,$.jsx)(`option`,{value:`100`,children:`100`})]})]})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,$.jsx)(`input`,{type:`text`,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:ring-2 focus:ring-accent`,placeholder:e.descriptionPlaceholder,value:u,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,$.jsxs)(X,{type:`button`,disabled:f||!a.trim(),onClick:()=>void _(),children:[f?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(Ut,{className:`size-4`}),f?e.creating:e.createButton]}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>{v(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),m&&(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m})]}),(0,$.jsx)(E,{open:h,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:p}),(0,$.jsx)(hu,{open:g,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:a||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,$.jsxs)(X,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,$.jsx)(Ut,{className:`size-4`}),e.createTitle]})}var Pu={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function Fu({share:e,t,language:n,onRevoked:r,onExtended:i}){let[a,o]=(0,Z.useReducer)(de,Pu),{revokeOpen:s,revoking:c,linksOpen:l,urlCopied:u,copyFailed:d,extending:f}=a,p=!e.expired&&!e.revoked,h=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,g=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,_=(0,Z.useCallback)(async()=>{o({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await ge(e.id),r()}catch{}finally{o({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),v=(0,Z.useCallback)(async()=>{if(o({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await Se(e.shareUrl)){o({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>o({type:`patch`,patch:{copyFailed:!1}}),2500);return}o({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>o({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),y=(0,Z.useCallback)(async()=>{o({type:`patch`,patch:{extending:!0}});try{await B(e.id,864e5),i()}catch{}finally{o({type:`patch`,patch:{extending:!1}})}},[e.id,i]),b=`share-links-${e.id}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(`flex min-w-0 flex-1 items-start gap-3 rounded-md text-left`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),"aria-expanded":l,"aria-controls":b,onClick:()=>o({type:`patch`,patch:{linksOpen:!l}}),children:[(0,$.jsx)(le,{className:Y(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,l?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),(0,$.jsx)(Xe,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:Y(`text-xs font-medium`,g),children:h})]}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.workspaceRelativePath}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:xu(e.fileSize)}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(cn,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:Su(e.expiresAt,n)]}),(0,$.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,$.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void v(),children:u?(0,$.jsx)(fe,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(m,{className:`size-3.5`})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void y(),disabled:f,title:t.extend,children:f?(0,$.jsx)(J,{className:`size-3.5 animate-spin`}):(0,$.jsx)(cn,{className:`size-3.5`})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>o({type:`patch`,patch:{revokeOpen:!0}}),disabled:c,children:c?(0,$.jsx)(J,{className:`size-3.5 animate-spin`}):(0,$.jsx)(en,{className:`size-3.5`})})]})})]}),p&&l?(0,$.jsxs)(`div`,{id:b,className:`mt-3 border-t border-edge-subtle pt-3 pl-7`,children:[(0,$.jsx)(_t,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),d?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(xt,{reachability:e.reachability})})]}):null]}),(0,$.jsx)(rn,{open:s,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void _(),onCancel:()=>o({type:`patch`,patch:{revokeOpen:!1}})})]})}function Iu({t:e,onCleaned:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(!1),o=(0,Z.useCallback)(async()=>{r(!1),a(!0);try{await tn(),t()}catch{}finally{a(!1)}},[t]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>r(!0),className:`border-danger/40 px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:[i?(0,$.jsx)(J,{className:`size-3.5 animate-spin`}):(0,$.jsx)(en,{className:`size-3.5`}),e.cleanExpired]})}),(0,$.jsx)(rn,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}function Lu(e,t){return e==null?t:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ru(e,t){return e===`PENDING_UPDATE`?t.pendingUpdate??t.generic:e===`UNINSTALLER_NOT_FOUND`?t.uninstallerNotFound??t.generic:e===`NOT_PACKAGED`?t.notPackaged??t.generic:t.generic}function zu(e,t){if(e.platform===`darwin`)return t.uninstallDescDarwin;if(e.platform===`win32`)return t.uninstallDescWin;if(e.platform===`linux`){if(e.linuxPackageKind===`appimage`)return t.uninstallDescLinuxAppImage;if(e.linuxPackageKind===`deb`){let n=e.linuxDebPackageName??`xopc`;return t.uninstallDescLinuxDeb.replace(/\{\{package\}\}/g,n)}return t.uninstallDescLinuxUnknown}return t.uninstallDescLinuxUnknown}var Bu={info:null,loadError:null,actionError:null,copiedField:null,clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``,uninstallDialogOpen:!1,removeUserDataOnUninstall:!1,busy:!1};function Vu({api:e,messages:t,embedded:n=!0}){let[r,i]=(0,Z.useReducer)(de,Bu),{info:a,loadError:o,actionError:s,copiedField:c,clearDialogOpen:l,clearConfirmChecked:u,clearConfirmText:d,uninstallDialogOpen:f,removeUserDataOnUninstall:p,busy:h}=r,g=(0,Z.useCallback)(async()=>{if(e?.getUninstallInfo){i({type:`patch`,patch:{loadError:null}});try{i({type:`patch`,patch:{info:await e.getUninstallInfo()}})}catch(e){i({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}}},[e]);(0,Z.useEffect)(()=>{g()},[g]);let _=async(e,n)=>{if(await Se(e)){i({type:`patch`,patch:{actionError:null,copiedField:n}}),window.setTimeout(()=>i({type:`patch`,patch:{copiedField:null}}),2e3);return}i({type:`patch`,patch:{actionError:t.copyFailed}})},v=async e=>{let t=window.electronAPI?.shell;if(!t)return;let n=await t.openPath(e);n.error&&i({type:`patch`,patch:{actionError:n.error}})},y=async()=>{if(e?.clearUserData){i({type:`patch`,patch:{busy:!0,actionError:null}});try{let n=await e.clearUserData();n.ok||i({type:`patch`,patch:{actionError:Ru(n.error,t.errors)}})}catch(e){i({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.errors.generic}})}finally{i({type:`patch`,patch:{busy:!1,clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})}}},b=async()=>{if(e?.uninstallApp){i({type:`patch`,patch:{busy:!0,actionError:null}});try{let n=await e.uninstallApp({removeUserData:p});n.ok||i({type:`patch`,patch:{actionError:Ru(n.error,t.errors)}})}catch(e){i({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.errors.generic}})}finally{i({type:`patch`,patch:{busy:!1,uninstallDialogOpen:!1}})}}};if(o)return(0,$.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:o});if(!a)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading});let x=!a.packaged,S=h||a.pendingUpdate||x,C=!x&&a.uninstallMode!==`unsupported`,w=zu(a,t),T=u&&d.trim()===t.clearDataConfirmPhrase;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Tn,{children:[n?(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(dt,{className:`size-4 text-accent`,strokeWidth:1.75}),t.title]}):null,s?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:s}):null,x?(0,$.jsxs)(`div`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 py-2.5`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.devOnlyTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.devOnlyBody})]}):null,a.pendingUpdate?(0,$.jsx)(`p`,{className:`mb-3 rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:t.pendingUpdateBlocked}):null,a.hasSeparateCliData&&a.cliDataPath?(0,$.jsxs)(`div`,{className:`mb-4 rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2.5`,children:[(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:t.cliDataWarning}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`mt-2 inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,jt.press),onClick:()=>void v(a.cliDataPath),children:[(0,$.jsx)(ht,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t.openCliData]})]}):null,(0,$.jsxs)(`dl`,{className:`space-y-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:t.appPath}),(0,$.jsxs)(`dd`,{className:`mt-1 flex items-start justify-between gap-2`,children:[(0,$.jsx)(`code`,{className:`break-all text-xs text-fg`,children:a.appPath}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`inline-flex shrink-0 items-center gap-1 rounded-lg border border-edge px-2 py-1 text-xs text-fg hover:bg-surface-hover`,jt.press),onClick:()=>void _(a.appPath,`app`),children:[(0,$.jsx)(m,{className:`size-3`,"aria-hidden":!0}),c===`app`?t.copied:t.copyPath]})]})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:t.dataPath}),(0,$.jsxs)(`dd`,{className:`mt-1 flex items-start justify-between gap-2`,children:[(0,$.jsx)(`code`,{className:`break-all text-xs text-fg`,children:a.userDataPath}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`inline-flex shrink-0 items-center gap-1 rounded-lg border border-edge px-2 py-1 text-xs text-fg hover:bg-surface-hover`,jt.press),onClick:()=>void _(a.userDataPath,`data`),children:[(0,$.jsx)(m,{className:`size-3`,"aria-hidden":!0}),c===`data`?t.copied:t.copyPath]})]}),(0,$.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[t.dataSize,`: `,Lu(a.userDataSizeBytes,t.dataSizeUnknown)]})]})]}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border border-edge-subtle bg-surface-panel/60 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.clearData}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.clearDataDesc})]}),(0,$.jsx)(`button`,{type:`button`,disabled:S,className:Y(`inline-flex shrink-0 items-center justify-center rounded-lg border border-danger/40 bg-danger px-3 py-1.5 text-sm font-medium text-white hover:bg-danger/90 disabled:opacity-50`,jt.press),onClick:()=>{i({type:`patch`,patch:{clearConfirmChecked:!1,clearConfirmText:``,clearDialogOpen:!0}})},children:t.clearData})]}),C?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border border-edge-subtle bg-surface-panel/60 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.uninstall}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:w})]}),(0,$.jsx)(`button`,{type:`button`,disabled:S,className:Y(`inline-flex shrink-0 items-center justify-center rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-sm font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,jt.press),onClick:()=>{i({type:`patch`,patch:{removeUserDataOnUninstall:!1,uninstallDialogOpen:!0}})},children:t.uninstall})]}):null]})]}),(0,$.jsx)(ve,{open:l,onOpenChange:e=>{e||i({type:`patch`,patch:{clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})},children:(0,$.jsxs)(R,{children:[(0,$.jsx)(V,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Ze)}),(0,$.jsxs)(nn,{className:Y(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,sn,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsx)(Ct,{className:`text-base font-semibold text-fg`,children:t.clearDataConfirmTitle}),(0,$.jsx)(je,{className:`mt-2 text-sm text-fg-muted`,children:t.clearDataConfirmDesc}),(0,$.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:u,onChange:e=>i({type:`patch`,patch:{clearConfirmChecked:e.target.checked}})}),(0,$.jsx)(`span`,{children:t.clearDataConfirmCheckbox})]}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,$.jsx)(`label`,{className:`block text-sm font-medium text-fg`,htmlFor:`clear-data-confirm`,children:t.clearDataConfirmLabel}),(0,$.jsx)(`input`,{id:`clear-data-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:Y(`w-full rounded-md border border-edge bg-surface-panel px-3 py-1.5 font-mono text-xs text-fg`,`placeholder:text-fg-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:border-edge`),placeholder:t.clearDataConfirmPhrase,value:d,onChange:e=>i({type:`patch`,patch:{clearConfirmText:e.target.value}})}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.clearDataConfirmHint})]}),(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:h,onClick:()=>{i({type:`patch`,patch:{clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})},children:t.cancel}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:h||!T,onClick:()=>void y(),children:t.confirmClear})]})]})]})}),C?(0,$.jsx)(ve,{open:f,onOpenChange:e=>{e||i({type:`patch`,patch:{uninstallDialogOpen:!1}})},children:(0,$.jsxs)(R,{children:[(0,$.jsx)(V,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Ze)}),(0,$.jsxs)(nn,{className:Y(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,sn,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsx)(Ct,{className:`text-base font-semibold text-fg`,children:t.uninstallConfirmTitle}),(0,$.jsx)(je,{className:`mt-2 text-sm text-fg-muted`,children:w}),(0,$.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:p,onChange:e=>i({type:`patch`,patch:{removeUserDataOnUninstall:e.target.checked}})}),(0,$.jsx)(`span`,{children:t.removeUserDataCheckbox})]}),p?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.clearDataConfirmDesc}):null,(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:h,onClick:()=>i({type:`patch`,patch:{uninstallDialogOpen:!1}}),children:t.cancel}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:h,onClick:()=>void b(),children:t.confirmUninstall})]})]})]})}):null]})}function Hu(){let e=(0,Q.c)(22),t=a(Uu),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.systemSettings,i=r.appManagement,o=typeof window<`u`?window.electronAPI?.system:void 0;if(!j()||!o){let t;e[2]===i.title?t=e[3]:(t=(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:i.title}),e[2]=i.title,e[3]=t);let n;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=wn(),e[4]=n):n=e[4];let a;e[5]===r.desktopOnlyTitle?a=e[6]:(a=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.desktopOnlyTitle}),e[5]=r.desktopOnlyTitle,e[6]=a);let o;e[7]===r.desktopOnlyBody?o=e[8]:(o=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.desktopOnlyBody}),e[7]=r.desktopOnlyBody,e[8]=o);let s;e[9]!==a||e[10]!==o?(s=(0,$.jsxs)(`div`,{className:n,children:[a,o]}),e[9]=a,e[10]=o,e[11]=s):s=e[11];let c;return e[12]!==t||e[13]!==s?(c=(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[t,s]}),e[12]=t,e[13]=s,e[14]=c):c=e[14],c}let c;e[15]===i.title?c=e[16]:(c=(0,$.jsx)(`div`,{children:(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:i.title})}),e[15]=i.title,e[16]=c);let l;e[17]===i?l=e[18]:(l=(0,$.jsx)(Vu,{api:o,messages:i,embedded:!1}),e[17]=i,e[18]=l);let u;return e[19]!==c||e[20]!==l?(u=(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[c,l]}),e[19]=c,e[20]=l,e[21]=u):u=e[21],u}function Uu(e){return e.language}async function Wu(){if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia)return!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop();return!0}catch{return!1}}function Gu(e,t,n){return e.outcome===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.outcome===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function Ku(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function qu(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function Ju(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}var Yu=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function Xu(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||Yu.has(e)?t===`unknown`:!1}function Zu(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:Yu.has(e)?t===`denied`:!0}var Qu=[{key:`fullDisk`,pane:`fullDisk`,platforms:[`darwin`]},{key:`screen`,pane:`screen`},{key:`microphone`,pane:`microphone`},{key:`accessibility`,pane:`accessibility`},{key:`automation`,pane:`automation`},{key:`notifications`,pane:`notifications`},{key:`location`,pane:`location`}];function $u(e){return e===`linux`?Qu:Qu.filter(t=>!t.platforms||t.platforms.includes(e))}function ed(e,t){let n=s(e).systemSettings.status;return t===`granted`?{label:n.granted,className:`text-emerald-600 dark:text-emerald-400`}:t===`denied`?{label:n.denied,className:`text-amber-600 dark:text-amber-400`}:{label:n.unknown,className:`text-fg-muted`}}function td(e,t,n){let r=s(e).systemSettings.permUnknown?.[t];return r?n===`darwin`&&r.darwin?r.darwin:n===`win32`&&r.win32?r.win32:n===`linux`&&r.linux?r.linux:null:null}var nd={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function rd(){let e=a(e=>e.language),t=s(e).systemSettings,[n,r]=(0,Z.useReducer)(de,nd),{behavior:i,perms:o,loadError:c,permFeedback:l,permBusy:u,refreshing:d}=n,f=typeof window<`u`?window.electronAPI?.system:void 0,p=(0,Z.useCallback)(async e=>{if(f){r({type:`patch`,patch:{loadError:null}});try{r({type:`patch`,patch:{behavior:await f.getBehavior(),perms:await f.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:t.refreshDone}:{}}})}catch(t){r({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[f,t.refreshDone]),m=(0,Z.useCallback)(async()=>{if(!(d||u)){r({type:`patch`,patch:{refreshing:!0}});try{await p({showRefreshFeedback:!0})}finally{r({type:`patch`,patch:{refreshing:!1}})}}},[p,u,d]);if((0,Z.useEffect)(()=>{let e=new Set([t.refreshDone,t.openSettingsDone,t.openSettingsFailed,t.desktopNotify.testShown]);if(!l||!e.has(l))return;let n=window.setTimeout(()=>{r({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(n)},[l,t.openSettingsDone,t.openSettingsFailed,t.refreshDone,t.desktopNotify.testShown]),(0,Z.useEffect)(()=>{j()&&f&&p()},[f,p]),!j()||!f)return(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.title}),(0,$.jsxs)(`div`,{className:wn(),children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.desktopOnlyTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.desktopOnlyBody})]})]});let h=async e=>{try{let{behavior:t}=await f.setBehavior(e);r({type:`patch`,patch:{behavior:t}}),(e.notifyEnabled!==void 0||e.notifySoundEnabled!==void 0)&&qe()}catch(e){r({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},g=async e=>{if(!e){await h({notifyEnabled:!1});return}r({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await Qt(t.desktopNotify.testTitle,t.desktopNotify.testBody);if(e===`unsupported`){r({type:`patch`,patch:{permFeedback:t.notificationsFeedback.unsupported}});return}if(e===`denied`){r({type:`patch`,patch:{permFeedback:t.desktopNotify.denied}});return}if(e===`default`){r({type:`patch`,patch:{permFeedback:t.notificationsFeedback.default}});return}await h({notifyEnabled:!0}),r({type:`patch`,patch:{perms:await f.getPermissions()}}),r({type:`patch`,patch:{permFeedback:t.desktopNotify.testShown}})}catch(e){r({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{permBusy:!1}})}},_=async e=>{r({type:`patch`,patch:{permFeedback:null}}),r({type:`patch`,patch:{loadError:null}});try{(await f.openPrivacy(e)).ok?r({type:`patch`,patch:{permFeedback:t.openSettingsDone}}):r({type:`patch`,patch:{permFeedback:t.openSettingsFailed}})}catch(e){r({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},v=async()=>{r({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),r({type:`patch`,patch:{loadError:null}});try{let e=await f.requestMicrophone(),n=await Wu();r({type:`patch`,patch:{perms:await f.getPermissions()}}),r({type:`patch`,patch:{permFeedback:Gu(e,n,t.permFeedback)}})}catch(e){r({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{permBusy:!1}})}},y=async()=>{if(f.requestAccessibility){r({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),r({type:`patch`,patch:{loadError:null}});try{let e=await f.requestAccessibility();r({type:`patch`,patch:{perms:await f.getPermissions()}}),r({type:`patch`,patch:{permFeedback:Ku(e,t.accessibilityFeedback)}})}catch(e){r({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{permBusy:!1}})}}},b=async()=>{if(f.requestNotifications){r({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),r({type:`patch`,patch:{loadError:null}});try{let e=await f.requestNotifications();r({type:`patch`,patch:{perms:await f.getPermissions()}}),r({type:`patch`,patch:{permFeedback:qu(e,t.notificationsFeedback)}})}catch(e){r({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{permBusy:!1}})}}},x=async()=>{if(f.requestScreen){r({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),r({type:`patch`,patch:{loadError:null}});try{let e=await f.requestScreen();r({type:`patch`,patch:{perms:await f.getPermissions()}}),r({type:`patch`,patch:{permFeedback:Ju(e,t.screenFeedback)}})}catch(e){r({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{permBusy:!1}})}}},S=i?i.platform===`win32`?t.permissionsHintWin:i.platform===`linux`?t.permissionsHintLinux:i.platform===`darwin`?t.permissionsHintDarwin:t.permissionsHint:t.permissionsHint;return(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,$.jsx)(`div`,{children:(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.title})}),c?(0,$.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:c}):null,l?(0,$.jsx)(`p`,{className:Y(`text-sm`,l===t.refreshDone||l===t.openSettingsDone||l===t.permFeedback.granted||l===t.permFeedback.alreadyGranted||l===t.accessibilityFeedback.granted||l===t.accessibilityFeedback.alreadyGranted||l===t.notificationsFeedback.granted||l===t.notificationsFeedback.alreadyGranted||l===t.screenFeedback.granted||l===t.screenFeedback.alreadyGranted||l===t.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:l}):null,(0,$.jsxs)(Tn,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(K,{className:`size-4 text-accent`,strokeWidth:1.75}),t.behaviorGroup]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.openAtLogin}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.openAtLoginDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!i,checked:!!i?.openAtLogin,onChange:e=>{h({openAtLogin:e.target.checked})}})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.keepAwake}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.keepAwakeDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!i,checked:!!i?.keepAwakePreferred,onChange:e=>{h({keepAwakePreferred:e.target.checked})}})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifyDesktop}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifyDesktopDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!i||u,checked:!!i?.notifyEnabled,onChange:e=>{g(e.target.checked)}})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifySound}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifySoundDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!i,checked:!!i?.notifySoundEnabled,onChange:e=>{h({notifySoundEnabled:e.target.checked})}})]})]})]}),i&&o?(0,$.jsxs)(`section`,{className:wn(),children:[(0,$.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.permissionsTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:S}),i.platform===`darwin`&&!i.packaged?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:t.permissionsHintDevDarwin}):null]}),(0,$.jsxs)(`button`,{type:`button`,disabled:d||u,"aria-busy":d,className:Y(`mt-2 inline-flex max-w-full items-center justify-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 py-1.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:opacity-50 sm:mt-0`,jt.press),onClick:()=>void m(),children:[(0,$.jsx)(At,{className:Y(`size-3.5`,d&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),d?t.refreshing:t.refresh]})]}),(0,$.jsx)(`ul`,{className:`space-y-3`,children:$u(i.platform).map(({key:n,pane:r})=>{let a=ed(e,o[n]),s=t.perm[n],c=o[n]===`unknown`?td(e,n,i.platform):null;return s?(0,$.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl border border-edge-subtle bg-surface-panel/60 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:s.desc}),(0,$.jsx)(`p`,{className:`mt-1 text-xs font-medium ${a.className}`,children:a.label}),c?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:c}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[n===`notifications`&&Xu(n,o[n],i.platform)?(0,$.jsx)(`button`,{type:`button`,disabled:u,className:Y(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,jt.press),onClick:()=>void b(),children:t.requestAccess}):null,n===`microphone`&&Xu(n,o[n],i.platform)?(0,$.jsx)(`button`,{type:`button`,disabled:u,className:Y(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,jt.press),onClick:()=>void v(),children:t.requestAccess}):null,n===`accessibility`&&Xu(n,o[n],i.platform)?(0,$.jsx)(`button`,{type:`button`,disabled:u,className:Y(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,jt.press),onClick:()=>void y(),children:t.requestAccess}):null,n===`screen`&&Xu(n,o[n],i.platform)?(0,$.jsx)(`button`,{type:`button`,disabled:u,className:Y(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,jt.press),onClick:()=>void x(),children:t.requestAccess}):null,Zu(n,o[n],i.platform)?(0,$.jsxs)(`button`,{type:`button`,className:Y(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,jt.press),onClick:()=>void _(r),children:[t.openSettings,(0,$.jsx)(Dt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},n):null})})]}):null]})}var id=/^([^:=]+)[:=](.*)$/;function ad(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=id.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function od(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 sd(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 cd(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 ld(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)||cd(t)&&(r[e]=t);return r}function ud(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function dd(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 fd(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=ud(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=dd(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=od(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function pd(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:sd(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function md(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function hd(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)||cd(t)?[]:[pd(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 gd(e){return fd(e)}async function _d(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]=fd(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(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),Xt()}function vd(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 yd(e,t){let n=await _(l(`/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=vd(n.payload.tools);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,tools:r}}function bd(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function xd(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 Sd(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 md(r)}function Cd(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 wd(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt)}function Td({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:s,headers:c,onChange:l}){let u=(e,t)=>{l(c.map((n,r)=>r===e?{...n,...t}:n))},d=()=>{l([...c,{key:``,value:``}])},f=e=>{let t=c.filter((t,n)=>n!==e);l(t.length>0?t:[{key:``,value:``}])},p=async()=>{try{let e=await w();if(!e){window.alert(a);return}let t=ad(e);if(!t?.length){window.alert(a);return}l(t)}catch{window.alert(a)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void p(),children:[(0,$.jsx)(Qe,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{className:Y(wd(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>u(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:Y(wd(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:s,onChange:e=>u(t,{value:e.target.value})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:c.length<=1&&!e.key&&!e.value,onClick:()=>f(t),"aria-label":r,children:(0,$.jsx)(en,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},Cd(e,t,c)))}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`self-start text-sm text-accent hover:underline`,jt.press),onClick:d,children:[`+ `,n]})]})}var Ed=[`stdio`,`sse`,`streamable-http`];function Dd(e){let t=(0,Q.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,$.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,$.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,$.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,$.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 Od(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt)}function kd(e){let t=(0,Q.c)(67),{row:n,t:r,onUpdate:i,idConflictMessage:a}=e,o=r.transportLabel,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=Od(),t[0]=s):s=t[0];let c=n.transport,l;t[1]===i?l=t[2]:(l=e=>i({transport:e.target.value}),t[1]=i,t[2]=l);let u;t[3]===r.transportLabels?u=t[4]:(u=Ed.map(e=>(0,$.jsx)(`option`,{value:e,children:r.transportLabels[e]},e)),t[3]=r.transportLabels,t[4]=u);let d;t[5]!==n.transport||t[6]!==l||t[7]!==u?(d=(0,$.jsx)(`select`,{className:s,value:c,onChange:l,children:u}),t[5]=n.transport,t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]!==r.transportLabel||t[10]!==d?(f=(0,$.jsx)(Dd,{label:o,required:!0,children:d}),t[9]=r.transportLabel,t[10]=d,t[11]=f):f=t[11];let p=r.serverIdLabel,m;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=Od(),t[12]=m):m=t[12];let h;t[13]===i?h=t[14]:(h=e=>i({id:e.target.value}),t[13]=i,t[14]=h);let g;t[15]!==n.id||t[16]!==r.serverIdPlaceholder||t[17]!==h?(g=(0,$.jsx)(`input`,{className:m,value:n.id,placeholder:r.serverIdPlaceholder,onChange:h}),t[15]=n.id,t[16]=r.serverIdPlaceholder,t[17]=h,t[18]=g):g=t[18];let _;t[19]===a?_=t[20]:(_=a?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:a}):null,t[19]=a,t[20]=_);let v;t[21]!==r.serverIdLabel||t[22]!==g||t[23]!==_?(v=(0,$.jsxs)(Dd,{label:p,required:!0,children:[g,_]}),t[21]=r.serverIdLabel,t[22]=g,t[23]=_,t[24]=v):v=t[24];let y;t[25]!==i||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?(y=n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dd,{label:r.commandLabel,required:!0,children:(0,$.jsx)(`input`,{className:Od(),value:n.command,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(Dd,{label:r.argsLabel,description:r.argsHint,children:(0,$.jsx)(`input`,{className:Od(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,$.jsx)(Dd,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Od(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,$.jsx)(Dd,{label:r.envLabel,description:r.envHint,children:(0,$.jsx)(`textarea`,{className:Y(Od(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`md:col-span-2`,children:(0,$.jsx)(Dd,{label:r.urlLabel,required:!0,children:(0,$.jsx)(`input`,{className:Y(Od(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}),(0,$.jsx)(Td,{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=>i({headers:e})})]}),t[25]=i,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]=y):y=t[48];let b=r.timeoutLabel,x=r.timeoutHint,S;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(S=Od(),t[49]=S):S=t[49];let C;t[50]===n?C=t[51]:(C=bd(n),t[50]=n,t[51]=C);let w;t[52]===i?w=t[53]:(w=e=>i({connectionTimeoutMs:xd(e.target.value)}),t[52]=i,t[53]=w);let T;t[54]!==r.timeoutPlaceholder||t[55]!==C||t[56]!==w?(T=(0,$.jsx)(`input`,{type:`number`,min:1,max:600,className:S,value:C,placeholder:r.timeoutPlaceholder,onChange:w}),t[54]=r.timeoutPlaceholder,t[55]=C,t[56]=w,t[57]=T):T=t[57];let E;t[58]!==r.timeoutHint||t[59]!==r.timeoutLabel||t[60]!==T?(E=(0,$.jsx)(Dd,{label:b,description:x,children:T}),t[58]=r.timeoutHint,t[59]=r.timeoutLabel,t[60]=T,t[61]=E):E=t[61];let D;return t[62]!==v||t[63]!==y||t[64]!==E||t[65]!==f?(D=(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[f,v,y,E]}),t[62]=v,t[63]=y,t[64]=E,t[65]=f,t[66]=D):D=t[66],D}function Ad(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function jd(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Ad(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
|
|
3
|
+
`).toLowerCase().includes(r)}function Md(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Nd(e){let t=(0,Q.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,s]=(0,Z.useState)(``),c;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>jd(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],c=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=c}else c=t[3];let l=c,u;t[7]===o?u=t[8]:(u=o.trim(),t[7]=o,t[8]=u);let d=u.length>0,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(He,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=f):f=t[9];let p,m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=Y(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt),m=e=>s(e.target.value),t[10]=p,t[11]=m):(p=t[10],m=t[11]);let h;t[12]!==o||t[13]!==i?(h=(0,$.jsxs)(`div`,{className:`relative`,children:[f,(0,$.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:p,onChange:m})]}),t[12]=o,t[13]=i,t[14]=h):h=t[14];let g;t[15]!==l.length||t[16]!==d||t[17]!==n.length?(g=d?(0,$.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[l.length,` / `,n.length]}):null,t[15]=l.length,t[16]=d,t[17]=n.length,t[18]=g):g=t[18];let _;t[19]!==h||t[20]!==g?(_=(0,$.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[h,g]}),t[19]=h,t[20]=g,t[21]=_):_=t[21];let v;t[22]!==l||t[23]!==a||t[24]!==r?(v=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:l.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>{let n=e.shortName||Md(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,$.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=l,t[23]=a,t[24]=r,t[25]=v):v=t[25];let y;return t[26]!==_||t[27]!==v?(y=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[_,v]}),t[26]=_,t[27]=v,t[28]=y):y=t[28],y}function Pd(e){let t=(0,Q.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:o,searchPlaceholder:s,searchEmptyLabel:c,emptyLabel:l,closeLabel:u,tools:d,stripPrefix:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(V,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Ze)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`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`,sn,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=m):m=t[1];let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Ot,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=h):h=t[2];let g;t[3]===a?g=t[4]:(g=(0,$.jsxs)(Ct,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[h,a]}),t[3]=a,t[4]=g);let _;t[5]!==i||t[6]!==o||t[7]!==d.length?(_=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(d.length)),t[5]=i,t[6]=o,t[7]=d.length,t[8]=_):_=t[8];let v;t[9]===_?v=t[10]:(v=(0,$.jsx)(je,{className:`mt-1 text-sm text-fg-muted`,children:_}),t[9]=_,t[10]=v);let y;t[11]!==g||t[12]!==v?(y=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[g,v]}),t[11]=g,t[12]=v,t[13]=y):y=t[13];let b;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(It,{className:`size-4`,"aria-hidden":!0}),t[14]=b):b=t[14];let x;t[15]===u?x=t[16]:(x=(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":u,children:b})}),t[15]=u,t[16]=x);let S;t[17]!==y||t[18]!==x?(S=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[y,x]}),t[17]=y,t[18]=x,t[19]=S):S=t[19];let C;t[20]!==l||t[21]!==n||t[22]!==c||t[23]!==s||t[24]!==i||t[25]!==f||t[26]!==d?(C=d.length>0?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,$.jsx)(Nd,{tools:d,stripPrefix:f,searchPlaceholder:s,searchEmptyLabel:c},`${i}-${n?`open`:`closed`}`)}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l})}),t[20]=l,t[21]=n,t[22]=c,t[23]=s,t[24]=i,t[25]=f,t[26]=d,t[27]=C):C=t[27];let w;t[28]===u?w=t[29]:(w=(0,$.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`secondary`,children:u})})}),t[28]=u,t[29]=w);let T;t[30]!==S||t[31]!==C||t[32]!==w?(T=(0,$.jsxs)(R,{children:[p,(0,$.jsxs)(nn,{className:m,children:[S,C,w]})]}),t[30]=S,t[31]=C,t[32]=w,t[33]=T):T=t[33];let E;return t[34]!==r||t[35]!==n||t[36]!==T?(E=(0,$.jsx)(ve,{open:n,onOpenChange:r,children:T}),t[34]=r,t[35]=n,t[36]=T,t[37]=E):E=t[37],E}function Fd({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,Z.useState)(n),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)({status:`idle`}),[S,C]=(0,Z.useState)(null),w=n.id.trim(),T=d.id.trim()!==w&&o.has(d.id.trim())||o.has(d.id.trim())&&t===`add`?s.reservedServerId:void 0,E=d.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===d.id.trim())?c.duplicateServerId:void 0,D=d.id.trim().length>0&&!T&&!E&&(d.transport===`stdio`?d.command.trim().length>0:d.url.trim().length>0),O=(0,Z.useCallback)(async()=>{if(d.id.trim()){_(!0),y(null),x({status:`loading`});try{x({status:`ok`,tools:(await yd(d.id.trim(),gd(d))).tools})}catch(e){x({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{_(!1)}}},[d]),k=(0,Z.useCallback)(async()=>{if(!(!D||m)){h(!0),y(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(d),await _d({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},ld(a)),await u(),l()}catch(e){y(e instanceof Error?e.message:String(e))}finally{h(!1)}}},[D,a,r,n.clientKey,t,l,u,w,d,m,i]);return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/35 px-4 py-8`,children:(0,$.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,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:t===`add`?c.addCustomServerTitle:c.editCustomServerTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?c.addCustomServerHint:c.editCustomServerHint})]}),(0,$.jsx)(X,{variant:`ghost`,onClick:l,children:c.modalClose})]}),(0,$.jsxs)(`div`,{className:`mt-5 flex flex-col gap-4`,children:[(0,$.jsx)(kd,{row:d,t:s,onUpdate:e=>{f(t=>({...t,...e})),y(null)},idConflictMessage:T??E}),b.status===`ok`?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(Ot,{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,$.jsx)(X,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>C(b.tools),children:s.viewAllTools}):null]})}):null,b.status===`error`?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:b.message}):null,v?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:v}):null]}),(0,$.jsxs)(`div`,{className:`mt-5 flex flex-wrap justify-end gap-2`,children:[(0,$.jsxs)(X,{variant:`secondary`,disabled:!d.id.trim()||g,onClick:()=>void O(),children:[g?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(Jt,{className:`size-4`}),s.testConnection]}),(0,$.jsx)(X,{variant:`secondary`,onClick:l,children:c.modalCancel}),(0,$.jsxs)(X,{variant:`primary`,disabled:!D||m,onClick:()=>void k(),children:[m?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(p,{className:`size-4`}),m?s.saving:c.modalSave]})]})]})}),S?(0,$.jsx)(Pd,{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 Id(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 Ld(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function Rd(){return Ld(await _(l(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function zd(){return Ld(await _(l(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function Bd(e){return Ld(await _(l(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Vd(e,t){return Ld(await _(l(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Hd(e,t){let n=await _(l(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return Xt(),Ld(n,`Could not install connector.`).instance}async function Ud(e){await _(l(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),Xt()}async function Wd(e){return Ld(await _(l(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}var Gd=Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Tt),Kd=Y(Gd,`min-h-28 font-mono`);function qd(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 Jd(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 Yd(e,t){return t.some(t=>t.connectorId===e.id)}function Xd(e){let t=(0,Q.c)(32),{connector:n,installed:r,onInstall:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)(H,{className:`size-5`,"aria-hidden":!0})}),t[0]=a):a=t[0];let o;t[1]===n.displayName?o=t[2]:(o=(0,$.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,$.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,$.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,$.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,$.jsxs)(`div`,{className:`flex min-w-0 gap-3`,children:[a,(0,$.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 m;t[16]===r?m=t[17]:(m=r?(0,$.jsx)(p,{className:`size-4`}):(0,$.jsx)(ct,{className:`size-4`}),t[16]=r,t[17]=m);let h=r?`Installed`:`Install`,g;t[18]!==r||t[19]!==h||t[20]!==d||t[21]!==f||t[22]!==m?(g=(0,$.jsxs)(X,{variant:d,disabled:r,onClick:f,children:[m,h]}),t[18]=r,t[19]=h,t[20]=d,t[21]=f,t[22]=m,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==u?(_=(0,$.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,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:n.tags.map(Zd)}):null,t[27]=n.tags,t[28]=v);let y;return t[29]!==_||t[30]!==v?(y=(0,$.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 Zd(e){return(0,$.jsx)(`span`,{className:`rounded-full border border-edge px-2 py-0.5 text-[11px] text-fg-subtle`,children:e},e)}function Qd({draft:e,onChange:t,onClose:n,onInstalled:r}){let{connector:i}=e,a=(0,Z.useCallback)(async()=>{t({...e,installing:!0,error:null});try{let n=await Bd(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,Z.useCallback)(async()=>{if(e.oauth.flow){t({...e,installing:!0,error:null});try{await Vd(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,Z.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=qd(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let a=await Hd(i.id,{secrets:e.secrets,config:n}),o=null;try{o=await Wd(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,$.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/35 px-4 py-8`,children:(0,$.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,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h2`,{className:`text-lg font-semibold text-fg`,children:[`Install `,i.displayName]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.description})]}),(0,$.jsx)(X,{variant:`ghost`,onClick:n,children:`Close`})]}),(0,$.jsxs)(`div`,{className:`mt-5 flex flex-col gap-4`,children:[i.auth.mode===`oauth`?(0,$.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:`Connect with GitHub`}),(0,$.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,$.jsxs)(`div`,{className:`mt-3 rounded-xl bg-surface-base p-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`p`,{children:[`Open `,(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.oauth.flow.verificationUri}),` and enter this code:`]}),(0,$.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,$.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,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsxs)(X,{variant:`secondary`,disabled:e.installing,onClick:()=>void a(),children:[e.installing&&!e.oauth.flow?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(Jt,{className:`size-4`}),`Connect GitHub`]}),(0,$.jsxs)(X,{variant:`primary`,disabled:e.installing||!e.oauth.flow,onClick:()=>void o(),children:[e.installing&&e.oauth.flow?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(p,{className:`size-4`}),`I authorized GitHub`]})]})]}):null,(i.setup.secrets??[]).map(n=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,$.jsx)(Ke,{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,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,$.jsx)(`textarea`,{className:Kd,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,$.jsx)(`input`,{className:Gd,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,$.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,$.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`p`,{className:`font-medium text-fg`,children:[`Installed as `,e.result.materialized.serverId]}),e.health?(0,$.jsxs)(`p`,{className:`mt-1`,children:[e.health.toolCount,` tools discovered.`]}):(0,$.jsx)(`p`,{className:`mt-1`,children:`Installed. Tool preview can be tested from Installed.`})]}):null]}),(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(X,{variant:`secondary`,onClick:n,children:`Done`}),(0,$.jsxs)(X,{variant:`primary`,disabled:e.installing||i.auth.mode===`oauth`&&!e.oauth.connected,onClick:()=>void s(),children:[e.installing?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(ct,{className:`size-4`}),`Install`]})]})]})})}function $d({instance:e,onChanged:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),u=(0,Z.useCallback)(async()=>{r(!0),l(null);try{s(await Wd(e.instanceId)),await t()}catch(e){l(e instanceof Error?e.message:String(e))}finally{r(!1)}},[e.instanceId,t]),d=(0,Z.useCallback)(async()=>{a(!0),l(null);try{await Ud(e.instanceId),await t()}catch(e){l(e instanceof Error?e.message:String(e)),a(!1)}},[e.instanceId,t]);return(0,$.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(`span`,{className:`rounded-full border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:`catalog`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:[`MCP server: `,e.materialized.serverId]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(X,{variant:`secondary`,disabled:n,onClick:()=>void u(),children:[n?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(Jt,{className:`size-4`}),`Test`]}),(0,$.jsxs)(X,{variant:`ghost`,disabled:i,onClick:()=>void d(),children:[i?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(en,{className:`size-4`}),`Remove`]})]})]}),c?(0,$.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,$.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[o.toolCount,` tools discovered.`]}):null]})}function ef({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),p=Id(e),m=(0,Z.useCallback)(async()=>{o(!0),f(null);try{u((await yd(e.id.trim())).toolCount)}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),h=(0,Z.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,$.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,$.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,$.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,$.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-fg-subtle`,title:p,children:p}):null]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(X,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(Jt,{className:`size-4`}),t.testConnection]}),(0,$.jsxs)(X,{variant:`secondary`,onClick:r,children:[(0,$.jsx)(Ft,{className:`size-4`}),n.editCustomServer]}),(0,$.jsxs)(X,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(en,{className:`size-4`}),t.removeServer]})]})]}),d?(0,$.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,$.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[l,` tools discovered.`]})]})}function tf(){let e=s(a(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=g(e=>e.token),i=!!r,[o,c]=(0,Z.useState)(`installed`),[l,u]=(0,Z.useState)({catalog:[],instances:[],loading:!0,error:null}),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,_]=(0,Z.useState)(void 0),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),{data:S,mutate:C}=rt(i),w=S?.payload?.config,T=(0,Z.useMemo)(()=>w===void 0?null:hd(w),[w]),E=T?.servers??[];(0,Z.useEffect)(()=>{T&&_(T.sessionIdleTtlMinutes)},[T]);let D=(0,Z.useCallback)(async()=>{if(!r){u({catalog:[],instances:[],loading:!1,error:null});return}u(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Rd(),zd()]);u({catalog:e,instances:t,loading:!1,error:null})}catch(e){u({catalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,Z.useEffect)(()=>{D()},[D]);let O=(0,Z.useMemo)(()=>new Set(l.instances.map(e=>e.connectorId)),[l.instances]),k=(0,Z.useMemo)(()=>new Set(l.instances.map(e=>e.materialized.serverId)),[l.instances]),A=(0,Z.useCallback)(async e=>{if(!T||w===void 0)return;let t=E.filter(t=>t.clientKey!==e.clientKey);await _d({sessionIdleTtlMinutes:T.sessionIdleTtlMinutes,servers:t},ld(w)),await C(),await D()},[w,E,D,T,C]),j=(0,Z.useCallback)(async()=>{if(!(!T||w===void 0||v)){y(!0),x(!1);try{await _d({sessionIdleTtlMinutes:h,servers:E},ld(w)),await C(),x(!0)}finally{y(!1)}}},[w,E,T,C,h,v]),M=l.instances.length+E.length;return(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-5 px-4 py-8`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.subtitle})]}),i?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`installed`,`discover`].map(e=>(0,$.jsx)(X,{variant:o===e?`primary`:`secondary`,onClick:()=>c(e),children:e===`installed`?t.tabInstalled:t.tabDiscover},e))}),l.loading&&i?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(J,{className:`size-4 animate-spin`}),t.loading]}):null,l.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:l.error}):null,o===`installed`&&i?(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Cn,{icon:$e,title:n.globalTitle,subtitle:n.globalHint}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-end`,children:[(0,$.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.idleTtlLabel}),(0,$.jsx)(`input`,{type:`number`,min:0,className:Gd,value:h??``,placeholder:n.idleTtlPlaceholder,onChange:e=>{let t=e.target.value.trim();_(t===``?void 0:Number.parseInt(t,10)),x(!1)}}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.idleTtlHint})]}),(0,$.jsxs)(X,{variant:`secondary`,disabled:v,onClick:()=>void j(),children:[v?(0,$.jsx)(J,{className:`size-4 animate-spin`}):null,n.save]})]}),b?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.saved}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.installedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.installedHint})]}),(0,$.jsxs)(X,{variant:`primary`,onClick:()=>m({mode:`add`,row:Sd(E,k)}),children:[(0,$.jsx)(Ut,{className:`size-4`}),t.addCustomServer]})]}),M===0?(0,$.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.installedEmpty}):(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[l.instances.map(e=>(0,$.jsx)($d,{instance:e,onChanged:D},e.instanceId)),E.map(e=>(0,$.jsx)(ef,{row:e,t:n,cs:t,onEdit:()=>m({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>A(e)},e.clientKey))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,o===`discover`&&i?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.catalogHint}),l.catalog.map(e=>(0,$.jsx)(Xd,{connector:e,installed:O.has(e.id)||Yd(e,l.instances),onInstall:e=>f(Jd(e))},e.id))]}):null,d?(0,$.jsx)(Qd,{draft:d,onChange:f,onClose:()=>f(null),onInstalled:async()=>{await D(),await C(),f(null),c(`installed`)}}):null,p?(0,$.jsx)(Fd,{open:!0,mode:p.mode,initialRow:p.row,existingCustomServers:E,sessionIdleTtlMinutes:h,config:w,managedServerIds:k,t:n,cs:t,onClose:()=>m(null),onSaved:async()=>{await C(),await D(),c(`installed`)}},`${p.mode}-${p.row.clientKey}`):null]})}var nf=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`app-management`,`agent-defaults`,`agent-browser`,`connectors`,`credentials`,`gateway`,`heartbeat`,`tunnel`,`remote-access`,`shares`,`goals`,`dreams`];function rf(){let e=(0,Q.c)(32),{section:t}=xe(),n=a(af),r,i,o,c,l;if(e[0]!==n||e[1]!==t){l=Symbol.for(`react.early_return_sentinel`);bb0:{let a=s(n);if(t===`agent`||t===`agents`){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ue,{to:`/agents`,replace:!0}),e[7]=t):t=e[7],l=t;break bb0}if(!t||!nf.includes(t)){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ue,{to:`/settings/overview`,replace:!0}),e[8]=t):t=e[8],l=t;break bb0}if(t===`tunnel`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ue,{to:`/settings/remote-access`,replace:!0}),e[9]=t):t=e[9],l=t;break bb0}let u=t;if(u===`overview`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Cr,{}),e[10]=t):t=e[10],l=t;break bb0}let d=a.settingsSections[u];if(u===`agent-defaults`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Wn,{}),e[11]=t):t=e[11],l=t;break bb0}if(u===`agent-browser`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(zn,{}),e[12]=t):t=e[12],l=t;break bb0}if(u===`connectors`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(tf,{}),e[13]=t):t=e[13],l=t;break bb0}if(u===`appearance`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(lo,{}),e[14]=t):t=e[14],l=t;break bb0}if(u===`keyboard-shortcuts`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(vo,{}),e[15]=t):t=e[15],l=t;break bb0}if(u===`system`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(rd,{}),e[16]=t):t=e[16],l=t;break bb0}if(u===`app-management`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Hu,{}),e[17]=t):t=e[17],l=t;break bb0}if(u===`credentials`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ga,{}),e[18]=t):t=e[18],l=t;break bb0}if(u===`gateway`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(tc,{}),e[19]=t):t=e[19],l=t;break bb0}if(u===`heartbeat`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Sc,{}),e[20]=t):t=e[20],l=t;break bb0}if(u===`tunnel`||u===`remote-access`){let t;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ql,{}),e[21]=t):t=e[21],l=t;break bb0}if(u===`shares`){let t;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(wu,{}),e[22]=t):t=e[22],l=t;break bb0}if(u===`dreams`){let t;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(xs,{}),e[23]=t):t=e[23],l=t;break bb0}if(u===`goals`){let t;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(js,{}),e[24]=t):t=e[24],l=t;break bb0}o=`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,c=(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:d}),r=`text-sm text-fg-muted`,i=a.settingsPage.comingSoon.replace(`{{title}}`,d)}e[0]=n,e[1]=t,e[2]=r,e[3]=i,e[4]=o,e[5]=c,e[6]=l}else r=e[2],i=e[3],o=e[4],c=e[5],l=e[6];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u;e[25]!==r||e[26]!==i?(u=(0,$.jsx)(`p`,{className:r,children:i}),e[25]=r,e[26]=i,e[27]=u):u=e[27];let d;return e[28]!==o||e[29]!==c||e[30]!==u?(d=(0,$.jsxs)(`div`,{className:o,children:[c,u]}),e[28]=o,e[29]=c,e[30]=u,e[31]=d):d=e[31],d}function af(e){return e.language}export{rf as SettingsPage};
|