@xopcai/xopc 0.0.115 → 0.0.117
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 +26 -10
- package/README.zh-CN.md +26 -10
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/demo-memory/src/index.d.ts +6 -0
- package/dist/extensions/demo-memory/src/index.js +132 -0
- package/dist/extensions/demo-memory/src/index.js.map +1 -0
- package/dist/extensions/demo-memory/xopc.extension.json +15 -0
- package/dist/extensions/feishu/src/schema/config-schema.d.ts +3 -3
- package/dist/extensions/telegram/src/command-handler.js +1 -2
- package/dist/extensions/telegram/src/command-handler.js.map +1 -1
- package/dist/extensions/telegram/src/config-schema.d.ts +8 -8
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/config-schema.d.ts +3 -3
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DVnBfANm.js → agent-avatar-dicebear-BBLhJ2C6.js} +1 -1
- package/dist/gateway/static/root/assets/agents-C6xgagZd.js +71 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-CBpLONvG.js +1 -0
- package/dist/gateway/static/root/assets/{appearance-settings-BQpPSTHD.js → appearance-settings-CGcc54yj.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-DdDx0V4z.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CXu-Csep.js → archive-plugin-DZsVqMhU.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BAjgOoGY.js → attachment-load-CIol6JWX.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-BSBgB2hO.js → binary-plugins-B3UauMfp.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BpXw9TTR.js → block-editor-2HJoFchH.js} +3 -3
- package/dist/gateway/static/root/assets/browser-settings-page-CUOO-PQk.js +8 -0
- package/dist/gateway/static/root/assets/capability-presets-api-XQoMTI0A.js +1 -0
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-CfqF-kGr.js +1 -0
- package/dist/gateway/static/root/assets/{channels-settings-BbPUpzWB.js → channels-settings-BYyRzsex.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-DIvEz4NX.js +2 -0
- package/dist/gateway/static/root/assets/cron-api-R41aQCX9.js +1 -0
- package/dist/gateway/static/root/assets/cron-page-D97nFqQD.js +3 -0
- package/dist/gateway/static/root/assets/dreaming-settings-Bceaw1PG.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-D9kgUHCc.js → extension-debug-page-DX5WRE_t.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CGyhXqzR.js → extension-page-Buah7Bw-.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DL8Xquqd.js → extension-settings-page-DuroLVnf.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-D0VXA932.js → fetch-B5zdl27C.js} +1 -1
- package/dist/gateway/static/root/assets/{format-interval-label-Be8SmgUw.js → format-interval-label-Dn_QKIqb.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-config-api-gT4ZhE7h.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-iISWAZRm.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DERUH61L.js → gateway-startup-retry-B3kL8KGY.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DCUROLMQ.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-BPmqWk90.js → goals-config-api-AR-fVh0P.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-Cpb21ezg.js +2 -0
- package/dist/gateway/static/root/assets/goals-settings-CPAuFwoD.js +1 -0
- package/dist/gateway/static/root/assets/{heartbeat-config-api-Bfdzr8oV.js → heartbeat-config-api-D7bKFEeO.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-CC69vNx0.js +1 -0
- package/dist/gateway/static/root/assets/index-CwhK8qCh.js +122 -0
- package/dist/gateway/static/root/assets/index-CyfhARL-.css +1 -0
- package/dist/gateway/static/root/assets/{interval-presets-utKbuCRY.js → interval-presets-0DtsnxE0.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CjqS6c6V.js → keyboard-shortcuts-settings-BPREtN8B.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DefCgF4o.js +2 -0
- package/dist/gateway/static/root/assets/{markdown-split-DW8C47iB.js → markdown-split-ChbR9LGO.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-D6HwDhDT.js → media-plugins-B82oP80n.js} +1 -1
- package/dist/gateway/static/root/assets/messages-Cf1O9JB0.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-DmKiIihT.js +2 -0
- package/dist/gateway/static/root/assets/note-detail-page-CxxfLRJZ.js +2 -0
- package/dist/gateway/static/root/assets/{note-image-lightbox-pJM35Pz5.js → note-image-lightbox-CDknITM3.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-X2slSx7V.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CVwHuyN6.js → preview-open-alternatives-DV3xQsWB.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BvmUWqgu.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-Ba-UEk7x.js → save-bar-controls-BODCXnvY.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-CNN9595U.js → schedule-field-CgJSCD3B.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DnNMmtD5.js → schema-form-qtfEI6QM.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-B0yESuuL.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-q2M8RKOo.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-CmOz80i5.js → settings-collapsible-section-BHZKjVcS.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-BmK7JJOV.js → settings-form-section-5i35D-J1.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-CGozabLD.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-FoOSe6nU.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-Dp2qGrHC.js → share-preview-page-B0H63tDv.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Cy5zWyYQ.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DaZNFro9.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-CnwtUzvw.js +2 -0
- package/dist/gateway/static/root/assets/system-settings-panel-DXs2VmBt.js +1 -0
- package/dist/gateway/static/root/assets/typed-models-lib-4gPuydz_.js +1 -0
- package/dist/gateway/static/root/assets/{use-channel-catalog-CHlO8J9G.js → use-channel-catalog-BCjP_VHb.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-DvKiOglO.js +1 -0
- package/dist/gateway/static/root/assets/{voice-player-store-DDDWYHvg.js → voice-player-store-BlF9V05n.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-CAVZcONQ.js +18 -0
- package/dist/gateway/static/root/index.html +5 -5
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +1 -1
- package/dist/src/agent/agent-manager.js +7 -8
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/agent-scope.js +6 -8
- package/dist/src/agent/agent-scope.js.map +1 -1
- package/dist/src/agent/background-review/coordinator.js +0 -1
- package/dist/src/agent/background-review/coordinator.js.map +1 -1
- package/dist/src/agent/background-review/run-background-review.d.ts +0 -2
- package/dist/src/agent/background-review/run-background-review.js +2 -4
- package/dist/src/agent/background-review/run-background-review.js.map +1 -1
- package/dist/src/agent/background-review/settings.js +8 -7
- package/dist/src/agent/background-review/settings.js.map +1 -1
- package/dist/src/agent/bootstrap/bootstrap-context.d.ts +2 -2
- package/dist/src/agent/bootstrap/bootstrap-context.js +4 -4
- package/dist/src/agent/bootstrap/bootstrap-context.js.map +1 -1
- package/dist/src/agent/context/workspace-seed.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js.map +1 -1
- package/dist/src/agent/fallback/candidates.js +6 -3
- package/dist/src/agent/fallback/candidates.js.map +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/post-turn.js +8 -1
- package/dist/src/agent/goals/post-turn.js.map +1 -1
- package/dist/src/agent/image/generation/runtime-types.d.ts +2 -0
- package/dist/src/agent/image/generation/runtime.js +1 -1
- package/dist/src/agent/image/generation/runtime.js.map +1 -1
- package/dist/src/agent/image/image-helpers.d.ts +1 -1
- package/dist/src/agent/image/image-helpers.js +4 -17
- package/dist/src/agent/image/image-helpers.js.map +1 -1
- package/dist/src/agent/image/image-model-fallback.js +1 -1
- package/dist/src/agent/image/image-model-fallback.js.map +1 -1
- package/dist/src/agent/image/inbound-image-handling.js +1 -1
- package/dist/src/agent/image/inbound-image-handling.js.map +1 -1
- package/dist/src/agent/image/tool-model-config.d.ts +1 -1
- package/dist/src/agent/image/tool-model-config.js +2 -2
- package/dist/src/agent/image/tool-model-config.js.map +1 -1
- 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/mcp/resolve-embedded-mcp-tools.js +1 -1
- package/dist/src/agent/mcp/resolve-embedded-mcp-tools.js.map +1 -1
- package/dist/src/agent/media-generation/runtime-shared.d.ts +5 -2
- package/dist/src/agent/media-generation/runtime-shared.js +1 -1
- package/dist/src/agent/media-generation/runtime-shared.js.map +1 -1
- package/dist/src/agent/memory/builtin-memory-store.d.ts +2 -0
- package/dist/src/agent/memory/builtin-memory-store.js +4 -0
- package/dist/src/agent/memory/builtin-memory-store.js.map +1 -1
- package/dist/src/agent/memory/builtin-provider.d.ts +31 -9
- package/dist/src/agent/memory/builtin-provider.js +261 -11
- package/dist/src/agent/memory/builtin-provider.js.map +1 -1
- package/dist/src/agent/memory/context-assembler.d.ts +10 -0
- package/dist/src/agent/memory/context-assembler.js +26 -0
- package/dist/src/agent/memory/context-assembler.js.map +1 -0
- package/dist/src/agent/memory/create-memory-manager.js +25 -7
- package/dist/src/agent/memory/create-memory-manager.js.map +1 -1
- package/dist/src/agent/memory/dreaming/config.d.ts +1 -6
- package/dist/src/agent/memory/dreaming/config.js +8 -8
- package/dist/src/agent/memory/dreaming/config.js.map +1 -1
- package/dist/src/agent/memory/dreaming/deep-promotion.d.ts +2 -0
- package/dist/src/agent/memory/dreaming/deep-promotion.js +24 -0
- package/dist/src/agent/memory/dreaming/deep-promotion.js.map +1 -1
- package/dist/src/agent/memory/index.d.ts +1 -0
- package/dist/src/agent/memory/index.js +4 -3
- package/dist/src/agent/memory/inject-prefetch.js +6 -2
- package/dist/src/agent/memory/inject-prefetch.js.map +1 -1
- package/dist/src/agent/memory/manager.d.ts +37 -1
- package/dist/src/agent/memory/manager.js +332 -40
- package/dist/src/agent/memory/manager.js.map +1 -1
- package/dist/src/agent/memory/memory-config.js +12 -15
- package/dist/src/agent/memory/memory-config.js.map +1 -1
- package/dist/src/agent/memory/plugin-discovery.d.ts +19 -5
- package/dist/src/agent/memory/plugin-discovery.js +97 -31
- package/dist/src/agent/memory/plugin-discovery.js.map +1 -1
- package/dist/src/agent/memory/provider.d.ts +20 -15
- package/dist/src/agent/memory/stub-memory-provider.d.ts +17 -2
- package/dist/src/agent/memory/stub-memory-provider.js +20 -3
- package/dist/src/agent/memory/stub-memory-provider.js.map +1 -1
- package/dist/src/agent/memory/types.d.ts +136 -0
- package/dist/src/agent/models/manager.d.ts +1 -1
- package/dist/src/agent/models/manager.js +1 -1
- package/dist/src/agent/models/manager.js.map +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.d.ts +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js +2 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
- package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.d.ts +2 -2
- package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.js +1 -1
- package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.js.map +1 -1
- package/dist/src/agent/orchestration/run-agent-turn-with-timeout.d.ts +2 -6
- package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +2 -8
- package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js.map +1 -1
- package/dist/src/agent/reply/post-compaction-context.js +11 -6
- package/dist/src/agent/reply/post-compaction-context.js.map +1 -1
- package/dist/src/agent/reply/startup-context.js +8 -9
- package/dist/src/agent/reply/startup-context.js.map +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +1 -4
- package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
- package/dist/src/agent/service/session-context-report.js +1 -1
- package/dist/src/agent/service/session-context-report.js.map +1 -1
- package/dist/src/agent/service.js +21 -25
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/service.types.d.ts +1 -2
- package/dist/src/agent/session/session-hydrator.js +1 -2
- package/dist/src/agent/session/session-hydrator.js.map +1 -1
- package/dist/src/agent/session/session-inspector.d.ts +1 -1
- package/dist/src/agent/session/session-inspector.js +9 -14
- package/dist/src/agent/session/session-inspector.js.map +1 -1
- package/dist/src/agent/skills/hub-pull.js +1 -1
- package/dist/src/agent/starter-agents.d.ts +1 -3
- package/dist/src/agent/starter-agents.js +13 -21
- package/dist/src/agent/starter-agents.js.map +1 -1
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js +1 -2
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js.map +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/curated-memory-tool.d.ts +2 -5
- package/dist/src/agent/tools/curated-memory-tool.js +20 -16
- package/dist/src/agent/tools/curated-memory-tool.js.map +1 -1
- package/dist/src/agent/tools/factory.d.ts +0 -4
- package/dist/src/agent/tools/factory.js +32 -66
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/image-generate-tool.d.ts +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +19 -14
- package/dist/src/agent/tools/image-generate-tool.js.map +1 -1
- package/dist/src/agent/tools/image-tool.js +1 -3
- package/dist/src/agent/tools/image-tool.js.map +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/memory-tool.d.ts +2 -2
- package/dist/src/agent/tools/memory-tool.js +39 -14
- package/dist/src/agent/tools/memory-tool.js.map +1 -1
- package/dist/src/agent/tools/session-search-tool.js +1 -3
- package/dist/src/agent/tools/session-search-tool.js.map +1 -1
- package/dist/src/agent/tools/web-extract.js +6 -5
- package/dist/src/agent/tools/web-extract.js.map +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/subagent-runner.js +1 -3
- package/dist/src/agent/workflow/subagent-runner.js.map +1 -1
- package/dist/src/agent-manifest/index.d.ts +4 -0
- package/dist/src/agent-manifest/index.js +10 -0
- package/dist/src/agent-manifest/index.js.map +1 -0
- package/dist/src/agent-manifest/prompt.d.ts +2 -0
- package/dist/src/agent-manifest/prompt.js +57 -0
- package/dist/src/agent-manifest/prompt.js.map +1 -0
- package/dist/src/agent-manifest/resolver.d.ts +11 -0
- package/dist/src/agent-manifest/resolver.js +93 -0
- package/dist/src/agent-manifest/resolver.js.map +1 -0
- package/dist/src/agent-manifest/schema.d.ts +778 -0
- package/dist/src/agent-manifest/schema.js +267 -0
- package/dist/src/agent-manifest/schema.js.map +1 -0
- package/dist/src/agent-manifest/validator.d.ts +24 -0
- package/dist/src/agent-manifest/validator.js +87 -0
- package/dist/src/agent-manifest/validator.js.map +1 -0
- package/dist/src/agent-runtime/boundary-guard.d.ts +12 -0
- package/dist/src/agent-runtime/boundary-guard.js +23 -0
- package/dist/src/agent-runtime/boundary-guard.js.map +1 -0
- package/dist/src/agent-runtime/index.d.ts +7 -0
- package/dist/src/agent-runtime/index.js +8 -0
- package/dist/src/agent-runtime/memory-runtime.d.ts +21 -0
- package/dist/src/agent-runtime/memory-runtime.js +50 -0
- package/dist/src/agent-runtime/memory-runtime.js.map +1 -0
- package/dist/src/agent-runtime/model-router.d.ts +11 -0
- package/dist/src/agent-runtime/model-router.js +16 -0
- package/dist/src/agent-runtime/model-router.js.map +1 -0
- package/dist/src/agent-runtime/run-trace.d.ts +27 -0
- package/dist/src/agent-runtime/run-trace.js +53 -0
- package/dist/src/agent-runtime/run-trace.js.map +1 -0
- package/dist/src/agent-runtime/runtime-profile.d.ts +24 -0
- package/dist/src/agent-runtime/runtime-profile.js +44 -0
- package/dist/src/agent-runtime/runtime-profile.js.map +1 -0
- package/dist/src/agent-runtime/tool-registry.d.ts +28 -0
- package/dist/src/agent-runtime/tool-registry.js +52 -0
- package/dist/src/agent-runtime/tool-registry.js.map +1 -0
- package/dist/src/agent-runtime/workflow-runtime.d.ts +31 -0
- package/dist/src/agent-runtime/workflow-runtime.js +34 -0
- package/dist/src/agent-runtime/workflow-runtime.js.map +1 -0
- package/dist/src/browser/actions/extension-registry-bridge.js +1 -1
- package/dist/src/browser/actions/extension-registry-bridge.js.map +1 -1
- package/dist/src/browser/actions/registry.js +5 -8
- package/dist/src/browser/actions/registry.js.map +1 -1
- package/dist/src/browser/backend-from-config.d.ts +1 -1
- package/dist/src/browser/backend-from-config.js +50 -71
- package/dist/src/browser/backend-from-config.js.map +1 -1
- package/dist/src/browser/browser-command-timeout.d.ts +0 -1
- package/dist/src/browser/browser-command-timeout.js +3 -7
- package/dist/src/browser/browser-command-timeout.js.map +1 -1
- package/dist/src/browser/providers/browser-ext-install.d.ts +2 -12
- package/dist/src/browser/providers/browser-ext-install.js +3 -8
- package/dist/src/browser/providers/browser-ext-install.js.map +1 -1
- package/dist/src/browser/readiness.js +16 -16
- package/dist/src/browser/readiness.js.map +1 -1
- package/dist/src/browser/schemas.js +1 -1
- package/dist/src/browser/schemas.js.map +1 -1
- package/dist/src/chat-commands/builtins/config.js +4 -4
- package/dist/src/chat-commands/builtins/config.js.map +1 -1
- package/dist/src/chat-commands/builtins/thinking.js +16 -42
- package/dist/src/chat-commands/builtins/thinking.js.map +1 -1
- package/dist/src/chat-commands/config-paths.js +1 -1
- package/dist/src/chat-commands/config-paths.js.map +1 -1
- package/dist/src/chat-commands/context.js +3 -4
- package/dist/src/chat-commands/context.js.map +1 -1
- package/dist/src/cli/command-manifest.js +1 -1
- package/dist/src/cli/command-manifest.js.map +1 -1
- package/dist/src/cli/commands/agent.js +3 -1
- package/dist/src/cli/commands/agent.js.map +1 -1
- package/dist/src/cli/commands/agents.js +3 -6
- package/dist/src/cli/commands/agents.js.map +1 -1
- package/dist/src/cli/commands/browser-cli-helpers.js +9 -11
- package/dist/src/cli/commands/browser-cli-helpers.js.map +1 -1
- package/dist/src/cli/commands/config.js +5 -5
- package/dist/src/cli/commands/config.js.map +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 -17
- package/dist/src/cli/commands/doctor/checks/provider-auth.js.map +1 -1
- package/dist/src/cli/commands/goal.js +1 -1
- package/dist/src/cli/commands/image.js +13 -372
- package/dist/src/cli/commands/image.js.map +1 -1
- package/dist/src/cli/commands/models.js +26 -10
- package/dist/src/cli/commands/models.js.map +1 -1
- package/dist/src/cli/commands/onboard/channels/registry.js.map +1 -1
- package/dist/src/cli/commands/onboard/model.js +20 -22
- package/dist/src/cli/commands/onboard/model.js.map +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/commands/onboard.js.map +1 -1
- package/dist/src/cli/utils/init-workspace-core.d.ts +1 -4
- package/dist/src/cli/utils/init-workspace-core.js +7 -6
- package/dist/src/cli/utils/init-workspace-core.js.map +1 -1
- package/dist/src/commands/agents.config.d.ts +0 -1
- package/dist/src/commands/agents.config.js +66 -12
- package/dist/src/commands/agents.config.js.map +1 -1
- package/dist/src/config/agent-profile.d.ts +5 -17
- package/dist/src/config/agent-profile.js +31 -64
- package/dist/src/config/agent-profile.js.map +1 -1
- package/dist/src/config/agent-typed-models.d.ts +1 -1
- package/dist/src/config/agent-typed-models.js +0 -1
- package/dist/src/config/agent-typed-models.js.map +1 -1
- package/dist/src/config/index.js +3 -3
- package/dist/src/config/integration.d.ts +1 -1
- package/dist/src/config/reload.js +1 -1
- package/dist/src/config/reload.js.map +1 -1
- package/dist/src/config/rules.js +6 -56
- package/dist/src/config/rules.js.map +1 -1
- package/dist/src/config/schema.d.ts +925 -781
- package/dist/src/config/schema.js +157 -424
- package/dist/src/config/schema.js.map +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/index.js +1 -1
- package/dist/src/cron/service.js +1 -1
- package/dist/src/cron/validation.d.ts +3 -3
- package/dist/src/extensions/activation-context.js +13 -7
- package/dist/src/extensions/activation-context.js.map +1 -1
- package/dist/src/gateway/agents-admin.d.ts +17 -18
- package/dist/src/gateway/agents-admin.js +123 -88
- package/dist/src/gateway/agents-admin.js.map +1 -1
- package/dist/src/gateway/capability-presets-admin.d.ts +56 -0
- package/dist/src/gateway/capability-presets-admin.js +214 -0
- package/dist/src/gateway/capability-presets-admin.js.map +1 -0
- package/dist/src/gateway/hono/lib/agent-model.d.ts +1 -1
- package/dist/src/gateway/hono/lib/agent-model.js +1 -1
- package/dist/src/gateway/hono/lib/agent-model.js.map +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +234 -127
- package/dist/src/gateway/hono/lib/config-payload.js +13 -37
- package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
- package/dist/src/gateway/hono/routes/agents.js +56 -33
- package/dist/src/gateway/hono/routes/agents.js.map +1 -1
- package/dist/src/gateway/hono/routes/browser.js +8 -15
- package/dist/src/gateway/hono/routes/browser.js.map +1 -1
- package/dist/src/gateway/hono/routes/capability-presets.d.ts +3 -0
- package/dist/src/gateway/hono/routes/capability-presets.js +145 -0
- package/dist/src/gateway/hono/routes/capability-presets.js.map +1 -0
- package/dist/src/gateway/hono/routes/config-patch/agents.d.ts +1 -17
- package/dist/src/gateway/hono/routes/config-patch/agents.js +2 -443
- package/dist/src/gateway/hono/routes/config-patch/agents.js.map +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +7 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js.map +1 -1
- package/dist/src/gateway/hono/routes/config.js +1 -1
- package/dist/src/gateway/hono/routes/config.js.map +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 +7 -0
- package/dist/src/gateway/hono/routes/dreaming.js.map +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/index.js +2 -0
- package/dist/src/gateway/hono/routes/index.js.map +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
- package/dist/src/gateway/hono/routes/memory.d.ts +3 -0
- package/dist/src/gateway/hono/routes/memory.js +290 -0
- package/dist/src/gateway/hono/routes/memory.js.map +1 -0
- 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/sse.js.map +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/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 +2 -2
- package/dist/src/gateway/service.js +20 -16
- 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/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/types.d.ts +10 -0
- package/dist/src/notes/agent-context.js +2 -2
- package/dist/src/providers/index.d.ts +2 -2
- package/dist/src/providers/index.js +10 -14
- package/dist/src/providers/index.js.map +1 -1
- package/dist/src/session/index.js +1 -1
- package/dist/src/session/session-workspace.js +7 -2
- package/dist/src/session/session-workspace.js.map +1 -1
- package/dist/src/session/store.js +5 -0
- package/dist/src/session/store.js.map +1 -1
- package/dist/src/session/thinking-resolve.d.ts +1 -1
- package/dist/src/session/thinking-resolve.js +1 -1
- package/dist/src/session/thinking-resolve.js.map +1 -1
- package/dist/src/storage/sqlite/connection.js +1 -1
- package/dist/src/storage/sqlite/index.d.ts +1 -0
- package/dist/src/storage/sqlite/index.js +2 -1
- package/dist/src/storage/sqlite/memory-records-repository.d.ts +101 -0
- package/dist/src/storage/sqlite/memory-records-repository.js +309 -0
- package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -0
- package/dist/src/storage/sqlite/migrations/011_goal_context_messages.sql +8 -0
- package/dist/src/storage/sqlite/migrations/012_memory_records.sql +63 -0
- package/dist/src/storage/sqlite/migrations/013_memory_trace_events.sql +21 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +2 -2
- package/dist/src/storage/sqlite/migrations/runner.js +4 -4
- package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +2 -2
- package/dist/src/storage/sqlite/schema.js +3 -3
- package/dist/src/storage/sqlite/schema.sql +95 -0
- package/dist/src/tui/backends/embedded-backend.js +6 -4
- package/dist/src/tui/backends/embedded-backend.js.map +1 -1
- package/dist/src/tui/extension-host/load-extensions.js.map +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 +14 -2
- 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/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 +3 -4
- package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
- package/dist/src/workflows/service/workflow-session-bridge.js +1 -1
- package/package.json +4 -3
- 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/config-api-NOoPiIYz.js +0 -3
- package/dist/gateway/static/root/assets/connectors-settings-CAXYMOdp.js +0 -2
- package/dist/gateway/static/root/assets/cron-api-C9BOqAXd.js +0 -1
- 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-config-api-C-xjn__h.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/use-settings-tab-guard-CW5JORnl.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-Cf1O9JB0.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-B5zdl27C.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{Ai as p,Bi as m,Ca as h,Cs as g,Ct as _,Gi as v,Gr as y,Hi as b,Ii as x,Ji as S,La as C,Li as w,Lr as T,Ls as E,Mi as D,Ms as O,Nn as k,Oa as A,Oo as j,Pn as M,Qa as N,Ra as P,Ro as F,Rr as I,Sa as L,St as ee,Ta as R,Ti as z,Ua as B,Ui as V,Vi as H,_t as U,bo as te,bt as W,dt as G,fa as K,fi as ne,ft as re,gt as ie,hi as ae,ht as oe,io as q,ki as se,li as ce,mi as le,na as ue,no as de,nt as fe,pi as J,pt as pe,rt as me,s as he,ss as ge,tt as _e,ui as ve,us as ye,ut as be,vt as xe,xt as Se,yt as Ce,za as we}from"./index-CwhK8qCh.js";import{a as Te,c as Ee,d as De,f as Oe,l as ke,n as Ae,o as je,r as Me,s as Ne,t as Pe,u as Fe}from"./voice-api-key-field-DvKiOglO.js";import{t as Ie}from"./settings-advanced-gate-q2M8RKOo.js";import{t as Le}from"./settings-collapsible-section-BHZKjVcS.js";import{n as Re,t as ze}from"./settings-form-section-5i35D-J1.js";import{n as Be,t as Ve}from"./save-bar-controls-BODCXnvY.js";var Y=n(),X=e(t(),1),Z=r(),He=()=>c(Oe);function Ue(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 We={saving:!1,savedFlash:!1,error:void 0};function Ge({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.imageModelsSettings,i=!!s(e=>e.token),[c,l]=(0,X.useReducer)(me,We),{saving:u,error:p}=c,m=y(),g=(0,X.useMemo)(()=>new Set(m.map(e=>e.id)),[m]),{data:_=[],isLoading:v}=f(i?He():null,De,{revalidateOnFocus:!1}),b=_.some(e=>e.configured),x=ke(_),S=x.credDirty;(0,X.useEffect)(()=>{if(!S)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[S]);let C=(0,X.useCallback)(async()=>{l({type:`patch`,patch:{saving:!0,error:void 0}});try{x.credDirty&&await x.saveCredentials(r.credentialsSaveError),l({type:`patch`,patch:{savedFlash:!0}}),d({type:`success`,title:r.saved})}catch(e){l({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{l({type:`patch`,patch:{saving:!1}})}},[x,r.credentialsSaveError,r.saved]),w=(0,X.useCallback)(()=>{x.credDirty&&x.onDiscardCredentials(),l({type:`patch`,patch:{error:void 0,savedFlash:!1}})},[x]);Be({id:`image-models`,dirty:S,saving:u,save:C,discard:w});let T=(0,X.useMemo)(()=>Ue(r),[r]),E=(0,X.useMemo)(()=>({getApiKey:n.providersSettings.getApiKey,getApiKeyIntl:n.providersSettings.getApiKeyIntl,getApiKeyCn:n.providersSettings.getApiKeyCn}),[n.providersSettings]),D=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,O=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`,k=e?`flex w-full items-center gap-2 text-sm text-fg-muted`:`mx-auto flex w-full max-w-app-main items-center gap-2 px-4 py-8 text-sm text-fg-muted`;return i?v?(0,Z.jsxs)(`div`,{className:k,children:[(0,Z.jsx)(q,{className:`size-4 animate-spin`}),` Loading…`]}):(0,Z.jsxs)(`div`,{className:D,children:[e?null:(0,Z.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:w,disabled:!S||u,children:r.discard}),(0,Z.jsxs)(V,{type:`button`,variant:`primary`,onClick:()=>void C(),disabled:!S||u,children:[u?(0,Z.jsx)(q,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(A,{className:`size-3.5`}),(0,Z.jsx)(`span`,{className:`ml-1.5`,children:u?r.saving:r.save})]})]})]}),p?(0,Z.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:p}):null,(0,Z.jsx)(Le,{advancedOnly:!0,icon:h,showLabel:r.providersTitle,hideLabel:r.providersTitle,defaultOpen:b,children:_.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.providersEmpty}):(0,Z.jsx)(Fe,{summaries:_,credDraft:x.credDraft,credBaseline:x.credBaseline,credDirty:x.credDirty,credSaving:x.credSaving,credError:x.credError,credSavedFlash:x.credSavedFlash,credNoopFlash:x.credNoopFlash,updateCredRow:x.updateCredRow,onDiscardCredentials:x.onDiscardCredentials,onSaveCredentials:()=>void x.saveCredentials(r.credentialsSaveError),extensionIds:g,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:t,apiKeyLinkLabels:E,messages:T})})]}):(0,Z.jsx)(`div`,{className:O,children:t===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var Q=m;function Ke(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function qe(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Je(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function Ye(){return i(H,m)}function Xe(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Ze(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 Qe=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],$e=[{id:`whisper-1`,name:`Whisper-1`}],et=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],tt=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],nt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],rt=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],it=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],at=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],ot=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],st=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],ct=[{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 lt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function ut(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 dt(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 ft(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 pt(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function mt(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 ht(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 _t({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.voiceSettings,i=!!s(e=>e.token),[l,u]=(0,X.useReducer)(gt,{form:null,baseline:null}),p=l.form,m=l.baseline,[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(null),x=(0,X.useRef)(!1),S=(0,X.useRef)({parsed:null,models:void 0}),{data:C,error:w,isLoading:T,mutate:E}=I(i),{data:D,error:O,isLoading:k,mutate:A}=f(i?c(`/api/voice/models`):null,Ae,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:N}=f(i?c(`/api/voice/providers`):null,Me,{revalidateOnFocus:!1}),{data:P,error:L,isLoading:ee}=f(i?c(`/api/voice/stt-providers`):null,Te,{revalidateOnFocus:!1}),R=(0,X.useMemo)(()=>j?.providers??[],[j]),B=(0,X.useMemo)(()=>P?.providers??[],[P]),H=(0,X.useMemo)(()=>C?.payload?.config===void 0?null:je(C.payload.config),[C]),U=(0,X.useMemo)(()=>!p||!m?!1:JSON.stringify(p)!==JSON.stringify(m),[p,m]);i?H!==null&&D!==void 0&&!x.current&&(S.current.parsed!==H||S.current.models!==D)&&(S.current={parsed:H,models:D},u({type:`sync`,value:H}),g(D)):(S.current.parsed!==null||S.current.models!==void 0)&&(S.current={parsed:null,models:void 0},u({type:`reset`}),g(null),x.current=!1);let te=!!(i&&(H===null||D===void 0||j===void 0||P===void 0)&&(T||k||N||ee)),W=w instanceof Error?w.message:w?String(w):O instanceof Error?O.message:O?String(O):M instanceof Error?M.message:M?String(M):L instanceof Error?L.message:L?String(L):null,G=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),K=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),ne=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),re=(0,X.useCallback)(e=>{x.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}}}}})},[]),ie=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),ae=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),oe=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),se=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),ce=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),le=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]),ue=(0,X.useCallback)(async()=>{if(!(!p||_)){v(!0),b(null);try{await Ne(p),u({type:`saved`,value:p}),x.current=!1,d({type:`success`,title:r.saved})}catch(e){b(e instanceof Error?e.message:r.saveError)}finally{v(!1)}}},[p,_,r.saveError]),de=(0,X.useCallback)(()=>{m&&(x.current=!1,u({type:`discard`}),b(null))},[m]);Be({id:`voice`,dirty:U,saving:_,save:ue,discard:de});let fe=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,J=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,Z.jsxs)(`div`,{className:J,children:[e?null:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.settingsSections.voice}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]});if(te)return(0,Z.jsx)(`div`,{className:J,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(q,{className:`size-4 animate-spin`}),r.loading]})});if(!p||h===null)return(0,Z.jsxs)(`div`,{className:J,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y??W??r.loadError}),(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>{E(),A()},children:r.retry})]});let pe=p.stt,me=p.tts,he=pt(r);return(0,Z.jsxs)(`div`,{className:fe,children:[(0,Z.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[e?(0,Z.jsx)(`div`,{className:`min-w-0`,"aria-hidden":!0}):(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.settingsSections.voice}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,Z.jsxs)(`a`,{href:z(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,Z.jsx)(F,{className:`size-3.5`})]})]}),e?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(V,{type:`button`,variant:`secondary`,disabled:!U||_,onClick:de,children:r.discard}),(0,Z.jsx)(V,{type:`button`,variant:`primary`,disabled:!U||_,onClick:()=>void ue(),children:_?r.saving:r.save})]})]}),U&&!e?(0,Z.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,y?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(vt,{v:r,stt:pe,tts:me}),(0,Z.jsx)(bt,{v:r,apiKeyLabels:he,stt:pe,models:h,sttProviders:B,updateStt:G,updateSttAlibaba:K,updateSttOpenai:ne,updateSttFallback:re}),(0,Z.jsx)(Tt,{v:r,apiKeyLabels:he,tts:me,models:h,ttsProviders:R,updateTts:ie,updateTtsAlibaba:ae,updateTtsOpenai:oe,updateTtsEdge:se,updateTtsMinimax:ce,updateTtsLocalCli:le})]}),(0,Z.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,Z.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,Z.jsx)(`strong`,{className:`text-accent`,children:r.notes.title}),` `,r.notes.duration]}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:r.notes.envVars})]})]})}function vt(e){let t=(0,Y.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,Z.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,Z.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,Z.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} · ${lt(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,Z.jsx)(yt,{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?dt(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,Z.jsx)(yt,{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?`${ut(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,Z.jsx)(yt,{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,Z.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,Z.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 yt(e){let t=(0,Y.c)(10),{label:n,value:r,ready:a}=e,o;t[0]===n?o=t[1]:(o=(0,Z.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,Z.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,Z.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 bt(e){let t=(0,Y.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:Qe,p=o?.stt?.openai?.length?o.stt.openai:$e,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(wt),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,Z.jsx)(N,{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,Z.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,Z.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,Z.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,Z.jsx)(Et,{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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:n.stt.provider}),(0,Z.jsx)(`select`,{className:Ye(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[lt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:n.stt.model}),a.provider===`alibaba`?(0,Z.jsx)(`select`,{className:Ye(),value:a.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(Ct)}):a.provider===`openai`?(0,Z.jsx)(`select`,{className:Ye(),value:a.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map(St)}):a.provider===`groq`?(0,Z.jsx)(`select`,{className:Ye(),value:m||et[0].id,onChange:e=>w({model:e.target.value}),children:et.map(xt)}):(0,Z.jsx)(`input`,{className:Je(),value:m,onChange:e=>w({model:e.target.value}),placeholder:a.provider})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:n.stt.apiKey}),(0,Z.jsx)(Pe,{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,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Ke(a.provider)?` ${Ke(a.provider)}`:``]})]})]}),S.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,Z.jsx)(Dt,{field:e,value:mt(x,e),onChange:t=>w({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Q},e.key))}):null,(0,Z.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,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,Z.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,Z.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,Z.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,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)}function St(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Ct(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)}function wt(e){return e.key!==`apiKey`&&e.key!==`model`}function Tt({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:tt,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:nt,m=r?.tts?.alibaba?.length?r.tts.alibaba:rt,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:it,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:at,_=r?.tts?.minimax?.length?r.tts.minimax:ot,v=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:st,[y,b]=(0,X.useState)(e.tts.test.sampleText),[x,C]=(0,X.useState)({status:`idle`}),w=(0,X.useRef)(null),T=(0,X.useRef)(null),E=(0,X.useCallback)(()=>{w.current?.pause(),w.current=null,T.current&&=(URL.revokeObjectURL(T.current),null)},[]),D=(0,X.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)),M=!!O?.diagnostics.requiresApiKey,N=!!O?.configured||!M,P=n.enabled?N?`ready`:`action`:`muted`,F=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,I=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,X.useEffect)(()=>()=>E(),[E]);let L=(0,X.useCallback)(e=>{o({provider:e}),C({status:`idle`})},[o]),ee=(0,X.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 Ee({text:t,provider:n.provider,providerConfig:A,...F?{model:F}:{},...I?{voice:I}:{}}),i=Ze(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`,Xe(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)})}},[F,I,A,E,y,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),R=(0,X.useCallback)(e=>{o({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,o]),z=(0,X.useCallback)((e,t)=>{let r={[e.key]:t};R(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,R,l,u,c]);return(0,Z.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,Z.jsxs)(`div`,{className:`mb-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(S,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Et,{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,Z.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2.5 text-sm`,P===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:P===`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,Z.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?N?`${e.tts.statusReady} ${ut(n.provider,e)}${I?` · ${I}`:``}`:`${e.tts.statusNeedsSetup} ${ut(n.provider,e)} · ${O?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.tts.trigger}),(0,Z.jsxs)(`select`,{className:Ye(),value:n.trigger,onChange:e=>o({trigger:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`off`,children:e.tts.triggerOff}),(0,Z.jsx)(`option`,{value:`inbound`,children:e.tts.triggerInbound}),(0,Z.jsx)(`option`,{value:`tagged`,children:e.tts.triggerTagged}),(0,Z.jsx)(`option`,{value:`always`,children:e.tts.triggerAlways})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.tts.provider}),(0,Z.jsx)(`select`,{className:Ye(),value:n.provider,onChange:e=>L(e.target.value),children:D.map(t=>(0,Z.jsx)(`option`,{value:t.id,children:ut(t.id,e)},t.id))}),(0,Z.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??ft(n.provider,e)]})]})]}),(0,Z.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-3`,open:!N||n.provider===`tts-local-cli`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.stt.apiKey}),(0,Z.jsx)(Pe,{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,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,qe(n.provider)?` ${qe(n.provider)}`:``]})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.stt.model}),(0,Z.jsx)(`select`,{className:Ye(),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,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(`select`,{className:Ye(),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,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(`select`,{className:Ye(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:g.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.preset}),(0,Z.jsxs)(`select`,{className:Ye(),value:``,onChange:e=>{let t=ct.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,Z.jsx)(`option`,{value:``,children:e.tts.localCli.presetPlaceholder}),ct.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.id},e.id))]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.command}),(0,Z.jsx)(`input`,{className:i(Je(),`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,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)($,{children:e.tts.localCli.cwd}),(0,Z.jsx)(`input`,{className:i(Je(),`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,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)($,{children:e.tts.localCli.outputFormat}),(0,Z.jsxs)(`select`,{className:Ye(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`wav`,children:`wav`}),(0,Z.jsx)(`option`,{value:`mp3`,children:`mp3`}),(0,Z.jsx)(`option`,{value:`opus`,children:`opus`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.timeoutMs}),(0,Z.jsx)(`input`,{className:Je(),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,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,j.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:j.map(e=>(0,Z.jsx)(Dt,{field:e,value:mt(A,e),onChange:t=>z(e,t),className:e.type===`textarea`?`sm:col-span-2`:Q},e.key))}):null]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Z.jsxs)(V,{type:`button`,variant:`primary`,onClick:()=>void ee(),disabled:x.status===`loading`,className:`h-9`,children:[x.status===`loading`?(0,Z.jsx)(q,{className:`size-4 animate-spin`}):(0,Z.jsx)(we,{className:`size-4`}),x.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,Z.jsxs)(V,{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,Z.jsx)(K,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,Z.jsx)(`textarea`,{className:i(Je(),`mt-3 min-h-20 resize-y`),value:y,onChange:e=>b(e.target.value),maxLength:1e3}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,Z.jsxs)(`span`,{className:`text-fg-subtle`,children:[y.length,`/1000`]}),x.status===`playing`||x.status===`done`?(0,Z.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,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:x.message}):null]})]})]}):null]})]})}function Et(e){let t=(0,Y.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`,b,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,Z.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,Z.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,Z.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,Z.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`,x;t[18]===y?x=t[19]:(x=i(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=x);let S=n?`translate-x-5`:`translate-x-0.5`,C;t[20]===S?C=t[21]:(C=i(`size-5 rounded-full bg-white shadow-surface transition-transform`,S),t[20]=S,t[21]=C);let w;t[22]===C?w=t[23]:(w=(0,Z.jsx)(`span`,{className:C}),t[22]=C,t[23]=w);let T;t[24]!==x||t[25]!==w?(T=(0,Z.jsx)(`span`,{className:x,"aria-hidden":!0,children:w}),t[24]=x,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,Z.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 Dt(e){let t=(0,Y.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,Z.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,Z.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,Z.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(ht(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,Z.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,Z.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,Z.jsx)($,{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,Z.jsx)(`select`,{id:s,className:Ye(),value:l,required:n.required,onChange:e=>a(ht(n,e.target.value)),children:(n.options??[]).map(Ot)}):n.type===`textarea`?(0,Z.jsx)(`textarea`,{id:s,className:i(Je(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(ht(n,e.target.value))}):n.type===`password`?(0,Z.jsx)(D,{id:s,className:o,value:l,onChange:e=>a(ht(n,e)),placeholder:n.placeholder,labels:se}):(0,Z.jsx)(`input`,{id:s,className:Je(),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(ht(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,Z.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,Z.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 Ot(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)}function $(e){let t=(0,Y.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function kt(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 At(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}}}})}),T()}async function jt(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 Mt(e){let t=(0,Y.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Nt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function Pt(){return i(H,m)}var Ft=[`brave`,`tavily`,`bing`,`searxng`];function It(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var Lt=_e();function Rt({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,X.useReducer)(Lt,{form:null,baseline:null}),m=u.form,h=u.baseline,[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(null),x=(0,X.useRef)(!1),S=(0,X.useRef)(null),{data:w,error:T,isLoading:E,mutate:D}=I(l);fe({enabled:l,parsed:(0,X.useMemo)(()=>w?.payload?.config===void 0?null:kt(w.payload.config),[w]),dirty:x.current,trackedParsedRef:S,dispatch:f,onResetDirty:()=>{x.current=!1}});let O=!!(l&&E&&w===void 0&&!T),k=T instanceof Error?T.message:T?String(T):null,A=(0,X.useMemo)(()=>!m||!h?!1:JSON.stringify(m)!==JSON.stringify(h),[m,h]),j=(0,X.useCallback)(e=>{x.current=!0,f({type:`patch`,patch:e})},[]),M=(0,X.useCallback)(async()=>{if(!(!m||_)){v(!0),b(null);try{await At(m),x.current=!1,f({type:`saved`,value:m}),d({type:`success`,title:r.saved})}catch(e){b(e instanceof Error?e.message:r.saveError)}finally{v(!1)}}},[m,_,r.saveError]),N=(0,X.useCallback)(()=>{h&&(x.current=!1,f({type:`discard`}),b(null))},[h]);Be({id:`search`,dirty:A,saving:_,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`,L=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?O?(0,Z.jsxs)(`div`,{className:i(L,`items-center`),children:[(0,Z.jsx)(q,{className:`size-8 animate-spin text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.loading})]}):m?(0,Z.jsxs)(`div`,{className:P,children:[(0,Z.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[e?(0,Z.jsx)(`div`,{className:`min-w-0`,"aria-hidden":!0}):(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,Z.jsxs)(`a`,{href:z(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,Z.jsx)(F,{className:`size-3.5`})]})]}),e?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(V,{type:`button`,variant:`secondary`,disabled:!A||_,onClick:N,children:r.discard}),(0,Z.jsx)(V,{type:`button`,variant:`primary`,disabled:!A||_,onClick:()=>void M(),children:_?r.saving:r.save})]})]}),A&&!e?(0,Z.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,y?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null,(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Re,{icon:R,title:r.sectionRegion,subtitle:r.sectionRegionHint}),(0,Z.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,Z.jsx)(Mt,{label:r.regionLabel,description:r.regionDesc,children:(0,Z.jsxs)(`select`,{className:Pt(),value:m.regionMode,onChange:e=>j({regionMode:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`auto`,children:r.regionAuto}),(0,Z.jsx)(`option`,{value:`cn`,children:r.regionCn}),(0,Z.jsx)(`option`,{value:`global`,children:r.regionGlobal})]})})})]}),(0,Z.jsx)(Ie,{children:(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Re,{icon:g,title:r.sectionBlocklist,subtitle:r.sectionBlocklistHint}),(0,Z.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:m.blocklistEnabled,onChange:e=>j({blocklistEnabled:e.target.checked})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:r.blocklistEnabled}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.blocklistEnabledDesc})]})]}),(0,Z.jsx)(Mt,{label:r.blocklistDomains,description:r.blocklistDomainsDesc,children:(0,Z.jsx)(`textarea`,{className:i(Nt(),`min-h-[6rem] font-mono text-xs`),value:m.blocklistDomains.join(`
|
|
2
|
+
`),placeholder:r.blocklistDomainsPlaceholder,disabled:!m.blocklistEnabled,onChange:e=>{j({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Re,{icon:R,title:r.sectionSearch,subtitle:r.sectionSearchHint}),(0,Z.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,Z.jsx)(Mt,{label:r.maxResultsLabel,description:r.maxResultsDesc,children:(0,Z.jsx)(`input`,{type:`number`,min:1,max:50,className:Nt(),value:m.maxResults,onChange:e=>j({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.providersTitle}),m.providers.map((e,t)=>(0,Z.jsx)(zt,{row:e,providerIndex:t,labels:r,secretLabels:p(n.providersSettings),onChange:e=>{let n=[...m.providers];n[t]=e,j({providers:n})},onRemove:()=>{j({providers:m.providers.filter((e,n)=>n!==t)})}},`${e.type}:${e.url}:${e.apiKey}:${e.disabled}`)),(0,Z.jsxs)(V,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>j({providers:[...m.providers,It()]}),children:[(0,Z.jsx)(C,{className:`size-4`}),r.addProvider]})]})]})]}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r.footerHint})]}):(0,Z.jsxs)(`div`,{className:L,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y??k??r.loadError}),(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void D(),children:c.refresh})]}):(0,Z.jsxs)(`div`,{className:L,children:[e?null:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:r.title}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]})}function zt(e){let t=(0,Y.c)(54),{row:n,providerIndex:r,labels:a,secretLabels:o,onChange:s,onRemove:c}=e,l;t[0]===r?l=t[1]:(l=()=>jt(r).then(Bt),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(Pt(),`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=Ft.map(e=>(0,Z.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,Z.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,Z.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,Z.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,Z.jsx)(ue,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===c?b=t[23]:(b=(0,Z.jsx)(V,{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,Z.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,Z.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,Z.jsx)(Mt,{label:a.urlLabel,description:a.urlDesc,children:(0,Z.jsx)(`input`,{type:`url`,className:Nt(),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,Z.jsx)(D,{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,Z.jsx)(Mt,{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 O;return t[50]!==S||t[51]!==C||t[52]!==E?(O=(0,Z.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]=O):O=t[53],O}function Bt(e){return e.apiKey??null}var Vt=[{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 Ht(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 Ut(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 Wt(){let e=await u(c(`/api/models-json`)),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok||!t.payload)throw Error(Ht(t)||`HTTP ${e.status}`);return{...t.payload,config:Ut(t.payload.config)}}async function Gt(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(Ht(n)||`HTTP ${t.status}`);return await Se(),n.payload}function Kt(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 qt(){let e=(0,Y.c)(31),t=s(Qt),n=!!t,{data:r,isLoading:i}=I(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?ee:null,Zt,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?W:null,Xt,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=ie(u,xe(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=Ut(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(Yt).map(Jt)),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 Jt(e){return e.id}function Yt(e){return e.configured}function Xt(){return Wt()}function Zt(){return _()}function Qt(e){return e.token}function $t(e){let t=(0,Y.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=qt();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.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,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(tn)})]}),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(en),o=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,c;t[7]===o?c=t[8]:(c=(0,Z.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,Z.jsx)(C,{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,Z.jsxs)(V,{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,Z.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,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge-subtle bg-surface-panel/40 px-6 py-10 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,Z.jsxs)(V,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,Z.jsx)(C,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,Z.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 en(e){return e.configured}function tn(e){return(0,Z.jsx)(`div`,{className:`h-32 animate-pulse rounded-2xl bg-surface-hover`},e)}function nn(e){let t=(0,Y.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`,w.pressCard),t[0]=o):o=t[0];let s;t[1]===n.name?s=t[2]:(s=(0,Z.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,Z.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,Z.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,Z.jsx)(ge,{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,Z.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,Z.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,Z.jsx)(L,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,Z.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,Z.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,Z.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 rn(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 an(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 on(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 sn(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 cn(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 ln(e){let t=await u(c(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var un=[`common`,`specialty`,`enterprise`,`oauth`,`extension`];function dn(e){let t=new Map;for(let e of un)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 fn={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 pn(e){return e===`openrouter`?`openrouter`:e===`zhipuCn`?`zhipu-cn`:e===`zaiGeneral`?`zai`:e}var mn=[{value:`text`,labelKey:`inputTextOnly`},{value:`text,image`,labelKey:`inputTextVision`}];function hn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function gn(){return i(H,m)}function _n(e){return(e.input||[`text`]).includes(`image`)?`text,image`:`text`}function vn(e){return e===`text,image`?[`text`,`image`]:[`text`]}function yn(e){let t=(0,Y.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,X.useState)(u),[p,m]=(0,X.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,_;t[3]!==g||t[4]!==l?(_=()=>{l(),g(!1)},t[3]=g,t[4]=l,t[5]=_):_=t[5];let v=_,y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(ne,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,M)}),t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=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`,k),t[7]=b):b=t[7];let x;t[8]!==a||t[9]!==o||t[10]!==v||t[11]!==s||t[12]!==c||t[13]!==p||t[14]!==d.providerId||t[15]!==d.type?(x=(0,Z.jsxs)(J,{children:[y,(0,Z.jsx)(ve,{className:b,children:d.type===`pick`?(0,Z.jsx)(xn,{builtinRows:a,searchQuery:p,onSearchChange:m,labels:s,onPickBuiltin:e=>f({type:`builtin`,providerId:e}),onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,Z.jsx)(Sn,{providerId:d.providerId,builtinRows:a,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v}):(0,Z.jsx)(Tn,{customConfig:o,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v})})]}),t[8]=a,t[9]=o,t[10]=v,t[11]=s,t[12]=c,t[13]=p,t[14]=d.providerId,t[15]=d.type,t[16]=x):x=t[16];let S;return t[17]!==g||t[18]!==n||t[19]!==x?(S=(0,Z.jsx)(le,{open:n,onOpenChange:g,children:x}),t[17]=g,t[18]=n,t[19]=x,t[20]=S):S=t[20],S}function bn(e){let t=(0,Y.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`,w.press),t[0]=r):r=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t[1]=a):a=t[1];let o;return t[2]===n?o=t[3]:(o=(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:a})}),t[2]=n,t[3]=o),o}function xn(e){let t=(0,Y.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=be[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=dn(f),t[7]=f,t[8]=p);let m=p,h;t[9]===o.step1Title?h=t[10]:(h=(0,Z.jsx)(ae,{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,Z.jsx)(bn,{label:o.close}),t[11]=o.close,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Z.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,Z.jsx)(R,{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 x=o.searchPlaceholder,S;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=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`,b),t[19]=S):S=t[19];let C;t[20]!==o.searchPlaceholder||t[21]!==r||t[22]!==y?(C=(0,Z.jsx)(`div`,{className:`px-5 pt-3`,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[v,(0,Z.jsx)(`input`,{type:`search`,value:r,onChange:y,placeholder:x,autoComplete:`off`,autoFocus:!0,className:S})]})}),t[20]=o.searchPlaceholder,t[21]=r,t[22]=y,t[23]=C):C=t[23];let T;t[24]!==o.addCustom||t[25]!==o.customDescription||t[26]!==c||t[27]!==u?(T=u?null:(0,Z.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`,w.press),children:[(0,Z.jsx)(j,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.addCustom}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:o.customDescription})]}),(0,Z.jsx)(ye,{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]=T):T=t[28];let E;t[29]!==f.length||t[30]!==m||t[31]!==o.categories||t[32]!==o.noResults||t[33]!==s?(E=f.length===0?(0,Z.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:o.noResults}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:un.map(e=>{let t=m.get(e)??[];return t.length===0?null:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:o.categories[e]??e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,Z.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`,w.press),children:[(0,Z.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,Z.jsx)(ge,{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]=E):E=t[34];let D;t[35]!==T||t[36]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[T,E]}),t[35]=T,t[36]=E,t[37]=D):D=t[37];let O;return t[38]!==C||t[39]!==D||t[40]!==_?(O=(0,Z.jsxs)(Z.Fragment,{children:[_,C,D]}),t[38]=C,t[39]=D,t[40]=_,t[41]=O):O=t[41],O}function Sn({providerId:e,builtinRows:t,labels:n,language:r,onBack:o,onSaved:s}){let c=t.find(t=>t.id===e),l=be[e],[u,d]=(0,X.useState)(``),[f,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),y=(0,X.useRef)(null),x=a(r).providersSettings,S=p(x),C=(0,X.useMemo)(()=>G(e,r),[e,r]),T=c?.supportsApiKey!==!1,E=c?.supportsOAuth===!0,[O,k]=(0,X.useState)(null),[A,j]=(0,X.useState)(null),[M,N]=(0,X.useState)(`idle`),[P,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(null),[ee,R]=(0,X.useState)(``),z=M===`waiting`||M===`waiting_code`;(0,X.useEffect)(()=>{if(!O||!z)return;let e=window.setInterval(()=>{(async()=>{try{let t=await an(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??x.saved),window.setTimeout(s,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),N(`error`),j(t.error??t.message??x.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[O,z,s,x.revokeFailed,x.saved]),(0,X.useEffect)(()=>()=>{O&&cn(O).catch(()=>{})},[O]);let B=async()=>{N(`waiting`),j(x.oauthStarting),g(null);try{k((await rn(e)).sessionId)}catch(e){N(`error`),j(e instanceof Error?e.message:x.revokeFailed)}},H=async()=>{if(O){try{await sn(O)}catch{}N(`idle`),j(null),k(null),F(null),L(null)}},te=async()=>{if(!(!O||!ee.trim()))try{await on(O,ee.trim()),R(``),j(x.oauthProcessingCode)}catch(e){N(`error`),j(e instanceof Error?e.message:x.revokeFailed)}},W=async()=>{let t=u.trim();if(!(!t||!T)){m(!0),g(null);try{await U({[e]:t}),v(!0),window.setTimeout(s,600)}catch(e){g(e instanceof Error?e.message:n.saveError)}finally{m(!1)}}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),"aria-label":n.back,children:(0,Z.jsx)(ye,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Z.jsx)(ae,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:c?.name??e}),(0,Z.jsx)(bn,{label:n.close})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[l?.description?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.description}):null,T?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,Z.jsx)(D,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:S,inputRef:y,onKeyDown:e=>{e.key===`Enter`&&W()}})]}):null,E?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:x.oauth}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:x.oauthHint})]}),(0,Z.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:z,onClick:()=>void B(),children:[z?(0,Z.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,x.oauth]})]}),A?(0,Z.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,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[P?(0,Z.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:[x.openAuthPage,(0,Z.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void H(),children:x.cancelOAuth})]}):null,I?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:I}):null,M===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(`input`,{type:`text`,value:ee,onChange:e=>R(e.target.value),onKeyDown:e=>e.key===`Enter`&&void te(),placeholder:x.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`,b)}),(0,Z.jsx)(V,{type:`button`,variant:`primary`,onClick:()=>void te(),children:x.submitCode})]}):null]}):null,C.length>0&&T?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:C.map(({kind:e,href:t})=>(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[re(e,n),(0,Z.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,h?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),T?(0,Z.jsx)(V,{type:`button`,variant:`primary`,disabled:!u.trim()||f||_,onClick:()=>void W(),children:_?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function Cn(e=`custom`){if(e!==`custom`&&fn[e]){let t=fn[e];return{preset:e,providerId:pn(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 wn(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:fn[t.key]?{...Cn(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 Tn({customConfig:e,labels:t,language:n,onBack:r,onSaved:o}){let[s,c]=(0,X.useReducer)(wn,void 0,()=>Cn()),[l,u]=(0,X.useState)(!1),d=p(a(n).providersSettings),{preset:f,providerId:m,baseUrl:h,api:g,apiKey:_,modelIds:y,error:x}=s,S=async()=>{let n=m.trim(),r=h.trim();if(!n){c({type:`setError`,value:t.providerIdRequired});return}if(!r){c({type:`setError`,value:t.baseUrlRequired});return}let i=y.map(e=>e.trim()).filter(Boolean);u(!0),c({type:`setError`,value:null});try{let t=e?.providers??{},a={baseUrl:r,api:g,apiKey:_.trim()||void 0,models:i.map(e=>({id:e}))};await Gt({providers:{...t,[n]:a}}),o()}catch(e){c({type:`setError`,value:e instanceof Error?e.message:t.saveError})}finally{u(!1)}},T=m.trim()&&h.trim();return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:r,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),"aria-label":t.back,children:(0,Z.jsx)(ye,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Z.jsx)(ae,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:t.step2CustomTitle}),(0,Z.jsx)(bn,{label:t.close})]}),(0,Z.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.customDescription}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:t.presetLabel}),(0,Z.jsxs)(`select`,{id:`custom-preset`,value:f,onChange:e=>c({type:`applyPreset`,key:e.target.value}),className:gn(),children:[(0,Z.jsx)(`option`,{value:`custom`,children:t.presetCustom}),(0,Z.jsx)(`option`,{value:`ollama`,children:t.presetOllama}),(0,Z.jsx)(`option`,{value:`lmstudio`,children:t.presetLmStudio}),(0,Z.jsx)(`option`,{value:`openrouter`,children:t.presetOpenRouter}),(0,Z.jsx)(`option`,{value:`zhipuCn`,children:t.presetZhipuCn}),(0,Z.jsx)(`option`,{value:`zaiGeneral`,children:t.presetZaiGeneral})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:t.providerIdLabel}),(0,Z.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,autoFocus:!0,value:m,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`,b)})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:t.baseUrlLabel}),(0,Z.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:h,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`,b)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:t.apiTypeLabel}),(0,Z.jsx)(`select`,{id:`custom-api-type`,value:g,onChange:e=>c({type:`setApi`,value:e.target.value}),className:gn(),children:Vt.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:t.apiKeyLabel}),(0,Z.jsx)(D,{id:`custom-api-key`,value:_,onChange:e=>c({type:`setApiKey`,value:e}),placeholder:t.apiKeyPlaceholder,labels:d})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.modelIdLabel}),y.map((e,n)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.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`,b)}),y.length>1?(0,Z.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`,w.press),children:(0,Z.jsx)(v,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${n}`)),(0,Z.jsxs)(V,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>c({type:`addModelSlot`}),children:[(0,Z.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),t.addModel]})]}),x?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:r,children:t.cancel}),(0,Z.jsx)(V,{type:`button`,variant:`primary`,disabled:!T||l,onClick:()=>void S(),children:l?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),t.saving]}):t.save})]})]})}function En(e){let t=(0,Y.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}:Kt(``),t[0]=n,t[1]=l);let[u,d]=(0,X.useState)(l),[f,p]=(0,X.useState)(Dn),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,y;t[9]!==u||t[10]!==s||t[11]!==o||t[12]!==_?(y=()=>{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]=y):y=t[13];let b=y,S=u,C;t[14]===S?C=t[15]:(C=_n(S),t[14]=S,t[15]=C);let w=C,T=r?c.addModelTitle:c.editModelTitle,E;t[16]===T?E=t[17]:(E=(0,Z.jsx)(ae,{className:`text-base font-semibold text-fg`,children:T}),t[16]=T,t[17]=E);let D;t[18]!==c.modelProviderLabel||t[19]!==a?(D=a?(0,Z.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]=D):D=t[20];let O;t[21]!==E||t[22]!==D?(O=(0,Z.jsxs)(`div`,{children:[E,D]}),t[21]=E,t[22]=D,t[23]=O):O=t[23];let k;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(k=i(x,`p-1.5 hover:bg-surface-base`),t[24]=k):k=t[24];let A;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(v,{className:`size-4`}),t[25]=A):A=t[25];let j;t[26]===c.close?j=t[27]:(j=(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:k,"aria-label":c.close,children:A})}),t[26]=c.close,t[27]=j);let M;t[28]!==O||t[29]!==j?(M=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[O,j]}),t[28]=O,t[29]=j,t[30]=M):M=t[30];let N;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=N):N=t[31];let P;t[32]===c.modelId?P=t[33]:(P=(0,Z.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[c.modelId,N]}),t[32]=c.modelId,t[33]=P);let F;t[34]===f?F=t[35]:(F=i(hn(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=F);let I=u.id||``,L;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>h(`id`,e.target.value),t[36]=L):L=t[36];let ee=!r,R;t[37]!==F||t[38]!==I||t[39]!==ee?(R=(0,Z.jsx)(`input`,{className:F,value:I,onChange:L,placeholder:`e.g. llama3.1:8b`,disabled:ee}),t[37]=F,t[38]=I,t[39]=ee,t[40]=R):R=t[40];let z;t[41]===f?z=t[42]:(z=f.has(`id`)?(0,Z.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]!==P||t[44]!==R||t[45]!==z?(B=(0,Z.jsxs)(`div`,{children:[P,R,z]}),t[43]=P,t[44]=R,t[45]=z,t[46]=B):B=t[46];let H;t[47]===c.displayName?H=t[48]:(H=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.displayName}),t[47]=c.displayName,t[48]=H);let U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U=hn(),t[49]=U):U=t[49];let te=u.name||``,W;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>h(`name`,e.target.value),t[50]=W):W=t[50];let G;t[51]===te?G=t[52]:(G=(0,Z.jsx)(`input`,{className:U,value:te,onChange:W}),t[51]=te,t[52]=G);let K;t[53]!==H||t[54]!==G?(K=(0,Z.jsxs)(`div`,{children:[H,G]}),t[53]=H,t[54]=G,t[55]=K):K=t[55];let ne;t[56]===c.inputTypes?ne=t[57]:(ne=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.inputTypes}),t[56]=c.inputTypes,t[57]=ne);let re;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(re=gn(),t[58]=re):re=t[58];let ie;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>h(`input`,vn(e.target.value)),t[59]=ie):ie=t[59];let oe;t[60]===c?oe=t[61]:(oe=mn.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:c[e.labelKey]},e.value)),t[60]=c,t[61]=oe);let q;t[62]!==w||t[63]!==oe?(q=(0,Z.jsx)(`select`,{className:re,value:w,onChange:ie,children:oe}),t[62]=w,t[63]=oe,t[64]=q):q=t[64];let se;t[65]!==ne||t[66]!==q?(se=(0,Z.jsxs)(`div`,{children:[ne,q]}),t[65]=ne,t[66]=q,t[67]=se):se=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 de;t[69]===le?de=t[70]:(de=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:le,onChange:ue}),t[69]=le,t[70]=de);let fe;t[71]!==c.reasoning||t[72]!==de?(fe=(0,Z.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[de,c.reasoning]}),t[71]=c.reasoning,t[72]=de,t[73]=fe):fe=t[73];let J;t[74]!==se||t[75]!==fe?(J=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[se,fe]}),t[74]=se,t[75]=fe,t[76]=J):J=t[76];let pe;t[77]===c.contextWindow?pe=t[78]:(pe=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.contextWindow}),t[77]=c.contextWindow,t[78]=pe);let me;t[79]===f?me=t[80]:(me=i(hn(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=me);let he=u.contextWindow??128e3,ge;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>h(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=ge):ge=t[81];let _e;t[82]!==me||t[83]!==he?(_e=(0,Z.jsx)(`input`,{type:`number`,min:1,className:me,value:he,onChange:ge}),t[82]=me,t[83]=he,t[84]=_e):_e=t[84];let ve;t[85]===f?ve=t[86]:(ve=f.has(`contextWindow`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=ve);let ye;t[87]!==pe||t[88]!==_e||t[89]!==ve?(ye=(0,Z.jsxs)(`div`,{children:[pe,_e,ve]}),t[87]=pe,t[88]=_e,t[89]=ve,t[90]=ye):ye=t[90];let be;t[91]===c.maxOutputTokens?be=t[92]:(be=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.maxOutputTokens}),t[91]=c.maxOutputTokens,t[92]=be);let xe;t[93]===f?xe=t[94]:(xe=i(hn(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=xe);let Se=u.maxTokens??16384,Ce;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=e=>h(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=Ce):Ce=t[95];let we;t[96]!==xe||t[97]!==Se?(we=(0,Z.jsx)(`input`,{type:`number`,min:1,className:xe,value:Se,onChange:Ce}),t[96]=xe,t[97]=Se,t[98]=we):we=t[98];let Te;t[99]===f?Te=t[100]:(Te=f.has(`maxTokens`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=Te);let Ee;t[101]!==be||t[102]!==we||t[103]!==Te?(Ee=(0,Z.jsxs)(`div`,{children:[be,we,Te]}),t[101]=be,t[102]=we,t[103]=Te,t[104]=Ee):Ee=t[104];let De;t[105]!==ye||t[106]!==Ee?(De=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ye,Ee]}),t[105]=ye,t[106]=Ee,t[107]=De):De=t[107];let Oe;t[108]===c.costSection?Oe=t[109]:(Oe=(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:c.costSection}),t[108]=c.costSection,t[109]=Oe);let ke;t[110]===c.costInput?ke=t[111]:(ke=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costInput}),t[110]=c.costInput,t[111]=ke);let Ae;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=hn(),t[112]=Ae):Ae=t[112];let je=u.cost?.input??0,Me;t[113]===u.cost?Me=t[114]:(Me=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]=Me);let Ne;t[115]!==je||t[116]!==Me?(Ne=(0,Z.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ae,value:je,onChange:Me}),t[115]=je,t[116]=Me,t[117]=Ne):Ne=t[117];let Pe;t[118]!==ke||t[119]!==Ne?(Pe=(0,Z.jsxs)(`div`,{children:[ke,Ne]}),t[118]=ke,t[119]=Ne,t[120]=Pe):Pe=t[120];let Fe;t[121]===c.costOutput?Fe=t[122]:(Fe=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costOutput}),t[121]=c.costOutput,t[122]=Fe);let Ie;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=hn(),t[123]=Ie):Ie=t[123];let Le=u.cost?.output??0,Re;t[124]===u.cost?Re=t[125]:(Re=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]=Re);let ze;t[126]!==Le||t[127]!==Re?(ze=(0,Z.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ie,value:Le,onChange:Re}),t[126]=Le,t[127]=Re,t[128]=ze):ze=t[128];let Be;t[129]!==Fe||t[130]!==ze?(Be=(0,Z.jsxs)(`div`,{children:[Fe,ze]}),t[129]=Fe,t[130]=ze,t[131]=Be):Be=t[131];let Ve;t[132]!==Pe||t[133]!==Be?(Ve=(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Pe,Be]}),t[132]=Pe,t[133]=Be,t[134]=Ve):Ve=t[134];let He;t[135]!==Oe||t[136]!==Ve?(He=(0,Z.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Oe,Ve]}),t[135]=Oe,t[136]=Ve,t[137]=He):He=t[137];let Ue;t[138]!==B||t[139]!==K||t[140]!==J||t[141]!==De||t[142]!==He?(Ue=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[B,K,J,De,He]}),t[138]=B,t[139]=K,t[140]=J,t[141]=De,t[142]=He,t[143]=Ue):Ue=t[143];let We;t[144]===c.cancel?We=t[145]:(We=(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsx)(V,{type:`button`,variant:`secondary`,children:c.cancel})}),t[144]=c.cancel,t[145]=We);let Ge=r?c.addModelConfirm:c.saveModelConfirm,Q;t[146]!==b||t[147]!==Ge?(Q=(0,Z.jsx)(V,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:b,children:Ge}),t[146]=b,t[147]=Ge,t[148]=Q):Q=t[148];let Ke;t[149]!==We||t[150]!==Q?(Ke=(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[We,Q]}),t[149]=We,t[150]=Q,t[151]=Ke):Ke=t[151];let qe;return t[152]!==M||t[153]!==Ue||t[154]!==Ke?(qe=(0,Z.jsxs)(Z.Fragment,{children:[M,Ue,Ke]}),t[152]=M,t[153]=Ue,t[154]=Ke,t[155]=qe):qe=t[155],qe}function Dn(){return new Map}function On(e){let t=(0,Y.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,Z.jsx)(ne,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,M)}),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`,k,`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,Z.jsx)(En,{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,Z.jsxs)(J,{children:[u,(0,Z.jsx)(ve,{className:d,onOpenAutoFocus:kn,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,Z.jsx)(le,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function kn(e){return e.preventDefault()}function An(e){let t=(0,Y.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>Ce(n).then(jn),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,Z.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,Z.jsx)(D,{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,Z.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 jn(e){return e.apiKey??null}function Mn(e){let t=(0,Y.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,Z.jsx)(ne,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,M)}),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`,k),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,Z.jsxs)(J,{children:[p,(0,Z.jsx)(ve,{className:m,children:o?(0,Z.jsx)(Pn,{providerId:a,customConfig:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,Z.jsx)(Nn,{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,Z.jsx)(le,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function Nn({providerId:e,builtinRows:t,allModels:n,labels:r,language:o,onClose:s,onSaved:c}){let l=t.find(t=>t.id===e),u=be[e],d=n.filter(t=>t.provider===e),[f,p]=(0,X.useState)(l?.apiKey??``),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(!1),[y,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(!1),T=a(o).providersSettings,E=l?.supportsApiKey!==!1,D=l?.supportsOAuth===!0,k=l?.authMode===`oauth`&&l.authStatus===`connected`,A=l?.configured===!0&&l.activeKeySource!==`env`&&l.activeKeySource!==`extension`&&l.activeKeySource!==`models_json`,[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),[I,L]=(0,X.useState)(`idle`),[ee,R]=(0,X.useState)(null),[z,B]=(0,X.useState)(null),[H,te]=(0,X.useState)(``),W=I===`waiting`||I===`waiting_code`,K=(0,X.useMemo)(()=>G(e,o),[e,o]),ne=f!==(l?.apiKey??``),ie=async()=>{let t=f.trim();if(!(!t||!E||oe(t))){h(!0),x(null);try{await U({[e]:t}),_(!0),window.setTimeout(()=>{c(),s()},600)}catch(e){x(e instanceof Error?e.message:r.saveError)}finally{h(!1)}}};(0,X.useEffect)(()=>{if(!j||!W)return;let e=window.setInterval(()=>{(async()=>{try{let t=await an(j);t.status===`waiting_auth`||t.status===`waiting_code`?(L(t.status===`waiting_code`?`waiting_code`:`waiting`),P(t.message??null),R(t.authUrl??null),B(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),L(`success`),P(t.message??T.saved),window.setTimeout(()=>{c(),s()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),L(`error`),P(t.error??t.message??T.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[j,W,s,c,T.revokeFailed,T.saved]),(0,X.useEffect)(()=>()=>{j&&cn(j).catch(()=>{})},[j]);let se=async()=>{try{await pe(e),c(),s()}catch{}},le=async()=>{L(`waiting`),P(T.oauthStarting),x(null);try{M((await rn(e)).sessionId)}catch(e){L(`error`),P(e instanceof Error?e.message:T.revokeFailed)}},fe=async()=>{if(j){try{await sn(j)}catch{}L(`idle`),P(null),M(null),R(null),B(null)}},J=async()=>{if(!(!j||!H.trim()))try{await on(j,H.trim()),te(``),P(T.oauthProcessingCode)}catch(e){L(`error`),P(e instanceof Error?e.message:T.revokeFailed)}},me=async()=>{try{await ln(e),c(),s()}catch(e){x(e instanceof Error?e.message:T.revokeFailed)}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(ae,{className:`text-base font-semibold text-fg`,children:l?.name??e}),(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),children:(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[u?.description?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,l?.baseUrl?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,Z.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,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,E?(0,Z.jsx)(An,{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,Z.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,Z.jsx)(`p`,{children:r.extensionKeyHint}),l?.extensionId?(0,Z.jsxs)(O,{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,Z.jsx)(F,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,D?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:T.oauth}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:k?T.sourceOauth:T.oauthHint})]}),k?(0,Z.jsx)(V,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void me(),children:T.revoke}):(0,Z.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:W,onClick:()=>void le(),children:[W?(0,Z.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),T.oauth]})]}),N?(0,Z.jsx)(`p`,{className:i(`text-xs`,I===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:N}):null,I===`waiting`||I===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ee?(0,Z.jsxs)(`a`,{href:ee,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,Z.jsx)(F,{className:`size-4`,"aria-hidden":!0}),T.openAuthPage]}):null,(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:T.cancelOAuth})]}):null,z?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:z}):null,I===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(`input`,{type:`text`,value:H,onChange:e=>te(e.target.value),onKeyDown:e=>e.key===`Enter`&&void J(),placeholder:T.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`,b)}),(0,Z.jsx)(V,{type:`button`,variant:`primary`,onClick:()=>void J(),children:T.submitCode})]}):null]}):null,K.length>0&&E?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:K.map(({kind:e,href:t})=>(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[re(e,r),(0,Z.jsx)(F,{className:`size-3`,"aria-hidden":!0})]},e))}):null,d.length>0?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,d.length,`)`]}),(0,Z.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,Z.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,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),y?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[A?(0,Z.jsxs)(V,{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:()=>C(!0),children:[(0,Z.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:E&&ne&&!oe(f.trim())?(0,Z.jsx)(V,{type:`button`,variant:`primary`,disabled:!f.trim()||m||g,onClick:()=>void ie(),children:g?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):m?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,Z.jsx)(he,{open:S,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,l?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void se(),onCancel:()=>C(!1)})]})}function Pn({providerId:e,customConfig:t,labels:n,language:r,onClose:o,onSaved:s}){let c=a(r).modelsSettings,l=t?.providers[e],[u,d]=(0,X.useState)(l?.baseUrl??``),[f,p]=(0,X.useState)(l?.apiKey??``),[m,h]=(0,X.useState)(l?.models??[]),[g,_]=(0,X.useState)(!1),[y,x]=(0,X.useState)(null),[S,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(null),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(null),M=n=>{if(!t)return null;let r=f.trim(),i={...l,baseUrl:u.trim()||void 0,apiKey:oe(r)?l?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},N=async()=>{let e=M({models:m});if(e){_(!0),x(null);try{await Gt(e),s(),o()}catch(e){x(e instanceof Error?e.message:n.saveError)}finally{_(!1)}}},P=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await Gt({providers:r}),s(),o()}catch{}},F=(e,t)=>{j({model:e,isNew:t}),k(!0)},I=async e=>{if(!A)return;let t=A.isNew?[...m,e]:m.map(t=>t.id===e.id?e:t);h(t);let r=M({models:t});if(r)try{await Gt(r),s()}catch(e){x(e instanceof Error?e.message:n.saveError)}},L=async e=>{let t=m.filter(t=>t.id!==e);h(t),D(null);let r=M({models:t});if(r)try{await Gt(r),s()}catch(e){x(e instanceof Error?e.message:n.saveError)}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(ae,{className:`text-base font-semibold text-fg`,children:e}),(0,Z.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),children:(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,Z.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`,b)})]}),(0,Z.jsx)(An,{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,Z.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[c.modelsSection,m.length>0?` (${m.length})`:``]}),(0,Z.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>F(null,!0),children:[(0,Z.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),c.addModel]})]}),m.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.modelsEmpty}):(0,Z.jsx)(`ul`,{className:`space-y-2`,children:m.map(e=>(0,Z.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,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,Z.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,Z.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),onClick:()=>F(e,!1),"aria-label":c.editModel,children:(0,Z.jsx)(B,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.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`,w.press),onClick:()=>D(e.id),"aria-label":c.removeModel,children:(0,Z.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),y?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,Z.jsxs)(V,{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:()=>T(!0),children:[(0,Z.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(V,{type:`button`,variant:`primary`,disabled:g,onClick:()=>void N(),children:g?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,Z.jsx)(he,{open:S,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void P(),onCancel:()=>T(!1)}),(0,Z.jsx)(he,{open:E!==null,title:c.removeModel,description:c.removeModelConfirm.replace(`{{id}}`,E??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{E&&L(E)},onCancel:()=>D(null)}),(0,Z.jsx)(On,{open:O,onOpenChange:e=>{k(e),e||j(null)},providerId:e,model:A?.model??null,isNew:A?.isNew??!1,onSave:e=>void I(e),m:c})]})}var Fn=[`services`,`image-models`,`voice`,`search`];function In(e){let t=(e??``).trim();return Fn.includes(t)?t:`services`}function Ln(){let e=(0,Y.c)(72),t=o(zn),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,s=r.modelsHub,[c,l]=E(),u;e[2]===c?u=e[3]:(u=In(c.get(`tab`)),e[2]=c,e[3]=u);let d=u,[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),g=qt(),_;e[4]!==s.servicesHint||e[5]!==s.tabs.services?(_={id:`services`,icon:P,label:s.tabs.services,hint:s.servicesHint},e[4]=s.servicesHint,e[5]=s.tabs.services,e[6]=_):_=e[6];let v;e[7]!==s.imageModelsHint||e[8]!==s.tabs.imageModels?(v={id:`image-models`,icon:te,label:s.tabs.imageModels,hint:s.imageModelsHint},e[7]=s.imageModelsHint,e[8]=s.tabs.imageModels,e[9]=v):v=e[9];let y;e[10]!==s.tabs.voice||e[11]!==s.voiceHint?(y={id:`voice`,icon:N,label:s.tabs.voice,hint:s.voiceHint},e[10]=s.tabs.voice,e[11]=s.voiceHint,e[12]=y):y=e[12];let b;e[13]!==s.searchHint||e[14]!==s.tabs.search?(b={id:`search`,icon:R,label:s.tabs.search,hint:s.searchHint},e[13]=s.searchHint,e[14]=s.tabs.search,e[15]=b):b=e[15];let x;e[16]!==_||e[17]!==v||e[18]!==y||e[19]!==b?(x=[_,v,y,b],e[16]=_,e[17]=v,e[18]=y,e[19]=b,e[20]=x):x=e[20];let S=x,C;e[21]===l?C=e[22]:(C=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]=C);let T=C,D=Rn,O;e[23]===r.settingsSections.credentials?O=e[24]:(O=(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.settingsSections.credentials}),e[23]=r.settingsSections.credentials,e[24]=O);let k;e[25]===s.subtitle?k=e[26]:(k=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s.subtitle}),e[25]=s.subtitle,e[26]=k);let A;e[27]===t?A=e[28]:(A=z(t,`configuration`),e[27]=t,e[28]=A);let j;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),e[29]=j):j=e[29];let M;e[30]!==s.docsLink||e[31]!==A?(M=(0,Z.jsxs)(`a`,{href:A,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,j]}),e[30]=s.docsLink,e[31]=A,e[32]=M):M=e[32];let I;e[33]!==M||e[34]!==O||e[35]!==k?(I=(0,Z.jsx)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[O,k,M]})}),e[33]=M,e[34]=O,e[35]=k,e[36]=I):I=e[36];let L;e[37]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(Ve,{}),e[37]=L):L=e[37];let ee=s.tabsAria,B;e[38]!==d||e[39]!==T?(B=e=>{e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),T(Fn[(Fn.indexOf(d)+(e.key===`ArrowRight`?1:-1)+Fn.length)%Fn.length]))},e[38]=d,e[39]=T,e[40]=B):B=e[40];let V;e[41]!==d||e[42]!==T||e[43]!==S?(V=S.map(e=>{let{id:t,icon:n,label:r}=e,a=t===d;return(0,Z.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`,w.press,a?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>T(t),children:[(0,Z.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:r})]},t)}),e[41]=d,e[42]=T,e[43]=S,e[44]=V):V=e[44];let H;e[45]!==s.tabsAria||e[46]!==B||e[47]!==V?(H=(0,Z.jsx)(`div`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,"aria-label":ee,onKeyDown:B,children:V}),e[45]=s.tabsAria,e[46]=B,e[47]=V,e[48]=H):H=e[48];let U;e[49]!==d||e[50]!==s.connectedProviders||e[51]!==S?(U=S.map(e=>(0,Z.jsx)(Vn,{id:e.id,activeTab:d,hint:e.hint,children:e.id===`services`?(0,Z.jsx)($t,{labels:s.connectedProviders,onAdd:()=>p(!0),onManage:(e,t)=>h({providerId:e,isCustom:t})}):(0,Z.jsx)(Bn,{tab:e.id})},e.id)),e[49]=d,e[50]=s.connectedProviders,e[51]=S,e[52]=U):U=e[52];let W;e[53]!==f||e[54]!==s.addProviderDialog||e[55]!==t||e[56]!==g.builtinRows||e[57]!==g.customConfig?(W=(0,Z.jsx)(yn,{open:f,onOpenChange:p,builtinRows:g.builtinRows,customConfig:g.customConfig,labels:s.addProviderDialog,language:t,onSaved:D}),e[53]=f,e[54]=s.addProviderDialog,e[55]=t,e[56]=g.builtinRows,e[57]=g.customConfig,e[58]=W):W=e[58];let G;e[59]!==s.manageProviderDialog||e[60]!==t||e[61]!==m||e[62]!==g.allModels||e[63]!==g.builtinRows||e[64]!==g.customConfig?(G=m?(0,Z.jsx)(Mn,{open:!0,onOpenChange:e=>{e||h(null)},providerId:m.providerId,isCustom:m.isCustom,builtinRows:g.builtinRows,customConfig:g.customConfig,allModels:g.allModels,labels:s.manageProviderDialog,language:t,onSaved:D}):null,e[59]=s.manageProviderDialog,e[60]=t,e[61]=m,e[62]=g.allModels,e[63]=g.builtinRows,e[64]=g.customConfig,e[65]=G):G=e[65];let K;return e[66]!==I||e[67]!==H||e[68]!==U||e[69]!==W||e[70]!==G?(K=(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-4 px-4 py-6`,children:[I,L,H,U,W,G]}),e[66]=I,e[67]=H,e[68]=U,e[69]=W,e[70]=G,e[71]=K):K=e[71],K}function Rn(){Se()}function zn(e){return e.language}function Bn(e){let t=(0,Y.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,Z.jsx)(Ge,{embedded:!0}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(_t,{embedded:!0}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rt,{embedded:!0}),t[2]=e):e=t[2],e}}}function Vn({id:e,activeTab:t,hint:n,children:r}){let a=e===t,o=(0,X.useRef)(a);return a&&(o.current=!0),o.current?(0,Z.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,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{Ln as ModelsHubPanel};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-2HJoFchH.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-CwhK8qCh.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-Cf1O9JB0.js","assets/fetch-B5zdl27C.js","assets/gateway-startup-retry-B3kL8KGY.js","assets/toast-z0toXu32.js","assets/theme-store-CD2wtgZV.js","assets/index-CyfhARL-.css","assets/vendor-codemirror-CNP1wPe7.js","assets/note-image-lightbox-CDknITM3.js","assets/voice-player-store-BlF9V05n.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-Cf1O9JB0.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,Ci as p,Co as m,Ds as h,Dt as g,Fs as _,Gi as v,Ht as y,Is as b,Jo as x,Lo as S,Lt as C,Nt as w,Ot as T,Po as E,Rt as D,Ts as ee,Tt as te,Ua as O,bi as k,ha as ne,ia as A,ja as j,jt as M,kt as N,ra as re,to as ie,zt as P}from"./index-CwhK8qCh.js";import{n as ae,t as F}from"./note-image-lightbox-CDknITM3.js";import{r as I}from"./note-time-hm6JO_Wi.js";var L=n(),R=e(t(),1),z=r(),B={edit:O,ai_edit:ne,sync:j,restore:h};function V(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function oe({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let c=o(s(e=>e.language)).notes,f=c,{data:p}=u(e?[`note-history`,e]:null,()=>d(e)),[h,g]=(0,R.useState)(!1),[_,y]=(0,R.useState)(null),b=(0,R.useCallback)(async t=>{g(!0);try{await P(e,t),l({type:`success`,title:c.restoreSuccess}),y(null),i()}catch{l({type:`error`,title:c.restoreFailed})}finally{g(!1)}},[e,c.restoreSuccess,c.restoreFailed,i]),x=Date.now();return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,z.jsx)(m,{className:`h-4 w-4`,"aria-hidden":!0}),c.history]}),(0,z.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,z.jsx)(v,{className:`h-4 w-4`,"aria-hidden":!0})})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:p?.length?(0,z.jsx)(`ul`,{className:`divide-y divide-edge`,children:p.map(e=>{let r=B[e.trigger]??O,i=t===e.timestamp,o=_===e.timestamp;return(0,z.jsxs)(`li`,{children:[(0,z.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,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:V(e.trigger,c)}),(0,z.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:I(e.timestamp,x,f)})]}),e.snippet&&(0,z.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,z.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:o?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:c.restoreConfirm}),(0,z.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),b(e.timestamp)},disabled:h,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:h?`...`:c.restore}),(0,z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),y(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,z.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),y(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,z.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:c.historyEmpty}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:c.historyEmptyDescription})]})})]})}function se(e){let t=(0,L.c)(10),{noteId:n,note:r,catalyzing:i,onCatalyze:c,onClose:l,noteThreads:d,openingChat:f,onOpenChat:p,onOpenNewChat:m}=e,h=o(s(J)).notes,g=_(),v=r?.aiDeep?.catalysis,y=v?.report??null,b;t[0]===n?b=t[1]:(b=n?[`note-agent-context-status`,n]:null,t[0]=n,t[1]=b);let x;t[2]===n?x=t[3]:(x=()=>T(n),t[2]=n,t[3]=x);let S;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!1},t[4]=S):S=t[4];let{data:w,mutate:E,isLoading:te}=u(b,x,S),O;t[5]===n?O=t[6]:(O=async e=>{try{await D(n,e)}catch{}},t[5]=n,t[6]=O);let k=O,j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,z.jsx)(ne,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[7]=j):j=t[7];let M;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,z.jsx)(ee,{className:`h-4 w-4 rotate-180`,"aria-hidden":!0}),t[8]=M):M=t[8];let N;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,z.jsx)(ie,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[9]=N):N=t[9],(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[j,(0,z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:h.catalysisSectionTitle})]}),(0,z.jsx)(`button`,{type:`button`,onClick:l,"aria-label":h.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:M})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,z.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:h.catalysisSectionDescription}),w?(0,z.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-base p-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.contextStatusTitle}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void E(()=>C(n),{revalidate:!1}),disabled:te,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:h.contextRebuild}),(0,z.jsx)(`span`,{className:a(`rounded-full px-2 py-0.5 text-[11px] font-medium`,w.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:w.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:w.status})]}),(0,z.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:h.contextStatusDetail.replace(`{{attachments}}`,String(w.attachments.length)).replace(`{{tokens}}`,String(w.tokenEstimate??0))}),w.attachments.length>0?(0,z.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:w.attachments.slice(0,5).map(q)}):null]}):null,(0,z.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?h.processing:y?h.recatalyze:h.catalyzeAction}),y?(0,z.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.valueHypothesis}),(0,z.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:y.valueHypothesis})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.targetUsers}),(0,z.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:y.targetUsers.slice(0,5).map(K)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.keyQuestions}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.keyQuestions.slice(0,3).map(G)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.mvpPathLabel}),(0,z.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.mvpPath.slice(0,3).map(W)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.risks}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.risks.slice(0,3).map(U)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.nextActions}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.nextActions.slice(0,4).map(H)})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:h.confidenceLabel.replace(`{{percent}}`,String(Math.round(y.confidence*100)))}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void k(`helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,v?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":h.feedbackHelpfulAria,children:(0,z.jsx)(re,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void k(`not_helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,v?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":h.feedbackNotHelpfulAria,children:(0,z.jsx)(A,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]}):(0,z.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:h.noCatalysisReportHint}),(0,z.jsxs)(`section`,{className:`mt-6 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[N,h.relatedThreadsTitle]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:h.relatedThreadsDescription})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:p,disabled:f,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:f?h.openingChat:h.openThread}),(0,z.jsx)(`button`,{type:`button`,onClick:m,disabled:f,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:h.newThread})]})]}),d.length>0?(0,z.jsx)(`div`,{className:`space-y-2`,children:d.slice(0,5).map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>g(`/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,z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||h.noteDiscussionFallback}),(0,z.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:h.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,z.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:h.noThreads})]})]})]})}function H(e){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,z.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`)}function U(e){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-fg-muted`}),(0,z.jsx)(`span`,{children:e})]},e)}function W(e,t){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,z.jsx)(`span`,{children:e})]},e)}function G(e){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-accent`}),(0,z.jsx)(`span`,{children:e})]},e)}function K(e){return(0,z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e)}function q(e){return(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,z.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId)}function J(e){return e.language}var Y=()=>i(()=>import(`./block-editor-2HJoFchH.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,R.lazy)(()=>Y().then(e=>({default:e.BlockEditor}))),le=(0,R.lazy)(()=>X().then(e=>({default:e.MarkdownEditor})));function ue(){let e=(0,L.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,z.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,z.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,z.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,z.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,L.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:x},t[2]=i.source,t[3]=s);let c;t[4]===i.preview?c=t[5]:(c={id:`preview`,label:i.preview,Icon:S},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,z.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,z.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,z.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,L.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,z.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,z.jsx)(F,{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=_(),d=c(e=>e.resolved)===`dark`,{openImage:h}=ae(),[v,b]=(0,R.useState)(`wysiwyg`),[x,S]=(0,R.useState)(null),[C,T]=(0,R.useState)(null),[E,D]=(0,R.useState)(!1),[O,A]=(0,R.useState)(``),[j,re]=(0,R.useState)(360),[P,F]=(0,R.useState)(!1),[I,L]=(0,R.useState)(!1),[B,V]=(0,R.useState)(!1),H=(0,R.useRef)(!1),U=(0,R.useRef)(!1),W=(0,R.useRef)(null),G=(0,R.useRef)(null),K=(0,R.useRef)(null),q=(0,R.useRef)(null),J=(0,R.useRef)(null),Y=k(e=>e.setPageHeader),X=k(e=>e.clearPageHeader),{data:Z,mutate:Q}=u(e?[`note-detail`,e]:null,()=>g(e)),{data:fe=[],mutate:pe}=u(e?[`note-threads`,e]:null,()=>M(e),{revalidateOnFocus:!1});(0,R.useEffect)(()=>{H.current=!1,A(``),T(null),S(null),U.current=!1},[e]),(0,R.useEffect)(()=>{!Z||H.current||(A(Z.title??``),H.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,R.useMemo)(()=>(0,z.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`,p),children:(0,z.jsx)(ee,{className:`h-4 w-4`,"aria-hidden":!0})}),[r.back,t]),ge=(0,R.useCallback)(t=>{A(t),e&&(q.current=t,G.current&&clearTimeout(G.current),G.current=setTimeout(async()=>{let t=q.current;if(q.current=null,t!==null){D(!0);try{await f(e,{title:t}),await Q(),n?.()}catch{}finally{D(!1)}}},600))},[e,Q,n]),_e=(0,R.useMemo)(()=>(0,z.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2 px-3 sm:px-5 xl:px-6`,p),children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:O||me||void 0,children:O||me}),E?(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:r.saving}):null]}),[r.saving,E,me,O]),$=(0,R.useCallback)(async(t=!1)=>{V(!0);try{let n=await w(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{V(!1)}},[Q,pe,i,e,r.chatOpenFailedMessage,r.chatOpenFailedTitle]),ve=(0,R.useCallback)(async()=>{L(!0);try{await te(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{L(!1)}},[Q,e]),ye=(0,R.useCallback)(()=>{S(x===`breakdown`?null:`breakdown`),!Z?.aiDeep?.catalysis?.report&&!I&&ve()},[x,I,ve,Z?.aiDeep?.catalysis?.report]),be=(0,R.useMemo)(()=>(0,z.jsxs)(`div`,{className:a(`flex items-center gap-2`,p),children:[(0,z.jsxs)(`button`,{type:`button`,onClick:ye,disabled:I,"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`,x===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,z.jsx)(ne,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),I?r.catalyzing:r.catalyzeButton]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>$(!1),disabled:B,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,z.jsx)(ie,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),B?r.openingChat:r.openChatButton]}),(0,z.jsx)(de,{mode:v,onModeChange:b,labels:{edit:r.modeEdit,source:r.modeSource,preview:r.modePreview}}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>S(x===`history`?null:`history`),"aria-label":r.history,className:a(`rounded-lg p-1.5 transition-colors`,x===`history`?`bg-accent/10 text-accent`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:(0,z.jsx)(m,{className:`h-4 w-4`,"aria-hidden":!0})})]}),[I,ye,$,v,r.history,r.modeEdit,r.modePreview,r.modeSource,B,x]);(0,R.useLayoutEffect)(()=>(Y({startExtra:he,main:Z?_e:null,end:Z?be:null}),()=>X()),[X,be,_e,he,Z,Y]);let xe=(0,R.useCallback)(t=>{e&&(K.current=t,W.current&&clearTimeout(W.current),W.current=setTimeout(async()=>{let t=K.current;if(K.current=null,t!==null){D(!0);try{await f(e,{markdown:t}),await Q(),n?.()}catch(e){l({type:`error`,title:r.saveFailed,message:e instanceof Error?e.message:r.saveFailedHint})}finally{D(!1)}}},600))},[e,Q,r.saveFailed,r.saveFailedHint,n]),Se=(0,R.useCallback)(t=>{N(e,t.timestamp).then(e=>{e&&T(e)})},[e]),Ce=(0,R.useCallback)(()=>{S(null),T(null)},[]),we=(0,R.useCallback)(()=>{S(null),T(null),Q(),n?.()},[Q,n]);if((0,R.useEffect)(()=>()=>{W.current&&clearTimeout(W.current),G.current&&clearTimeout(G.current);let t=K.current,n=q.current;K.current=null,q.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&f(e,r)},[e]),Z===void 0)return(0,z.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,z.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-accent border-t-transparent`})});if(Z===null)return(0,z.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.notFoundTitle}),(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFoundDescription}),(0,z.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??``:O,De=Te?C.markdown??``:Z.markdown??``;return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,z.jsx)(`div`,{ref:J,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:Te?(0,z.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[Ee&&(0,z.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Ee}),De?(0,z.jsx)(y,{noteId:e,content:De,className:`opacity-80`}):(0,z.jsx)(`p`,{className:`italic text-fg-muted`,children:r.emptyPreview})]}):(0,z.jsxs)(z.Fragment,{children:[v===`wysiwyg`&&(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`shrink-0 px-6 pt-4`,children:(0,z.jsx)(`input`,{type:`text`,value:O,onChange:e=>ge(e.target.value),onCompositionStart:()=>{U.current=!0},onCompositionEnd:()=>{U.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!U.current&&!t.isComposing&&(e.preventDefault(),(J.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,z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(ue,{}),children:(0,z.jsx)(ce,{initialContent:Z.markdown??``,onChange:xe,noteId:e},`wysiwyg-${e}`)})})]}),v===`source`&&(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`shrink-0 px-6 pt-4`,children:(0,z.jsx)(`input`,{type:`text`,value:O,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,z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(ue,{}),children:(0,z.jsx)(le,{initialContent:Z.markdown??``,onChange:xe,isDark:d},`source-${e}`)})})]}),v===`preview`&&(0,z.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&h(t.currentSrc||t.src,t.alt)},children:[O&&(0,z.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:O}),Z.markdown?(0,z.jsx)(y,{noteId:e,content:Z.markdown,className:`[&_img]:cursor-zoom-in`}):(0,z.jsx)(`p`,{className:`italic text-fg-muted`,children:r.emptyPreview})]})]})})}),(0,z.jsx)(`div`,{className:a(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!P&&`transition-[width] duration-300 ease-in-out`),style:{width:x?j:0},children:(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,style:{width:j},children:[(0,z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),F(!0);let n=e.clientX,r=j,i=e.pointerId,a=e=>{let t=r-(e.clientX-n);re(Math.max(280,Math.min(600,t)))},o=()=>{try{t.releasePointerCapture(i)}catch{}F(!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`,P&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:x===`history`?(0,z.jsx)(oe,{noteId:e,activeTimestamp:C?.timestamp??null,onSelect:Se,onClose:Ce,onRestored:we}):x===`breakdown`?(0,z.jsx)(se,{noteId:e,note:Z??null,catalyzing:I,onCatalyze:ve,onClose:()=>S(null),noteThreads:fe,openingChat:B,onOpenChat:()=>$(!1),onOpenNewChat:()=>$(!0)}):null})]})})]})}function pe(){let e=(0,L.c)(5),{noteId:t}=b(),n=_(),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,z.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-6xl flex-1 flex-col`,children:(0,z.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{Gi as a,fi as o,hi as s,li as c,mi as l,pi as u,ui as d}from"./index-CwhK8qCh.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)(o,{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)(s,{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)(c,{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)(d,{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-Cf1O9JB0.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s}from"./fetch-B5zdl27C.js";import{r as c}from"./toast-z0toXu32.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{Bo as u,Bt as d,Ci as f,Et as p,Fs as m,Ft as h,Ha as g,It as _,Mt as v,Os as y,Pt as b,Qa as x,So as S,Ta as C,Ut as w,Va as T,Wa as E,bi as D,bo as O,fa as k,fo as A,io as j,la as M,ma as N,na as P,qt as F,rt as I,wa as L,ys as R,za as z}from"./index-CwhK8qCh.js";import{t as B}from"./voice-player-store-BlF9V05n.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=F(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)(S,{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 d;t[9]===a?d=t[10]:(d=i(`size-12 shrink-0 rounded-lg border border-edge-subtle bg-surface-hover object-cover`,a),t[9]=a,t[10]=d);let f;return t[11]!==n||t[12]!==l||t[13]!==d?(f=(0,W.jsx)(w,{src:l,expectedNoteId:n,alt:``,loading:`lazy`,draggable:!1,onLoadFailed:u,className:d}),t[11]=n,t[12]=l,t[13]=d,t[14]=f):f=t[14],f}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,h=m&&s,g=m&&c,_=m?l:0,v=m&&u>0?u:a??0,y=v>0?Math.min(_/v*100,100):0,b;t[0]!==r||t[1]!==a||t[2]!==n||t[3]!==p?(b=e=>{e.stopPropagation(),p(n,r,a)},t[0]=r,t[1]=a,t[2]=n,t[3]=p,t[4]=b):b=t[4];let x=b,S;t[5]!==r||t[6]!==a||t[7]!==n||t[8]!==p?(S=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]=S):S=t[9];let C=S,w;t[10]===o?w=t[11]:(w=i(`flex items-center gap-2`,o),t[10]=o,t[11]=w);let T=h?`bg-accent text-white`:`bg-accent/10 text-accent hover:bg-accent/20`,D;t[12]===T?D=t[13]:(D=i(`flex h-7 w-7 shrink-0 items-center justify-center rounded-full transition-colors`,T),t[12]=T,t[13]=D);let O=h?`Pause`:`Play`,k;t[14]!==g||t[15]!==h?(k=g?(0,W.jsx)(j,{className:`h-3.5 w-3.5 animate-spin`}):h?(0,W.jsx)(E,{className:`h-3.5 w-3.5`}):(0,W.jsx)(z,{className:`h-3.5 w-3.5 ml-0.5`}),t[14]=g,t[15]=h,t[16]=k):k=t[16];let A;t[17]!==x||t[18]!==C||t[19]!==D||t[20]!==O||t[21]!==k?(A=(0,W.jsx)(`button`,{type:`button`,onClick:x,onKeyDown:C,className:D,"aria-label":O,children:k}),t[17]=x,t[18]=C,t[19]=D,t[20]=O,t[21]=k,t[22]=A):A=t[22];let M=`${y}%`,N;t[23]===M?N=t[24]:(N=(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:M}})}),t[23]=M,t[24]=N);let P;t[25]!==v||t[26]!==m||t[27]!==_?(P=G(m&&_>0?_:v),t[25]=v,t[26]=m,t[27]=_,t[28]=P):P=t[28];let F;t[29]===P?F=t[30]:(F=(0,W.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:P}),t[29]=P,t[30]=F);let I;t[31]!==N||t[32]!==F?(I=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[N,F]}),t[31]=N,t[32]=F,t[33]=I):I=t[33];let L;return t[34]!==I||t[35]!==w||t[36]!==A?(L=(0,W.jsxs)(`div`,{className:w,onClick:K,children:[A,I]}),t[34]=I,t[35]=w,t[36]=A,t[37]=L):L=t[37],L}function K(e){return e.stopPropagation()}function q(e){return e.toggle}var ue={thought:A,todo:N,voice:x,media:O,bookmark:R,mixed:A,task:N};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,d=ue[n.kind]||A,f;t[0]!==c||t[1]!==n?(f=de(n,c),t[0]=c,t[1]=n,t[2]=f):f=t[2];let p=f,m=!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=_,b,x;t[7]!==n.id||t[8]!==r?(b=()=>r(n.id),x=e=>{(e.key===`Enter`||e.key===` `)&&r(n.id)},t[7]=n.id,t[8]=r,t[9]=b,t[10]=x):(b=t[9],x=t[10]);let S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=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]=S):S=t[11];let C;t[12]!==d||t[13]!==n.coverAttachmentId||t[14]!==n.id||t[15]!==n.kind||t[16]!==n.voiceAttachmentId||t[17]!==n.voiceDurationSec?(C=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)(d,{className:`mt-0.5 h-4 w-4 shrink-0 text-fg-muted`}),t[12]=d,t[13]=n.coverAttachmentId,t[14]=n.id,t[15]=n.kind,t[16]=n.voiceAttachmentId,t[17]=n.voiceDurationSec,t[18]=C):C=t[18];let w;t[19]===n.title?w=t[20]:(w=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]=w);let E=n.title?`text-fg-muted`:m?`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]!==p||t[24]!==D?(O=(0,W.jsx)(`p`,{className:D,children:p}),t[23]=p,t[24]=D,t[25]=O):O=t[25];let k;t[26]!==O||t[27]!==w?(k=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,O]}),t[26]=O,t[27]=w,t[28]=k):k=t[28];let j;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(j=(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)(u,{className:`h-4 w-4`})})}),t[29]=j):j=t[29];let M;t[30]!==n.id||t[31]!==n.pinned||t[32]!==a?(M=()=>a(n.id,!n.pinned),t[30]=n.id,t[31]=n.pinned,t[32]=a,t[33]=M):M=t[33];let N;t[34]===n.pinned?N=t[35]:(N=n.pinned?(0,W.jsx)(T,{className:`h-4 w-4`}):(0,W.jsx)(g,{className:`h-4 w-4`}),t[34]=n.pinned,t[35]=N);let F=n.pinned?c.unpin:c.pin,I;t[36]!==M||t[37]!==N||t[38]!==F?(I=(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:M,children:[N,F]}),t[36]=M,t[37]=N,t[38]=F,t[39]=I):I=t[39];let L;t[40]!==n.id||t[41]!==o?(L=()=>o(n.id),t[40]=n.id,t[41]=o,t[42]=L):L=t[42];let R;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,W.jsx)(y,{className:`h-4 w-4`}),t[43]=R):R=t[43];let z;t[44]!==c.archive||t[45]!==L?(z=(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:L,children:[R,c.archive]}),t[44]=c.archive,t[45]=L,t[46]=z):z=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)(P,{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]!==I||t[56]!==z||t[57]!==G?(K=(0,W.jsxs)(re,{children:[j,(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:[I,z,B,G]})})]}),t[55]=I,t[56]=z,t[57]=G,t[58]=K):K=t[58];let q;t[59]!==k||t[60]!==K||t[61]!==C?(q=(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[C,k,K]}),t[59]=k,t[60]=K,t[61]=C,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)(g,{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]!==b||t[76]!==x?(he=(0,W.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:b,onKeyDown:x,className:S,children:[q,Q]}),t[73]=q,t[74]=Q,t[75]=b,t[76]=x,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,u]=(0,U.useState)(``),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(0),[_,v]=(0,U.useState)(!1),y=(0,U.useRef)(null),b=(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,b.current=null,C.current=[],m(!1),g(0)},[]);(0,U.useEffect)(()=>()=>D(),[D]);let A=(0,U.useCallback)(async()=>{let e=b.current;if(!e||e.state!==`recording`)return;v(!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{v(!1)}return}v(!1)},[D,a]),j=(0,U.useCallback)(async()=>{if(!(!a||_||p)&&!(!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,b.current=n,C.current=[],w.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&C.current.push(e.data)},n.start(),m(!0),g(0),T.current=setInterval(()=>{g(Math.round((Date.now()-w.current)/1e3))},250),E.current=setTimeout(()=>{A()},X)}catch{D()}},[D,a,p,A,_]),M=(0,U.useCallback)(()=>{if(p){A();return}j()},[p,j,A]),N=(0,U.useCallback)(async e=>{let t=l.trim();if(!(!t||d)){f(!0),u(``);try{await n(t,e)}catch{u(t)}finally{f(!1),y.current?.focus()}}},[l,d,n]),P=(0,U.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),N()),e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),N({navigate:!1}))},[N]),F=d||_;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`,p&&`border-danger ring-1 ring-danger/40`),children:[r&&(0,W.jsx)(`button`,{type:`button`,onClick:r,disabled:F||s||p,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)(O,{className:`h-4 w-4`})}),a&&(0,W.jsx)(`button`,{type:`button`,onClick:M,disabled:F||c||d,className:i(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,p?`bg-danger-soft text-danger hover:bg-danger-soft`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-label":p?`Stop recording`:`Voice`,"aria-pressed":p,children:p?(0,W.jsx)(k,{className:`h-4 w-4 fill-current`}):(0,W.jsx)(x,{className:`h-4 w-4`})}),p?(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:o.replace(`{{seconds}}`,String(h))}):(0,W.jsx)(`textarea`,{ref:y,value:l,onChange:e=>u(e.target.value),onKeyDown:P,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||p,onClick:e=>void N({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&&!p?`text-accent hover:bg-accent-soft`:`text-fg-disabled`),children:(0,W.jsx)(L,{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)(I,he),[g]=(0,U.useState)(ye),y=m(),x;e[0]!==n||e[1]!==r.kindFilter||e[2]!==r.search||e[3]!==r.statusFilter?(x=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]=x):x=e[4];let S=x,w;e[5]!==r.kindFilter||e[6]!==r.search||e[7]!==r.statusFilter?(w=()=>v({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:O,isLoading:k}=l(S,w,T),A=k&&!E,j;e[10]===E?.items?j=e[11]:(j=E?.items??[],e[10]=E?.items,e[11]=j);let N=j,P=E?.total??0,F=D(ve),L=D(_e),R=P>0?t.noteCount.replace(`{{count}}`,String(P)):null,z,B;e[12]!==L||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`,f),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}),()=>L()):(L(),()=>L()),B=[L,n,t.title,R,F],e[12]=L,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]!==O||e[26]!==y?(re=async(e,t)=>{let n=await b(e,`web`);await O(),t?.navigate!==!1&&y(`/notes/${n.id}`)},e[25]=O,e[26]=y,e[27]=re):re=e[27];let H=re,ie;e[28]!==O||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 h(n,`web`),await O()}catch(e){let n=e;c({type:`error`,title:t.imageUploadFailed,message:n instanceof Error?n.message:t.imageUploadFailedHint})}},e.click()},e[28]=O,e[29]=t.imageUploadFailed,e[30]=t.imageUploadFailedHint,e[31]=ie):ie=e[31];let ae=ie,oe;e[32]!==O||e[33]!==t.voiceUploadFailed||e[34]!==t.voiceUploadFailedHint?(oe=async(e,n)=>{try{await _(e,n,`web`),await O()}catch(e){let n=e;c({type:`error`,title:t.voiceUploadFailed,message:n instanceof Error?n.message:t.voiceUploadFailedHint})}},e[32]=O,e[33]=t.voiceUploadFailed,e[34]=t.voiceUploadFailedHint,e[35]=oe):oe=e[35];let ce=oe,G;e[36]===O?G=e[37]:(G=async(e,t)=>{await d(e,{pinned:t}),await O()},e[36]=O,e[37]=G);let le=G,K;e[38]===O?K=e[39]:(K=async e=>{await d(e,{status:`archived`}),await O()},e[38]=O,e[39]=K);let q=K,ue;e[40]===O?ue=e[41]:(ue=async e=>{await p(e),await O()},e[40]=O,e[41]=ue);let de=ue,fe;e[42]===y?fe=e[43]:(fe=e=>{y(`/notes/${e}`)},e[42]=y,e[43]=fe);let pe=fe;if(!n){let n;e[44]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsx)(M,{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)(C,{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]!==g||e[93]!==A||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:A?(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)(M,{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,g,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]=g,e[93]=A,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{Li as r,Ro as i,Vo as a,xi as o}from"./index-CwhK8qCh.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=o()&&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=o()&&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`,r.transition,r.press,r.focusRingPanel),onClick:()=>void p?.(),children:[(0,c.jsx)(i,{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`,r.transition,r.press,r.focusRingPanel),onClick:()=>void h?.(),children:[(0,c.jsx)(i,{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`,r.transition,r.press,r.focusRingPanel),t[19]=O):O=t[19];let k;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,c.jsx)(a,{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};
|