@xopcai/xopc 0.0.115 → 0.0.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/README.zh-CN.md +5 -4
- 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/adapters/streaming-adapter.js +1 -1
- package/dist/extensions/telegram/src/inbound-processor.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/update-offset-store.js +1 -1
- 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/{agent-avatar-dicebear-DVnBfANm.js → agent-avatar-dicebear-CWM1UU5P.js} +1 -1
- package/dist/gateway/static/root/assets/agent-browser-settings-page-D1SyFYeh.js +6 -0
- package/dist/gateway/static/root/assets/agent-defaults-tabbed-page-C9YxgvuI.js +1 -0
- package/dist/gateway/static/root/assets/agents-CteVs3UO.js +71 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-yXSXY_bu.js +1 -0
- package/dist/gateway/static/root/assets/{appearance-settings-BQpPSTHD.js → appearance-settings-DjY1P_ug.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-CVQ1M8Ax.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CXu-Csep.js → archive-plugin-CytE5j-e.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BAjgOoGY.js → attachment-load-BvvrN6rF.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-BSBgB2hO.js → binary-plugins-IBWSitnj.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BpXw9TTR.js → block-editor-C-wDpsf-.js} +3 -3
- package/dist/gateway/static/root/assets/{channels-settings-BbPUpzWB.js → channels-settings-Cd3JbeQ1.js} +1 -1
- package/dist/gateway/static/root/assets/{config-api-NOoPiIYz.js → config-api-C4RAtTKW.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-MsMa5qBr.js +2 -0
- package/dist/gateway/static/root/assets/{cron-api-C9BOqAXd.js → cron-api-sJNMqB6P.js} +1 -1
- package/dist/gateway/static/root/assets/cron-page-D30CSwkn.js +3 -0
- package/dist/gateway/static/root/assets/dreaming-settings-6fCUWRQf.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-D9kgUHCc.js → extension-debug-page-BAIyjDlq.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CGyhXqzR.js → extension-page-DEhv2GpC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DL8Xquqd.js → extension-settings-page-DOuAxTDW.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-D0VXA932.js → fetch-CTsREQIe.js} +1 -1
- package/dist/gateway/static/root/assets/{format-interval-label-Be8SmgUw.js → format-interval-label-D35Bfhtx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-C-xjn__h.js → gateway-config-api-C6989a-W.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-BpF26t91.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DERUH61L.js → gateway-startup-retry-C1KAHrd2.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DOjhmRyf.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-BPmqWk90.js → goals-config-api-KnLGpu6h.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-Xl9_wrFc.js +2 -0
- package/dist/gateway/static/root/assets/goals-settings-DtPtqZi8.js +1 -0
- package/dist/gateway/static/root/assets/{heartbeat-config-api-Bfdzr8oV.js → heartbeat-config-api-uKw1f0IG.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DN9vEj9P.js +1 -0
- package/dist/gateway/static/root/assets/index-C8ytlAF2.js +122 -0
- package/dist/gateway/static/root/assets/index-CVpJW2NS.css +1 -0
- package/dist/gateway/static/root/assets/{interval-presets-utKbuCRY.js → interval-presets-Dq0FXJ65.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CjqS6c6V.js → keyboard-shortcuts-settings-C9_t4m7t.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-SNkWzidV.js +2 -0
- package/dist/gateway/static/root/assets/{markdown-split-DW8C47iB.js → markdown-split-Ca87W8-h.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-D6HwDhDT.js → media-plugins-BAcUjPRJ.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BqzIDrlr.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-BO4o-GmO.js +2 -0
- package/dist/gateway/static/root/assets/note-detail-page-DLV_XDmT.js +2 -0
- package/dist/gateway/static/root/assets/{note-image-lightbox-pJM35Pz5.js → note-image-lightbox-hnSX5SSn.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-ycsDlkFA.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CVwHuyN6.js → preview-open-alternatives-CNgM20H5.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DQpnE8K9.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-Ba-UEk7x.js → save-bar-controls-CcdjGcfT.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-CNN9595U.js → schedule-field-CYr39z76.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DnNMmtD5.js → schema-form-BRAJgZQ2.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BZui7iAY.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DEfzZ1ax.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-CmOz80i5.js → settings-collapsible-section-BhzjeGWi.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-BmK7JJOV.js → settings-form-section-Cz3Pcr9b.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-CLuSsu1-.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-Cq4qpXLi.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-Dp2qGrHC.js → share-preview-page-DL4y9K5e.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-B9F3HyYQ.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-Bp9UPPwm.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-BIoBsfSV.js +2 -0
- package/dist/gateway/static/root/assets/system-settings-panel-FD2jxRZ3.js +1 -0
- package/dist/gateway/static/root/assets/use-agent-defaults-form-Cz2_pPzu.js +1 -0
- package/dist/gateway/static/root/assets/{use-channel-catalog-CHlO8J9G.js → use-channel-catalog-BInPrfR5.js} +1 -1
- package/dist/gateway/static/root/assets/{use-settings-tab-guard-CW5JORnl.js → use-settings-tab-guard-nuHMmZQv.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-BUIrKb8s.js +1 -0
- package/dist/gateway/static/root/assets/{voice-player-store-DDDWYHvg.js → voice-player-store-1U3vFppm.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-qE3SexnO.js +18 -0
- package/dist/gateway/static/root/index.html +5 -5
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +6 -6
- package/dist/src/agent/agent-scope.js +1 -1
- package/dist/src/agent/bootstrap/load-bootstrap-files.js +1 -1
- package/dist/src/agent/bootstrap/project-agents-context.js +1 -1
- package/dist/src/agent/context/workspace-seed.js +2 -2
- package/dist/src/agent/context/workspace-state.js +1 -1
- package/dist/src/agent/context/workspace.js +1 -1
- package/dist/src/agent/goals/checklist-judge.d.ts +1 -0
- package/dist/src/agent/goals/checklist-judge.js +1 -1
- package/dist/src/agent/goals/checklist-judge.js.map +1 -1
- package/dist/src/agent/goals/evaluate-turn.d.ts +1 -0
- package/dist/src/agent/goals/evaluate-turn.js +1 -0
- package/dist/src/agent/goals/evaluate-turn.js.map +1 -1
- package/dist/src/agent/goals/goal-locale.js +2 -2
- package/dist/src/agent/goals/post-turn.js +11 -4
- package/dist/src/agent/goals/post-turn.js.map +1 -1
- package/dist/src/agent/image/load-image-media.js +2 -2
- package/dist/src/agent/image/understanding/pi-ai-provider.js +5 -2
- package/dist/src/agent/image/understanding/pi-ai-provider.js.map +1 -1
- package/dist/src/agent/image/understanding/provider-registry.d.ts +1 -0
- package/dist/src/agent/image/understanding/provider-registry.js +16 -2
- package/dist/src/agent/image/understanding/provider-registry.js.map +1 -1
- package/dist/src/agent/ipc/inbox.js +3 -3
- 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 +1 -1
- 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/memory-flush.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.js +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.js +4 -4
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/config.js +2 -2
- package/dist/src/agent/skills/filesystem-watcher.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 +2 -2
- package/dist/src/agent/skills/index.js +2 -2
- package/dist/src/agent/skills/installer.js +2 -2
- package/dist/src/agent/skills/managed-store.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/skills/skill-view-path.js +1 -1
- package/dist/src/agent/skills/test-framework.js +1 -1
- package/dist/src/agent/starter-agents.js +1 -1
- package/dist/src/agent/tools/composio-tool.d.ts +8 -0
- package/dist/src/agent/tools/composio-tool.js +46 -0
- package/dist/src/agent/tools/composio-tool.js.map +1 -0
- package/dist/src/agent/tools/dreaming-tool.js +1 -1
- package/dist/src/agent/tools/factory.js +13 -8
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/find.js +1 -1
- package/dist/src/agent/tools/grep.js +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +1 -1
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -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/workflow/builtins/audit-repo.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/audit-repo.js +15 -2
- package/dist/src/agent/workflow/builtins/audit-repo.js.map +1 -1
- package/dist/src/agent/workflow/builtins/client-proposal.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/client-proposal.js +10 -1
- package/dist/src/agent/workflow/builtins/client-proposal.js.map +1 -1
- package/dist/src/agent/workflow/builtins/competitor-scan.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/competitor-scan.js +16 -2
- package/dist/src/agent/workflow/builtins/competitor-scan.js.map +1 -1
- package/dist/src/agent/workflow/builtins/content-draft.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/content-draft.js +15 -2
- package/dist/src/agent/workflow/builtins/content-draft.js.map +1 -1
- package/dist/src/agent/workflow/builtins/content-repurpose.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/content-repurpose.js +10 -1
- package/dist/src/agent/workflow/builtins/content-repurpose.js.map +1 -1
- package/dist/src/agent/workflow/builtins/debug-incident.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/debug-incident.js +9 -1
- package/dist/src/agent/workflow/builtins/debug-incident.js.map +1 -1
- package/dist/src/agent/workflow/builtins/decision-compare.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/decision-compare.js +16 -2
- package/dist/src/agent/workflow/builtins/decision-compare.js.map +1 -1
- package/dist/src/agent/workflow/builtins/implementation-plan.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/implementation-plan.js +11 -1
- package/dist/src/agent/workflow/builtins/implementation-plan.js.map +1 -1
- package/dist/src/agent/workflow/builtins/inbox-triage.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/inbox-triage.js +11 -1
- package/dist/src/agent/workflow/builtins/inbox-triage.js.map +1 -1
- package/dist/src/agent/workflow/builtins/meeting-prep.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/meeting-prep.js +9 -1
- package/dist/src/agent/workflow/builtins/meeting-prep.js.map +1 -1
- package/dist/src/agent/workflow/builtins/multi-perspective-review.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/multi-perspective-review.js +9 -1
- package/dist/src/agent/workflow/builtins/multi-perspective-review.js.map +1 -1
- package/dist/src/agent/workflow/builtins/offer-design.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/offer-design.js +10 -1
- package/dist/src/agent/workflow/builtins/offer-design.js.map +1 -1
- package/dist/src/agent/workflow/builtins/pr-review.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/pr-review.js +9 -1
- package/dist/src/agent/workflow/builtins/pr-review.js.map +1 -1
- package/dist/src/agent/workflow/builtins/release-check.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/release-check.js +10 -1
- package/dist/src/agent/workflow/builtins/release-check.js.map +1 -1
- package/dist/src/agent/workflow/builtins/research.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/research.js +16 -2
- package/dist/src/agent/workflow/builtins/research.js.map +1 -1
- package/dist/src/agent/workflow/builtins/weekly-review.d.ts +1 -1
- package/dist/src/agent/workflow/builtins/weekly-review.js +9 -1
- package/dist/src/agent/workflow/builtins/weekly-review.js.map +1 -1
- package/dist/src/agent/workflow/catalog.js +1 -1
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/profiles/store.js +2 -2
- 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/pipeline/source.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +4 -4
- package/dist/src/browser/providers/cloakbrowser.js +5 -5
- package/dist/src/browser/providers/playwright-doctor.js +1 -1
- package/dist/src/browser/stealth.js +1 -1
- package/dist/src/channels/catalog/channel-catalog-service.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/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/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +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-create.js +1 -1
- package/dist/src/cli/commands/extension-dev.js +2 -2
- package/dist/src/cli/commands/extension-marketplace.js +2 -2
- package/dist/src/cli/commands/extension-pack.js +2 -2
- package/dist/src/cli/commands/extension.js +3 -3
- 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 +2 -2
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/skills-test.js +1 -1
- package/dist/src/cli/templates.js +1 -1
- package/dist/src/cli/utils/gateway-client.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +2 -2
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/agent-typed-models.js +1 -1
- package/dist/src/config/gateway-bind.js +1 -1
- package/dist/src/config/index.js +8 -8
- package/dist/src/config/loader.js +4 -4
- package/dist/src/config/models-json.js +2 -2
- package/dist/src/config/paths-state.js +1 -1
- package/dist/src/config/paths.js +1 -1
- package/dist/src/config/profile.js +1 -1
- package/dist/src/config/reload.js +1 -1
- package/dist/src/config/schema.d.ts +7 -0
- package/dist/src/config/schema.js +5 -3
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/config/workspace-path.js +1 -1
- package/dist/src/connectors/composio-triggers.d.ts +10 -0
- package/dist/src/connectors/composio-triggers.js +32 -0
- package/dist/src/connectors/composio-triggers.js.map +1 -0
- package/dist/src/connectors/composio.d.ts +54 -0
- package/dist/src/connectors/composio.js +334 -0
- package/dist/src/connectors/composio.js.map +1 -0
- package/dist/src/connectors/health.js +16 -1
- package/dist/src/connectors/health.js.map +1 -1
- package/dist/src/connectors/install.d.ts +2 -1
- package/dist/src/connectors/install.js +50 -13
- package/dist/src/connectors/install.js.map +1 -1
- package/dist/src/connectors/instances.js +57 -6
- package/dist/src/connectors/instances.js.map +1 -1
- package/dist/src/connectors/lifecycle.d.ts +3 -0
- package/dist/src/connectors/lifecycle.js +23 -0
- package/dist/src/connectors/lifecycle.js.map +1 -0
- package/dist/src/connectors/materialize.js +2 -1
- package/dist/src/connectors/materialize.js.map +1 -1
- package/dist/src/connectors/providers.d.ts +1 -0
- package/dist/src/connectors/providers.js +10 -2
- package/dist/src/connectors/providers.js.map +1 -1
- package/dist/src/connectors/registries/modelscope.d.ts +2 -0
- package/dist/src/connectors/registries/modelscope.js +205 -0
- package/dist/src/connectors/registries/modelscope.js.map +1 -0
- package/dist/src/connectors/registries/official-mcp.d.ts +2 -0
- package/dist/src/connectors/registries/official-mcp.js +142 -0
- package/dist/src/connectors/registries/official-mcp.js.map +1 -0
- package/dist/src/connectors/registries/search.d.ts +12 -0
- package/dist/src/connectors/registries/search.js +89 -0
- package/dist/src/connectors/registries/search.js.map +1 -0
- package/dist/src/connectors/registries/smithery.d.ts +2 -0
- package/dist/src/connectors/registries/smithery.js +98 -0
- package/dist/src/connectors/registries/smithery.js.map +1 -0
- package/dist/src/connectors/registries/types.d.ts +20 -0
- package/dist/src/connectors/registries/types.js +1 -0
- package/dist/src/connectors/secret-store.js +4 -2
- package/dist/src/connectors/secret-store.js.map +1 -1
- package/dist/src/connectors/setup-secrets.d.ts +15 -0
- package/dist/src/connectors/setup-secrets.js +64 -0
- package/dist/src/connectors/setup-secrets.js.map +1 -0
- package/dist/src/connectors/supervisor.d.ts +15 -0
- package/dist/src/connectors/supervisor.js +73 -0
- package/dist/src/connectors/supervisor.js.map +1 -0
- package/dist/src/connectors/types.d.ts +27 -3
- package/dist/src/connectors/usage.js +6 -1
- package/dist/src/connectors/usage.js.map +1 -1
- package/dist/src/cron/executor.js +1 -1
- package/dist/src/cron/service.js +1 -1
- 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 +2 -2
- package/dist/src/extensions/health.js +1 -1
- package/dist/src/extensions/install.js +2 -2
- package/dist/src/extensions/loader.js +2 -2
- package/dist/src/extensions/lockfile.js +3 -3
- package/dist/src/extensions/security.js +1 -1
- package/dist/src/extensions/update.js +2 -2
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/file-path-classifier.js +2 -2
- 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/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/connectors.js +230 -3
- package/dist/src/gateway/hono/routes/connectors.js.map +1 -1
- package/dist/src/gateway/hono/routes/dreaming.js +1 -1
- package/dist/src/gateway/hono/routes/goals.js +52 -5
- package/dist/src/gateway/hono/routes/goals.js.map +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/voice.js +14 -1
- package/dist/src/gateway/hono/routes/voice.js.map +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +2 -2
- package/dist/src/gateway/hono/sse.js.map +1 -1
- package/dist/src/gateway/lock.js +3 -3
- package/dist/src/gateway/ports.js +1 -1
- package/dist/src/gateway/service/agent-runner.d.ts +5 -12
- package/dist/src/gateway/service/agent-runner.js +8 -8
- package/dist/src/gateway/service/agent-runner.js.map +1 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/marketplace-service.js +2 -2
- package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -10
- package/dist/src/gateway/service/run-gateway-agent.js.map +1 -1
- package/dist/src/gateway/service.d.ts +1 -1
- package/dist/src/gateway/service.js +13 -8
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/gateway/user-turn-input.d.ts +18 -0
- package/dist/src/gateway/user-turn-input.js +16 -0
- package/dist/src/gateway/user-turn-input.js.map +1 -0
- package/dist/src/gateway/workspace-fs-file-list.js +1 -1
- package/dist/src/goals/goal-queue-store.d.ts +2 -1
- package/dist/src/goals/goal-queue-store.js +2 -2
- package/dist/src/goals/goal-queue-store.js.map +1 -1
- package/dist/src/goals/goal-queue-types.d.ts +4 -3
- package/dist/src/goals/goal-runner.js +25 -3
- package/dist/src/goals/goal-runner.js.map +1 -1
- package/dist/src/goals/goal-service.d.ts +6 -1
- package/dist/src/goals/goal-service.js +9 -2
- package/dist/src/goals/goal-service.js.map +1 -1
- package/dist/src/goals/goal-store.d.ts +7 -1
- package/dist/src/goals/goal-store.js +42 -0
- package/dist/src/goals/goal-store.js.map +1 -1
- package/dist/src/goals/goal-workflow-judge.js +2 -2
- package/dist/src/goals/types.d.ts +10 -0
- package/dist/src/i18n/goals-bundle.js +1 -1
- package/dist/src/i18n/index.js +1 -1
- package/dist/src/i18n/share-tool-bundle.js +2 -2
- package/dist/src/infra/brew.js +1 -1
- 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 +1 -1
- package/dist/src/infra/stable-node-path.js +1 -1
- 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 +2 -2
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/infra/write-file-atomic.js +2 -2
- package/dist/src/media/store.js +1 -1
- package/dist/src/notes/agent-context.js +1 -1
- package/dist/src/notes/service.js +1 -1
- package/dist/src/notes/store.js +2 -2
- package/dist/src/project-trust/trust-store.js +2 -2
- package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
- package/dist/src/providers/index.js +1 -1
- package/dist/src/providers/model-registry.js +4 -4
- package/dist/src/session/init-session-turn.js +1 -1
- package/dist/src/session/resolve-session.js +1 -1
- package/dist/src/session/session-title.js +2 -2
- package/dist/src/session/store.js +1 -1
- 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/connection.js +1 -1
- package/dist/src/storage/sqlite/memory-index-repository.js +2 -2
- package/dist/src/storage/sqlite/migrations/011_goal_context_messages.sql +8 -0
- package/dist/src/storage/sqlite/migrations/discover.js +1 -1
- package/dist/src/storage/sqlite/migrations/runner.d.ts +2 -2
- package/dist/src/storage/sqlite/migrations/runner.js +5 -5
- package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +2 -2
- package/dist/src/storage/sqlite/schema.js +4 -4
- package/dist/src/storage/sqlite/schema.sql +9 -0
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/clipboard-image.js +3 -3
- package/dist/src/tui/extension-host/load-extensions.js +1 -1
- package/dist/src/tui/theme-manager.js +1 -1
- package/dist/src/tui/tui-command-formatters.js +4 -4
- package/dist/src/tui/tui-commands.js +2 -2
- 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-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +6 -6
- package/dist/src/tunnel/frpc-binary.js +4 -4
- 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/utils/logger/streams.js +1 -1
- package/dist/src/voice/tts/audio.js +1 -1
- package/dist/src/voice/tts/openai-compatible-speech.d.ts +1 -1
- package/dist/src/voice/tts/openai-compatible-speech.js.map +1 -1
- package/dist/src/voice/tts/providers/edge-speech.js +15 -3
- package/dist/src/voice/tts/providers/edge-speech.js.map +1 -1
- package/dist/src/voice/tts/speak-core.js +3 -3
- package/dist/src/voice/tts/speak-core.js.map +1 -1
- package/dist/src/voice/tts/speech-provider-types.d.ts +2 -2
- package/dist/src/voice/tts/types.js +1 -1
- package/dist/src/voice/tts/types.js.map +1 -1
- package/dist/src/workflows/domain/result.d.ts +0 -1
- package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
- package/dist/src/workflows/engine/workflow-engine.js +7 -23
- package/dist/src/workflows/engine/workflow-engine.js.map +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +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 +2 -2
- package/dist/gateway/static/root/assets/agent-browser-settings-page-DPXc4hz8.js +0 -6
- package/dist/gateway/static/root/assets/agent-defaults-tabbed-page-CTJ0YnRQ.js +0 -1
- package/dist/gateway/static/root/assets/agents-zJXQfJ_W.js +0 -71
- package/dist/gateway/static/root/assets/app-management-settings-panel-DzGbdr04.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-CPjfyzSD.js +0 -1
- package/dist/gateway/static/root/assets/connectors-settings-CAXYMOdp.js +0 -2
- package/dist/gateway/static/root/assets/cron-page-DuUbBeKI.js +0 -3
- package/dist/gateway/static/root/assets/dreaming-settings-DQ4DtiK1.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-BMPwIjKI.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-BJsyjJnF.js +0 -1
- package/dist/gateway/static/root/assets/goals-page-BerDgIhw.js +0 -2
- package/dist/gateway/static/root/assets/goals-settings-ByTjeAto.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-TbHgcjTn.js +0 -1
- package/dist/gateway/static/root/assets/index-AkTrf6Pb.js +0 -122
- package/dist/gateway/static/root/assets/index-fh5sXTj9.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-DGXuPf5B.js +0 -2
- package/dist/gateway/static/root/assets/messages-upgxw6Ub.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-Bot16nn7.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-page-Brlyou8M.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-DvZ4pwc-.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BZEDmxbZ.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DdGGlsfn.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DlkEkPf9.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-DFPTrsPF.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CYCCfgh4.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-Bff1pGd0.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CJGKpBur.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-C6ocduTD.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-5jrIEr5b.js +0 -1
- package/dist/gateway/static/root/assets/use-agent-defaults-form-BuiXLIs5.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-DDoQyghO.js +0 -1
- package/dist/gateway/static/root/assets/workflow-page.utils-CKjeEGqx.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-B604ehHG.js +0 -18
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-BqzIDrlr.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l,t as u}from"./fetch-CTsREQIe.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{Cs as p,Ct as m,Di as h,Fa as g,Fn as _,Ga as v,Gi as y,Hi as b,In as x,Ka as S,Ki as C,Kr as w,Ks as T,Lo as E,Mi as D,Ns as O,Oa as k,Pi as A,Pn as j,Qi as M,Ri as N,Rr as P,St as F,Tt as I,Ui as L,Vi as R,Vs as z,Wa as B,Wi as V,Xa as H,Yi as ee,_i as te,_t as ne,ao as re,bi as ie,bs as U,bt as ae,di as oe,do as W,fi as se,ft as ce,gi as G,gs as K,hi as le,ht as ue,ja as q,ji as de,ka as fe,ko as J,lo as pe,mi as me,mt as he,nt as ge,oa as _e,ot as ve,pt as ye,qi as Y,qo as be,rt as xe,s as Se,tt as Ce,va as we,vi as Te,vt as Ee,wt as De,xi as Oe,xt as ke,yi as Ae,ys as je,yt as Me,zi as X,zr as Ne}from"./index-C8ytlAF2.js";import{a as Pe,c as Fe,d as Ie,f as Le,l as Re,n as ze,o as Be,r as Ve,s as He,t as Ue,u as We}from"./voice-api-key-field-BUIrKb8s.js";import{t as Ge}from"./settings-advanced-gate-DEfzZ1ax.js";import{t as Ke}from"./settings-collapsible-section-BhzjeGWi.js";import{n as qe,t as Je}from"./settings-form-section-Cz3Pcr9b.js";import{i as Ye,l as Xe,r as Ze,t as Qe}from"./config-api-C4RAtTKW.js";import{n as $e,t as et}from"./save-bar-controls-CcdjGcfT.js";var Z=n(),Q=e(t(),1),$=r();async function tt(){let e=await u(c(`/api/image/providers`));if(!e.ok)throw Error(`Image providers: HTTP ${e.status}`);return(await e.json()).payload?.providers??[]}function nt(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 rt(e,t){let n=nt(e.filter(e=>e.configured===!0));return!t||n.includes(t)?n:[t,...n]}function it(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 at=`image-generation-providers`;function ot(e){let t=(0,Z.c)(80),{value:n,disabled:r,placeholder:a,searchPlaceholder:o,noMatches:s,registryEmptyHint:c,outOfFilterNote:l,className:u,onChange:d}=e,[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(``),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},t[0]=v):v=t[0];let{data:y,isLoading:S,error:C}=f(at,tt,v),w;t[1]===n?w=t[2]:(w=n.trim(),t[1]=n,t[2]=w);let T=w,E;t[3]===y?E=t[4]:(E=nt((y??[]).filter(lt)),t[3]=y,t[4]=E);let D=E,O;t[5]===y?O=t[6]:(O=y??[],t[5]=y,t[6]=O);let k;t[7]!==O||t[8]!==T?(k=rt(O,T),t[7]=O,t[8]=T,t[9]=k):k=t[9];let A=k,j;t[10]!==A||t[11]!==g?(j=it(A,g),t[10]=A,t[11]=g,t[12]=j):j=t[12];let M=j,N;t[13]!==D||t[14]!==l||t[15]!==T?(N=!!l&&!!T&&!D.includes(T),t[13]=D,t[14]=l,t[15]=T,t[16]=N):N=t[16];let P=N,F;t[17]!==a||t[18]!==n?(F=n.trim()?n:a,t[17]=a,t[18]=n,t[19]=F):F=t[19];let I=F,L;t[20]!==a||t[21]!==n?(L=n.trim()||a,t[20]=a,t[21]=n,t[22]=L):L=t[22];let z=L,B;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{h(e),e||_(``)},t[23]=B):B=t[23];let H=B,ee=r||S,te=S?`…`:z,ne;t[24]===u?ne=t[25]:(ne=i(R,`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`,X.transition,X.press,`hover:border-edge hover:bg-surface-hover/45`,V,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,u),t[24]=u,t[25]=ne);let re=S?`…`:I,U;t[26]===re?U=t[27]:(U=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:re}),t[26]=re,t[27]=U);let ae;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(je,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[28]=ae):ae=t[28];let oe;t[29]!==m||t[30]!==ee||t[31]!==te||t[32]!==ne||t[33]!==U?(oe=(0,$.jsx)(Oe,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,disabled:ee,title:te,className:ne,"aria-haspopup":`listbox`,"aria-expanded":m,children:[U,ae]})}),t[29]=m,t[30]=ee,t[31]=te,t[32]=ne,t[33]=U,t[34]=oe):oe=t[34];let W;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(W=i(`w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,x),t[35]=W):W=t[35];let se;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(se=i(`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`,b),t[36]=se):se=t[36];let ce;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>_(e.target.value),t[37]=ce):ce=t[37];let G;t[38]!==g||t[39]!==o?(G=(0,$.jsx)(`input`,{type:`search`,className:se,placeholder:o,value:g,onChange:ce,onKeyDown:st}),t[38]=g,t[39]=o,t[40]=G):G=t[40];let K;t[41]===C?K=t[42]:(K=C?(0,$.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:C instanceof Error?C.message:`Failed to load image providers`}):null,t[41]=C,t[42]=K);let le;t[43]!==A||t[44]!==C||t[45]!==S||t[46]!==s||t[47]!==c?(le=!C&&A.length===0&&!S?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:c??s}):null,t[43]=A,t[44]=C,t[45]=S,t[46]=s,t[47]=c,t[48]=le):le=t[48];let ue;t[49]!==A||t[50]!==C||t[51]!==M.length||t[52]!==s?(ue=!C&&A.length>0&&M.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:s}):null,t[49]=A,t[50]=C,t[51]=M.length,t[52]=s,t[53]=ue):ue=t[53];let q;if(t[54]!==M||t[55]!==d||t[56]!==n){let e;t[58]!==d||t[59]!==n?(e=e=>(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e===n,className:i(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,X.press,e===n&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{d(e),h(!1),_(``)},children:[(0,$.jsx)(p,{className:i(`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]=d,t[59]=n,t[60]=e):e=t[60],q=M.map(e),t[54]=M,t[55]=d,t[56]=n,t[57]=q}else q=t[57];let de;t[61]!==o||t[62]!==K||t[63]!==le||t[64]!==ue||t[65]!==q?(de=(0,$.jsxs)(`div`,{className:`max-h-60 overflow-auto`,role:`listbox`,"aria-label":o,children:[K,le,ue,q]}),t[61]=o,t[62]=K,t[63]=le,t[64]=ue,t[65]=q,t[66]=de):de=t[66];let fe;t[67]!==G||t[68]!==de?(fe=(0,$.jsx)(Ae,{children:(0,$.jsxs)(Te,{className:W,side:`bottom`,sideOffset:4,align:`end`,onOpenAutoFocus:ct,children:[G,de]})}),t[67]=G,t[68]=de,t[69]=fe):fe=t[69];let J;t[70]!==m||t[71]!==oe||t[72]!==fe?(J=(0,$.jsxs)(ie,{open:m,onOpenChange:H,modal:!1,children:[oe,fe]}),t[70]=m,t[71]=oe,t[72]=fe,t[73]=J):J=t[73];let pe;t[74]!==l||t[75]!==P?(pe=P?(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400/90`,children:l}):null,t[74]=l,t[75]=P,t[76]=pe):pe=t[76];let me;return t[77]!==J||t[78]!==pe?(me=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[J,pe]}),t[77]=J,t[78]=pe,t[79]=me):me=t[79],me}function st(e){return e.stopPropagation()}function ct(e){return e.preventDefault()}function lt(e){return e.configured===!0}function ut(e,t,n){let r=e.trim();return r?`model:${r}`:`empty:${n.slice(0,t).filter(e=>!e.trim()).length}`}function dt(e){let t=(0,Z.c)(37),{a:n,chat:r,form:i,update:a}=e,o;t[0]!==n.cardModelsSubtitle||t[1]!==n.cardModelsTitle?(o=(0,$.jsx)(qe,{icon:J,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)(ve,{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)(Xe,{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)(ot,{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)(Xe,{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)(Je,{children:[o,p]}),t[34]=o,t[35]=p,t[36]=m):m=t[36],m}function ft(e){let t=(0,Z.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)(ve,{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)(Y,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":n.removeModelFallback,onClick:()=>a({imageModelFallbacks:i.imageModelFallbacks.filter((e,n)=>n!==t)}),children:(0,$.jsx)(_e,{className:`size-4`,strokeWidth:1.75})})]},ut(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)(B,{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)(Y,{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)(Xe,{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)(ot,{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)(Y,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":n.removeModelFallback,onClick:()=>a({imageGenerationModelFallbacks:i.imageGenerationModelFallbacks.filter((e,n)=>n!==t)}),children:(0,$.jsx)(_e,{className:`size-4`,strokeWidth:1.75})})]},ut(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)(B,{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)(Y,{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)(Xe,{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 pt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,C)}var mt=()=>c(Le);function ht(e){return{imageModel:e.imageModel,imageModelFallbacks:e.imageModelFallbacks,imageGenerationModel:e.imageGenerationModel,imageGenerationModelFallbacks:e.imageGenerationModelFallbacks,imageGenerationModelTimeoutMs:e.imageGenerationModelTimeoutMs,imageGenerationModelAutoProviderFallback:e.imageGenerationModelAutoProviderFallback}}function gt(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 _t=Ce(),vt={loading:!0,saving:!1,savedFlash:!1,error:void 0};function yt({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.imageModelsSettings,c=!!s(e=>e.token),[l,u]=(0,Q.useReducer)(_t,{form:null,baseline:null}),p=l.form,m=l.baseline,[h,_]=(0,Q.useReducer)(xe,vt),{loading:v,saving:y,error:b}=h,x=w(),S=(0,Q.useMemo)(()=>new Set(x.map(e=>e.id)),[x]),C=(0,Q.useCallback)(async()=>{if(c){_({type:`patch`,patch:{loading:!0,error:void 0}});try{let e=await Qe();u({type:`sync`,value:structuredClone(e)})}catch(e){_({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{loading:!1}})}}},[c]);(0,Q.useEffect)(()=>{C()},[C]);let T=(0,Q.useCallback)(e=>{u({type:`patch`,patch:e})},[]),{data:E=[]}=f(c?mt():null,Ie,{revalidateOnFocus:!1}),D=E.some(e=>e.configured),O=Ne(c),k=Re(E),A=(0,Q.useMemo)(()=>!p||!m?!1:JSON.stringify(ht(p))!==JSON.stringify(ht(m)),[p,m]),j=A||k.credDirty;(0,Q.useEffect)(()=>{if(!j)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[j]);let M=(0,Q.useCallback)(async()=>{if(p){_({type:`patch`,patch:{saving:!0,error:void 0}});try{try{Ze(p.paramsJson)}catch(e){_({type:`patch`,patch:{error:e instanceof SyntaxError?n.agentSettings.advanced.paramsInvalidJson:e instanceof Error?e.message:n.agentSettings.advanced.paramsInvalidJson}});return}let e=[];A&&e.push(Ye(p).then(()=>{u({type:`saved`,value:structuredClone(p)}),O.mutate?.()})),k.credDirty&&e.push(k.saveCredentials(r.credentialsSaveError)),await Promise.all(e),_({type:`patch`,patch:{savedFlash:!0}}),d({type:`success`,title:r.saved})}catch(e){_({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{_({type:`patch`,patch:{saving:!1}})}}},[p,A,O,n.agentSettings,k,r.credentialsSaveError]),N=(0,Q.useCallback)(()=>{m&&(u({type:`discard`}),k.credDirty&&k.onDiscardCredentials(),_({type:`patch`,patch:{error:void 0,savedFlash:!1}}))},[m,k]);$e({id:`image-models`,dirty:j,saving:y,save:M,discard:N});let P=(0,Q.useMemo)(()=>gt(r),[r]),F=(0,Q.useMemo)(()=>({getApiKey:n.providersSettings.getApiKey,getApiKeyIntl:n.providersSettings.getApiKeyIntl,getApiKeyCn:n.providersSettings.getApiKeyCn}),[n.providersSettings]),I=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,L=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`,R=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 c?v||!p?(0,$.jsxs)(`div`,{className:R,children:[(0,$.jsx)(W,{className:`size-4 animate-spin`}),` Loading…`]}):(0,$.jsxs)(`div`,{className:I,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)(Y,{type:`button`,variant:`secondary`,onClick:N,disabled:!j||y,children:r.discard}),(0,$.jsxs)(Y,{type:`button`,variant:`primary`,onClick:()=>void M(),disabled:!j||y,children:[y?(0,$.jsx)(W,{className:`size-3.5 animate-spin`}):(0,$.jsx)(g,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`ml-1.5`,children:y?r.saving:r.save})]})]})]}),b?(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:b}):null,(0,$.jsx)(dt,{form:p,update:T,a:n.agentSettings,chat:n.chat}),(0,$.jsx)(Ke,{advancedOnly:!0,showLabel:r.fallbackChainsTitle,hideLabel:r.fallbackChainsTitle,children:(0,$.jsx)(ft,{form:p,update:T,a:n.agentSettings,chat:n.chat})}),(0,$.jsx)(Ke,{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:i(pt(),`max-w-48`),value:p.imageGenerationModelTimeoutMs??``,placeholder:`120000`,onChange:e=>{let t=e.target.value.trim(),n=t===``?null:Math.max(0,Math.floor(Number(t)));T({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:p.imageGenerationModelAutoProviderFallback,onChange:e=>T({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)(Ke,{advancedOnly:!0,icon:fe,showLabel:r.providersTitle,hideLabel:r.providersTitle,defaultOpen:D,children:E.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.providersEmpty}):(0,$.jsx)(We,{summaries:E,credDraft:k.credDraft,credBaseline:k.credBaseline,credDirty:k.credDirty,credSaving:k.credSaving,credError:k.credError,credSavedFlash:k.credSavedFlash,credNoopFlash:k.credNoopFlash,updateCredRow:k.updateCredRow,onDiscardCredentials:k.onDiscardCredentials,onSaveCredentials:()=>void k.saveCredentials(r.credentialsSaveError),extensionIds:S,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:t,apiKeyLinkLabels:F,messages:P})})]}):(0,$.jsx)(`div`,{className:L,children:t===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var bt=L;function xt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function St(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Ct(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,C,`dark:border-edge`)}function wt(){return i(y,L)}function Tt(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Et(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}var Dt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],Ot=[{id:`whisper-1`,name:`Whisper-1`}],kt=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],At=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],jt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Mt=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],Nt=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],Pt=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],Ft=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],It=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],Lt=[{id:`piper`,command:`piper --model /path/to/voice.onnx --output_file "{{OutputPath}}"`,outputFormat:`wav`},{id:`sherpa-onnx`,command:`sherpa-onnx-offline-tts --text "{{Text}}" --output-filename "{{OutputPath}}"`,outputFormat:`wav`},{id:`mlx-audio`,command:`python -m mlx_audio.tts.generate --text "{{Text}}" --file_prefix "{{OutputBase}}"`,outputFormat:`wav`}];function Rt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function zt(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 Bt(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function Vt(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function Ht(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Ut(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 Wt(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 Gt(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 Kt({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.voiceSettings,i=!!s(e=>e.token),[l,u]=(0,Q.useReducer)(Gt,{form:null,baseline:null}),p=l.form,m=l.baseline,[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(!1),C=(0,Q.useRef)({parsed:null,models:void 0}),{data:w,error:T,isLoading:E,mutate:D}=Ne(i),{data:O,error:k,isLoading:A,mutate:j}=f(i?c(`/api/voice/models`):null,ze,{revalidateOnFocus:!1}),{data:M,error:N,isLoading:P}=f(i?c(`/api/voice/providers`):null,Ve,{revalidateOnFocus:!1}),{data:F,error:I,isLoading:L}=f(i?c(`/api/voice/stt-providers`):null,Pe,{revalidateOnFocus:!1}),R=(0,Q.useMemo)(()=>M?.providers??[],[M]),z=(0,Q.useMemo)(()=>F?.providers??[],[F]),B=(0,Q.useMemo)(()=>w?.payload?.config===void 0?null:Be(w.payload.config),[w]),V=(0,Q.useMemo)(()=>!p||!m?!1:JSON.stringify(p)!==JSON.stringify(m),[p,m]);i?B!==null&&O!==void 0&&!S.current&&(C.current.parsed!==B||C.current.models!==O)&&(C.current={parsed:B,models:O},u({type:`sync`,value:B}),_(O)):(C.current.parsed!==null||C.current.models!==void 0)&&(C.current={parsed:null,models:void 0},u({type:`reset`}),_(null),S.current=!1);let H=!!(i&&(B===null||O===void 0||M===void 0||F===void 0)&&(E||A||P||L)),ee=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,te=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),ne=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),re=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),ie=(0,Q.useCallback)(e=>{S.current=!0,u({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}}}}})},[]),U=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),ae=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),oe=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),se=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),ce=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),G=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]),K=(0,Q.useCallback)(async()=>{if(!(!p||v)){y(!0),x(null);try{await He(p),u({type:`saved`,value:p}),S.current=!1,d({type:`success`,title:r.saved})}catch(e){x(e instanceof Error?e.message:r.saveError)}finally{y(!1)}}},[p,v,r.saveError]),le=(0,Q.useCallback)(()=>{m&&(S.current=!1,u({type:`discard`}),x(null))},[m]);$e({id:`voice`,dirty:V,saving:v,save:K,discard:le});let ue=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,q=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:q,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:q,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(W,{className:`size-4 animate-spin`}),r.loading]})});if(!p||g===null)return(0,$.jsxs)(`div`,{className:q,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:b??ee??r.loadError}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>{D(),j()},children:r.retry})]});let de=p.stt,fe=p.tts,J=Ht(r);return(0,$.jsxs)(`div`,{className:ue,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:h(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)(be,{className:`size-3.5`})]})]}),e?null:(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`secondary`,disabled:!V||v,onClick:le,children:r.discard}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:!V||v,onClick:()=>void K(),children:v?r.saving:r.save})]})]}),V&&!e?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,b?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(qt,{v:r,stt:de,tts:fe}),(0,$.jsx)(Yt,{v:r,apiKeyLabels:J,stt:de,models:g,sttProviders:z,updateStt:te,updateSttAlibaba:ne,updateSttOpenai:re,updateSttFallback:ie}),(0,$.jsx)(en,{v:r,apiKeyLabels:J,tts:fe,models:g,ttsProviders:R,updateTts:U,updateTtsAlibaba:ae,updateTtsOpenai:oe,updateTtsEdge:se,updateTtsMinimax:ce,updateTtsLocalCli:G})]}),(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 qt(e){let t=(0,Z.c)(39),{v:n,stt:r,tts:i}=e,a=i.provider===`openai`?i.openai?.voice:i.provider===`alibaba`?i.alibaba?.voice:i.provider===`minimax`?i.minimax?.voice:i.provider===`edge`?i.edge?.voice:void 0,o;t[0]===n.overview.title?o=t[1]:(o=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=o);let s;t[2]===n.overview.description?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,$.jsxs)(`div`,{className:`mb-4`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(l=r.enabled?`${n.overview.ready} · ${Rt(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=l):l=t[10];let u;t[11]!==r.enabled||t[12]!==l||t[13]!==n.overview.input?(u=(0,$.jsx)(Jt,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?Bt(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=d):d=t[18];let f=i.enabled&&i.trigger!==`off`,p;t[19]!==d||t[20]!==f||t[21]!==n.overview.replies?(p=(0,$.jsx)(Jt,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${zt(i.provider,n)}${a?` · ${a}`:``}`:n.overview.off,t[23]=a,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=m):m=t[27];let h;t[28]!==m||t[29]!==i.enabled||t[30]!==n.overview.voice?(h=(0,$.jsx)(Jt,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,p,h]}),t[32]=h,t[33]=u,t[34]=p,t[35]=g):g=t[35];let _;return t[36]!==g||t[37]!==c?(_=(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[c,g]}),t[36]=g,t[37]=c,t[38]=_):_=t[38],_}function Jt(e){let t=(0,Z.c)(10),{label:n,value:r,ready:a}=e,o;t[0]===n?o=t[1]:(o=(0,$.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=o);let s=a?`text-fg`:`text-fg-muted`,c;t[2]===s?c=t[3]:(c=i(`mt-1 text-sm font-medium`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,$.jsx)(`div`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function Yt(e){let t=(0,Z.c)(46),{v:n,apiKeyLabels:r,stt:a,models:o,sttProviders:s,updateStt:c,updateSttAlibaba:l,updateSttOpenai:u,updateSttFallback:d}=e,f=o?.stt?.alibaba?.length?o.stt.alibaba:Dt,p=o?.stt?.openai?.length?o.stt.openai:Ot,m;if(t[0]!==s){let e=new Set;m=[];for(let t of s)e.has(t.id)||(e.add(t.id),m.push(t));t[0]=s,t[1]=m}else m=t[1];let h=m,g,_,v,y,b;if(t[2]!==f||t[3]!==r||t[4]!==p||t[5]!==h||t[6]!==a||t[7]!==c||t[8]!==l||t[9]!==d||t[10]!==u||t[11]!==n){let e=h.find(e=>e.id===a.provider),o=a.providers?.[a.provider],s=typeof o?.apiKey==`string`?o.apiKey:``,m=typeof o?.model==`string`?o.model:``,x={...a.provider===`alibaba`?a.alibaba??{}:{},...a.provider===`openai`?a.openai??{}:{},...o??{}},S=(e?.fields??[]).filter($t),C;t[17]!==a.provider||t[18]!==a.providers||t[19]!==c?(C=e=>{c({providers:{...a.providers??{},[a.provider]:{...a.providers?.[a.provider]??{},...e}}})},t[17]=a.provider,t[18]=a.providers,t[19]=c,t[20]=C):C=t[20];let w=C;y=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(re,{className:`size-4 text-accent`,strokeWidth:1.75}),t[21]=T):T=t[21];let E;t[22]===n.stt.title?E=t[23]:(E=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[22]=n.stt.title,t[23]=E);let D;t[24]===n.stt.description?D=t[25]:(D=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[24]=n.stt.description,t[25]=D),t[26]!==E||t[27]!==D?(b=(0,$.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[26]=E,t[27]=D,t[28]=b):b=t[28],g=`space-y-4`;let O;t[29]===c?O=t[30]:(O=e=>c({enabled:e}),t[29]=c,t[30]=O),t[31]!==a.enabled||t[32]!==O||t[33]!==n.overview.off||t[34]!==n.overview.ready||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(_=(0,$.jsx)(tn,{checked:a.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:O}),t[31]=a.enabled,t[32]=O,t[33]=n.overview.off,t[34]=n.overview.ready,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=_):_=t[37],v=a.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,bt),children:[(0,$.jsx)(an,{children:n.stt.provider}),(0,$.jsx)(`select`,{className:wt(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,$.jsxs)(`option`,{value:e.id,children:[Rt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,bt),children:[(0,$.jsx)(an,{children:n.stt.model}),a.provider===`alibaba`?(0,$.jsx)(`select`,{className:wt(),value:a.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(Qt)}):a.provider===`openai`?(0,$.jsx)(`select`,{className:wt(),value:a.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map(Zt)}):a.provider===`groq`?(0,$.jsx)(`select`,{className:wt(),value:m||kt[0].id,onChange:e=>w({model:e.target.value}),children:kt.map(Xt)}):(0,$.jsx)(`input`,{className:Ct(),value:m,onChange:e=>w({model:e.target.value}),placeholder:a.provider})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,bt),children:[(0,$.jsx)(an,{children:n.stt.apiKey}),(0,$.jsx)(Ue,{kind:`stt`,providerId:a.provider,fieldId:`voice-stt-${a.provider}-api-key`,value:a.provider===`alibaba`?a.alibaba?.apiKey??``:a.provider===`openai`?a.openai?.apiKey??``:s,onChange:e=>{a.provider===`alibaba`?l({apiKey:e}):a.provider===`openai`?u({apiKey:e}):w({apiKey:e})},labels:r,placeholder:a.provider===`groq`?`gsk_...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,xt(a.provider)?` ${xt(a.provider)}`:``]})]})]}),S.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,$.jsx)(nn,{field:e,value:Ut(x,e),onChange:t=>w({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:bt},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:a.fallback?.enabled??!0,onChange:e=>d({enabled:e.target.checked})})]})]}):null,t[2]=f,t[3]=r,t[4]=p,t[5]=h,t[6]=a,t[7]=c,t[8]=l,t[9]=d,t[10]=u,t[11]=n,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b}else g=t[12],_=t[13],v=t[14],y=t[15],b=t[16];let x;t[38]!==g||t[39]!==_||t[40]!==v?(x=(0,$.jsxs)(`div`,{className:g,children:[_,v]}),t[38]=g,t[39]=_,t[40]=v,t[41]=x):x=t[41];let S;return t[42]!==y||t[43]!==b||t[44]!==x?(S=(0,$.jsxs)(`section`,{className:y,children:[b,x]}),t[42]=y,t[43]=b,t[44]=x,t[45]=S):S=t[45],S}function Xt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Zt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Qt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function $t(e){return e.key!==`apiKey`&&e.key!==`model`}function en({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:a,updateTts:o,updateTtsAlibaba:s,updateTtsOpenai:c,updateTtsEdge:l,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:At,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:jt,m=r?.tts?.alibaba?.length?r.tts.alibaba:Mt,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:Nt,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:Pt,_=r?.tts?.minimax?.length?r.tts.minimax:Ft,v=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:It,[y,b]=(0,Q.useState)(e.tts.test.sampleText),[x,C]=(0,Q.useState)({status:`idle`}),w=(0,Q.useRef)(null),T=(0,Q.useRef)(null),E=(0,Q.useCallback)(()=>{w.current?.pause(),w.current=null,T.current&&=(URL.revokeObjectURL(T.current),null)},[]),D=(0,Q.useMemo)(()=>{let e=new Set,t=[];for(let n of a)e.has(n.id)||(e.add(n.id),t.push(n));return t},[a]),O=D.find(e=>e.id===n.provider),k=n.providers?.[n.provider],A={...n.provider===`openai`?n.openai??{}:{},...n.provider===`alibaba`?n.alibaba??{}:{},...n.provider===`edge`?n.edge??{}:{},...n.provider===`minimax`?n.minimax??{}:{},...n.provider===`tts-local-cli`?n[`tts-local-cli`]??{}:{},...k??{}},j=(O?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),N=!!O?.diagnostics.requiresApiKey,P=!!O?.configured||!N,F=n.enabled?P?`ready`:`action`:`muted`,I=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,L=n.provider===`openai`?n.openai?.voice:n.provider===`alibaba`?n.alibaba?.voice:n.provider===`minimax`?n.minimax?.voice:n.provider===`edge`?n.edge?.voice:void 0;(0,Q.useEffect)(()=>()=>E(),[E]);let R=(0,Q.useCallback)(e=>{o({provider:e}),C({status:`idle`})},[o]),z=(0,Q.useCallback)(async()=>{let t=y.trim();if(!t){C({status:`error`,message:e.tts.test.emptyText});return}E(),C({status:`loading`});try{let r=await Fe({text:t,provider:n.provider,providerConfig:A,...I?{model:I}:{},...L?{voice:L}:{}}),i=Et(r.audio,r.mimeType);T.current=i;let a=new Audio(i);w.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,Tt(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>C({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>C({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),C({status:`playing`,summary:o})}catch(e){E(),C({status:`error`,message:e instanceof Error?e.message:String(e)})}},[I,L,A,E,y,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),B=(0,Q.useCallback)(e=>{o({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,o]),V=(0,Q.useCallback)((e,t)=>{let r={[e.key]:t};B(r),n.provider===`openai`&&e.key===`baseUrl`?c(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&l(r)},[n.provider,B,l,u,c]);return(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(M,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(tn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>o({enabled:e})}),(0,$.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2.5 text-sm`,F===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:F===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,$.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?P?`${e.tts.statusReady} ${zt(n.provider,e)}${L?` · ${L}`:``}`:`${e.tts.statusNeedsSetup} ${zt(n.provider,e)} · ${O?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,bt),children:[(0,$.jsx)(an,{children:e.tts.trigger}),(0,$.jsxs)(`select`,{className:wt(),value:n.trigger,onChange:e=>o({trigger:e.target.value}),children:[(0,$.jsx)(`option`,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(`option`,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(`option`,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(`option`,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,bt),children:[(0,$.jsx)(an,{children:e.tts.provider}),(0,$.jsx)(`select`,{className:wt(),value:n.provider,onChange:e=>R(e.target.value),children:D.map(t=>(0,$.jsx)(`option`,{value:t.id,children:zt(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[O?.configured?e.tts.configured:O?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${O.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,O?.description??Vt(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-3`,open:!P||n.provider===`tts-local-cli`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,$.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,bt),children:[(0,$.jsx)(an,{children:e.stt.apiKey}),(0,$.jsx)(Ue,{kind:`tts`,providerId:n.provider,fieldId:`voice-tts-${n.provider}-api-key`,value:n.provider===`openai`?n.openai?.apiKey??``:n.provider===`alibaba`?n.alibaba?.apiKey??``:n.minimax?.apiKey??``,onChange:e=>{n.provider===`openai`?c({apiKey:e}):n.provider===`alibaba`?s({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,St(n.provider)?` ${St(n.provider)}`:``]})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,bt),children:[(0,$.jsx)(an,{children:e.stt.model}),(0,$.jsx)(`select`,{className:wt(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?c({model:e.target.value}):n.provider===`alibaba`?s({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:_).map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,bt),children:[(0,$.jsx)(an,{children:e.tts.voice}),(0,$.jsx)(`select`,{className:wt(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?c({voice:e.target.value}):n.provider===`alibaba`?s({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:v).map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,bt),children:[(0,$.jsx)(an,{children:e.tts.voice}),(0,$.jsx)(`select`,{className:wt(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:g.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(an,{children:e.tts.localCli.preset}),(0,$.jsxs)(`select`,{className:wt(),value:``,onChange:e=>{let t=Lt.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,$.jsx)(`option`,{value:``,children:e.tts.localCli.presetPlaceholder}),Lt.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.id},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(an,{children:e.tts.localCli.command}),(0,$.jsx)(`input`,{className:i(Ct(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.command??``,onChange:e=>d({command:e.target.value}),placeholder:e.tts.localCli.commandPlaceholder}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(an,{children:e.tts.localCli.cwd}),(0,$.jsx)(`input`,{className:i(Ct(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.cwd??``,onChange:e=>d({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(an,{children:e.tts.localCli.outputFormat}),(0,$.jsxs)(`select`,{className:wt(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({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:e.tts.localCli.outputFormatDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(an,{children:e.tts.localCli.timeoutMs}),(0,$.jsx)(`input`,{className:Ct(),type:`number`,min:0,step:1e3,value:typeof n[`tts-local-cli`]?.timeoutMs==`number`?String(n[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){d({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&d({timeoutMs:n})},placeholder:`30000`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,j.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:j.map(e=>(0,$.jsx)(nn,{field:e,value:Ut(A,e),onChange:t=>V(e,t),className:e.type===`textarea`?`sm:col-span-2`:bt},e.key))}):null]})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(Y,{type:`button`,variant:`primary`,onClick:()=>void z(),disabled:x.status===`loading`,className:`h-9`,children:[x.status===`loading`?(0,$.jsx)(W,{className:`size-4 animate-spin`}):(0,$.jsx)(S,{className:`size-4`}),x.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,onClick:()=>{E(),C(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:x.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(we,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsx)(`textarea`,{className:i(Ct(),`mt-3 min-h-20 resize-y`),value:y,onChange:e=>b(e.target.value),maxLength:1e3}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[y.length,`/1000`]}),x.status===`playing`||x.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[x.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,x.summary]}):null,x.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:x.message}):null]})]})]}):null]})]})}function tn(e){let t=(0,Z.c)(33),{checked:n,title:r,description:a,onLabel:o,offLabel:s,onChange:c}=e,l;t[0]!==n||t[1]!==c?(l=()=>c(!n),t[0]=n,t[1]=c,t[2]=l):l=t[2];let u=n?`border-accent/45 bg-accent/10 text-fg shadow-surface dark:bg-accent/15`:`border-edge bg-surface-panel text-fg hover:border-accent/35 hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=i(`group flex w-full items-center justify-between gap-4 rounded-2xl border px-4 py-3 text-left transition-colors`,C,u),t[3]=u,t[4]=d);let f=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,p;t[5]===f?p=t[6]:(p=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?o:s,h;t[7]!==p||t[8]!==m?(h=(0,$.jsx)(`span`,{className:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==h||t[11]!==r?(g=(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,h]}),t[10]=h,t[11]=r,t[12]=g):g=t[12];let _;t[13]===a?_=t[14]:(_=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:a}),t[13]=a,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,b;t[18]===y?b=t[19]:(b=i(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=b);let x=n?`translate-x-5`:`translate-x-0.5`,S;t[20]===x?S=t[21]:(S=i(`size-5 rounded-full bg-white shadow-surface transition-transform`,x),t[20]=x,t[21]=S);let w;t[22]===S?w=t[23]:(w=(0,$.jsx)(`span`,{className:S}),t[22]=S,t[23]=w);let T;t[24]!==b||t[25]!==w?(T=(0,$.jsx)(`span`,{className:b,"aria-hidden":!0,children:w}),t[24]=b,t[25]=w,t[26]=T):T=t[26];let E;return t[27]!==n||t[28]!==l||t[29]!==v||t[30]!==T||t[31]!==d?(E=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:l,className:d,children:[v,T]}),t[27]=n,t[28]=l,t[29]=v,t[30]=T,t[31]=d,t[32]=E):E=t[32],E}function nn(e){let t=(0,Z.c)(36),{field:n,value:r,onChange:a,className:o}=e,s=`voice-schema-field-${n.key}`,c=n.description;if(n.type===`boolean`){let e;t[0]===o?e=t[1]:(e=i(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let s;t[2]===n.label?s=t[3]:(s=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=s);let l;t[4]===c?l=t[5]:(l=c?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,$.jsxs)(`span`,{children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==a?(f=e=>a(Wt(n,e.target.checked)),t[9]=n,t[10]=a,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:f}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==e||t[16]!==u||t[17]!==p?(m=(0,$.jsxs)(`label`,{className:e,children:[u,p]}),t[15]=e,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}let l=typeof r==`boolean`?``:String(r),u;t[19]===o?u=t[20]:(u=i(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,$.jsx)(an,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==o||t[24]!==n||t[25]!==l||t[26]!==s||t[27]!==a?(f=n.type===`select`?(0,$.jsx)(`select`,{id:s,className:wt(),value:l,required:n.required,onChange:e=>a(Wt(n,e.target.value)),children:(n.options??[]).map(rn)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:s,className:i(Ct(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Wt(n,e.target.value))}):n.type===`password`?(0,$.jsx)(A,{id:s,className:o,value:l,onChange:e=>a(Wt(n,e)),placeholder:n.placeholder,labels:de}):(0,$.jsx)(`input`,{id:s,className:Ct(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Wt(n,e.target.value))}),t[23]=o,t[24]=n,t[25]=l,t[26]=s,t[27]=a,t[28]=f):f=t[28];let p;t[29]===c?p=t[30]:(p=c?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[29]=c,t[30]=p);let m;return t[31]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(`div`,{className:u,children:[d,f,p]}),t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function rn(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function an(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function on(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 sn(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(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),P()}async function cn(e){let t=await l(c(`/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 ln(e){let t=(0,Z.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function un(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,C,`dark:border-edge`)}function dn(){return i(y,L)}var fn=[`brave`,`tavily`,`bing`,`searxng`];function pn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var mn=Ce();function hn({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.webSearchSettings,c=n.logs,l=!!s(e=>e.token),[u,f]=(0,Q.useReducer)(mn,{form:null,baseline:null}),p=u.form,m=u.baseline,[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=(0,Q.useRef)(!1),x=(0,Q.useRef)(null),{data:S,error:C,isLoading:w,mutate:T}=Ne(l);ge({enabled:l,parsed:(0,Q.useMemo)(()=>S?.payload?.config===void 0?null:on(S.payload.config),[S]),dirty:b.current,trackedParsedRef:x,dispatch:f,onResetDirty:()=>{b.current=!1}});let E=!!(l&&w&&S===void 0&&!C),k=C instanceof Error?C.message:C?String(C):null,A=(0,Q.useMemo)(()=>!p||!m?!1:JSON.stringify(p)!==JSON.stringify(m),[p,m]),j=(0,Q.useCallback)(e=>{b.current=!0,f({type:`patch`,patch:e})},[]),M=(0,Q.useCallback)(async()=>{if(!(!p||g)){_(!0),y(null);try{await sn(p),b.current=!1,f({type:`saved`,value:p}),d({type:`success`,title:r.saved})}catch(e){y(e instanceof Error?e.message:r.saveError)}finally{_(!1)}}},[p,g,r.saveError]),N=(0,Q.useCallback)(()=>{m&&(b.current=!1,f({type:`discard`}),y(null))},[m]);$e({id:`search`,dirty:A,saving:g,save:M,discard:N});let P=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,F=e?`flex flex-col gap-3`:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`;return l?E?(0,$.jsxs)(`div`,{className:i(F,`items-center`),children:[(0,$.jsx)(W,{className:`size-8 animate-spin text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.loading})]}):p?(0,$.jsxs)(`div`,{className:P,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:h(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)(be,{className:`size-3.5`})]})]}),e?null:(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`secondary`,disabled:!A||g,onClick:N,children:r.discard}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:!A||g,onClick:()=>void M(),children:g?r.saving:r.save})]})]}),A&&!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)(Je,{children:[(0,$.jsx)(qe,{icon:q,title:r.sectionRegion,subtitle:r.sectionRegionHint}),(0,$.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,$.jsx)(ln,{label:r.regionLabel,description:r.regionDesc,children:(0,$.jsxs)(`select`,{className:dn(),value:p.regionMode,onChange:e=>j({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)(Ge,{children:(0,$.jsxs)(Je,{children:[(0,$.jsx)(qe,{icon:O,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:p.blocklistEnabled,onChange:e=>j({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)(ln,{label:r.blocklistDomains,description:r.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:i(un(),`min-h-[6rem] font-mono text-xs`),value:p.blocklistDomains.join(`
|
|
2
|
+
`),placeholder:r.blocklistDomainsPlaceholder,disabled:!p.blocklistEnabled,onChange:e=>{j({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,$.jsxs)(Je,{children:[(0,$.jsx)(qe,{icon:q,title:r.sectionSearch,subtitle:r.sectionSearchHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,$.jsx)(ln,{label:r.maxResultsLabel,description:r.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:un(),value:p.maxResults,onChange:e=>j({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}),p.providers.map((e,t)=>(0,$.jsx)(gn,{row:e,providerIndex:t,labels:r,secretLabels:D(n.providersSettings),onChange:e=>{let n=[...p.providers];n[t]=e,j({providers:n})},onRemove:()=>{j({providers:p.providers.filter((e,n)=>n!==t)})}},`${e.type}:${e.url}:${e.apiKey}:${e.disabled}`)),(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>j({providers:[...p.providers,pn()]}),children:[(0,$.jsx)(B,{className:`size-4`}),r.addProvider]})]})]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r.footerHint})]}):(0,$.jsxs)(`div`,{className:F,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:v??k??r.loadError}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>void T(),children:c.refresh})]}):(0,$.jsxs)(`div`,{className:F,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 gn(e){let t=(0,Z.c)(54),{row:n,providerIndex:r,labels:a,secretLabels:o,onChange:s,onRemove:c}=e,l;t[0]===r?l=t[1]:(l=()=>cn(r).then(_n),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(dn(),`min-w-[8rem]`),t[2]=d):d=t[2];let f=n.type,p;t[3]!==s||t[4]!==n?(p=e=>s({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=s,t[4]=n,t[5]=p):p=t[5];let m;t[6]===a.providerTypes?m=t[7]:(m=fn.map(e=>(0,$.jsx)(`option`,{value:e,children:a.providerTypes[e]},e)),t[6]=a.providerTypes,t[7]=m);let h;t[8]!==n.type||t[9]!==p||t[10]!==m?(h=(0,$.jsx)(`select`,{className:d,value:f,onChange:p,children:m}),t[8]=n.type,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==s||t[13]!==n?(g=e=>s({...n,disabled:e.target.checked}),t[12]=s,t[13]=n,t[14]=g):g=t[14];let _;t[15]!==n.disabled||t[16]!==g?(_=(0,$.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:g}),t[15]=n.disabled,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==a.disabled||t[19]!==_?(v=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[_,a.disabled]}),t[18]=a.disabled,t[19]=_,t[20]=v):v=t[20];let y;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(_e,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===c?b=t[23]:(b=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:c,children:y}),t[22]=c,t[23]=b);let x;t[24]!==b||t[25]!==v?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v,b]}),t[24]=b,t[25]=v,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==h?(S=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[h,x]}),t[27]=x,t[28]=h,t[29]=S):S=t[29];let C;t[30]!==a.urlDesc||t[31]!==a.urlLabel||t[32]!==s||t[33]!==n?(C=n.type===`searxng`?(0,$.jsx)(ln,{label:a.urlLabel,description:a.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:un(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>s({...n,url:e.target.value})})}):null,t[30]=a.urlDesc,t[31]=a.urlLabel,t[32]=s,t[33]=n,t[34]=C):C=t[34];let w;t[35]!==s||t[36]!==n?(w=e=>s({...n,apiKey:e}),t[35]=s,t[36]=n,t[37]=w):w=t[37];let T;t[38]!==a.keyPlaceholder||t[39]!==a.keyPlaceholderMasked||t[40]!==a.saveError||t[41]!==u||t[42]!==n.apiKey||t[43]!==o||t[44]!==w?(T=(0,$.jsx)(A,{value:n.apiKey,onChange:w,placeholder:a.keyPlaceholder,labels:o,reveal:u,loadFailedLabel:a.saveError,notInConfigFile:a.keyPlaceholderMasked}),t[38]=a.keyPlaceholder,t[39]=a.keyPlaceholderMasked,t[40]=a.saveError,t[41]=u,t[42]=n.apiKey,t[43]=o,t[44]=w,t[45]=T):T=t[45];let E;t[46]!==a.apiKeyDesc||t[47]!==a.apiKeyLabel||t[48]!==T?(E=(0,$.jsx)(ln,{label:a.apiKeyLabel,description:a.apiKeyDesc,children:T}),t[46]=a.apiKeyDesc,t[47]=a.apiKeyLabel,t[48]=T,t[49]=E):E=t[49];let D;return t[50]!==S||t[51]!==C||t[52]!==E?(D=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel/60 p-4 dark:border-edge-subtle`,children:[S,C,E]}),t[50]=S,t[51]=C,t[52]=E,t[53]=D):D=t[53],D}function _n(e){return e.apiKey??null}var vn=[{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 yn(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 bn(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 xn(){let e=await u(c(`/api/models-json`)),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok||!t.payload)throw Error(yn(t)||`HTTP ${e.status}`);return{...t.payload,config:bn(t.payload.config)}}async function Sn(e){let t=await u(c(`/api/models-json`),{method:`PATCH`,body:JSON.stringify({config:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(yn(n)||`HTTP ${t.status}`);return await m(),n.payload}function Cn(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 wn(){let e=(0,Z.c)(31),t=s(kn),n=!!t,{data:r,isLoading:i}=Ne(n),a;e[0]===n?a=e[1]:(a=n?c(`/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 l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},e[4]=l):l=e[4];let{data:u,isLoading:d}=f(a,o,l),p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},e[5]=p):p=e[5];let{data:m,isLoading:h}=f(n?De:null,On,p),g;e[6]===m?g=e[7]:(g=m===void 0?[]:m,e[6]=m,e[7]=g);let _=g,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[8]=v):v=e[8];let{data:y}=f(n?F:null,Dn,v),b;bb0:{if(!u||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],b=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==u||e[12]!==_?(t=Ee(u,ae(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=u,e[12]=_,e[13]=t):t=e[13],b=t}let x=b,S;bb1:{if(!y){S=null;break bb1}let t;e[14]===y.config?t=e[15]:(t=bn(y.config),e[14]=y.config,e[15]=t),S=t}let C=S,w;if(e[16]!==x||e[17]!==C||e[18]!==u||e[19]!==_){w=[];let t=new Set((u??[]).filter(En).map(Tn)),n;e[21]===C?n=e[22]:(n=new Set(C?Object.keys(C.providers):[]),e[21]=C,e[22]=n);let r=n;for(let e of x){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?C.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;w.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(C){let t;e[23]===C.providers?t=e[24]:(t=Object.entries(C.providers),e[23]=C.providers,e[24]=t);for(let[e,n]of t)w.some(t=>t.id===e)||w.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=x,e[17]=C,e[18]=u,e[19]=_,e[20]=w}else w=e[20];let T=w,E=i||d||h,D;return e[25]!==x||e[26]!==T||e[27]!==C||e[28]!==E||e[29]!==_?(D={cards:T,loading:E,builtinRows:x,customConfig:C,allModels:_},e[25]=x,e[26]=T,e[27]=C,e[28]=E,e[29]=_,e[30]=D):D=e[30],D}function Tn(e){return e.id}function En(e){return e.configured}function Dn(){return xn()}function On(){return I()}function kn(e){return e.token}function An(e){let t=(0,Z.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=wn();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(Mn)})]}),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(jn),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)(B,{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)(Y,{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)(Y,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,$.jsx)(B,{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)(Nn,{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 jn(e){return e.configured}function Mn(e){return(0,$.jsx)(`div`,{className:`h-32 animate-pulse rounded-2xl bg-surface-hover`},e)}function Nn(e){let t=(0,Z.c)(28),{card:n,labels:r,onManage:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=i(`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`,X.pressCard),t[0]=o):o=t[0];let s;t[1]===n.name?s=t[2]:(s=(0,$.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=s);let c;t[3]!==n.isCustom||t[4]!==r.custom?(c=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]=c):c=t[5];let l;t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(K,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=u):u=t[9];let d;t[10]===l?d=t[11]:(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,u]}),t[10]=l,t[11]=d);let f;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(f=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=f):f=t[15];let p;t[16]===f?p=t[17]:(p=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f}),t[16]=f,t[17]=p);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(k,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[m,r.manage]}),t[19]=r.manage,t[20]=h);let g;t[21]!==h||t[22]!==p?(g=(0,$.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[p,h]}),t[21]=h,t[22]=p,t[23]=g):g=t[23];let _;return t[24]!==a||t[25]!==g||t[26]!==d?(_=(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:o,children:[d,g]}),t[24]=a,t[25]=g,t[26]=d,t[27]=_):_=t[27],_}async function Pn(e){let t=await u(c(`/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 Fn(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function In(e,t){let n=await u(c(`/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 Ln(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function Rn(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function zn(e){let t=await u(c(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var Bn=[`common`,`specialty`,`enterprise`,`oauth`,`extension`];function Vn(e){let t=new Map;for(let e of Bn)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 Hn={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 Un(e){return e===`openrouter`?`openrouter`:e===`zhipuCn`?`zhipu-cn`:e===`zaiGeneral`?`zai`:e}var Wn=[{value:`text`,labelKey:`inputTextOnly`},{value:`text,image`,labelKey:`inputTextVision`}];function Gn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,C,`dark:border-edge`)}function Kn(){return i(y,L)}function qn(e){return(e.input||[`text`]).includes(`image`)?`text,image`:`text`}function Jn(e){return e===`text,image`?[`text`,`image`]:[`text`]}function Yn(e){let t=(0,Z.c)(21),{open:n,onOpenChange:r,builtinRows:a,customConfig:o,labels:s,language:c,onSaved:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,Q.useState)(u),[p,m]=(0,Q.useState)(``),h;t[1]===r?h=t[2]:(h=e=>{e||window.setTimeout(()=>{f({type:`pick`}),m(``)},200),r(e)},t[1]=r,t[2]=h);let g=h,v;t[3]!==g||t[4]!==l?(v=()=>{l(),g(!1)},t[3]=g,t[4]=l,t[5]=v):v=t[5];let y=v,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(me,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,_)}),t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x=i(`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`,j),t[7]=x):x=t[7];let S;t[8]!==a||t[9]!==o||t[10]!==y||t[11]!==s||t[12]!==c||t[13]!==p||t[14]!==d.providerId||t[15]!==d.type?(S=(0,$.jsxs)(le,{children:[b,(0,$.jsx)(se,{className:x,children:d.type===`pick`?(0,$.jsx)(Zn,{builtinRows:a,searchQuery:p,onSearchChange:m,labels:s,onPickBuiltin:e=>f({type:`builtin`,providerId:e}),onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,$.jsx)(Qn,{providerId:d.providerId,builtinRows:a,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:y}):(0,$.jsx)(tr,{customConfig:o,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:y})})]}),t[8]=a,t[9]=o,t[10]=y,t[11]=s,t[12]=c,t[13]=p,t[14]=d.providerId,t[15]=d.type,t[16]=S):S=t[16];let C;return t[17]!==g||t[18]!==n||t[19]!==S?(C=(0,$.jsx)(G,{open:n,onOpenChange:g,children:S}),t[17]=g,t[18]=n,t[19]=S,t[20]=C):C=t[20],C}function Xn(e){let t=(0,Z.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),t[0]=r):r=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[1]=a):a=t[1];let o;return t[2]===n?o=t[3]:(o=(0,$.jsx)(oe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:a})}),t[2]=n,t[3]=o),o}function Zn(e){let t=(0,Z.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:a,labels:o,onPickBuiltin:s,onPickCustom:c}=e,l;t[0]===r?l=t[1]:(l=r.trim().toLowerCase(),t[0]=r,t[1]=l);let u=l,d;bb0:{if(!u){d=n;break bb0}let e;if(t[2]!==n||t[3]!==u){let r;t[5]===u?r=t[6]:(r=e=>{let t=ce[e.id]?.aliases??[];return e.id.toLowerCase().includes(u)||e.name.toLowerCase().includes(u)||t.some(e=>e.toLowerCase().includes(u))},t[5]=u,t[6]=r),e=n.filter(r),t[2]=n,t[3]=u,t[4]=e}else e=t[4];d=e}let f=d,p;t[7]===f?p=t[8]:(p=Vn(f),t[7]=f,t[8]=p);let m=p,h;t[9]===o.step1Title?h=t[10]:(h=(0,$.jsx)(te,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o.step1Title}),t[9]=o.step1Title,t[10]=h);let g;t[11]===o.close?g=t[12]:(g=(0,$.jsx)(Xn,{label:o.close}),t[11]=o.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)(q,{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]===a?y=t[18]:(y=e=>a(e.target.value),t[17]=a,t[18]=y);let b=o.searchPlaceholder,x;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(x=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,C),t[19]=x):x=t[19];let S;t[20]!==o.searchPlaceholder||t[21]!==r||t[22]!==y?(S=(0,$.jsx)(`div`,{className:`px-5 pt-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[v,(0,$.jsx)(`input`,{type:`search`,value:r,onChange:y,placeholder:b,autoComplete:`off`,autoFocus:!0,className:x})]})}),t[20]=o.searchPlaceholder,t[21]=r,t[22]=y,t[23]=S):S=t[23];let w;t[24]!==o.addCustom||t[25]!==o.customDescription||t[26]!==c||t[27]!==u?(w=u?null:(0,$.jsxs)(`button`,{type:`button`,onClick:c,className:i(`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`,X.press),children:[(0,$.jsx)(E,{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:o.addCustom}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:o.customDescription})]}),(0,$.jsx)(U,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=o.addCustom,t[25]=o.customDescription,t[26]=c,t[27]=u,t[28]=w):w=t[28];let T;t[29]!==f.length||t[30]!==m||t[31]!==o.categories||t[32]!==o.noResults||t[33]!==s?(T=f.length===0?(0,$.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:o.noResults}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:Bn.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:o.categories[e]??e}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:i(`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`,X.press),children:[(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,$.jsx)(K,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null]},e.id))})]},e)})}),t[29]=f.length,t[30]=m,t[31]=o.categories,t[32]=o.noResults,t[33]=s,t[34]=T):T=t[34];let D;t[35]!==w||t[36]!==T?(D=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[w,T]}),t[35]=w,t[36]=T,t[37]=D):D=t[37];let O;return t[38]!==S||t[39]!==D||t[40]!==_?(O=(0,$.jsxs)($.Fragment,{children:[_,S,D]}),t[38]=S,t[39]=D,t[40]=_,t[41]=O):O=t[41],O}function Qn({providerId:e,builtinRows:t,labels:n,language:r,onBack:o,onSaved:s}){let c=t.find(t=>t.id===e),l=ce[e],[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(null),y=a(r).providersSettings,b=D(y),x=(0,Q.useMemo)(()=>ye(e,r),[e,r]),S=c?.supportsApiKey!==!1,w=c?.supportsOAuth===!0,[T,E]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(`idle`),[N,P]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(``),z=j===`waiting`||j===`waiting_code`;(0,Q.useEffect)(()=>{if(!T||!z)return;let e=window.setInterval(()=>{(async()=>{try{let t=await Fn(T);t.status===`waiting_auth`||t.status===`waiting_code`?(M(t.status===`waiting_code`?`waiting_code`:`waiting`),k(t.message??null),P(t.authUrl??null),I(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),M(`success`),k(t.message??y.saved),window.setTimeout(s,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),M(`error`),k(t.error??t.message??y.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[T,z,s,y.revokeFailed,y.saved]),(0,Q.useEffect)(()=>()=>{T&&Rn(T).catch(()=>{})},[T]);let B=async()=>{M(`waiting`),k(y.oauthStarting),h(null);try{E((await Pn(e)).sessionId)}catch(e){M(`error`),k(e instanceof Error?e.message:y.revokeFailed)}},V=async()=>{if(T){try{await Ln(T)}catch{}M(`idle`),k(null),E(null),P(null),I(null)}},H=async()=>{if(!(!T||!L.trim()))try{await In(T,L.trim()),R(``),k(y.oauthProcessingCode)}catch(e){M(`error`),k(e instanceof Error?e.message:y.revokeFailed)}},ee=async()=>{let t=u.trim();if(!(!t||!S)){p(!0),h(null);try{await Me({[e]:t}),_(!0),window.setTimeout(s,600)}catch(e){h(e instanceof Error?e.message:n.saveError)}finally{p(!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:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),"aria-label":n.back,children:(0,$.jsx)(U,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(te,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:c?.name??e}),(0,$.jsx)(Xn,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[l?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.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)(A,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:b,inputRef:v,onKeyDown:e=>{e.key===`Enter`&&ee()}})]}):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:y.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:y.oauthHint})]}),(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:z,onClick:()=>void B(),children:[z?(0,$.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,y.oauth]})]}),O?(0,$.jsx)(`p`,{className:i(`text-xs`,j===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:O}):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:[y.openAuthPage,(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>void V(),children:y.cancelOAuth})]}):null,F?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:F}):null,j===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:L,onChange:e=>R(e.target.value),onKeyDown:e=>e.key===`Enter`&&void H(),placeholder:y.pasteRedirectUrl,className:i(`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`,C)}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,onClick:()=>void H(),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:[he(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)(Y,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),S?(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:!u.trim()||f||g,onClick:()=>void ee(),children:g?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(K,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function $n(e=`custom`){if(e!==`custom`&&Hn[e]){let t=Hn[e];return{preset:e,providerId:Un(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 er(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:Hn[t.key]?{...$n(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 tr({customConfig:e,labels:t,language:n,onBack:r,onSaved:o}){let[s,c]=(0,Q.useReducer)(er,void 0,()=>$n()),[l,u]=(0,Q.useState)(!1),d=D(a(n).providersSettings),{preset:f,providerId:p,baseUrl:m,api:h,apiKey:g,modelIds:_,error:v}=s,y=async()=>{let n=p.trim(),r=m.trim();if(!n){c({type:`setError`,value:t.providerIdRequired});return}if(!r){c({type:`setError`,value:t.baseUrlRequired});return}let i=_.map(e=>e.trim()).filter(Boolean);u(!0),c({type:`setError`,value:null});try{let t=e?.providers??{},a={baseUrl:r,api:h,apiKey:g.trim()||void 0,models:i.map(e=>({id:e}))};await Sn({providers:{...t,[n]:a}}),o()}catch(e){c({type:`setError`,value:e instanceof Error?e.message:t.saveError})}finally{u(!1)}},b=p.trim()&&m.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:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),"aria-label":t.back,children:(0,$.jsx)(U,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(te,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:t.step2CustomTitle}),(0,$.jsx)(Xn,{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:f,onChange:e=>c({type:`applyPreset`,key:e.target.value}),className:Kn(),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:p,onChange:e=>c({type:`setProviderId`,value:e.target.value}),placeholder:t.providerIdPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,C)})]}),(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:m,onChange:e=>c({type:`setBaseUrl`,value:e.target.value}),placeholder:t.baseUrlPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,C)})]}),(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:h,onChange:e=>c({type:`setApi`,value:e.target.value}),className:Kn(),children:vn.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)(A,{id:`custom-api-key`,value:g,onChange:e=>c({type:`setApiKey`,value:e}),placeholder:t.apiKeyPlaceholder,labels:d})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.modelIdLabel}),_.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>c({type:`updateModelId`,index:n,value:e.target.value}),placeholder:t.modelIdPlaceholder,className:i(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,C)}),_.length>1?(0,$.jsx)(`button`,{type:`button`,onClick:()=>c({type:`removeModelSlot`,index:n}),className:i(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,X.press),children:(0,$.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${n}`)),(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>c({type:`addModelSlot`}),children:[(0,$.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}),t.addModel]})]}),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-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:r,children:t.cancel}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:!b||l,onClick:()=>void y(),children:l?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),t.saving]}):t.save})]})]})}function nr(e){let t=(0,Z.c)(156),{model:n,isNew:r,providerId:a,onSave:o,onClose:s,m:c}=e,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:Cn(``),t[0]=n,t[1]=l);let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(rr),m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(e,t)=>{d(n=>({...n,[e]:t})),p(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=m):m=t[2];let h=m,g;t[3]!==u.contextWindow||t[4]!==u.id||t[5]!==u.maxTokens||t[6]!==c.modelIdRequired||t[7]!==c.mustBePositive?(g=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,c.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,c.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,c.mustBePositive),p(e),e.size===0},t[3]=u.contextWindow,t[4]=u.id,t[5]=u.maxTokens,t[6]=c.modelIdRequired,t[7]=c.mustBePositive,t[8]=g):g=t[8];let _=g,v;t[9]!==u||t[10]!==s||t[11]!==o||t[12]!==_?(v=()=>{if(!_())return;let e=(u.id||``).trim();o({...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}}),s()},t[9]=u,t[10]=s,t[11]=o,t[12]=_,t[13]=v):v=t[13];let y=v,b=u,x;t[14]===b?x=t[15]:(x=qn(b),t[14]=b,t[15]=x);let S=x,C=r?c.addModelTitle:c.editModelTitle,w;t[16]===C?w=t[17]:(w=(0,$.jsx)(te,{className:`text-base font-semibold text-fg`,children:C}),t[16]=C,t[17]=w);let T;t[18]!==c.modelProviderLabel||t[19]!==a?(T=a?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[c.modelProviderLabel,`: `,a]}):null,t[18]=c.modelProviderLabel,t[19]=a,t[20]=T):T=t[20];let E;t[21]!==w||t[22]!==T?(E=(0,$.jsxs)(`div`,{children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(D=i(N,`p-1.5 hover:bg-surface-base`),t[24]=D):D=t[24];let O;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(ee,{className:`size-4`}),t[25]=O):O=t[25];let k;t[26]===c.close?k=t[27]:(k=(0,$.jsx)(oe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:D,"aria-label":c.close,children:O})}),t[26]=c.close,t[27]=k);let A;t[28]!==E||t[29]!==k?(A=(0,$.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[E,k]}),t[28]=E,t[29]=k,t[30]=A):A=t[30];let j;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=j):j=t[31];let M;t[32]===c.modelId?M=t[33]:(M=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[c.modelId,j]}),t[32]=c.modelId,t[33]=M);let P;t[34]===f?P=t[35]:(P=i(Gn(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=P);let F=u.id||``,I;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>h(`id`,e.target.value),t[36]=I):I=t[36];let L=!r,R;t[37]!==P||t[38]!==F||t[39]!==L?(R=(0,$.jsx)(`input`,{className:P,value:F,onChange:I,placeholder:`e.g. llama3.1:8b`,disabled:L}),t[37]=P,t[38]=F,t[39]=L,t[40]=R):R=t[40];let z;t[41]===f?z=t[42]:(z=f.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[41]=f,t[42]=z);let B;t[43]!==M||t[44]!==R||t[45]!==z?(B=(0,$.jsxs)(`div`,{children:[M,R,z]}),t[43]=M,t[44]=R,t[45]=z,t[46]=B):B=t[46];let V;t[47]===c.displayName?V=t[48]:(V=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.displayName}),t[47]=c.displayName,t[48]=V);let H;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(H=Gn(),t[49]=H):H=t[49];let ne=u.name||``,re;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>h(`name`,e.target.value),t[50]=re):re=t[50];let ie;t[51]===ne?ie=t[52]:(ie=(0,$.jsx)(`input`,{className:H,value:ne,onChange:re}),t[51]=ne,t[52]=ie);let U;t[53]!==V||t[54]!==ie?(U=(0,$.jsxs)(`div`,{children:[V,ie]}),t[53]=V,t[54]=ie,t[55]=U):U=t[55];let ae;t[56]===c.inputTypes?ae=t[57]:(ae=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.inputTypes}),t[56]=c.inputTypes,t[57]=ae);let W;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(W=Kn(),t[58]=W):W=t[58];let se;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>h(`input`,Jn(e.target.value)),t[59]=se):se=t[59];let ce;t[60]===c?ce=t[61]:(ce=Wn.map(e=>(0,$.jsx)(`option`,{value:e.value,children:c[e.labelKey]},e.value)),t[60]=c,t[61]=ce);let G;t[62]!==S||t[63]!==ce?(G=(0,$.jsx)(`select`,{className:W,value:S,onChange:se,children:ce}),t[62]=S,t[63]=ce,t[64]=G):G=t[64];let K;t[65]!==ae||t[66]!==G?(K=(0,$.jsxs)(`div`,{children:[ae,G]}),t[65]=ae,t[66]=G,t[67]=K):K=t[67];let le=u.reasoning||!1,ue;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>h(`reasoning`,e.target.checked),t[68]=ue):ue=t[68];let q;t[69]===le?q=t[70]:(q=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:le,onChange:ue}),t[69]=le,t[70]=q);let de;t[71]!==c.reasoning||t[72]!==q?(de=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[q,c.reasoning]}),t[71]=c.reasoning,t[72]=q,t[73]=de):de=t[73];let fe;t[74]!==K||t[75]!==de?(fe=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[K,de]}),t[74]=K,t[75]=de,t[76]=fe):fe=t[76];let J;t[77]===c.contextWindow?J=t[78]:(J=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.contextWindow}),t[77]=c.contextWindow,t[78]=J);let pe;t[79]===f?pe=t[80]:(pe=i(Gn(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=pe);let me=u.contextWindow??128e3,he;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(he=e=>h(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=he):he=t[81];let ge;t[82]!==pe||t[83]!==me?(ge=(0,$.jsx)(`input`,{type:`number`,min:1,className:pe,value:me,onChange:he}),t[82]=pe,t[83]=me,t[84]=ge):ge=t[84];let _e;t[85]===f?_e=t[86]:(_e=f.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=_e);let ve;t[87]!==J||t[88]!==ge||t[89]!==_e?(ve=(0,$.jsxs)(`div`,{children:[J,ge,_e]}),t[87]=J,t[88]=ge,t[89]=_e,t[90]=ve):ve=t[90];let ye;t[91]===c.maxOutputTokens?ye=t[92]:(ye=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.maxOutputTokens}),t[91]=c.maxOutputTokens,t[92]=ye);let be;t[93]===f?be=t[94]:(be=i(Gn(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=be);let xe=u.maxTokens??16384,Se;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(Se=e=>h(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=Se):Se=t[95];let Ce;t[96]!==be||t[97]!==xe?(Ce=(0,$.jsx)(`input`,{type:`number`,min:1,className:be,value:xe,onChange:Se}),t[96]=be,t[97]=xe,t[98]=Ce):Ce=t[98];let we;t[99]===f?we=t[100]:(we=f.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=we);let Te;t[101]!==ye||t[102]!==Ce||t[103]!==we?(Te=(0,$.jsxs)(`div`,{children:[ye,Ce,we]}),t[101]=ye,t[102]=Ce,t[103]=we,t[104]=Te):Te=t[104];let Ee;t[105]!==ve||t[106]!==Te?(Ee=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ve,Te]}),t[105]=ve,t[106]=Te,t[107]=Ee):Ee=t[107];let De;t[108]===c.costSection?De=t[109]:(De=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:c.costSection}),t[108]=c.costSection,t[109]=De);let Oe;t[110]===c.costInput?Oe=t[111]:(Oe=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costInput}),t[110]=c.costInput,t[111]=Oe);let ke;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(ke=Gn(),t[112]=ke):ke=t[112];let Ae=u.cost?.input??0,je;t[113]===u.cost?je=t[114]:(je=e=>h(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[113]=u.cost,t[114]=je);let Me;t[115]!==Ae||t[116]!==je?(Me=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:ke,value:Ae,onChange:je}),t[115]=Ae,t[116]=je,t[117]=Me):Me=t[117];let X;t[118]!==Oe||t[119]!==Me?(X=(0,$.jsxs)(`div`,{children:[Oe,Me]}),t[118]=Oe,t[119]=Me,t[120]=X):X=t[120];let Ne;t[121]===c.costOutput?Ne=t[122]:(Ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costOutput}),t[121]=c.costOutput,t[122]=Ne);let Pe;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=Gn(),t[123]=Pe):Pe=t[123];let Fe=u.cost?.output??0,Ie;t[124]===u.cost?Ie=t[125]:(Ie=e=>h(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[124]=u.cost,t[125]=Ie);let Le;t[126]!==Fe||t[127]!==Ie?(Le=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Pe,value:Fe,onChange:Ie}),t[126]=Fe,t[127]=Ie,t[128]=Le):Le=t[128];let Re;t[129]!==Ne||t[130]!==Le?(Re=(0,$.jsxs)(`div`,{children:[Ne,Le]}),t[129]=Ne,t[130]=Le,t[131]=Re):Re=t[131];let ze;t[132]!==X||t[133]!==Re?(ze=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[X,Re]}),t[132]=X,t[133]=Re,t[134]=ze):ze=t[134];let Be;t[135]!==De||t[136]!==ze?(Be=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[De,ze]}),t[135]=De,t[136]=ze,t[137]=Be):Be=t[137];let Ve;t[138]!==B||t[139]!==U||t[140]!==fe||t[141]!==Ee||t[142]!==Be?(Ve=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[B,U,fe,Ee,Be]}),t[138]=B,t[139]=U,t[140]=fe,t[141]=Ee,t[142]=Be,t[143]=Ve):Ve=t[143];let He;t[144]===c.cancel?He=t[145]:(He=(0,$.jsx)(oe,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`secondary`,children:c.cancel})}),t[144]=c.cancel,t[145]=He);let Ue=r?c.addModelConfirm:c.saveModelConfirm,We;t[146]!==y||t[147]!==Ue?(We=(0,$.jsx)(Y,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:y,children:Ue}),t[146]=y,t[147]=Ue,t[148]=We):We=t[148];let Ge;t[149]!==He||t[150]!==We?(Ge=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[He,We]}),t[149]=He,t[150]=We,t[151]=Ge):Ge=t[151];let Ke;return t[152]!==A||t[153]!==Ve||t[154]!==Ge?(Ke=(0,$.jsxs)($.Fragment,{children:[A,Ve,Ge]}),t[152]=A,t[153]=Ve,t[154]=Ge,t[155]=Ke):Ke=t[155],Ke}function rr(){return new Map}function ir(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:a,model:o,isNew:s,onSave:c,m:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(me,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,_)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(`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`,j,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=d):d=t[1];let f;t[2]!==s||t[3]!==l||t[4]!==o||t[5]!==r||t[6]!==c||t[7]!==n||t[8]!==a?(f=n?(0,$.jsx)(nr,{model:o,isNew:s,providerId:a,onSave:c,onClose:()=>r(!1),m:l},`${a??`none`}-${o?.id??`new`}`):null,t[2]=s,t[3]=l,t[4]=o,t[5]=r,t[6]=c,t[7]=n,t[8]=a,t[9]=f):f=t[9];let p;t[10]===f?p=t[11]:(p=(0,$.jsxs)(le,{children:[u,(0,$.jsx)(se,{className:d,onOpenAutoFocus:ar,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,$.jsx)(G,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function ar(e){return e.preventDefault()}function or(e){let t=(0,Z.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>ke(n).then(sr),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)(A,{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 sr(e){return e.apiKey??null}function cr(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:a,isCustom:o,builtinRows:s,customConfig:c,allModels:l,labels:u,language:d,onSaved:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(me,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,_)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`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`,j),t[1]=m):m=t[1];let h;t[2]!==l||t[3]!==s||t[4]!==c||t[5]!==o||t[6]!==u||t[7]!==d||t[8]!==r||t[9]!==f||t[10]!==a?(h=(0,$.jsxs)(le,{children:[p,(0,$.jsx)(se,{className:m,children:o?(0,$.jsx)(ur,{providerId:a,customConfig:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,$.jsx)(lr,{providerId:a,builtinRows:s,allModels:l,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=l,t[3]=s,t[4]=c,t[5]=o,t[6]=u,t[7]=d,t[8]=r,t[9]=f,t[10]=a,t[11]=h):h=t[11];let g;return t[12]!==r||t[13]!==n||t[14]!==h?(g=(0,$.jsx)(G,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function lr({providerId:e,builtinRows:t,allModels:n,labels:r,language:o,onClose:s,onSaved:c}){let l=t.find(t=>t.id===e),u=ce[e],d=n.filter(t=>t.provider===e),[f,p]=(0,Q.useState)(l?.apiKey??``),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),S=a(o).providersSettings,w=l?.supportsApiKey!==!1,T=l?.supportsOAuth===!0,E=l?.authMode===`oauth`&&l.authStatus===`connected`,D=l?.configured===!0&&l.activeKeySource!==`env`&&l.activeKeySource!==`extension`&&l.activeKeySource!==`models_json`,[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(`idle`),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),[R,B]=(0,Q.useState)(``),V=M===`waiting`||M===`waiting_code`,H=(0,Q.useMemo)(()=>ye(e,o),[e,o]),re=f!==(l?.apiKey??``),ie=async()=>{let t=f.trim();if(!(!t||!w||ne(t))){h(!0),y(null);try{await Me({[e]:t}),_(!0),window.setTimeout(()=>{c(),s()},600)}catch(e){y(e instanceof Error?e.message:r.saveError)}finally{h(!1)}}};(0,Q.useEffect)(()=>{if(!O||!V)return;let e=window.setInterval(()=>{(async()=>{try{let t=await Fn(O);t.status===`waiting_auth`||t.status===`waiting_code`?(N(t.status===`waiting_code`?`waiting_code`:`waiting`),j(t.message??null),F(t.authUrl??null),L(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),N(`success`),j(t.message??S.saved),window.setTimeout(()=>{c(),s()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),N(`error`),j(t.error??t.message??S.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[O,V,s,c,S.revokeFailed,S.saved]),(0,Q.useEffect)(()=>()=>{O&&Rn(O).catch(()=>{})},[O]);let U=async()=>{try{await ue(e),c(),s()}catch{}},ae=async()=>{N(`waiting`),j(S.oauthStarting),y(null);try{k((await Pn(e)).sessionId)}catch(e){N(`error`),j(e instanceof Error?e.message:S.revokeFailed)}},se=async()=>{if(O){try{await Ln(O)}catch{}N(`idle`),j(null),k(null),F(null),L(null)}},G=async()=>{if(!(!O||!R.trim()))try{await In(O,R.trim()),B(``),j(S.oauthProcessingCode)}catch(e){N(`error`),j(e instanceof Error?e.message:S.revokeFailed)}},le=async()=>{try{await zn(e),c(),s()}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)(te,{className:`text-base font-semibold text-fg`,children:l?.name??e}),(0,$.jsx)(oe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),children:(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[u?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,l?.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:l.baseUrl})]}):l?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,w?(0,$.jsx)(or,{providerId:e,inputId:`manage-api-key`,value:f,onChange:e=>{p(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}}):l?.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}),l?.extensionId?(0,$.jsxs)(z,{to:`/settings/ext/${encodeURIComponent(l.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:s,children:[r.openExtensionSettings,(0,$.jsx)(be,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,T?(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:E?S.sourceOauth:S.oauthHint})]}),E?(0,$.jsx)(Y,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void le(),children:S.revoke}):(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:V,onClick:()=>void ae(),children:[V?(0,$.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(pe,{className:`size-3.5`,"aria-hidden":!0}),S.oauth]})]}),A?(0,$.jsx)(`p`,{className:i(`text-xs`,M===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:A}):null,M===`waiting`||M===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[P?(0,$.jsxs)(`a`,{href:P,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)(be,{className:`size-4`,"aria-hidden":!0}),S.openAuthPage]}):null,(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>void se(),children:S.cancelOAuth})]}):null,I?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:I}):null,M===`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 G(),placeholder:S.pasteRedirectUrl,className:i(`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`,C)}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,onClick:()=>void G(),children:S.submitCode})]}):null]}):null,H.length>0&&w?(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:[he(e,r),(0,$.jsx)(be,{className:`size-3`,"aria-hidden":!0})]},e))}):null,d.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,` (`,d.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:d.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:[D?(0,$.jsxs)(Y,{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)(_e,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:w&&re&&!ne(f.trim())?(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:!f.trim()||m||g,onClick:()=>void ie(),children:g?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(K,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):m?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(Se,{open:b,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,l?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void U(),onCancel:()=>x(!1)})]})}function ur({providerId:e,customConfig:t,labels:n,language:r,onClose:o,onSaved:s}){let c=a(r).modelsSettings,l=t?.providers[e],[u,d]=(0,Q.useState)(l?.baseUrl??``),[f,p]=(0,Q.useState)(l?.apiKey??``),[m,h]=(0,Q.useState)(l?.models??[]),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),[S,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(null),k=n=>{if(!t)return null;let r=f.trim(),i={...l,baseUrl:u.trim()||void 0,apiKey:ne(r)?l?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},A=async()=>{let e=k({models:m});if(e){_(!0),y(null);try{await Sn(e),s(),o()}catch(e){y(e instanceof Error?e.message:n.saveError)}finally{_(!1)}}},j=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await Sn({providers:r}),s(),o()}catch{}},M=(e,t)=>{O({model:e,isNew:t}),E(!0)},N=async e=>{if(!D)return;let t=D.isNew?[...m,e]:m.map(t=>t.id===e.id?e:t);h(t);let r=k({models:t});if(r)try{await Sn(r),s()}catch(e){y(e instanceof Error?e.message:n.saveError)}},P=async e=>{let t=m.filter(t=>t.id!==e);h(t),w(null);let r=k({models:t});if(r)try{await Sn(r),s()}catch(e){y(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)(te,{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)(oe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),children:(0,$.jsx)(ee,{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:u,onChange:e=>d(e.target.value),className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,C)})]}),(0,$.jsx)(or,{providerId:e,inputId:`manage-custom-api-key`,value:f,onChange:p,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,$.jsxs)(`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:[c.modelsSection,m.length>0?` (${m.length})`:``]}),(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>M(null,!0),children:[(0,$.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}),c.addModel]})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:m.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),onClick:()=>M(e,!1),"aria-label":c.editModel,children:(0,$.jsx)(H,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,X.press),onClick:()=>w(e.id),"aria-label":c.removeModel,children:(0,$.jsx)(_e,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),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:[(0,$.jsxs)(Y,{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)(_e,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:g,onClick:()=>void A(),children:g?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(Se,{open:b,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void j(),onCancel:()=>x(!1)}),(0,$.jsx)(Se,{open:S!==null,title:c.removeModel,description:c.removeModelConfirm.replace(`{{id}}`,S??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{S&&P(S)},onCancel:()=>w(null)}),(0,$.jsx)(ir,{open:T,onOpenChange:e=>{E(e),e||O(null)},providerId:e,model:D?.model??null,isNew:D?.isNew??!1,onSave:e=>void N(e),m:c})]})}var dr=[`services`,`image-models`,`voice`,`search`];function fr(e){let t=(e??``).trim();return dr.includes(t)?t:`services`}function pr(){let e=(0,Z.c)(72),t=o(hr),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,s=r.modelsHub,[c,l]=T(),u;e[2]===c?u=e[3]:(u=fr(c.get(`tab`)),e[2]=c,e[3]=u);let d=u,[f,p]=(0,Q.useState)(!1),[m,g]=(0,Q.useState)(null),_=wn(),y;e[4]!==s.servicesHint||e[5]!==s.tabs.services?(y={id:`services`,icon:v,label:s.tabs.services,hint:s.servicesHint},e[4]=s.servicesHint,e[5]=s.tabs.services,e[6]=y):y=e[6];let b;e[7]!==s.imageModelsHint||e[8]!==s.tabs.imageModels?(b={id:`image-models`,icon:J,label:s.tabs.imageModels,hint:s.imageModelsHint},e[7]=s.imageModelsHint,e[8]=s.tabs.imageModels,e[9]=b):b=e[9];let x;e[10]!==s.tabs.voice||e[11]!==s.voiceHint?(x={id:`voice`,icon:re,label:s.tabs.voice,hint:s.voiceHint},e[10]=s.tabs.voice,e[11]=s.voiceHint,e[12]=x):x=e[12];let S;e[13]!==s.searchHint||e[14]!==s.tabs.search?(S={id:`search`,icon:q,label:s.tabs.search,hint:s.searchHint},e[13]=s.searchHint,e[14]=s.tabs.search,e[15]=S):S=e[15];let C;e[16]!==y||e[17]!==b||e[18]!==x||e[19]!==S?(C=[y,b,x,S],e[16]=y,e[17]=b,e[18]=x,e[19]=S,e[20]=C):C=e[20];let w=C,E;e[21]===l?E=e[22]:(E=e=>{l(t=>{let n=new URLSearchParams(t);return e===`services`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[21]=l,e[22]=E);let D=E,O=mr,k;e[23]===r.settingsSections.credentials?k=e[24]:(k=(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.settingsSections.credentials}),e[23]=r.settingsSections.credentials,e[24]=k);let A;e[25]===s.subtitle?A=e[26]:(A=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s.subtitle}),e[25]=s.subtitle,e[26]=A);let j;e[27]===t?j=e[28]:(j=h(t,`configuration`),e[27]=t,e[28]=j);let M;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(be,{className:`size-3.5`,"aria-hidden":!0}),e[29]=M):M=e[29];let N;e[30]!==s.docsLink||e[31]!==j?(N=(0,$.jsxs)(`a`,{href:j,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:[s.docsLink,M]}),e[30]=s.docsLink,e[31]=j,e[32]=N):N=e[32];let P;e[33]!==N||e[34]!==k||e[35]!==A?(P=(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:[k,A,N]})}),e[33]=N,e[34]=k,e[35]=A,e[36]=P):P=e[36];let F;e[37]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(et,{}),e[37]=F):F=e[37];let I=s.tabsAria,L;e[38]!==d||e[39]!==D?(L=e=>{e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),D(dr[(dr.indexOf(d)+(e.key===`ArrowRight`?1:-1)+dr.length)%dr.length]))},e[38]=d,e[39]=D,e[40]=L):L=e[40];let R;e[41]!==d||e[42]!==D||e[43]!==w?(R=w.map(e=>{let{id:t,icon:n,label:r}=e,a=t===d;return(0,$.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,id:`hub-tab-${t}`,"aria-controls":`hub-panel-${t}`,className:i(`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`,X.press,a?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>D(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]=d,e[42]=D,e[43]=w,e[44]=R):R=e[44];let z;e[45]!==s.tabsAria||e[46]!==L||e[47]!==R?(z=(0,$.jsx)(`div`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,"aria-label":I,onKeyDown:L,children:R}),e[45]=s.tabsAria,e[46]=L,e[47]=R,e[48]=z):z=e[48];let B;e[49]!==d||e[50]!==s.connectedProviders||e[51]!==w?(B=w.map(e=>(0,$.jsx)(_r,{id:e.id,activeTab:d,hint:e.hint,children:e.id===`services`?(0,$.jsx)(An,{labels:s.connectedProviders,onAdd:()=>p(!0),onManage:(e,t)=>g({providerId:e,isCustom:t})}):(0,$.jsx)(gr,{tab:e.id})},e.id)),e[49]=d,e[50]=s.connectedProviders,e[51]=w,e[52]=B):B=e[52];let V;e[53]!==f||e[54]!==s.addProviderDialog||e[55]!==t||e[56]!==_.builtinRows||e[57]!==_.customConfig?(V=(0,$.jsx)(Yn,{open:f,onOpenChange:p,builtinRows:_.builtinRows,customConfig:_.customConfig,labels:s.addProviderDialog,language:t,onSaved:O}),e[53]=f,e[54]=s.addProviderDialog,e[55]=t,e[56]=_.builtinRows,e[57]=_.customConfig,e[58]=V):V=e[58];let H;e[59]!==s.manageProviderDialog||e[60]!==t||e[61]!==m||e[62]!==_.allModels||e[63]!==_.builtinRows||e[64]!==_.customConfig?(H=m?(0,$.jsx)(cr,{open:!0,onOpenChange:e=>{e||g(null)},providerId:m.providerId,isCustom:m.isCustom,builtinRows:_.builtinRows,customConfig:_.customConfig,allModels:_.allModels,labels:s.manageProviderDialog,language:t,onSaved:O}):null,e[59]=s.manageProviderDialog,e[60]=t,e[61]=m,e[62]=_.allModels,e[63]=_.builtinRows,e[64]=_.customConfig,e[65]=H):H=e[65];let ee;return e[66]!==P||e[67]!==z||e[68]!==B||e[69]!==V||e[70]!==H?(ee=(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-4 px-4 py-6`,children:[P,F,z,B,V,H]}),e[66]=P,e[67]=z,e[68]=B,e[69]=V,e[70]=H,e[71]=ee):ee=e[71],ee}function mr(){m()}function hr(e){return e.language}function gr(e){let t=(0,Z.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)(yt,{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)(Kt,{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)(hn,{embedded:!0}),t[2]=e):e=t[2],e}}}function _r({id:e,activeTab:t,hint:n,children:r}){let a=e===t,o=(0,Q.useRef)(a);return a&&(o.current=!0),o.current?(0,$.jsxs)(`div`,{role:`tabpanel`,id:`hub-panel-${e}`,"aria-labelledby":`hub-tab-${e}`,hidden:!a,className:i(a?`flex min-w-0 flex-col gap-3`:void 0),children:[a?(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{pr as ModelsHubPanel};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-C-wDpsf-.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-C8ytlAF2.js","assets/preload-helper-zJ_50EbN.js","assets/dist-CkobR7mk.js","assets/Combination-BzaXOLd9.js","assets/dist-DokQNVMQ.js","assets/vendor-react-BOUWij0V.js","assets/cn-JdwAhgNB.js","assets/vendor-swr-BIWyz7Rc.js","assets/createLucideIcon-DPHK1VkS.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-DjbfSsfA.js","assets/config-reload-event-Bjh2zoKp.js","assets/messages-BqzIDrlr.js","assets/fetch-CTsREQIe.js","assets/gateway-startup-retry-C1KAHrd2.js","assets/toast-z0toXu32.js","assets/theme-store-CD2wtgZV.js","assets/index-CVpJW2NS.css","assets/vendor-codemirror-CNP1wPe7.js","assets/note-image-lightbox-hnSX5SSn.js","assets/voice-player-store-1U3vFppm.js","assets/block-editor-D4ZIVQbk.css","assets/markdown-editor-AssmZFx4.js","assets/code-editor-dZTY2dRW.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-BqzIDrlr.js";import{t as s}from"./locale-store-DjbfSsfA.js";import{i as c}from"./theme-store-CD2wtgZV.js";import{r as l}from"./toast-z0toXu32.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{At as d,Bt as f,Dt as p,Fs as m,Ft as h,Gs as g,Ht as _,Is as v,Ko as y,Mo as b,Mt as x,Nt as S,Ra as C,Si as w,Ti as T,Uo as E,Vt as D,Ws as O,Wt as k,Xa as A,Yi as j,ca as M,co as ee,jt as N,kt as P,la as F,rs as te,xa as I,zt as ne}from"./index-C8ytlAF2.js";import{n as re,t as ie}from"./note-image-lightbox-hnSX5SSn.js";import{r as L}from"./note-time-hm6JO_Wi.js";var R=n(),z=e(t(),1),B=r(),V={edit:A,ai_edit:I,sync:C,restore:v};function H(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function ae({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let c=o(s(e=>e.language)).notes,d=c,{data:f}=u(e?[`note-history`,e]:null,()=>x(e)),[p,m]=(0,z.useState)(!1),[h,g]=(0,z.useState)(null),_=(0,z.useCallback)(async t=>{m(!0);try{await D(e,t),l({type:`success`,title:c.restoreSuccess}),g(null),i()}catch{l({type:`error`,title:c.restoreFailed})}finally{m(!1)}},[e,c.restoreSuccess,c.restoreFailed,i]),v=Date.now();return(0,B.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,B.jsx)(b,{className:`h-4 w-4`,"aria-hidden":!0}),c.history]}),(0,B.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg p-1 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,B.jsx)(j,{className:`h-4 w-4`,"aria-hidden":!0})})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:f?.length?(0,B.jsx)(`ul`,{className:`divide-y divide-edge`,children:f.map(e=>{let r=V[e.trigger]??A,i=t===e.timestamp,o=h===e.timestamp;return(0,B.jsxs)(`li`,{children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:a(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:H(e.trigger,c)}),(0,B.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:L(e.timestamp,v,d)})]}),e.snippet&&(0,B.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,B.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:o?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:c.restoreConfirm}),(0,B.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),_(e.timestamp)},disabled:p,className:`shrink-0 rounded-lg bg-accent px-3 py-1 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:opacity-50`,children:p?`...`:c.restore}),(0,B.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),g(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,B.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),g(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:c.restore})})]},e.timestamp)})}):(0,B.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:c.historyEmpty}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:c.historyEmptyDescription})]})})]})}function oe(e){let t=(0,R.c)(10),{noteId:n,note:r,catalyzing:i,onCatalyze:c,onClose:l,noteThreads:p,openingChat:h,onOpenChat:g,onOpenNewChat:_}=e,v=o(s(se)).notes,y=O(),b=r?.aiDeep?.catalysis,x=b?.report??null,S;t[0]===n?S=t[1]:(S=n?[`note-agent-context-status`,n]:null,t[0]=n,t[1]=S);let C;t[2]===n?C=t[3]:(C=()=>d(n),t[2]=n,t[3]=C);let w;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(w={revalidateOnFocus:!1},t[4]=w):w=t[4];let{data:T,mutate:E,isLoading:D}=u(S,C,w),k;t[5]===n?k=t[6]:(k=async e=>{try{await f(n,e)}catch{}},t[5]=n,t[6]=k);let A=k,j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,B.jsx)(I,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[7]=j):j=t[7];let N;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,B.jsx)(m,{className:`h-4 w-4 rotate-180`,"aria-hidden":!0}),t[8]=N):N=t[8];let P;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,B.jsx)(ee,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[9]=P):P=t[9],(0,B.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[j,(0,B.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:v.catalysisSectionTitle})]}),(0,B.jsx)(`button`,{type:`button`,onClick:l,"aria-label":v.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:N})]}),(0,B.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,B.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:v.catalysisSectionDescription}),T?(0,B.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-base p-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.contextStatusTitle}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void E(()=>ne(n),{revalidate:!1}),disabled:D,className:`rounded-md px-1.5 py-0.5 text-[11px] font-medium text-accent transition-colors hover:bg-accent/10 disabled:cursor-not-allowed disabled:opacity-50`,children:v.contextRebuild}),(0,B.jsx)(`span`,{className:a(`rounded-full px-2 py-0.5 text-[11px] font-medium`,T.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:T.status===`partial`?`bg-amber-500/10 text-amber-600 dark:text-amber-300`:`bg-red-500/10 text-red-600 dark:text-red-300`),children:T.status})]}),(0,B.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:v.contextStatusDetail.replace(`{{attachments}}`,String(T.attachments.length)).replace(`{{tokens}}`,String(T.tokenEstimate??0))}),T.attachments.length>0?(0,B.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:T.attachments.slice(0,5).map(J)}):null]}):null,(0,B.jsx)(`button`,{type:`button`,onClick:c,disabled:i,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:i?v.processing:x?v.recatalyze:v.catalyzeAction}),x?(0,B.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.valueHypothesis}),(0,B.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:x.valueHypothesis})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.targetUsers}),(0,B.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:x.targetUsers.slice(0,5).map(q)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.keyQuestions}),(0,B.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:x.keyQuestions.slice(0,3).map(K)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.mvpPathLabel}),(0,B.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:x.mvpPath.slice(0,3).map(G)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.risks}),(0,B.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:x.risks.slice(0,3).map(W)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.nextActions}),(0,B.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:x.nextActions.slice(0,4).map(U)})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,children:v.confidenceLabel.replace(`{{percent}}`,String(Math.round(x.confidence*100)))}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>void A(`helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,b?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":v.feedbackHelpfulAria,children:(0,B.jsx)(M,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void A(`not_helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,b?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":v.feedbackNotHelpfulAria,children:(0,B.jsx)(F,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]}):(0,B.jsx)(`div`,{className:`mt-4 rounded-lg border border-dashed border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:v.noCatalysisReportHint}),(0,B.jsxs)(`section`,{className:`mt-6 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:[(0,B.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[P,v.relatedThreadsTitle]}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:v.relatedThreadsDescription})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:g,disabled:h,className:`rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,children:h?v.openingChat:v.openThread}),(0,B.jsx)(`button`,{type:`button`,onClick:_,disabled:h,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:v.newThread})]})]}),p.length>0?(0,B.jsx)(`div`,{className:`space-y-2`,children:p.slice(0,5).map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>y(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,B.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||v.noteDiscussionFallback}),(0,B.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:v.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,B.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:v.noThreads})]})]})]})}function U(e){return(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,B.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`)}function W(e){return(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-fg-muted`}),(0,B.jsx)(`span`,{children:e})]},e)}function G(e,t){return(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,B.jsx)(`span`,{children:e})]},e)}function K(e){return(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-accent`}),(0,B.jsx)(`span`,{children:e})]},e)}function q(e){return(0,B.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e)}function J(e){return(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,B.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId)}function se(e){return e.language}var Y=()=>i(()=>import(`./block-editor-C-wDpsf-.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),X=()=>i(()=>import(`./markdown-editor-AssmZFx4.js`).then(e=>e.n),__vite__mapDeps([24,1,3,20,7,25])),ce=(0,z.lazy)(()=>Y().then(e=>({default:e.BlockEditor}))),le=(0,z.lazy)(()=>X().then(e=>({default:e.MarkdownEditor})));function ue(){let e=(0,R.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,B.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,B.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,B.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,B.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,B.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function de(e){let t=(0,R.c)(14),{mode:n,onModeChange:r,labels:i}=e,o;t[0]===i.edit?o=t[1]:(o={id:`wysiwyg`,label:i.edit,Icon:E},t[0]=i.edit,t[1]=o);let s;t[2]===i.source?s=t[3]:(s={id:`source`,label:i.source,Icon:te},t[2]=i.source,t[3]=s);let c;t[4]===i.preview?c=t[5]:(c={id:`preview`,label:i.preview,Icon:y},t[4]=i.preview,t[5]=c);let l;t[6]!==o||t[7]!==s||t[8]!==c?(l=[o,s,c],t[6]=o,t[7]=s,t[8]=c,t[9]=l):l=t[9];let u=l,d;return t[10]!==n||t[11]!==u||t[12]!==r?(d=(0,B.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-edge p-0.5`,children:u.map(e=>{let{id:t,label:i,Icon:o}=e;return(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(t),onMouseEnter:()=>{t===`wysiwyg`&&Y(),t===`source`&&X()},onFocus:()=>{t===`wysiwyg`&&Y(),t===`source`&&X()},className:a(`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium transition-colors`,n===t?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,B.jsx)(o,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i]},t)})}),t[10]=n,t[11]=u,t[12]=r,t[13]=d):d=t[13],d}function Z(e){let t=(0,R.c)(9),{noteId:n,onBack:r,onSaved:i}=e,a=s(Q),c;t[0]===a?c=t[1]:(c=o(a),t[0]=a,t[1]=c);let l=c.notes.lightboxClose,u;t[2]!==n||t[3]!==r||t[4]!==i?(u=(0,B.jsx)(fe,{noteId:n,onBack:r,onSaved:i}),t[2]=n,t[3]=r,t[4]=i,t[5]=u):u=t[5];let d;return t[6]!==l||t[7]!==u?(d=(0,B.jsx)(ie,{closeLabel:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8],d}function Q(e){return e.language}function fe({noteId:e,onBack:t,onSaved:n}){let r=o(s(e=>e.language)).notes,i=O(),d=c(e=>e.resolved)===`dark`,{openImage:f}=re(),[g,v]=(0,z.useState)(`wysiwyg`),[y,x]=(0,z.useState)(null),[C,E]=(0,z.useState)(null),[D,A]=(0,z.useState)(!1),[j,M]=(0,z.useState)(``),[F,te]=(0,z.useState)(360),[ne,ie]=(0,z.useState)(!1),[L,R]=(0,z.useState)(!1),[V,H]=(0,z.useState)(!1),U=(0,z.useRef)(!1),W=(0,z.useRef)(!1),G=(0,z.useRef)(null),K=(0,z.useRef)(null),q=(0,z.useRef)(null),J=(0,z.useRef)(null),se=(0,z.useRef)(null),Y=w(e=>e.setPageHeader),X=w(e=>e.clearPageHeader),{data:Z,mutate:Q}=u(e?[`note-detail`,e]:null,()=>P(e)),{data:fe=[],mutate:pe}=u(e?[`note-threads`,e]:null,()=>S(e),{revalidateOnFocus:!1});(0,z.useEffect)(()=>{U.current=!1,M(``),E(null),x(null),W.current=!1},[e]),(0,z.useEffect)(()=>{!Z||U.current||(M(Z.title??``),U.current=!0)},[Z]);let me=Z?new Date(Z.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,he=(0,z.useMemo)(()=>(0,B.jsx)(`button`,{type:`button`,onClick:t,"aria-label":r.back,className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,T),children:(0,B.jsx)(m,{className:`h-4 w-4`,"aria-hidden":!0})}),[r.back,t]),ge=(0,z.useCallback)(t=>{M(t),e&&(J.current=t,K.current&&clearTimeout(K.current),K.current=setTimeout(async()=>{let t=J.current;if(J.current=null,t!==null){A(!0);try{await _(e,{title:t}),await Q(),n?.()}catch{}finally{A(!1)}}},600))},[e,Q,n]),_e=(0,z.useMemo)(()=>(0,B.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2 px-3 sm:px-5 xl:px-6`,T),children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:j||me||void 0,children:j||me}),D?(0,B.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:r.saving}):null]}),[r.saving,D,me,j]),$=(0,z.useCallback)(async(t=!1)=>{H(!0);try{let n=await h(e,{forceNew:t});await Q(),await pe(),i(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){l({type:`error`,title:r.chatOpenFailedTitle,message:e instanceof Error?e.message:r.chatOpenFailedMessage})}finally{H(!1)}},[Q,pe,i,e,r.chatOpenFailedMessage,r.chatOpenFailedTitle]),ve=(0,z.useCallback)(async()=>{R(!0);try{await p(e),await Q(),l({type:`success`,title:r.catalysisDone})}catch(e){l({type:`error`,title:r.catalysisFailed,message:e instanceof Error?e.message:r.chatOpenFailedMessage})}finally{R(!1)}},[Q,e]),ye=(0,z.useCallback)(()=>{x(y===`breakdown`?null:`breakdown`),!Z?.aiDeep?.catalysis?.report&&!L&&ve()},[y,L,ve,Z?.aiDeep?.catalysis?.report]),be=(0,z.useMemo)(()=>(0,B.jsxs)(`div`,{className:a(`flex items-center gap-2`,T),children:[(0,B.jsxs)(`button`,{type:`button`,onClick:ye,disabled:L,"aria-label":r.catalysisSectionTitle,className:a(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50`,y===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,B.jsx)(I,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),L?r.catalyzing:r.catalyzeButton]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>$(!1),disabled:V,className:a(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,B.jsx)(ee,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),V?r.openingChat:r.openChatButton]}),(0,B.jsx)(de,{mode:g,onModeChange:v,labels:{edit:r.modeEdit,source:r.modeSource,preview:r.modePreview}}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>x(y===`history`?null:`history`),"aria-label":r.history,className:a(`rounded-lg p-1.5 transition-colors`,y===`history`?`bg-accent/10 text-accent`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:(0,B.jsx)(b,{className:`h-4 w-4`,"aria-hidden":!0})})]}),[L,ye,$,g,r.history,r.modeEdit,r.modePreview,r.modeSource,V,y]);(0,z.useLayoutEffect)(()=>(Y({startExtra:he,main:Z?_e:null,end:Z?be:null}),()=>X()),[X,be,_e,he,Z,Y]);let xe=(0,z.useCallback)(t=>{e&&(q.current=t,G.current&&clearTimeout(G.current),G.current=setTimeout(async()=>{let t=q.current;if(q.current=null,t!==null){A(!0);try{await _(e,{markdown:t}),await Q(),n?.()}catch(e){l({type:`error`,title:r.saveFailed,message:e instanceof Error?e.message:r.saveFailedHint})}finally{A(!1)}}},600))},[e,Q,r.saveFailed,r.saveFailedHint,n]),Se=(0,z.useCallback)(t=>{N(e,t.timestamp).then(e=>{e&&E(e)})},[e]),Ce=(0,z.useCallback)(()=>{x(null),E(null)},[]),we=(0,z.useCallback)(()=>{x(null),E(null),Q(),n?.()},[Q,n]);if((0,z.useEffect)(()=>()=>{G.current&&clearTimeout(G.current),K.current&&clearTimeout(K.current);let t=q.current,n=J.current;q.current=null,J.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&_(e,r)},[e]),Z===void 0)return(0,B.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,B.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-accent border-t-transparent`})});if(Z===null)return(0,B.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.notFoundTitle}),(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFoundDescription}),(0,B.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:r.back})]});let Te=C!==null,Ee=Te?C.title??``:j,De=Te?C.markdown??``:Z.markdown??``;return(0,B.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,B.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,B.jsx)(`div`,{ref:se,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:Te?(0,B.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[Ee&&(0,B.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Ee}),De?(0,B.jsx)(k,{noteId:e,content:De,className:`opacity-80`}):(0,B.jsx)(`p`,{className:`italic text-fg-muted`,children:r.emptyPreview})]}):(0,B.jsxs)(B.Fragment,{children:[g===`wysiwyg`&&(0,B.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,B.jsx)(`div`,{className:`shrink-0 px-6 pt-4`,children:(0,B.jsx)(`input`,{type:`text`,value:j,onChange:e=>ge(e.target.value),onCompositionStart:()=>{W.current=!0},onCompositionEnd:()=>{W.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!W.current&&!t.isComposing&&(e.preventDefault(),(se.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:r.titlePlaceholder,className:`w-full border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`})}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(ue,{}),children:(0,B.jsx)(ce,{initialContent:Z.markdown??``,onChange:xe,noteId:e},`wysiwyg-${e}`)})})]}),g===`source`&&(0,B.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,B.jsx)(`div`,{className:`shrink-0 px-6 pt-4`,children:(0,B.jsx)(`input`,{type:`text`,value:j,onChange:e=>ge(e.target.value),placeholder:r.titlePlaceholder,className:`w-full border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`})}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(ue,{}),children:(0,B.jsx)(le,{initialContent:Z.markdown??``,onChange:xe,isDark:d},`source-${e}`)})})]}),g===`preview`&&(0,B.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&f(t.currentSrc||t.src,t.alt)},children:[j&&(0,B.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:j}),Z.markdown?(0,B.jsx)(k,{noteId:e,content:Z.markdown,className:`[&_img]:cursor-zoom-in`}):(0,B.jsx)(`p`,{className:`italic text-fg-muted`,children:r.emptyPreview})]})]})})}),(0,B.jsx)(`div`,{className:a(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!ne&&`transition-[width] duration-300 ease-in-out`),style:{width:y?F:0},children:(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,style:{width:F},children:[(0,B.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),ie(!0);let n=e.clientX,r=F,i=e.pointerId,a=e=>{let t=r-(e.clientX-n);te(Math.max(280,Math.min(600,t)))},o=()=>{try{t.releasePointerCapture(i)}catch{}ie(!1),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)},className:a(`absolute left-0 top-0 z-10 h-full w-2 -translate-x-1/2 cursor-col-resize`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,ne&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:y===`history`?(0,B.jsx)(ae,{noteId:e,activeTimestamp:C?.timestamp??null,onSelect:Se,onClose:Ce,onRestored:we}):y===`breakdown`?(0,B.jsx)(oe,{noteId:e,note:Z??null,catalyzing:L,onCatalyze:ve,onClose:()=>x(null),noteThreads:fe,openingChat:V,onOpenChat:()=>$(!1),onOpenNewChat:()=>$(!0)}):null})]})})]})}function pe(){let e=(0,R.c)(5),{noteId:t}=g(),n=O(),r;e[0]===n?r=e[1]:(r=()=>{n(`/notes`)},e[0]=n,e[1]=r);let i=r;if(!t)return null;let a;return e[2]!==i||e[3]!==t?(a=(0,B.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-6xl flex-1 flex-col`,children:(0,B.jsx)(Z,{noteId:t,onBack:i})}),e[2]=i,e[3]=t,e[4]=a):a=e[4],a}export{pe as NoteDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{Yi as a,_i as o,di as s,fi as c,gi as l,hi as u,mi as d}from"./index-C8ytlAF2.js";var f=n(),p=e(t(),1),m=r(),h=(0,p.createContext)(null);function g(){let e=(0,f.c)(1),t=(0,p.useContext)(h);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={openImage:_},e[0]=t):t=e[0],t}return t}function _(){}function v(e){let t=(0,f.c)(22),{children:n,closeLabel:r}=e,g=r===void 0?`Close`:r,[_,v]=(0,p.useState)(null),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=(e,t)=>{v({src:e,alt:t})},t[0]=y):y=t[0];let b=y,x;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x={openImage:b},t[1]=x):x=t[1];let S=x,C=_!==null,w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=e=>{e||v(null)},t[2]=w):w=t[2];let T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,m.jsx)(d,{className:`fixed inset-0 z-[70] bg-scrim/90 backdrop-blur-sm`}),t[3]=T):T=t[3];let E;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(E=i(`fixed inset-0 z-[71] flex items-center justify-center p-4 outline-none`,`data-[state=open]:animate-in data-[state=closed]:animate-out`),t[4]=E):E=t[4];let D=_?.alt||`Image preview`,O;t[5]===D?O=t[6]:(O=(0,m.jsx)(o,{className:`sr-only`,children:D}),t[5]=D,t[6]=O);let k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,m.jsx)(a,{className:`h-5 w-5`,"aria-hidden":!0}),t[7]=k):k=t[7];let A;t[8]===g?A=t[9]:(A=(0,m.jsx)(s,{asChild:!0,children:(0,m.jsx)(`button`,{type:`button`,"aria-label":g,className:`absolute right-4 top-4 z-10 rounded-lg bg-surface-panel/80 p-2 text-fg-muted backdrop-blur transition-colors hover:bg-surface-hover hover:text-fg`,children:k})}),t[8]=g,t[9]=A);let j;t[10]===_?j=t[11]:(j=_?(0,m.jsx)(`img`,{src:_.src,alt:_.alt??``,className:`max-h-[min(90vh,900px)] max-w-[min(95vw,1200px)] rounded-lg object-contain shadow-lg`}):null,t[10]=_,t[11]=j);let M;t[12]!==A||t[13]!==j||t[14]!==O?(M=(0,m.jsxs)(u,{children:[T,(0,m.jsxs)(c,{className:E,"aria-describedby":void 0,children:[O,A,j]})]}),t[12]=A,t[13]=j,t[14]=O,t[15]=M):M=t[15];let N;t[16]!==M||t[17]!==C?(N=(0,m.jsx)(l,{open:C,onOpenChange:w,children:M}),t[16]=M,t[17]=C,t[18]=N):N=t[18];let P;return t[19]!==n||t[20]!==N?(P=(0,m.jsxs)(h.Provider,{value:S,children:[n,N]}),t[19]=n,t[20]=N,t[21]=P):P=t[21],P}export{g as n,v as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-BqzIDrlr.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s}from"./fetch-CTsREQIe.js";import{r as c}from"./toast-z0toXu32.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{Aa as u,Gt as d,Ht as f,It as p,Ja as m,Ka as h,Ls as g,Lt as _,Ot as v,Pt as y,Rt as b,Si as x,Ti as S,Ws as C,Ya as w,Yo as T,Yt as E,Za as D,ao as O,ba as k,do as A,ha as j,ja as M,jo as N,ko as P,ks as F,oa as I,rt as L,va as R,yo as z}from"./index-C8ytlAF2.js";import{t as B}from"./voice-player-store-1U3vFppm.js";import{n as V,r as ee,t as te}from"./note-time-hm6JO_Wi.js";import{a as ne,i as re,n as H,o as ie,r as ae,t as oe}from"./dist-By6Rh2ee.js";var se=n(),U=e(t(),1),W=r();function ce(e){let t=(0,se.c)(15),{noteId:n,attachmentId:r,className:a}=e,[o,s]=(0,U.useState)(!1),c;t[0]!==r||t[1]!==n?(c=E(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c;if(o){let e;t[3]===a?e=t[4]:(e=i(`flex size-12 shrink-0 items-center justify-center rounded-lg border border-edge-subtle bg-surface-hover text-fg-muted`,a),t[3]=a,t[4]=e);let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsx)(N,{className:`h-4 w-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,W.jsx)(`div`,{className:e,"aria-hidden":!0,children:n}),t[6]=e,t[7]=r),r}let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>s(!0),t[8]=u):u=t[8];let f;t[9]===a?f=t[10]:(f=i(`size-12 shrink-0 rounded-lg border border-edge-subtle bg-surface-hover object-cover`,a),t[9]=a,t[10]=f);let p;return t[11]!==n||t[12]!==l||t[13]!==f?(p=(0,W.jsx)(d,{src:l,expectedNoteId:n,alt:``,loading:`lazy`,draggable:!1,onLoadFailed:u,className:f}),t[11]=n,t[12]=l,t[13]=f,t[14]=p):p=t[14],p}function G(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,`0`)}`}function le(e){let t=(0,se.c)(38),{noteId:n,attachmentId:r,durationSec:a,className:o}=e,{playing:s,loading:c,currentTime:l,duration:u,noteId:d,attachmentId:f}=B(),p=B(q),m=d===n&&f===r,g=m&&s,_=m&&c,v=m?l:0,y=m&&u>0?u:a??0,b=y>0?Math.min(v/y*100,100):0,x;t[0]!==r||t[1]!==a||t[2]!==n||t[3]!==p?(x=e=>{e.stopPropagation(),p(n,r,a)},t[0]=r,t[1]=a,t[2]=n,t[3]=p,t[4]=x):x=t[4];let S=x,C;t[5]!==r||t[6]!==a||t[7]!==n||t[8]!==p?(C=e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),p(n,r,a))},t[5]=r,t[6]=a,t[7]=n,t[8]=p,t[9]=C):C=t[9];let w=C,T;t[10]===o?T=t[11]:(T=i(`flex items-center gap-2`,o),t[10]=o,t[11]=T);let E=g?`bg-accent text-white`:`bg-accent/10 text-accent hover:bg-accent/20`,O;t[12]===E?O=t[13]:(O=i(`flex h-7 w-7 shrink-0 items-center justify-center rounded-full transition-colors`,E),t[12]=E,t[13]=O);let k=g?`Pause`:`Play`,j;t[14]!==_||t[15]!==g?(j=_?(0,W.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`}):g?(0,W.jsx)(D,{className:`h-3.5 w-3.5`}):(0,W.jsx)(h,{className:`h-3.5 w-3.5 ml-0.5`}),t[14]=_,t[15]=g,t[16]=j):j=t[16];let M;t[17]!==S||t[18]!==w||t[19]!==O||t[20]!==k||t[21]!==j?(M=(0,W.jsx)(`button`,{type:`button`,onClick:S,onKeyDown:w,className:O,"aria-label":k,children:j}),t[17]=S,t[18]=w,t[19]=O,t[20]=k,t[21]=j,t[22]=M):M=t[22];let N=`${b}%`,P;t[23]===N?P=t[24]:(P=(0,W.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,W.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:N}})}),t[23]=N,t[24]=P);let F;t[25]!==y||t[26]!==m||t[27]!==v?(F=G(m&&v>0?v:y),t[25]=y,t[26]=m,t[27]=v,t[28]=F):F=t[28];let I;t[29]===F?I=t[30]:(I=(0,W.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:F}),t[29]=F,t[30]=I);let L;t[31]!==P||t[32]!==I?(L=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[P,I]}),t[31]=P,t[32]=I,t[33]=L):L=t[33];let R;return t[34]!==L||t[35]!==T||t[36]!==M?(R=(0,W.jsxs)(`div`,{className:T,onClick:K,children:[M,L]}),t[34]=L,t[35]=T,t[36]=M,t[37]=R):R=t[37],R}function K(e){return e.stopPropagation()}function q(e){return e.toggle}var ue={thought:z,todo:k,voice:O,media:P,bookmark:F,mixed:z,task:k};function de(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function J(e){let t=(0,se.c)(78),{note:n,onPress:r,onPin:a,onArchive:o,onDelete:s,labels:c,timeLabels:l}=e,u=ue[n.kind]||z,d;t[0]!==c||t[1]!==n?(d=de(n,c),t[0]=c,t[1]=n,t[2]=d):d=t[2];let f=d,p=!n.snippet?.trim(),[h]=(0,U.useState)(Y),_;t[3]!==n.createdAt||t[4]!==h||t[5]!==l?(_=ee(n.createdAt,h,l),t[3]=n.createdAt,t[4]=h,t[5]=l,t[6]=_):_=t[6];let v=_,y,b;t[7]!==n.id||t[8]!==r?(y=()=>r(n.id),b=e=>{(e.key===`Enter`||e.key===` `)&&r(n.id)},t[7]=n.id,t[8]=r,t[9]=y,t[10]=b):(y=t[9],b=t[10]);let x;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(x=i(`group relative flex cursor-pointer flex-col gap-2 rounded-xl border border-edge-subtle bg-surface-base p-4`,`transition-colors duration-150 ease-out hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[11]=x):x=t[11];let S;t[12]!==u||t[13]!==n.coverAttachmentId||t[14]!==n.id||t[15]!==n.kind||t[16]!==n.voiceAttachmentId||t[17]!==n.voiceDurationSec?(S=n.coverAttachmentId?(0,W.jsx)(ce,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,W.jsx)(le,{noteId:n.id,attachmentId:n.voiceAttachmentId,durationSec:n.voiceDurationSec,className:`mt-0.5 w-32 shrink-0`}):(0,W.jsx)(u,{className:`mt-0.5 h-4 w-4 shrink-0 text-fg-muted`}),t[12]=u,t[13]=n.coverAttachmentId,t[14]=n.id,t[15]=n.kind,t[16]=n.voiceAttachmentId,t[17]=n.voiceDurationSec,t[18]=S):S=t[18];let C;t[19]===n.title?C=t[20]:(C=n.title&&(0,W.jsx)(`h3`,{className:`mb-0.5 truncate text-sm font-semibold text-fg`,children:n.title}),t[19]=n.title,t[20]=C);let E=n.title?`text-fg-muted`:p?`italic text-fg-muted`:`text-fg`,D;t[21]===E?D=t[22]:(D=i(`text-sm line-clamp-3`,E),t[21]=E,t[22]=D);let O;t[23]!==f||t[24]!==D?(O=(0,W.jsx)(`p`,{className:D,children:f}),t[23]=f,t[24]=D,t[25]=O):O=t[25];let k;t[26]!==O||t[27]!==C?(k=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[C,O]}),t[26]=O,t[27]=C,t[28]=k):k=t[28];let A;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,W.jsx)(ie,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,onClick:me,className:`shrink-0 rounded-md p-1 text-fg-muted opacity-0 transition-opacity group-hover:opacity-100 hover:bg-surface-hover focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":`Actions`,children:(0,W.jsx)(T,{className:`h-4 w-4`})})}),t[29]=A):A=t[29];let j;t[30]!==n.id||t[31]!==n.pinned||t[32]!==a?(j=()=>a(n.id,!n.pinned),t[30]=n.id,t[31]=n.pinned,t[32]=a,t[33]=j):j=t[33];let M;t[34]===n.pinned?M=t[35]:(M=n.pinned?(0,W.jsx)(m,{className:`h-4 w-4`}):(0,W.jsx)(w,{className:`h-4 w-4`}),t[34]=n.pinned,t[35]=M);let N=n.pinned?c.unpin:c.pin,P;t[36]!==j||t[37]!==M||t[38]!==N?(P=(0,W.jsxs)(H,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:j,children:[M,N]}),t[36]=j,t[37]=M,t[38]=N,t[39]=P):P=t[39];let F;t[40]!==n.id||t[41]!==o?(F=()=>o(n.id),t[40]=n.id,t[41]=o,t[42]=F):F=t[42];let L;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,W.jsx)(g,{className:`h-4 w-4`}),t[43]=L):L=t[43];let R;t[44]!==c.archive||t[45]!==F?(R=(0,W.jsxs)(H,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:F,children:[L,c.archive]}),t[44]=c.archive,t[45]=F,t[46]=R):R=t[46];let B;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,W.jsx)(ne,{className:`my-1 h-px bg-edge-subtle`}),t[47]=B):B=t[47];let V;t[48]!==n.id||t[49]!==s?(V=()=>s(n.id),t[48]=n.id,t[49]=s,t[50]=V):V=t[50];let te;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,W.jsx)(I,{className:`h-4 w-4`}),t[51]=te):te=t[51];let G;t[52]!==c.delete||t[53]!==V?(G=(0,W.jsxs)(H,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-red-500 outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:V,children:[te,c.delete]}),t[52]=c.delete,t[53]=V,t[54]=G):G=t[54];let K;t[55]!==P||t[56]!==R||t[57]!==G?(K=(0,W.jsxs)(re,{children:[A,(0,W.jsx)(ae,{children:(0,W.jsxs)(oe,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:pe,children:[P,R,B,G]})})]}),t[55]=P,t[56]=R,t[57]=G,t[58]=K):K=t[58];let q;t[59]!==k||t[60]!==K||t[61]!==S?(q=(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[S,k,K]}),t[59]=k,t[60]=K,t[61]=S,t[62]=q):q=t[62];let J;t[63]===n.pinned?J=t[64]:(J=n.pinned&&(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-accent/10 px-1.5 py-0.5 text-xs font-medium text-accent`,children:(0,W.jsx)(w,{className:`h-3 w-3`})}),t[63]=n.pinned,t[64]=J);let X;t[65]===n.tags?X=t[66]:(X=n.tags?.map(fe),t[65]=n.tags,t[66]=X);let Z;t[67]===v?Z=t[68]:(Z=(0,W.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:v}),t[67]=v,t[68]=Z);let Q;t[69]!==J||t[70]!==X||t[71]!==Z?(Q=(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[J,X,Z]}),t[69]=J,t[70]=X,t[71]=Z,t[72]=Q):Q=t[72];let he;return t[73]!==q||t[74]!==Q||t[75]!==y||t[76]!==b?(he=(0,W.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:y,onKeyDown:b,className:x,children:[q,Q]}),t[73]=q,t[74]=Q,t[75]=y,t[76]=b,t[77]=he):he=t[77],he}function fe(e){return(0,W.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e)}function pe(e){return e.stopPropagation()}function me(e){return e.stopPropagation()}function Y(){return Date.now()}var X=3e4;function Z(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function Q({placeholder:e,sendLabel:t,onCapture:n,onImagePick:r,onVoiceCapture:a,recordingLabel:o=`Recording…`,imageDisabled:s=!1,voiceDisabled:c=!1}){let[l,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(0),[v,y]=(0,U.useState)(!1),b=(0,U.useRef)(null),x=(0,U.useRef)(null),S=(0,U.useRef)(null),C=(0,U.useRef)([]),w=(0,U.useRef)(0),T=(0,U.useRef)(null),E=(0,U.useRef)(null),D=(0,U.useCallback)(()=>{T.current&&=(clearInterval(T.current),null),E.current&&=(clearTimeout(E.current),null),S.current?.getTracks().forEach(e=>e.stop()),S.current=null,x.current=null,C.current=[],h(!1),_(0)},[]);(0,U.useEffect)(()=>()=>D(),[D]);let k=(0,U.useCallback)(async()=>{let e=x.current;if(!e||e.state!==`recording`)return;y(!0),await new Promise(t=>{e.addEventListener(`stop`,()=>t(),{once:!0}),e.stop()});let t=Math.max(1,Math.round((Date.now()-w.current)/1e3)),n=e.mimeType||Z()||`audio/webm`,r=new Blob(C.current,{type:n});if(D(),r.size>0&&a){let e=n.includes(`mp4`)?`m4a`:n.includes(`ogg`)?`ogg`:`webm`,i=new File([r],`voice-${Date.now()}.${e}`,{type:n});try{await a(i,t)}finally{y(!1)}return}y(!1)},[D,a]),A=(0,U.useCallback)(async()=>{if(!(!a||v||m)&&!(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`))try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=Z(),n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);S.current=e,x.current=n,C.current=[],w.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&C.current.push(e.data)},n.start(),h(!0),_(0),T.current=setInterval(()=>{_(Math.round((Date.now()-w.current)/1e3))},250),E.current=setTimeout(()=>{k()},X)}catch{D()}},[D,a,m,k,v]),j=(0,U.useCallback)(()=>{if(m){k();return}A()},[m,A,k]),M=(0,U.useCallback)(async e=>{let t=l.trim();if(!(!t||f)){p(!0),d(``);try{await n(t,e)}catch{d(t)}finally{p(!1),b.current?.focus()}}},[l,f,n]),N=(0,U.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),M()),e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),M({navigate:!1}))},[M]),F=f||v;return(0,W.jsxs)(`div`,{className:i(`flex items-center gap-1.5 rounded-2xl border border-edge bg-surface-panel px-2 py-2 shadow-float dark:shadow-elevated`,`focus-within:border-accent focus-within:ring-1 focus-within:ring-accent`,m&&`border-danger ring-1 ring-danger/40`),children:[r&&(0,W.jsx)(`button`,{type:`button`,onClick:r,disabled:F||s||m,className:`shrink-0 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":`Image`,children:(0,W.jsx)(P,{className:`h-4 w-4`})}),a&&(0,W.jsx)(`button`,{type:`button`,onClick:j,disabled:F||c||f,className:i(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,m?`bg-danger-soft text-danger hover:bg-danger-soft`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-label":m?`Stop recording`:`Voice`,"aria-pressed":m,children:m?(0,W.jsx)(R,{className:`h-4 w-4 fill-current`}):(0,W.jsx)(O,{className:`h-4 w-4`})}),m?(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:o.replace(`{{seconds}}`,String(g))}):(0,W.jsx)(`textarea`,{ref:b,value:l,onChange:e=>d(e.target.value),onKeyDown:N,placeholder:e,rows:1,disabled:F,className:`min-h-8 flex-1 resize-none bg-transparent py-1.5 text-sm leading-5 text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:{fieldSizing:`content`}}),(0,W.jsx)(`button`,{type:`button`,disabled:!l.trim()||F||m,onClick:e=>void M({navigate:!e.shiftKey}),"aria-label":t,className:i(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,l.trim()&&!F&&!m?`text-accent hover:bg-accent-soft`:`text-fg-disabled`),children:(0,W.jsx)(u,{className:`h-4 w-4`})})]})}var he={statusFilter:`all`,kindFilter:`all`,search:``};function $(){let e=(0,se.c)(107),t=a(o(xe)).notes,n=!!s(be),[r,u]=(0,U.useReducer)(L,he),[d]=(0,U.useState)(ye),m=C(),h;e[0]!==n||e[1]!==r.kindFilter||e[2]!==r.search||e[3]!==r.statusFilter?(h=n?[`notes-list`,r.statusFilter,r.kindFilter,r.search]:null,e[0]=n,e[1]=r.kindFilter,e[2]=r.search,e[3]=r.statusFilter,e[4]=h):h=e[4];let g=h,w;e[5]!==r.kindFilter||e[6]!==r.search||e[7]!==r.statusFilter?(w=()=>y({status:r.statusFilter===`all`?void 0:r.statusFilter,kind:r.kindFilter===`all`?void 0:r.kindFilter,search:r.search||void 0,limit:100,sortBy:`createdAt`,sortOrder:`desc`}),e[5]=r.kindFilter,e[6]=r.search,e[7]=r.statusFilter,e[8]=w):w=e[8];let T;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(T={keepPreviousData:!0},e[9]=T):T=e[9];let{data:E,mutate:D,isLoading:O}=l(g,w,T),k=O&&!E,A;e[10]===E?.items?A=e[11]:(A=E?.items??[],e[10]=E?.items,e[11]=A);let N=A,P=E?.total??0,F=x(ve),I=x(_e),R=P>0?t.noteCount.replace(`{{count}}`,String(P)):null,z,B;e[12]!==I||e[13]!==n||e[14]!==t.title||e[15]!==R||e[16]!==F?(z=()=>n?(F({startExtra:null,main:(0,W.jsxs)(`div`,{className:i(`flex min-w-0 items-center gap-2 px-3 sm:px-5 xl:px-6`,S),children:[(0,W.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),R?(0,W.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:R}):null]}),end:null}),()=>I()):(I(),()=>I()),B=[I,n,t.title,R,F],e[12]=I,e[13]=n,e[14]=t.title,e[15]=R,e[16]=F,e[17]=z,e[18]=B):(z=e[17],B=e[18]),(0,U.useLayoutEffect)(z,B);let ee;e[19]!==t.daysAgo||e[20]!==t.justNow||e[21]!==t.minutesAgo||e[22]!==t.today||e[23]!==t.yesterday?(ee={justNow:t.justNow,minutesAgo:t.minutesAgo,today:t.today,yesterday:t.yesterday,daysAgo:t.daysAgo},e[19]=t.daysAgo,e[20]=t.justNow,e[21]=t.minutesAgo,e[22]=t.today,e[23]=t.yesterday,e[24]=ee):ee=e[24];let ne=ee,re;e[25]!==D||e[26]!==m?(re=async(e,t)=>{let n=await p(e,`web`);await D(),t?.navigate!==!1&&m(`/notes/${n.id}`)},e[25]=D,e[26]=m,e[27]=re):re=e[27];let H=re,ie;e[28]!==D||e[29]!==t.imageUploadFailed||e[30]!==t.imageUploadFailedHint?(ie=()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.onchange=async()=>{let n=e.files?.[0];if(n)try{await _(n,`web`),await D()}catch(e){let n=e;c({type:`error`,title:t.imageUploadFailed,message:n instanceof Error?n.message:t.imageUploadFailedHint})}},e.click()},e[28]=D,e[29]=t.imageUploadFailed,e[30]=t.imageUploadFailedHint,e[31]=ie):ie=e[31];let ae=ie,oe;e[32]!==D||e[33]!==t.voiceUploadFailed||e[34]!==t.voiceUploadFailedHint?(oe=async(e,n)=>{try{await b(e,n,`web`),await D()}catch(e){let n=e;c({type:`error`,title:t.voiceUploadFailed,message:n instanceof Error?n.message:t.voiceUploadFailedHint})}},e[32]=D,e[33]=t.voiceUploadFailed,e[34]=t.voiceUploadFailedHint,e[35]=oe):oe=e[35];let ce=oe,G;e[36]===D?G=e[37]:(G=async(e,t)=>{await f(e,{pinned:t}),await D()},e[36]=D,e[37]=G);let le=G,K;e[38]===D?K=e[39]:(K=async e=>{await f(e,{status:`archived`}),await D()},e[38]=D,e[39]=K);let q=K,ue;e[40]===D?ue=e[41]:(ue=async e=>{await v(e),await D()},e[40]=D,e[41]=ue);let de=ue,fe;e[42]===m?fe=e[43]:(fe=e=>{m(`/notes/${e}`)},e[42]=m,e[43]=fe);let pe=fe;if(!n){let n;e[44]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsx)(j,{className:`h-10 w-10 text-fg-muted`}),e[44]=n):n=e[44];let r;return e[45]===t.needToken?r=e[46]:(r=(0,W.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[n,(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]}),e[45]=t.needToken,e[46]=r),r}let me;e[47]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,W.jsx)(M,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),e[47]=me):me=e[47];let Y;e[48]===u?Y=e[49]:(Y=e=>u({type:`patch`,patch:{search:e.target.value}}),e[48]=u,e[49]=Y);let X;e[50]!==t.searchPlaceholder||e[51]!==Y||e[52]!==r.search?(X=(0,W.jsxs)(`div`,{className:`relative`,children:[me,(0,W.jsx)(`input`,{type:`search`,value:r.search,onChange:Y,placeholder:t.searchPlaceholder,className:`w-full rounded-xl border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`})]}),e[50]=t.searchPlaceholder,e[51]=Y,e[52]=r.search,e[53]=X):X=e[53];let Z;e[54]===Symbol.for(`react.memo_cache_sentinel`)?(Z=[`all`,`inbox`,`processed`,`archived`],e[54]=Z):Z=e[54];let $;e[55]!==u||e[56]!==t.filterAll||e[57]!==t.filterArchived||e[58]!==t.filterInbox||e[59]!==t.filterProcessed||e[60]!==r.statusFilter?($=Z.map(e=>{let n=e===`all`?t.filterAll:e===`inbox`?t.filterInbox:e===`processed`?t.filterProcessed:t.filterArchived;return(0,W.jsx)(`button`,{type:`button`,onClick:()=>u({type:`patch`,patch:{statusFilter:e}}),className:i(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,r.statusFilter===e?`bg-accent text-white`:`bg-surface-hover text-fg-muted hover:text-fg`),children:n},e)}),e[55]=u,e[56]=t.filterAll,e[57]=t.filterArchived,e[58]=t.filterInbox,e[59]=t.filterProcessed,e[60]=r.statusFilter,e[61]=$):$=e[61];let Se,Ce;e[62]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,W.jsx)(`div`,{className:`mx-1 h-4 w-px bg-edge-subtle`}),Ce=[`all`,`thought`,`todo`,`voice`,`media`,`bookmark`],e[62]=Se,e[63]=Ce):(Se=e[62],Ce=e[63]);let we;e[64]!==u||e[65]!==t.kindAll||e[66]!==t.kindBookmark||e[67]!==t.kindMedia||e[68]!==t.kindThought||e[69]!==t.kindTodo||e[70]!==t.kindVoice||e[71]!==r.kindFilter?(we=Ce.map(e=>{let n=e===`all`?t.kindAll:e===`thought`?t.kindThought:e===`todo`?t.kindTodo:e===`voice`?t.kindVoice:e===`media`?t.kindMedia:t.kindBookmark;return(0,W.jsx)(`button`,{type:`button`,onClick:()=>u({type:`patch`,patch:{kindFilter:e}}),className:i(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,r.kindFilter===e?`bg-accent text-white`:`bg-surface-hover text-fg-muted hover:text-fg`),children:n},e)}),e[64]=u,e[65]=t.kindAll,e[66]=t.kindBookmark,e[67]=t.kindMedia,e[68]=t.kindThought,e[69]=t.kindTodo,e[70]=t.kindVoice,e[71]=r.kindFilter,e[72]=we):we=e[72];let Te;e[73]!==$||e[74]!==we?(Te=(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[$,Se,we]}),e[73]=$,e[74]=we,e[75]=Te):Te=e[75];let Ee;e[76]!==X||e[77]!==Te?(Ee=(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4 p-4 pb-2`,children:[X,Te]}),e[76]=X,e[77]=Te,e[78]=Ee):Ee=e[78];let De;e[79]!==q||e[80]!==de||e[81]!==pe||e[82]!==le||e[83]!==t.archive||e[84]!==t.delete||e[85]!==t.imageNote||e[86]!==t.noNotes||e[87]!==t.noNotesDescription||e[88]!==t.noText||e[89]!==t.pin||e[90]!==t.unpin||e[91]!==N||e[92]!==d||e[93]!==k||e[94]!==ne?(De=(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pt-3 pb-24 [scrollbar-gutter:stable]`,children:k?(0,W.jsx)(`div`,{className:`flex flex-col gap-3`,children:[1,2,3].map(ge)}):N.length===0?(0,W.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] flex-col items-center justify-center gap-2 py-16 text-center`,children:[(0,W.jsx)(j,{className:`h-8 w-8 text-fg-muted`}),(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:t.noNotes}),(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.noNotesDescription})]}):(0,W.jsx)(`div`,{className:`flex flex-col gap-3`,children:N.map((e,n)=>{let r=n>0?te(N[n-1].createdAt):null;return(0,W.jsxs)(`div`,{children:[te(e.createdAt)!==r&&(0,W.jsx)(`div`,{className:i(`pb-2 text-xs font-medium text-fg-muted`,n>0&&`pt-2`),children:V(e.createdAt,d,ne)}),(0,W.jsx)(J,{note:e,onPress:pe,onPin:le,onArchive:q,onDelete:de,timeLabels:ne,labels:{pin:t.pin,unpin:t.unpin,archive:t.archive,delete:t.delete,imageNote:t.imageNote,noText:t.noText}})]},e.id)})})}),e[79]=q,e[80]=de,e[81]=pe,e[82]=le,e[83]=t.archive,e[84]=t.delete,e[85]=t.imageNote,e[86]=t.noNotes,e[87]=t.noNotesDescription,e[88]=t.noText,e[89]=t.pin,e[90]=t.unpin,e[91]=N,e[92]=d,e[93]=k,e[94]=ne,e[95]=De):De=e[95];let Oe;e[96]!==H||e[97]!==ae||e[98]!==ce||e[99]!==t.quickCapturePlaceholder||e[100]!==t.recording||e[101]!==t.send?(Oe=(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10 bg-gradient-to-t from-surface-panel from-60% via-surface-panel/90 to-transparent px-4 pb-[max(0.75rem,env(safe-area-inset-bottom))] pt-6`,children:(0,W.jsx)(`div`,{className:`pointer-events-auto`,children:(0,W.jsx)(Q,{placeholder:t.quickCapturePlaceholder,sendLabel:t.send,onCapture:H,onImagePick:ae,onVoiceCapture:ce,recordingLabel:t.recording})})}),e[96]=H,e[97]=ae,e[98]=ce,e[99]=t.quickCapturePlaceholder,e[100]=t.recording,e[101]=t.send,e[102]=Oe):Oe=e[102];let ke;return e[103]!==Ee||e[104]!==De||e[105]!==Oe?(ke=(0,W.jsxs)(`div`,{className:`relative mx-auto flex h-full min-h-0 w-full max-w-3xl flex-1 flex-col overflow-hidden`,children:[Ee,De,Oe]}),e[103]=Ee,e[104]=De,e[105]=Oe,e[106]=ke):ke=e[106],ke}function ge(e){return(0,W.jsx)(`div`,{className:`h-24 animate-pulse rounded-xl bg-surface-hover`},e)}function _e(e){return e.clearPageHeader}function ve(e){return e.setPageHeader}function ye(){return Date.now()}function be(e){return e.token}function xe(e){return e.language}export{$ as NotesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Ci as r,Xo as i,qo as a,zi as o}from"./index-C8ytlAF2.js";var s=e(),c=t();function l(e){let t=(0,s.c)(31),{message:l,downloadLabel:u,onDownload:d,openSystemLabel:f,onOpenWithSystemApp:p,chooseAppLabel:m,onChooseOpenWithApp:h,canOpenWithSystemApp:g,canChooseOpenWithApp:_}=e,v=g===void 0?!0:g,y=_===void 0?!0:_,b;t[0]!==v||t[1]!==p||t[2]!==f?(b=r()&&v&&typeof p==`function`&&typeof f==`string`&&f.length>0,t[0]=v,t[1]=p,t[2]=f,t[3]=b):b=t[3];let x=b,S;t[4]!==y||t[5]!==m||t[6]!==h?(S=r()&&y&&typeof h==`function`&&typeof m==`string`&&m.length>0,t[4]=y,t[5]=m,t[6]=h,t[7]=S):S=t[7];let C=S,w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w=n(`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-hover/60 p-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge`),t[8]=w):w=t[8];let T;t[9]===l?T=t[10]:(T=(0,c.jsx)(`p`,{className:`min-w-0 text-xs leading-relaxed text-fg-muted`,children:l}),t[9]=l,t[10]=T);let E;t[11]!==p||t[12]!==f||t[13]!==x?(E=x?(0,c.jsxs)(`button`,{type:`button`,className:n(`inline-flex items-center gap-1.5 rounded-md border border-edge bg-surface-panel px-3 py-1.5 text-xs font-medium text-fg shadow-sm dark:border-edge`,o.transition,o.press,o.focusRingPanel),onClick:()=>void p?.(),children:[(0,c.jsx)(a,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),f]}):null,t[11]=p,t[12]=f,t[13]=x,t[14]=E):E=t[14];let D;t[15]!==m||t[16]!==h||t[17]!==C?(D=C?(0,c.jsxs)(`button`,{type:`button`,className:n(`inline-flex items-center gap-1.5 rounded-md border border-edge bg-surface-panel px-3 py-1.5 text-xs font-medium text-fg shadow-sm dark:border-edge`,o.transition,o.press,o.focusRingPanel),onClick:()=>void h?.(),children:[(0,c.jsx)(a,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),m]}):null,t[15]=m,t[16]=h,t[17]=C,t[18]=D):D=t[18];let O;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(O=n(`inline-flex items-center gap-1.5 rounded-md border border-accent bg-accent px-3 py-1.5 text-xs font-medium text-white shadow-sm`,o.transition,o.press,o.focusRingPanel),t[19]=O):O=t[19];let k;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,c.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[20]=k):k=t[20];let A;t[21]!==u||t[22]!==d?(A=(0,c.jsxs)(`button`,{type:`button`,className:O,onClick:d,children:[k,u]}),t[21]=u,t[22]=d,t[23]=A):A=t[23];let j;t[24]!==A||t[25]!==E||t[26]!==D?(j=(0,c.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[E,D,A]}),t[24]=A,t[25]=E,t[26]=D,t[27]=j):j=t[27];let M;return t[28]!==j||t[29]!==T?(M=(0,c.jsxs)(`div`,{className:w,children:[T,j]}),t[28]=j,t[29]=T,t[30]=M):M=t[30],M}export{l as t};
|