@qt4798/pi-web 0.17.2 → 0.17.3
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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +16 -16
- package/.next/build-manifest.json +4 -4
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +5 -5
- package/.next/react-loadable-manifest.json +72 -60
- package/.next/required-server-files.js +27 -28
- package/.next/required-server-files.json +27 -28
- package/.next/server/app/_global-error/page.js +1 -1
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +4 -3
- package/.next/server/app/_not-found.segments/_full.segment.rsc +4 -3
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -3
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +3 -2
- package/.next/server/app/api/agent/[id]/bash-output/route.js +1 -1
- package/.next/server/app/api/agent/[id]/bash-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agent/[id]/events/route.js +2 -2
- package/.next/server/app/api/agent/[id]/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agent/[id]/route.js +1 -1
- package/.next/server/app/api/agent/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agent/new/route.js +1 -1
- package/.next/server/app/api/agent/new/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/new/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agent/running/events/route.js +1 -1
- package/.next/server/app/api/agent/running/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agent/running/route.js +1 -1
- package/.next/server/app/api/agent/running/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app-update/route.js +1 -1
- package/.next/server/app/api/app-update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/api-key/[provider]/route.js +1 -1
- package/.next/server/app/api/auth/api-key/[provider]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/combined/route.js +1 -1
- package/.next/server/app/api/auth/combined/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/login/[provider]/route.js +2 -2
- package/.next/server/app/api/auth/login/[provider]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/logout/[provider]/route.js +1 -1
- package/.next/server/app/api/auth/logout/[provider]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/providers/route.js +1 -1
- package/.next/server/app/api/auth/providers/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/backup/export/route.js +1 -1
- package/.next/server/app/api/backup/export/route.js.nft.json +1 -1
- package/.next/server/app/api/backup/export/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/backup/import/route.js +1 -1
- package/.next/server/app/api/backup/import/route.js.nft.json +1 -1
- package/.next/server/app/api/backup/import/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/cwd/browse/route.js +1 -1
- package/.next/server/app/api/cwd/browse/route.js.nft.json +1 -1
- package/.next/server/app/api/cwd/browse/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/cwd/validate/route.js +1 -1
- package/.next/server/app/api/cwd/validate/route.js.nft.json +1 -1
- package/.next/server/app/api/cwd/validate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/deepseek/balance/route.js +1 -1
- package/.next/server/app/api/deepseek/balance/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/default-cwd/route.js +1 -1
- package/.next/server/app/api/default-cwd/route.js.nft.json +1 -1
- package/.next/server/app/api/default-cwd/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/events/route.js +2 -2
- package/.next/server/app/api/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/features/route.js +1 -1
- package/.next/server/app/api/features/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/file-index/route.js +1 -1
- package/.next/server/app/api/file-index/route.js.nft.json +1 -1
- package/.next/server/app/api/file-index/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/files/[...path]/route.js +1 -1
- package/.next/server/app/api/files/[...path]/route.js.nft.json +1 -1
- package/.next/server/app/api/files/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/diff/route.js +2 -2
- package/.next/server/app/api/git/diff/route.js.nft.json +1 -1
- package/.next/server/app/api/git/diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/push/route.js +1 -1
- package/.next/server/app/api/git/push/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/stash/route.js +1 -1
- package/.next/server/app/api/git/stash/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/status/route.js +2 -2
- package/.next/server/app/api/git/status/route.js.nft.json +1 -1
- package/.next/server/app/api/git/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/home/route.js +1 -1
- package/.next/server/app/api/home/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/import/discover/route.js +1 -1
- package/.next/server/app/api/import/discover/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/import/execute/route.js +1 -1
- package/.next/server/app/api/import/execute/route.js.nft.json +1 -1
- package/.next/server/app/api/import/execute/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/import/status/route.js +1 -1
- package/.next/server/app/api/import/status/route.js.nft.json +1 -1
- package/.next/server/app/api/import/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/logs/route.js +1 -1
- package/.next/server/app/api/logs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/restart/route.js +1 -1
- package/.next/server/app/api/mcp/restart/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/route.js +2 -2
- package/.next/server/app/api/mcp/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/models/route.js +1 -1
- package/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/models-config/builtin/route.js +1 -1
- package/.next/server/app/api/models-config/builtin/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/models-config/catalog/route.js +1 -1
- package/.next/server/app/api/models-config/catalog/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/models-config/discover/route.js +1 -1
- package/.next/server/app/api/models-config/discover/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/models-config/route.js +1 -1
- package/.next/server/app/api/models-config/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/models-config/test/route.js +1 -1
- package/.next/server/app/api/models-config/test/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/modes/route.js +1 -1
- package/.next/server/app/api/modes/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/plugins/check/route.js +1 -1
- package/.next/server/app/api/plugins/check/route.js.nft.json +1 -1
- package/.next/server/app/api/plugins/check/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/plugins/route.js +1 -1
- package/.next/server/app/api/plugins/route.js.nft.json +1 -1
- package/.next/server/app/api/plugins/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/project-aliases/route.js +1 -1
- package/.next/server/app/api/project-aliases/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/project-state/route.js +1 -1
- package/.next/server/app/api/project-state/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/project-trust/route.js +1 -1
- package/.next/server/app/api/project-trust/route.js.nft.json +1 -1
- package/.next/server/app/api/project-trust/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/projects/visibility/route.js +1 -1
- package/.next/server/app/api/projects/visibility/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/proxy/route.js +1 -1
- package/.next/server/app/api/proxy/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/proxy/test/route.js +1 -1
- package/.next/server/app/api/proxy/test/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/[id]/auto-name/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/auto-name/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/[id]/context/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/context/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/[id]/details/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/details/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/tool-result-image/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/tool-result-image/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/[id]/export/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/export/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/[id]/queue-recovery/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/queue-recovery/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/[id]/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/[id]/state/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/state/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/route.js +1 -1
- package/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sessions/search/route.js +1 -1
- package/.next/server/app/api/sessions/search/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/settings/title-model/route.js +1 -1
- package/.next/server/app/api/settings/title-model/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/check/route.js +1 -1
- package/.next/server/app/api/skills/check/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/check/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/install/route.js +1 -1
- package/.next/server/app/api/skills/install/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/install/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/route.js +1 -1
- package/.next/server/app/api/skills/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/search/route.js +1 -1
- package/.next/server/app/api/skills/search/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/update/route.js +1 -1
- package/.next/server/app/api/skills/update/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/snippets/[id]/route.js +1 -1
- package/.next/server/app/api/snippets/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/snippets/route.js +1 -1
- package/.next/server/app/api/snippets/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/subagents/[id]/route.js +1 -1
- package/.next/server/app/api/subagents/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/subagents/profiles/route.js +1 -1
- package/.next/server/app/api/subagents/profiles/route.js.nft.json +1 -1
- package/.next/server/app/api/subagents/profiles/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/subagents/settings/route.js +1 -1
- package/.next/server/app/api/subagents/settings/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[id]/[action]/route.js +1 -1
- package/.next/server/app/api/tasks/[id]/[action]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[id]/changed-files/route.js +2 -2
- package/.next/server/app/api/tasks/[id]/changed-files/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[id]/diff/route.js +1 -1
- package/.next/server/app/api/tasks/[id]/diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[id]/events/route.js +1 -1
- package/.next/server/app/api/tasks/[id]/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[id]/route.js +1 -1
- package/.next/server/app/api/tasks/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/batch/route.js +1 -1
- package/.next/server/app/api/tasks/batch/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/events/route.js +1 -1
- package/.next/server/app/api/tasks/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/route.js +1 -1
- package/.next/server/app/api/tasks/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/settings/route.js +1 -1
- package/.next/server/app/api/tasks/settings/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/settings/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/templates/route.js +1 -1
- package/.next/server/app/api/tasks/templates/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/terminal/[id]/events/route.js +2 -2
- package/.next/server/app/api/terminal/[id]/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/terminal/[id]/route.js +1 -1
- package/.next/server/app/api/terminal/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/terminal/route.js +1 -1
- package/.next/server/app/api/terminal/route.js.nft.json +1 -1
- package/.next/server/app/api/terminal/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/themes/[name]/route.js +1 -1
- package/.next/server/app/api/themes/[name]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/themes/route.js +1 -1
- package/.next/server/app/api/themes/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tools/settings/route.js +1 -1
- package/.next/server/app/api/tools/settings/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/usage/route.js +1 -1
- package/.next/server/app/api/usage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/vision-config/route.js +2 -2
- package/.next/server/app/api/vision-config/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/route.js +1 -1
- package/.next/server/app/api/worktrees/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
- package/.next/server/app/icon.ico/route.js +1 -1
- package/.next/server/app/icon.png/route.js +1 -1
- package/.next/server/app/icon.svg/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +6 -5
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +6 -5
- package/.next/server/app/index.segments/_full.segment.rsc +6 -5
- package/.next/server/app/index.segments/_tree.segment.rsc +3 -2
- package/.next/server/app/page.js +3 -3
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +16 -16
- package/.next/server/chunks/2430.js +4 -4
- package/.next/server/chunks/7790.js +1 -1
- package/.next/server/chunks/7915.js +1 -1
- package/.next/server/chunks/9280.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/middleware.js +6 -6
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/1966.b8f83f7ba376c962.js +1 -0
- package/.next/static/chunks/3899.d4d0ae202f418161.js +1 -0
- package/.next/static/chunks/app/_not-found/page-2da68441239d5ed5.js +1 -0
- package/.next/static/chunks/app/layout-324e170a1e2a663e.js +1 -0
- package/.next/static/chunks/app/{page-a5bd25a6c7117c16.js → page-5a4b9ce0c45aedbb.js} +4 -4
- package/.next/static/chunks/main-10987b1ebc0342cf.js +5 -0
- package/.next/static/chunks/main-app-413def87654f9d85.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/global-error-512d48f348bac9b3.js +1 -0
- package/.next/static/chunks/webpack-eed65adb5946593c.js +1 -0
- package/.next/static/css/26b54210008ec821.css +1 -0
- package/.next/static/css/{683b2ca13a4576ae.css → f8c37f1cfee885e7.css} +1 -1
- package/.next/trace +7 -8
- package/.next/trace-build +1 -1
- package/.next/types/app/api/agent/[id]/bash-output/route.ts +1 -1
- package/.next/types/app/api/agent/[id]/events/route.ts +1 -1
- package/.next/types/app/api/agent/[id]/route.ts +1 -1
- package/.next/types/app/api/agent/new/route.ts +1 -1
- package/.next/types/app/api/agent/running/events/route.ts +1 -1
- package/.next/types/app/api/agent/running/route.ts +1 -1
- package/.next/types/app/api/app-update/route.ts +1 -1
- package/.next/types/app/api/auth/api-key/[provider]/route.ts +1 -1
- package/.next/types/app/api/auth/combined/route.ts +1 -1
- package/.next/types/app/api/auth/login/[provider]/route.ts +1 -1
- package/.next/types/app/api/auth/logout/[provider]/route.ts +1 -1
- package/.next/types/app/api/auth/providers/route.ts +1 -1
- package/.next/types/app/api/backup/export/route.ts +1 -1
- package/.next/types/app/api/backup/import/route.ts +1 -1
- package/.next/types/app/api/cwd/browse/route.ts +1 -1
- package/.next/types/app/api/cwd/validate/route.ts +1 -1
- package/.next/types/app/api/deepseek/balance/route.ts +1 -1
- package/.next/types/app/api/default-cwd/route.ts +1 -1
- package/.next/types/app/api/events/route.ts +1 -1
- package/.next/types/app/api/features/route.ts +1 -1
- package/.next/types/app/api/file-index/route.ts +1 -1
- package/.next/types/app/api/files/[...path]/route.ts +1 -1
- package/.next/types/app/api/git/diff/route.ts +1 -1
- package/.next/types/app/api/git/push/route.ts +1 -1
- package/.next/types/app/api/git/stash/route.ts +1 -1
- package/.next/types/app/api/git/status/route.ts +1 -1
- package/.next/types/app/api/home/route.ts +1 -1
- package/.next/types/app/api/import/discover/route.ts +1 -1
- package/.next/types/app/api/import/execute/route.ts +1 -1
- package/.next/types/app/api/import/status/route.ts +1 -1
- package/.next/types/app/api/logs/route.ts +1 -1
- package/.next/types/app/api/mcp/restart/route.ts +1 -1
- package/.next/types/app/api/mcp/route.ts +1 -1
- package/.next/types/app/api/models/route.ts +1 -1
- package/.next/types/app/api/models-config/builtin/route.ts +1 -1
- package/.next/types/app/api/models-config/catalog/route.ts +1 -1
- package/.next/types/app/api/models-config/discover/route.ts +1 -1
- package/.next/types/app/api/models-config/route.ts +1 -1
- package/.next/types/app/api/models-config/test/route.ts +1 -1
- package/.next/types/app/api/modes/route.ts +1 -1
- package/.next/types/app/api/plugins/check/route.ts +1 -1
- package/.next/types/app/api/plugins/route.ts +1 -1
- package/.next/types/app/api/project-aliases/route.ts +1 -1
- package/.next/types/app/api/project-state/route.ts +1 -1
- package/.next/types/app/api/project-trust/route.ts +1 -1
- package/.next/types/app/api/projects/visibility/route.ts +1 -1
- package/.next/types/app/api/proxy/route.ts +1 -1
- package/.next/types/app/api/proxy/test/route.ts +1 -1
- package/.next/types/app/api/sessions/[id]/auto-name/route.ts +1 -1
- package/.next/types/app/api/sessions/[id]/context/route.ts +1 -1
- package/.next/types/app/api/sessions/[id]/details/route.ts +1 -1
- package/.next/types/app/api/sessions/[id]/entries/[entryId]/thinking/route.ts +1 -1
- package/.next/types/app/api/sessions/[id]/entries/[entryId]/tool-result-image/route.ts +1 -1
- package/.next/types/app/api/sessions/[id]/export/route.ts +1 -1
- package/.next/types/app/api/sessions/[id]/queue-recovery/route.ts +1 -1
- package/.next/types/app/api/sessions/[id]/route.ts +1 -1
- package/.next/types/app/api/sessions/[id]/state/route.ts +1 -1
- package/.next/types/app/api/sessions/route.ts +1 -1
- package/.next/types/app/api/sessions/search/route.ts +1 -1
- package/.next/types/app/api/settings/title-model/route.ts +1 -1
- package/.next/types/app/api/skills/check/route.ts +1 -1
- package/.next/types/app/api/skills/install/route.ts +1 -1
- package/.next/types/app/api/skills/route.ts +1 -1
- package/.next/types/app/api/skills/search/route.ts +1 -1
- package/.next/types/app/api/skills/update/route.ts +1 -1
- package/.next/types/app/api/snippets/[id]/route.ts +1 -1
- package/.next/types/app/api/snippets/route.ts +1 -1
- package/.next/types/app/api/subagents/[id]/route.ts +1 -1
- package/.next/types/app/api/subagents/profiles/route.ts +1 -1
- package/.next/types/app/api/subagents/settings/route.ts +1 -1
- package/.next/types/app/api/tasks/[id]/[action]/route.ts +1 -1
- package/.next/types/app/api/tasks/[id]/changed-files/route.ts +1 -1
- package/.next/types/app/api/tasks/[id]/diff/route.ts +1 -1
- package/.next/types/app/api/tasks/[id]/events/route.ts +1 -1
- package/.next/types/app/api/tasks/[id]/route.ts +1 -1
- package/.next/types/app/api/tasks/batch/route.ts +1 -1
- package/.next/types/app/api/tasks/events/route.ts +1 -1
- package/.next/types/app/api/tasks/route.ts +1 -1
- package/.next/types/app/api/tasks/settings/route.ts +1 -1
- package/.next/types/app/api/tasks/templates/route.ts +1 -1
- package/.next/types/app/api/terminal/[id]/events/route.ts +1 -1
- package/.next/types/app/api/terminal/[id]/route.ts +1 -1
- package/.next/types/app/api/terminal/route.ts +1 -1
- package/.next/types/app/api/themes/[name]/route.ts +1 -1
- package/.next/types/app/api/themes/route.ts +1 -1
- package/.next/types/app/api/tools/settings/route.ts +1 -1
- package/.next/types/app/api/usage/route.ts +1 -1
- package/.next/types/app/api/vision-config/route.ts +1 -1
- package/.next/types/app/api/worktrees/route.ts +1 -1
- package/.next/types/app/layout.ts +1 -1
- package/.next/types/app/page.ts +1 -1
- package/LICENSE +22 -22
- package/README.en.md +145 -145
- package/README.ja.md +134 -134
- package/README.md +372 -372
- package/README.ru.md +134 -134
- package/bin/fix-pi-agent-undici.js +122 -122
- package/bin/memory-watchdog.js +135 -135
- package/bin/pi-web-options.js +114 -114
- package/bin/pi-web.js +140 -140
- package/bin/prepare-terminal.js +14 -14
- package/bin/process-lifecycle.js +81 -81
- package/bin/watchdog-preload.js +20 -20
- package/bin/with-memory-limit.js +73 -46
- package/lib/theme/openchamber/aura.json +41 -41
- package/lib/theme/openchamber/ayu.json +41 -41
- package/lib/theme/openchamber/carbonfox.json +41 -41
- package/lib/theme/openchamber/catppuccin.json +41 -41
- package/lib/theme/openchamber/dracula.json +41 -41
- package/lib/theme/openchamber/fields-of-the-shire.json +41 -41
- package/lib/theme/openchamber/flexoki.json +41 -41
- package/lib/theme/openchamber/gruvbox.json +41 -41
- package/lib/theme/openchamber/jetbrains.json +41 -41
- package/lib/theme/openchamber/kanagawa.json +41 -41
- package/lib/theme/openchamber/mono-plus.json +41 -41
- package/lib/theme/openchamber/mono.json +41 -41
- package/lib/theme/openchamber/monokai.json +41 -41
- package/lib/theme/openchamber/night-owl.json +41 -41
- package/lib/theme/openchamber/nord.json +41 -41
- package/lib/theme/openchamber/one-dark-pro.json +41 -41
- package/lib/theme/openchamber/openchamber.json +41 -41
- package/lib/theme/openchamber/solarized.json +41 -41
- package/lib/theme/openchamber/tokyonight.json +41 -41
- package/lib/theme/openchamber/vesper.json +41 -41
- package/lib/theme/openchamber/vitesse-dark.json +23 -23
- package/lib/theme/openchamber/vitesse-light.json +23 -23
- package/next.config.ts +56 -56
- package/package.json +115 -115
- package/public/catppuccin-icons/LICENSE +25 -25
- package/public/catppuccin-icons/latte/3d.svg +3 -3
- package/public/catppuccin-icons/latte/_file.svg +3 -3
- package/public/catppuccin-icons/latte/_folder.svg +3 -3
- package/public/catppuccin-icons/latte/_folder_open.svg +3 -3
- package/public/catppuccin-icons/latte/_root.svg +7 -7
- package/public/catppuccin-icons/latte/_root_open.svg +5 -5
- package/public/catppuccin-icons/latte/adobe-ae.svg +6 -6
- package/public/catppuccin-icons/latte/adobe-ai.svg +6 -6
- package/public/catppuccin-icons/latte/adobe-id.svg +6 -6
- package/public/catppuccin-icons/latte/adobe-ps.svg +6 -6
- package/public/catppuccin-icons/latte/adobe-xd.svg +6 -6
- package/public/catppuccin-icons/latte/adonis.svg +6 -6
- package/public/catppuccin-icons/latte/alex.svg +6 -6
- package/public/catppuccin-icons/latte/amber.svg +3 -3
- package/public/catppuccin-icons/latte/android.svg +3 -3
- package/public/catppuccin-icons/latte/angular-component.svg +6 -6
- package/public/catppuccin-icons/latte/angular-directive.svg +6 -6
- package/public/catppuccin-icons/latte/angular-guard.svg +6 -6
- package/public/catppuccin-icons/latte/angular-pipe.svg +6 -6
- package/public/catppuccin-icons/latte/angular-service.svg +6 -6
- package/public/catppuccin-icons/latte/angular.svg +6 -6
- package/public/catppuccin-icons/latte/ansible-lint.svg +4 -4
- package/public/catppuccin-icons/latte/antlr.svg +6 -6
- package/public/catppuccin-icons/latte/apache.svg +7 -7
- package/public/catppuccin-icons/latte/api-blueprint.svg +3 -3
- package/public/catppuccin-icons/latte/apollo.svg +6 -6
- package/public/catppuccin-icons/latte/apple.svg +3 -3
- package/public/catppuccin-icons/latte/arduino.svg +3 -3
- package/public/catppuccin-icons/latte/asciidoc.svg +3 -3
- package/public/catppuccin-icons/latte/assembly.svg +4 -4
- package/public/catppuccin-icons/latte/astro-config.svg +7 -7
- package/public/catppuccin-icons/latte/astro.svg +6 -6
- package/public/catppuccin-icons/latte/audio.svg +6 -6
- package/public/catppuccin-icons/latte/autohotkey.svg +6 -6
- package/public/catppuccin-icons/latte/azure-pipelines.svg +3 -3
- package/public/catppuccin-icons/latte/babel.svg +3 -3
- package/public/catppuccin-icons/latte/bash.svg +7 -7
- package/public/catppuccin-icons/latte/batch.svg +6 -6
- package/public/catppuccin-icons/latte/bazel.svg +3 -3
- package/public/catppuccin-icons/latte/benchmark.svg +3 -3
- package/public/catppuccin-icons/latte/bicep.svg +5 -5
- package/public/catppuccin-icons/latte/binary.svg +6 -6
- package/public/catppuccin-icons/latte/biome.svg +3 -3
- package/public/catppuccin-icons/latte/bitbucket.svg +3 -3
- package/public/catppuccin-icons/latte/blink.svg +10 -10
- package/public/catppuccin-icons/latte/blitz.svg +3 -3
- package/public/catppuccin-icons/latte/bower.svg +9 -9
- package/public/catppuccin-icons/latte/browserslist.svg +6 -6
- package/public/catppuccin-icons/latte/bun-lock.svg +8 -8
- package/public/catppuccin-icons/latte/bun.svg +7 -7
- package/public/catppuccin-icons/latte/c-header.svg +3 -3
- package/public/catppuccin-icons/latte/c.svg +3 -3
- package/public/catppuccin-icons/latte/cabal.svg +7 -7
- package/public/catppuccin-icons/latte/caddy.svg +6 -6
- package/public/catppuccin-icons/latte/capacitor.svg +3 -3
- package/public/catppuccin-icons/latte/cargo-lock.svg +8 -8
- package/public/catppuccin-icons/latte/cargo.svg +7 -7
- package/public/catppuccin-icons/latte/certificate.svg +7 -7
- package/public/catppuccin-icons/latte/changelog.svg +3 -3
- package/public/catppuccin-icons/latte/circle-ci.svg +6 -6
- package/public/catppuccin-icons/latte/clojure.svg +10 -10
- package/public/catppuccin-icons/latte/cmake.svg +7 -7
- package/public/catppuccin-icons/latte/cobol.svg +3 -3
- package/public/catppuccin-icons/latte/code-climate.svg +3 -3
- package/public/catppuccin-icons/latte/code-of-conduct.svg +6 -6
- package/public/catppuccin-icons/latte/codeowners.svg +6 -6
- package/public/catppuccin-icons/latte/coffeescript.svg +6 -6
- package/public/catppuccin-icons/latte/commitlint.svg +6 -6
- package/public/catppuccin-icons/latte/config.svg +3 -3
- package/public/catppuccin-icons/latte/contributing.svg +6 -6
- package/public/catppuccin-icons/latte/cpp-header.svg +4 -4
- package/public/catppuccin-icons/latte/cpp.svg +4 -4
- package/public/catppuccin-icons/latte/crystal.svg +3 -3
- package/public/catppuccin-icons/latte/csharp.svg +3 -3
- package/public/catppuccin-icons/latte/cspell.svg +4 -4
- package/public/catppuccin-icons/latte/css-map.svg +8 -8
- package/public/catppuccin-icons/latte/css.svg +6 -6
- package/public/catppuccin-icons/latte/css3.svg +6 -6
- package/public/catppuccin-icons/latte/csv.svg +3 -3
- package/public/catppuccin-icons/latte/cucumber.svg +3 -3
- package/public/catppuccin-icons/latte/cuda.svg +6 -6
- package/public/catppuccin-icons/latte/cue.svg +4 -4
- package/public/catppuccin-icons/latte/cursor-ignore.svg +4 -4
- package/public/catppuccin-icons/latte/cursor.svg +4 -4
- package/public/catppuccin-icons/latte/cypress.svg +6 -6
- package/public/catppuccin-icons/latte/d.svg +3 -3
- package/public/catppuccin-icons/latte/darklua.svg +6 -6
- package/public/catppuccin-icons/latte/dart-generated.svg +6 -6
- package/public/catppuccin-icons/latte/dart.svg +6 -6
- package/public/catppuccin-icons/latte/database.svg +3 -3
- package/public/catppuccin-icons/latte/deno.svg +3 -3
- package/public/catppuccin-icons/latte/deno_lock.svg +6 -6
- package/public/catppuccin-icons/latte/dependabot.svg +3 -3
- package/public/catppuccin-icons/latte/devcontainer.svg +4 -4
- package/public/catppuccin-icons/latte/dhall.svg +3 -3
- package/public/catppuccin-icons/latte/diff.svg +7 -7
- package/public/catppuccin-icons/latte/django.svg +6 -6
- package/public/catppuccin-icons/latte/docker-compose.svg +3 -3
- package/public/catppuccin-icons/latte/docker-ignore.svg +3 -3
- package/public/catppuccin-icons/latte/docker.svg +3 -3
- package/public/catppuccin-icons/latte/docusaurus.svg +7 -7
- package/public/catppuccin-icons/latte/drawio.svg +3 -3
- package/public/catppuccin-icons/latte/drizzle-orm.svg +3 -3
- package/public/catppuccin-icons/latte/dub-selections.svg +8 -8
- package/public/catppuccin-icons/latte/dub.svg +7 -7
- package/public/catppuccin-icons/latte/editorconfig.svg +3 -3
- package/public/catppuccin-icons/latte/ejs.svg +3 -3
- package/public/catppuccin-icons/latte/eleventy.svg +3 -3
- package/public/catppuccin-icons/latte/elixir.svg +3 -3
- package/public/catppuccin-icons/latte/elm.svg +3 -3
- package/public/catppuccin-icons/latte/ember.svg +3 -3
- package/public/catppuccin-icons/latte/env.svg +3 -3
- package/public/catppuccin-icons/latte/envrc.svg +6 -6
- package/public/catppuccin-icons/latte/erlang.svg +6 -6
- package/public/catppuccin-icons/latte/esbuild.svg +3 -3
- package/public/catppuccin-icons/latte/eslint-ignore.svg +6 -6
- package/public/catppuccin-icons/latte/eslint.svg +6 -6
- package/public/catppuccin-icons/latte/exe.svg +6 -6
- package/public/catppuccin-icons/latte/fastlane.svg +14 -14
- package/public/catppuccin-icons/latte/favicon.svg +3 -3
- package/public/catppuccin-icons/latte/figma.svg +9 -9
- package/public/catppuccin-icons/latte/firebase.svg +3 -3
- package/public/catppuccin-icons/latte/flutter.svg +8 -8
- package/public/catppuccin-icons/latte/folder_admin.svg +6 -6
- package/public/catppuccin-icons/latte/folder_admin_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_android.svg +6 -6
- package/public/catppuccin-icons/latte/folder_android_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_animation.svg +6 -6
- package/public/catppuccin-icons/latte/folder_animation_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_api.svg +6 -6
- package/public/catppuccin-icons/latte/folder_api_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_app.svg +7 -7
- package/public/catppuccin-icons/latte/folder_app_open.svg +7 -7
- package/public/catppuccin-icons/latte/folder_assets.svg +5 -5
- package/public/catppuccin-icons/latte/folder_assets_open.svg +5 -5
- package/public/catppuccin-icons/latte/folder_audio.svg +9 -9
- package/public/catppuccin-icons/latte/folder_audio_open.svg +9 -9
- package/public/catppuccin-icons/latte/folder_audit.svg +4 -4
- package/public/catppuccin-icons/latte/folder_audit_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_aws.svg +9 -9
- package/public/catppuccin-icons/latte/folder_aws_open.svg +9 -9
- package/public/catppuccin-icons/latte/folder_azure-devops.svg +4 -4
- package/public/catppuccin-icons/latte/folder_azure-devops_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_azure-pipelines.svg +6 -6
- package/public/catppuccin-icons/latte/folder_azure-pipelines_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_benchmark.svg +6 -6
- package/public/catppuccin-icons/latte/folder_benchmark_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_caddy.svg +7 -7
- package/public/catppuccin-icons/latte/folder_caddy_open.svg +7 -7
- package/public/catppuccin-icons/latte/folder_cargo.svg +6 -6
- package/public/catppuccin-icons/latte/folder_cargo_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_circle-ci.svg +9 -9
- package/public/catppuccin-icons/latte/folder_circle-ci_open.svg +9 -9
- package/public/catppuccin-icons/latte/folder_client.svg +6 -6
- package/public/catppuccin-icons/latte/folder_client_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_cloud.svg +6 -6
- package/public/catppuccin-icons/latte/folder_cloud_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_command.svg +6 -6
- package/public/catppuccin-icons/latte/folder_command_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_components.svg +6 -6
- package/public/catppuccin-icons/latte/folder_components_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_composables.svg +6 -6
- package/public/catppuccin-icons/latte/folder_composables_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_config.svg +6 -6
- package/public/catppuccin-icons/latte/folder_config_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_connection.svg +6 -6
- package/public/catppuccin-icons/latte/folder_connection_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_constant.svg +6 -6
- package/public/catppuccin-icons/latte/folder_constant_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_content.svg +4 -4
- package/public/catppuccin-icons/latte/folder_content_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_controllers.svg +6 -6
- package/public/catppuccin-icons/latte/folder_controllers_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_core.svg +6 -6
- package/public/catppuccin-icons/latte/folder_core_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_coverage.svg +6 -6
- package/public/catppuccin-icons/latte/folder_coverage_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_cursor.svg +4 -4
- package/public/catppuccin-icons/latte/folder_cursor_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_cypress.svg +6 -6
- package/public/catppuccin-icons/latte/folder_cypress_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_database.svg +6 -6
- package/public/catppuccin-icons/latte/folder_database_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_debug.svg +6 -6
- package/public/catppuccin-icons/latte/folder_debug_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_devcontainer.svg +7 -7
- package/public/catppuccin-icons/latte/folder_devcontainer_open.svg +7 -7
- package/public/catppuccin-icons/latte/folder_direnv.svg +6 -6
- package/public/catppuccin-icons/latte/folder_direnv_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_dist.svg +6 -6
- package/public/catppuccin-icons/latte/folder_dist_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_docker.svg +9 -9
- package/public/catppuccin-icons/latte/folder_docker_open.svg +9 -9
- package/public/catppuccin-icons/latte/folder_docs.svg +6 -6
- package/public/catppuccin-icons/latte/folder_docs_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_download.svg +6 -6
- package/public/catppuccin-icons/latte/folder_download_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_drizzle-orm.svg +6 -6
- package/public/catppuccin-icons/latte/folder_drizzle-orm_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_examples.svg +6 -6
- package/public/catppuccin-icons/latte/folder_examples_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_fastlane.svg +8 -8
- package/public/catppuccin-icons/latte/folder_fastlane_open.svg +8 -8
- package/public/catppuccin-icons/latte/folder_firebase.svg +6 -6
- package/public/catppuccin-icons/latte/folder_firebase_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_fonts.svg +6 -6
- package/public/catppuccin-icons/latte/folder_fonts_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_forgejo.svg +7 -7
- package/public/catppuccin-icons/latte/folder_forgejo_open.svg +7 -7
- package/public/catppuccin-icons/latte/folder_functions.svg +6 -6
- package/public/catppuccin-icons/latte/folder_functions_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_fvm.svg +6 -6
- package/public/catppuccin-icons/latte/folder_fvm_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_git.svg +6 -6
- package/public/catppuccin-icons/latte/folder_git_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_github.svg +6 -6
- package/public/catppuccin-icons/latte/folder_github_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_gitlab.svg +6 -6
- package/public/catppuccin-icons/latte/folder_gitlab_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_gradle.svg +7 -7
- package/public/catppuccin-icons/latte/folder_gradle_open.svg +7 -7
- package/public/catppuccin-icons/latte/folder_graphql.svg +4 -4
- package/public/catppuccin-icons/latte/folder_graphql_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_hooks.svg +6 -6
- package/public/catppuccin-icons/latte/folder_hooks_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_husky.svg +7 -7
- package/public/catppuccin-icons/latte/folder_husky_open.svg +7 -7
- package/public/catppuccin-icons/latte/folder_images.svg +8 -8
- package/public/catppuccin-icons/latte/folder_images_open.svg +8 -8
- package/public/catppuccin-icons/latte/folder_include.svg +5 -5
- package/public/catppuccin-icons/latte/folder_include_open.svg +5 -5
- package/public/catppuccin-icons/latte/folder_intellij.svg +8 -8
- package/public/catppuccin-icons/latte/folder_intellij_open.svg +8 -8
- package/public/catppuccin-icons/latte/folder_javascript.svg +4 -4
- package/public/catppuccin-icons/latte/folder_javascript_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_kubernetes.svg +9 -9
- package/public/catppuccin-icons/latte/folder_kubernetes_open.svg +9 -9
- package/public/catppuccin-icons/latte/folder_layouts.svg +6 -6
- package/public/catppuccin-icons/latte/folder_layouts_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_lib.svg +4 -4
- package/public/catppuccin-icons/latte/folder_lib_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_linux.svg +5 -5
- package/public/catppuccin-icons/latte/folder_linux_open.svg +5 -5
- package/public/catppuccin-icons/latte/folder_locales.svg +6 -6
- package/public/catppuccin-icons/latte/folder_locales_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_luau.svg +5 -5
- package/public/catppuccin-icons/latte/folder_luau_open.svg +5 -5
- package/public/catppuccin-icons/latte/folder_lune.svg +5 -5
- package/public/catppuccin-icons/latte/folder_lune_open.svg +5 -5
- package/public/catppuccin-icons/latte/folder_macos.svg +10 -10
- package/public/catppuccin-icons/latte/folder_macos_open.svg +10 -10
- package/public/catppuccin-icons/latte/folder_messages.svg +4 -4
- package/public/catppuccin-icons/latte/folder_messages_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_middleware.svg +6 -6
- package/public/catppuccin-icons/latte/folder_middleware_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_mocks.svg +6 -6
- package/public/catppuccin-icons/latte/folder_mocks_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_moonrepo.svg +5 -5
- package/public/catppuccin-icons/latte/folder_moonrepo_open.svg +5 -5
- package/public/catppuccin-icons/latte/folder_next.svg +6 -6
- package/public/catppuccin-icons/latte/folder_next_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_nix.svg +11 -11
- package/public/catppuccin-icons/latte/folder_nix_open.svg +11 -11
- package/public/catppuccin-icons/latte/folder_node.svg +6 -6
- package/public/catppuccin-icons/latte/folder_node_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_nuxt.svg +6 -6
- package/public/catppuccin-icons/latte/folder_nuxt_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_packages.svg +6 -6
- package/public/catppuccin-icons/latte/folder_packages_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_pesde.svg +6 -6
- package/public/catppuccin-icons/latte/folder_pesde_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_plugins.svg +6 -6
- package/public/catppuccin-icons/latte/folder_plugins_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_pre-commit.svg +5 -5
- package/public/catppuccin-icons/latte/folder_pre-commit_open.svg +5 -5
- package/public/catppuccin-icons/latte/folder_prisma.svg +6 -6
- package/public/catppuccin-icons/latte/folder_prisma_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_private.svg +5 -5
- package/public/catppuccin-icons/latte/folder_private_open.svg +5 -5
- package/public/catppuccin-icons/latte/folder_proto.svg +11 -11
- package/public/catppuccin-icons/latte/folder_proto_open.svg +9 -9
- package/public/catppuccin-icons/latte/folder_public.svg +6 -6
- package/public/catppuccin-icons/latte/folder_public_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_queue.svg +6 -6
- package/public/catppuccin-icons/latte/folder_queue_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_redux.svg +6 -6
- package/public/catppuccin-icons/latte/folder_redux_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_renovate.svg +7 -7
- package/public/catppuccin-icons/latte/folder_renovate_open.svg +7 -7
- package/public/catppuccin-icons/latte/folder_roblox.svg +3 -3
- package/public/catppuccin-icons/latte/folder_roblox_open.svg +3 -3
- package/public/catppuccin-icons/latte/folder_routes.svg +6 -6
- package/public/catppuccin-icons/latte/folder_routes_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_sass.svg +6 -6
- package/public/catppuccin-icons/latte/folder_sass_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_scripts.svg +6 -6
- package/public/catppuccin-icons/latte/folder_scripts_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_security.svg +4 -4
- package/public/catppuccin-icons/latte/folder_security_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_server.svg +6 -6
- package/public/catppuccin-icons/latte/folder_server_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_shared.svg +4 -4
- package/public/catppuccin-icons/latte/folder_shared_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_src.svg +6 -6
- package/public/catppuccin-icons/latte/folder_src_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_storybook.svg +6 -6
- package/public/catppuccin-icons/latte/folder_storybook_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_styles.svg +6 -6
- package/public/catppuccin-icons/latte/folder_styles_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_svg.svg +6 -6
- package/public/catppuccin-icons/latte/folder_svg_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_symlink.svg +5 -5
- package/public/catppuccin-icons/latte/folder_symlink_open.svg +5 -5
- package/public/catppuccin-icons/latte/folder_tauri.svg +9 -9
- package/public/catppuccin-icons/latte/folder_tauri_open.svg +9 -9
- package/public/catppuccin-icons/latte/folder_temp.svg +6 -6
- package/public/catppuccin-icons/latte/folder_temp_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_templates.svg +6 -6
- package/public/catppuccin-icons/latte/folder_templates_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_tests.svg +6 -6
- package/public/catppuccin-icons/latte/folder_tests_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_themes.svg +9 -9
- package/public/catppuccin-icons/latte/folder_themes_open.svg +9 -9
- package/public/catppuccin-icons/latte/folder_turbo.svg +9 -9
- package/public/catppuccin-icons/latte/folder_turbo_open.svg +10 -10
- package/public/catppuccin-icons/latte/folder_types.svg +6 -6
- package/public/catppuccin-icons/latte/folder_types_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_upload.svg +9 -9
- package/public/catppuccin-icons/latte/folder_upload_open.svg +9 -9
- package/public/catppuccin-icons/latte/folder_utils.svg +6 -6
- package/public/catppuccin-icons/latte/folder_utils_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_vercel.svg +6 -6
- package/public/catppuccin-icons/latte/folder_vercel_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_video.svg +6 -6
- package/public/catppuccin-icons/latte/folder_video_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_views.svg +6 -6
- package/public/catppuccin-icons/latte/folder_views_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_vscode.svg +6 -6
- package/public/catppuccin-icons/latte/folder_vscode_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_windows.svg +4 -4
- package/public/catppuccin-icons/latte/folder_windows_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_workflows.svg +6 -6
- package/public/catppuccin-icons/latte/folder_workflows_open.svg +6 -6
- package/public/catppuccin-icons/latte/folder_wxt.svg +4 -4
- package/public/catppuccin-icons/latte/folder_wxt_open.svg +4 -4
- package/public/catppuccin-icons/latte/folder_xcode.svg +12 -12
- package/public/catppuccin-icons/latte/folder_xcode_open.svg +10 -10
- package/public/catppuccin-icons/latte/folder_xmake.svg +8 -8
- package/public/catppuccin-icons/latte/folder_xmake_open.svg +8 -8
- package/public/catppuccin-icons/latte/folder_yarn.svg +7 -7
- package/public/catppuccin-icons/latte/folder_yarn_open.svg +9 -9
- package/public/catppuccin-icons/latte/font.svg +3 -3
- package/public/catppuccin-icons/latte/foreman.svg +9 -9
- package/public/catppuccin-icons/latte/forgejo.svg +6 -6
- package/public/catppuccin-icons/latte/fortran.svg +3 -3
- package/public/catppuccin-icons/latte/fsharp.svg +3 -3
- package/public/catppuccin-icons/latte/fvm.svg +3 -3
- package/public/catppuccin-icons/latte/gatsby.svg +6 -6
- package/public/catppuccin-icons/latte/gcp.svg +9 -9
- package/public/catppuccin-icons/latte/git-cliff.svg +5 -5
- package/public/catppuccin-icons/latte/git.svg +6 -6
- package/public/catppuccin-icons/latte/gitlab.svg +3 -3
- package/public/catppuccin-icons/latte/gitpod.svg +3 -3
- package/public/catppuccin-icons/latte/gleam-config.svg +5 -5
- package/public/catppuccin-icons/latte/gleam.svg +4 -4
- package/public/catppuccin-icons/latte/go-mod.svg +3 -3
- package/public/catppuccin-icons/latte/go-template.svg +4 -4
- package/public/catppuccin-icons/latte/go.svg +3 -3
- package/public/catppuccin-icons/latte/godot-assets.svg +3 -3
- package/public/catppuccin-icons/latte/godot.svg +3 -3
- package/public/catppuccin-icons/latte/gradle.svg +6 -6
- package/public/catppuccin-icons/latte/graphql.svg +3 -3
- package/public/catppuccin-icons/latte/groovy.svg +6 -6
- package/public/catppuccin-icons/latte/gulp.svg +3 -3
- package/public/catppuccin-icons/latte/hacking.svg +7 -7
- package/public/catppuccin-icons/latte/haml.svg +7 -7
- package/public/catppuccin-icons/latte/handlebars.svg +3 -3
- package/public/catppuccin-icons/latte/hardhat.svg +3 -3
- package/public/catppuccin-icons/latte/hare.svg +7 -7
- package/public/catppuccin-icons/latte/haskell.svg +3 -3
- package/public/catppuccin-icons/latte/haxe.svg +6 -6
- package/public/catppuccin-icons/latte/helm.svg +3 -3
- package/public/catppuccin-icons/latte/heroku.svg +6 -6
- package/public/catppuccin-icons/latte/histoire.svg +6 -6
- package/public/catppuccin-icons/latte/html.svg +6 -6
- package/public/catppuccin-icons/latte/http.svg +6 -6
- package/public/catppuccin-icons/latte/huff.svg +4 -4
- package/public/catppuccin-icons/latte/hugo.svg +6 -6
- package/public/catppuccin-icons/latte/humans.svg +13 -13
- package/public/catppuccin-icons/latte/husky.svg +3 -3
- package/public/catppuccin-icons/latte/image.svg +8 -8
- package/public/catppuccin-icons/latte/ionic.svg +6 -6
- package/public/catppuccin-icons/latte/java-annotation.svg +3 -3
- package/public/catppuccin-icons/latte/java-class-abstract.svg +3 -3
- package/public/catppuccin-icons/latte/java-class-final.svg +3 -3
- package/public/catppuccin-icons/latte/java-class-sealed.svg +3 -3
- package/public/catppuccin-icons/latte/java-class.svg +3 -3
- package/public/catppuccin-icons/latte/java-enum.svg +3 -3
- package/public/catppuccin-icons/latte/java-exception.svg +3 -3
- package/public/catppuccin-icons/latte/java-interface.svg +4 -4
- package/public/catppuccin-icons/latte/java-jar.svg +7 -7
- package/public/catppuccin-icons/latte/java-record.svg +4 -4
- package/public/catppuccin-icons/latte/java.svg +7 -7
- package/public/catppuccin-icons/latte/javascript-config.svg +7 -7
- package/public/catppuccin-icons/latte/javascript-map.svg +8 -8
- package/public/catppuccin-icons/latte/javascript-react.svg +8 -8
- package/public/catppuccin-icons/latte/javascript-test.svg +3 -3
- package/public/catppuccin-icons/latte/javascript.svg +6 -6
- package/public/catppuccin-icons/latte/jest.svg +8 -8
- package/public/catppuccin-icons/latte/jinja.svg +3 -3
- package/public/catppuccin-icons/latte/json-schema.svg +3 -3
- package/public/catppuccin-icons/latte/json.svg +3 -3
- package/public/catppuccin-icons/latte/juce.svg +14 -14
- package/public/catppuccin-icons/latte/jule.svg +5 -5
- package/public/catppuccin-icons/latte/julia.svg +7 -7
- package/public/catppuccin-icons/latte/jupyter.svg +6 -6
- package/public/catppuccin-icons/latte/just.svg +5 -5
- package/public/catppuccin-icons/latte/kdl.svg +5 -5
- package/public/catppuccin-icons/latte/key.svg +6 -6
- package/public/catppuccin-icons/latte/knip.svg +3 -3
- package/public/catppuccin-icons/latte/kotlin.svg +8 -8
- package/public/catppuccin-icons/latte/laravel.svg +8 -8
- package/public/catppuccin-icons/latte/latex.svg +3 -3
- package/public/catppuccin-icons/latte/latte.svg +6 -6
- package/public/catppuccin-icons/latte/lerna.svg +6 -6
- package/public/catppuccin-icons/latte/less.svg +3 -3
- package/public/catppuccin-icons/latte/lib.svg +3 -3
- package/public/catppuccin-icons/latte/license.svg +3 -3
- package/public/catppuccin-icons/latte/lint-staged.svg +8 -8
- package/public/catppuccin-icons/latte/liquid.svg +3 -3
- package/public/catppuccin-icons/latte/lisp.svg +6 -6
- package/public/catppuccin-icons/latte/lock.svg +3 -3
- package/public/catppuccin-icons/latte/log.svg +6 -6
- package/public/catppuccin-icons/latte/lua-check.svg +9 -9
- package/public/catppuccin-icons/latte/lua-client.svg +7 -7
- package/public/catppuccin-icons/latte/lua-rocks.svg +7 -7
- package/public/catppuccin-icons/latte/lua-server.svg +7 -7
- package/public/catppuccin-icons/latte/lua-test.svg +9 -9
- package/public/catppuccin-icons/latte/lua.svg +6 -6
- package/public/catppuccin-icons/latte/luau-check.svg +9 -9
- package/public/catppuccin-icons/latte/luau-client.svg +7 -7
- package/public/catppuccin-icons/latte/luau-config.svg +9 -9
- package/public/catppuccin-icons/latte/luau-server.svg +7 -7
- package/public/catppuccin-icons/latte/luau-test.svg +5 -5
- package/public/catppuccin-icons/latte/luau.svg +4 -4
- package/public/catppuccin-icons/latte/macos.svg +9 -9
- package/public/catppuccin-icons/latte/makefile.svg +6 -6
- package/public/catppuccin-icons/latte/mantle.svg +3 -3
- package/public/catppuccin-icons/latte/markdown-mdx.svg +3 -3
- package/public/catppuccin-icons/latte/markdown.svg +3 -3
- package/public/catppuccin-icons/latte/marko.svg +9 -9
- package/public/catppuccin-icons/latte/matlab.svg +6 -6
- package/public/catppuccin-icons/latte/mdbook.svg +4 -4
- package/public/catppuccin-icons/latte/mermaid.svg +3 -3
- package/public/catppuccin-icons/latte/meson.svg +6 -6
- package/public/catppuccin-icons/latte/midi.svg +6 -6
- package/public/catppuccin-icons/latte/mjml.svg +3 -3
- package/public/catppuccin-icons/latte/modernizr.svg +3 -3
- package/public/catppuccin-icons/latte/moonrepo.svg +4 -4
- package/public/catppuccin-icons/latte/moonwave.svg +3 -3
- package/public/catppuccin-icons/latte/ms-excel.svg +6 -6
- package/public/catppuccin-icons/latte/ms-powerpoint.svg +6 -6
- package/public/catppuccin-icons/latte/ms-word.svg +6 -6
- package/public/catppuccin-icons/latte/msbuild.svg +8 -8
- package/public/catppuccin-icons/latte/nativescript.svg +3 -3
- package/public/catppuccin-icons/latte/nest-controller.svg +3 -3
- package/public/catppuccin-icons/latte/nest-decorator.svg +3 -3
- package/public/catppuccin-icons/latte/nest-filter.svg +3 -3
- package/public/catppuccin-icons/latte/nest-gateway.svg +3 -3
- package/public/catppuccin-icons/latte/nest-guard.svg +3 -3
- package/public/catppuccin-icons/latte/nest-middleware.svg +3 -3
- package/public/catppuccin-icons/latte/nest-pipe.svg +3 -3
- package/public/catppuccin-icons/latte/nest-service.svg +3 -3
- package/public/catppuccin-icons/latte/nest.svg +3 -3
- package/public/catppuccin-icons/latte/netlify.svg +6 -6
- package/public/catppuccin-icons/latte/next.svg +6 -6
- package/public/catppuccin-icons/latte/nextflow.svg +3 -3
- package/public/catppuccin-icons/latte/nginx.svg +6 -6
- package/public/catppuccin-icons/latte/nim.svg +3 -3
- package/public/catppuccin-icons/latte/ninja.svg +6 -6
- package/public/catppuccin-icons/latte/nix-lock.svg +11 -11
- package/public/catppuccin-icons/latte/nix.svg +10 -10
- package/public/catppuccin-icons/latte/nodemon.svg +3 -3
- package/public/catppuccin-icons/latte/npm-ignore.svg +6 -6
- package/public/catppuccin-icons/latte/npm-lock.svg +7 -7
- package/public/catppuccin-icons/latte/npm.svg +6 -6
- package/public/catppuccin-icons/latte/nuget.svg +3 -3
- package/public/catppuccin-icons/latte/nunjucks.svg +3 -3
- package/public/catppuccin-icons/latte/nuxt-ignore.svg +3 -3
- package/public/catppuccin-icons/latte/nuxt.svg +3 -3
- package/public/catppuccin-icons/latte/nx-ignore.svg +4 -4
- package/public/catppuccin-icons/latte/nx.svg +4 -4
- package/public/catppuccin-icons/latte/ocaml.svg +7 -7
- package/public/catppuccin-icons/latte/odin.svg +3 -3
- package/public/catppuccin-icons/latte/opentofu.svg +4 -4
- package/public/catppuccin-icons/latte/org.svg +7 -7
- package/public/catppuccin-icons/latte/package-json.svg +3 -3
- package/public/catppuccin-icons/latte/panda-css.svg +3 -3
- package/public/catppuccin-icons/latte/pdf.svg +3 -3
- package/public/catppuccin-icons/latte/perl.svg +3 -3
- package/public/catppuccin-icons/latte/pesde-lock.svg +7 -7
- package/public/catppuccin-icons/latte/pesde.svg +6 -6
- package/public/catppuccin-icons/latte/php.svg +3 -3
- package/public/catppuccin-icons/latte/phrase.svg +6 -6
- package/public/catppuccin-icons/latte/phtml.svg +6 -6
- package/public/catppuccin-icons/latte/pixi-lock.svg +6 -6
- package/public/catppuccin-icons/latte/pixi.svg +7 -7
- package/public/catppuccin-icons/latte/plantuml.svg +3 -3
- package/public/catppuccin-icons/latte/playwright.svg +9 -9
- package/public/catppuccin-icons/latte/plop.svg +3 -3
- package/public/catppuccin-icons/latte/pnpm-lock.svg +9 -9
- package/public/catppuccin-icons/latte/pnpm.svg +8 -8
- package/public/catppuccin-icons/latte/poetry-lock.svg +13 -13
- package/public/catppuccin-icons/latte/postcss.svg +8 -8
- package/public/catppuccin-icons/latte/powershell.svg +6 -6
- package/public/catppuccin-icons/latte/pre-commit.svg +4 -4
- package/public/catppuccin-icons/latte/premake.svg +7 -7
- package/public/catppuccin-icons/latte/prettier-ignore.svg +3 -3
- package/public/catppuccin-icons/latte/prettier.svg +8 -8
- package/public/catppuccin-icons/latte/prisma.svg +3 -3
- package/public/catppuccin-icons/latte/prolog.svg +3 -3
- package/public/catppuccin-icons/latte/properties.svg +3 -3
- package/public/catppuccin-icons/latte/proto.svg +8 -8
- package/public/catppuccin-icons/latte/prototools.svg +3 -3
- package/public/catppuccin-icons/latte/pug.svg +3 -3
- package/public/catppuccin-icons/latte/puppet.svg +3 -3
- package/public/catppuccin-icons/latte/puppeteer.svg +5 -5
- package/public/catppuccin-icons/latte/python-compiled.svg +8 -8
- package/public/catppuccin-icons/latte/python-config.svg +9 -9
- package/public/catppuccin-icons/latte/python.svg +8 -8
- package/public/catppuccin-icons/latte/qwik.svg +6 -6
- package/public/catppuccin-icons/latte/r.svg +6 -6
- package/public/catppuccin-icons/latte/racket.svg +6 -6
- package/public/catppuccin-icons/latte/razor.svg +3 -3
- package/public/catppuccin-icons/latte/rdata.svg +4 -4
- package/public/catppuccin-icons/latte/readme.svg +6 -6
- package/public/catppuccin-icons/latte/reason.svg +6 -6
- package/public/catppuccin-icons/latte/redwood.svg +3 -3
- package/public/catppuccin-icons/latte/release.svg +6 -6
- package/public/catppuccin-icons/latte/remix.svg +3 -3
- package/public/catppuccin-icons/latte/renovate.svg +6 -6
- package/public/catppuccin-icons/latte/rescript.svg +6 -6
- package/public/catppuccin-icons/latte/rmd.svg +4 -4
- package/public/catppuccin-icons/latte/roblox.svg +3 -3
- package/public/catppuccin-icons/latte/robots.svg +6 -6
- package/public/catppuccin-icons/latte/rocket.svg +3 -3
- package/public/catppuccin-icons/latte/rojo.svg +3 -3
- package/public/catppuccin-icons/latte/rokit.svg +4 -4
- package/public/catppuccin-icons/latte/rollup.svg +6 -6
- package/public/catppuccin-icons/latte/rproj.svg +5 -5
- package/public/catppuccin-icons/latte/rsml.svg +10 -10
- package/public/catppuccin-icons/latte/ruby-gem-lock.svg +7 -7
- package/public/catppuccin-icons/latte/ruby-gem.svg +6 -6
- package/public/catppuccin-icons/latte/ruby.svg +3 -3
- package/public/catppuccin-icons/latte/ruff.svg +3 -3
- package/public/catppuccin-icons/latte/rust-alt-config.svg +4 -4
- package/public/catppuccin-icons/latte/rust-alt.svg +3 -3
- package/public/catppuccin-icons/latte/rust-config.svg +7 -7
- package/public/catppuccin-icons/latte/rust.svg +6 -6
- package/public/catppuccin-icons/latte/salesforce.svg +3 -3
- package/public/catppuccin-icons/latte/sass.svg +3 -3
- package/public/catppuccin-icons/latte/scala.svg +3 -3
- package/public/catppuccin-icons/latte/scheme.svg +3 -3
- package/public/catppuccin-icons/latte/search.svg +3 -3
- package/public/catppuccin-icons/latte/security.svg +4 -4
- package/public/catppuccin-icons/latte/semantic-release.svg +3 -3
- package/public/catppuccin-icons/latte/semgrep-ignore.svg +3 -3
- package/public/catppuccin-icons/latte/semgrep.svg +3 -3
- package/public/catppuccin-icons/latte/sentry.svg +3 -3
- package/public/catppuccin-icons/latte/serverless.svg +3 -3
- package/public/catppuccin-icons/latte/shader.svg +3 -3
- package/public/catppuccin-icons/latte/sketch.svg +3 -3
- package/public/catppuccin-icons/latte/slidesk.svg +7 -7
- package/public/catppuccin-icons/latte/snowpack.svg +6 -6
- package/public/catppuccin-icons/latte/solid.svg +5 -5
- package/public/catppuccin-icons/latte/solidity.svg +3 -3
- package/public/catppuccin-icons/latte/sonar-cloud.svg +7 -7
- package/public/catppuccin-icons/latte/spwn.svg +7 -7
- package/public/catppuccin-icons/latte/squirrel.svg +4 -4
- package/public/catppuccin-icons/latte/stackblitz.svg +3 -3
- package/public/catppuccin-icons/latte/stata.svg +4 -4
- package/public/catppuccin-icons/latte/stencil.svg +3 -3
- package/public/catppuccin-icons/latte/stitches.svg +7 -7
- package/public/catppuccin-icons/latte/storybook-svelte.svg +6 -6
- package/public/catppuccin-icons/latte/storybook-vue.svg +6 -6
- package/public/catppuccin-icons/latte/storybook.svg +6 -6
- package/public/catppuccin-icons/latte/stylelint-ignore.svg +7 -7
- package/public/catppuccin-icons/latte/stylelint.svg +7 -7
- package/public/catppuccin-icons/latte/stylua-ignore.svg +3 -3
- package/public/catppuccin-icons/latte/stylua.svg +7 -7
- package/public/catppuccin-icons/latte/sublime.svg +3 -3
- package/public/catppuccin-icons/latte/super-collider.svg +3 -3
- package/public/catppuccin-icons/latte/svelte-config.svg +6 -6
- package/public/catppuccin-icons/latte/svelte.svg +6 -6
- package/public/catppuccin-icons/latte/svg.svg +3 -3
- package/public/catppuccin-icons/latte/swift.svg +3 -3
- package/public/catppuccin-icons/latte/swiftformat.svg +4 -4
- package/public/catppuccin-icons/latte/symlink.svg +5 -5
- package/public/catppuccin-icons/latte/tailwind.svg +3 -3
- package/public/catppuccin-icons/latte/taskfile.svg +3 -3
- package/public/catppuccin-icons/latte/tauri-ignore.svg +6 -6
- package/public/catppuccin-icons/latte/tauri.svg +8 -8
- package/public/catppuccin-icons/latte/terraform.svg +3 -3
- package/public/catppuccin-icons/latte/text.svg +6 -6
- package/public/catppuccin-icons/latte/todo.svg +6 -6
- package/public/catppuccin-icons/latte/toml.svg +3 -3
- package/public/catppuccin-icons/latte/turbo.svg +10 -10
- package/public/catppuccin-icons/latte/twig.svg +4 -4
- package/public/catppuccin-icons/latte/twine.svg +6 -6
- package/public/catppuccin-icons/latte/typescript-config.svg +7 -7
- package/public/catppuccin-icons/latte/typescript-def.svg +7 -7
- package/public/catppuccin-icons/latte/typescript-react.svg +8 -8
- package/public/catppuccin-icons/latte/typescript-test.svg +3 -3
- package/public/catppuccin-icons/latte/typescript.svg +6 -6
- package/public/catppuccin-icons/latte/typst.svg +3 -3
- package/public/catppuccin-icons/latte/unity.svg +3 -3
- package/public/catppuccin-icons/latte/unocss.svg +6 -6
- package/public/catppuccin-icons/latte/url.svg +3 -3
- package/public/catppuccin-icons/latte/uv.svg +3 -3
- package/public/catppuccin-icons/latte/v.svg +6 -6
- package/public/catppuccin-icons/latte/vala.svg +3 -3
- package/public/catppuccin-icons/latte/vanilla-extract.svg +4 -4
- package/public/catppuccin-icons/latte/vapi.svg +3 -3
- package/public/catppuccin-icons/latte/vento.svg +5 -5
- package/public/catppuccin-icons/latte/vercel-ignore.svg +3 -3
- package/public/catppuccin-icons/latte/vercel.svg +3 -3
- package/public/catppuccin-icons/latte/verilog.svg +6 -6
- package/public/catppuccin-icons/latte/vhs.svg +3 -3
- package/public/catppuccin-icons/latte/video.svg +6 -6
- package/public/catppuccin-icons/latte/vim.svg +3 -3
- package/public/catppuccin-icons/latte/visual-studio.svg +3 -3
- package/public/catppuccin-icons/latte/vital.svg +6 -6
- package/public/catppuccin-icons/latte/vite.svg +6 -6
- package/public/catppuccin-icons/latte/vitest.svg +6 -6
- package/public/catppuccin-icons/latte/vs-codium.svg +8 -8
- package/public/catppuccin-icons/latte/vscode-ignore.svg +3 -3
- package/public/catppuccin-icons/latte/vscode.svg +3 -3
- package/public/catppuccin-icons/latte/vue-config.svg +6 -6
- package/public/catppuccin-icons/latte/vue.svg +6 -6
- package/public/catppuccin-icons/latte/wally.svg +27 -27
- package/public/catppuccin-icons/latte/web-assembly.svg +7 -7
- package/public/catppuccin-icons/latte/webpack.svg +7 -7
- package/public/catppuccin-icons/latte/windi.svg +3 -3
- package/public/catppuccin-icons/latte/workflow.svg +3 -3
- package/public/catppuccin-icons/latte/wrangler.svg +4 -4
- package/public/catppuccin-icons/latte/wxt.svg +3 -3
- package/public/catppuccin-icons/latte/xaml.svg +8 -8
- package/public/catppuccin-icons/latte/xcode.svg +7 -7
- package/public/catppuccin-icons/latte/xmake.svg +7 -7
- package/public/catppuccin-icons/latte/xml.svg +3 -3
- package/public/catppuccin-icons/latte/yaml.svg +3 -3
- package/public/catppuccin-icons/latte/yarn-lock.svg +7 -7
- package/public/catppuccin-icons/latte/yarn.svg +6 -6
- package/public/catppuccin-icons/latte/zap.svg +3 -3
- package/public/catppuccin-icons/latte/zig.svg +3 -3
- package/public/catppuccin-icons/latte/zip.svg +3 -3
- package/public/catppuccin-icons/mocha/3d.svg +3 -3
- package/public/catppuccin-icons/mocha/_file.svg +3 -3
- package/public/catppuccin-icons/mocha/_folder.svg +3 -3
- package/public/catppuccin-icons/mocha/_folder_open.svg +3 -3
- package/public/catppuccin-icons/mocha/_root.svg +7 -7
- package/public/catppuccin-icons/mocha/_root_open.svg +5 -5
- package/public/catppuccin-icons/mocha/adobe-ae.svg +6 -6
- package/public/catppuccin-icons/mocha/adobe-ai.svg +6 -6
- package/public/catppuccin-icons/mocha/adobe-id.svg +6 -6
- package/public/catppuccin-icons/mocha/adobe-ps.svg +6 -6
- package/public/catppuccin-icons/mocha/adobe-xd.svg +6 -6
- package/public/catppuccin-icons/mocha/adonis.svg +6 -6
- package/public/catppuccin-icons/mocha/alex.svg +6 -6
- package/public/catppuccin-icons/mocha/amber.svg +3 -3
- package/public/catppuccin-icons/mocha/android.svg +3 -3
- package/public/catppuccin-icons/mocha/angular-component.svg +6 -6
- package/public/catppuccin-icons/mocha/angular-directive.svg +6 -6
- package/public/catppuccin-icons/mocha/angular-guard.svg +6 -6
- package/public/catppuccin-icons/mocha/angular-pipe.svg +6 -6
- package/public/catppuccin-icons/mocha/angular-service.svg +6 -6
- package/public/catppuccin-icons/mocha/angular.svg +6 -6
- package/public/catppuccin-icons/mocha/ansible-lint.svg +4 -4
- package/public/catppuccin-icons/mocha/antlr.svg +6 -6
- package/public/catppuccin-icons/mocha/apache.svg +7 -7
- package/public/catppuccin-icons/mocha/api-blueprint.svg +3 -3
- package/public/catppuccin-icons/mocha/apollo.svg +6 -6
- package/public/catppuccin-icons/mocha/apple.svg +3 -3
- package/public/catppuccin-icons/mocha/arduino.svg +3 -3
- package/public/catppuccin-icons/mocha/asciidoc.svg +3 -3
- package/public/catppuccin-icons/mocha/assembly.svg +4 -4
- package/public/catppuccin-icons/mocha/astro-config.svg +7 -7
- package/public/catppuccin-icons/mocha/astro.svg +6 -6
- package/public/catppuccin-icons/mocha/audio.svg +6 -6
- package/public/catppuccin-icons/mocha/autohotkey.svg +6 -6
- package/public/catppuccin-icons/mocha/azure-pipelines.svg +3 -3
- package/public/catppuccin-icons/mocha/babel.svg +3 -3
- package/public/catppuccin-icons/mocha/bash.svg +7 -7
- package/public/catppuccin-icons/mocha/batch.svg +6 -6
- package/public/catppuccin-icons/mocha/bazel.svg +3 -3
- package/public/catppuccin-icons/mocha/benchmark.svg +3 -3
- package/public/catppuccin-icons/mocha/bicep.svg +5 -5
- package/public/catppuccin-icons/mocha/binary.svg +6 -6
- package/public/catppuccin-icons/mocha/biome.svg +3 -3
- package/public/catppuccin-icons/mocha/bitbucket.svg +3 -3
- package/public/catppuccin-icons/mocha/blink.svg +10 -10
- package/public/catppuccin-icons/mocha/blitz.svg +3 -3
- package/public/catppuccin-icons/mocha/bower.svg +9 -9
- package/public/catppuccin-icons/mocha/browserslist.svg +6 -6
- package/public/catppuccin-icons/mocha/bun-lock.svg +8 -8
- package/public/catppuccin-icons/mocha/bun.svg +7 -7
- package/public/catppuccin-icons/mocha/c-header.svg +3 -3
- package/public/catppuccin-icons/mocha/c.svg +3 -3
- package/public/catppuccin-icons/mocha/cabal.svg +7 -7
- package/public/catppuccin-icons/mocha/caddy.svg +6 -6
- package/public/catppuccin-icons/mocha/capacitor.svg +3 -3
- package/public/catppuccin-icons/mocha/cargo-lock.svg +8 -8
- package/public/catppuccin-icons/mocha/cargo.svg +7 -7
- package/public/catppuccin-icons/mocha/certificate.svg +7 -7
- package/public/catppuccin-icons/mocha/changelog.svg +3 -3
- package/public/catppuccin-icons/mocha/circle-ci.svg +6 -6
- package/public/catppuccin-icons/mocha/clojure.svg +10 -10
- package/public/catppuccin-icons/mocha/cmake.svg +7 -7
- package/public/catppuccin-icons/mocha/cobol.svg +3 -3
- package/public/catppuccin-icons/mocha/code-climate.svg +3 -3
- package/public/catppuccin-icons/mocha/code-of-conduct.svg +6 -6
- package/public/catppuccin-icons/mocha/codeowners.svg +6 -6
- package/public/catppuccin-icons/mocha/coffeescript.svg +6 -6
- package/public/catppuccin-icons/mocha/commitlint.svg +6 -6
- package/public/catppuccin-icons/mocha/config.svg +3 -3
- package/public/catppuccin-icons/mocha/contributing.svg +6 -6
- package/public/catppuccin-icons/mocha/cpp-header.svg +4 -4
- package/public/catppuccin-icons/mocha/cpp.svg +4 -4
- package/public/catppuccin-icons/mocha/crystal.svg +3 -3
- package/public/catppuccin-icons/mocha/csharp.svg +3 -3
- package/public/catppuccin-icons/mocha/cspell.svg +4 -4
- package/public/catppuccin-icons/mocha/css-map.svg +8 -8
- package/public/catppuccin-icons/mocha/css.svg +6 -6
- package/public/catppuccin-icons/mocha/css3.svg +6 -6
- package/public/catppuccin-icons/mocha/csv.svg +3 -3
- package/public/catppuccin-icons/mocha/cucumber.svg +3 -3
- package/public/catppuccin-icons/mocha/cuda.svg +6 -6
- package/public/catppuccin-icons/mocha/cue.svg +4 -4
- package/public/catppuccin-icons/mocha/cursor-ignore.svg +4 -4
- package/public/catppuccin-icons/mocha/cursor.svg +4 -4
- package/public/catppuccin-icons/mocha/cypress.svg +6 -6
- package/public/catppuccin-icons/mocha/d.svg +3 -3
- package/public/catppuccin-icons/mocha/darklua.svg +6 -6
- package/public/catppuccin-icons/mocha/dart-generated.svg +6 -6
- package/public/catppuccin-icons/mocha/dart.svg +6 -6
- package/public/catppuccin-icons/mocha/database.svg +3 -3
- package/public/catppuccin-icons/mocha/deno.svg +3 -3
- package/public/catppuccin-icons/mocha/deno_lock.svg +6 -6
- package/public/catppuccin-icons/mocha/dependabot.svg +3 -3
- package/public/catppuccin-icons/mocha/devcontainer.svg +4 -4
- package/public/catppuccin-icons/mocha/dhall.svg +3 -3
- package/public/catppuccin-icons/mocha/diff.svg +7 -7
- package/public/catppuccin-icons/mocha/django.svg +6 -6
- package/public/catppuccin-icons/mocha/docker-compose.svg +3 -3
- package/public/catppuccin-icons/mocha/docker-ignore.svg +3 -3
- package/public/catppuccin-icons/mocha/docker.svg +3 -3
- package/public/catppuccin-icons/mocha/docusaurus.svg +7 -7
- package/public/catppuccin-icons/mocha/drawio.svg +3 -3
- package/public/catppuccin-icons/mocha/drizzle-orm.svg +3 -3
- package/public/catppuccin-icons/mocha/dub-selections.svg +8 -8
- package/public/catppuccin-icons/mocha/dub.svg +7 -7
- package/public/catppuccin-icons/mocha/editorconfig.svg +3 -3
- package/public/catppuccin-icons/mocha/ejs.svg +3 -3
- package/public/catppuccin-icons/mocha/eleventy.svg +3 -3
- package/public/catppuccin-icons/mocha/elixir.svg +3 -3
- package/public/catppuccin-icons/mocha/elm.svg +3 -3
- package/public/catppuccin-icons/mocha/ember.svg +3 -3
- package/public/catppuccin-icons/mocha/env.svg +3 -3
- package/public/catppuccin-icons/mocha/envrc.svg +6 -6
- package/public/catppuccin-icons/mocha/erlang.svg +6 -6
- package/public/catppuccin-icons/mocha/esbuild.svg +3 -3
- package/public/catppuccin-icons/mocha/eslint-ignore.svg +6 -6
- package/public/catppuccin-icons/mocha/eslint.svg +6 -6
- package/public/catppuccin-icons/mocha/exe.svg +6 -6
- package/public/catppuccin-icons/mocha/fastlane.svg +14 -14
- package/public/catppuccin-icons/mocha/favicon.svg +3 -3
- package/public/catppuccin-icons/mocha/figma.svg +9 -9
- package/public/catppuccin-icons/mocha/firebase.svg +3 -3
- package/public/catppuccin-icons/mocha/flutter.svg +8 -8
- package/public/catppuccin-icons/mocha/folder_admin.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_admin_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_android.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_android_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_animation.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_animation_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_api.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_api_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_app.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_app_open.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_assets.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_assets_open.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_audio.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_audio_open.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_audit.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_audit_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_aws.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_aws_open.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_azure-devops.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_azure-devops_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_azure-pipelines.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_azure-pipelines_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_benchmark.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_benchmark_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_caddy.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_caddy_open.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_cargo.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_cargo_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_circle-ci.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_circle-ci_open.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_client.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_client_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_cloud.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_cloud_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_command.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_command_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_components.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_components_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_composables.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_composables_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_config.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_config_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_connection.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_connection_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_constant.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_constant_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_content.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_content_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_controllers.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_controllers_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_core.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_core_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_coverage.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_coverage_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_cursor.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_cursor_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_cypress.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_cypress_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_database.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_database_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_debug.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_debug_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_devcontainer.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_devcontainer_open.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_direnv.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_direnv_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_dist.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_dist_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_docker.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_docker_open.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_docs.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_docs_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_download.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_download_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_drizzle-orm.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_drizzle-orm_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_examples.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_examples_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_fastlane.svg +8 -8
- package/public/catppuccin-icons/mocha/folder_fastlane_open.svg +8 -8
- package/public/catppuccin-icons/mocha/folder_firebase.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_firebase_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_fonts.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_fonts_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_forgejo.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_forgejo_open.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_functions.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_functions_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_fvm.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_fvm_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_git.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_git_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_github.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_github_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_gitlab.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_gitlab_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_gradle.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_gradle_open.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_graphql.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_graphql_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_hooks.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_hooks_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_husky.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_husky_open.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_images.svg +8 -8
- package/public/catppuccin-icons/mocha/folder_images_open.svg +8 -8
- package/public/catppuccin-icons/mocha/folder_include.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_include_open.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_intellij.svg +8 -8
- package/public/catppuccin-icons/mocha/folder_intellij_open.svg +8 -8
- package/public/catppuccin-icons/mocha/folder_javascript.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_javascript_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_kubernetes.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_kubernetes_open.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_layouts.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_layouts_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_lib.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_lib_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_linux.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_linux_open.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_locales.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_locales_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_luau.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_luau_open.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_lune.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_lune_open.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_macos.svg +10 -10
- package/public/catppuccin-icons/mocha/folder_macos_open.svg +10 -10
- package/public/catppuccin-icons/mocha/folder_messages.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_messages_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_middleware.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_middleware_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_mocks.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_mocks_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_moonrepo.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_moonrepo_open.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_next.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_next_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_nix.svg +11 -11
- package/public/catppuccin-icons/mocha/folder_nix_open.svg +11 -11
- package/public/catppuccin-icons/mocha/folder_node.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_node_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_nuxt.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_nuxt_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_packages.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_packages_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_pesde.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_pesde_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_plugins.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_plugins_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_pre-commit.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_pre-commit_open.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_prisma.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_prisma_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_private.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_private_open.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_proto.svg +11 -11
- package/public/catppuccin-icons/mocha/folder_proto_open.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_public.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_public_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_queue.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_queue_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_redux.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_redux_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_renovate.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_renovate_open.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_roblox.svg +3 -3
- package/public/catppuccin-icons/mocha/folder_roblox_open.svg +3 -3
- package/public/catppuccin-icons/mocha/folder_routes.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_routes_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_sass.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_sass_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_scripts.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_scripts_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_security.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_security_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_server.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_server_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_shared.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_shared_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_src.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_src_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_storybook.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_storybook_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_styles.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_styles_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_svg.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_svg_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_symlink.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_symlink_open.svg +5 -5
- package/public/catppuccin-icons/mocha/folder_tauri.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_tauri_open.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_temp.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_temp_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_templates.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_templates_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_tests.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_tests_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_themes.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_themes_open.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_turbo.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_turbo_open.svg +10 -10
- package/public/catppuccin-icons/mocha/folder_types.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_types_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_upload.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_upload_open.svg +9 -9
- package/public/catppuccin-icons/mocha/folder_utils.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_utils_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_vercel.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_vercel_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_video.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_video_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_views.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_views_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_vscode.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_vscode_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_windows.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_windows_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_workflows.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_workflows_open.svg +6 -6
- package/public/catppuccin-icons/mocha/folder_wxt.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_wxt_open.svg +4 -4
- package/public/catppuccin-icons/mocha/folder_xcode.svg +12 -12
- package/public/catppuccin-icons/mocha/folder_xcode_open.svg +10 -10
- package/public/catppuccin-icons/mocha/folder_xmake.svg +8 -8
- package/public/catppuccin-icons/mocha/folder_xmake_open.svg +8 -8
- package/public/catppuccin-icons/mocha/folder_yarn.svg +7 -7
- package/public/catppuccin-icons/mocha/folder_yarn_open.svg +9 -9
- package/public/catppuccin-icons/mocha/font.svg +3 -3
- package/public/catppuccin-icons/mocha/foreman.svg +9 -9
- package/public/catppuccin-icons/mocha/forgejo.svg +6 -6
- package/public/catppuccin-icons/mocha/fortran.svg +3 -3
- package/public/catppuccin-icons/mocha/fsharp.svg +3 -3
- package/public/catppuccin-icons/mocha/fvm.svg +3 -3
- package/public/catppuccin-icons/mocha/gatsby.svg +6 -6
- package/public/catppuccin-icons/mocha/gcp.svg +9 -9
- package/public/catppuccin-icons/mocha/git-cliff.svg +5 -5
- package/public/catppuccin-icons/mocha/git.svg +6 -6
- package/public/catppuccin-icons/mocha/gitlab.svg +3 -3
- package/public/catppuccin-icons/mocha/gitpod.svg +3 -3
- package/public/catppuccin-icons/mocha/gleam-config.svg +5 -5
- package/public/catppuccin-icons/mocha/gleam.svg +4 -4
- package/public/catppuccin-icons/mocha/go-mod.svg +3 -3
- package/public/catppuccin-icons/mocha/go-template.svg +4 -4
- package/public/catppuccin-icons/mocha/go.svg +3 -3
- package/public/catppuccin-icons/mocha/godot-assets.svg +3 -3
- package/public/catppuccin-icons/mocha/godot.svg +3 -3
- package/public/catppuccin-icons/mocha/gradle.svg +6 -6
- package/public/catppuccin-icons/mocha/graphql.svg +3 -3
- package/public/catppuccin-icons/mocha/groovy.svg +6 -6
- package/public/catppuccin-icons/mocha/gulp.svg +3 -3
- package/public/catppuccin-icons/mocha/hacking.svg +7 -7
- package/public/catppuccin-icons/mocha/haml.svg +7 -7
- package/public/catppuccin-icons/mocha/handlebars.svg +3 -3
- package/public/catppuccin-icons/mocha/hardhat.svg +3 -3
- package/public/catppuccin-icons/mocha/hare.svg +7 -7
- package/public/catppuccin-icons/mocha/haskell.svg +3 -3
- package/public/catppuccin-icons/mocha/haxe.svg +6 -6
- package/public/catppuccin-icons/mocha/helm.svg +3 -3
- package/public/catppuccin-icons/mocha/heroku.svg +6 -6
- package/public/catppuccin-icons/mocha/histoire.svg +6 -6
- package/public/catppuccin-icons/mocha/html.svg +6 -6
- package/public/catppuccin-icons/mocha/http.svg +6 -6
- package/public/catppuccin-icons/mocha/huff.svg +4 -4
- package/public/catppuccin-icons/mocha/hugo.svg +6 -6
- package/public/catppuccin-icons/mocha/humans.svg +13 -13
- package/public/catppuccin-icons/mocha/husky.svg +3 -3
- package/public/catppuccin-icons/mocha/image.svg +8 -8
- package/public/catppuccin-icons/mocha/ionic.svg +6 -6
- package/public/catppuccin-icons/mocha/java-annotation.svg +3 -3
- package/public/catppuccin-icons/mocha/java-class-abstract.svg +3 -3
- package/public/catppuccin-icons/mocha/java-class-final.svg +3 -3
- package/public/catppuccin-icons/mocha/java-class-sealed.svg +3 -3
- package/public/catppuccin-icons/mocha/java-class.svg +3 -3
- package/public/catppuccin-icons/mocha/java-enum.svg +3 -3
- package/public/catppuccin-icons/mocha/java-exception.svg +3 -3
- package/public/catppuccin-icons/mocha/java-interface.svg +4 -4
- package/public/catppuccin-icons/mocha/java-jar.svg +7 -7
- package/public/catppuccin-icons/mocha/java-record.svg +4 -4
- package/public/catppuccin-icons/mocha/java.svg +7 -7
- package/public/catppuccin-icons/mocha/javascript-config.svg +7 -7
- package/public/catppuccin-icons/mocha/javascript-map.svg +8 -8
- package/public/catppuccin-icons/mocha/javascript-react.svg +8 -8
- package/public/catppuccin-icons/mocha/javascript-test.svg +3 -3
- package/public/catppuccin-icons/mocha/javascript.svg +6 -6
- package/public/catppuccin-icons/mocha/jest.svg +8 -8
- package/public/catppuccin-icons/mocha/jinja.svg +3 -3
- package/public/catppuccin-icons/mocha/json-schema.svg +3 -3
- package/public/catppuccin-icons/mocha/json.svg +3 -3
- package/public/catppuccin-icons/mocha/juce.svg +14 -14
- package/public/catppuccin-icons/mocha/jule.svg +5 -5
- package/public/catppuccin-icons/mocha/julia.svg +7 -7
- package/public/catppuccin-icons/mocha/jupyter.svg +6 -6
- package/public/catppuccin-icons/mocha/just.svg +5 -5
- package/public/catppuccin-icons/mocha/kdl.svg +5 -5
- package/public/catppuccin-icons/mocha/key.svg +6 -6
- package/public/catppuccin-icons/mocha/knip.svg +3 -3
- package/public/catppuccin-icons/mocha/kotlin.svg +8 -8
- package/public/catppuccin-icons/mocha/laravel.svg +8 -8
- package/public/catppuccin-icons/mocha/latex.svg +3 -3
- package/public/catppuccin-icons/mocha/latte.svg +6 -6
- package/public/catppuccin-icons/mocha/lerna.svg +6 -6
- package/public/catppuccin-icons/mocha/less.svg +3 -3
- package/public/catppuccin-icons/mocha/lib.svg +3 -3
- package/public/catppuccin-icons/mocha/license.svg +3 -3
- package/public/catppuccin-icons/mocha/lint-staged.svg +8 -8
- package/public/catppuccin-icons/mocha/liquid.svg +3 -3
- package/public/catppuccin-icons/mocha/lisp.svg +6 -6
- package/public/catppuccin-icons/mocha/lock.svg +3 -3
- package/public/catppuccin-icons/mocha/log.svg +6 -6
- package/public/catppuccin-icons/mocha/lua-check.svg +9 -9
- package/public/catppuccin-icons/mocha/lua-client.svg +7 -7
- package/public/catppuccin-icons/mocha/lua-rocks.svg +7 -7
- package/public/catppuccin-icons/mocha/lua-server.svg +7 -7
- package/public/catppuccin-icons/mocha/lua-test.svg +9 -9
- package/public/catppuccin-icons/mocha/lua.svg +6 -6
- package/public/catppuccin-icons/mocha/luau-check.svg +9 -9
- package/public/catppuccin-icons/mocha/luau-client.svg +7 -7
- package/public/catppuccin-icons/mocha/luau-config.svg +9 -9
- package/public/catppuccin-icons/mocha/luau-server.svg +7 -7
- package/public/catppuccin-icons/mocha/luau-test.svg +5 -5
- package/public/catppuccin-icons/mocha/luau.svg +4 -4
- package/public/catppuccin-icons/mocha/macos.svg +9 -9
- package/public/catppuccin-icons/mocha/makefile.svg +6 -6
- package/public/catppuccin-icons/mocha/mantle.svg +3 -3
- package/public/catppuccin-icons/mocha/markdown-mdx.svg +3 -3
- package/public/catppuccin-icons/mocha/markdown.svg +3 -3
- package/public/catppuccin-icons/mocha/marko.svg +9 -9
- package/public/catppuccin-icons/mocha/matlab.svg +6 -6
- package/public/catppuccin-icons/mocha/mdbook.svg +4 -4
- package/public/catppuccin-icons/mocha/mermaid.svg +3 -3
- package/public/catppuccin-icons/mocha/meson.svg +6 -6
- package/public/catppuccin-icons/mocha/midi.svg +6 -6
- package/public/catppuccin-icons/mocha/mjml.svg +3 -3
- package/public/catppuccin-icons/mocha/modernizr.svg +3 -3
- package/public/catppuccin-icons/mocha/moonrepo.svg +4 -4
- package/public/catppuccin-icons/mocha/moonwave.svg +3 -3
- package/public/catppuccin-icons/mocha/ms-excel.svg +6 -6
- package/public/catppuccin-icons/mocha/ms-powerpoint.svg +6 -6
- package/public/catppuccin-icons/mocha/ms-word.svg +6 -6
- package/public/catppuccin-icons/mocha/msbuild.svg +8 -8
- package/public/catppuccin-icons/mocha/nativescript.svg +3 -3
- package/public/catppuccin-icons/mocha/nest-controller.svg +3 -3
- package/public/catppuccin-icons/mocha/nest-decorator.svg +3 -3
- package/public/catppuccin-icons/mocha/nest-filter.svg +3 -3
- package/public/catppuccin-icons/mocha/nest-gateway.svg +3 -3
- package/public/catppuccin-icons/mocha/nest-guard.svg +3 -3
- package/public/catppuccin-icons/mocha/nest-middleware.svg +3 -3
- package/public/catppuccin-icons/mocha/nest-pipe.svg +3 -3
- package/public/catppuccin-icons/mocha/nest-service.svg +3 -3
- package/public/catppuccin-icons/mocha/nest.svg +3 -3
- package/public/catppuccin-icons/mocha/netlify.svg +6 -6
- package/public/catppuccin-icons/mocha/next.svg +6 -6
- package/public/catppuccin-icons/mocha/nextflow.svg +3 -3
- package/public/catppuccin-icons/mocha/nginx.svg +6 -6
- package/public/catppuccin-icons/mocha/nim.svg +3 -3
- package/public/catppuccin-icons/mocha/ninja.svg +6 -6
- package/public/catppuccin-icons/mocha/nix-lock.svg +11 -11
- package/public/catppuccin-icons/mocha/nix.svg +10 -10
- package/public/catppuccin-icons/mocha/nodemon.svg +3 -3
- package/public/catppuccin-icons/mocha/npm-ignore.svg +6 -6
- package/public/catppuccin-icons/mocha/npm-lock.svg +7 -7
- package/public/catppuccin-icons/mocha/npm.svg +6 -6
- package/public/catppuccin-icons/mocha/nuget.svg +3 -3
- package/public/catppuccin-icons/mocha/nunjucks.svg +3 -3
- package/public/catppuccin-icons/mocha/nuxt-ignore.svg +3 -3
- package/public/catppuccin-icons/mocha/nuxt.svg +3 -3
- package/public/catppuccin-icons/mocha/nx-ignore.svg +4 -4
- package/public/catppuccin-icons/mocha/nx.svg +4 -4
- package/public/catppuccin-icons/mocha/ocaml.svg +7 -7
- package/public/catppuccin-icons/mocha/odin.svg +3 -3
- package/public/catppuccin-icons/mocha/opentofu.svg +4 -4
- package/public/catppuccin-icons/mocha/org.svg +7 -7
- package/public/catppuccin-icons/mocha/package-json.svg +3 -3
- package/public/catppuccin-icons/mocha/panda-css.svg +3 -3
- package/public/catppuccin-icons/mocha/pdf.svg +3 -3
- package/public/catppuccin-icons/mocha/perl.svg +3 -3
- package/public/catppuccin-icons/mocha/pesde-lock.svg +7 -7
- package/public/catppuccin-icons/mocha/pesde.svg +6 -6
- package/public/catppuccin-icons/mocha/php.svg +3 -3
- package/public/catppuccin-icons/mocha/phrase.svg +6 -6
- package/public/catppuccin-icons/mocha/phtml.svg +6 -6
- package/public/catppuccin-icons/mocha/pixi-lock.svg +6 -6
- package/public/catppuccin-icons/mocha/pixi.svg +7 -7
- package/public/catppuccin-icons/mocha/plantuml.svg +3 -3
- package/public/catppuccin-icons/mocha/playwright.svg +9 -9
- package/public/catppuccin-icons/mocha/plop.svg +3 -3
- package/public/catppuccin-icons/mocha/pnpm-lock.svg +9 -9
- package/public/catppuccin-icons/mocha/pnpm.svg +8 -8
- package/public/catppuccin-icons/mocha/poetry-lock.svg +13 -13
- package/public/catppuccin-icons/mocha/postcss.svg +8 -8
- package/public/catppuccin-icons/mocha/powershell.svg +6 -6
- package/public/catppuccin-icons/mocha/pre-commit.svg +4 -4
- package/public/catppuccin-icons/mocha/premake.svg +7 -7
- package/public/catppuccin-icons/mocha/prettier-ignore.svg +3 -3
- package/public/catppuccin-icons/mocha/prettier.svg +8 -8
- package/public/catppuccin-icons/mocha/prisma.svg +3 -3
- package/public/catppuccin-icons/mocha/prolog.svg +3 -3
- package/public/catppuccin-icons/mocha/properties.svg +3 -3
- package/public/catppuccin-icons/mocha/proto.svg +8 -8
- package/public/catppuccin-icons/mocha/prototools.svg +3 -3
- package/public/catppuccin-icons/mocha/pug.svg +3 -3
- package/public/catppuccin-icons/mocha/puppet.svg +3 -3
- package/public/catppuccin-icons/mocha/puppeteer.svg +5 -5
- package/public/catppuccin-icons/mocha/python-compiled.svg +8 -8
- package/public/catppuccin-icons/mocha/python-config.svg +9 -9
- package/public/catppuccin-icons/mocha/python.svg +8 -8
- package/public/catppuccin-icons/mocha/qwik.svg +6 -6
- package/public/catppuccin-icons/mocha/r.svg +6 -6
- package/public/catppuccin-icons/mocha/racket.svg +6 -6
- package/public/catppuccin-icons/mocha/razor.svg +3 -3
- package/public/catppuccin-icons/mocha/rdata.svg +4 -4
- package/public/catppuccin-icons/mocha/readme.svg +6 -6
- package/public/catppuccin-icons/mocha/reason.svg +6 -6
- package/public/catppuccin-icons/mocha/redwood.svg +3 -3
- package/public/catppuccin-icons/mocha/release.svg +6 -6
- package/public/catppuccin-icons/mocha/remix.svg +3 -3
- package/public/catppuccin-icons/mocha/renovate.svg +6 -6
- package/public/catppuccin-icons/mocha/rescript.svg +6 -6
- package/public/catppuccin-icons/mocha/rmd.svg +4 -4
- package/public/catppuccin-icons/mocha/roblox.svg +3 -3
- package/public/catppuccin-icons/mocha/robots.svg +6 -6
- package/public/catppuccin-icons/mocha/rocket.svg +3 -3
- package/public/catppuccin-icons/mocha/rojo.svg +3 -3
- package/public/catppuccin-icons/mocha/rokit.svg +4 -4
- package/public/catppuccin-icons/mocha/rollup.svg +6 -6
- package/public/catppuccin-icons/mocha/rproj.svg +5 -5
- package/public/catppuccin-icons/mocha/rsml.svg +10 -10
- package/public/catppuccin-icons/mocha/ruby-gem-lock.svg +7 -7
- package/public/catppuccin-icons/mocha/ruby-gem.svg +6 -6
- package/public/catppuccin-icons/mocha/ruby.svg +3 -3
- package/public/catppuccin-icons/mocha/ruff.svg +3 -3
- package/public/catppuccin-icons/mocha/rust-alt-config.svg +4 -4
- package/public/catppuccin-icons/mocha/rust-alt.svg +3 -3
- package/public/catppuccin-icons/mocha/rust-config.svg +7 -7
- package/public/catppuccin-icons/mocha/rust.svg +6 -6
- package/public/catppuccin-icons/mocha/salesforce.svg +3 -3
- package/public/catppuccin-icons/mocha/sass.svg +3 -3
- package/public/catppuccin-icons/mocha/scala.svg +3 -3
- package/public/catppuccin-icons/mocha/scheme.svg +3 -3
- package/public/catppuccin-icons/mocha/search.svg +3 -3
- package/public/catppuccin-icons/mocha/security.svg +4 -4
- package/public/catppuccin-icons/mocha/semantic-release.svg +3 -3
- package/public/catppuccin-icons/mocha/semgrep-ignore.svg +3 -3
- package/public/catppuccin-icons/mocha/semgrep.svg +3 -3
- package/public/catppuccin-icons/mocha/sentry.svg +3 -3
- package/public/catppuccin-icons/mocha/serverless.svg +3 -3
- package/public/catppuccin-icons/mocha/shader.svg +3 -3
- package/public/catppuccin-icons/mocha/sketch.svg +3 -3
- package/public/catppuccin-icons/mocha/slidesk.svg +7 -7
- package/public/catppuccin-icons/mocha/snowpack.svg +6 -6
- package/public/catppuccin-icons/mocha/solid.svg +5 -5
- package/public/catppuccin-icons/mocha/solidity.svg +3 -3
- package/public/catppuccin-icons/mocha/sonar-cloud.svg +7 -7
- package/public/catppuccin-icons/mocha/spwn.svg +7 -7
- package/public/catppuccin-icons/mocha/squirrel.svg +4 -4
- package/public/catppuccin-icons/mocha/stackblitz.svg +3 -3
- package/public/catppuccin-icons/mocha/stata.svg +4 -4
- package/public/catppuccin-icons/mocha/stencil.svg +3 -3
- package/public/catppuccin-icons/mocha/stitches.svg +7 -7
- package/public/catppuccin-icons/mocha/storybook-svelte.svg +6 -6
- package/public/catppuccin-icons/mocha/storybook-vue.svg +6 -6
- package/public/catppuccin-icons/mocha/storybook.svg +6 -6
- package/public/catppuccin-icons/mocha/stylelint-ignore.svg +7 -7
- package/public/catppuccin-icons/mocha/stylelint.svg +7 -7
- package/public/catppuccin-icons/mocha/stylua-ignore.svg +3 -3
- package/public/catppuccin-icons/mocha/stylua.svg +7 -7
- package/public/catppuccin-icons/mocha/sublime.svg +3 -3
- package/public/catppuccin-icons/mocha/super-collider.svg +3 -3
- package/public/catppuccin-icons/mocha/svelte-config.svg +6 -6
- package/public/catppuccin-icons/mocha/svelte.svg +6 -6
- package/public/catppuccin-icons/mocha/svg.svg +3 -3
- package/public/catppuccin-icons/mocha/swift.svg +3 -3
- package/public/catppuccin-icons/mocha/swiftformat.svg +4 -4
- package/public/catppuccin-icons/mocha/symlink.svg +5 -5
- package/public/catppuccin-icons/mocha/tailwind.svg +3 -3
- package/public/catppuccin-icons/mocha/taskfile.svg +3 -3
- package/public/catppuccin-icons/mocha/tauri-ignore.svg +6 -6
- package/public/catppuccin-icons/mocha/tauri.svg +8 -8
- package/public/catppuccin-icons/mocha/terraform.svg +3 -3
- package/public/catppuccin-icons/mocha/text.svg +6 -6
- package/public/catppuccin-icons/mocha/todo.svg +6 -6
- package/public/catppuccin-icons/mocha/toml.svg +3 -3
- package/public/catppuccin-icons/mocha/turbo.svg +10 -10
- package/public/catppuccin-icons/mocha/twig.svg +4 -4
- package/public/catppuccin-icons/mocha/twine.svg +6 -6
- package/public/catppuccin-icons/mocha/typescript-config.svg +7 -7
- package/public/catppuccin-icons/mocha/typescript-def.svg +7 -7
- package/public/catppuccin-icons/mocha/typescript-react.svg +8 -8
- package/public/catppuccin-icons/mocha/typescript-test.svg +3 -3
- package/public/catppuccin-icons/mocha/typescript.svg +6 -6
- package/public/catppuccin-icons/mocha/typst.svg +3 -3
- package/public/catppuccin-icons/mocha/unity.svg +3 -3
- package/public/catppuccin-icons/mocha/unocss.svg +6 -6
- package/public/catppuccin-icons/mocha/url.svg +3 -3
- package/public/catppuccin-icons/mocha/uv.svg +3 -3
- package/public/catppuccin-icons/mocha/v.svg +6 -6
- package/public/catppuccin-icons/mocha/vala.svg +3 -3
- package/public/catppuccin-icons/mocha/vanilla-extract.svg +4 -4
- package/public/catppuccin-icons/mocha/vapi.svg +3 -3
- package/public/catppuccin-icons/mocha/vento.svg +5 -5
- package/public/catppuccin-icons/mocha/vercel-ignore.svg +3 -3
- package/public/catppuccin-icons/mocha/vercel.svg +3 -3
- package/public/catppuccin-icons/mocha/verilog.svg +6 -6
- package/public/catppuccin-icons/mocha/vhs.svg +3 -3
- package/public/catppuccin-icons/mocha/video.svg +6 -6
- package/public/catppuccin-icons/mocha/vim.svg +3 -3
- package/public/catppuccin-icons/mocha/visual-studio.svg +3 -3
- package/public/catppuccin-icons/mocha/vital.svg +6 -6
- package/public/catppuccin-icons/mocha/vite.svg +6 -6
- package/public/catppuccin-icons/mocha/vitest.svg +6 -6
- package/public/catppuccin-icons/mocha/vs-codium.svg +8 -8
- package/public/catppuccin-icons/mocha/vscode-ignore.svg +3 -3
- package/public/catppuccin-icons/mocha/vscode.svg +3 -3
- package/public/catppuccin-icons/mocha/vue-config.svg +6 -6
- package/public/catppuccin-icons/mocha/vue.svg +6 -6
- package/public/catppuccin-icons/mocha/wally.svg +27 -27
- package/public/catppuccin-icons/mocha/web-assembly.svg +7 -7
- package/public/catppuccin-icons/mocha/webpack.svg +7 -7
- package/public/catppuccin-icons/mocha/windi.svg +3 -3
- package/public/catppuccin-icons/mocha/workflow.svg +3 -3
- package/public/catppuccin-icons/mocha/wrangler.svg +4 -4
- package/public/catppuccin-icons/mocha/wxt.svg +3 -3
- package/public/catppuccin-icons/mocha/xaml.svg +8 -8
- package/public/catppuccin-icons/mocha/xcode.svg +7 -7
- package/public/catppuccin-icons/mocha/xmake.svg +7 -7
- package/public/catppuccin-icons/mocha/xml.svg +3 -3
- package/public/catppuccin-icons/mocha/yaml.svg +3 -3
- package/public/catppuccin-icons/mocha/yarn-lock.svg +7 -7
- package/public/catppuccin-icons/mocha/yarn.svg +6 -6
- package/public/catppuccin-icons/mocha/zap.svg +3 -3
- package/public/catppuccin-icons/mocha/zig.svg +3 -3
- package/public/catppuccin-icons/mocha/zip.svg +3 -3
- package/public/favicon.svg +7 -7
- package/public/gruvbox-dark.json +91 -91
- package/public/icons/catppuccin/LICENSE +22 -22
- package/public/icons/catppuccin/README.md +10 -10
- package/public/icons/catppuccin/latte/_file.svg +3 -3
- package/public/icons/catppuccin/latte/_folder.svg +3 -3
- package/public/icons/catppuccin/latte/_folder_open.svg +3 -3
- package/public/icons/catppuccin/latte/bash.svg +7 -7
- package/public/icons/catppuccin/latte/bun-lock.svg +8 -8
- package/public/icons/catppuccin/latte/config.svg +3 -3
- package/public/icons/catppuccin/latte/css.svg +6 -6
- package/public/icons/catppuccin/latte/database.svg +3 -3
- package/public/icons/catppuccin/latte/docker.svg +3 -3
- package/public/icons/catppuccin/latte/env.svg +3 -3
- package/public/icons/catppuccin/latte/eslint.svg +6 -6
- package/public/icons/catppuccin/latte/git.svg +6 -6
- package/public/icons/catppuccin/latte/go.svg +3 -3
- package/public/icons/catppuccin/latte/graphql.svg +3 -3
- package/public/icons/catppuccin/latte/html.svg +6 -6
- package/public/icons/catppuccin/latte/javascript-react.svg +8 -8
- package/public/icons/catppuccin/latte/javascript.svg +6 -6
- package/public/icons/catppuccin/latte/json.svg +3 -3
- package/public/icons/catppuccin/latte/lock.svg +3 -3
- package/public/icons/catppuccin/latte/markdown.svg +3 -3
- package/public/icons/catppuccin/latte/ms-word.svg +6 -6
- package/public/icons/catppuccin/latte/next.svg +6 -6
- package/public/icons/catppuccin/latte/npm-lock.svg +7 -7
- package/public/icons/catppuccin/latte/pdf.svg +3 -3
- package/public/icons/catppuccin/latte/python.svg +8 -8
- package/public/icons/catppuccin/latte/rust.svg +6 -6
- package/public/icons/catppuccin/latte/sass.svg +3 -3
- package/public/icons/catppuccin/latte/terraform.svg +3 -3
- package/public/icons/catppuccin/latte/toml.svg +3 -3
- package/public/icons/catppuccin/latte/typescript-react.svg +8 -8
- package/public/icons/catppuccin/latte/typescript.svg +6 -6
- package/public/icons/catppuccin/latte/yaml.svg +3 -3
- package/public/icons/catppuccin/mocha/_file.svg +3 -3
- package/public/icons/catppuccin/mocha/_folder.svg +3 -3
- package/public/icons/catppuccin/mocha/_folder_open.svg +3 -3
- package/public/icons/catppuccin/mocha/bash.svg +7 -7
- package/public/icons/catppuccin/mocha/bun-lock.svg +8 -8
- package/public/icons/catppuccin/mocha/config.svg +3 -3
- package/public/icons/catppuccin/mocha/css.svg +6 -6
- package/public/icons/catppuccin/mocha/database.svg +3 -3
- package/public/icons/catppuccin/mocha/docker.svg +3 -3
- package/public/icons/catppuccin/mocha/env.svg +3 -3
- package/public/icons/catppuccin/mocha/eslint.svg +6 -6
- package/public/icons/catppuccin/mocha/git.svg +6 -6
- package/public/icons/catppuccin/mocha/go.svg +3 -3
- package/public/icons/catppuccin/mocha/graphql.svg +3 -3
- package/public/icons/catppuccin/mocha/html.svg +6 -6
- package/public/icons/catppuccin/mocha/javascript-react.svg +8 -8
- package/public/icons/catppuccin/mocha/javascript.svg +6 -6
- package/public/icons/catppuccin/mocha/json.svg +3 -3
- package/public/icons/catppuccin/mocha/lock.svg +3 -3
- package/public/icons/catppuccin/mocha/markdown.svg +3 -3
- package/public/icons/catppuccin/mocha/ms-word.svg +6 -6
- package/public/icons/catppuccin/mocha/next.svg +6 -6
- package/public/icons/catppuccin/mocha/npm-lock.svg +7 -7
- package/public/icons/catppuccin/mocha/pdf.svg +3 -3
- package/public/icons/catppuccin/mocha/python.svg +8 -8
- package/public/icons/catppuccin/mocha/rust.svg +6 -6
- package/public/icons/catppuccin/mocha/sass.svg +3 -3
- package/public/icons/catppuccin/mocha/terraform.svg +3 -3
- package/public/icons/catppuccin/mocha/toml.svg +3 -3
- package/public/icons/catppuccin/mocha/typescript-react.svg +8 -8
- package/public/icons/catppuccin/mocha/typescript.svg +6 -6
- package/public/icons/catppuccin/mocha/yaml.svg +3 -3
- package/public/provider-icons.svg +54 -54
- package/public/sw.test.mjs +149 -149
- package/.next/static/chunks/app/_not-found/page-4e8d0b14be117d20.js +0 -1
- package/.next/static/chunks/app/layout-344bb26f147e8fc7.js +0 -1
- package/.next/static/chunks/main-39024e6d570ad5e5.js +0 -5
- package/.next/static/chunks/main-app-0b45ce7a4444c85e.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/global-error-9b3287a6309b286c.js +0 -1
- package/.next/static/chunks/webpack-6a622f7fe45a5a31.js +0 -1
- /package/.next/static/{ttjXA0WqHPS9c_XTNNfP0 → dcKTpfVZrwILk5_itBCpU}/_buildManifest.js +0 -0
- /package/.next/static/{ttjXA0WqHPS9c_XTNNfP0 → dcKTpfVZrwILk5_itBCpU}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{14755:(e,t,o)=>{"use strict";o.d(t,{SC:()=>a,getPresetFromTools:()=>d,xG:()=>c});let r=[],n=["read","grep","find","ls"],s=["read","bash","edit","write"],i=["bash","read","edit","write","grep","find","ls"],a=["read","grep","find","ls"],l=new Set([...i,"powershell"]);function d(e){var t=e.filter(e=>e.active).map(e=>e.name);if(0===t.length)return"none";let o=t.map(e=>"powershell"===e?"bash":e).filter(e=>l.has(e)).sort().join(",");return o===[...n].sort().join(",")?"plan":o===[...s].sort().join(",")?"default":o===[...i].sort().join(",")?"full":"default"}function c(e){return"none"===e?[...r]:"full"===e?[...i]:"plan"===e?[...a]:[...s]}},23084:(e,t,o)=>{"use strict";async function r(e,t){let o=await fetch(e,{...t,headers:t?.body?{"Content-Type":"application/json"}:void 0}),r=await o.json().catch(()=>({}));if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);return r}async function n(e){return(await r(`/api/tasks?projectRoot=${encodeURIComponent(e)}`)).tasks}async function s(){return(await r("/api/tasks/projects")).projects}async function i(e){return(await r("/api/tasks",{method:"POST",body:JSON.stringify(e)})).task}async function a(e,t,o){return(await r(`/api/tasks/${e}?projectRoot=${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({projectRoot:t,...o})})).task}async function l(e,t,o=!1){await r(`/api/tasks/${e}?projectRoot=${encodeURIComponent(t)}&deleteWorktree=${+!!o}`,{method:"DELETE"})}async function d(e,t,o,n){await r(`/api/tasks/${e}/${o}?projectRoot=${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify({...n})})}async function c(e,t,o){await r(`/api/tasks/${e}/return?projectRoot=${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify({feedback:o})})}async function p(e,t,o,n){await r(`/api/tasks/${e}/merge?projectRoot=${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify({message:o,deleteWorktree:n})})}async function u(e,t,o){await r(`/api/tasks/${e}/complete?projectRoot=${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify({deleteWorktree:o})})}async function h(e,t,o){await r(`/api/tasks/${e}/archive?projectRoot=${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify({archived:o})})}async function g(e,t){await r("/api/tasks/batch?mode=reorder",{method:"POST",body:JSON.stringify({projectRoot:e,orderedIds:t})})}async function m(e){return(await r("/api/tasks/batch?mode=start-all",{method:"POST",body:JSON.stringify({projectRoot:e})})).claimed}async function f(e,t,o=500){return(await r(`/api/tasks/${t}/events?projectRoot=${encodeURIComponent(e)}&limit=${o}`)).events}async function x(e,t){return r(`/api/tasks/${t}/changed-files?projectRoot=${encodeURIComponent(e)}`)}async function k(e,t,o){return r(`/api/tasks/${t}/diff?projectRoot=${encodeURIComponent(e)}&file=${encodeURIComponent(o)}`)}async function v(e){return(await r(`/api/tasks/settings?projectRoot=${encodeURIComponent(e)}`)).settings}async function y(e){return(await r(`/api/tasks/settings?projectRoot=${encodeURIComponent(e)}&own=1`)).settings}async function b(e,t){await r("/api/tasks/settings",{method:"PUT",body:JSON.stringify({projectRoot:e,settings:t})})}async function w(e){await r(`/api/tasks/settings?projectRoot=${encodeURIComponent(e)}`,{method:"DELETE"})}async function j(){return(await r("/api/tasks/templates")).templates}async function S(e){return(await r("/api/tasks/templates",{method:"POST",body:JSON.stringify(e)})).template}async function C(e){await r(`/api/tasks/templates?id=${e}`,{method:"DELETE"})}o.d(t,{B_:()=>C,CG:()=>v,E:()=>w,HB:()=>f,JH:()=>x,Lu:()=>g,Pf:()=>y,VB:()=>j,Vk:()=>n,Wt:()=>s,ZX:()=>u,a5:()=>m,bH:()=>l,createTaskApi:()=>i,eA:()=>b,et:()=>h,h:()=>k,in:()=>c,nY:()=>S,oB:()=>p,oQ:()=>d,updateTaskApi:()=>a})},39247:(e,t,o)=>{"use strict";o.d(t,{I18nProvider:()=>c,s:()=>p});var r=o(95155),n=o(12115);let s=new Map;function i(e){if(!e.id.trim())throw Error("Locale id must not be empty");if(s.has(e.id))throw Error(`Locale already registered: ${e.id}`);s.set(e.id,e)}function a(e){return s.get(e)}i({id:"en",label:"English",messages:{"i18n.close":"Close","i18n.cancel":"Cancel","i18n.checking":"Checking…","desktop.settings":"Settings","desktop.settingsSections":"Settings sections","desktop.closeSettings":"Close settings","desktop.display":"Display","desktop.server":"Server","desktop.serverCurrent":"Current server","desktop.serverSwitch":"Switch server","desktop.serverSwitchHint":"Open Pi Web Desktop connection manager: switch between saved servers or add a new server (URL + password).","desktop.reloadPage":"Reload page","desktop.serverHintTitle":"Need a remote server or an access password?","desktop.serverHintBody":"The desktop app now connects to your local server automatically. Switch servers, reach it from your phone, or add an access password from this top-right icon.","desktop.serverHintAction":"Open connection manager","desktop.serverHintDismiss":"Got it","desktop.chat":"Chat","desktop.models":"Models","desktop.skills":"Skills","desktop.plugins":"Plugins","desktop.proxy":"Proxy","desktop.proxyEnable":"Enable Proxy","desktop.proxyProtocol":"Protocol","desktop.proxyHost":"Host","desktop.proxyPort":"Port","desktop.proxyUsername":"Username (optional)","desktop.proxyPassword":"Password (optional)","desktop.proxyNoProxy":"No-Proxy (comma-separated, optional)","desktop.proxySave":"Save","desktop.proxySaving":"Saving…","desktop.proxyTest":"Test Connection","desktop.proxyTesting":"Testing…","desktop.proxySaved":"Proxy configuration saved","desktop.proxySaveFailed":"Failed to save","desktop.proxyTestSuccess":"Connected","desktop.proxyTestFailed":"Connection failed","desktop.proxyUnsaved":"Unsaved changes","desktop.features":"Features","desktop.logs":"Logs","desktop.snippets":"Snippets","desktop.snippetsDesc":"Reusable text/code snippets — type # in the composer to autocomplete","desktop.snippetNew":"New snippet","desktop.snippetName":"Name","desktop.snippetContent":"Content","desktop.snippetSave":"Save","desktop.snippetEdit":"Edit","desktop.snippetDelete":"Delete","desktop.snippetEmpty":"No snippets yet — create one to get started.","desktop.snippetNameRequired":"Snippet name is required","desktop.snippetHint":"Type #name in the composer to autocomplete; Enter expands it to the snippet content.","desktop.logsAllCodes":"All error codes","desktop.logsAllLevels":"All levels","desktop.logsAllSources":"All sources","desktop.logsSearch":"Search error logs","desktop.logsClear":"Clear logs","desktop.logsCopy":"Copy log","desktop.logsEmpty":"No error logs","desktop.mcpVisionTitle":"DeepSeek Vision module","desktop.mcpVisionDesc":"Dedicated configuration for the deepseek-vision module (image analysis / OCR). Both the MCP registration and the model settings can be edited here.","desktop.mcpVisionRegistered":"Registered","desktop.mcpVisionNotRegistered":"Not registered","desktop.mcpVisionRegistration":"MCP registration","desktop.mcpVisionCommand":"Command","desktop.mcpVisionCommandRequired":"Command is required","desktop.mcpVisionLifecycle":"Lifecycle","desktop.mcpVisionTransport":"Transport","desktop.mcpVisionTransportFixed":"stdio (fixed)","desktop.mcpVisionSaveReg":"Save registration","desktop.mcpVisionSavedReg":"Registration saved — takes effect in a new session or after restarting pi.","desktop.mcpVisionRemove":"Remove from MCP config","desktop.mcpVisionRemoved":"Registration removed","desktop.mcpVisionModelConfig":"Model configuration","desktop.mcpVisionModelNote":'Model settings are written to .env immediately. Use "Restart server" below to apply them right away.',"desktop.mcpVisionProvider":"Provider","desktop.mcpVisionBaseUrl":"Base URL","desktop.mcpVisionApiKey":"API key","desktop.mcpVisionModel":"Vision model","desktop.mcpVisionMaxTokens":"Max output tokens","desktop.mcpVisionSaveModel":"Save model configuration","desktop.mcpVisionSavedModel":"Model configuration saved","desktop.mcpVisionNameReserved":"This name is reserved for the built-in DeepSeek Vision configuration — pick another name.","desktop.mcpVisionRestart":"Restart server (apply now)","desktop.mcpVisionRestarting":"Restarting…","desktop.mcpVisionRestarted":"Restart command sent — takes effect shortly","desktop.mcpVisionRestartTitle":"Restart the deepseek-vision server so .env changes take effect immediately","desktop.mcpVisionRestartNoSession":"Open a session first to restart the server","desktop.applyNow":"Apply now","desktop.applyNowApplying":"Reloading…","desktop.applyNowDone":"Reloaded — changes applied","desktop.applyNowTitle":"Reload the current session so changes take effect immediately (no pi restart needed)","desktop.applyNowNoSession":"Open a session first to apply changes now","desktop.featuresDesc":"Manage optional Pi Web features. Disabling one hides its entry points.","desktop.featuresTasksBoard":"Task Board","desktop.featuresTasksBoardDesc":"Show the Task Board entry in the top toolbar to manage cross-project tasks.","desktop.featuresLoading":"Loading…","desktop.featuresSaving":"Saving…","desktop.featuresCollabDefault":"Default task mode","desktop.featuresCollabDefaultDesc":"Default collaboration mode for new chats (Normal / Plan / Goal)","desktop.featuresTokenDefault":"Default token profile","desktop.featuresTokenDefaultDesc":"Default token profile for new chats (Lite / Balanced / Delivery)","desktop.featuresApprovalDefault":"Default tool approval","desktop.featuresApprovalDefaultDesc":"Default tool approval for new chats (Ask / Auto / Yolo)","desktop.usage":"Usage","desktop.usageSession":"Current session","desktop.usageGlobal":"Global","desktop.usageContext":"Context {used} / {window} tokens","desktop.usageContextHint":"Live context usage of the current session","desktop.usageNoSessionData":"No usage data for the current session","desktop.usageNoSession":"No session open","desktop.usageTotal":"Estimated total","desktop.usageMessages":"Messages","desktop.usageMessagesHint":"across all sessions","desktop.usageSessions":"sessions","desktop.usageDaily":"Daily usage trend","desktop.usageTopSessions":"Top sessions by usage","desktop.usageNoData":"No data yet","desktop.mcp":"MCP","desktop.mcpServers":"MCP servers","desktop.mcpAddServer":"Add server","desktop.mcpNewServer":"New MCP server","desktop.mcpEditServer":'Edit MCP server "{name}"',"desktop.mcpRestartNote":"MCP servers are loaded when pi starts. Changes made here take effect after restarting pi.","desktop.mcpEmpty":"No MCP servers configured yet — add one to expose tools to the agent.","desktop.mcpEmptyOther":"No other MCP servers configured — DeepSeek Vision is managed in the card above.","desktop.mcpServerName":"Name","desktop.mcpCommand":"Command","desktop.mcpArgs":"Arguments (one per line)","desktop.mcpTransport":"Transport","desktop.mcpLifecycle":"Lifecycle","desktop.mcpRequestTimeoutMs":"Request timeout (ms)","desktop.mcpEnv":"Environment (JSON)","desktop.mcpEdit":"Edit","desktop.mcpDelete":"Delete","desktop.mcpSave":"Save","desktop.saving":"Saving…","desktop.mcpCancel":"Cancel","desktop.mcpSavedRestart":"Saved — restart pi to apply changes.","desktop.tools":"Tools","desktop.refreshSession":"Refresh session","desktop.shellTool":"Shell tool","desktop.usePowerShell":"Use PowerShell for shell commands","desktop.shellToolDescription":"On Windows, prefer PowerShell over bash for the shell tool. Saves to defaultTools in settings.json.","desktop.shellToolWindowsOnly":"PowerShell is only configurable on Windows.","desktop.shellToolMacOnly":"Shell tool settings are only available on Windows.","desktop.subagentCardProcessing":"Processing","desktop.transcriptRoleUser":"User","desktop.transcriptRoleAssistant":"Assistant","desktop.transcriptRoleResult":"Result","desktop.transcriptRoleBash":"Bash","desktop.backup":"Backup","desktop.backupExportTitle":"Export backup","desktop.backupExportDescription":"Package all global configuration: providers, models, credentials, settings, MCP servers, skills and local plugins.","desktop.backupIncludeSecrets":"Include API keys and credentials","desktop.backupSecretsWarning":"Warning: the backup will contain plaintext API keys (models.json) and OAuth credentials (auth.json). Keep it safe.","desktop.backupIncludeSessions":"Include session history","desktop.backupSessionsHint":"Sessions can be large and may contain sensitive conversation content.","desktop.backupExportButton":"Export backup","desktop.backupExporting":"Exporting…","desktop.backupExportFailed":"Backup export failed","desktop.backupImportTitle":"Import backup","desktop.backupImportButton":"Choose backup file","desktop.backupImportDescription":"Restore from a pi-backup zip. Paths are remapped to this machine and MCP commands are adapted per platform.","desktop.backupImportFailed":"Failed to read the backup file","desktop.backupRestoreFailed":"Restore failed","desktop.backupManifest":"Backup created","desktop.backupNoSecrets":"no credentials included","desktop.backupCategories":"Restore categories","desktop.backupCategorycore":"Core config","desktop.backupCategoryskills":"Skills","desktop.backupCategorypackages":"Plugins","desktop.backupCategorymcp":"MCP servers","desktop.backupCategorysessions":"Sessions","desktop.backupMcpServers":"MCP servers","desktop.backupNpmPackages":"npm packages","desktop.backupReinstallNpm":"Reinstall these npm packages after restore","desktop.backupReinstallNpmHint":"Install scripts run code shipped with the backup; only enable this if you trust its source","desktop.backupInstallModel":"Model for the install session","desktop.backupInstallSession":"Create install session","desktop.backupOpenSession":"Open session","desktop.backupInstallSessionFailed":"Failed to create the install session","desktop.backupRestoreButton":"Restore","desktop.backupRestoring":"Restoring…","desktop.backupRestoreReport":"Restore report","desktop.backupReportRestored":"Restored","desktop.backupReportRestart":"Needs restart to take effect","desktop.backupReportManual":"Needs manual attention","desktop.backupRestartHint":"Settings, models, credentials and MCP config take effect after restarting pi-web / pi.","desktop.importSessions":"Import Sessions","desktop.importSessionsDesc":"Import conversation history from other AI coding tools into pi-web. Currently supports Reasonix, with more tools coming soon.","desktop.comingSoon":"Coming soon","desktop.projects":"projects","desktop.importSelectProjects":"Select projects to import","desktop.importSelectAll":"Select all","desktop.importDeselectAll":"Deselect all","desktop.importMerged":"Merge into existing project","desktop.importNewProject":"New project","desktop.importExistingCount":"{count} existing","desktop.importStart":"Start import","desktop.importing":"Importing…","desktop.importDone":"Import complete","desktop.importedSummary":"Successfully imported {imported} sessions","desktop.importSkippedCount":"{skipped} skipped","desktop.importErrorsCount":"{errors} errors","desktop.importGeneratingTitles":"Generating titles…","desktop.importGenerateTitles":"Generate titles for imported sessions","desktop.importAgain":"Import again","desktop.importNoData":"No Reasonix data found. Make sure ~/.reasonix/projects/ exists with session files.","desktop.importFromReasonix":"from Reasonix","desktop.importFromCodex":"from Codex","desktop.builtinModelsTitle":"Model configuration","desktop.builtinModelsFetchNew":"Fetch new models","desktop.builtinModelsLoadFailed":"Failed to load models","desktop.builtinModelsEmpty":"No models available for this provider.","desktop.builtinModelsContext":"Context","desktop.builtinModelsMaxTokens":"Max output","desktop.builtinModelsReasoning":"Reasoning model","desktop.builtinModelsThinking":"Thinking levels (thinkingLevelMap)","desktop.builtinModelsDirty":"{count} unsaved change(s)","desktop.builtinModelsHide":"Hide this model","desktop.inputShortcut":"Input shortcut","desktop.inputShortcutDescription":"Choose how to send messages with the Enter key.","desktop.useCtrlEnter":"Ctrl+Enter to send","desktop.useCtrlEnterDescription":"Enter inserts a newline, Ctrl+Enter sends the message.","desktop.useEnter":"Enter to send","desktop.useEnterDescription":"Enter sends the message, Shift+Enter inserts a newline.","desktop.theme":"Theme","desktop.themes":"Themes","desktop.language":"Language","desktop.light":"Light","desktop.dark":"Dark","desktop.system":"System","desktop.english":"English","desktop.chinese":"简体中文","desktop.themeDescription":"Choose the appearance of Pi Web.","desktop.languageDescription":"Choose the display language for the interface.","desktop.colorScheme":"Color Scheme","desktop.openThemeFolder":"Open Pi theme folder","desktop.learnPiThemes":"Learn about Pi themes","desktop.defaultTheme":"Default","desktop.appearanceMode":"Appearance Mode","desktop.loadingThemes":"Loading themes…","desktop.borderVisibility":"Border Visibility","desktop.borderSubtle":"Subtle","desktop.borderBold":"Bold","desktop.noCustomThemes":"No custom themes installed.","desktop.noCustomThemesHint":"Add JSON files to","desktop.noCustomThemesHint2":"to see them here.","desktop.darkVariant":"Dark variant available","desktop.lightVariant":"Light variant available","desktop.switchToLight":"Switch to light mode","desktop.switchToDark":"Switch to dark mode","desktop.showSidebar":"Show sidebar","desktop.hideSidebar":"Hide sidebar","desktop.resizeSidebar":"Resize sidebar","desktop.resizeFilePanel":"Resize file panel","desktop.trustProject":"Trust project","desktop.trustingProject":"Trusting…","desktop.projectResourcesRestricted":"Project resources are restricted","desktop.projectSkillsRestricted":"Project skills are unavailable until you trust this project.","desktop.projectSkillInstallUnavailable":"Trust this project before installing project skills.","desktop.shellCommand":"Shell command","desktop.shellOutputLocal":"output stays local","desktop.shellOutputModel":"output is available to the model","desktop.runningShellCommand":"Running shell command…","desktop.loadFullOutput":"Load full output","desktop.download":"Download","desktop.trustProjectTitle":"Trust this project?","desktop.trustProjectBody":"Project extensions, skills, prompts, and package resources can execute code. Trust this project only if you recognize its contents.","desktop.minimize":"Minimize","desktop.maximize":"Maximize","desktop.restore":"Restore","desktop.islandLabel":"Window controls","desktop.islandResetHint":"Drag to move, double-click to reset","desktop.islandDrag":"Drag to move","desktop.close":"Close","desktop.viewFullHistory":"View full history","desktop.fullHistoryAvailableAfterSave":"Full history is available after the session is saved","desktop.systemPrompt":"System prompt","desktop.sessionInfo":"Session info","desktop.hideFilePanel":"Hide file panel","desktop.showFilePanel":"Show file panel","desktop.sessionInfoTitle":"Session Info","desktop.sessionInfoFile":"File","desktop.sessionInfoId":"ID","desktop.sessionInfoInMemory":"In-memory","desktop.sessionInfoMessages":"Messages","desktop.sessionInfoTokens":"Tokens","desktop.sessionInfoActiveTime":"Estimated Active Time","desktop.sessionInfoUser":"User","desktop.sessionInfoAssistant":"Assistant","desktop.sessionInfoToolCalls":"Tool Calls","desktop.sessionInfoToolResults":"Tool Results","desktop.sessionInfoTotal":"Total","desktop.sessionInfoInput":"Input","desktop.sessionInfoOutput":"Output","desktop.sessionInfoCacheRead":"Cache Read","desktop.sessionInfoCacheWrite":"Cache Write","desktop.sessionInfoCost":"Cost","desktop.sessionInfoCostOfficial":"Cost (official)","desktop.sessionInfoContext":"Context","desktop.balance":"Balance","desktop.balanceGranted":"Granted","desktop.balanceToppedUp":"Topped up","desktop.balanceUnavailable":"Balance unavailable","desktop.turnUsageTitle":"This turn","desktop.turnUsageByOfficialPrice":"priced at official rates","desktop.copyFilePath":"Copy file path","desktop.copySessionId":"Copy session ID","desktop.projectDir":"Project","desktop.gitBranch":"Git branch","desktop.gitWorktree":"Worktree","desktop.projectSection":"Project Info","desktop.copyProjectDir":"Copy project path","desktop.copyGitBranch":"Copy git branch","desktop.copyGitWorktree":"Copy worktree path","desktop.sendMessageForSessionInfo":"Send a message or run /session to load session info","desktop.selectSessionFromSidebar":"Select a session from the sidebar","desktop.getStarted":"Get Started","desktop.selectProjectDirectory":"Select a project directory from the sidebar","desktop.addModelsFromBottom":"Add models via the Models button at the bottom","desktop.loadingSession":"Loading session...","desktop.scrollToLoadEarlierMessages":"Scroll up to load earlier messages ({count} hidden)","desktop.scrollToBottom":"Scroll to latest","desktop.filesWritten":"Files changed","desktop.openWrittenFile":"Open {name}","desktop.taskRunning":"running","desktop.taskTodo":"todo","desktop.taskStatusHint":"Task progress for the current project — click to open the board","desktop.runningTool":"Running tool...","desktop.runningTools":"Running {tools}...","desktop.waitingForModel":"Waiting for model...","desktop.runningCommand":"Running command...","desktop.thinking":"Thinking...","desktop.extensionRequest":"extension request","desktop.extensionPanel":"Extension panel","desktop.cancel":"Cancel","desktop.confirm":"Confirm","desktop.submit":"Submit","desktop.queued":"Queued","desktop.queueMoveUp":"Move up","desktop.queueMoveDown":"Move down","desktop.queueRecallOne":"Recall to input","desktop.queueRemove":"Remove queued message","desktop.recalledEditing":"Editing a queued message. Sending puts it back at its original position.","desktop.steer":"Steer","desktop.followUp":"Follow-up","desktop.recallToInput":"Recall to input","desktop.recallQueuedMessages":"Remove all queued messages and put them back into the input box for editing","desktop.retrying":"Retrying","desktop.compacted":"Compacted","desktop.tokens":"tokens","desktop.saved":"saved","desktop.removeImage":"Remove image","desktop.loadingCommands":"Loading commands...","desktop.slashCommands":"Slash commands","desktop.tabOrEnter":"Tab / Enter","desktop.noSlashCommands":"No extension, prompt, or skill commands found","desktop.builtIn":"Built-in","desktop.extensions":"Extensions","desktop.prompts":"Prompts","desktop.commandSkills":"Skills","desktop.match":"match","desktop.matches":"matches","desktop.snippetMatches":"snippet matches","desktop.command":"command","desktop.commands":"commands","desktop.loadingFiles":"Loading files...","desktop.files":"Files","desktop.searchingAllFiles":"searching all files...","desktop.indexTruncated":"index truncated","desktop.searching":"Searching...","desktop.search":"Search","desktop.noMatchingFiles":"No matching files","desktop.steerOrQueueFollowUp":"Steer now / queue follow-up...","desktop.agentRunning":"Agent is running...","desktop.messageWithCommands":"Message... Type / for commands, @ for files","desktop.inputHistory":"Input history","desktop.quickChanges":"Quick Changes","desktop.changedFiles":"{count} changed files","desktop.imageAttachmentsCannotQueue":"Image attachments cannot be queued while the agent is running","desktop.injectMessageNow":"Interrupt the current run and inject this message now","desktop.queueMessageAfterFinish":"Queue this message after the agent finishes","desktop.attachImage":"Attach image","desktop.push":"Push current branch","desktop.pushOk":"Push succeeded","desktop.pushFailed":"Push failed","desktop.stash":"Stash","desktop.stashTitle":"Stash manager","desktop.stashPush":"Stash changes","desktop.stashList":"Stash list","desktop.stashEmpty":"No stashes","desktop.stashPop":"Pop","desktop.stashDrop":"Drop","desktop.stashMessagePlaceholder":"Stash message (optional)…","desktop.stashDone":"Done","desktop.attachMenu":"Choose input mode","desktop.attachUpload":"Upload file","desktop.attachUploadDesc":"Attach images and other files","desktop.attachReference":"Reference files","desktop.attachReferenceDesc":"Reference workspace files with @","desktop.attachSessions":"Reference sessions","desktop.attachSessionsDesc":"Reference past conversations with #","desktop.attachCommands":"Use commands","desktop.attachCommandsDesc":"Use commands and skills with /","desktop.planModeBadge":"Plan mode","desktop.planModeLabel":"Plan mode","desktop.planModeHint":"Plan mode: read-only analysis, no file modifications. Confirm execution or exit when done.","desktop.disableCompletionSound":"Disable completion sound","desktop.enableCompletionSound":"Enable completion sound","desktop.soundLabelOn":"Sound: On","desktop.soundLabelOff":"Sound: Off","desktop.changeReasoningLevel":"Change reasoning level: {level}","desktop.reasoningLevel":"Change reasoning level","desktop.moreControls":"More controls","desktop.more":"More","modes.collabNormal":"Normal","modes.collabPlan":"Plan","modes.collabGoal":"Goal","modes.tokenEconomy":"Lite","modes.tokenFull":"Balanced","modes.tokenDelivery":"Delivery","modes.approvalAsk":"Ask","modes.approvalAuto":"Auto","modes.approvalYolo":"Yolo","modes.collabNormalTitle":"Normal \xb7 act as you go","modes.collabNormalDesc":"Execute directly, advancing as you go","modes.collabPlanTitle":"Plan \xb7 confirm before executing","modes.collabPlanDesc":"Produce a plan first; tool execution still follows permissions","modes.collabGoalTitle":"Goal \xb7 keep pushing","modes.collabGoalDesc":"Work continuously until done or blocked","modes.tokenEconomyTitle":"Lite \xb7 fast, token-saving","modes.tokenEconomyDesc":"Less context, tools enabled on demand","modes.tokenFullTitle":"Balanced \xb7 daily general use","modes.tokenFullDesc":"Full tools, autonomous execution","modes.tokenDeliveryTitle":"Delivery \xb7 full verification","modes.tokenDeliveryDesc":"Mandatory acceptance, recheck and verify","modes.approvalAskTitle":"Require approval","modes.approvalAskDesc":"Writes and commands needing approval ask first","modes.approvalAutoTitle":"Auto-approve","modes.approvalAutoDesc":"Auto-execute what the policy allows","modes.approvalYoloTitle":"Yolo approve","modes.approvalYoloDesc":"Skip normal tool prompts (this session only)","desktop.goalRunning":"Goal","desktop.goalComplete":"Goal complete","desktop.goalBlocked":"Goal blocked","desktop.goalPaused":"Goal paused","desktop.goalNoProgress":"{n} no-progress turns","desktop.goalPause":"Pause goal","desktop.goalPauseShort":"Ⅱ","desktop.goalResume":"Resume goal","desktop.goalResumeShort":"▶","desktop.goalStop":"Stop goal","desktop.goalEdit":"Edit","desktop.goalSave":"Save","desktop.goalCancel":"Cancel","desktop.goalEditHint":"Cmd+Enter to save \xb7 Esc to cancel","desktop.goalBudget":"budget","desktop.goalTurns":"turns","desktop.goalBudgetLimited":"budget exhausted","approval.title":"Tool approval required","approval.subtitle":"The agent wants to run this tool. Choose Allow to run it, or Deny to send a blocked result back.","approval.queued":"more waiting","approval.allow":"Allow","approval.deny":"Deny","approval.denyWithReason":"Deny with reason","approval.hideReason":"Hide reason","approval.reasonPlaceholder":"Reason shown to the agent (optional)","desktop.stopCompaction":"Stop compaction","desktop.compactContext":"Compact context","desktop.compacting":"Compacting...","desktop.compact":"Compact","desktop.changeToolPreset":"Change tool preset: {preset}","desktop.toolPreset":"Change tool preset","desktop.sendMessage":"Send message","desktop.stopAgent":"Stop agent","desktop.stop":"Stop","desktop.collapseControls":"Collapse controls","desktop.usePiDefault":"Use pi default","desktop.reasoningOff":"Reasoning off","desktop.minimalReasoning":"Minimal reasoning","desktop.lowReasoning":"Low reasoning","desktop.mediumReasoning":"Medium reasoning","desktop.highReasoning":"High reasoning","desktop.extraHighReasoning":"Extra-high reasoning","desktop.maxReasoning":"Max reasoning","desktop.noToolsReadOnly":"No tools, read-only","desktop.fourBuiltInTools":"4 built-in tools","desktop.allBuiltInTools":"All built-in tools","desktop.toolOff":"off","desktop.toolDefault":"default","desktop.toolFull":"full","desktop.thinkingAuto":"auto","desktop.thinkingOff":"off","desktop.thinkingMinimal":"minimal","desktop.thinkingLow":"low","desktop.thinkingMedium":"medium","desktop.thinkingHigh":"high","desktop.thinkingExtraHigh":"xhigh","desktop.thinkingMax":"max","desktop.compactCommandDescription":"Compress context, optionally with instructions","desktop.reloadCommandDescription":"Reload extensions, skills, prompts, and tools","desktop.nameCommandDescription":"Set the session display name","desktop.sessionCommandDescription":"Show session message, token, and cost stats","desktop.copyCommandDescription":"Copy the last assistant message","desktop.selectModel":"Select model","desktop.modelsLoadFailed":"Failed to load model list","desktop.noModelsConfigured":"No models configured — add a provider in Model settings","desktop.selectProject":"Select project","desktop.selectProjectFirst":"Select a project first","desktop.noMatchingProjects":"No matching projects","desktop.noProjectsYet":"No projects yet","desktop.useDefaultDirectory":"Use default directory","desktop.customPath":"Custom path…","desktop.projectPathPlaceholder":"/path/to/project","desktop.filterProjects":"Filter projects…","desktop.searchProjects":"Search projects…","desktop.recentProjects":"Recent Projects","desktop.addProjectTab":"Add project tab","desktop.maxProjectTabs":"Up to 4 project tabs (1 dropdown + 4 tabs)","desktop.branch":"Branch","desktop.editProjectAlias":"Rename project","desktop.projectAliasPlaceholder":"Add a remark for this project…","desktop.quickWorkspace":"Quick workspace","desktop.selectFolder":"Select folder","desktop.checking":"Checking…","desktop.open":"Open","common.ok":"OK","common.language":"Language","common.models":"Models","common.skills":"Skills","common.agents":"Sub-agents","common.plugins":"Plugins","common.settings":"Settings","settings.title":"Settings","settings.general":"General","settings.generalDescription":"Choose how Pi Web looks and which language it uses.","settings.appearance":"Appearance","settings.appearanceDescription":"Select a theme or follow your system preference.","settings.chatContentWidth":"Chat content width","settings.chatContentFontSize":"Chat font size","settings.resetChatContentWidth":"Reset chat content width","settings.resetChatContentFontSize":"Reset chat font size","settings.chatContentWidthDescription":"Set the maximum width of messages and the composer.","settings.themeLight":"Light","settings.themeDark":"Dark","settings.themeSystem":"System","settings.thinkingDisplay":"Thinking display","settings.thinkingDisplayDescription":"Choose whether model reasoning blocks are expanded when messages load.","settings.thinkingExpandedDefault":"Expand thinking blocks by default","settings.chat":"Chat","settings.quoteSelection":"Show actions for selected text","settings.languageDescription":"Choose the language used throughout the interface.","settings.shellTool":"Shell tool","settings.shellToolDescription":"Choose which shell the model uses for commands. Direct ! and !! commands still use Bash.","settings.usePowerShell":"Use PowerShell instead of Bash","settings.projectRequired":"Open a project to configure this section","skills.scope.global":"global","skills.scope.project":"project","skills.scope.path":"path","agents.close":"Close","agents.builtInTitle":"Enable Pi Web built-in sub-agents","agents.builtInDescription":"Provides Pi Web's integrated Agent tools and disables a conflicting pi-subagents extension.","agents.reloadRequired":"Reload the current session to apply this change.","agents.reloadSession":"Reload session","agents.reloading":"Reloading...","agents.loading":"Loading sub-agents...","agents.new":"New sub-agent","agents.empty":"Select or create a sub-agent profile","agents.saveScope":"Save to","agents.name":"Sub-agent ID","agents.displayName":"Display name","agents.description":"Description","agents.prompt":"System instructions","agents.tools":"Tools","agents.resources":"Resources","agents.loadSkills":"Load skills","agents.loadExtensions":"Load extensions","agents.model":"Model override","agents.modelsLoading":"Loading models...","agents.modelUnavailable":"{model} (unavailable)","agents.thinking":"Thinking","agents.maxTurns":"Max turns","agents.inherit":"Parent default","agents.enable":"Enable sub-agent","agents.disable":"Disable sub-agent","agents.builtinPath":"Built-in profile","agents.inheritContext":"Inherit parent context","agents.background":"Run in background by default","agents.duplicate":"Duplicate","agents.copyName":"{name} copy","agents.delete":"Delete","agents.deleteConfirm":"Delete {name}?","agents.save":"Save","agents.saving":"Saving...","agents.scope.builtin":"built-in","agents.scope.global":"global","agents.scope.workspace":"workspace","agents.scope.project":"project","agents.overridden":"Overridden","subagent.readOnlyNotice":"Sub-agent sessions are read-only","subagent.open":"Open sub-agent session","agentSwitcher.title":"Agents","agentSwitcher.main":"Main agent","agentSwitcher.subagent":"Sub-agent","agentSwitcher.current":"Current","agentSwitcher.count":"{count} sub-agents","agentSwitcher.runningCount":"{count} running","agentSwitcher.search":"Search agents","agentSwitcher.noFamily":"No agent family for this session","agentSwitcher.noMatches":"No matching agents","agentSwitcher.status.starting":"Starting","agentSwitcher.status.running":"Running","agentSwitcher.status.completed":"Completed","agentSwitcher.status.failed":"Failed","agentSwitcher.status.aborted":"Aborted","agentSwitcher.status.interrupted":"Interrupted","appUpdate.releaseNotes":"Pi Web v{version} is available. View release notes","sidebar.hide":"Hide sidebar","sidebar.show":"Show sidebar","theme.light":"Light mode (click for dark)","theme.dark":"Dark mode (click for system)","theme.auto":"System theme (click for light)","history.full":"Full history","history.unsaved":"Full history is available after the session is saved","history.label":"Full history","title.generating":"Generating...","title.updated":"Title updated","title.failed":"Generation failed","title.generate":"Generate title","title.unsaved":"Title generation is available after the session is saved","title.noMessages":"Send a message before naming this session","title.generateSession":"Generate a session title","system.prompt":"System prompt","system.empty":"System prompt is empty (tools are disabled)","system.load":"System prompt has not loaded yet","system.loading":"Loading system prompt…","system.label":"System","tools.label":"Tools","tools.title":"Tool definitions","tools.details":"Tool definition details","tools.load":"Tool definitions have not loaded yet","tools.loading":"Loading tool definitions…","tools.noTools":"No active tools","tools.description":"Description","tools.parameters":"Parameters","tools.parameterCount":"{count} parameters","tools.noParameters":"No parameters","tools.required":"Required","tools.optional":"Optional","tools.allowedValues":"Allowed","tools.defaultValue":"Default","tools.guidelines":"Prompt guidelines","session.info":"Session info","session.name":"Name","session.file":"Session File","session.inMemory":"In-memory","session.id":"ID","session.user":"User","session.assistant":"Assistant","session.toolCalls":"Tool Calls","session.toolResults":"Tool Results","session.total":"Total","session.input":"Input","session.output":"Output","session.cacheRead":"Cache Read","session.cacheWrite":"Cache Write","session.cost":"Cost","session.context":"Context","session.cacheHitRate":"Avg cache hit rate","session.copy":"Copy {value}","session.copied":"Copied","session.title":"Session info","session.load":"Send a message or run /session to load session info","session.infoSection":"Session Info","session.projectSection":"Project Info","session.messages":"Messages","session.tokens":"Tokens","session.totalActive":"Active Time","session.copyFile":"Copy file path","session.copyId":"Copy session ID","session.projectDir":"Project Dir","session.gitBranch":"Git Branch","session.gitWorktree":"Worktree","session.copyProjectDir":"Copy project directory","session.copyGitBranch":"Copy git branch","session.copyGitWorktree":"Copy worktree path","workspace.opening":"Opening workspace...","workspace.unable":"Unable to open workspace","workspace.selectSession":"Select a session from the sidebar","workspace.getStarted":"Get Started","workspace.selectProject":"Select a project directory from the sidebar","workspace.addModels":"Open Settings at the bottom, then choose Models","workspace.stepProject":"Select a project directory from the sidebar","workspace.stepModels":"Open Settings at the bottom, then choose Models","files.hidePanel":"Hide file panel","files.showPanel":"Show file panel","files.noneOpen":"No file open","layout.resizeSidebar":"Resize sidebar","layout.resizeFilePanel":"Resize file panel","layout.resizeHint":"Drag to resize. Double-click or press Enter to reset.","sidebar.new":"New","sidebar.newSessionTitle":"New session in {path}","sidebar.refresh":"Refresh","sidebar.selectProject":"Select project…","sidebar.filterProjects":"Filter projects…","sidebar.noMatchingProjects":"No matching projects","sidebar.searchFiles":"Search files","sidebar.searchFilesPlaceholder":"Search files…","sidebar.clearSearch":"Clear search","sidebar.searchingFiles":"Searching…","sidebar.noMatchingFiles":"No matching files","sidebar.useDefaultDirectory":"Use default directory","sidebar.customPath":"Custom path…","directoryPicker.selectDirectory":"Select directory","directoryPicker.goToParent":"Go to parent directory","directoryPicker.loadingDirectories":"Loading directories…","directoryPicker.noSubdirectories":"No subdirectories","directoryPicker.noMatchingDirectories":"No matching subdirectories","directoryPicker.filterPlaceholder":"Filter subdirectories…","directoryPicker.selectCurrentDirectory":"Select current directory","directoryPicker.selectThisFolder":"Select this folder","directoryPicker.noDrives":"No drives found","desktop.switchWorktree":"Switch worktree","desktop.switchWorktreeWithPath":"Switch worktree: {path}","desktop.openRepoRoot":"Open repo root","desktop.openRepoRootDescription":"Open the repository root to manage worktrees.","desktop.gitRepoRootOnly":"Git repo root only","desktop.gitRepoRootOnlyDescription":"Worktrees are available in Git repository roots.","desktop.checkingWorktrees":"Checking worktrees for this directory.","desktop.worktreesLoading":"Worktrees...","desktop.createWorktree":"Create a worktree checkout for a branch","desktop.newWorktree":"New worktree…","desktop.branchName":"branch name","desktop.creating":"Creating…","desktop.create":"Create","desktop.main":"main","desktop.removeWorktree":"Remove worktree checkout {path}; the branch is kept","desktop.uncommittedChanges":"Uncommitted changes. Force remove checkout?","desktop.force":"Force","desktop.sessions":"Sessions","desktop.newSession":"New","desktop.newSessionIn":"New session in {cwd}","desktop.refresh":"Refresh","desktop.loading":"Loading...","desktop.noModels":"No models available","desktop.noSessionsFound":"No sessions found","desktop.explorer":"Explorer","desktop.uploadFiles":"Upload files","desktop.uploadFilesToProjectRoot":"Upload files to project root","desktop.refreshExplorer":"Refresh explorer","desktop.agentRunningLabel":"Agent running","desktop.newActivity":"New activity","desktop.newSessionActivity":"New session activity","desktop.deleteSession":"Delete {title}?","desktop.delete":"Delete","desktop.deleteWithShift":"Delete (Shift-click to skip confirmation)","desktop.openingWorkspace":"Opening workspace…","desktop.unableToOpenWorkspace":"Unable to open this workspace","desktop.rename":"Rename","desktop.titleGenerationFailed":"Title generation failed","desktop.retryTitleGeneration":"Retry title generation","desktop.retry":"Retry","desktop.changeTitleModel":"Change model","desktop.pastedLabel":"[Pasted text #{id} \xb7 {lines} lines]","desktop.pastedShowPreview":"Preview pasted text","desktop.pastedHidePreview":"Collapse pasted text preview","desktop.pastedRemove":"Remove pasted text","desktop.pastedMissingContent":"A pasted-text placeholder lost its original content — send blocked. Please paste that content again.","desktop.generateTitle":"Generate title","desktop.generateAllTitles":"Generate titles for all sessions in this project","desktop.generatingTitlesProgress":"Generating titles… {done}/{total}","desktop.generatingTitle":"Generating title...","desktop.titleNeedsMessages":"No messages to generate a title from","desktop.expandForks":"Expand forks","desktop.collapseForks":"Collapse forks","desktop.sessionViewList":"List","desktop.sessionViewGroups":"Groups","desktop.searchSessions":"Search sessions, branches...","desktop.noSearchResults":"No matching sessions","desktop.pinned":"Pinned","desktop.today":"Today","desktop.yesterday":"Yesterday","desktop.older":"Older","desktop.collapseGroup":"Collapse","desktop.expandGroup":"Expand","desktop.pin":"Pin to top","desktop.unpin":"Unpin","desktop.forkedFrom":"Forked from {title}","desktop.messagesCount":"{count} msgs","desktop.worktree":"Worktree: {cwd}","desktop.justNow":"just now","desktop.minutesAgo":"{count}m ago","desktop.hoursAgo":"{count}h ago","desktop.daysAgo":"{count}d ago","desktop.panelGroupBubble":"Grouped","desktop.panelProjectBubble":"Projects","desktop.rowStyleToggle":"Toggle row style","desktop.sidebarModeCycle":"Cycle sidebar mode","desktop.panelFormLabel":"Panel","desktop.expandAllFolders":"Expand all folders","desktop.collapseAllFolders":"Collapse all folders","desktop.filterMenu":"Filter","desktop.moreActions":"More actions","desktop.viewSection":"View","desktop.viewByProject":"By project","desktop.viewTimeline":"Timeline","desktop.sortSection":"Sort by","desktop.sortUpdated":"Updated","desktop.sortCreated":"Created","desktop.hiddenProjectsSection":"Hidden projects","desktop.noHiddenProjects":"No hidden projects","desktop.restoreProject":"Restore","desktop.archivedView":"Archived","desktop.archiveSession":"Archive","desktop.archiveSessionConfirm":"Archive {title}?","desktop.unarchiveSession":"Unarchive","desktop.deleteForever":"Delete forever","desktop.deleteArchivedConfirm":"Permanently delete this archived session? Its file will be removed and this cannot be undone.","desktop.removeProject":"Remove project","desktop.removeProjectConfirm":"Project {name} will be removed from the sidebar, but files on disk are not deleted.","desktop.removeProjectRunningConfirm":"This project still has running sessions. Remove it anyway?","desktop.showMore":"Show more","desktop.viewFiles":"View files","desktop.backToSessions":"Back to sessions","desktop.newSessionHere":"New session in this project","desktop.newTask":"New task","desktop.showAllProjects":"Show all projects","desktop.showCurrentProject":"Show current project","desktop.sidebarModeHintTitle":"Two list layouts","desktop.sidebarModeHintDesc":"This button switches between the current-project dropdown and the all-projects panel (grouped / project / timeline views, archiving and per-project file trees).","desktop.sidebarModeHintOk":"Got it","desktop.noProjects":"No projects yet","desktop.noArchivedSessions":"No archived sessions","desktop.searchArchived":"Search archived sessions...","desktop.projectSectionHeader":"Projects","desktop.closeTab":"Close","desktop.closeTabWithLabel":"Close {label}","desktop.modelsHideApiKey":"Hide API key","desktop.modelsShowApiKey":"Show API key","desktop.modelsInheritNone":"— inherit / none —","desktop.modelsProvider":"Provider","desktop.modelsProviderName":"Provider name","desktop.modelsBaseUrl":"Base URL","desktop.modelsApiKey":"API Key","desktop.modelsApiKeyHelp":"Prefix with ! to run a shell command, or use an env var name","desktop.modelsApiKeyPlaceholder":"ENV_VAR_NAME, !shell-command, or literal key","desktop.modelsApi":"API","desktop.modelsDefault":"Default","desktop.modelsDisabled":"Disabled","desktop.modelsCustom":"Custom","desktop.modelsModelSection":"Model","desktop.modelsTestingConnection":"Testing model connection...","desktop.modelsConnected":"Connected","desktop.modelsFailed":"Failed","desktop.modelsTestConnection":"Test model connection","desktop.modelsTesting":"Testing…","desktop.modelsTest":"Test","desktop.modelsOk":"OK","desktop.modelsRemove":"Remove","desktop.modelsIdRequired":"ID *","desktop.modelsName":"Name","desktop.modelsDisplayName":"Display name","desktop.modelsApiOverride":"API override","desktop.modelsReasoningThinking":"Reasoning / thinking","desktop.modelsImageInput":"Image input","desktop.modelsDeepSeekCompat":"DeepSeek thinking compat","desktop.modelsThinkingLevelMap":"Thinking level map","desktop.modelsClearAll":"clear all","desktop.modelsDiscoveryFetching":"Importing models…","desktop.modelsDiscoveryFetch":"Import models…","desktop.modelsDiscoveryFilterPlaceholder":"Filter {count} models…","desktop.modelsDiscoveryFilter":"Filter upstream models","desktop.modelsDiscoverySelectShown":"Select shown","desktop.modelsDiscoveryNoMatches":"No matching models.","desktop.modelsDiscoveryAdded":"added","desktop.modelsDiscoveryShowing":"Showing first {shown} of {total}","desktop.modelsDiscoveryFetched":"{count} models fetched","desktop.modelsDiscoveryAddSelected":"Add selected","desktop.modelsDiscoveryAddSelectedCount":"Add selected ({count})","desktop.modelsCatalogSource":"source: models.dev ↗","desktop.modelsCatalogFilling":"Filling details…","desktop.modelsCatalogFill":"Fill model details","desktop.modelsCatalogFilled":"{count} fields filled","desktop.modelsCatalogNoEmptyFields":"No empty fields to fill","desktop.modelsCatalogNoExactMatch":"No exact models.dev match","desktop.modelsCatalogPriceProvider":"Price matched Provider {provider}","desktop.modelsCatalogPriceBaseUrl":"Price matched Base URL to {provider}","desktop.modelsCatalogPriceConsensus":"Price agreed by {support}/{total} records","desktop.modelsCatalogPriceUnreliable":"No reliable price found","desktop.modelsCatalogUndo":"Undo","desktop.modelsContextWindow":"Context window (tokens)","desktop.modelsMaxOutputTokens":"Max output tokens","desktop.modelsCostPerMillionTokens":"Cost (per million tokens)","desktop.modelsSubscription":"Subscription","desktop.titleModel":"Title generation model","desktop.titleModelDescription":'Model used to auto-generate session titles. Keep "Follow session model" to use each session\'s own model.',"desktop.titleModelFollowSession":"Follow session model (default)","desktop.titleModelInvalid":"no longer imported — title generation falls back to the session model","desktop.titleModelSaved":"Saved","desktop.titleModelSaveError":"Failed to save title model setting","desktop.modelsNotConnected":"not connected","desktop.modelsAlreadyConnected":"Already connected. You can re-login or disconnect.","desktop.modelsConnectAccount":"Connect your {provider} account.","desktop.modelsOpeningBrowser":"Opening browser…","desktop.modelsCompleteSignIn":"Complete sign-in in the browser, then copy the redirect URL from the address bar and paste it below.","desktop.modelsBrowserDidNotOpen":"If the browser window did not open,","desktop.modelsOpenLoginPage":"click here to open the login page","desktop.modelsEnterValue":"Enter value…","desktop.modelsOpenVerificationPage":"Open the verification page and enter this code:","desktop.modelsExpiresInMinutes":"Expires in {count} minutes.","desktop.modelsConnectedSuccessfully":"Connected successfully.","desktop.modelsReLogin":"Re-login","desktop.modelsLogin":"Login","desktop.modelsDisconnect":"Disconnect","desktop.modelsConnectionLost":"Connection lost","desktop.modelsAuthenticationStateChanged":"Authentication state changed. Please refresh and try again.","desktop.modelsVerifying":"Verifying…","desktop.modelsContinuing":"Continuing…","desktop.modelsServerError":"Server error {status}","desktop.modelsNetworkError":"Network error","desktop.modelsConfigured":"configured","desktop.modelsNotConfigured":"not configured","desktop.modelsApiKeyStored":"API key is stored. Enter a new key below to replace it, or disconnect to remove it.","desktop.modelsEnableModels":"Enter your {provider} API key to enable {count} {models}.","desktop.modelsSingular":"model","desktop.modelsPlural":"models","desktop.modelsEnterNewKey":"Enter new key to replace…","desktop.modelsSaving":"Saving…","desktop.modelsSaved":"Saved","desktop.modelsRemoving":"Removing…","desktop.modelsSearchProviders":"Search providers…","desktop.modelsNoProvidersMatch":"No providers match","desktop.modelsCompatibleProvider":"OpenAI / Anthropic compatible","desktop.modelsCustomEndpointFormat":"Custom endpoint format","desktop.modelsAddCustomTitle":"Add custom provider","desktop.modelsProviderNameOptional":"Provider name (optional)","desktop.modelsCallFormat":"Call format","desktop.modelsCallFormatHelp":"Choose one of the existing call formats","desktop.modelsCustomCallFormat":"Custom call format","desktop.modelsCustomCallFormatHelp":"Custom endpoints use the OpenAI-compatible protocol (openai-completions) by default. Pick another format above if your API speaks a different protocol.","desktop.modelsFullUrl":"Full URL","desktop.modelsAddModelManual":"Add model","desktop.modelsImportProvider":"Import from existing provider","desktop.modelsImportProviderPlaceholder":"— import existing provider config —","desktop.modelsImported":"imported","desktop.modelsAddUrl":"+ Add URL","desktop.modelsUrlPlaceholder":"https://api.example.com/v1","desktop.modelsUrlInvalid":"URL must start with http:// or https://","desktop.modelsCustomRequest":"Custom request","desktop.modelsRequestModelId":"Request model ID","desktop.modelsRequestModelIdHelp":"Optional — creates the first model with these request settings","desktop.modelsRequestContextLength":"Context length (tokens)","desktop.modelsRequestOutputLength":"Output length (tokens)","desktop.modelsAdd":"Add","desktop.modelsSubscriptions":"Subscriptions","desktop.modelsCount":"{count} models","desktop.modelsLoading":"Loading…","desktop.modelsNewModel":"new model","desktop.modelsAddModel":"+ model","desktop.modelsAddProvider":"+ Add provider","desktop.modelsSelectProviderOrModel":"Select a provider or model","desktop.modelsClose":"Close models","desktop.modelsSave":"Save","desktop.searchModels":"Search models…","desktop.noModelsMatch":"No matching models","desktop.global":"global","desktop.project":"project","desktop.path":"path","desktop.addPlugin":"Add plugin","desktop.addPluginTitle":"Add Plugin","desktop.pluginSource":"Source","desktop.install":"Install","desktop.installing":"Installing...","desktop.examples":"Examples","desktop.disabled":"Disabled","desktop.filtered":"filtered","desktop.noResources":"No resources","desktop.packageDisabled":"Package disabled","desktop.noResolvedResources":"No resolved resources","desktop.unknown":"Unknown","desktop.installedVersion":"installed {version}","desktop.configuredVersion":"configured {version}","desktop.enablePackage":"Enable package","desktop.disablePackage":"Disable package","desktop.update":"Update","desktop.updating":"Updating...","desktop.reloadSession":"Reload session","desktop.reloading":"Reloading...","desktop.reloadCurrentSession":"Reload current session","desktop.openSessionToReload":"Open a session to reload","desktop.remove":"Remove","desktop.removing":"Removing...","desktop.status":"Status","desktop.version":"Version","desktop.package":"Package","desktop.resources":"Resources","desktop.installedPath":"Installed path","desktop.notFound":"Not found","desktop.cwd":"Cwd","desktop.resolvedResources":"Resolved Resources","desktop.packageRemoved":"Package removed.","desktop.packageInstalled":"Package installed.","desktop.packageUpdated":"Package updated.","desktop.packageDisabledMessage":"Package disabled.","desktop.packageEnabled":"Package enabled.","desktop.sessionReloaded":"Session reloaded.","desktop.noPluginsConfigured":"No plugins configured","desktop.selectPackage":"Select a package","desktop.diagnosticsCount":"{count} diagnostic{suffix}","desktop.pluginResourceTotals":"{extensions} ext \xb7 {skills} skills \xb7 {prompts} prompts \xb7 {themes} themes","desktop.extensionsCount":"{count} ext","desktop.skillsCount":"{count} skills","desktop.promptsCount":"{count} prompts","desktop.themesCount":"{count} themes","desktop.addSkill":"Add skill","desktop.addSkillTitle":"Add Skill","desktop.skillSearchPlaceholder":"e.g. react, testing, deploy","desktop.noSkillsFound":"No skills found","desktop.skillSearchHint":"Search skills.sh to discover and install skills for your agent.","desktop.visibleInModelPrompt":"Visible in model prompt — click to disable","desktop.hiddenFromModelPrompt":"Hidden from model prompt — click to enable","desktop.dormant":"Dormant","desktop.hiddenButInvocable":"Hidden from the model, still manually invocable","desktop.check":"Check","desktop.upToDate":"Up to date","desktop.automaticChecksUnavailable":"Automatic checks unavailable","desktop.checkFailed":"Check failed","desktop.name":"Name","desktop.description":"Description","desktop.selectSkill":"Select a skill","desktop.checkUpdates":"Check updates","desktop.updateAvailable":"Update available","desktop.installed":"Installed","desktop.updatesCount":"{count} update{suffix}","desktop.downloadFile":"Download file","desktop.loadingFile":"Loading...","desktop.noChanges":"No changes","desktop.unchangedLines":"... {count} unchanged lines ...","desktop.lines":"{count} lines","desktop.mentionFile":"Mention file","desktop.mentionSelectedLines":"Mention selected lines {start}-{end}","desktop.source":"Source","desktop.diff":"Diff","desktop.enableWordWrap":"Enable word wrap","desktop.disableWordWrap":"Disable word wrap","desktop.wrap":"wrap","desktop.code":"Code","desktop.preview":"Preview","desktop.raw":"Raw","desktop.htmlPreview":"HTML preview","desktop.image":"image","desktop.audio":"audio","desktop.docxPreview":"docx preview","desktop.failedToLoadImage":"Failed to load image","desktop.failedToLoadAudio":"Failed to load audio","desktop.docxTooLargeForPreview":"DOCX too large for preview (>10MB)","desktop.previewFile":"Preview {file}","desktop.branches":"Branches","desktop.noActiveSession":"No active session","desktop.sessionHasNoBranches":"No branches yet — use Edit from here or Fork on a message to create one","desktop.copyMessage":"Copy message","desktop.copyPlainText":"Copy as plain text","desktop.createTaskFromMessage":"Create task from message","desktop.editFromHere":"Edit from here — branches within this session","desktop.creatingNewSession":"Creating new session…","desktop.newSessionFromHere":"New session — creates an independent copy from here","desktop.estimatedStreamingTokenCount":"Estimated token count while streaming","desktop.tokensPerSecond":"{count} t/s","desktop.thinkingContentUnavailable":"Thinking content unavailable","desktop.loadingThinking":"Loading thinking...","desktop.conversationCompacted":"Conversation compacted","desktop.compactionSummaryDescription":"The conversation history before this point was compacted into the following summary:","desktop.noSummary":"(no summary)","desktop.fileContext":"File context: {context}","desktop.readFilesCount":"{count} read","desktop.modifiedFilesCount":"{count} modified","desktop.modifiedFiles":"Modified files","desktop.readFiles":"Read files","desktop.hiddenExtensionMessage":"hidden extension message","desktop.noMessage":"(no message)","desktop.showExtensionMessage":"Show extension message","desktop.copied":"Copied","desktop.copy":"Copy","desktop.collapse":"Collapse","desktop.expand":"Expand","desktop.hideDetails":"Hide details","desktop.showDetails":"Show details","desktop.before":"Before","desktop.after":"After","desktop.noOutput":"(no output)","desktop.extension":"extension","desktop.assistant":"assistant","desktop.favorites":"Favorites","desktop.favorite":"Favorite","desktop.unfavorite":"Unfavorite","desktop.processStepThinking":"Thinking","desktop.processStepFileRead":"Read","desktop.processStepFileCreate":"Create","desktop.processStepFileEdit":"Edit","desktop.processStepFileDelete":"Delete","desktop.processStepSearch":"Search","desktop.processStepFind":"Find","desktop.processStepList":"List","desktop.processStepRead":"Read","desktop.processStepFetch":"Fetch","desktop.processStepDelete":"Delete","desktop.processStepCopy":"Copy","desktop.processStepCommand":"Run","desktop.processStepTool":"Tool","desktop.processStepTodo":"Todo","desktop.processStepArtifact":"Artifact","desktop.processStepCompaction":"Compaction","desktop.processStepError":"Error","desktop.processWorking":"Working...","desktop.processUsed":"Used {summary}","desktop.processToolCount":"{count} tool","desktop.processToolsCount":"{count} tools","desktop.processFailedCount":" ({failed} failed)","desktop.processThoughtCount":"{count} thought","desktop.processThoughtsCount":"{count} thoughts","desktop.processThoughtDone":"Thought {duration}s","desktop.processThoughtDoneNoDuration":"Thought","desktop.processCustomCount":"{count} event","desktop.processCustomsCount":"{count} events","desktop.processCompleted":"Process complete","desktop.processOutput":"Process output","desktop.processTabMode":"Tab mode","desktop.processTimelineMode":"Timeline mode","desktop.processFailedStep":"failed","desktop.markdownPreviewAvailableAfterStreaming":"Preview available after streaming","desktop.markdownPreviewMermaidDiagram":"Preview Mermaid diagram","desktop.markdownInvalidMermaidDiagram":"Invalid Mermaid diagram","desktop.markdownRenderingMermaidDiagram":"Rendering Mermaid diagram","desktop.openMermaidViewer":"Open Mermaid viewer","desktop.mermaidDiagram":"Mermaid diagram","desktop.mermaidViewer":"Mermaid diagram viewer","desktop.zoomPanHint":"Drag to pan \xb7 Scroll to zoom","desktop.selectText":"Select text","desktop.zoomOut":"Zoom out","desktop.resetZoom":"Reset to 100% (fit)","desktop.zoomIn":"Zoom in","desktop.fitToViewport":"Fit to viewport","desktop.quoteReply":"Quote reply","desktop.quoteReplyHint":"Click to quote reply","desktop.openFile":"Open","desktop.queueRecoveryTitle":"Recover queued messages","desktop.queueImportTitle":"Imported queued messages","desktop.queueRecoveryDescription":"These messages were saved before the previous server session ended. Choose what to re-queue; nothing is sent automatically.","desktop.queueImportDescription":"Choose which imported messages to re-queue. Nothing is sent automatically.","desktop.selectAll":"Select all","desktop.selectNone":"Select none","desktop.import":"Import","desktop.queueImages":"Image attachment","desktop.queueNoText":"(image-only message)","desktop.queueExported":"Exported {count} message(s)","desktop.queueImportEmpty":"No valid queued messages found","desktop.queueImported":"Imported {count} message(s) for review","desktop.dismiss":"Dismiss","desktop.discard":"Discard","desktop.requeue":"Re-queue","desktop.requeueAndContinue":"Re-queue & continue","desktop.markdownPlainText":"text","desktop.hideTaskBoard":"Hide task board","desktop.showTaskBoard":"Show task board","tasks.actionArchive":"Archive","tasks.actionCancel":"Cancel","tasks.actionEdit":"Edit","tasks.actionMerge":"Merge","tasks.stashDone":"Changes stashed successfully","tasks.actionRequeue":"Re-queue","tasks.actionRetry":"Retry","tasks.actionReturn":"Return with feedback","tasks.actionStart":"Start","tasks.actionComplete":"Complete","tasks.actionUnarchive":"Unarchive","tasks.actionViewSession":"View session","tasks.allFolders":"All projects","tasks.archiveAllDone":"Archive all","tasks.badgeCleanupFailed":"cleanup failed","tasks.badgeWorktreeKept":"worktree kept","tasks.beta":"Beta","tasks.cancelDescription":"The task will stop. You can leave a reason for whoever requeues it later (optional).","tasks.cancelKeep":"Keep task","tasks.cancelReasonLabel":"Cancel reason (optional)","tasks.cancelReasonPlaceholder":"e.g. wrong approach, requirements changed…","tasks.cancelSubmit":"Cancel task","tasks.cancelTitle":"Cancel task","tasks.changedFiles":"Changed files","tasks.colAttention":"Attention","tasks.colDone":"Done","tasks.colInProgress":"In progress","tasks.colTodo":"Todo","tasks.delete":"Delete","tasks.deleteConfirm":"Delete","tasks.deleteTemplate":"Delete template","tasks.deleteWorktree":"Also delete the worktree","tasks.diff":"Diff","tasks.dropToStart":"Drop to start","tasks.editTitle":"Edit task","tasks.empty":"No tasks yet","tasks.emptyColAttention":"Nothing needs you","tasks.emptyColDone":"Nothing completed yet","tasks.emptyColInProgress":"Nothing running","tasks.emptyColTodo":"No pending tasks","tasks.emptyHint":"Create a task and the board walks it through execution — start it and a worktree branch runs the agent to completion.","tasks.errorView":"View","tasks.event_archived":"archived","tasks.event_canceled":"canceled","tasks.event_created":"created","tasks.event_failed":"failed","tasks.event_interrupted":"interrupted","tasks.event_merge_failed":"merge failed","tasks.event_merge_requested":"merge requested","tasks.event_merged":"merged","tasks.event_merging":"merging","tasks.event_preflight_failed":"preflight failed","tasks.event_preflight_passed":"preflight passed","tasks.event_preflight_start":"preflight running","tasks.event_preparing":"preparing","tasks.event_queued":"queued","tasks.event_recovered":"recovered","tasks.event_requeued":"re-queued","tasks.event_return_feedback":"feedback","tasks.event_returned":"returned","tasks.event_review":"review","tasks.event_started":"started","tasks.event_unarchived":"unarchived","tasks.event_updated":"updated","tasks.fieldProject":"Project","tasks.fieldPrompt":"Prompt","tasks.fieldPromptPlaceholder":"Describe the work the agent should complete…","tasks.fieldTitle":"Title","tasks.fieldTitlePlaceholder":"Short title for the task","tasks.filter":"Filter","tasks.loading":"Loading…","tasks.mergeAutoMessage":"Let the agent write the commit message","tasks.mergeConfirm":"Merge","tasks.mergeDeleteWorktree":"Delete the worktree after merging","tasks.mergeManualMessage":"Provide a commit message","tasks.mergeMessagePlaceholder":"Commit message…","tasks.mergeStrategyMerge":"Merge commit","tasks.mergeStrategySquash":"Squash","tasks.mergeTitle":"Merge task","tasks.completeDeleteWorktree":"Delete worktree on completion","tasks.completeDescription":"This task produced no file changes, so there is nothing to merge. Confirm to mark it done.","tasks.completeSubmit":"Complete","tasks.completeTitle":"Complete task","tasks.followUpPlaceholderRequeue":"Note for the agent (optional)…","tasks.followUpPlaceholderRetry":"Note for the agent (optional)…","tasks.actionAddNote":"Note (optional)","tasks.restartDescription":"The note is injected into the next run's prompt (optional).","tasks.restartTitleRequeue":"Requeue","tasks.restartTitleRetry":"Retry","tasks.planReviewTitle":"Plan complete","tasks.planReviewDescription":"The plan-mode analysis has finished. Confirm to execute the plan, send suggestions for another pass, or exit plan mode.","tasks.planReviewShowPlan":"View plan","tasks.planReviewHidePlan":"Collapse plan","tasks.planReviewExecute":"Execute","tasks.planReviewExecutePrompt":"Please execute the following plan:\n\n{plan}","tasks.planReviewSuggest":"Suggest","tasks.planReviewSendFeedback":"Send suggestions","tasks.planReviewFeedbackLabel":"Suggestions (sent back to the agent to refine the plan)","tasks.planReviewFeedbackPlaceholder":"e.g. add risk analysis first, split into smaller steps…","tasks.planReviewExit":"Exit plan mode","tasks.metaCommit":"Commit","tasks.metaCreated":"Created","tasks.metaProject":"Project","tasks.new":"New task","tasks.newTitle":"New task","tasks.noDiff":"No diff available","tasks.noEvents":"No events yet","tasks.notifyFailed":"{title} failed","tasks.notifyReview":"{title} is ready for review","tasks.returnPlaceholder":"Feedback for the agent…","tasks.returnSubmit":"Send back","tasks.save":"Save","tasks.saveAsTemplate":"Save as template","tasks.sessionFile":"Session file","tasks.sessionHint":"The task's agent conversation is stored like any other session. Open it from the sessions list to read or continue it.","tasks.sessionId":"Session id","tasks.sessionTitle":"Task session","tasks.settingsAutoProcess":"Auto-process queued tasks","tasks.settingsDeleteWorktree":"Delete worktree after merge (default)","tasks.settingsInitCommand":"Init command (run in the worktree before the agent)","tasks.settingsInitPlaceholder":"e.g. pnpm install","tasks.settingsMaxConcurrent":"Max concurrent tasks (0 = unlimited)","tasks.settingsMergeStrategy":"Merge strategy","tasks.settingsNoProject":"Create a task first to pick a project.","tasks.settingsPreflightCommand":"Preflight command (acceptance check)","tasks.settingsPreflightPlaceholder":"e.g. npm test","tasks.settingsProject":"Project","tasks.settingsReset":"Reset to defaults","tasks.settingsStagePrompts":"Stage prompts (extra instructions)","tasks.settingsTitle":"Task settings","tasks.showArchived":"Show archived","tasks.showCanceled":"Show canceled","tasks.stage_merge":"Merge","tasks.stage_retry":"Retry","tasks.stage_return":"Return","tasks.stage_work":"Work","tasks.startAll":"Start all","tasks.statusAwaitingInput":"Awaiting input","tasks.statusCanceled":"Canceled","tasks.statusDone":"Done","tasks.statusFailed":"Failed","tasks.statusInterrupted":"Interrupted","tasks.statusMerging":"Merging","tasks.statusPreparing":"Preparing","tasks.statusQueued":"Queued","tasks.statusReview":"Review","tasks.statusRunning":"Running","tasks.statusTodo":"Todo","tasks.templateNamePlaceholder":"Template name…","tasks.templates":"Templates","tasks.timeline":"Timeline","tasks.title":"Tasks","tasks.attentionBadge":"needs you","sidebar.checking":"Checking…","sidebar.open":"Open","sidebar.cancel":"Cancel","sidebar.openRepoRoot":"Open repo root","sidebar.openRepoRootTitle":"Open the repository root to manage worktrees.","sidebar.gitRepoRootOnly":"Git repo root only","sidebar.gitRepoRootOnlyTitle":"Worktrees are available in Git repository roots.","sidebar.worktrees":"Worktrees...","sidebar.checkingWorktrees":"Checking worktrees for this directory.","sidebar.filterWorktrees":"Filter worktrees…","sidebar.noMatchingWorktrees":"No matching worktrees","sidebar.switchWorktree":"Switch worktree","sidebar.switchWorktreeTitle":"Switch worktree: {path}","sidebar.main":"main","sidebar.forceRemoveCheckout":"Uncommitted changes. Force remove checkout?","sidebar.force":"Force","sidebar.createWorktreeTitle":"Create a worktree checkout for a branch","sidebar.newWorktree":"New worktree…","sidebar.branchName":"branch name","sidebar.creating":"Creating…","sidebar.create":"Create","sidebar.uploadFilesTitle":"Upload files to project root","sidebar.uploadFiles":"Upload files","sidebar.refreshExplorer":"Refresh explorer","sidebar.searchSessions":"Search all conversations...","sidebar.toggleSessionSearch":"Search conversations","sidebar.sessionSearching":"Searching...","sidebar.sessionSearchEmpty":"No matching conversations","sidebar.sessionSearchCount":"{count} matching conversations","sidebar.sessionSearchPartial":"Search limit reached. Results may be incomplete.","sidebar.sessionSearchFailed":"Could not search conversations","sidebar.changedFiles":"{count} changed files","sidebar.loading":"Loading...","sidebar.noSessions":"No sessions found","sidebar.agentRunning":"Agent running…","sidebar.newActivity":"New activity","sidebar.newSessionActivity":"New session activity","sidebar.deleteSession":"Delete {title}?","sidebar.rename":"Rename","sidebar.delete":"Delete","sidebar.deleteWithShiftClick":"Delete (Shift+click to delete without confirmation)","sidebar.expandSubagents":"Expand subagents","sidebar.collapseSubagents":"Collapse subagents","sidebar.messagesCount":"{count} msgs","sidebar.worktreePath":"Worktree: {path}","sidebar.removeWorktreeTitle":"Remove worktree checkout {path}; the branch is kept","files.modified":"Modified","files.added":"Added","files.deleted":"Deleted","files.renamed":"Renamed","files.untracked":"Untracked","files.conflict":"Conflict","files.newlyUploaded":"Newly uploaded","files.containsChangedFiles":"Contains changed files","files.insertPath":"Insert path into chat","files.mention":"mention","files.download":"Download file","files.dismissError":"Dismiss error","files.addUploadedFile":"Add uploaded file to chat","files.addAllUploadedFiles":"Add all uploaded files to chat","files.dismissUploadResults":"Dismiss upload results","files.loading":"Loading files...","files.noFiles":"No files found","files.explorer":"Explorer","files.changedCount":"{count} files","files.changeStats":"{count} changed files, {additions} lines added, {deletions} lines deleted","files.conflictSummary":"{count} file{countSuffix} already exist: {files}","files.cannotReplace":"Cannot replace: {files}","files.replace":"Replace","files.skipExisting":"Skip existing","files.cancel":"Cancel","files.checking":"Checking files","files.uploading":"Uploading, {progress}%","files.edit":"Edit","files.save":"Save","files.saveHint":"Save (Cmd/Ctrl+S)","files.cancelEdit":"Cancel edit","files.saveFailed":"Save failed: {error}","files.unsavedChanges":"Discard unsaved changes?","files.externalModified":"This file was modified outside the editor. Reload to load the latest version.","files.reload":"Reload","files.reloadOverwriteConfirm":"Overwrite your unsaved edits with the version on disk?","files.newFile":"New file","files.newFolder":"New folder","files.delete":"Delete","files.promptFileName":"File name","files.promptFolderName":"Folder name","files.confirmDeleteFile":'Delete "{name}"? This cannot be undone.',"files.confirmDeleteDirectory":'Delete "{name}" and all its contents? This cannot be undone.',"chat.loadingSession":"Loading session...","chat.runningTool":"Running tool...","chat.generatingToolInput":"Generating parameters...","chat.runningNamedTool":"Running {name}...","chat.runningTools":"Running {names}...","chat.runningToolsMore":"Running {names} (+{count})...","chat.waitingModel":"Waiting for model...","chat.runningCommand":"Running command...","chat.thinking":"Thinking...","chat.processDetails":"Process details","chat.message":"message","chat.messages":"messages","chat.toolCall":"tool call","chat.toolCalls":"tool calls","chat.collapseProcess":"Collapse process details","chat.expandProcess":"Expand process details","chat.filesWritten":"Files changed","chat.openWrittenFile":"Open {name}","chat.loadEarlier":"Scroll up to load earlier messages","chat.extensionRequest":"extension request","chat.extensionExpiresIn":"expires in {seconds}s","chat.extensionPending":"Awaiting response","chat.extensionCollapse":"Collapse","chat.extensionExpand":"Expand","chat.cancel":"Cancel","chat.confirm":"Confirm","chat.submit":"Submit","chat.extensionInput":"Extension terminal input","chat.extensionPanel":"Extension panel","chat.extensionWidgets":"Extension widgets","chat.extensionWidgetAbove":"Above editor widget","chat.extensionWidgetBelow":"Below editor widget","chat.extensionWidgetLine":"{count} line","chat.extensionWidgetLines":"{count} lines","chat.close":"Close","chat.queued":"Queued \xb7 {count}","chat.recall":"Recall to input","chat.recallTitle":"Remove all queued messages and put them back into the input box for editing","chat.retrying":"Retrying ({attempt}/{max})…","chat.loadingCommands":"Loading commands...","chat.slashCommands":"Slash commands \xb7 {label}","chat.tabEnter":"Tab / Enter","chat.noCommands":"No extension, prompt, or skill commands found","chat.match":"1 match","chat.matches":"{count} matches","chat.command":"1 command","chat.commands":"{count} commands","chat.loadingFiles":"Loading files...","chat.files":"Files \xb7 {label}{hint}","chat.searching":"Searching…","chat.noMatchingFiles":"No matching files","chat.searchingAll":" \xb7 searching all files…","chat.indexTruncated":" \xb7 index truncated","chat.steerPlaceholder":"Steer now / queue follow-up...","chat.agentPlaceholder":"Agent is running…","chat.messagePlaceholder":"Message… Type / for commands, @ for files","chat.steer":"Steer","chat.followUp":"Follow-up","chat.steerHint":"Interrupt the current run and inject this message now","chat.followUpHint":"Queue this message after the agent finishes","chat.inputHistory":"Input history","chat.modelError":"Model error","chat.modelScopeWarning":"Model scope warning","chat.modelScopeWarnings":"Model scope warnings","chat.send":"Send","chat.askSelection":"Ask about selected text","chat.askInCurrent":"Ask here","chat.askInNewChat":"Ask in new chat","chat.newQuoteChat":"New chat about selected text","chat.quoteIntro":"About this passage:","chat.quoteQuestion":"My question:","chat.quoteForkFailed":"Unable to create a branch from this message.","chat.attachImage":"Attach image","chat.previewImage":"Preview image","chat.filterModels":"Filter models…","chat.noMatchingModels":"No matching models","chat.moreControls":"More controls","chat.collapseControls":"Collapse controls","chat.shell":"Shell","terminal.title":"Terminal","terminal.tabLabel":"Terminal: {name}","terminal.open":"Open workspace terminal","terminal.close":"Terminate terminal","terminal.restart":"Restart terminal","terminal.reconnect":"Reconnect terminal","terminal.connecting":"Connecting","terminal.ready":"Connected","terminal.exited":"Terminal closed","terminal.error":"Connection error","terminal.exitCode":"Process exited with code {code}","chat.outputLocal":"output stays local","chat.outputModel":"output sent to model","chat.chatOnly":"Chat only","chat.readOnlyTools":"{count} read-only built-in tools","chat.builtInTools":"{count} built-in tools","chat.allBuiltInTools":"All built-in tools","chat.changeReasoning":"Change reasoning level: {level}","chat.changeReasoningLabel":"Change reasoning level","chat.changeToolPreset":"Change tool preset","chat.stopCompaction":"Stop compaction","chat.compactContext":"Compact context","chat.compacting":"Compacting…","chat.compact":"Compact","chat.stopAgent":"Stop agent","chat.stop":"Stop","chat.disableSound":"Disable completion sound","chat.enableSound":"Enable completion sound","chat.thinkingUseDefault":"Use pi default","chat.thinkingOff":"Reasoning off","chat.thinkingMinimal":"Minimal reasoning","chat.thinkingLow":"Low reasoning","chat.thinkingMedium":"Medium reasoning","chat.thinkingHigh":"High reasoning","chat.thinkingXhigh":"Extra-high reasoning","chat.thinkingMax":"Max reasoning","chat.builtIn":"Built-in","chat.extensions":"Extensions","chat.prompts":"Prompts","chat.skills":"Skills","chat.dormant":"dormant","chat.commandCompact":"Compress context, optionally with instructions","chat.commandReload":"Reload extensions, skills, prompts, and tools","chat.commandName":"Set the session display name","chat.commandSession":"Show session message, token, and cost stats","chat.commandCopy":"Copy the last assistant message","chat.commandClone":"Clone the current branch into a new session","chat.compacted":"Compacted","chat.imageNotSupportedTitle":"Images may not be sent","chat.imageNotSupportedBody":"The selected model ({model}) does not support image input. The attached images will likely be ignored.","chat.tokensSaved":"{saved} saved","i18n.copy":"Copy","i18n.copied":"Copied","i18n.save":"Save","i18n.saving":"Saving…","i18n.saved":"Saved","i18n.remove":"Remove","i18n.removing":"Removing…","i18n.delete":"Delete","i18n.loading":"Loading...","i18n.search":"Search","i18n.refresh":"Refresh","i18n.update":"Update","i18n.updating":"Updating...","i18n.check":"Check","i18n.install":"Install","i18n.installing":"Installing...","i18n.noResults":"No results","i18n.searchProviders":"Search providers…","i18n.noProviders":"No providers match","i18n.newModel":"new model","i18n.addProvider":"Add provider","i18n.selectProviderModel":"Select a provider or model","i18n.visibleInPrompt":"Visible in model prompt — click to disable","i18n.hiddenFromPrompt":"Hidden from model prompt — click to enable","i18n.dormant":"Dormant","i18n.hiddenButInvocable":"Hidden from model, still manually invocable","i18n.skillSearchPlaceholder":"e.g. react, testing, deploy","i18n.searching":"Searching…","i18n.noSkills":"No skills found","i18n.checkUpdates":"Check updates","i18n.updates":"updates","i18n.noResolvedResources":"No resolved resources","i18n.enablePackage":"Enable package","i18n.disablePackage":"Disable package","i18n.filtered":"filtered","i18n.openSessionToReload":"Open a session to reload","i18n.notFound":"Not found","i18n.noPlugins":"No plugins configured","trust.resourcesNotLoaded":"Restricted mode","trust.trustProject":"Trust project","trust.trusting":"Trusting...","trust.cancel":"Cancel","trust.dialogTitle":"Trust this project?","trust.dialogBody":"Project resources can run local code. Trust only projects whose contents you know.","trust.skillsNotLoaded":"Project skills are not loaded because this project is not trusted.","trust.pluginsNotLoaded":"Project plugins are not loaded because this project is not trusted.","trust.projectScopeUnavailable":"Project installs are unavailable while project resources are not loaded.","i18n.creatingSession":"Creating new session…","i18n.creating":"Creating…","i18n.subscription":"Subscription","i18n.subscriptions":"Subscriptions","i18n.customEndpoint":"Custom endpoint format","i18n.noChanges":"No changes","i18n.branches":"Branches","i18n.noActiveSession":"No active session","i18n.noBranches":"This session has no branches","i18n.source":"Source","i18n.preview":"Preview","i18n.diff":"Diff","i18n.downloadFile":"Download file","i18n.liveSync":"Live sync active","i18n.notWatching":"Not watching","i18n.fileViewMode":"File view mode","i18n.compareHead":"Compare working tree with HEAD","i18n.mentionSelectedLines":"Mention selected lines","i18n.disableWrap":"Disable word wrap","i18n.enableWrap":"Enable word wrap","i18n.htmlPreview":"HTML preview","i18n.previewFile":"Preview {file}","i18n.invalidMermaid":"Invalid Mermaid diagram","i18n.renderingMermaid":"Rendering Mermaid diagram","i18n.previewAfterStreaming":"Preview available after streaming","i18n.showMermaidSource":"Show Mermaid source","i18n.previewMermaid":"Preview Mermaid diagram","i18n.openMermaidViewer":"Open diagram viewer","i18n.mermaidViewer":"Mermaid diagram viewer","i18n.mermaidDiagram":"Mermaid diagram","i18n.zoomOut":"Zoom out","i18n.zoomIn":"Zoom in","i18n.fitToWidth":"Fit to width","models.discoveryFetching":"Importing models…","models.discoveryFetch":"Import models…","models.discoveryFilterPlaceholder":"Filter {count} models…","models.discoveryFilter":"Filter upstream models","models.discoverySelectShown":"Select shown","models.discoveryNoMatches":"No matching models.","models.discoveryAdded":"added","models.discoveryShowing":"Showing first {shown} of {total}","models.discoveryFetched":"{count} models fetched","models.discoveryAddSelected":"Add selected","models.discoveryAddSelectedCount":"Add selected ({count})","models.catalogSource":"source: models.dev ↗","models.catalogFilling":"Filling details…","models.catalogFill":"Fill model details","models.catalogFilled":"{count} fields filled","models.catalogNoEmptyFields":"No empty fields to fill","models.catalogNoExactMatch":"No exact models.dev match","models.catalogPriceProvider":"Price matched Provider {provider}","models.catalogPriceBaseUrl":"Price matched Base URL to {provider}","models.catalogPriceConsensus":"Price agreed by {support}/{total} records","models.catalogPriceUnreliable":"No reliable price found","models.catalogUndo":"Undo","models.capabilities":"Capabilities","models.reasoning":"Reasoning / thinking","models.imageInput":"Image input","models.modelSpecs":"Model specifications","models.contextWindow":"Context window (tokens)","models.maxOutputTokens":"Max output tokens","models.costPerMillion":"Cost per million tokens","models.costInput":"Input","models.costOutput":"Output","models.costCacheRead":"Cache read","models.costCacheWrite":"Cache write","models.notProvided":"Not provided","models.editCosts":"Edit prices","models.finishEditingCosts":"Done","models.costAllRequired":"Enter a valid non-negative price; blank fields are saved as 0.","models.advancedSettings":"Advanced settings","models.providerDefaults":"Using provider defaults","models.headersSummary":"Headers: {count}","models.compatSummary":"Compatibility: {count}","models.thinkingSummary":"Thinking levels: {count}","models.apiOverride":"API override","models.headers":"Headers","models.headersHelp":"Added to this model's requests and overrides provider headers.","models.compatibility":"Compatibility","models.deepSeekThinkingCompat":"DeepSeek thinking compatibility","models.developerRole":"Use the developer role for the system prompt","models.thinkingLevelMap":"Thinking level map","models.clearAll":"Clear all","i18n.testingModel":"Testing model connection...","i18n.connected":"Connected","i18n.failed":"Failed","i18n.test":"Test","i18n.testConnection":"Test model connection","i18n.provider":"Provider","i18n.model":"Model","i18n.providerName":"Provider name","i18n.rename":"Rename","i18n.default":"Default","i18n.disabled":"Disabled","i18n.noResources":"No resources","i18n.unknown":"Unknown","i18n.installedVersion":"installed {version}","i18n.configuredVersion":"configured {version}","i18n.extensions":"Extensions","i18n.prompts":"Prompts","i18n.themes":"Themes","i18n.resourceCount":"{count} {label}","i18n.extensionShort":"ext","i18n.skillShort":"skills","i18n.promptShort":"prompts","i18n.themeShort":"themes","i18n.custom":"Custom","i18n.clearAll":"clear all","i18n.connectedSuccessfully":"Connected successfully.","i18n.notConnected":"not connected","i18n.configured":"configured","i18n.notConfigured":"not configured","i18n.openingBrowser":"Opening browser…","i18n.submit":"Submit","i18n.login":"Login","i18n.relogin":"Re-login","i18n.disconnect":"Disconnect","i18n.networkError":"Network error","i18n.continuing":"Continuing…","i18n.skills":"Skills","i18n.plugins":"Plugins","i18n.addSkill":"Add skill","i18n.addPlugin":"Add plugin","i18n.selectSkill":"Select a skill","i18n.selectPackage":"Select a package","i18n.updateAvailable":"Update available","i18n.upToDate":"Up to date","i18n.automaticChecksUnavailable":"Automatic checks unavailable","i18n.checkFailed":"Check failed","i18n.installed":"Installed","i18n.status":"Status","i18n.version":"Version","i18n.package":"Package","i18n.resources":"Resources","i18n.installedPath":"Installed path","i18n.cwd":"CWD","i18n.resolvedResources":"Resolved Resources","i18n.reloadSession":"Reload session","i18n.reloading":"Reloading...","i18n.packageRemoved":"Package removed.","i18n.packageInstalled":"Package installed.","i18n.packageUpdated":"Package updated.","i18n.packagesUpdated":"Packages updated.","i18n.updateAllPlugins":"Update all","i18n.updateAllPluginsHint":"Updates all configured plugins","i18n.packageDisabled":"Package disabled.","i18n.packageEnabled":"Package enabled.","i18n.sessionReloaded":"Session reloaded.","i18n.thinking":"Thinking","i18n.largeMessageReveal":"Message content is very large ({size}). Click to view as plain text — markdown rendering is disabled to keep the page responsive.","i18n.loadingThinking":"Loading thinking...","i18n.copyMessage":"Copy message","i18n.editFromHere":"Edit from here","i18n.editFromHereTitle":"Edit from here — branches within this session","i18n.newSession":"New session","i18n.newSessionTitle":"New session — creates an independent copy from here","i18n.estimatedTokens":"Estimated token count while streaming","i18n.noOutput":"(no output)","i18n.openImage":"Open image","i18n.noSummary":"(no summary)","i18n.conversationCompacted":"Conversation compacted","i18n.compactionDescription":"The conversation history before this point was compacted into the following summary:","i18n.fileContext":"File context: {details}","i18n.readFiles":"Read files","i18n.modifiedFiles":"Modified files","i18n.hiddenExtensionMessage":"hidden extension message","i18n.noMessage":"(no message)","i18n.showExtensionMessage":"Show extension message","i18n.collapse":"Collapse","i18n.expand":"Expand","i18n.hideDetails":"Hide details","i18n.showDetails":"Show details","i18n.thinkingUnavailable":"Thinking content unavailable","i18n.before":"Before","i18n.after":"After","i18n.sessionComplete":"Session complete","i18n.taskFinished":"Task finished.","i18n.attentionNeeded":"Pi needs your attention","i18n.extensionInputNeeded":"An extension is waiting for your input."}}),i({id:"zh-CN",label:"简体中文",messages:{"i18n.close":"关闭","i18n.cancel":"取消","i18n.checking":"正在检查…","desktop.settings":"设置","desktop.settingsSections":"设置分类","desktop.closeSettings":"关闭设置","desktop.display":"显示","desktop.server":"服务器","desktop.serverCurrent":"当前服务器","desktop.serverSwitch":"切换服务器","desktop.serverSwitchHint":"打开 Pi Web 桌面端连接管理:可切换已保存的服务器,或添加新的服务器地址(URL + 密码)。","desktop.reloadPage":"重新加载页面","desktop.serverHintTitle":"想连远程服务器,或设置访问密码?","desktop.serverHintBody":"桌面端已默认直连本机服务,打开即用。需要换服务器、从手机连接或给本机加访问密码,都在右上角这个图标里。","desktop.serverHintAction":"打开连接管理","desktop.serverHintDismiss":"知道了","desktop.chat":"聊天","desktop.models":"模型","desktop.skills":"技能","desktop.plugins":"插件","desktop.proxy":"代理","desktop.proxyEnable":"启用代理","desktop.proxyProtocol":"协议","desktop.proxyHost":"主机","desktop.proxyPort":"端口","desktop.proxyUsername":"用户名(可选)","desktop.proxyPassword":"密码(可选)","desktop.proxyNoProxy":"绕过代理(逗号分隔,可选)","desktop.proxySave":"保存","desktop.proxySaving":"保存中…","desktop.proxyTest":"测试连接","desktop.proxyTesting":"测试中…","desktop.proxySaved":"代理配置已保存","desktop.proxySaveFailed":"保存失败","desktop.proxyTestSuccess":"连接成功","desktop.proxyTestFailed":"连接失败","desktop.proxyUnsaved":"有未保存的更改","desktop.features":"功能","desktop.logs":"日志","desktop.snippets":"片段","desktop.snippetsDesc":"常用代码/文本片段,输入 # 号即可补全插入","desktop.snippetNew":"新增片段","desktop.snippetName":"名称","desktop.snippetContent":"内容","desktop.snippetSave":"保存","desktop.snippetEdit":"编辑","desktop.snippetDelete":"删除","desktop.snippetEmpty":"还没有片段,先新增一个吧。","desktop.snippetNameRequired":"请输入片段名称","desktop.snippetHint":"在输入框输入 #名称 即可弹出补全,Enter 展开为片段内容。","desktop.logsAllCodes":"全部错误码","desktop.logsAllLevels":"全部级别","desktop.logsAllSources":"全部来源","desktop.logsSearch":"搜索错误日志","desktop.logsClear":"清空日志","desktop.logsCopy":"复制日志","desktop.logsEmpty":"暂无错误日志","desktop.mcpVisionTitle":"DeepSeek Vision 视觉模块","desktop.mcpVisionDesc":"deepseek-vision 视觉模块(图像分析 / OCR)的独立配置,MCP 注册与模型配置均可在此修改。","desktop.mcpVisionRegistered":"已注册","desktop.mcpVisionNotRegistered":"未注册","desktop.mcpVisionRegistration":"MCP 注册","desktop.mcpVisionCommand":"命令","desktop.mcpVisionCommandRequired":"命令不能为空","desktop.mcpVisionLifecycle":"生命周期","desktop.mcpVisionTransport":"传输方式","desktop.mcpVisionTransportFixed":"stdio(固定)","desktop.mcpVisionSaveReg":"保存注册","desktop.mcpVisionSavedReg":"注册已保存 — 新开会话或重启 pi 后生效","desktop.mcpVisionRemove":"从 MCP 配置移除","desktop.mcpVisionRemoved":"已移除注册","desktop.mcpVisionModelConfig":"模型配置","desktop.mcpVisionModelNote":"模型配置保存后立即写入 .env,点击“重启服务器”即可立即生效。","desktop.mcpVisionProvider":"Provider","desktop.mcpVisionBaseUrl":"Base URL","desktop.mcpVisionApiKey":"API Key","desktop.mcpVisionModel":"视觉模型","desktop.mcpVisionMaxTokens":"最大输出 tokens","desktop.mcpVisionSaveModel":"保存模型配置","desktop.mcpVisionSavedModel":"模型配置已保存","desktop.mcpVisionNameReserved":"该名称由内置的 DeepSeek Vision 配置使用,请换一个名称。","desktop.mcpVisionRestart":"重启服务器(立即生效)","desktop.mcpVisionRestarting":"重启中…","desktop.mcpVisionRestarted":"已发送重启指令,稍候生效","desktop.mcpVisionRestartTitle":"重启 deepseek-vision 服务器,使 .env 配置立即生效","desktop.mcpVisionRestartNoSession":"请先打开一个会话,才能重启服务器","desktop.applyNow":"立即生效","desktop.applyNowApplying":"重载中…","desktop.applyNowDone":"已重载,改动已生效","desktop.applyNowTitle":"重载当前会话,使改动立即生效(无需重启 pi)","desktop.applyNowNoSession":"请先打开一个会话,才能立即生效","desktop.featuresDesc":"管理 Pi Web 的可选功能。关闭后相关入口将不再显示。","desktop.featuresTasksBoard":"任务看板","desktop.featuresTasksBoardDesc":"在顶部工具栏显示任务看板入口,用于管理多项目任务。","desktop.featuresLoading":"加载中…","desktop.featuresSaving":"保存中…","desktop.featuresCollabDefault":"默认任务模式","desktop.featuresCollabDefaultDesc":"新建对话默认的协作模式(常规 / 计划 / 目标)","desktop.featuresTokenDefault":"默认运行档位","desktop.featuresTokenDefaultDesc":"新建对话默认的档位(轻量 / 均衡 / 交付)","desktop.featuresApprovalDefault":"默认工具权限","desktop.featuresApprovalDefaultDesc":"新建对话默认的工具权限(批准 / 自动 / Yolo)","desktop.usage":"用量","desktop.usageSession":"当前会话","desktop.usageGlobal":"全局","desktop.usageContext":"上下文占用 {used} / {window} tokens","desktop.usageContextHint":"当前会话实时上下文占用","desktop.usageNoSessionData":"当前会话暂无用量数据","desktop.usageNoSession":"未打开会话","desktop.usageTotal":"预估总用量","desktop.usageMessages":"消息数","desktop.usageMessagesHint":"全部会话","desktop.usageSessions":"个会话","desktop.usageDaily":"每日用量趋势","desktop.usageTopSessions":"用量最高的会话","desktop.usageNoData":"暂无数据","desktop.mcp":"MCP","desktop.mcpServers":"MCP 服务器","desktop.mcpAddServer":"添加服务器","desktop.mcpNewServer":"新增 MCP 服务器","desktop.mcpEditServer":'编辑 MCP 服务器 "{name}"',"desktop.mcpRestartNote":"MCP 服务器在 pi 启动时加载,此处修改需重启 pi 后生效。","desktop.mcpEmpty":"尚未配置 MCP 服务器 — 添加一个即可向 Agent 暴露工具。","desktop.mcpEmptyOther":"未配置其他 MCP 服务器 — DeepSeek Vision 的配置见上方卡片。","desktop.mcpServerName":"名称","desktop.mcpCommand":"命令","desktop.mcpArgs":"参数(每行一个)","desktop.mcpTransport":"传输方式","desktop.mcpLifecycle":"生命周期","desktop.mcpRequestTimeoutMs":"请求超时(毫秒)","desktop.mcpEnv":"环境变量(JSON)","desktop.mcpEdit":"编辑","desktop.mcpDelete":"删除","desktop.mcpSave":"保存","desktop.saving":"保存中…","desktop.mcpCancel":"取消","desktop.mcpSavedRestart":"已保存 — 重启 pi 后生效。","desktop.tools":"工具","desktop.refreshSession":"刷新会话","desktop.shellTool":"Shell 工具","desktop.usePowerShell":"Shell 命令使用 PowerShell","desktop.shellToolDescription":"在 Windows 上,shell 工具优先使用 PowerShell 而非 bash。写入 settings.json 的 defaultTools。","desktop.shellToolWindowsOnly":"PowerShell 仅可在 Windows 上配置。","desktop.shellToolMacOnly":"Shell 工具设置仅适用于 Windows。","desktop.subagentCardProcessing":"正在处理","desktop.transcriptRoleUser":"用户","desktop.transcriptRoleAssistant":"助手","desktop.transcriptRoleResult":"结果","desktop.transcriptRoleBash":"Bash","desktop.backup":"备份","desktop.backupExportTitle":"导出备份","desktop.backupExportDescription":"打包全部全局配置:供应商、模型、凭证、设置、MCP 服务器、技能与本地插件。","desktop.backupIncludeSecrets":"包含 API 密钥与登录凭证","desktop.backupSecretsWarning":"警告:备份将包含明文 API 密钥(models.json)与 OAuth 凭证(auth.json),请妥善保管。","desktop.backupIncludeSessions":"包含会话历史","desktop.backupSessionsHint":"会话历史可能较大,且含敏感对话内容。","desktop.backupExportButton":"导出备份","desktop.backupExporting":"导出中…","desktop.backupExportFailed":"备份导出失败","desktop.backupImportTitle":"导入备份","desktop.backupImportButton":"选择备份文件","desktop.backupImportDescription":"从 pi-backup zip 恢复。路径会自动重映射到本机,MCP 命令按平台适配。","desktop.backupImportFailed":"读取备份文件失败","desktop.backupRestoreFailed":"恢复失败","desktop.backupManifest":"备份创建于","desktop.backupNoSecrets":"不含凭证","desktop.backupCategories":"恢复类别","desktop.backupCategorycore":"核心配置","desktop.backupCategoryskills":"技能","desktop.backupCategorypackages":"插件","desktop.backupCategorymcp":"MCP 服务器","desktop.backupCategorysessions":"会话","desktop.backupMcpServers":"MCP 服务器","desktop.backupNpmPackages":"npm 插件包","desktop.backupReinstallNpm":"恢复后重新安装这些 npm 包","desktop.backupReinstallNpmHint":"安装脚本将执行备份包自带的代码,仅在你信任该备份来源时勾选","desktop.backupInstallModel":"安装会话使用的模型","desktop.backupInstallSession":"创建安装会话","desktop.backupOpenSession":"打开会话","desktop.backupInstallSessionFailed":"创建安装会话失败","desktop.backupRestoreButton":"开始恢复","desktop.backupRestoring":"恢复中…","desktop.backupRestoreReport":"恢复报告","desktop.backupReportRestored":"已恢复","desktop.backupReportRestart":"需重启生效","desktop.backupReportManual":"需人工确认","desktop.backupRestartHint":"设置、模型、凭证与 MCP 配置需重启 pi-web / pi 后生效。","desktop.importSessions":"导入会话","desktop.importSessionsDesc":"从其他 AI 编码工具导入历史对话记录到 pi-web。目前支持 Reasonix,更多工具陆续支持中。","desktop.comingSoon":"即将支持","desktop.projects":"个项目","desktop.importSelectProjects":"选择要导入的项目","desktop.importSelectAll":"全选","desktop.importDeselectAll":"取消全选","desktop.importMerged":"合并到现有项目","desktop.importNewProject":"新建项目","desktop.importExistingCount":"{count} 个已有","desktop.importStart":"开始导入","desktop.importing":"导入中…","desktop.importDone":"导入完成","desktop.importedSummary":"成功导入 {imported} 个会话","desktop.importSkippedCount":"{skipped} 个跳过","desktop.importErrorsCount":"{errors} 个失败","desktop.importGeneratingTitles":"正在生成标题…","desktop.importGenerateTitles":"为导入的会话生成标题","desktop.importAgain":"再次导入","desktop.importNoData":"未找到 Reasonix 数据。请确认 ~/.reasonix/projects/ 目录存在且包含会话文件。","desktop.importFromReasonix":"来自 Reasonix","desktop.importFromCodex":"来自 Codex","desktop.builtinModelsTitle":"模型配置","desktop.builtinModelsFetchNew":"获取新模型","desktop.builtinModelsLoadFailed":"加载模型失败","desktop.builtinModelsEmpty":"该供应商暂无可用模型。","desktop.builtinModelsContext":"上下文","desktop.builtinModelsMaxTokens":"最大返回","desktop.builtinModelsReasoning":"思考模型","desktop.builtinModelsThinking":"思考强度(thinkingLevelMap)","desktop.builtinModelsDirty":"{count} 处未保存修改","desktop.builtinModelsHide":"隐藏此模型","desktop.inputShortcut":"输入快捷键","desktop.inputShortcutDescription":"选择使用 Enter 键发送消息的方式。","desktop.useCtrlEnter":"使用 Ctrl+Enter 发送","desktop.useCtrlEnterDescription":"Enter 用于换行,Ctrl+Enter 发送消息。","desktop.useEnter":"使用 Enter 发送","desktop.useEnterDescription":"Enter 发送消息,Shift+Enter 用于换行。","desktop.theme":"主题","desktop.themes":"主题","desktop.language":"语言","desktop.light":"浅色","desktop.dark":"深色","desktop.system":"跟随系统","desktop.english":"English","desktop.chinese":"简体中文","desktop.themeDescription":"选择 Pi Web 的外观。","desktop.languageDescription":"选择界面的显示语言。","desktop.colorScheme":"配色方案","desktop.openThemeFolder":"打开本地 Pi theme 文件夹","desktop.learnPiThemes":"了解 Pi theme","desktop.defaultTheme":"默认","desktop.appearanceMode":"外观模式","desktop.loadingThemes":"加载主题中…","desktop.borderVisibility":"边框可见度","desktop.borderSubtle":"浅淡","desktop.borderBold":"浓重","desktop.noCustomThemes":"未安装自定义主题。","desktop.noCustomThemesHint":"将 JSON 文件放入","desktop.noCustomThemesHint2":"即可在此处看到。","desktop.darkVariant":"深色变体可用","desktop.lightVariant":"浅色变体可用","desktop.switchToLight":"切换至浅色模式","desktop.switchToDark":"切换至深色模式","desktop.showSidebar":"显示侧边栏","desktop.hideSidebar":"隐藏侧边栏","desktop.resizeSidebar":"调整侧边栏宽度","desktop.resizeFilePanel":"调整文件面板宽度","desktop.trustProject":"信任项目","desktop.trustingProject":"正在信任…","desktop.projectResourcesRestricted":"项目资源已受限","desktop.projectSkillsRestricted":"信任此项目后才能使用项目技能。","desktop.projectSkillInstallUnavailable":"请先信任此项目,再安装项目技能。","desktop.shellCommand":"Shell 命令","desktop.shellOutputLocal":"输出仅保留在本地","desktop.shellOutputModel":"输出将提供给模型","desktop.runningShellCommand":"正在运行 Shell 命令…","desktop.loadFullOutput":"加载完整输出","desktop.download":"下载","desktop.trustProjectTitle":"信任此项目?","desktop.trustProjectBody":"项目扩展、技能、提示词和软件包资源可能执行代码。仅在确认项目内容可信时授予信任。","desktop.minimize":"最小化","desktop.maximize":"最大化","desktop.restore":"还原","desktop.islandLabel":"窗口控制","desktop.islandResetHint":"拖动调整位置,双击复位","desktop.islandDrag":"按住拖动","desktop.close":"关闭","desktop.viewFullHistory":"查看完整历史","desktop.fullHistoryAvailableAfterSave":"保存会话后可查看完整历史","desktop.systemPrompt":"系统提示词","desktop.sessionInfo":"会话信息","desktop.hideFilePanel":"隐藏文件面板","desktop.showFilePanel":"显示文件面板","desktop.sessionInfoTitle":"会话信息","desktop.sessionInfoFile":"文件","desktop.sessionInfoId":"ID","desktop.sessionInfoInMemory":"内存中","desktop.sessionInfoMessages":"消息","desktop.sessionInfoTokens":"令牌","desktop.sessionInfoActiveTime":"估算活跃耗时","desktop.sessionInfoUser":"用户","desktop.sessionInfoAssistant":"助手","desktop.sessionInfoToolCalls":"工具调用","desktop.sessionInfoToolResults":"工具结果","desktop.sessionInfoTotal":"总计","desktop.sessionInfoInput":"输入","desktop.sessionInfoOutput":"输出","desktop.sessionInfoCacheRead":"缓存读取","desktop.sessionInfoCacheWrite":"缓存写入","desktop.sessionInfoCost":"费用","desktop.sessionInfoCostOfficial":"费用(官网价)","desktop.sessionInfoContext":"上下文","desktop.balance":"余额","desktop.balanceGranted":"赠送额度","desktop.balanceToppedUp":"充值额度","desktop.balanceUnavailable":"余额不可用","desktop.turnUsageTitle":"本次回复","desktop.turnUsageByOfficialPrice":"按官网价折算","desktop.copyFilePath":"复制文件路径","desktop.copySessionId":"复制会话 ID","desktop.projectDir":"项目","desktop.gitBranch":"Git 分支","desktop.gitWorktree":"工作树","desktop.projectSection":"项目信息","desktop.copyProjectDir":"复制项目路径","desktop.copyGitBranch":"复制 Git 分支","desktop.copyGitWorktree":"复制工作树路径","desktop.sendMessageForSessionInfo":"发送消息或运行 /session 以加载会话信息","desktop.selectSessionFromSidebar":"请从侧边栏选择会话","desktop.getStarted":"开始使用","desktop.selectProjectDirectory":"从侧边栏选择项目目录","desktop.addModelsFromBottom":"通过底部的“模型”按钮添加模型","desktop.loadingSession":"正在加载会话...","desktop.scrollToLoadEarlierMessages":"向上滚动以加载更早的消息(隐藏了 {count} 条)","desktop.scrollToBottom":"滚动到底部","desktop.filesWritten":"改动的文件","desktop.openWrittenFile":"打开 {name}","desktop.taskRunning":"进行中","desktop.taskTodo":"待办","desktop.taskStatusHint":"当前项目的任务进度,点击打开任务看板","desktop.runningTool":"正在运行工具...","desktop.runningTools":"正在运行 {tools}...","desktop.waitingForModel":"正在等待模型...","desktop.runningCommand":"正在运行命令...","desktop.thinking":"思考中...","desktop.extensionRequest":"扩展请求","desktop.extensionPanel":"扩展面板","desktop.cancel":"取消","desktop.confirm":"确认","desktop.submit":"提交","desktop.queued":"已排队","desktop.queueMoveUp":"上移","desktop.queueMoveDown":"下移","desktop.queueRecallOne":"取回到输入框","desktop.queueRemove":"移除排队消息","desktop.recalledEditing":"正在编辑一条已取回的排队消息;发送后会回到原来的队列位置。","desktop.steer":"引导","desktop.followUp":"后续消息","desktop.recallToInput":"恢复到输入框","desktop.recallQueuedMessages":"移除所有排队消息,并将其放回输入框以便编辑","desktop.retrying":"正在重试","desktop.compacted":"已压缩","desktop.tokens":"令牌","desktop.saved":"已节省","desktop.removeImage":"移除图片","desktop.loadingCommands":"正在加载命令...","desktop.slashCommands":"斜杠命令","desktop.tabOrEnter":"Tab / Enter","desktop.noSlashCommands":"未找到扩展、提示词或技能命令","desktop.builtIn":"内置","desktop.extensions":"扩展","desktop.prompts":"提示词","desktop.commandSkills":"技能","desktop.match":"个匹配项","desktop.matches":"个匹配项","desktop.snippetMatches":"个片段匹配","desktop.command":"个命令","desktop.commands":"个命令","desktop.loadingFiles":"正在加载文件...","desktop.files":"文件","desktop.searchingAllFiles":"正在搜索所有文件...","desktop.indexTruncated":"索引已截断","desktop.searching":"正在搜索...","desktop.search":"搜索","desktop.noMatchingFiles":"没有匹配的文件","desktop.steerOrQueueFollowUp":"立即引导 / 排队后续消息...","desktop.agentRunning":"Agent 正在运行...","desktop.messageWithCommands":"输入消息... 输入 / 查看命令,@ 查看文件","desktop.inputHistory":"输入历史","desktop.quickChanges":"快速变更","desktop.changedFiles":"{count} 个变更文件","desktop.imageAttachmentsCannotQueue":"Agent 运行时无法将图片附件加入队列","desktop.injectMessageNow":"中断当前运行并立即注入此消息","desktop.queueMessageAfterFinish":"在 Agent 完成后将此消息加入队列","desktop.attachImage":"添加图片","desktop.push":"推送当前分支","desktop.pushOk":"推送成功","desktop.pushFailed":"推送失败","desktop.stash":"Stash 管理","desktop.stashTitle":"Stash 管理","desktop.stashPush":"保存到 Stash","desktop.stashList":"Stash 列表","desktop.stashEmpty":"暂无 stash","desktop.stashPop":"恢复","desktop.stashDrop":"删除","desktop.stashMessagePlaceholder":"stash 说明(可选)…","desktop.stashDone":"操作成功","desktop.attachMenu":"选择输入模式","desktop.attachUpload":"上传文件","desktop.attachUploadDesc":"附加图片等文件","desktop.attachReference":"引用文件","desktop.attachReferenceDesc":"通过 @ 引用工作区文件","desktop.attachSessions":"引用会话","desktop.attachSessionsDesc":"通过 # 引用过去的对话","desktop.attachCommands":"使用命令","desktop.attachCommandsDesc":"通过 / 使用命令和技能","desktop.planModeBadge":"计划模式","desktop.planModeLabel":"计划模式","desktop.planModeHint":"当前为计划模式:只读分析,不修改文件。结束后可确认执行或退出。","desktop.disableCompletionSound":"关闭完成提示音","desktop.enableCompletionSound":"开启完成提示音","desktop.soundLabelOn":"提示音:开启","desktop.soundLabelOff":"提示音:关闭","desktop.changeReasoningLevel":"更改推理级别:{level}","desktop.reasoningLevel":"更改推理级别","desktop.moreControls":"更多控件","desktop.more":"更多","modes.collabNormal":"常规","modes.collabPlan":"计划","modes.collabGoal":"目标","modes.tokenEconomy":"轻量","modes.tokenFull":"均衡","modes.tokenDelivery":"交付","modes.approvalAsk":"批准","modes.approvalAuto":"自动","modes.approvalYolo":"Yolo","modes.collabNormalTitle":"常规 \xb7 边做边推进","modes.collabNormalDesc":"直接执行,边做边推进","modes.collabPlanTitle":"计划 \xb7 确认后执行","modes.collabPlanDesc":"先产出计划;工具执行仍由权限与沙箱决定","modes.collabGoalTitle":"目标 \xb7 持续推进","modes.collabGoalDesc":"输入目标后持续工作,直到完成或阻塞","modes.tokenEconomyTitle":"轻量 \xb7 快速省用量","modes.tokenEconomyDesc":"少上下文,工具按需启用","modes.tokenFullTitle":"均衡 \xb7 日常通用","modes.tokenFullDesc":"完整工具,模型自主执行","modes.tokenDeliveryTitle":"交付 \xb7 完整验证","modes.tokenDeliveryDesc":"强制验收,复查验证","modes.approvalAskTitle":"需要批准","modes.approvalAskDesc":"需审批的写入与命令会先询问","modes.approvalAutoTitle":"自动批准","modes.approvalAutoDesc":"自动执行权限策略允许的操作","modes.approvalYoloTitle":"Yolo 批准","modes.approvalYoloDesc":"跳过普通工具权限提示(仅本会话)","desktop.goalRunning":"目标","desktop.goalComplete":"目标完成","desktop.goalBlocked":"目标阻塞","desktop.goalPaused":"目标暂停","desktop.goalNoProgress":"{n} 轮无进展","desktop.goalPause":"暂停目标","desktop.goalPauseShort":"Ⅱ","desktop.goalResume":"恢复目标","desktop.goalResumeShort":"▶","desktop.goalStop":"结束目标","desktop.goalEdit":"编辑","desktop.goalSave":"保存","desktop.goalCancel":"取消","desktop.goalEditHint":"Cmd+Enter 保存 \xb7 Esc 取消","desktop.goalBudget":"预算","desktop.goalTurns":"轮次","desktop.goalBudgetLimited":"预算耗尽","approval.title":"需要工具审批","approval.subtitle":"Agent 想执行此工具。选择「允许」执行,或「拒绝」向 Agent 返回被阻止的结果。","approval.queued":"个待处理","approval.allow":"允许","approval.deny":"拒绝","approval.denyWithReason":"附理由拒绝","approval.hideReason":"隐藏理由","approval.reasonPlaceholder":"展示给 Agent 的理由(可选)","desktop.stopCompaction":"停止压缩","desktop.compactContext":"压缩上下文","desktop.compacting":"正在压缩...","desktop.compact":"压缩","desktop.changeToolPreset":"更改工具预设:{preset}","desktop.toolPreset":"更改工具预设","desktop.sendMessage":"发送消息","desktop.stopAgent":"停止 Agent","desktop.stop":"停止","desktop.collapseControls":"收起控件","desktop.usePiDefault":"使用 pi 默认设置","desktop.reasoningOff":"关闭推理","desktop.minimalReasoning":"最小推理","desktop.lowReasoning":"低推理","desktop.mediumReasoning":"中等推理","desktop.highReasoning":"高推理","desktop.extraHighReasoning":"超高推理","desktop.maxReasoning":"最高推理","desktop.noToolsReadOnly":"不使用工具,只读","desktop.fourBuiltInTools":"4 个内置工具","desktop.allBuiltInTools":"所有内置工具","desktop.toolOff":"关闭","desktop.toolDefault":"默认","desktop.toolFull":"完整","desktop.thinkingAuto":"自动","desktop.thinkingOff":"关闭","desktop.thinkingMinimal":"最小","desktop.thinkingLow":"低","desktop.thinkingMedium":"中等","desktop.thinkingHigh":"高","desktop.thinkingExtraHigh":"超高","desktop.thinkingMax":"最高","desktop.compactCommandDescription":"压缩上下文,可选择附加指令","desktop.reloadCommandDescription":"重新加载扩展、技能、提示词和工具","desktop.nameCommandDescription":"设置会话显示名称","desktop.sessionCommandDescription":"显示会话消息、令牌和费用统计","desktop.copyCommandDescription":"复制最后一条助手消息","desktop.selectModel":"选择模型","desktop.modelsLoadFailed":"模型列表加载失败","desktop.noModelsConfigured":"未配置可用模型,请到「模型」设置添加供应商","desktop.selectProject":"选择项目","desktop.selectProjectFirst":"请先选择项目","desktop.noMatchingProjects":"没有匹配的项目","desktop.noProjectsYet":"尚无项目","desktop.useDefaultDirectory":"使用默认目录","desktop.customPath":"自定义路径…","desktop.projectPathPlaceholder":"/path/to/project","desktop.filterProjects":"筛选项目…","desktop.searchProjects":"搜索项目…","desktop.recentProjects":"最近项目","desktop.addProjectTab":"新增项目 tab","desktop.maxProjectTabs":"最多 4 个项目 tab(下拉框 1 个 + tab 4 个)","desktop.branch":"分支","desktop.editProjectAlias":"修改项目备注","desktop.projectAliasPlaceholder":"给项目加个备注…","desktop.quickWorkspace":"快速工作区","desktop.selectFolder":"选择文件夹","desktop.checking":"正在检查…","desktop.open":"打开","common.ok":"确定","common.language":"语言","common.models":"模型","common.skills":"技能","common.agents":"子代理","common.plugins":"插件","common.settings":"设置","settings.title":"设置","settings.general":"常规","settings.generalDescription":"选择 Pi Web 的显示方式和界面语言。","settings.appearance":"外观","settings.appearanceDescription":"选择浅色或深色主题,也可以跟随系统设置。","settings.chatContentWidth":"聊天内容宽度","settings.chatContentFontSize":"聊天字体大小","settings.resetChatContentWidth":"重置聊天内容宽度","settings.resetChatContentFontSize":"重置聊天字体大小","settings.chatContentWidthDescription":"设置消息内容和输入框的最大宽度。","settings.themeLight":"浅色","settings.themeDark":"深色","settings.themeSystem":"跟随系统","settings.thinkingDisplay":"思考过程显示","settings.thinkingDisplayDescription":"选择消息加载时模型思考块是否默认展开。","settings.thinkingExpandedDefault":"默认展开思考块","settings.chat":"对话","settings.quoteSelection":"选中文字时显示提问浮窗","settings.languageDescription":"选择整个界面使用的语言。","settings.shellTool":"Shell 工具","settings.shellToolDescription":"选择模型执行命令时使用的 Shell。直接输入的 ! 和 !! 命令仍使用 Bash。","settings.usePowerShell":"使用 PowerShell 替代 Bash","settings.projectRequired":"打开项目后才能配置此项","skills.scope.global":"全局","skills.scope.project":"项目","skills.scope.path":"路径","agents.close":"关闭","agents.builtInTitle":"启用 Pi Web 内置子代理","agents.builtInDescription":"提供 Pi Web 集成的 Agent 工具,并停用发生冲突的 pi-subagents 扩展。","agents.reloadRequired":"重新加载当前会话后生效。","agents.reloadSession":"重新加载会话","agents.reloading":"正在重新加载...","agents.loading":"正在加载子代理...","agents.new":"新建子代理","agents.empty":"选择或创建一个子代理配置","agents.saveScope":"保存到","agents.name":"子代理 ID","agents.displayName":"显示名称","agents.description":"描述","agents.prompt":"系统指令","agents.tools":"工具","agents.resources":"资源","agents.loadSkills":"加载技能","agents.loadExtensions":"加载扩展","agents.model":"指定模型","agents.modelsLoading":"正在加载模型...","agents.modelUnavailable":"{model}(不可用)","agents.thinking":"思考级别","agents.maxTurns":"最大轮次","agents.inherit":"跟随父会话","agents.enable":"启用子代理","agents.disable":"停用子代理","agents.builtinPath":"内置配置","agents.inheritContext":"继承父会话上下文","agents.background":"默认在后台运行","agents.duplicate":"创建副本","agents.copyName":"{name} 副本","agents.delete":"删除","agents.deleteConfirm":"删除 {name}?","agents.save":"保存","agents.saving":"正在保存...","agents.scope.builtin":"内置","agents.scope.global":"全局","agents.scope.workspace":"工作区","agents.scope.project":"项目","agents.overridden":"被覆盖","subagent.readOnlyNotice":"子代理会话为只读视图","subagent.open":"打开子代理会话","agentSwitcher.title":"Agents","agentSwitcher.main":"主 Agent","agentSwitcher.subagent":"子 Agent","agentSwitcher.current":"当前","agentSwitcher.count":"{count} 个子 Agent","agentSwitcher.runningCount":"{count} 个运行中","agentSwitcher.search":"搜索 Agents","agentSwitcher.noFamily":"当前会话没有子代理族谱","agentSwitcher.noMatches":"没有匹配的 Agent","agentSwitcher.status.starting":"正在启动","agentSwitcher.status.running":"运行中","agentSwitcher.status.completed":"已完成","agentSwitcher.status.failed":"失败","agentSwitcher.status.aborted":"已中止","agentSwitcher.status.interrupted":"已中断","appUpdate.releaseNotes":"Pi Web v{version} 可用,查看更新说明","sidebar.hide":"隐藏侧边栏","sidebar.show":"显示侧边栏","theme.light":"浅色模式(点击切换到深色)","theme.dark":"深色模式(点击切换到跟随系统)","theme.auto":"跟随系统(点击切换到浅色)","history.full":"完整历史","history.unsaved":"会话保存后才能查看完整历史","history.label":"完整历史","title.generating":"正在生成...","title.updated":"标题已更新","title.failed":"生成失败","title.generate":"生成标题","title.unsaved":"会话保存后才能生成标题","title.noMessages":"请先发送消息,再为会话命名","title.generateSession":"生成会话标题","system.prompt":"系统提示词","system.empty":"系统提示词为空(工具已禁用)","system.load":"系统提示词尚未加载","system.loading":"正在加载系统提示词…","system.label":"系统","tools.label":"工具","tools.title":"工具定义","tools.details":"工具定义详情","tools.load":"工具定义尚未加载","tools.loading":"正在加载工具定义…","tools.noTools":"没有启用的工具","tools.description":"描述","tools.parameters":"参数","tools.parameterCount":"{count} 个参数","tools.noParameters":"无参数","tools.required":"必填","tools.optional":"可选","tools.allowedValues":"可选值","tools.defaultValue":"默认值","tools.guidelines":"提示词规则","session.info":"会话信息","session.name":"名称","session.file":"会话文件","session.inMemory":"内存中","session.id":"ID","session.user":"用户","session.assistant":"助手","session.toolCalls":"工具调用","session.toolResults":"工具结果","session.total":"总计","session.input":"输入","session.output":"输出","session.cacheRead":"缓存读取","session.cacheWrite":"缓存写入","session.cost":"费用","session.context":"上下文","session.cacheHitRate":"平均缓存命中率","session.copy":"复制{value}","session.copied":"已复制","session.title":"会话信息","session.load":"发送消息或运行 /session 以加载会话信息","session.infoSection":"会话信息","session.projectSection":"项目信息","session.messages":"消息","session.tokens":"Token","session.totalActive":"活跃时长","session.copyFile":"复制文件路径","session.copyId":"复制会话 ID","session.projectDir":"项目目录","session.gitBranch":"Git 分支","session.gitWorktree":"Worktree","session.copyProjectDir":"复制项目目录","session.copyGitBranch":"复制 Git 分支","session.copyGitWorktree":"复制 Worktree 路径","workspace.opening":"正在打开工作区...","workspace.unable":"无法打开工作区","workspace.selectSession":"从侧边栏选择一个会话","workspace.getStarted":"开始使用","workspace.selectProject":"从侧边栏选择项目目录","workspace.addModels":"打开底部的“设置”,然后选择“模型”","workspace.stepProject":"从侧边栏选择项目目录","workspace.stepModels":"打开底部的“设置”,然后选择“模型”","files.hidePanel":"隐藏文件面板","files.showPanel":"显示文件面板","files.noneOpen":"没有打开的文件","layout.resizeSidebar":"调整侧边栏宽度","layout.resizeFilePanel":"调整文件面板宽度","layout.resizeHint":"拖动调整宽度。双击或按 Enter 恢复默认值。","sidebar.new":"新建","sidebar.newSessionTitle":"在 {path} 中新建会话","sidebar.refresh":"刷新","sidebar.selectProject":"选择项目…","sidebar.filterProjects":"筛选项目…","sidebar.noMatchingProjects":"没有匹配的项目","sidebar.searchFiles":"搜索文件","sidebar.searchFilesPlaceholder":"搜索文件…","sidebar.clearSearch":"清除搜索","sidebar.searchingFiles":"搜索中…","sidebar.noMatchingFiles":"没有匹配的文件","sidebar.useDefaultDirectory":"使用默认目录","sidebar.customPath":"自定义路径…","directoryPicker.selectDirectory":"选择目录","directoryPicker.goToParent":"转到上级目录","directoryPicker.loadingDirectories":"正在加载目录…","directoryPicker.noSubdirectories":"没有子目录","directoryPicker.noMatchingDirectories":"没有匹配的子目录","directoryPicker.filterPlaceholder":"筛选子目录…","directoryPicker.selectCurrentDirectory":"选择当前目录","directoryPicker.selectThisFolder":"选择此文件夹","directoryPicker.noDrives":"未找到盘符","desktop.switchWorktree":"切换工作树","desktop.switchWorktreeWithPath":"切换工作树:{path}","desktop.openRepoRoot":"打开仓库根目录","desktop.openRepoRootDescription":"打开仓库根目录以管理工作树。","desktop.gitRepoRootOnly":"仅 Git 仓库根目录","desktop.gitRepoRootOnlyDescription":"工作树仅在 Git 仓库根目录可用。","desktop.checkingWorktrees":"正在检查此目录的工作树。","desktop.worktreesLoading":"工作树…","desktop.createWorktree":"为分支创建工作树检出","desktop.newWorktree":"新建工作树…","desktop.branchName":"分支名称","desktop.creating":"正在创建…","desktop.create":"创建","desktop.main":"主工作树","desktop.removeWorktree":"移除工作树检出 {path};分支将保留","desktop.uncommittedChanges":"存在未提交的更改。要强制移除检出吗?","desktop.force":"强制移除","desktop.sessions":"会话","desktop.newSession":"新建","desktop.newSessionIn":"在 {cwd} 中新建会话","desktop.refresh":"刷新","desktop.loading":"正在加载…","desktop.noModels":"没有可用模型","desktop.noSessionsFound":"未找到会话","desktop.explorer":"资源管理器","desktop.uploadFiles":"上传文件","desktop.uploadFilesToProjectRoot":"上传文件到项目根目录","desktop.refreshExplorer":"刷新资源管理器","desktop.agentRunningLabel":"Agent 正在运行","desktop.newActivity":"有新动态","desktop.newSessionActivity":"会话有新动态","desktop.deleteSession":"删除“{title}”?","desktop.delete":"删除","desktop.deleteWithShift":"删除(按住 Shift 点击跳过确认)","desktop.openingWorkspace":"正在打开工作区…","desktop.unableToOpenWorkspace":"无法打开此工作区","desktop.rename":"重命名","desktop.titleGenerationFailed":"标题生成失败","desktop.retryTitleGeneration":"重新生成标题","desktop.retry":"重试","desktop.changeTitleModel":"换模型","desktop.pastedLabel":"[已粘贴文本 #{id} \xb7 {lines} 行]","desktop.pastedShowPreview":"预览粘贴文本","desktop.pastedHidePreview":"收起粘贴文本预览","desktop.pastedRemove":"删除粘贴文本","desktop.pastedMissingContent":"消息中残留未还原的粘贴占位符(原文已丢失),已阻止发送,请重新粘贴该段内容。","desktop.generateTitle":"生成标题","desktop.generateAllTitles":"批量生成当前项目所有会话的标题","desktop.generatingTitlesProgress":"正在批量生成标题… {done}/{total}","desktop.generatingTitle":"正在生成标题…","desktop.titleNeedsMessages":"会话暂无消息,无法生成标题","desktop.expandForks":"展开分支","desktop.collapseForks":"折叠分支","desktop.sessionViewList":"列表","desktop.sessionViewGroups":"分组","desktop.searchSessions":"搜索会话、分支...","desktop.noSearchResults":"未找到匹配会话","desktop.pinned":"置顶","desktop.today":"今天","desktop.yesterday":"昨天","desktop.older":"更早","desktop.collapseGroup":"收起","desktop.expandGroup":"展开","desktop.pin":"置顶","desktop.unpin":"取消置顶","desktop.forkedFrom":"从「{title}」分叉","desktop.messagesCount":"{count} 条消息","desktop.worktree":"工作树:{cwd}","desktop.justNow":"刚刚","desktop.minutesAgo":"{count} 分钟前","desktop.hoursAgo":"{count} 小时前","desktop.daysAgo":"{count} 天前","desktop.panelGroupBubble":"分组","desktop.panelProjectBubble":"项目","desktop.rowStyleToggle":"切换行样式","desktop.sidebarModeCycle":"切换侧边栏模式","desktop.panelFormLabel":"面板","desktop.expandAllFolders":"展开全部文件夹","desktop.collapseAllFolders":"收起全部文件夹","desktop.filterMenu":"筛选","desktop.moreActions":"更多操作","desktop.viewSection":"视图","desktop.viewByProject":"按项目","desktop.viewTimeline":"时间线","desktop.sortSection":"排序方式","desktop.sortUpdated":"更新时间","desktop.sortCreated":"创建时间","desktop.hiddenProjectsSection":"已隐藏项目","desktop.noHiddenProjects":"无已隐藏项目","desktop.restoreProject":"恢复显示","desktop.archivedView":"归档","desktop.archiveSession":"归档","desktop.archiveSessionConfirm":"归档“{title}”?","desktop.unarchiveSession":"取消归档","desktop.deleteForever":"彻底删除","desktop.deleteArchivedConfirm":"彻底删除这个归档会话?会话文件将被移除,此操作不可恢复。","desktop.removeProject":"移除项目","desktop.removeProjectConfirm":"项目“{name}”会从侧边栏移除,但不会删除磁盘上的文件。","desktop.removeProjectRunningConfirm":"该项目仍有会话在运行,确定移除吗?","desktop.showMore":"显示更多","desktop.viewFiles":"查看文件","desktop.backToSessions":"返回会话","desktop.newSessionHere":"在此项目新建会话","desktop.newTask":"新建任务","desktop.showAllProjects":"显示所有项目","desktop.showCurrentProject":"显示当前项目","desktop.sidebarModeHintTitle":"两种列表展示方式","desktop.sidebarModeHintDesc":"点这个按钮可在「当前项目下拉」与「全部项目面板」之间切换;面板还支持分组 / 时间线视图、归档和按项目查看文件树。","desktop.sidebarModeHintOk":"知道了","desktop.noProjects":"暂无项目","desktop.noArchivedSessions":"暂无归档会话","desktop.searchArchived":"搜索归档会话...","desktop.projectSectionHeader":"项目","desktop.closeTab":"关闭","desktop.closeTabWithLabel":"关闭 {label}","desktop.modelsHideApiKey":"隐藏 API 密钥","desktop.modelsShowApiKey":"显示 API 密钥","desktop.modelsInheritNone":"— 继承 / 无 —","desktop.modelsProvider":"提供商","desktop.modelsProviderName":"提供商名称","desktop.modelsBaseUrl":"基础 URL","desktop.modelsApiKey":"API 密钥","desktop.modelsApiKeyHelp":"使用 ! 前缀运行 shell 命令,或使用环境变量名称","desktop.modelsApiKeyPlaceholder":"环境变量名称、!shell 命令或原始密钥","desktop.modelsApi":"API","desktop.modelsDefault":"默认","desktop.modelsDisabled":"已禁用","desktop.modelsCustom":"自定义","desktop.modelsModelSection":"模型","desktop.modelsTestingConnection":"正在测试模型连接...","desktop.modelsConnected":"已连接","desktop.modelsFailed":"失败","desktop.modelsTestConnection":"测试模型连接","desktop.modelsTesting":"测试中…","desktop.modelsTest":"测试","desktop.modelsOk":"正常","desktop.modelsRemove":"移除","desktop.modelsIdRequired":"ID *","desktop.modelsName":"名称","desktop.modelsDisplayName":"显示名称","desktop.modelsApiOverride":"覆盖 API","desktop.modelsReasoningThinking":"推理 / 思考","desktop.modelsImageInput":"图片输入","desktop.modelsDeepSeekCompat":"DeepSeek 思考兼容模式","desktop.modelsThinkingLevelMap":"思考级别映射","desktop.modelsClearAll":"清除全部","desktop.modelsDiscoveryFetching":"正在导入模型…","desktop.modelsDiscoveryFetch":"导入模型…","desktop.modelsDiscoveryFilterPlaceholder":"筛选 {count} 个模型…","desktop.modelsDiscoveryFilter":"筛选上游模型","desktop.modelsDiscoverySelectShown":"选择当前结果","desktop.modelsDiscoveryNoMatches":"没有匹配的模型。","desktop.modelsDiscoveryAdded":"已添加","desktop.modelsDiscoveryShowing":"显示前 {shown} 个,共 {total} 个","desktop.modelsDiscoveryFetched":"已获取 {count} 个模型","desktop.modelsDiscoveryAddSelected":"添加所选模型","desktop.modelsDiscoveryAddSelectedCount":"添加所选模型({count})","desktop.modelsCatalogSource":"来源:models.dev ↗","desktop.modelsCatalogFilling":"正在填入模型信息…","desktop.modelsCatalogFill":"填入模型信息","desktop.modelsCatalogFilled":"已填入 {count} 个字段","desktop.modelsCatalogNoEmptyFields":"没有需要填入的空字段","desktop.modelsCatalogNoExactMatch":"models.dev 中没有精确匹配","desktop.modelsCatalogPriceProvider":"价格已匹配 Provider {provider}","desktop.modelsCatalogPriceBaseUrl":"价格已按 Base URL 匹配 {provider}","desktop.modelsCatalogPriceConsensus":"价格得到 {support}/{total} 条记录支持","desktop.modelsCatalogPriceUnreliable":"未找到可靠价格","desktop.modelsCatalogUndo":"撤销","desktop.modelsContextWindow":"上下文窗口(令牌)","desktop.modelsMaxOutputTokens":"最大输出令牌数","desktop.modelsCostPerMillionTokens":"费用(每百万令牌)","desktop.modelsSubscription":"订阅","desktop.titleModel":"标题生成模型","desktop.titleModelDescription":'用于自动生成会话标题的模型。保持"跟随会话模型"则使用每个会话自身的模型。',"desktop.titleModelFollowSession":"跟随会话模型(默认)","desktop.titleModelInvalid":"已不再导入——标题生成将回退到会话模型","desktop.titleModelSaved":"已保存","desktop.titleModelSaveError":"保存标题生成模型设置失败","desktop.modelsNotConnected":"未连接","desktop.modelsAlreadyConnected":"已连接。你可以重新登录或断开连接。","desktop.modelsConnectAccount":"连接你的 {provider} 账户。","desktop.modelsOpeningBrowser":"正在打开浏览器…","desktop.modelsCompleteSignIn":"请在浏览器中完成登录,然后复制地址栏中的重定向 URL 并粘贴到下方。","desktop.modelsBrowserDidNotOpen":"如果浏览器窗口未打开,","desktop.modelsOpenLoginPage":"点击此处打开登录页面","desktop.modelsEnterValue":"输入值…","desktop.modelsOpenVerificationPage":"打开验证页面并输入此代码:","desktop.modelsExpiresInMinutes":"将在 {count} 分钟后过期。","desktop.modelsConnectedSuccessfully":"连接成功。","desktop.modelsReLogin":"重新登录","desktop.modelsLogin":"登录","desktop.modelsDisconnect":"断开连接","desktop.modelsConnectionLost":"连接已断开","desktop.modelsAuthenticationStateChanged":"认证状态已变化,请刷新后重试。","desktop.modelsVerifying":"验证中…","desktop.modelsContinuing":"正在继续…","desktop.modelsServerError":"服务器错误 {status}","desktop.modelsNetworkError":"网络错误","desktop.modelsConfigured":"已配置","desktop.modelsNotConfigured":"未配置","desktop.modelsApiKeyStored":"API 密钥已保存。请在下方输入新密钥以替换它,或断开连接以移除它。","desktop.modelsEnableModels":"输入你的 {provider} API 密钥以启用 {count} 个{models}。","desktop.modelsSingular":"模型","desktop.modelsPlural":"模型","desktop.modelsEnterNewKey":"输入新密钥以替换…","desktop.modelsSaving":"保存中…","desktop.modelsSaved":"已保存","desktop.modelsRemoving":"移除中…","desktop.modelsSearchProviders":"搜索提供商…","desktop.modelsNoProvidersMatch":"没有匹配的提供商","desktop.modelsCompatibleProvider":"兼容 OpenAI / Anthropic","desktop.modelsCustomEndpointFormat":"自定义端点格式","desktop.modelsAddCustomTitle":"添加自定义提供商","desktop.modelsProviderNameOptional":"提供商名称(可选)","desktop.modelsCallFormat":"调用格式","desktop.modelsCallFormatHelp":"选择一种现有的调用格式","desktop.modelsCustomCallFormat":"自定义调用格式","desktop.modelsCustomCallFormatHelp":"自定义端点默认按 OpenAI 兼容协议(openai-completions)请求;若你的接口是其它协议,请在上方格式下拉中改选。","desktop.modelsFullUrl":"完整 URL","desktop.modelsAddModelManual":"添加模型","desktop.modelsImportProvider":"从已有提供商导入","desktop.modelsImportProviderPlaceholder":"— 导入现有提供商配置 —","desktop.modelsImported":"已导入","desktop.modelsAddUrl":"+ 添加 URL","desktop.modelsUrlPlaceholder":"https://api.example.com/v1","desktop.modelsUrlInvalid":"URL 必须以 http:// 或 https:// 开头","desktop.modelsCustomRequest":"自定义请求","desktop.modelsRequestModelId":"请求模型 ID","desktop.modelsRequestModelIdHelp":"可选 — 创建带这些请求设置的首个模型","desktop.modelsRequestContextLength":"上下文长度(令牌)","desktop.modelsRequestOutputLength":"输出长度(令牌)","desktop.modelsAdd":"添加","desktop.modelsSubscriptions":"订阅","desktop.modelsCount":"{count} 个模型","desktop.modelsLoading":"加载中…","desktop.modelsNewModel":"新模型","desktop.modelsAddModel":"+ 添加模型","desktop.modelsAddProvider":"+ 添加提供商","desktop.modelsSelectProviderOrModel":"选择提供商或模型","desktop.modelsClose":"关闭模型设置","desktop.modelsSave":"保存","desktop.searchModels":"搜索模型…","desktop.noModelsMatch":"没有匹配的模型","desktop.global":"全局","desktop.project":"项目","desktop.path":"路径","desktop.addPlugin":"添加插件","desktop.addPluginTitle":"添加插件","desktop.pluginSource":"来源","desktop.install":"安装","desktop.installing":"正在安装...","desktop.examples":"示例","desktop.disabled":"已禁用","desktop.filtered":"已筛选","desktop.noResources":"没有资源","desktop.packageDisabled":"软件包已禁用","desktop.noResolvedResources":"没有已解析的资源","desktop.unknown":"未知","desktop.installedVersion":"已安装 {version}","desktop.configuredVersion":"已配置 {version}","desktop.enablePackage":"启用软件包","desktop.disablePackage":"禁用软件包","desktop.update":"更新","desktop.updating":"正在更新...","desktop.reloadSession":"重新加载会话","desktop.reloading":"正在重新加载...","desktop.reloadCurrentSession":"重新加载当前会话","desktop.openSessionToReload":"打开一个会话以重新加载","desktop.remove":"移除","desktop.removing":"正在移除...","desktop.status":"状态","desktop.version":"版本","desktop.package":"软件包","desktop.resources":"资源","desktop.installedPath":"安装路径","desktop.notFound":"未找到","desktop.cwd":"当前目录","desktop.resolvedResources":"已解析资源","desktop.packageRemoved":"软件包已移除。","desktop.packageInstalled":"软件包已安装。","desktop.packageUpdated":"软件包已更新。","desktop.packageDisabledMessage":"软件包已禁用。","desktop.packageEnabled":"软件包已启用。","desktop.sessionReloaded":"会话已重新加载。","desktop.noPluginsConfigured":"未配置插件","desktop.selectPackage":"选择一个软件包","desktop.diagnosticsCount":"{count} 条诊断信息","desktop.pluginResourceTotals":"{extensions} 个扩展 \xb7 {skills} 个技能 \xb7 {prompts} 个提示词 \xb7 {themes} 个主题","desktop.extensionsCount":"{count} 个扩展","desktop.skillsCount":"{count} 个技能","desktop.promptsCount":"{count} 个提示词","desktop.themesCount":"{count} 个主题","desktop.addSkill":"添加技能","desktop.addSkillTitle":"添加技能","desktop.skillSearchPlaceholder":"例如:react、testing、deploy","desktop.noSkillsFound":"未找到技能","desktop.skillSearchHint":"搜索 skills.sh,发现并为你的 Agent 安装技能。","desktop.visibleInModelPrompt":"在模型提示词中可见 — 点击以禁用","desktop.hiddenFromModelPrompt":"在模型提示词中隐藏 — 点击以启用","desktop.dormant":"休眠","desktop.hiddenButInvocable":"已从模型中隐藏,仍可手动调用","desktop.check":"检查","desktop.upToDate":"已是最新","desktop.automaticChecksUnavailable":"无法自动检查更新","desktop.checkFailed":"检查失败","desktop.name":"名称","desktop.description":"描述","desktop.selectSkill":"选择一个技能","desktop.checkUpdates":"检查更新","desktop.updateAvailable":"有可用更新","desktop.installed":"已安装","desktop.updatesCount":"{count} 个更新","desktop.downloadFile":"下载文件","desktop.loadingFile":"正在加载...","desktop.noChanges":"没有更改","desktop.unchangedLines":"... {count} 行未更改 ...","desktop.lines":"{count} 行","desktop.mentionFile":"提及文件","desktop.mentionSelectedLines":"提及所选行 {start}-{end}","desktop.source":"源文件","desktop.diff":"差异","desktop.enableWordWrap":"启用自动换行","desktop.disableWordWrap":"禁用自动换行","desktop.wrap":"换行","desktop.code":"代码","desktop.preview":"预览","desktop.raw":"原始内容","desktop.htmlPreview":"HTML 预览","desktop.image":"图片","desktop.audio":"音频","desktop.docxPreview":"DOCX 预览","desktop.failedToLoadImage":"加载图片失败","desktop.failedToLoadAudio":"加载音频失败","desktop.docxTooLargeForPreview":"DOCX 文件过大,无法预览(超过 10MB)","desktop.previewFile":"预览 {file}","desktop.branches":"分支","desktop.noActiveSession":"没有活动会话","desktop.sessionHasNoBranches":"此会话暂无分支 —— 对任意消息点「从这里继续」或「分叉」后会出现分支树","desktop.copyMessage":"复制消息","desktop.copyPlainText":"复制纯文本","desktop.createTaskFromMessage":"创建任务","desktop.editFromHere":"从此处编辑 — 在此会话内创建分支","desktop.creatingNewSession":"正在创建新会话…","desktop.newSessionFromHere":"新建会话 — 从此处创建独立副本","desktop.estimatedStreamingTokenCount":"流式输出期间的预估令牌数","desktop.tokensPerSecond":"{count} 令牌/秒","desktop.thinkingContentUnavailable":"思考内容不可用","desktop.loadingThinking":"正在加载思考内容...","desktop.conversationCompacted":"对话已压缩","desktop.compactionSummaryDescription":"此处之前的对话历史已压缩为以下摘要:","desktop.noSummary":"(无摘要)","desktop.fileContext":"文件上下文:{context}","desktop.readFilesCount":"已读取 {count} 个","desktop.modifiedFilesCount":"已修改 {count} 个","desktop.modifiedFiles":"已修改的文件","desktop.readFiles":"已读取的文件","desktop.hiddenExtensionMessage":"隐藏的扩展消息","desktop.noMessage":"(无消息)","desktop.showExtensionMessage":"显示扩展消息","desktop.copied":"已复制","desktop.copy":"复制","desktop.collapse":"收起","desktop.expand":"展开","desktop.hideDetails":"隐藏详情","desktop.showDetails":"显示详情","desktop.before":"之前","desktop.after":"之后","desktop.noOutput":"(无输出)","desktop.extension":"扩展","desktop.assistant":"助手","desktop.favorites":"收藏","desktop.favorite":"收藏","desktop.unfavorite":"取消收藏","desktop.processStepThinking":"思考","desktop.processStepFileRead":"读取","desktop.processStepFileCreate":"创建","desktop.processStepFileEdit":"编辑","desktop.processStepFileDelete":"删除","desktop.processStepSearch":"搜索","desktop.processStepFind":"查找","desktop.processStepList":"列出","desktop.processStepRead":"读取","desktop.processStepFetch":"抓取","desktop.processStepDelete":"删除","desktop.processStepCopy":"复制","desktop.processStepCommand":"运行","desktop.processStepTool":"工具","desktop.processStepTodo":"待办","desktop.processStepArtifact":"产物","desktop.processStepCompaction":"压缩","desktop.processStepError":"错误","desktop.processWorking":"工作中...","desktop.processUsed":"使用了 {summary}","desktop.processToolCount":"{count} 个工具","desktop.processToolsCount":"{count} 个工具","desktop.processFailedCount":"({failed} 个失败)","desktop.processThoughtCount":"{count} 条思考","desktop.processThoughtsCount":"{count} 条思考","desktop.processThoughtDone":"已思考 {duration}s","desktop.processThoughtDoneNoDuration":"已思考","desktop.processCustomCount":"{count} 个事件","desktop.processCustomsCount":"{count} 个事件","desktop.processCompleted":"处理完成","desktop.processOutput":"处理输出","desktop.processTabMode":"标签页模式","desktop.processTimelineMode":"时间线模式","desktop.processFailedStep":"失败","desktop.markdownPreviewAvailableAfterStreaming":"流式输出结束后可预览","desktop.markdownPreviewMermaidDiagram":"预览 Mermaid 图表","desktop.markdownInvalidMermaidDiagram":"无效的 Mermaid 图表","desktop.markdownRenderingMermaidDiagram":"正在渲染 Mermaid 图表","desktop.openMermaidViewer":"打开 Mermaid 查看器","desktop.mermaidDiagram":"Mermaid 图表","desktop.mermaidViewer":"Mermaid 图表查看器","desktop.zoomPanHint":"拖动平移 \xb7 滚轮缩放","desktop.selectText":"选择文本","desktop.zoomOut":"缩小","desktop.resetZoom":"重置为 100%(适应窗口)","desktop.zoomIn":"放大","desktop.fitToViewport":"适应窗口","desktop.quoteReply":"引用回复","desktop.quoteReplyHint":"点击引用回复","desktop.openFile":"打开","desktop.queueRecoveryTitle":"恢复排队消息","desktop.queueImportTitle":"导入的排队消息","desktop.queueRecoveryDescription":"这些消息在上一个服务会话结束前已保存。请选择要重新入队的消息;系统不会自动发送。","desktop.queueImportDescription":"请选择要重新入队的导入消息;系统不会自动发送。","desktop.selectAll":"全选","desktop.selectNone":"取消全选","desktop.import":"导入","desktop.queueImages":"图片附件","desktop.queueNoText":"(仅图片消息)","desktop.queueExported":"已导出 {count} 条消息","desktop.queueImportEmpty":"未找到有效的排队消息","desktop.queueImported":"已导入 {count} 条消息,等待确认","desktop.dismiss":"暂不处理","desktop.discard":"丢弃","desktop.requeue":"重新入队","desktop.requeueAndContinue":"重新入队并继续","desktop.markdownPlainText":"文本","desktop.hideTaskBoard":"隐藏任务看板","desktop.showTaskBoard":"显示任务看板","tasks.actionArchive":"归档","tasks.stashDone":"变更已成功暂存","tasks.actionCancel":"取消","tasks.actionEdit":"编辑","tasks.actionMerge":"合并","tasks.actionRequeue":"重新排队","tasks.actionRetry":"重试","tasks.actionReturn":"退回反馈","tasks.actionStart":"开始","tasks.actionComplete":"直接完成","tasks.actionUnarchive":"取消归档","tasks.actionViewSession":"查看会话","tasks.allFolders":"全部项目","tasks.archiveAllDone":"全部归档","tasks.badgeCleanupFailed":"清理失败","tasks.badgeWorktreeKept":"保留 worktree","tasks.beta":"Beta","tasks.cancelDescription":"任务将停止。可以留下取消原因,方便之后重新排队时了解背景(可选)。","tasks.cancelKeep":"保留任务","tasks.cancelReasonLabel":"取消原因(可选)","tasks.cancelReasonPlaceholder":"例如:方案不对、需求变了…","tasks.cancelSubmit":"取消任务","tasks.cancelTitle":"取消任务","tasks.changedFiles":"变更文件","tasks.colAttention":"待处理","tasks.colDone":"已完成","tasks.colInProgress":"进行中","tasks.colTodo":"待办","tasks.delete":"删除","tasks.deleteConfirm":"确认删除","tasks.deleteTemplate":"删除模板","tasks.deleteWorktree":"同时删除 worktree","tasks.diff":"差异","tasks.dropToStart":"松手启动","tasks.editTitle":"编辑任务","tasks.empty":"还没有任务","tasks.emptyColAttention":"没有需要你处理的任务","tasks.emptyColDone":"还没有完成的任务","tasks.emptyColInProgress":"没有正在执行的任务","tasks.emptyColTodo":"暂无待办任务","tasks.emptyHint":"创建一个任务,看板会驱动它完成整个流程——启动后会在 worktree 分支里运行 agent 直到结束。","tasks.errorView":"查看","tasks.event_archived":"已归档","tasks.event_canceled":"已取消","tasks.event_created":"已创建","tasks.event_failed":"失败","tasks.event_interrupted":"已中断","tasks.event_merge_failed":"合并失败","tasks.event_merge_requested":"合并请求","tasks.event_merged":"已合并","tasks.event_merging":"合并中","tasks.event_preflight_failed":"预检失败","tasks.event_preflight_passed":"预检通过","tasks.event_preflight_start":"预检运行中","tasks.event_preparing":"准备中","tasks.event_queued":"已排队","tasks.event_recovered":"已恢复","tasks.event_requeued":"已重新排队","tasks.event_return_feedback":"反馈","tasks.event_returned":"已退回","tasks.event_review":"待验收","tasks.event_started":"已启动","tasks.event_unarchived":"已取消归档","tasks.event_updated":"已更新","tasks.fieldProject":"项目","tasks.fieldPrompt":"任务说明","tasks.fieldPromptPlaceholder":"描述 agent 需要完成的工作…","tasks.fieldTitle":"标题","tasks.fieldTitlePlaceholder":"任务的简短标题","tasks.filter":"筛选","tasks.loading":"加载中…","tasks.mergeAutoMessage":"让 agent 自动写提交信息","tasks.mergeConfirm":"合并","tasks.mergeDeleteWorktree":"合并后删除 worktree","tasks.mergeManualMessage":"手动填写提交信息","tasks.mergeMessagePlaceholder":"提交信息…","tasks.mergeStrategyMerge":"合并提交","tasks.mergeStrategySquash":"压缩提交","tasks.mergeTitle":"合并任务","tasks.completeDeleteWorktree":"完成后删除 worktree","tasks.completeDescription":"该任务没有产生任何文件变更,无需合并。确认后直接标记为完成。","tasks.completeSubmit":"确认完成","tasks.completeTitle":"完成任务","tasks.followUpPlaceholderRequeue":"给 agent 的备注(可选)…","tasks.followUpPlaceholderRetry":"给 agent 的备注(可选)…","tasks.actionAddNote":"备注(可选)","tasks.restartDescription":"备注会注入下一次运行的提示词中(可选)。","tasks.restartTitleRequeue":"重新排队","tasks.restartTitleRetry":"重试","tasks.planReviewTitle":"计划已完成","tasks.planReviewDescription":"计划模式的分析已结束。你可以确认执行这份计划、提出建议继续完善,或退出计划模式。","tasks.planReviewShowPlan":"查看计划","tasks.planReviewHidePlan":"收起计划","tasks.planReviewExecute":"确认执行","tasks.planReviewExecutePrompt":"请按以下计划执行:\n\n{plan}","tasks.planReviewSuggest":"提出建议","tasks.planReviewSendFeedback":"发送建议","tasks.planReviewFeedbackLabel":"建议(将返回给 agent 继续完善计划)","tasks.planReviewFeedbackPlaceholder":"例如:先补充风险分析,拆分更细的步骤…","tasks.planReviewExit":"退出计划","tasks.metaCommit":"提交","tasks.metaCreated":"创建于","tasks.metaProject":"项目","tasks.new":"新建任务","tasks.newTitle":"新建任务","tasks.noDiff":"暂无差异","tasks.noEvents":"暂无事件","tasks.notifyFailed":"{title} 执行失败","tasks.notifyReview":"{title} 等待验收","tasks.returnPlaceholder":"给 agent 的反馈…","tasks.returnSubmit":"退回","tasks.save":"保存","tasks.saveAsTemplate":"存为模板","tasks.sessionFile":"会话文件","tasks.sessionHint":"任务的 agent 会话与其他会话一样存储。在会话列表中打开即可查看或继续。","tasks.sessionId":"会话 ID","tasks.sessionTitle":"任务会话","tasks.settingsAutoProcess":"自动处理排队任务","tasks.settingsDeleteWorktree":"合并后默认删除 worktree","tasks.settingsInitCommand":"初始化命令(agent 启动前在 worktree 中执行)","tasks.settingsInitPlaceholder":"例如 pnpm install","tasks.settingsMaxConcurrent":"最大并发任务数(0 = 不限)","tasks.settingsMergeStrategy":"合并策略","tasks.settingsNoProject":"先创建一个任务以选择项目。","tasks.settingsPreflightCommand":"预检命令(验收检查)","tasks.settingsPreflightPlaceholder":"例如 npm test","tasks.settingsProject":"项目","tasks.settingsReset":"恢复默认设置","tasks.settingsStagePrompts":"阶段提示词(附加指令)","tasks.settingsTitle":"任务设置","tasks.showArchived":"显示已归档","tasks.showCanceled":"显示已取消","tasks.stage_merge":"合并","tasks.stage_retry":"重试","tasks.stage_return":"退回","tasks.stage_work":"执行","tasks.startAll":"全部启动","tasks.statusAwaitingInput":"等待输入","tasks.statusCanceled":"已取消","tasks.statusDone":"已完成","tasks.statusFailed":"失败","tasks.statusInterrupted":"已中断","tasks.statusMerging":"合并中","tasks.statusPreparing":"准备中","tasks.statusQueued":"排队中","tasks.statusReview":"待验收","tasks.statusRunning":"运行中","tasks.statusTodo":"待办","tasks.templateNamePlaceholder":"模板名称…","tasks.templates":"模板","tasks.timeline":"时间线","tasks.title":"任务","tasks.attentionBadge":"条待处理","sidebar.checking":"检查中…","sidebar.open":"打开","sidebar.cancel":"取消","sidebar.openRepoRoot":"打开仓库根目录","sidebar.openRepoRootTitle":"打开仓库根目录以管理 worktree。","sidebar.gitRepoRootOnly":"仅 Git 仓库根目录","sidebar.gitRepoRootOnlyTitle":"只能在 Git 仓库根目录使用 worktree。","sidebar.worktrees":"Worktrees...","sidebar.checkingWorktrees":"正在检查此目录的 worktree。","sidebar.filterWorktrees":"筛选 worktree…","sidebar.noMatchingWorktrees":"没有匹配的 worktree","sidebar.switchWorktree":"切换 worktree","sidebar.switchWorktreeTitle":"切换 worktree:{path}","sidebar.main":"主分支","sidebar.forceRemoveCheckout":"存在未提交的更改。强制移除 checkout?","sidebar.force":"强制移除","sidebar.createWorktreeTitle":"为分支创建 worktree checkout","sidebar.newWorktree":"新建 worktree…","sidebar.branchName":"分支名称","sidebar.creating":"创建中…","sidebar.create":"创建","sidebar.uploadFilesTitle":"将文件上传到项目根目录","sidebar.uploadFiles":"上传文件","sidebar.refreshExplorer":"刷新文件浏览器","sidebar.searchSessions":"搜索所有对话...","sidebar.toggleSessionSearch":"搜索对话","sidebar.sessionSearching":"搜索中...","sidebar.sessionSearchEmpty":"没有匹配的对话","sidebar.sessionSearchCount":"{count} 个匹配的对话","sidebar.sessionSearchPartial":"已达到搜索上限,结果可能不完整。","sidebar.sessionSearchFailed":"无法搜索对话","sidebar.changedFiles":"{count} 个变更文件","sidebar.loading":"加载中...","sidebar.noSessions":"未找到会话","sidebar.agentRunning":"Agent 运行中…","sidebar.newActivity":"有新活动","sidebar.newSessionActivity":"会话有新活动","sidebar.deleteSession":"删除 {title}?","sidebar.rename":"重命名","sidebar.delete":"删除","sidebar.deleteWithShiftClick":"删除(按住 Shift 点击可跳过确认)","sidebar.expandSubagents":"展开子智能体","sidebar.collapseSubagents":"折叠子智能体","sidebar.messagesCount":"{count} 条消息","sidebar.worktreePath":"Worktree:{path}","sidebar.removeWorktreeTitle":"移除 worktree checkout {path};保留分支","files.modified":"已修改","files.added":"已添加","files.deleted":"已删除","files.renamed":"已重命名","files.untracked":"未跟踪","files.conflict":"冲突","files.newlyUploaded":"刚上传","files.containsChangedFiles":"包含已更改文件","files.insertPath":"将路径插入聊天","files.mention":"提及","files.download":"下载文件","files.dismissError":"关闭错误","files.addUploadedFile":"将上传的文件添加到聊天","files.addAllUploadedFiles":"将所有上传的文件添加到聊天","files.dismissUploadResults":"关闭上传结果","files.loading":"正在加载文件...","files.noFiles":"未找到文件","files.explorer":"文件浏览器","files.changedCount":"{count} 个文件","files.changeStats":"{count} 个变更文件,新增 {additions} 行,删除 {deletions} 行","files.conflictSummary":"已有 {count} 个文件:{files}","files.cannotReplace":"无法替换:{files}","files.replace":"替换","files.skipExisting":"跳过已有文件","files.cancel":"取消","files.checking":"正在检查文件","files.uploading":"正在上传,{progress}%","files.edit":"编辑","files.save":"保存","files.saveHint":"保存(Cmd/Ctrl+S)","files.cancelEdit":"取消编辑","files.saveFailed":"保存失败:{error}","files.unsavedChanges":"放弃未保存的改动?","files.externalModified":"文件已被外部修改。重新加载以获取最新版本。","files.reload":"重新加载","files.reloadOverwriteConfirm":"用磁盘上的版本覆盖未保存的改动?","files.newFile":"新建文件","files.newFolder":"新建文件夹","files.delete":"删除","files.promptFileName":"文件名","files.promptFolderName":"文件夹名","files.confirmDeleteFile":"删除“{name}”?此操作无法撤销。","files.confirmDeleteDirectory":"删除“{name}”及其所有内容?此操作无法撤销。","chat.loadingSession":"正在加载会话...","chat.runningTool":"正在运行工具...","chat.generatingToolInput":"正在生成参数...","chat.runningNamedTool":"正在运行 {name}...","chat.runningTools":"正在运行 {names}...","chat.runningToolsMore":"正在运行 {names}(另有 {count} 个)...","chat.waitingModel":"正在等待模型...","chat.runningCommand":"正在运行命令...","chat.thinking":"正在思考...","chat.processDetails":"处理详情","chat.message":"条消息","chat.messages":"条消息","chat.toolCall":"次工具调用","chat.toolCalls":"次工具调用","chat.collapseProcess":"收起处理详情","chat.expandProcess":"展开处理详情","chat.filesWritten":"改动的文件","chat.openWrittenFile":"打开 {name}","chat.loadEarlier":"向上滚动以加载更早的消息","chat.extensionRequest":"扩展请求","chat.extensionExpiresIn":"{seconds} 秒后过期","chat.extensionPending":"待回答","chat.extensionCollapse":"收起","chat.extensionExpand":"展开","chat.cancel":"取消","chat.confirm":"确认","chat.submit":"提交","chat.extensionInput":"扩展终端输入","chat.extensionPanel":"扩展面板","chat.extensionWidgets":"扩展组件","chat.extensionWidgetAbove":"输入框上方组件","chat.extensionWidgetBelow":"输入框下方组件","chat.extensionWidgetLine":"{count} 行","chat.extensionWidgetLines":"{count} 行","chat.close":"关闭","chat.queued":"已排队 \xb7 {count}","chat.recall":"移回输入框","chat.recallTitle":"移除所有排队消息并将其放回输入框编辑","chat.retrying":"正在重试({attempt}/{max})…","chat.loadingCommands":"正在加载命令...","chat.slashCommands":"斜杠命令 \xb7 {label}","chat.tabEnter":"Tab / Enter","chat.noCommands":"未找到扩展、提示词或技能命令","chat.match":"1 个匹配项","chat.matches":"{count} 个匹配项","chat.command":"1 个命令","chat.commands":"{count} 个命令","chat.loadingFiles":"正在加载文件...","chat.files":"文件 \xb7 {label}{hint}","chat.searching":"搜索中…","chat.noMatchingFiles":"未找到匹配的文件","chat.searchingAll":" \xb7 正在搜索所有文件…","chat.indexTruncated":" \xb7 索引不完整","chat.steerPlaceholder":"立即引导 / 排队后续消息...","chat.agentPlaceholder":"Agent 运行中…","chat.messagePlaceholder":"消息…输入 / 使用命令,输入 @ 查找文件","chat.steer":"引导","chat.followUp":"后续消息","chat.steerHint":"中断当前运行并立即注入此消息","chat.followUpHint":"在 Agent 完成后排队此消息","chat.inputHistory":"输入历史","chat.modelError":"模型错误","chat.modelScopeWarning":"模型范围警告","chat.modelScopeWarnings":"模型范围警告","chat.send":"发送","chat.askSelection":"询问选中的文字","chat.askInCurrent":"在当前对话询问","chat.askInNewChat":"在新对话询问","chat.newQuoteChat":"关于选中文字的新对话","chat.quoteIntro":"关于这段内容:","chat.quoteQuestion":"我的问题是:","chat.quoteForkFailed":"无法从这条消息创建分支。","chat.attachImage":"附加图片","chat.previewImage":"预览图片","chat.filterModels":"筛选模型…","chat.noMatchingModels":"没有匹配的模型","chat.moreControls":"更多控件","chat.collapseControls":"收起控件","chat.shell":"Shell","terminal.title":"终端","terminal.tabLabel":"终端:{name}","terminal.open":"打开工作区终端","terminal.close":"终止终端","terminal.restart":"重启终端","terminal.reconnect":"重新连接终端","terminal.connecting":"连接中","terminal.ready":"已连接","terminal.exited":"终端已关闭","terminal.error":"连接错误","terminal.exitCode":"进程已退出,退出码 {code}","chat.outputLocal":"输出保留在本地","chat.outputModel":"输出发送给模型","chat.chatOnly":"仅聊天","chat.readOnlyTools":"{count} 个只读内置工具","chat.builtInTools":"{count} 个内置工具","chat.allBuiltInTools":"全部内置工具","chat.changeReasoning":"更改推理级别:{level}","chat.changeReasoningLabel":"更改推理级别","chat.changeToolPreset":"更改工具预设","chat.stopCompaction":"停止压缩","chat.compactContext":"压缩上下文","chat.compacting":"正在压缩…","chat.compact":"压缩","chat.stopAgent":"停止 Agent","chat.stop":"停止","chat.disableSound":"关闭完成提示音","chat.enableSound":"开启完成提示音","chat.thinkingUseDefault":"使用 pi 默认设置","chat.thinkingOff":"关闭推理","chat.thinkingMinimal":"最低限度推理","chat.thinkingLow":"低强度推理","chat.thinkingMedium":"中等强度推理","chat.thinkingHigh":"高强度推理","chat.thinkingXhigh":"超高强度推理","chat.thinkingMax":"最高强度推理","chat.builtIn":"内置","chat.extensions":"扩展","chat.prompts":"提示词","chat.skills":"技能","chat.dormant":"休眠","chat.commandCompact":"压缩上下文,可选附加说明","chat.commandReload":"重新加载扩展、技能、提示词和工具","chat.commandName":"设置会话显示名称","chat.commandSession":"显示会话消息、Token 和费用统计","chat.commandCopy":"复制最后一条助手消息","chat.commandClone":"将当前分支复制为独立新会话","chat.compacted":"已压缩","chat.imageNotSupportedTitle":"图片可能无法发送","chat.imageNotSupportedBody":"当前选择的模型({model})不支持图片输入,附加的图片可能会被忽略。","chat.tokensSaved":"节省 {saved}","i18n.copy":"复制","i18n.copied":"已复制","i18n.save":"保存","i18n.saving":"保存中…","i18n.saved":"已保存","i18n.remove":"移除","i18n.removing":"移除中…","i18n.delete":"删除","i18n.loading":"加载中...","i18n.search":"搜索","i18n.refresh":"刷新","i18n.update":"更新","i18n.updating":"更新中...","i18n.check":"检查","i18n.install":"安装","i18n.installing":"安装中...","i18n.noResults":"没有结果","i18n.searchProviders":"搜索 Provider…","i18n.noProviders":"没有匹配的 Provider","i18n.newModel":"新模型","i18n.addProvider":"添加 Provider","i18n.selectProviderModel":"选择 Provider 或模型","i18n.visibleInPrompt":"在模型提示词中可见,点击以禁用","i18n.hiddenFromPrompt":"在模型提示词中隐藏,点击以启用","i18n.dormant":"休眠","i18n.hiddenButInvocable":"对模型隐藏,仍可手动调用","i18n.skillSearchPlaceholder":"例如 react、testing、deploy","i18n.searching":"搜索中…","i18n.noSkills":"未找到技能","i18n.checkUpdates":"检查更新","i18n.updates":"项更新","i18n.noResolvedResources":"没有已解析资源","i18n.enablePackage":"启用包","i18n.disablePackage":"禁用包","i18n.filtered":"已筛选","i18n.openSessionToReload":"打开会话后才能重新加载","i18n.notFound":"未找到","i18n.noPlugins":"未配置插件","trust.resourcesNotLoaded":"受限模式","trust.trustProject":"信任项目","trust.trusting":"正在信任...","trust.cancel":"取消","trust.dialogTitle":"信任此项目?","trust.dialogBody":"项目资源可以运行本地代码。请仅信任你了解其内容的项目。","trust.skillsNotLoaded":"此项目尚未受信任,项目技能未加载。","trust.pluginsNotLoaded":"此项目尚未受信任,项目插件未加载。","trust.projectScopeUnavailable":"项目资源未加载时,无法安装到项目范围。","i18n.creatingSession":"正在创建新会话…","i18n.creating":"创建中…","i18n.subscription":"订阅","i18n.subscriptions":"订阅服务","i18n.customEndpoint":"自定义端点格式","i18n.noChanges":"没有更改","i18n.branches":"分支","i18n.noActiveSession":"没有活动会话","i18n.noBranches":"此会话没有分支","i18n.source":"源代码","i18n.preview":"预览","i18n.diff":"Diff","i18n.downloadFile":"下载文件","i18n.liveSync":"实时同步已启用","i18n.notWatching":"未监视","i18n.fileViewMode":"文件视图模式","i18n.compareHead":"比较工作区与 HEAD","i18n.mentionSelectedLines":"提及所选行","i18n.disableWrap":"禁用自动换行","i18n.enableWrap":"启用自动换行","i18n.htmlPreview":"HTML 预览","i18n.previewFile":"预览 {file}","i18n.invalidMermaid":"Mermaid 图表无效","i18n.renderingMermaid":"正在渲染 Mermaid 图表","i18n.previewAfterStreaming":"流式输出完成后可预览","i18n.showMermaidSource":"显示 Mermaid 源码","i18n.previewMermaid":"预览 Mermaid 图表","i18n.openMermaidViewer":"打开图表查看器","i18n.mermaidViewer":"Mermaid 图表查看器","i18n.mermaidDiagram":"Mermaid 图表","i18n.zoomOut":"缩小","i18n.zoomIn":"放大","i18n.fitToWidth":"适应宽度","models.discoveryFetching":"正在导入模型…","models.discoveryFetch":"导入模型…","models.discoveryFilterPlaceholder":"筛选 {count} 个模型…","models.discoveryFilter":"筛选上游模型","models.discoverySelectShown":"选择当前结果","models.discoveryNoMatches":"没有匹配的模型。","models.discoveryAdded":"已添加","models.discoveryShowing":"显示前 {shown} 个,共 {total} 个","models.discoveryFetched":"已获取 {count} 个模型","models.discoveryAddSelected":"添加所选模型","models.discoveryAddSelectedCount":"添加所选模型({count})","models.catalogSource":"来源:models.dev ↗","models.catalogFilling":"正在填入模型信息…","models.catalogFill":"填入模型信息","models.catalogFilled":"已填入 {count} 个字段","models.catalogNoEmptyFields":"没有需要填入的空字段","models.catalogNoExactMatch":"models.dev 中没有精确匹配","models.catalogPriceProvider":"价格已匹配 Provider {provider}","models.catalogPriceBaseUrl":"价格已按 Base URL 匹配 {provider}","models.catalogPriceConsensus":"价格得到 {support}/{total} 条记录支持","models.catalogPriceUnreliable":"未找到可靠价格","models.catalogUndo":"撤销","models.capabilities":"能力","models.reasoning":"推理 / 思考","models.imageInput":"图片输入","models.modelSpecs":"模型规格","models.contextWindow":"上下文窗口(tokens)","models.maxOutputTokens":"最大输出 tokens","models.costPerMillion":"每百万 tokens 价格","models.costInput":"输入","models.costOutput":"输出","models.costCacheRead":"缓存读取","models.costCacheWrite":"缓存写入","models.notProvided":"未提供","models.editCosts":"编辑价格","models.finishEditingCosts":"完成","models.costAllRequired":"请输入有效的非负价格;留空项将按 0 保存。","models.advancedSettings":"高级设置","models.providerDefaults":"沿用 Provider 默认设置","models.headersSummary":"Headers:{count}","models.compatSummary":"兼容性:{count}","models.thinkingSummary":"思考等级:{count}","models.apiOverride":"API 覆盖","models.headers":"Headers","models.headersHelp":"仅添加到该模型的请求中,并覆盖 Provider 的同名 Header。","models.compatibility":"兼容性","models.deepSeekThinkingCompat":"DeepSeek 思考兼容","models.developerRole":"使用 developer role 传递系统提示词","models.thinkingLevelMap":"思考等级映射","models.clearAll":"全部清除","i18n.testingModel":"正在测试模型连接...","i18n.connected":"已连接","i18n.failed":"失败","i18n.test":"测试","i18n.testConnection":"测试模型连接","i18n.provider":"Provider","i18n.model":"模型","i18n.providerName":"Provider 名称","i18n.rename":"重命名","i18n.default":"默认","i18n.disabled":"已禁用","i18n.noResources":"没有资源","i18n.unknown":"未知","i18n.installedVersion":"已安装 {version}","i18n.configuredVersion":"已配置 {version}","i18n.extensions":"扩展","i18n.prompts":"提示词","i18n.themes":"主题","i18n.resourceCount":"{count}{label}","i18n.extensionShort":"扩展","i18n.skillShort":"技能","i18n.promptShort":"提示词","i18n.themeShort":"主题","i18n.custom":"自定义","i18n.clearAll":"清除全部","i18n.connectedSuccessfully":"连接成功。","i18n.notConnected":"未连接","i18n.configured":"已配置","i18n.notConfigured":"未配置","i18n.openingBrowser":"正在打开浏览器…","i18n.submit":"提交","i18n.login":"登录","i18n.relogin":"重新登录","i18n.disconnect":"断开连接","i18n.networkError":"网络错误","i18n.continuing":"继续中…","i18n.skills":"技能","i18n.plugins":"插件","i18n.addSkill":"添加技能","i18n.addPlugin":"添加插件","i18n.selectSkill":"选择技能","i18n.selectPackage":"选择包","i18n.updateAvailable":"有可用更新","i18n.upToDate":"已是最新","i18n.automaticChecksUnavailable":"自动检查不可用","i18n.checkFailed":"检查失败","i18n.installed":"已安装","i18n.status":"状态","i18n.version":"版本","i18n.package":"包","i18n.resources":"资源","i18n.installedPath":"安装路径","i18n.cwd":"CWD","i18n.resolvedResources":"已解析资源","i18n.reloadSession":"重新加载会话","i18n.reloading":"重新加载中...","i18n.packageRemoved":"包已移除。","i18n.packageInstalled":"包已安装。","i18n.packageUpdated":"包已更新。","i18n.packagesUpdated":"所有插件已更新。","i18n.updateAllPlugins":"更新全部","i18n.updateAllPluginsHint":"更新所有已配置的插件","i18n.packageDisabled":"包已禁用。","i18n.packageEnabled":"包已启用。","i18n.sessionReloaded":"会话已重新加载。","i18n.thinking":"思考","i18n.largeMessageReveal":"消息内容过大({size})。点击以纯文本查看 — 已禁用 markdown 渲染以避免页面卡顿。","i18n.loadingThinking":"正在加载思考内容...","i18n.copyMessage":"复制消息","i18n.editFromHere":"从此处编辑","i18n.editFromHereTitle":"从此处编辑,此会话内创建分支","i18n.newSession":"新会话","i18n.newSessionTitle":"新会话,从此处创建独立副本","i18n.estimatedTokens":"流式输出期间的估算 Token 数","i18n.noOutput":"(无输出)","i18n.openImage":"打开图片","i18n.noSummary":"(无摘要)","i18n.conversationCompacted":"会话已压缩","i18n.compactionDescription":"此处之前的会话历史已压缩为以下摘要:","i18n.fileContext":"文件上下文:{details}","i18n.readFiles":"读取的文件","i18n.modifiedFiles":"修改的文件","i18n.hiddenExtensionMessage":"隐藏的扩展消息","i18n.noMessage":"(无消息)","i18n.showExtensionMessage":"显示扩展消息","i18n.collapse":"收起","i18n.expand":"展开","i18n.hideDetails":"隐藏详情","i18n.showDetails":"显示详情","i18n.thinkingUnavailable":"思考内容不可用","i18n.before":"之前","i18n.after":"之后","i18n.sessionComplete":"任务完成","i18n.taskFinished":"任务已完成。","i18n.attentionNeeded":"Pi 需要你的操作","i18n.extensionInputNeeded":"扩展正在等待你的输入。"}});let l="pi-locale",d=(0,n.createContext)(null);function c({children:e}){let[t,o]=(0,n.useState)("en"),[i,p]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=function(){try{let e=window.localStorage.getItem(l);if("en"===e||"zh-CN"===e)return e}catch{}for(let e of window.navigator.languages.length?window.navigator.languages:[window.navigator.language]){let t=e.toLowerCase();if("en"===t||t.startsWith("en-"))break;if("zh"===t||"zh-cn"===t||t.startsWith("zh-cn-")||"zh-sg"===t||t.startsWith("zh-sg-")||"zh-hans"===t||t.startsWith("zh-hans-")||"zh-tw"===t||t.startsWith("zh-tw-")||"zh-hk"===t||t.startsWith("zh-hk-")||"zh-mo"===t||t.startsWith("zh-mo-")||"zh-hant"===t||t.startsWith("zh-hant-")||t.startsWith("zh-"))return"zh-CN"}return"en"}();o(e),document.documentElement.lang=e,p(!0)},[]);let u=(0,n.useMemo)(()=>(function(){let e=a("en"),t=a("zh-CN");if(!e||!t)throw Error("Built-in locales must be registered before rendering I18nProvider");return{en:e.messages,"zh-CN":t.messages}})(),[]),h=(0,n.useMemo)(()=>[...s.keys()].map(e=>a(e)).filter(e=>!!e),[]),g=(0,n.useCallback)(e=>{if(a(e)){o(e);document.documentElement.lang=e,document.documentElement.dataset.language=e;try{window.localStorage.setItem(l,e)}catch{}}},[]),m=(0,n.useCallback)((e,o)=>(function(e,t,o,r={}){let n=o[e]?.[t]??o.en?.[t];return void 0===n?t:function(e,t={}){return e.replace(/\{([\w.-]+)\}/g,(e,o)=>{let r=t[o];return void 0===r?e:String(r)})}(n,r)})(t,e,u,o),[t,u]),f=(0,n.useMemo)(()=>({locale:t,setLocale:g,t:m,supportedLocales:h}),[t,g,m,h]);return(0,r.jsx)(d.Provider,{value:f,children:i?e:null})}function p(){let e=(0,n.useContext)(d);if(!e)throw Error("useI18n must be used inside I18nProvider");return e}},55600:(e,t,o)=>{"use strict";o.d(t,{AppShell:()=>py});var r=o(95155),n=o(12115),s=o(53516),i=o(73321);let a=null;class l extends Error{constructor(e,t){super(e),this.code=t,this.name="SessionTitleClientError"}}async function d(e,t){let o=await fetch(`/api/sessions/${encodeURIComponent(e)}/auto-name`,{method:"POST",signal:t}),r=await o.json().catch(()=>({}));if(!o.ok||!r.title)throw new l(r.error||`HTTP ${o.status}`,r.code);return{title:r.title,usage:r.usage}}async function c(e){try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/auto-name`,{method:"DELETE"}),o=await t.json().catch(()=>({}));return t.ok&&!0===o.cancelled}catch{return!1}}var p=o(47650),u=o(25349),h=o(64178),g=o(9720),m=o(98664),f=o(20077),x=o(49467),k=o(56123),v=o(6033),y=o(85265),b=o(94125),w=o(25388),j=o(3083),S=o(73988),C=o(41780),T=o(11693),R=o(77862),z=o(19157),I=o(72422),M=o(5085),P=o(80388),E=o(36824),W=o(42515),F=o(44368);function D(e,t){if(e.size!==t.size)return!1;for(let o of e)if(!t.has(o))return!1;return!0}var A=o(39247);let N="(max-width: 640px)",L=e=>(function(e,t){if(!window.matchMedia)return()=>{};let o=window.matchMedia(e);return o.addEventListener("change",t),()=>o.removeEventListener("change",t)})(N,e),$=()=>!!window.matchMedia&&window.matchMedia(N).matches;function H(){return!1}function O(){return(0,n.useSyncExternalStore)(L,$,H)}async function B(e){let t=e?`?path=${encodeURIComponent(e)}`:"",o=await fetch(`/api/cwd/browse${t}`),r=await o.json();if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);return r}function U(){return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M1.5 3h4l1.5 2h7.5v7.5h-13z"})})}function _(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,r.jsx)("path",{d:"M2 9h12"}),(0,r.jsx)("circle",{cx:"11.5",cy:"11",r:"0.6",fill:"currentColor",stroke:"none"})]})}function q({onCancel:e,onSelect:t,initialPath:o,busy:s=!1,error:i}){let a,{t:l}=(0,A.s)(),[d,c]=(0,n.useState)(null),[u,h]=(0,n.useState)(""),[g,m]=(0,n.useState)(null),[f,x]=(0,n.useState)([]),[k,v]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),[w,j]=(0,n.useState)(!0),[S,C]=(0,n.useState)(""),T=(0,n.useCallback)(async e=>{j(!0),b(null),C("");try{let t=await B(e),o=t.path??e??"/";h(o),m(t.parentPath??null),x(t.directories??[]),v(t.drives??null)}catch(e){b(e instanceof Error?e.message:String(e))}finally{j(!1)}},[]);(0,n.useEffect)(()=>{c(document.body),T(o||void 0)},[o,T]);let R=!!u&&!s,z=!!g||/^[a-zA-Z]:[\\/]?$/.test(u);return d?(0,p.createPortal)((0,r.jsx)("div",{className:"directory-picker-backdrop",role:"dialog","aria-modal":"true","aria-label":l("directoryPicker.selectDirectory"),onClick:t=>{t.target!==t.currentTarget||s||e()},onKeyDown:t=>{"Escape"!==t.key||s||e()},style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.35)"},children:(0,r.jsxs)("div",{className:"directory-picker-panel",style:{width:520,maxWidth:"calc(100vw - 16px)",height:"min(620px, calc(100dvh - 16px))",maxHeight:"calc(100dvh - 16px)",display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 8px 32px rgba(0,0,0,0.18)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,padding:"12px 18px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("div",{style:{minWidth:0,flex:1},children:(0,r.jsx)("div",{style:{color:"var(--text)",fontWeight:700,fontSize:15},children:l("directoryPicker.selectDirectory")})}),(0,r.jsx)("button",{type:"button",onClick:e,disabled:s,title:l("i18n.close"),"aria-label":l("i18n.close"),style:{padding:"2px 6px",border:0,background:"none",color:"var(--text-muted)",fontSize:20,lineHeight:1,cursor:s?"default":"pointer",opacity:s?.5:1},children:"\xd7"})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0,padding:"10px 14px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("button",{className:"directory-picker-back",type:"button",onClick:()=>void T(g??void 0),disabled:w||!z,title:l("directoryPicker.goToParent"),"aria-label":l("directoryPicker.goToParent"),style:{width:36,height:36,padding:0,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-hover)",color:"var(--text-muted)",cursor:z?"pointer":"default",opacity:z?1:.45},children:(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"m18 15-6-6-6 6"})})}),(0,r.jsx)("div",{title:u,style:{minWidth:0,flex:1,height:36,display:"flex",alignItems:"center",padding:"0 10px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u||l("directoryPicker.loadingDirectories")})]}),(0,r.jsxs)("div",{className:"directory-picker-list",style:{flex:1,minHeight:0,overflow:"auto",padding:"8px 10px"},children:[w?(0,r.jsx)("div",{style:{padding:8,color:"var(--text-dim)",fontSize:11},children:l("directoryPicker.loadingDirectories")}):null!==k?(0,r.jsx)(r.Fragment,{children:k.length>0?k.map(e=>(0,r.jsxs)("button",{className:"directory-picker-entry",type:"button",onClick:()=>void T(e.path),title:e.path,style:{width:"100%",minHeight:34,display:"flex",alignItems:"center",gap:7,padding:"6px 8px",border:0,borderRadius:5,background:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-mono)",fontSize:11},children:[(0,r.jsx)(_,{}),(0,r.jsx)("span",{children:e.name})]},e.path)):(0,r.jsx)("div",{style:{padding:8,color:"var(--text-dim)",fontSize:11},children:l("directoryPicker.noDrives")})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{type:"text",value:S,onChange:e=>C(e.target.value),placeholder:l("directoryPicker.filterPlaceholder"),"aria-label":l("directoryPicker.filterPlaceholder"),style:{width:"100%",boxSizing:"border-box",marginBottom:6,padding:"5px 9px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:11,outline:"none"}}),(a=function(e,t){if(null===t||""===t)return[...e];let o=t.trim().toLowerCase();return o?e.filter(e=>e.name.toLowerCase().includes(o)):[...e]}(f,S)).length>0?a.map(e=>(0,r.jsxs)("button",{className:"directory-picker-entry",type:"button",onClick:()=>void T(e.path),title:e.path,style:{width:"100%",minHeight:30,display:"flex",alignItems:"center",gap:7,padding:"5px 8px",border:0,borderRadius:5,background:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-mono)",fontSize:11},children:[(0,r.jsx)(U,{}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.path)):(0,r.jsx)("div",{style:{padding:8,color:"var(--text-dim)",fontSize:11},children:l(S.trim()?"directoryPicker.noMatchingDirectories":"directoryPicker.noSubdirectories")})]}),(y||i)&&(0,r.jsx)("div",{style:{padding:"8px",color:"#dc2626",fontSize:11},children:y??i})]}),(0,r.jsxs)("div",{className:"directory-picker-footer",style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:10,flexShrink:0,padding:"10px 18px",borderTop:"1px solid var(--border)"},children:[(0,r.jsx)("button",{className:"directory-picker-action",type:"button",onClick:e,disabled:s,style:{padding:"6px 14px",border:"1px solid var(--border)",borderRadius:6,background:"none",color:"var(--text-muted)",cursor:s?"default":"pointer",fontSize:13},children:l("i18n.cancel")}),(0,r.jsx)("button",{className:"directory-picker-action",type:"button",onClick:()=>t(u),disabled:!R,title:l("directoryPicker.selectCurrentDirectory"),style:{padding:"6px 16px",border:0,borderRadius:6,background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:600,opacity:R?1:.6,cursor:R?"pointer":"default"},children:l(s?"i18n.checking":"directoryPicker.selectThisFolder")})]})]})}),d):null}var V=o(63256),K=o(19413),G=o(30515),J=o(32970),Y=o(69248),X=o(95516),Z=o(6513);function Q(e,t){return`url(/catppuccin-icons/${e}/${t}.svg)`}function ee({icon:e,size:t=14}){let o={"--catppuccin-icon-light":Q("latte",e),"--catppuccin-icon-dark":Q("mocha",e),width:t,height:t};return(0,r.jsx)("span",{className:"catppuccin-file-icon",style:o,"aria-hidden":"true"})}let et={".github":"github",".git":"git",".vscode":"vscode",".next":"next",".nuxt":"nuxt",".storybook":"storybook",".turbo":"turbo",".yarn":"yarn",".husky":"husky",".cursor":"cursor",api:"api",app:"app",assets:"assets",components:"components",config:"config",docs:"docs",examples:"examples",hooks:"hooks",lib:"lib",node_modules:"node",pages:"routes",public:"public",scripts:"scripts",src:"src",styles:"styles",test:"tests",tests:"tests",__tests__:"tests",types:"types",utils:"utils"};function eo({size:e=14,open:t=!1,name:o}){let n=o?et[o.toLowerCase()]:void 0,s=n?`folder_${n}${t?"_open":""}`:`_${t?"folder_open":"folder"}`;return(0,r.jsx)(ee,{icon:s,size:e})}function er({size:e=14}){return(0,r.jsx)(ee,{icon:"_file",size:e})}function en({icon:e,size:t=14}){return(0,r.jsx)(ee,{icon:e,size:t})}let es={".babelrc":"babel",".dockerignore":"docker-ignore",".env":"env",".eslintignore":"eslint-ignore",".eslintrc":"eslint",".gitattributes":"git",".gitignore":"git",".gitmodules":"git",".npmignore":"npm-ignore",".prettierignore":"prettier-ignore",".prettierrc":"prettier",".yarnrc":"yarn","bun.lock":"bun-lock","bun.lockb":"bun-lock","cargo.lock":"cargo-lock","cargo.toml":"cargo",codeowners:"codeowners","docker-compose.yaml":"docker-compose","docker-compose.yml":"docker-compose",dockerfile:"docker","eslint.config.js":"eslint","eslint.config.mjs":"eslint","eslint.config.ts":"eslint","next.config.js":"next","next.config.mjs":"next","next.config.ts":"next","package-lock.json":"npm-lock","package.json":"package-json","pnpm-lock.yaml":"pnpm-lock","pnpm-workspace.yaml":"pnpm","prettier.config.js":"prettier","prettier.config.mjs":"prettier","prettier.config.ts":"prettier","tailwind.config.js":"tailwind","tailwind.config.ts":"tailwind","tsconfig.json":"typescript-config","vite.config.js":"vite","vite.config.mjs":"vite","vite.config.ts":"vite","vitest.config.ts":"vitest","yarn.lock":"yarn-lock"},ei={astro:"astro",bash:"bash",c:"c",cpp:"cpp",css:"css",csv:"csv",cjs:"javascript",cts:"typescript",dockerfile:"docker",env:"env",go:"go",gql:"graphql",graphql:"graphql",hcl:"terraform",htm:"html",html:"html",ini:"config",java:"java",js:"javascript",json:"json",jsonc:"json",jsonl:"json",jsx:"javascript-react",less:"less",lua:"lua",md:"markdown",mdx:"markdown-mdx",mjs:"javascript",mts:"typescript",pdf:"pdf",php:"php",py:"python",rs:"rust",sass:"sass",scss:"sass",sh:"bash",sql:"database",svg:"svg",svelte:"svelte",tf:"terraform",toml:"toml",ts:"typescript",tsx:"typescript-react",txt:"text",vue:"vue",xml:"xml",yaml:"yaml",yml:"yaml",zsh:"bash"};function ea(e,t=14){let o=e.toLowerCase(),n=es[o];if(n)return(0,r.jsx)(en,{icon:n,size:t});if(".env"===o||o.startsWith(".env."))return(0,r.jsx)(en,{icon:"env",size:t});if("dockerfile"===o||o.startsWith("dockerfile."))return(0,r.jsx)(en,{icon:"docker",size:t});if(o.endsWith(".config.ts")||o.endsWith(".config.js")||o.endsWith(".config.mjs")||o.endsWith(".config.cjs"))return(0,r.jsx)(en,{icon:o.startsWith("vite.")?"vite":"config",size:t});let s=ei[o.split(".").pop()??""];return s?(0,r.jsx)(en,{icon:s,size:t}):(0,r.jsx)(er,{size:t})}function el(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")?e.replace(/\\/g,"/"):e}function ed(e){return el(e).split("/").filter(Boolean).map(encodeURIComponent).join("/")}function ec(e){let t=el(e).replace(/\/+$/,"");return t.split("/").pop()??t}function ep(e,t){if(!t)return e;let o=el(e),r=el(t).replace(/\/$/,"");return o.startsWith(r+"/")?o.slice(r.length+1):e}function eu(e,t){return`${el(e).replace(/\/$/,"")}/${t}`}var eh=o(87358);function eg(){let e=eh.env.NEXT_PUBLIC_PI_WEB_FILE_EDITING;return!!e&&["1","true","yes","on"].includes(e.trim().toLowerCase())}function em(e){let t=e.replace(/\\/g,"/").replace(/\/+$/,"");return/^[a-zA-Z]:\//.test(t)?t.toLowerCase():t}function ef(e){return"added"===e?"var(--git-status-added)":"deleted"===e?"var(--git-status-deleted)":"modified"===e?"var(--git-status-modified)":"var(--text)"}function ex(e){return"deleted"===e?3:"added"===e?2:1}async function ek(e){let t=await fetch(`/api/git/status?${new URLSearchParams({cwd:e}).toString()}`,{cache:"no-store"});if(!t.ok)throw Error(`Failed to load Git status (HTTP ${t.status})`);return t.json()}async function ev(e){let t=ed(e),o=await fetch(`/api/files/${t}?type=list`);if(!o.ok){let e=`Failed to load files (HTTP ${o.status})`;try{let t=await o.json();t.error&&(e=t.error)}catch{}throw Error(e)}return((await o.json()).entries??[]).map(t=>({name:t.name,fullPath:eu(e,t.name),isDir:t.isDir,size:t.size,children:t.isDir?[]:void 0,loaded:!t.isDir}))}function ey({size:e=11}){return(0,r.jsx)(V.At,{size:e,weight:"regular","aria-hidden":"true"})}function eb({onClick:e,title:t}){return(0,r.jsx)("button",{type:"button",onClick:e,title:t,"aria-label":t,style:{width:24,height:24,padding:0,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"none",borderRadius:4,background:"none",color:"var(--text-dim)",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,r.jsx)(h.X,{size:13,weight:"regular","aria-hidden":"true"})})}async function ew(e,t,o,r){let n=await fetch(`/api/files/${ed(e)}?type=create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,kind:o,content:r??""})}),s=await n.json().catch(()=>({}));if(!n.ok||!s.path)throw Error(s.error??`Create failed (HTTP ${n.status})`);return{path:s.path}}async function ej(e){let t=await fetch(`/api/files/${ed(e)}`,{method:"DELETE"});if(!t.ok){let e=`Delete failed (HTTP ${t.status})`;try{let o=await t.json();o.error&&(e=o.error)}catch{}throw Error(e)}}let eS={display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 5px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"};function eC({node:e,depth:t,cwd:o,onOpenFile:s,onAtMention:i,expandedPaths:a,onToggleExpanded:l,refreshToken:d,highlightedPaths:c,ignoredPaths:p,changedFiles:u,editingEnabled:h,onCreateFile:g,onCreateFolder:m,onDelete:f}){let x,{t:k}=(0,A.s)(),v=a.has(e.fullPath),y=c.has(e.fullPath),w=em(e.fullPath),j=function(e,t){if(t.has(e))return!0;for(let o of t)if(e.startsWith(`${o}/`))return!0;return!1}(w,p),S=function(e,t,o){let r,n=o.get(e);if(n||!t)return n;for(let[t,n]of o)t.startsWith(`${e}/`)&&(!r||ex(n)>ex(r))&&(r=n);return r}(w,e.isDir,u),[C,R]=(0,n.useState)(e.children??[]),[z,I]=(0,n.useState)(e.loaded??!1),[M,P]=(0,n.useState)(!1),[W,F]=(0,n.useState)(!1),D=(0,n.useCallback)(async(t=!1)=>{if(!z||t){P(!0);try{let t=await ev(e.fullPath);R(t),I(!0)}catch{}finally{P(!1)}}},[z,e.fullPath]);(0,n.useEffect)(()=>{void 0!==d&&v&&z&&D(!0)},[d]);let N=(0,n.useCallback)(()=>{if(e.isDir){let t=!v;l(e.fullPath,t),t&&!z&&D()}else s(e.fullPath,e.name)},[e.isDir,e.fullPath,e.name,z,v,D,s,l]);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{onClick:N,onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1),style:{position:"relative",display:"flex",alignItems:"center",gap:4,paddingLeft:8+14*t,paddingRight:8,height:24,cursor:"pointer",background:W?"var(--bg-hover)":"transparent",borderRadius:4,userSelect:"none",opacity:j?W?.72:.5:1},children:[e.isDir&&(0,r.jsx)(b.K,{size:10,color:"var(--text-dim)",weight:"regular",style:{flexShrink:0,transform:v?"rotate(90deg)":"none",transition:"transform 0.1s"},"aria-hidden":"true"}),!e.isDir&&(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsxs)("span",{style:{position:"relative",width:14,height:14,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:[e.isDir?(0,r.jsx)(eo,{size:14,open:v,name:e.name}):ea(e.name,14),S&&(0,r.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",left:-1,top:"50%",transform:"translateY(-50%)",zIndex:1,width:7,height:7,border:"1px solid var(--bg-panel)",borderRadius:"50%",background:ef(S)}})]}),(0,r.jsx)("span",{style:{fontSize:12,color:ef(S),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},title:e.fullPath,children:e.name}),y&&(0,r.jsx)("span",{title:"Newly uploaded","aria-label":"Newly uploaded",style:{width:6,height:6,flexShrink:0,borderRadius:"50%",background:"#3b82f6"}}),M&&(0,r.jsx)(K.y,{size:10,color:"var(--text-dim)",weight:"regular","aria-hidden":"true"}),W&&(x=[],(i&&x.push((0,r.jsxs)("button",{onClick:t=>{t.stopPropagation(),i(ep(e.fullPath,o),e.isDir)},title:k("files.insertPath"),style:{...eS,color:"var(--accent)"},children:[(0,r.jsx)(ey,{}),k("files.mention")]},"mention")),h&&e.isDir&&x.push((0,r.jsx)("button",{onClick:t=>{t.stopPropagation(),g(e.fullPath)},title:k("files.newFile"),"aria-label":k("files.newFile"),style:eS,children:(0,r.jsx)(G.p,{size:11,weight:"regular","aria-hidden":"true"})},"new-file"),(0,r.jsx)("button",{onClick:t=>{t.stopPropagation(),m(e.fullPath)},title:k("files.newFolder"),"aria-label":k("files.newFolder"),style:eS,children:(0,r.jsx)(J.JU,{size:11,weight:"regular","aria-hidden":"true"})},"new-folder")),e.isDir||x.push((0,r.jsx)("a",{href:`/api/files/${ed(e.fullPath)}?type=download`,download:!0,onClick:e=>e.stopPropagation(),title:k("files.download"),style:{...eS,color:"var(--text-muted)",textDecoration:"none"},children:(0,r.jsx)(E.z,{size:11,weight:"regular","aria-hidden":"true"})},"download")),h&&x.push((0,r.jsx)("button",{onClick:t=>{t.stopPropagation(),f(e.fullPath,e.name,e.isDir)},title:k("files.delete"),"aria-label":k("files.delete"),style:{...eS,color:"#f87171"},children:(0,r.jsx)(T.l,{size:11,weight:"regular","aria-hidden":"true"})},"delete")),0===x.length)?null:(0,r.jsx)("div",{style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:3},children:x}))]}),e.isDir&&v&&(0,r.jsxs)("div",{children:[C.map(e=>(0,r.jsx)(eC,{node:e,depth:t+1,cwd:o,onOpenFile:s,onAtMention:i,expandedPaths:a,onToggleExpanded:l,refreshToken:d,highlightedPaths:c,ignoredPaths:p,changedFiles:u,editingEnabled:h,onCreateFile:g,onCreateFolder:m,onDelete:f},e.fullPath)),0===C.length&&z&&(0,r.jsx)("div",{style:{paddingLeft:8+(t+1)*14,fontSize:11,color:"var(--text-dim)",height:22,display:"flex",alignItems:"center"},children:"empty"})]})]})}let eT=(0,n.forwardRef)(function({cwd:e,onOpenFile:t,refreshKey:o,onAtMention:s,onAtMentions:i,onUploadBusyChange:a,fileSearchOpen:l=!1,onFileSearchOpenChange:d,onFileCreated:c,onFileDeleted:p},u){let{t:h}=(0,A.s)(),[g,f]=(0,n.useState)([]),[x,k]=(0,n.useState)(null),[v,y]=(0,n.useState)(!0),[b,w]=(0,n.useState)(null),[j,S]=(0,n.useState)(new Set),[C,T]=(0,n.useState)(0),[z,I]=(0,n.useState)(new Set),[M,P]=(0,n.useState)(""),[E,W]=(0,n.useState)([]),[F,D]=(0,n.useState)(!1),[N,L]=(0,n.useState)(!1),[$,H]=(0,n.useState)(new Set),O=(0,n.useRef)(null),B=M.trim().length>0,[U,_]=(0,n.useState)("idle"),[q,V]=(0,n.useState)(0),[G,J]=(0,n.useState)(null),[Q,ee]=(0,n.useState)(null),[et,eo]=(0,n.useState)(null),[er,en]=(0,n.useState)(null),es=(0,n.useRef)(null),ei=(0,n.useRef)(null),ea=`${o??0}:${C}`,el="idle"!==U,ec=eg(),eh=(0,n.useMemo)(()=>new Set((x?.ignoredPaths??[]).map(em)),[x]),ef=(0,n.useMemo)(()=>new Map((x?.files??[]).map(e=>{var t;return[em(e.filePath),"added"===(t=e.status)||"untracked"===t?"added":"deleted"===t||"conflict"===t?"deleted":"modified"]})),[x]);(0,n.useEffect)(()=>{if(!l)return;let t=M.trim();if(!t){W([]),D(!1),L(!1);return}let o=new AbortController;D(!0),L(!1);let r=setTimeout(()=>{fetch(`/api/file-index?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`,{signal:o.signal}).then(e=>e.ok?e.json():Promise.reject(Error("Search failed"))).then(e=>W((e.matches??[]).filter(e=>!e.isDir).map(e=>e.path))).catch(()=>{o.signal.aborted||(W([]),L(!0))}).finally(()=>{o.signal.aborted||D(!1)})},150);return()=>{clearTimeout(r),o.abort()}},[e,l,M]),(0,n.useEffect)(()=>{l&&O.current?.focus()},[l]),(0,n.useEffect)(()=>{if(0===E.length)return;let t=new Set;for(let o of E){let r=o.split("/"),n="";for(let o=0;o<r.length-1;o++)n=n?`${n}/${r[o]}`:r[o],t.add(eu(e,n))}H(e=>{let o=!1,r=new Set(e);for(let e of t)r.has(e)||(r.add(e),o=!0);return o?r:e})},[e,E]);let ex=(0,n.useMemo)(()=>{let t=o=>({name:o.name,fullPath:eu(e,o.path),isDir:o.isDir,size:0,children:o.children.map(t),loaded:!0});return(function(e){let t=[],o=new Map;for(let r of e){let e=r.split("/"),n=t,s="";for(let t=0;t<e.length;t++){s=s?`${s}/${e[t]}`:e[t];let r=o.get(s);r||(r={name:e[t],path:s,isDir:t<e.length-1,children:[]},o.set(s,r),n.push(r)),n=r.children}}let r=e=>{e.sort((e,t)=>e.isDir!==t.isDir?e.isDir?-1:1:e.name.localeCompare(t.name)),e.forEach(e=>r(e.children))};return r(t),t})(E).map(t)},[e,E]),eS=(0,n.useCallback)((e,t)=>{S(o=>{let r=new Set(o);return t?r.add(e):r.delete(e),r})},[]),eT=(0,n.useCallback)(t=>{let o=t.uploaded??[];ee({uploaded:o,skipped:t.skipped??[],errors:t.errors??[]}),o.length>0&&(I(new Set(o.map(t=>eu(e,t)))),T(e=>e+1))},[e]),eR=(0,n.useCallback)(async(t,o)=>{eo(null),J(null),V(0),_("uploading");try{let{status:r,data:n}=await new Promise((r,n)=>{let s=new FormData;t.forEach(e=>s.append("files",e,e.name));let i=new XMLHttpRequest;i.open("POST",`/api/files/${ed(e)}?type=upload&conflict=${o}`),i.upload.onprogress=e=>{e.lengthComputable&&e.total>0&&V(Math.round(e.loaded/e.total*100))},i.onerror=()=>n(Error("Network error while uploading files")),i.onabort=()=>n(Error("Upload cancelled")),i.onload=()=>{let e={};try{e=JSON.parse(i.responseText)}catch{i.responseText&&(e.error=i.responseText)}r({status:i.status,data:e})},i.send(s)});if(409===r&&n.conflicts?.length)return void eo({files:t,conflicts:n.conflicts,nonReplaceable:n.nonReplaceable??[]});if(r<200||r>=300)throw Error(n.error??`Upload failed (HTTP ${r})`);V(100),eT(n)}catch(e){J(e instanceof Error?e.message:String(e))}finally{_("idle")}},[eT,e]),ez=(0,n.useCallback)(async t=>{if(0!==t.length&&!el){ee(null),I(new Set),eo(null),J(null),V(0),_("checking");try{let o=await fetch(`/api/files/${ed(e)}?type=upload-check`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileNames:t.map(e=>e.name)})}),r=await o.json().catch(()=>({}));if(!o.ok)throw Error(r.error??`Upload check failed (HTTP ${o.status})`);if(r.conflicts?.length)return void eo({files:t,conflicts:r.conflicts,nonReplaceable:r.nonReplaceable??[]});await eR(t,"error")}catch(e){J(e instanceof Error?e.message:String(e))}finally{_("idle")}}},[e,eR,el]),eI=(0,n.useCallback)(e=>{let t=Array.from(e.target.files??[]);e.target.value="",ez(t)},[ez]),eM=(0,n.useCallback)(async e=>{en(null);let t=window.prompt(h("files.promptFileName"));if(t)try{await ew(e,t,"file");let o=eu(e,t);I(new Set([o])),T(e=>e+1),c?.(o)}catch(e){en(e instanceof Error?e.message:String(e))}},[c,h]),eP=(0,n.useCallback)(async e=>{en(null);let t=window.prompt(h("files.promptFolderName"));if(t)try{await ew(e,t,"directory");let o=eu(e,t);I(new Set([o])),T(e=>e+1)}catch(e){en(e instanceof Error?e.message:String(e))}},[h]),eE=(0,n.useCallback)(async(e,t,o)=>{en(null);let r=o?h("files.confirmDeleteDirectory",{name:t}):h("files.confirmDeleteFile",{name:t});if(window.confirm(r))try{await ej(e),T(e=>e+1),p?.(e,o)}catch(e){en(e instanceof Error?e.message:String(e))}},[p,h]);(0,n.useImperativeHandle)(u,()=>({openUploadPicker(){el||ei.current?.click()},openCreateFilePicker(t){eM(t??e)},openCreateFolderPicker(t){eP(t??e)}}),[el,e,eM,eP]),(0,n.useEffect)(()=>{a?.(el)},[a,el]),(0,n.useEffect)(()=>()=>a?.(!1),[a]),(0,n.useEffect)(()=>{let t=es.current!==e;es.current=e,t&&(S(new Set),I(new Set),ee(null),eo(null),J(null)),y(t),w(null);let o=!1;return Promise.all([ev(e),ek(e).catch(()=>null)]).then(([e,t])=>{o||(f(e),k(t))}).catch(e=>{o||w(e instanceof Error?e.message:String(e))}).finally(()=>{o||y(!1)}),()=>{o=!0}},[e,o,C]);let eW=el||null!==et||null!==G||null!==Q,eF=(0,n.useCallback)(()=>{Q&&0!==Q.uploaded.length&&i?.(Q.uploaded.map(t=>ep(eu(e,t),e)))},[e,i,Q]);return(0,r.jsxs)("div",{style:{minHeight:"100%"},children:[(0,r.jsx)("input",{ref:ei,type:"file",multiple:!0,hidden:!0,onChange:eI}),eW&&(0,r.jsxs)("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:[el&&(0,r.jsxs)("div",{role:"status","aria-live":"polite","aria-label":"checking"===U?"Checking files":`Uploading, ${q}%`,children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,minHeight:14,color:"var(--text-muted)"},children:["checking"===U?(0,r.jsx)(K.y,{size:13,weight:"regular",style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true"}):(0,r.jsx)(R.C,{size:13,weight:"regular","aria-hidden":"true"}),"uploading"===U&&(0,r.jsxs)("span",{style:{fontSize:10},children:[q,"%"]})]}),"uploading"===U&&(0,r.jsx)("div",{style:{height:3,marginTop:4,overflow:"hidden",borderRadius:2,background:"var(--border)"},children:(0,r.jsx)("div",{style:{width:`${q}%`,height:"100%",background:"var(--text-muted)",transition:"width 120ms ease"}})})]}),et&&(0,r.jsxs)("div",{role:"alert",style:{padding:7,border:"1px solid color-mix(in srgb, #f59e0b 55%, var(--border))",borderRadius:4,background:"color-mix(in srgb, #f59e0b 9%, var(--bg-panel))"},children:[(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text)",lineHeight:1.35,overflowWrap:"anywhere"},children:[et.conflicts.length," file",1===et.conflicts.length?"":"s"," already exist: ",et.conflicts.join(", ")]}),et.nonReplaceable.length>0&&(0,r.jsxs)("div",{style:{marginTop:3,fontSize:10,color:"#f59e0b",lineHeight:1.35,overflowWrap:"anywhere"},children:["Cannot replace: ",et.nonReplaceable.join(", ")]}),(0,r.jsxs)("div",{style:{display:"flex",gap:5,marginTop:7},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void eR(et.files,"overwrite"),style:{height:22,padding:"0 7px",border:"1px solid #ef4444",borderRadius:4,background:"transparent",color:"#ef4444",cursor:"pointer",fontSize:10},children:"Replace"}),(0,r.jsx)("button",{type:"button",onClick:()=>void eR(et.files,"skip"),style:{height:22,padding:"0 7px",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--text)",cursor:"pointer",fontSize:10},children:"Skip existing"}),(0,r.jsx)("button",{type:"button",onClick:()=>eo(null),style:{height:22,padding:"0 7px",border:"none",borderRadius:4,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:10},children:"Cancel"})]})]}),G&&(0,r.jsxs)("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:6,fontSize:11,lineHeight:1.35,color:"#f87171"},children:[(0,r.jsx)("span",{style:{minWidth:0,flex:1,overflowWrap:"anywhere"},children:G}),(0,r.jsx)(eb,{onClick:()=>J(null),title:"Dismiss error"})]}),Q&&(0,r.jsxs)("div",{"aria-live":"polite",children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minHeight:22,fontSize:11},children:[(0,r.jsxs)("div",{style:{minWidth:0,flex:1,display:"flex",alignItems:"center",gap:8},children:[Q.uploaded.length>0&&(0,r.jsxs)("span",{title:`${Q.uploaded.length} uploaded`,"aria-label":`${Q.uploaded.length} uploaded`,style:{display:"flex",alignItems:"center",gap:3,color:"#22c55e"},children:[(0,r.jsx)(m.J,{size:13,weight:"regular","aria-hidden":"true"}),(0,r.jsx)("span",{children:Q.uploaded.length})]}),Q.skipped.length>0&&(0,r.jsxs)("span",{title:`${Q.skipped.length} skipped`,"aria-label":`${Q.skipped.length} skipped`,style:{display:"flex",alignItems:"center",gap:3,color:"var(--text-dim)"},children:[(0,r.jsx)(Y.F,{size:13,weight:"regular","aria-hidden":"true"}),(0,r.jsx)("span",{children:Q.skipped.length})]}),Q.errors.length>0&&(0,r.jsxs)("span",{title:`${Q.errors.length} failed`,"aria-label":`${Q.errors.length} failed`,style:{display:"flex",alignItems:"center",gap:3,color:"#f87171"},children:[(0,r.jsx)(X.N,{size:13,weight:"regular","aria-hidden":"true"}),(0,r.jsx)("span",{children:Q.errors.length})]})]}),Q.uploaded.length>0&&i&&(0,r.jsxs)("button",{type:"button",onClick:eF,title:1===Q.uploaded.length?"Add uploaded file to chat":"Add all uploaded files to chat","aria-label":1===Q.uploaded.length?"Add uploaded file to chat":"Add all uploaded files to chat",style:{height:22,padding:"0 7px",display:"flex",alignItems:"center",justifyContent:"center",gap:4,flexShrink:0,border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsx)(ey,{}),"mention"]}),(0,r.jsx)(eb,{onClick:()=>ee(null),title:"Dismiss upload results"})]}),Q.errors.map(e=>(0,r.jsxs)("div",{title:e.error,style:{display:"flex",alignItems:"center",gap:4,marginTop:3,minWidth:0,fontSize:10,color:"#f87171"},children:[(0,r.jsx)(Z.R,{size:11,weight:"regular",style:{flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.name))]})]}),er&&(0,r.jsxs)("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:6,padding:"6px 8px",borderBottom:"1px solid var(--border)",fontSize:11,lineHeight:1.35,color:"#f87171"},children:[(0,r.jsx)("span",{style:{minWidth:0,flex:1,overflowWrap:"anywhere"},children:er}),(0,r.jsx)(eb,{onClick:()=>en(null),title:h("files.dismissError")})]}),l&&(0,r.jsxs)("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsxs)("div",{style:{position:"relative"},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",color:"var(--text-dim)",pointerEvents:"none"},children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,r.jsx)("path",{d:"m20 20-4-4"})]}),(0,r.jsx)("input",{ref:O,value:M,onChange:e=>P(e.target.value),onKeyDown:e=>{"Escape"===e.key&&d?.(!1)},placeholder:h("sidebar.searchFilesPlaceholder"),"aria-label":h("sidebar.searchFiles"),style:{width:"100%",boxSizing:"border-box",padding:"6px 24px",border:"1px solid var(--border)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:11}}),M&&(0,r.jsx)("button",{type:"button",onClick:()=>P(""),title:h("sidebar.clearSearch"),"aria-label":h("sidebar.clearSearch"),style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"none",borderRadius:4,background:"none",color:"var(--text-dim)",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-dim)"},children:(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M18 6 6 18"}),(0,r.jsx)("path",{d:"m6 6 12 12"})]})})]}),B&&(0,r.jsxs)("div",{style:{paddingTop:3},children:[F&&(0,r.jsx)("div",{role:"status",style:{padding:"6px 2px",fontSize:10,color:"var(--text-dim)"},children:h("sidebar.searchingFiles")}),!F&&N&&(0,r.jsx)("div",{role:"alert",style:{padding:"6px 2px",fontSize:10,color:"#f87171"},children:h("i18n.networkError")}),!F&&!N&&0===E.length&&(0,r.jsx)("div",{style:{padding:"6px 2px",fontSize:10,color:"var(--text-dim)"},children:h("sidebar.noMatchingFiles")}),!F&&!N&&E.length>0&&(0,r.jsx)("div",{children:ex.map(o=>(0,r.jsx)(eC,{node:o,depth:0,cwd:e,onOpenFile:t,onAtMention:s,expandedPaths:$,onToggleExpanded:(e,t)=>{H(o=>{let r=new Set(o);return t?r.add(e):r.delete(e),r})},refreshToken:"",highlightedPaths:z,ignoredPaths:eh,changedFiles:ef,editingEnabled:ec,onCreateFile:eM,onCreateFolder:eP,onDelete:eE},`${M}:${o.fullPath}`))})]})]}),(0,r.jsxs)("div",{style:{padding:"2px 4px"},children:[v?(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"Loading files..."}):b?(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"#f87171"},children:b}):B?(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"}}):g.map(o=>(0,r.jsx)(eC,{node:o,depth:0,cwd:e,onOpenFile:t,onAtMention:s,expandedPaths:j,onToggleExpanded:eS,refreshToken:ea,highlightedPaths:z,ignoredPaths:eh,changedFiles:ef,editingEnabled:ec,onCreateFile:eM,onCreateFolder:eP,onDelete:eE},o.fullPath)),!v&&!b&&0===g.length&&(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"No files found"})]})]})}),eR={modified:"var(--git-status-modified)",added:"var(--git-status-added)",deleted:"var(--git-status-deleted)",renamed:"var(--git-status-modified)",untracked:"var(--git-status-added)",conflict:"var(--git-status-deleted)"};async function ez(e){let t=await fetch(`/api/git/status?${new URLSearchParams({cwd:e}).toString()}`);if(!t.ok)throw Error(`Failed to load Git status (HTTP ${t.status})`);return t.json()}function eI({status:e,cwd:t,onOpenFile:o}){let[s,i]=(0,n.useState)(!1),a=ep(e.filePath,t);return(0,r.jsxs)("button",{type:"button",onClick:()=>o(e.filePath,ec(e.filePath),{initialDisplayMode:"diff"}),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),title:e.filePath,style:{width:"100%",display:"flex",alignItems:"center",gap:4,padding:"0 5px",height:24,border:"none",borderRadius:4,background:s?"var(--bg-hover)":"transparent",color:"var(--text)",cursor:"pointer",textAlign:"left"},children:[(0,r.jsx)("span",{style:{width:14,flexShrink:0,color:eR[e.status],fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600,textAlign:"center"},children:e.code}),(0,r.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center",opacity:.85},children:ea(ec(e.filePath),13)}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,fontSize:12},children:a})]})}function eM({cwd:e,refreshKey:t,onOpenFile:o}){let{t:s}=(0,A.s)(),[i,a]=(0,n.useState)(!1),[l,d]=(0,n.useState)(null),[c,p]=(0,n.useState)(!1),u=(0,n.useCallback)(async()=>{p(!0);try{d(await ez(e))}catch{d(null)}finally{p(!1)}},[e]);if((0,n.useEffect)(()=>{u()},[u,t]),!l?.isGitRepository||0===l.files.length)return null;let h=l.files.reduce((e,t)=>("added"===t.status||"untracked"===t.status?e.added+=1:"deleted"===t.status||"conflict"===t.status?e.deleted+=1:e.modified+=1,e),{modified:0,added:0,deleted:0});return(0,r.jsxs)("section",{style:{flex:"0 0 auto",minHeight:0,borderTop:"1px solid var(--border)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0},children:[(0,r.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),"aria-expanded":i,style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0,padding:"6px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left"},children:[(0,r.jsx)(b.K,{size:9,weight:"regular",style:{transform:i?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s("desktop.quickChanges")})]}),(0,r.jsxs)("div",{className:"git-changes-indicator","aria-label":`Changed files: ${h.modified} modified, ${h.added} added, ${h.deleted} deleted`,children:[h.modified>0&&(0,r.jsx)("span",{className:"git-changes-indicator-part git-changes-indicator-modified",children:h.modified}),h.added>0&&(0,r.jsx)("span",{className:"git-changes-indicator-part git-changes-indicator-added",children:h.added}),h.deleted>0&&(0,r.jsx)("span",{className:"git-changes-indicator-part git-changes-indicator-deleted",children:h.deleted})]}),(0,r.jsxs)("span",{style:{marginLeft:6,color:"var(--git-status-added)",fontFamily:"var(--font-mono)",fontSize:11},children:["+",l.additions]}),(0,r.jsxs)("span",{style:{marginLeft:5,color:"var(--git-status-deleted)",fontFamily:"var(--font-mono)",fontSize:11},children:["-",l.deletions]}),(0,r.jsx)("button",{type:"button",onClick:()=>void u(),disabled:c,title:s("desktop.refresh"),"aria-label":s("desktop.refresh"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,marginLeft:4,marginRight:6,border:"none",borderRadius:5,background:"none",color:"var(--text-dim)",cursor:c?"wait":"pointer",opacity:c?.55:1},children:c?(0,r.jsx)(K.y,{size:12,style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true"}):(0,r.jsx)(C.S,{size:13,weight:"regular","aria-hidden":"true"})})]}),i&&(0,r.jsx)("div",{style:{minHeight:0,maxHeight:"min(35vh, 280px)",overflowY:"auto",overflowX:"hidden",padding:"2px 4px 4px"},children:l.files.map(t=>(0,r.jsx)(eI,{status:t,cwd:e,onOpenFile:o},t.filePath))})]})}var eP=o(76721),eE=o(61448),eW=o(95660),eF=o(59680),eD=o(20412),eA=o(12272),eN=o(9005),eL=o(31966),e$=o(47421),eH=o(14225),eO=o(8962),eB=o(65408),eU=o(75742),e_=o(73534),eq=o(6923),eV=o(64577),eK=o(32159),eG=o(30600),eJ=o(65377),eY=o(2125),eX=o(86272),eZ=o(37218),eQ=o(65738);function e0(){try{return window.localStorage}catch{return null}}let e1="pi-web:sidebar-mode",e2="pi-web:sidebar-task-preferences",e4="pi-web:sidebar-collapsed-projects",e6="projects",e8={organizeBy:"project",sortBy:"updated"};function e5(e,t=e0()){if(t)try{0===e.size?t.removeItem(e4):t.setItem(e4,JSON.stringify(Object.fromEntries([...e].map(e=>[e,!0]))))}catch{}}function e3(e,t){let o=t.trim().toLowerCase();return!o||!!(e.name||e.firstMessage?.slice(0,50)||e.id).toLowerCase().includes(o)||!!e.branch?.toLowerCase().includes(o)}function e7(e){return e.projectKey??e.projectRoot??e.cwd??""}function e9(e,t,o){return"created"===o?t.created.localeCompare(e.created):t.modified.localeCompare(e.modified)}function te(e,t={}){let{hiddenKeys:o,search:r}=t;return e.filter(e=>!(e.archived||o?.size&&o.has(e7(e)))&&e3(e,r??""))}function tt(e,t){return t.get(e.projectKey)?.latest??""}let to={pinned:"desktop.pinned",today:"desktop.today",yesterday:"desktop.yesterday",older:"desktop.older"};function tr(e){let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${o}-${r}`}function tn(e,t,o="updated"){let r=new Date,n=tr(r),s=tr(new Date(r.getTime()-864e5)),i={pinned:[],today:[],yesterday:[],older:[]};for(let t of e){let e=tr(new Date(t.modified));t.pinned&&i.pinned.push(t),e===n?i.today.push(t):e===s?i.yesterday.push(t):i.older.push(t)}return["pinned","today","yesterday","older"].map(e=>({key:e,rows:function(e,t,o,r="updated"){if(0===e.length)return[];let n=new Map(t.map(e=>[e.id,e])),s=new Set(e.map(e=>e.id)),i=new Map;for(let t of e)if(t.parentSessionId&&s.has(t.parentSessionId)){let e=i.get(t.parentSessionId)??[];e.push(t),i.set(t.parentSessionId,e)}let a=(e,t)=>e9(e,t,r),l=e.filter(e=>!(e.parentSessionId&&s.has(e.parentSessionId))).sort(a);for(let e of i.values())e.sort(a);let d=[],c=new Set,p=e=>{if(!c.has(e.id))for(let t of(c.add(e.id),d.push({session:e,forkDepth:o?0:(e=>{let t=0,o=e,r=new Set;for(;o?.parentSessionId&&!r.has(o.id);){r.add(o.id);let e=n.get(o.parentSessionId);if(!e)break;o=e,t++}return t})(e)}),i.get(e.id)??[]))p(t)};for(let e of l)p(e);for(let t of e)p(t);return d}(i[e],t,"pinned"===e,o)})).filter(e=>e.rows.length>0)}var ts=o(97320);function ti(e,t){let o=new Date(e),r=new Date().getTime()-o.getTime(),n=Math.floor(r/6e4),s=Math.floor(r/36e5),i=Math.floor(r/864e5);return n<1?t("desktop.justNow"):n<60?t("desktop.minutesAgo",{count:n}):s<24?t("desktop.hoursAgo",{count:s}):i<7?t("desktop.daysAgo",{count:i}):o.toLocaleDateString()}function ta(){let{t:e}=(0,A.s)();return(0,r.jsx)("span",{title:e("desktop.agentRunning"),"aria-label":e("desktop.agentRunningLabel"),style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"var(--accent)"},children:(0,r.jsx)(ts.A,{size:13,style:{display:"block",animation:"spin 0.9s linear infinite"},"aria-hidden":"true"})})}function tl(){let{t:e}=(0,A.s)();return(0,r.jsx)("span",{title:e("desktop.newActivity"),"aria-label":e("desktop.newSessionActivity"),style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"var(--accent)"},children:(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",style:{display:"block"},children:(0,r.jsx)("circle",{cx:"7",cy:"7",r:"3",fill:"currentColor",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"1;0.25;1",dur:"1.6s",repeatCount:"indefinite"})})})})}let td=e=>({display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,background:e?"var(--bg-selected)":"transparent",border:"none",borderRadius:5,flexShrink:0,color:e?"var(--accent)":"var(--text-muted)",cursor:"pointer",transition:"color 0.12s, background 0.12s"});function tc({sessions:e,loading:t,runningIds:o,unreadIds:s,aliases:i,selectedSessionId:a,selectedProjectRoot:l,searchQuery:d,onSearchQueryChange:c,onSelectSession:p,onNewSessionInProject:u,onArchive:h,onDeleteForever:g,onRemoveProject:m,hiddenProjects:f,onUnhideProject:x,onPickFolder:k,onCycleToList:v,onRenamed:y,onNewTask:b,renderFileTree:w,isMobile:j}){let{t:S}=(0,A.s)(),[C,T]=(0,n.useState)(()=>(function(e=e0()){if(!e)return e8;try{let t=e.getItem(e2);if(!t)return e8;let o=JSON.parse(t);if(!o||"object"!=typeof o||Array.isArray(o))return e8;let{organizeBy:r,sortBy:n}=o;return{organizeBy:"grouped"===r||"project"===r||"timeline"===r?r:e8.organizeBy,sortBy:"updated"===n||"created"===n?n:e8.sortBy}}catch{return e8}})()),[R,z]=(0,n.useState)(()=>(function(e=e0()){if(!e)return new Set;try{let t=e.getItem(e4);if(!t)return new Set;let o=JSON.parse(t);if(!o||"object"!=typeof o||Array.isArray(o))return new Set;return new Set(Object.entries(o).filter(([,e])=>!0===e).map(([e])=>e))}catch{return new Set}})()),[I,M]=(0,n.useState)(!1),[P,E]=(0,n.useState)(null),[W,F]=(0,n.useState)(!1),[D,N]=(0,n.useState)(null),[L,$]=(0,n.useState)(null),[H,O]=(0,n.useState)({}),B="detailed",U=(0,n.useRef)(null),_=(0,n.useRef)(null),[q,V]=(0,n.useState)(0);(0,n.useEffect)(()=>{let e=setInterval(()=>V(e=>e+1),6e4);return()=>clearInterval(e)},[]);let K=(0,n.useCallback)(e=>{T(t=>{let o={...t,...e};return!function(e,t=e0()){if(t)try{t.setItem(e2,JSON.stringify(e))}catch{}}(o),o})},[]),G=(0,n.useCallback)(e=>{z(t=>{let o=new Set(t);return o.has(e)?o.delete(e):o.add(e),e5(o),o})},[]),J=(0,n.useMemo)(()=>new Set(f.map(e=>e.key)),[f]),Y=(0,n.useMemo)(()=>(function(e){let{sessions:t,hiddenKeys:o,aliases:r={},sortBy:n,collapsedKeys:s,runningIds:i,unreadIds:a,search:l,extraRoots:d}=e,c=te(t,{hiddenKeys:o,search:l}),p=new Map;for(let e of c){let t=e7(e);if(!t)continue;let o=e.projectRoot??e.cwd??"",r=p.get(t);r||(r={projectRoot:o,sessions:[],latest:""},p.set(t,r)),r.sessions.push(e),e.modified>r.latest&&(r.latest=e.modified)}for(let e of d??[])!o?.has(e)&&(p.has(e)||p.set(e,{projectRoot:e,sessions:[],latest:""}));let u=[];for(let[e,t]of p){var h;t.sessions.sort((e,t)=>e9(e,t,n));let o=s?.has(e)??!1;u.push({projectKey:e,projectRoot:t.projectRoot,name:r[t.projectRoot]?.trim()||((h=t.projectRoot).replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean).pop()??h),sessions:o?[]:t.sessions,totalCount:t.sessions.length,collapsed:o,hasRunning:t.sessions.some(e=>i?.has(e.id)??!1),hasUnread:t.sessions.some(e=>a?.has(e.id)??!1)})}return u.sort((e,t)=>{let o=tt(e,p);return tt(t,p).localeCompare(o)}),u})({sessions:e,hiddenKeys:J,aliases:i,sortBy:C.sortBy,collapsedKeys:R,runningIds:o,unreadIds:s,search:d,extraRoots:l?[l]:[]}),[e,J,i,C.sortBy,R,o,s,d,l]),X=(0,n.useMemo)(()=>{var t;return te((t={sessions:e,hiddenKeys:J,sortBy:C.sortBy,search:d}).sessions,{hiddenKeys:t.hiddenKeys,search:t.search}).sort((e,o)=>e9(e,o,t.sortBy))},[e,J,C.sortBy,d]),Z=(0,n.useMemo)(()=>tn(te(e,{hiddenKeys:J,search:d}),e,C.sortBy),[e,J,d,C.sortBy,q]),Q=(0,n.useMemo)(()=>(function(e){let{sessions:t,hiddenKeys:o,search:r}=e;return t.filter(e=>!(!e.archived||o?.size&&o.has(e7(e)))&&e3(e,r??"")).sort((e,t)=>(t.archivedAt??t.modified).localeCompare(e.archivedAt??e.modified))})({sessions:e,hiddenKeys:J,search:d}),[e,J,d]);(0,n.useEffect)(()=>{if(!W&&!D)return;let e=e=>{let t=e.target;W&&!U.current?.contains(t)&&F(!1),!D||_.current?.contains(t)||t instanceof Element&&t.closest("[data-menu-trigger]")||N(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[W,D]);let ee=(0,n.useCallback)(()=>{if(R.size>0){let e=new Set;z(e),e5(e)}else{let e=new Set(Y.map(e=>e.projectKey));z(e),e5(e)}},[R,Y]),et=e=>({display:"flex",alignItems:"center",gap:3,height:22,padding:"0 7px",background:e?"var(--bg-selected)":"none",border:"none",borderRadius:11,color:e?"var(--text)":"var(--text-dim)",fontSize:11.5,fontWeight:e?600:400,cursor:"pointer",whiteSpace:"nowrap",transition:"color 0.12s, background 0.12s"}),eo=e=>{M(!1),E(null),K({organizeBy:"grouped"===e?"grouped":"timeline"===C.organizeBy?"timeline":"project"})},er=e=>H[e]??5,en=(e,t=!1,n=B)=>{let l;return(0,r.jsx)(tp,{session:e,isSelected:e.id===a,isRunning:o.has(e.id),isUnread:s.has(e.id),indent:t,forceActionsVisible:j,rowStyle:n,folderName:(l=e.projectRoot??e.cwd??"",i[l]?.trim()||l.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean).pop()||l||"?"),onSelect:()=>p(e),onArchive:()=>h(e,!0),onRenamed:y},e.id)},es=P?(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",minHeight:0,flex:1},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",flexShrink:0},children:[(0,r.jsxs)("button",{onClick:()=>E(null),style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px",background:"none",border:"none",borderRadius:6,color:"var(--text-muted)",fontSize:12,cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:[(0,r.jsx)(eL.A,{size:11,"aria-hidden":"true"}),S("desktop.backToSessions")]}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,color:"var(--text-dim)"},title:P.root,children:P.name})]}),(0,r.jsx)("div",{className:"scroll-overlay",style:{flex:1,minHeight:0,overflowX:"hidden"},children:w(P.root)})]}):I?(0,r.jsxs)("div",{style:{padding:"0 4px"},children:[0===Q.length&&(0,r.jsx)("div",{style:{padding:"16px 10px",color:"var(--text-muted)",fontSize:12},children:S(d.trim()?"desktop.noSearchResults":"desktop.noArchivedSessions")}),Q.map(e=>(0,r.jsx)(tu,{session:e,folderName:i[e.projectRoot??e.cwd]?.trim()||(e.projectRoot??e.cwd??"").replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean).pop()||e.projectRoot||e.cwd||"?",onUnarchive:()=>h(e,!1),onDeleteForever:()=>{window.confirm(S("desktop.deleteArchivedConfirm"))&&g(e)}},e.id))]}):"project"===C.organizeBy?(0,r.jsxs)("div",{style:{padding:"0 4px"},children:[(0,r.jsx)("div",{style:{padding:"6px 8px 2px",fontSize:11,fontWeight:600,color:"var(--text-dim)",letterSpacing:"0.04em"},children:S("desktop.projectSectionHeader")}),0===Y.length&&!t&&(0,r.jsx)("div",{style:{padding:"16px 10px",color:"var(--text-muted)",fontSize:12},children:S(d.trim()?"desktop.noSearchResults":"desktop.noProjects")}),Y.map(t=>{let n=er(t.projectKey),s=t.sessions.slice(0,n),i=t.sessions.length-s.length;return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{position:"relative"},onMouseEnter:()=>$(t.projectKey),onMouseLeave:()=>$(e=>e===t.projectKey?null:e),children:(0,r.jsxs)("div",{onClick:()=>G(t.projectKey),style:{display:"flex",alignItems:"center",gap:6,height:34,paddingLeft:8,paddingRight:66,cursor:"pointer",color:"var(--text)",borderRadius:6},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:[(0,r.jsx)(eP.A,{size:10,style:{transform:t.collapsed?"none":"rotate(90deg)",transition:"transform 0.15s",flexShrink:0,color:"var(--text-dim)"},"aria-hidden":"true"}),t.collapsed&&t.hasRunning?(0,r.jsx)(ta,{}):t.collapsed?(0,r.jsx)(eE.A,{size:14,style:{flexShrink:0,color:"var(--text-dim)"},"aria-hidden":"true"}):(0,r.jsx)(eW.A,{size:14,style:{flexShrink:0,color:"var(--text-dim)"},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13,fontWeight:500},title:t.projectRoot,children:t.name}),t.collapsed&&t.hasUnread&&!t.hasRunning&&(0,r.jsx)(tl,{}),(0,r.jsxs)("div",{"data-folder-actions":!0,style:{position:"absolute",right:6,top:4,display:"flex",gap:2,opacity:j||D===t.projectKey||L===t.projectKey?1:0,transition:"opacity 0.12s"},children:[(0,r.jsx)("button",{"data-menu-trigger":!0,onClick:e=>{e.stopPropagation(),N(D===t.projectKey?null:t.projectKey)},title:S("desktop.moreActions"),"aria-label":S("desktop.moreActions"),style:{...td(D===t.projectKey),width:24,height:24},children:(0,r.jsx)(eF.A,{size:14,"aria-hidden":"true"})}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),E({root:t.projectRoot,name:t.name})},title:S("desktop.viewFiles"),"aria-label":S("desktop.viewFiles"),style:{...td(!1),width:24,height:24},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(eD.A,{size:14,"aria-hidden":"true"})}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),u(t.projectRoot)},title:S("desktop.newSessionHere"),"aria-label":S("desktop.newSessionHere"),style:{...td(!1),width:24,height:24},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(eA.A,{size:14,"aria-hidden":"true"})})]}),D===t.projectKey&&(0,r.jsx)("div",{ref:_,style:{position:"absolute",right:6,top:30,zIndex:30,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.35)",padding:4,minWidth:120},children:(0,r.jsxs)("button",{onClick:()=>{N(null),(!(t.hasRunning||e.some(e=>(e.projectRoot??e.cwd)===t.projectRoot&&o.has(e.id)&&!e.archived))||window.confirm(S("desktop.removeProjectRunningConfirm")))&&m(t.projectRoot,t.name)},style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"6px 10px",background:"none",border:"none",borderRadius:6,color:"var(--text)",fontSize:12,cursor:"pointer",textAlign:"left"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:[(0,r.jsx)(eN.A,{size:12,style:{color:"var(--text-dim)"},"aria-hidden":"true"}),S("desktop.removeProject")]})})]})}),!t.collapsed&&(0,r.jsxs)("div",{children:[s.map(e=>en(e,!0,"compact")),i>0&&(0,r.jsx)("button",{onClick:()=>O(e=>({...e,[t.projectKey]:er(t.projectKey)+5})),style:{display:"block",width:"100%",padding:"5px 8px 5px 42px",background:"none",border:"none",borderRadius:6,color:"var(--text-dim)",fontSize:11,cursor:"pointer",textAlign:"left"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:S("desktop.showMore")})]})]},t.projectKey)})]}):"timeline"===C.organizeBy?(0,r.jsxs)("div",{style:{padding:"0 4px"},children:[0===X.length&&!t&&(0,r.jsx)("div",{style:{padding:"16px 10px",color:"var(--text-muted)",fontSize:12},children:S(d.trim()?"desktop.noSearchResults":"desktop.noSessionsFound")}),X.map(e=>en(e))]}):(0,r.jsxs)("div",{style:{padding:"0 4px"},children:[0===Z.length&&!t&&(0,r.jsx)("div",{style:{padding:"16px 10px",color:"var(--text-muted)",fontSize:12},children:S(d.trim()?"desktop.noSearchResults":"desktop.noSessionsFound")}),Z.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{padding:"8px 8px 2px",fontSize:11,fontWeight:600,color:"var(--text-dim)",letterSpacing:"0.04em"},children:S("pinned"===e.key?"desktop.pinned":"today"===e.key?"desktop.today":"yesterday"===e.key?"desktop.yesterday":"desktop.older")}),e.rows.map(e=>en(e.session,e.forkDepth>0))]},e.key))]});return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 0",minHeight:0,overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:2,padding:"6px 6px",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:1,background:"var(--bg-hover)",borderRadius:12,padding:2},children:[(0,r.jsxs)("button",{style:et("grouped"===C.organizeBy),onClick:()=>eo("grouped"),"aria-pressed":"grouped"===C.organizeBy,children:[(0,r.jsx)(e$.A,{size:11,style:{opacity:.7},"aria-hidden":"true"}),S("desktop.panelGroupBubble")]}),(0,r.jsxs)("button",{style:et("grouped"!==C.organizeBy),onClick:()=>eo("project"),"aria-pressed":"grouped"!==C.organizeBy,children:[(0,r.jsx)(eH.A,{size:11,"aria-hidden":"true"}),S("desktop.panelProjectBubble")]})]}),(0,r.jsx)("button",{onClick:ee,title:R.size>0?S("desktop.expandAllFolders"):S("desktop.collapseAllFolders"),"aria-label":R.size>0?S("desktop.expandAllFolders"):S("desktop.collapseAllFolders"),style:{...td(!1),marginLeft:2},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:R.size>0?(0,r.jsx)(eO.A,{size:13,"aria-hidden":"true"}):(0,r.jsx)(eB.A,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("button",{onClick:v,title:`${S("desktop.sidebarModeCycle")}:${S("desktop.sessionViewList")}`,"aria-label":S("desktop.sidebarModeCycle"),style:{...td(!1),marginLeft:2},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(eU.A,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("div",{style:{flex:1}}),(0,r.jsxs)("div",{ref:U,style:{position:"relative"},children:[(0,r.jsx)("button",{onClick:()=>F(e=>!e),title:S("desktop.filterMenu"),"aria-label":S("desktop.filterMenu"),"aria-expanded":W,style:td(W),onMouseEnter:e=>{W||(e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{W||(e.currentTarget.style.color="var(--text-muted)")},children:(0,r.jsx)(e_.A,{size:13,"aria-hidden":"true"})}),W&&(0,r.jsxs)("div",{style:{position:"absolute",right:0,top:28,zIndex:40,width:168,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.4)",padding:5},children:[(0,r.jsx)("div",{style:{padding:"6px 8px 2px",fontSize:11,fontWeight:600,color:"var(--text-dim)"},children:S("desktop.viewSection")}),[["project","desktop.viewByProject",eH.A],["timeline","desktop.viewTimeline",eq.A]].map(([e,t,o])=>(0,r.jsxs)("button",{onClick:()=>{K({organizeBy:e})},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 7px",background:"none",border:"none",borderRadius:6,color:"var(--text)",fontSize:11.5,cursor:"pointer",textAlign:"left"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:[(0,r.jsx)(o,{size:13,style:{color:"var(--text-dim)",flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{flex:1},children:S(t)}),C.organizeBy===e&&(0,r.jsx)(eV.A,{size:13,strokeWidth:2.5,style:{color:"var(--accent)"},"aria-hidden":"true"})]},e)),(0,r.jsx)("div",{style:{height:1,background:"var(--border)",margin:"6px 4px"}}),(0,r.jsx)("div",{style:{padding:"2px 8px",fontSize:11,fontWeight:600,color:"var(--text-dim)"},children:S("desktop.sortSection")}),[["updated","desktop.sortUpdated"],["created","desktop.sortCreated"]].map(([e,t])=>(0,r.jsxs)("button",{onClick:()=>{K({sortBy:e})},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 7px",background:"none",border:"none",borderRadius:6,color:"var(--text)",fontSize:11.5,cursor:"pointer",textAlign:"left"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:[(0,r.jsx)("span",{style:{flex:1},children:S(t)}),C.sortBy===e&&(0,r.jsx)(eV.A,{size:13,strokeWidth:2.5,style:{color:"var(--accent)"},"aria-hidden":"true"})]},e)),(0,r.jsx)("div",{style:{height:1,background:"var(--border)",margin:"6px 4px"}}),(0,r.jsx)("div",{style:{padding:"2px 8px",fontSize:11,fontWeight:600,color:"var(--text-dim)"},children:S("desktop.hiddenProjectsSection")}),0===f.length?(0,r.jsx)("div",{style:{padding:"4px 8px 8px",fontSize:11,color:"var(--text-dim)"},children:S("desktop.noHiddenProjects")}):f.map(e=>(0,r.jsxs)("button",{onClick:()=>{F(!1),x(e)},title:e.path,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 8px",background:"none",border:"none",borderRadius:6,color:"var(--text)",fontSize:12,cursor:"pointer",textAlign:"left"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:[(0,r.jsx)(eH.A,{size:13,style:{color:"var(--text-dim)",flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name||e.path}),(0,r.jsx)("span",{style:{fontSize:11,color:"var(--accent)",flexShrink:0},children:S("desktop.restoreProject")})]},e.key))]})]}),(0,r.jsx)("button",{onClick:()=>{M(e=>!e),E(null)},title:S("desktop.archivedView"),"aria-label":S("desktop.archivedView"),"aria-pressed":I,style:td(I),onMouseEnter:e=>{I||(e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{I||(e.currentTarget.style.color="var(--text-muted)")},children:I?(0,r.jsx)(eN.A,{size:13,"aria-hidden":"true"}):(0,r.jsx)(eK.A,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("button",{onClick:k,title:S("desktop.selectFolder"),"aria-label":S("desktop.selectFolder"),style:{...td(!1),marginRight:2},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(eG.A,{size:13,"aria-hidden":"true"})})]}),j&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"0 8px 6px",flexShrink:0},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,background:"var(--bg-hover)",borderRadius:8,padding:"0 9px",height:30},children:[(0,r.jsx)(eJ.A,{size:13,color:"var(--text-dim)",style:{flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("input",{value:d,onChange:e=>c(e.target.value),placeholder:I?S("desktop.searchArchived"):S("desktop.searchSessions"),"aria-label":I?S("desktop.searchArchived"):S("desktop.searchSessions"),style:{flex:1,minWidth:0,background:"none",border:"none",outline:"none",color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)"}}),d&&(0,r.jsx)("button",{onClick:()=>c(""),"aria-label":S("i18n.close"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:4,flexShrink:0},children:(0,r.jsx)(eN.A,{size:11,"aria-hidden":"true"})})]}),(0,r.jsxs)("button",{onClick:b,title:S("desktop.newTask"),"aria-label":S("desktop.newTask"),style:{display:"flex",alignItems:"center",gap:4,flexShrink:0,height:30,padding:"0 10px",background:"var(--bg-selected)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:12,fontWeight:500,whiteSpace:"nowrap",cursor:"pointer"},children:[(0,r.jsx)(eY.A,{size:13,"aria-hidden":"true"}),S("desktop.newTask")]})]}),t&&0===e.length&&(0,r.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:S("desktop.loading")}),(0,r.jsx)("div",{className:"scroll-overlay",style:{flex:"1 1 0",minHeight:0},children:es})]})}function tp({session:e,isSelected:t,isRunning:o,isUnread:s,indent:i,forceActionsVisible:a,rowStyle:l,folderName:p,onSelect:u,onArchive:h,onRenamed:g}){let{t:m}=(0,A.s)(),[f,x]=(0,n.useState)(!1),[k,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(!1),[w,j]=(0,n.useState)(null),S=(0,n.useRef)(null),C=e.name||e.firstMessage?.slice(0,50)||e.id,T=e.messageCount>0,R=(0,n.useCallback)(async t=>{if(t.stopPropagation(),y){S.current?.abort(),c(e.id);return}if(!T)return;let o=new AbortController;S.current=o,b(!0),j(null);try{await d(e.id,o.signal),g()}catch(e){o.signal.aborted||j(e instanceof Error?e.message:String(e))}finally{S.current===o&&(S.current=null),b(!1)}},[y,T,e.id,g]);if(k)return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,height:30,paddingLeft:i?42:10,paddingRight:6,background:"rgba(239,68,68,0.06)",borderRadius:6},children:[(0,r.jsx)("span",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m("desktop.archiveSessionConfirm",{title:`“${C.slice(0,18)}${C.length>18?"…":""}”`})}),(0,r.jsxs)("button",{onClick:()=>{v(!1),h()},style:{display:"flex",alignItems:"center",gap:4,height:24,padding:"0 9px",background:"#ef4444",border:"none",borderRadius:5,color:"#fff",fontSize:11,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap"},children:[(0,r.jsx)(eK.A,{size:11,"aria-hidden":"true"}),m("desktop.archiveSession")]}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),v(!1)},style:{height:24,padding:"0 9px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",fontSize:11,cursor:"pointer",whiteSpace:"nowrap"},children:m("desktop.cancel")})]});let z=(0,r.jsxs)("div",{style:{display:"flex",gap:2,flexShrink:0},children:[(0,r.jsx)("button",{onClick:R,disabled:!T,title:w??m(T?y?"desktop.generatingTitle":"desktop.generateTitle":"desktop.titleNeedsMessages"),"aria-label":m("desktop.generateTitle"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,background:"none",border:"none",borderRadius:4,color:w?"#ef4444":"var(--text-dim)",cursor:T?"pointer":"default",flexShrink:0,opacity:y?.7:T?1:.35,transition:"color 0.12s"},onMouseEnter:e=>{!y&&T&&(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{e.currentTarget.style.color=w?"#ef4444":"var(--text-dim)"},children:y?(0,r.jsxs)("svg",{style:{animation:"spin 1s linear infinite"},width:"13",height:"13",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),(0,r.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}):(0,r.jsx)(eX.A,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),v(!0)},title:m("desktop.archiveSession"),"aria-label":m("desktop.archiveSession"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,background:"none",border:"none",borderRadius:4,color:"var(--text-dim)",cursor:"pointer",flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:(0,r.jsx)(eK.A,{size:13,"aria-hidden":"true"})})]}),I=f||a,M=o?(0,r.jsx)(ta,{}):s?(0,r.jsx)(tl,{}):null;return(0,r.jsxs)("div",{onClick:u,onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),style:{position:"relative",padding:`${5*("detailed"===l)}px 6px ${5*("detailed"===l)}px ${i?42:18}px`,height:"detailed"===l?46:30,display:"flex",flexDirection:"column",justifyContent:"center",cursor:"pointer",borderRadius:6,background:t?"var(--bg-selected)":f?"var(--bg-hover)":"transparent",borderLeft:t?"2px solid var(--accent)":"2px solid transparent"},title:C,children:[M&&i&&(0,r.jsx)("span",{style:{position:"absolute",left:22,top:0,bottom:0,display:"flex",alignItems:"center"},children:M}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[M&&!i&&M,(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12.5,color:"var(--text)",fontWeight:t?500:400},children:C}),I?z:(0,r.jsx)("span",{style:{flexShrink:0,fontSize:11,color:"var(--text-dim)",whiteSpace:"nowrap"},children:ti(e.modified,m)})]}),"detailed"===l&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:2,minWidth:0},children:[(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11,color:"var(--text-dim)"},title:e.projectRoot??e.cwd,children:p}),I&&(0,r.jsx)("span",{style:{flexShrink:0,fontSize:11,color:"var(--text-dim)",whiteSpace:"nowrap"},children:ti(e.modified,m)})]})]})}function tu({session:e,folderName:t,onUnarchive:o,onDeleteForever:s}){let{t:i}=(0,A.s)(),[a,l]=(0,n.useState)(!1),d=e.name||e.firstMessage?.slice(0,50)||e.id;return(0,r.jsxs)("div",{onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{padding:"6px 10px",borderRadius:6,background:a?"var(--bg-hover)":"transparent"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12.5,color:"var(--text)"},title:d,children:d}),(0,r.jsx)("span",{style:{flexShrink:0,fontSize:11,color:"var(--text-dim)"},children:ti(e.archivedAt??e.modified,i)})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:2},children:[(0,r.jsx)(eH.A,{size:12,style:{color:"var(--text-dim)",flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11,color:"var(--text-dim)"},title:e.projectRoot??e.cwd,children:t}),(0,r.jsx)("button",{onClick:o,title:i("desktop.unarchiveSession"),"aria-label":i("desktop.unarchiveSession"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,background:"none",border:"none",borderRadius:4,color:"var(--text-dim)",cursor:"pointer",flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:(0,r.jsx)(eZ.A,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("button",{onClick:s,title:i("desktop.deleteForever"),"aria-label":i("desktop.deleteForever"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,background:"none",border:"none",borderRadius:4,color:"#ef4444",cursor:"pointer",flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color="#f87171"},onMouseLeave:e=>{e.currentTarget.style.color="#ef4444"},children:(0,r.jsx)(eQ.A,{size:13,"aria-hidden":"true"})})]})]})}let th="pi-web:file-explorer:open";function tg(){try{return window.localStorage}catch{return null}}var tm=o(79617),tf=o(87358);function tx(e){return e&&"win32"===tf.platform?(0,tm.normalize)(e):e}function tk(e,t){return e===t||!!e&&!!t&&"win32"===tf.platform&&tx(e).toLowerCase()===tx(t).toLowerCase()}let tv="normal",ty="full",tb="auto";function tw(e){return"normal"===e||"plan"===e||"goal"===e?e:tv}function tj(e){return"economy"===e||"delivery"===e||"full"===e?e:ty}function tS(e){return"ask"===e||"auto"===e||"yolo"===e?e:tb}let tC=["bash","edit","edit_file","grep","find","kill_shell","ls","read","update_goal","wait","write","write_file"],tT=`You are in PLAN MODE. Work as a read-only planning assistant.
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{10283:(e,t,o)=>{Promise.resolve().then(o.bind(o,55600)),Promise.resolve().then(o.bind(o,39247))},14755:(e,t,o)=>{"use strict";o.d(t,{SC:()=>a,getPresetFromTools:()=>d,xG:()=>c});let r=[],n=["read","grep","find","ls"],s=["read","bash","edit","write"],i=["bash","read","edit","write","grep","find","ls"],a=["read","grep","find","ls"],l=new Set([...i,"powershell"]);function d(e){var t=e.filter(e=>e.active).map(e=>e.name);if(0===t.length)return"none";let o=t.map(e=>"powershell"===e?"bash":e).filter(e=>l.has(e)).sort().join(",");return o===[...n].sort().join(",")?"plan":o===[...s].sort().join(",")?"default":o===[...i].sort().join(",")?"full":"default"}function c(e){return"none"===e?[...r]:"full"===e?[...i]:"plan"===e?[...a]:[...s]}},23084:(e,t,o)=>{"use strict";async function r(e,t){let o=await fetch(e,{...t,headers:t?.body?{"Content-Type":"application/json"}:void 0}),r=await o.json().catch(()=>({}));if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);return r}async function n(e){return(await r(`/api/tasks?projectRoot=${encodeURIComponent(e)}`)).tasks}async function s(){return(await r("/api/tasks/projects")).projects}async function i(e){return(await r("/api/tasks",{method:"POST",body:JSON.stringify(e)})).task}async function a(e,t,o){return(await r(`/api/tasks/${e}?projectRoot=${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({projectRoot:t,...o})})).task}async function l(e,t,o=!1){await r(`/api/tasks/${e}?projectRoot=${encodeURIComponent(t)}&deleteWorktree=${+!!o}`,{method:"DELETE"})}async function d(e,t,o,n){await r(`/api/tasks/${e}/${o}?projectRoot=${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify({...n})})}async function c(e,t,o){await r(`/api/tasks/${e}/return?projectRoot=${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify({feedback:o})})}async function p(e,t,o,n){await r(`/api/tasks/${e}/merge?projectRoot=${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify({message:o,deleteWorktree:n})})}async function u(e,t,o){await r(`/api/tasks/${e}/complete?projectRoot=${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify({deleteWorktree:o})})}async function h(e,t,o){await r(`/api/tasks/${e}/archive?projectRoot=${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify({archived:o})})}async function g(e,t){await r("/api/tasks/batch?mode=reorder",{method:"POST",body:JSON.stringify({projectRoot:e,orderedIds:t})})}async function m(e){return(await r("/api/tasks/batch?mode=start-all",{method:"POST",body:JSON.stringify({projectRoot:e})})).claimed}async function f(e,t,o=500){return(await r(`/api/tasks/${t}/events?projectRoot=${encodeURIComponent(e)}&limit=${o}`)).events}async function x(e,t){return r(`/api/tasks/${t}/changed-files?projectRoot=${encodeURIComponent(e)}`)}async function k(e,t,o){return r(`/api/tasks/${t}/diff?projectRoot=${encodeURIComponent(e)}&file=${encodeURIComponent(o)}`)}async function v(e){return(await r(`/api/tasks/settings?projectRoot=${encodeURIComponent(e)}`)).settings}async function y(e){return(await r(`/api/tasks/settings?projectRoot=${encodeURIComponent(e)}&own=1`)).settings}async function b(e,t){await r("/api/tasks/settings",{method:"PUT",body:JSON.stringify({projectRoot:e,settings:t})})}async function w(e){await r(`/api/tasks/settings?projectRoot=${encodeURIComponent(e)}`,{method:"DELETE"})}async function j(){return(await r("/api/tasks/templates")).templates}async function S(e){return(await r("/api/tasks/templates",{method:"POST",body:JSON.stringify(e)})).template}async function C(e){await r(`/api/tasks/templates?id=${e}`,{method:"DELETE"})}o.d(t,{B_:()=>C,CG:()=>v,E:()=>w,HB:()=>f,JH:()=>x,Lu:()=>g,Pf:()=>y,VB:()=>j,Vk:()=>n,Wt:()=>s,ZX:()=>u,a5:()=>m,bH:()=>l,createTaskApi:()=>i,eA:()=>b,et:()=>h,h:()=>k,in:()=>c,nY:()=>S,oB:()=>p,oQ:()=>d,updateTaskApi:()=>a})},39247:(e,t,o)=>{"use strict";o.d(t,{I18nProvider:()=>c,s:()=>p});var r=o(95155),n=o(12115);let s=new Map;function i(e){if(!e.id.trim())throw Error("Locale id must not be empty");if(s.has(e.id))throw Error(`Locale already registered: ${e.id}`);s.set(e.id,e)}function a(e){return s.get(e)}i({id:"en",label:"English",messages:{"i18n.close":"Close","i18n.cancel":"Cancel","i18n.checking":"Checking…","desktop.settings":"Settings","desktop.settingsSections":"Settings sections","desktop.closeSettings":"Close settings","desktop.display":"Display","desktop.server":"Server","desktop.serverCurrent":"Current server","desktop.serverSwitch":"Switch server","desktop.serverSwitchHint":"Open Pi Web Desktop connection manager: switch between saved servers or add a new server (URL + password).","desktop.reloadPage":"Reload page","desktop.serverHintTitle":"Need a remote server or an access password?","desktop.serverHintBody":"The desktop app now connects to your local server automatically. Switch servers, reach it from your phone, or add an access password from this top-right icon.","desktop.serverHintAction":"Open connection manager","desktop.serverHintDismiss":"Got it","desktop.chat":"Chat","desktop.models":"Models","desktop.skills":"Skills","desktop.plugins":"Plugins","desktop.subagents":"Subagents","desktop.proxy":"Proxy","desktop.proxyEnable":"Enable Proxy","desktop.proxyProtocol":"Protocol","desktop.proxyHost":"Host","desktop.proxyPort":"Port","desktop.proxyUsername":"Username (optional)","desktop.proxyPassword":"Password (optional)","desktop.proxyNoProxy":"No-Proxy (comma-separated, optional)","desktop.proxySave":"Save","desktop.proxySaving":"Saving…","desktop.proxyTest":"Test Connection","desktop.proxyTesting":"Testing…","desktop.proxySaved":"Proxy configuration saved","desktop.proxySaveFailed":"Failed to save","desktop.proxyTestSuccess":"Connected","desktop.proxyTestFailed":"Connection failed","desktop.proxyUnsaved":"Unsaved changes","desktop.features":"Features","desktop.logs":"Logs","desktop.snippets":"Snippets","desktop.snippetsDesc":"Reusable text/code snippets — type # in the composer to autocomplete","desktop.snippetNew":"New snippet","desktop.snippetName":"Name","desktop.snippetContent":"Content","desktop.snippetSave":"Save","desktop.snippetEdit":"Edit","desktop.snippetDelete":"Delete","desktop.snippetEmpty":"No snippets yet — create one to get started.","desktop.snippetNameRequired":"Snippet name is required","desktop.snippetHint":"Type #name in the composer to autocomplete; Enter expands it to the snippet content.","desktop.logsAllCodes":"All error codes","desktop.logsAllLevels":"All levels","desktop.logsAllSources":"All sources","desktop.logsSearch":"Search error logs","desktop.logsClear":"Clear logs","desktop.logsCopy":"Copy log","desktop.logsEmpty":"No error logs","desktop.mcpVisionTitle":"DeepSeek Vision module","desktop.mcpVisionDesc":"Dedicated configuration for the deepseek-vision module (image analysis / OCR). Both the MCP registration and the model settings can be edited here.","desktop.mcpVisionRegistered":"Registered","desktop.mcpVisionNotRegistered":"Not registered","desktop.mcpVisionRegistration":"MCP registration","desktop.mcpVisionCommand":"Command","desktop.mcpVisionCommandRequired":"Command is required","desktop.mcpVisionLifecycle":"Lifecycle","desktop.mcpVisionTransport":"Transport","desktop.mcpVisionTransportFixed":"stdio (fixed)","desktop.mcpVisionSaveReg":"Save registration","desktop.mcpVisionSavedReg":"Registration saved — takes effect in a new session or after restarting pi.","desktop.mcpVisionRemove":"Remove from MCP config","desktop.mcpVisionRemoved":"Registration removed","desktop.mcpVisionModelConfig":"Model configuration","desktop.mcpVisionModelNote":'Model settings are written to .env immediately. Use "Restart server" below to apply them right away.',"desktop.mcpVisionProvider":"Provider","desktop.mcpVisionBaseUrl":"Base URL","desktop.mcpVisionApiKey":"API key","desktop.mcpVisionModel":"Vision model","desktop.mcpVisionMaxTokens":"Max output tokens","desktop.mcpVisionSaveModel":"Save model configuration","desktop.mcpVisionSavedModel":"Model configuration saved","desktop.mcpVisionNameReserved":"This name is reserved for the built-in DeepSeek Vision configuration — pick another name.","desktop.mcpVisionRestart":"Restart server (apply now)","desktop.mcpVisionRestarting":"Restarting…","desktop.mcpVisionRestarted":"Restart command sent — takes effect shortly","desktop.mcpVisionRestartTitle":"Restart the deepseek-vision server so .env changes take effect immediately","desktop.mcpVisionRestartNoSession":"Open a session first to restart the server","desktop.applyNow":"Apply now","desktop.applyNowApplying":"Reloading…","desktop.applyNowDone":"Reloaded — changes applied","desktop.applyNowTitle":"Reload the current session so changes take effect immediately (no pi restart needed)","desktop.applyNowNoSession":"Open a session first to apply changes now","desktop.featuresDesc":"Manage optional Pi Web features. Disabling one hides its entry points.","desktop.featuresTasksBoard":"Task Board","desktop.featuresTasksBoardDesc":"Show the Task Board entry in the top toolbar to manage cross-project tasks.","desktop.featuresLoading":"Loading…","desktop.featuresSaving":"Saving…","desktop.featuresCollabDefault":"Default task mode","desktop.featuresCollabDefaultDesc":"Default collaboration mode for new chats (Normal / Plan / Goal)","desktop.featuresTokenDefault":"Default token profile","desktop.featuresTokenDefaultDesc":"Default token profile for new chats (Lite / Balanced / Delivery)","desktop.featuresApprovalDefault":"Default tool approval","desktop.featuresApprovalDefaultDesc":"Default tool approval for new chats (Ask / Auto / Yolo)","desktop.usage":"Usage","desktop.usageSession":"Current session","desktop.usageGlobal":"Global","desktop.usageContext":"Context {used} / {window} tokens","desktop.usageContextHint":"Live context usage of the current session","desktop.usageNoSessionData":"No usage data for the current session","desktop.usageNoSession":"No session open","desktop.usageTotal":"Estimated total","desktop.usageMessages":"Messages","desktop.usageMessagesHint":"across all sessions","desktop.usageSessions":"sessions","desktop.usageDaily":"Daily usage trend","desktop.usageTopSessions":"Top sessions by usage","desktop.usageNoData":"No data yet","desktop.mcp":"MCP","desktop.mcpServers":"MCP servers","desktop.mcpAddServer":"Add server","desktop.mcpNewServer":"New MCP server","desktop.mcpEditServer":'Edit MCP server "{name}"',"desktop.mcpRestartNote":"MCP servers are loaded when pi starts. Changes made here take effect after restarting pi.","desktop.mcpEmpty":"No MCP servers configured yet — add one to expose tools to the agent.","desktop.mcpEmptyOther":"No other MCP servers configured — DeepSeek Vision is managed in the card above.","desktop.mcpServerName":"Name","desktop.mcpCommand":"Command","desktop.mcpArgs":"Arguments (one per line)","desktop.mcpTransport":"Transport","desktop.mcpLifecycle":"Lifecycle","desktop.mcpRequestTimeoutMs":"Request timeout (ms)","desktop.mcpEnv":"Environment (JSON)","desktop.mcpEdit":"Edit","desktop.mcpDelete":"Delete","desktop.mcpSave":"Save","desktop.saving":"Saving…","desktop.mcpCancel":"Cancel","desktop.mcpSavedRestart":"Saved — restart pi to apply changes.","desktop.tools":"Tools","desktop.refreshSession":"Refresh session","desktop.shellTool":"Shell tool","desktop.usePowerShell":"Use PowerShell for shell commands","desktop.shellToolDescription":"On Windows, prefer PowerShell over bash for the shell tool. Saves to defaultTools in settings.json.","desktop.shellToolWindowsOnly":"PowerShell is only configurable on Windows.","desktop.shellToolMacOnly":"Shell tool settings are only available on Windows.","desktop.subagentCardProcessing":"Processing","desktop.transcriptRoleUser":"User","desktop.transcriptRoleAssistant":"Assistant","desktop.transcriptRoleResult":"Result","desktop.transcriptRoleBash":"Bash","desktop.backup":"Backup","desktop.backupExportTitle":"Export backup","desktop.backupExportDescription":"Package all global configuration: providers, models, credentials, settings, MCP servers, skills and local plugins.","desktop.backupIncludeSecrets":"Include API keys and credentials","desktop.backupSecretsWarning":"Warning: the backup will contain plaintext API keys (models.json) and OAuth credentials (auth.json). Keep it safe.","desktop.backupIncludeSessions":"Include session history","desktop.backupSessionsHint":"Sessions can be large and may contain sensitive conversation content.","desktop.backupExportButton":"Export backup","desktop.backupExporting":"Exporting…","desktop.backupExportFailed":"Backup export failed","desktop.backupImportTitle":"Import backup","desktop.backupImportButton":"Choose backup file","desktop.backupImportDescription":"Restore from a pi-backup zip. Paths are remapped to this machine and MCP commands are adapted per platform.","desktop.backupImportFailed":"Failed to read the backup file","desktop.backupRestoreFailed":"Restore failed","desktop.backupManifest":"Backup created","desktop.backupNoSecrets":"no credentials included","desktop.backupCategories":"Restore categories","desktop.backupCategorycore":"Core config","desktop.backupCategoryskills":"Skills","desktop.backupCategorypackages":"Plugins","desktop.backupCategorymcp":"MCP servers","desktop.backupCategorysessions":"Sessions","desktop.backupMcpServers":"MCP servers","desktop.backupNpmPackages":"npm packages","desktop.backupReinstallNpm":"Reinstall these npm packages after restore","desktop.backupReinstallNpmHint":"Install scripts run code shipped with the backup; only enable this if you trust its source","desktop.backupInstallModel":"Model for the install session","desktop.backupInstallSession":"Create install session","desktop.backupOpenSession":"Open session","desktop.backupInstallSessionFailed":"Failed to create the install session","desktop.backupRestoreButton":"Restore","desktop.backupRestoring":"Restoring…","desktop.backupRestoreReport":"Restore report","desktop.backupReportRestored":"Restored","desktop.backupReportRestart":"Needs restart to take effect","desktop.backupReportManual":"Needs manual attention","desktop.backupRestartHint":"Settings, models, credentials and MCP config take effect after restarting pi-web / pi.","desktop.importSessions":"Import Sessions","desktop.importSessionsDesc":"Import conversation history from other AI coding tools into pi-web. Currently supports Reasonix, with more tools coming soon.","desktop.comingSoon":"Coming soon","desktop.projects":"projects","desktop.importSelectProjects":"Select projects to import","desktop.importSelectAll":"Select all","desktop.importDeselectAll":"Deselect all","desktop.importMerged":"Merge into existing project","desktop.importNewProject":"New project","desktop.importExistingCount":"{count} existing","desktop.importStart":"Start import","desktop.importing":"Importing…","desktop.importDone":"Import complete","desktop.importedSummary":"Successfully imported {imported} sessions","desktop.importSkippedCount":"{skipped} skipped","desktop.importErrorsCount":"{errors} errors","desktop.importGeneratingTitles":"Generating titles…","desktop.importGenerateTitles":"Generate titles for imported sessions","desktop.importAgain":"Import again","desktop.importNoData":"No Reasonix data found. Make sure ~/.reasonix/projects/ exists with session files.","desktop.importFromReasonix":"from Reasonix","desktop.importFromCodex":"from Codex","desktop.builtinModelsTitle":"Model configuration","desktop.builtinModelsFetchNew":"Fetch new models","desktop.builtinModelsLoadFailed":"Failed to load models","desktop.builtinModelsEmpty":"No models available for this provider.","desktop.builtinModelsContext":"Context","desktop.builtinModelsMaxTokens":"Max output","desktop.builtinModelsReasoning":"Reasoning model","desktop.builtinModelsThinking":"Thinking levels (thinkingLevelMap)","desktop.builtinModelsDirty":"{count} unsaved change(s)","desktop.builtinModelsHide":"Hide this model","desktop.inputShortcut":"Input shortcut","desktop.inputShortcutDescription":"Choose how to send messages with the Enter key.","desktop.useCtrlEnter":"Ctrl+Enter to send","desktop.useCtrlEnterDescription":"Enter inserts a newline, Ctrl+Enter sends the message.","desktop.useEnter":"Enter to send","desktop.useEnterDescription":"Enter sends the message, Shift+Enter inserts a newline.","desktop.theme":"Theme","desktop.themes":"Themes","desktop.language":"Language","desktop.light":"Light","desktop.dark":"Dark","desktop.system":"System","desktop.english":"English","desktop.chinese":"简体中文","desktop.themeDescription":"Choose the appearance of Pi Web.","desktop.languageDescription":"Choose the display language for the interface.","desktop.colorScheme":"Color Scheme","desktop.openThemeFolder":"Open Pi theme folder","desktop.learnPiThemes":"Learn about Pi themes","desktop.defaultTheme":"Default","desktop.appearanceMode":"Appearance Mode","desktop.loadingThemes":"Loading themes…","desktop.borderVisibility":"Border Visibility","desktop.borderSubtle":"Subtle","desktop.borderBold":"Bold","desktop.noCustomThemes":"No custom themes installed.","desktop.noCustomThemesHint":"Add JSON files to","desktop.noCustomThemesHint2":"to see them here.","desktop.darkVariant":"Dark variant available","desktop.lightVariant":"Light variant available","desktop.switchToLight":"Switch to light mode","desktop.switchToDark":"Switch to dark mode","desktop.showSidebar":"Show sidebar","desktop.hideSidebar":"Hide sidebar","desktop.resizeSidebar":"Resize sidebar","desktop.resizeFilePanel":"Resize file panel","desktop.trustProject":"Trust project","desktop.trustingProject":"Trusting…","desktop.projectResourcesRestricted":"Project resources are restricted","desktop.projectSkillsRestricted":"Project skills are unavailable until you trust this project.","desktop.projectSkillInstallUnavailable":"Trust this project before installing project skills.","desktop.shellCommand":"Shell command","desktop.shellOutputLocal":"output stays local","desktop.shellOutputModel":"output is available to the model","desktop.runningShellCommand":"Running shell command…","desktop.loadFullOutput":"Load full output","desktop.download":"Download","desktop.trustProjectTitle":"Trust this project?","desktop.trustProjectBody":"Project extensions, skills, prompts, and package resources can execute code. Trust this project only if you recognize its contents.","desktop.minimize":"Minimize","desktop.maximize":"Maximize","desktop.restore":"Restore","desktop.islandLabel":"Window controls","desktop.islandResetHint":"Drag to move, double-click to reset","desktop.islandDrag":"Drag to move","desktop.close":"Close","desktop.viewFullHistory":"View full history","desktop.fullHistoryAvailableAfterSave":"Full history is available after the session is saved","desktop.systemPrompt":"System prompt","desktop.sessionInfo":"Session info","desktop.hideFilePanel":"Hide file panel","desktop.showFilePanel":"Show file panel","desktop.sessionInfoTitle":"Session Info","desktop.sessionInfoFile":"File","desktop.sessionInfoId":"ID","desktop.sessionInfoInMemory":"In-memory","desktop.sessionInfoMessages":"Messages","desktop.sessionInfoTokens":"Tokens","desktop.sessionInfoActiveTime":"Estimated Active Time","desktop.sessionInfoUser":"User","desktop.sessionInfoAssistant":"Assistant","desktop.sessionInfoToolCalls":"Tool Calls","desktop.sessionInfoToolResults":"Tool Results","desktop.sessionInfoTotal":"Total","desktop.sessionInfoInput":"Input","desktop.sessionInfoOutput":"Output","desktop.sessionInfoCacheRead":"Cache Read","desktop.sessionInfoCacheWrite":"Cache Write","desktop.sessionInfoCost":"Cost","desktop.sessionInfoCostOfficial":"Cost (official)","desktop.sessionInfoContext":"Context","desktop.balance":"Balance","desktop.balanceGranted":"Granted","desktop.balanceToppedUp":"Topped up","desktop.balanceUnavailable":"Balance unavailable","desktop.turnUsageTitle":"This turn","desktop.turnUsageByOfficialPrice":"priced at official rates","desktop.copyFilePath":"Copy file path","desktop.copySessionId":"Copy session ID","desktop.projectDir":"Project","desktop.gitBranch":"Git branch","desktop.gitWorktree":"Worktree","desktop.projectSection":"Project Info","desktop.copyProjectDir":"Copy project path","desktop.copyGitBranch":"Copy git branch","desktop.copyGitWorktree":"Copy worktree path","desktop.sendMessageForSessionInfo":"Send a message or run /session to load session info","desktop.selectSessionFromSidebar":"Select a session from the sidebar","desktop.getStarted":"Get Started","desktop.selectProjectDirectory":"Select a project directory from the sidebar","desktop.addModelsFromBottom":"Add models via the Models button at the bottom","desktop.loadingSession":"Loading session...","desktop.scrollToLoadEarlierMessages":"Scroll up to load earlier messages ({count} hidden)","desktop.scrollToBottom":"Scroll to latest","desktop.filesWritten":"Files changed","desktop.openWrittenFile":"Open {name}","desktop.taskRunning":"running","desktop.taskTodo":"todo","desktop.taskStatusHint":"Task progress for the current project — click to open the board","desktop.runningTool":"Running tool...","desktop.runningTools":"Running {tools}...","desktop.waitingForModel":"Waiting for model...","desktop.runningCommand":"Running command...","desktop.thinking":"Thinking...","desktop.extensionRequest":"extension request","desktop.extensionPanel":"Extension panel","desktop.cancel":"Cancel","desktop.confirm":"Confirm","desktop.submit":"Submit","desktop.queued":"Queued","desktop.queueMoveUp":"Move up","desktop.queueMoveDown":"Move down","desktop.queueRecallOne":"Recall to input","desktop.queueRemove":"Remove queued message","desktop.recalledEditing":"Editing a queued message. Sending puts it back at its original position.","desktop.steer":"Steer","desktop.followUp":"Follow-up","desktop.recallToInput":"Recall to input","desktop.recallQueuedMessages":"Remove all queued messages and put them back into the input box for editing","desktop.retrying":"Retrying","desktop.compacted":"Compacted","desktop.tokens":"tokens","desktop.saved":"saved","desktop.removeImage":"Remove image","desktop.loadingCommands":"Loading commands...","desktop.slashCommands":"Slash commands","desktop.tabOrEnter":"Tab / Enter","desktop.noSlashCommands":"No extension, prompt, or skill commands found","desktop.builtIn":"Built-in","desktop.extensions":"Extensions","desktop.prompts":"Prompts","desktop.commandSkills":"Skills","desktop.match":"match","desktop.matches":"matches","desktop.snippetMatches":"snippet matches","desktop.command":"command","desktop.commands":"commands","desktop.loadingFiles":"Loading files...","desktop.files":"Files","desktop.searchingAllFiles":"searching all files...","desktop.indexTruncated":"index truncated","desktop.searching":"Searching...","desktop.search":"Search","desktop.noMatchingFiles":"No matching files","desktop.steerOrQueueFollowUp":"Steer now / queue follow-up...","desktop.agentRunning":"Agent is running...","desktop.messageWithCommands":"Message... Type / for commands, @ for files","desktop.inputHistory":"Input history","desktop.quickChanges":"Quick Changes","desktop.changedFiles":"{count} changed files","desktop.imageAttachmentsCannotQueue":"Image attachments cannot be queued while the agent is running","desktop.injectMessageNow":"Interrupt the current run and inject this message now","desktop.queueMessageAfterFinish":"Queue this message after the agent finishes","desktop.attachImage":"Attach image","desktop.push":"Push current branch","desktop.pushOk":"Push succeeded","desktop.pushFailed":"Push failed","desktop.stash":"Stash","desktop.stashTitle":"Stash manager","desktop.stashPush":"Stash changes","desktop.stashList":"Stash list","desktop.stashEmpty":"No stashes","desktop.stashPop":"Pop","desktop.stashDrop":"Drop","desktop.stashMessagePlaceholder":"Stash message (optional)…","desktop.stashDone":"Done","desktop.attachMenu":"Choose input mode","desktop.attachUpload":"Upload file","desktop.attachUploadDesc":"Attach images and other files","desktop.attachReference":"Reference files","desktop.attachReferenceDesc":"Reference workspace files with @","desktop.attachSessions":"Reference sessions","desktop.attachSessionsDesc":"Reference past conversations with #","desktop.attachCommands":"Use commands","desktop.attachCommandsDesc":"Use commands and skills with /","desktop.planModeBadge":"Plan mode","desktop.planModeLabel":"Plan mode","desktop.planModeHint":"Plan mode: read-only analysis, no file modifications. Confirm execution or exit when done.","desktop.disableCompletionSound":"Disable completion sound","desktop.enableCompletionSound":"Enable completion sound","desktop.soundLabelOn":"Sound: On","desktop.soundLabelOff":"Sound: Off","desktop.changeReasoningLevel":"Change reasoning level: {level}","desktop.reasoningLevel":"Change reasoning level","desktop.moreControls":"More controls","desktop.more":"More","modes.collabNormal":"Normal","modes.collabPlan":"Plan","modes.collabGoal":"Goal","modes.tokenEconomy":"Lite","modes.tokenFull":"Balanced","modes.tokenDelivery":"Delivery","modes.approvalAsk":"Ask","modes.approvalAuto":"Auto","modes.approvalYolo":"Yolo","modes.collabNormalTitle":"Normal \xb7 act as you go","modes.collabNormalDesc":"Execute directly, advancing as you go","modes.collabPlanTitle":"Plan \xb7 confirm before executing","modes.collabPlanDesc":"Produce a plan first; tool execution still follows permissions","modes.collabGoalTitle":"Goal \xb7 keep pushing","modes.collabGoalDesc":"Work continuously until done or blocked","modes.tokenEconomyTitle":"Lite \xb7 fast, token-saving","modes.tokenEconomyDesc":"Less context, tools enabled on demand","modes.tokenFullTitle":"Balanced \xb7 daily general use","modes.tokenFullDesc":"Full tools, autonomous execution","modes.tokenDeliveryTitle":"Delivery \xb7 full verification","modes.tokenDeliveryDesc":"Mandatory acceptance, recheck and verify","modes.approvalAskTitle":"Require approval","modes.approvalAskDesc":"Writes and commands needing approval ask first","modes.approvalAutoTitle":"Auto-approve","modes.approvalAutoDesc":"Auto-execute what the policy allows","modes.approvalYoloTitle":"Yolo approve","modes.approvalYoloDesc":"Skip normal tool prompts (this session only)","desktop.goalRunning":"Goal","desktop.goalComplete":"Goal complete","desktop.goalBlocked":"Goal blocked","desktop.goalPaused":"Goal paused","desktop.goalNoProgress":"{n} no-progress turns","desktop.goalPause":"Pause goal","desktop.goalPauseShort":"Ⅱ","desktop.goalResume":"Resume goal","desktop.goalResumeShort":"▶","desktop.goalStop":"Stop goal","desktop.goalEdit":"Edit","desktop.goalSave":"Save","desktop.goalCancel":"Cancel","desktop.goalEditHint":"Cmd+Enter to save \xb7 Esc to cancel","desktop.goalBudget":"budget","desktop.goalTurns":"turns","desktop.goalBudgetLimited":"budget exhausted","approval.title":"Tool approval required","approval.subtitle":"The agent wants to run this tool. Choose Allow to run it, or Deny to send a blocked result back.","approval.queued":"more waiting","approval.allow":"Allow","approval.deny":"Deny","approval.denyWithReason":"Deny with reason","approval.hideReason":"Hide reason","approval.reasonPlaceholder":"Reason shown to the agent (optional)","desktop.stopCompaction":"Stop compaction","desktop.compactContext":"Compact context","desktop.compacting":"Compacting...","desktop.compact":"Compact","desktop.changeToolPreset":"Change tool preset: {preset}","desktop.toolPreset":"Change tool preset","desktop.sendMessage":"Send message","desktop.stopAgent":"Stop agent","desktop.stop":"Stop","desktop.collapseControls":"Collapse controls","desktop.usePiDefault":"Use pi default","desktop.reasoningOff":"Reasoning off","desktop.minimalReasoning":"Minimal reasoning","desktop.lowReasoning":"Low reasoning","desktop.mediumReasoning":"Medium reasoning","desktop.highReasoning":"High reasoning","desktop.extraHighReasoning":"Extra-high reasoning","desktop.maxReasoning":"Max reasoning","desktop.noToolsReadOnly":"No tools, read-only","desktop.fourBuiltInTools":"4 built-in tools","desktop.allBuiltInTools":"All built-in tools","desktop.toolOff":"off","desktop.toolDefault":"default","desktop.toolFull":"full","desktop.thinkingAuto":"auto","desktop.thinkingOff":"off","desktop.thinkingMinimal":"minimal","desktop.thinkingLow":"low","desktop.thinkingMedium":"medium","desktop.thinkingHigh":"high","desktop.thinkingExtraHigh":"xhigh","desktop.thinkingMax":"max","desktop.compactCommandDescription":"Compress context, optionally with instructions","desktop.reloadCommandDescription":"Reload extensions, skills, prompts, and tools","desktop.nameCommandDescription":"Set the session display name","desktop.sessionCommandDescription":"Show session message, token, and cost stats","desktop.copyCommandDescription":"Copy the last assistant message","desktop.selectModel":"Select model","desktop.modelsLoadFailed":"Failed to load model list","desktop.noModelsConfigured":"No models configured — add a provider in Model settings","desktop.selectProject":"Select project","desktop.selectProjectFirst":"Select a project first","desktop.noMatchingProjects":"No matching projects","desktop.noProjectsYet":"No projects yet","desktop.useDefaultDirectory":"Use default directory","desktop.customPath":"Custom path…","desktop.projectPathPlaceholder":"/path/to/project","desktop.filterProjects":"Filter projects…","desktop.searchProjects":"Search projects…","desktop.recentProjects":"Recent Projects","desktop.addProjectTab":"Add project tab","desktop.maxProjectTabs":"Up to 4 project tabs (1 dropdown + 4 tabs)","desktop.branch":"Branch","desktop.editProjectAlias":"Rename project","desktop.projectAliasPlaceholder":"Add a remark for this project…","desktop.quickWorkspace":"Quick workspace","desktop.selectFolder":"Select folder","desktop.checking":"Checking…","desktop.open":"Open","common.ok":"OK","common.language":"Language","common.models":"Models","common.skills":"Skills","common.agents":"Sub-agents","common.plugins":"Plugins","common.settings":"Settings","settings.title":"Settings","settings.general":"General","settings.generalDescription":"Choose how Pi Web looks and which language it uses.","settings.appearance":"Appearance","settings.appearanceDescription":"Select a theme or follow your system preference.","settings.chatContentWidth":"Chat content width","settings.chatContentFontSize":"Chat font size","settings.resetChatContentWidth":"Reset chat content width","settings.resetChatContentFontSize":"Reset chat font size","settings.chatContentWidthDescription":"Set the maximum width of messages and the composer.","settings.themeLight":"Light","settings.themeDark":"Dark","settings.themeSystem":"System","settings.thinkingDisplay":"Thinking display","settings.thinkingDisplayDescription":"Choose whether model reasoning blocks are expanded when messages load.","settings.thinkingExpandedDefault":"Expand thinking blocks by default","settings.chat":"Chat","settings.quoteSelection":"Show actions for selected text","settings.languageDescription":"Choose the language used throughout the interface.","settings.shellTool":"Shell tool","settings.shellToolDescription":"Choose which shell the model uses for commands. Direct ! and !! commands still use Bash.","settings.usePowerShell":"Use PowerShell instead of Bash","settings.projectRequired":"Open a project to configure this section","skills.scope.global":"global","skills.scope.project":"project","skills.scope.path":"path","agents.close":"Close","agents.builtInTitle":"Enable Pi Web built-in sub-agents","agents.builtInDescription":"Provides Pi Web's integrated Agent tools and disables a conflicting pi-subagents extension.","agents.reloadRequired":"Reload the current session to apply this change.","agents.reloadSession":"Reload session","agents.reloading":"Reloading...","agents.loading":"Loading sub-agents...","agents.new":"New sub-agent","agents.empty":"Select or create a sub-agent profile","agents.saveScope":"Save to","agents.name":"Sub-agent ID","agents.displayName":"Display name","agents.description":"Description","agents.prompt":"System instructions","agents.tools":"Tools","agents.resources":"Resources","agents.loadSkills":"Load skills","agents.loadExtensions":"Load extensions","agents.model":"Model override","agents.modelsLoading":"Loading models...","agents.modelUnavailable":"{model} (unavailable)","agents.thinking":"Thinking","agents.maxTurns":"Max turns","agents.inherit":"Parent default","agents.enable":"Enable sub-agent","agents.disable":"Disable sub-agent","agents.builtinPath":"Built-in profile","agents.inheritContext":"Inherit parent context","agents.background":"Run in background by default","agents.duplicate":"Duplicate","agents.copyName":"{name} copy","agents.delete":"Delete","agents.deleteConfirm":"Delete {name}?","agents.save":"Save","agents.saving":"Saving...","agents.scope.builtin":"built-in","agents.scope.global":"global","agents.scope.workspace":"workspace","agents.scope.project":"project","agents.overridden":"Overridden","subagent.readOnlyNotice":"Sub-agent sessions are read-only","subagent.open":"Open sub-agent session","agentSwitcher.title":"Agents","agentSwitcher.main":"Main agent","agentSwitcher.subagent":"Sub-agent","agentSwitcher.current":"Current","agentSwitcher.count":"{count} sub-agents","agentSwitcher.runningCount":"{count} running","agentSwitcher.search":"Search agents","agentSwitcher.noFamily":"No agent family for this session","agentSwitcher.noMatches":"No matching agents","agentSwitcher.status.starting":"Starting","agentSwitcher.status.running":"Running","agentSwitcher.status.completed":"Completed","agentSwitcher.status.failed":"Failed","agentSwitcher.status.aborted":"Aborted","agentSwitcher.status.interrupted":"Interrupted","appUpdate.releaseNotes":"Pi Web v{version} is available. View release notes","sidebar.hide":"Hide sidebar","sidebar.show":"Show sidebar","theme.light":"Light mode (click for dark)","theme.dark":"Dark mode (click for system)","theme.auto":"System theme (click for light)","history.full":"Full history","history.unsaved":"Full history is available after the session is saved","history.label":"Full history","title.generating":"Generating...","title.updated":"Title updated","title.failed":"Generation failed","title.generate":"Generate title","title.unsaved":"Title generation is available after the session is saved","title.noMessages":"Send a message before naming this session","title.generateSession":"Generate a session title","system.prompt":"System prompt","system.empty":"System prompt is empty (tools are disabled)","system.load":"System prompt has not loaded yet","system.loading":"Loading system prompt…","system.label":"System","tools.label":"Tools","tools.title":"Tool definitions","tools.details":"Tool definition details","tools.load":"Tool definitions have not loaded yet","tools.loading":"Loading tool definitions…","tools.noTools":"No active tools","tools.description":"Description","tools.parameters":"Parameters","tools.parameterCount":"{count} parameters","tools.noParameters":"No parameters","tools.required":"Required","tools.optional":"Optional","tools.allowedValues":"Allowed","tools.defaultValue":"Default","tools.guidelines":"Prompt guidelines","session.info":"Session info","session.name":"Name","session.file":"Session File","session.inMemory":"In-memory","session.id":"ID","session.user":"User","session.assistant":"Assistant","session.toolCalls":"Tool Calls","session.toolResults":"Tool Results","session.total":"Total","session.input":"Input","session.output":"Output","session.cacheRead":"Cache Read","session.cacheWrite":"Cache Write","session.cost":"Cost","session.context":"Context","session.cacheHitRate":"Avg cache hit rate","session.copy":"Copy {value}","session.copied":"Copied","session.title":"Session info","session.load":"Send a message or run /session to load session info","session.infoSection":"Session Info","session.projectSection":"Project Info","session.messages":"Messages","session.tokens":"Tokens","session.totalActive":"Active Time","session.copyFile":"Copy file path","session.copyId":"Copy session ID","session.projectDir":"Project Dir","session.gitBranch":"Git Branch","session.gitWorktree":"Worktree","session.copyProjectDir":"Copy project directory","session.copyGitBranch":"Copy git branch","session.copyGitWorktree":"Copy worktree path","workspace.opening":"Opening workspace...","workspace.unable":"Unable to open workspace","workspace.selectSession":"Select a session from the sidebar","workspace.getStarted":"Get Started","workspace.selectProject":"Select a project directory from the sidebar","workspace.addModels":"Open Settings at the bottom, then choose Models","workspace.stepProject":"Select a project directory from the sidebar","workspace.stepModels":"Open Settings at the bottom, then choose Models","files.hidePanel":"Hide file panel","files.showPanel":"Show file panel","files.noneOpen":"No file open","layout.resizeSidebar":"Resize sidebar","layout.resizeFilePanel":"Resize file panel","layout.resizeHint":"Drag to resize. Double-click or press Enter to reset.","sidebar.new":"New","sidebar.newSessionTitle":"New session in {path}","sidebar.refresh":"Refresh","sidebar.selectProject":"Select project…","sidebar.filterProjects":"Filter projects…","sidebar.noMatchingProjects":"No matching projects","sidebar.searchFiles":"Search files","sidebar.searchFilesPlaceholder":"Search files…","sidebar.clearSearch":"Clear search","sidebar.searchingFiles":"Searching…","sidebar.noMatchingFiles":"No matching files","sidebar.useDefaultDirectory":"Use default directory","sidebar.customPath":"Custom path…","directoryPicker.selectDirectory":"Select directory","directoryPicker.goToParent":"Go to parent directory","directoryPicker.loadingDirectories":"Loading directories…","directoryPicker.noSubdirectories":"No subdirectories","directoryPicker.noMatchingDirectories":"No matching subdirectories","directoryPicker.filterPlaceholder":"Filter subdirectories…","directoryPicker.selectCurrentDirectory":"Select current directory","directoryPicker.selectThisFolder":"Select this folder","directoryPicker.noDrives":"No drives found","desktop.switchWorktree":"Switch worktree","desktop.switchWorktreeWithPath":"Switch worktree: {path}","desktop.openRepoRoot":"Open repo root","desktop.openRepoRootDescription":"Open the repository root to manage worktrees.","desktop.gitRepoRootOnly":"Git repo root only","desktop.gitRepoRootOnlyDescription":"Worktrees are available in Git repository roots.","desktop.checkingWorktrees":"Checking worktrees for this directory.","desktop.worktreesLoading":"Worktrees...","desktop.createWorktree":"Create a worktree checkout for a branch","desktop.newWorktree":"New worktree…","desktop.branchName":"branch name","desktop.creating":"Creating…","desktop.create":"Create","desktop.main":"main","desktop.removeWorktree":"Remove worktree checkout {path}; the branch is kept","desktop.uncommittedChanges":"Uncommitted changes. Force remove checkout?","desktop.force":"Force","desktop.sessions":"Sessions","desktop.newSession":"New","desktop.newSessionIn":"New session in {cwd}","desktop.refresh":"Refresh","desktop.loading":"Loading...","desktop.noModels":"No models available","desktop.noSessionsFound":"No sessions found","desktop.explorer":"Explorer","desktop.uploadFiles":"Upload files","desktop.uploadFilesToProjectRoot":"Upload files to project root","desktop.refreshExplorer":"Refresh explorer","desktop.agentRunningLabel":"Agent running","desktop.newActivity":"New activity","desktop.newSessionActivity":"New session activity","desktop.deleteSession":"Delete {title}?","desktop.delete":"Delete","desktop.deleteWithShift":"Delete (Shift-click to skip confirmation)","desktop.openingWorkspace":"Opening workspace…","desktop.unableToOpenWorkspace":"Unable to open this workspace","desktop.rename":"Rename","desktop.titleGenerationFailed":"Title generation failed","desktop.retryTitleGeneration":"Retry title generation","desktop.retry":"Retry","desktop.changeTitleModel":"Change model","desktop.pastedLabel":"[Pasted text #{id} \xb7 {lines} lines]","desktop.pastedShowPreview":"Preview pasted text","desktop.pastedHidePreview":"Collapse pasted text preview","desktop.pastedRemove":"Remove pasted text","desktop.pastedMissingContent":"A pasted-text placeholder lost its original content — send blocked. Please paste that content again.","desktop.generateTitle":"Generate title","desktop.generateAllTitles":"Generate titles for all sessions in this project","desktop.generatingTitlesProgress":"Generating titles… {done}/{total}","desktop.generatingTitle":"Generating title...","desktop.titleNeedsMessages":"No messages to generate a title from","desktop.expandForks":"Expand forks","desktop.collapseForks":"Collapse forks","desktop.sessionViewList":"List","desktop.sessionViewGroups":"Groups","desktop.searchSessions":"Search sessions, branches...","desktop.noSearchResults":"No matching sessions","desktop.pinned":"Pinned","desktop.today":"Today","desktop.yesterday":"Yesterday","desktop.older":"Older","desktop.collapseGroup":"Collapse","desktop.expandGroup":"Expand","desktop.pin":"Pin to top","desktop.unpin":"Unpin","desktop.forkedFrom":"Forked from {title}","desktop.messagesCount":"{count} msgs","desktop.worktree":"Worktree: {cwd}","desktop.justNow":"just now","desktop.minutesAgo":"{count}m ago","desktop.hoursAgo":"{count}h ago","desktop.daysAgo":"{count}d ago","desktop.panelGroupBubble":"Grouped","desktop.panelProjectBubble":"Projects","desktop.rowStyleToggle":"Toggle row style","desktop.sidebarModeCycle":"Cycle sidebar mode","desktop.panelFormLabel":"Panel","desktop.expandAllFolders":"Expand all folders","desktop.collapseAllFolders":"Collapse all folders","desktop.filterMenu":"Filter","desktop.moreActions":"More actions","desktop.viewSection":"View","desktop.viewByProject":"By project","desktop.viewTimeline":"Timeline","desktop.sortSection":"Sort by","desktop.sortUpdated":"Updated","desktop.sortCreated":"Created","desktop.hiddenProjectsSection":"Hidden projects","desktop.noHiddenProjects":"No hidden projects","desktop.restoreProject":"Restore","desktop.archivedView":"Archived","desktop.archiveSession":"Archive","desktop.archiveSessionConfirm":"Archive {title}?","desktop.unarchiveSession":"Unarchive","desktop.deleteForever":"Delete forever","desktop.deleteArchivedConfirm":"Permanently delete this archived session? Its file will be removed and this cannot be undone.","desktop.removeProject":"Remove project","desktop.removeProjectConfirm":"Project {name} will be removed from the sidebar, but files on disk are not deleted.","desktop.removeProjectRunningConfirm":"This project still has running sessions. Remove it anyway?","desktop.showMore":"Show more","desktop.viewFiles":"View files","desktop.backToSessions":"Back to sessions","desktop.newSessionHere":"New session in this project","desktop.newTask":"New task","desktop.showAllProjects":"Show all projects","desktop.showCurrentProject":"Show current project","desktop.sidebarModeHintTitle":"Two list layouts","desktop.sidebarModeHintDesc":"This button switches between the current-project dropdown and the all-projects panel (grouped / project / timeline views, archiving and per-project file trees).","desktop.sidebarModeHintOk":"Got it","desktop.noProjects":"No projects yet","desktop.noArchivedSessions":"No archived sessions","desktop.searchArchived":"Search archived sessions...","desktop.projectSectionHeader":"Projects","desktop.closeTab":"Close","desktop.closeTabWithLabel":"Close {label}","desktop.modelsHideApiKey":"Hide API key","desktop.modelsShowApiKey":"Show API key","desktop.modelsInheritNone":"— inherit / none —","desktop.modelsProvider":"Provider","desktop.modelsProviderName":"Provider name","desktop.modelsBaseUrl":"Base URL","desktop.modelsApiKey":"API Key","desktop.modelsApiKeyHelp":"Prefix with ! to run a shell command, or use an env var name","desktop.modelsApiKeyPlaceholder":"ENV_VAR_NAME, !shell-command, or literal key","desktop.modelsApi":"API","desktop.modelsDefault":"Default","desktop.modelsDisabled":"Disabled","desktop.modelsCustom":"Custom","desktop.modelsModelSection":"Model","desktop.modelsTestingConnection":"Testing model connection...","desktop.modelsConnected":"Connected","desktop.modelsFailed":"Failed","desktop.modelsTestConnection":"Test model connection","desktop.modelsTesting":"Testing…","desktop.modelsTest":"Test","desktop.modelsOk":"OK","desktop.modelsRemove":"Remove","desktop.modelsIdRequired":"ID *","desktop.modelsName":"Name","desktop.modelsDisplayName":"Display name","desktop.modelsApiOverride":"API override","desktop.modelsReasoningThinking":"Reasoning / thinking","desktop.modelsImageInput":"Image input","desktop.modelsDeepSeekCompat":"DeepSeek thinking compat","desktop.modelsThinkingLevelMap":"Thinking level map","desktop.modelsClearAll":"clear all","desktop.modelsDiscoveryFetching":"Importing models…","desktop.modelsDiscoveryFetch":"Import models…","desktop.modelsDiscoveryFilterPlaceholder":"Filter {count} models…","desktop.modelsDiscoveryFilter":"Filter upstream models","desktop.modelsDiscoverySelectShown":"Select shown","desktop.modelsDiscoveryNoMatches":"No matching models.","desktop.modelsDiscoveryAdded":"added","desktop.modelsDiscoveryShowing":"Showing first {shown} of {total}","desktop.modelsDiscoveryFetched":"{count} models fetched","desktop.modelsDiscoveryAddSelected":"Add selected","desktop.modelsDiscoveryAddSelectedCount":"Add selected ({count})","desktop.modelsCatalogSource":"source: models.dev ↗","desktop.modelsCatalogFilling":"Filling details…","desktop.modelsCatalogFill":"Fill model details","desktop.modelsCatalogFilled":"{count} fields filled","desktop.modelsCatalogNoEmptyFields":"No empty fields to fill","desktop.modelsCatalogNoExactMatch":"No exact models.dev match","desktop.modelsCatalogPriceProvider":"Price matched Provider {provider}","desktop.modelsCatalogPriceBaseUrl":"Price matched Base URL to {provider}","desktop.modelsCatalogPriceConsensus":"Price agreed by {support}/{total} records","desktop.modelsCatalogPriceUnreliable":"No reliable price found","desktop.modelsCatalogUndo":"Undo","desktop.modelsContextWindow":"Context window (tokens)","desktop.modelsMaxOutputTokens":"Max output tokens","desktop.modelsCostPerMillionTokens":"Cost (per million tokens)","desktop.modelsSubscription":"Subscription","desktop.titleModel":"Title generation model","desktop.titleModelDescription":'Model used to auto-generate session titles. Keep "Follow session model" to use each session\'s own model.',"desktop.titleModelFollowSession":"Follow session model (default)","desktop.titleModelInvalid":"no longer imported — title generation falls back to the session model","desktop.titleModelSaved":"Saved","desktop.titleModelSaveError":"Failed to save title model setting","desktop.modelsNotConnected":"not connected","desktop.modelsAlreadyConnected":"Already connected. You can re-login or disconnect.","desktop.modelsConnectAccount":"Connect your {provider} account.","desktop.modelsOpeningBrowser":"Opening browser…","desktop.modelsCompleteSignIn":"Complete sign-in in the browser, then copy the redirect URL from the address bar and paste it below.","desktop.modelsBrowserDidNotOpen":"If the browser window did not open,","desktop.modelsOpenLoginPage":"click here to open the login page","desktop.modelsEnterValue":"Enter value…","desktop.modelsOpenVerificationPage":"Open the verification page and enter this code:","desktop.modelsExpiresInMinutes":"Expires in {count} minutes.","desktop.modelsConnectedSuccessfully":"Connected successfully.","desktop.modelsReLogin":"Re-login","desktop.modelsLogin":"Login","desktop.modelsDisconnect":"Disconnect","desktop.modelsConnectionLost":"Connection lost","desktop.modelsAuthenticationStateChanged":"Authentication state changed. Please refresh and try again.","desktop.modelsVerifying":"Verifying…","desktop.modelsContinuing":"Continuing…","desktop.modelsServerError":"Server error {status}","desktop.modelsNetworkError":"Network error","desktop.modelsConfigured":"configured","desktop.modelsNotConfigured":"not configured","desktop.modelsApiKeyStored":"API key is stored. Enter a new key below to replace it, or disconnect to remove it.","desktop.modelsEnableModels":"Enter your {provider} API key to enable {count} {models}.","desktop.modelsSingular":"model","desktop.modelsPlural":"models","desktop.modelsEnterNewKey":"Enter new key to replace…","desktop.modelsSaving":"Saving…","desktop.modelsSaved":"Saved","desktop.modelsRemoving":"Removing…","desktop.modelsSearchProviders":"Search providers…","desktop.modelsNoProvidersMatch":"No providers match","desktop.modelsCompatibleProvider":"OpenAI / Anthropic compatible","desktop.modelsCustomEndpointFormat":"Custom endpoint format","desktop.modelsAddCustomTitle":"Add custom provider","desktop.modelsProviderNameOptional":"Provider name (optional)","desktop.modelsCallFormat":"Call format","desktop.modelsCallFormatHelp":"Choose one of the existing call formats","desktop.modelsCustomCallFormat":"Custom call format","desktop.modelsCustomCallFormatHelp":"Custom endpoints use the OpenAI-compatible protocol (openai-completions) by default. Pick another format above if your API speaks a different protocol.","desktop.modelsFullUrl":"Full URL","desktop.modelsAddModelManual":"Add model","desktop.modelsImportProvider":"Import from existing provider","desktop.modelsImportProviderPlaceholder":"— import existing provider config —","desktop.modelsImported":"imported","desktop.modelsAddUrl":"+ Add URL","desktop.modelsUrlPlaceholder":"https://api.example.com/v1","desktop.modelsUrlInvalid":"URL must start with http:// or https://","desktop.modelsCustomRequest":"Custom request","desktop.modelsRequestModelId":"Request model ID","desktop.modelsRequestModelIdHelp":"Optional — creates the first model with these request settings","desktop.modelsRequestContextLength":"Context length (tokens)","desktop.modelsRequestOutputLength":"Output length (tokens)","desktop.modelsAdd":"Add","desktop.modelsSubscriptions":"Subscriptions","desktop.modelsCount":"{count} models","desktop.modelsLoading":"Loading…","desktop.modelsNewModel":"new model","desktop.modelsAddModel":"+ model","desktop.modelsAddProvider":"+ Add provider","desktop.modelsSelectProviderOrModel":"Select a provider or model","desktop.modelsClose":"Close models","desktop.modelsSave":"Save","desktop.searchModels":"Search models…","desktop.noModelsMatch":"No matching models","desktop.global":"global","desktop.project":"project","desktop.path":"path","desktop.addPlugin":"Add plugin","desktop.addPluginTitle":"Add Plugin","desktop.pluginSource":"Source","desktop.install":"Install","desktop.installing":"Installing...","desktop.examples":"Examples","desktop.disabled":"Disabled","desktop.filtered":"filtered","desktop.noResources":"No resources","desktop.packageDisabled":"Package disabled","desktop.noResolvedResources":"No resolved resources","desktop.unknown":"Unknown","desktop.installedVersion":"installed {version}","desktop.configuredVersion":"configured {version}","desktop.enablePackage":"Enable package","desktop.disablePackage":"Disable package","desktop.update":"Update","desktop.updating":"Updating...","desktop.reloadSession":"Reload session","desktop.reloading":"Reloading...","desktop.reloadCurrentSession":"Reload current session","desktop.openSessionToReload":"Open a session to reload","desktop.remove":"Remove","desktop.removing":"Removing...","desktop.status":"Status","desktop.version":"Version","desktop.package":"Package","desktop.resources":"Resources","desktop.installedPath":"Installed path","desktop.notFound":"Not found","desktop.cwd":"Cwd","desktop.resolvedResources":"Resolved Resources","desktop.packageRemoved":"Package removed.","desktop.packageInstalled":"Package installed.","desktop.packageUpdated":"Package updated.","desktop.packageDisabledMessage":"Package disabled.","desktop.packageEnabled":"Package enabled.","desktop.sessionReloaded":"Session reloaded.","desktop.noPluginsConfigured":"No plugins configured","desktop.selectPackage":"Select a package","desktop.diagnosticsCount":"{count} diagnostic{suffix}","desktop.pluginResourceTotals":"{extensions} ext \xb7 {skills} skills \xb7 {prompts} prompts \xb7 {themes} themes","desktop.extensionsCount":"{count} ext","desktop.skillsCount":"{count} skills","desktop.promptsCount":"{count} prompts","desktop.themesCount":"{count} themes","desktop.addSkill":"Add skill","desktop.addSkillTitle":"Add Skill","desktop.skillSearchPlaceholder":"e.g. react, testing, deploy","desktop.noSkillsFound":"No skills found","desktop.skillSearchHint":"Search skills.sh to discover and install skills for your agent.","desktop.visibleInModelPrompt":"Visible in model prompt — click to disable","desktop.hiddenFromModelPrompt":"Hidden from model prompt — click to enable","desktop.dormant":"Dormant","desktop.hiddenButInvocable":"Hidden from the model, still manually invocable","desktop.check":"Check","desktop.upToDate":"Up to date","desktop.automaticChecksUnavailable":"Automatic checks unavailable","desktop.checkFailed":"Check failed","desktop.name":"Name","desktop.description":"Description","desktop.selectSkill":"Select a skill","desktop.checkUpdates":"Check updates","desktop.updateAvailable":"Update available","desktop.installed":"Installed","desktop.updatesCount":"{count} update{suffix}","desktop.downloadFile":"Download file","desktop.loadingFile":"Loading...","desktop.noChanges":"No changes","desktop.unchangedLines":"... {count} unchanged lines ...","desktop.lines":"{count} lines","desktop.mentionFile":"Mention file","desktop.mentionSelectedLines":"Mention selected lines {start}-{end}","desktop.source":"Source","desktop.diff":"Diff","desktop.enableWordWrap":"Enable word wrap","desktop.disableWordWrap":"Disable word wrap","desktop.wrap":"wrap","desktop.code":"Code","desktop.preview":"Preview","desktop.raw":"Raw","desktop.htmlPreview":"HTML preview","desktop.image":"image","desktop.audio":"audio","desktop.docxPreview":"docx preview","desktop.failedToLoadImage":"Failed to load image","desktop.failedToLoadAudio":"Failed to load audio","desktop.docxTooLargeForPreview":"DOCX too large for preview (>10MB)","desktop.previewFile":"Preview {file}","desktop.branches":"Branches","desktop.noActiveSession":"No active session","desktop.sessionHasNoBranches":"No branches yet — use Edit from here or Fork on a message to create one","desktop.copyMessage":"Copy message","desktop.copyPlainText":"Copy as plain text","desktop.createTaskFromMessage":"Create task from message","desktop.editFromHere":"Edit from here — branches within this session","desktop.creatingNewSession":"Creating new session…","desktop.newSessionFromHere":"New session — creates an independent copy from here","desktop.estimatedStreamingTokenCount":"Estimated token count while streaming","desktop.tokensPerSecond":"{count} t/s","desktop.thinkingContentUnavailable":"Thinking content unavailable","desktop.loadingThinking":"Loading thinking...","desktop.conversationCompacted":"Conversation compacted","desktop.compactionSummaryDescription":"The conversation history before this point was compacted into the following summary:","desktop.noSummary":"(no summary)","desktop.fileContext":"File context: {context}","desktop.readFilesCount":"{count} read","desktop.modifiedFilesCount":"{count} modified","desktop.modifiedFiles":"Modified files","desktop.readFiles":"Read files","desktop.hiddenExtensionMessage":"hidden extension message","desktop.noMessage":"(no message)","desktop.showExtensionMessage":"Show extension message","desktop.copied":"Copied","desktop.copy":"Copy","desktop.collapse":"Collapse","desktop.expand":"Expand","desktop.hideDetails":"Hide details","desktop.showDetails":"Show details","desktop.before":"Before","desktop.after":"After","desktop.noOutput":"(no output)","desktop.extension":"extension","desktop.assistant":"assistant","desktop.favorites":"Favorites","desktop.favorite":"Favorite","desktop.unfavorite":"Unfavorite","desktop.processStepThinking":"Thinking","desktop.processStepFileRead":"Read","desktop.processStepFileCreate":"Create","desktop.processStepFileEdit":"Edit","desktop.processStepFileDelete":"Delete","desktop.processStepSearch":"Search","desktop.processStepFind":"Find","desktop.processStepList":"List","desktop.processStepRead":"Read","desktop.processStepFetch":"Fetch","desktop.processStepDelete":"Delete","desktop.processStepCopy":"Copy","desktop.processStepCommand":"Run","desktop.processStepTool":"Tool","desktop.processStepTodo":"Todo","desktop.processStepArtifact":"Artifact","desktop.processStepCompaction":"Compaction","desktop.processStepError":"Error","desktop.processWorking":"Working...","desktop.processUsed":"Used {summary}","desktop.processToolCount":"{count} tool","desktop.processToolsCount":"{count} tools","desktop.processFailedCount":" ({failed} failed)","desktop.processThoughtCount":"{count} thought","desktop.processThoughtsCount":"{count} thoughts","desktop.processThoughtDone":"Thought {duration}s","desktop.processThoughtDoneNoDuration":"Thought","desktop.processCustomCount":"{count} event","desktop.processCustomsCount":"{count} events","desktop.processCompleted":"Process complete","desktop.processOutput":"Process output","desktop.processTabMode":"Tab mode","desktop.processTimelineMode":"Timeline mode","desktop.processFailedStep":"failed","desktop.markdownPreviewAvailableAfterStreaming":"Preview available after streaming","desktop.markdownPreviewMermaidDiagram":"Preview Mermaid diagram","desktop.markdownInvalidMermaidDiagram":"Invalid Mermaid diagram","desktop.markdownRenderingMermaidDiagram":"Rendering Mermaid diagram","desktop.openMermaidViewer":"Open Mermaid viewer","desktop.mermaidDiagram":"Mermaid diagram","desktop.mermaidViewer":"Mermaid diagram viewer","desktop.zoomPanHint":"Drag to pan \xb7 Scroll to zoom","desktop.selectText":"Select text","desktop.zoomOut":"Zoom out","desktop.resetZoom":"Reset to 100% (fit)","desktop.zoomIn":"Zoom in","desktop.fitToViewport":"Fit to viewport","desktop.quoteReply":"Quote reply","desktop.quoteReplyHint":"Click to quote reply","desktop.openFile":"Open","desktop.queueRecoveryTitle":"Recover queued messages","desktop.queueImportTitle":"Imported queued messages","desktop.queueRecoveryDescription":"These messages were saved before the previous server session ended. Choose what to re-queue; nothing is sent automatically.","desktop.queueImportDescription":"Choose which imported messages to re-queue. Nothing is sent automatically.","desktop.selectAll":"Select all","desktop.selectNone":"Select none","desktop.import":"Import","desktop.queueImages":"Image attachment","desktop.queueNoText":"(image-only message)","desktop.queueExported":"Exported {count} message(s)","desktop.queueImportEmpty":"No valid queued messages found","desktop.queueImported":"Imported {count} message(s) for review","desktop.dismiss":"Dismiss","desktop.discard":"Discard","desktop.requeue":"Re-queue","desktop.requeueAndContinue":"Re-queue & continue","desktop.markdownPlainText":"text","desktop.hideTaskBoard":"Hide task board","desktop.showTaskBoard":"Show task board","tasks.actionArchive":"Archive","tasks.actionCancel":"Cancel","tasks.actionEdit":"Edit","tasks.actionMerge":"Merge","tasks.stashDone":"Changes stashed successfully","tasks.actionRequeue":"Re-queue","tasks.actionRetry":"Retry","tasks.actionReturn":"Return with feedback","tasks.actionStart":"Start","tasks.actionComplete":"Complete","tasks.actionUnarchive":"Unarchive","tasks.actionViewSession":"View session","tasks.allFolders":"All projects","tasks.archiveAllDone":"Archive all","tasks.badgeCleanupFailed":"cleanup failed","tasks.badgeWorktreeKept":"worktree kept","tasks.beta":"Beta","tasks.cancelDescription":"The task will stop. You can leave a reason for whoever requeues it later (optional).","tasks.cancelKeep":"Keep task","tasks.cancelReasonLabel":"Cancel reason (optional)","tasks.cancelReasonPlaceholder":"e.g. wrong approach, requirements changed…","tasks.cancelSubmit":"Cancel task","tasks.cancelTitle":"Cancel task","tasks.changedFiles":"Changed files","tasks.colAttention":"Attention","tasks.colDone":"Done","tasks.colInProgress":"In progress","tasks.colTodo":"Todo","tasks.delete":"Delete","tasks.deleteConfirm":"Delete","tasks.deleteTemplate":"Delete template","tasks.deleteWorktree":"Also delete the worktree","tasks.diff":"Diff","tasks.dropToStart":"Drop to start","tasks.editTitle":"Edit task","tasks.empty":"No tasks yet","tasks.emptyColAttention":"Nothing needs you","tasks.emptyColDone":"Nothing completed yet","tasks.emptyColInProgress":"Nothing running","tasks.emptyColTodo":"No pending tasks","tasks.emptyHint":"Create a task and the board walks it through execution — start it and a worktree branch runs the agent to completion.","tasks.errorView":"View","tasks.event_archived":"archived","tasks.event_canceled":"canceled","tasks.event_created":"created","tasks.event_failed":"failed","tasks.event_interrupted":"interrupted","tasks.event_merge_failed":"merge failed","tasks.event_merge_requested":"merge requested","tasks.event_merged":"merged","tasks.event_merging":"merging","tasks.event_preflight_failed":"preflight failed","tasks.event_preflight_passed":"preflight passed","tasks.event_preflight_start":"preflight running","tasks.event_preparing":"preparing","tasks.event_queued":"queued","tasks.event_recovered":"recovered","tasks.event_requeued":"re-queued","tasks.event_return_feedback":"feedback","tasks.event_returned":"returned","tasks.event_review":"review","tasks.event_started":"started","tasks.event_unarchived":"unarchived","tasks.event_updated":"updated","tasks.fieldProject":"Project","tasks.fieldPrompt":"Prompt","tasks.fieldPromptPlaceholder":"Describe the work the agent should complete…","tasks.fieldTitle":"Title","tasks.fieldTitlePlaceholder":"Short title for the task","tasks.filter":"Filter","tasks.loading":"Loading…","tasks.mergeAutoMessage":"Let the agent write the commit message","tasks.mergeConfirm":"Merge","tasks.mergeDeleteWorktree":"Delete the worktree after merging","tasks.mergeManualMessage":"Provide a commit message","tasks.mergeMessagePlaceholder":"Commit message…","tasks.mergeStrategyMerge":"Merge commit","tasks.mergeStrategySquash":"Squash","tasks.mergeTitle":"Merge task","tasks.completeDeleteWorktree":"Delete worktree on completion","tasks.completeDescription":"This task produced no file changes, so there is nothing to merge. Confirm to mark it done.","tasks.completeSubmit":"Complete","tasks.completeTitle":"Complete task","tasks.followUpPlaceholderRequeue":"Note for the agent (optional)…","tasks.followUpPlaceholderRetry":"Note for the agent (optional)…","tasks.actionAddNote":"Note (optional)","tasks.restartDescription":"The note is injected into the next run's prompt (optional).","tasks.restartTitleRequeue":"Requeue","tasks.restartTitleRetry":"Retry","tasks.planReviewTitle":"Plan complete","tasks.planReviewDescription":"The plan-mode analysis has finished. Confirm to execute the plan, send suggestions for another pass, or exit plan mode.","tasks.planReviewShowPlan":"View plan","tasks.planReviewHidePlan":"Collapse plan","tasks.planReviewExecute":"Execute","tasks.planReviewExecutePrompt":"Please execute the following plan:\n\n{plan}","tasks.planReviewSuggest":"Suggest","tasks.planReviewSendFeedback":"Send suggestions","tasks.planReviewFeedbackLabel":"Suggestions (sent back to the agent to refine the plan)","tasks.planReviewFeedbackPlaceholder":"e.g. add risk analysis first, split into smaller steps…","tasks.planReviewExit":"Exit plan mode","tasks.metaCommit":"Commit","tasks.metaCreated":"Created","tasks.metaProject":"Project","tasks.new":"New task","tasks.newTitle":"New task","tasks.noDiff":"No diff available","tasks.noEvents":"No events yet","tasks.notifyFailed":"{title} failed","tasks.notifyReview":"{title} is ready for review","tasks.returnPlaceholder":"Feedback for the agent…","tasks.returnSubmit":"Send back","tasks.save":"Save","tasks.saveAsTemplate":"Save as template","tasks.sessionFile":"Session file","tasks.sessionHint":"The task's agent conversation is stored like any other session. Open it from the sessions list to read or continue it.","tasks.sessionId":"Session id","tasks.sessionTitle":"Task session","tasks.settingsAutoProcess":"Auto-process queued tasks","tasks.settingsDeleteWorktree":"Delete worktree after merge (default)","tasks.settingsInitCommand":"Init command (run in the worktree before the agent)","tasks.settingsInitPlaceholder":"e.g. pnpm install","tasks.settingsMaxConcurrent":"Max concurrent tasks (0 = unlimited)","tasks.settingsMergeStrategy":"Merge strategy","tasks.settingsNoProject":"Create a task first to pick a project.","tasks.settingsPreflightCommand":"Preflight command (acceptance check)","tasks.settingsPreflightPlaceholder":"e.g. npm test","tasks.settingsProject":"Project","tasks.settingsReset":"Reset to defaults","tasks.settingsStagePrompts":"Stage prompts (extra instructions)","tasks.settingsTitle":"Task settings","tasks.showArchived":"Show archived","tasks.showCanceled":"Show canceled","tasks.stage_merge":"Merge","tasks.stage_retry":"Retry","tasks.stage_return":"Return","tasks.stage_work":"Work","tasks.startAll":"Start all","tasks.statusAwaitingInput":"Awaiting input","tasks.statusCanceled":"Canceled","tasks.statusDone":"Done","tasks.statusFailed":"Failed","tasks.statusInterrupted":"Interrupted","tasks.statusMerging":"Merging","tasks.statusPreparing":"Preparing","tasks.statusQueued":"Queued","tasks.statusReview":"Review","tasks.statusRunning":"Running","tasks.statusTodo":"Todo","tasks.templateNamePlaceholder":"Template name…","tasks.templates":"Templates","tasks.timeline":"Timeline","tasks.title":"Tasks","tasks.attentionBadge":"needs you","sidebar.checking":"Checking…","sidebar.open":"Open","sidebar.cancel":"Cancel","sidebar.openRepoRoot":"Open repo root","sidebar.openRepoRootTitle":"Open the repository root to manage worktrees.","sidebar.gitRepoRootOnly":"Git repo root only","sidebar.gitRepoRootOnlyTitle":"Worktrees are available in Git repository roots.","sidebar.worktrees":"Worktrees...","sidebar.checkingWorktrees":"Checking worktrees for this directory.","sidebar.filterWorktrees":"Filter worktrees…","sidebar.noMatchingWorktrees":"No matching worktrees","sidebar.switchWorktree":"Switch worktree","sidebar.switchWorktreeTitle":"Switch worktree: {path}","sidebar.main":"main","sidebar.forceRemoveCheckout":"Uncommitted changes. Force remove checkout?","sidebar.force":"Force","sidebar.createWorktreeTitle":"Create a worktree checkout for a branch","sidebar.newWorktree":"New worktree…","sidebar.branchName":"branch name","sidebar.creating":"Creating…","sidebar.create":"Create","sidebar.uploadFilesTitle":"Upload files to project root","sidebar.uploadFiles":"Upload files","sidebar.refreshExplorer":"Refresh explorer","sidebar.searchSessions":"Search all conversations...","sidebar.toggleSessionSearch":"Search conversations","sidebar.sessionSearching":"Searching...","sidebar.sessionSearchEmpty":"No matching conversations","sidebar.sessionSearchCount":"{count} matching conversations","sidebar.sessionSearchPartial":"Search limit reached. Results may be incomplete.","sidebar.sessionSearchFailed":"Could not search conversations","sidebar.changedFiles":"{count} changed files","sidebar.loading":"Loading...","sidebar.noSessions":"No sessions found","sidebar.agentRunning":"Agent running…","sidebar.newActivity":"New activity","sidebar.newSessionActivity":"New session activity","sidebar.deleteSession":"Delete {title}?","sidebar.rename":"Rename","sidebar.delete":"Delete","sidebar.deleteWithShiftClick":"Delete (Shift+click to delete without confirmation)","sidebar.expandSubagents":"Expand subagents","sidebar.collapseSubagents":"Collapse subagents","sidebar.messagesCount":"{count} msgs","sidebar.worktreePath":"Worktree: {path}","sidebar.removeWorktreeTitle":"Remove worktree checkout {path}; the branch is kept","files.modified":"Modified","files.added":"Added","files.deleted":"Deleted","files.renamed":"Renamed","files.untracked":"Untracked","files.conflict":"Conflict","files.newlyUploaded":"Newly uploaded","files.containsChangedFiles":"Contains changed files","files.insertPath":"Insert path into chat","files.mention":"mention","files.download":"Download file","files.dismissError":"Dismiss error","files.addUploadedFile":"Add uploaded file to chat","files.addAllUploadedFiles":"Add all uploaded files to chat","files.dismissUploadResults":"Dismiss upload results","files.loading":"Loading files...","files.noFiles":"No files found","files.explorer":"Explorer","files.changedCount":"{count} files","files.changeStats":"{count} changed files, {additions} lines added, {deletions} lines deleted","files.conflictSummary":"{count} file{countSuffix} already exist: {files}","files.cannotReplace":"Cannot replace: {files}","files.replace":"Replace","files.skipExisting":"Skip existing","files.cancel":"Cancel","files.checking":"Checking files","files.uploading":"Uploading, {progress}%","files.edit":"Edit","files.save":"Save","files.saveHint":"Save (Cmd/Ctrl+S)","files.cancelEdit":"Cancel edit","files.saveFailed":"Save failed: {error}","files.unsavedChanges":"Discard unsaved changes?","files.externalModified":"This file was modified outside the editor. Reload to load the latest version.","files.reload":"Reload","files.reloadOverwriteConfirm":"Overwrite your unsaved edits with the version on disk?","files.newFile":"New file","files.newFolder":"New folder","files.delete":"Delete","files.promptFileName":"File name","files.promptFolderName":"Folder name","files.confirmDeleteFile":'Delete "{name}"? This cannot be undone.',"files.confirmDeleteDirectory":'Delete "{name}" and all its contents? This cannot be undone.',"chat.loadingSession":"Loading session...","chat.runningTool":"Running tool...","chat.generatingToolInput":"Generating parameters...","chat.runningNamedTool":"Running {name}...","chat.runningTools":"Running {names}...","chat.runningToolsMore":"Running {names} (+{count})...","chat.waitingModel":"Waiting for model...","chat.runningCommand":"Running command...","chat.thinking":"Thinking...","chat.processDetails":"Process details","chat.message":"message","chat.messages":"messages","chat.toolCall":"tool call","chat.toolCalls":"tool calls","chat.collapseProcess":"Collapse process details","chat.expandProcess":"Expand process details","chat.filesWritten":"Files changed","chat.openWrittenFile":"Open {name}","chat.loadEarlier":"Scroll up to load earlier messages","chat.extensionRequest":"extension request","chat.extensionExpiresIn":"expires in {seconds}s","chat.extensionPending":"Awaiting response","chat.extensionCollapse":"Collapse","chat.extensionExpand":"Expand","chat.cancel":"Cancel","chat.confirm":"Confirm","chat.submit":"Submit","chat.extensionInput":"Extension terminal input","chat.extensionPanel":"Extension panel","chat.extensionWidgets":"Extension widgets","chat.extensionWidgetAbove":"Above editor widget","chat.extensionWidgetBelow":"Below editor widget","chat.extensionWidgetLine":"{count} line","chat.extensionWidgetLines":"{count} lines","chat.close":"Close","chat.queued":"Queued \xb7 {count}","chat.recall":"Recall to input","chat.recallTitle":"Remove all queued messages and put them back into the input box for editing","chat.retrying":"Retrying ({attempt}/{max})…","chat.loadingCommands":"Loading commands...","chat.slashCommands":"Slash commands \xb7 {label}","chat.tabEnter":"Tab / Enter","chat.noCommands":"No extension, prompt, or skill commands found","chat.match":"1 match","chat.matches":"{count} matches","chat.command":"1 command","chat.commands":"{count} commands","chat.loadingFiles":"Loading files...","chat.files":"Files \xb7 {label}{hint}","chat.searching":"Searching…","chat.noMatchingFiles":"No matching files","chat.searchingAll":" \xb7 searching all files…","chat.indexTruncated":" \xb7 index truncated","chat.steerPlaceholder":"Steer now / queue follow-up...","chat.agentPlaceholder":"Agent is running…","chat.messagePlaceholder":"Message… Type / for commands, @ for files","chat.steer":"Steer","chat.followUp":"Follow-up","chat.steerHint":"Interrupt the current run and inject this message now","chat.followUpHint":"Queue this message after the agent finishes","chat.inputHistory":"Input history","chat.modelError":"Model error","chat.modelScopeWarning":"Model scope warning","chat.modelScopeWarnings":"Model scope warnings","chat.send":"Send","chat.askSelection":"Ask about selected text","chat.askInCurrent":"Ask here","chat.askInNewChat":"Ask in new chat","chat.newQuoteChat":"New chat about selected text","chat.quoteIntro":"About this passage:","chat.quoteQuestion":"My question:","chat.quoteForkFailed":"Unable to create a branch from this message.","chat.attachImage":"Attach image","chat.previewImage":"Preview image","chat.filterModels":"Filter models…","chat.noMatchingModels":"No matching models","chat.moreControls":"More controls","chat.collapseControls":"Collapse controls","chat.shell":"Shell","terminal.title":"Terminal","terminal.tabLabel":"Terminal: {name}","terminal.open":"Open workspace terminal","terminal.close":"Terminate terminal","terminal.restart":"Restart terminal","terminal.reconnect":"Reconnect terminal","terminal.connecting":"Connecting","terminal.ready":"Connected","terminal.exited":"Terminal closed","terminal.error":"Connection error","terminal.exitCode":"Process exited with code {code}","chat.outputLocal":"output stays local","chat.outputModel":"output sent to model","chat.chatOnly":"Chat only","chat.readOnlyTools":"{count} read-only built-in tools","chat.builtInTools":"{count} built-in tools","chat.allBuiltInTools":"All built-in tools","chat.changeReasoning":"Change reasoning level: {level}","chat.changeReasoningLabel":"Change reasoning level","chat.changeToolPreset":"Change tool preset","chat.stopCompaction":"Stop compaction","chat.compactContext":"Compact context","chat.compacting":"Compacting…","chat.compact":"Compact","chat.stopAgent":"Stop agent","chat.stop":"Stop","chat.disableSound":"Disable completion sound","chat.enableSound":"Enable completion sound","chat.thinkingUseDefault":"Use pi default","chat.thinkingOff":"Reasoning off","chat.thinkingMinimal":"Minimal reasoning","chat.thinkingLow":"Low reasoning","chat.thinkingMedium":"Medium reasoning","chat.thinkingHigh":"High reasoning","chat.thinkingXhigh":"Extra-high reasoning","chat.thinkingMax":"Max reasoning","chat.builtIn":"Built-in","chat.extensions":"Extensions","chat.prompts":"Prompts","chat.skills":"Skills","chat.dormant":"dormant","chat.commandCompact":"Compress context, optionally with instructions","chat.commandReload":"Reload extensions, skills, prompts, and tools","chat.commandName":"Set the session display name","chat.commandSession":"Show session message, token, and cost stats","chat.commandCopy":"Copy the last assistant message","chat.commandClone":"Clone the current branch into a new session","chat.compacted":"Compacted","chat.imageNotSupportedTitle":"Images may not be sent","chat.imageNotSupportedBody":"The selected model ({model}) does not support image input. The attached images will likely be ignored.","chat.tokensSaved":"{saved} saved","i18n.copy":"Copy","i18n.copied":"Copied","i18n.save":"Save","i18n.saving":"Saving…","i18n.saved":"Saved","i18n.remove":"Remove","i18n.removing":"Removing…","i18n.delete":"Delete","i18n.loading":"Loading...","i18n.search":"Search","i18n.refresh":"Refresh","i18n.update":"Update","i18n.updating":"Updating...","i18n.check":"Check","i18n.install":"Install","i18n.installing":"Installing...","i18n.noResults":"No results","i18n.searchProviders":"Search providers…","i18n.noProviders":"No providers match","i18n.newModel":"new model","i18n.addProvider":"Add provider","i18n.selectProviderModel":"Select a provider or model","i18n.visibleInPrompt":"Visible in model prompt — click to disable","i18n.hiddenFromPrompt":"Hidden from model prompt — click to enable","i18n.dormant":"Dormant","i18n.hiddenButInvocable":"Hidden from model, still manually invocable","i18n.skillSearchPlaceholder":"e.g. react, testing, deploy","i18n.searching":"Searching…","i18n.noSkills":"No skills found","i18n.checkUpdates":"Check updates","i18n.updates":"updates","i18n.noResolvedResources":"No resolved resources","i18n.enablePackage":"Enable package","i18n.disablePackage":"Disable package","i18n.filtered":"filtered","i18n.openSessionToReload":"Open a session to reload","i18n.notFound":"Not found","i18n.noPlugins":"No plugins configured","trust.resourcesNotLoaded":"Restricted mode","trust.trustProject":"Trust project","trust.trusting":"Trusting...","trust.cancel":"Cancel","trust.dialogTitle":"Trust this project?","trust.dialogBody":"Project resources can run local code. Trust only projects whose contents you know.","trust.skillsNotLoaded":"Project skills are not loaded because this project is not trusted.","trust.pluginsNotLoaded":"Project plugins are not loaded because this project is not trusted.","trust.projectScopeUnavailable":"Project installs are unavailable while project resources are not loaded.","i18n.creatingSession":"Creating new session…","i18n.creating":"Creating…","i18n.subscription":"Subscription","i18n.subscriptions":"Subscriptions","i18n.customEndpoint":"Custom endpoint format","i18n.noChanges":"No changes","i18n.branches":"Branches","i18n.noActiveSession":"No active session","i18n.noBranches":"This session has no branches","i18n.source":"Source","i18n.preview":"Preview","i18n.diff":"Diff","i18n.downloadFile":"Download file","i18n.liveSync":"Live sync active","i18n.notWatching":"Not watching","i18n.fileViewMode":"File view mode","i18n.compareHead":"Compare working tree with HEAD","i18n.mentionSelectedLines":"Mention selected lines","i18n.disableWrap":"Disable word wrap","i18n.enableWrap":"Enable word wrap","i18n.htmlPreview":"HTML preview","i18n.previewFile":"Preview {file}","i18n.invalidMermaid":"Invalid Mermaid diagram","i18n.renderingMermaid":"Rendering Mermaid diagram","i18n.previewAfterStreaming":"Preview available after streaming","i18n.showMermaidSource":"Show Mermaid source","i18n.previewMermaid":"Preview Mermaid diagram","i18n.openMermaidViewer":"Open diagram viewer","i18n.mermaidViewer":"Mermaid diagram viewer","i18n.mermaidDiagram":"Mermaid diagram","i18n.zoomOut":"Zoom out","i18n.zoomIn":"Zoom in","i18n.fitToWidth":"Fit to width","models.discoveryFetching":"Importing models…","models.discoveryFetch":"Import models…","models.discoveryFilterPlaceholder":"Filter {count} models…","models.discoveryFilter":"Filter upstream models","models.discoverySelectShown":"Select shown","models.discoveryNoMatches":"No matching models.","models.discoveryAdded":"added","models.discoveryShowing":"Showing first {shown} of {total}","models.discoveryFetched":"{count} models fetched","models.discoveryAddSelected":"Add selected","models.discoveryAddSelectedCount":"Add selected ({count})","models.catalogSource":"source: models.dev ↗","models.catalogFilling":"Filling details…","models.catalogFill":"Fill model details","models.catalogFilled":"{count} fields filled","models.catalogNoEmptyFields":"No empty fields to fill","models.catalogNoExactMatch":"No exact models.dev match","models.catalogPriceProvider":"Price matched Provider {provider}","models.catalogPriceBaseUrl":"Price matched Base URL to {provider}","models.catalogPriceConsensus":"Price agreed by {support}/{total} records","models.catalogPriceUnreliable":"No reliable price found","models.catalogUndo":"Undo","models.capabilities":"Capabilities","models.reasoning":"Reasoning / thinking","models.imageInput":"Image input","models.modelSpecs":"Model specifications","models.contextWindow":"Context window (tokens)","models.maxOutputTokens":"Max output tokens","models.costPerMillion":"Cost per million tokens","models.costInput":"Input","models.costOutput":"Output","models.costCacheRead":"Cache read","models.costCacheWrite":"Cache write","models.notProvided":"Not provided","models.editCosts":"Edit prices","models.finishEditingCosts":"Done","models.costAllRequired":"Enter a valid non-negative price; blank fields are saved as 0.","models.advancedSettings":"Advanced settings","models.providerDefaults":"Using provider defaults","models.headersSummary":"Headers: {count}","models.compatSummary":"Compatibility: {count}","models.thinkingSummary":"Thinking levels: {count}","models.apiOverride":"API override","models.headers":"Headers","models.headersHelp":"Added to this model's requests and overrides provider headers.","models.compatibility":"Compatibility","models.deepSeekThinkingCompat":"DeepSeek thinking compatibility","models.developerRole":"Use the developer role for the system prompt","models.thinkingLevelMap":"Thinking level map","models.clearAll":"Clear all","i18n.testingModel":"Testing model connection...","i18n.connected":"Connected","i18n.failed":"Failed","i18n.test":"Test","i18n.testConnection":"Test model connection","i18n.provider":"Provider","i18n.model":"Model","i18n.providerName":"Provider name","i18n.rename":"Rename","i18n.default":"Default","i18n.disabled":"Disabled","i18n.noResources":"No resources","i18n.unknown":"Unknown","i18n.installedVersion":"installed {version}","i18n.configuredVersion":"configured {version}","i18n.extensions":"Extensions","i18n.prompts":"Prompts","i18n.themes":"Themes","i18n.resourceCount":"{count} {label}","i18n.extensionShort":"ext","i18n.skillShort":"skills","i18n.promptShort":"prompts","i18n.themeShort":"themes","i18n.custom":"Custom","i18n.clearAll":"clear all","i18n.connectedSuccessfully":"Connected successfully.","i18n.notConnected":"not connected","i18n.configured":"configured","i18n.notConfigured":"not configured","i18n.openingBrowser":"Opening browser…","i18n.submit":"Submit","i18n.login":"Login","i18n.relogin":"Re-login","i18n.disconnect":"Disconnect","i18n.networkError":"Network error","i18n.continuing":"Continuing…","i18n.skills":"Skills","i18n.plugins":"Plugins","i18n.addSkill":"Add skill","i18n.addPlugin":"Add plugin","i18n.selectSkill":"Select a skill","i18n.selectPackage":"Select a package","i18n.updateAvailable":"Update available","i18n.upToDate":"Up to date","i18n.automaticChecksUnavailable":"Automatic checks unavailable","i18n.checkFailed":"Check failed","i18n.installed":"Installed","i18n.status":"Status","i18n.version":"Version","i18n.package":"Package","i18n.resources":"Resources","i18n.installedPath":"Installed path","i18n.cwd":"CWD","i18n.resolvedResources":"Resolved Resources","i18n.reloadSession":"Reload session","i18n.reloading":"Reloading...","i18n.packageRemoved":"Package removed.","i18n.packageInstalled":"Package installed.","i18n.packageUpdated":"Package updated.","i18n.packagesUpdated":"Packages updated.","i18n.updateAllPlugins":"Update all","i18n.updateAllPluginsHint":"Updates all configured plugins","i18n.packageDisabled":"Package disabled.","i18n.packageEnabled":"Package enabled.","i18n.sessionReloaded":"Session reloaded.","i18n.thinking":"Thinking","i18n.largeMessageReveal":"Message content is very large ({size}). Click to view as plain text — markdown rendering is disabled to keep the page responsive.","i18n.loadingThinking":"Loading thinking...","i18n.copyMessage":"Copy message","i18n.editFromHere":"Edit from here","i18n.editFromHereTitle":"Edit from here — branches within this session","i18n.newSession":"New session","i18n.newSessionTitle":"New session — creates an independent copy from here","i18n.estimatedTokens":"Estimated token count while streaming","i18n.noOutput":"(no output)","i18n.openImage":"Open image","i18n.noSummary":"(no summary)","i18n.conversationCompacted":"Conversation compacted","i18n.compactionDescription":"The conversation history before this point was compacted into the following summary:","i18n.fileContext":"File context: {details}","i18n.readFiles":"Read files","i18n.modifiedFiles":"Modified files","i18n.hiddenExtensionMessage":"hidden extension message","i18n.noMessage":"(no message)","i18n.showExtensionMessage":"Show extension message","i18n.collapse":"Collapse","i18n.expand":"Expand","i18n.hideDetails":"Hide details","i18n.showDetails":"Show details","i18n.thinkingUnavailable":"Thinking content unavailable","i18n.before":"Before","i18n.after":"After","i18n.sessionComplete":"Session complete","i18n.taskFinished":"Task finished.","i18n.attentionNeeded":"Pi needs your attention","i18n.extensionInputNeeded":"An extension is waiting for your input."}}),i({id:"zh-CN",label:"简体中文",messages:{"i18n.close":"关闭","i18n.cancel":"取消","i18n.checking":"正在检查…","desktop.settings":"设置","desktop.settingsSections":"设置分类","desktop.closeSettings":"关闭设置","desktop.display":"显示","desktop.server":"服务器","desktop.serverCurrent":"当前服务器","desktop.serverSwitch":"切换服务器","desktop.serverSwitchHint":"打开 Pi Web 桌面端连接管理:可切换已保存的服务器,或添加新的服务器地址(URL + 密码)。","desktop.reloadPage":"重新加载页面","desktop.serverHintTitle":"想连远程服务器,或设置访问密码?","desktop.serverHintBody":"桌面端已默认直连本机服务,打开即用。需要换服务器、从手机连接或给本机加访问密码,都在右上角这个图标里。","desktop.serverHintAction":"打开连接管理","desktop.serverHintDismiss":"知道了","desktop.chat":"聊天","desktop.models":"模型","desktop.skills":"技能","desktop.plugins":"插件","desktop.subagents":"子代理","desktop.proxy":"代理","desktop.proxyEnable":"启用代理","desktop.proxyProtocol":"协议","desktop.proxyHost":"主机","desktop.proxyPort":"端口","desktop.proxyUsername":"用户名(可选)","desktop.proxyPassword":"密码(可选)","desktop.proxyNoProxy":"绕过代理(逗号分隔,可选)","desktop.proxySave":"保存","desktop.proxySaving":"保存中…","desktop.proxyTest":"测试连接","desktop.proxyTesting":"测试中…","desktop.proxySaved":"代理配置已保存","desktop.proxySaveFailed":"保存失败","desktop.proxyTestSuccess":"连接成功","desktop.proxyTestFailed":"连接失败","desktop.proxyUnsaved":"有未保存的更改","desktop.features":"功能","desktop.logs":"日志","desktop.snippets":"片段","desktop.snippetsDesc":"常用代码/文本片段,输入 # 号即可补全插入","desktop.snippetNew":"新增片段","desktop.snippetName":"名称","desktop.snippetContent":"内容","desktop.snippetSave":"保存","desktop.snippetEdit":"编辑","desktop.snippetDelete":"删除","desktop.snippetEmpty":"还没有片段,先新增一个吧。","desktop.snippetNameRequired":"请输入片段名称","desktop.snippetHint":"在输入框输入 #名称 即可弹出补全,Enter 展开为片段内容。","desktop.logsAllCodes":"全部错误码","desktop.logsAllLevels":"全部级别","desktop.logsAllSources":"全部来源","desktop.logsSearch":"搜索错误日志","desktop.logsClear":"清空日志","desktop.logsCopy":"复制日志","desktop.logsEmpty":"暂无错误日志","desktop.mcpVisionTitle":"DeepSeek Vision 视觉模块","desktop.mcpVisionDesc":"deepseek-vision 视觉模块(图像分析 / OCR)的独立配置,MCP 注册与模型配置均可在此修改。","desktop.mcpVisionRegistered":"已注册","desktop.mcpVisionNotRegistered":"未注册","desktop.mcpVisionRegistration":"MCP 注册","desktop.mcpVisionCommand":"命令","desktop.mcpVisionCommandRequired":"命令不能为空","desktop.mcpVisionLifecycle":"生命周期","desktop.mcpVisionTransport":"传输方式","desktop.mcpVisionTransportFixed":"stdio(固定)","desktop.mcpVisionSaveReg":"保存注册","desktop.mcpVisionSavedReg":"注册已保存 — 新开会话或重启 pi 后生效","desktop.mcpVisionRemove":"从 MCP 配置移除","desktop.mcpVisionRemoved":"已移除注册","desktop.mcpVisionModelConfig":"模型配置","desktop.mcpVisionModelNote":"模型配置保存后立即写入 .env,点击“重启服务器”即可立即生效。","desktop.mcpVisionProvider":"Provider","desktop.mcpVisionBaseUrl":"Base URL","desktop.mcpVisionApiKey":"API Key","desktop.mcpVisionModel":"视觉模型","desktop.mcpVisionMaxTokens":"最大输出 tokens","desktop.mcpVisionSaveModel":"保存模型配置","desktop.mcpVisionSavedModel":"模型配置已保存","desktop.mcpVisionNameReserved":"该名称由内置的 DeepSeek Vision 配置使用,请换一个名称。","desktop.mcpVisionRestart":"重启服务器(立即生效)","desktop.mcpVisionRestarting":"重启中…","desktop.mcpVisionRestarted":"已发送重启指令,稍候生效","desktop.mcpVisionRestartTitle":"重启 deepseek-vision 服务器,使 .env 配置立即生效","desktop.mcpVisionRestartNoSession":"请先打开一个会话,才能重启服务器","desktop.applyNow":"立即生效","desktop.applyNowApplying":"重载中…","desktop.applyNowDone":"已重载,改动已生效","desktop.applyNowTitle":"重载当前会话,使改动立即生效(无需重启 pi)","desktop.applyNowNoSession":"请先打开一个会话,才能立即生效","desktop.featuresDesc":"管理 Pi Web 的可选功能。关闭后相关入口将不再显示。","desktop.featuresTasksBoard":"任务看板","desktop.featuresTasksBoardDesc":"在顶部工具栏显示任务看板入口,用于管理多项目任务。","desktop.featuresLoading":"加载中…","desktop.featuresSaving":"保存中…","desktop.featuresCollabDefault":"默认任务模式","desktop.featuresCollabDefaultDesc":"新建对话默认的协作模式(常规 / 计划 / 目标)","desktop.featuresTokenDefault":"默认运行档位","desktop.featuresTokenDefaultDesc":"新建对话默认的档位(轻量 / 均衡 / 交付)","desktop.featuresApprovalDefault":"默认工具权限","desktop.featuresApprovalDefaultDesc":"新建对话默认的工具权限(批准 / 自动 / Yolo)","desktop.usage":"用量","desktop.usageSession":"当前会话","desktop.usageGlobal":"全局","desktop.usageContext":"上下文占用 {used} / {window} tokens","desktop.usageContextHint":"当前会话实时上下文占用","desktop.usageNoSessionData":"当前会话暂无用量数据","desktop.usageNoSession":"未打开会话","desktop.usageTotal":"预估总用量","desktop.usageMessages":"消息数","desktop.usageMessagesHint":"全部会话","desktop.usageSessions":"个会话","desktop.usageDaily":"每日用量趋势","desktop.usageTopSessions":"用量最高的会话","desktop.usageNoData":"暂无数据","desktop.mcp":"MCP","desktop.mcpServers":"MCP 服务器","desktop.mcpAddServer":"添加服务器","desktop.mcpNewServer":"新增 MCP 服务器","desktop.mcpEditServer":'编辑 MCP 服务器 "{name}"',"desktop.mcpRestartNote":"MCP 服务器在 pi 启动时加载,此处修改需重启 pi 后生效。","desktop.mcpEmpty":"尚未配置 MCP 服务器 — 添加一个即可向 Agent 暴露工具。","desktop.mcpEmptyOther":"未配置其他 MCP 服务器 — DeepSeek Vision 的配置见上方卡片。","desktop.mcpServerName":"名称","desktop.mcpCommand":"命令","desktop.mcpArgs":"参数(每行一个)","desktop.mcpTransport":"传输方式","desktop.mcpLifecycle":"生命周期","desktop.mcpRequestTimeoutMs":"请求超时(毫秒)","desktop.mcpEnv":"环境变量(JSON)","desktop.mcpEdit":"编辑","desktop.mcpDelete":"删除","desktop.mcpSave":"保存","desktop.saving":"保存中…","desktop.mcpCancel":"取消","desktop.mcpSavedRestart":"已保存 — 重启 pi 后生效。","desktop.tools":"工具","desktop.refreshSession":"刷新会话","desktop.shellTool":"Shell 工具","desktop.usePowerShell":"Shell 命令使用 PowerShell","desktop.shellToolDescription":"在 Windows 上,shell 工具优先使用 PowerShell 而非 bash。写入 settings.json 的 defaultTools。","desktop.shellToolWindowsOnly":"PowerShell 仅可在 Windows 上配置。","desktop.shellToolMacOnly":"Shell 工具设置仅适用于 Windows。","desktop.subagentCardProcessing":"正在处理","desktop.transcriptRoleUser":"用户","desktop.transcriptRoleAssistant":"助手","desktop.transcriptRoleResult":"结果","desktop.transcriptRoleBash":"Bash","desktop.backup":"备份","desktop.backupExportTitle":"导出备份","desktop.backupExportDescription":"打包全部全局配置:供应商、模型、凭证、设置、MCP 服务器、技能与本地插件。","desktop.backupIncludeSecrets":"包含 API 密钥与登录凭证","desktop.backupSecretsWarning":"警告:备份将包含明文 API 密钥(models.json)与 OAuth 凭证(auth.json),请妥善保管。","desktop.backupIncludeSessions":"包含会话历史","desktop.backupSessionsHint":"会话历史可能较大,且含敏感对话内容。","desktop.backupExportButton":"导出备份","desktop.backupExporting":"导出中…","desktop.backupExportFailed":"备份导出失败","desktop.backupImportTitle":"导入备份","desktop.backupImportButton":"选择备份文件","desktop.backupImportDescription":"从 pi-backup zip 恢复。路径会自动重映射到本机,MCP 命令按平台适配。","desktop.backupImportFailed":"读取备份文件失败","desktop.backupRestoreFailed":"恢复失败","desktop.backupManifest":"备份创建于","desktop.backupNoSecrets":"不含凭证","desktop.backupCategories":"恢复类别","desktop.backupCategorycore":"核心配置","desktop.backupCategoryskills":"技能","desktop.backupCategorypackages":"插件","desktop.backupCategorymcp":"MCP 服务器","desktop.backupCategorysessions":"会话","desktop.backupMcpServers":"MCP 服务器","desktop.backupNpmPackages":"npm 插件包","desktop.backupReinstallNpm":"恢复后重新安装这些 npm 包","desktop.backupReinstallNpmHint":"安装脚本将执行备份包自带的代码,仅在你信任该备份来源时勾选","desktop.backupInstallModel":"安装会话使用的模型","desktop.backupInstallSession":"创建安装会话","desktop.backupOpenSession":"打开会话","desktop.backupInstallSessionFailed":"创建安装会话失败","desktop.backupRestoreButton":"开始恢复","desktop.backupRestoring":"恢复中…","desktop.backupRestoreReport":"恢复报告","desktop.backupReportRestored":"已恢复","desktop.backupReportRestart":"需重启生效","desktop.backupReportManual":"需人工确认","desktop.backupRestartHint":"设置、模型、凭证与 MCP 配置需重启 pi-web / pi 后生效。","desktop.importSessions":"导入会话","desktop.importSessionsDesc":"从其他 AI 编码工具导入历史对话记录到 pi-web。目前支持 Reasonix,更多工具陆续支持中。","desktop.comingSoon":"即将支持","desktop.projects":"个项目","desktop.importSelectProjects":"选择要导入的项目","desktop.importSelectAll":"全选","desktop.importDeselectAll":"取消全选","desktop.importMerged":"合并到现有项目","desktop.importNewProject":"新建项目","desktop.importExistingCount":"{count} 个已有","desktop.importStart":"开始导入","desktop.importing":"导入中…","desktop.importDone":"导入完成","desktop.importedSummary":"成功导入 {imported} 个会话","desktop.importSkippedCount":"{skipped} 个跳过","desktop.importErrorsCount":"{errors} 个失败","desktop.importGeneratingTitles":"正在生成标题…","desktop.importGenerateTitles":"为导入的会话生成标题","desktop.importAgain":"再次导入","desktop.importNoData":"未找到 Reasonix 数据。请确认 ~/.reasonix/projects/ 目录存在且包含会话文件。","desktop.importFromReasonix":"来自 Reasonix","desktop.importFromCodex":"来自 Codex","desktop.builtinModelsTitle":"模型配置","desktop.builtinModelsFetchNew":"获取新模型","desktop.builtinModelsLoadFailed":"加载模型失败","desktop.builtinModelsEmpty":"该供应商暂无可用模型。","desktop.builtinModelsContext":"上下文","desktop.builtinModelsMaxTokens":"最大返回","desktop.builtinModelsReasoning":"思考模型","desktop.builtinModelsThinking":"思考强度(thinkingLevelMap)","desktop.builtinModelsDirty":"{count} 处未保存修改","desktop.builtinModelsHide":"隐藏此模型","desktop.inputShortcut":"输入快捷键","desktop.inputShortcutDescription":"选择使用 Enter 键发送消息的方式。","desktop.useCtrlEnter":"使用 Ctrl+Enter 发送","desktop.useCtrlEnterDescription":"Enter 用于换行,Ctrl+Enter 发送消息。","desktop.useEnter":"使用 Enter 发送","desktop.useEnterDescription":"Enter 发送消息,Shift+Enter 用于换行。","desktop.theme":"主题","desktop.themes":"主题","desktop.language":"语言","desktop.light":"浅色","desktop.dark":"深色","desktop.system":"跟随系统","desktop.english":"English","desktop.chinese":"简体中文","desktop.themeDescription":"选择 Pi Web 的外观。","desktop.languageDescription":"选择界面的显示语言。","desktop.colorScheme":"配色方案","desktop.openThemeFolder":"打开本地 Pi theme 文件夹","desktop.learnPiThemes":"了解 Pi theme","desktop.defaultTheme":"默认","desktop.appearanceMode":"外观模式","desktop.loadingThemes":"加载主题中…","desktop.borderVisibility":"边框可见度","desktop.borderSubtle":"浅淡","desktop.borderBold":"浓重","desktop.noCustomThemes":"未安装自定义主题。","desktop.noCustomThemesHint":"将 JSON 文件放入","desktop.noCustomThemesHint2":"即可在此处看到。","desktop.darkVariant":"深色变体可用","desktop.lightVariant":"浅色变体可用","desktop.switchToLight":"切换至浅色模式","desktop.switchToDark":"切换至深色模式","desktop.showSidebar":"显示侧边栏","desktop.hideSidebar":"隐藏侧边栏","desktop.resizeSidebar":"调整侧边栏宽度","desktop.resizeFilePanel":"调整文件面板宽度","desktop.trustProject":"信任项目","desktop.trustingProject":"正在信任…","desktop.projectResourcesRestricted":"项目资源已受限","desktop.projectSkillsRestricted":"信任此项目后才能使用项目技能。","desktop.projectSkillInstallUnavailable":"请先信任此项目,再安装项目技能。","desktop.shellCommand":"Shell 命令","desktop.shellOutputLocal":"输出仅保留在本地","desktop.shellOutputModel":"输出将提供给模型","desktop.runningShellCommand":"正在运行 Shell 命令…","desktop.loadFullOutput":"加载完整输出","desktop.download":"下载","desktop.trustProjectTitle":"信任此项目?","desktop.trustProjectBody":"项目扩展、技能、提示词和软件包资源可能执行代码。仅在确认项目内容可信时授予信任。","desktop.minimize":"最小化","desktop.maximize":"最大化","desktop.restore":"还原","desktop.islandLabel":"窗口控制","desktop.islandResetHint":"拖动调整位置,双击复位","desktop.islandDrag":"按住拖动","desktop.close":"关闭","desktop.viewFullHistory":"查看完整历史","desktop.fullHistoryAvailableAfterSave":"保存会话后可查看完整历史","desktop.systemPrompt":"系统提示词","desktop.sessionInfo":"会话信息","desktop.hideFilePanel":"隐藏文件面板","desktop.showFilePanel":"显示文件面板","desktop.sessionInfoTitle":"会话信息","desktop.sessionInfoFile":"文件","desktop.sessionInfoId":"ID","desktop.sessionInfoInMemory":"内存中","desktop.sessionInfoMessages":"消息","desktop.sessionInfoTokens":"令牌","desktop.sessionInfoActiveTime":"估算活跃耗时","desktop.sessionInfoUser":"用户","desktop.sessionInfoAssistant":"助手","desktop.sessionInfoToolCalls":"工具调用","desktop.sessionInfoToolResults":"工具结果","desktop.sessionInfoTotal":"总计","desktop.sessionInfoInput":"输入","desktop.sessionInfoOutput":"输出","desktop.sessionInfoCacheRead":"缓存读取","desktop.sessionInfoCacheWrite":"缓存写入","desktop.sessionInfoCost":"费用","desktop.sessionInfoCostOfficial":"费用(官网价)","desktop.sessionInfoContext":"上下文","desktop.balance":"余额","desktop.balanceGranted":"赠送额度","desktop.balanceToppedUp":"充值额度","desktop.balanceUnavailable":"余额不可用","desktop.turnUsageTitle":"本次回复","desktop.turnUsageByOfficialPrice":"按官网价折算","desktop.copyFilePath":"复制文件路径","desktop.copySessionId":"复制会话 ID","desktop.projectDir":"项目","desktop.gitBranch":"Git 分支","desktop.gitWorktree":"工作树","desktop.projectSection":"项目信息","desktop.copyProjectDir":"复制项目路径","desktop.copyGitBranch":"复制 Git 分支","desktop.copyGitWorktree":"复制工作树路径","desktop.sendMessageForSessionInfo":"发送消息或运行 /session 以加载会话信息","desktop.selectSessionFromSidebar":"请从侧边栏选择会话","desktop.getStarted":"开始使用","desktop.selectProjectDirectory":"从侧边栏选择项目目录","desktop.addModelsFromBottom":"通过底部的“模型”按钮添加模型","desktop.loadingSession":"正在加载会话...","desktop.scrollToLoadEarlierMessages":"向上滚动以加载更早的消息(隐藏了 {count} 条)","desktop.scrollToBottom":"滚动到底部","desktop.filesWritten":"改动的文件","desktop.openWrittenFile":"打开 {name}","desktop.taskRunning":"进行中","desktop.taskTodo":"待办","desktop.taskStatusHint":"当前项目的任务进度,点击打开任务看板","desktop.runningTool":"正在运行工具...","desktop.runningTools":"正在运行 {tools}...","desktop.waitingForModel":"正在等待模型...","desktop.runningCommand":"正在运行命令...","desktop.thinking":"思考中...","desktop.extensionRequest":"扩展请求","desktop.extensionPanel":"扩展面板","desktop.cancel":"取消","desktop.confirm":"确认","desktop.submit":"提交","desktop.queued":"已排队","desktop.queueMoveUp":"上移","desktop.queueMoveDown":"下移","desktop.queueRecallOne":"取回到输入框","desktop.queueRemove":"移除排队消息","desktop.recalledEditing":"正在编辑一条已取回的排队消息;发送后会回到原来的队列位置。","desktop.steer":"引导","desktop.followUp":"后续消息","desktop.recallToInput":"恢复到输入框","desktop.recallQueuedMessages":"移除所有排队消息,并将其放回输入框以便编辑","desktop.retrying":"正在重试","desktop.compacted":"已压缩","desktop.tokens":"令牌","desktop.saved":"已节省","desktop.removeImage":"移除图片","desktop.loadingCommands":"正在加载命令...","desktop.slashCommands":"斜杠命令","desktop.tabOrEnter":"Tab / Enter","desktop.noSlashCommands":"未找到扩展、提示词或技能命令","desktop.builtIn":"内置","desktop.extensions":"扩展","desktop.prompts":"提示词","desktop.commandSkills":"技能","desktop.match":"个匹配项","desktop.matches":"个匹配项","desktop.snippetMatches":"个片段匹配","desktop.command":"个命令","desktop.commands":"个命令","desktop.loadingFiles":"正在加载文件...","desktop.files":"文件","desktop.searchingAllFiles":"正在搜索所有文件...","desktop.indexTruncated":"索引已截断","desktop.searching":"正在搜索...","desktop.search":"搜索","desktop.noMatchingFiles":"没有匹配的文件","desktop.steerOrQueueFollowUp":"立即引导 / 排队后续消息...","desktop.agentRunning":"Agent 正在运行...","desktop.messageWithCommands":"输入消息... 输入 / 查看命令,@ 查看文件","desktop.inputHistory":"输入历史","desktop.quickChanges":"快速变更","desktop.changedFiles":"{count} 个变更文件","desktop.imageAttachmentsCannotQueue":"Agent 运行时无法将图片附件加入队列","desktop.injectMessageNow":"中断当前运行并立即注入此消息","desktop.queueMessageAfterFinish":"在 Agent 完成后将此消息加入队列","desktop.attachImage":"添加图片","desktop.push":"推送当前分支","desktop.pushOk":"推送成功","desktop.pushFailed":"推送失败","desktop.stash":"Stash 管理","desktop.stashTitle":"Stash 管理","desktop.stashPush":"保存到 Stash","desktop.stashList":"Stash 列表","desktop.stashEmpty":"暂无 stash","desktop.stashPop":"恢复","desktop.stashDrop":"删除","desktop.stashMessagePlaceholder":"stash 说明(可选)…","desktop.stashDone":"操作成功","desktop.attachMenu":"选择输入模式","desktop.attachUpload":"上传文件","desktop.attachUploadDesc":"附加图片等文件","desktop.attachReference":"引用文件","desktop.attachReferenceDesc":"通过 @ 引用工作区文件","desktop.attachSessions":"引用会话","desktop.attachSessionsDesc":"通过 # 引用过去的对话","desktop.attachCommands":"使用命令","desktop.attachCommandsDesc":"通过 / 使用命令和技能","desktop.planModeBadge":"计划模式","desktop.planModeLabel":"计划模式","desktop.planModeHint":"当前为计划模式:只读分析,不修改文件。结束后可确认执行或退出。","desktop.disableCompletionSound":"关闭完成提示音","desktop.enableCompletionSound":"开启完成提示音","desktop.soundLabelOn":"提示音:开启","desktop.soundLabelOff":"提示音:关闭","desktop.changeReasoningLevel":"更改推理级别:{level}","desktop.reasoningLevel":"更改推理级别","desktop.moreControls":"更多控件","desktop.more":"更多","modes.collabNormal":"常规","modes.collabPlan":"计划","modes.collabGoal":"目标","modes.tokenEconomy":"轻量","modes.tokenFull":"均衡","modes.tokenDelivery":"交付","modes.approvalAsk":"批准","modes.approvalAuto":"自动","modes.approvalYolo":"Yolo","modes.collabNormalTitle":"常规 \xb7 边做边推进","modes.collabNormalDesc":"直接执行,边做边推进","modes.collabPlanTitle":"计划 \xb7 确认后执行","modes.collabPlanDesc":"先产出计划;工具执行仍由权限与沙箱决定","modes.collabGoalTitle":"目标 \xb7 持续推进","modes.collabGoalDesc":"输入目标后持续工作,直到完成或阻塞","modes.tokenEconomyTitle":"轻量 \xb7 快速省用量","modes.tokenEconomyDesc":"少上下文,工具按需启用","modes.tokenFullTitle":"均衡 \xb7 日常通用","modes.tokenFullDesc":"完整工具,模型自主执行","modes.tokenDeliveryTitle":"交付 \xb7 完整验证","modes.tokenDeliveryDesc":"强制验收,复查验证","modes.approvalAskTitle":"需要批准","modes.approvalAskDesc":"需审批的写入与命令会先询问","modes.approvalAutoTitle":"自动批准","modes.approvalAutoDesc":"自动执行权限策略允许的操作","modes.approvalYoloTitle":"Yolo 批准","modes.approvalYoloDesc":"跳过普通工具权限提示(仅本会话)","desktop.goalRunning":"目标","desktop.goalComplete":"目标完成","desktop.goalBlocked":"目标阻塞","desktop.goalPaused":"目标暂停","desktop.goalNoProgress":"{n} 轮无进展","desktop.goalPause":"暂停目标","desktop.goalPauseShort":"Ⅱ","desktop.goalResume":"恢复目标","desktop.goalResumeShort":"▶","desktop.goalStop":"结束目标","desktop.goalEdit":"编辑","desktop.goalSave":"保存","desktop.goalCancel":"取消","desktop.goalEditHint":"Cmd+Enter 保存 \xb7 Esc 取消","desktop.goalBudget":"预算","desktop.goalTurns":"轮次","desktop.goalBudgetLimited":"预算耗尽","approval.title":"需要工具审批","approval.subtitle":"Agent 想执行此工具。选择「允许」执行,或「拒绝」向 Agent 返回被阻止的结果。","approval.queued":"个待处理","approval.allow":"允许","approval.deny":"拒绝","approval.denyWithReason":"附理由拒绝","approval.hideReason":"隐藏理由","approval.reasonPlaceholder":"展示给 Agent 的理由(可选)","desktop.stopCompaction":"停止压缩","desktop.compactContext":"压缩上下文","desktop.compacting":"正在压缩...","desktop.compact":"压缩","desktop.changeToolPreset":"更改工具预设:{preset}","desktop.toolPreset":"更改工具预设","desktop.sendMessage":"发送消息","desktop.stopAgent":"停止 Agent","desktop.stop":"停止","desktop.collapseControls":"收起控件","desktop.usePiDefault":"使用 pi 默认设置","desktop.reasoningOff":"关闭推理","desktop.minimalReasoning":"最小推理","desktop.lowReasoning":"低推理","desktop.mediumReasoning":"中等推理","desktop.highReasoning":"高推理","desktop.extraHighReasoning":"超高推理","desktop.maxReasoning":"最高推理","desktop.noToolsReadOnly":"不使用工具,只读","desktop.fourBuiltInTools":"4 个内置工具","desktop.allBuiltInTools":"所有内置工具","desktop.toolOff":"关闭","desktop.toolDefault":"默认","desktop.toolFull":"完整","desktop.thinkingAuto":"自动","desktop.thinkingOff":"关闭","desktop.thinkingMinimal":"最小","desktop.thinkingLow":"低","desktop.thinkingMedium":"中等","desktop.thinkingHigh":"高","desktop.thinkingExtraHigh":"超高","desktop.thinkingMax":"最高","desktop.compactCommandDescription":"压缩上下文,可选择附加指令","desktop.reloadCommandDescription":"重新加载扩展、技能、提示词和工具","desktop.nameCommandDescription":"设置会话显示名称","desktop.sessionCommandDescription":"显示会话消息、令牌和费用统计","desktop.copyCommandDescription":"复制最后一条助手消息","desktop.selectModel":"选择模型","desktop.modelsLoadFailed":"模型列表加载失败","desktop.noModelsConfigured":"未配置可用模型,请到「模型」设置添加供应商","desktop.selectProject":"选择项目","desktop.selectProjectFirst":"请先选择项目","desktop.noMatchingProjects":"没有匹配的项目","desktop.noProjectsYet":"尚无项目","desktop.useDefaultDirectory":"使用默认目录","desktop.customPath":"自定义路径…","desktop.projectPathPlaceholder":"/path/to/project","desktop.filterProjects":"筛选项目…","desktop.searchProjects":"搜索项目…","desktop.recentProjects":"最近项目","desktop.addProjectTab":"新增项目 tab","desktop.maxProjectTabs":"最多 4 个项目 tab(下拉框 1 个 + tab 4 个)","desktop.branch":"分支","desktop.editProjectAlias":"修改项目备注","desktop.projectAliasPlaceholder":"给项目加个备注…","desktop.quickWorkspace":"快速工作区","desktop.selectFolder":"选择文件夹","desktop.checking":"正在检查…","desktop.open":"打开","common.ok":"确定","common.language":"语言","common.models":"模型","common.skills":"技能","common.agents":"子代理","common.plugins":"插件","common.settings":"设置","settings.title":"设置","settings.general":"常规","settings.generalDescription":"选择 Pi Web 的显示方式和界面语言。","settings.appearance":"外观","settings.appearanceDescription":"选择浅色或深色主题,也可以跟随系统设置。","settings.chatContentWidth":"聊天内容宽度","settings.chatContentFontSize":"聊天字体大小","settings.resetChatContentWidth":"重置聊天内容宽度","settings.resetChatContentFontSize":"重置聊天字体大小","settings.chatContentWidthDescription":"设置消息内容和输入框的最大宽度。","settings.themeLight":"浅色","settings.themeDark":"深色","settings.themeSystem":"跟随系统","settings.thinkingDisplay":"思考过程显示","settings.thinkingDisplayDescription":"选择消息加载时模型思考块是否默认展开。","settings.thinkingExpandedDefault":"默认展开思考块","settings.chat":"对话","settings.quoteSelection":"选中文字时显示提问浮窗","settings.languageDescription":"选择整个界面使用的语言。","settings.shellTool":"Shell 工具","settings.shellToolDescription":"选择模型执行命令时使用的 Shell。直接输入的 ! 和 !! 命令仍使用 Bash。","settings.usePowerShell":"使用 PowerShell 替代 Bash","settings.projectRequired":"打开项目后才能配置此项","skills.scope.global":"全局","skills.scope.project":"项目","skills.scope.path":"路径","agents.close":"关闭","agents.builtInTitle":"启用 Pi Web 内置子代理","agents.builtInDescription":"提供 Pi Web 集成的 Agent 工具,并停用发生冲突的 pi-subagents 扩展。","agents.reloadRequired":"重新加载当前会话后生效。","agents.reloadSession":"重新加载会话","agents.reloading":"正在重新加载...","agents.loading":"正在加载子代理...","agents.new":"新建子代理","agents.empty":"选择或创建一个子代理配置","agents.saveScope":"保存到","agents.name":"子代理 ID","agents.displayName":"显示名称","agents.description":"描述","agents.prompt":"系统指令","agents.tools":"工具","agents.resources":"资源","agents.loadSkills":"加载技能","agents.loadExtensions":"加载扩展","agents.model":"指定模型","agents.modelsLoading":"正在加载模型...","agents.modelUnavailable":"{model}(不可用)","agents.thinking":"思考级别","agents.maxTurns":"最大轮次","agents.inherit":"跟随父会话","agents.enable":"启用子代理","agents.disable":"停用子代理","agents.builtinPath":"内置配置","agents.inheritContext":"继承父会话上下文","agents.background":"默认在后台运行","agents.duplicate":"创建副本","agents.copyName":"{name} 副本","agents.delete":"删除","agents.deleteConfirm":"删除 {name}?","agents.save":"保存","agents.saving":"正在保存...","agents.scope.builtin":"内置","agents.scope.global":"全局","agents.scope.workspace":"工作区","agents.scope.project":"项目","agents.overridden":"被覆盖","subagent.readOnlyNotice":"子代理会话为只读视图","subagent.open":"打开子代理会话","agentSwitcher.title":"子代理","agentSwitcher.main":"主 Agent","agentSwitcher.subagent":"子代理","agentSwitcher.current":"当前","agentSwitcher.count":"{count} 个子代理","agentSwitcher.runningCount":"{count} 个运行中","agentSwitcher.search":"搜索子代理","agentSwitcher.noFamily":"当前会话没有子代理族谱","agentSwitcher.noMatches":"没有匹配的子代理","agentSwitcher.status.starting":"正在启动","agentSwitcher.status.running":"运行中","agentSwitcher.status.completed":"已完成","agentSwitcher.status.failed":"失败","agentSwitcher.status.aborted":"已中止","agentSwitcher.status.interrupted":"已中断","appUpdate.releaseNotes":"Pi Web v{version} 可用,查看更新说明","sidebar.hide":"隐藏侧边栏","sidebar.show":"显示侧边栏","theme.light":"浅色模式(点击切换到深色)","theme.dark":"深色模式(点击切换到跟随系统)","theme.auto":"跟随系统(点击切换到浅色)","history.full":"完整历史","history.unsaved":"会话保存后才能查看完整历史","history.label":"完整历史","title.generating":"正在生成...","title.updated":"标题已更新","title.failed":"生成失败","title.generate":"生成标题","title.unsaved":"会话保存后才能生成标题","title.noMessages":"请先发送消息,再为会话命名","title.generateSession":"生成会话标题","system.prompt":"系统提示词","system.empty":"系统提示词为空(工具已禁用)","system.load":"系统提示词尚未加载","system.loading":"正在加载系统提示词…","system.label":"系统","tools.label":"工具","tools.title":"工具定义","tools.details":"工具定义详情","tools.load":"工具定义尚未加载","tools.loading":"正在加载工具定义…","tools.noTools":"没有启用的工具","tools.description":"描述","tools.parameters":"参数","tools.parameterCount":"{count} 个参数","tools.noParameters":"无参数","tools.required":"必填","tools.optional":"可选","tools.allowedValues":"可选值","tools.defaultValue":"默认值","tools.guidelines":"提示词规则","session.info":"会话信息","session.name":"名称","session.file":"会话文件","session.inMemory":"内存中","session.id":"ID","session.user":"用户","session.assistant":"助手","session.toolCalls":"工具调用","session.toolResults":"工具结果","session.total":"总计","session.input":"输入","session.output":"输出","session.cacheRead":"缓存读取","session.cacheWrite":"缓存写入","session.cost":"费用","session.context":"上下文","session.cacheHitRate":"平均缓存命中率","session.copy":"复制{value}","session.copied":"已复制","session.title":"会话信息","session.load":"发送消息或运行 /session 以加载会话信息","session.infoSection":"会话信息","session.projectSection":"项目信息","session.messages":"消息","session.tokens":"Token","session.totalActive":"活跃时长","session.copyFile":"复制文件路径","session.copyId":"复制会话 ID","session.projectDir":"项目目录","session.gitBranch":"Git 分支","session.gitWorktree":"Worktree","session.copyProjectDir":"复制项目目录","session.copyGitBranch":"复制 Git 分支","session.copyGitWorktree":"复制 Worktree 路径","workspace.opening":"正在打开工作区...","workspace.unable":"无法打开工作区","workspace.selectSession":"从侧边栏选择一个会话","workspace.getStarted":"开始使用","workspace.selectProject":"从侧边栏选择项目目录","workspace.addModels":"打开底部的“设置”,然后选择“模型”","workspace.stepProject":"从侧边栏选择项目目录","workspace.stepModels":"打开底部的“设置”,然后选择“模型”","files.hidePanel":"隐藏文件面板","files.showPanel":"显示文件面板","files.noneOpen":"没有打开的文件","layout.resizeSidebar":"调整侧边栏宽度","layout.resizeFilePanel":"调整文件面板宽度","layout.resizeHint":"拖动调整宽度。双击或按 Enter 恢复默认值。","sidebar.new":"新建","sidebar.newSessionTitle":"在 {path} 中新建会话","sidebar.refresh":"刷新","sidebar.selectProject":"选择项目…","sidebar.filterProjects":"筛选项目…","sidebar.noMatchingProjects":"没有匹配的项目","sidebar.searchFiles":"搜索文件","sidebar.searchFilesPlaceholder":"搜索文件…","sidebar.clearSearch":"清除搜索","sidebar.searchingFiles":"搜索中…","sidebar.noMatchingFiles":"没有匹配的文件","sidebar.useDefaultDirectory":"使用默认目录","sidebar.customPath":"自定义路径…","directoryPicker.selectDirectory":"选择目录","directoryPicker.goToParent":"转到上级目录","directoryPicker.loadingDirectories":"正在加载目录…","directoryPicker.noSubdirectories":"没有子目录","directoryPicker.noMatchingDirectories":"没有匹配的子目录","directoryPicker.filterPlaceholder":"筛选子目录…","directoryPicker.selectCurrentDirectory":"选择当前目录","directoryPicker.selectThisFolder":"选择此文件夹","directoryPicker.noDrives":"未找到盘符","desktop.switchWorktree":"切换工作树","desktop.switchWorktreeWithPath":"切换工作树:{path}","desktop.openRepoRoot":"打开仓库根目录","desktop.openRepoRootDescription":"打开仓库根目录以管理工作树。","desktop.gitRepoRootOnly":"仅 Git 仓库根目录","desktop.gitRepoRootOnlyDescription":"工作树仅在 Git 仓库根目录可用。","desktop.checkingWorktrees":"正在检查此目录的工作树。","desktop.worktreesLoading":"工作树…","desktop.createWorktree":"为分支创建工作树检出","desktop.newWorktree":"新建工作树…","desktop.branchName":"分支名称","desktop.creating":"正在创建…","desktop.create":"创建","desktop.main":"主工作树","desktop.removeWorktree":"移除工作树检出 {path};分支将保留","desktop.uncommittedChanges":"存在未提交的更改。要强制移除检出吗?","desktop.force":"强制移除","desktop.sessions":"会话","desktop.newSession":"新建","desktop.newSessionIn":"在 {cwd} 中新建会话","desktop.refresh":"刷新","desktop.loading":"正在加载…","desktop.noModels":"没有可用模型","desktop.noSessionsFound":"未找到会话","desktop.explorer":"资源管理器","desktop.uploadFiles":"上传文件","desktop.uploadFilesToProjectRoot":"上传文件到项目根目录","desktop.refreshExplorer":"刷新资源管理器","desktop.agentRunningLabel":"Agent 正在运行","desktop.newActivity":"有新动态","desktop.newSessionActivity":"会话有新动态","desktop.deleteSession":"删除“{title}”?","desktop.delete":"删除","desktop.deleteWithShift":"删除(按住 Shift 点击跳过确认)","desktop.openingWorkspace":"正在打开工作区…","desktop.unableToOpenWorkspace":"无法打开此工作区","desktop.rename":"重命名","desktop.titleGenerationFailed":"标题生成失败","desktop.retryTitleGeneration":"重新生成标题","desktop.retry":"重试","desktop.changeTitleModel":"换模型","desktop.pastedLabel":"[已粘贴文本 #{id} \xb7 {lines} 行]","desktop.pastedShowPreview":"预览粘贴文本","desktop.pastedHidePreview":"收起粘贴文本预览","desktop.pastedRemove":"删除粘贴文本","desktop.pastedMissingContent":"消息中残留未还原的粘贴占位符(原文已丢失),已阻止发送,请重新粘贴该段内容。","desktop.generateTitle":"生成标题","desktop.generateAllTitles":"批量生成当前项目所有会话的标题","desktop.generatingTitlesProgress":"正在批量生成标题… {done}/{total}","desktop.generatingTitle":"正在生成标题…","desktop.titleNeedsMessages":"会话暂无消息,无法生成标题","desktop.expandForks":"展开分支","desktop.collapseForks":"折叠分支","desktop.sessionViewList":"列表","desktop.sessionViewGroups":"分组","desktop.searchSessions":"搜索会话、分支...","desktop.noSearchResults":"未找到匹配会话","desktop.pinned":"置顶","desktop.today":"今天","desktop.yesterday":"昨天","desktop.older":"更早","desktop.collapseGroup":"收起","desktop.expandGroup":"展开","desktop.pin":"置顶","desktop.unpin":"取消置顶","desktop.forkedFrom":"从「{title}」分叉","desktop.messagesCount":"{count} 条消息","desktop.worktree":"工作树:{cwd}","desktop.justNow":"刚刚","desktop.minutesAgo":"{count} 分钟前","desktop.hoursAgo":"{count} 小时前","desktop.daysAgo":"{count} 天前","desktop.panelGroupBubble":"分组","desktop.panelProjectBubble":"项目","desktop.rowStyleToggle":"切换行样式","desktop.sidebarModeCycle":"切换侧边栏模式","desktop.panelFormLabel":"面板","desktop.expandAllFolders":"展开全部文件夹","desktop.collapseAllFolders":"收起全部文件夹","desktop.filterMenu":"筛选","desktop.moreActions":"更多操作","desktop.viewSection":"视图","desktop.viewByProject":"按项目","desktop.viewTimeline":"时间线","desktop.sortSection":"排序方式","desktop.sortUpdated":"更新时间","desktop.sortCreated":"创建时间","desktop.hiddenProjectsSection":"已隐藏项目","desktop.noHiddenProjects":"无已隐藏项目","desktop.restoreProject":"恢复显示","desktop.archivedView":"归档","desktop.archiveSession":"归档","desktop.archiveSessionConfirm":"归档“{title}”?","desktop.unarchiveSession":"取消归档","desktop.deleteForever":"彻底删除","desktop.deleteArchivedConfirm":"彻底删除这个归档会话?会话文件将被移除,此操作不可恢复。","desktop.removeProject":"移除项目","desktop.removeProjectConfirm":"项目“{name}”会从侧边栏移除,但不会删除磁盘上的文件。","desktop.removeProjectRunningConfirm":"该项目仍有会话在运行,确定移除吗?","desktop.showMore":"显示更多","desktop.viewFiles":"查看文件","desktop.backToSessions":"返回会话","desktop.newSessionHere":"在此项目新建会话","desktop.newTask":"新建任务","desktop.showAllProjects":"显示所有项目","desktop.showCurrentProject":"显示当前项目","desktop.sidebarModeHintTitle":"两种列表展示方式","desktop.sidebarModeHintDesc":"点这个按钮可在「当前项目下拉」与「全部项目面板」之间切换;面板还支持分组 / 时间线视图、归档和按项目查看文件树。","desktop.sidebarModeHintOk":"知道了","desktop.noProjects":"暂无项目","desktop.noArchivedSessions":"暂无归档会话","desktop.searchArchived":"搜索归档会话...","desktop.projectSectionHeader":"项目","desktop.closeTab":"关闭","desktop.closeTabWithLabel":"关闭 {label}","desktop.modelsHideApiKey":"隐藏 API 密钥","desktop.modelsShowApiKey":"显示 API 密钥","desktop.modelsInheritNone":"— 继承 / 无 —","desktop.modelsProvider":"提供商","desktop.modelsProviderName":"提供商名称","desktop.modelsBaseUrl":"基础 URL","desktop.modelsApiKey":"API 密钥","desktop.modelsApiKeyHelp":"使用 ! 前缀运行 shell 命令,或使用环境变量名称","desktop.modelsApiKeyPlaceholder":"环境变量名称、!shell 命令或原始密钥","desktop.modelsApi":"API","desktop.modelsDefault":"默认","desktop.modelsDisabled":"已禁用","desktop.modelsCustom":"自定义","desktop.modelsModelSection":"模型","desktop.modelsTestingConnection":"正在测试模型连接...","desktop.modelsConnected":"已连接","desktop.modelsFailed":"失败","desktop.modelsTestConnection":"测试模型连接","desktop.modelsTesting":"测试中…","desktop.modelsTest":"测试","desktop.modelsOk":"正常","desktop.modelsRemove":"移除","desktop.modelsIdRequired":"ID *","desktop.modelsName":"名称","desktop.modelsDisplayName":"显示名称","desktop.modelsApiOverride":"覆盖 API","desktop.modelsReasoningThinking":"推理 / 思考","desktop.modelsImageInput":"图片输入","desktop.modelsDeepSeekCompat":"DeepSeek 思考兼容模式","desktop.modelsThinkingLevelMap":"思考级别映射","desktop.modelsClearAll":"清除全部","desktop.modelsDiscoveryFetching":"正在导入模型…","desktop.modelsDiscoveryFetch":"导入模型…","desktop.modelsDiscoveryFilterPlaceholder":"筛选 {count} 个模型…","desktop.modelsDiscoveryFilter":"筛选上游模型","desktop.modelsDiscoverySelectShown":"选择当前结果","desktop.modelsDiscoveryNoMatches":"没有匹配的模型。","desktop.modelsDiscoveryAdded":"已添加","desktop.modelsDiscoveryShowing":"显示前 {shown} 个,共 {total} 个","desktop.modelsDiscoveryFetched":"已获取 {count} 个模型","desktop.modelsDiscoveryAddSelected":"添加所选模型","desktop.modelsDiscoveryAddSelectedCount":"添加所选模型({count})","desktop.modelsCatalogSource":"来源:models.dev ↗","desktop.modelsCatalogFilling":"正在填入模型信息…","desktop.modelsCatalogFill":"填入模型信息","desktop.modelsCatalogFilled":"已填入 {count} 个字段","desktop.modelsCatalogNoEmptyFields":"没有需要填入的空字段","desktop.modelsCatalogNoExactMatch":"models.dev 中没有精确匹配","desktop.modelsCatalogPriceProvider":"价格已匹配 Provider {provider}","desktop.modelsCatalogPriceBaseUrl":"价格已按 Base URL 匹配 {provider}","desktop.modelsCatalogPriceConsensus":"价格得到 {support}/{total} 条记录支持","desktop.modelsCatalogPriceUnreliable":"未找到可靠价格","desktop.modelsCatalogUndo":"撤销","desktop.modelsContextWindow":"上下文窗口(令牌)","desktop.modelsMaxOutputTokens":"最大输出令牌数","desktop.modelsCostPerMillionTokens":"费用(每百万令牌)","desktop.modelsSubscription":"订阅","desktop.titleModel":"标题生成模型","desktop.titleModelDescription":'用于自动生成会话标题的模型。保持"跟随会话模型"则使用每个会话自身的模型。',"desktop.titleModelFollowSession":"跟随会话模型(默认)","desktop.titleModelInvalid":"已不再导入——标题生成将回退到会话模型","desktop.titleModelSaved":"已保存","desktop.titleModelSaveError":"保存标题生成模型设置失败","desktop.modelsNotConnected":"未连接","desktop.modelsAlreadyConnected":"已连接。你可以重新登录或断开连接。","desktop.modelsConnectAccount":"连接你的 {provider} 账户。","desktop.modelsOpeningBrowser":"正在打开浏览器…","desktop.modelsCompleteSignIn":"请在浏览器中完成登录,然后复制地址栏中的重定向 URL 并粘贴到下方。","desktop.modelsBrowserDidNotOpen":"如果浏览器窗口未打开,","desktop.modelsOpenLoginPage":"点击此处打开登录页面","desktop.modelsEnterValue":"输入值…","desktop.modelsOpenVerificationPage":"打开验证页面并输入此代码:","desktop.modelsExpiresInMinutes":"将在 {count} 分钟后过期。","desktop.modelsConnectedSuccessfully":"连接成功。","desktop.modelsReLogin":"重新登录","desktop.modelsLogin":"登录","desktop.modelsDisconnect":"断开连接","desktop.modelsConnectionLost":"连接已断开","desktop.modelsAuthenticationStateChanged":"认证状态已变化,请刷新后重试。","desktop.modelsVerifying":"验证中…","desktop.modelsContinuing":"正在继续…","desktop.modelsServerError":"服务器错误 {status}","desktop.modelsNetworkError":"网络错误","desktop.modelsConfigured":"已配置","desktop.modelsNotConfigured":"未配置","desktop.modelsApiKeyStored":"API 密钥已保存。请在下方输入新密钥以替换它,或断开连接以移除它。","desktop.modelsEnableModels":"输入你的 {provider} API 密钥以启用 {count} 个{models}。","desktop.modelsSingular":"模型","desktop.modelsPlural":"模型","desktop.modelsEnterNewKey":"输入新密钥以替换…","desktop.modelsSaving":"保存中…","desktop.modelsSaved":"已保存","desktop.modelsRemoving":"移除中…","desktop.modelsSearchProviders":"搜索提供商…","desktop.modelsNoProvidersMatch":"没有匹配的提供商","desktop.modelsCompatibleProvider":"兼容 OpenAI / Anthropic","desktop.modelsCustomEndpointFormat":"自定义端点格式","desktop.modelsAddCustomTitle":"添加自定义提供商","desktop.modelsProviderNameOptional":"提供商名称(可选)","desktop.modelsCallFormat":"调用格式","desktop.modelsCallFormatHelp":"选择一种现有的调用格式","desktop.modelsCustomCallFormat":"自定义调用格式","desktop.modelsCustomCallFormatHelp":"自定义端点默认按 OpenAI 兼容协议(openai-completions)请求;若你的接口是其它协议,请在上方格式下拉中改选。","desktop.modelsFullUrl":"完整 URL","desktop.modelsAddModelManual":"添加模型","desktop.modelsImportProvider":"从已有提供商导入","desktop.modelsImportProviderPlaceholder":"— 导入现有提供商配置 —","desktop.modelsImported":"已导入","desktop.modelsAddUrl":"+ 添加 URL","desktop.modelsUrlPlaceholder":"https://api.example.com/v1","desktop.modelsUrlInvalid":"URL 必须以 http:// 或 https:// 开头","desktop.modelsCustomRequest":"自定义请求","desktop.modelsRequestModelId":"请求模型 ID","desktop.modelsRequestModelIdHelp":"可选 — 创建带这些请求设置的首个模型","desktop.modelsRequestContextLength":"上下文长度(令牌)","desktop.modelsRequestOutputLength":"输出长度(令牌)","desktop.modelsAdd":"添加","desktop.modelsSubscriptions":"订阅","desktop.modelsCount":"{count} 个模型","desktop.modelsLoading":"加载中…","desktop.modelsNewModel":"新模型","desktop.modelsAddModel":"+ 添加模型","desktop.modelsAddProvider":"+ 添加提供商","desktop.modelsSelectProviderOrModel":"选择提供商或模型","desktop.modelsClose":"关闭模型设置","desktop.modelsSave":"保存","desktop.searchModels":"搜索模型…","desktop.noModelsMatch":"没有匹配的模型","desktop.global":"全局","desktop.project":"项目","desktop.path":"路径","desktop.addPlugin":"添加插件","desktop.addPluginTitle":"添加插件","desktop.pluginSource":"来源","desktop.install":"安装","desktop.installing":"正在安装...","desktop.examples":"示例","desktop.disabled":"已禁用","desktop.filtered":"已筛选","desktop.noResources":"没有资源","desktop.packageDisabled":"软件包已禁用","desktop.noResolvedResources":"没有已解析的资源","desktop.unknown":"未知","desktop.installedVersion":"已安装 {version}","desktop.configuredVersion":"已配置 {version}","desktop.enablePackage":"启用软件包","desktop.disablePackage":"禁用软件包","desktop.update":"更新","desktop.updating":"正在更新...","desktop.reloadSession":"重新加载会话","desktop.reloading":"正在重新加载...","desktop.reloadCurrentSession":"重新加载当前会话","desktop.openSessionToReload":"打开一个会话以重新加载","desktop.remove":"移除","desktop.removing":"正在移除...","desktop.status":"状态","desktop.version":"版本","desktop.package":"软件包","desktop.resources":"资源","desktop.installedPath":"安装路径","desktop.notFound":"未找到","desktop.cwd":"当前目录","desktop.resolvedResources":"已解析资源","desktop.packageRemoved":"软件包已移除。","desktop.packageInstalled":"软件包已安装。","desktop.packageUpdated":"软件包已更新。","desktop.packageDisabledMessage":"软件包已禁用。","desktop.packageEnabled":"软件包已启用。","desktop.sessionReloaded":"会话已重新加载。","desktop.noPluginsConfigured":"未配置插件","desktop.selectPackage":"选择一个软件包","desktop.diagnosticsCount":"{count} 条诊断信息","desktop.pluginResourceTotals":"{extensions} 个扩展 \xb7 {skills} 个技能 \xb7 {prompts} 个提示词 \xb7 {themes} 个主题","desktop.extensionsCount":"{count} 个扩展","desktop.skillsCount":"{count} 个技能","desktop.promptsCount":"{count} 个提示词","desktop.themesCount":"{count} 个主题","desktop.addSkill":"添加技能","desktop.addSkillTitle":"添加技能","desktop.skillSearchPlaceholder":"例如:react、testing、deploy","desktop.noSkillsFound":"未找到技能","desktop.skillSearchHint":"搜索 skills.sh,发现并为你的 Agent 安装技能。","desktop.visibleInModelPrompt":"在模型提示词中可见 — 点击以禁用","desktop.hiddenFromModelPrompt":"在模型提示词中隐藏 — 点击以启用","desktop.dormant":"休眠","desktop.hiddenButInvocable":"已从模型中隐藏,仍可手动调用","desktop.check":"检查","desktop.upToDate":"已是最新","desktop.automaticChecksUnavailable":"无法自动检查更新","desktop.checkFailed":"检查失败","desktop.name":"名称","desktop.description":"描述","desktop.selectSkill":"选择一个技能","desktop.checkUpdates":"检查更新","desktop.updateAvailable":"有可用更新","desktop.installed":"已安装","desktop.updatesCount":"{count} 个更新","desktop.downloadFile":"下载文件","desktop.loadingFile":"正在加载...","desktop.noChanges":"没有更改","desktop.unchangedLines":"... {count} 行未更改 ...","desktop.lines":"{count} 行","desktop.mentionFile":"提及文件","desktop.mentionSelectedLines":"提及所选行 {start}-{end}","desktop.source":"源文件","desktop.diff":"差异","desktop.enableWordWrap":"启用自动换行","desktop.disableWordWrap":"禁用自动换行","desktop.wrap":"换行","desktop.code":"代码","desktop.preview":"预览","desktop.raw":"原始内容","desktop.htmlPreview":"HTML 预览","desktop.image":"图片","desktop.audio":"音频","desktop.docxPreview":"DOCX 预览","desktop.failedToLoadImage":"加载图片失败","desktop.failedToLoadAudio":"加载音频失败","desktop.docxTooLargeForPreview":"DOCX 文件过大,无法预览(超过 10MB)","desktop.previewFile":"预览 {file}","desktop.branches":"分支","desktop.noActiveSession":"没有活动会话","desktop.sessionHasNoBranches":"此会话暂无分支 —— 对任意消息点「从这里继续」或「分叉」后会出现分支树","desktop.copyMessage":"复制消息","desktop.copyPlainText":"复制纯文本","desktop.createTaskFromMessage":"创建任务","desktop.editFromHere":"从此处编辑 — 在此会话内创建分支","desktop.creatingNewSession":"正在创建新会话…","desktop.newSessionFromHere":"新建会话 — 从此处创建独立副本","desktop.estimatedStreamingTokenCount":"流式输出期间的预估令牌数","desktop.tokensPerSecond":"{count} 令牌/秒","desktop.thinkingContentUnavailable":"思考内容不可用","desktop.loadingThinking":"正在加载思考内容...","desktop.conversationCompacted":"对话已压缩","desktop.compactionSummaryDescription":"此处之前的对话历史已压缩为以下摘要:","desktop.noSummary":"(无摘要)","desktop.fileContext":"文件上下文:{context}","desktop.readFilesCount":"已读取 {count} 个","desktop.modifiedFilesCount":"已修改 {count} 个","desktop.modifiedFiles":"已修改的文件","desktop.readFiles":"已读取的文件","desktop.hiddenExtensionMessage":"隐藏的扩展消息","desktop.noMessage":"(无消息)","desktop.showExtensionMessage":"显示扩展消息","desktop.copied":"已复制","desktop.copy":"复制","desktop.collapse":"收起","desktop.expand":"展开","desktop.hideDetails":"隐藏详情","desktop.showDetails":"显示详情","desktop.before":"之前","desktop.after":"之后","desktop.noOutput":"(无输出)","desktop.extension":"扩展","desktop.assistant":"助手","desktop.favorites":"收藏","desktop.favorite":"收藏","desktop.unfavorite":"取消收藏","desktop.processStepThinking":"思考","desktop.processStepFileRead":"读取","desktop.processStepFileCreate":"创建","desktop.processStepFileEdit":"编辑","desktop.processStepFileDelete":"删除","desktop.processStepSearch":"搜索","desktop.processStepFind":"查找","desktop.processStepList":"列出","desktop.processStepRead":"读取","desktop.processStepFetch":"抓取","desktop.processStepDelete":"删除","desktop.processStepCopy":"复制","desktop.processStepCommand":"运行","desktop.processStepTool":"工具","desktop.processStepTodo":"待办","desktop.processStepArtifact":"产物","desktop.processStepCompaction":"压缩","desktop.processStepError":"错误","desktop.processWorking":"工作中...","desktop.processUsed":"使用了 {summary}","desktop.processToolCount":"{count} 个工具","desktop.processToolsCount":"{count} 个工具","desktop.processFailedCount":"({failed} 个失败)","desktop.processThoughtCount":"{count} 条思考","desktop.processThoughtsCount":"{count} 条思考","desktop.processThoughtDone":"已思考 {duration}s","desktop.processThoughtDoneNoDuration":"已思考","desktop.processCustomCount":"{count} 个事件","desktop.processCustomsCount":"{count} 个事件","desktop.processCompleted":"处理完成","desktop.processOutput":"处理输出","desktop.processTabMode":"标签页模式","desktop.processTimelineMode":"时间线模式","desktop.processFailedStep":"失败","desktop.markdownPreviewAvailableAfterStreaming":"流式输出结束后可预览","desktop.markdownPreviewMermaidDiagram":"预览 Mermaid 图表","desktop.markdownInvalidMermaidDiagram":"无效的 Mermaid 图表","desktop.markdownRenderingMermaidDiagram":"正在渲染 Mermaid 图表","desktop.openMermaidViewer":"打开 Mermaid 查看器","desktop.mermaidDiagram":"Mermaid 图表","desktop.mermaidViewer":"Mermaid 图表查看器","desktop.zoomPanHint":"拖动平移 \xb7 滚轮缩放","desktop.selectText":"选择文本","desktop.zoomOut":"缩小","desktop.resetZoom":"重置为 100%(适应窗口)","desktop.zoomIn":"放大","desktop.fitToViewport":"适应窗口","desktop.quoteReply":"引用回复","desktop.quoteReplyHint":"点击引用回复","desktop.openFile":"打开","desktop.queueRecoveryTitle":"恢复排队消息","desktop.queueImportTitle":"导入的排队消息","desktop.queueRecoveryDescription":"这些消息在上一个服务会话结束前已保存。请选择要重新入队的消息;系统不会自动发送。","desktop.queueImportDescription":"请选择要重新入队的导入消息;系统不会自动发送。","desktop.selectAll":"全选","desktop.selectNone":"取消全选","desktop.import":"导入","desktop.queueImages":"图片附件","desktop.queueNoText":"(仅图片消息)","desktop.queueExported":"已导出 {count} 条消息","desktop.queueImportEmpty":"未找到有效的排队消息","desktop.queueImported":"已导入 {count} 条消息,等待确认","desktop.dismiss":"暂不处理","desktop.discard":"丢弃","desktop.requeue":"重新入队","desktop.requeueAndContinue":"重新入队并继续","desktop.markdownPlainText":"文本","desktop.hideTaskBoard":"隐藏任务看板","desktop.showTaskBoard":"显示任务看板","tasks.actionArchive":"归档","tasks.stashDone":"变更已成功暂存","tasks.actionCancel":"取消","tasks.actionEdit":"编辑","tasks.actionMerge":"合并","tasks.actionRequeue":"重新排队","tasks.actionRetry":"重试","tasks.actionReturn":"退回反馈","tasks.actionStart":"开始","tasks.actionComplete":"直接完成","tasks.actionUnarchive":"取消归档","tasks.actionViewSession":"查看会话","tasks.allFolders":"全部项目","tasks.archiveAllDone":"全部归档","tasks.badgeCleanupFailed":"清理失败","tasks.badgeWorktreeKept":"保留 worktree","tasks.beta":"Beta","tasks.cancelDescription":"任务将停止。可以留下取消原因,方便之后重新排队时了解背景(可选)。","tasks.cancelKeep":"保留任务","tasks.cancelReasonLabel":"取消原因(可选)","tasks.cancelReasonPlaceholder":"例如:方案不对、需求变了…","tasks.cancelSubmit":"取消任务","tasks.cancelTitle":"取消任务","tasks.changedFiles":"变更文件","tasks.colAttention":"待处理","tasks.colDone":"已完成","tasks.colInProgress":"进行中","tasks.colTodo":"待办","tasks.delete":"删除","tasks.deleteConfirm":"确认删除","tasks.deleteTemplate":"删除模板","tasks.deleteWorktree":"同时删除 worktree","tasks.diff":"差异","tasks.dropToStart":"松手启动","tasks.editTitle":"编辑任务","tasks.empty":"还没有任务","tasks.emptyColAttention":"没有需要你处理的任务","tasks.emptyColDone":"还没有完成的任务","tasks.emptyColInProgress":"没有正在执行的任务","tasks.emptyColTodo":"暂无待办任务","tasks.emptyHint":"创建一个任务,看板会驱动它完成整个流程——启动后会在 worktree 分支里运行 agent 直到结束。","tasks.errorView":"查看","tasks.event_archived":"已归档","tasks.event_canceled":"已取消","tasks.event_created":"已创建","tasks.event_failed":"失败","tasks.event_interrupted":"已中断","tasks.event_merge_failed":"合并失败","tasks.event_merge_requested":"合并请求","tasks.event_merged":"已合并","tasks.event_merging":"合并中","tasks.event_preflight_failed":"预检失败","tasks.event_preflight_passed":"预检通过","tasks.event_preflight_start":"预检运行中","tasks.event_preparing":"准备中","tasks.event_queued":"已排队","tasks.event_recovered":"已恢复","tasks.event_requeued":"已重新排队","tasks.event_return_feedback":"反馈","tasks.event_returned":"已退回","tasks.event_review":"待验收","tasks.event_started":"已启动","tasks.event_unarchived":"已取消归档","tasks.event_updated":"已更新","tasks.fieldProject":"项目","tasks.fieldPrompt":"任务说明","tasks.fieldPromptPlaceholder":"描述 agent 需要完成的工作…","tasks.fieldTitle":"标题","tasks.fieldTitlePlaceholder":"任务的简短标题","tasks.filter":"筛选","tasks.loading":"加载中…","tasks.mergeAutoMessage":"让 agent 自动写提交信息","tasks.mergeConfirm":"合并","tasks.mergeDeleteWorktree":"合并后删除 worktree","tasks.mergeManualMessage":"手动填写提交信息","tasks.mergeMessagePlaceholder":"提交信息…","tasks.mergeStrategyMerge":"合并提交","tasks.mergeStrategySquash":"压缩提交","tasks.mergeTitle":"合并任务","tasks.completeDeleteWorktree":"完成后删除 worktree","tasks.completeDescription":"该任务没有产生任何文件变更,无需合并。确认后直接标记为完成。","tasks.completeSubmit":"确认完成","tasks.completeTitle":"完成任务","tasks.followUpPlaceholderRequeue":"给 agent 的备注(可选)…","tasks.followUpPlaceholderRetry":"给 agent 的备注(可选)…","tasks.actionAddNote":"备注(可选)","tasks.restartDescription":"备注会注入下一次运行的提示词中(可选)。","tasks.restartTitleRequeue":"重新排队","tasks.restartTitleRetry":"重试","tasks.planReviewTitle":"计划已完成","tasks.planReviewDescription":"计划模式的分析已结束。你可以确认执行这份计划、提出建议继续完善,或退出计划模式。","tasks.planReviewShowPlan":"查看计划","tasks.planReviewHidePlan":"收起计划","tasks.planReviewExecute":"确认执行","tasks.planReviewExecutePrompt":"请按以下计划执行:\n\n{plan}","tasks.planReviewSuggest":"提出建议","tasks.planReviewSendFeedback":"发送建议","tasks.planReviewFeedbackLabel":"建议(将返回给 agent 继续完善计划)","tasks.planReviewFeedbackPlaceholder":"例如:先补充风险分析,拆分更细的步骤…","tasks.planReviewExit":"退出计划","tasks.metaCommit":"提交","tasks.metaCreated":"创建于","tasks.metaProject":"项目","tasks.new":"新建任务","tasks.newTitle":"新建任务","tasks.noDiff":"暂无差异","tasks.noEvents":"暂无事件","tasks.notifyFailed":"{title} 执行失败","tasks.notifyReview":"{title} 等待验收","tasks.returnPlaceholder":"给 agent 的反馈…","tasks.returnSubmit":"退回","tasks.save":"保存","tasks.saveAsTemplate":"存为模板","tasks.sessionFile":"会话文件","tasks.sessionHint":"任务的 agent 会话与其他会话一样存储。在会话列表中打开即可查看或继续。","tasks.sessionId":"会话 ID","tasks.sessionTitle":"任务会话","tasks.settingsAutoProcess":"自动处理排队任务","tasks.settingsDeleteWorktree":"合并后默认删除 worktree","tasks.settingsInitCommand":"初始化命令(agent 启动前在 worktree 中执行)","tasks.settingsInitPlaceholder":"例如 pnpm install","tasks.settingsMaxConcurrent":"最大并发任务数(0 = 不限)","tasks.settingsMergeStrategy":"合并策略","tasks.settingsNoProject":"先创建一个任务以选择项目。","tasks.settingsPreflightCommand":"预检命令(验收检查)","tasks.settingsPreflightPlaceholder":"例如 npm test","tasks.settingsProject":"项目","tasks.settingsReset":"恢复默认设置","tasks.settingsStagePrompts":"阶段提示词(附加指令)","tasks.settingsTitle":"任务设置","tasks.showArchived":"显示已归档","tasks.showCanceled":"显示已取消","tasks.stage_merge":"合并","tasks.stage_retry":"重试","tasks.stage_return":"退回","tasks.stage_work":"执行","tasks.startAll":"全部启动","tasks.statusAwaitingInput":"等待输入","tasks.statusCanceled":"已取消","tasks.statusDone":"已完成","tasks.statusFailed":"失败","tasks.statusInterrupted":"已中断","tasks.statusMerging":"合并中","tasks.statusPreparing":"准备中","tasks.statusQueued":"排队中","tasks.statusReview":"待验收","tasks.statusRunning":"运行中","tasks.statusTodo":"待办","tasks.templateNamePlaceholder":"模板名称…","tasks.templates":"模板","tasks.timeline":"时间线","tasks.title":"任务","tasks.attentionBadge":"条待处理","sidebar.checking":"检查中…","sidebar.open":"打开","sidebar.cancel":"取消","sidebar.openRepoRoot":"打开仓库根目录","sidebar.openRepoRootTitle":"打开仓库根目录以管理 worktree。","sidebar.gitRepoRootOnly":"仅 Git 仓库根目录","sidebar.gitRepoRootOnlyTitle":"只能在 Git 仓库根目录使用 worktree。","sidebar.worktrees":"Worktrees...","sidebar.checkingWorktrees":"正在检查此目录的 worktree。","sidebar.filterWorktrees":"筛选 worktree…","sidebar.noMatchingWorktrees":"没有匹配的 worktree","sidebar.switchWorktree":"切换 worktree","sidebar.switchWorktreeTitle":"切换 worktree:{path}","sidebar.main":"主分支","sidebar.forceRemoveCheckout":"存在未提交的更改。强制移除 checkout?","sidebar.force":"强制移除","sidebar.createWorktreeTitle":"为分支创建 worktree checkout","sidebar.newWorktree":"新建 worktree…","sidebar.branchName":"分支名称","sidebar.creating":"创建中…","sidebar.create":"创建","sidebar.uploadFilesTitle":"将文件上传到项目根目录","sidebar.uploadFiles":"上传文件","sidebar.refreshExplorer":"刷新文件浏览器","sidebar.searchSessions":"搜索所有对话...","sidebar.toggleSessionSearch":"搜索对话","sidebar.sessionSearching":"搜索中...","sidebar.sessionSearchEmpty":"没有匹配的对话","sidebar.sessionSearchCount":"{count} 个匹配的对话","sidebar.sessionSearchPartial":"已达到搜索上限,结果可能不完整。","sidebar.sessionSearchFailed":"无法搜索对话","sidebar.changedFiles":"{count} 个变更文件","sidebar.loading":"加载中...","sidebar.noSessions":"未找到会话","sidebar.agentRunning":"Agent 运行中…","sidebar.newActivity":"有新活动","sidebar.newSessionActivity":"会话有新活动","sidebar.deleteSession":"删除 {title}?","sidebar.rename":"重命名","sidebar.delete":"删除","sidebar.deleteWithShiftClick":"删除(按住 Shift 点击可跳过确认)","sidebar.expandSubagents":"展开子智能体","sidebar.collapseSubagents":"折叠子智能体","sidebar.messagesCount":"{count} 条消息","sidebar.worktreePath":"Worktree:{path}","sidebar.removeWorktreeTitle":"移除 worktree checkout {path};保留分支","files.modified":"已修改","files.added":"已添加","files.deleted":"已删除","files.renamed":"已重命名","files.untracked":"未跟踪","files.conflict":"冲突","files.newlyUploaded":"刚上传","files.containsChangedFiles":"包含已更改文件","files.insertPath":"将路径插入聊天","files.mention":"提及","files.download":"下载文件","files.dismissError":"关闭错误","files.addUploadedFile":"将上传的文件添加到聊天","files.addAllUploadedFiles":"将所有上传的文件添加到聊天","files.dismissUploadResults":"关闭上传结果","files.loading":"正在加载文件...","files.noFiles":"未找到文件","files.explorer":"文件浏览器","files.changedCount":"{count} 个文件","files.changeStats":"{count} 个变更文件,新增 {additions} 行,删除 {deletions} 行","files.conflictSummary":"已有 {count} 个文件:{files}","files.cannotReplace":"无法替换:{files}","files.replace":"替换","files.skipExisting":"跳过已有文件","files.cancel":"取消","files.checking":"正在检查文件","files.uploading":"正在上传,{progress}%","files.edit":"编辑","files.save":"保存","files.saveHint":"保存(Cmd/Ctrl+S)","files.cancelEdit":"取消编辑","files.saveFailed":"保存失败:{error}","files.unsavedChanges":"放弃未保存的改动?","files.externalModified":"文件已被外部修改。重新加载以获取最新版本。","files.reload":"重新加载","files.reloadOverwriteConfirm":"用磁盘上的版本覆盖未保存的改动?","files.newFile":"新建文件","files.newFolder":"新建文件夹","files.delete":"删除","files.promptFileName":"文件名","files.promptFolderName":"文件夹名","files.confirmDeleteFile":"删除“{name}”?此操作无法撤销。","files.confirmDeleteDirectory":"删除“{name}”及其所有内容?此操作无法撤销。","chat.loadingSession":"正在加载会话...","chat.runningTool":"正在运行工具...","chat.generatingToolInput":"正在生成参数...","chat.runningNamedTool":"正在运行 {name}...","chat.runningTools":"正在运行 {names}...","chat.runningToolsMore":"正在运行 {names}(另有 {count} 个)...","chat.waitingModel":"正在等待模型...","chat.runningCommand":"正在运行命令...","chat.thinking":"正在思考...","chat.processDetails":"处理详情","chat.message":"条消息","chat.messages":"条消息","chat.toolCall":"次工具调用","chat.toolCalls":"次工具调用","chat.collapseProcess":"收起处理详情","chat.expandProcess":"展开处理详情","chat.filesWritten":"改动的文件","chat.openWrittenFile":"打开 {name}","chat.loadEarlier":"向上滚动以加载更早的消息","chat.extensionRequest":"扩展请求","chat.extensionExpiresIn":"{seconds} 秒后过期","chat.extensionPending":"待回答","chat.extensionCollapse":"收起","chat.extensionExpand":"展开","chat.cancel":"取消","chat.confirm":"确认","chat.submit":"提交","chat.extensionInput":"扩展终端输入","chat.extensionPanel":"扩展面板","chat.extensionWidgets":"扩展组件","chat.extensionWidgetAbove":"输入框上方组件","chat.extensionWidgetBelow":"输入框下方组件","chat.extensionWidgetLine":"{count} 行","chat.extensionWidgetLines":"{count} 行","chat.close":"关闭","chat.queued":"已排队 \xb7 {count}","chat.recall":"移回输入框","chat.recallTitle":"移除所有排队消息并将其放回输入框编辑","chat.retrying":"正在重试({attempt}/{max})…","chat.loadingCommands":"正在加载命令...","chat.slashCommands":"斜杠命令 \xb7 {label}","chat.tabEnter":"Tab / Enter","chat.noCommands":"未找到扩展、提示词或技能命令","chat.match":"1 个匹配项","chat.matches":"{count} 个匹配项","chat.command":"1 个命令","chat.commands":"{count} 个命令","chat.loadingFiles":"正在加载文件...","chat.files":"文件 \xb7 {label}{hint}","chat.searching":"搜索中…","chat.noMatchingFiles":"未找到匹配的文件","chat.searchingAll":" \xb7 正在搜索所有文件…","chat.indexTruncated":" \xb7 索引不完整","chat.steerPlaceholder":"立即引导 / 排队后续消息...","chat.agentPlaceholder":"Agent 运行中…","chat.messagePlaceholder":"消息…输入 / 使用命令,输入 @ 查找文件","chat.steer":"引导","chat.followUp":"后续消息","chat.steerHint":"中断当前运行并立即注入此消息","chat.followUpHint":"在 Agent 完成后排队此消息","chat.inputHistory":"输入历史","chat.modelError":"模型错误","chat.modelScopeWarning":"模型范围警告","chat.modelScopeWarnings":"模型范围警告","chat.send":"发送","chat.askSelection":"询问选中的文字","chat.askInCurrent":"在当前对话询问","chat.askInNewChat":"在新对话询问","chat.newQuoteChat":"关于选中文字的新对话","chat.quoteIntro":"关于这段内容:","chat.quoteQuestion":"我的问题是:","chat.quoteForkFailed":"无法从这条消息创建分支。","chat.attachImage":"附加图片","chat.previewImage":"预览图片","chat.filterModels":"筛选模型…","chat.noMatchingModels":"没有匹配的模型","chat.moreControls":"更多控件","chat.collapseControls":"收起控件","chat.shell":"Shell","terminal.title":"终端","terminal.tabLabel":"终端:{name}","terminal.open":"打开工作区终端","terminal.close":"终止终端","terminal.restart":"重启终端","terminal.reconnect":"重新连接终端","terminal.connecting":"连接中","terminal.ready":"已连接","terminal.exited":"终端已关闭","terminal.error":"连接错误","terminal.exitCode":"进程已退出,退出码 {code}","chat.outputLocal":"输出保留在本地","chat.outputModel":"输出发送给模型","chat.chatOnly":"仅聊天","chat.readOnlyTools":"{count} 个只读内置工具","chat.builtInTools":"{count} 个内置工具","chat.allBuiltInTools":"全部内置工具","chat.changeReasoning":"更改推理级别:{level}","chat.changeReasoningLabel":"更改推理级别","chat.changeToolPreset":"更改工具预设","chat.stopCompaction":"停止压缩","chat.compactContext":"压缩上下文","chat.compacting":"正在压缩…","chat.compact":"压缩","chat.stopAgent":"停止 Agent","chat.stop":"停止","chat.disableSound":"关闭完成提示音","chat.enableSound":"开启完成提示音","chat.thinkingUseDefault":"使用 pi 默认设置","chat.thinkingOff":"关闭推理","chat.thinkingMinimal":"最低限度推理","chat.thinkingLow":"低强度推理","chat.thinkingMedium":"中等强度推理","chat.thinkingHigh":"高强度推理","chat.thinkingXhigh":"超高强度推理","chat.thinkingMax":"最高强度推理","chat.builtIn":"内置","chat.extensions":"扩展","chat.prompts":"提示词","chat.skills":"技能","chat.dormant":"休眠","chat.commandCompact":"压缩上下文,可选附加说明","chat.commandReload":"重新加载扩展、技能、提示词和工具","chat.commandName":"设置会话显示名称","chat.commandSession":"显示会话消息、Token 和费用统计","chat.commandCopy":"复制最后一条助手消息","chat.commandClone":"将当前分支复制为独立新会话","chat.compacted":"已压缩","chat.imageNotSupportedTitle":"图片可能无法发送","chat.imageNotSupportedBody":"当前选择的模型({model})不支持图片输入,附加的图片可能会被忽略。","chat.tokensSaved":"节省 {saved}","i18n.copy":"复制","i18n.copied":"已复制","i18n.save":"保存","i18n.saving":"保存中…","i18n.saved":"已保存","i18n.remove":"移除","i18n.removing":"移除中…","i18n.delete":"删除","i18n.loading":"加载中...","i18n.search":"搜索","i18n.refresh":"刷新","i18n.update":"更新","i18n.updating":"更新中...","i18n.check":"检查","i18n.install":"安装","i18n.installing":"安装中...","i18n.noResults":"没有结果","i18n.searchProviders":"搜索 Provider…","i18n.noProviders":"没有匹配的 Provider","i18n.newModel":"新模型","i18n.addProvider":"添加 Provider","i18n.selectProviderModel":"选择 Provider 或模型","i18n.visibleInPrompt":"在模型提示词中可见,点击以禁用","i18n.hiddenFromPrompt":"在模型提示词中隐藏,点击以启用","i18n.dormant":"休眠","i18n.hiddenButInvocable":"对模型隐藏,仍可手动调用","i18n.skillSearchPlaceholder":"例如 react、testing、deploy","i18n.searching":"搜索中…","i18n.noSkills":"未找到技能","i18n.checkUpdates":"检查更新","i18n.updates":"项更新","i18n.noResolvedResources":"没有已解析资源","i18n.enablePackage":"启用包","i18n.disablePackage":"禁用包","i18n.filtered":"已筛选","i18n.openSessionToReload":"打开会话后才能重新加载","i18n.notFound":"未找到","i18n.noPlugins":"未配置插件","trust.resourcesNotLoaded":"受限模式","trust.trustProject":"信任项目","trust.trusting":"正在信任...","trust.cancel":"取消","trust.dialogTitle":"信任此项目?","trust.dialogBody":"项目资源可以运行本地代码。请仅信任你了解其内容的项目。","trust.skillsNotLoaded":"此项目尚未受信任,项目技能未加载。","trust.pluginsNotLoaded":"此项目尚未受信任,项目插件未加载。","trust.projectScopeUnavailable":"项目资源未加载时,无法安装到项目范围。","i18n.creatingSession":"正在创建新会话…","i18n.creating":"创建中…","i18n.subscription":"订阅","i18n.subscriptions":"订阅服务","i18n.customEndpoint":"自定义端点格式","i18n.noChanges":"没有更改","i18n.branches":"分支","i18n.noActiveSession":"没有活动会话","i18n.noBranches":"此会话没有分支","i18n.source":"源代码","i18n.preview":"预览","i18n.diff":"Diff","i18n.downloadFile":"下载文件","i18n.liveSync":"实时同步已启用","i18n.notWatching":"未监视","i18n.fileViewMode":"文件视图模式","i18n.compareHead":"比较工作区与 HEAD","i18n.mentionSelectedLines":"提及所选行","i18n.disableWrap":"禁用自动换行","i18n.enableWrap":"启用自动换行","i18n.htmlPreview":"HTML 预览","i18n.previewFile":"预览 {file}","i18n.invalidMermaid":"Mermaid 图表无效","i18n.renderingMermaid":"正在渲染 Mermaid 图表","i18n.previewAfterStreaming":"流式输出完成后可预览","i18n.showMermaidSource":"显示 Mermaid 源码","i18n.previewMermaid":"预览 Mermaid 图表","i18n.openMermaidViewer":"打开图表查看器","i18n.mermaidViewer":"Mermaid 图表查看器","i18n.mermaidDiagram":"Mermaid 图表","i18n.zoomOut":"缩小","i18n.zoomIn":"放大","i18n.fitToWidth":"适应宽度","models.discoveryFetching":"正在导入模型…","models.discoveryFetch":"导入模型…","models.discoveryFilterPlaceholder":"筛选 {count} 个模型…","models.discoveryFilter":"筛选上游模型","models.discoverySelectShown":"选择当前结果","models.discoveryNoMatches":"没有匹配的模型。","models.discoveryAdded":"已添加","models.discoveryShowing":"显示前 {shown} 个,共 {total} 个","models.discoveryFetched":"已获取 {count} 个模型","models.discoveryAddSelected":"添加所选模型","models.discoveryAddSelectedCount":"添加所选模型({count})","models.catalogSource":"来源:models.dev ↗","models.catalogFilling":"正在填入模型信息…","models.catalogFill":"填入模型信息","models.catalogFilled":"已填入 {count} 个字段","models.catalogNoEmptyFields":"没有需要填入的空字段","models.catalogNoExactMatch":"models.dev 中没有精确匹配","models.catalogPriceProvider":"价格已匹配 Provider {provider}","models.catalogPriceBaseUrl":"价格已按 Base URL 匹配 {provider}","models.catalogPriceConsensus":"价格得到 {support}/{total} 条记录支持","models.catalogPriceUnreliable":"未找到可靠价格","models.catalogUndo":"撤销","models.capabilities":"能力","models.reasoning":"推理 / 思考","models.imageInput":"图片输入","models.modelSpecs":"模型规格","models.contextWindow":"上下文窗口(tokens)","models.maxOutputTokens":"最大输出 tokens","models.costPerMillion":"每百万 tokens 价格","models.costInput":"输入","models.costOutput":"输出","models.costCacheRead":"缓存读取","models.costCacheWrite":"缓存写入","models.notProvided":"未提供","models.editCosts":"编辑价格","models.finishEditingCosts":"完成","models.costAllRequired":"请输入有效的非负价格;留空项将按 0 保存。","models.advancedSettings":"高级设置","models.providerDefaults":"沿用 Provider 默认设置","models.headersSummary":"Headers:{count}","models.compatSummary":"兼容性:{count}","models.thinkingSummary":"思考等级:{count}","models.apiOverride":"API 覆盖","models.headers":"Headers","models.headersHelp":"仅添加到该模型的请求中,并覆盖 Provider 的同名 Header。","models.compatibility":"兼容性","models.deepSeekThinkingCompat":"DeepSeek 思考兼容","models.developerRole":"使用 developer role 传递系统提示词","models.thinkingLevelMap":"思考等级映射","models.clearAll":"全部清除","i18n.testingModel":"正在测试模型连接...","i18n.connected":"已连接","i18n.failed":"失败","i18n.test":"测试","i18n.testConnection":"测试模型连接","i18n.provider":"Provider","i18n.model":"模型","i18n.providerName":"Provider 名称","i18n.rename":"重命名","i18n.default":"默认","i18n.disabled":"已禁用","i18n.noResources":"没有资源","i18n.unknown":"未知","i18n.installedVersion":"已安装 {version}","i18n.configuredVersion":"已配置 {version}","i18n.extensions":"扩展","i18n.prompts":"提示词","i18n.themes":"主题","i18n.resourceCount":"{count}{label}","i18n.extensionShort":"扩展","i18n.skillShort":"技能","i18n.promptShort":"提示词","i18n.themeShort":"主题","i18n.custom":"自定义","i18n.clearAll":"清除全部","i18n.connectedSuccessfully":"连接成功。","i18n.notConnected":"未连接","i18n.configured":"已配置","i18n.notConfigured":"未配置","i18n.openingBrowser":"正在打开浏览器…","i18n.submit":"提交","i18n.login":"登录","i18n.relogin":"重新登录","i18n.disconnect":"断开连接","i18n.networkError":"网络错误","i18n.continuing":"继续中…","i18n.skills":"技能","i18n.plugins":"插件","i18n.addSkill":"添加技能","i18n.addPlugin":"添加插件","i18n.selectSkill":"选择技能","i18n.selectPackage":"选择包","i18n.updateAvailable":"有可用更新","i18n.upToDate":"已是最新","i18n.automaticChecksUnavailable":"自动检查不可用","i18n.checkFailed":"检查失败","i18n.installed":"已安装","i18n.status":"状态","i18n.version":"版本","i18n.package":"包","i18n.resources":"资源","i18n.installedPath":"安装路径","i18n.cwd":"CWD","i18n.resolvedResources":"已解析资源","i18n.reloadSession":"重新加载会话","i18n.reloading":"重新加载中...","i18n.packageRemoved":"包已移除。","i18n.packageInstalled":"包已安装。","i18n.packageUpdated":"包已更新。","i18n.packagesUpdated":"所有插件已更新。","i18n.updateAllPlugins":"更新全部","i18n.updateAllPluginsHint":"更新所有已配置的插件","i18n.packageDisabled":"包已禁用。","i18n.packageEnabled":"包已启用。","i18n.sessionReloaded":"会话已重新加载。","i18n.thinking":"思考","i18n.largeMessageReveal":"消息内容过大({size})。点击以纯文本查看 — 已禁用 markdown 渲染以避免页面卡顿。","i18n.loadingThinking":"正在加载思考内容...","i18n.copyMessage":"复制消息","i18n.editFromHere":"从此处编辑","i18n.editFromHereTitle":"从此处编辑,此会话内创建分支","i18n.newSession":"新会话","i18n.newSessionTitle":"新会话,从此处创建独立副本","i18n.estimatedTokens":"流式输出期间的估算 Token 数","i18n.noOutput":"(无输出)","i18n.openImage":"打开图片","i18n.noSummary":"(无摘要)","i18n.conversationCompacted":"会话已压缩","i18n.compactionDescription":"此处之前的会话历史已压缩为以下摘要:","i18n.fileContext":"文件上下文:{details}","i18n.readFiles":"读取的文件","i18n.modifiedFiles":"修改的文件","i18n.hiddenExtensionMessage":"隐藏的扩展消息","i18n.noMessage":"(无消息)","i18n.showExtensionMessage":"显示扩展消息","i18n.collapse":"收起","i18n.expand":"展开","i18n.hideDetails":"隐藏详情","i18n.showDetails":"显示详情","i18n.thinkingUnavailable":"思考内容不可用","i18n.before":"之前","i18n.after":"之后","i18n.sessionComplete":"任务完成","i18n.taskFinished":"任务已完成。","i18n.attentionNeeded":"Pi 需要你的操作","i18n.extensionInputNeeded":"扩展正在等待你的输入。"}});let l="pi-locale",d=(0,n.createContext)(null);function c({children:e}){let[t,o]=(0,n.useState)("en"),[i,p]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=function(){try{let e=window.localStorage.getItem(l);if("en"===e||"zh-CN"===e)return e}catch{}for(let e of window.navigator.languages.length?window.navigator.languages:[window.navigator.language]){let t=e.toLowerCase();if("en"===t||t.startsWith("en-"))break;if("zh"===t||"zh-cn"===t||t.startsWith("zh-cn-")||"zh-sg"===t||t.startsWith("zh-sg-")||"zh-hans"===t||t.startsWith("zh-hans-")||"zh-tw"===t||t.startsWith("zh-tw-")||"zh-hk"===t||t.startsWith("zh-hk-")||"zh-mo"===t||t.startsWith("zh-mo-")||"zh-hant"===t||t.startsWith("zh-hant-")||t.startsWith("zh-"))return"zh-CN"}return"en"}();o(e),document.documentElement.lang=e,p(!0)},[]);let u=(0,n.useMemo)(()=>(function(){let e=a("en"),t=a("zh-CN");if(!e||!t)throw Error("Built-in locales must be registered before rendering I18nProvider");return{en:e.messages,"zh-CN":t.messages}})(),[]),h=(0,n.useMemo)(()=>[...s.keys()].map(e=>a(e)).filter(e=>!!e),[]),g=(0,n.useCallback)(e=>{if(a(e)){o(e);document.documentElement.lang=e,document.documentElement.dataset.language=e;try{window.localStorage.setItem(l,e)}catch{}}},[]),m=(0,n.useCallback)((e,o)=>(function(e,t,o,r={}){let n=o[e]?.[t]??o.en?.[t];return void 0===n?t:function(e,t={}){return e.replace(/\{([\w.-]+)\}/g,(e,o)=>{let r=t[o];return void 0===r?e:String(r)})}(n,r)})(t,e,u,o),[t,u]),f=(0,n.useMemo)(()=>({locale:t,setLocale:g,t:m,supportedLocales:h}),[t,g,m,h]);return(0,r.jsx)(d.Provider,{value:f,children:i?e:null})}function p(){let e=(0,n.useContext)(d);if(!e)throw Error("useI18n must be used inside I18nProvider");return e}},55600:(e,t,o)=>{"use strict";o.d(t,{AppShell:()=>py});var r=o(95155),n=o(12115),s=o(53516),i=o(73321);let a=null;class l extends Error{constructor(e,t){super(e),this.code=t,this.name="SessionTitleClientError"}}async function d(e,t){let o=await fetch(`/api/sessions/${encodeURIComponent(e)}/auto-name`,{method:"POST",signal:t}),r=await o.json().catch(()=>({}));if(!o.ok||!r.title)throw new l(r.error||`HTTP ${o.status}`,r.code);return{title:r.title,usage:r.usage}}async function c(e){try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/auto-name`,{method:"DELETE"}),o=await t.json().catch(()=>({}));return t.ok&&!0===o.cancelled}catch{return!1}}var p=o(47650),u=o(25349),h=o(64178),g=o(9720),m=o(98664),f=o(20077),x=o(49467),k=o(56123),v=o(6033),y=o(85265),b=o(94125),w=o(25388),j=o(3083),S=o(73988),C=o(41780),T=o(11693),R=o(77862),z=o(19157),I=o(72422),M=o(5085),P=o(80388),E=o(36824),W=o(42515),F=o(44368);function D(e,t){if(e.size!==t.size)return!1;for(let o of e)if(!t.has(o))return!1;return!0}var A=o(39247);let N="(max-width: 640px)",L=e=>(function(e,t){if(!window.matchMedia)return()=>{};let o=window.matchMedia(e);return o.addEventListener("change",t),()=>o.removeEventListener("change",t)})(N,e),$=()=>!!window.matchMedia&&window.matchMedia(N).matches;function H(){return!1}function O(){return(0,n.useSyncExternalStore)(L,$,H)}async function B(e){let t=e?`?path=${encodeURIComponent(e)}`:"",o=await fetch(`/api/cwd/browse${t}`),r=await o.json();if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);return r}function U(){return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M1.5 3h4l1.5 2h7.5v7.5h-13z"})})}function _(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,r.jsx)("path",{d:"M2 9h12"}),(0,r.jsx)("circle",{cx:"11.5",cy:"11",r:"0.6",fill:"currentColor",stroke:"none"})]})}function q({onCancel:e,onSelect:t,initialPath:o,busy:s=!1,error:i}){let a,{t:l}=(0,A.s)(),[d,c]=(0,n.useState)(null),[u,h]=(0,n.useState)(""),[g,m]=(0,n.useState)(null),[f,x]=(0,n.useState)([]),[k,v]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),[w,j]=(0,n.useState)(!0),[S,C]=(0,n.useState)(""),T=(0,n.useCallback)(async e=>{j(!0),b(null),C("");try{let t=await B(e),o=t.path??e??"/";h(o),m(t.parentPath??null),x(t.directories??[]),v(t.drives??null)}catch(e){b(e instanceof Error?e.message:String(e))}finally{j(!1)}},[]);(0,n.useEffect)(()=>{c(document.body),T(o||void 0)},[o,T]);let R=!!u&&!s,z=!!g||/^[a-zA-Z]:[\\/]?$/.test(u);return d?(0,p.createPortal)((0,r.jsx)("div",{className:"directory-picker-backdrop",role:"dialog","aria-modal":"true","aria-label":l("directoryPicker.selectDirectory"),onClick:t=>{t.target!==t.currentTarget||s||e()},onKeyDown:t=>{"Escape"!==t.key||s||e()},style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.35)"},children:(0,r.jsxs)("div",{className:"directory-picker-panel",style:{width:520,maxWidth:"calc(100vw - 16px)",height:"min(620px, calc(100dvh - 16px))",maxHeight:"calc(100dvh - 16px)",display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 8px 32px rgba(0,0,0,0.18)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,padding:"12px 18px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("div",{style:{minWidth:0,flex:1},children:(0,r.jsx)("div",{style:{color:"var(--text)",fontWeight:700,fontSize:15},children:l("directoryPicker.selectDirectory")})}),(0,r.jsx)("button",{type:"button",onClick:e,disabled:s,title:l("i18n.close"),"aria-label":l("i18n.close"),style:{padding:"2px 6px",border:0,background:"none",color:"var(--text-muted)",fontSize:20,lineHeight:1,cursor:s?"default":"pointer",opacity:s?.5:1},children:"\xd7"})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0,padding:"10px 14px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("button",{className:"directory-picker-back",type:"button",onClick:()=>void T(g??void 0),disabled:w||!z,title:l("directoryPicker.goToParent"),"aria-label":l("directoryPicker.goToParent"),style:{width:36,height:36,padding:0,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-hover)",color:"var(--text-muted)",cursor:z?"pointer":"default",opacity:z?1:.45},children:(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"m18 15-6-6-6 6"})})}),(0,r.jsx)("div",{title:u,style:{minWidth:0,flex:1,height:36,display:"flex",alignItems:"center",padding:"0 10px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u||l("directoryPicker.loadingDirectories")})]}),(0,r.jsxs)("div",{className:"directory-picker-list",style:{flex:1,minHeight:0,overflow:"auto",padding:"8px 10px"},children:[w?(0,r.jsx)("div",{style:{padding:8,color:"var(--text-dim)",fontSize:11},children:l("directoryPicker.loadingDirectories")}):null!==k?(0,r.jsx)(r.Fragment,{children:k.length>0?k.map(e=>(0,r.jsxs)("button",{className:"directory-picker-entry",type:"button",onClick:()=>void T(e.path),title:e.path,style:{width:"100%",minHeight:34,display:"flex",alignItems:"center",gap:7,padding:"6px 8px",border:0,borderRadius:5,background:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-mono)",fontSize:11},children:[(0,r.jsx)(_,{}),(0,r.jsx)("span",{children:e.name})]},e.path)):(0,r.jsx)("div",{style:{padding:8,color:"var(--text-dim)",fontSize:11},children:l("directoryPicker.noDrives")})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{type:"text",value:S,onChange:e=>C(e.target.value),placeholder:l("directoryPicker.filterPlaceholder"),"aria-label":l("directoryPicker.filterPlaceholder"),style:{width:"100%",boxSizing:"border-box",marginBottom:6,padding:"5px 9px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:11,outline:"none"}}),(a=function(e,t){if(null===t||""===t)return[...e];let o=t.trim().toLowerCase();return o?e.filter(e=>e.name.toLowerCase().includes(o)):[...e]}(f,S)).length>0?a.map(e=>(0,r.jsxs)("button",{className:"directory-picker-entry",type:"button",onClick:()=>void T(e.path),title:e.path,style:{width:"100%",minHeight:30,display:"flex",alignItems:"center",gap:7,padding:"5px 8px",border:0,borderRadius:5,background:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-mono)",fontSize:11},children:[(0,r.jsx)(U,{}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.path)):(0,r.jsx)("div",{style:{padding:8,color:"var(--text-dim)",fontSize:11},children:l(S.trim()?"directoryPicker.noMatchingDirectories":"directoryPicker.noSubdirectories")})]}),(y||i)&&(0,r.jsx)("div",{style:{padding:"8px",color:"#dc2626",fontSize:11},children:y??i})]}),(0,r.jsxs)("div",{className:"directory-picker-footer",style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:10,flexShrink:0,padding:"10px 18px",borderTop:"1px solid var(--border)"},children:[(0,r.jsx)("button",{className:"directory-picker-action",type:"button",onClick:e,disabled:s,style:{padding:"6px 14px",border:"1px solid var(--border)",borderRadius:6,background:"none",color:"var(--text-muted)",cursor:s?"default":"pointer",fontSize:13},children:l("i18n.cancel")}),(0,r.jsx)("button",{className:"directory-picker-action",type:"button",onClick:()=>t(u),disabled:!R,title:l("directoryPicker.selectCurrentDirectory"),style:{padding:"6px 16px",border:0,borderRadius:6,background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:600,opacity:R?1:.6,cursor:R?"pointer":"default"},children:l(s?"i18n.checking":"directoryPicker.selectThisFolder")})]})]})}),d):null}var V=o(63256),K=o(19413),G=o(30515),J=o(32970),Y=o(69248),X=o(95516),Z=o(6513);function Q(e,t){return`url(/catppuccin-icons/${e}/${t}.svg)`}function ee({icon:e,size:t=14}){let o={"--catppuccin-icon-light":Q("latte",e),"--catppuccin-icon-dark":Q("mocha",e),width:t,height:t};return(0,r.jsx)("span",{className:"catppuccin-file-icon",style:o,"aria-hidden":"true"})}let et={".github":"github",".git":"git",".vscode":"vscode",".next":"next",".nuxt":"nuxt",".storybook":"storybook",".turbo":"turbo",".yarn":"yarn",".husky":"husky",".cursor":"cursor",api:"api",app:"app",assets:"assets",components:"components",config:"config",docs:"docs",examples:"examples",hooks:"hooks",lib:"lib",node_modules:"node",pages:"routes",public:"public",scripts:"scripts",src:"src",styles:"styles",test:"tests",tests:"tests",__tests__:"tests",types:"types",utils:"utils"};function eo({size:e=14,open:t=!1,name:o}){let n=o?et[o.toLowerCase()]:void 0,s=n?`folder_${n}${t?"_open":""}`:`_${t?"folder_open":"folder"}`;return(0,r.jsx)(ee,{icon:s,size:e})}function er({size:e=14}){return(0,r.jsx)(ee,{icon:"_file",size:e})}function en({icon:e,size:t=14}){return(0,r.jsx)(ee,{icon:e,size:t})}let es={".babelrc":"babel",".dockerignore":"docker-ignore",".env":"env",".eslintignore":"eslint-ignore",".eslintrc":"eslint",".gitattributes":"git",".gitignore":"git",".gitmodules":"git",".npmignore":"npm-ignore",".prettierignore":"prettier-ignore",".prettierrc":"prettier",".yarnrc":"yarn","bun.lock":"bun-lock","bun.lockb":"bun-lock","cargo.lock":"cargo-lock","cargo.toml":"cargo",codeowners:"codeowners","docker-compose.yaml":"docker-compose","docker-compose.yml":"docker-compose",dockerfile:"docker","eslint.config.js":"eslint","eslint.config.mjs":"eslint","eslint.config.ts":"eslint","next.config.js":"next","next.config.mjs":"next","next.config.ts":"next","package-lock.json":"npm-lock","package.json":"package-json","pnpm-lock.yaml":"pnpm-lock","pnpm-workspace.yaml":"pnpm","prettier.config.js":"prettier","prettier.config.mjs":"prettier","prettier.config.ts":"prettier","tailwind.config.js":"tailwind","tailwind.config.ts":"tailwind","tsconfig.json":"typescript-config","vite.config.js":"vite","vite.config.mjs":"vite","vite.config.ts":"vite","vitest.config.ts":"vitest","yarn.lock":"yarn-lock"},ei={astro:"astro",bash:"bash",c:"c",cpp:"cpp",css:"css",csv:"csv",cjs:"javascript",cts:"typescript",dockerfile:"docker",env:"env",go:"go",gql:"graphql",graphql:"graphql",hcl:"terraform",htm:"html",html:"html",ini:"config",java:"java",js:"javascript",json:"json",jsonc:"json",jsonl:"json",jsx:"javascript-react",less:"less",lua:"lua",md:"markdown",mdx:"markdown-mdx",mjs:"javascript",mts:"typescript",pdf:"pdf",php:"php",py:"python",rs:"rust",sass:"sass",scss:"sass",sh:"bash",sql:"database",svg:"svg",svelte:"svelte",tf:"terraform",toml:"toml",ts:"typescript",tsx:"typescript-react",txt:"text",vue:"vue",xml:"xml",yaml:"yaml",yml:"yaml",zsh:"bash"};function ea(e,t=14){let o=e.toLowerCase(),n=es[o];if(n)return(0,r.jsx)(en,{icon:n,size:t});if(".env"===o||o.startsWith(".env."))return(0,r.jsx)(en,{icon:"env",size:t});if("dockerfile"===o||o.startsWith("dockerfile."))return(0,r.jsx)(en,{icon:"docker",size:t});if(o.endsWith(".config.ts")||o.endsWith(".config.js")||o.endsWith(".config.mjs")||o.endsWith(".config.cjs"))return(0,r.jsx)(en,{icon:o.startsWith("vite.")?"vite":"config",size:t});let s=ei[o.split(".").pop()??""];return s?(0,r.jsx)(en,{icon:s,size:t}):(0,r.jsx)(er,{size:t})}function el(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")?e.replace(/\\/g,"/"):e}function ed(e){return el(e).split("/").filter(Boolean).map(encodeURIComponent).join("/")}function ec(e){let t=el(e).replace(/\/+$/,"");return t.split("/").pop()??t}function ep(e,t){if(!t)return e;let o=el(e),r=el(t).replace(/\/$/,"");return o.startsWith(r+"/")?o.slice(r.length+1):e}function eu(e,t){return`${el(e).replace(/\/$/,"")}/${t}`}var eh=o(87358);function eg(){let e=eh.env.NEXT_PUBLIC_PI_WEB_FILE_EDITING;return!!e&&["1","true","yes","on"].includes(e.trim().toLowerCase())}function em(e){let t=e.replace(/\\/g,"/").replace(/\/+$/,"");return/^[a-zA-Z]:\//.test(t)?t.toLowerCase():t}function ef(e){return"added"===e?"var(--git-status-added)":"deleted"===e?"var(--git-status-deleted)":"modified"===e?"var(--git-status-modified)":"var(--text)"}function ex(e){return"deleted"===e?3:"added"===e?2:1}async function ek(e){let t=await fetch(`/api/git/status?${new URLSearchParams({cwd:e}).toString()}`,{cache:"no-store"});if(!t.ok)throw Error(`Failed to load Git status (HTTP ${t.status})`);return t.json()}async function ev(e){let t=ed(e),o=await fetch(`/api/files/${t}?type=list`);if(!o.ok){let e=`Failed to load files (HTTP ${o.status})`;try{let t=await o.json();t.error&&(e=t.error)}catch{}throw Error(e)}return((await o.json()).entries??[]).map(t=>({name:t.name,fullPath:eu(e,t.name),isDir:t.isDir,size:t.size,children:t.isDir?[]:void 0,loaded:!t.isDir}))}function ey({size:e=11}){return(0,r.jsx)(V.At,{size:e,weight:"regular","aria-hidden":"true"})}function eb({onClick:e,title:t}){return(0,r.jsx)("button",{type:"button",onClick:e,title:t,"aria-label":t,style:{width:24,height:24,padding:0,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"none",borderRadius:4,background:"none",color:"var(--text-dim)",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,r.jsx)(h.X,{size:13,weight:"regular","aria-hidden":"true"})})}async function ew(e,t,o,r){let n=await fetch(`/api/files/${ed(e)}?type=create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,kind:o,content:r??""})}),s=await n.json().catch(()=>({}));if(!n.ok||!s.path)throw Error(s.error??`Create failed (HTTP ${n.status})`);return{path:s.path}}async function ej(e){let t=await fetch(`/api/files/${ed(e)}`,{method:"DELETE"});if(!t.ok){let e=`Delete failed (HTTP ${t.status})`;try{let o=await t.json();o.error&&(e=o.error)}catch{}throw Error(e)}}let eS={display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 5px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"};function eC({node:e,depth:t,cwd:o,onOpenFile:s,onAtMention:i,expandedPaths:a,onToggleExpanded:l,refreshToken:d,highlightedPaths:c,ignoredPaths:p,changedFiles:u,editingEnabled:h,onCreateFile:g,onCreateFolder:m,onDelete:f}){let x,{t:k}=(0,A.s)(),v=a.has(e.fullPath),y=c.has(e.fullPath),w=em(e.fullPath),j=function(e,t){if(t.has(e))return!0;for(let o of t)if(e.startsWith(`${o}/`))return!0;return!1}(w,p),S=function(e,t,o){let r,n=o.get(e);if(n||!t)return n;for(let[t,n]of o)t.startsWith(`${e}/`)&&(!r||ex(n)>ex(r))&&(r=n);return r}(w,e.isDir,u),[C,R]=(0,n.useState)(e.children??[]),[z,I]=(0,n.useState)(e.loaded??!1),[M,P]=(0,n.useState)(!1),[W,F]=(0,n.useState)(!1),D=(0,n.useCallback)(async(t=!1)=>{if(!z||t){P(!0);try{let t=await ev(e.fullPath);R(t),I(!0)}catch{}finally{P(!1)}}},[z,e.fullPath]);(0,n.useEffect)(()=>{void 0!==d&&v&&z&&D(!0)},[d]);let N=(0,n.useCallback)(()=>{if(e.isDir){let t=!v;l(e.fullPath,t),t&&!z&&D()}else s(e.fullPath,e.name)},[e.isDir,e.fullPath,e.name,z,v,D,s,l]);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{onClick:N,onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1),style:{position:"relative",display:"flex",alignItems:"center",gap:4,paddingLeft:8+14*t,paddingRight:8,height:24,cursor:"pointer",background:W?"var(--bg-hover)":"transparent",borderRadius:4,userSelect:"none",opacity:j?W?.72:.5:1},children:[e.isDir&&(0,r.jsx)(b.K,{size:10,color:"var(--text-dim)",weight:"regular",style:{flexShrink:0,transform:v?"rotate(90deg)":"none",transition:"transform 0.1s"},"aria-hidden":"true"}),!e.isDir&&(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsxs)("span",{style:{position:"relative",width:14,height:14,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:[e.isDir?(0,r.jsx)(eo,{size:14,open:v,name:e.name}):ea(e.name,14),S&&(0,r.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",left:-1,top:"50%",transform:"translateY(-50%)",zIndex:1,width:7,height:7,border:"1px solid var(--bg-panel)",borderRadius:"50%",background:ef(S)}})]}),(0,r.jsx)("span",{style:{fontSize:12,color:ef(S),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},title:e.fullPath,children:e.name}),y&&(0,r.jsx)("span",{title:"Newly uploaded","aria-label":"Newly uploaded",style:{width:6,height:6,flexShrink:0,borderRadius:"50%",background:"#3b82f6"}}),M&&(0,r.jsx)(K.y,{size:10,color:"var(--text-dim)",weight:"regular","aria-hidden":"true"}),W&&(x=[],(i&&x.push((0,r.jsxs)("button",{onClick:t=>{t.stopPropagation(),i(ep(e.fullPath,o),e.isDir)},title:k("files.insertPath"),style:{...eS,color:"var(--accent)"},children:[(0,r.jsx)(ey,{}),k("files.mention")]},"mention")),h&&e.isDir&&x.push((0,r.jsx)("button",{onClick:t=>{t.stopPropagation(),g(e.fullPath)},title:k("files.newFile"),"aria-label":k("files.newFile"),style:eS,children:(0,r.jsx)(G.p,{size:11,weight:"regular","aria-hidden":"true"})},"new-file"),(0,r.jsx)("button",{onClick:t=>{t.stopPropagation(),m(e.fullPath)},title:k("files.newFolder"),"aria-label":k("files.newFolder"),style:eS,children:(0,r.jsx)(J.JU,{size:11,weight:"regular","aria-hidden":"true"})},"new-folder")),e.isDir||x.push((0,r.jsx)("a",{href:`/api/files/${ed(e.fullPath)}?type=download`,download:!0,onClick:e=>e.stopPropagation(),title:k("files.download"),style:{...eS,color:"var(--text-muted)",textDecoration:"none"},children:(0,r.jsx)(E.z,{size:11,weight:"regular","aria-hidden":"true"})},"download")),h&&x.push((0,r.jsx)("button",{onClick:t=>{t.stopPropagation(),f(e.fullPath,e.name,e.isDir)},title:k("files.delete"),"aria-label":k("files.delete"),style:{...eS,color:"#f87171"},children:(0,r.jsx)(T.l,{size:11,weight:"regular","aria-hidden":"true"})},"delete")),0===x.length)?null:(0,r.jsx)("div",{style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:3},children:x}))]}),e.isDir&&v&&(0,r.jsxs)("div",{children:[C.map(e=>(0,r.jsx)(eC,{node:e,depth:t+1,cwd:o,onOpenFile:s,onAtMention:i,expandedPaths:a,onToggleExpanded:l,refreshToken:d,highlightedPaths:c,ignoredPaths:p,changedFiles:u,editingEnabled:h,onCreateFile:g,onCreateFolder:m,onDelete:f},e.fullPath)),0===C.length&&z&&(0,r.jsx)("div",{style:{paddingLeft:8+(t+1)*14,fontSize:11,color:"var(--text-dim)",height:22,display:"flex",alignItems:"center"},children:"empty"})]})]})}let eT=(0,n.forwardRef)(function({cwd:e,onOpenFile:t,refreshKey:o,onAtMention:s,onAtMentions:i,onUploadBusyChange:a,fileSearchOpen:l=!1,onFileSearchOpenChange:d,onFileCreated:c,onFileDeleted:p},u){let{t:h}=(0,A.s)(),[g,f]=(0,n.useState)([]),[x,k]=(0,n.useState)(null),[v,y]=(0,n.useState)(!0),[b,w]=(0,n.useState)(null),[j,S]=(0,n.useState)(new Set),[C,T]=(0,n.useState)(0),[z,I]=(0,n.useState)(new Set),[M,P]=(0,n.useState)(""),[E,W]=(0,n.useState)([]),[F,D]=(0,n.useState)(!1),[N,L]=(0,n.useState)(!1),[$,H]=(0,n.useState)(new Set),O=(0,n.useRef)(null),B=M.trim().length>0,[U,_]=(0,n.useState)("idle"),[q,V]=(0,n.useState)(0),[G,J]=(0,n.useState)(null),[Q,ee]=(0,n.useState)(null),[et,eo]=(0,n.useState)(null),[er,en]=(0,n.useState)(null),es=(0,n.useRef)(null),ei=(0,n.useRef)(null),ea=`${o??0}:${C}`,el="idle"!==U,ec=eg(),eh=(0,n.useMemo)(()=>new Set((x?.ignoredPaths??[]).map(em)),[x]),ef=(0,n.useMemo)(()=>new Map((x?.files??[]).map(e=>{var t;return[em(e.filePath),"added"===(t=e.status)||"untracked"===t?"added":"deleted"===t||"conflict"===t?"deleted":"modified"]})),[x]);(0,n.useEffect)(()=>{if(!l)return;let t=M.trim();if(!t){W([]),D(!1),L(!1);return}let o=new AbortController;D(!0),L(!1);let r=setTimeout(()=>{fetch(`/api/file-index?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`,{signal:o.signal}).then(e=>e.ok?e.json():Promise.reject(Error("Search failed"))).then(e=>W((e.matches??[]).filter(e=>!e.isDir).map(e=>e.path))).catch(()=>{o.signal.aborted||(W([]),L(!0))}).finally(()=>{o.signal.aborted||D(!1)})},150);return()=>{clearTimeout(r),o.abort()}},[e,l,M]),(0,n.useEffect)(()=>{l&&O.current?.focus()},[l]),(0,n.useEffect)(()=>{if(0===E.length)return;let t=new Set;for(let o of E){let r=o.split("/"),n="";for(let o=0;o<r.length-1;o++)n=n?`${n}/${r[o]}`:r[o],t.add(eu(e,n))}H(e=>{let o=!1,r=new Set(e);for(let e of t)r.has(e)||(r.add(e),o=!0);return o?r:e})},[e,E]);let ex=(0,n.useMemo)(()=>{let t=o=>({name:o.name,fullPath:eu(e,o.path),isDir:o.isDir,size:0,children:o.children.map(t),loaded:!0});return(function(e){let t=[],o=new Map;for(let r of e){let e=r.split("/"),n=t,s="";for(let t=0;t<e.length;t++){s=s?`${s}/${e[t]}`:e[t];let r=o.get(s);r||(r={name:e[t],path:s,isDir:t<e.length-1,children:[]},o.set(s,r),n.push(r)),n=r.children}}let r=e=>{e.sort((e,t)=>e.isDir!==t.isDir?e.isDir?-1:1:e.name.localeCompare(t.name)),e.forEach(e=>r(e.children))};return r(t),t})(E).map(t)},[e,E]),eS=(0,n.useCallback)((e,t)=>{S(o=>{let r=new Set(o);return t?r.add(e):r.delete(e),r})},[]),eT=(0,n.useCallback)(t=>{let o=t.uploaded??[];ee({uploaded:o,skipped:t.skipped??[],errors:t.errors??[]}),o.length>0&&(I(new Set(o.map(t=>eu(e,t)))),T(e=>e+1))},[e]),eR=(0,n.useCallback)(async(t,o)=>{eo(null),J(null),V(0),_("uploading");try{let{status:r,data:n}=await new Promise((r,n)=>{let s=new FormData;t.forEach(e=>s.append("files",e,e.name));let i=new XMLHttpRequest;i.open("POST",`/api/files/${ed(e)}?type=upload&conflict=${o}`),i.upload.onprogress=e=>{e.lengthComputable&&e.total>0&&V(Math.round(e.loaded/e.total*100))},i.onerror=()=>n(Error("Network error while uploading files")),i.onabort=()=>n(Error("Upload cancelled")),i.onload=()=>{let e={};try{e=JSON.parse(i.responseText)}catch{i.responseText&&(e.error=i.responseText)}r({status:i.status,data:e})},i.send(s)});if(409===r&&n.conflicts?.length)return void eo({files:t,conflicts:n.conflicts,nonReplaceable:n.nonReplaceable??[]});if(r<200||r>=300)throw Error(n.error??`Upload failed (HTTP ${r})`);V(100),eT(n)}catch(e){J(e instanceof Error?e.message:String(e))}finally{_("idle")}},[eT,e]),ez=(0,n.useCallback)(async t=>{if(0!==t.length&&!el){ee(null),I(new Set),eo(null),J(null),V(0),_("checking");try{let o=await fetch(`/api/files/${ed(e)}?type=upload-check`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileNames:t.map(e=>e.name)})}),r=await o.json().catch(()=>({}));if(!o.ok)throw Error(r.error??`Upload check failed (HTTP ${o.status})`);if(r.conflicts?.length)return void eo({files:t,conflicts:r.conflicts,nonReplaceable:r.nonReplaceable??[]});await eR(t,"error")}catch(e){J(e instanceof Error?e.message:String(e))}finally{_("idle")}}},[e,eR,el]),eI=(0,n.useCallback)(e=>{let t=Array.from(e.target.files??[]);e.target.value="",ez(t)},[ez]),eM=(0,n.useCallback)(async e=>{en(null);let t=window.prompt(h("files.promptFileName"));if(t)try{await ew(e,t,"file");let o=eu(e,t);I(new Set([o])),T(e=>e+1),c?.(o)}catch(e){en(e instanceof Error?e.message:String(e))}},[c,h]),eP=(0,n.useCallback)(async e=>{en(null);let t=window.prompt(h("files.promptFolderName"));if(t)try{await ew(e,t,"directory");let o=eu(e,t);I(new Set([o])),T(e=>e+1)}catch(e){en(e instanceof Error?e.message:String(e))}},[h]),eE=(0,n.useCallback)(async(e,t,o)=>{en(null);let r=o?h("files.confirmDeleteDirectory",{name:t}):h("files.confirmDeleteFile",{name:t});if(window.confirm(r))try{await ej(e),T(e=>e+1),p?.(e,o)}catch(e){en(e instanceof Error?e.message:String(e))}},[p,h]);(0,n.useImperativeHandle)(u,()=>({openUploadPicker(){el||ei.current?.click()},openCreateFilePicker(t){eM(t??e)},openCreateFolderPicker(t){eP(t??e)}}),[el,e,eM,eP]),(0,n.useEffect)(()=>{a?.(el)},[a,el]),(0,n.useEffect)(()=>()=>a?.(!1),[a]),(0,n.useEffect)(()=>{let t=es.current!==e;es.current=e,t&&(S(new Set),I(new Set),ee(null),eo(null),J(null)),y(t),w(null);let o=!1;return Promise.all([ev(e),ek(e).catch(()=>null)]).then(([e,t])=>{o||(f(e),k(t))}).catch(e=>{o||w(e instanceof Error?e.message:String(e))}).finally(()=>{o||y(!1)}),()=>{o=!0}},[e,o,C]);let eW=el||null!==et||null!==G||null!==Q,eF=(0,n.useCallback)(()=>{Q&&0!==Q.uploaded.length&&i?.(Q.uploaded.map(t=>ep(eu(e,t),e)))},[e,i,Q]);return(0,r.jsxs)("div",{style:{minHeight:"100%"},children:[(0,r.jsx)("input",{ref:ei,type:"file",multiple:!0,hidden:!0,onChange:eI}),eW&&(0,r.jsxs)("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:[el&&(0,r.jsxs)("div",{role:"status","aria-live":"polite","aria-label":"checking"===U?"Checking files":`Uploading, ${q}%`,children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,minHeight:14,color:"var(--text-muted)"},children:["checking"===U?(0,r.jsx)(K.y,{size:13,weight:"regular",style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true"}):(0,r.jsx)(R.C,{size:13,weight:"regular","aria-hidden":"true"}),"uploading"===U&&(0,r.jsxs)("span",{style:{fontSize:10},children:[q,"%"]})]}),"uploading"===U&&(0,r.jsx)("div",{style:{height:3,marginTop:4,overflow:"hidden",borderRadius:2,background:"var(--border)"},children:(0,r.jsx)("div",{style:{width:`${q}%`,height:"100%",background:"var(--text-muted)",transition:"width 120ms ease"}})})]}),et&&(0,r.jsxs)("div",{role:"alert",style:{padding:7,border:"1px solid color-mix(in srgb, #f59e0b 55%, var(--border))",borderRadius:4,background:"color-mix(in srgb, #f59e0b 9%, var(--bg-panel))"},children:[(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text)",lineHeight:1.35,overflowWrap:"anywhere"},children:[et.conflicts.length," file",1===et.conflicts.length?"":"s"," already exist: ",et.conflicts.join(", ")]}),et.nonReplaceable.length>0&&(0,r.jsxs)("div",{style:{marginTop:3,fontSize:10,color:"#f59e0b",lineHeight:1.35,overflowWrap:"anywhere"},children:["Cannot replace: ",et.nonReplaceable.join(", ")]}),(0,r.jsxs)("div",{style:{display:"flex",gap:5,marginTop:7},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void eR(et.files,"overwrite"),style:{height:22,padding:"0 7px",border:"1px solid #ef4444",borderRadius:4,background:"transparent",color:"#ef4444",cursor:"pointer",fontSize:10},children:"Replace"}),(0,r.jsx)("button",{type:"button",onClick:()=>void eR(et.files,"skip"),style:{height:22,padding:"0 7px",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--text)",cursor:"pointer",fontSize:10},children:"Skip existing"}),(0,r.jsx)("button",{type:"button",onClick:()=>eo(null),style:{height:22,padding:"0 7px",border:"none",borderRadius:4,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:10},children:"Cancel"})]})]}),G&&(0,r.jsxs)("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:6,fontSize:11,lineHeight:1.35,color:"#f87171"},children:[(0,r.jsx)("span",{style:{minWidth:0,flex:1,overflowWrap:"anywhere"},children:G}),(0,r.jsx)(eb,{onClick:()=>J(null),title:"Dismiss error"})]}),Q&&(0,r.jsxs)("div",{"aria-live":"polite",children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minHeight:22,fontSize:11},children:[(0,r.jsxs)("div",{style:{minWidth:0,flex:1,display:"flex",alignItems:"center",gap:8},children:[Q.uploaded.length>0&&(0,r.jsxs)("span",{title:`${Q.uploaded.length} uploaded`,"aria-label":`${Q.uploaded.length} uploaded`,style:{display:"flex",alignItems:"center",gap:3,color:"#22c55e"},children:[(0,r.jsx)(m.J,{size:13,weight:"regular","aria-hidden":"true"}),(0,r.jsx)("span",{children:Q.uploaded.length})]}),Q.skipped.length>0&&(0,r.jsxs)("span",{title:`${Q.skipped.length} skipped`,"aria-label":`${Q.skipped.length} skipped`,style:{display:"flex",alignItems:"center",gap:3,color:"var(--text-dim)"},children:[(0,r.jsx)(Y.F,{size:13,weight:"regular","aria-hidden":"true"}),(0,r.jsx)("span",{children:Q.skipped.length})]}),Q.errors.length>0&&(0,r.jsxs)("span",{title:`${Q.errors.length} failed`,"aria-label":`${Q.errors.length} failed`,style:{display:"flex",alignItems:"center",gap:3,color:"#f87171"},children:[(0,r.jsx)(X.N,{size:13,weight:"regular","aria-hidden":"true"}),(0,r.jsx)("span",{children:Q.errors.length})]})]}),Q.uploaded.length>0&&i&&(0,r.jsxs)("button",{type:"button",onClick:eF,title:1===Q.uploaded.length?"Add uploaded file to chat":"Add all uploaded files to chat","aria-label":1===Q.uploaded.length?"Add uploaded file to chat":"Add all uploaded files to chat",style:{height:22,padding:"0 7px",display:"flex",alignItems:"center",justifyContent:"center",gap:4,flexShrink:0,border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsx)(ey,{}),"mention"]}),(0,r.jsx)(eb,{onClick:()=>ee(null),title:"Dismiss upload results"})]}),Q.errors.map(e=>(0,r.jsxs)("div",{title:e.error,style:{display:"flex",alignItems:"center",gap:4,marginTop:3,minWidth:0,fontSize:10,color:"#f87171"},children:[(0,r.jsx)(Z.R,{size:11,weight:"regular",style:{flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.name))]})]}),er&&(0,r.jsxs)("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:6,padding:"6px 8px",borderBottom:"1px solid var(--border)",fontSize:11,lineHeight:1.35,color:"#f87171"},children:[(0,r.jsx)("span",{style:{minWidth:0,flex:1,overflowWrap:"anywhere"},children:er}),(0,r.jsx)(eb,{onClick:()=>en(null),title:h("files.dismissError")})]}),l&&(0,r.jsxs)("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsxs)("div",{style:{position:"relative"},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",color:"var(--text-dim)",pointerEvents:"none"},children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,r.jsx)("path",{d:"m20 20-4-4"})]}),(0,r.jsx)("input",{ref:O,value:M,onChange:e=>P(e.target.value),onKeyDown:e=>{"Escape"===e.key&&d?.(!1)},placeholder:h("sidebar.searchFilesPlaceholder"),"aria-label":h("sidebar.searchFiles"),style:{width:"100%",boxSizing:"border-box",padding:"6px 24px",border:"1px solid var(--border)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:11}}),M&&(0,r.jsx)("button",{type:"button",onClick:()=>P(""),title:h("sidebar.clearSearch"),"aria-label":h("sidebar.clearSearch"),style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"none",borderRadius:4,background:"none",color:"var(--text-dim)",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-dim)"},children:(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M18 6 6 18"}),(0,r.jsx)("path",{d:"m6 6 12 12"})]})})]}),B&&(0,r.jsxs)("div",{style:{paddingTop:3},children:[F&&(0,r.jsx)("div",{role:"status",style:{padding:"6px 2px",fontSize:10,color:"var(--text-dim)"},children:h("sidebar.searchingFiles")}),!F&&N&&(0,r.jsx)("div",{role:"alert",style:{padding:"6px 2px",fontSize:10,color:"#f87171"},children:h("i18n.networkError")}),!F&&!N&&0===E.length&&(0,r.jsx)("div",{style:{padding:"6px 2px",fontSize:10,color:"var(--text-dim)"},children:h("sidebar.noMatchingFiles")}),!F&&!N&&E.length>0&&(0,r.jsx)("div",{children:ex.map(o=>(0,r.jsx)(eC,{node:o,depth:0,cwd:e,onOpenFile:t,onAtMention:s,expandedPaths:$,onToggleExpanded:(e,t)=>{H(o=>{let r=new Set(o);return t?r.add(e):r.delete(e),r})},refreshToken:"",highlightedPaths:z,ignoredPaths:eh,changedFiles:ef,editingEnabled:ec,onCreateFile:eM,onCreateFolder:eP,onDelete:eE},`${M}:${o.fullPath}`))})]})]}),(0,r.jsxs)("div",{style:{padding:"2px 4px"},children:[v?(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"Loading files..."}):b?(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"#f87171"},children:b}):B?(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"}}):g.map(o=>(0,r.jsx)(eC,{node:o,depth:0,cwd:e,onOpenFile:t,onAtMention:s,expandedPaths:j,onToggleExpanded:eS,refreshToken:ea,highlightedPaths:z,ignoredPaths:eh,changedFiles:ef,editingEnabled:ec,onCreateFile:eM,onCreateFolder:eP,onDelete:eE},o.fullPath)),!v&&!b&&0===g.length&&(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"No files found"})]})]})}),eR={modified:"var(--git-status-modified)",added:"var(--git-status-added)",deleted:"var(--git-status-deleted)",renamed:"var(--git-status-modified)",untracked:"var(--git-status-added)",conflict:"var(--git-status-deleted)"};async function ez(e){let t=await fetch(`/api/git/status?${new URLSearchParams({cwd:e}).toString()}`);if(!t.ok)throw Error(`Failed to load Git status (HTTP ${t.status})`);return t.json()}function eI({status:e,cwd:t,onOpenFile:o}){let[s,i]=(0,n.useState)(!1),a=ep(e.filePath,t);return(0,r.jsxs)("button",{type:"button",onClick:()=>o(e.filePath,ec(e.filePath),{initialDisplayMode:"diff"}),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),title:e.filePath,style:{width:"100%",display:"flex",alignItems:"center",gap:4,padding:"0 5px",height:24,border:"none",borderRadius:4,background:s?"var(--bg-hover)":"transparent",color:"var(--text)",cursor:"pointer",textAlign:"left"},children:[(0,r.jsx)("span",{style:{width:14,flexShrink:0,color:eR[e.status],fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600,textAlign:"center"},children:e.code}),(0,r.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center",opacity:.85},children:ea(ec(e.filePath),13)}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,fontSize:12},children:a})]})}function eM({cwd:e,refreshKey:t,onOpenFile:o}){let{t:s}=(0,A.s)(),[i,a]=(0,n.useState)(!1),[l,d]=(0,n.useState)(null),[c,p]=(0,n.useState)(!1),u=(0,n.useCallback)(async()=>{p(!0);try{d(await ez(e))}catch{d(null)}finally{p(!1)}},[e]);if((0,n.useEffect)(()=>{u()},[u,t]),!l?.isGitRepository||0===l.files.length)return null;let h=l.files.reduce((e,t)=>("added"===t.status||"untracked"===t.status?e.added+=1:"deleted"===t.status||"conflict"===t.status?e.deleted+=1:e.modified+=1,e),{modified:0,added:0,deleted:0});return(0,r.jsxs)("section",{style:{flex:"0 0 auto",minHeight:0,borderTop:"1px solid var(--border)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0},children:[(0,r.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),"aria-expanded":i,style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0,padding:"6px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left"},children:[(0,r.jsx)(b.K,{size:9,weight:"regular",style:{transform:i?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s("desktop.quickChanges")})]}),(0,r.jsxs)("div",{className:"git-changes-indicator","aria-label":`Changed files: ${h.modified} modified, ${h.added} added, ${h.deleted} deleted`,children:[h.modified>0&&(0,r.jsx)("span",{className:"git-changes-indicator-part git-changes-indicator-modified",children:h.modified}),h.added>0&&(0,r.jsx)("span",{className:"git-changes-indicator-part git-changes-indicator-added",children:h.added}),h.deleted>0&&(0,r.jsx)("span",{className:"git-changes-indicator-part git-changes-indicator-deleted",children:h.deleted})]}),(0,r.jsxs)("span",{style:{marginLeft:6,color:"var(--git-status-added)",fontFamily:"var(--font-mono)",fontSize:11},children:["+",l.additions]}),(0,r.jsxs)("span",{style:{marginLeft:5,color:"var(--git-status-deleted)",fontFamily:"var(--font-mono)",fontSize:11},children:["-",l.deletions]}),(0,r.jsx)("button",{type:"button",onClick:()=>void u(),disabled:c,title:s("desktop.refresh"),"aria-label":s("desktop.refresh"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,marginLeft:4,marginRight:6,border:"none",borderRadius:5,background:"none",color:"var(--text-dim)",cursor:c?"wait":"pointer",opacity:c?.55:1},children:c?(0,r.jsx)(K.y,{size:12,style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true"}):(0,r.jsx)(C.S,{size:13,weight:"regular","aria-hidden":"true"})})]}),i&&(0,r.jsx)("div",{style:{minHeight:0,maxHeight:"min(35vh, 280px)",overflowY:"auto",overflowX:"hidden",padding:"2px 4px 4px"},children:l.files.map(t=>(0,r.jsx)(eI,{status:t,cwd:e,onOpenFile:o},t.filePath))})]})}var eP=o(76721),eE=o(61448),eW=o(95660),eF=o(59680),eD=o(20412),eA=o(12272),eN=o(9005),eL=o(31966),e$=o(47421),eH=o(14225),eO=o(8962),eB=o(65408),eU=o(75742),e_=o(73534),eq=o(6923),eV=o(64577),eK=o(32159),eG=o(30600),eJ=o(65377),eY=o(2125),eX=o(86272),eZ=o(37218),eQ=o(65738);function e0(){try{return window.localStorage}catch{return null}}let e1="pi-web:sidebar-mode",e2="pi-web:sidebar-task-preferences",e4="pi-web:sidebar-collapsed-projects",e6="projects",e8={organizeBy:"project",sortBy:"updated"};function e5(e,t=e0()){if(t)try{0===e.size?t.removeItem(e4):t.setItem(e4,JSON.stringify(Object.fromEntries([...e].map(e=>[e,!0]))))}catch{}}function e3(e,t){let o=t.trim().toLowerCase();return!o||!!(e.name||e.firstMessage?.slice(0,50)||e.id).toLowerCase().includes(o)||!!e.branch?.toLowerCase().includes(o)}function e7(e){return e.projectKey??e.projectRoot??e.cwd??""}function e9(e,t,o){return"created"===o?t.created.localeCompare(e.created):t.modified.localeCompare(e.modified)}function te(e,t={}){let{hiddenKeys:o,search:r}=t;return e.filter(e=>!(e.archived||o?.size&&o.has(e7(e)))&&e3(e,r??""))}function tt(e,t){return t.get(e.projectKey)?.latest??""}let to={pinned:"desktop.pinned",today:"desktop.today",yesterday:"desktop.yesterday",older:"desktop.older"};function tr(e){let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${o}-${r}`}function tn(e,t,o="updated"){let r=new Date,n=tr(r),s=tr(new Date(r.getTime()-864e5)),i={pinned:[],today:[],yesterday:[],older:[]};for(let t of e){let e=tr(new Date(t.modified));t.pinned&&i.pinned.push(t),e===n?i.today.push(t):e===s?i.yesterday.push(t):i.older.push(t)}return["pinned","today","yesterday","older"].map(e=>({key:e,rows:function(e,t,o,r="updated"){if(0===e.length)return[];let n=new Map(t.map(e=>[e.id,e])),s=new Set(e.map(e=>e.id)),i=new Map;for(let t of e)if(t.parentSessionId&&s.has(t.parentSessionId)){let e=i.get(t.parentSessionId)??[];e.push(t),i.set(t.parentSessionId,e)}let a=(e,t)=>e9(e,t,r),l=e.filter(e=>!(e.parentSessionId&&s.has(e.parentSessionId))).sort(a);for(let e of i.values())e.sort(a);let d=[],c=new Set,p=e=>{if(!c.has(e.id))for(let t of(c.add(e.id),d.push({session:e,forkDepth:o?0:(e=>{let t=0,o=e,r=new Set;for(;o?.parentSessionId&&!r.has(o.id);){r.add(o.id);let e=n.get(o.parentSessionId);if(!e)break;o=e,t++}return t})(e)}),i.get(e.id)??[]))p(t)};for(let e of l)p(e);for(let t of e)p(t);return d}(i[e],t,"pinned"===e,o)})).filter(e=>e.rows.length>0)}var ts=o(97320);function ti(e,t){let o=new Date(e),r=new Date().getTime()-o.getTime(),n=Math.floor(r/6e4),s=Math.floor(r/36e5),i=Math.floor(r/864e5);return n<1?t("desktop.justNow"):n<60?t("desktop.minutesAgo",{count:n}):s<24?t("desktop.hoursAgo",{count:s}):i<7?t("desktop.daysAgo",{count:i}):o.toLocaleDateString()}function ta(){let{t:e}=(0,A.s)();return(0,r.jsx)("span",{title:e("desktop.agentRunning"),"aria-label":e("desktop.agentRunningLabel"),style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"var(--accent)"},children:(0,r.jsx)(ts.A,{size:13,style:{display:"block",animation:"spin 0.9s linear infinite"},"aria-hidden":"true"})})}function tl(){let{t:e}=(0,A.s)();return(0,r.jsx)("span",{title:e("desktop.newActivity"),"aria-label":e("desktop.newSessionActivity"),style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"var(--accent)"},children:(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",style:{display:"block"},children:(0,r.jsx)("circle",{cx:"7",cy:"7",r:"3",fill:"currentColor",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"1;0.25;1",dur:"1.6s",repeatCount:"indefinite"})})})})}let td=e=>({display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,background:e?"var(--bg-selected)":"transparent",border:"none",borderRadius:5,flexShrink:0,color:e?"var(--accent)":"var(--text-muted)",cursor:"pointer",transition:"color 0.12s, background 0.12s"});function tc({sessions:e,loading:t,runningIds:o,unreadIds:s,aliases:i,selectedSessionId:a,selectedProjectRoot:l,searchQuery:d,onSearchQueryChange:c,onSelectSession:p,onNewSessionInProject:u,onArchive:h,onDeleteForever:g,onRemoveProject:m,hiddenProjects:f,onUnhideProject:x,onPickFolder:k,onCycleToList:v,onRenamed:y,onNewTask:b,renderFileTree:w,isMobile:j}){let{t:S}=(0,A.s)(),[C,T]=(0,n.useState)(()=>(function(e=e0()){if(!e)return e8;try{let t=e.getItem(e2);if(!t)return e8;let o=JSON.parse(t);if(!o||"object"!=typeof o||Array.isArray(o))return e8;let{organizeBy:r,sortBy:n}=o;return{organizeBy:"grouped"===r||"project"===r||"timeline"===r?r:e8.organizeBy,sortBy:"updated"===n||"created"===n?n:e8.sortBy}}catch{return e8}})()),[R,z]=(0,n.useState)(()=>(function(e=e0()){if(!e)return new Set;try{let t=e.getItem(e4);if(!t)return new Set;let o=JSON.parse(t);if(!o||"object"!=typeof o||Array.isArray(o))return new Set;return new Set(Object.entries(o).filter(([,e])=>!0===e).map(([e])=>e))}catch{return new Set}})()),[I,M]=(0,n.useState)(!1),[P,E]=(0,n.useState)(null),[W,F]=(0,n.useState)(!1),[D,N]=(0,n.useState)(null),[L,$]=(0,n.useState)(null),[H,O]=(0,n.useState)({}),B="detailed",U=(0,n.useRef)(null),_=(0,n.useRef)(null),[q,V]=(0,n.useState)(0);(0,n.useEffect)(()=>{let e=setInterval(()=>V(e=>e+1),6e4);return()=>clearInterval(e)},[]);let K=(0,n.useCallback)(e=>{T(t=>{let o={...t,...e};return!function(e,t=e0()){if(t)try{t.setItem(e2,JSON.stringify(e))}catch{}}(o),o})},[]),G=(0,n.useCallback)(e=>{z(t=>{let o=new Set(t);return o.has(e)?o.delete(e):o.add(e),e5(o),o})},[]),J=(0,n.useMemo)(()=>new Set(f.map(e=>e.key)),[f]),Y=(0,n.useMemo)(()=>(function(e){let{sessions:t,hiddenKeys:o,aliases:r={},sortBy:n,collapsedKeys:s,runningIds:i,unreadIds:a,search:l,extraRoots:d}=e,c=te(t,{hiddenKeys:o,search:l}),p=new Map;for(let e of c){let t=e7(e);if(!t)continue;let o=e.projectRoot??e.cwd??"",r=p.get(t);r||(r={projectRoot:o,sessions:[],latest:""},p.set(t,r)),r.sessions.push(e),e.modified>r.latest&&(r.latest=e.modified)}for(let e of d??[])!o?.has(e)&&(p.has(e)||p.set(e,{projectRoot:e,sessions:[],latest:""}));let u=[];for(let[e,t]of p){var h;t.sessions.sort((e,t)=>e9(e,t,n));let o=s?.has(e)??!1;u.push({projectKey:e,projectRoot:t.projectRoot,name:r[t.projectRoot]?.trim()||((h=t.projectRoot).replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean).pop()??h),sessions:o?[]:t.sessions,totalCount:t.sessions.length,collapsed:o,hasRunning:t.sessions.some(e=>i?.has(e.id)??!1),hasUnread:t.sessions.some(e=>a?.has(e.id)??!1)})}return u.sort((e,t)=>{let o=tt(e,p);return tt(t,p).localeCompare(o)}),u})({sessions:e,hiddenKeys:J,aliases:i,sortBy:C.sortBy,collapsedKeys:R,runningIds:o,unreadIds:s,search:d,extraRoots:l?[l]:[]}),[e,J,i,C.sortBy,R,o,s,d,l]),X=(0,n.useMemo)(()=>{var t;return te((t={sessions:e,hiddenKeys:J,sortBy:C.sortBy,search:d}).sessions,{hiddenKeys:t.hiddenKeys,search:t.search}).sort((e,o)=>e9(e,o,t.sortBy))},[e,J,C.sortBy,d]),Z=(0,n.useMemo)(()=>tn(te(e,{hiddenKeys:J,search:d}),e,C.sortBy),[e,J,d,C.sortBy,q]),Q=(0,n.useMemo)(()=>(function(e){let{sessions:t,hiddenKeys:o,search:r}=e;return t.filter(e=>!(!e.archived||o?.size&&o.has(e7(e)))&&e3(e,r??"")).sort((e,t)=>(t.archivedAt??t.modified).localeCompare(e.archivedAt??e.modified))})({sessions:e,hiddenKeys:J,search:d}),[e,J,d]);(0,n.useEffect)(()=>{if(!W&&!D)return;let e=e=>{let t=e.target;W&&!U.current?.contains(t)&&F(!1),!D||_.current?.contains(t)||t instanceof Element&&t.closest("[data-menu-trigger]")||N(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[W,D]);let ee=(0,n.useCallback)(()=>{if(R.size>0){let e=new Set;z(e),e5(e)}else{let e=new Set(Y.map(e=>e.projectKey));z(e),e5(e)}},[R,Y]),et=e=>({display:"flex",alignItems:"center",gap:3,height:22,padding:"0 7px",background:e?"var(--bg-selected)":"none",border:"none",borderRadius:11,color:e?"var(--text)":"var(--text-dim)",fontSize:11.5,fontWeight:e?600:400,cursor:"pointer",whiteSpace:"nowrap",transition:"color 0.12s, background 0.12s"}),eo=e=>{M(!1),E(null),K({organizeBy:"grouped"===e?"grouped":"timeline"===C.organizeBy?"timeline":"project"})},er=e=>H[e]??5,en=(e,t=!1,n=B)=>{let l;return(0,r.jsx)(tp,{session:e,isSelected:e.id===a,isRunning:o.has(e.id),isUnread:s.has(e.id),indent:t,forceActionsVisible:j,rowStyle:n,folderName:(l=e.projectRoot??e.cwd??"",i[l]?.trim()||l.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean).pop()||l||"?"),onSelect:()=>p(e),onArchive:()=>h(e,!0),onRenamed:y},e.id)},es=P?(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",minHeight:0,flex:1},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",flexShrink:0},children:[(0,r.jsxs)("button",{onClick:()=>E(null),style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px",background:"none",border:"none",borderRadius:6,color:"var(--text-muted)",fontSize:12,cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:[(0,r.jsx)(eL.A,{size:11,"aria-hidden":"true"}),S("desktop.backToSessions")]}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,color:"var(--text-dim)"},title:P.root,children:P.name})]}),(0,r.jsx)("div",{className:"scroll-overlay",style:{flex:1,minHeight:0,overflowX:"hidden"},children:w(P.root)})]}):I?(0,r.jsxs)("div",{style:{padding:"0 4px"},children:[0===Q.length&&(0,r.jsx)("div",{style:{padding:"16px 10px",color:"var(--text-muted)",fontSize:12},children:S(d.trim()?"desktop.noSearchResults":"desktop.noArchivedSessions")}),Q.map(e=>(0,r.jsx)(tu,{session:e,folderName:i[e.projectRoot??e.cwd]?.trim()||(e.projectRoot??e.cwd??"").replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean).pop()||e.projectRoot||e.cwd||"?",onUnarchive:()=>h(e,!1),onDeleteForever:()=>{window.confirm(S("desktop.deleteArchivedConfirm"))&&g(e)}},e.id))]}):"project"===C.organizeBy?(0,r.jsxs)("div",{style:{padding:"0 4px"},children:[(0,r.jsx)("div",{style:{padding:"6px 8px 2px",fontSize:11,fontWeight:600,color:"var(--text-dim)",letterSpacing:"0.04em"},children:S("desktop.projectSectionHeader")}),0===Y.length&&!t&&(0,r.jsx)("div",{style:{padding:"16px 10px",color:"var(--text-muted)",fontSize:12},children:S(d.trim()?"desktop.noSearchResults":"desktop.noProjects")}),Y.map(t=>{let n=er(t.projectKey),s=t.sessions.slice(0,n),i=t.sessions.length-s.length;return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{position:"relative"},onMouseEnter:()=>$(t.projectKey),onMouseLeave:()=>$(e=>e===t.projectKey?null:e),children:(0,r.jsxs)("div",{onClick:()=>G(t.projectKey),style:{display:"flex",alignItems:"center",gap:6,height:34,paddingLeft:8,paddingRight:66,cursor:"pointer",color:"var(--text)",borderRadius:6},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:[(0,r.jsx)(eP.A,{size:10,style:{transform:t.collapsed?"none":"rotate(90deg)",transition:"transform 0.15s",flexShrink:0,color:"var(--text-dim)"},"aria-hidden":"true"}),t.collapsed&&t.hasRunning?(0,r.jsx)(ta,{}):t.collapsed?(0,r.jsx)(eE.A,{size:14,style:{flexShrink:0,color:"var(--text-dim)"},"aria-hidden":"true"}):(0,r.jsx)(eW.A,{size:14,style:{flexShrink:0,color:"var(--text-dim)"},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13,fontWeight:500},title:t.projectRoot,children:t.name}),t.collapsed&&t.hasUnread&&!t.hasRunning&&(0,r.jsx)(tl,{}),(0,r.jsxs)("div",{"data-folder-actions":!0,style:{position:"absolute",right:6,top:4,display:"flex",gap:2,opacity:j||D===t.projectKey||L===t.projectKey?1:0,transition:"opacity 0.12s"},children:[(0,r.jsx)("button",{"data-menu-trigger":!0,onClick:e=>{e.stopPropagation(),N(D===t.projectKey?null:t.projectKey)},title:S("desktop.moreActions"),"aria-label":S("desktop.moreActions"),style:{...td(D===t.projectKey),width:24,height:24},children:(0,r.jsx)(eF.A,{size:14,"aria-hidden":"true"})}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),E({root:t.projectRoot,name:t.name})},title:S("desktop.viewFiles"),"aria-label":S("desktop.viewFiles"),style:{...td(!1),width:24,height:24},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(eD.A,{size:14,"aria-hidden":"true"})}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),u(t.projectRoot)},title:S("desktop.newSessionHere"),"aria-label":S("desktop.newSessionHere"),style:{...td(!1),width:24,height:24},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(eA.A,{size:14,"aria-hidden":"true"})})]}),D===t.projectKey&&(0,r.jsx)("div",{ref:_,style:{position:"absolute",right:6,top:30,zIndex:30,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.35)",padding:4,minWidth:120},children:(0,r.jsxs)("button",{onClick:()=>{N(null),(!(t.hasRunning||e.some(e=>(e.projectRoot??e.cwd)===t.projectRoot&&o.has(e.id)&&!e.archived))||window.confirm(S("desktop.removeProjectRunningConfirm")))&&m(t.projectRoot,t.name)},style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"6px 10px",background:"none",border:"none",borderRadius:6,color:"var(--text)",fontSize:12,cursor:"pointer",textAlign:"left"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:[(0,r.jsx)(eN.A,{size:12,style:{color:"var(--text-dim)"},"aria-hidden":"true"}),S("desktop.removeProject")]})})]})}),!t.collapsed&&(0,r.jsxs)("div",{children:[s.map(e=>en(e,!0,"compact")),i>0&&(0,r.jsx)("button",{onClick:()=>O(e=>({...e,[t.projectKey]:er(t.projectKey)+5})),style:{display:"block",width:"100%",padding:"5px 8px 5px 42px",background:"none",border:"none",borderRadius:6,color:"var(--text-dim)",fontSize:11,cursor:"pointer",textAlign:"left"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:S("desktop.showMore")})]})]},t.projectKey)})]}):"timeline"===C.organizeBy?(0,r.jsxs)("div",{style:{padding:"0 4px"},children:[0===X.length&&!t&&(0,r.jsx)("div",{style:{padding:"16px 10px",color:"var(--text-muted)",fontSize:12},children:S(d.trim()?"desktop.noSearchResults":"desktop.noSessionsFound")}),X.map(e=>en(e))]}):(0,r.jsxs)("div",{style:{padding:"0 4px"},children:[0===Z.length&&!t&&(0,r.jsx)("div",{style:{padding:"16px 10px",color:"var(--text-muted)",fontSize:12},children:S(d.trim()?"desktop.noSearchResults":"desktop.noSessionsFound")}),Z.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{padding:"8px 8px 2px",fontSize:11,fontWeight:600,color:"var(--text-dim)",letterSpacing:"0.04em"},children:S("pinned"===e.key?"desktop.pinned":"today"===e.key?"desktop.today":"yesterday"===e.key?"desktop.yesterday":"desktop.older")}),e.rows.map(e=>en(e.session,e.forkDepth>0))]},e.key))]});return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 0",minHeight:0,overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:2,padding:"6px 6px",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:1,background:"var(--bg-hover)",borderRadius:12,padding:2},children:[(0,r.jsxs)("button",{style:et("grouped"===C.organizeBy),onClick:()=>eo("grouped"),"aria-pressed":"grouped"===C.organizeBy,children:[(0,r.jsx)(e$.A,{size:11,style:{opacity:.7},"aria-hidden":"true"}),S("desktop.panelGroupBubble")]}),(0,r.jsxs)("button",{style:et("grouped"!==C.organizeBy),onClick:()=>eo("project"),"aria-pressed":"grouped"!==C.organizeBy,children:[(0,r.jsx)(eH.A,{size:11,"aria-hidden":"true"}),S("desktop.panelProjectBubble")]})]}),(0,r.jsx)("button",{onClick:ee,title:R.size>0?S("desktop.expandAllFolders"):S("desktop.collapseAllFolders"),"aria-label":R.size>0?S("desktop.expandAllFolders"):S("desktop.collapseAllFolders"),style:{...td(!1),marginLeft:2},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:R.size>0?(0,r.jsx)(eO.A,{size:13,"aria-hidden":"true"}):(0,r.jsx)(eB.A,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("button",{onClick:v,title:`${S("desktop.sidebarModeCycle")}:${S("desktop.sessionViewList")}`,"aria-label":S("desktop.sidebarModeCycle"),style:{...td(!1),marginLeft:2},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(eU.A,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("div",{style:{flex:1}}),(0,r.jsxs)("div",{ref:U,style:{position:"relative"},children:[(0,r.jsx)("button",{onClick:()=>F(e=>!e),title:S("desktop.filterMenu"),"aria-label":S("desktop.filterMenu"),"aria-expanded":W,style:td(W),onMouseEnter:e=>{W||(e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{W||(e.currentTarget.style.color="var(--text-muted)")},children:(0,r.jsx)(e_.A,{size:13,"aria-hidden":"true"})}),W&&(0,r.jsxs)("div",{style:{position:"absolute",right:0,top:28,zIndex:40,width:168,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.4)",padding:5},children:[(0,r.jsx)("div",{style:{padding:"6px 8px 2px",fontSize:11,fontWeight:600,color:"var(--text-dim)"},children:S("desktop.viewSection")}),[["project","desktop.viewByProject",eH.A],["timeline","desktop.viewTimeline",eq.A]].map(([e,t,o])=>(0,r.jsxs)("button",{onClick:()=>{K({organizeBy:e})},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 7px",background:"none",border:"none",borderRadius:6,color:"var(--text)",fontSize:11.5,cursor:"pointer",textAlign:"left"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:[(0,r.jsx)(o,{size:13,style:{color:"var(--text-dim)",flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{flex:1},children:S(t)}),C.organizeBy===e&&(0,r.jsx)(eV.A,{size:13,strokeWidth:2.5,style:{color:"var(--accent)"},"aria-hidden":"true"})]},e)),(0,r.jsx)("div",{style:{height:1,background:"var(--border)",margin:"6px 4px"}}),(0,r.jsx)("div",{style:{padding:"2px 8px",fontSize:11,fontWeight:600,color:"var(--text-dim)"},children:S("desktop.sortSection")}),[["updated","desktop.sortUpdated"],["created","desktop.sortCreated"]].map(([e,t])=>(0,r.jsxs)("button",{onClick:()=>{K({sortBy:e})},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 7px",background:"none",border:"none",borderRadius:6,color:"var(--text)",fontSize:11.5,cursor:"pointer",textAlign:"left"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:[(0,r.jsx)("span",{style:{flex:1},children:S(t)}),C.sortBy===e&&(0,r.jsx)(eV.A,{size:13,strokeWidth:2.5,style:{color:"var(--accent)"},"aria-hidden":"true"})]},e)),(0,r.jsx)("div",{style:{height:1,background:"var(--border)",margin:"6px 4px"}}),(0,r.jsx)("div",{style:{padding:"2px 8px",fontSize:11,fontWeight:600,color:"var(--text-dim)"},children:S("desktop.hiddenProjectsSection")}),0===f.length?(0,r.jsx)("div",{style:{padding:"4px 8px 8px",fontSize:11,color:"var(--text-dim)"},children:S("desktop.noHiddenProjects")}):f.map(e=>(0,r.jsxs)("button",{onClick:()=>{F(!1),x(e)},title:e.path,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 8px",background:"none",border:"none",borderRadius:6,color:"var(--text)",fontSize:12,cursor:"pointer",textAlign:"left"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:[(0,r.jsx)(eH.A,{size:13,style:{color:"var(--text-dim)",flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name||e.path}),(0,r.jsx)("span",{style:{fontSize:11,color:"var(--accent)",flexShrink:0},children:S("desktop.restoreProject")})]},e.key))]})]}),(0,r.jsx)("button",{onClick:()=>{M(e=>!e),E(null)},title:S("desktop.archivedView"),"aria-label":S("desktop.archivedView"),"aria-pressed":I,style:td(I),onMouseEnter:e=>{I||(e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{I||(e.currentTarget.style.color="var(--text-muted)")},children:I?(0,r.jsx)(eN.A,{size:13,"aria-hidden":"true"}):(0,r.jsx)(eK.A,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("button",{onClick:k,title:S("desktop.selectFolder"),"aria-label":S("desktop.selectFolder"),style:{...td(!1),marginRight:2},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(eG.A,{size:13,"aria-hidden":"true"})})]}),j&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"0 8px 6px",flexShrink:0},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,background:"var(--bg-hover)",borderRadius:8,padding:"0 9px",height:30},children:[(0,r.jsx)(eJ.A,{size:13,color:"var(--text-dim)",style:{flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("input",{value:d,onChange:e=>c(e.target.value),placeholder:I?S("desktop.searchArchived"):S("desktop.searchSessions"),"aria-label":I?S("desktop.searchArchived"):S("desktop.searchSessions"),style:{flex:1,minWidth:0,background:"none",border:"none",outline:"none",color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)"}}),d&&(0,r.jsx)("button",{onClick:()=>c(""),"aria-label":S("i18n.close"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:4,flexShrink:0},children:(0,r.jsx)(eN.A,{size:11,"aria-hidden":"true"})})]}),(0,r.jsxs)("button",{onClick:b,title:S("desktop.newTask"),"aria-label":S("desktop.newTask"),style:{display:"flex",alignItems:"center",gap:4,flexShrink:0,height:30,padding:"0 10px",background:"var(--bg-selected)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:12,fontWeight:500,whiteSpace:"nowrap",cursor:"pointer"},children:[(0,r.jsx)(eY.A,{size:13,"aria-hidden":"true"}),S("desktop.newTask")]})]}),t&&0===e.length&&(0,r.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:S("desktop.loading")}),(0,r.jsx)("div",{className:"scroll-overlay",style:{flex:"1 1 0",minHeight:0},children:es})]})}function tp({session:e,isSelected:t,isRunning:o,isUnread:s,indent:i,forceActionsVisible:a,rowStyle:l,folderName:p,onSelect:u,onArchive:h,onRenamed:g}){let{t:m}=(0,A.s)(),[f,x]=(0,n.useState)(!1),[k,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(!1),[w,j]=(0,n.useState)(null),S=(0,n.useRef)(null),C=e.name||e.firstMessage?.slice(0,50)||e.id,T=e.messageCount>0,R=(0,n.useCallback)(async t=>{if(t.stopPropagation(),y){S.current?.abort(),c(e.id);return}if(!T)return;let o=new AbortController;S.current=o,b(!0),j(null);try{await d(e.id,o.signal),g()}catch(e){o.signal.aborted||j(e instanceof Error?e.message:String(e))}finally{S.current===o&&(S.current=null),b(!1)}},[y,T,e.id,g]);if(k)return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,height:30,paddingLeft:i?42:10,paddingRight:6,background:"rgba(239,68,68,0.06)",borderRadius:6},children:[(0,r.jsx)("span",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m("desktop.archiveSessionConfirm",{title:`“${C.slice(0,18)}${C.length>18?"…":""}”`})}),(0,r.jsxs)("button",{onClick:()=>{v(!1),h()},style:{display:"flex",alignItems:"center",gap:4,height:24,padding:"0 9px",background:"#ef4444",border:"none",borderRadius:5,color:"#fff",fontSize:11,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap"},children:[(0,r.jsx)(eK.A,{size:11,"aria-hidden":"true"}),m("desktop.archiveSession")]}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),v(!1)},style:{height:24,padding:"0 9px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",fontSize:11,cursor:"pointer",whiteSpace:"nowrap"},children:m("desktop.cancel")})]});let z=(0,r.jsxs)("div",{style:{display:"flex",gap:2,flexShrink:0},children:[(0,r.jsx)("button",{onClick:R,disabled:!T,title:w??m(T?y?"desktop.generatingTitle":"desktop.generateTitle":"desktop.titleNeedsMessages"),"aria-label":m("desktop.generateTitle"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,background:"none",border:"none",borderRadius:4,color:w?"#ef4444":"var(--text-dim)",cursor:T?"pointer":"default",flexShrink:0,opacity:y?.7:T?1:.35,transition:"color 0.12s"},onMouseEnter:e=>{!y&&T&&(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{e.currentTarget.style.color=w?"#ef4444":"var(--text-dim)"},children:y?(0,r.jsxs)("svg",{style:{animation:"spin 1s linear infinite"},width:"13",height:"13",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),(0,r.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}):(0,r.jsx)(eX.A,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),v(!0)},title:m("desktop.archiveSession"),"aria-label":m("desktop.archiveSession"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,background:"none",border:"none",borderRadius:4,color:"var(--text-dim)",cursor:"pointer",flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:(0,r.jsx)(eK.A,{size:13,"aria-hidden":"true"})})]}),I=f||a,M=o?(0,r.jsx)(ta,{}):s?(0,r.jsx)(tl,{}):null;return(0,r.jsxs)("div",{onClick:u,onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),style:{position:"relative",padding:`${5*("detailed"===l)}px 6px ${5*("detailed"===l)}px ${i?42:18}px`,height:"detailed"===l?46:30,display:"flex",flexDirection:"column",justifyContent:"center",cursor:"pointer",borderRadius:6,background:t?"var(--bg-selected)":f?"var(--bg-hover)":"transparent",borderLeft:t?"2px solid var(--accent)":"2px solid transparent"},title:C,children:[M&&i&&(0,r.jsx)("span",{style:{position:"absolute",left:22,top:0,bottom:0,display:"flex",alignItems:"center"},children:M}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[M&&!i&&M,(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12.5,color:"var(--text)",fontWeight:t?500:400},children:C}),I?z:(0,r.jsx)("span",{style:{flexShrink:0,fontSize:11,color:"var(--text-dim)",whiteSpace:"nowrap"},children:ti(e.modified,m)})]}),"detailed"===l&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:2,minWidth:0},children:[(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11,color:"var(--text-dim)"},title:e.projectRoot??e.cwd,children:p}),I&&(0,r.jsx)("span",{style:{flexShrink:0,fontSize:11,color:"var(--text-dim)",whiteSpace:"nowrap"},children:ti(e.modified,m)})]})]})}function tu({session:e,folderName:t,onUnarchive:o,onDeleteForever:s}){let{t:i}=(0,A.s)(),[a,l]=(0,n.useState)(!1),d=e.name||e.firstMessage?.slice(0,50)||e.id;return(0,r.jsxs)("div",{onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{padding:"6px 10px",borderRadius:6,background:a?"var(--bg-hover)":"transparent"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12.5,color:"var(--text)"},title:d,children:d}),(0,r.jsx)("span",{style:{flexShrink:0,fontSize:11,color:"var(--text-dim)"},children:ti(e.archivedAt??e.modified,i)})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:2},children:[(0,r.jsx)(eH.A,{size:12,style:{color:"var(--text-dim)",flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11,color:"var(--text-dim)"},title:e.projectRoot??e.cwd,children:t}),(0,r.jsx)("button",{onClick:o,title:i("desktop.unarchiveSession"),"aria-label":i("desktop.unarchiveSession"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,background:"none",border:"none",borderRadius:4,color:"var(--text-dim)",cursor:"pointer",flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:(0,r.jsx)(eZ.A,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("button",{onClick:s,title:i("desktop.deleteForever"),"aria-label":i("desktop.deleteForever"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,background:"none",border:"none",borderRadius:4,color:"#ef4444",cursor:"pointer",flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color="#f87171"},onMouseLeave:e=>{e.currentTarget.style.color="#ef4444"},children:(0,r.jsx)(eQ.A,{size:13,"aria-hidden":"true"})})]})]})}let th="pi-web:file-explorer:open";function tg(){try{return window.localStorage}catch{return null}}var tm=o(79617),tf=o(87358);function tx(e){return e&&"win32"===tf.platform?(0,tm.normalize)(e):e}function tk(e,t){return e===t||!!e&&!!t&&"win32"===tf.platform&&tx(e).toLowerCase()===tx(t).toLowerCase()}let tv="normal",ty="full",tb="auto";function tw(e){return"normal"===e||"plan"===e||"goal"===e?e:tv}function tj(e){return"economy"===e||"delivery"===e||"full"===e?e:ty}function tS(e){return"ask"===e||"auto"===e||"yolo"===e?e:tb}let tC=["bash","edit","edit_file","grep","find","kill_shell","ls","read","update_goal","wait","write","write_file"],tT=`You are in PLAN MODE. Work as a read-only planning assistant.
|
|
2
2
|
- Analyze, read, search and reason about the codebase; do NOT modify any files.
|
|
3
3
|
- Do NOT run shell commands that mutate state, install packages, or start servers.
|
|
4
4
|
- When you have enough understanding, produce a concrete, step-by-step implementation plan.
|
|
@@ -33,8 +33,8 @@ ${e}`;(0,n.useEffect)(()=>{t||l(!0)},[t]),(0,n.useEffect)(()=>{if(!a||t)return;l
|
|
|
33
33
|
|
|
34
34
|
Goal: ${o}`:tI)}return t.join("\n\n")}({collaborationMode:eC.current,tokenMode:eT.current,goalText:"goal"===eC.current?eI.current??void 0:void 0}),c=d||!em.current||a?"":ao,p=d||c,h=[eC.current,eT.current,em.current?"legacy-plan":"",p?String(p.length):""].join("|"),g=t?.id??"new";p&&(eM.current.sessionKey!==g||eM.current.signature!==h)?(eM.current={sessionKey:g,signature:h},s=`${p}
|
|
35
35
|
|
|
36
|
-
${o}`):s=o;let m=s,f=n?.map(e=>({type:"image",source:{type:"base64",media_type:e.mimeType,data:e.data}})),x={role:"user",content:f?.length?[...o.trim()?[{type:"text",text:o}]:[],...f]:o,timestamp:Date.now()};T(e=>[...e,x]),oo.current=ac(x),ot.current=l,"goal"!==eC.current||a||(eI.current=i,eA(e=>({...e,status:"running",goalText:i,turnsUsed:0,noProgressTurns:0,tokensUsed:0})),eL.current=!0),tq.current=!0,U(!0),e5(a?{kind:"running_command"}:{kind:"waiting_model"}),F({type:"start"}),t2.current=!0,e7(!0),t4.current=!0;let k=n?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType})),v=null,y=!1;try{if(u&&r){let e=t_.current??await t9.current,t=e??await ow();if(t){v=t,ob(1,o),ei&&(eZ(ei),e&&await i6(t,{type:"set_model",provider:ei.provider,modelId:ei.modelId}));let r=await Promise.race([oR(t).then(()=>!0).catch(()=>!1),ai(4e3).then(()=>!1)]);y=!0,await i6(t,{type:"prompt",message:m,...k?.length?{images:k}:{}}),r||oL(t,l),"goal"!==eC.current||a||i6(t,{type:"goal_start",goalText:i}).catch(()=>{})}else throw Error("Unable to create a session for this message")}else if(t){v=t.id;let e=await Promise.race([oR(t.id).then(()=>!0).catch(()=>!1),ai(4e3).then(()=>!1)]);y=!0,await i6(t.id,{type:"prompt",message:m,...k?.length?{images:k}:{}}),e||oL(t.id,l),"goal"!==eC.current||a||i6(t.id,{type:"goal_start",goalText:i}).catch(()=>{})}a&&v&&oL(v,l)}catch(t){if(console.error("Failed to send message:",t),y&&v)return void oL(v,l);if(tK.current=!1,oC(),t instanceof as){let e=oo.current;e&&T(t=>{let o=t[t.length-1];return o?.role==="user"&&ac(o)===e?t.slice(0,-1):t}),oM({type:"error",message:t.message})}else{let o=oo.current;o&&T(e=>{let t=e[e.length-1];return t?.role==="user"&&ac(t)===o?e.slice(0,-1):e}),e.chatInputRef?.current?.replaceMessage?.(x),oM({type:"error",message:`Failed to send message: ${t instanceof Error?t.message:String(t)}`})}oo.current=null,tq.current=!1,U(!1),e5(null),F({type:"end"})}},[u,r,ei,t,ow,oR,ob,oL,oM,oS,oC,oc]),oU=(0,n.useCallback)(async(o,r)=>{if(tq.current||tX.current)return;let n=`${r?"!!":"!"}${o}`;tX.current=!0,K({command:o,excludeFromContext:r}),q(!0);try{let e=t_.current??t?.id??await ow();if(!e)throw Error("Unable to create a session for the shell command");ob(1,n),await i6(e,{type:"bash",command:o,excludeFromContext:r}),await ok(e)}catch(t){console.error("Failed to execute shell command:",t),oM({type:"error",message:t instanceof Error?t.message:String(t)}),e.chatInputRef?.current?.insertIfEmpty(n)}finally{tX.current=!1,K(null),q(!1)}},[oM,ow,ok,e.chatInputRef,ob,t]),o_=(0,n.useCallback)(async()=>{let e=t_.current;if(e)try{await i6(e,{type:tX.current?"abort_bash":"abort"})}catch(e){console.error("Failed to abort:",e)}},[]),oq=(0,n.useCallback)(async e=>{let t=t_.current;if(t){eG(e);try{let{cancelled:o,newSessionId:r}=await i6(t,{type:"fork",entryId:e})??{};!o&&r&&a?.(r)}catch(e){console.error("Fork failed:",e)}finally{eG(null)}}},[a]),oV=(0,n.useCallback)(async e=>{let t=t_.current;t&&(i6(t,{type:"navigate_tree",targetId:e}).catch(()=>{}),S(e),await ov(t,e))},[ov]),oK=(0,n.useCallback)(async e=>{S(e);let t=t_.current;t&&(await ov(t,e),e&&i6(t,{type:"navigate_tree",targetId:e}).catch(()=>{}))},[ov]),oG=(0,n.useCallback)(async(e,t)=>{if(u){let o={provider:e,modelId:t};oa.current=o,ea(o),eZ(o);let r=t_.current??await t9.current;if(!r)return;try{await i6(r,{type:"set_model",provider:e,modelId:t})}catch(e){console.error("Failed to set model:",e)}return}let o=t_.current;if(!o)return;let r=++or.current,n=eJ??g?.context.model??null;eY({provider:e,modelId:t});try{await i6(o,{type:"set_model",provider:e,modelId:t})}catch(o){console.error("Failed to set model:",o),or.current===r&&(eY(n&&(n.provider!==e||n.modelId!==t)?n:null),oM({type:"error",message:o instanceof Error?o.message:String(o)}))}},[oM,eJ,g?.context.model,u,ea]),oJ=(0,n.useCallback)(async()=>{let e=t_.current;if(e&&!eQ){e0(!0),e2(null),e6(null);try{let t=await i6(e,{type:"compact"});e6(ap(t,"manual")),await ok(e,!0)}catch(e){e2(e instanceof Error?e.message:String(e)),e6(null)}finally{e0(!1)}}},[eQ,ok]),oY=(0,n.useCallback)(async e=>{let o=++on.current,n=r??t?.cwd??"",s=n?`/api/models?cwd=${encodeURIComponent(n)}`:"/api/models",i=os.current;i?.abort();let a=new AbortController;os.current=a;let l=()=>a.abort();e?.aborted?a.abort():e?.addEventListener("abort",l,{once:!0});try{let e=await fetch(s,{signal:a.signal});if(!e.ok){let t=`HTTP ${e.status}`;try{let o=await e.json();o?.error&&(t=o.error)}catch{}throw Error(t)}let t=await e.json();if(o!==on.current||h!==oi.current)return;es(null),J(t.models),Q(t.thinkingLevels??{}),et(t.thinkingLevelMaps??{}),er(t.modelScopeWarnings??[]);let r=t.modelList??[];if(X(r),u&&!t_.current){let e=(t.defaultModel?r.find(e=>e.id===t.defaultModel?.modelId&&e.provider===t.defaultModel?.provider):void 0)??r[0];ed(e?{provider:e.provider,modelId:e.id}:null);let o=e?t.thinkingLevelPins?.[`${e.provider}/${e.id}`]:void 0;null===ol.current&&eH(o??"auto")}}catch(e){if(a.signal.aborted||o!==on.current||h!==oi.current)return;es(e instanceof Error?e.message:String(e))}finally{e?.removeEventListener("abort",l),os.current===a&&(os.current=null)}},[u,h,r,t?.cwd]),oX=(0,n.useCallback)(async e=>{if(!e.startsWith("/"))return{handled:!1};let t=e.match(/^\/([^\s]+)(?:\s+([\s\S]*))?$/);if(!t)return{handled:!1};let[,o,r=""]=t,n=r.trim(),s=t_.current??await ow(),i=e=>(e.handled&&(e.error?oM({type:"error",message:e.error}):"openSessionStats"!==e.action&&oM({type:"success",message:e.message??"Command completed"})),e);try{switch(o){case"compact":{if(!s||eQ)return i({handled:!0,error:"No active session to compact"});e0(!0),e2(null),e6(null);let e=await i6(s,{type:"compact",...n?{customInstructions:n}:{}});return e6(ap(e,"manual")),await ok(s,!0)&&ob(),i({handled:!0,message:"Compacted context"})}case"reload":if(!s)return i({handled:!0,error:"No active session to reload"});return await i6(s,{type:"reload"}),await Promise.all([ok(s,!1,!0),oy(s),oj(),oY()]),i({handled:!0,message:"Reloaded session resources"});case"name":if(!s)return i({handled:!0,error:"No active session to name"});if(!n)return i({handled:!0,error:"Usage: /name <name>"});return await i6(s,{type:"set_session_name",name:tM(n)}),await ok(s)&&ob(),i({handled:!0,message:`Session renamed to ${n}`});case"session":{if(!s)return i({handled:!0,error:"No active session"});let e=await i6(s,{type:"get_session_stats"});return e&&ti(e),p?.(),i({handled:!0,action:"openSessionStats"})}case"copy":{if(!s)return i({handled:!0,error:"No active session"});let e=await i6(s,{type:"get_last_assistant_text"}),t=e?.text??"";if(!t)return i({handled:!0,error:"No assistant message to copy"});return await navigator.clipboard.writeText(t),i({handled:!0,message:"Copied last assistant message"})}default:return{handled:!1}}}catch(e){return i({handled:!0,error:e instanceof Error?e.message:String(e)})}finally{"compact"===o&&e0(!1)}},[oM,ow,eQ,oY,ok,oj,oy,ob,p]),oZ=(0,n.useCallback)(async e=>{let t=!1;try{let o=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(o.ok){let e=await o.json(),r=e.state;if(e.running&&r&&(r.isStreaming||r.isPromptRunning||r.isBashRunning||r.isCompacting))return;t=!0}}catch{}t?oF():oL(e)},[oL,oF]),oQ=(0,n.useCallback)(async(e,t)=>{let o=t_.current;if(!o)return;let r=t?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));tq.current=!0,U(!0),e5(e=>e??{kind:"waiting_model"});try{await i6(o,{type:"steer",message:e,...r?.length?{images:r}:{}})}catch(e){console.error("Failed to steer:",e),oZ(o)}},[oZ]),o0=(0,n.useCallback)(async(e,t,o)=>{let r=t_.current;if(!r)return;let n=o?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));tq.current=!0,U(!0),e5(e=>e??{kind:"waiting_model"});try{await i6(r,{type:"prompt",message:e,streamingBehavior:t,...n?.length?{images:n}:{}})}catch(e){console.error("Failed to queue prompt:",e),oZ(r)}},[oZ]),o1=(0,n.useCallback)(async(e,t)=>{let o=t_.current;if(!o)return;let r=t?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));tq.current=!0,U(!0),e5(e=>e??{kind:"waiting_model"});try{await i6(o,{type:"follow_up",message:e,...r?.length?{images:r}:{}})}catch(e){console.error("Failed to follow up:",e),oZ(o)}},[oZ]),o2=(0,n.useCallback)(async()=>{let e=t_.current;if(e)try{await i6(e,{type:"abort_compaction"})}catch(e){console.error("Failed to abort compaction:",e)}},[]),o4=(0,n.useCallback)(async()=>{let t=t_.current;if(t)try{let o=await i6(t,{type:"clear_queue"});tx({steering:[],followUp:[]});let r=[...o?.steering??[],...o?.followUp??[]];r.length>0&&e.chatInputRef?.current?.prependText(r.join("\n\n"))}catch(e){console.error("Failed to recall queued messages:",e),oM({type:"error",message:"Failed to recall queued messages"})}},[e.chatInputRef,oM,tx]);(0,n.useEffect)(()=>{0===tk.length&&tF(!1)},[tk.length]);let o6=(0,n.useCallback)(async(e,t,o=!1)=>{let r=t_.current;if(!r)return tk;try{let n=await i6(r,{type:"resolve_recovery",keep:e,discard:t,continueRun:o}),s=n?.remaining??[];return tE(s),o&&e.length>0&&(async()=>{try{let e=await fetch(`/api/agent/${encodeURIComponent(r)}`);if(!e.ok)return;let t=await e.json(),o=t.state;if(!t.running||!o||!o.isStreaming&&!o.isPromptRunning)return;tV.current=!!o.isStreaming,tK.current=!!o.isPromptRunning,tq.current=!0,U(!0),e5(i9(o)),F({type:"start"}),oT(r),!o.isStreaming&&o.isPromptRunning&&oL(r)}catch{}})(),s}catch(e){return console.error("Failed to resolve queued message recovery:",e),oM({type:"error",message:"Failed to resolve queued message recovery"}),tk}},[tk,oM,oT,oL,tE]),o8=(0,n.useCallback)(async()=>{let e=t_.current;if(!e)return null;try{return await i6(e,{type:"export_queue"})}catch(e){return console.error("Failed to export queue:",e),oM({type:"error",message:"Failed to export queue"}),null}},[oM]),o5=(0,n.useCallback)(async e=>{let t=t_.current;if(!t)return null;try{let o=await i6(t,{type:"import_queue",entries:e});return o&&tx(at(o)),o?.imported??0}catch(e){return console.error("Failed to import queue:",e),oM({type:"error",message:"Failed to import queue"}),null}},[oM,tx]),o3=(0,n.useCallback)(async e=>{let t=t_.current;if(!t)return null;try{let o=await i6(t,{type:"stage_recovery",entries:e});return o?.pendingRecovery&&tE(o.pendingRecovery),(o?.staged??0)>0&&tF(!0),o?.staged??0}catch(e){return console.error("Failed to stage imported queue:",e),oM({type:"error",message:"Failed to stage imported queue"}),null}},[oM,tE]),o7=(0,n.useCallback)(async(e,t,o)=>{let r=t_.current;if(!r)return!1;try{let n=await i6(r,{type:"move_queue",kind:e,fromIndex:t,toIndex:o});return n&&tx(at(n)),!0}catch(e){return console.error("Failed to move queued message:",e),oM({type:"error",message:e instanceof Error?e.message:"Failed to move queued message"}),!1}},[oM,tx]),o9=(0,n.useCallback)(async(e,t)=>{let o=t_.current;if(!o)return null;try{let r=await i6(o,{type:"recall_queue_item",kind:e,index:t});return r&&(void 0!==r.steering||void 0!==r.followUp)&&tx(at(r)),r?.entry?{text:r.entry.text,images:r.entry.images?.map(({data:e,mimeType:t})=>({data:e,mimeType:t}))}:null}catch(e){return console.error("Failed to recall queued message:",e),oM({type:"error",message:e instanceof Error?e.message:"Failed to recall queued message"}),null}},[oM,tx]),re=(0,n.useCallback)(async(e,t,o,r)=>{let n=t_.current;if(!n)return!1;try{let s=await i6(n,{type:"requeue_at",kind:e,index:t,text:o,images:r?.map(({data:e,mimeType:t})=>({type:"image",data:e,mimeType:t}))});return s&&tx(at(s)),!0}catch(e){return console.error("Failed to requeue message:",e),oM({type:"error",message:e instanceof Error?e.message:"Failed to requeue message"}),!1}},[oM,tx]),rt=(0,n.useCallback)(async(e,t)=>{let o=t_.current;if(!o)return!1;try{let r=await i6(o,{type:"remove_queue_item",kind:e,index:t});return r&&tx(at(r)),!0}catch(e){return console.error("Failed to remove queued message:",e),oM({type:"error",message:e instanceof Error?e.message:"Failed to remove queued message"}),!1}},[oM,tx]),ro=(0,n.useCallback)(async e=>{if(ol.current="auto"===e?null:e,eH(e),"auto"===e)return;let t=t_.current??await t9.current;if(t)try{await i6(t,{type:"set_thinking_level",level:e})}catch(e){console.error("Failed to set thinking level:",e)}},[]),rr=(0,n.useCallback)(async e=>{let t=(0,i8.xG)(e);ou(e);let o=t_.current??await t9.current;if(o)try{await i6(o,{type:"set_tools",toolNames:t})}catch(e){console.error("Failed to set tools:",e)}},[ou]),rn=(0,n.useRef)(0),rs=(0,n.useCallback)(async e=>{let t=t_.current??await t9.current,o=++rn.current;if(e){if(eg.current="plan"===ec?"default":ec,eh(!0),em.current=!0,eM.current={sessionKey:"",signature:""},t)try{if(await i6(t,{type:"prompt",message:"/plan"}),rn.current!==o)return}catch(e){if(rn.current!==o)return;console.error("Failed to enter plan mode:",e)}}else if(eh(!1),em.current=!1,eM.current={sessionKey:"",signature:""},t){try{if(await i6(t,{type:"prompt",message:"/plan exit"}),rn.current!==o)return}catch(e){if(rn.current!==o)return;console.error("Failed to exit plan mode:",e)}if(rn.current!==o)return;try{let e=eg.current;await i6(t,{type:"set_tools",toolNames:(0,i8.xG)(e)})}catch(e){console.error("Failed to restore tools after plan exit:",e)}}},[ec]),ri=(0,n.useCallback)(e=>{ex(e);let t=t_.current;if(!t){ek.current=e;return}ek.current=null,fetch(`/api/modes?session=${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(e=>{console.error("Failed to persist mode settings:",e)})},[]),ra=(0,n.useCallback)(e=>{if(ri({...eP.current,collaborationMode:tw(e)}),eC.current=tw(e),eM.current={sessionKey:"",signature:""},"goal"!==e){eI.current=null,eL.current=!1,eA(e=>"idle"===e.status?e:{...e,status:"idle",goalText:null});let e=t_.current;e&&i6(e,{type:"goal_stop"}).catch(()=>{})}},[ri]),rl=(0,n.useCallback)(async e=>{ri({...eP.current,tokenMode:tj(e)});let t=t_.current??await t9.current;if(t)try{if("economy"!==e||em.current){if("economy"!==e){let e=em.current?i8.SC:(0,i8.xG)("plan"===ec?"default":ec);await i6(t,{type:"set_tools",toolNames:e})}}else await i6(t,{type:"set_tools",toolNames:[...tC]})}catch(e){console.error("Failed to apply token mode tools:",e)}},[ri,ec]),rd=(0,n.useCallback)(async e=>{ri({...eP.current,toolApprovalMode:tS(e)});let t=t_.current??await t9.current;if(t)try{await i6(t,{type:"set_approval_mode",mode:tS(e)})}catch(e){console.error("Failed to apply approval mode:",e)}},[ri]),rc=(0,n.useCallback)(async e=>{ri({...eP.current,permissionRules:e});let t=t_.current??await t9.current;if(t)try{await i6(t,{type:"set_approval_policy",policy:e})}catch(e){console.error("Failed to apply permission rules:",e)}},[ri]),rp=(0,n.useCallback)(async(e,t,o)=>{let r=t_.current;if(r)try{await i6(r,{type:"resolve_approval",id:e,approve:t,reason:o})}catch(e){console.error("Failed to resolve approval:",e)}finally{eW(t=>t.filter(t=>t.id!==e))}},[]),ru=(0,n.useCallback)(e=>{eI.current=e},[]),rh=(0,n.useCallback)(e=>{let t=e.trim();if(!t)return;eI.current=t,eA(e=>({...e,status:"running",goalText:t,turnsUsed:0,noProgressTurns:0,tokensUsed:0,startedAt:Date.now()}));let o=t_.current;o&&i6(o,{type:"goal_start",goalText:t}).catch(()=>{})},[]),rg=(0,n.useCallback)(()=>{if("running"!==eN.current.status)return;eA(e=>({...e,status:"paused"}));let e=t_.current;e&&i6(e,{type:"goal_pause"}).catch(()=>{})},[]),rm=(0,n.useCallback)(()=>{let e=eN.current;if("paused"!==e.status&&"blocked"!==e.status)return;eA(e=>({...e,status:"running"}));let t=t_.current;t&&i6(t,{type:"goal_resume"}).catch(()=>{})},[]),rf=(0,n.useCallback)(()=>{eL.current=!1,eI.current=null,eA(e=>({...e,status:"idle",goalText:null,turnsUsed:0,noProgressTurns:0}));let e=t_.current;e&&i6(e,{type:"goal_stop"}).catch(()=>{})},[]),rx=(0,n.useCallback)(e=>{let t=e.trim();if(!t)return;eA(e=>({...e,goalText:t}));let o=t_.current;o&&i6(o,{type:"goal_edit",goalText:t}).catch(()=>{})},[]),rk=(0,n.useCallback)(()=>{let e=t7.current,t=t1.current;if(!e||!t)return;let o=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,r=Math.max(0,e.scrollHeight-e.clientHeight),n=Math.min(Math.max(0,o-16),r);t6.current=n>=r-150,t5.current=Date.now()+700,e.scrollTo({top:n,behavior:"smooth"})},[]),rv=(0,n.useCallback)(e=>{if(e instanceof KeyboardEvent){if(!an.has(e.key)||e.target instanceof Element&&e.target.closest("input, textarea, [contenteditable='true']"))return}else if(e instanceof PointerEvent){let t=t7.current;if(t&&e.target instanceof Element&&!t.contains(e.target))return}t8.current=Date.now()+1200},[]),ry=(0,n.useCallback)(()=>{let e=t7.current;if(e){let{scrollTop:t,clientHeight:o,scrollHeight:r}=e;t6.current=t+o>=r-150}if(Date.now()<t8.current){t4.current=!1;return}Date.now()<t5.current||(t4.current=!1)},[]);(0,n.useEffect)(()=>{if(tJ.current=!0,t){t_.current=t.id;let e=eR.current,o=ez.current;("auto"!==e||o.allow.length||o.ask.length||o.deny.length)&&(i6(t.id,{type:"set_approval_mode",mode:e}).catch(()=>{}),i6(t.id,{type:"set_approval_policy",policy:o}).catch(()=>{}));let r=e=>{!tZ.current&&(tZ.current=!0,e.isBashRunning&&(tX.current=!0,q(!0)),oy(t.id),(e.isStreaming||e.isPromptRunning)&&(tV.current=!!e.isStreaming,tK.current=!!e.isPromptRunning,tq.current=!0,U(!0),e5(i9(e)),F({type:"start"}),oT(t.id),!e.isStreaming&&e.isPromptRunning&&oL(t.id)))};(async()=>{try{let e,o=new AbortController,n=setTimeout(()=>o.abort(),2e4);try{e=await fetch(`/api/sessions/${encodeURIComponent(t.id)}/state`,{signal:o.signal})}finally{clearTimeout(n)}if(!e.ok)throw Error(`HTTP ${e.status}`);let s=await e.json();if(!tJ.current||t_.current!==t.id)return;s.running&&s.state&&r(s.state)}catch{}})(),ok(t.id,!0,!0).then(e=>{e?.running&&e.state&&r(e.state),e?.state&&(void 0!==e.state.isCompacting&&e0(e.state.isCompacting),void 0!==e.state.contextUsage&&e_(e.state.contextUsage??null),void 0!==e.state.systemPrompt&&eV(e.state.systemPrompt??null),void 0!==e.state.thinkingLevel&&eH(e.state.thinkingLevel??"auto"),void 0!==e.state.extensionStatuses&&tu(e.state.extensionStatuses??[]),void 0!==e.state.extensionWidgets&&tg(e.state.extensionWidgets??[]),void 0!==e.state.queuedMessages&&tx(at(e.state.queuedMessages)),void 0!==e.state.pendingRecovery&&tE(e.state.pendingRecovery??[])),e?.running||(async()=>{for(let e=0;e<5;e++){if(e>0&&await new Promise(e=>setTimeout(e,2e3)),!tJ.current||t_.current!==t.id||tq.current)return;try{let e=await fetch(`/api/agent/${encodeURIComponent(t.id)}`);if(!e.ok)continue;let o=await e.json();if(!tJ.current||t_.current!==t.id)return;if(o?.running&&o.state)return void r(o.state)}catch{}}})()})}return()=>{tJ.current=!1,f.current?.abort(),k.current?.abort(),oc(),tN(),oS(),oC()}},[oc]),(0,n.useEffect)(()=>{c?.(eq)},[eq,c]),(0,n.useEffect)(()=>{d&&d(g?.tree??[],j,oK)},[g?.tree,j,oK,d]),(0,n.useEffect)(()=>(window.addEventListener("keydown",rv),window.addEventListener("pointerdown",rv,{passive:!0}),()=>{window.removeEventListener("keydown",rv),window.removeEventListener("pointerdown",rv)}),[rv]),(0,n.useEffect)(()=>{let e=t7.current;if(e)return e.addEventListener("wheel",rv,{passive:!0}),e.addEventListener("touchstart",rv,{passive:!0}),e.addEventListener("scroll",ry,{passive:!0}),()=>{e.removeEventListener("wheel",rv),e.removeEventListener("touchstart",rv),e.removeEventListener("scroll",ry)}},[C.length,v,ry,rv]),(0,n.useEffect)(()=>{C.length>0&&(t2.current?(t0.current=!0,t1.current&&(t2.current=!1,rk())):v||!t0.current?(v||(t0.current=!0),oH("instant")):!tq.current&&(t4.current||t6.current)&&(oH("smooth"),rj(e=>e+1)))},[C.length,v,B,oH,rk]);let rb=(0,n.useRef)(null),[rw,rj]=(0,n.useState)(0),rS=`${t?.id??null}#${rw}`;(0,n.useEffect)(()=>{let e;if(v){rb.current=null;return}if(0===C.length||rb.current===rS)return;rb.current=rS;let t=!1,o=!1,r=-1,n=0,s=Date.now(),i=()=>{if(t||o)return;let a=t7.current;if(a){if(Date.now()<t8.current){let{scrollTop:e,clientHeight:t,scrollHeight:r}=a;if(e+t<r-150){o=!0;return}}if(oH("instant"),a.scrollHeight===r){if((n+=1)>=4||Date.now()-s>=3e4)return}else if(r=a.scrollHeight,n=0,Date.now()-s>=3e4)return;e=window.setTimeout(i,n>0?500:250)}};return e=window.setTimeout(i,250),()=>{t=!0,void 0!==e&&window.clearTimeout(e)}},[v,oH,rS]),(0,n.useEffect)(()=>{let e=new AbortController;return oY(e.signal).catch(e=>{if(e instanceof DOMException&&"AbortError"===e.name)return}),()=>e.abort()},[oY,l]),(0,n.useEffect)(()=>{if(!en)return;let e=()=>{"visible"===document.visibilityState&&oY()};return document.addEventListener("visibilitychange",e),window.addEventListener("online",e),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("online",e)}},[en,oY]),(0,n.useEffect)(()=>{if(!e1)return;let e=setTimeout(()=>e2(null),3e3);return()=>clearTimeout(e)},[e1]),(0,n.useEffect)(()=>{if(!e4)return;let e=setTimeout(()=>e6(null),6e3);return()=>clearTimeout(e)},[e4]),(0,n.useEffect)(()=>{if(0===tr.visible.length)return;let e=tr.visible.find(e=>e.exiting);if(e){let t=setTimeout(()=>{tn({type:"remove",id:e.id})},180);return()=>clearTimeout(t)}if(!tr.visible[0])return;let t=setTimeout(()=>{tn({type:"mark_oldest_exiting"})},5e3);return()=>clearTimeout(t)},[tr.visible]),(0,n.useEffect)(()=>{ti(null)},[C.length,eU?.tokens,eU?.percent,eU?.contextWindow]);let rC=g?.tree??[];return{data:g,loading:v,error:b,activeLeafId:j,messages:C,entryIds:R,historyCursor:I,hasEarlierMessages:P,streamState:W,agentRunning:B,bashRunning:_,pendingBash:V,modelNames:G,modelList:Y,modelThinkingLevels:Z,modelThinkingLevelMaps:ee,modelScopeWarnings:eo,modelsError:en,newSessionModel:ei,toolPreset:ec,thinkingLevel:e$,retryInfo:eO,contextUsage:eU,systemPrompt:eq,forkingEntryId:eK,isCompacting:eQ,compactError:e1,compactResult:e4,currentModel:om,displayModel:of,sessionStats:ox,tokenRate:A,planMode:eu,collaborationMode:eb,tokenMode:ew,toolApprovalMode:ej,permissionRules:eS,modeSettings:ef,approvalRequests:eE,handleCollaborationModeChange:ra,handleTokenModeChange:rl,handleToolApprovalModeChange:rd,handlePermissionRulesChange:rc,resolveApproval:rp,setActiveGoalText:ru,goalState:eD,handleGoalStart:rh,handleGoalPause:rg,handleGoalResume:rm,handleGoalStop:rf,handleGoalEdit:rx,slashCommands:e9,slashCommandsLoading:tt,queuedMessages:tm,pendingRecovery:tk,recoveryIsImport:tW,notices:tr.visible,extensionDialog:ta,extensionCustomUi:td,extensionStatuses:tp,extensionWidgets:th,respondToExtensionUi:oz,sendExtensionCustomInput:oI,agentPhase:e8,isNew:u,promptAnchorActive:e3,branchTree:rC,sessionIdRef:t_,eventSourceRef:tL,messagesEndRef:t3,scrollContainerRef:t7,lastUserMsgRef:t1,pendingScrollToUserRef:t2,initialScrollDoneRef:t0,scrollUserMsgToTop:rk,handleSend:oB,executeBash:oU,handleAbort:o_,handleFork:oq,handleNavigate:oV,handleModelChange:oG,handleCompact:oJ,handleSteer:oQ,handleFollowUp:o1,handlePromptWithStreamingBehavior:o0,handleAbortCompaction:o2,handleRecallQueue:o4,resolveRecovery:o6,exportQueueData:o8,importQueueData:o5,stageQueueImport:o3,moveQueuedMessage:o7,recallQueuedMessage:o9,requeueAt:re,removeQueuedMessage:rt,handleBuiltinSlashCommand:oX,handleToolPresetChange:rr,handleThinkingLevelChange:ro,handlePlanModeChange:rs,loadTools:oy,loadSlashCommands:oj,reloadModels:oY,setActiveLeafId:S,setData:m,setMessages:T,loadContext:ov,dispatch:F,setAgentRunning:U,setForkingEntryId:eG,handleLeafChange:oK,handleAgentEventRef:tQ}}({session:e,newSessionCwd:t,onAgentEnd:W,onSessionCreated:i,onSessionForked:l,modelsRefreshKey:d,chatInputRef:c,onBranchDataChange:p,onSystemPromptChange:u,onSessionStatsPanelOpen:g}),[tc,tp]=(0,n.useState)(!1);(0,n.useEffect)(()=>{0===eg.length&&tp(!1)},[eg.length]);let{balance:tu,refresh:th,refreshSoon:tg}=function(){let[e,t]=(0,n.useState)(null),[o,r]=(0,n.useState)(!1),s=(0,n.useRef)(null),i=(0,n.useRef)(null),a=(0,n.useRef)(!0);(0,n.useEffect)(()=>(a.current=!0,()=>{a.current=!1,i.current&&clearTimeout(i.current),s.current?.abort()}),[]);let l=(0,n.useRef)(null),d=(0,n.useCallback)(async()=>{s.current?.abort();let e=new AbortController;s.current=e;try{let o=await fetch("/api/deepseek/balance",{signal:e.signal,cache:"no-store"}),n=await o.json();if(!a.current)return;if(n?.available&&null!=n.totalBalance){let e=l.current;(null===e||e.available!==n.available||e.reason!==n.reason||e.currency!==n.currency||e.totalBalance!==n.totalBalance||e.grantedBalance!==n.grantedBalance||e.toppedUpBalance!==n.toppedUpBalance)&&(l.current=n,t(n)),r(!1)}else null===l.current&&r(!0)}catch{if(!a.current)return;null===l.current&&r(!0)}},[]),c=(0,n.useCallback)(()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null,d()},2e3)},[d]);return{balance:e,failed:o,refresh:d,refreshSoon:c}}(),tm=el?.provider==="deepseek",tf=(0,n.useRef)(null);(0,n.useEffect)(()=>{tm&&th()},[tm,th]),(0,n.useEffect)(()=>{if(tm)for(let e=H.length-1;e>=0;e--){let t=H[e];if("assistant"!==t.role||!t.usage)continue;let o=`${e}:${B[e]??""}`;o!==tf.current&&(tf.current=o,tg());break}},[H,B,tm,tg]);let tx=(0,n.useMemo)(()=>{let e=H.findLast(e=>"assistant"===e.role&&!!e.usage);if(!e?.usage)return null;let t=e.usage;return{model:e.model??"",input:t.input??0,output:t.output??0,cacheRead:t.cacheRead??0,costCNY:r4(e.model)?r6(e.model,t):0,costUSD:r4(e.model)?0:t.cost?.total??0}},[H]),[tk,tP]=(0,n.useState)(!1),[tE,tW]=(0,n.useState)(null),tF=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(!e6){tF.current=!1;return}if(_){tF.current=!0;return}tF.current&&(tF.current=!1,tW(function(e){for(let t=e.length-1;t>=0;t--){let o=e[t];if("assistant"!==o.role)continue;let r=o.content;if("string"==typeof r&&r.trim())return r;if(Array.isArray(r)){let e=r.filter(e=>"text"===e.type).map(e=>e.text??"").join("\n").trim();if(e)return e}}for(let t=e.length-1;t>=0;t--){let o=e[t];if("toolResult"!==o.role)continue;let r=o.content,n="string"==typeof r?r:Array.isArray(r)?r.map(e=>e.text??"").join("\n"):"";if(!n)continue;let s=n.match(/\*\*Proposed Plan\*\*\s*\n+([\s\S]+)/i);if(s?.[1]?.trim())return s[1].trim()}return null}(H)??null),tP(!0))},[_,e6,H]);let tD=(0,n.useCallback)(()=>{tP(!1);let e=tA.current;"plan"===e5&&e7("normal"),e8(!1).then(()=>{e&&eD(I("tasks.planReviewExecutePrompt",{plan:e}))})},[e8,eD,I,e5,e7]),tA=(0,n.useRef)(null);(0,n.useEffect)(()=>{tA.current=tE},[tE]);let tN=(0,n.useCallback)(e=>{tP(!1),eB(e)},[eB]),tL=(0,n.useCallback)(()=>{tP(!1),"plan"===e5&&e7("normal"),e8(!1)},[e8,e5,e7]);(0,n.useEffect)(()=>{ex&&E.current!==ex.id&&(E.current=ex.id,P.current&&M.current())},[ex]),(0,n.useEffect)(()=>(a=_||q?eN:null,()=>void(a=null)),[_,q,eN]);let[t$,tH]=(0,n.useState)(!1),[tO,tB]=(0,n.useState)(!1),[tU,t_]=(0,n.useState)(!1),tq=(0,n.useCallback)(()=>{let e=eM.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;tH(e.scrollTop>1),tB(t>1),t_(t>240)},[eM]),tV=(0,n.useCallback)(()=>{window.requestAnimationFrame(()=>{let e=eM.current,t=eI.current;if(!e||!t)return;let o=Math.max(88,c?.current?.measureHeight?.()??0),r=()=>{if(!e||!t)return;let r=Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop-96-e.clientHeight+o);e.scrollTo({top:r,behavior:"auto"})};r(),tq(),window.setTimeout(r,200)})},[eI,eM,tq,c]);(0,n.useEffect)(()=>{let e=eM.current;if(!e)return;let t=new ResizeObserver(tq);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),e.addEventListener("scroll",tq,{passive:!0}),tq(),()=>{e.removeEventListener("scroll",tq),t.disconnect()}},[H.length,eM,tq]);let tK=(0,n.useRef)(!1);(0,n.useEffect)(()=>{let t=eM.current;if(!t)return;let o=()=>{if(tK.current||!tl||!ta||t.scrollTop>8)return;let o=e?.id;if(!o)return;tK.current=!0;let r=t.scrollHeight-t.scrollTop;td(o,eT,ta).finally(()=>{tK.current=!1,requestAnimationFrame(()=>{let e=t.scrollHeight-r;Math.abs(t.scrollTop-e)>1&&t.scrollTo({top:e,behavior:"auto"})})})};return t.addEventListener("scroll",o,{passive:!0}),()=>t.removeEventListener("scroll",o)},[eM,ta,tl,td,e?.id,eT]);let tG=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(!tl||!ta)return;let t=eM.current,o=e?.id;if(!t||!o||tK.current||tG.current||L||t.scrollTop>8||t.scrollHeight>t.clientHeight+50)return;tG.current=!0;let r=t.scrollHeight-t.scrollTop;td(o,eT,ta).finally(()=>{tG.current=!1,requestAnimationFrame(()=>{let e=t.scrollHeight-r;Math.abs(t.scrollTop-e)>1&&t.scrollTo({top:e,behavior:"auto"})})})},[eM,ta,tl,td,e?.id,eT,L,H.length]);let tJ=(0,n.useRef)(null),tY=(0,n.useRef)([]),tX=(0,n.useMemo)(()=>({getOffsetForIndex:e=>tJ.current?.getOffsetForIndex(e)?.[0]??0,sizeFor:e=>{let t=tJ.current;if(!t)return 0;let o=t.measurementsCache[e];return o?.size??t.options.estimateSize?.(e)??0},totalHeight:()=>tJ.current?.getTotalSize()??0,refToItemIndex:e=>tY.current[e],itemCount:tY.current.length}),[]),tZ=ed?[ed.sessionId,ed.sessionFile??"",ed.sessionName??"",ed.userMessages,ed.assistantMessages,ed.toolCalls,ed.toolResults,ed.totalMessages,ed.tokens.input,ed.tokens.output,ed.tokens.cacheRead,ed.tokens.cacheWrite,ed.tokens.total,ed.cost??0,ed.totalActiveMs??0].join("|"):null,tQ=(0,n.useRef)(ed);tQ.current=ed,(0,n.useEffect)(()=>{h?.(tQ.current)},[tZ,h]),(0,n.useEffect)(()=>()=>{h?.(null)},[h]);let t0=er?`${er.percent??"null"}|${er.contextWindow}|${er.tokens??"null"}`:null,t2=(0,n.useRef)(er);t2.current=er,(0,n.useEffect)(()=>{m?.(t2.current)},[t0,m]),(0,n.useEffect)(()=>()=>{m?.(null)},[m]);let{isDragOver:t4,handleDragEnter:t6,handleDragOver:t3,handleDragLeave:t7,handleDrop:oe}=function(e){let[t,o]=(0,n.useState)(!1),r=(0,n.useRef)(0),s=(0,n.useCallback)(e=>{e.dataTransfer.files.length&&(e.preventDefault(),r.current+=1,o(!0))},[]),i=(0,n.useCallback)(e=>{e.dataTransfer.files.length&&e.preventDefault()},[]);return{isDragOver:t,handleDragEnter:s,handleDragOver:i,handleDragLeave:(0,n.useCallback)(()=>{r.current-=1,r.current<=0&&(r.current=0,o(!1))},[]),handleDrop:(0,n.useCallback)(t=>{t.preventDefault(),r.current=0,o(!1),e(Array.from(t.dataTransfer.files),t.dataTransfer)},[e])}}((0,n.useCallback)((e,t)=>{if(_){let t=e.filter(e=>e.type.startsWith("image/"));t.length&&c?.current?.addImages(t);return}c?.current?.addFiles(e,t)},[_,c])),or=H.filter(e=>"user"===e.role||"assistant"===e.role),on=(0,n.useMemo)(()=>{let e=new Set,t=[];for(let r=H.length-1;r>=0&&t.length<50;r-=1){var o;let n="user"!==(o=H[r]).role?null:("string"==typeof o.content?o.content:o.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n")).trim()||null;!n||e.has(n)||(e.add(n),t.push(n))}return t},[H]),os=(w=or.length,(j=(0,n.useRef)([])).current=Array(w).fill(null).map((e,t)=>j.current[t]??null),j),oi=eS&&0===H.length&&!U.isStreaming&&!_,oa=e?.cwd??t??void 0,ol=(0,n.useMemo)(()=>(function(e,t,o){let r=new Map;for(let t of e)"toolResult"===t.role&&r.set(t.toolCallId,t);let n=-1;for(let t=e.length-1;t>=0;t--)if("user"===e[t].role){n=t;break}let s=new Map,i=0;e.forEach((e,t)=>{("user"===e.role||"assistant"===e.role)&&s.set(t,i++)});let a=[];for(let n=0;n<e.length;){let s,i=e[n],l="custom"===i.role&&"compaction"===i.customType;if(0===n&&"user"!==i.role&&!l){let o=1;for(;o<e.length&&"user"!==e[o].role;)o+=1;let s=Array.from({length:o},(e,t)=>t).filter(t=>ot(e[t])),i=t5(e,t,s,r);if(i.length>0){a.push({kind:"turn",userIdx:-1,endIdx:o,startsCompactionTurn:!1,finalAssistantIdx:-1,visibleProcessIndices:s,processBlocks:i,finalAnswerMessage:null,writtenFiles:void 0}),n=o;continue}}if("user"!==i.role&&!l){a.push({kind:"single",idx:n}),n+=1;continue}let d=n,c=d+1;for(;c<e.length&&"user"!==e[c].role;)c+=1;let p=function(e,t,o){for(let n=o-1;n>t;n--){var r;if("assistant"===(r=e[n]).role&&t1(r).answerBlocks.some(e=>"image"===e.type||"text"===e.type&&e.text.trim().length>0))return n}for(let r=o-1;r>t;r--)if(e[r]?.role==="assistant")return r;return -1}(e,d,c);if(-1===p){let o=Array.from({length:c-d-1},(e,t)=>d+1+t).filter(t=>ot(e[t])),s=t5(e,t,o,r);a.push({kind:"turn",userIdx:d,endIdx:c,startsCompactionTurn:l,finalAssistantIdx:p,visibleProcessIndices:o,processBlocks:s,finalAnswerMessage:null,writtenFiles:void 0}),n=c;continue}let u=[];for(let e=d+1;e<p;e++)u.push(e);let h=u.filter(t=>ot(e[t])),g=e[p],m=t1(g),f=m.processBlocks.length>0?oo(g,m.processBlocks,{omitUsage:!0}):null,x=m.answerBlocks.length>0?oo(g,m.answerBlocks):null,k=t5(e,t,h,r);if(f&&(k=k.concat(t8(g,{messageIndex:p,entryId:t[p],toolResults:r}).processBlocks)),x){let t=[];for(let o=d+1;o<=p;o++){let r=e[o];if(r?.role==="assistant")for(let e of r.content??[])t.push(e)}s=function(e,t,o){let r=new Set,n=[];for(let s of e){if("toolCall"!==s.type||!function(e){let t,o;return"write"===(t=e.toLowerCase())||t.startsWith("write_")||t.endsWith(".write")||t.endsWith("_write")||"edit"===(o=e.toLowerCase())||o.startsWith("edit_")||o.endsWith(".edit")||o.endsWith("_edit")||o.includes("str_replace")||o.includes("replace_editor")}(s.toolName))continue;let e=t?.get(s.toolCallId);if(!e||e.isError)continue;let i=function(e){if(!e)return null;let t=e.file_path??e.path;return"string"==typeof t&&t.length>0?t:null}(s.input);if(!i)continue;let a=function(e,t){let o;if(!e)return null;let r=/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")||void 0!==t&&(/^[a-zA-Z]:[\\/]/.test(t)||t.startsWith("\\\\")),n=e=>r?e.replace(/\\/g,"/"):e,s=n(e),i=t?n(t).replace(/\/+$/,""):void 0,a=/^[a-zA-Z]:\//.test(s),l=s.startsWith("//");if(a||l)o=s;else if(s.startsWith("/")){let e=i?.match(/^([a-zA-Z]:)(?:\/|$)/)?.[1]??i?.match(/^(\/\/[^/]+\/[^/]+)(?:\/|$)/)?.[1];o=e?`${e}${s}`:s}else{if(!i)return null;o=`${i}/${s}`}return t9(o)}(i,o);a&&(r.has(a)||(r.add(a),n.push({filePath:a})))}return n}(t,r,o)}a.push({kind:"turn",userIdx:d,endIdx:c,startsCompactionTurn:l,finalAssistantIdx:p,visibleProcessIndices:h,processBlocks:k,finalAnswerMessage:x,writtenFiles:s}),n=c}return{toolResultsMap:r,lastUserIdx:n,visibleRefIndexByMessage:s,items:a}})(H,B,oa),[H,B,oa]),od=el?J[`${el.provider}:${el.modelId}`]??null:null,oc=el?Y[`${el.provider}:${el.modelId}`]??null:null,op=(0,n.useCallback)(()=>{Q()},[Q]),ou=(0,n.useCallback)(e=>{e8(e),e&&"plan"!==e5?e7("plan"):e||"plan"!==e5||e7("normal")},[e8,e7,e5]),oh=(0,n.useCallback)(e=>{e7(e),"plan"!==e||e6?"plan"!==e&&e6&&e8(!1):e8(!0)},[e7,e8,e6]),og=e?.relation?.kind==="subagent"?(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"14px 16px",borderTop:"1px solid var(--border)",color:"var(--text-dim)",fontSize:12},children:[(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,r.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,r.jsx)("path",{d:"M12 7v4"})]}),I("subagent.readOnlyNotice")]}):(0,r.jsx)(iM,{ref:c,onSend:eD,onBash:eA,tasksBoardEnabled:y,onAbort:eN,onSteer:_?eB:void 0,onFollowUp:_?eU:void 0,onPromptWithStreamingBehavior:_?e_:void 0,isStreaming:_,model:el,modelNames:K,modelList:G,modelScopeWarnings:X,modelsError:Z,onRetryModels:op,onModelChange:eH,compactResult:ea,toolPreset:ee,onToolPresetChange:e||eS?e1:void 0,planMode:e6,onPlanModeChange:ou,collaborationMode:e5,toolApprovalMode:e3,onCollaborationModeChange:oh,goalState:tt,onGoalStart:to,onGoalPause:tr,onGoalResume:tn,onGoalStop:ts,thinkingLevel:et,onThinkingLevelChange:e||eS?e2:void 0,availableThinkingLevels:od,thinkingLevelMap:oc,retryInfo:eo,queuedMessages:eh,inputHistory:on,onRecallQueue:eV,onMoveQueue:eY,onRecallOne:eX,onRequeueAt:eZ,onRemoveQueueItem:eQ,slashCommands:ep,slashCommandsLoading:eu,onLoadSlashCommands:e4,onBuiltinCommand:e0,onAudioUnlock:R,draftKey:e?.id??(t?`new:${t}`:void 0),cwd:e?.cwd??t}),om=ey.filter(e=>"belowEditor"!==e.placement),of=ey.filter(e=>"belowEditor"===e.placement),ox=es?I("desktop.compacting"):function(e,t){if(e?.kind==="running_tools"){let o=e.tools.map(e=>e.name);return 0===o.length?t("desktop.runningTool"):t("desktop.runningTools",{tools:o.length<=3?o.join(", "):`${o.slice(0,2).join(", ")} (+${o.length-2})`})}return e?.kind==="waiting_model"?t("desktop.waitingForModel"):e?.kind==="running_command"?t("desktop.runningCommand"):null}(ej,I);return L?(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-text-muted",children:I("desktop.loadingSession")}):$?(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-red-400",children:$}):(0,r.jsxs)("div",{className:"relative flex h-full min-w-0 flex-col overflow-hidden",onDragEnter:t6,onDragOver:t3,onDragLeave:t7,onDrop:oe,children:[t4&&(0,r.jsxs)("div",{className:"pointer-events-none absolute inset-0 z-50 flex animate-[drop-zone-in_0.15s_ease_both] items-center justify-center bg-[rgba(37,99,235,0.06)] backdrop-blur-[1px]",children:[(0,r.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[0,.8,1.6].map(e=>(0,r.jsx)("div",{className:"absolute h-[720px] w-[720px] rounded-full border-[1.5px] border-solid border-[rgba(37,99,235,0.5)] animate-[drop-ripple_2.4s_ease-out_infinite_backwards]",style:{transformOrigin:"center",animationDelay:`${e}s`}},e))}),(0,r.jsxs)("svg",{width:"280",height:"280",viewBox:"0 0 140 140",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"drop-shadow-[0_6px_18px_rgba(37,99,235,0.18)]",children:[(0,r.jsx)("rect",{x:"28",y:"44",width:"84",height:"60",rx:"8",fill:"rgba(37,99,235,0.08)",stroke:"rgba(37,99,235,0.50)",strokeWidth:"1.8"}),(0,r.jsx)("path",{d:"M36 100 L54 72 L68 88 L80 74 L104 100Z",fill:"rgba(37,99,235,0.16)",stroke:"rgba(37,99,235,0.40)",strokeWidth:"1.4",strokeLinejoin:"round"}),(0,r.jsx)("circle",{cx:"96",cy:"58",r:"8",fill:"rgba(37,99,235,0.22)",stroke:"rgba(37,99,235,0.55)",strokeWidth:"1.6"}),(0,r.jsxs)("g",{stroke:"rgba(37,99,235,0.45)",strokeWidth:"1.4",strokeLinecap:"round",children:[(0,r.jsx)("line",{x1:"96",y1:"46",x2:"96",y2:"43"}),(0,r.jsx)("line",{x1:"96",y1:"70",x2:"96",y2:"73"}),(0,r.jsx)("line",{x1:"84",y1:"58",x2:"81",y2:"58"}),(0,r.jsx)("line",{x1:"108",y1:"58",x2:"111",y2:"58"}),(0,r.jsx)("line",{x1:"87.5",y1:"49.5",x2:"85.4",y2:"47.4"}),(0,r.jsx)("line",{x1:"104.5",y1:"66.5",x2:"106.6",y2:"68.6"}),(0,r.jsx)("line",{x1:"104.5",y1:"49.5",x2:"106.6",y2:"47.4"}),(0,r.jsx)("line",{x1:"87.5",y1:"66.5",x2:"85.4",y2:"68.6"})]})]})]}),ex&&(0,r.jsx)(ak,{request:ex,onRespond:eb}),ek&&(0,r.jsx)(av,{request:ek,onInput:ew}),!eS&&eg.length>0&&!tc&&(0,r.jsx)(iW,{items:eg,sessionId:e?.id,onResolve:eK,onExport:eG,onStageImport:eJ,onDismiss:()=>tp(!0),mode:em?"import":"recovery"}),e9.length>0&&(0,r.jsx)(nI,{request:e9[0]??null,queuedCount:Math.max(0,e9.length-1),busy:!1,onResolve:(e,t)=>{let o=e9[0];o&&te(o.id,e,t)}}),oi?(0,r.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center overflow-y-auto",children:(0,r.jsxs)("div",{className:"w-full max-w-[820px]",children:[(0,r.jsx)("div",{style:{display:"flex",justifyContent:"center",marginBottom:28},children:(0,r.jsxs)("svg",{fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",style:{width:64,height:64,color:"var(--accent)",opacity:.85},"aria-label":"Pi",children:[(0,r.jsx)("title",{children:"Pi"}),(0,r.jsx)("path",{clipRule:"evenodd",d:"M1 1h16.5v11H12v5.5H6.5V23H1V1zm5.5 5.5V12H12V6.5H6.5z"}),(0,r.jsx)("path",{d:"M17.5 12H23v11h-5.5V12z"})]})}),z&&(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:10,marginBottom:18,marginTop:-14},children:[(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:["web ",(0,r.jsxs)("span",{style:{color:"var(--text)"},children:["v","0.17.2"]})]}),(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:["pi ",(0,r.jsxs)("span",{style:{color:"var(--text)"},children:["v","0.85.1"]})]})]}),(0,r.jsx)("div",{style:{padding:"0 34px 6px 7px",paddingRight:z?16:34},children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,r.jsx)("div",{ref:x,style:{display:"flex",alignItems:"center",minWidth:0,flex:1,minHeight:48}}),(0,r.jsxs)("div",{style:{display:z?"none":"flex",flexDirection:"column",alignItems:"flex-end",gap:2,flexShrink:0},children:[(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:["web ",(0,r.jsxs)("span",{style:{color:"var(--text)"},children:["v","0.17.2"]})]}),(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:["pi ",(0,r.jsxs)("span",{style:{color:"var(--text)"},children:["v","0.85.1"]})]})]})]})}),(0,r.jsx)("div",{style:{padding:"0 16px",paddingRight:z?16:34},children:(0,r.jsx)(ax,{notices:ef,align:"right"})}),"goal"===e5&&(0,r.jsx)(nR,{goalState:tt,onPause:tr,onResume:tn,onStop:ts,onEdit:ti}),og,(0,r.jsx)("div",{style:{padding:"0 16px 6px",paddingRight:z?16:34,marginTop:-15},children:(0,r.jsx)(iK,{onViewFullHistory:k,cwd:oa,systemPrompt:v,sessionStats:ed,contextUsage:er,hasSession:!!e,showChat:!0,showSoundLabel:!0,soundEnabled:S,onSoundToggle:C,onCompact:e?eO:void 0,onAbortCompaction:eq,isCompacting:es,compactError:ei,isDeepSeekOfficial:tm,deepseekBalance:tu,lastTurnUsage:tx})})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative flex flex-1 overflow-hidden z-0",children:[(0,r.jsx)("div",{style:{position:"absolute",top:12,left:0,right:18*!z,zIndex:40,padding:"0 16px",pointerEvents:"none"},children:(0,r.jsx)("div",{style:{maxWidth:820,margin:"0 auto"},children:(0,r.jsx)(ax,{notices:ef,floating:!0,align:"right"})})}),(0,r.jsxs)("div",{className:"relative flex-1 min-h-0 min-w-0",children:[(0,r.jsx)("div",{ref:eM,className:"h-full min-w-0 overflow-x-hidden overflow-y-auto pt-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,r.jsx)("div",{style:{minWidth:0,padding:"0 16px"},children:(0,r.jsxs)("div",{style:{width:"100%",minWidth:0,maxWidth:820,margin:"0 auto"},children:[(0,r.jsx)(am,{statuses:ev}),(0,r.jsx)(af,{widgets:om}),(()=>{let{toolResultsMap:t,lastUserIdx:o,visibleRefIndexByMessage:n,items:s}=ol,i=(s,i={})=>{let a=i.messageOverride??H[s];if(!a||"toolResult"===a.role)return null;let l="user"===a.role&&s>0&&"assistant"===H[s-1].role?B[s-1]:void 0,d="user"===a.role||"assistant"===a.role,c=n.get(s),p=i.keyPrefix??"message",u=!1;if("assistant"===a.role){u=!0;for(let e=s+1;e<H.length;e++){let t=H[e].role;if("user"===t)break;if("assistant"===t){u=!1;break}}u&&U.isStreaming&&s===H.length-1&&(u=!1)}void 0!==i.showTimestamp&&(u=i.showTimestamp);let h=(0,r.jsx)(ne,{message:a,toolResults:t,modelNames:K,cwd:oa,onOpenFile:f,entryId:B[s],onFork:_||eS||0===s&&"user"===a.role?void 0:eL,forking:en===B[s],onNavigate:_?void 0:e$,prevAssistantEntryId:_?void 0:l,onEditContent:F,onQuoteReply:D,onOpenSession:b,onCreateTask:N,showTimestamp:u,prevTimestamp:s>0?H[s-1].timestamp:void 0,sessionId:e?.id??ez.current??void 0,writtenFiles:i.writtenFiles},`${p}-view-${s}`);return d&&!1!==i.attachRef&&void 0!==c?(0,r.jsx)("div",{ref:e=>{os.current[c]=e,s===o&&(eP.current=e,e&&eE.current&&(eE.current=!1,eW.current=!0,eF()))},children:h},`${p}-${s}`):h},a=[],l=[],d=[],c=0,p=(e,t,o)=>{null!==e&&(a.push(e),l.push(t),d.push(o))},u=(e,t)=>B[e]||`${t}-${e}`;for(let a of s){if("single"===a.kind){if(H[a.idx]?.role==="toolResult")continue;p(i(a.idx),n.get(a.idx),u(a.idx,"single"));continue}let{userIdx:s,endIdx:l,startsCompactionTurn:d,finalAssistantIdx:h}=a;if((_||U.isStreaming)&&l===H.length&&(s===o||d)){s>=0&&p(i(s),n.get(s),u(s,"user"));let o=U.streamingMessage?.role==="assistant",a=[],d=!o&&h>=0?h:l;for(let e=s+1;e<d;e++)ot(H[e])&&a.push(e);let c=t5(H,B,a,t),g=null;if(!o&&h>=0){let e=H[h],o=t1(e,{isStreaming:!0}),r=t8(e,{messageIndex:h,entryId:B[h],toolResults:t,isStreaming:!0});c=c.concat(r.processBlocks),o.answerBlocks.length>0&&(g=oo(e,o.answerBlocks,{omitUsage:!0}))}if(o){let e=U.streamingMessage,o=t1(e,{isStreaming:!0}),r=t8(e,{messageIndex:H.length,toolResults:t,isStreaming:!0});c=c.concat(r.processBlocks),o.answerBlocks.length>0&&(g=oo(e,o.answerBlocks,{omitUsage:!0}))}if(c.length>0){let t=a.map(e=>n.get(e)).find(e=>"number"==typeof e);p((0,r.jsx)("div",{ref:void 0===t?void 0:e=>{os.current[t]=e},children:(0,r.jsx)(su,{blocks:c,isStreaming:_||U.isStreaming,cwd:oa,onOpenFile:f,sessionId:e?.id??ez.current??void 0,tokenRate:ec})},`live-process-group-${s}`),t,`live-process-${s}-${a[0]??"none"}`)}g&&p((0,r.jsx)(ne,{message:g,isStreaming:!0,modelNames:K,cwd:oa,onOpenFile:f,onQuoteReply:D,onOpenSession:b},`live-answer-${s}`),h>=0?n.get(h):void 0,h>=0?`live-answer-${u(h,"answer")}`:`live-answer-streaming-${s}`);continue}if(-1===h&&0===a.processBlocks.length){if(s>=0)for(let e=s;e<l;e++)p(i(e),n.get(e),u(e,"raw"));continue}s>=0&&p(i(s),n.get(s),u(s,"user"));let{processBlocks:g,finalAnswerMessage:m,writtenFiles:x,visibleProcessIndices:k}=a;if(g.length>0){let t=k.map(e=>n.get(e)).find(e=>"number"==typeof e)??(m?void 0:n.get(h));k[0],p((0,r.jsx)("div",{ref:void 0===t?void 0:e=>{os.current[t]=e},children:(0,r.jsx)(su,{blocks:g,isStreaming:!1,defaultExpanded:!1,onAutoExpanded:void 0,cwd:oa,onOpenFile:f,sessionId:e?.id??ez.current??void 0})},`process-group-${s}-${h}`),t,`process-${s>=0?u(s,"user"):`orphan-${c++}`}`)}if(m&&p(i(h,{messageOverride:m,writtenFiles:x}),n.get(h),u(h,"answer")),h>=0)for(let e=h+1;e<l;e++)p(i(e),n.get(e),u(e,"tail"))}let h=[],g=l.map((e,t)=>({startRef:e,itemIdx:t})).filter(e=>void 0!==e.startRef);return g.forEach((e,t)=>{let o=g[t+1]?.startRef??or.length;for(let t=e.startRef;t<o;t++)h[t]=e.itemIdx}),tY.current=h,(0,r.jsx)(iJ,{scrollElementRef:eM,items:a,itemKeys:d,virtualizerRef:tJ})})(),ox&&(es||_&&!U.streamingMessage)&&(0,r.jsx)("div",{className:"py-2 text-[13px] text-text-muted",children:(0,r.jsxs)("span",{className:"animate-[pulse_1.5s_infinite]",children:[ox,ej?.kind==="waiting_model"&&(0,r.jsx)("span",{style:{display:"inline-block",width:12,height:12,marginLeft:6,verticalAlign:"-2px",border:"1.5px solid var(--text-muted)",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.6s linear infinite"}})]})}),V&&(0,r.jsx)(ne,{message:{role:"bashExecution",command:V.command,output:"",excludeFromContext:V.excludeFromContext},sessionId:e?.id??ez.current??void 0}),q&&!V&&(0,r.jsx)("div",{className:"py-2 text-[13px] text-text-muted",children:(0,r.jsx)("span",{className:"animate-[pulse_1.5s_infinite]",children:I("desktop.runningShellCommand")})}),(0,r.jsx)("div",{style:{height:96}}),(0,r.jsx)("div",{ref:eI}),(0,r.jsx)(nb,{open:tk,planText:tE,busy:_,onExecute:tD,onFeedback:tN,onExit:tL,onClose:()=>tP(!1)})]})})}),t$&&(0,r.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 z-10 h-8 bg-gradient-to-b from-[var(--bg)] to-transparent"}),tO&&(0,r.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-8 bg-gradient-to-t from-[var(--bg)] to-transparent"}),tU&&(0,r.jsxs)("button",{type:"button",onClick:()=>tV(),title:I("desktop.scrollToBottom"),"aria-label":I("desktop.scrollToBottom"),style:{position:"absolute",bottom:14,right:18,zIndex:20,display:"flex",alignItems:"center",gap:6,padding:"5px 10px",border:"1px solid var(--border)",borderRadius:999,background:"color-mix(in srgb, var(--bg-panel) 92%, transparent)",color:"var(--text-muted)",fontSize:11,fontWeight:600,cursor:"pointer",boxShadow:"0 4px 14px rgba(0,0,0,0.14)",backdropFilter:"blur(4px)",transition:"color 0.12s, border-color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)"},children:[(0,r.jsx)(rJ.Z,{size:12,weight:"bold","aria-hidden":"true"}),I("desktop.scrollToBottom")]})]}),z?null:(0,r.jsx)(iZ,{messages:H,streamingMessage:U.streamingMessage,scrollContainer:eM,messageRefs:os,virtualizer:tX})]}),(0,r.jsxs)("div",{className:"relative z-10",children:[(0,r.jsx)("div",{style:{padding:"0 16px",paddingRight:z?16:34},children:(0,r.jsx)("div",{style:{maxWidth:820,margin:"0 auto"},children:(0,r.jsx)(af,{widgets:of})})}),og,(0,r.jsx)("div",{className:`session-info-bar-wrap${z?" is-mobile":""}`,children:(0,r.jsx)("div",{className:"session-info-bar-inner",children:(0,r.jsx)(iK,{onViewFullHistory:k,cwd:oa,systemPrompt:v,sessionStats:ed,contextUsage:er,hasSession:!!e,showChat:!0,soundEnabled:S,onSoundToggle:C,onCompact:e?eO:void 0,onAbortCompaction:eq,isCompacting:es,compactError:ei,branchTree:eC,branchActiveLeafId:eT,onBranchLeafChange:eR,isDeepSeekOfficial:tm,deepseekBalance:tu,lastTurnUsage:tx})})})]})]})]})}function am({statuses:e}){return 0===e.length?null:(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:10},children:e.map(e=>(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,maxWidth:"100%",padding:"4px 8px",border:"1px solid color-mix(in srgb, var(--accent) 24%, var(--border))",borderRadius:6,background:"color-mix(in srgb, var(--accent) 7%, var(--bg))",color:"var(--text-muted)",fontSize:12},children:[(0,r.jsx)("span",{style:{color:"var(--accent)",fontFamily:"var(--font-mono)",fontSize:11},children:e.key}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.text})]},e.key))})}function af({widgets:e}){return 0===e.length?null:(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:10},children:e.map(e=>(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:7,background:"var(--bg-panel)",overflow:"hidden"},children:[(0,r.jsx)("div",{style:{padding:"5px 9px",borderBottom:"1px solid var(--border)",color:"var(--text-dim)",fontSize:11,fontFamily:"var(--font-mono)"},children:e.key}),(0,r.jsx)("pre",{style:{margin:0,padding:"8px 9px",color:"var(--text-muted)",fontSize:12,lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)"},children:e.lines.join("\n")})]},e.key))})}function ax({notices:e,floating:t=!1,align:o="left"}){return 0===e.length?null:(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",alignItems:"right"===o?"flex-end":"stretch",marginBottom:10*!t},children:e.map((o,n)=>{let s="error"===o.type?"#ef4444":"warning"===o.type?"#d97706":"success"===o.type?"#10b981":"var(--accent)";return(0,r.jsxs)("div",{className:"notice-shelf-item",style:{display:"flex",alignItems:"center",gap:10,minHeight:44,maxHeight:180,marginBottom:6*(n!==e.length-1),overflowY:"auto",overflowX:"hidden",borderRadius:14,border:"1px solid color-mix(in srgb, var(--border) 70%, transparent)",background:"var(--bg)",color:"var(--text-muted)",width:"fit-content",maxWidth:"min(100%, 620px)",boxShadow:t?"0 1px 2px rgba(15,23,42,0.05), 0 10px 28px -14px rgba(15,23,42,0.24)":"0 1px 2px rgba(15,23,42,0.04), 0 8px 24px -12px rgba(15,23,42,0.10)",fontSize:13,lineHeight:1.45,transformOrigin:"top center",animation:o.exiting?"notice-shelf-out 0.18s ease-in forwards":"notice-shelf-in 0.18s ease-out both",padding:"0 12px"},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:s,flexShrink:0}}),(0,r.jsx)("span",{style:{padding:"10px 0",minWidth:0,maxWidth:"100%",overflowWrap:"anywhere",whiteSpace:"pre-wrap"},children:o.message})]},o.id)})})}function ak({request:e,onRespond:t}){let{t:o}=(0,A.s)(),[s,i]=(0,n.useState)("editor"===e.method?e.prefill??"":"");(0,n.useEffect)(()=>{i("editor"===e.method?e.prefill??"":"")},[e]);let a=()=>{"confirm"===e.method?t(e,{confirmed:!0}):t(e,{value:s})};return(0,r.jsx)("div",{style:{position:"absolute",inset:0,zIndex:90,display:"flex",alignItems:"center",justifyContent:"center",padding:20,background:"rgba(0,0,0,0.18)"},children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true",style:{width:"min(560px, 100%)",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg)",boxShadow:"0 20px 60px rgba(0,0,0,0.28)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{padding:"12px 14px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("div",{style:{color:"var(--text)",fontSize:14,fontWeight:650},children:e.title}),(0,r.jsx)("div",{style:{marginTop:3,color:"var(--text-dim)",fontSize:11,fontFamily:"var(--font-mono)"},children:o("desktop.extensionRequest")})]}),(0,r.jsxs)("div",{style:{padding:14},children:["confirm"===e.method&&(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontSize:13,lineHeight:1.6,whiteSpace:"pre-wrap"},children:e.message}),"select"===e.method&&(0,r.jsx)("div",{style:{display:"grid",gap:8},children:e.options.map(o=>(0,r.jsx)("button",{onClick:()=>t(e,{value:o}),style:{width:"100%",padding:"9px 10px",borderRadius:7,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text)",cursor:"pointer",textAlign:"left",fontSize:13},children:o},o))}),"input"===e.method&&(0,r.jsx)("input",{autoFocus:!0,value:s,placeholder:e.placeholder,onChange:e=>i(e.target.value),onKeyDown:o=>{"Enter"===o.key&&a(),"Escape"===o.key&&t(e,{cancelled:!0})},style:{width:"100%",padding:"9px 10px",borderRadius:7,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text)",outline:"none",fontSize:13}}),"editor"===e.method&&(0,r.jsx)("textarea",{autoFocus:!0,value:s,onChange:e=>i(e.target.value),onKeyDown:o=>{"Escape"===o.key&&t(e,{cancelled:!0}),(o.metaKey||o.ctrlKey)&&"Enter"===o.key&&a()},style:{width:"100%",minHeight:220,padding:10,borderRadius:7,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text)",outline:"none",resize:"vertical",fontSize:13,lineHeight:1.55,fontFamily:"var(--font-mono)"}})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"10px 14px",borderTop:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,r.jsx)("button",{onClick:()=>t(e,{cancelled:!0}),style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer"},children:o("desktop.cancel")}),"confirm"===e.method?(0,r.jsx)("button",{onClick:a,style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--accent)",background:"var(--accent)",color:"#fff",cursor:"pointer"},children:o("desktop.confirm")}):"select"!==e.method?(0,r.jsx)("button",{onClick:a,style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--accent)",background:"var(--accent)",color:"#fff",cursor:"pointer"},children:o("desktop.submit")}):null]})]})})}function av({request:e,onInput:t}){let{t:o}=(0,A.s)(),s=(0,n.useRef)(null),i=function(e){let t=/^[┌├└╭╰][─┬┴┼]+[┐┤┘╮╯]$/,o=[];for(let r of e){let e=tJ(r).trimEnd();if(t.test(e))continue;let n=r,s=tZ(n);("│"===s||"┃"===s)&&" "===tZ(n=tX(n,0))&&(n=tX(n,0));let i=function(e){let t=tY(e);for(let e=t.length-1;e>=0;e--)if(""!==t[e].char.trim())return e;return -1}(n),a=i>=0?tY(n)[i]?.char:void 0;("│"===a||"┃"===a)&&(n=tX(n,i)),o.push(function(e){let t=e;for(;;){let e=tY(t),o=e[e.length-1];if(!o||""!==o.char.trim())return t;t=t.slice(0,o.start)+t.slice(o.end)}}(n))}for(;o.length>0&&""===tJ(o[0]).trim();)o.shift();for(;o.length>0&&""===tJ(o[o.length-1]).trim();)o.pop();return o.length?o:e}(e.lines);return(0,n.useEffect)(()=>{s.current?.focus()},[e.id]),(0,r.jsx)("div",{style:{position:"absolute",inset:0,zIndex:95,display:"flex",alignItems:"center",justifyContent:"center",padding:20,background:"rgba(0,0,0,0.18)"},children:(0,r.jsxs)("div",{ref:s,tabIndex:0,role:"dialog","aria-modal":"true",onKeyDown:o=>{let r=function(e){if(e.ctrlKey&&!e.metaKey&&!e.altKey&&1===e.key.length){let t=e.key.toLowerCase();if(t>="a"&&t<="z")return String.fromCharCode(t.charCodeAt(0)-96)}switch(e.key){case"ArrowUp":return"\x1b[A";case"ArrowDown":return"\x1b[B";case"ArrowRight":return"\x1b[C";case"ArrowLeft":return"\x1b[D";case"Enter":return"\r";case"Escape":return"\x1b";case"Backspace":return"";case"Tab":return" ";case" ":return" ";default:if(!e.ctrlKey&&!e.metaKey&&!e.altKey&&1===e.key.length)return e.key;return null}}(o);r&&(o.preventDefault(),o.stopPropagation(),t(e,r))},style:{width:"min(920px, 100%)",maxHeight:"min(760px, calc(100vh - 40px))",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg)",boxShadow:"0 20px 60px rgba(0,0,0,0.28)",overflow:"hidden",outline:"none"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("div",{style:{color:"var(--text)",fontSize:13,fontWeight:650},children:o("desktop.extensionPanel")}),(0,r.jsx)("button",{onClick:()=>t(e,"\x03"),style:{padding:"5px 9px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:o("desktop.close")})]}),(0,r.jsx)("pre",{style:{margin:0,padding:14,maxHeight:"calc(min(760px, 100vh - 40px) - 48px)",overflow:"auto",background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.45,whiteSpace:"pre"},children:(i.length?i:[""]).map((e,t,o)=>{var s;return(0,r.jsxs)(n.Fragment,{children:[(s=`line-${t}`,(function(e){let t,o=[],r={},n=0;for(tV.lastIndex=0;null!==(t=tV.exec(e));)t.index>n&&o.push({text:e.slice(n,t.index),style:r}),r=function(e,t){let o={...e};for(let e=0;e<t.length;e++){let r=t[e];if(0===r)for(let e of Object.keys(o))delete o[e];else if(1===r)o.fontWeight=700;else if(2===r)o.opacity=.65;else if(3===r)o.fontStyle="italic";else if(4===r)o.textDecoration="underline";else if(22===r)delete o.fontWeight,delete o.opacity;else if(23===r)delete o.fontStyle;else if(24===r)delete o.textDecoration;else if(39===r)delete o.color;else if(49===r)delete o.backgroundColor;else if(r>=30&&r<=37)o.color=tK[r-30];else if(r>=90&&r<=97)o.color=tG[r-90];else if(r>=40&&r<=47)o.backgroundColor=tK[r-40];else if(r>=100&&r<=107)o.backgroundColor=tG[r-100];else if((38===r||48===r)&&2===t[e+1]){let[n,s,i]=[t[e+2],t[e+3],t[e+4]];[n,s,i].every(e=>"number"==typeof e&&Number.isFinite(e))&&(38===r?o.color=`rgb(${n}, ${s}, ${i})`:o.backgroundColor=`rgb(${n}, ${s}, ${i})`),e+=4}else if((38===r||48===r)&&5===t[e+1]){let n=function(e){if(e>=0&&e<8)return tK[e];if(e>=8&&e<16)return tG[e-8];if(e>=16&&e<=231){let t=e-16,o=Math.floor(t/36),r=Math.floor(t%36/6),n=e=>0===e?0:55+40*e;return`rgb(${n(o)}, ${n(r)}, ${n(t%6)})`}if(e>=232&&e<=255){let t=8+(e-232)*10;return`rgb(${t}, ${t}, ${t})`}}(t[e+2]);n&&(38===r?o.color=n:o.backgroundColor=n),e+=2}}return o}(r,t[1]?t[1].split(";").map(e=>Number(e||"0")):[0]),n=t.index+t[0].length;return n<e.length&&o.push({text:e.slice(n),style:r}),o})(e).map((e,t)=>Object.keys(e.style).length>0?(0,r.jsx)("span",{style:e.style,children:e.text},`${s}-${t}`):e.text)),t<o.length-1?"\n":null]},t)})})]})})}var ay=o(93549);let ab={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif"},aw={mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",oga:"audio/ogg",opus:"audio/ogg",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",weba:"audio/webm"};function aj(e){return(e.replace(/\\/g,"/").split("/").pop()??"").toLowerCase().split(".").pop()??""}function aS(e){let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return t?.closest(".file-source-line[data-line-number]")??null}function aC(e,t){if(!t||t.isCollapsed||0===t.rangeCount)return null;let o=t.getRangeAt(0);if(!e.contains(o.startContainer)||!e.contains(o.endContainer))return null;let r=Number(aS(o.startContainer)?.dataset.lineNumber),n=Number(aS(o.endContainer)?.dataset.lineNumber);return Number.isInteger(r)&&Number.isInteger(n)?r<=n?{startLine:r,endLine:n}:{startLine:n,endLine:r}:null}function aT(e,t,o,r={}){let n=ed(e),s=new URLSearchParams({type:t});for(let[e,t]of(o&&s.set("sessionId",o),Object.entries(r)))void 0!==t&&s.set(e,String(t));return`/api/files/${n}?${s.toString()}`}function aR({filePath:e,sourceSessionId:t}){let{t:o}=(0,A.s)();return(0,r.jsx)("a",{href:aT(e,"download",t),download:ec(e),title:o("desktop.downloadFile"),style:{display:"flex",alignItems:"center",justifyContent:"center",height:20,padding:"0 5px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,textDecoration:"none"},children:(0,r.jsx)(E.z,{size:11,"aria-hidden":"true"})})}let az={fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.6,tabSize:2},aI={fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.6,padding:"12px 0 12px 16px",color:"var(--text-dim)",textAlign:"right",userSelect:"none"};async function aM(e,t){let o=await fetch(`/api/files/${ed(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});if(!o.ok)throw Error((await o.json().catch(()=>({}))).error??`HTTP ${o.status}`);let r=await o.json();return"number"==typeof r.size?r.size:0}let aP={delete:"3px solid var(--git-status-deleted)",add:"3px solid var(--git-status-added)",edit:"3px solid var(--git-status-modified)"},aE="var(--git-status-deleted-bg)",aW="var(--git-status-added-bg)",aF="var(--git-status-added)";function aD(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function aA({oldContent:e,newContent:t}){let{t:o}=(0,A.s)(),n=function(e,t){let o=e.length,r=t.length,n=o+r,s=Array(2*n+1).fill(0),i=[];for(let a=0;a<=n;a++){i.push([...s]);for(let l=-a;l<=a;l+=2){let d,c=(d=l===-a||l!==a&&s[l-1+n]<s[l+1+n]?s[l+1+n]:s[l-1+n]+1)-l;for(;d<o&&c<r&&e[d]===t[c];)d++,c++;if(s[l+n]=d,d>=o&&c>=r){let s=[],l=o,d=r;for(let o=a;o>0;o--){let r,a=i[o-1],c=l-d;r=c===-o||c!==o&&a[c-1+n]<a[c+1+n]?c+1:c-1;let p=a[r+n],u=p-r;for(;l>p&&d>u;)l--,d--,s.unshift({type:"unchanged",text:e[l]});o>0&&(l>p?(l--,s.unshift({type:"removed",text:e[l]})):(d--,s.unshift({type:"added",text:t[d]})))}for(;l>0&&d>0;)l--,d--,s.unshift({type:"unchanged",text:e[l]});return s}}}return[...e.map(e=>({type:"removed",text:e})),...t.map(e=>({type:"added",text:e}))]}(e.split("\n"),t.split("\n"));if(!n.some(e=>"unchanged"!==e.type))return(0,r.jsx)("div",{style:{padding:"12px 16px",fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:o("desktop.noChanges")});let s=new Set(n.flatMap((e,t)=>"unchanged"!==e.type?[t]:[])),i=new Set;for(let e of s)for(let t=Math.max(0,e-3);t<=Math.min(n.length-1,e+3);t++)i.add(t);let a=[],l=0;for(;l<n.length;)if(i.has(l)){let e=[];for(;l<n.length&&i.has(l);)e.push(n[l]),l++;a.push({hidden:!1,lines:e})}else{let e=0;for(;l<n.length&&!i.has(l);)e++,l++;a.push({hidden:!0,count:e})}let d=[],c=1;for(let e of n)"removed"===e.type?d.push(0):d.push(c++);let p=0;return(0,r.jsx)("div",{style:{fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.6,minWidth:"max-content"},children:a.map((e,t)=>{if(e.hidden){let n=(0,r.jsx)("div",{style:{padding:"2px 16px",color:"var(--text-dim)",background:"var(--bg-panel)",fontSize:11,borderTop:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:o("desktop.unchangedLines",{count:e.count})},t);return p+=e.count,n}let n=[],s=[],i=[],a=()=>{if(s.length||i.length){let e=s.length&&i.length?"edit":s.length?"delete":"add";for(let t of s)n.push({key:t.key,kind:"removed",text:t.text,lineNo:null,block:e});for(let t of i)n.push({key:t.key,kind:"added",text:t.text,lineNo:t.lineNo,block:e});s=[],i=[]}};e.lines.forEach((e,o)=>{"unchanged"===e.type?(a(),n.push({key:`${t}:${o}`,kind:"context",text:e.text,lineNo:d[p+o],block:null})):"removed"===e.type?s.push({key:`${t}:${o}`,text:e.text}):i.push({key:`${t}:${o}`,text:e.text,lineNo:d[p+o]})}),a();let l=n.map(e=>{let t="removed"===e.kind?aE:"added"===e.kind?aW:"transparent",o=e.block?aP[e.block]:"3px solid transparent",n="added"===e.kind?aF:"var(--text-dim)";return(0,r.jsxs)("div",{style:{display:"flex",background:t,borderLeft:o},children:[(0,r.jsx)("span",{style:{minWidth:44,padding:"0 8px 0 16px",textAlign:"right",color:n,userSelect:"none",fontSize:11,lineHeight:1.6,flexShrink:0},children:e.lineNo??""}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,padding:"0 8px 0 0",whiteSpace:"pre",color:"var(--text)"},children:e.text||"\xa0"})]},e.key)});return p+=e.lines.length,(0,r.jsx)("div",{children:l},t)})})}function aN({patch:e}){let t=rU(e);if(!t)return null;let o=[],n=[],s=[],i=()=>{if(n.length||s.length){let e=n.length&&s.length?"edit":n.length?"delete":"add";for(let t of n)o.push({key:t.key,kind:"removed",text:t.text,lineNo:null,block:e});for(let t of s)o.push({key:t.key,kind:"added",text:t.text,lineNo:t.lineNo,block:e});n=[],s=[]}};return t.forEach((e,t)=>{e.rows.forEach((e,r)=>{if("hunk"===e.type){i(),o.push({key:`${t}:${r}:h`,kind:"hunk",text:e.text,lineNo:null,block:null});return}let{left:a,right:l}=e;if("context"===a.type&&"context"===l.type){i(),o.push({key:`${t}:${r}:c`,kind:"context",text:a.text,lineNo:l.lineNo,block:null});return}"removed"===a.type&&n.push({key:`${t}:${r}:l`,text:a.text}),"added"===l.type&&s.push({key:`${t}:${r}:r`,text:l.text,lineNo:l.lineNo})})}),i(),(0,r.jsx)("div",{style:{fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,minWidth:"max-content"},children:o.map(e=>{if("hunk"===e.kind)return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{height:"1.55em"}}),(0,r.jsx)("div",{style:{padding:"3px 12px",color:"var(--accent-blue)",background:"var(--bg-secondary)"},children:e.text}),(0,r.jsx)("div",{style:{height:"1.55em"}})]},e.key);let t="removed"===e.kind?aE:"added"===e.kind?aW:"transparent",o=e.block?aP[e.block]:"3px solid transparent",n="added"===e.kind?aF:"var(--text-dim)";return(0,r.jsxs)("div",{style:{display:"flex",background:t,borderLeft:o},children:[(0,r.jsx)("span",{style:{width:44,flexShrink:0,padding:"0 8px 0 16px",textAlign:"right",color:n,userSelect:"none",fontSize:11},children:e.lineNo??""}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,padding:"0 8px 0 0",whiteSpace:"pre",color:"var(--text)"},children:e.text||"\xa0"})]},e.key)})})}function aL({filePath:e,cwd:t,sourceSessionId:o}){let{t:s}=(0,A.s)(),[i,a]=(0,n.useState)(0),[l,d]=(0,n.useState)(null),[c,p]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),g=(0,n.useRef)(null),m=ec(e).toLowerCase().split(".").pop()??"";(0,n.useEffect)(()=>{a(0),d(null),p(null),h(null),g.current&&(g.current.close(),g.current=null);let t=new EventSource(aT(e,"watch",o));return g.current=t,t.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&d(t.size)}catch{}a(e=>e+1)}),()=>{t.close(),g.current=null}},[e,o]);let f=aT(e,"read",o,i?{v:i}:void 0),x=null!=l?aD(l):null;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:ep(e,t)}),(0,r.jsx)("span",{style:{marginLeft:"auto"},children:m||s("desktop.image")}),c&&(0,r.jsxs)("span",{children:[c.w," \xd7 ",c.h]}),x&&(0,r.jsx)("span",{children:x}),(0,r.jsx)(aR,{filePath:e,sourceSessionId:o})]}),(0,r.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg-panel)",display:"flex",alignItems:"center",justifyContent:"center",padding:16,backgroundImage:"linear-gradient(45deg, var(--bg) 25%, transparent 25%), linear-gradient(-45deg, var(--bg) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--bg) 75%), linear-gradient(-45deg, transparent 75%, var(--bg) 75%)",backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px"},children:u?(0,r.jsx)("div",{style:{color:"#f87171",fontSize:13},children:u}):(0,r.jsx)("img",{src:f,alt:e,onLoad:e=>{let t=e.currentTarget;p({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>h(s("desktop.failedToLoadImage")),style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}})})]})}function a$({filePath:e,cwd:t,sourceSessionId:o}){let{t:s}=(0,A.s)(),[i,a]=(0,n.useState)(0),[l,d]=(0,n.useState)(null),[c,p]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),g=(0,n.useRef)(null),m=ec(e).toLowerCase().split(".").pop()??"";(0,n.useEffect)(()=>{a(0),d(null),p(null),h(null),g.current&&(g.current.close(),g.current=null);let t=new EventSource(aT(e,"watch",o));return g.current=t,t.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&d(t.size)}catch{}p(null),h(null),a(e=>e+1)}),()=>{t.close(),g.current=null}},[e,o]);let f=aT(e,"read",o,i?{v:i}:void 0);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:ep(e,t)}),(0,r.jsx)("span",{style:{marginLeft:"auto"},children:m||s("desktop.audio")}),null!=c&&(0,r.jsx)("span",{children:function(e){if(!Number.isFinite(e))return"";let t=Math.round(e),o=Math.floor(t/60);return`${o}:${String(t%60).padStart(2,"0")}`}(c)}),null!=l&&(0,r.jsx)("span",{children:aD(l)}),(0,r.jsx)(aR,{filePath:e,sourceSessionId:o})]}),(0,r.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,background:"var(--bg-panel)"},children:(0,r.jsxs)("div",{style:{width:"min(680px, 100%)"},children:[u&&(0,r.jsx)("div",{style:{color:"#f87171",fontSize:13,marginBottom:12,textAlign:"center"},children:u}),(0,r.jsx)("audio",{controls:!0,preload:"metadata",src:f,onLoadedMetadata:e=>p(e.currentTarget.duration),onError:()=>h(s("desktop.failedToLoadAudio")),style:{width:"100%"}},f)]})})]})}function aH({filePath:e,cwd:t,sourceSessionId:o}){let{t:s}=(0,A.s)(),[i,a]=(0,n.useState)(0),[l,d]=(0,n.useState)(null),[c,p]=(0,n.useState)(null),u=(0,n.useRef)(null),h=aj(e),g="pdf"===h,m=g?aT(e,"read",o,i?{v:i}:void 0):aT(e,"preview",o,i?{v:i}:void 0);return(0,n.useEffect)(()=>{a(0),d(null),p(null),u.current&&(u.current.close(),u.current=null),fetch(aT(e,"meta",o)).then(e=>e.json()).then(e=>{e.error&&p(e.error),"number"==typeof e.size&&(d(e.size),!g&&e.size>0xa00000&&p(s("desktop.docxTooLargeForPreview")))}).catch(e=>p(String(e)));let t=new EventSource(aT(e,"watch",o));return u.current=t,t.addEventListener("change",e=>{try{let t=JSON.parse(e.data);if("number"==typeof t.size&&(d(t.size),!g&&t.size>0xa00000))return void p(s("desktop.docxTooLargeForPreview"))}catch{}p(null),a(e=>e+1)}),()=>{t.close(),u.current=null}},[e,g,o,s]),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e,children:ep(e,t)}),(0,r.jsx)("span",{style:{marginLeft:"auto"},children:"docx"===h?s("desktop.docxPreview"):"pdf"}),null!=l&&(0,r.jsx)("span",{children:aD(l)}),(0,r.jsx)(aR,{filePath:e,sourceSessionId:o})]}),(0,r.jsx)("div",{style:{flex:1,minHeight:0,background:"var(--bg-panel)"},children:c?(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",padding:24,color:"#f87171",fontSize:13,textAlign:"center"},children:c}):(0,r.jsx)("iframe",{src:m,sandbox:g?void 0:"allow-same-origin",title:s("desktop.previewFile",{file:ec(e)}),style:{width:"100%",height:"100%",border:"none",background:g?"var(--bg)":"#eef1f5"}},m)})]})}function aO({filePath:e,cwd:t,sourceSessionId:o,onOpenFile:n,onAtMention:s,onMentionLines:i,initialDisplayMode:a,onFileSaved:l}){let d;return null!==(ab[aj(e)]??null)?(0,r.jsx)(aL,{filePath:e,cwd:t,sourceSessionId:o}):null!==(aw[aj(e)]??null)?(0,r.jsx)(a$,{filePath:e,cwd:t,sourceSessionId:o}):null!==("pdf"===(d=aj(e))||"docx"===d?d:null)?(0,r.jsx)(aH,{filePath:e,cwd:t,sourceSessionId:o}):(0,r.jsx)(aB,{filePath:e,cwd:t,sourceSessionId:o,onOpenFile:n,onAtMention:s,onMentionLines:i,initialDisplayMode:a,onFileSaved:l})}function aB({filePath:e,cwd:t,sourceSessionId:o,onOpenFile:s,onAtMention:i,onMentionLines:a,initialDisplayMode:l,onFileSaved:d}){let c,p,{t:u}=(0,A.s)(),[g,m]=(0,n.useState)(null),[x,k]=(0,n.useState)(null),[v,y]=(0,n.useState)(null),[b,w]=(0,n.useState)(!0),[j,S]=(0,n.useState)(null),[C,T]=(0,n.useState)(!1),[R,z]=(0,n.useState)("source"),[I,M]=(0,n.useState)(!1),[P,E]=(0,n.useState)(0),[W,F]=(0,n.useState)(null),D=(0,n.useRef)(null),N=(0,n.useRef)(null),[L,$]=(0,n.useState)(!1),[H,O]=(0,n.useState)(""),[B,U]=(0,n.useState)(""),[_,q]=(0,n.useState)(!1),[V,K]=(0,n.useState)(null),[G,J]=(0,n.useState)(!1),Y=(0,n.useRef)(null),X=(0,n.useRef)(null),Z=(0,n.useRef)(0),Q=(0,n.useRef)(!1);(0,n.useEffect)(()=>{Q.current=L},[L]);let ee=L&&H!==B,et=!!(g?.content&&g.content.includes("\0")),eo=(0,n.useCallback)(async e=>{if(!t)return void y(null);try{let o=new URLSearchParams({cwd:t,path:e}),r=await fetch(`/api/git/diff?${o.toString()}`),n=await r.json();y(r.ok&&n.supported&&"string"==typeof n.patch?n:null)}catch{y(null)}},[t]),er=(0,n.useCallback)((e,t=!1)=>fetch(aT(e,"read",o)).then(e=>e.json()).then(e=>e.error?(S(e.error),null):(t?(m(t=>(t&&k(t.content),e)),E(e=>e+1)):m(e),e)).catch(e=>(S(String(e)),null)),[o]);(0,n.useEffect)(()=>{w(!0),S(null),m(null),k(null),y(null),T(!1),z("source"),M(!1),E(0),$(!1),O(""),U(""),K(null),J(!1),q(!1),D.current&&(D.current.close(),D.current=null),er(e).then(e=>{(e?.language==="markdown"||e?.language==="html")&&"diff"!==l&&T(!0)}).finally(()=>w(!1)),eo(e);let t=new EventSource(aT(e,"watch",o));return D.current=t,t.addEventListener("change",()=>{Q.current?J(!0):(er(e,!0),eo(e))}),()=>{t.close(),D.current=null}},[e,er,eo,l,o]);let en=(0,n.useCallback)(()=>{g&&!et&&(O(g.content),U(g.content),K(null),J(!1),$(!0))},[g,et]),es=(0,n.useCallback)(()=>{$(!1),O(""),U(""),K(null),J(!1)},[]),ei=(0,n.useCallback)(()=>{(!ee||window.confirm(u("files.unsavedChanges")))&&es()},[ee,es,u]),ea=(0,n.useCallback)(async()=>{if(!g||_)return;let t=++Z.current;q(!0),K(null);try{let o=await aM(e,H);if(t!==Z.current)return;m(e=>e?{...e,content:H,size:o}:e),U(H),q(!1),es(),eo(e),d?.()}catch(e){if(t!==Z.current)return;K(e instanceof Error?e.message:String(e)),q(!1)}},[g,_,H,e,es,eo,d]);(0,n.useEffect)(()=>{if(!L)return;let e=e=>{if((e.metaKey||e.ctrlKey)&&"s"===e.key.toLowerCase()){e.preventDefault(),ea();return}"Escape"===e.key&&(e.preventDefault(),ei())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[L,ea,ei]),(0,n.useEffect)(()=>{if(!ee)return;let e=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[ee]);let ed=(0,n.useCallback)(()=>{let e=Y.current,t=X.current;e&&t&&(t.scrollTop=e.scrollTop)},[]),ec=(0,n.useCallback)(e=>{if("Tab"!==e.key||e.metaKey||e.ctrlKey||e.altKey)return;e.preventDefault();let t=e.currentTarget,{selectionStart:o,selectionEnd:r}=t;O(t.value.slice(0,o)+" "+t.value.slice(r)),requestAnimationFrame(()=>{let e=Y.current;if(!e)return;let t=o+2;e.selectionStart=t,e.selectionEnd=t})},[]),eu=(0,n.useMemo)(()=>ru(g?.content??""),[g?.content]),eh=v?.supported===!0&&"string"==typeof v.patch;(0,n.useEffect)(()=>{"diff"===l&&eh&&z("diff")},[eh,l]);let em=eh&&v?.status==="deleted",ef=(0,n.useCallback)(o=>{a&&o&&a(ep(e,t),o.startLine,o.endLine)},[t,e,a]);if((0,n.useEffect)(()=>{let e=()=>{let e=N.current,t="source"===R&&!C;F(a&&t&&e?aC(e,window.getSelection()):null)};if(e(),a&&"source"===R&&!C)return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[g?.content,a,C,R]),(0,n.useEffect)(()=>{if(!a||"source"!==R||C)return;let e=e=>{if(e.repeat||"i"!==e.key.toLowerCase()||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey)return;let t=e.target;if(t instanceof Element&&t.closest("input, textarea, [contenteditable='true']"))return;let o=N.current,r=o?aC(o,window.getSelection()):null;r&&(e.preventDefault(),ef(r))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[ef,a,C,R]),b)return(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:13},children:u("desktop.loadingFile")});if(em&&!g)return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsx)("div",{style:{padding:"5px 16px",borderBottom:"1px solid var(--border)",color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11},title:e,children:ep(e,t)}),(0,r.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg)"},children:(0,r.jsx)(aN,{patch:v.patch})})]});if(j)return(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#f87171",fontSize:13},children:j});if(!g)return null;let ex="html"===g.language,ek="markdown"===g.language,ev=(p=(c=el(e).replace(/\/+$/,"")).lastIndexOf("/"))<0?"":0===p?"/":2===p&&/^[a-zA-Z]:\//.test(c)?c.slice(0,3):c.slice(0,p),ey=g.content.split("\n"),eb=null!==x&&x!==g.content||eh,ew=!em&&!et&&eg();return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:ep(e,t)}),(0,r.jsx)("span",{style:{marginLeft:"auto"},children:g.language}),"source"===R&&!L&&(0,r.jsx)("span",{children:u("desktop.lines",{count:ey.length})}),(0,r.jsx)("span",{children:aD(g.size)}),eb&&!L&&(0,r.jsxs)("div",{style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:[(0,r.jsx)("button",{onClick:()=>z("source"),style:{padding:"2px 8px",fontSize:11,border:"none",cursor:"pointer",background:"source"===R?"var(--bg-selected)":"var(--bg-hover)",color:"source"===R?"var(--text)":"var(--text-muted)",fontWeight:"source"===R?600:400},children:u("desktop.source")}),(0,r.jsxs)("button",{onClick:()=>z("diff"),style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:"1px solid var(--border)",cursor:"pointer",background:"diff"===R?"var(--bg-selected)":"var(--bg-hover)",color:"diff"===R?"var(--text)":"var(--text-muted)",fontWeight:"diff"===R?600:400},children:[u("desktop.diff")," ",P>0&&(0,r.jsxs)("span",{style:{color:"var(--git-status-added)",marginLeft:2},children:["+",P]})]})]}),"source"===R&&!C&&!L&&(0,r.jsx)("button",{onClick:()=>M(e=>!e),title:I?u("desktop.disableWordWrap"):u("desktop.enableWordWrap"),style:{padding:"2px 8px",fontSize:11,cursor:"pointer",background:I?"var(--bg-selected)":"var(--bg-hover)",color:I?"var(--text)":"var(--text-muted)",border:"1px solid var(--border)",borderRadius:5,fontWeight:I?600:400},children:u("desktop.wrap")}),ex&&"source"===R&&!L&&(0,r.jsxs)("div",{style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:[(0,r.jsx)("button",{onClick:()=>T(!1),style:{padding:"2px 8px",fontSize:11,border:"none",cursor:"pointer",background:C?"var(--bg-hover)":"var(--bg-selected)",color:C?"var(--text-muted)":"var(--text)",fontWeight:C?400:600},children:u("desktop.code")}),(0,r.jsx)("button",{onClick:()=>T(!0),style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:"1px solid var(--border)",cursor:"pointer",background:C?"var(--bg-selected)":"var(--bg-hover)",color:C?"var(--text)":"var(--text-muted)",fontWeight:C?600:400},children:u("desktop.preview")})]}),ek&&"source"===R&&!L&&(0,r.jsxs)("div",{style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:[(0,r.jsx)("button",{onClick:()=>T(!0),style:{padding:"2px 8px",fontSize:11,border:"none",cursor:"pointer",background:C?"var(--bg-selected)":"var(--bg-hover)",color:C?"var(--text)":"var(--text-muted)",fontWeight:C?600:400},children:u("desktop.preview")}),(0,r.jsx)("button",{onClick:()=>T(!1),style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:"1px solid var(--border)",cursor:"pointer",background:C?"var(--bg-hover)":"var(--bg-selected)",color:C?"var(--text-muted)":"var(--text)",fontWeight:C?400:600},children:u("desktop.raw")})]}),L?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onClick:()=>void ea(),disabled:_,title:u("files.saveHint"),"aria-label":u("files.save"),style:{height:20,minWidth:20,padding:"0 5px",display:"inline-flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-selected)",color:"var(--text)",cursor:"pointer"},children:(0,r.jsx)(ay.g,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:ei,disabled:_,title:u("files.cancelEdit"),"aria-label":u("files.cancelEdit"),style:{height:20,minWidth:20,padding:"0 5px",display:"inline-flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer"},children:(0,r.jsx)(h.X,{size:13,"aria-hidden":"true"})})]}):"source"===R&&ew?(0,r.jsx)("button",{type:"button",onClick:en,title:u("files.edit"),"aria-label":u("files.edit"),style:{height:20,minWidth:20,padding:"0 5px",display:"inline-flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer"},children:(0,r.jsx)(f.I,{size:13,"aria-hidden":"true"})}):null,(i||a)&&!L&&(0,r.jsx)("button",{type:"button",onPointerDown:e=>e.preventDefault(),onClick:()=>{W&&a?ef(W):i?.(ep(e,t),!1)},title:W?u("desktop.mentionSelectedLines",{start:W.startLine,end:W.endLine}):u("desktop.mentionFile"),"aria-label":W?u("desktop.mentionSelectedLines",{start:W.startLine,end:W.endLine}):u("desktop.mentionFile"),style:{height:20,minWidth:20,padding:"0 5px",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer"},children:"@"}),!L&&(0,r.jsx)(aR,{filePath:e,sourceSessionId:o})]}),(0,r.jsx)("div",{ref:N,style:{flex:1,overflow:"auto",background:"var(--bg)"},children:L?(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[G&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 12px",borderBottom:"1px solid var(--border)",background:"rgba(214,168,75,0.14)",color:"#d6a84b",fontSize:11,flexShrink:0},children:[(0,r.jsx)("span",{style:{flex:1},children:u("files.externalModified")}),(0,r.jsx)("button",{type:"button",onClick:()=>{(!ee||window.confirm(u("files.reloadOverwriteConfirm")))&&er(e).then(e=>{e&&(O(e.content),U(e.content),J(!1))})},disabled:_,style:{padding:"2px 8px",fontSize:11,border:"1px solid #d6a84b",borderRadius:4,background:"transparent",color:"#d6a84b",cursor:"pointer"},children:u("files.reload")})]}),V&&(0,r.jsx)("div",{style:{padding:"5px 12px",borderBottom:"1px solid var(--border)",background:"rgba(248,113,113,0.14)",color:"#f87171",fontSize:11,flexShrink:0},children:u("files.saveFailed",{error:V})}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(0,r.jsx)("div",{ref:X,"aria-hidden":"true",style:{...aI,height:"100%",overflow:"hidden",whiteSpace:"pre",pointerEvents:"none"},children:H.split("\n").map((e,t)=>`${t+1}
|
|
37
|
-
`).join("")}),(0,r.jsx)("textarea",{ref:Y,value:H,onChange:e=>O(e.target.value),onScroll:ed,onKeyDown:ec,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",wrap:"off",style:{flex:1,height:"100%",resize:"none",border:"none",outline:"none",background:"var(--bg)",color:"var(--text)",...az,whiteSpace:"pre",overflow:"auto",padding:0,tabSize:2}})]})]}):"diff"===R&&eb?eh?(0,r.jsx)(aN,{patch:v.patch}):(0,r.jsx)(aA,{oldContent:x,newContent:g.content}):ex&&C?(0,r.jsx)("iframe",{srcDoc:g.content,sandbox:"allow-scripts",style:{width:"100%",height:"100%",border:"none",background:"var(--bg)"},title:u("desktop.htmlPreview")}):ek&&C?(0,r.jsx)("div",{className:"markdown-body markdown-file-preview",style:{padding:"24px 32px"},children:(0,r.jsx)(on.oz,{remarkPlugins:rm,rehypePlugins:rf,components:{h1:({children:e})=>(0,r.jsx)("h1",{id:rp(e),children:e}),h2:({children:e})=>(0,r.jsx)("h2",{id:rp(e),children:e}),h3:({children:e})=>(0,r.jsx)("h3",{id:rp(e),children:e}),code({className:e,children:t,...o}){let n=e?.replace("language-","").toLowerCase()??"",s=String(t);return e?.includes("language-")||s.includes("\n")?"mermaid"===n?(0,r.jsx)(rE,{code:s.replace(/\n$/,"")}):(0,r.jsx)(rD,{code:s.replace(/\n$/,""),lang:n}):(0,r.jsx)("code",{className:"inline max-w-full whitespace-normal break-words [overflow-wrap:anywhere] align-baseline bg-(--bg-secondary) border border-(--border) px-1.5 py-0.5 text-xs font-mono text-(--accent-blue)",...o,children:t})},pre:({children:e})=>(0,r.jsx)(r.Fragment,{children:e}),a({href:e,children:o,...n}){delete n.node;let i="text-(--accent-blue) underline underline-offset-2 hover:text-(--accent-blue)/80",a=s?oe(e,ev,t??ev):null;return a&&s?(0,r.jsx)("a",{href:e,...n,className:i,onClick:e=>{if(e.defaultPrevented||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.currentTarget.getAttribute("target");t&&"_self"!==t||(e.preventDefault(),s(a))},children:o}):(0,r.jsx)("a",{href:e,...n,className:i,target:"_blank",rel:"noopener noreferrer",children:o})},table:({children:e})=>(0,r.jsx)("div",{className:"my-3 rounded-lg overflow-hidden border border-(--border)",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsx)("table",{className:"w-full text-sm border-collapse [&_tr:last-child>td]:border-b-0",children:e})})})},children:eu})}):(0,r.jsx)(os.A,{language:"text"===g.language?"plaintext":g.language,style:rx,showLineNumbers:!0,lineNumberStyle:{color:"var(--text-dim)",fontStyle:"normal",minWidth:"3em",paddingRight:"1em"},customStyle:{margin:0,padding:"12px 0",background:"var(--bg)",fontSize:13,lineHeight:1.6,fontFamily:"var(--font-mono)",minHeight:"100%"},codeTagProps:{style:{fontFamily:"var(--font-mono)"}},lineProps:e=>({className:"file-source-line","data-line-number":String(e)}),wrapLongLines:I,children:g.content})})]})}function aU({tabs:e,activeTabId:t,onSelectTab:o,onCloseTab:s}){let{t:i}=(0,A.s)(),[a,l]=(0,n.useState)(null);return(0,r.jsx)("div",{role:"tablist",style:{display:"flex",alignItems:"flex-end",background:"var(--bg-panel)",overflowX:"auto",flexShrink:0,height:36},children:e.map(n=>{let d=n.id===t;return(0,r.jsxs)("div",{role:"tab","aria-label":"terminal"===n.kind?i("terminal.tabLabel",{name:n.label}):n.label,"aria-selected":d,tabIndex:d||!t&&e[0].id===n.id?0:-1,onKeyDown:t=>{if(t.target===t.currentTarget){if("Enter"===t.key||" "===t.key)t.preventDefault(),o(n.id);else if(["ArrowLeft","ArrowRight","Home","End"].includes(t.key)){t.preventDefault();let r=e.findIndex(e=>e.id===n.id),s="Home"===t.key?0:"End"===t.key?e.length-1:(r+("ArrowRight"===t.key?1:-1)+e.length)%e.length;o(e[s].id),t.currentTarget.parentElement?.children[s]?.focus()}}},onClick:()=>o(n.id),onMouseDown:e=>{1===e.button&&e.preventDefault()},onAuxClick:e=>{1===e.button&&(e.preventDefault(),e.stopPropagation(),n.closing||s(n.id))},style:{display:"flex",alignItems:"center",gap:6,height:36,paddingLeft:12,paddingRight:6,borderRight:"1px solid var(--border)",background:d?"var(--bg)":"var(--bg-panel)",cursor:"pointer",fontSize:12,color:d?"var(--text)":"var(--text-muted)",whiteSpace:"nowrap",maxWidth:180,minWidth:80,flexShrink:0,userSelect:"none",transition:"background 0.1s, color 0.1s"},children:[(0,r.jsx)("span",{style:{flexShrink:0,opacity:d?1:.7,display:"flex",alignItems:"center"},children:"terminal"===n.kind?(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,r.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}):ea(n.label,13)}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,fontWeight:d?500:400},title:n.filePath,children:n.label}),(0,r.jsx)("button",{disabled:n.closing,onClick:e=>{e.stopPropagation(),s(n.id)},onMouseEnter:()=>l(n.id),onMouseLeave:()=>l(null),style:{display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,background:a===n.id?"var(--bg-hover)":"transparent",border:"none",borderRadius:4,color:a===n.id?"var(--text)":"var(--text-dim)",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.1s, color 0.1s"},title:i("desktop.closeTab"),"aria-label":i("desktop.closeTabWithLabel",{label:n.label}),children:(0,r.jsx)(h.X,{size:11,"aria-hidden":"true"})})]},n.id)})})}var a_=o(27289),aq=o(93534),aV=o(45781),aK=o(68731),aG=o(93912),aJ=o(23675),aY=o(48716),aX=o(47013),aZ=o(51265);let aQ={"restore-script":"restore","generate-cmd":"cmd",keep:"keep","keep-with-warning":"warning",manual:"manual"};function a0({cwd:e}){let{t}=(0,A.s)(),o=(0,n.useRef)(null),[s,i]=(0,n.useState)(!0),[a,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(!1),[p,u]=(0,n.useState)(null),[h,g]=(0,n.useState)(null),[m,f]=(0,n.useState)(new Set),[x,k]=(0,n.useState)(new Set),[v,y]=(0,n.useState)(!1),[b,w]=(0,n.useState)(null),[j,S]=(0,n.useState)(!1),[C,T]=(0,n.useState)(null),[R,z]=(0,n.useState)([]),[I,M]=(0,n.useState)(""),[P,E]=(0,n.useState)(null),[W,F]=(0,n.useState)(null);(0,n.useEffect)(()=>{fetch("/api/models").then(e=>e.json()).then(e=>{let t=e.models??[];z(t),t.length>0&&M(`${t[0].provider}/${t[0].id}`)}).catch(()=>{})},[]);let D=(0,n.useCallback)(async()=>{c(!0),u(null);try{let e=await fetch("/api/backup/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({includeSecrets:s,includeSessions:a})});if(!e.ok){let t=await e.json();u(t.error??`HTTP ${e.status}`);return}let t=await e.blob(),o=(e.headers.get("Content-Disposition")??"").match(/filename="?([^";]+)"?/),r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download=o?.[1]??"pi-backup.zip",document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(r)}catch{u(String(t("desktop.backupExportFailed")))}finally{c(!1)}},[s,a,t]),N=(0,n.useCallback)(async e=>{if(e){w(null),T(null),g(null);try{let o=new FormData;o.append("phase","parse"),o.append("file",e);let r=await fetch("/api/backup/import",{method:"POST",body:o}),n=await r.json();if(!r.ok||n.error)return void w(n.error??`HTTP ${r.status}`);if("preview"!==n.phase||!n.preview)return void w(String(t("desktop.backupImportFailed")));g(n),f(new Set(n.preview.categories)),k(new Set),y(!1)}catch{w(String(t("desktop.backupImportFailed")))}}},[t]),L=(0,n.useCallback)(async()=>{if(h){S(!0),w(null);try{let e=new FormData;e.append("phase","restore"),e.append("token",h.token),e.append("selections",JSON.stringify({categories:[...m],skippedMcpServers:[...x],reinstallNpm:v}));let r=await fetch("/api/backup/import",{method:"POST",body:e}),n=await r.json();if(!r.ok||n.error)return void w(n.error??`HTTP ${r.status}`);if("report"!==n.phase||!n.report)return void w(String(t("desktop.backupRestoreFailed")));T(n.report),g(null),o.current&&(o.current.value="")}catch{w(String(t("desktop.backupRestoreFailed")))}finally{S(!1)}}},[h,m,x,v,t]),$=(0,n.useCallback)(async o=>{if(o.installPrompt&&e){E(o.name),F(null);try{let t=I.indexOf("/"),r=t>0?I.slice(0,t):void 0,n=t>0?I.slice(t+1):void 0,s=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,message:o.installPrompt,provider:r,modelId:n})}),i=await s.json();if(!s.ok||i.error)return void w(i.error??`HTTP ${s.status}`);F({server:o.name,sessionId:i.sessionId})}catch{w(String(t("desktop.backupInstallSessionFailed")))}finally{E(null)}}},[e,I,t]),H=e=>"win32"===e?"Windows":"darwin"===e?"macOS":"Linux";return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0,overflowY:"auto"},children:[(0,r.jsx)("header",{style:{padding:"18px 22px 14px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("h1",{style:{margin:0,fontSize:16,fontWeight:700,color:"var(--text)"},children:t("desktop.backup")})}),(0,r.jsxs)("section",{style:{padding:"18px 22px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("h2",{style:{margin:0,fontSize:13,fontWeight:600,color:"var(--text)"},children:t("desktop.backupExportTitle")}),(0,r.jsx)("p",{style:{margin:"6px 0 12px",fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:t("desktop.backupExportDescription")}),(0,r.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"flex-start",cursor:"pointer",marginBottom:8},children:[(0,r.jsx)("input",{type:"checkbox",checked:s,onChange:e=>i(e.target.checked),style:{marginTop:2}}),(0,r.jsxs)("span",{style:{fontSize:12,color:"var(--text)"},children:[t("desktop.backupIncludeSecrets"),(0,r.jsx)("span",{style:{display:"block",fontSize:11,color:"#ef4444"},children:t("desktop.backupSecretsWarning")})]})]}),(0,r.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"flex-start",cursor:"pointer",marginBottom:14},children:[(0,r.jsx)("input",{type:"checkbox",checked:a,onChange:e=>l(e.target.checked),style:{marginTop:2}}),(0,r.jsxs)("span",{style:{fontSize:12,color:"var(--text)"},children:[t("desktop.backupIncludeSessions"),(0,r.jsx)("span",{style:{display:"block",fontSize:11,color:"var(--text-dim)"},children:t("desktop.backupSessionsHint")})]})]}),(0,r.jsxs)("button",{type:"button",onClick:D,disabled:d,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 14px",background:"var(--accent)",border:"none",borderRadius:6,color:"#fff",fontSize:12,fontWeight:600,cursor:d?"wait":"pointer"},children:[(0,r.jsx)(aX.f,{size:15,"aria-hidden":"true"}),d?t("desktop.backupExporting"):t("desktop.backupExportButton")]}),p&&(0,r.jsx)("p",{style:{margin:"8px 0 0",fontSize:11,color:"#ef4444"},children:p})]}),(0,r.jsxs)("section",{style:{padding:"18px 22px"},children:[(0,r.jsx)("h2",{style:{margin:0,fontSize:13,fontWeight:600,color:"var(--text)"},children:t("desktop.backupImportTitle")}),(0,r.jsx)("p",{style:{margin:"6px 0 12px",fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:t("desktop.backupImportDescription")}),(0,r.jsx)("input",{ref:o,type:"file",accept:".zip,application/zip",onChange:e=>N(e.target.files?.[0]),style:{display:"none"}}),(0,r.jsxs)("button",{type:"button",onClick:()=>o.current?.click(),style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 14px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,fontWeight:600,cursor:"pointer"},children:[(0,r.jsx)(aZ._,{size:15,"aria-hidden":"true"}),t("desktop.backupImportButton")]}),b&&(0,r.jsx)("p",{style:{margin:"0 0 10px",fontSize:11,color:"#ef4444",lineHeight:1.5},children:b}),h&&(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:8,padding:14,background:"var(--bg-panel)",display:"flex",flexDirection:"column",gap:12},children:[(0,r.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:[(0,r.jsxs)("span",{style:{color:"var(--text)",fontWeight:600},children:[t("desktop.backupManifest"),":"]})," ",new Date(h.preview.manifest.createdAt).toLocaleString()," \xb7 ",H(h.preview.manifest.sourcePlatform)," →",H(navigator.platform.includes("Win")?"win32":navigator.platform.includes("Linux")?"linux":"darwin")," \xb7 pi-web ",h.preview.manifest.piWebVersion,h.preview.manifest.includeSecrets?"":` \xb7 ${t("desktop.backupNoSecrets")}`]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:6},children:t("desktop.backupCategories")}),(0,r.jsx)("div",{style:{display:"flex",gap:14,flexWrap:"wrap"},children:h.preview.categories.map(e=>(0,r.jsxs)("label",{style:{display:"flex",gap:6,alignItems:"center",cursor:"pointer",fontSize:12,color:"var(--text)"},children:[(0,r.jsx)("input",{type:"checkbox",checked:m.has(e),onChange:t=>{let o=new Set(m);t.target.checked?o.add(e):o.delete(e),f(o)}}),t(`desktop.backupCategory${e}`)]},e))})]}),h.preview.servers.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:6},children:t("desktop.backupMcpServers")}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:h.preview.servers.map(o=>(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,fontSize:12},children:[(0,r.jsx)("input",{type:"checkbox",checked:!x.has(o.name),onChange:e=>{let t=new Set(x);e.target.checked?t.delete(o.name):t.add(o.name),k(t)},style:{marginTop:2}}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:2},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("code",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text)"},children:o.name}),(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:8,background:"manual"===o.action||"keep-with-warning"===o.action?"rgba(239,68,68,0.15)":"var(--bg-selected)",color:"manual"===o.action||"keep-with-warning"===o.action?"#ef4444":"var(--text-muted)"},children:aQ[o.action]})]}),(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[(0,r.jsx)("code",{style:{fontFamily:"var(--font-mono)"},children:o.original.command}),o.adapted&&o.adapted.command!==o.original.command&&(0,r.jsxs)(r.Fragment,{children:[" → ",(0,r.jsx)("code",{style:{fontFamily:"var(--font-mono)",color:"var(--text)"},children:o.adapted.command})]})]}),o.reason&&(0,r.jsx)("div",{style:{fontSize:11,color:"#ef4444"},children:o.reason}),"manual"===o.action&&o.installPrompt&&e&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:2,flexWrap:"wrap"},children:[(0,r.jsx)("select",{value:I,onChange:e=>M(e.target.value),style:{fontSize:11,padding:"4px 6px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text)",maxWidth:220},title:t("desktop.backupInstallModel"),children:R.map(e=>(0,r.jsxs)("option",{value:`${e.provider}/${e.id}`,children:[e.provider,"/",e.name||e.id]},`${e.provider}/${e.id}`))}),(0,r.jsx)("button",{type:"button",disabled:P===o.name,onClick:()=>$(o),style:{padding:"4px 10px",fontSize:11,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text)",cursor:P===o.name?"wait":"pointer"},children:P===o.name?"…":t("desktop.backupInstallSession")}),W?.server===o.name&&(0,r.jsx)("a",{href:`?session=${encodeURIComponent(W.sessionId)}`,style:{fontSize:11,color:"var(--accent)"},children:t("desktop.backupOpenSession")})]})]})]},o.name))})]}),h.preview.npmPackages.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:6},children:t("desktop.backupNpmPackages")}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:6},children:h.preview.npmPackages.map(e=>(0,r.jsx)("code",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text)"},children:e},e))}),(0,r.jsxs)("label",{style:{display:"flex",gap:6,alignItems:"flex-start",cursor:"pointer",fontSize:12,color:"var(--text)",lineHeight:1.4},children:[(0,r.jsx)("input",{type:"checkbox",checked:v,onChange:e=>y(e.target.checked),style:{marginTop:2}}),(0,r.jsxs)("span",{children:[t("desktop.backupReinstallNpm"),(0,r.jsx)("span",{style:{display:"block",fontSize:11,color:"var(--text-dim)"},children:t("desktop.backupReinstallNpmHint")})]})]})]}),h.preview.warnings.length>0&&(0,r.jsx)("div",{style:{fontSize:11,color:"#ef4444",lineHeight:1.5},children:h.preview.warnings.map((e,t)=>(0,r.jsxs)("div",{children:["⚠ ",e]},t))}),(0,r.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,r.jsxs)("button",{type:"button",onClick:L,disabled:j||0===m.size,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 14px",background:"var(--accent)",border:"none",borderRadius:6,color:"#fff",fontSize:12,fontWeight:600,cursor:j?"wait":"pointer",opacity:0===m.size?.5:1},children:[(0,r.jsx)(aZ._,{size:15,"aria-hidden":"true"}),j?t("desktop.backupRestoring"):t("desktop.backupRestoreButton")]}),(0,r.jsx)("button",{type:"button",onClick:()=>{g(null),o.current&&(o.current.value="")},disabled:j,style:{padding:"8px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",fontSize:12,cursor:"pointer"},children:t("desktop.cancel")})]})]}),C&&(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:8,padding:14,background:"var(--bg-panel)",display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:"var(--text)"},children:[(0,r.jsx)(rQ.W,{size:16,"aria-hidden":"true"}),t("desktop.backupRestoreReport")]}),C.restored.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{fontSize:11,fontWeight:600,color:"#4ade80",marginBottom:4},children:["✓ ",t("desktop.backupReportRestored")]}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.6,fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:C.restored.join("\n")})]}),C.needsRestart.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{fontSize:11,fontWeight:600,color:"#fbbf24",marginBottom:4},children:["\uD83D\uDD04 ",t("desktop.backupReportRestart")]}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.6,fontFamily:"var(--font-mono)"},children:C.needsRestart.join("\n")})]}),C.manual.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{fontSize:11,fontWeight:600,color:"#ef4444",marginBottom:4},children:[(0,r.jsx)(X.N,{size:12,style:{verticalAlign:-2},"aria-hidden":"true"})," ",t("desktop.backupReportManual")]}),C.manual.map((e,t)=>(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.6},children:[(0,r.jsx)("strong",{style:{color:"var(--text)"},children:e.server}),": ",e.message]},t))]}),C.warnings.length>0&&(0,r.jsx)("div",{style:{fontSize:11,color:"#ef4444",lineHeight:1.6},children:C.warnings.map((e,t)=>(0,r.jsxs)("div",{children:["⚠ ",e]},t))}),C.needsRestart.length>0&&(0,r.jsx)("p",{style:{margin:0,fontSize:11,color:"#fbbf24",lineHeight:1.5},children:t("desktop.backupRestartHint")})]})]})]})}let a1={position:"relative",width:40,height:22,borderRadius:11,border:"none",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.18s ease",outline:"none"},a2={position:"absolute",top:3,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left 0.18s ease, transform 0.18s ease",boxShadow:"0 1px 3px rgba(0,0,0,0.18)"};function a4({checked:e,onChange:t,label:o,description:n}){return(0,r.jsxs)("label",{style:{display:"flex",alignItems:n?"flex-start":"center",justifyContent:"space-between",gap:12,padding:"12px 14px",borderRadius:7,cursor:"pointer",userSelect:"none",transition:"background 0.12s",margin:"0 -14px"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:[(0,r.jsxs)("span",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("span",{style:{display:"block",fontSize:13,fontWeight:550,color:"var(--text)",lineHeight:1.4},children:o}),n&&(0,r.jsx)("span",{style:{display:"block",fontSize:11,lineHeight:1.5,color:"var(--text-muted)",marginTop:2},children:n})]}),(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":e,onClick:o=>{o.preventDefault(),t(!e)},style:{...a1,background:e?"var(--accent)":"color-mix(in srgb, var(--border) 70%, var(--bg))"},children:(0,r.jsx)("span",{style:{...a2,left:e?21:3}})})]})}function a6({title:e,description:t,children:o}){return(0,r.jsxs)("section",{style:{padding:"20px 22px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("h2",{style:{margin:0,fontSize:14,fontWeight:650,color:"var(--text)"},children:e}),(0,r.jsx)("p",{style:{margin:"5px 0 14px",fontSize:12,lineHeight:1.5,color:"var(--text-muted)"},children:t}),(0,r.jsx)("div",{children:o})]})}let a8="pi-input-shortcut";function a5(){try{let e=localStorage.getItem(a8);return"ctrl-enter"===e?"ctrl-enter":"enter"}catch{return"enter"}}function a3(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)(a5);(0,n.useEffect)(()=>{let e=()=>o(a5());return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]);let s=(0,n.useCallback)(e=>{o(e);try{localStorage.setItem(a8,e),window.dispatchEvent(new StorageEvent("storage",{key:a8,newValue:e}))}catch{}},[]);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0,overflowY:"auto"},children:[(0,r.jsx)("header",{style:{padding:"18px 22px 14px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("h1",{style:{margin:0,fontSize:16,fontWeight:700,color:"var(--text)"},children:e("desktop.chat")})}),(0,r.jsx)(a6,{title:e("desktop.inputShortcut"),description:e("desktop.inputShortcutDescription"),children:(0,r.jsx)(a4,{checked:"ctrl-enter"===t,onChange:e=>s(e?"ctrl-enter":"enter"),label:e("desktop.useCtrlEnter"),description:e("desktop.useCtrlEnterDescription")})})]})}var a7=o(95650),a9=o(55803),le=o(23602),lt=o(18613),lo=o(12779);let lr={display:"flex",gap:6,flexWrap:"wrap"};function ln(e,t,o){return{display:"inline-flex",alignItems:"center",gap:7,padding:"7px 14px",border:`1px solid ${e?"var(--accent)":t?"var(--border-hover)":"var(--border)"}`,borderRadius:8,background:e?"color-mix(in srgb, var(--accent) 12%, var(--bg))":t?"var(--bg-hover)":"var(--bg-card)",color:e?"var(--accent)":t?"var(--text)":"var(--text-muted)",fontSize:13,fontWeight:e?600:400,cursor:o?"not-allowed":"pointer",opacity:o?.5:1,transition:"border-color 0.15s, background 0.15s, color 0.15s",outline:"none",whiteSpace:"nowrap"}}function ls({icon:e,label:t,actions:o}){return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10,width:"100%"},children:[(0,r.jsx)("span",{style:{color:"var(--text-dim)",display:"inline-flex",flexShrink:0},children:e}),(0,r.jsx)("span",{style:{fontSize:11,fontWeight:700,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em"},children:t}),o&&(0,r.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:12,marginLeft:"auto"},children:o})]})}let li={display:"inline-flex",alignItems:"center",gap:6,padding:0,border:0,background:"transparent",color:"var(--accent)",fontSize:11,cursor:"pointer",whiteSpace:"nowrap"},la={onMouseEnter:e=>{e.currentTarget.style.textDecoration="underline"},onMouseLeave:e=>{e.currentTarget.style.textDecoration="none"}};function ll({title:e,description:t,children:o}){return(0,r.jsxs)("section",{style:{padding:"20px 22px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("h2",{style:{margin:0,fontSize:14,fontWeight:650,color:"var(--text)"},children:e}),(0,r.jsx)("p",{style:{margin:"5px 0 16px",fontSize:12,lineHeight:1.5,color:"var(--text-muted)"},children:t}),o]})}function ld({depth:e}){let t=e/100;return(0,r.jsxs)("svg",{width:14,height:14,viewBox:"0 0 14 14",style:{flexShrink:0},children:[(0,r.jsx)("rect",{x:1.5,y:1.5,width:11,height:11,rx:2.5,style:{fill:"none",stroke:"var(--text-dim)",strokeWidth:1+2*t,opacity:.2+.8*t}}),(0,r.jsx)("rect",{x:4,y:4,width:6,height:6,rx:1,style:{fill:"var(--text-dim)",opacity:.05+.35*t}})]})}function lc({hasDark:e,hasLight:t,darkColor:o,lightColor:n,t:s}){return(0,r.jsxs)("span",{style:{display:"inline-flex",gap:3,alignItems:"center",flexShrink:0},children:[e&&(0,r.jsx)("span",{title:s("desktop.darkVariant"),style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:o??"#7c6f64"}}),t&&(0,r.jsx)("span",{title:s("desktop.lightVariant"),style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:n??"#d5c4a1",border:"1px solid rgba(0,0,0,0.1)"}})]})}function lp(){let{mode:e,resolvedMode:t,themeName:o,setMode:s,setTheme:i,previewTheme:a,clearPreview:l,isThemeCached:d,borderDepth:c,setBorderDepth:p}=o9(),{locale:u,setLocale:h,t:g}=(0,A.s)(),[m,f]=(0,n.useState)([]),[x,k]=(0,n.useState)(!0),[v,y]=(0,n.useState)(null),[b,w]=(0,n.useState)(null);(0,n.useEffect)(()=>{let e=!1;return fetch("/api/themes").then(e=>e.ok?e.json():null).then(t=>{!e&&t&&f(t.themeSets)}).catch(()=>{}).finally(()=>{e||k(!1)}),()=>{e=!0}},[]);let j=(0,n.useCallback)(e=>{y(e),i(e).finally(()=>y(null))},[i]),S=(0,n.useRef)(null),C=(0,n.useCallback)(e=>{w(e),null!==S.current&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{S.current=null,null!==e?d(e)&&a(e):l()},160)},[a,l,d]),T=(0,n.useCallback)(e=>{s(e)},[s]),R=(0,n.useCallback)(()=>{window.piDesktop?.openThemeFolder()},[]),z=(0,n.useCallback)(()=>{window.piDesktop?window.piDesktop.openThemeDocs():window.open("https://pi.dev/docs/latest/themes","_blank","noopener,noreferrer")},[]);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0,overflowY:"auto"},children:[(0,r.jsx)("header",{style:{padding:"18px 22px 14px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("h1",{style:{margin:0,fontSize:16,fontWeight:700,color:"var(--text)"},children:g("desktop.display")})}),(0,r.jsxs)(ll,{title:g("desktop.theme"),description:g("desktop.themeDescription"),children:[(0,r.jsx)(ls,{icon:(0,r.jsx)(a7.p,{size:14,weight:"fill"}),label:g("desktop.colorScheme"),actions:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button",onClick:R,style:li,...la,children:[(0,r.jsx)(a9.N,{size:12,weight:"regular","aria-hidden":"true"}),g("desktop.openThemeFolder")]}),(0,r.jsxs)("button",{type:"button",onClick:z,style:li,...la,children:[(0,r.jsx)(le.B,{size:12,weight:"regular","aria-hidden":"true"}),g("desktop.learnPiThemes")]})]})}),x?(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-dim)"},children:g("desktop.loadingThemes")}):(0,r.jsxs)("div",{style:lr,children:[(0,r.jsx)("button",{type:"button",onClick:()=>j(""),disabled:null!==v,style:ln(""===o,"__default__"===b,null!==v),onMouseEnter:()=>C(""),onMouseLeave:()=>C(null),children:g("desktop.defaultTheme")}),m.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>j(e.name),disabled:null!==v,style:ln(o===e.name,b===e.name,v===e.name),onMouseEnter:()=>C(e.name),onMouseLeave:()=>C(null),children:[e.displayName,(0,r.jsx)(lc,{hasDark:e.hasDark,hasLight:e.hasLight,darkColor:e.accent,lightColor:e.accentLight,t:g})]},e.name))]}),(0,r.jsxs)("div",{style:{marginTop:20},children:[(0,r.jsx)(ls,{icon:(0,r.jsx)(ld,{depth:c}),label:`${g("desktop.borderVisibility")} (${c})`}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",flexShrink:0},children:g("desktop.borderSubtle")}),(0,r.jsx)("input",{type:"range",min:0,max:100,step:1,value:c,onChange:e=>p(Number(e.target.value)),style:{flex:1,accentColor:"var(--accent)",height:6,cursor:"pointer"}}),(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",flexShrink:0},children:g("desktop.borderBold")})]}),(0,r.jsx)("div",{style:{marginTop:10,display:"flex",gap:10},children:[0,25,50,75,100].map(e=>{let t=c===e,o=e<=50?`color-mix(in srgb, var(--border-orig) ${2*e}%, var(--bg) ${100-2*e}%)`:`color-mix(in srgb, var(--border-orig) ${100-(e-50)*2}%, var(--text) ${(e-50)*2}%)`;return(0,r.jsx)("div",{onClick:()=>p(e),style:{width:28,height:20,border:`2px solid ${t?"var(--accent)":o}`,borderRadius:5,background:"var(--bg-card)",cursor:"pointer",transition:"border-color 0.1s"}},e)})})]}),(0,r.jsxs)("div",{style:{marginTop:20},children:[(0,r.jsx)(ls,{icon:"dark"===t?(0,r.jsx)(lt.A,{size:14,weight:"fill"}):(0,r.jsx)(lo.b,{size:14,weight:"fill"}),label:g("desktop.appearanceMode")}),(0,r.jsx)("div",{style:lr,children:[{value:"light",icon:(0,r.jsx)(lo.b,{size:15,weight:"light"===e?"fill":"regular"})},{value:"dark",icon:(0,r.jsx)(lt.A,{size:15,weight:"dark"===e?"fill":"regular"})},{value:"system",icon:(0,r.jsx)(aq.V,{size:15,weight:"system"===e?"fill":"regular"})}].map(t=>{let o=e===t.value;return(0,r.jsxs)("button",{type:"button",onClick:()=>T(t.value),style:ln(o,b===`mode:${t.value}`),onMouseEnter:()=>w(`mode:${t.value}`),onMouseLeave:()=>w(null),children:[t.icon,g(`desktop.${t.value}`)]},t.value)})})]}),!x&&0===m.length&&(0,r.jsxs)("p",{style:{margin:"14px 0 0",fontSize:11,color:"var(--text-dim)",lineHeight:1.5},children:[g("desktop.noCustomThemes")," ",g("desktop.noCustomThemesHint")," ",(0,r.jsx)("code",{style:{fontSize:10,background:"var(--bg-secondary)",padding:"1px 5px",borderRadius:3,fontFamily:"var(--font-mono)"},children:"~/.pi/agent/themes/*.json"})," ",g("desktop.noCustomThemesHint2")]})]}),(0,r.jsx)(ll,{title:g("desktop.language"),description:g("desktop.languageDescription"),children:(0,r.jsx)("div",{style:lr,children:["en","zh-CN"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>h("zh-CN"===e?"zh-CN":"en"),style:ln("zh-CN"===e?"zh-CN"===u:"zh-CN"!==u,b===`lang:${e}`),onMouseEnter:()=>w(`lang:${e}`),onMouseLeave:()=>w(null),children:"en"===e?g("desktop.english"):g("desktop.chinese")},e))})})]})}var lu=o(94638);function lh({children:e}){return(0,r.jsx)("div",{style:{borderRadius:12,border:"1px solid var(--border)",background:"color-mix(in srgb, var(--bg-panel) 55%, transparent)",overflow:"hidden"},children:e})}function lg({children:e}){return(0,r.jsx)("div",{style:{padding:"0 14px"},children:(0,r.jsx)("div",{style:{borderBottom:"1px solid var(--border)"},children:e})})}function lm({children:e}){return(0,r.jsx)("div",{style:{padding:"0 14px"},children:e})}function lf({children:e}){return(0,r.jsx)("div",{style:{display:"flex",gap:8,borderRadius:10,border:"1px solid var(--border)",background:"color-mix(in srgb, var(--bg-panel) 55%, transparent)",padding:"10px 12px",fontSize:12,lineHeight:1.5,color:"var(--text-muted)"},children:e})}let lx=[{value:"normal",labelKey:"modes.collabNormal"},{value:"plan",labelKey:"modes.collabPlan"},{value:"goal",labelKey:"modes.collabGoal"}],lk=[{value:"economy",labelKey:"modes.tokenEconomy"},{value:"full",labelKey:"modes.tokenFull"},{value:"delivery",labelKey:"modes.tokenDelivery"}],lv=[{value:"ask",labelKey:"modes.approvalAsk"},{value:"auto",labelKey:"modes.approvalAuto"},{value:"yolo",labelKey:"modes.approvalYolo"}];function ly({options:e,value:t,onChange:o,disabled:n,accentFor:s}){let{t:i}=(0,A.s)();return(0,r.jsx)("div",{role:"radiogroup",style:{display:"flex",border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",height:28,flexShrink:0},children:e.map(e=>{let a=e.value===t,l=s?.(e.value);return(0,r.jsx)("button",{type:"button",role:"radio","aria-checked":a,disabled:n,onClick:()=>{e.value!==t&&o(e.value)},style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",padding:"0 12px",background:a?"var(--bg-selected)":"none",border:"none",color:a?l??"var(--accent)":"var(--text-muted)",cursor:n?"not-allowed":"pointer",fontSize:11.5,fontWeight:a?650:500,opacity:n?.5:1,whiteSpace:"nowrap",transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{a||n||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{a||(e.currentTarget.style.background="none")},children:i(e.labelKey)},e.value)})})}function lb(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)({tasksBoard:!0}),[s,i]=(0,n.useState)(null),[a,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=!1;return(async()=>{try{let[t,r]=await Promise.all([fetch("/api/features"),fetch("/api/modes")]);if(!e&&t.ok){let e=await t.json();o(t=>({...t,...e}))}if(!e&&r.ok){let e=await r.json();i({collaborationMode:tw(e.collaborationMode),tokenMode:tj(e.tokenMode),toolApprovalMode:tS(e.toolApprovalMode),permissionRules:e.permissionRules??{allow:[],ask:[],deny:[]}})}e||l(!0)}catch{}})(),()=>{e=!0}},[]);let p=(0,n.useCallback)(async e=>{c(!0);try{let t=await fetch("/api/features",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tasksBoard:e})});if(t.ok){let e=await t.json();o(t=>({...t,...e.features})),window.dispatchEvent(new CustomEvent("pi:features-changed"))}}catch{}finally{c(!1)}},[]),u=(0,n.useCallback)(async e=>{c(!0);try{let t=await fetch("/api/modes",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok){let e=await t.json();i(t=>t?{...t,collaborationMode:tw(e.modes?.collaborationMode??t.collaborationMode),tokenMode:tj(e.modes?.tokenMode??t.tokenMode),toolApprovalMode:tS(e.modes?.toolApprovalMode??t.toolApprovalMode),permissionRules:e.modes?.permissionRules??t.permissionRules}:t),window.dispatchEvent(new CustomEvent("pi:modes-changed"))}}catch{}finally{c(!1)}},[]);return(0,r.jsx)("div",{style:{flex:1,overflow:"auto",minWidth:0,padding:"20px 22px",display:"flex",flexDirection:"column",gap:16},children:(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[a?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lh,{children:(0,r.jsx)(lm,{children:(0,r.jsx)(a4,{checked:t.tasksBoard,onChange:e=>void p(e),label:(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,r.jsx)(lu.x,{size:14,"aria-hidden":"true"}),e("desktop.featuresTasksBoard"),(0,r.jsx)("span",{style:{borderRadius:999,background:"rgba(37,99,235,0.12)",color:"var(--accent)",padding:"1px 7px",fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Beta"})]}),description:e("desktop.featuresTasksBoardDesc")})})}),s&&(0,r.jsxs)(lh,{children:[(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"12px 0"},children:[(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:e("desktop.featuresCollabDefault")}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:e("desktop.featuresCollabDefaultDesc")})]}),(0,r.jsx)(ly,{options:lx,value:s.collaborationMode,onChange:e=>void u({collaborationMode:e}),disabled:d})]})}),(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"12px 0"},children:[(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:e("desktop.featuresTokenDefault")}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:e("desktop.featuresTokenDefaultDesc")})]}),(0,r.jsx)(ly,{options:lk,value:s.tokenMode,onChange:e=>void u({tokenMode:e}),disabled:d})]})}),(0,r.jsx)(lm,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"12px 0"},children:[(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:e("desktop.featuresApprovalDefault")}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:e("desktop.featuresApprovalDefaultDesc")})]}),(0,r.jsx)(ly,{options:lv,value:s.toolApprovalMode,onChange:e=>void u({toolApprovalMode:e}),disabled:d,accentFor:e=>"yolo"===e?"var(--accent-red, #ef4444)":void 0})]})})]})]}):(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.featuresLoading")}),(0,r.jsx)(lf,{children:e("desktop.featuresDesc")}),d&&(0,r.jsx)("div",{style:{padding:"0 2px",fontSize:11,color:"var(--text-muted)"},children:e("desktop.featuresSaving")})]})})}var lw=o(76553);function lj({open:e,onClose:t,children:o}){let[s,i]=(0,n.useState)(!1),[a,l]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{if(e)l(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>i(!0)));else{i(!1);let e=setTimeout(()=>l(!1),250);return()=>clearTimeout(e)}},[e]),a)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{onClick:t,style:{position:"fixed",inset:0,zIndex:1001,background:s?"rgba(0,0,0,0.35)":"rgba(0,0,0,0)",transition:"background 0.25s ease"}}),(0,r.jsxs)("div",{style:{position:"fixed",bottom:0,left:0,right:0,zIndex:1002,maxHeight:"85dvh",borderRadius:"16px 16px 0 0",background:"var(--bg)",boxShadow:"0 -4px 24px rgba(0,0,0,0.15)",transform:s?"translateY(0)":"translateY(100%)",transition:"transform 0.25s cubic-bezier(0.32, 0.72, 0, 1)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,r.jsx)("div",{style:{display:"flex",justifyContent:"center",padding:"10px 0 4px",flexShrink:0},children:(0,r.jsx)("div",{style:{width:36,height:4,borderRadius:2,background:"var(--border)"}})}),(0,r.jsx)("div",{style:{flex:1,overflow:"auto",minHeight:0},children:o})]})]}):null}function lS({onSessionsChanged:e}){let{t}=(0,A.s)(),o=O(),[s,i]=(0,n.useState)(null),[a,l]=(0,n.useState)([]),[p,u]=(0,n.useState)([]),[g,m]=(0,n.useState)(new Set),[f,x]=(0,n.useState)(null),[k,v]=(0,n.useState)({imported:0,skipped:0,errors:0,total:0,done:!1}),[y,b]=(0,n.useState)([]),[w,j]=(0,n.useState)(!1),[S,C]=(0,n.useState)({done:0,total:0}),T=(0,n.useRef)(new Map),R=(0,n.useRef)(!1),[z,I]=(0,n.useState)(!1),[M,P]=(0,n.useState)(null),[W,F]=(0,n.useState)(!1),D=(0,n.useCallback)(async()=>{I(!0),P(null);try{let e=await fetch("/api/import/discover"),t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);l(t.sources),t.reasonix?.available&&(u(t.reasonix.projects),i("reasonix"))}catch(e){P(e instanceof Error?e.message:String(e))}finally{I(!1)}},[]),[N,L]=(0,n.useState)(!1);(0,n.useEffect)(()=>{N||(L(!0),D())},[N,D]);let $=(0,n.useCallback)(async()=>{if(0!==g.size&&s){I(!0),P(null);try{let e=await fetch("/api/import/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:s,projects:[...g]})}),t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);x(t.jobId)}catch(e){P(e instanceof Error?e.message:String(e))}finally{I(!1)}}},[s,g]);(0,n.useEffect)(()=>{let t;if(!f)return;let o=!0,r=async()=>{if(o)try{let n=await fetch(`/api/import/status?jobId=${encodeURIComponent(f)}`),s=await n.json();if(!o)return;v({imported:s.imported??0,skipped:s.skipped??0,errors:s.errors??0,total:s.total??0,done:s.done??!1}),s.done&&s.sessionIds&&(b(s.sessionIds),e?.()),s.done||(t=setTimeout(r,800))}catch{o&&(t=setTimeout(r,2e3))}};return r(),()=>{o=!1,clearTimeout(t)}},[f,e]);let H=(0,n.useCallback)(async()=>{if(w){for(let[e,t]of(R.current=!0,T.current))t.abort(),c(e);return}if(0===y.length)return;R.current=!1,j(!0),C({done:0,total:y.length});let t=0,o=0,r=async()=>{for(;!R.current;){let e=y[t++];if(!e)return;let r=new AbortController;T.current.set(e,r);try{await d(e,r.signal)}catch{}finally{T.current.delete(e),C({done:o+=1,total:y.length})}}};await Promise.all(Array.from({length:Math.min(2,y.length)},r)),T.current.clear(),j(!1),e?.()},[w,y,e]);if(k.done&&y.length>0)return(0,r.jsxs)("div",{style:{padding:"18px 22px",display:"flex",flexDirection:"column",gap:14},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)(nv.r,{size:20,weight:"fill",style:{color:"#4ade80"}}),(0,r.jsx)("span",{style:{fontSize:14,fontWeight:600,color:"var(--text)"},children:t("desktop.importDone")??"导入完成"})]}),(0,r.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:[t("desktop.importedSummary",{imported:k.imported})??`成功导入 ${k.imported} 个会话`,k.skipped>0&&(0,r.jsx)("span",{style:{marginLeft:8},children:t("desktop.importSkippedCount",{skipped:k.skipped})??`,${k.skipped} 个跳过`}),k.errors>0&&(0,r.jsx)("span",{style:{marginLeft:8,color:"#ef4444"},children:t("desktop.importErrorsCount",{errors:k.errors})??`,${k.errors} 个失败`})]}),(0,r.jsxs)("button",{type:"button",onClick:H,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 14px",background:"var(--accent)",border:"none",borderRadius:6,color:"#fff",fontSize:12,fontWeight:600,cursor:"pointer",alignSelf:"flex-start"},children:[w?(0,r.jsx)(K.y,{size:14,style:{animation:"spin 1s linear infinite"}}):(0,r.jsx)(lw.o,{size:15}),w?`${t("desktop.importGeneratingTitles")??"正在生成标题…"} (${S.done}/${S.total}) — ${t("desktop.stop")??"停止"}`:t("desktop.importGenerateTitles")??"为导入的会话生成标题"]}),(0,r.jsx)("button",{type:"button",onClick:()=>{x(null),v({imported:0,skipped:0,errors:0,total:0,done:!1}),b([]),j(!1),C({done:0,total:0})},style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",fontSize:12,cursor:"pointer",alignSelf:"flex-start"},children:t("desktop.importAgain")??"再次导入"})]});let B=(0,r.jsxs)("div",{style:{padding:o?"12px 18px":"18px 22px",display:"flex",flexDirection:"column",gap:14},children:[M&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,fontSize:12,color:"#ef4444",lineHeight:1.5},children:[(0,r.jsx)(X.N,{size:14,style:{flexShrink:0,marginTop:1}}),(0,r.jsx)("span",{children:M})]}),!f&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:t("desktop.importSessionsDesc")??"从其他 AI 编码工具导入历史对话记录到 pi-web。目前支持 Reasonix,更多工具陆续支持中。"}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:a.map(e=>(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",border:"1px solid var(--border)",borderRadius:8,cursor:"available"===e.status?"pointer":"default",background:s===e.key?"var(--bg-selected)":"var(--bg-panel)",opacity:"unavailable"===e.status?.5:"coming-soon"===e.status?.7:1,transition:"background 0.12s"},children:[(0,r.jsx)("input",{type:"radio",name:"import-source",value:e.key,checked:s===e.key,disabled:"available"!==e.status,onChange:()=>i(e.key)}),(0,r.jsxs)("div",{style:{flex:1},children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:e.label}),"coming-soon"===e.status&&(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",marginTop:1},children:t("desktop.comingSoon")??"即将支持"})]}),"reasonix"===e.key&&p.length>0&&(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)"},children:[p.length," ",t("desktop.projects")??"个项目"," \xb7 ",p.reduce((e,t)=>e+t.sessions,0)," ",t("desktop.sessions")??"会话"]})]},e.key))}),"reasonix"===s&&p.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)"},children:t("desktop.importSelectProjects")??"选择要导入的项目"}),(0,r.jsx)("button",{type:"button",onClick:()=>m(new Set(p.map(e=>e.name))),style:lC,children:t("desktop.importSelectAll")??"全选"}),(0,r.jsx)("button",{type:"button",onClick:()=>m(new Set),style:lC,children:t("desktop.importDeselectAll")??"取消全选"})]}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:p.map(e=>(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",border:"1px solid var(--border)",borderRadius:6,cursor:"pointer",background:g.has(e.name)?"var(--bg-selected)":"transparent",transition:"background 0.12s"},children:[(0,r.jsx)("input",{type:"checkbox",checked:g.has(e.name),onChange:()=>{var t;return t=e.name,void m(e=>{let o=new Set(e);return o.has(t)?o.delete(t):o.add(t),o})}}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:500,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)",marginTop:2},children:[e.sessions," ",t("desktop.sessions")??"会话",e.matched&&(0,r.jsxs)("span",{style:{marginLeft:8,color:"var(--accent)"},children:["→ ",t("desktop.importMerged")??"合并到现有项目",e.existingCount>0&&` (${t("desktop.importExistingCount",{count:e.existingCount})??`${e.existingCount} 个已有`})`]}),!e.matched&&(0,r.jsxs)("span",{style:{marginLeft:8,color:"var(--text-muted)"},children:["→ ",t("desktop.importNewProject")??"新建项目"]})]})]})]},e.name))}),(0,r.jsx)("button",{type:"button",onClick:$,disabled:z||0===g.size,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 14px",background:"var(--accent)",border:"none",borderRadius:6,color:"#fff",fontSize:12,fontWeight:600,cursor:0===g.size?"not-allowed":"pointer",alignSelf:"flex-start",opacity:0===g.size?.5:1},children:z?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(K.y,{size:14,style:{animation:"spin 1s linear infinite"}})," ",t("desktop.importing")??"导入中…"]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(E.z,{size:15})," ",t("desktop.importStart")??"开始导入"]})})]}),"reasonix"===s&&0===p.length&&!z&&(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",padding:"12px 0"},children:t("desktop.importNoData")??"未找到 Reasonix 数据。请确认 ~/.reasonix/projects/ 目录存在且包含会话文件。"})]}),f&&!k.done&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text)"},children:[(0,r.jsx)(K.y,{size:14,style:{animation:"spin 1s linear infinite"}}),t("desktop.importing")??"导入中…"]}),(0,r.jsx)("div",{style:{height:6,borderRadius:3,background:"var(--bg-panel)",overflow:"hidden"},children:(0,r.jsx)("div",{style:{height:"100%",borderRadius:3,background:"var(--accent)",width:`${k.total>0?(k.imported+k.skipped+k.errors)/k.total*100:0}%`,transition:"width 0.3s ease"}})}),(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:[k.imported+k.skipped+k.errors," / ",k.total,k.skipped>0&&` \xb7 ${t("desktop.importSkippedCount",{skipped:k.skipped})??`${k.skipped} 跳过`}`]})]})]});return o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button",onClick:()=>F(!0),style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",width:"100%",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text)",fontSize:12,cursor:"pointer"},children:[(0,r.jsx)(E.z,{size:16}),(0,r.jsx)("span",{style:{fontWeight:500},children:t("desktop.importSessions")??"导入会话"})]}),(0,r.jsxs)(lj,{open:W,onClose:()=>F(!1),children:[(0,r.jsxs)("div",{style:{padding:"4px 18px 14px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:t("desktop.importSessions")??"导入会话"}),(0,r.jsx)("button",{onClick:()=>F(!1),style:lT,children:(0,r.jsx)(h.X,{size:18})})]}),B]})]}):B}let lC={background:"none",border:"none",color:"var(--accent)",fontSize:11,cursor:"pointer",padding:"2px 4px"},lT={background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",padding:4,display:"flex"},lR="deepseek-vision",lz={padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",width:"100%",boxSizing:"border-box"};function lI(){return{fontSize:12,color:"var(--text-muted)"}}let lM={padding:"7px 12px",border:"none",borderRadius:6,background:"var(--accent)",color:"#fff",cursor:"pointer",fontSize:12};function lP({sessionId:e}){let{t}=(0,A.s)(),[o,s]=(0,n.useState)(!1),[i,a]=(0,n.useState)(null),[l,d]=(0,n.useState)(!1),[c,p]=(0,n.useState)(null),[u,h]=(0,n.useState)(!1),[g,m]=(0,n.useState)({}),[f,x]=(0,n.useState)(""),[k,v]=(0,n.useState)(""),[y,b]=(0,n.useState)("eager"),[w,j]=(0,n.useState)(!1),[S,C]=(0,n.useState)(null),[T,R]=(0,n.useState)(!1),[z,I]=(0,n.useState)(!1),[M,P]=(0,n.useState)({provider:"custom",baseUrl:"",apiKey:"",model:"",maxTokens:4096,hasApiKey:!1}),[E,W]=(0,n.useState)(""),[F,D]=(0,n.useState)(""),[N,L]=(0,n.useState)(!1),[$,H]=(0,n.useState)(null),[O,B]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=!1;return(async()=>{a(null);try{let[t,o]=await Promise.all([fetch("/api/mcp"),fetch("/api/vision-config")]),r=await t.json();if(!t.ok||r.error)throw Error(r.error??`HTTP ${t.status}`);let n=await o.json();if(!o.ok||n.error)throw Error(n.error??`HTTP ${o.status}`);if(e)return;m(r.mcpServers??{}),x(r.filePath);let i=(r.mcpServers??{})[lR];v(i?.command??""),b(i?.lifecycle==="lazy"?"lazy":"eager"),P({provider:n.provider,baseUrl:n.baseUrl,apiKey:"",model:n.model,maxTokens:n.maxTokens,hasApiKey:n.hasApiKey}),n.path&&D(n.path),s(!0)}catch(t){e||a(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[]);let U=(0,n.useCallback)(async()=>{if(!k.trim())return void C(t("desktop.mcpVisionCommandRequired"));j(!0),C(null),R(!1),I(!1);try{let e=g[lR],t={...g,[lR]:{...e??{},command:k.trim(),args:Array.isArray(e?.args)?e.args:[],transport:"stdio",lifecycle:y}},o=await fetch("/api/mcp",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServers:t})}),r=await o.json();if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);m(t),R(!0)}catch(e){C(e instanceof Error?e.message:String(e))}finally{j(!1)}},[g,k,y,t]),_=(0,n.useCallback)(async()=>{j(!0),C(null),R(!1),I(!1);try{let e={...g};delete e[lR];let t=await fetch("/api/mcp",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServers:e})}),o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);m(e),v(""),b("eager"),I(!0)}catch(e){C(e instanceof Error?e.message:String(e))}finally{j(!1)}},[g]),q=(0,n.useCallback)(async()=>{L(!0),H(null),B(!1);try{let e=await fetch("/api/vision-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...M,...E?{apiKey:E}:{}})}),t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);P({...t,apiKey:"",hasApiKey:t.hasApiKey}),W(""),B(!0)}catch(e){H(e instanceof Error?e.message:String(e))}finally{L(!1)}},[M,E]),V=(0,n.useCallback)(async()=>{if(e){d(!0),p(null),h(!1);try{let t=await fetch("/api/mcp/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:e,name:lR})}),o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);h(!0)}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}},[e]),K=!!g[lR];return(0,r.jsxs)(lh,{children:[(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"12px 0"},children:[(0,r.jsx)(sR.k,{size:15,"aria-hidden":"true"}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:t("desktop.mcpVisionTitle")}),(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:3,background:K?"rgba(37,99,235,0.12)":"rgba(245,158,11,0.12)",color:K?"var(--accent)":"#d97706",textTransform:"capitalize"},children:K?t("desktop.mcpVisionRegistered"):t("desktop.mcpVisionNotRegistered")})]}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:t("desktop.mcpVisionDesc")})]})]})}),o?i?(0,r.jsx)(lm,{children:(0,r.jsx)("div",{style:{padding:"8px 0",fontSize:12,color:"#ef4444"},children:i})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lg,{children:(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",padding:"10px 0 2px"},children:t("desktop.mcpVisionRegistration")})}),(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(120px, 180px) 1fr",gap:8,alignItems:"center",padding:"6px 0"},children:[(0,r.jsxs)("span",{style:lI(),children:[t("desktop.mcpVisionCommand")," *"]}),(0,r.jsx)("input",{value:k,onChange:e=>v(e.target.value),placeholder:"/path/to/deepseek-vision-mcp",style:lz}),(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionLifecycle")}),(0,r.jsxs)("select",{value:y,onChange:e=>b(e.target.value),style:{...lz,fontFamily:"var(--font-mono)"},children:[(0,r.jsx)("option",{value:"eager",children:"eager"}),(0,r.jsx)("option",{value:"lazy",children:"lazy"})]}),(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionTransport")}),(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",fontFamily:"var(--font-mono)",padding:"7px 0"},children:t("desktop.mcpVisionTransportFixed")})]})}),(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"6px 0",flexWrap:"wrap"},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void U(),disabled:w,style:{...lM,cursor:w?"wait":"pointer"},children:w?t("desktop.saving"):t("desktop.mcpVisionSaveReg")}),K&&(0,r.jsx)("button",{type:"button",onClick:()=>void _(),disabled:w,title:t("desktop.mcpVisionRemove"),style:{padding:"7px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"#ef4444",cursor:w?"not-allowed":"pointer",fontSize:12},children:t("desktop.mcpVisionRemove")}),T&&(0,r.jsx)("span",{style:{color:"#22c55e",fontSize:12},children:t("desktop.mcpVisionSavedReg")}),z&&(0,r.jsx)("span",{style:{color:"#22c55e",fontSize:12},children:t("desktop.mcpVisionRemoved")}),S&&(0,r.jsx)("span",{style:{color:"#ef4444",fontSize:12},children:S})]})}),(0,r.jsx)(lg,{children:(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",padding:"10px 0 2px"},children:t("desktop.mcpVisionModelConfig")})}),(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(120px, 180px) 1fr",gap:8,alignItems:"center",padding:"6px 0"},children:[(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionProvider")}),(0,r.jsx)("input",{value:M.provider,onChange:e=>P(t=>({...t,provider:e.target.value})),style:lz}),(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionBaseUrl")}),(0,r.jsx)("input",{value:M.baseUrl,onChange:e=>P(t=>({...t,baseUrl:e.target.value})),style:lz}),(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionApiKey")}),(0,r.jsx)("input",{type:"password",value:E,onChange:e=>W(e.target.value),placeholder:M.hasApiKey?"••••••••":"API key",style:lz}),(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionModel")}),(0,r.jsx)("input",{value:M.model,onChange:e=>P(t=>({...t,model:e.target.value})),style:lz}),(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionMaxTokens")}),(0,r.jsx)("input",{type:"number",min:1,value:M.maxTokens,onChange:e=>P(t=>({...t,maxTokens:Number(e.target.value)||1})),style:lz})]})}),(0,r.jsx)(lm,{children:(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"6px 0"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void q(),disabled:N,style:{...lM,cursor:N?"wait":"pointer"},children:N?t("desktop.saving"):t("desktop.mcpVisionSaveModel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void V(),disabled:l||!e||!K,title:e?t("desktop.mcpVisionRestartTitle"):t("desktop.mcpVisionRestartNoSession"),style:{padding:"7px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:!l&&e&&K?"pointer":"not-allowed",fontSize:12,opacity:!l&&e&&K?1:.5},children:l?t("desktop.mcpVisionRestarting"):t("desktop.mcpVisionRestart")}),O&&(0,r.jsx)("span",{style:{color:"#22c55e",fontSize:12},children:t("desktop.mcpVisionSavedModel")}),u&&(0,r.jsx)("span",{style:{color:"#22c55e",fontSize:12},children:t("desktop.mcpVisionRestarted")}),$&&(0,r.jsx)("span",{style:{color:"#ef4444",fontSize:12},children:$}),c&&(0,r.jsx)("span",{style:{color:"#ef4444",fontSize:12},children:c})]}),(0,r.jsxs)(lf,{children:[t("desktop.mcpVisionModelNote"),F&&(0,r.jsx)("div",{style:{marginTop:4,fontFamily:"var(--font-mono)",fontSize:10},children:F}),f&&(0,r.jsx)("div",{style:{fontFamily:"var(--font-mono)",fontSize:10},children:f})]})]})})]}):(0,r.jsx)(lm,{children:(0,r.jsx)("div",{style:{padding:"8px 0",fontSize:12,color:"var(--text-muted)"},children:t("desktop.loading")})})]})}function lE({sessionId:e,onApplied:t,onBeforeApply:o}){let{t:s}=(0,A.s)(),[i,a]=(0,n.useState)(!1),[l,d]=(0,n.useState)(!1),[c,p]=(0,n.useState)(null),u=(0,n.useCallback)(async()=>{if(e){a(!0),p(null),d(!1);try{await o?.(),await i6(e,{type:"reload"}),d(!0),await t?.()}catch(e){p(e instanceof Error?e.message:String(e))}finally{a(!1)}}},[e,t,o]),h=i||!e;return(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void u(),disabled:h,title:s(e?"desktop.applyNowTitle":"desktop.applyNowNoSession"),style:{padding:"7px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:h?"not-allowed":"pointer",fontSize:12,opacity:h?.5:1,whiteSpace:"nowrap"},children:s(i?"desktop.applyNowApplying":"desktop.applyNow")}),l&&(0,r.jsx)("span",{style:{color:"#22c55e",fontSize:12},children:s("desktop.applyNowDone")}),c&&(0,r.jsx)("span",{style:{color:"#ef4444",fontSize:12},children:c})]})}let lW=["stdio","sse","http"],lF=["eager","lazy"],lD={name:"",command:"",args:"",transport:"stdio",lifecycle:"eager",requestTimeoutMs:"",env:""},lA={padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",width:"100%",boxSizing:"border-box"};function lN(){return{fontSize:12,color:"var(--text-muted)"}}function lL(e,t){return{fontSize:10,padding:"1px 6px",borderRadius:3,background:t,color:e,flexShrink:0,textTransform:"capitalize"}}function l$({sessionId:e}){let{t}=(0,A.s)(),[o,s]=(0,n.useState)({}),[i,a]=(0,n.useState)(""),[l,d]=(0,n.useState)(!1),[c,p]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),[g,m]=(0,n.useState)(lD),[x,k]=(0,n.useState)(!1),[y,b]=(0,n.useState)(null),[w,j]=(0,n.useState)(!1),S=(0,n.useCallback)(async()=>{p(null);try{let e=await fetch("/api/mcp"),t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);s(t.mcpServers??{}),a(t.filePath)}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!0)}},[]);(0,n.useEffect)(()=>{S()},[S]);let C=(0,n.useCallback)(()=>{m(lD),h({name:"",isNew:!0}),b(null),j(!1)},[]),R=(0,n.useCallback)((e,t)=>{m({name:e,command:t.command??"",args:Array.isArray(t.args)?t.args.join("\n"):"",transport:"string"==typeof t.transport?t.transport:"stdio",lifecycle:"string"==typeof t.lifecycle?t.lifecycle:"eager",requestTimeoutMs:"number"==typeof t.requestTimeoutMs?String(t.requestTimeoutMs):"",env:void 0!==t.env?JSON.stringify(t.env,null,2):""}),h({name:e,isNew:!1}),b(null),j(!1)},[]),z=(0,n.useCallback)(async()=>{if(u){k(!0),b(null),j(!1);try{let e=g.name.trim();if(u.isNew&&!e)return void b("Server name is required");if(u.isNew&&!/^[a-zA-Z0-9_-]+$/.test(e))return void b("Allowed characters: a-z, A-Z, 0-9, _ and -");if(u.isNew&&e===lR)return void b(t("desktop.mcpVisionNameReserved"));let r=function(e){if(!e.command.trim())return{error:"Command is required"};let t=e.args.split("\n").map(e=>e.trim()).filter(Boolean),o={command:e.command.trim(),args:t,transport:lW.includes(e.transport)?e.transport:"stdio",lifecycle:lF.includes(e.lifecycle)?e.lifecycle:"eager"};if(""!==e.requestTimeoutMs.trim()){let t=Number(e.requestTimeoutMs);if(!Number.isFinite(t)||t<=0)return{error:"Request timeout must be a positive number"};o.requestTimeoutMs=t}if(""!==e.env.trim())try{o.env=JSON.parse(e.env)}catch{return{error:"Environment must be valid JSON"}}return{server:o}}(g);if(r.error||!r.server)return void b(r.error??"Invalid server");let n={...o};u.isNew?n[e]=r.server:(delete n[u.name],n[g.name.trim()||u.name]=r.server);let i=await fetch("/api/mcp",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServers:n})}),a=await i.json();if(!i.ok||a.error)throw Error(a.error??`HTTP ${i.status}`);s(n),h(null),j(!0)}catch(e){b(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[u,g,o,t]),I=(0,n.useCallback)(async e=>{k(!0),b(null);try{let t={...o};delete t[e];let r=await fetch("/api/mcp",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServers:t})}),n=await r.json();if(!r.ok||n.error)throw Error(n.error??`HTTP ${r.status}`);s(t),j(!0)}catch(e){b(e instanceof Error?e.message:String(e))}finally{k(!1)}},[o]),M=(0,n.useCallback)((e,t)=>{m(o=>({...o,[e]:t}))},[]),P=Object.entries(o).filter(([e])=>e!==lR);return(0,r.jsx)("div",{style:{flex:1,overflow:"auto",minWidth:0,padding:"20px 22px",display:"flex",flexDirection:"column",gap:16},children:(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:l?c?(0,r.jsx)("div",{style:{fontSize:12,color:"#ef4444"},children:c}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:t("desktop.mcpServers")}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[(0,r.jsx)(lE,{sessionId:e,onApplied:S}),(0,r.jsxs)("button",{type:"button",onClick:C,style:{display:"flex",alignItems:"center",gap:6,padding:"7px 12px",border:"none",borderRadius:6,background:"var(--accent)",color:"#fff",cursor:"pointer",fontSize:12,flexShrink:0},children:[(0,r.jsx)(v.c,{size:13,"aria-hidden":"true"}),t("desktop.mcpAddServer")]})]})]}),(0,r.jsx)(lf,{children:t("desktop.mcpRestartNote")}),(0,r.jsx)(lP,{sessionId:e}),0!==P.length||u?P.map(([e,o])=>(0,r.jsx)(lh,{children:(0,r.jsx)(lm,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 0",minWidth:0},children:[(0,r.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontSize:13,fontWeight:600,color:"var(--text)",fontFamily:"var(--font-mono)"},children:e}),(0,r.jsx)("span",{style:lL("var(--accent)","rgba(37,99,235,0.12)"),children:o.transport??"stdio"}),(0,r.jsx)("span",{style:lL("#d97706","rgba(245,158,11,0.12)"),children:o.lifecycle??"lazy"})]}),(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[o.command,Array.isArray(o.args)&&o.args.length>0?` ${o.args.map(e=>e.includes(" ")?`"${e}"`:e).join(" ")}`:""]})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:6,flexShrink:0},children:[(0,r.jsxs)("button",{type:"button",onClick:()=>R(e,o),disabled:x,style:{display:"flex",alignItems:"center",gap:5,padding:"6px 10px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:x?"not-allowed":"pointer",fontSize:12,opacity:x?.5:1},children:[(0,r.jsx)(f.I,{size:12,"aria-hidden":"true"}),t("desktop.mcpEdit")]}),(0,r.jsx)("button",{type:"button",onClick:()=>void I(e),disabled:x,title:t("desktop.mcpDelete"),"aria-label":t("desktop.mcpDelete"),style:{display:"flex",alignItems:"center",padding:"6px 9px",background:"rgba(239,68,68,0.08)",border:"1px solid var(--border)",borderRadius:6,color:"#ef4444",cursor:x?"not-allowed":"pointer",fontSize:12,opacity:x?.5:1},children:(0,r.jsx)(T.l,{size:12,"aria-hidden":"true"})})]})]})})},e)):(0,r.jsx)(lh,{children:(0,r.jsx)(lm,{children:(0,r.jsx)("div",{style:{padding:"14px 0",fontSize:12,color:"var(--text-dim)"},children:o[lR]?t("desktop.mcpEmptyOther"):t("desktop.mcpEmpty")})})}),u&&(0,r.jsxs)(lh,{children:[(0,r.jsx)(lg,{children:(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)",padding:"12px 0 4px"},children:u.isNew?t("desktop.mcpNewServer"):t("desktop.mcpEditServer",{name:u.name})})}),(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(150px, 220px) 1fr",gap:"8px 12px",alignItems:"center",padding:"8px 0"},children:[(0,r.jsx)("span",{style:lN(),children:t("desktop.mcpServerName")}),(0,r.jsx)("input",{value:g.name,onChange:e=>M("name",e.target.value),disabled:!u.isNew,placeholder:"my-server",style:{...lA,opacity:u.isNew?1:.5}}),(0,r.jsxs)("span",{style:lN(),children:[t("desktop.mcpCommand")," *"]}),(0,r.jsx)("input",{value:g.command,onChange:e=>M("command",e.target.value),placeholder:"npx @modelcontextprotocol/server-foo",style:lA}),(0,r.jsx)("span",{style:lN(),children:t("desktop.mcpArgs")}),(0,r.jsx)("textarea",{value:g.args,onChange:e=>M("args",e.target.value),placeholder:"--port 3000\n--verbose",rows:3,style:{...lA,resize:"vertical",lineHeight:1.5}}),(0,r.jsx)("span",{style:lN(),children:t("desktop.mcpTransport")}),(0,r.jsx)("select",{value:g.transport,onChange:e=>M("transport",e.target.value),style:{...lA,fontFamily:"var(--font-mono)"},children:lW.map(e=>(0,r.jsx)("option",{value:e,children:e},e))}),(0,r.jsx)("span",{style:lN(),children:t("desktop.mcpLifecycle")}),(0,r.jsx)("select",{value:g.lifecycle,onChange:e=>M("lifecycle",e.target.value),style:{...lA,fontFamily:"var(--font-mono)"},children:lF.map(e=>(0,r.jsx)("option",{value:e,children:e},e))}),(0,r.jsx)("span",{style:lN(),children:t("desktop.mcpRequestTimeoutMs")}),(0,r.jsx)("input",{type:"number",min:1,value:g.requestTimeoutMs,onChange:e=>M("requestTimeoutMs",e.target.value),placeholder:"300000",style:lA}),(0,r.jsx)("span",{style:lN(),children:t("desktop.mcpEnv")}),(0,r.jsx)("textarea",{value:g.env,onChange:e=>M("env",e.target.value),placeholder:'{\n "API_KEY": "..."\n}',rows:3,style:{...lA,resize:"vertical",lineHeight:1.5}})]})}),(0,r.jsx)(lm,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0"},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void z(),disabled:x,style:{padding:"7px 12px",border:"none",borderRadius:6,background:"var(--accent)",color:"#fff",cursor:x?"wait":"pointer",fontSize:12},children:x?t("desktop.saving"):t("desktop.mcpSave")}),(0,r.jsx)("button",{type:"button",onClick:()=>h(null),disabled:x,style:{padding:"7px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:x?"not-allowed":"pointer",fontSize:12},children:t("desktop.mcpCancel")}),y&&(0,r.jsx)("span",{style:{color:"#ef4444",fontSize:12},children:y})]})})]}),w&&!u&&(0,r.jsx)("div",{style:{fontSize:12,color:"#22c55e"},children:t("desktop.mcpSavedRestart")})]}):(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)"},children:t("desktop.loading")})})})}var lH=o(9210);function lO(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)(null),[s,i]=(0,n.useState)([]),[a,l]=(0,n.useState)(!0),[d,c]=(0,n.useState)(!1),[p,u]=(0,n.useState)(!1),[h,g]=(0,n.useState)(null);(0,n.useEffect)(()=>{fetch("/api/settings/title-model").then(e=>e.json()).then(e=>{o(e.value),i(e.models??[])}).catch(()=>{}).finally(()=>l(!1))},[]);let m=null!==t&&!s.some(e=>e.label===t),f=(0,n.useCallback)(async t=>{c(!0),g(null),u(!1);try{let e=await fetch("/api/settings/title-model",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:""===t?null:t})}),r=await e.json();if(!e.ok||r.error)return void g(r.error??`HTTP ${e.status}`);o(r.value??null),u(!0),setTimeout(()=>u(!1),2e3)}catch{g(String(e("desktop.titleModelSaveError")))}finally{c(!1)}},[e]),x=[...new Set(s.map(e=>e.provider))];return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 18px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)",whiteSpace:"nowrap"},children:e("desktop.titleModel")}),(0,r.jsxs)("select",{value:t??"",disabled:a||d,onChange:e=>f(e.target.value),style:{flex:1,minWidth:200,maxWidth:420,padding:"6px 9px",fontSize:12,color:"var(--text)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5},children:[(0,r.jsx)("option",{value:"",children:e("desktop.titleModelFollowSession")}),m&&null!==t&&(0,r.jsxs)("option",{value:t,style:{color:"#ef4444"},children:[t,"(",e("desktop.titleModelInvalid"),")"]}),x.map(e=>(0,r.jsx)("optgroup",{label:e,children:s.filter(t=>t.provider===e).map(e=>(0,r.jsxs)("option",{value:e.label,children:[e.name||e.id,e.reasoning?"(reasoning)":""]},e.label))},e))]}),d&&(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)"},children:"…"}),!d&&p&&(0,r.jsx)("span",{style:{fontSize:11,color:"#4ade80"},children:e("desktop.titleModelSaved")})]}),(0,r.jsx)("p",{style:{margin:0,fontSize:11,color:"var(--text-muted)",lineHeight:1.5},children:e("desktop.titleModelDescription")}),h&&(0,r.jsx)("p",{style:{margin:0,fontSize:11,color:"#ef4444",lineHeight:1.5},children:h}),m&&null!==t&&(0,r.jsxs)("p",{style:{margin:0,fontSize:11,color:"#ef4444",lineHeight:1.5},children:[t,"(",e("desktop.titleModelInvalid"),")"]})]})}let lB=["name","reasoning","contextWindow","maxTokens","thinkingLevelMap","hidden"];function lU(e){if(""===e.trim())return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}function l_(e){let t=lU(e.contextWindow??""),o=lU(e.maxTokens??""),r=e.thinkingLevelMap&&Object.keys(e.thinkingLevelMap).length>0?{...e.thinkingLevelMap}:void 0;return{...e.name?.trim()?{name:e.name.trim()}:{},..."boolean"==typeof e.reasoning?{reasoning:e.reasoning}:{},...void 0!==t?{contextWindow:t}:{},...void 0!==o?{maxTokens:o}:{},...r?{thinkingLevelMap:r}:{},..."boolean"==typeof e.hidden?{hidden:e.hidden}:{}}}function lq({providerId:e,onRegisterFlush:t,onConfigChange:o}){let{t:s}=(0,A.s)(),i=O(),[a,l]=(0,n.useState)([]),[d,c]=(0,n.useState)({}),[p,u]=(0,n.useState)({}),[h,g]=(0,n.useState)(new Set),[m,f]=(0,n.useState)(!0),[x,k]=(0,n.useState)(!1),[v,y]=(0,n.useState)(null),[b,w]=(0,n.useState)(!1),[j,S]=(0,n.useState)(null),C=(0,n.useRef)(d),T=(0,n.useRef)(p),R=(0,n.useRef)(a),z=(0,n.useRef)(h),I=(0,n.useRef)(0),M=(0,n.useRef)(null);C.current=d,T.current=p,R.current=a,z.current=h,(0,n.useEffect)(()=>{let t=!1;return f(!0),y(null),(async()=>{try{let o=await fetch(`/api/models-config/builtin?provider=${encodeURIComponent(e)}`),r=await o.json();if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);if(t)return;let n={};for(let e of r.models){let t=r.overrides[e.id]??{};n[e.id]={name:"string"==typeof t.name&&t.name.length>0?t.name:e.name,reasoning:"boolean"==typeof t.reasoning?t.reasoning:e.reasoning,contextWindow:"number"==typeof t.contextWindow?String(t.contextWindow):null!=e.contextWindow?String(e.contextWindow):"",maxTokens:"number"==typeof t.maxTokens?String(t.maxTokens):null!=e.maxTokens?String(e.maxTokens):"",hidden:"boolean"==typeof t.hidden&&t.hidden,thinkingLevelMap:t.thinkingLevelMap??e.thinkingLevelMap}}l(r.models),c(n),u(n),g(new Set)}catch(e){t||y(e instanceof Error?e.message:String(e))}finally{t||f(!1)}})(),()=>{t=!0}},[e]);let P=(0,n.useCallback)((e,t)=>{I.current+=1,c(o=>({...o,[e]:{...o[e]??{},...t}})),g(t=>new Set(t).add(e))},[]),E=(0,n.useCallback)(async()=>{let t=M.current;if(t)return t;let r=(async()=>{let t=new Set(z.current);if(0===t.size)return;let r=I.current,n={...C.current},s={},i={};for(let e of R.current){let t=n[e.id],o=T.current[e.id];t&&(s[e.id]=l_(t)),o&&(i[e.id]=l_(o))}let a=function(e,t,o){let r={};for(let n of e){let e=t[n];if(!e)continue;let s=o[n]??{},i={};for(let t of lB){let o=e[t],r=s[t];JSON.stringify(o)!==JSON.stringify(r)&&(i[t]=void 0===o?null:o)}Object.keys(i).length>0&&(r[n]=i)}return r}(t,s,i);if(0===Object.keys(a).length)return void g(new Set);k(!0),y(null),w(!1);try{let s=await fetch("/api/models-config/builtin",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,patches:a})}),i=await s.json();if(!s.ok||i.error)throw Error(i.error??`HTTP ${s.status}`);o?.(i.provider??null);let l={...T.current};for(let e of t){let t=n[e];t&&(l[e]={...t})}T.current=l,u(l),I.current===r&&g(e=>new Set([...e].filter(e=>!t.has(e)))),w(!0),setTimeout(()=>w(!1),2e3)}catch(e){throw y(e instanceof Error?e.message:String(e)),e}finally{k(!1)}})();M.current=r;try{await r}finally{M.current===r&&(M.current=null)}},[o,e]);(0,n.useEffect)(()=>{if(t)return t(e,E)??void 0},[t,e,E]);let[W,F]=(0,n.useState)({phase:"idle"}),[D,N]=(0,n.useState)([]),L=(0,n.useCallback)(async()=>{F({phase:"loading"});try{let t=await fetch("/api/models-config/discover",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerName:e,provider:{}})}),o=await t.json();if(!t.ok||o.error||!o.models)return void F({phase:"error",message:o.error??`HTTP ${t.status}`});let r=new Set(R.current.map(e=>e.id)),n=new Set(o.models.filter(e=>!r.has(e.id)).map(e=>e.id));F({phase:"success",models:o.models,newIds:n}),N(o.models.filter(e=>n.has(e.id)).map(e=>e.id))}catch(e){F({phase:"error",message:e instanceof Error?e.message:String(e)})}},[e]),$=(0,n.useCallback)(async()=>{if(W.models?.length){k(!0),y(null);try{let t=W.models.map(e=>({id:e.id,...e.name?{name:e.name}:{}})),r=await fetch("/api/models-config/builtin",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,models:t})}),n=await r.json();if(!r.ok||n.error)throw Error(n.error??`HTTP ${r.status}`);o?.(n.provider??null),F({phase:"idle"}),N([]);let s=await fetch(`/api/models-config/builtin?provider=${encodeURIComponent(e)}`);if(s.ok){let e=await s.json();if(e.models){l(e.models),R.current=e.models;let t={};for(let o of e.models){let r=e.overrides?.[o.id]??{};t[o.id]={name:"string"==typeof r.name&&r.name.length>0?r.name:o.name,reasoning:"boolean"==typeof r.reasoning?r.reasoning:o.reasoning,contextWindow:"number"==typeof r.contextWindow?String(r.contextWindow):null!=o.contextWindow?String(o.contextWindow):"",maxTokens:"number"==typeof r.maxTokens?String(r.maxTokens):null!=o.maxTokens?String(o.maxTokens):"",hidden:"boolean"==typeof r.hidden&&r.hidden,thinkingLevelMap:r.thinkingLevelMap??o.thinkingLevelMap}}c(t),u(t),g(new Set)}}}catch(e){y(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[W.models,o,e]);return m?(0,r.jsx)("div",{style:{borderTop:"1px solid var(--border)",marginTop:14,paddingTop:12},children:(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-dim)"},children:s("desktop.modelsLoading")})}):(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",marginTop:14,paddingTop:12,display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)"},children:s("desktop.builtinModelsTitle")}),(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",paddingTop:10,display:"flex",flexDirection:"column",gap:8},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("button",{type:"button",onClick:()=>{L()},disabled:"loading"===W.phase,style:{padding:"5px 12px",background:(W.phase,"var(--bg-panel)"),border:"1px solid var(--border)",borderRadius:5,color:"loading"===W.phase?"var(--text-dim)":"var(--text-muted)",cursor:"loading"===W.phase?"not-allowed":"pointer",fontSize:12},children:"loading"===W.phase?s("desktop.modelsDiscoveryFetching"):s("desktop.builtinModelsFetchNew")}),"success"===W.phase&&W.models&&(0,r.jsx)("button",{type:"button",onClick:()=>{$()},disabled:x||0===D.length,style:{padding:"5px 12px",background:D.length>0&&!x?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:D.length>0&&!x?"#fff":"var(--text-dim)",cursor:D.length>0&&!x?"pointer":"not-allowed",fontSize:12,fontWeight:600},children:x?s("desktop.modelsSaving"):`${s("desktop.modelsAddModelManual")} (${D.length})`})]}),"error"===W.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:11,color:"#f87171"},children:W.message}),"success"===W.phase&&W.models&&(0,r.jsx)("div",{style:{maxHeight:200,overflowY:"auto",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)"},children:W.models.map(e=>{let t=W.newIds?.has(e.id)??!1,o=D.includes(e.id);return(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,minHeight:32,padding:"5px 9px",borderBottom:"1px solid var(--border)",cursor:t?"pointer":"default",opacity:t?1:.55},children:[(0,r.jsx)("input",{type:"checkbox",checked:o,disabled:!t,onChange:t=>{N(o=>t.target.checked?[...o,e.id]:o.filter(t=>t!==e.id))},style:{width:13,height:13,accentColor:"var(--accent)",flexShrink:0}}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",fontWeight:t?600:400},children:e.name||e.id}),(0,r.jsx)("code",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:e.id}),t&&(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:8,background:"var(--accent)",color:"#fff",marginLeft:"auto"},children:"新"})]},e.id)})})]}),v&&(0,r.jsx)("p",{style:{margin:0,fontSize:11,color:"#f87171"},children:v}),0===a.length&&!v&&(0,r.jsx)("p",{style:{margin:0,fontSize:11,color:"var(--text-dim)"},children:s("desktop.builtinModelsEmpty")}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:a.map(e=>{let t=d[e.id]??{},o=j===e.id,n=h.has(e.id);return(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",padding:"8px 10px"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsxs)("button",{type:"button",onClick:()=>S(o?null:e.id),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text)",fontSize:12,fontWeight:600,padding:0,textAlign:"left"},children:[t.name||e.name||e.id,n&&(0,r.jsx)("span",{style:{color:"var(--accent)",marginLeft:6},children:"•"})]}),(0,r.jsx)("code",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:e.id}),(t.reasoning??e.reasoning)&&(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:8,background:"var(--bg-selected)",color:"var(--text-muted)"},children:"reasoning"}),(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)"},children:[s("desktop.builtinModelsContext"),": ",(0,r.jsx)("b",{children:t.contextWindow?Number(t.contextWindow).toLocaleString():"—"})," \xb7 ",s("desktop.builtinModelsMaxTokens"),": ",(0,r.jsx)("b",{children:t.maxTokens?Number(t.maxTokens).toLocaleString():"—"})]})]}),o&&(0,r.jsxs)("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsxs)("label",{style:{display:"flex",gap:6,alignItems:"center",fontSize:12,color:"var(--text)",width:"100%"},children:[s("desktop.modelsName"),(0,r.jsx)("input",{type:"text",value:t.name??"",placeholder:e.name||e.id,onChange:t=>P(e.id,{name:t.target.value.trim()||void 0}),style:{flex:1,minWidth:0,padding:"4px 7px",fontSize:11,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text)",fontFamily:"var(--font-mono)"}}),(0,r.jsxs)("label",{style:{display:"flex",gap:4,alignItems:"center",fontSize:11,color:t.hidden?"#f87171":"var(--text-muted)",cursor:"pointer",whiteSpace:"nowrap",marginLeft:8},children:[(0,r.jsx)("input",{type:"checkbox",checked:!0===t.hidden,onChange:t=>P(e.id,{hidden:t.target.checked})}),s("desktop.builtinModelsHide")]})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:16,flexWrap:"wrap",flexDirection:i?"column":"row",alignItems:i?"flex-start":"center"},children:[(0,r.jsxs)("label",{style:{display:"flex",gap:6,alignItems:"center",fontSize:12,color:"var(--text)",cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:!0===t.reasoning,onChange:t=>P(e.id,{reasoning:t.target.checked})}),s("desktop.builtinModelsReasoning")]}),(0,r.jsxs)("label",{style:{display:"flex",gap:6,alignItems:"center",fontSize:12,color:"var(--text)",flex:i?1:void 0,width:i?"100%":void 0},children:[s("desktop.modelsContextWindow"),(0,r.jsx)("input",{type:"number",min:1,value:t.contextWindow??"",placeholder:null!=e.contextWindow?String(e.contextWindow):"",onChange:t=>P(e.id,{contextWindow:t.target.value}),style:{flex:1,minWidth:0,padding:"4px 7px",fontSize:11,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text)",fontFamily:"var(--font-mono)"}})]}),(0,r.jsxs)("label",{style:{display:"flex",gap:6,alignItems:"center",fontSize:12,color:"var(--text)",flex:i?1:void 0,width:i?"100%":void 0},children:[s("desktop.modelsMaxOutputTokens"),(0,r.jsx)("input",{type:"number",min:1,value:t.maxTokens??"",placeholder:null!=e.maxTokens?String(e.maxTokens):"",onChange:t=>P(e.id,{maxTokens:t.target.value}),style:{flex:1,minWidth:0,padding:"4px 7px",fontSize:11,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text)",fontFamily:"var(--font-mono)"}})]})]}),(0,r.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)"},children:s("desktop.builtinModelsThinking")}),(0,r.jsx)(l5,{value:t.thinkingLevelMap,onChange:t=>P(e.id,{thinkingLevelMap:t})})]})]},e.id)})}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,r.jsx)("button",{type:"button",onClick:()=>{E().catch(()=>{})},disabled:x||0===h.size,style:{alignSelf:"flex-start",padding:"5px 14px",background:h.size>0&&!x?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:h.size>0&&!x?"#fff":"var(--text-dim)",cursor:h.size>0&&!x?"pointer":"not-allowed",fontSize:12,fontWeight:600},children:x?s("desktop.modelsSaving"):b?s("desktop.modelsSaved"):s("desktop.modelsSave")}),h.size>0&&(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)"},children:s("desktop.builtinModelsDirty",{count:h.size})})]})]})}let lV=["openai-completions","openai-responses","anthropic-messages","google-generative-ai","mistral-conversations"],lK="__custom__";function lG(){let{t:e}=(0,A.s)();return(0,n.useCallback)((t,o)=>e(t,o),[e])}function lJ({label:e,children:t}){return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:e}),t]})}let lY={padding:"6px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:12,outline:"none",width:"100%",boxSizing:"border-box"};function lX({value:e,onChange:t,placeholder:o,mono:n,inputRef:s}){return(0,r.jsx)("input",{ref:s,value:e,onChange:e=>t(e.target.value),placeholder:o,style:{...lY,fontFamily:n?"var(--font-mono)":"inherit"}})}function lZ({value:e,onChange:t,placeholder:o,mono:s,onKeyDown:i,autoComplete:a="off",spellCheck:l=!1,style:d}){let c=lG(),[p,u]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{e||u(!1)},[e]),(0,r.jsxs)("div",{style:{position:"relative",width:"100%",...d},children:[(0,r.jsx)("input",{type:p?"text":"password",value:e,onChange:e=>t(e.target.value),onKeyDown:i,placeholder:o,style:{...lY,paddingRight:34,fontFamily:s?"var(--font-mono)":"inherit"},autoComplete:a,spellCheck:l}),(0,r.jsx)("button",{type:"button",onClick:()=>u(e=>!e),"aria-label":c(p?"desktop.modelsHideApiKey":"desktop.modelsShowApiKey"),title:c(p?"desktop.modelsHideApiKey":"desktop.modelsShowApiKey"),style:{position:"absolute",right:5,top:"50%",transform:"translateY(-50%)",width:24,height:24,padding:0,border:"none",background:"transparent",color:"var(--text-dim)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:p?(0,r.jsx)(lH.G,{size:15}):(0,r.jsx)(sR.b,{size:15})})]})}function lQ({value:e,onChange:t,placeholder:o}){return(0,r.jsx)("input",{type:"number",value:e,onChange:e=>t(e.target.value),placeholder:o,style:lY})}function l0({value:e,onChange:t,options:o,required:n}){let s=lG();return(0,r.jsxs)("select",{value:e,onChange:e=>t(e.target.value),style:{...lY,color:e?"var(--text)":"var(--text-dim)"},children:[!n&&(0,r.jsx)("option",{value:"",children:s("desktop.modelsInheritNone")}),o.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]})}function l1({label:e,checked:t,onChange:o}){return(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:12,color:"var(--text-muted)"},children:[(0,r.jsx)("input",{type:"checkbox",checked:t,onChange:e=>o(e.target.checked),style:{width:13,height:13,accentColor:"var(--accent)",cursor:"pointer"}}),e]})}function l2({children:e}){return(0,r.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:e})}function l4({name:e,provider:t,onChange:o,onRename:s,onDelete:i,onAddModels:a,onAddModel:l}){let d=lG(),[c,p]=(0,n.useState)(e),[u,h]=(0,n.useState)({phase:"idle"}),[g,m]=(0,n.useState)(""),[f,x]=(0,n.useState)([]),k=(0,n.useRef)(0),v=(0,n.useRef)(null);(0,n.useEffect)(()=>p(e),[e]);let y=(e,r)=>o({...t,[e]:r});(0,n.useEffect)(()=>{t.api||o({...t,api:"openai-completions"})},[t.api]),(0,n.useEffect)(()=>{k.current+=1,h({phase:"idle"}),m(""),x([])},[e,t.baseUrl,t.api,t.apiKey]);let b=(0,n.useCallback)(async()=>{if("loading"===u.phase)return;let o=++k.current;h({phase:"loading"}),x([]);try{let r=await fetch("/api/models-config/discover",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerName:e,provider:{...t,models:void 0}})}),n=await r.json();if(o!==k.current)return;if(!r.ok||n.error||!n.models)return void h({phase:"error",message:n.error??`HTTP ${r.status}`});h({phase:"success",models:n.models,endpoint:n.endpoint??t.baseUrl??""})}catch(e){if(o!==k.current)return;h({phase:"error",message:e instanceof Error?e.message:String(e)})}},[u.phase,e,t]),w=new Set((t.models??[]).map(e=>e.id)),j="success"===u.phase?u.models:[],S=g.trim().toLocaleLowerCase(),C=j.filter(e=>!S||e.id.toLocaleLowerCase().includes(S)||e.name?.toLocaleLowerCase().includes(S)),T=C.slice(0,300),R=T.filter(e=>!w.has(e.id)).map(e=>e.id),z=f.filter(e=>!w.has(e)).length,I=R.length>0&&R.every(e=>f.includes(e)),M=!I&&R.some(e=>f.includes(e));return(0,n.useEffect)(()=>{v.current&&(v.current.indeterminate=M)},[M]),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(l2,{children:d("desktop.modelsProvider")}),(0,r.jsx)("button",{onClick:i,style:{padding:"3px 8px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:4,color:"#ef4444",cursor:"pointer",fontSize:11},children:d("desktop.delete")})]}),(0,r.jsxs)(lJ,{label:d("desktop.modelsProviderName"),children:[(0,r.jsx)(lX,{value:c,onChange:p,placeholder:"provider-name",mono:!0}),c!==e&&c.trim()&&(0,r.jsx)("button",{onClick:()=>s(c.trim()),style:{marginTop:4,padding:"3px 10px",background:"var(--accent)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",fontSize:11,alignSelf:"flex-start"},children:d("desktop.rename")})]}),(0,r.jsx)(lJ,{label:d("desktop.modelsBaseUrl"),children:(0,r.jsx)(lX,{value:t.baseUrl??"",onChange:e=>y("baseUrl",e||void 0),placeholder:"http(s)://host:port/v1",mono:!0})}),(0,r.jsxs)(lJ,{label:d("desktop.modelsApiKey"),children:[(0,r.jsx)(lZ,{value:t.apiKey??"",onChange:e=>y("apiKey",e||void 0),placeholder:d("desktop.modelsApiKeyPlaceholder"),mono:!0}),(0,r.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:d("desktop.modelsApiKeyHelp")})]}),(0,r.jsx)(lJ,{label:d("desktop.modelsApi"),children:(0,r.jsx)(l0,{value:t.api??"openai-completions",onChange:e=>y("api",e),options:lV,required:!0})}),(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",paddingTop:14,display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:["success"!==u.phase&&(0,r.jsx)("button",{onClick:b,disabled:"loading"===u.phase,style:{height:30,padding:"0 12px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)",color:t.baseUrl?.trim()&&"loading"!==u.phase?"var(--text-muted)":"var(--text-dim)",cursor:t.baseUrl?.trim()&&"loading"!==u.phase?"pointer":"not-allowed",fontSize:11},children:"loading"===u.phase?d("desktop.modelsDiscoveryFetching"):d("desktop.modelsDiscoveryFetch")}),(0,r.jsx)("button",{onClick:l,title:d("desktop.modelsAddModelManual"),style:{height:30,padding:"0 12px",border:"none",borderRadius:5,background:"var(--accent)",color:"#fff",cursor:"pointer",fontSize:11,fontWeight:600},children:d("desktop.modelsAddModelManual")})]}),"error"===u.phase&&(0,r.jsx)("div",{style:{padding:"7px 9px",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",fontSize:11,lineHeight:1.4},children:u.message}),"success"===u.phase&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{value:g,onChange:e=>m(e.target.value),placeholder:d("desktop.modelsDiscoveryFilterPlaceholder",{count:u.models.length}),"aria-label":d("desktop.modelsDiscoveryFilter"),style:{...lY,width:"100%",minWidth:0}}),(0,r.jsxs)("div",{style:{maxHeight:220,overflowY:"auto",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)"},children:[(0,r.jsxs)("label",{style:{minHeight:32,padding:"5px 9px",display:"flex",alignItems:"center",gap:8,position:"sticky",top:0,zIndex:1,borderBottom:"1px solid var(--border)",background:"var(--bg)",cursor:R.length?"pointer":"default",color:"var(--text-muted)",fontSize:10,fontWeight:600},children:[(0,r.jsx)("input",{ref:v,type:"checkbox",checked:I,disabled:0===R.length,onChange:()=>{let e=new Set(R);x(t=>I?t.filter(t=>!e.has(t)):Array.from(new Set([...t,...R])))},style:{width:13,height:13,accentColor:"var(--accent)",flexShrink:0}}),d("desktop.modelsDiscoverySelectShown")]}),0===T.length?(0,r.jsx)("div",{style:{padding:12,color:"var(--text-dim)",fontSize:11},children:d("desktop.modelsDiscoveryNoMatches")}):T.map((e,t)=>{let o=w.has(e.id),n=f.includes(e.id);return(0,r.jsxs)("label",{style:{minHeight:36,padding:"6px 9px",display:"flex",alignItems:"center",gap:8,borderTop:0===t?"none":"1px solid var(--border)",cursor:o?"default":"pointer",opacity:o?.65:1},children:[(0,r.jsx)("input",{type:"checkbox",checked:n||o,disabled:o,onChange:()=>{var t;return t=e.id,void x(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},style:{width:13,height:13,accentColor:"var(--accent)",flexShrink:0}}),(0,r.jsxs)("span",{style:{minWidth:0,flex:1},children:[(0,r.jsx)("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)",fontSize:11},children:e.name??e.id}),e.name&&(0,r.jsx)("code",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontSize:10,fontFamily:"var(--font-mono)"},children:e.id})]}),o&&(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10},children:d("desktop.modelsDiscoveryAdded")})]},e.id)})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10},children:[(0,r.jsx)("span",{title:u.endpoint,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontSize:10},children:C.length>T.length?d("desktop.modelsDiscoveryShowing",{shown:T.length,total:C.length}):d("desktop.modelsDiscoveryFetched",{count:u.models.length})}),(0,r.jsx)("button",{onClick:()=>{if("success"!==u.phase)return;let e=new Set(f),t=u.models.filter(t=>e.has(t.id)&&!w.has(t.id));0!==t.length&&(a(t),x([]))},disabled:0===z,style:{height:28,padding:"0 11px",border:"none",borderRadius:5,background:z?"var(--accent)":"var(--bg-panel)",color:z?"#fff":"var(--text-dim)",cursor:z?"pointer":"not-allowed",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:z?d("desktop.modelsDiscoveryAddSelectedCount",{count:z}):d("desktop.modelsDiscoveryAddSelected")})]})]})]})]})}let l6=["off","minimal","low","medium","high","xhigh","max"],l8={off:"var(--text-dim)",minimal:"var(--text-muted)",low:"#60a5fa",medium:"#a78bfa",high:"#f472b6",xhigh:"#fb923c",max:"#ef4444"};function l5({value:e,onChange:t}){let o=lG(),n=e??{},s=(e,o)=>{let r={...n};"omit"===o?delete r[e]:r[e]=o,t(Object.keys(r).length?r:void 0)};return(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:l6.map(e=>{let t=n[e],i=e in n?null===t?"null":"string":"omit",a="string"==typeof t?t:"",l=l8[e],d={padding:"4px 10px",fontSize:10,border:"none",cursor:"pointer",fontWeight:400,transition:"background 0.1s, color 0.1s",whiteSpace:"nowrap",background:"var(--bg-panel)",color:"var(--text-dim)"},c={background:"var(--accent)",color:"#fff",fontWeight:600};return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 4px",borderRadius:6,background:"transparent",border:"1px solid transparent"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,width:68,flexShrink:0},children:[(0,r.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:l,flexShrink:0,opacity:"null"===i?.3:1}}),(0,r.jsx)("span",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:"null"===i?"var(--text-dim)":"var(--text-muted)",textDecoration:"null"===i?"line-through":"none"},children:e})]}),(0,r.jsxs)("div",{style:{display:"flex",borderRadius:5,border:"1px solid var(--border)",overflow:"hidden",flexShrink:0},children:[(0,r.jsx)("button",{onClick:()=>s(e,"omit"),style:{...d,..."omit"===i?c:{}},children:o("desktop.modelsDefault")}),(0,r.jsx)("button",{onClick:()=>s(e,null),style:{...d,borderLeft:"1px solid var(--border)",..."null"===i?{background:"#ef4444",color:"#fff",fontWeight:600}:{}},children:o("desktop.modelsDisabled")})]}),(0,r.jsxs)("div",{style:{display:"flex",borderRadius:5,border:`1px solid ${"string"===i?"var(--accent)":"var(--border)"}`,overflow:"hidden",transition:"border-color 0.1s"},children:[(0,r.jsx)("button",{onClick:()=>s(e,a||e),style:{...d,..."string"===i?c:{},borderRight:"1px solid var(--border)",flexShrink:0},children:o("desktop.modelsCustom")}),(0,r.jsx)("input",{value:a,onChange:t=>s(e,t.target.value),onFocus:()=>{"string"!==i&&s(e,a||e)},placeholder:e,maxLength:10,style:{width:"12ch",background:"string"===i?"var(--bg)":"var(--bg-panel)",border:"none",outline:"none",color:"string"===i?"var(--text)":"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,padding:"4px 7px",transition:"background 0.1s, color 0.1s"}})]})]},e)})})}let l3={thinkingFormat:"deepseek",requiresReasoningContentOnAssistantMessages:!0};function l7({providerName:e,provider:t,model:o,onChange:s,onDelete:i}){let a=lG(),[l,d]=(0,n.useState)({phase:"idle"}),[c,p]=(0,n.useState)({phase:"idle"}),u=(0,n.useRef)(0),h=(0,n.useRef)(null),g=(e,t)=>s({...o,[e]:t}),f=(()=>{if("idle"===l.phase)return null;if("testing"===l.phase)return a("desktop.modelsTestingConnection");let e=[void 0!==l.latencyMs?`${l.latencyMs}ms`:null,void 0!==l.status?`HTTP ${l.status}`:null].filter(Boolean);return"success"===l.phase?[a("desktop.modelsConnected"),...e,l.responseText||null].filter(Boolean).join(" \xb7 "):[a("desktop.modelsFailed"),...e,l.message].filter(Boolean).join(" \xb7 ")})();(0,n.useEffect)(()=>{d({phase:"idle"})},[e,t.baseUrl,t.api,t.apiKey,o.id,o.api]);let x=(0,n.useCallback)(async()=>{if(o.id.trim()&&"testing"!==l.phase){d({phase:"testing"});try{let r=await fetch("/api/models-config/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerName:e,provider:t,model:o})}),n=await r.json();if(!r.ok||!n.ok)return void d({phase:"error",message:n.error??`HTTP ${r.status}`,latencyMs:n.latencyMs,status:n.status});d({phase:"success",latencyMs:n.latencyMs,status:n.status,responseText:n.responseText})}catch(e){d({phase:"error",message:e instanceof Error?e.message:String(e)})}}},[o,t,e,l.phase]);(0,n.useEffect)(()=>{u.current+=1,p({phase:"idle"}),h.current=null},[e,t.baseUrl,o.id]);let k=(0,n.useCallback)(async()=>{let r=o.id.trim();if(!r||"loading"===c.phase)return;let n=++u.current;p({phase:"loading"});try{let i=new URLSearchParams({q:r,provider:e,limit:"50"});t.baseUrl?.trim()&&i.set("baseUrl",t.baseUrl.trim());let a=await fetch(`/api/models-config/catalog?${i}`),l=await a.json();if(n!==u.current)return;if(!a.ok||l.error||!l.recommendation)return void p({phase:"error",message:l.error??`HTTP ${a.status}`});let d=function(e,t){let o={...e},r=0;if(!e.name?.trim()&&t.name&&(o.name=t.name,r+=1),void 0===e.reasoning&&!0===t.reasoning&&(o.reasoning=!0,r+=1),!e.input?.length&&t.input?.length&&(o.input=[...t.input],r+=1),void 0===e.contextWindow&&void 0!==t.contextWindow&&(o.contextWindow=t.contextWindow,r+=1),void 0===e.maxTokens&&void 0!==t.maxTokens&&(o.maxTokens=t.maxTokens,r+=1),t.cost){let n={...e.cost??{}},s=!1;for(let e of["input","output","cacheRead","cacheWrite"])void 0===n[e]&&void 0!==t.cost[e]&&(n[e]=t.cost[e],s=!0,r+=1);s&&(o.cost=n)}return{model:o,appliedCount:r}}(o,l.recommendation.preset);d.appliedCount>0&&(h.current=o,s(d.model)),p({phase:"success",recommendation:l.recommendation,appliedCount:d.appliedCount})}catch(e){if(n!==u.current)return;p({phase:"error",message:e instanceof Error?e.message:String(e)})}},[c.phase,o,s,t.baseUrl,e]),v=(()=>{if("success"!==c.phase)return null;let{recommendation:t,appliedCount:o}=c,r=o>0?a("desktop.modelsCatalogFilled",{count:o}):a("desktop.modelsCatalogNoEmptyFields");if("unreliable"===t.price.status){let e="no-exact-match"===t.price.reason?a("desktop.modelsCatalogNoExactMatch"):a("desktop.modelsCatalogPriceUnreliable");return`${r} \xb7 ${e}`}let n="provider"===t.price.method?a("desktop.modelsCatalogPriceProvider",{provider:t.price.providerName??t.price.providerId??e}):"base-url"===t.price.method?a("desktop.modelsCatalogPriceBaseUrl",{provider:t.price.providerName??t.price.providerId??e}):a("desktop.modelsCatalogPriceConsensus",{support:t.price.support,total:t.price.total});return`${r} \xb7 ${n}`})(),y="error"===c.phase?c.message:v,b="error"===c.phase?"#ef4444":"success"===c.phase&&"unreliable"===c.recommendation.price.status?"#d97706":"var(--text-dim)";return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(l2,{children:a("desktop.modelsModelSection")}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[f&&(0,r.jsx)("span",{title:f,style:{maxWidth:260,height:24,padding:"0 8px",border:`1px solid ${"error"===l.phase?"#fecaca":"success"===l.phase?"#bbf7d0":"var(--border)"}`,borderRadius:4,background:"error"===l.phase?"#fee2e2":"success"===l.phase?"#dcfce7":"#e5e7eb",color:"#111827",fontSize:11,display:"inline-flex",alignItems:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",boxSizing:"border-box"},children:f}),(0,r.jsxs)("button",{onClick:x,disabled:!o.id.trim()||"testing"===l.phase,title:a("desktop.modelsTestConnection"),style:{height:24,padding:"0 8px",background:"success"===l.phase?"#16a34a":"none",border:`1px solid ${"success"===l.phase?"#16a34a":"var(--border)"}`,borderRadius:4,color:"success"===l.phase?"#fff":o.id.trim()&&"testing"!==l.phase?"var(--text-muted)":"var(--text-dim)",cursor:o.id.trim()&&"testing"!==l.phase?"pointer":"not-allowed",fontSize:11,display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",gap:5},children:["success"===l.phase&&(0,r.jsx)(m.S,{size:11}),"testing"===l.phase?a("desktop.modelsTesting"):"success"===l.phase?a("desktop.modelsOk"):a("desktop.modelsTest")]}),(0,r.jsx)("button",{onClick:i,style:{height:24,padding:"0 8px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:4,color:"#ef4444",cursor:"pointer",fontSize:11,boxSizing:"border-box"},children:a("desktop.modelsRemove")})]})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,r.jsx)(lJ,{label:a("desktop.modelsIdRequired"),children:(0,r.jsx)(lX,{value:o.id,onChange:e=>g("id",e),placeholder:"model-id",mono:!0})}),(0,r.jsx)(lJ,{label:a("desktop.modelsName"),children:(0,r.jsx)(lX,{value:o.name??"",onChange:e=>g("name",e||void 0),placeholder:a("desktop.modelsDisplayName")})})]}),(0,r.jsxs)("div",{style:{padding:"10px 0",borderTop:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("button",{onClick:()=>void k(),disabled:!o.id.trim()||"loading"===c.phase,style:{height:28,padding:"0 10px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)",color:o.id.trim()&&"loading"!==c.phase?"var(--text-muted)":"var(--text-dim)",cursor:o.id.trim()&&"loading"!==c.phase?"pointer":"not-allowed",fontSize:11},children:"loading"===c.phase?a("desktop.modelsCatalogFilling"):a("desktop.modelsCatalogFill")}),(0,r.jsx)("a",{href:"https://github.com/anomalyco/models.dev",target:"_blank",rel:"noreferrer",style:{marginLeft:"auto",color:"var(--text-dim)",fontSize:10,textDecoration:"none"},children:a("desktop.modelsCatalogSource")})]}),(0,r.jsxs)("div",{"aria-live":"polite",style:{marginTop:6,height:20,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,color:b,fontSize:10},children:[(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y}),"success"===c.phase&&h.current&&(0,r.jsx)("button",{onClick:()=>{let e=h.current;e&&(h.current=null,s(e),p({phase:"idle"}))},style:{background:"none",border:"none",color:"var(--accent)",cursor:"pointer",fontSize:10,flexShrink:0},children:a("desktop.modelsCatalogUndo")})]})]}),(0,r.jsx)(lJ,{label:a("desktop.modelsApiOverride"),children:(0,r.jsx)(l0,{value:o.api??"",onChange:e=>g("api",e||void 0),options:lV})}),(0,r.jsxs)("div",{style:{display:"flex",gap:20,flexWrap:"wrap"},children:[(0,r.jsx)(l1,{label:a("desktop.modelsReasoningThinking"),checked:o.reasoning??!1,onChange:e=>g("reasoning",e||void 0)}),(0,r.jsx)(l1,{label:a("desktop.modelsImageInput"),checked:o.input?.includes("image")??!1,onChange:e=>g("input",e?["text","image"]:void 0)})]}),o.reasoning&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l1,{label:a("desktop.modelsDeepSeekCompat"),checked:o.compat?.thinkingFormat==="deepseek",onChange:e=>s(function(e,t){if(t)return{...e,compat:{...e.compat??{},...l3}};if(!e.compat)return e;let o={...e.compat};return delete o.thinkingFormat,delete o.requiresReasoningContentOnAssistantMessages,{...e,compat:Object.keys(o).length?o:void 0}}(o,e))}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,r.jsx)(l2,{children:a("desktop.modelsThinkingLevelMap")}),o.thinkingLevelMap&&(0,r.jsx)("button",{onClick:()=>g("thinkingLevelMap",void 0),style:{fontSize:10,padding:"2px 7px",background:"none",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-dim)",cursor:"pointer"},children:a("desktop.modelsClearAll")})]}),(0,r.jsx)(l5,{value:o.thinkingLevelMap,onChange:e=>g("thinkingLevelMap",e)})]})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,r.jsx)(lJ,{label:a("desktop.modelsContextWindow"),children:(0,r.jsx)(lQ,{value:void 0!==o.contextWindow?String(o.contextWindow):"",onChange:e=>g("contextWindow",e?parseInt(e):void 0),placeholder:"128000"})}),(0,r.jsx)(lJ,{label:a("desktop.modelsMaxOutputTokens"),children:(0,r.jsx)(lQ,{value:void 0!==o.maxTokens?String(o.maxTokens):"",onChange:e=>g("maxTokens",e?parseInt(e):void 0),placeholder:"16384"})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(l2,{children:a("desktop.modelsCostPerMillionTokens")}),(0,r.jsx)("div",{style:{marginTop:8,display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:8},children:["input","output","cacheRead","cacheWrite"].map(e=>(0,r.jsx)(lJ,{label:e,children:(0,r.jsx)(lQ,{value:o.cost?.[e]!==void 0?String(o.cost[e]):"",onChange:t=>{let r;return r=parseFloat(t),void s({...o,cost:{...o.cost??{},[e]:isNaN(r)?void 0:r}})},placeholder:"0"})},e))})]})]})}function l9({provider:e,onRefresh:t,onRegisterBuiltinFlush:o,onBuiltinProviderChange:s}){let i=lG(),[a,l]=(0,n.useState)({phase:"idle"}),[d,c]=(0,n.useState)(""),p=(0,n.useRef)(null),u=(0,n.useRef)(null);(0,n.useEffect)(()=>{("auth"===a.phase||"prompt"===a.phase)&&setTimeout(()=>u.current?.focus(),50)},[a.phase]),(0,n.useEffect)(()=>{l({phase:"idle"}),c(""),p.current?.close(),p.current=null},[e.id]),(0,n.useEffect)(()=>()=>{p.current?.close()},[]);let h=(0,n.useCallback)(()=>{p.current?.close(),l({phase:"connecting"}),c("");let o=new EventSource(`/api/auth/login/${encodeURIComponent(e.id)}`);p.current=o,o.onmessage=e=>{let r=JSON.parse(e.data);"auth"===r.type?(l({phase:"auth",url:r.url,instructions:r.instructions??null,token:r.token}),window.open(r.url,"_blank","noopener,noreferrer")):"device_code"===r.type?(l({phase:"device_code",userCode:r.userCode,verificationUri:r.verificationUri,intervalSeconds:r.intervalSeconds??null,expiresInSeconds:r.expiresInSeconds??null}),window.open(r.verificationUri,"_blank","noopener,noreferrer")):"prompt_request"===r.type?l({phase:"prompt",message:r.message,placeholder:r.placeholder??null,token:r.token}):"select_request"===r.type?l({phase:"select",message:r.message,options:r.options??[],token:r.token}):"progress"===r.type?l({phase:"progress",message:r.message}):"success"===r.type?(o.close(),l({phase:"success"}),t()):"error"===r.type?(o.close(),l({phase:"error",message:r.message})):"cancelled"===r.type&&(o.close(),l({phase:"idle"}))},o.onerror=()=>{o.close(),l(e=>"success"===e.phase?e:{phase:"error",message:i("desktop.modelsConnectionLost")})}},[e.id,t,i]),g=(0,n.useCallback)(async()=>{try{let t=await fetch(`/api/auth/logout/${encodeURIComponent(e.id)}`,{method:"POST"});if(t.ok)l({phase:"idle"});else{let e=await t.json().catch(()=>null);l({phase:"error",message:409===t.status?i("desktop.modelsAuthenticationStateChanged"):e?.error??`HTTP ${t.status}`})}}catch(e){l({phase:"error",message:e instanceof Error?e.message:String(e)})}finally{t()}},[e.id,t,i]),m=(0,n.useCallback)(async(t,o)=>{if(o.trim()){l({phase:"progress",message:i("desktop.modelsVerifying")});try{let r=await fetch(`/api/auth/login/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,code:o.trim()})});if(!r.ok){let e=await r.json().catch(()=>({}));l({phase:"error",message:e.error??i("desktop.modelsServerError",{status:r.status})});return}c("")}catch(e){l({phase:"error",message:e instanceof Error?e.message:i("desktop.modelsNetworkError")})}}},[e.id,i]),f=(0,n.useCallback)(async(t,o)=>{l({phase:"progress",message:i("desktop.modelsContinuing")});try{let r=await fetch(`/api/auth/login/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,code:o})});if(!r.ok){let e=await r.json().catch(()=>({}));l({phase:"error",message:e.error??i("desktop.modelsServerError",{status:r.status})})}}catch(e){l({phase:"error",message:e instanceof Error?e.message:i("desktop.modelsNetworkError")})}},[e.id,i]),x="connecting"===a.phase||"progress"===a.phase||"auth"===a.phase||"device_code"===a.phase||"prompt"===a.phase||"select"===a.phase;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(l2,{children:i("desktop.modelsSubscription")}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e.loggedIn?"#4ade80":"var(--border)",display:"inline-block"}}),(0,r.jsx)("span",{style:{fontSize:11,color:e.loggedIn?"#4ade80":"var(--text-dim)"},children:e.loggedIn?i("desktop.modelsConnected"):i("desktop.modelsNotConnected")})]})]}),(0,r.jsxs)("div",{style:{minHeight:48},children:["idle"===a.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:e.loggedIn?i("desktop.modelsAlreadyConnected"):i("desktop.modelsConnectAccount",{provider:e.name})}),"connecting"===a.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)"},children:i("desktop.modelsOpeningBrowser")}),"select"===a.phase&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:a.message}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:a.options.map(e=>(0,r.jsx)("button",{onClick:()=>f(a.token,e.id),style:{padding:"6px 9px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",cursor:"pointer",fontSize:12,textAlign:"left"},children:e.label},e.id))})]}),("auth"===a.phase||"prompt"===a.phase)&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:"auth"===a.phase?i("desktop.modelsCompleteSignIn"):a.message}),"auth"===a.phase&&(0,r.jsxs)("p",{style:{margin:0,fontSize:11,color:"var(--text-dim)",lineHeight:1.5},children:[i("desktop.modelsBrowserDidNotOpen")," ",(0,r.jsx)("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",wordBreak:"break-all"},children:i("desktop.modelsOpenLoginPage")}),"."]}),(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("input",{ref:u,value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&m(a.token,d)},placeholder:"auth"===a.phase?"http://localhost:1455/auth/callback?code=…":a.placeholder??i("desktop.modelsEnterValue"),style:{flex:1,padding:"6px 9px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:12,outline:"none",fontFamily:"var(--font-mono)",boxSizing:"border-box"}}),(0,r.jsx)("button",{onClick:()=>m(a.token,d),disabled:!d.trim(),style:{padding:"6px 12px",background:d.trim()?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:d.trim()?"#fff":"var(--text-dim)",cursor:d.trim()?"pointer":"not-allowed",fontSize:12,fontWeight:600,flexShrink:0},children:i("desktop.submit")})]})]}),"device_code"===a.phase&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:i("desktop.modelsOpenVerificationPage")}),(0,r.jsx)("div",{style:{padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:16,fontWeight:700,fontFamily:"var(--font-mono)",letterSpacing:0},children:a.userCode}),(0,r.jsxs)("p",{style:{margin:0,fontSize:11,color:"var(--text-dim)",lineHeight:1.5},children:[(0,r.jsx)("a",{href:a.verificationUri,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",wordBreak:"break-all"},children:a.verificationUri}),a.expiresInSeconds?` ${i("desktop.modelsExpiresInMinutes",{count:Math.ceil(a.expiresInSeconds/60)})}`:""]})]}),"progress"===a.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)"},children:a.message}),"success"===a.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"#4ade80"},children:i("desktop.modelsConnectedSuccessfully")}),"error"===a.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"#f87171"},children:a.message})]}),(0,r.jsx)("div",{style:{display:"flex",gap:8},children:x?(0,r.jsx)("button",{onClick:()=>{p.current?.close(),l({phase:"idle"})},style:{padding:"5px 12px",background:"none",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:i("desktop.cancel")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:h,style:{padding:"5px 14px",background:"var(--accent)",border:"none",borderRadius:5,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600},children:e.loggedIn?i("desktop.modelsReLogin"):i("desktop.modelsLogin")}),e.loggedIn&&(0,r.jsx)("button",{onClick:g,style:{padding:"5px 12px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",cursor:"pointer",fontSize:12},children:i("desktop.modelsDisconnect")})]})}),(0,r.jsx)(lq,{providerId:e.id,onRegisterFlush:o,onConfigChange:s})]})}function de({provider:e,onRefresh:t,onRegisterBuiltinFlush:o,onBuiltinProviderChange:s}){let i=lG(),[a,l]=(0,n.useState)(""),[d,c]=(0,n.useState)(!1),[p,u]=(0,n.useState)(!1),[h,g]=(0,n.useState)(null),[f,x]=(0,n.useState)(!1);(0,n.useEffect)(()=>{l(""),g(null),x(!1)},[e.id]);let k=(0,n.useCallback)(async()=>{if(a.trim()){c(!0),g(null),x(!1);try{let o=await fetch(`/api/auth/api-key/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:a.trim()})}),r=await o.json();!o.ok||r.error?g(r.error??`HTTP ${o.status}`):(l(""),x(!0),setTimeout(()=>x(!1),2e3),t())}catch(e){g(String(e))}finally{c(!1)}}},[a,e.id,t]),v=(0,n.useCallback)(async()=>{u(!0),g(null);try{let t=await fetch(`/api/auth/api-key/${encodeURIComponent(e.id)}`,{method:"DELETE"}),o=await t.json();(!t.ok||o.error)&&g(409===t.status?i("desktop.modelsAuthenticationStateChanged"):o.error??`HTTP ${t.status}`)}catch(e){g(String(e))}finally{t(),u(!1)}},[e.id,t,i]);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(l2,{children:i("desktop.modelsApiKey")}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e.configured?"#4ade80":"var(--border)",display:"inline-block"}}),(0,r.jsx)("span",{style:{fontSize:11,color:e.configured?"#4ade80":"var(--text-dim)"},children:e.configured?i("desktop.modelsConfigured"):i("desktop.modelsNotConfigured")})]})]}),(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:e.configured?i("desktop.modelsApiKeyStored"):i("desktop.modelsEnableModels",{provider:e.displayName,count:e.modelCount,models:1===e.modelCount?i("desktop.modelsSingular"):i("desktop.modelsPlural")})}),(0,r.jsx)(lJ,{label:i("desktop.modelsApiKey"),children:(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)(lZ,{value:a,onChange:l,onKeyDown:e=>{"Enter"===e.key&&a.trim()&&k()},placeholder:e.configured?i("desktop.modelsEnterNewKey"):"sk-…",style:{flex:1},autoComplete:"off",spellCheck:!1,mono:!0}),(0,r.jsxs)("button",{onClick:k,disabled:d||!a.trim()||f,style:{padding:"6px 12px",background:f?"#16a34a":a.trim()?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:a.trim()||f?"#fff":"var(--text-dim)",cursor:d||!a.trim()||f?"not-allowed":"pointer",fontSize:12,fontWeight:600,flexShrink:0,display:"flex",alignItems:"center",gap:5},children:[f&&(0,r.jsx)(m.S,{size:12}),f?i("desktop.modelsSaved"):d?i("desktop.modelsSaving"):i("desktop.modelsSave")]})]})}),h&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"#f87171"},children:h}),e.configured&&(0,r.jsx)("button",{onClick:v,disabled:p,style:{alignSelf:"flex-start",padding:"5px 12px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",cursor:p?"not-allowed":"pointer",fontSize:12},children:p?i("desktop.modelsRemoving"):i("desktop.modelsDisconnect")}),(0,r.jsx)(lq,{providerId:e.id,onRegisterFlush:o,onConfigChange:s})]})}function dt({oauthProviders:e,apiKeyProviders:t,onSelectOAuth:o,onSelectApiKey:s,onAddCustom:i,onClose:a}){let l=lG(),[d,c]=(0,n.useState)(""),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{setTimeout(()=>p.current?.focus(),30)},[]);let h=d.trim().toLowerCase(),g=e.filter(e=>!e.loggedIn&&(!h||e.name.toLowerCase().includes(h))),m=t.filter(e=>!e.configured&&(!h||e.displayName.toLowerCase().includes(h)||e.id.toLowerCase().includes(h))),f=!h||"custom".includes(h)||"openai-compatible".includes(h)||"anthropic-compatible".includes(h),x=g.length+m.length+ +!!f,k={display:"flex",flexDirection:"row",alignItems:"center",gap:8,padding:"10px 12px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:7,boxSizing:"border-box",cursor:"pointer",minWidth:0,textAlign:"left",transition:"border-color 0.12s, background 0.12s",width:"100%"};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&a()},children:(0,r.jsxs)("div",{style:{width:820,maxWidth:"calc(100vw - 32px)",maxHeight:"min(72vh, calc(100vh - 32px))",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.22)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--border)",flexShrink:0,display:"flex",alignItems:"center",gap:8},children:[(0,r.jsx)(u.$,{size:13,style:{color:"var(--text-dim)",flexShrink:0}}),(0,r.jsx)("input",{ref:p,value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Escape"===e.key&&a()},placeholder:l("desktop.modelsSearchProviders"),style:{flex:1,background:"none",border:"none",outline:"none",color:"var(--text)",fontSize:13,boxSizing:"border-box"}})]}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:14},children:0===x?(0,r.jsx)("div",{style:{padding:"20px 0",fontSize:12,color:"var(--text-dim)",textAlign:"center"},children:l("desktop.modelsNoProvidersMatch")}):(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(240px, 100%), 1fr))",gap:8},children:[f&&(0,r.jsx)("div",{style:{gridColumn:"1 / -1",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:l("desktop.modelsCustom")}),f&&(0,r.jsxs)("button",{onClick:()=>{i(),a()},style:k,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l("desktop.modelsCompatibleProvider")}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:l("desktop.modelsCustomEndpointFormat")})]}),(0,r.jsx)("span",{style:{width:26,height:26,borderRadius:5,background:"var(--bg-hover)",border:"1px dashed var(--border)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,r.jsx)(v.c,{size:13,style:{color:"var(--text-dim)"}})})]}),g.length>0&&(0,r.jsx)("div",{style:{gridColumn:"1 / -1",paddingTop:6*!!f,fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:l("desktop.modelsSubscriptions")}),g.map(e=>(0,r.jsxs)("button",{onClick:()=>{o(e.id),a()},style:k,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:"OAuth"})]}),(0,r.jsx)(is,{id:e.id,size:28})]},e.id)),m.length>0&&(0,r.jsx)("div",{style:{gridColumn:"1 / -1",paddingTop:6*(g.length>0),fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:l("desktop.modelsApiKey")}),m.map(e=>(0,r.jsxs)("button",{onClick:()=>{s(e.id),a()},style:k,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.displayName}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:l("desktop.modelsCount",{count:e.modelCount})})]}),(0,r.jsx)(is,{id:e.id,size:28})]},e.id))]})})]})})}function dr({existingProviders:e,onCancel:t,onSubmit:o}){let s=lG(),[i,a]=(0,n.useState)(""),[l,d]=(0,n.useState)(lV[0]),[c,p]=(0,n.useState)(lV[0]),[u,h]=(0,n.useState)(""),[g,m]=(0,n.useState)(""),[f,x]=(0,n.useState)(void 0),[k,y]=(0,n.useState)(!1),[b,w]=(0,n.useState)(""),[j,S]=(0,n.useState)(""),[C,T]=(0,n.useState)(""),[R,z]=(0,n.useState)(""),I=(0,n.useRef)(null);(0,n.useEffect)(()=>{setTimeout(()=>I.current?.focus(),30)},[]);let M=!u.trim()||/^https?:\/\//i.test(u.trim());return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&t()},children:(0,r.jsxs)("div",{style:{width:480,maxWidth:"calc(100vw - 32px)",maxHeight:"min(82vh, calc(100vh - 32px))",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.22)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:s("desktop.modelsAddCustomTitle")}),(0,r.jsx)("button",{onClick:t,"aria-label":s("desktop.modelsClose"),title:s("desktop.modelsClose"),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),(0,r.jsxs)("div",{style:{padding:16,overflowY:"auto",display:"flex",flexDirection:"column",gap:14},children:[(0,r.jsx)(lJ,{label:s("desktop.modelsProviderNameOptional"),children:(0,r.jsx)(lX,{value:i,onChange:a,placeholder:"new-provider",mono:!0,inputRef:I})}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)(l2,{children:s("desktop.modelsCallFormat")}),(0,r.jsxs)("select",{value:c,onChange:e=>{let t=e.target.value;(p(t),t===lK)?y(!0):d(t)},style:lY,children:[lV.map(e=>(0,r.jsx)("option",{value:e,children:e},e)),(0,r.jsx)("option",{value:lK,children:s("desktop.modelsCustomCallFormat")})]}),(0,r.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:s("desktop.modelsCallFormatHelp")}),c===lK&&(0,r.jsx)("span",{style:{fontSize:10,color:"#d97706",lineHeight:1.4},children:s("desktop.modelsCustomCallFormatHelp")})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)(l2,{children:s("desktop.modelsImportProvider")}),(0,r.jsxs)("select",{value:R,onChange:t=>{var o;let r;return z(o=t.target.value),void((r=e.find(e=>e.name===o))&&(r.provider.api&&(d(r.provider.api),p(r.provider.api)),h(r.provider.baseUrl??""),m(r.provider.apiKey??""),x(r.provider.headers?{...r.provider.headers}:void 0)))},style:{...lY,color:R?"var(--text)":"var(--text-dim)"},children:[(0,r.jsx)("option",{value:"",children:s("desktop.modelsImportProviderPlaceholder")}),e.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name,e.provider.api?` \xb7 ${e.provider.api}`:""]},e.name))]}),R&&(0,r.jsxs)("span",{style:{fontSize:10,color:"#4ade80"},children:[s("desktop.modelsImported"),": ",R]})]}),(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",paddingTop:12,display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)(l2,{children:s("desktop.modelsFullUrl")}),k?(0,r.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,r.jsx)(lX,{value:u,onChange:h,placeholder:s("desktop.modelsUrlPlaceholder"),mono:!0}),(0,r.jsx)("button",{onClick:()=>{y(!1),h("")},title:s("desktop.modelsRemove"),style:{flexShrink:0,width:28,height:28,background:"none",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-dim)",cursor:"pointer",fontSize:14,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"\xd7"})]}):(0,r.jsxs)("button",{onClick:()=>y(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"7px 0",background:"none",border:"1px dashed var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer",fontSize:12},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:[(0,r.jsx)(v.c,{size:12}),s("desktop.modelsAddUrl")]}),u.trim()&&!M&&(0,r.jsx)("span",{style:{fontSize:10,color:"#ef4444"},children:s("desktop.modelsUrlInvalid")}),(0,r.jsxs)(lJ,{label:s("desktop.modelsApiKey"),children:[(0,r.jsx)(lZ,{value:g,onChange:m,placeholder:s("desktop.modelsApiKeyPlaceholder"),mono:!0}),(0,r.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:s("desktop.modelsApiKeyHelp")})]})]}),(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",paddingTop:12,display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)(l2,{children:s("desktop.modelsCustomRequest")}),(0,r.jsxs)(lJ,{label:s("desktop.modelsRequestModelId"),children:[(0,r.jsx)(lX,{value:b,onChange:w,placeholder:"model-id",mono:!0}),(0,r.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:s("desktop.modelsRequestModelIdHelp")})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,r.jsx)(lJ,{label:s("desktop.modelsRequestContextLength"),children:(0,r.jsx)(lQ,{value:j,onChange:S,placeholder:"128000"})}),(0,r.jsx)(lJ,{label:s("desktop.modelsRequestOutputLength"),children:(0,r.jsx)(lQ,{value:C,onChange:T,placeholder:"16384"})})]})]})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"10px 16px",borderTop:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsx)("button",{onClick:t,style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:13},children:s("desktop.cancel")}),(0,r.jsx)("button",{onClick:()=>{let e=b.trim()?{id:b.trim(),...parseInt(j,10)>0?{contextWindow:parseInt(j,10)}:{},...parseInt(C,10)>0?{maxTokens:parseInt(C,10)}:{}}:void 0;o({name:i.trim(),api:l,...u.trim()?{baseUrl:u.trim()}:{},...g.trim()?{apiKey:g.trim()}:{},...f?{headers:f}:{},model:e})},disabled:!M,style:{padding:"6px 16px",background:M?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:6,color:M?"#fff":"var(--text-dim)",cursor:M?"pointer":"not-allowed",fontSize:13,fontWeight:600},children:s("desktop.modelsAdd")})]})]})})}function dn({embedded:e=!1,sessionId:t,onCloseAction:o,onSavedAction:s,onRegisterFlush:i}){let a=lG(),l=O(),[d,c]=(0,n.useState)({providers:{}}),[p,u]=(0,n.useState)(!0),[h,g]=(0,n.useState)(!1),[f,x]=(0,n.useState)(null),[k,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(null),[w,j]=(0,n.useState)([]),[S,C]=(0,n.useState)([]),[T,R]=(0,n.useState)(!1),[I,M]=(0,n.useState)(!1),[P,E]=(0,n.useState)({oauth:!1,apiKey:!1}),W=(0,n.useRef)({providers:{}}),F=(0,n.useRef)(new Map),D=(0,n.useRef)(0),A=(0,n.useRef)(!1);W.current=d;let N=(0,n.useCallback)(e=>{let t=e(W.current);return W.current=t,D.current+=1,c(t),t},[]),L=(0,n.useCallback)(()=>{fetch("/api/auth/combined").then(e=>e.json()).then(e=>{j(e.oauth??[]),C(e.apiKey??[])}).catch(()=>{}).finally(()=>E({oauth:!0,apiKey:!0}))},[]),$=(0,n.useCallback)((e,t)=>(F.current.set(e,t),()=>{F.current.get(e)===t&&F.current.delete(e)}),[]),H=(0,n.useCallback)(async()=>{for(let e of[...F.current.values()])await e()},[]);(0,n.useEffect)(()=>{if(i)return i(H)??void 0},[H,i]);let B=(0,n.useCallback)((e,t)=>{N(o=>{let r={...o.providers??{}};return t?r[e]=t:delete r[e],{...o,providers:r}}),s?.()},[s,N]),U=(0,n.useCallback)(async e=>{if(!A.current){A.current=!0,x(null);try{await H(),b(e)}catch(e){x(e instanceof Error?e.message:String(e))}finally{A.current=!1}}},[H]);(0,n.useEffect)(()=>{fetch("/api/models-config").then(e=>e.json()).then(e=>{let t=e.providers?e:{...e,providers:{}};W.current=t,D.current+=1,c(t)}).catch(()=>{let e={providers:{}};W.current=e,D.current+=1,c(e)}).finally(()=>u(!1)),L()},[L]);let _=(0,n.useCallback)(async e=>{if(!A.current){A.current=!0,x(null);try{await H();let t=e.name.trim()||"new-provider",o=t,r=1;for(;W.current.providers?.[o];)o=`${t}-${r++}`;let n={api:e.api||"openai-completions",...e.baseUrl?{baseUrl:e.baseUrl}:{},...e.apiKey?{apiKey:e.apiKey}:{},...e.headers?{headers:e.headers}:{},...e.model?{models:[e.model]}:{}};N(e=>({...e,providers:{...e.providers??{},[o]:n}})),b({type:"provider",name:o}),M(!1)}catch(e){x(e instanceof Error?e.message:String(e))}finally{A.current=!1}}},[H,N]),q=(0,n.useCallback)((e,t)=>{N(o=>({...o,providers:{...o.providers??{},[e]:t}}))},[N]),V=(0,n.useCallback)((e,t)=>{N(o=>{let r=Object.entries(o.providers??{}),n=r.findIndex(([t])=>t===e);return -1===n?o:(r[n]=[t,r[n][1]],{...o,providers:Object.fromEntries(r)})}),b(o=>o?"provider"===o.type&&o.name===e?{type:"provider",name:t}:"model"===o.type&&o.providerName===e?{...o,providerName:t}:o:o)},[N]),K=(0,n.useCallback)(e=>{let t=Object.keys(N(t=>{let o={...t.providers??{}};return delete o[e],{...t,providers:o}}).providers??{});b(t.length>0?{type:"provider",name:t[0]}:null)},[N]),G=(0,n.useCallback)(async e=>{if(!A.current){A.current=!0,x(null);try{await H();let t=N(t=>{let o=t.providers?.[e]??{},r=[...o.models??[],{id:""}];return{...t,providers:{...t.providers??{},[e]:{...o,models:r}}}}),o=(t.providers?.[e]?.models?.length??1)-1;b({type:"model",providerName:e,index:o})}catch(e){x(e instanceof Error?e.message:String(e))}finally{A.current=!1}}},[H,N]),J=(0,n.useCallback)((e,t)=>{N(o=>{let r=o.providers?.[e]??{},n=[...r.models??[]],s=new Set(n.map(e=>e.id));for(let e of t)s.has(e.id)||(s.add(e.id),n.push({id:e.id,name:e.name}));return{...o,providers:{...o.providers??{},[e]:{...r,models:n}}}})},[N]),Y=(0,n.useCallback)((e,t,o)=>{N(r=>{let n=r.providers?.[e]??{},s=[...n.models??[]];return s[t]=o,{...r,providers:{...r.providers??{},[e]:{...n,models:s}}}})},[N]),X=(0,n.useCallback)(async(e,t)=>{if(!A.current){A.current=!0,x(null);try{await H(),N(o=>{let r=o.providers?.[e]??{},n=[...r.models??[]];return n.splice(t,1),{...o,providers:{...o.providers??{},[e]:{...r,models:n.length?n:void 0}}}}),b({type:"provider",name:e})}catch(e){x(e instanceof Error?e.message:String(e))}finally{A.current=!1}}},[H,N]),Z=(0,n.useCallback)(async()=>{if(!h){g(!0),x(null),v(!1);try{await H();let e=W.current,t=await fetch("/api/models-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);o.config&&(W.current=o.config,D.current+=1,c(o.config)),v(!0),s?.(),setTimeout(()=>v(!1),2e3)}catch(e){x(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[H,s,h]),Q=(0,n.useCallback)(async()=>{try{await H(),o?.()}catch(e){x(e instanceof Error?e.message:String(e))}},[H,o]),ee=Object.entries(d.providers??{}),et=new Set([...w.map(e=>e.id),...S.map(e=>e.id)]),eo=ee.filter(([e])=>!et.has(e)),er=w.filter(e=>e.loggedIn),en=S.filter(e=>e.configured);(0,n.useEffect)(()=>{if(y||p||!P.oauth||!P.apiKey)return;let e=er[0]?{type:"oauth",providerId:er[0].id}:en[0]?{type:"apikey",providerId:en[0].id}:eo[0]?.[0]?{type:"provider",name:eo[0][0]}:null;e&&b(e)},[en,er,eo,p,P.apiKey,P.oauth,y]);let es=(()=>{if(!y)return null;if("oauth"===y.type){let e=w.find(e=>e.id===y.providerId);return e?(0,r.jsx)(l9,{provider:e,onRefresh:L,onRegisterBuiltinFlush:$,onBuiltinProviderChange:t=>B(e.id,t)},e.id):null}if("apikey"===y.type){let e=S.find(e=>e.id===y.providerId);return e?(0,r.jsx)(de,{provider:e,onRefresh:L,onRegisterBuiltinFlush:$,onBuiltinProviderChange:t=>B(e.id,t)},e.id):null}if("provider"===y.type){let e=d.providers?.[y.name];return e?(0,r.jsx)(l4,{name:y.name,provider:e,onChange:e=>q(y.name,e),onRename:e=>V(y.name,e),onDelete:()=>K(y.name),onAddModels:e=>J(y.name,e),onAddModel:()=>{G(y.name)}},y.name):null}let e=d.providers?.[y.providerName],t=e?.models?.[y.index];return t?(0,r.jsx)(l7,{providerName:y.providerName,provider:e,model:t,onChange:e=>Y(y.providerName,y.index,e),onDelete:()=>{X(y.providerName,y.index)}},`${y.providerName}-${y.index}`):null})();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:e?{display:"flex",flex:1,minWidth:0,minHeight:0,overflow:"hidden"}:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:t=>{e||t.target!==t.currentTarget||Q()},children:(0,r.jsxs)("div",{style:e?{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"}:{width:l?"calc(100vw - 16px)":860,maxWidth:"calc(100vw - 16px)",height:l?"calc(100dvh - 16px)":"78vh",maxHeight:"calc(100dvh - 16px)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[!e&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:a("desktop.models")}),(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:"~/.pi/agent/models.json"})]}),(0,r.jsx)("button",{onClick:()=>{Q()},"aria-label":a("desktop.modelsClose"),title:a("desktop.modelsClose"),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),(0,r.jsx)(lO,{}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:l?"column":"row",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{width:l?"100%":210,maxHeight:l?"40vh":void 0,borderRight:l?"none":"1px solid var(--border)",borderBottom:l?"1px solid var(--border)":"none",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,r.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:[er.map(e=>{let t=y?.type==="oauth"&&y.providerId===e.id;return(0,r.jsxs)("div",{onClick:()=>{U({type:"oauth",providerId:e.id})},style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",borderRadius:5,cursor:"pointer",background:t?"var(--bg-selected)":"none"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[(0,r.jsx)(is,{id:e.id,size:16}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.id)}),en.map(e=>{let t=y?.type==="apikey"&&y.providerId===e.id;return(0,r.jsxs)("div",{onClick:()=>{U({type:"apikey",providerId:e.id})},style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",borderRadius:5,cursor:"pointer",background:t?"var(--bg-selected)":"none"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[(0,r.jsx)(is,{id:e.id,size:16}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.displayName})]},e.id)}),(er.length>0||en.length>0)&&eo.length>0&&(0,r.jsx)("div",{style:{margin:"4px 8px",borderTop:"1px solid var(--border)"}}),p?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:a("desktop.modelsLoading")}):eo.map(([e,t])=>{let o=y?.type==="provider"&&y.name===e,n=t.models??[];return(0,r.jsxs)("div",{style:{marginBottom:2},children:[(0,r.jsxs)("div",{onClick:()=>{U({type:"provider",name:e})},style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,cursor:"pointer",background:o?"var(--bg-selected)":"none"},onMouseEnter:e=>{o||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{o||(e.currentTarget.style.background="none")},children:[(0,r.jsx)(z.G,{size:11,style:{color:"var(--text-dim)",flexShrink:0}}),(0,r.jsx)("span",{style:{fontSize:12,fontWeight:o?600:400,color:"var(--text)",fontFamily:"var(--font-mono)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})]}),n.map((t,o)=>{let n=y?.type==="model"&&y.providerName===e&&y.index===o;return(0,r.jsxs)("div",{onClick:()=>{U({type:"model",providerName:e,index:o})},style:{display:"flex",alignItems:"center",gap:6,padding:"5px 8px 5px 26px",borderRadius:5,cursor:"pointer",background:n?"var(--bg-selected)":"none"},onMouseEnter:e=>{n||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{n||(e.currentTarget.style.background="none")},children:[(0,r.jsx)("span",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:t.id?"var(--text-muted)":"var(--text-dim)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.id||a("desktop.modelsNewModel")}),t.reasoning&&(0,r.jsx)("span",{style:{fontSize:9,padding:"1px 4px",background:"rgba(99,102,241,0.12)",color:"rgba(99,102,241,0.8)",borderRadius:3,flexShrink:0},children:"T"})]},o)}),(0,r.jsx)("div",{onClick:t=>{t.stopPropagation(),G(e)},style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px 4px 26px",borderRadius:5,cursor:"pointer",color:"var(--text-dim)"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,r.jsx)("span",{style:{fontSize:11},children:a("desktop.modelsAddModel")})})]},e)})]}),(0,r.jsx)("div",{style:{borderTop:"1px solid var(--border)",padding:"8px 6px"},children:(0,r.jsx)("button",{onClick:()=>R(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,width:"100%",padding:"6px 0",background:"none",border:"1px dashed var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer",fontSize:12},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:a("desktop.modelsAddProvider")})})]}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:p?null:es??(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:a("desktop.modelsSelectProviderOrModel")})})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:10,padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:[f&&(0,r.jsx)("span",{style:{fontSize:12,color:"#f87171",flex:1},children:f}),!e&&(0,r.jsx)("button",{onClick:()=>{Q()},style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:13},children:a("desktop.cancel")}),(0,r.jsx)(lE,{sessionId:t,onBeforeApply:Z}),(0,r.jsxs)("button",{onClick:Z,disabled:h||k,style:{position:"relative",padding:"6px 16px",minWidth:92,background:k?"#16a34a":h?"var(--bg-panel)":"var(--accent)",border:"none",borderRadius:6,color:k?"#fff":h?"var(--text-muted)":"#fff",cursor:h||k?"default":"pointer",fontSize:13,fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,transition:"background-color 0.2s ease, color 0.2s ease",animation:k?"saved-pop 0.45s ease":void 0},children:[k&&(0,r.jsx)(m.S,{size:14,style:{strokeDasharray:18,animation:"saved-check-draw 0.35s ease forwards",flexShrink:0}}),(0,r.jsx)("span",{children:k?a("desktop.modelsSaved"):h?a("desktop.modelsSaving"):a("desktop.modelsSave")})]})]})]})}),T&&(0,r.jsx)(dt,{oauthProviders:w,apiKeyProviders:S,onSelectOAuth:e=>{U({type:"oauth",providerId:e})},onSelectApiKey:e=>{U({type:"apikey",providerId:e})},onAddCustom:()=>{R(!1),M(!0)},onClose:()=>R(!1)}),I&&(0,r.jsx)(dr,{existingProviders:eo.map(([e,t])=>({name:e,provider:t})),onCancel:()=>M(!1),onSubmit:e=>{_(e)}})]})}function ds(e){return e.replace(/^\/(?:Users|home)\/[^/]+/,"~")}function di(e){let t=e.trim().match(/^\$?\s*pi\s+install\s+(\S+)\s*$/);return t?.[1]??e}function da(e){return`${e.scope}\0${e.source}`}function dl(e,t){if(e.disabled)return t("desktop.disabled");let o=[e.counts.extensions?t("desktop.extensionsCount",{count:e.counts.extensions}):"",e.counts.skills?t("desktop.skillsCount",{count:e.counts.skills}):"",e.counts.prompts?t("desktop.promptsCount",{count:e.counts.prompts}):"",e.counts.themes?t("desktop.themesCount",{count:e.counts.themes}):""].filter(Boolean);return o.length?o.join(" \xb7 "):t("desktop.noResources")}function dd(e,t){let o=[];return e.version&&o.push(t("desktop.installedVersion",{version:e.version})),e.configuredVersion&&o.push(t("desktop.configuredVersion",{version:e.configuredVersion})),o.length?o.join(" \xb7 "):t("desktop.unknown")}function dc(e){return"loaded"===e?"var(--accent)":"installed"===e?"#f59e0b":"disabled"===e?"var(--text-dim)":"#ef4444"}function dp({pkg:e}){let{t}=(0,A.s)(),o=[["extension",t("desktop.extensions")],["skill",t("desktop.skills")],["prompt",t("desktop.prompts")],["theme",t("desktop.themes")]].map(([t,o])=>({kind:t,label:o,resources:e.resources.filter(e=>e.kind===t)})).filter(e=>e.resources.length>0);return 0===o.length?(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-dim)"},children:t(e.disabled?"desktop.packageDisabled":"desktop.noResolvedResources")}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:o.map((e,t)=>(0,r.jsxs)("div",{style:{borderTop:0===t?"none":"1px solid var(--border)",paddingTop:12*(0!==t)},children:[(0,r.jsx)("div",{style:{fontSize:10,fontWeight:700,color:"var(--text-dim)",textTransform:"uppercase",marginBottom:6},children:e.label}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.resources.map(e=>(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.path,children:e.name}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:1},title:e.path,children:e.relativePath})]},`${e.kind}:${e.path}`))})]},e.kind))})}function du({scope:e}){let{t}=(0,A.s)();return(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,flexShrink:0,background:"project"===e?"rgba(99,102,241,0.12)":"rgba(120,120,120,0.12)",color:"project"===e?"rgba(99,102,241,0.85)":"var(--text-dim)"},children:t(`desktop.${e}`)})}function dh(e,t){return{padding:"6px 12px",background:t?"rgba(239,68,68,0.08)":"none",border:"1px solid var(--border)",borderRadius:6,color:t?"#ef4444":"var(--text-muted)",cursor:e?"not-allowed":"pointer",fontSize:12,opacity:e?.5:1}}function dg({enabled:e,loading:t,onToggle:o,label:n}){return(0,r.jsx)("button",{type:"button",onClick:o,disabled:t,title:n,"aria-label":n,"aria-pressed":e,style:{flexShrink:0,width:40,height:22,borderRadius:11,border:"none",padding:0,cursor:t?"wait":"pointer",background:e?"var(--accent)":"var(--border)",position:"relative",transition:"background 0.18s",outline:"none",opacity:t?.65:1},children:(0,r.jsx)("span",{style:{position:"absolute",top:3,left:e?21:3,width:16,height:16,borderRadius:"50%",background:"var(--bg)",boxShadow:"0 1px 4px rgba(0,0,0,0.22)",transition:"left 0.18s cubic-bezier(.4,0,.2,1)"}})})}function dm({value:e,onChange:t}){let{t:o}=(0,A.s)();return(0,r.jsx)("div",{style:{display:"inline-flex",border:"1px solid var(--border)",borderRadius:7,overflow:"hidden",height:30},children:["global","project"].map(n=>{let s=e===n;return(0,r.jsx)("button",{onClick:()=>t(n),style:{width:76,border:"none",borderRight:"global"===n?"1px solid var(--border)":"none",background:s?"var(--bg-selected)":"none",color:s?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12},children:o(`desktop.${n}`)},n)})})}function df({cwd:e,source:t,scope:o,busy:s,actionError:i,onSourceChange:a,onScopeChange:l,onInstall:d}){let{t:c}=(0,A.s)(),p=(0,n.useRef)(null);return(0,n.useEffect)(()=>{p.current?.focus()},[]),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:18,maxWidth:660,minHeight:"100%"},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[(0,r.jsx)("div",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:c("desktop.addPluginTitle")}),(0,r.jsx)("a",{href:"https://pi.dev/packages",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",fontSize:12,textDecoration:"none",whiteSpace:"nowrap"},children:"pi.dev/packages ↗"})]}),(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:"project"===o?`${ds(e)}/.pi/agent/{npm,git}`:"~/.pi/agent/{npm,git}"})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:7},children:[(0,r.jsx)("label",{htmlFor:"plugin-source",style:{fontSize:12,fontWeight:600,color:"var(--text-muted)"},children:c("desktop.pluginSource")}),(0,r.jsx)("input",{id:"plugin-source",ref:p,value:t,onChange:e=>a(e.target.value),onPaste:e=>{let t=e.clipboardData.getData("text"),o=di(t);o!==t&&(e.preventDefault(),a(o))},onBlur:e=>a(di(e.currentTarget.value)),placeholder:"npm:@scope/package",style:{width:"100%",height:36,padding:"0 11px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:13,outline:"none"},onKeyDown:e=>{"Enter"===e.key&&t.trim()&&!s&&d()}})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)(dm,{value:o,onChange:l}),(0,r.jsx)("button",{type:"button",onClick:d,disabled:s||!t.trim(),style:{...dh(s||!t.trim()),background:"var(--accent)",color:"white",borderColor:"var(--accent)"},children:c(s?"desktop.installing":"desktop.install")})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:7},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)"},children:c("desktop.examples")}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:["npm:@scope/pi-plugin","git:https://github.com/user/repo","/absolute/path/to/plugin"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>a(e),style:{width:"100%",minHeight:30,textAlign:"left",padding:"6px 9px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-dim)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:11},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-panel)",e.currentTarget.style.color="var(--text-dim)"},children:e},e))})]}),i&&(0,r.jsx)("div",{style:{fontSize:12,color:"#ef4444",whiteSpace:"pre-wrap"},children:i})]})}function dx({pkg:e,cwd:t,busyKey:o,actionError:n,actionMessage:s,sessionId:i,onAction:a,onReloadSession:l}){let{t:d}=(0,A.s)(),c=da(e),p=o?.endsWith(c)??!1,u="reload"===o,h=!e.disabled;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,maxWidth:680},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12,minWidth:0,flexWrap:"wrap"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:180,flex:1},children:[(0,r.jsx)(dg,{enabled:h,loading:p||u,onToggle:()=>a(e.disabled?"enable":"disable",e),label:d(e.disabled?"desktop.enablePackage":"desktop.disablePackage")}),(0,r.jsx)(du,{scope:e.scope}),e.disabled?(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,background:"rgba(120,120,120,0.12)",color:"var(--text-dim)"},children:d("desktop.disabled")}):e.filtered&&(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,background:"rgba(245,158,11,0.12)",color:"#d97706"},children:d("desktop.filtered")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.source})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("button",{onClick:()=>a("update",e),disabled:p||u,style:dh(p||u),children:d(o===`update:${c}`?"desktop.updating":"desktop.update")}),(0,r.jsx)("button",{onClick:l,disabled:!i||u||p,style:dh(!i||u||p),title:d(i?"desktop.reloadCurrentSession":"desktop.openSessionToReload"),children:d(u?"desktop.reloading":"desktop.reloadSession")}),(0,r.jsx)("button",{onClick:()=>a("remove",e),disabled:p||u,style:dh(p||u,!0),children:d(o===`remove:${c}`?"desktop.removing":"desktop.remove")})]})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(96px, 130px) minmax(0, 1fr)",gap:"9px 14px",fontSize:12,lineHeight:1.45},children:[(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:d("desktop.status")}),(0,r.jsx)("div",{style:{color:dc(e.status),textTransform:"capitalize"},children:e.status}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:d("desktop.version")}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:dd(e,d)}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:d("desktop.package")}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",overflowWrap:"anywhere"},children:e.packageName??d("desktop.unknown")}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:d("desktop.resources")}),(0,r.jsx)("div",{style:{color:"var(--text-muted)"},children:dl(e,d)}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:d("desktop.installedPath")}),(0,r.jsx)("div",{style:{color:e.installedPath?"var(--text-muted)":"#ef4444",fontFamily:"var(--font-mono)",overflowWrap:"anywhere"},children:e.installedPath?ds(e.installedPath):d("desktop.notFound")}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:d("desktop.cwd")}),(0,r.jsx)("div",{style:{color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflowWrap:"anywhere"},children:ds(t)})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:700,color:"var(--text)"},children:d("desktop.resolvedResources")}),(0,r.jsx)(dp,{pkg:e})]}),s&&(0,r.jsx)("div",{style:{fontSize:12,color:"#16a34a"},children:s}),n&&(0,r.jsx)("div",{style:{fontSize:12,color:"#ef4444",whiteSpace:"pre-wrap"},children:n})]})}function dk({cwd:e,sessionId:t,embedded:o=!1,onCloseAction:s,onReloadedAction:i}){let a=O(),{t:l}=(0,A.s)(),[d,c]=(0,n.useState)(null),[p,u]=(0,n.useState)(!0),[h,g]=(0,n.useState)(null),[m,f]=(0,n.useState)(null),[x,k]=(0,n.useState)(!1),[y,b]=(0,n.useState)(""),[w,j]=(0,n.useState)("global"),[S,C]=(0,n.useState)(null),[T,R]=(0,n.useState)(null),[z,I]=(0,n.useState)(null),M=(0,n.useMemo)(()=>d?.packages??[],[d?.packages]),P=M.find(e=>da(e)===m)??null,E=(0,n.useMemo)(()=>["project","global"].map(e=>({scope:e,packages:M.filter(t=>t.scope===e)})).filter(e=>e.packages.length>0),[M]),W=(0,n.useCallback)(async()=>{u(!0),g(null);try{let t=await fetch(`/api/plugins?cwd=${encodeURIComponent(e)}`),o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);c(o),k(e=>0===o.packages.length||e),f(e=>e&&o.packages.some(t=>da(t)===e)?e:o.packages[0]?da(o.packages[0]):null)}catch(e){g(e instanceof Error?e.message:String(e))}finally{u(!1)}},[e]);(0,n.useEffect)(()=>{W()},[W]);let F=(0,n.useCallback)(async(t,o)=>{let r=da(o);C(`${t}:${r}`),R(null),I(null);try{let r=await fetch("/api/plugins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,source:o.source,scope:o.scope,cwd:e})}),n=await r.json();if(!r.ok||n.error)throw Error(n.error??`HTTP ${r.status}`);if(c(n),"remove"===t)f(n.packages[0]?da(n.packages[0]):null),0===n.packages.length&&k(!0),I(l("desktop.packageRemoved"));else{let e={install:l("desktop.packageInstalled"),update:l("desktop.packageUpdated"),disable:l("desktop.packageDisabledMessage"),enable:l("desktop.packageEnabled")};I(e[t])}}catch(e){R(e instanceof Error?e.message:String(e))}finally{C(null)}},[e,l]),D=(0,n.useCallback)(async()=>{let t=di(y).trim();if(!t)return;let o=`${w}\0${t}`;C(`install:${o}`),R(null),I(null);try{var r;let n,s,i=await fetch("/api/plugins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"install",source:t,scope:w,cwd:e})}),a=await i.json();if(!i.ok||a.error)throw Error(a.error??`HTTP ${i.status}`);c(a);let d=(r=a.packages,s=(n=t.trim()).startsWith("npm:")?n.slice(4):n,r.find(e=>e.scope===w&&e.source===n)??r.find(e=>e.scope===w&&e.source===`npm:${s}`)??r.find(e=>e.scope===w&&e.source.endsWith(n)));f(d?da(d):o),k(!1),b(""),I(l("desktop.packageInstalled"))}catch(e){R(e instanceof Error?e.message:String(e))}finally{C(null)}},[e,w,y,l]),N=(0,n.useCallback)(async()=>{if(t){C("reload"),R(null),I(null);try{await i6(t,{type:"reload"}),i?.(),await W(),I(l("desktop.sessionReloaded"))}catch(e){R(e instanceof Error?e.message:String(e))}finally{C(null)}}},[W,i,t,l]),L=S?.startsWith("install:")??!1;return(0,r.jsx)("div",{style:o?{display:"flex",flex:1,minWidth:0,minHeight:0,overflow:"hidden"}:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{o||e.target!==e.currentTarget||s?.()},children:(0,r.jsxs)("div",{style:o?{display:"flex",flex:1,minWidth:0,minHeight:0,flexDirection:"column",overflow:"hidden"}:{width:a?"calc(100vw - 16px)":860,maxWidth:"calc(100vw - 16px)",height:a?"calc(100dvh - 16px)":"76vh",maxHeight:"calc(100dvh - 16px)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[!o&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,minWidth:0},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:l("desktop.plugins")}),(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ds(e)})]}),(0,r.jsx)("button",{onClick:s,title:l("desktop.close"),"aria-label":l("desktop.close"),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:a?"column":"row",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{width:a?"100%":245,maxHeight:a?"40vh":void 0,borderRight:a?"none":"1px solid var(--border)",borderBottom:a?"1px solid var(--border)":"none",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:p?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:l("desktop.loading")}):h?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"#ef4444"},children:h}):0===M.length?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"var(--text-dim)"},children:l("desktop.noPluginsConfigured")}):E.map(e=>(0,r.jsxs)("div",{style:{marginBottom:6},children:[(0,r.jsx)("div",{style:{padding:"4px 8px 3px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase"},children:l(`desktop.${e.scope}`)}),e.packages.map(e=>{let t=da(e),o=!x&&m===t;return(0,r.jsxs)("div",{onClick:()=>{f(t),k(!1),R(null),I(null)},style:{display:"flex",alignItems:"center",gap:7,padding:"8px 8px",borderRadius:5,cursor:"pointer",background:o?"var(--bg-selected)":"none"},onMouseEnter:e=>{o||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{o||(e.currentTarget.style.background="none")},children:[(0,r.jsx)("span",{style:{flexShrink:0,width:7,height:7,borderRadius:"50%",background:dc(e.status)}}),(0,r.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:o?600:400,color:"var(--text)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.source}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:2},children:dl(e,l)}),(e.version||e.configuredVersion)&&(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:2},children:dd(e,l)})]})]},t)})]},e.scope))}),(0,r.jsx)("div",{style:{padding:"8px 6px",borderTop:"1px solid var(--border)",flexShrink:0},children:(0,r.jsxs)("button",{type:"button",onClick:()=>{k(!0),R(null),I(null)},style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,border:"none",width:"100%",cursor:"pointer",background:x?"var(--bg-selected)":"none",color:x?"var(--accent)":"var(--text-dim)",fontSize:12},onMouseEnter:e=>{x||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{x||(e.currentTarget.style.background="none")},children:[(0,r.jsx)(v.c,{size:13}),l("desktop.addPlugin")]})})]}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:x?(0,r.jsx)(df,{cwd:e,source:y,scope:w,busy:L,actionError:T,onSourceChange:b,onScopeChange:j,onInstall:D}):p?null:P?(0,r.jsx)(dx,{pkg:P,cwd:e,busyKey:S,actionError:T,actionMessage:z,sessionId:t,onAction:F,onReloadSession:N},da(P)):(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:l("desktop.selectPackage")})})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsx)("div",{style:{minWidth:0,flex:1,fontSize:11,color:"var(--text-dim)",overflow:"hidden"},children:d?.diagnostics.length?(0,r.jsx)("span",{title:d.diagnostics.map(e=>`${e.type}: ${e.source?`${e.source}: `:""}${e.message}`).join("\n"),style:{color:d.diagnostics.some(e=>"error"===e.type)?"#ef4444":"#d97706"},children:l("desktop.diagnosticsCount",{count:d.diagnostics.length,suffix:1===d.diagnostics.length?"":"s"})}):(0,r.jsx)("span",{children:d?l("desktop.pluginResourceTotals",{extensions:d.totals.extensions,skills:d.totals.skills,prompts:d.totals.prompts,themes:d.totals.themes}):""})}),(0,r.jsx)("button",{onClick:()=>void W(),disabled:p||null!==S,style:dh(p||null!==S),children:l("desktop.refresh")}),!o&&(0,r.jsx)("button",{onClick:s,style:dh(!1),children:l("desktop.close")})]})]})})}var dv=o(36282);function dy(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)({enabled:!1,protocol:"http",host:"127.0.0.1",port:7890,username:"",password:"",noProxy:"localhost,127.0.0.1,.local",hasPassword:!1}),[s,i]=(0,n.useState)(!1),[a,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(null),[p,u]=(0,n.useState)(null),[h,g]=(0,n.useState)(null),[m,f]=(0,n.useState)(!1),[x,k]=(0,n.useState)(!1);(0,n.useEffect)(()=>{(async()=>{try{let e=await fetch("/api/proxy");if(e.ok){let t=await e.json();o(e=>({...e,...t,password:""}))}}catch{}})()},[]);let v=(0,n.useCallback)((e,t)=>{o(o=>({...o,[e]:t})),"password"===e&&k(!0),f(!0),u(null),g(null)},[]),y=(0,n.useCallback)(async()=>{i(!0),u(null),g(null);try{let r={...t};delete r.hasPassword,x||delete r.password;let n=await fetch("/api/proxy",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),s=await n.json();if(n.ok){u(!0),f(!1),k(!1);let e=await fetch("/api/proxy");if(e.ok){let t=await e.json();o(e=>({...e,...t,password:""}))}}else u(!1),g(s.error||e("desktop.proxySaveFailed"))}catch(t){u(!1),g(t instanceof Error?t.message:e("desktop.proxySaveFailed"))}finally{i(!1)}},[t,x,e]),b=(0,n.useCallback)(async()=>{l(!0),c(null),m&&await y();try{let t=await fetch("/api/proxy/test",{method:"POST"}),o=await t.json();o.success?c({ok:!0,message:`${e("desktop.proxyTestSuccess")} \xb7 ${o.latencyMs}ms`,latencyMs:o.latencyMs}):c({ok:!1,message:o.error||e("desktop.proxyTestFailed")})}catch(t){c({ok:!1,message:t instanceof Error?t.message:e("desktop.proxyTestFailed")})}finally{l(!1)}},[m,y,e]),w=(0,n.useCallback)(()=>{if(!t.enabled||!t.host||!t.port)return null;let e="";return t.username&&t.password?e=`${t.username}:${"•".repeat(Math.min(t.password.length,8))}@`:t.username&&(e=`${t.username}@`),`${t.protocol}://${e}${t.host}:${t.port}`},[t.enabled,t.host,t.port,t.protocol,t.username,t.password])();return(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",padding:"16px 20px",overflow:"auto",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:4},children:[(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:500,color:"var(--text)",cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:t.enabled,onChange:e=>v("enabled",e.target.checked),style:{width:16,height:16,accentColor:"var(--accent)"}}),e("desktop.proxyEnable")]}),t.enabled&&w&&(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontFamily:"var(--font-mono)",backgroundColor:"var(--bg-hover)",padding:"2px 10px",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"60%"},title:w,children:w})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px 16px",opacity:t.enabled?1:.5,pointerEvents:t.enabled?"auto":"none"},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.proxyProtocol")}),(0,r.jsxs)("select",{value:t.protocol,onChange:e=>v("protocol",e.target.value),style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:13,fontFamily:"var(--font-mono)",outline:"none"},children:[(0,r.jsx)("option",{value:"http",children:"HTTP"}),(0,r.jsx)("option",{value:"https",children:"HTTPS"}),(0,r.jsx)("option",{value:"socks5",children:"SOCKS5"})]})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.proxyHost")}),(0,r.jsx)("input",{type:"text",value:t.host,onChange:e=>v("host",e.target.value),placeholder:"127.0.0.1",style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:13,fontFamily:"var(--font-mono)",outline:"none"}})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.proxyPort")}),(0,r.jsx)("input",{type:"number",value:t.port,onChange:e=>v("port",parseInt(e.target.value,10)||0),placeholder:"7890",min:1,max:65535,style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:13,fontFamily:"var(--font-mono)",outline:"none"}})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.proxyUsername")}),(0,r.jsx)("input",{type:"text",value:t.username,onChange:e=>v("username",e.target.value),placeholder:t.username?"":e("desktop.proxyUsername"),style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:13,fontFamily:"var(--font-mono)",outline:"none"}})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.proxyPassword")}),(0,r.jsx)("input",{type:"password",value:t.password,onChange:e=>v("password",e.target.value),placeholder:t.hasPassword?"••••••••":e("desktop.proxyPassword"),style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:13,fontFamily:"var(--font-mono)",outline:"none"}})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,gridColumn:"1 / -1"},children:[(0,r.jsx)("label",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.proxyNoProxy")}),(0,r.jsx)("input",{type:"text",value:t.noProxy,onChange:e=>v("noProxy",e.target.value),placeholder:"localhost,127.0.0.1,.local",style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:13,fontFamily:"var(--font-mono)",outline:"none"}})]})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:10,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:y,disabled:s,style:{padding:"6px 18px",borderRadius:6,border:"none",background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:500,cursor:s?"not-allowed":"pointer",opacity:s?.5:1,transition:"background 0.15s"},onMouseEnter:e=>{s||(e.currentTarget.style.background="var(--accent-hover)")},onMouseLeave:e=>{s||(e.currentTarget.style.background="var(--accent)")},children:s?e("desktop.proxySaving"):e("desktop.proxySave")}),(0,r.jsx)("button",{type:"button",onClick:b,disabled:a||!t.enabled,style:{padding:"6px 18px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:t.enabled?"var(--text)":"var(--text-muted)",fontSize:13,fontWeight:500,cursor:t.enabled?"pointer":"not-allowed",opacity:t.enabled?1:.5,transition:"background 0.15s"},onMouseEnter:e=>{t.enabled&&(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t.enabled&&(e.currentTarget.style.background="var(--bg)")},children:a?e("desktop.proxyTesting"):e("desktop.proxyTest")})]}),!0===p&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderRadius:6,backgroundColor:"rgba(34, 197, 94, 0.12)",color:"#22c55e",fontSize:13},children:[(0,r.jsx)(nv.r,{size:16,weight:"fill"}),e("desktop.proxySaved")]}),!1===p&&h&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderRadius:6,backgroundColor:"rgba(239, 68, 68, 0.10)",color:"#ef4444",fontSize:13},children:[(0,r.jsx)(iU.J,{size:16,weight:"fill"}),h]}),d&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderRadius:6,backgroundColor:d.ok?"rgba(34, 197, 94, 0.10)":"rgba(239, 68, 68, 0.10)",color:d.ok?"#22c55e":"#ef4444",fontSize:13},children:[d.ok?(0,r.jsx)(nv.r,{size:16,weight:"fill"}):(0,r.jsx)(iU.J,{size:16,weight:"fill"}),d.message,void 0!==d.latencyMs&&(0,r.jsxs)("span",{style:{color:"var(--text-muted)",fontSize:12,marginLeft:4},children:["(",d.latencyMs,"ms)"]})]}),m&&!p&&!h&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 12px",borderRadius:6,backgroundColor:"var(--bg-hover)",color:"var(--text-muted)",fontSize:12},children:[(0,r.jsx)(dv.j,{size:12,weight:"fill"}),e("desktop.proxyUnsaved")]})]})}function db(e){return e.replace(/^\/(?:Users|home)\/[^/]+/,"~")}function dw(e){let t=e.sourceInfo?.source,o=e.sourceInfo?.scope;return"user"===o||"user"===t?"global":"project"===o||"project"===t?"project":"path"}function dj(e){return e.install?`${e.install.scope}\0${e.install.package}`:null}function dS(e,t){return e?e.slice(0,8):t}function dC({enabled:e,loading:t,onToggle:o}){let{t:n}=(0,A.s)();return(0,r.jsx)("button",{onClick:o,disabled:t,title:n(e?"desktop.visibleInModelPrompt":"desktop.hiddenFromModelPrompt"),style:{flexShrink:0,width:40,height:22,borderRadius:11,border:"none",padding:0,cursor:t?"wait":"pointer",background:e?"var(--accent)":"var(--border)",position:"relative",transition:"background 0.18s",outline:"none"},children:(0,r.jsx)("span",{style:{position:"absolute",top:3,left:e?21:3,width:16,height:16,borderRadius:"50%",background:"var(--bg)",boxShadow:"0 1px 4px rgba(0,0,0,0.22)",transition:"left 0.18s cubic-bezier(.4,0,.2,1)"}})})}function dT({skill:e,cwd:t,onToggle:o,toggling:n,saveError:s,updateStatus:i,checkingUpdate:a,updating:l,updateError:d,onCheckUpdate:c,onUpdate:p}){let{t:u}=(0,A.s)(),h=dw(e),g=!e.disableModelInvocation;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7},children:[(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,flexShrink:0,background:"project"===h?"rgba(99,102,241,0.12)":"rgba(120,120,120,0.12)",color:"project"===h?"rgba(99,102,241,0.8)":"var(--text-dim)"},children:u(`desktop.${h}`)}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-dim)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:function(e){if("project"===h&&e.startsWith(t)){let o=e.slice(t.length).replace(/^[/\\]/,"");return`./${o}`}return db(e)}(e.filePath)}),(0,r.jsx)(dC,{enabled:g,loading:n,onToggle:()=>o(e)}),s&&(0,r.jsx)("span",{style:{fontSize:12,color:"#f87171",flexShrink:0},children:s})]}),!g&&(0,r.jsx)("div",{style:{marginTop:-12,color:"var(--text-dim)",fontSize:12},children:u("desktop.hiddenButInvocable")}),e.install?.skillsShUrl&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:u("desktop.pluginSource")}),(0,r.jsx)("a",{href:e.install.skillsShUrl,target:"_blank",rel:"noreferrer",title:e.install.skillsShUrl,style:{display:"flex",alignItems:"center",gap:8,width:"fit-content",maxWidth:"100%",color:"var(--accent)",textDecoration:"none"},children:(0,r.jsxs)("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[e.install.skillsShUrl.replace(/^https?:\/\//,"")," ↗"]})})]}),e.install&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:7},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:u("desktop.version")}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-muted)"},children:dS(i?.currentVersion??e.install.versionHash,u("desktop.unknown"))}),e.install.canCheckForUpdates&&(0,r.jsx)("button",{onClick:c,disabled:a||l,style:{padding:"4px 9px",border:"1px solid var(--border)",borderRadius:5,background:"none",color:"var(--text-muted)",cursor:a||l?"not-allowed":"pointer",opacity:a||l?.5:1,fontSize:11},children:u("desktop.check")}),i?.state==="update-available"&&(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"#d97706"},children:dS(i.latestVersion,u("desktop.unknown"))}),(a||i&&"update-available"!==i.state)&&(0,r.jsx)("span",{style:{fontSize:12,color:a?"var(--accent)":i?.state==="up-to-date"?"#16a34a":i?.state==="error"?"#ef4444":"var(--text-dim)"},children:a?u("desktop.checking"):i?.state==="up-to-date"?u("desktop.upToDate"):i?.state==="unsupported"?u("desktop.automaticChecksUnavailable"):i?.message||u("desktop.checkFailed")}),i?.state==="update-available"&&(0,r.jsx)("button",{onClick:p,disabled:l||a,style:{padding:"4px 10px",border:"none",borderRadius:5,background:"var(--accent)",color:"#fff",cursor:l||a?"not-allowed":"pointer",opacity:l||a?.5:1,fontSize:11,fontWeight:600},children:u(l?"desktop.updating":"desktop.update")})]}),d&&(0,r.jsx)("span",{style:{fontSize:12,color:"#ef4444"},children:d})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:u("desktop.name")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--text)"},children:e.name})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:u("desktop.description")}),(0,r.jsx)("span",{style:{fontSize:14,color:"var(--text-muted)",lineHeight:1.6},children:e.description})]})]})}function dR({cwd:e,installedPackages:t,projectResourcesLoaded:o,onInstalled:s}){let{t:i}=(0,A.s)(),[a,l]=(0,n.useState)(""),[d,c]=(0,n.useState)([]),[p,u]=(0,n.useState)(!1),[h,g]=(0,n.useState)(null),[m,f]=(0,n.useState)(null),[x,k]=(0,n.useState)(null),[v,y]=(0,n.useState)(new Set),[b,w]=(0,n.useState)("global"),j=(0,n.useRef)(null);(0,n.useEffect)(()=>{j.current?.focus()},[]),(0,n.useEffect)(()=>{o||w("global")},[o]);let S=(0,n.useCallback)(async e=>{if(e.trim()){u(!0),g(null),c([]);try{let t=await fetch("/api/skills/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e.trim()})}),o=await t.json();if(o.error)return void g(o.error);c(o.results??[]),0===(o.results??[]).length&&g(i("desktop.noSkillsFound"))}catch(e){g(String(e))}finally{u(!1)}}},[i]),C=(0,n.useCallback)(async t=>{f(t),k(null);try{let o=await fetch("/api/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:t,scope:b,cwd:e})}),r=await o.json();if(!o.ok||r.error)return void k(r.error??`HTTP ${o.status}`);y(e=>new Set(e).add(`${b}:${t}`)),s()}catch(e){k(String(e))}finally{f(null)}},[s,b,e]),T="global"===b?"~/.pi/agent/skills/":`${db(e)}/.pi/skills/`;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:20},children:[(0,r.jsx)("div",{style:{fontSize:14,fontWeight:600,color:"var(--text)"},children:i("desktop.addSkillTitle")}),(0,r.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,r.jsx)("input",{ref:j,value:a,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&S(a)},placeholder:i("desktop.skillSearchPlaceholder"),style:{flex:1,padding:"7px 10px",fontSize:13,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",outline:"none"}}),(0,r.jsx)("button",{onClick:()=>S(a),disabled:p||!a.trim(),style:{padding:"7px 16px",fontSize:13,borderRadius:6,border:"none",background:"var(--accent)",color:"#fff",cursor:p||!a.trim()?"not-allowed":"pointer",opacity:p||!a.trim()?.5:1,flexShrink:0},children:p?i("desktop.searching"):i("desktop.search")})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)("div",{style:{display:"flex",borderRadius:5,border:"1px solid var(--border)",overflow:"hidden",fontSize:12,flexShrink:0},children:["global","project"].map(e=>(0,r.jsx)("button",{onClick:()=>w(e),disabled:"project"===e&&!o,title:"project"!==e||o?void 0:i("desktop.projectSkillInstallUnavailable"),style:{padding:"3px 10px",border:"none",cursor:"project"!==e||o?"pointer":"not-allowed",opacity:"project"!==e||o?1:.5,background:b===e?"var(--bg-selected)":"none",color:b===e?"var(--text)":"var(--text-dim)",fontWeight:b===e?600:400,borderRight:"global"===e?"1px solid var(--border)":"none"},children:i(`desktop.${e}`)},e))}),(0,r.jsxs)("span",{style:{fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["→ ",T]})]}),h&&(0,r.jsx)("div",{style:{fontSize:12,color:"#f87171"},children:h}),x&&(0,r.jsx)("div",{style:{fontSize:12,color:"#f87171",wordBreak:"break-word"},children:x})]}),d.length>0?(0,r.jsx)("div",{style:{flex:1,overflowY:"auto"},children:d.map(e=>{let o=t[b].has(e.package)||v.has(`${b}:${e.package}`),n=m===e.package,s=e.package.indexOf("@"),a=s>-1?e.package.slice(0,s):e.package,l=s>-1?e.package.slice(s+1):null;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"12px 0",borderBottom:"1px solid var(--border)"},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)",marginBottom:3},children:l??a}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-dim)"},children:a}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:e.installs}),e.url&&(0,r.jsx)("a",{href:e.url,target:"_blank",rel:"noreferrer",style:{fontSize:12,color:"var(--accent)",textDecoration:"none"},children:"skills.sh ↗"})]})]}),(0,r.jsx)("button",{onClick:()=>!o&&!n&&C(e.package),disabled:o||n||null!==m,style:{flexShrink:0,padding:"5px 14px",fontSize:12,fontWeight:500,borderRadius:5,border:"1px solid var(--border)",cursor:o||n||null!==m?"not-allowed":"pointer",background:o?"rgba(34,197,94,0.1)":"none",color:o?"#16a34a":n?"var(--accent)":"var(--text-muted)",transition:"color 0.12s"},children:o?`✓ ${i("desktop.installed")}`:n?i("desktop.installing"):i("desktop.install")})]},e.package)})}):!h&&!p&&(0,r.jsxs)("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.8},children:[i("desktop.skillSearchHint").split("skills.sh")[0],(0,r.jsx)("a",{href:"https://skills.sh",target:"_blank",rel:"noreferrer",style:{color:"var(--accent)",textDecoration:"none"},children:"skills.sh"}),i("desktop.skillSearchHint").split("skills.sh")[1]]})]})}function dz({cwd:e,embedded:t=!1,sessionId:o,onCloseAction:s}){let i=O(),{t:a}=(0,A.s)(),[l,d]=(0,n.useState)([]),[c,p]=(0,n.useState)(!0),[u,h]=(0,n.useState)(null),[g,m]=(0,n.useState)(null),[f,x]=(0,n.useState)(new Set),[k,y]=(0,n.useState)(null),[b,w]=(0,n.useState)(!1),[j,S]=(0,n.useState)({}),[C,T]=(0,n.useState)(new Set),[R,z]=(0,n.useState)(!1),[I,M]=(0,n.useState)(null),[P,E]=(0,n.useState)(null),[W,F]=(0,n.useState)(!0),D=(0,n.useCallback)(async()=>{p(!0),h(null);try{let t=await fetch(`/api/skills?cwd=${encodeURIComponent(e)}`),o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);let r=o.skills??[];if(d(r),F(o.projectResourcesLoaded??!0),r.length>0&&!g){let e=r.find(e=>!e.disableModelInvocation)??r[0];m(e.filePath)}return r}catch(e){return h(String(e)),[]}finally{p(!1)}},[e,g]);(0,n.useEffect)(()=>{S({}),E(null),D()},[e]);let N=(0,n.useCallback)(async t=>{let o=(t?[t]:l.filter(e=>!!e.install)).map(dj).filter(e=>!!e);if(0!==o.length){E(null),T(e=>new Set([...e,...o])),t||z(!0);try{let o=await fetch("/api/skills/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,package:t?.install?.package,scope:t?.install?.scope})}),r=await o.json();if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);S(e=>{let t={...e};for(let e of r.updates??[])t[`${e.scope}\0${e.package}`]=e;return t})}catch(e){E(e instanceof Error?e.message:String(e))}finally{T(e=>{let t=new Set(e);for(let e of o)t.delete(e);return t}),t||z(!1)}}},[e,l]),L=(0,n.useCallback)(async t=>{if(!t.install)return;let o=dj(t);M(o),E(null);try{let r=await fetch("/api/skills/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,package:t.install.package,scope:t.install.scope})}),n=await r.json();if(!r.ok||n.error||!n.success)throw Error(n.error??`HTTP ${r.status}`);await D();let s=n.skill?.install?.versionHash;S(e=>({...e,[o]:{package:t.install.package,scope:t.install.scope,state:"up-to-date",currentVersion:s,latestVersion:s}}))}catch(e){E(e instanceof Error?e.message:String(e))}finally{M(null)}},[e,D]),$=(0,n.useCallback)(async t=>{let o=!t.disableModelInvocation;x(e=>new Set(e).add(t.filePath)),y(null);try{let r=await fetch("/api/skills",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,filePath:t.filePath,disableModelInvocation:o})}),n=await r.json();if(!r.ok||n.error)return void y(n.error??`HTTP ${r.status}`);d(e=>e.map(e=>e.filePath===t.filePath?{...e,disableModelInvocation:o}:e))}catch(e){y(String(e))}finally{x(e=>{let o=new Set(e);return o.delete(t.filePath),o})}},[e]),H=l.find(e=>e.filePath===g)??null;return(0,r.jsx)("div",{style:t?{display:"flex",flex:1,minWidth:0,minHeight:0,overflow:"hidden"}:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{t||e.target!==e.currentTarget||s?.()},children:(0,r.jsxs)("div",{style:t?{display:"flex",flex:1,minWidth:0,minHeight:0,flexDirection:"column",overflow:"hidden"}:{width:i?"calc(100vw - 16px)":860,maxWidth:"calc(100vw - 16px)",height:i?"calc(100dvh - 16px)":"78vh",maxHeight:"calc(100dvh - 16px)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[!t&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:a("desktop.skills")}),(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:db(e)})]}),(0,r.jsx)("button",{onClick:s,title:a("desktop.close"),"aria-label":a("desktop.close"),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),!W&&(0,r.jsx)("div",{role:"status",style:{padding:"8px 18px",borderBottom:"1px solid var(--border)",background:"var(--bg-subtle)",color:"var(--text-muted)",fontSize:12},children:a("desktop.projectSkillsRestricted")}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:i?"column":"row",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{width:i?"100%":210,maxHeight:i?"40vh":void 0,borderRight:i?"none":"1px solid var(--border)",borderBottom:i?"1px solid var(--border)":"none",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,r.jsx)("div",{style:{padding:"8px 8px 0",display:"flex",justifyContent:"flex-end"},children:(0,r.jsx)(lE,{sessionId:o,onApplied:D})}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:c?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:a("desktop.loading")}):u?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"#f87171"},children:u}):0===l.length?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"var(--text-dim)"},children:a("desktop.noSkillsFound")}):(()=>{let e=[];for(let{key:t,label:o,matches:r}of[{key:"project / skills.sh",label:`${a("desktop.project")} / skills.sh`,matches:e=>"project"===dw(e)&&!!e.install?.skillsShUrl},{key:"project",label:a("desktop.project"),matches:e=>"project"===dw(e)&&!e.install?.skillsShUrl},{key:"global / skills.sh",label:`${a("desktop.global")} / skills.sh`,matches:e=>"global"===dw(e)&&!!e.install?.skillsShUrl},{key:"global",label:a("desktop.global"),matches:e=>"global"===dw(e)&&!e.install?.skillsShUrl},{key:"path",label:a("desktop.path"),matches:e=>"path"===dw(e)}]){let n=l.filter(r);n.length>0&&e.push({key:t,label:o,skills:n})}return e.map(({key:e,label:t,skills:o})=>(o.filter(e=>e.disableModelInvocation),(0,r.jsxs)("div",{style:{marginBottom:6},children:[(0,r.jsx)("div",{style:{padding:"4px 8px 3px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em"},children:t}),[...o.filter(e=>!e.disableModelInvocation),...o.filter(e=>e.disableModelInvocation)].map(e=>{let t,o,n=!b&&g===e.filePath,s=e.disableModelInvocation;return(0,r.jsxs)("div",{onClick:()=>{m(e.filePath),w(!1)},style:{display:"flex",alignItems:"center",gap:7,padding:"8px 8px",borderRadius:5,cursor:"pointer",background:n?"var(--bg-selected)":"none"},onMouseEnter:e=>{n||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{n||(e.currentTarget.style.background="none")},children:[(0,r.jsx)("span",{style:{flexShrink:0,width:7,height:7,borderRadius:"50%",background:s?"var(--border)":"var(--accent)",boxShadow:s?"none":"0 0 4px var(--accent)",transition:"background 0.15s, box-shadow 0.15s"}}),(0,r.jsx)("span",{style:{fontSize:12,fontWeight:n?600:400,color:s?"var(--text-dim)":"var(--text)",fontFamily:"var(--font-mono)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(o=(t=dj(e))?j[t]:void 0,o?.state!=="update-available"?null:(0,r.jsx)("span",{title:a("desktop.updateAvailable"),style:{color:"#d97706",fontSize:13,lineHeight:1,flexShrink:0},children:"↑"}))]},e.filePath)})]},e)))})()}),(0,r.jsx)("div",{style:{padding:"8px 6px",borderTop:"1px solid var(--border)",flexShrink:0},children:(0,r.jsxs)("div",{onClick:()=>w(!0),style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,cursor:"pointer",background:b?"var(--bg-selected)":"none",color:b?"var(--accent)":"var(--text-dim)",fontSize:12},onMouseEnter:e=>{b||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{b||(e.currentTarget.style.background="none")},children:[(0,r.jsx)(v.c,{size:13}),a("desktop.addSkill")]})})]}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:b?(0,r.jsx)(dR,{cwd:e,installedPackages:{global:new Set(l.filter(e=>e.install?.scope==="global").map(e=>e.install.package)),project:new Set(l.filter(e=>e.install?.scope==="project").map(e=>e.install.package))},projectResourcesLoaded:W,onInstalled:()=>{D()}}):c?null:H?(0,r.jsx)(dT,{skill:H,cwd:e,onToggle:$,toggling:f.has(H.filePath),saveError:k,updateStatus:dj(H)?j[dj(H)]:void 0,checkingUpdate:!!dj(H)&&C.has(dj(H)),updating:I===dj(H),updateError:P,onCheckUpdate:()=>void N(H),onUpdate:()=>void L(H)},H.filePath):(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:a("desktop.selectSkill")})})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[l.some(e=>!!e.install)&&(0,r.jsx)("button",{onClick:()=>void N(),disabled:R||null!==I,style:{padding:"6px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:R||null!==I?"not-allowed":"pointer",opacity:R||null!==I?.5:1,fontSize:12},children:R?a("desktop.checking"):a("desktop.checkUpdates")}),Object.values(j).filter(e=>"update-available"===e.state).length>0&&(0,r.jsx)("span",{style:{fontSize:12,color:"#d97706"},children:a("desktop.updatesCount").replace("{count}",String(Object.values(j).filter(e=>"update-available"===e.state).length)).replace("{suffix}",1===Object.values(j).filter(e=>"update-available"===e.state).length?"":"s")})]}),!t&&(0,r.jsx)("button",{onClick:s,style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:13},children:a("desktop.close")})]})]})})}function dI(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)([]),[s,i]=(0,n.useState)(""),[a,l]=(0,n.useState)(""),[d,c]=(0,n.useState)(""),[p,u]=(0,n.useState)(""),[h,g]=(0,n.useState)(!0),[m,f]=(0,n.useState)(null),x=(0,n.useCallback)(async()=>{g(!0),f(null);try{let e=await fetch("/api/logs?limit=500"),t=await e.json();if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);o(t.entries??[])}catch(e){f(e instanceof Error?e.message:String(e))}finally{g(!1)}},[]);(0,n.useEffect)(()=>{x()},[x]);let k=(0,n.useMemo)(()=>[...new Set(t.map(e=>e.source).filter(Boolean))].sort(),[t]),v=(0,n.useMemo)(()=>[...new Set(t.map(e=>e.statusCode).filter(e=>void 0!==e))].sort((e,t)=>e-t),[t]),y=(0,n.useMemo)(()=>{let e=p.trim().toLocaleLowerCase();return t.filter(e=>!s||e.level===s).filter(e=>!a||e.statusCode===Number(a)).filter(e=>!d||e.source===d).filter(t=>!e||[t.message,t.details,t.provider,t.model,t.source].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e))).slice(0,200)},[t,s,a,d,p]),b=async()=>{try{let e=await fetch("/api/logs",{method:"DELETE"});if(!e.ok)throw Error(`HTTP ${e.status}`);o([])}catch(e){f(e instanceof Error?e.message:String(e))}},w=async e=>{let t=[`[${e.timestamp}] ${e.level.toUpperCase()} ${e.statusCode??"—"}`,`${e.source}${e.provider?` \xb7 ${e.provider}`:""}${e.model?` \xb7 ${e.model}`:""}`,e.message,e.details].filter(Boolean).join("\n");try{await re(t),f(null)}catch(e){f(e instanceof Error?e.message:String(e))}};return(0,r.jsxs)("div",{style:{flex:1,minWidth:0,minHeight:0,overflow:"auto",padding:"18px 20px",display:"flex",flexDirection:"column",gap:12},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsxs)("select",{value:s,onChange:e=>i(e.target.value),style:{padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12},children:[(0,r.jsx)("option",{value:"",children:e("desktop.logsAllLevels")}),["error","warning","info"].map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsxs)("select",{value:a,onChange:e=>l(e.target.value),style:{padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12},children:[(0,r.jsx)("option",{value:"",children:e("desktop.logsAllCodes")}),v.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsxs)("select",{value:d,onChange:e=>c(e.target.value),style:{padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12},children:[(0,r.jsx)("option",{value:"",children:e("desktop.logsAllSources")}),k.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsx)("input",{value:p,onChange:e=>u(e.target.value),placeholder:e("desktop.logsSearch"),style:{flex:1,minWidth:180,padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12}}),(0,r.jsx)("button",{type:"button",onClick:()=>void x(),title:e("desktop.refresh"),"aria-label":e("desktop.refresh"),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:30,height:30,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer"},children:(0,r.jsx)(C.S,{size:14})}),(0,r.jsx)("button",{type:"button",onClick:()=>void b(),title:e("desktop.logsClear"),"aria-label":e("desktop.logsClear"),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:30,height:30,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"#ef4444",cursor:"pointer"},children:(0,r.jsx)(T.l,{size:14})})]}),h&&(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontSize:12},children:e("desktop.loading")}),m&&(0,r.jsx)("div",{style:{color:"#ef4444",fontSize:12},children:m}),!h&&!m&&0===y.length&&(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontSize:12},children:e("desktop.logsEmpty")}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:y.map(t=>(0,r.jsxs)("details",{style:{border:"1px solid var(--border)",borderRadius:7,background:"var(--bg-panel)",padding:"8px 10px"},children:[(0,r.jsxs)("summary",{style:{cursor:"pointer",color:"error"===t.level?"#ef4444":"warning"===t.level?"#f59e0b":"var(--text)",fontSize:12},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",marginRight:8},children:t.statusCode??"—"}),(0,r.jsx)("span",{style:{marginRight:8},children:new Date(t.timestamp).toLocaleString()}),(0,r.jsx)("span",{style:{overflowWrap:"anywhere"},children:t.message.length>180?`${t.message.slice(0,180)}…`:t.message})]}),(0,r.jsxs)("div",{style:{padding:"8px 0 0 18px",color:"var(--text-muted)",fontSize:11,lineHeight:1.5,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:[(0,r.jsxs)("div",{children:[t.source,t.provider?` \xb7 ${t.provider}`:"",t.model?` \xb7 ${t.model}`:""]}),(0,r.jsx)("div",{style:{marginTop:5,maxHeight:260,overflow:"auto"},children:t.message}),t.details&&(0,r.jsx)("div",{style:{marginTop:5,maxHeight:260,overflow:"auto"},children:t.details}),(0,r.jsx)("button",{type:"button",onClick:()=>void w(t),style:{marginTop:8,padding:"4px 7px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",fontSize:11},children:e("desktop.logsCopy")})]})]},t.id))})]})}let dM={padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,width:"100%"},dP={padding:"6px 12px",border:"none",borderRadius:6,background:"var(--accent)",color:"#fff",cursor:"pointer",fontSize:12};function dE(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)([]),[s,i]=(0,n.useState)(!0),[a,l]=(0,n.useState)(null),[d,c]=(0,n.useState)(""),[p,u]=(0,n.useState)(""),[g,m]=(0,n.useState)(!1),[x,k]=(0,n.useState)(null),y=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/snippets");if(!e.ok)return;let t=await e.json();o(t.snippets??[]),i(!1)}catch{i(!1)}},[]);(0,n.useEffect)(()=>{y()},[y]);let b=(0,n.useCallback)(()=>{window.dispatchEvent(new Event("pi:snippets-changed"))},[]),w=()=>{l(null),c(""),u(""),k(null)},j=(0,n.useCallback)(async()=>{let t=d.trim();if(!t)return void k(e("desktop.snippetNameRequired"));m(!0),k(null);try{if(a){let e=await fetch(`/api/snippets/${encodeURIComponent(a.id)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,content:p})});if(!e.ok)throw Error(`HTTP ${e.status}`)}else{let e=await fetch("/api/snippets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,content:p})});if(!e.ok)throw Error(`HTTP ${e.status}`)}await y(),b(),w()}catch(e){k(e instanceof Error?e.message:String(e))}finally{m(!1)}},[a,d,p,y,b,e]),S=(0,n.useCallback)(async e=>{try{let t=await fetch(`/api/snippets/${encodeURIComponent(e)}`,{method:"DELETE"});if(!t.ok)throw Error(`HTTP ${t.status}`);a?.id===e&&w(),await y(),b()}catch(e){k(e instanceof Error?e.message:String(e))}},[a,y,b]);return(0,r.jsxs)(lh,{children:[(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"12px 0"},children:[(0,r.jsx)(n7.c,{size:15,"aria-hidden":"true"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:e("desktop.snippets")}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:e("desktop.snippetsDesc")})]})]})}),(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{width:"100%"},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:8},children:[(0,r.jsx)("button",{type:"button",onClick:w,style:dP,children:(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[(0,r.jsx)(v.F,{size:13})," ",e("desktop.snippetNew")]})}),a&&(0,r.jsx)("button",{type:"button",onClick:w,style:{...dP,background:"var(--bg-hover)",color:"var(--text-muted)"},children:(0,r.jsx)(h.X,{size:13})})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(120px, 200px) 1fr",gap:8,alignItems:"start",marginBottom:8},children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",display:"block",marginBottom:4},children:e("desktop.snippetName")}),(0,r.jsx)("input",{value:d,onChange:e=>c(e.target.value),placeholder:"#name",style:dM})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",display:"block",marginBottom:4},children:e("desktop.snippetContent")}),(0,r.jsx)("textarea",{value:p,onChange:e=>u(e.target.value),rows:3,style:{...dM,resize:"vertical",fontFamily:"var(--font-mono)",fontSize:11}})]})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:10},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void j(),disabled:g,style:{...dP,cursor:g?"wait":"pointer"},children:e("desktop.snippetSave")}),x&&(0,r.jsx)("span",{style:{color:"var(--status-error, #ef4444)",fontSize:12},children:x})]}),s?(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-dim)"},children:e("desktop.loadingThemes")}):0===t.length?(0,r.jsx)(lf,{children:e("desktop.snippetEmpty")}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:t.map(t=>(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6},children:[(0,r.jsx)("span",{style:{color:"var(--accent)",fontFamily:"var(--font-mono)",fontSize:11},children:"#"}),(0,r.jsx)("span",{style:{fontWeight:600,fontSize:12,flexShrink:0},children:t.name}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-muted)",fontSize:11,fontFamily:"var(--font-mono)"},children:t.content.split("\n")[0]}),(0,r.jsx)("button",{type:"button",onClick:()=>{l(t),c(t.name),u(t.content),k(null)},title:e("desktop.snippetEdit"),style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",padding:2},children:(0,r.jsx)(f.I,{size:13})}),(0,r.jsx)("button",{type:"button",onClick:()=>void S(t.id),title:e("desktop.snippetDelete"),style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",padding:2},children:(0,r.jsx)(T.l,{size:13})})]},t.id))})]})}),(0,r.jsx)(lm,{children:(0,r.jsx)(lf,{children:e("desktop.snippetHint")})})]})}let dW={builtin:0,global:1,workspace:2,project:3},dF="pi-web:settings-navigation";function dD(){try{return window.localStorage}catch{return null}}function dA(e){let t=e.getItem(dF);if(!t)return{};try{let e=JSON.parse(t);if(null===e||"object"!=typeof e||Array.isArray(e))return{};return{section:"string"==typeof e.section?e.section:void 0,selections:null===e.selections||"object"!=typeof e.selections||Array.isArray(e.selections)?void 0:e.selections}}catch{return{}}}function dN(e,t){return"models"===e?e:t?JSON.stringify([e,t]):null}function dL(e,t,o=dD()){if(!o)return null;let r=dN(e,t);if(!r)return null;try{let e=dA(o).selections?.[r];return"string"==typeof e&&e.length>0?e:null}catch{return null}}function d$({embedded:e,title:t,subtitle:o,closeLabel:n="Close",onClose:s,children:i,width:a=900,height:l="78vh"}){let d=e?void 0:{"--config-panel-width":`${a}px`,"--config-panel-height":l};return(0,r.jsx)("div",{role:e?void 0:"dialog","aria-modal":e?void 0:"true","aria-label":t,className:`config-panel-root ${e?"is-embedded":"is-modal"}`,onClick:t=>{e||t.target!==t.currentTarget||s()},children:(0,r.jsxs)("div",{className:"config-panel-surface",style:d,children:[!e&&(0,r.jsxs)("div",{className:"config-panel-header",children:[(0,r.jsx)("strong",{className:"config-panel-title",children:t}),o&&(0,r.jsx)("code",{className:"config-panel-subtitle",title:o,children:o}),(0,r.jsx)("button",{type:"button",className:"config-close-button",onClick:s,title:n,"aria-label":n,children:"\xd7"})]}),i]})})}function dH({children:e}){return(0,r.jsx)("div",{className:"config-split-view",children:e})}function dO({children:e}){return(0,r.jsx)("aside",{className:"config-sidebar",children:e})}function dB({children:e}){return(0,r.jsx)("div",{className:"config-sidebar-list",children:e})}function dU({children:e}){return(0,r.jsx)("div",{className:"config-sidebar-group-label",children:e})}function d_({active:e=!1,className:t,children:o,...n}){return(0,r.jsx)("button",{type:"button",...n,"aria-current":e?"page":void 0,className:["config-sidebar-item",t].filter(Boolean).join(" "),children:o})}function dq({className:e,...t}){return(0,r.jsx)("span",{...t,className:["config-sidebar-text",e].filter(Boolean).join(" ")})}function dV({className:e,...t}){return(0,r.jsx)("div",{...t,className:["config-detail-stack",e].filter(Boolean).join(" ")})}function dK({className:e,...t}){return(0,r.jsx)("div",{...t,className:["config-detail-header",e].filter(Boolean).join(" ")})}function dG({className:e,...t}){return(0,r.jsx)("div",{...t,className:["config-detail-header-info",e].filter(Boolean).join(" ")})}function dJ({className:e,...t}){return(0,r.jsx)("div",{...t,className:["config-detail-actions",e].filter(Boolean).join(" ")})}function dY({label:e,children:t,style:o}){return(0,r.jsxs)("div",{className:"config-field",style:o,children:[(0,r.jsx)("span",{className:"config-field-label",children:e}),t]})}function dX({children:e}){return(0,r.jsx)("div",{className:"config-empty-state",children:e})}function dZ({children:e,style:t}){return(0,r.jsx)("div",{className:"config-detail",style:t,children:e})}function dQ({status:e,children:t}){return(0,r.jsxs)("footer",{className:"config-footer",children:[(0,r.jsx)("div",{className:"config-footer-status",children:e}),(0,r.jsx)("div",{className:"config-footer-actions",children:t})]})}function d0({variant:e="secondary",size:t="default",className:o,children:n,...s}){return(0,r.jsx)("button",{type:"button",...s,className:["config-button",`config-button-${e}`,`config-button-${t}`,o].filter(Boolean).join(" "),children:n})}function d1({checked:e,disabled:t=!1,loading:o=!1,label:n,onChange:s}){let i=t||o;return(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":e,"aria-busy":o||void 0,"aria-label":n,title:n,disabled:i,className:`config-switch${o?" is-loading":""}`,onClick:()=>s(!e),children:(0,r.jsx)("span",{className:"config-switch-knob","aria-hidden":"true"})})}function d2({active:e=!1,children:t,className:o,...n}){return(0,r.jsx)("div",{className:"config-list-action",children:(0,r.jsxs)("button",{type:"button",...n,"aria-current":e?"page":void 0,className:["config-list-action-button",o].filter(Boolean).join(" "),children:[(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M12 5v14M5 12h14"})}),t]})})}function d4({active:e,color:t}){return(0,r.jsx)("span",{"aria-hidden":"true",className:`config-status-dot${e?" is-active":!1===e?" is-inactive":""}`,style:t?{backgroundColor:t}:void 0})}let d6=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function d8(e,t){return d6.compare(e.name||e.modelId,t.name||t.modelId)||d6.compare(e.provider,t.provider)||d6.compare(e.modelId,t.modelId)}function d5({options:e,value:t,onChange:o,onClear:s,emptyLabel:i,selectedLabel:a,disabled:l=!1,busy:d=!1,isAutoSelection:c=!1,ariaLabel:p,variant:u="toolbar",placement:h="up"}){let g,m,f,x,k,v,y,b,w,{t:j}=(0,A.s)(),S=O(),C=(0,n.useRef)(null),T=(0,n.useRef)(null),[R,z]=(0,n.useState)(!1),[I,M]=(0,n.useState)(null),[P,E]=(0,n.useState)(""),W=l||d,F=(0,n.useMemo)(()=>[...e].sort(d8),[e]),D=(g=P.trim().toLocaleLowerCase())?F.filter(e=>`${e.name} ${e.modelId}`.toLocaleLowerCase().includes(g)):F,N=F.length>8,L=[];for(let e of D){let t=L.find(t=>t.provider===e.provider);t?t.options.push(e):L.push({provider:e.provider,options:[e]})}let $=a??(t?F.find(e=>e.modelId===t.modelId&&e.provider===t.provider)?.name??t.modelId:i??(F.length>0?"Select model":"No models"));(0,n.useEffect)(()=>{let e=e=>{C.current&&!C.current.contains(e.target)&&T.current&&!T.current.contains(e.target)&&(z(!1),E(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,n.useEffect)(()=>{W&&(z(!1),E(""))},[W]);let H="field"===u?{display:"flex",alignItems:"center",gap:7,width:"100%",minWidth:0,height:34,padding:"0 9px",overflow:"hidden",border:"1px solid var(--border)",borderRadius:5,background:W?"var(--bg-panel)":"var(--bg)",color:W?"var(--text-dim)":"var(--text)",cursor:W?"default":"pointer",fontSize:12,textAlign:"left"}:{display:"flex",alignItems:"center",justifyContent:S?"flex-start":void 0,gap:6,width:S?"100%":void 0,maxWidth:S?"100%":220,height:32,padding:S?"8px 10px":"8px 12px",overflow:"hidden",border:"none",borderRadius:9,background:R?"var(--bg-hover)":"none",color:"var(--text-muted)",cursor:W?"not-allowed":"pointer",fontSize:12,opacity:W?.5:1,transition:"background 0.12s, color 0.12s"};return(0,r.jsxs)("div",{ref:C,className:`model-selector is-${u}${W?" is-disabled":""}`,style:{position:"relative",width:"field"===u||S?"100%":void 0,minWidth:0,flex:"toolbar"===u&&S?"1 1 auto":void 0},onKeyDown:e=>{"Escape"===e.key&&R&&(e.preventDefault(),e.stopPropagation(),E(""),z(!1))},children:[(0,r.jsxs)("button",{type:"button","aria-label":p,"aria-haspopup":"listbox","aria-expanded":R,"aria-busy":d||void 0,disabled:W,title:d?"Switching model":W?$:F.length>0||s?"Change model":"No available models",style:H,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();M({top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width}),z(e=>(e&&E(""),!e))},onMouseEnter:e=>{W||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{if(W){e.currentTarget.style.background="field"===u?"var(--bg-panel)":"none",e.currentTarget.style.color="field"===u?"var(--text-dim)":"var(--text-muted)";return}e.currentTarget.style.background=R?"var(--bg-hover)":"field"===u?"var(--bg)":"none",e.currentTarget.style.color="field"===u?"var(--text)":"var(--text-muted)"},children:[d?(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",style:{animation:"spin 0.8s linear infinite",flexShrink:0},"aria-hidden":"true",children:(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-2.64-6.36"})}):(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flexShrink:0},children:[(0,r.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,r.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,r.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,r.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,r.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,r.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,r.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,r.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,r.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,r.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$}),"field"===u&&(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flexShrink:0,color:"var(--text-dim)"},children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})]}),R&&I&&(m=window.visualViewport?.height??window.innerHeight,f=window.visualViewport?.width??window.innerWidth,x=I.top-8,k=m-I.bottom-8,y=Math.max(120,Math.min((v="up"===h||x>k)?x:k,.6*m)),b=v?{bottom:m-I.top+6}:{top:I.bottom+6},w=S?{left:8,right:8,maxWidth:"calc(100vw - 16px)"}:{left:I.left,width:"max-content",minWidth:I.width,maxWidth:Math.max(I.width,f-I.left-8)},(0,r.jsxs)("div",{ref:T,role:"listbox","aria-label":p,style:{position:"fixed",...b,...w,zIndex:500,display:"flex",flexDirection:"column",maxHeight:y,overflow:"hidden",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg)",boxShadow:v?"0 -4px 16px rgba(0,0,0,0.10)":"0 4px 16px rgba(0,0,0,0.10)"},children:[N&&(0,r.jsx)("div",{style:{flexShrink:0,padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("input",{value:P,onChange:e=>E(e.target.value),placeholder:j("chat.filterModels"),"aria-label":j("chat.filterModels"),autoFocus:!0,autoComplete:"off",spellCheck:!1,style:{boxSizing:"border-box",width:"100%",minWidth:220*!S,padding:"5px 8px",border:"1px solid var(--border)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:11}})}),(0,r.jsxs)("div",{style:{minHeight:0,overflowY:"auto"},children:[s&&!P.trim()&&(0,r.jsx)(d3,{active:!t,label:i??"Default",onClick:()=>{z(!1),E(""),s()}}),0===L.length?(0,r.jsx)("div",{style:{padding:"8px 12px",color:"var(--text-dim)",fontSize:12,whiteSpace:"nowrap"},children:P.trim()?j("chat.noMatchingModels"):"No available models"}):L.map((e,n)=>(0,r.jsxs)("div",{children:[L.length>1&&(0,r.jsx)("div",{style:{padding:"6px 12px 4px",borderTop:n>0||s?"1px solid var(--border)":"none",color:"var(--text-dim)",fontSize:10,fontWeight:600,letterSpacing:0,textTransform:"uppercase"},children:e.provider}),e.options.map(e=>(0,r.jsx)(d3,{active:e.modelId===t?.modelId&&e.provider===t?.provider,label:e.name,onClick:()=>{let r;return r=e.modelId===t?.modelId&&e.provider===t?.provider,void(z(!1),E(""),(!r||c)&&o(e.provider,e.modelId))}},`${e.provider}:${e.modelId}`))]},e.provider))]})]}))]})}function d3({active:e,label:t,onClick:o}){return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":e,onClick:o,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",border:"none",background:e?"var(--bg-selected)":"none",color:e?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:e?600:400,textAlign:"left",whiteSpace:"nowrap"},onMouseEnter:t=>{e||(t.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:t=>{e||(t.currentTarget.style.background="none")},children:[e?(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},"aria-hidden":"true",children:(0,r.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsx)("span",{title:t,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:t})]})}let d7=["read","bash","edit","write","grep","find","ls"],d9=["","off","minimal","low","medium","high","xhigh","max"],ce={name:"custom-agent",displayName:"Custom agent",description:"",systemPrompt:"",tools:["read","bash","edit","write","grep","find","ls"],loadSkills:!1,loadExtensions:!1,inheritContext:!1,runInBackground:!1,enabled:!0},ct={width:"100%",minWidth:0,height:34,padding:"0 9px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg)",color:"var(--text)",fontSize:12,outline:"none"},co={background:"var(--bg-panel)",color:"var(--text-dim)",cursor:"default"};function cr(e){return{name:e.name,displayName:e.displayName,description:e.description,systemPrompt:e.systemPrompt,tools:[...e.tools],loadSkills:e.loadSkills,loadExtensions:e.loadExtensions,...e.model?{model:e.model}:{},...e.thinking?{thinking:e.thinking}:{},...e.maxTurns?{maxTurns:e.maxTurns}:{},inheritContext:e.inheritContext,runInBackground:e.runInBackground,enabled:e.enabled}}function cn(e){return`${e.scope}:${e.name}`}function cs(e){return"global"===e||"project"===e}function ci(e){return e.replace(/^\/(?:Users|home)\/[^/]+/,"~")}function ca({label:e,children:t}){return(0,r.jsx)(dY,{label:e,children:t})}function cl({checked:e,disabled:t,label:o,onChange:n}){return(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:7,color:t?"var(--text-dim)":"var(--text-muted)",fontSize:12,cursor:t?"default":"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:e,disabled:t,onChange:e=>n(e.target.checked)}),o]})}function cd({cwd:e,sessionId:t=null,onClose:o,onReloaded:s,embedded:i=!1}){let a=O(),{t:l}=(0,A.s)(),[d,c]=(0,n.useState)([]),[p,u]=(0,n.useState)([]),[h,g]=(0,n.useState)(!0),[m,f]=(0,n.useState)(null),[x,k]=(0,n.useState)(()=>dL("agents",e)),[v,y]=(0,n.useState)(ce),[b,w]=(0,n.useState)("view"),[j,S]=(0,n.useState)("global"),[C,T]=(0,n.useState)(!0),[R,z]=(0,n.useState)(!1),[I,M]=(0,n.useState)(!1),[P,E]=(0,n.useState)(!1),[W,F]=(0,n.useState)(null),[D,N]=(0,n.useState)(!1),[L,$]=(0,n.useState)(!0),[H,B]=(0,n.useState)(!1),[U,_]=(0,n.useState)(null),[q,V]=(0,n.useState)(!1),[K,G]=(0,n.useState)(!1),J=(0,n.useMemo)(()=>d.find(e=>cn(e)===x)??null,[d,x]),Y=(0,n.useMemo)(()=>p.map(e=>({provider:e.provider,modelId:e.id,name:e.name})),[p]),X=(0,n.useCallback)(async t=>{T(!0),F(null);try{let o=await fetch(`/api/subagents/profiles?cwd=${encodeURIComponent(e)}`,{cache:"no-store"}),r=await o.json();if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);let n=r.profiles??[];c(n);let s=t??dL("agents",e),i=n.find(e=>cn(e)===s)??n.find(e=>"project"===e.scope)??n.find(e=>"global"===e.scope)??n[0]??null;k(i?cn(i):null),i&&(y(cr(i)),w(cs(i.scope)?"edit":"view"),cs(i.scope)&&S(i.scope))}catch(e){F(e instanceof Error?e.message:String(e))}finally{T(!1)}},[e]);(0,n.useEffect)(()=>{X()},[X]),(0,n.useEffect)(()=>{let e=new AbortController;return $(!0),_(null),(async()=>{try{let t=await fetch("/api/subagents/settings",{cache:"no-store",signal:e.signal}),o=await t.json();if(!t.ok||o.error||"boolean"!=typeof o.enabled)throw Error(o.error??`HTTP ${t.status}`);N(o.enabled)}catch(t){if(e.signal.aborted)return;_(t instanceof Error?t.message:String(t))}finally{e.signal.aborted||$(!1)}})(),()=>e.abort()},[]),(0,n.useEffect)(()=>{x&&function(e,t,o,r=dD()){if(!r||!t)return;let n=dN(e,o);if(n)try{let e=dA(r);e.selections={...e.selections,[n]:t},r.setItem(dF,JSON.stringify(e))}catch{}}("agents",x,e)},[e,x]),(0,n.useEffect)(()=>{let t=new AbortController;return g(!0),f(null),(async()=>{try{let o=await fetch(`/api/models?cwd=${encodeURIComponent(e)}`,{signal:t.signal}),r=await o.json();if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);u(r.modelList??[]),f(r.modelError??null)}catch(e){if(t.signal.aborted)return;f(e instanceof Error?e.message:String(e))}finally{t.signal.aborted||g(!1)}})(),()=>t.abort()},[e]);let Z=async()=>{z(!0),F(null),M(!1);try{let t=await fetch("/api/subagents/profiles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,scope:j,profile:v})}),o=await t.json();if(!t.ok||o.error||!o.profile)throw Error(o.error??`HTTP ${t.status}`);await X(cn(o.profile)),M(!0),setTimeout(()=>M(!1),2e3)}catch(e){F(e instanceof Error?e.message:String(e))}finally{z(!1)}},Q=async()=>{if(J&&cs(J.scope)&&window.confirm(l("agents.deleteConfirm",{name:J.displayName}))){z(!0),F(null);try{let t=await fetch("/api/subagents/profiles",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,scope:J.scope,name:J.name})}),o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);await X()}catch(e){F(e instanceof Error?e.message:String(e))}finally{z(!1)}}},ee="view"!==b,et="create"===b,eo=!ee||R||P,er=et?j:J?.scope,en=et?"global"===j?`~/.pi/agent/agents/${v.name||"..."}.md`:`./.pi/agents/${v.name||"..."}.md`:J?function(e,t){if(!e.filePath)return null;if(("project"===e.scope||"workspace"===e.scope)&&e.filePath.startsWith(t)){let o=e.filePath.slice(t.length).replace(/^[/\\]/,"");return`./${o}`}return ci(e.filePath)}(J,e)??l("agents.builtinPath"):"",es=et?en:J?.filePath??en,ei=!v.model||p.some(e=>`${e.provider}/${e.id}`===v.model),ea=(()=>{if(!v.model)return null;let e=v.model.indexOf("/");return e<0?{provider:"",modelId:v.model}:{provider:v.model.slice(0,e),modelId:v.model.slice(e+1)}})(),el=eo?{...ct,...co}:ct,ed=(e,t)=>{y(o=>({...o,[e]:t}))},ec=async t=>{if(et)return void ed("enabled",t);if(J&&cs(J.scope)){E(!0),F(null);try{let o=await fetch("/api/subagents/profiles",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,scope:J.scope,name:J.name,enabled:t})}),r=await o.json();if(!o.ok||r.error||!r.profile)throw Error(r.error??`HTTP ${o.status}`);let n=r.profile;c(e=>e.map(e=>cn(e)===cn(n)?n:e)),y(e=>({...e,enabled:n.enabled}))}catch(e){F(e instanceof Error?e.message:String(e))}finally{E(!1)}}},ep=async e=>{B(!0),_(null);try{let o=await fetch("/api/subagents/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})}),r=await o.json();if(!o.ok||r.error||"boolean"!=typeof r.enabled)throw Error(r.error??`HTTP ${o.status}`);N(r.enabled),V(!!t)}catch(e){_(e instanceof Error?e.message:String(e))}finally{B(!1)}},eu=async()=>{if(t){G(!0),_(null);try{await i6(t,{type:"reload"}),V(!1),s?.()}catch(e){_(e instanceof Error?e.message:String(e))}finally{G(!1)}}};return(0,r.jsxs)(d$,{embedded:i,title:l("common.agents"),subtitle:ci(e),closeLabel:l("agents.close"),onClose:o,children:[(0,r.jsxs)("div",{className:"agents-feature-setting",children:[(0,r.jsxs)("div",{className:"agents-feature-copy",children:[(0,r.jsx)("strong",{children:l("agents.builtInTitle")}),(0,r.jsx)("span",{children:l("agents.builtInDescription")}),q&&(0,r.jsx)("span",{role:"status",className:"agents-feature-reload-notice",children:l("agents.reloadRequired")})]}),(0,r.jsxs)("div",{className:"agents-feature-actions",children:[q&&t&&(0,r.jsx)(d0,{size:"small",onClick:()=>void eu(),disabled:K||H,children:K?l("agents.reloading"):l("agents.reloadSession")}),(0,r.jsx)(d1,{checked:D,disabled:L||K,loading:H,label:l("agents.builtInTitle"),onChange:e=>void ep(e)})]})]}),(0,r.jsxs)(dH,{children:[(0,r.jsxs)(dO,{children:[(0,r.jsx)(dB,{children:C?(0,r.jsx)("div",{style:{padding:10,color:"var(--text-dim)",fontSize:12},children:l("agents.loading")}):["project","global","workspace","builtin"].map(e=>{let t=d.filter(t=>t.scope===e);return 0===t.length?null:(0,r.jsxs)("div",{className:"config-sidebar-group",children:[(0,r.jsx)(dU,{children:l(`agents.scope.${e}`)}),t.map(e=>{let t,o,n=(t=e.name.toLowerCase(),o=dW[e.scope],d.some(e=>e.name.toLowerCase()===t&&dW[e.scope]>o));return(0,r.jsxs)(d_,{active:x===cn(e)&&!et,onClick:()=>{k(cn(e)),y(cr(e)),w(cs(e.scope)?"edit":"view"),cs(e.scope)&&S(e.scope),F(null)},children:[(0,r.jsx)(d4,{active:e.enabled}),(0,r.jsx)(dq,{className:`is-grow${e.enabled?"":" is-muted"}`,children:e.displayName}),n&&(0,r.jsx)("span",{className:"agents-overridden-label",children:l("agents.overridden")})]},cn(e))})]},e)})}),(0,r.jsx)(d2,{active:et,onClick:()=>{let e="custom-agent",t=2;for(;d.some(t=>t.name===e);)e=`custom-agent-${t++}`;k(null),y({...ce,name:e,displayName:e}),w("create"),S("global"),F(null)},children:l("agents.new")})]}),(0,r.jsx)(dZ,{children:(0,r.jsx)(dV,{className:"is-fill",children:J||et?(0,r.jsxs)(dV,{children:[(0,r.jsxs)(dK,{children:[(0,r.jsxs)(dG,{children:[er&&(0,r.jsx)("span",{className:`config-scope-tag${"project"===er?" is-project":""}`,children:l(`agents.scope.${er}`)}),(0,r.jsx)("span",{title:es,className:"config-detail-path",children:en})]}),(0,r.jsxs)(dJ,{children:[J&&("view"===b||"edit"===b)&&(0,r.jsx)(d0,{size:"small",onClick:()=>{if(!J)return;let e=function(e,t){let o=new Set(t.map(e=>e.name.toLowerCase())),r=`${e}-copy`,n=r,s=2;for(;o.has(n.toLowerCase());)n=`${r}-${s++}`;return n}(J.name,d);k(null),y({...cr(J),name:e,displayName:l("agents.copyName",{name:J.displayName})}),w("create"),S(cs(J.scope)?J.scope:"global"),F(null)},disabled:R||P,children:l("agents.duplicate")}),J&&cs(J.scope)&&"edit"===b&&(0,r.jsx)(d0,{variant:"danger",size:"small",onClick:()=>void Q(),disabled:R||P,children:l("agents.delete")}),(0,r.jsx)(d1,{checked:v.enabled,disabled:eo,label:v.enabled?l("agents.disable"):l("agents.enable"),onChange:e=>void ec(e)})]})]}),et&&(0,r.jsx)(ca,{label:l("agents.saveScope"),children:(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:3,padding:3,border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)"},children:["global","project"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>S(e),disabled:R,style:{height:28,border:"none",borderRadius:4,background:j===e?"var(--bg-selected)":"transparent",color:j===e?"var(--text)":"var(--text-muted)",cursor:R?"default":"pointer",fontSize:11,fontWeight:j===e?600:400},children:l(`agents.scope.${e}`)},e))})}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:a?"1fr":"minmax(0, 1fr) minmax(0, 1fr)",gap:12},children:[(0,r.jsx)(ca,{label:l("agents.name"),children:et?(0,r.jsx)("input",{"aria-label":l("agents.name"),value:v.name,disabled:eo,onChange:e=>ed("name",e.target.value),style:ct}):(0,r.jsx)("code",{style:{minHeight:34,display:"flex",alignItems:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)",fontSize:12},children:v.name})}),(0,r.jsx)(ca,{label:l("agents.displayName"),children:(0,r.jsx)("input",{"aria-label":l("agents.displayName"),value:v.displayName,disabled:eo,onChange:e=>ed("displayName",e.target.value),style:el})})]}),(0,r.jsx)(ca,{label:l("agents.description"),children:(0,r.jsx)("input",{"aria-label":l("agents.description"),value:v.description,disabled:eo,onChange:e=>ed("description",e.target.value),style:el})}),(0,r.jsx)(ca,{label:l("agents.prompt"),children:(0,r.jsx)("textarea",{className:"agents-system-prompt","aria-label":l("agents.prompt"),value:v.systemPrompt,disabled:eo,onChange:e=>ed("systemPrompt",e.target.value),style:{...el,height:195,minHeight:195,maxHeight:"60vh",padding:9,overflow:"auto",resize:eo?"none":"vertical",lineHeight:1.5}})}),(0,r.jsx)(ca,{label:l("agents.tools"),children:(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px"},children:d7.map(e=>(0,r.jsx)(cl,{label:e,disabled:eo,checked:v.tools.includes(e),onChange:t=>ed("tools",t?[...v.tools,e]:v.tools.filter(t=>t!==e))},e))})}),(0,r.jsx)(ca,{label:l("agents.resources"),children:(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 20px"},children:[(0,r.jsx)(cl,{label:l("agents.loadSkills"),disabled:eo,checked:v.loadSkills,onChange:e=>ed("loadSkills",e)}),(0,r.jsx)(cl,{label:l("agents.loadExtensions"),disabled:eo,checked:v.loadExtensions,onChange:e=>ed("loadExtensions",e)})]})}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:a?"1fr":"minmax(0, 1.5fr) minmax(120px, 0.75fr) minmax(100px, 0.5fr)",gap:12},children:[(0,r.jsx)(ca,{label:l("agents.model"),children:(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)(d5,{options:Y,value:ea,onChange:(e,t)=>ed("model",`${e}/${t}`),onClear:()=>ed("model",void 0),emptyLabel:h?l("agents.modelsLoading"):l("agents.inherit"),selectedLabel:v.model&&!ei?l("agents.modelUnavailable",{model:v.model}):void 0,disabled:eo||h||0===p.length&&!v.model,ariaLabel:l("agents.model"),variant:"field",placement:"auto"}),m&&(0,r.jsx)("span",{style:{color:"#ef4444",fontSize:10},children:m})]})}),(0,r.jsx)(ca,{label:l("agents.thinking"),children:(0,r.jsx)("select",{"aria-label":l("agents.thinking"),value:v.thinking??"",disabled:eo,onChange:e=>ed("thinking",e.target.value||void 0),style:el,children:d9.map(e=>(0,r.jsx)("option",{value:e,children:e||l("agents.inherit")},e||"default"))})}),(0,r.jsx)(ca,{label:l("agents.maxTurns"),children:(0,r.jsx)("input",{"aria-label":l("agents.maxTurns"),type:"number",min:1,value:v.maxTurns??"",disabled:eo,onChange:e=>ed("maxTurns",e.target.value?Number(e.target.value):void 0),style:el})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"10px 20px"},children:[(0,r.jsx)(cl,{label:l("agents.inheritContext"),disabled:eo,checked:v.inheritContext,onChange:e=>ed("inheritContext",e)}),(0,r.jsx)(cl,{label:l("agents.background"),disabled:eo,checked:v.runInBackground,onChange:e=>ed("runInBackground",e)})]})]}):(0,r.jsx)(dX,{children:l("agents.empty")})})})]}),(0,r.jsx)(dQ,{status:(U||W)&&(0,r.jsx)("span",{role:"alert",style:{color:"#ef4444"},children:U||W}),children:ee&&(0,r.jsxs)(d0,{variant:"primary",onClick:()=>void Z(),disabled:R||I||P||!v.name.trim(),className:I?"is-success":void 0,children:[I&&(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:"config-button-success-icon",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}),(0,r.jsx)("span",{children:I?l("i18n.saved"):R?l("agents.saving"):l("agents.save")})]})})]})}function cc({sessionId:e,onSessionReloaded:t}){let{t:o}=(0,A.s)(),[s,i]=(0,n.useState)(null),[a,l]=(0,n.useState)(null);(0,n.useEffect)(()=>{let e=!1;return fetch("/api/tools/settings").then(async t=>{let o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);e||i(o)}).catch(t=>{e||l(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[]);let d=(0,n.useCallback)(async o=>{l(null);try{let r=await fetch("/api/tools/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:o})}),n=await r.json();if(!r.ok||n.error)throw Error(n.error??`HTTP ${r.status}`);i(n),e&&(await i6(e,{type:"reload"}),t())}catch(e){l(e instanceof Error?e.message:String(e))}},[t,e]);return(0,r.jsx)("div",{style:{padding:16,overflowY:"auto",minHeight:0,flex:1},children:(0,r.jsxs)(lh,{children:[(0,r.jsx)(lg,{children:(0,r.jsx)(a4,{label:o("desktop.usePowerShell"),description:o("desktop.shellToolDescription"),checked:s?.powerShellEnabled??!1,onChange:e=>void d(e)})}),(0,r.jsx)(lm,{children:(0,r.jsx)("div",{style:{padding:"10px 0",fontSize:12,lineHeight:1.5,color:"var(--text-dim)"},children:s?.isWindows?o("desktop.shellToolWindowsOnly"):a??o("desktop.shellToolMacOnly")})})]})})}function cp(e){return null==e?"—":i$(e)}function cu({sessionId:e,cwd:t}){let{t:o}=(0,A.s)(),[s,i]=(0,n.useState)(null),[a,l]=(0,n.useState)(null),[d,c]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let t=!1;return e?(fetch(`/api/agent/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{t||i(e?.state?.contextUsage??null)}).catch(()=>{}),()=>{t=!0}):void i(null)},[e]);let p=(0,n.useCallback)(async()=>{c(!0);try{let e=await fetch("/api/usage");e.ok&&l(await e.json())}catch{}finally{c(!1)}},[]);(0,n.useEffect)(()=>{p()},[p]);let u=(0,n.useMemo)(()=>a?.daily.slice(-14)??[],[a]),h=(0,n.useMemo)(()=>u.reduce((e,t)=>Math.max(e,t.tokens),0),[u]);return(0,r.jsxs)("div",{style:{flex:1,overflow:"auto",minWidth:0,padding:"16px 20px",display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsx)("h3",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text)"},children:o("desktop.usage")}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)"},children:o("desktop.usageSession")}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e?(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:12,border:"1px solid var(--border)",padding:16},children:s?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:16},children:[(0,r.jsxs)("svg",{width:72,height:72,viewBox:"0 0 72 72",style:{flexShrink:0},children:[(0,r.jsx)("circle",{cx:36,cy:36,r:30,fill:"none",stroke:"var(--border)",strokeWidth:7}),(0,r.jsx)("circle",{cx:36,cy:36,r:30,fill:"none",stroke:"var(--accent)",strokeWidth:7,strokeLinecap:"round",strokeDasharray:2*Math.PI*30,strokeDashoffset:2*Math.PI*30*(1-Math.min(1,(s.percent??0)/100)),transform:"rotate(-90 36 36)",style:{transition:"stroke-dashoffset 0.4s ease"}}),(0,r.jsx)("text",{x:36,y:41,textAnchor:"middle",fontSize:15,fontWeight:700,fill:"var(--text)",children:null!=s.percent?`${s.percent.toFixed(0)}%`:"?"})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[(0,r.jsx)("span",{style:{fontSize:13,color:"var(--text)"},children:o("desktop.usageContext",{used:cp(s.tokens),window:cp(s.contextWindow)})}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)"},children:o("desktop.usageContextHint")})]})]})}):(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)"},children:o("desktop.usageNoSessionData")})}):(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)"},children:o("desktop.usageNoSession")}),t&&(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)"},children:o("desktop.usageGlobal")}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:10},children:[{label:o("desktop.usageTotal"),value:cp(a?.totalTokens),sub:a?`${a.totalSessions} ${o("desktop.usageSessions")}`:"…"},{label:o("desktop.usageMessages"),value:a?String(a.messageCount):"…",sub:o("desktop.usageMessagesHint")}].map(e=>(0,r.jsxs)("div",{style:{borderRadius:12,border:"1px solid var(--border)",padding:"12px 14px",background:"var(--bg-panel)"},children:[(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:4},children:e.label}),(0,r.jsx)("div",{style:{fontSize:18,fontWeight:700,color:"var(--text)"},children:e.value}),(0,r.jsx)("div",{style:{fontSize:10.5,color:"var(--text-dim)",marginTop:2},children:e.sub})]},e.label))}),(0,r.jsxs)("div",{style:{borderRadius:12,border:"1px solid var(--border)",padding:"14px 16px"},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",marginBottom:10},children:o("desktop.usageDaily")}),0===u.length?(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)"},children:o(d?"desktop.featuresLoading":"desktop.usageNoData")}):(0,r.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,height:96,overflowX:"auto"},children:u.map(e=>{let t=h>0?Math.max(4,Math.round(e.tokens/h*72)):4;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4,flexShrink:0},children:[(0,r.jsx)("div",{style:{fontSize:9,color:"var(--text-dim)"},children:e.tokens>0?cp(e.tokens):""}),(0,r.jsx)("div",{style:{width:8,height:t,borderRadius:4,background:e.tokens>0?"var(--accent)":"var(--bg-hover)",opacity:e.tokens>0?.85:1},title:`${e.day}: ${cp(e.tokens)}`}),(0,r.jsx)("div",{style:{fontSize:9,color:"var(--text-dim)"},children:e.day.slice(5)})]},e.day)})})]}),(0,r.jsxs)("div",{style:{borderRadius:12,border:"1px solid var(--border)",overflow:"hidden"},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",padding:"10px 14px",borderBottom:"1px solid var(--border)"},children:o("desktop.usageTopSessions")}),a&&0===a.sessions.length?(0,r.jsx)("div",{style:{padding:"14px",fontSize:12,color:"var(--text-muted)"},children:o("desktop.usageNoData")}):(a?.sessions??[]).slice(0,12).map(e=>(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 14px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("span",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name??e.firstMessage??e.id}),(0,r.jsx)("span",{style:{flexShrink:0,fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:cp(e.tokens)})]},e.path))]})]})]})]})}function ch(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)(!1),[s,i]=(0,n.useState)("");(0,n.useEffect)(()=>{o(new URLSearchParams(window.location.search).has("piweb_connected")),i(window.location.host)},[]);let a=(0,n.useCallback)(()=>{window.location.href="piweb-switch://manage"},[]);return t?(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0,overflowY:"auto"},children:[(0,r.jsx)("header",{style:{padding:"18px 22px 14px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("h1",{style:{margin:0,fontSize:16,fontWeight:700,color:"var(--text)"},children:e("desktop.server")})}),(0,r.jsxs)("div",{style:{padding:"18px 22px",display:"flex",flexDirection:"column",gap:14},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,background:"var(--bg-hover)",border:"1px solid var(--border)"},children:[(0,r.jsx)(a_.X,{size:18,color:"var(--accent)"}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.serverCurrent")}),(0,r.jsx)("div",{style:{fontSize:14,fontWeight:600,color:"var(--text)",fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:s})]})]}),(0,r.jsxs)("button",{type:"button",onClick:a,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"10px 16px",borderRadius:10,background:"linear-gradient(135deg, var(--accent), var(--accent-hover, var(--accent)))",color:"#fff",fontSize:14,fontWeight:600,cursor:"pointer",border:"none"},children:[(0,r.jsx)(lw.o,{size:16}),e("desktop.serverSwitch")]}),(0,r.jsx)("p",{style:{margin:0,fontSize:12.5,lineHeight:1.7,color:"var(--text-muted)"},children:e("desktop.serverSwitchHint")})]})]}):null}let cg=[{id:"server",labelKey:"desktop.server",Icon:a_.X},{id:"display",labelKey:"desktop.display",Icon:aq.V},{id:"chat",labelKey:"desktop.chat",Icon:aV.W},{id:"models",labelKey:"desktop.models",Icon:z.f},{id:"skills",labelKey:"desktop.skills",Icon:I.B},{id:"plugins",labelKey:"desktop.plugins",Icon:M.F},{id:"proxy",labelKey:"desktop.proxy",Icon:aK.l},{id:"features",labelKey:"desktop.features",Icon:g.l},{id:"logs",labelKey:"desktop.logs",Icon:w.B},{id:"snippets",labelKey:"desktop.snippets",Icon:n7.c},{id:"usage",labelKey:"desktop.usage",Icon:aG._},{id:"mcp",labelKey:"desktop.mcp",Icon:aJ.b},{id:"subagents",labelKey:"desktop.subagents",Icon:aY.d},{id:"tools",labelKey:"desktop.tools",Icon:aJ.b},{id:"backup",labelKey:"desktop.backup",Icon:rQ.W},{id:"import",labelKey:"desktop.importSessions",Icon:E.z}];function cm({initialTab:e="models",cwd:t,sessionId:o,onCloseAction:s,onModelsSavedAction:i,onSessionReloadedAction:a,onSessionsChanged:l}){let d=O(),{t:c}=(0,A.s)(),[p,u]=(0,n.useState)("skills"===e||"plugins"===e?t?e:"display":e),[g,m]=(0,n.useState)(!1);(0,n.useEffect)(()=>{m(new URLSearchParams(window.location.search).has("piweb_connected"))},[]);let f=g?cg:cg.filter(({id:e})=>"server"!==e),[x,k]=(0,n.useState)(!1),[v,y]=(0,n.useState)(null),b=(0,n.useRef)(new Set),w=(0,n.useCallback)(e=>(b.current.add(e),()=>{b.current.delete(e)}),[]),j=(0,n.useCallback)(async()=>{if(!x){k(!0),y(null);try{let e=(await Promise.allSettled([...b.current].map(e=>e()))).find(e=>"rejected"===e.status);if(e)throw e.reason;s()}catch(e){y(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[x,s]);return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&j()},children:(0,r.jsxs)("section",{role:"dialog","aria-modal":"true","aria-label":c("desktop.settings"),className:"settings-modal",style:{width:d?"calc(100vw - 16px)":1e3,maxWidth:"calc(100vw - 16px)",height:d?"calc(100dvh - 16px)":"80vh",maxHeight:"calc(100dvh - 16px)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[(0,r.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,minWidth:0},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:c("desktop.settings")}),"models"===p?(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:"~/.pi/agent/models.json"}):t&&(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),(0,r.jsx)("button",{type:"button",onClick:()=>{j()},disabled:x,title:c("desktop.closeSettings"),"aria-label":c("desktop.closeSettings"),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:18,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:d?"column":"row",minHeight:0,overflow:"hidden",pointerEvents:x?"none":void 0},children:[(0,r.jsx)("nav",{"aria-label":c("desktop.settingsSections"),style:{display:"flex",flexDirection:d?"row":"column",gap:4,width:d?"100%":150,padding:8,flexShrink:0,minWidth:0,background:"var(--bg-panel)",borderRight:d?"none":"1px solid var(--border)",borderBottom:d?"1px solid var(--border)":"none",overflowX:d?"auto":void 0,overflowY:d?"hidden":void 0,WebkitOverflowScrolling:d?"touch":void 0},children:f.filter(({id:e})=>!(d&&"import"===e)).map(({id:e,labelKey:o,Icon:n})=>{let s=("skills"===e||"plugins"===e)&&!t,i=p===e;return(0,r.jsxs)("button",{type:"button",disabled:s,onClick:()=>u(e),"aria-current":i?"page":void 0,style:{display:"flex",alignItems:"center",gap:8,flex:d?"0 0 auto":void 0,whiteSpace:"nowrap",width:d?void 0:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:i?"var(--bg-selected)":"none",color:i?"var(--text)":"var(--text-muted)",cursor:s?"not-allowed":"pointer",opacity:s?.4:1,fontSize:12,fontWeight:i?600:400,textAlign:"left",transition:"background 0.12s, color 0.12s"},title:c(o),"aria-label":c(o),onMouseEnter:e=>{i||s||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{i||(e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)")},children:[(0,r.jsx)(n,{size:16,"aria-hidden":"true"}),!d&&(0,r.jsx)("span",{children:c(o)})]},e)})}),(0,r.jsx)("div",{style:{display:"server"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(ch,{})}),(0,r.jsx)("div",{style:{display:"display"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(lp,{})}),(0,r.jsx)("div",{style:{display:"chat"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(a3,{})}),(0,r.jsx)("div",{style:{display:"models"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(dn,{embedded:!0,sessionId:o,onSavedAction:i,onRegisterFlush:w})}),t&&(0,r.jsx)("div",{style:{display:"skills"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(dz,{cwd:t,embedded:!0,sessionId:o})}),t&&(0,r.jsx)("div",{style:{display:"plugins"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(dk,{cwd:t,sessionId:o,embedded:!0,onReloadedAction:a})}),(0,r.jsx)("div",{style:{display:"proxy"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(dy,{})}),(0,r.jsx)("div",{style:{display:"features"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(lb,{})}),(0,r.jsx)("div",{style:{display:"logs"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(dI,{})}),(0,r.jsx)("div",{style:{display:"snippets"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(dE,{})}),(0,r.jsx)("div",{style:{display:"usage"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(cu,{sessionId:o,cwd:t})}),(0,r.jsx)("div",{style:{display:"mcp"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(l$,{sessionId:o})}),(0,r.jsx)("div",{style:{display:"subagents"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(cd,{cwd:t??"",sessionId:o,onClose:s})}),(0,r.jsx)("div",{style:{display:"tools"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(cc,{sessionId:o,onSessionReloaded:a})}),(0,r.jsx)("div",{style:{display:"backup"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(a0,{cwd:t})}),(0,r.jsx)("div",{style:{display:"import"===p?"flex":"none",flex:1,minWidth:0,minHeight:0,overflowY:"auto"},children:(0,r.jsx)(lS,{onSessionsChanged:l})})]}),v&&(0,r.jsx)("div",{style:{padding:"6px 18px",borderTop:"1px solid var(--border)",color:"#f87171",fontSize:11},children:v})]})})}let cf=new Set(["awaiting_input","review","failed"]),cx=(0,n.createContext)(null);function ck(){let e=(0,n.useContext)(cx);if(!e)throw Error("useTasksView must be used within TasksViewProvider");return e}function cv({children:e}){let{t}=(0,A.s)(),o=(0,n.useRef)(t);(0,n.useEffect)(()=>{o.current=t},[t]);let[s,i]=(0,n.useState)([]),[a,l]=(0,n.useState)([]),d=(0,n.useRef)(0),c=(0,n.useCallback)(async()=>{let e=++d.current;try{let t=await (0,sS.Wt)(),o=(await Promise.all(t.map(e=>(0,sS.Vk)(e).catch(()=>[])))).flat().sort((e,t)=>t.id-e.id);if(e!==d.current)return;l(e=>cy(e,t)?e:t),i(e=>cy(e,o)?e:o)}catch{}},[]);(0,n.useEffect)(()=>{c();let e=null,t=!1,o=()=>{t||((e=new EventSource("/api/tasks/events")).onmessage=()=>{c()},e.onerror=()=>{e?.close(),e=null,c(),setTimeout(o,2e3)})};o();let r=()=>{"visible"===document.visibilityState&&c()},n=()=>void c();document.addEventListener("visibilitychange",r),window.addEventListener("online",n);let s=setInterval(()=>void c(),6e4);return()=>{t=!0,e?.close(),document.removeEventListener("visibilitychange",r),window.removeEventListener("online",n),clearInterval(s)}},[c]);let p=(0,n.useMemo)(()=>s.filter(e=>cf.has(e.status)&&null==e.archivedAt).length,[s]),u=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=u.current;if((u.current=new Map(s.map(e=>[e.id,e.status])),e&&0!==s.length)&&"Notification"in window){for(let o of s)if(e.get(o.id)!==o.status&&("review"===o.status||"failed"===o.status)&&null==o.archivedAt&&"visible"!==document.visibilityState)try{let e="review"===o.status?t("tasks.notifyReview",{title:o.title}):t("tasks.notifyFailed",{title:o.title});!function(e,t){new Promise(o=>{if(!("Notification"in window))return void o();let r=()=>{try{new Notification(e,{body:t,tag:"pi-tasks"})}catch{}o()};"granted"===Notification.permission?r():"denied"!==Notification.permission?Notification.requestPermission().then(e=>{"granted"===e?r():o()}):o()})}("Pi Web Tasks",e)}catch{}}},[s,t]);let h=(0,n.useMemo)(()=>({tasks:s,projects:a,attentionCount:p,refetch:c}),[s,a,p,c]);return(0,r.jsx)(cx.Provider,{value:h,children:e})}function cy(e,t){return JSON.stringify(e)===JSON.stringify(t)}var cb=o(4539),cw=o(12449),cj=o(2571);let cS=["todo","inProgress","attention","done"];function cC(e){return"review"===e.status&&0===e.filesChanged}function cT(){return{defaultAgentType:null,modeId:null,configValues:{},autoProcess:!0,maxConcurrent:1,mergeStrategy:"merge",deleteWorktreeDefault:!0,preflightCommand:null,initCommand:null,stagePrompts:null}}let cR=["todo","inProgress","attention","done"],cz={todo:{id:"todo",marker:"var(--text-dim)"},inProgress:{id:"inProgress",marker:"var(--accent)"},attention:{id:"attention",marker:"#f59e0b"},done:{id:"done",marker:"#10b981"}};var cI=o(54775),cM=o(98998),cP=o(36668);function cE({task:e}){let{t}=(0,A.s)(),o=t("failed"===e.status&&"interrupted"===e.failureReason?"tasks.statusInterrupted":function(e){switch(e){case"todo":return"tasks.statusTodo";case"queued":return"tasks.statusQueued";case"preparing":return"tasks.statusPreparing";case"running":return"tasks.statusRunning";case"awaiting_input":return"tasks.statusAwaitingInput";case"review":return"tasks.statusReview";case"merging":return"tasks.statusMerging";case"done":return"tasks.statusDone";case"failed":return"tasks.statusFailed";case"canceled":return"tasks.statusCanceled"}}(e.status)),n={display:"inline-flex",alignItems:"center",gap:4,borderRadius:999,padding:"2px 8px",fontSize:10,fontWeight:600,lineHeight:1.4,flexShrink:0,whiteSpace:"nowrap"};switch(e.status){case"queued":case"preparing":case"running":case"merging":return(0,r.jsxs)("span",{style:{...n,color:"var(--accent)"},children:[(0,r.jsx)(cI.N,{size:11,className:"pi-spin",style:{animation:"pi-spin 1s linear infinite"},"aria-hidden":"true"}),o]});case"awaiting_input":case"review":return(0,r.jsx)("span",{style:{...n,border:"1px solid rgba(245,158,11,0.45)",background:"rgba(245,158,11,0.08)",color:"#d97706"},children:o});case"done":return(0,r.jsxs)("span",{style:{...n,background:"rgba(16,185,129,0.12)",color:"#059669"},children:[(0,r.jsx)(m.J,{size:10,weight:"bold","aria-hidden":"true"}),o]});case"failed":return(0,r.jsx)("span",{style:{...n,background:"rgba(239,68,68,0.12)",color:"#dc2626"},children:o});default:return(0,r.jsx)("span",{style:{...n,background:"var(--bg-hover)",color:"var(--text-muted)"},children:o})}}function cW({task:e}){let t=e.preflight;if(!t||"review"!==e.status)return null;let o="passed"===t.status?{background:"rgba(16,185,129,0.12)",color:"#059669"}:"failed"===t.status?{background:"rgba(239,68,68,0.12)",color:"#dc2626"}:{background:"var(--bg-hover)",color:"var(--text-muted)"};return(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,borderRadius:999,padding:"1px 6px",fontSize:10,fontWeight:500,lineHeight:1.5,maxWidth:"100%",...o},title:t.command,children:["running"===t.status?(0,r.jsx)(cI.N,{size:10,style:{animation:"pi-spin 1s linear infinite"},"aria-hidden":"true"}):"passed"===t.status?(0,r.jsx)(nv.r,{size:10,"aria-hidden":"true"}):(0,r.jsx)(iU.J,{size:10,"aria-hidden":"true"}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.command})]})}function cF({task:e,folderName:t,now:o,onOpen:n,onStart:s,onCancel:i,onRetry:a,onRequeue:l,onViewSession:d,onMerge:c,onArchive:p,onEdit:u}){let{t:h}=(0,A.s)(),g=null!=e.archivedAt,f="running"===e.status||"awaiting_input"===e.status||"merging"===e.status,x=null!=e.filesChanged&&e.filesChanged>0?(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontFamily:"var(--font-mono)",fontSize:10},children:[(0,r.jsxs)("span",{style:{color:"#059669"},children:["+",e.additions??0]}),(0,r.jsxs)("span",{style:{color:"#dc2626"},children:["-",e.deletions??0]})]}):null,k=function(e,t){if(!e)return"";let o=new Date(e).getTime();if(Number.isNaN(o))return"";let r=Math.floor(Math.max(0,t-o)/6e4);if(r<1)return"now";if(r<60)return`${r}m`;let n=Math.floor(r/60);if(n<24)return`${n}h`;let s=Math.floor(n/24);return`${s}d`}(e.finishedAt??e.settledAt??e.startedAt??e.createdAt,o),{primary:v,more:y}=(()=>{let t=[],o=null;if(g)return{primary:o={icon:P.T,label:h("tasks.actionUnarchive"),onClick:p},more:t};switch(e.status){case"todo":o={icon:cj.j,label:h("tasks.actionStart"),onClick:s},t.push({icon:n9.S,label:h("tasks.actionEdit"),onClick:u});break;case"queued":case"preparing":case"running":case"awaiting_input":o={icon:cM.k,label:h("tasks.actionCancel"),onClick:i};break;case"review":o=cC(e)?{icon:m.J,label:h("tasks.actionComplete"),onClick:c}:{icon:cP.r,label:h("tasks.actionMerge"),onClick:c};break;case"merging":break;case"failed":o={icon:C.S,label:h("tasks.actionRetry"),onClick:a},t.push({icon:n9.S,label:h("tasks.actionEdit"),onClick:u}),t.push({icon:P.T,label:h("tasks.actionArchive"),onClick:p});break;case"done":o={icon:P.T,label:h("tasks.actionArchive"),onClick:p};break;case"canceled":o={icon:ny.f,label:h("tasks.actionRequeue"),onClick:l},t.push({icon:P.T,label:h("tasks.actionArchive"),onClick:p})}return{primary:o,more:t}})(),b=[...y];return null!=e.conversationId&&b.push({icon:nk.y,label:h("tasks.actionViewSession"),onClick:d}),(0,r.jsxs)("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),n())},style:{display:"flex",flexDirection:"column",cursor:"pointer",borderRadius:12,border:"1px solid color-mix(in srgb, var(--border) 85%, transparent)",background:"var(--bg-panel)",padding:12,textAlign:"left",transition:"border-color 0.12s",opacity:g?.6:1,boxShadow:"0 1px 2px rgba(0,0,0,0.04)"},className:"task-card-hover",onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="color-mix(in srgb, var(--border) 85%, transparent)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8},children:[(0,r.jsx)("span",{style:{minWidth:0,overflowWrap:"break-word",fontSize:13,fontWeight:500,lineHeight:1.4},children:e.title}),(0,r.jsx)(cE,{task:e})]}),(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"2px 6px",marginTop:6,fontSize:11,color:"var(--text-muted)"},children:[t?(0,r.jsx)("span",{style:{maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t}):null,t&&e.workBranch?(0,r.jsx)("span",{style:{opacity:.5},children:"/"}):null,e.workBranch?(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:180},children:e.workBranch}):null,(t||e.workBranch)&&(x||k)?(0,r.jsx)("span",{style:{opacity:.5},children:"\xb7"}):null,x,x&&k?(0,r.jsx)("span",{style:{opacity:.5},children:"\xb7"}):null,k?(0,r.jsx)("span",{style:{flexShrink:0},children:k}):null,(0,r.jsx)(cW,{task:e})]}),e.lastError&&("failed"===e.status||"review"===e.status)?(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:8,borderRadius:8,background:"rgba(239,68,68,0.08)",padding:"6px 8px",fontSize:11,color:"#dc2626"},children:[(0,r.jsx)(r0.t,{size:13,style:{flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.lastError}),(0,r.jsx)("button",{type:"button",style:{flexShrink:0,fontWeight:600,background:"none",border:"none",cursor:"pointer",color:"inherit",fontSize:11,textDecoration:"underline"},onClick:e=>{e.stopPropagation(),n()},children:h("tasks.errorView")})]}):null,"review"===e.status&&e.resultSummary?(0,r.jsx)("p",{style:{margin:"6px 0 0",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",fontSize:11,lineHeight:1.5,color:"var(--text-muted)"},children:e.resultSummary}):null,f&&e.latestProgress?(0,r.jsx)("p",{style:{margin:"6px 0 0",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",fontSize:11,lineHeight:1.5,color:"var(--text-muted)",fontStyle:"italic"},children:e.latestProgress}):null,v||b.length>0?(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:12,paddingTop:12,borderTop:"1px solid var(--border)"},children:[v?(0,r.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),v.onClick()},style:{display:"inline-flex",alignItems:"center",gap:5,padding:"4px 10px",borderRadius:7,background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer",fontSize:11,fontWeight:600},children:[(0,r.jsx)(v.icon,{size:12,weight:"bold","aria-hidden":"true"}),v.label]}):null,(0,r.jsx)("div",{style:{flex:1}}),b.map(e=>(0,r.jsx)("button",{type:"button",title:e.label,"aria-label":e.label,onClick:t=>{t.stopPropagation(),e.onClick()},style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,borderRadius:999,background:"none",border:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",opacity:0,transition:"opacity 0.12s, background 0.12s, color 0.12s"},className:"task-card-secondary",onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(e.icon,{size:13,"aria-hidden":"true"})},e.label))]}):null]})}function cD({open:e,onOpenChange:t,task:o}){let{t:s}=(0,A.s)(),{refetch:i}=ck(),[a,l]=(0,n.useState)(""),[d,c]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{e&&(l(""),c(!1))},[e,o]),!e||!o)return null;let p=async()=>{if(!d){c(!0);try{await (0,sS.oQ)(o.id,o.projectRoot,"cancel",{reason:a.trim()||null}),t(!1),i()}catch(e){console.error("cancel failed",e)}finally{c(!1)}}};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:950,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(440px, calc(100vw - 48px))",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:s("tasks.cancelTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":s("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:"14px 16px 16px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,lineHeight:1.5,color:"var(--text-muted)"},children:s("tasks.cancelDescription")}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)"},children:s("tasks.cancelReasonLabel")}),(0,r.jsx)("textarea",{value:a,onChange:e=>l(e.target.value),placeholder:s("tasks.cancelReasonPlaceholder"),rows:3,autoFocus:!0,style:{width:"100%",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px",color:"var(--text)",fontSize:13,outline:"none",fontFamily:"inherit",resize:"vertical"}})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),disabled:d,style:{padding:"8px 14px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:s("tasks.cancelKeep")}),(0,r.jsx)("button",{type:"button",onClick:()=>void p(),disabled:d,style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:s("tasks.cancelSubmit")})]})]})]})})}function cA({open:e,onOpenChange:t,task:o}){let{t:s}=(0,A.s)(),{refetch:i}=ck(),[a,l]=(0,n.useState)(!0),[d,c]=(0,n.useState)(!1),p=o?.worktreePath!=null;if((0,n.useEffect)(()=>{if(!e||!o)return;c(!1);let t=!1;return(0,sS.CG)(o.projectRoot).then(e=>{t||l(e.deleteWorktreeDefault)}).catch(()=>{t||l(!0)}),()=>{t=!0}},[e,o]),!e||!o)return null;let u=async()=>{if(!d){c(!0);try{await (0,sS.ZX)(o.id,o.projectRoot,p&&a),t(!1),i()}catch(e){console.error("complete failed",e)}finally{c(!1)}}};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:950,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(440px, calc(100vw - 48px))",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:s("tasks.completeTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":s("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:"14px 16px 16px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,lineHeight:1.5,color:"var(--text-muted)"},children:s("tasks.completeDescription")}),p?(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:a,onChange:e=>l(e.target.checked),style:{accentColor:"var(--accent)"}}),s("tasks.completeDeleteWorktree")]}):null,(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),disabled:d,style:{padding:"8px 14px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:s("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void u(),disabled:d,style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:s("tasks.completeSubmit")})]})]})]})})}var cN=o(51285),cL=o(16894);function c$({open:e,onOpenChange:t,task:o,onViewSession:s,onMerge:i,onEdit:a,onCancel:l,onRetry:d,onRequeue:c,onComplete:p}){let{t:u}=(0,A.s)(),{refetch:g}=ck(),[f,x]=(0,n.useState)([]),[k,v]=(0,n.useState)([]),[b,w]=(0,n.useState)(null),[j,S]=(0,n.useState)(null),[R,z]=(0,n.useState)(!1),[I,M]=(0,n.useState)(!1),[E,W]=(0,n.useState)(""),[F,D]=(0,n.useState)(!1),[N,L]=(0,n.useState)(!1),[$,H]=(0,n.useState)(!1),O=o?.id??null,B=o?.projectRoot??null,U=(0,n.useCallback)(async()=>{if(null==O||null==B)return;let[e,t]=await Promise.all([(0,sS.HB)(B,O).catch(()=>[]),o?.worktreePath?(0,sS.JH)(B,O).then(e=>e.files).catch(()=>[]):Promise.resolve([])]);x(e),v(t)},[O,B,o?.worktreePath]);(0,n.useEffect)(()=>{if(!e||null==O)return;x([]),v([]),M(!1),W(""),U();let t=window.setInterval(()=>void U(),5e3);return()=>window.clearInterval(t)},[e,O,U]);let _=(0,n.useCallback)(async e=>{H(!0);try{await e()}catch(e){console.error("detail action failed",e)}finally{H(!1),g()}},[g]),q=(0,n.useCallback)(async e=>{if(null!=B&&null!=O){z(!0);try{let t=await (0,sS.h)(B,O,e);S(t.supported&&t.patch?t.patch:null)}catch{S(null)}finally{z(!1)}}},[B,O]),V=async()=>{null!=o&&null!=B&&(await _(()=>(0,sS.bH)(o.id,B,N)),t(!1))},K=async()=>{null!=o&&null!=B&&E.trim()&&(await _(()=>(0,sS.in)(o.id,B,E.trim())),M(!1),W(""))};if(!e||null==o||null==B)return null;let G=[];if(null==o.archivedAt)switch(o.status){case"todo":G.push({label:u("tasks.actionStart"),icon:cj.j,onClick:()=>void _(()=>(0,sS.oQ)(o.id,B,"start")),filled:!0}),G.push({label:u("tasks.actionEdit"),icon:n9.S,onClick:()=>a(o)});break;case"queued":case"preparing":case"running":case"awaiting_input":G.push({label:u("tasks.actionCancel"),icon:cM.k,onClick:()=>l(o),danger:!0});break;case"review":G.push({label:cC(o)?u("tasks.actionComplete"):u("tasks.actionMerge"),icon:cC(o)?m.J:cN.Y,onClick:()=>cC(o)?p(o):i(o),filled:!0}),G.push({label:u("tasks.actionReturn"),icon:ny.f,onClick:()=>M(!0)});break;case"failed":G.push({label:u("tasks.actionRetry"),icon:C.S,onClick:()=>d(o),filled:!0}),G.push({label:u("tasks.actionEdit"),icon:n9.S,onClick:()=>a(o)});break;case"done":G.push({label:u("tasks.actionArchive"),icon:P.T,onClick:()=>void _(()=>(0,sS.et)(o.id,B,!0))});break;case"canceled":G.push({label:u("tasks.actionRequeue"),icon:ny.f,onClick:()=>c(o),filled:!0})}else G.push({label:u("tasks.actionUnarchive"),icon:P.T,onClick:()=>void _(()=>(0,sS.et)(o.id,B,!1))});return null!=o.conversationId&&G.push({label:u("tasks.actionViewSession"),icon:nk.y,onClick:()=>s(o)}),(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:800,background:"rgba(0,0,0,0.35)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 90vw)",background:"var(--bg-panel)",borderLeft:"1px solid var(--border)",display:"flex",flexDirection:"column",boxShadow:"-8px 0 32px rgba(0,0,0,0.2)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12,padding:"16px 16px 0"},children:[(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("h3",{style:{margin:0,fontSize:15,fontWeight:600,lineHeight:1.4,overflowWrap:"break-word"},children:o.title}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6},children:[(0,r.jsx)(cE,{task:o}),o.workBranch?(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-muted)"},children:[(0,r.jsx)(y.Z,{size:12,"aria-hidden":"true"}),o.workBranch]}):null]})]}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":u("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex",flexShrink:0},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,padding:"14px 16px 0"},children:G.map(e=>{let t,o;return(0,r.jsxs)("button",{type:"button",onClick:e.onClick,disabled:$,style:(t=e.filled,o=e.danger,{display:"inline-flex",alignItems:"center",gap:5,padding:"7px 12px",borderRadius:8,fontSize:12,fontWeight:600,cursor:"pointer",background:t?"var(--accent)":o?"rgba(239,68,68,0.1)":"var(--bg-hover)",color:t?"#fff":o?"#dc2626":"var(--text)",border:t||o?"none":"1px solid var(--border)"}),children:[(0,r.jsx)(e.icon,{size:13,weight:"bold","aria-hidden":"true"}),e.label]},e.label)})}),I&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"12px 16px 0"},children:[(0,r.jsx)("textarea",{value:E,onChange:e=>W(e.target.value),placeholder:u("tasks.returnPlaceholder"),rows:3,style:{width:"100%",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px",color:"var(--text)",fontSize:12,resize:"vertical",fontFamily:"inherit"}}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[(0,r.jsx)("button",{type:"button",onClick:()=>M(!1),style:{padding:"6px 12px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:u("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void K(),disabled:!E.trim(),style:{padding:"6px 14px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:u("tasks.returnSubmit")})]})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"14px 16px 0",fontSize:12,color:"var(--text-muted)"},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",width:64},children:u("tasks.metaProject")}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)",fontSize:11},children:o.projectRoot})]}),o.createdAt?(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",width:64},children:u("tasks.metaCreated")}),(0,r.jsx)("span",{children:new Date(o.createdAt).toLocaleString()})]}):null,o.mergeCommit?(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",width:64},children:u("tasks.metaCommit")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11},children:o.mergeCommit})]}):null]}),k.length>0&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"14px 16px 0"},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:u("tasks.changedFiles")}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2,maxHeight:140,overflowY:"auto"},children:k.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>{var t;w(t=e.file),S(null),q(t)},style:{display:"flex",alignItems:"center",gap:8,textAlign:"left",padding:"4px 6px",borderRadius:6,background:"none",border:"none",color:"var(--text)",fontSize:12,cursor:"pointer"},children:[(0,r.jsx)(cL.o,{size:13,style:{flexShrink:0,color:"var(--text-muted)"},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)",fontSize:11},children:e.file}),(0,r.jsxs)("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"#059669",flexShrink:0},children:["+",e.additions]}),(0,r.jsxs)("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"#dc2626",flexShrink:0},children:["-",e.deletions]})]},e.file))})]}),null!=b&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 16px 0",minHeight:0,flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:u("tasks.diff")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:b}),(0,r.jsx)("button",{type:"button",onClick:()=>w(null),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:2,display:"flex"},children:(0,r.jsx)(h.X,{size:12,"aria-hidden":"true"})})]}),R?(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",padding:8},children:u("tasks.loading")}):j?(0,r.jsx)("pre",{style:{margin:0,maxHeight:200,overflow:"auto",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:10,fontSize:11,lineHeight:1.5,fontFamily:"var(--font-mono)",color:"var(--text-muted)",whiteSpace:"pre"},children:j.split("\n").map((e,t)=>{let o;return e.startsWith("+")&&!e.startsWith("+++")?o="#059669":e.startsWith("-")&&!e.startsWith("---")?o="#dc2626":e.startsWith("@@")&&(o="var(--accent)"),(0,r.jsx)("div",{style:{color:o},children:e||" "},t)})}):(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",padding:8},children:u("tasks.noDiff")})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"14px 16px 0",flex:1,minHeight:0},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:u("tasks.timeline")}),(0,r.jsx)("div",{style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:8},children:0===f.length?(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",padding:8},children:u("tasks.noEvents")}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[...f].reverse().map(e=>{var t;let o,n;return(0,r.jsxs)("div",{style:{display:"flex",gap:8,padding:"4px 6px",borderRadius:6,fontSize:11},children:[(0,r.jsx)("span",{style:{color:"var(--text-dim)",flexShrink:0,fontFamily:"var(--font-mono)",fontSize:10,paddingTop:1},children:new Date(e.createdAt).toLocaleTimeString()}),(0,r.jsx)("span",{style:{color:"var(--text)",flexShrink:0,fontWeight:500},children:(t=e.kind,(n=u(o=`tasks.event_${t}`))===o?t:n)}),e.payload?.feedback?(0,r.jsx)("span",{style:{color:"var(--text-muted)",fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(e.payload.feedback)}):null]},e.id)})})})]}),(0,r.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"10px 16px",borderTop:"1px solid var(--border)",flexShrink:0},children:F?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:N,onChange:e=>L(e.target.checked),style:{accentColor:"var(--accent)"}}),u("tasks.deleteWorktree")]}),(0,r.jsx)("button",{type:"button",onClick:()=>D(!1),style:{padding:"6px 12px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:u("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void V(),disabled:$,style:{padding:"6px 14px",borderRadius:8,background:"#dc2626",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:u("tasks.deleteConfirm")})]}):(0,r.jsxs)("button",{type:"button",onClick:()=>D(!0),style:{display:"inline-flex",alignItems:"center",gap:5,padding:"6px 12px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"#dc2626",fontSize:12,cursor:"pointer"},children:[(0,r.jsx)(T.l,{size:13,"aria-hidden":"true"}),u("tasks.delete")]})})]})})}var cH=o(17757);function cO({open:e,onOpenChange:t,task:o,defaultProject:s,projects:i,prefillTitle:a,prefillPrompt:l,onSubmit:d}){let{t:c}=(0,A.s)(),[p,u]=(0,n.useState)(""),[g,m]=(0,n.useState)(""),[f,x]=(0,n.useState)(""),[k,v]=(0,n.useState)([]),[y,b]=(0,n.useState)(""),[w,j]=(0,n.useState)(!1),S=(0,n.useRef)(!1);if((0,n.useEffect)(()=>{if(!e){S.current=!1;return}S.current||(S.current=!0,u(o?.projectRoot??s??i[0]??""),m(o?.title??a??""),x(o?.config?.prompt??l??""),(0,sS.VB)().then(v).catch(()=>void 0))},[e,o,s,i,a,l]),!e)return null;let C=async()=>{if(p&&g.trim()&&!w){j(!0);try{await d(p,g.trim(),{prompt:f.trim(),agentType:o?.config?.agentType??null,modelId:o?.config?.modelId??null,thinkingLevel:o?.config?.thinkingLevel??null}),t(!1)}catch(e){console.error("submit task failed",e)}finally{j(!1)}}},R=async()=>{if(y.trim()&&g.trim())try{await (0,sS.nY)({name:y.trim(),title:g.trim(),config:{prompt:f.trim()}}),b(""),(0,sS.VB)().then(v).catch(()=>void 0)}catch(e){console.error("save template failed",e)}},z=async e=>{try{await (0,sS.B_)(e),(0,sS.VB)().then(v).catch(()=>void 0)}catch(e){console.error("delete template failed",e)}},I={width:"100%",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px",color:"var(--text)",fontSize:13,outline:"none"};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:900,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(520px, calc(100vw - 48px))",maxHeight:"80vh",overflowY:"auto",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:o?c("tasks.editTitle"):c("tasks.newTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":c("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:"14px 16px 16px"},children:[k.length>0&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:c("tasks.templates")}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:k.map(e=>(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,borderRadius:999,background:"var(--bg-hover)",padding:"3px 8px",fontSize:11},children:[(0,r.jsx)("button",{type:"button",onClick:()=>{m(e.title),x(e.config?.prompt??"")},style:{background:"none",border:"none",cursor:"pointer",color:"var(--text)",fontSize:11,padding:0},children:e.name}),(0,r.jsx)("button",{type:"button",onClick:()=>void z(e.id),"aria-label":c("tasks.deleteTemplate"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-dim)",padding:0,display:"flex"},children:(0,r.jsx)(T.l,{size:10,"aria-hidden":"true"})})]},e.id))})]}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:500,color:"var(--text)"},children:c("tasks.fieldProject")}),(0,r.jsx)("select",{value:p,onChange:e=>u(e.target.value),style:I,children:i.map(e=>(0,r.jsx)("option",{value:e,children:e.split("/").filter(Boolean).pop()??e},e))})]}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:500,color:"var(--text)"},children:c("tasks.fieldTitle")}),(0,r.jsx)("input",{value:g,onChange:e=>m(e.target.value),placeholder:c("tasks.fieldTitlePlaceholder"),style:I,autoFocus:!0})]}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:500,color:"var(--text)"},children:c("tasks.fieldPrompt")}),(0,r.jsx)("textarea",{value:f,onChange:e=>x(e.target.value),placeholder:c("tasks.fieldPromptPlaceholder"),rows:6,style:{...I,resize:"vertical",fontFamily:"inherit",lineHeight:1.5}})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("input",{value:y,onChange:e=>b(e.target.value),placeholder:c("tasks.templateNamePlaceholder"),style:{...I,flex:1}}),(0,r.jsxs)("button",{type:"button",onClick:()=>void R(),disabled:!y.trim()||!g.trim(),style:{display:"inline-flex",alignItems:"center",gap:5,padding:"8px 12px",borderRadius:8,background:"var(--bg-hover)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:[(0,r.jsx)(cH.D,{size:13,"aria-hidden":"true"}),c("tasks.saveAsTemplate")]})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),style:{padding:"8px 14px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:c("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void C(),disabled:!p||!g.trim()||w,style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:c("tasks.save")})]})]})]})})}function cB({open:e,onOpenChange:t,task:o}){let{t:s}=(0,A.s)(),{refetch:i}=ck(),[a,l]=(0,n.useState)(!0),[d,c]=(0,n.useState)(""),[p,u]=(0,n.useState)(!0),[g,m]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{e&&o&&(l(!0),c(o.title),m(!1),(0,sS.CG)(o.projectRoot).then(e=>u(e.deleteWorktreeDefault)).catch(()=>u(!0)))},[e,o]),!e||!o)return null;let f=async()=>{if((a||d.trim())&&!g){m(!0);try{await (0,sS.oB)(o.id,o.projectRoot,a?null:d.trim(),p),t(!1),i()}catch(e){console.error("merge failed",e)}finally{m(!1)}}};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:950,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(440px, calc(100vw - 48px))",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:s("tasks.mergeTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":s("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:"14px 16px 16px"},children:[(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,cursor:"pointer"},children:[(0,r.jsx)("input",{type:"radio",checked:a,onChange:()=>l(!0),style:{accentColor:"var(--accent)"}}),s("tasks.mergeAutoMessage")]}),(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,cursor:"pointer"},children:[(0,r.jsx)("input",{type:"radio",checked:!a,onChange:()=>l(!1),style:{accentColor:"var(--accent)"}}),s("tasks.mergeManualMessage")]}),!a&&(0,r.jsx)("input",{value:d,onChange:e=>c(e.target.value),placeholder:s("tasks.mergeMessagePlaceholder"),style:{width:"100%",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px",color:"var(--text)",fontSize:13,outline:"none",fontFamily:"inherit"}}),(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:p,onChange:e=>u(e.target.checked),style:{accentColor:"var(--accent)"}}),s("tasks.mergeDeleteWorktree")]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),style:{padding:"8px 14px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:s("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void f(),disabled:!a&&!d.trim()||g,style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:s("tasks.mergeConfirm")})]})]})]})})}function cU({open:e,onOpenChange:t,task:o,kind:s}){let{t:i}=(0,A.s)(),{refetch:a}=ck(),[l,d]=(0,n.useState)(""),[c,p]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{e&&(d(""),p(!1))},[e,o]),!e||!o)return null;let u="retry"===s,g=async()=>{if(!c){p(!0);try{await (0,sS.oQ)(o.id,o.projectRoot,s,{note:l.trim()||null}),t(!1),a()}catch(e){console.error("restart failed",e)}finally{p(!1)}}};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:950,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(480px, calc(100vw - 48px))",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:i(u?"tasks.restartTitleRetry":"tasks.restartTitleRequeue")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":i("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:"14px 16px 16px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,lineHeight:1.5,color:"var(--text-muted)"},children:i("tasks.restartDescription")}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)"},children:i("tasks.actionAddNote")}),(0,r.jsx)("textarea",{value:l,onChange:e=>d(e.target.value),placeholder:i(u?"tasks.followUpPlaceholderRetry":"tasks.followUpPlaceholderRequeue"),rows:3,autoFocus:!0,style:{width:"100%",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px",color:"var(--text)",fontSize:13,outline:"none",fontFamily:"inherit",resize:"vertical"}})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),disabled:c,style:{padding:"8px 14px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:i("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void g(),disabled:c,style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:i(u?"tasks.actionRetry":"tasks.actionRequeue")})]})]})]})})}let c_=["work","retry","return","merge"];function cq({open:e,onOpenChange:t,projectRoot:o}){let{t:s}=(0,A.s)(),{projects:i}=ck(),[a,l]=(0,n.useState)(""),[d,c]=(0,n.useState)(()=>cT()),[p,u]=(0,n.useState)(!1),[g,m]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{if(!e)return;let t=o??i[0]??"";l(t),t&&(0,sS.Pf)(t).then(e=>{u(null!=e),c(e??cT())}).catch(()=>{u(!1),c(cT())})},[e,o,i]),!e)return null;let f=(e,t)=>{c(o=>({...o,[e]:t}))},x=async()=>{if(a&&!g){m(!0);try{await (0,sS.eA)(a,d),u(!0),t(!1)}catch(e){console.error("save settings failed",e)}finally{m(!1)}}},k=async()=>{if(a)try{await (0,sS.E)(a),u(!1),c(cT())}catch(e){console.error("reset settings failed",e)}},v={width:"100%",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"7px 10px",color:"var(--text)",fontSize:12,outline:"none",fontFamily:"inherit"},y={display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 0",borderBottom:"1px solid var(--border)"};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:960,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(560px, calc(100vw - 48px))",maxHeight:"82vh",overflowY:"auto",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:s("tasks.settingsTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":s("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:"14px 16px 16px"},children:[(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:500},children:s("tasks.settingsProject")}),(0,r.jsx)("select",{value:a,onChange:e=>l(e.target.value),style:v,children:i.map(e=>(0,r.jsx)("option",{value:e,children:e.split("/").filter(Boolean).pop()??e},e))})]}),a?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:y,children:[(0,r.jsx)("span",{style:{fontSize:12},children:s("tasks.settingsAutoProcess")}),(0,r.jsx)("input",{type:"checkbox",checked:d.autoProcess,onChange:e=>f("autoProcess",e.target.checked),style:{accentColor:"var(--accent)"}})]}),(0,r.jsxs)("div",{style:y,children:[(0,r.jsx)("span",{style:{fontSize:12},children:s("tasks.settingsMaxConcurrent")}),(0,r.jsx)("input",{type:"number",min:0,value:d.maxConcurrent,onChange:e=>f("maxConcurrent",Math.max(0,Number(e.target.value)||0)),style:{...v,width:90}})]}),(0,r.jsxs)("div",{style:y,children:[(0,r.jsx)("span",{style:{fontSize:12},children:s("tasks.settingsMergeStrategy")}),(0,r.jsxs)("select",{value:d.mergeStrategy,onChange:e=>f("mergeStrategy",e.target.value),style:{...v,width:140},children:[(0,r.jsx)("option",{value:"merge",children:s("tasks.mergeStrategyMerge")}),(0,r.jsx)("option",{value:"squash",children:s("tasks.mergeStrategySquash")})]})]}),(0,r.jsxs)("div",{style:y,children:[(0,r.jsx)("span",{style:{fontSize:12},children:s("tasks.settingsDeleteWorktree")}),(0,r.jsx)("input",{type:"checkbox",checked:d.deleteWorktreeDefault,onChange:e=>f("deleteWorktreeDefault",e.target.checked),style:{accentColor:"var(--accent)"}})]}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:12},children:s("tasks.settingsPreflightCommand")}),(0,r.jsx)("input",{value:d.preflightCommand??"",onChange:e=>f("preflightCommand",e.target.value||null),placeholder:s("tasks.settingsPreflightPlaceholder"),style:{...v,fontFamily:"var(--font-mono)",fontSize:11}})]}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:12},children:s("tasks.settingsInitCommand")}),(0,r.jsx)("input",{value:d.initCommand??"",onChange:e=>f("initCommand",e.target.value||null),placeholder:s("tasks.settingsInitPlaceholder"),style:{...v,fontFamily:"var(--font-mono)",fontSize:11}})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,paddingTop:4},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:500},children:s("tasks.settingsStagePrompts")}),c_.map(e=>(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-muted)"},children:s(`tasks.stage.${e}`)}),(0,r.jsx)("input",{value:d.stagePrompts?.[e]??"",onChange:t=>f("stagePrompts",{...d.stagePrompts??{},[e]:t.target.value}),style:{...v,fontSize:11}})]},e))]}),p&&(0,r.jsx)("button",{type:"button",onClick:()=>void k(),style:{alignSelf:"flex-start",padding:"6px 12px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text-muted)",fontSize:12,cursor:"pointer"},children:s("tasks.settingsReset")})]}):(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",padding:8},children:s("tasks.settingsNoProject")}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),style:{padding:"8px 14px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:s("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void x(),disabled:!a||g,style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:s("tasks.save")})]})]})]})})}function cV({open:e,onOpenChange:t,task:o}){let{t:s}=(0,A.s)();return((0,n.useEffect)(()=>{if(!e)return},[e,o]),e&&o)?(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:970,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(520px, calc(100vw - 48px))",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:s("tasks.sessionTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":s("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:"14px 16px 16px",fontSize:12},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:10},children:[(0,r.jsx)("span",{style:{color:"var(--text-muted)"},children:s("tasks.sessionId")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,overflowWrap:"anywhere"},children:o.conversationId??"—"})]}),o.sessionFile?(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:10},children:[(0,r.jsx)("span",{style:{color:"var(--text-muted)"},children:s("tasks.sessionFile")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,overflowWrap:"anywhere"},children:o.sessionFile})]}):null,(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.6},children:s("tasks.sessionHint")}),(0,r.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:4},children:(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:s("i18n.close")})})]})]})}):null}let cK="__all__",cG="pi-tasks-board-filter",cJ={showCanceled:!1,showArchived:!1},cY="pi:open-task-settings";function cX(){let{t:e}=(0,A.s)(),{attentionCount:t}=ck();return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,height:36,flexShrink:0,padding:"0 16px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,r.jsxs)("h1",{style:{margin:0,display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:600},children:[(0,r.jsx)(lu.x,{size:15,color:"var(--text-muted)","aria-hidden":"true"}),e("tasks.title"),(0,r.jsx)("span",{style:{borderRadius:999,background:"rgba(37,99,235,0.12)",color:"var(--accent)",padding:"1px 8px",fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Beta"})]}),t>0?(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,borderRadius:999,background:"rgba(239,68,68,0.12)",color:"#dc2626",padding:"1px 8px",fontSize:10,fontWeight:700},children:[t," ",e("tasks.attentionBadge")]}):null,(0,r.jsx)("div",{style:{flex:1}}),(0,r.jsxs)("button",{type:"button",onClick:()=>window.dispatchEvent(new Event(cY)),style:{display:"inline-flex",alignItems:"center",gap:5,height:26,padding:"0 10px",borderRadius:7,background:"none",border:"none",color:"var(--text-muted)",fontSize:12,cursor:"pointer"},title:e("tasks.settingsTitle"),children:[(0,r.jsx)(cb.O,{size:13,"aria-hidden":"true"}),e("tasks.settingsTitle")]})]})}function cZ({activeProject:e}){let{t}=(0,A.s)(),{tasks:s,projects:i,refetch:a}=ck(),[l,d]=(0,n.useState)(null),[c,u]=(0,n.useState)(()=>(function(){try{let e=window.localStorage.getItem(cG);if(e){let t=JSON.parse(e);return{showCanceled:t.showCanceled??!1,showArchived:t.showArchived??!1}}}catch{}return cJ})()),[h,g]=(0,n.useState)(!1);(0,n.useEffect)(()=>{try{window.localStorage.setItem(cG,JSON.stringify(c))}catch{}},[c]);let[m,f]=(0,n.useState)(null),[x,k]=(0,n.useState)(!1),y=(0,n.useRef)(null),b=(0,n.useRef)({x:0,y:0}),w=(0,n.useRef)(null),j=(0,n.useRef)(null),[S,C]=(0,n.useState)(null),T=(0,n.useRef)(null);T.current=S;let R=(0,n.useRef)(!1),z=(0,n.useRef)(!1),[I,M]=(0,n.useState)(()=>Date.now());(0,n.useEffect)(()=>{let e=window.setInterval(()=>M(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let[P,E]=(0,n.useState)(!1),[W,F]=(0,n.useState)(null),[D,N]=(0,n.useState)(null);(0,n.useEffect)(()=>{let e=()=>{let e,t=(e=nP,nP=null,e);t&&(F(null),N(t),E(!0))};return e(),window.addEventListener(nM,e),()=>window.removeEventListener(nM,e)},[]);let[L,$]=(0,n.useState)(null),[H,O]=(0,n.useState)(null),[B,U]=(0,n.useState)(!1),[_,q]=(0,n.useState)(null),[V,K]=(0,n.useState)(!1),[G,J]=(0,n.useState)(null),[Y,X]=(0,n.useState)("retry"),[Z,Q]=(0,n.useState)(!1),[ee,et]=(0,n.useState)(null),[eo,er]=(0,n.useState)(!1),[en,es]=(0,n.useState)(!1),[ei,ea]=(0,n.useState)(null),[el,ed]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=()=>es(!0);return window.addEventListener(cY,e),()=>window.removeEventListener(cY,e)},[]);let ec=(0,n.useMemo)(()=>null==l?s:s.filter(e=>e.projectRoot===l),[s,l]),ep=(0,n.useMemo)(()=>(function(e,t,o=!1){let r={todo:[],inProgress:[],attention:[],done:[]};for(let n of e)("canceled"!==n.status||t)&&(null==n.archivedAt||o)&&r[function(e){switch(e){case"todo":case"queued":return"todo";case"preparing":case"running":return"inProgress";case"awaiting_input":case"review":case"merging":case"failed":return"attention";case"done":case"canceled":return"done"}}(n.status)].push(n);for(let e of cS)r[e].sort((e,t)=>(t.updatedAt??"").localeCompare(e.updatedAt??""));return r})(ec,c.showCanceled,c.showArchived),[ec,c]),eu=(0,n.useMemo)(()=>{let e=ep.todo;if(null==S)return e;let t=new Map(e.map(e=>[e.id,e])),o=S.flatMap(e=>t.get(e)??[]);for(let t of e)S.includes(t.id)||o.push(t);return o},[ep.todo,S]),eh=(0,n.useMemo)(()=>s.find(e=>e.id===L)??null,[s,L]),eg=(0,n.useMemo)(()=>s.find(e=>e.id===ei)??null,[s,ei]),em=(0,n.useCallback)(async e=>{try{await e()}catch(e){console.error("task action failed",e)}finally{a()}},[a]),ef=(0,n.useCallback)(e=>{null!=e.conversationId&&(ea(e.id),ed(!0))},[ea,ed]),ex=(0,n.useCallback)(e=>{O(e),U(!0)},[O,U]),ek=(0,n.useCallback)(()=>{F(null),E(!0)},[F,E]),ev=(0,n.useCallback)((e,t)=>{let o=w.current,r=y.current;o&&r&&(o.style.transform=`translate3d(${e-r.dx}px, ${t-r.dy}px, 0)`)},[]),ey=e=>{let t=e.currentTarget.getBoundingClientRect();y.current={dx:e.clientX-t.left,dy:e.clientY-t.top,width:t.width}},eb=(0,n.useCallback)(e=>{if(f(null),k(!1),e){R.current=!1;return}requestAnimationFrame(()=>{R.current=!1})},[f,k]),ew=(0,n.useCallback)(()=>{z.current=!0,C(null),eb(!0)},[eb,C]);(0,n.useEffect)(()=>{if(!m)return;let e=()=>{document.hidden&&ew()};return window.addEventListener("blur",ew),document.addEventListener("visibilitychange",e),()=>{window.removeEventListener("blur",ew),document.removeEventListener("visibilitychange",e)}},[m,ew]),(0,n.useEffect)(()=>{m&&!eu.some(e=>e.id===m.task.id)&&ew()},[m,eu,ew]);let ej=(0,n.useCallback)((e,t,o)=>{if(z.current){eb(!0),C(null);return}let r=j.current?.getBoundingClientRect(),n=null!=r&&t>=r.left&&t<=r.right&&o>=r.top&&o<=r.bottom;if(eb(!1),n){C(null);let t=s.find(t=>t.id===e.id);t?.status==="todo"&&null!=l&&em(()=>(0,sS.oQ)(e.id,e.projectRoot,"start"));return}let i=T.current;null!=l&&null!=i&&(async()=>{try{await (0,sS.Lu)(l,i)}catch(e){console.error("reorder failed",e)}await a(),C(null)})()},[em,eb,l,a,s]),eS=(0,n.useCallback)(()=>{em(async()=>{let e=await (0,sS.a5)(l);e>0&&console.log(`started ${e} tasks`)})},[em,l]),eC=(0,n.useCallback)(()=>{let e=ep.done.filter(e=>null==e.archivedAt);0!==e.length&&em(()=>Promise.all(e.map(e=>(0,sS.et)(e.id,e.projectRoot,!0))))},[em,ep.done]),eT=+(c.showCanceled!==cJ.showCanceled)+ +(c.showArchived!==cJ.showArchived),eR=s.length>0,ez=(0,n.useMemo)(()=>{let t=new Set(i);return e&&t.add(e),[...t].sort()},[i,e]),eI=(0,n.useMemo)(()=>{let e=new Map;for(let t of ez)e.set(t,t.split("/").filter(Boolean).pop()??t);return e},[ez]);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[eR&&(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8,padding:"14px 16px 8px"},children:[(0,r.jsxs)("select",{value:l??cK,onChange:e=>d(e.target.value===cK?null:e.target.value),style:{height:30,borderRadius:999,padding:"0 10px",background:"var(--bg-panel)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontWeight:500,cursor:"pointer",maxWidth:"14rem"},"aria-label":t("tasks.allFolders"),children:[(0,r.jsx)("option",{value:cK,children:t("tasks.allFolders")}),ez.map(e=>(0,r.jsx)("option",{value:e,children:eI.get(e)??e},e))]}),(0,r.jsxs)("div",{style:{position:"relative"},children:[(0,r.jsxs)("button",{type:"button",onClick:()=>g(e=>!e),style:{display:"inline-flex",alignItems:"center",gap:6,height:30,borderRadius:999,padding:"0 12px",background:"var(--bg-panel)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontWeight:500,cursor:"pointer"},children:[(0,r.jsx)(cw.n,{size:13,"aria-hidden":"true"}),t("tasks.filter"),eT>0?(0,r.jsx)("span",{style:{borderRadius:999,background:"rgba(37,99,235,0.12)",color:"var(--accent)",padding:"1px 6px",fontSize:10,fontWeight:700},children:eT}):null]}),h&&(0,r.jsx)("div",{style:{position:"absolute",top:34,left:0,zIndex:50,width:200,borderRadius:12,padding:6,background:"var(--bg-panel)",border:"1px solid var(--border)",boxShadow:"0 8px 24px rgba(0,0,0,0.16)"},children:[["showCanceled",t("tasks.showCanceled")],["showArchived",t("tasks.showArchived")]].map(([e,t])=>(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:8,cursor:"pointer",fontSize:12},children:[(0,r.jsx)("input",{type:"checkbox",checked:c[e],onChange:t=>u(o=>({...o,[e]:t.target.checked})),style:{accentColor:"var(--accent)"}}),t]},e))})]}),(0,r.jsx)("div",{style:{flex:1}}),(0,r.jsxs)("button",{type:"button",onClick:eS,style:{display:"inline-flex",alignItems:"center",gap:6,height:30,borderRadius:999,padding:"0 12px",background:"none",border:"none",color:"var(--text)",fontSize:12,cursor:"pointer"},title:t("tasks.startAll"),children:[(0,r.jsx)(cj.j,{size:13,"aria-hidden":"true"}),t("tasks.startAll")]}),(0,r.jsxs)("button",{type:"button",onClick:ek,style:{display:"inline-flex",alignItems:"center",gap:6,height:30,borderRadius:999,padding:"0 14px",background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:[(0,r.jsx)(v.F,{size:13,weight:"bold","aria-hidden":"true"}),t("tasks.new")]})]}),eR?(0,r.jsx)("div",{style:{flex:1,minHeight:0,overflowX:"auto"},children:(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:16,minWidth:"56rem",height:"100%",padding:"4px 16px 16px"},children:cR.map(e=>{let o="todo"===e?eu:ep[e],n=cz[e],s=e=>(0,r.jsx)(cF,{task:e,folderName:e.projectRoot?eI.get(e.projectRoot)??null:null,now:I,onOpen:()=>{R.current||$(e.id)},onStart:()=>void em(()=>(0,sS.oQ)(e.id,e.projectRoot,"start")),onCancel:()=>{q(e),K(!0)},onRetry:()=>{J(e),X("retry"),Q(!0)},onRequeue:()=>{J(e),X("requeue"),Q(!0)},onViewSession:()=>ef(e),onMerge:()=>{cC(e)?(et(e),er(!0)):ex(e)},onArchive:()=>void em(()=>(0,sS.et)(e.id,e.projectRoot,null==e.archivedAt)),onEdit:()=>{F(e),E(!0)}},e.id);return(0,r.jsxs)("div",{ref:"inProgress"===e?j:void 0,style:{display:"flex",flexDirection:"column",minHeight:0,gap:8},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,height:24,flexShrink:0,padding:"0 2px"},children:[(0,r.jsx)("span",{style:{width:3,height:14,borderRadius:999,background:n.marker,flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("h2",{style:{fontSize:12,fontWeight:600,color:"var(--text)"},children:t(`tasks.col${e[0].toUpperCase()}${e.slice(1)}`)}),(0,r.jsx)("span",{style:{borderRadius:999,background:"var(--bg-hover)",padding:"1px 8px",fontSize:10,fontWeight:600,color:"var(--text-muted)"},children:o.length}),(0,r.jsx)("div",{style:{flex:1}}),"done"===e&&ep.done.some(e=>null==e.archivedAt)?(0,r.jsx)("button",{type:"button",onClick:eC,style:{background:"none",border:"none",cursor:"pointer",fontSize:11,color:"var(--text-muted)",padding:"2px 6px",borderRadius:6},children:t("tasks.archiveAllDone")}):null]}),0===o.length?(0,r.jsx)("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:4,borderRadius:12,border:"1px dashed var(--border)",padding:16,textAlign:"center",..."inProgress"===e&&m?x?{borderColor:"var(--accent)",background:"rgba(37,99,235,0.08)"}:{borderColor:"var(--accent)"}:{}},children:(0,r.jsx)("p",{style:{fontSize:12,color:"var(--text-muted)"},children:t(`tasks.emptyCol${e[0].toUpperCase()}${e.slice(1)}`)})}):(0,r.jsx)("div",{style:{flex:1,minHeight:0,overflowY:"auto",borderRadius:12,transition:"background 0.15s, box-shadow 0.15s",..."inProgress"===e&&m?x?{background:"rgba(37,99,235,0.06)",boxShadow:"inset 0 0 0 2px var(--accent)"}:{boxShadow:"inset 0 0 0 1px rgba(37,99,235,0.25)"}:{}},children:(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:16,paddingBottom:4},children:o.map(t=>"todo"===e?(0,r.jsx)("div",{draggable:!0,onDragStart:e=>{var o,r;e.dataTransfer.effectAllowed="move",o=e.clientX,r=e.clientY,R.current=!0,z.current=!1,b.current={x:o,y:r},f({task:t,width:y.current?.width??280})},onDrag:e=>{var t,o;let r,n;return b.current={x:t=e.clientX,y:o=e.clientY},ev(t,o),void((n=null!=(r=j.current?.getBoundingClientRect())&&t>=r.left&&t<=r.right&&o>=r.top&&o<=r.bottom)!==x&&k(n))},onDragEnd:e=>ej(t,e.clientX,e.clientY),onPointerDown:ey,style:{cursor:"grab",opacity:m?.task.id===t.id?.4:1},children:s(t)},t.id):(0,r.jsx)("div",{children:s(t)},t.id))})})]},e)})})}):(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,padding:32,textAlign:"center"},children:[(0,r.jsx)(lu.x,{size:40,color:"var(--text-dim)",opacity:.4,"aria-hidden":"true"}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("p",{style:{fontSize:14,fontWeight:500,color:"var(--text)"},children:t("tasks.empty")}),(0,r.jsx)("p",{style:{maxWidth:320,fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:t("tasks.emptyHint")})]}),(0,r.jsxs)("button",{type:"button",onClick:ek,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 14px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:[(0,r.jsx)(v.F,{size:13,weight:"bold","aria-hidden":"true"}),t("tasks.new")]})]}),(0,r.jsx)(cO,{open:P,onOpenChange:E,task:W,defaultProject:D?.projectRoot??l??e??null,projects:ez,prefillTitle:D?D.text.slice(0,80):void 0,prefillPrompt:D?D.text:void 0,onSubmit:async(e,t,r)=>{await em(async()=>{let{createTaskApi:n}=await Promise.resolve().then(o.bind(o,23084)),{updateTaskApi:s}=await Promise.resolve().then(o.bind(o,23084));W?await s(W.id,e,{title:t,config:r}):await n({projectRoot:e,title:t,config:r})}),E(!1),N(null)}}),(0,r.jsx)(c$,{open:null!=L,onOpenChange:e=>{e||$(null)},task:eh,onViewSession:ef,onMerge:ex,onEdit:e=>{F(e),E(!0)},onCancel:e=>{q(e),K(!0)},onRetry:e=>{J(e),X("retry"),Q(!0)},onRequeue:e=>{J(e),X("requeue"),Q(!0)},onComplete:e=>{et(e),er(!0)}}),(0,r.jsx)(cB,{open:B,onOpenChange:U,task:H}),(0,r.jsx)(cD,{open:V,onOpenChange:K,task:_}),(0,r.jsx)(cU,{open:Z,onOpenChange:Q,task:G,kind:Y}),(0,r.jsx)(cA,{open:eo,onOpenChange:er,task:ee}),(0,r.jsx)(cV,{open:el&&null!=eg,onOpenChange:ed,task:eg}),(0,r.jsx)(cq,{open:en,onOpenChange:es,projectRoot:l}),m?(0,p.createPortal)((0,r.jsx)("div",{ref:w,style:{position:"fixed",left:0,top:0,zIndex:999,pointerEvents:"none",width:m.width,willChange:"transform"},"aria-hidden":"true",children:(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8,borderRadius:12,border:x?"1px solid var(--accent)":"1px solid var(--border)",background:"var(--bg-panel)",padding:12,boxShadow:"0 8px 24px rgba(0,0,0,0.2)",transform:"rotate(-1deg)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8},children:[(0,r.jsx)("span",{style:{minWidth:0,overflowWrap:"break-word",fontSize:13,fontWeight:500},children:m.task.title}),(0,r.jsx)(cE,{task:m.task})]}),x?(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,color:"var(--accent)"},children:[(0,r.jsx)(cj.j,{size:11,weight:"bold","aria-hidden":"true"}),t("tasks.dropToStart")]}):null]})}),document.body):null]})}var cQ=o(62235),c0=o(1022);function c1(){return!!window.__TAURI_INTERNALS__}let c2=null;function c4(){return c2||(c2=o.e(8518).then(o.bind(o,38518)).then(e=>e.getCurrentWindow())),c2}async function c6(e){let t=await c4();await e(t)}async function c8(){await c6(e=>e.minimize())}async function c5(){await c6(e=>e.toggleMaximize())}async function c3(){await c6(e=>e.startDragging())}async function c7(){await c6(e=>e.close())}async function c9(){return(await c4()).isMaximized()}function pe(){let[e,t]=(0,n.useState)(null);return(0,n.useEffect)(()=>{c1()&&t(function(){if("u"<typeof navigator)return null;let e=navigator.platform||"";return/mac/i.test(e)?"macos":/win/i.test(e)?"windows":/linux/i.test(e)?"linux":null}())},[]),{platform:e,isDesktop:null!==e,isMacOS:"macos"===e,dragRegionProps:e?{"data-tauri-drag-region":!0}:{}}}let pt="pi-web-island-pos";function po(e,t,o,r,n,s){return{x:Math.min(Math.max(0,e),Math.max(0,o-n)),y:Math.min(Math.max(0,t),Math.max(0,r-s))}}let pr={display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",borderRadius:7,transition:"background 0.12s, color 0.12s"};function pn({onRefreshSession:e}={}){let{t:t}=(0,A.s)(),{isDark:o}=o9(),{isDesktop:s,isMacOS:i}=pe(),a=s&&!i,[l,d]=(0,n.useState)(!1),[c,p]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),g=(0,n.useRef)(null),m=(0,n.useRef)(null);(0,n.useEffect)(()=>{a&&c4().then(()=>void 0,e=>{throw c2=null,e}).catch(e=>{console.error("[DynamicIsland] window API preload failed:",e)})},[a]);let f=(0,n.useCallback)(e=>{e().catch(e=>{console.error("[DynamicIsland] window command failed:",e),p(String(e)),window.setTimeout(()=>p(null),4e3)})},[]),x=(0,n.useCallback)(()=>{window.location.reload()},[]);(0,n.useEffect)(()=>{if(!c1()||!a)return;let e=()=>{c9().then(d)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a]),(0,n.useEffect)(()=>{if(a)try{let e=localStorage.getItem(pt);if(e){let t=JSON.parse(e);"number"==typeof t.x&&"number"==typeof t.y&&h(po(t.x,t.y,window.innerWidth,window.innerHeight,168,34))}}catch{}},[a]),(0,n.useEffect)(()=>{if(a&&u)try{localStorage.setItem(pt,JSON.stringify(u))}catch{}},[u,a]);let[k,v]=(0,n.useState)(0);(0,n.useEffect)(()=>{if(!a)return;let e=()=>{v(window.innerWidth),h(e=>e?po(e.x,e.y,window.innerWidth,window.innerHeight,168,34):e)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a]);let y=(0,n.useCallback)(e=>{if(0!==e.button||e.target.closest?.("[data-island-btn]"))return;let t=g.current;if(!t)return;let o=t.getBoundingClientRect();m.current={startX:e.clientX,startY:e.clientY,origX:o.left,origY:o.top},e.currentTarget.setPointerCapture(e.pointerId)},[]),b=(0,n.useCallback)(e=>{let t=m.current;if(!t)return;let o=e.clientX-t.startX,r=e.clientY-t.startY;h(po(t.origX+o,t.origY+r,window.innerWidth,window.innerHeight,168,34))},[]),w=(0,n.useCallback)(e=>{m.current=null;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}},[]),j=(0,n.useCallback)(()=>c5().then(()=>{d(e=>!e)}),[]),S=(0,n.useCallback)(e=>{if(!m.current&&!e.target.closest?.("[data-island-btn]")){h(null);try{localStorage.removeItem(pt)}catch{}}},[]);if(!a)return null;let T=k||window.innerWidth,R=null!==u?u.x:Math.max(0,T-168-14);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{ref:g,role:"toolbar","aria-label":t("desktop.islandLabel"),title:t("desktop.islandResetHint"),onPointerDown:y,onPointerMove:b,onPointerUp:w,onPointerCancel:w,onDoubleClick:S,onMouseDown:e=>e.stopPropagation(),onDoubleClickCapture:e=>e.stopPropagation(),style:{position:"fixed",top:null!==u?u.y:100,left:R,zIndex:700,display:"flex",alignItems:"center",gap:1,padding:"3px 5px",borderRadius:999,background:"color-mix(in srgb, var(--bg-panel) 88%, transparent)",border:"1px solid var(--border)",boxShadow:o?"0 6px 24px rgba(0,0,0,0.45)":"0 6px 20px rgba(0,0,0,0.12)",cursor:"grab",userSelect:"none",touchAction:"none"},children:[(0,r.jsx)("span",{"data-island-grip":!0,"aria-hidden":"true",title:t("desktop.islandDrag"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:12,height:26,flexShrink:0,marginRight:2,color:"var(--text-dim)",cursor:"grab"},children:(0,r.jsxs)("svg",{width:"6",height:"14",viewBox:"0 0 6 14",fill:"currentColor","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"1.5",cy:"2",r:"1.2"}),(0,r.jsx)("circle",{cx:"4.5",cy:"2",r:"1.2"}),(0,r.jsx)("circle",{cx:"1.5",cy:"7",r:"1.2"}),(0,r.jsx)("circle",{cx:"4.5",cy:"7",r:"1.2"}),(0,r.jsx)("circle",{cx:"1.5",cy:"12",r:"1.2"}),(0,r.jsx)("circle",{cx:"4.5",cy:"12",r:"1.2"})]})}),e&&(0,r.jsx)("button",{type:"button","data-island-btn":!0,"aria-label":t("desktop.refreshSession"),title:t("desktop.refreshSession"),onClick:()=>{try{e()}catch(e){console.error("[DynamicIsland] refresh session failed:",e)}},style:pr,onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(c0.P,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button","data-island-btn":!0,"aria-label":t("desktop.reloadPage"),title:t("desktop.reloadPage"),onClick:x,style:pr,onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(C.S,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("span",{"aria-hidden":"true",style:{width:1,height:18,flexShrink:0,background:"var(--border)",margin:"0 3px"}}),(0,r.jsx)("button",{type:"button","data-island-btn":!0,"aria-label":t("desktop.minimize"),title:t("desktop.minimize"),onClick:()=>f(c8),style:pr,onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1",children:(0,r.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})})}),(0,r.jsx)("button",{type:"button","data-island-btn":!0,"aria-label":t(l?"desktop.restore":"desktop.maximize"),title:t(l?"desktop.restore":"desktop.maximize"),onClick:()=>f(j),style:pr,onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:l?(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,r.jsx)("rect",{x:"2",y:"0.5",width:"7.5",height:"7.5"}),(0,r.jsx)("path",{d:"M0.5 2.5 V9.5 H7.5"})]}):(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1",children:(0,r.jsx)("rect",{x:"0.5",y:"0.5",width:"9",height:"9"})})}),(0,r.jsx)("button",{type:"button","data-island-btn":!0,"aria-label":t("desktop.close"),title:t("desktop.close"),onClick:()=>f(c7),style:pr,onMouseEnter:e=>{e.currentTarget.style.background="#e81123",e.currentTarget.style.color="#fff"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,r.jsx)("line",{x1:"0",y1:"0",x2:"10",y2:"10"}),(0,r.jsx)("line",{x1:"10",y1:"0",x2:"0",y2:"10"})]})})]}),c&&(0,r.jsx)("div",{role:"alert",style:{position:"fixed",top:(null!==u?u.y:100)+34+6,left:R,zIndex:700,maxWidth:280,padding:"5px 10px",borderRadius:8,background:"var(--bg-panel)",border:"1px solid var(--status-error, #f85149)",color:"var(--status-error, #f85149)",fontSize:11,lineHeight:1.5,wordBreak:"break-all",boxShadow:o?"0 6px 24px rgba(0,0,0,0.45)":"0 6px 20px rgba(0,0,0,0.12)",pointerEvents:"none"},children:c})]})}function ps(){try{return window.localStorage}catch{return null}}let pi="pi-web:desktop-server-hint-seen";function pa(e=ps()){if(e)try{e.setItem(pi,"1")}catch{}}function pl(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=!1;try{e=new URLSearchParams(window.location.search).has("piweb_connected")}catch{e=!1}e&&function(e=ps()){if(!e)return!1;try{return"1"!==e.getItem(pi)}catch{return!1}}()&&o(!0)},[]);let s=(0,n.useCallback)(()=>{pa(),o(!1)},[]),i=(0,n.useCallback)(()=>{pa(),o(!1),window.location.href="piweb-switch://manage"},[]);return t?(0,r.jsxs)("div",{role:"status",style:{position:"fixed",top:56,right:16,zIndex:700,width:288,padding:"14px 16px 14px",borderRadius:12,background:"var(--bg-panel)",border:"1px solid var(--border)",boxShadow:"0 12px 36px rgba(0,0,0,0.32)",color:"var(--text)"},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",top:-6,right:28,width:10,height:10,background:"var(--bg-panel)",borderTop:"1px solid var(--border)",borderLeft:"1px solid var(--border)",transform:"rotate(45deg)"}}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[(0,r.jsx)(a_.X,{size:18,color:"var(--accent)",style:{flexShrink:0,marginTop:1}}),(0,r.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,r.jsx)("div",{style:{fontSize:13.5,fontWeight:600,lineHeight:1.45},children:e("desktop.serverHintTitle")}),(0,r.jsx)("p",{style:{margin:"6px 0 0",fontSize:12.5,lineHeight:1.65,color:"var(--text-muted)"},children:e("desktop.serverHintBody")})]}),(0,r.jsx)("button",{type:"button",onClick:s,"aria-label":e("desktop.serverHintDismiss"),title:e("desktop.serverHintDismiss"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,flexShrink:0,background:"none",border:"none",cursor:"pointer",color:"var(--text-dim)"},children:(0,r.jsx)(h.X,{size:14,"aria-hidden":"true"})})]}),(0,r.jsx)("button",{type:"button",onClick:i,style:{marginTop:12,width:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 12px",borderRadius:9,background:"var(--accent)",border:"none",color:"#fff",fontSize:13,fontWeight:600,cursor:"pointer"},children:e("desktop.serverHintAction")})]}):null}function pd({isDark:e,toggleTheme:t,translate:o}){let[s,i]=(0,n.useState)(!1);(0,n.useEffect)(()=>{i(!0)},[]);let a=o(s?e?"desktop.switchToLight":"desktop.switchToDark":"desktop.switchToLight");return(0,r.jsx)("button",{className:"app-no-drag",suppressHydrationWarning:!0,onClick:e=>{let o=e.currentTarget.getBoundingClientRect();t({x:o.left+o.width/2,y:o.top+o.height/2})},title:a,"aria-label":a,"aria-pressed":!s||e,style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:s?e?(0,r.jsx)(lo.b,{size:16,"aria-hidden":"true"}):(0,r.jsx)(lt.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(lo.b,{size:16,"aria-hidden":"true"})})}function pc({topBarRef:e,sidebarOpen:t,onSidebarToggle:o,isDark:s,toggleTheme:i,isMobile:a,showTasks:l,tasksBoardEnabled:d,onToggleTasks:c,systemPrompt:p,activeTopPanel:u,topPanelPos:h,sessionStats:g,selectedSession:f,contextUsage:x,copiedSessionField:k,onCopySessionField:v,rightPanelOpen:y,onToggleFilePanel:b,onRefreshSession:j,onOpenSettings:S,sessionTitle:T,onWorkspaceControlsHostChange:R,onTitleRightHostChange:z,desktopChrome:I,windowDrag:M}){let P,E,W,F,D,N,L,$,H,O,B,{t:U}=(0,A.s)(),[_,q]=(0,n.useState)(!1),[V,K]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{try{K(new URLSearchParams(window.location.search).has("piweb_connected"))}catch{K(!1)}},[]),(0,r.jsxs)(r.Fragment,{children:[V&&(0,r.jsx)(pl,{}),(0,r.jsxs)("div",{ref:e,className:"app-title-bar",...I?.dragRegionProps,...M,style:{display:"flex",alignItems:"center",flexShrink:0,borderBottom:"1px solid var(--border)",height:48,background:"var(--bg-panel)",position:"relative",zIndex:600,paddingLeft:76*!!I?.isMacOS},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",minWidth:0,height:"100%",flex:"0 1 auto",position:"relative",zIndex:1},children:[(0,r.jsx)("button",{className:"app-no-drag",onClick:o,title:t?U("desktop.hideSidebar"):U("desktop.showSidebar"),"aria-label":t?U("desktop.hideSidebar"):U("desktop.showSidebar"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:t?(0,r.jsx)(cQ.V,{size:16,"aria-hidden":"true"}):(0,r.jsx)(w.B,{size:16,"aria-hidden":"true"})}),(0,r.jsx)("div",{className:"app-no-drag",ref:R,style:{flex:"0 1 auto",minWidth:0,maxWidth:"min(60vw, 820px)",height:"100%",display:"flex",alignItems:"center",padding:"0 8px 0 0",overflow:"visible"}})]}),(0,r.jsxs)("div",{className:"app-title-drag",style:{position:"absolute",left:"var(--pi-titlebar-sidebar-offset, 0px)",right:0,top:0,bottom:0,minWidth:0,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 12px",overflow:"hidden",userSelect:"none"},children:[T&&(0,r.jsx)("button",{type:"button",onClick:()=>{a&&q(!0)},title:a?T:void 0,style:{display:"block",flex:"0 1 auto",minWidth:0,maxWidth:"calc(100% - 320px)",fontSize:12,fontWeight:500,color:"var(--text-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",background:"none",border:"none",cursor:"pointer",padding:"2px 6px",borderRadius:5},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:T}),(0,r.jsx)("div",{className:"app-no-drag",ref:z,style:{flexShrink:0,display:"flex",alignItems:"center",marginLeft:4}})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:3,minWidth:0,height:"100%",flexShrink:1,overflow:"hidden",marginLeft:"auto",position:"relative",zIndex:1},children:[!a&&d&&(0,r.jsx)("button",{className:"app-no-drag",onClick:c,title:l?U("desktop.hideTaskBoard"):U("desktop.showTaskBoard"),"aria-label":l?U("desktop.hideTaskBoard"):U("desktop.showTaskBoard"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:l?"var(--bg-selected)":"none",border:"none",color:l?"var(--text)":"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background=l?"var(--bg-selected)":"none",e.currentTarget.style.color=l?"var(--text)":"var(--text-muted)"},children:(0,r.jsx)(lu.x,{size:16,"aria-hidden":"true"})}),(0,r.jsx)("button",{className:"app-no-drag",onClick:b,title:y?U("desktop.hideFilePanel"):U("desktop.showFilePanel"),"aria-label":y?U("desktop.hideFilePanel"):U("desktop.showFilePanel"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:y?"var(--bg-selected)":"none",border:"none",color:y?"var(--text)":"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background=y?"var(--bg-selected)":"none",e.currentTarget.style.color=y?"var(--text)":"var(--text-muted)"},children:(0,r.jsx)(cQ.V,{size:16,"aria-hidden":"true",style:{transform:"scaleX(-1)"}})}),(0,r.jsx)(pd,{isDark:s,toggleTheme:i,translate:U}),V&&(0,r.jsx)("button",{className:"app-no-drag",type:"button",onClick:()=>{window.location.href="piweb-switch://manage"},title:U("desktop.serverSwitch"),"aria-label":U("desktop.serverSwitch"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(a_.X,{size:16,"aria-hidden":"true"})}),!V&&(0,r.jsx)("button",{className:"app-no-drag",type:"button",onClick:j,title:U("desktop.refreshSession"),"aria-label":U("desktop.refreshSession"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(C.S,{size:16,"aria-hidden":"true"})}),(0,r.jsx)("button",{className:"app-no-drag",type:"button",onClick:S,title:U("desktop.settings"),"aria-label":U("desktop.settings"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(cb.O,{size:16,"aria-hidden":"true"})})]})]}),(0,r.jsx)(pn,{onRefreshSession:j}),u&&h&&(0,r.jsxs)("div",{style:{position:"fixed",top:h.top,left:h.left,width:h.width,maxHeight:`calc(100dvh - ${h.top}px)`,overflowY:"auto",zIndex:500},children:["system"===u&&(0,r.jsx)("div",{style:{background:"var(--bg-panel)",borderBottom:"1px solid var(--border)"},children:p?(0,r.jsx)("div",{style:{maxHeight:"min(600px, 75vh)",overflowY:"auto",padding:"12px 16px",color:"var(--text-muted)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap",fontFamily:"var(--font-mono)"},children:p}):""===p?(0,r.jsx)("div",{style:{padding:"10px 16px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:"System prompt is empty (tools are disabled)"}):(0,r.jsx)("div",{style:{padding:"10px 16px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:"Send a message to load the system prompt"})}),"session"===u&&(0,r.jsx)("div",{style:{background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",boxShadow:"0 10px 28px rgba(0,0,0,0.10)",padding:"12px 16px"},children:g?(P=[...g.sessionName?[{label:U("desktop.name"),value:g.sessionName,copyField:null}]:[],{label:U("desktop.sessionInfoFile"),value:g.sessionFile??U("desktop.sessionInfoInMemory"),copyField:"file"},{label:U("desktop.sessionInfoId"),value:g.sessionId,copyField:"id"}],E=[[U("desktop.sessionInfoUser"),g.userMessages.toLocaleString()],[U("desktop.sessionInfoAssistant"),g.assistantMessages.toLocaleString()],[U("desktop.sessionInfoToolCalls"),g.toolCalls.toLocaleString()],[U("desktop.sessionInfoToolResults"),g.toolResults.toLocaleString()],[U("desktop.sessionInfoTotal"),g.totalMessages.toLocaleString()]],W=[[U("desktop.sessionInfoInput"),g.tokens.input.toLocaleString()],[U("desktop.sessionInfoOutput"),g.tokens.output.toLocaleString()],...g.tokens.cacheRead>0?[[U("desktop.sessionInfoCacheRead"),g.tokens.cacheRead.toLocaleString()]]:[],...g.tokens.cacheWrite>0?[[U("desktop.sessionInfoCacheWrite"),g.tokens.cacheWrite.toLocaleString()]]:[],[U("desktop.sessionInfoTotal"),g.tokens.total.toLocaleString()]],F=x??g.contextUsage,N=[...g.cost>0?[[U("desktop.sessionInfoCost"),`$${g.cost.toFixed(4)}`]]:[],...F?.contextWindow?[[U("desktop.sessionInfoContext"),`${null!==F.percent?`${F.percent.toFixed(1)}%`:"?"} / ${(D=F.contextWindow)>=1e6?`${(D/1e6).toFixed(1)}M`:D>=1e3?`${(D/1e3).toFixed(0)}k`:String(D)}`]]:[]],L=(e,t,o="left",n=!1)=>(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:700,color:"var(--text)",marginBottom:6},children:e}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:n?"max-content max-content":"auto minmax(0, 1fr)",columnGap:n?14:12,rowGap:4,justifyContent:n?"start":void 0},children:t.map(([t,s])=>(0,r.jsxs)("div",{style:{display:"contents"},children:[(0,r.jsx)("div",{style:{color:"var(--text-dim)",whiteSpace:"nowrap"},children:t}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",minWidth:0,overflowWrap:n?"normal":"anywhere",textAlign:o,whiteSpace:"right"===o?"nowrap":"normal"},children:s})]},`${e}:${t}`))})]}),$=(e,t)=>{let o=k===e;return(0,r.jsx)("button",{type:"button",title:o?U("desktop.copied"):U({file:"desktop.copyFilePath",id:"desktop.copySessionId",projectDir:"desktop.copyProjectDir",gitBranch:"desktop.copyGitBranch",gitWorktree:"desktop.copyGitWorktree"}[e]),onClick:()=>v(e,t),style:{alignSelf:"start",display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,marginTop:-2,color:o?"var(--accent)":"var(--text-dim)",background:"transparent",border:"1px solid var(--border)",borderRadius:4,cursor:"pointer",flex:"0 0 auto",transition:"color 0.12s, border-color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color=o?"var(--accent)":"var(--text-dim)",e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="transparent"},children:o?(0,r.jsx)(m.J,{size:12,"aria-hidden":"true"}):(0,r.jsx)(or.Q,{size:12,"aria-hidden":"true"})})},H=(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:700,color:"var(--text)",marginBottom:6},children:U("desktop.sessionInfoTitle")}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr) auto",columnGap:12,rowGap:8,alignItems:"start"},children:P.map(e=>(0,r.jsxs)("div",{style:{display:"contents"},children:[(0,r.jsx)("div",{style:{color:"var(--text-dim)",whiteSpace:"nowrap"},children:e.label}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",minWidth:0,overflowWrap:"anywhere",wordBreak:"break-word",whiteSpace:"normal"},children:e.value}),(0,r.jsx)("div",{children:e.copyField?$(e.copyField,e.value):null})]},`session-info:${e.label}`))})]}),B=(O=[...f?[{label:U("desktop.projectDir"),value:f.projectRoot??f.cwd,copyField:"projectDir"}]:[],...f?.branch?[{label:U("desktop.gitBranch"),value:f.branch,copyField:"gitBranch"}]:[],...f?.isWorktree?[{label:U("desktop.gitWorktree"),value:f.cwd,copyField:"gitWorktree"}]:[]]).length>0?(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:700,color:"var(--text)",marginBottom:6},children:U("desktop.projectSection")}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr) auto",columnGap:12,rowGap:8,alignItems:"start"},children:O.map(e=>(0,r.jsxs)("div",{style:{display:"contents"},children:[(0,r.jsx)("div",{style:{color:"var(--text-dim)",whiteSpace:"nowrap"},children:e.label}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",minWidth:0,overflowWrap:"anywhere",wordBreak:"break-word",whiteSpace:"normal"},children:e.value}),(0,r.jsx)("div",{children:e.copyField?$(e.copyField,e.value):null})]},`project-info:${e.label}`))})]}):null,(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:a?"1fr":"minmax(360px, 1.7fr) minmax(140px, 0.55fr) minmax(190px, 0.75fr)",gap:a?16:24,fontSize:12,lineHeight:1.5,fontFamily:"var(--font-mono)"},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:a?16:20,minWidth:0},children:[H,B]}),L(U("desktop.sessionInfoMessages"),E),L(U("desktop.sessionInfoTokens"),[...W,...N],"right",!0)]})):(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:U("desktop.sendMessageForSessionInfo")})})]}),_&&T&&(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:3e3,display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:48,background:"rgba(0,0,0,0.35)"},onMouseDown:e=>{e.target===e.currentTarget&&q(!1)},children:(0,r.jsx)("div",{role:"dialog","aria-label":T,style:{maxWidth:"min(560px, calc(100vw - 32px))",maxHeight:"min(60vh, 400px)",overflow:"auto",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,boxShadow:"0 16px 40px rgba(0,0,0,0.3)",padding:"14px 18px",fontSize:13,lineHeight:1.6,color:"var(--text)",wordBreak:"break-word",whiteSpace:"pre-wrap"},children:T})})]})}function pp({cwd:e,busy:t,error:o,onCancelAction:n,onConfirmAction:s}){let{t:i}=(0,A.s)();return(0,r.jsx)("div",{role:"presentation",style:{position:"fixed",inset:0,zIndex:1100,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(0, 0, 0, 0.4)"},onClick:e=>{t||e.target!==e.currentTarget||n()},children:(0,r.jsxs)("section",{role:"dialog","aria-modal":"true","aria-labelledby":"project-trust-title",style:{width:440,maxWidth:"100%",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg-panel)",boxShadow:"0 12px 36px rgba(0, 0, 0, 0.24)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:12,padding:"18px 18px 14px"},children:[(0,r.jsx)(nz.o,{size:21,weight:"duotone",color:"var(--accent-orange)",style:{flexShrink:0,marginTop:1},"aria-hidden":"true"}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("h2",{id:"project-trust-title",style:{margin:0,fontSize:15,fontWeight:700,color:"var(--text)"},children:i("desktop.trustProjectTitle")}),(0,r.jsx)("p",{style:{margin:"7px 0 0",fontSize:12,lineHeight:1.6,color:"var(--text-muted)"},children:i("desktop.trustProjectBody")}),(0,r.jsx)("code",{style:{display:"block",marginTop:10,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:11,overflowWrap:"anywhere"},children:e}),o&&(0,r.jsx)("div",{role:"alert",style:{marginTop:10,color:"var(--accent-red)",fontSize:12,lineHeight:1.5},children:o})]})]}),(0,r.jsxs)("footer",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"10px 18px",borderTop:"1px solid var(--border)"},children:[(0,r.jsx)("button",{type:"button",onClick:n,disabled:t,style:{height:32,padding:"0 12px",border:"1px solid var(--border)",borderRadius:5,background:"transparent",color:"var(--text-muted)",cursor:t?"not-allowed":"pointer",fontSize:12},children:i("desktop.cancel")}),(0,r.jsx)("button",{type:"button",onClick:s,disabled:t,style:{height:32,padding:"0 12px",border:"1px solid var(--accent)",borderRadius:5,background:"var(--accent)",color:"white",cursor:t?"wait":"pointer",opacity:t?.7:1,fontSize:12,fontWeight:600},children:i(t?"desktop.trustingProject":"desktop.trustProject")})]})]})})}function pu(e,t,o){let r=Number.isFinite(e)?e:t,n=Math.max(t,o);return Math.round(Math.max(t,Math.min(n,r)))}function ph(e){return pu(.42*e,360,640)}function pg(e,t){try{window.localStorage.setItem(e,String(t))}catch{}}function pm(e){let{ariaLabel:t,cssVariable:o,defaultWidth:r,getDefaultWidth:s,getMaxWidth:i,growthDirection:a,maxWidth:l,minWidth:d,storageKey:c,widthRef:p}=e,u=(0,n.useRef)(null),h=(0,n.useRef)(null),g=(0,n.useRef)(!1),[m,f]=(0,n.useState)(r),[x,k]=(0,n.useState)(!1),[v,y]=(0,n.useState)(!1);(0,n.useEffect)(()=>{y(!0)},[]);let b=(0,n.useCallback)(()=>Math.min(l,Math.max(d,i())),[i,l,d]),w=(0,n.useCallback)(e=>pu(e,d,b()),[b,d]),j=(0,n.useCallback)(e=>{p.current=e;let t=`${e}px`;u.current?.style.setProperty(o,t),u.current?.parentElement?.style.setProperty(o,t)},[o,p]),S=(0,n.useCallback)((e,t={})=>{let{forcePersist:o=!1,persist:r=!0}=t,n=w(e),s=n!==p.current;return j(n),f(n),r&&(s||o)&&pg(c,n),n},[j,w,c,p]),C=(0,n.useCallback)(e=>{document.body.style.cursor=e.previousCursor,document.body.style.userSelect=e.previousUserSelect},[]),T=(0,n.useCallback)(e=>{let t=h.current;if(t&&t.pointerId===e){h.current=null,C(t),k(!1),S(p.current,{forcePersist:!0});try{t.target.hasPointerCapture(e)&&t.target.releasePointerCapture(e)}catch{}}},[S,C,p]),R=(0,n.useCallback)(e=>{if("mouse"===e.pointerType&&0!==e.button)return;e.preventDefault(),e.stopPropagation();let t=h.current;t&&T(t.pointerId);let o=e.currentTarget;o.focus({preventScroll:!0}),o.setPointerCapture(e.pointerId),h.current={pointerId:e.pointerId,startX:e.clientX,startWidth:p.current,target:o,previousCursor:document.body.style.cursor,previousUserSelect:document.body.style.userSelect},document.body.style.cursor="col-resize",document.body.style.userSelect="none",k(!0)},[T,p]),z=(0,n.useCallback)(e=>{let t=h.current;if(!t||t.pointerId!==e.pointerId)return;if("mouse"===e.pointerType&&0===e.buttons)return void T(e.pointerId);e.preventDefault();let o="right"===a?1:-1,r=w(t.startWidth+(e.clientX-t.startX)*o);j(r),e.currentTarget.setAttribute("aria-valuenow",String(r)),e.currentTarget.setAttribute("aria-valuetext",`${r} px`)},[j,w,T,a]),I=(0,n.useCallback)(e=>{T(e.pointerId)},[T]),M=(0,n.useCallback)(e=>{T(e.pointerId)},[T]),P=(0,n.useCallback)(e=>{T(e.pointerId)},[T]),E=(0,n.useCallback)(()=>{S(s?.()??r,{forcePersist:!0})},[S,r,s]),W=(0,n.useCallback)(()=>{S(p.current)},[S,p]),F=(0,n.useCallback)(e=>{let t=e.shiftKey?32:12,o="right"===a?"ArrowRight":"ArrowLeft",r="right"===a?"ArrowLeft":"ArrowRight";e.key===o?(e.preventDefault(),S(p.current+t,{forcePersist:!0})):e.key===r?(e.preventDefault(),S(p.current-t,{forcePersist:!0})):"Home"===e.key?(e.preventDefault(),S(d,{forcePersist:!0})):"End"===e.key?(e.preventDefault(),S(b(),{forcePersist:!0})):"Enter"===e.key&&(e.preventDefault(),E())},[S,b,a,d,E,p]);return(0,n.useEffect)(()=>{if(g.current)return;g.current=!0;let e=function(e){try{let t=window.localStorage.getItem(e);if(null===t)return null;let o=Number.parseInt(t,10);return Number.isFinite(o)?o:null}catch{return null}}(c),t=S(e??s?.()??r,{persist:!1});null!==e&&e!==t&&pg(c,t)},[S,r,s,c]),(0,n.useEffect)(()=>{if(!g.current)return;S(p.current);let e=()=>{S(p.current)};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[S,p]),(0,n.useEffect)(()=>{if(!x)return;let e=()=>{let e=h.current;e&&T(e.pointerId)},t=()=>{"visible"!==document.visibilityState&&e()};return window.addEventListener("blur",e),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("blur",e),document.removeEventListener("visibilitychange",t)}},[T,x]),(0,n.useEffect)(()=>()=>{let e=h.current;e&&(h.current=null,C(e))},[C]),{isResizing:x,panelRef:u,reclampWidth:W,separatorProps:{"aria-label":t,"aria-orientation":"vertical","aria-valuemax":v?b():l,"aria-valuemin":d,"aria-valuenow":m,"aria-valuetext":`${m} px`,onDoubleClick:E,onKeyDown:F,onLostPointerCapture:P,onPointerCancel:M,onPointerDown:R,onPointerMove:z,onPointerUp:I,role:"separator",tabIndex:0},width:m}}function pf(e){return e.name||e.firstMessage||e.id.slice(0,12)}function px({status:e}){return"running"===e||"starting"===e?(0,r.jsxs)("svg",{className:"animate-spin",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),(0,r.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}):"failed"===e?(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"m9 9 6 6M15 9l-6 6"})]}):"aborted"===e||"interrupted"===e?(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M9 9h6v6H9z"})]}):(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"m8 12 3 3 5-6"})]})}function pk({session:e,main:t,selected:o,running:n,onSelect:s}){let{locale:i,t:a}=(0,A.s)(),l=e.relation?.kind==="subagent"?e.relation:null,d=n?"running":l?.status??"completed",c=t?a("agentSwitcher.main"):l?.description||pf(e),p=t?pf(e):`${l?.profile??a("agentSwitcher.subagent")} \xb7 ${function(e,t){let o=new Date(e).getTime();if(!Number.isFinite(o))return"";let r=Math.round((o-Date.now())/1e3),n=new Intl.RelativeTimeFormat(t,{numeric:"auto"});if(60>Math.abs(r))return n.format(r,"second");let s=Math.round(r/60);if(60>Math.abs(s))return n.format(s,"minute");let i=Math.round(s/60);return 24>Math.abs(i)?n.format(i,"hour"):n.format(Math.round(i/24),"day")}(e.modified,i)}`;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":o,onClick:s,style:{width:"100%",minHeight:56,display:"grid",gridTemplateColumns:"28px minmax(0, 1fr) auto",alignItems:"center",gap:9,padding:"7px 12px",border:"none",borderBottom:"1px solid var(--border)",borderLeft:o?"2px solid var(--accent)":"2px solid transparent",background:o?"var(--bg-selected)":"transparent",color:"var(--text)",cursor:"pointer",textAlign:"left"},onMouseEnter:e=>{o||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{o||(e.currentTarget.style.background="transparent")},children:[(0,r.jsx)("span",{style:{width:28,height:28,display:"grid",placeItems:"center",color:t?"var(--text-muted)":"var(--accent)"},children:t?(0,r.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"8",r:"4"}),(0,r.jsx)("path",{d:"M4 21a8 8 0 0 1 16 0"})]}):(0,r.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("rect",{x:"5",y:"7",width:"14",height:"11",rx:"2"}),(0,r.jsx)("path",{d:"M9 11h.01M15 11h.01M9 15h6M12 7V4M10 4h4"})]})}),(0,r.jsxs)("span",{style:{minWidth:0},children:[(0,r.jsx)("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,fontWeight:o?600:500},title:c,children:c}),(0,r.jsx)("span",{style:{display:"block",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontSize:11},title:p,children:p})]}),(0,r.jsx)("span",{style:{display:"flex",alignItems:"center",gap:6,color:t&&!n?"var(--text-dim)":"running"===d||"starting"===d?"var(--accent)":"completed"===d?"#16a34a":"failed"===d?"#dc2626":"aborted"===d?"#d97706":"var(--text-dim)",fontSize:11,whiteSpace:"nowrap"},children:t&&!n?o?a("agentSwitcher.current"):null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(px,{status:d}),(0,r.jsx)("span",{children:a(`agentSwitcher.status.${d}`)})]})})]})}function pv({rootSession:e,subagents:t,selectedSessionId:o,runningSessionIds:s,onSelectSession:i}){let{t:a}=(0,A.s)(),[l,d]=(0,n.useState)(""),c=(0,n.useMemo)(()=>[...t].sort((e,t)=>{let o=s.has(e.id);return o!==s.has(t.id)?o?-1:1:t.modified.localeCompare(e.modified)}),[s,t]),p=l.trim().toLowerCase(),u=p?c.filter(e=>{let t=e.relation?.kind==="subagent"?e.relation:null;return[t?.description,t?.profile,e.name,e.firstMessage].some(e=>e?.toLowerCase().includes(p))}):c,h=t.filter(e=>s.has(e.id)).length;return(0,r.jsx)("div",{role:"listbox","aria-label":a("agentSwitcher.title"),style:{background:"var(--bg-panel)",borderLeft:"1px solid var(--border)",borderRight:"1px solid var(--border)",borderBottom:"1px solid var(--border)",borderRadius:"0 0 6px 6px",boxShadow:"0 10px 28px rgba(0,0,0,0.10)",overflow:"hidden"},children:(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{minHeight:44,display:"flex",alignItems:"center",gap:8,padding:"7px 12px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("strong",{style:{fontSize:12,fontWeight:600},children:a("agentSwitcher.title")}),(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontSize:11},children:a("agentSwitcher.count",{count:t.length})}),h>0&&(0,r.jsx)("span",{style:{marginLeft:"auto",color:"var(--accent)",fontSize:11},children:a("agentSwitcher.runningCount",{count:h})})]}),t.length>8&&(0,r.jsx)("div",{style:{padding:8,borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("input",{type:"search",value:l,onChange:e=>d(e.target.value),placeholder:a("agentSwitcher.search"),"aria-label":a("agentSwitcher.search"),style:{width:"100%",height:32,padding:"0 10px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg)",color:"var(--text)",fontSize:12,outline:"none"}})}),(0,r.jsxs)("div",{style:{maxHeight:"min(58dvh, 480px)",overflowY:"auto"},children:[(0,r.jsx)(pk,{session:e,main:!0,selected:e.id===o,running:s.has(e.id),onSelect:()=>i(e)}),u.map(e=>(0,r.jsx)(pk,{session:e,selected:e.id===o,running:s.has(e.id),onSelect:()=>i(e)},e.id)),0===u.length&&(0,r.jsx)("div",{style:{padding:"22px 12px",color:"var(--text-dim)",fontSize:12,textAlign:"center"},children:a("agentSwitcher.noMatches")})]})]})})}function py(){var e;let t,o,l=(0,i.useRouter)(),d=(0,i.useSearchParams)(),c=(0,n.useMemo)(()=>{let e;return{requestedCwd:e=d.get("cwd")?.trim()||null,sessionId:e?null:d.get("session")}},[d]),{isDark:p,toggleTheme:u}=o9(),{t:h}=(0,A.s)(),g=O(),[m,f]=(0,n.useState)(null),[x,k]=(0,n.useState)(null),[v,y]=(0,n.useState)(0),[b,w]=(0,n.useState)(0),[j,S]=(0,n.useState)(0),[C,T]=(0,n.useState)(!1),[R,z]=(0,n.useState)("models"),[I,M]=(0,n.useState)(0),[P,E]=(0,n.useState)(null),[W,F]=(0,n.useState)(!1),[D,N]=(0,n.useState)(!1),[L,$]=(0,n.useState)(null),[H,B]=(0,n.useState)(!0),[U,_]=(0,n.useState)(!1);(0,n.useEffect)(()=>{g&&B(!1)},[g]),(0,n.useEffect)(()=>{_(!0)},[]);let q=(0,n.useRef)(null),V=(0,n.useRef)(null),[K,G]=(0,n.useState)(null),[J,Y]=(0,n.useState)(null),[X,Z]=(0,n.useState)(null),Q=pe(),ee=function(){let{isDesktop:e,isMacOS:t}=pe(),o=(0,n.useCallback)(e=>{var t;0===e.button&&(t=e.target).closest("[data-tauri-drag-region]")&&!t.closest('button, a, input, textarea, select, [role="button"], [contenteditable="true"], [data-no-drag]')&&(e.preventDefault(),e.stopPropagation(),2===e.detail?c5():c3())},[]);return e&&!t?{onMouseDown:o}:{}}(),[et,eo]=(0,n.useState)(null),er=(0,n.useCallback)(e=>{eo(e)},[]),[en,es]=(0,n.useState)(null),ei=(0,n.useCallback)(e=>{es(e)},[]),[ea,el]=(0,n.useState)(null),ed=(0,n.useRef)(null),ep=(0,n.useCallback)((e,t)=>{re(t).then(()=>{ed.current&&clearTimeout(ed.current),el(e),ed.current=setTimeout(()=>el(null),1400)})},[]);(0,n.useEffect)(()=>()=>{ed.current&&clearTimeout(ed.current)},[]);let[eu,eh]=(0,n.useState)(null),eg=(0,n.useCallback)(e=>{eh(e)},[]),[em,ef]=(0,n.useState)(null),[ex,ek]=(0,n.useState)(null),ev=(0,n.useCallback)(()=>{g&&B(!1),ef("session")},[g]),ey=(0,n.useCallback)(()=>{g&&ef(null),B(e=>!e)},[g]);(0,n.useEffect)(()=>{if(!em||!V.current)return;let e=()=>{let e=V.current.getBoundingClientRect();ek({top:e.bottom,left:e.left,width:e.width})};e();let t=new ResizeObserver(e);return t.observe(V.current),()=>t.disconnect()},[em]);let[eb,ew]=(0,n.useState)([]),[ej,eS]=(0,n.useState)(null),[eC,eT]=(0,n.useState)(!1),[eR,ez]=(0,n.useState)(!1),[eI,eM]=(0,n.useState)([]),[eP,eE]=(0,n.useState)(()=>new Set);(0,n.useEffect)(()=>{if(!eR)return;let e=!1,t=()=>{fetch("/api/sessions",{cache:"no-store"}).then(e=>e.json()).then(t=>{e||(eM(t.sessions??[]),eE(new Set(t.runningSessionIds??[])))}).catch(()=>{})};t();let o=setInterval(t,3e3);return()=>{e=!0,clearInterval(o)}},[eR,m?.id,v]);let eW=(0,n.useCallback)(async e=>{try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}`,{cache:"no-store"}),o=await t.json();if(!t.ok||!o.info)throw Error(o.error??`HTTP ${t.status}`);e9.current(o.info)}catch(e){console.error("[pi-web] failed to open session:",e instanceof Error?e.message:e)}},[]),eF=(0,n.useRef)(260),eD=(0,n.useRef)(ph(1366)),eA=(0,n.useCallback)(()=>ph(window.innerWidth),[]),eN=(0,n.useCallback)(()=>(function(e){let{viewportWidth:t,rightPanelOpen:o,rightPanelWidth:r}=e;if(t<=640)return 480;let n=t<960;return Math.min(480,t-(n?320:420)-(!n&&o?r:0))})({viewportWidth:window.innerWidth,rightPanelOpen:eC,rightPanelWidth:eD.current}),[eC]),eL=(0,n.useCallback)(()=>(function(e){let{viewportWidth:t,sidebarOpen:o,sidebarWidth:r}=e;return t<960?1200:Math.min(1200,t-420-(o?r:0))})({viewportWidth:window.innerWidth,sidebarOpen:H,sidebarWidth:eF.current}),[H]),e$=pm({ariaLabel:h("desktop.resizeSidebar"),cssVariable:"--sidebar-width",defaultWidth:260,getMaxWidth:eN,growthDirection:"right",maxWidth:480,minWidth:180,storageKey:"pi-sidebar-width",widthRef:eF}),eH=pm({ariaLabel:h("desktop.resizeFilePanel"),cssVariable:"--right-panel-width",defaultWidth:ph(1366),getDefaultWidth:eA,getMaxWidth:eL,growthDirection:"left",maxWidth:1200,minWidth:300,storageKey:"pi-right-panel-width",widthRef:eD}),eO=e$.reclampWidth,eB=eH.reclampWidth;(0,n.useEffect)(()=>{eC&&(eO(),eB())},[eB,eO,eC]);let eU=(0,n.useCallback)((e,t)=>{q.current?.insertText(sj(e,t))},[]),e_=(0,n.useCallback)(e=>{let t=e.map(e=>sj(e,!1)).join("");t&&q.current?.insertText(t)},[]),eq=(0,n.useCallback)((e,t,o)=>{let r,n,s,i;q.current?.insertText((r=Math.max(1,Math.min(t,o)),n=Math.max(1,Math.max(t,o)),s=e.includes(" ")?`@"${e}"`:`@${e}`,i=r===n?`:${r}`:`:${r}-${n}`,`${s}${i} `))},[]),[eV,eK]=(0,n.useState)(()=>c.sessionId),[eG,eJ]=(0,n.useState)(null),[eY,eX]=(0,n.useState)(()=>c.requestedCwd?"validating":"idle"),[eZ,eQ]=(0,n.useState)(null),[e0,e1]=(0,n.useState)(()=>!eV),e2=(0,n.useRef)(!1),e4=(0,n.useRef)(new Map),[e6,e8]=(0,n.useState)(null),e5=(0,n.useRef)("");(0,n.useEffect)(()=>{let e=`${c.requestedCwd??""}|${c.sessionId??""}`;e5.current!==e&&(e5.current=e,eK(c.sessionId),e1(!c.sessionId),c.requestedCwd||eX("idle"),eQ(null))},[c]),(0,n.useEffect)(()=>{let e=c.requestedCwd;if(!e)return;let t=new AbortController;return eX("validating"),eQ(null),fetch("/api/cwd/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e}),signal:t.signal}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok||!t.cwd)throw Error(t.error??`HTTP ${e.status}`);e2.current=!0,k(t.cwd),eX("ready")}).catch(e=>{t.signal.aborted||(eQ(e instanceof Error?e.message:String(e)),eX("error"))}),()=>t.abort()},[c]);let e3=(0,n.useCallback)((e,t)=>{if(!e)return;if(eJ(e),e2.current&&m&&tk(m.projectRoot??m.cwd,t??e)){if(e2.current=!1,m){let e=m.projectRoot??m.cwd;e&&e4.current.set(e,m.id)}return}e2.current=!1;let o=t??e;if(m&&tk(m.projectRoot??m.cwd,o)){(m.projectRoot??m.cwd)&&e4.current.set(o,m.id);return}if(m){let e=m.projectRoot??m.cwd;e&&e4.current.set(e,m.id)}f(null),k(t=>t&&t!==e?null:t),w(e=>e+1),eo(null),ef(null),window.history.replaceState(null,"","/");let r=e4.current.get(o);e8(r?{projectRoot:o,sessionId:r}:null)},[m]);(0,n.useEffect)(()=>{let e=eG?ec(eG)||eG:null;document.title=e?`${e} — Pi Agent Web`:"Pi Agent Web"},[eG]);let e7=(0,n.useCallback)((e,t=!1)=>{if(t||e8(null),!t&&m){let t=tk(m.projectRoot??m.cwd,e.projectRoot??e.cwd);if(m.id===e.id&&t){g&&B(!1);return}}let o=e.projectRoot??e.cwd;o&&e4.current.set(o,e.id),k(null),f(e),w(e=>e+1),eo(null),e1(!0),g&&!t&&B(!1),t&&(e2.current=!0),t||window.history.replaceState(null,"",`?session=${encodeURIComponent(e.id)}`)},[g,m]),e9=(0,n.useRef)(()=>{});(0,n.useEffect)(()=>{e9.current=e7},[e7]);let te=(0,n.useCallback)(e=>{fetch("/api/sessions").then(e=>e.ok?e.json():null).then(t=>{let o=t?.sessions.find(t=>t.id===e);o&&f(t=>!t||t.id!==e||t.projectRoot&&t.name?t:o)}).catch(()=>{})},[]);(0,n.useEffect)(()=>{if(!e6)return;let{projectRoot:e,sessionId:t}=e6;e9.current({path:"",id:t,cwd:e,created:"",modified:"",messageCount:0,firstMessage:"",projectRoot:e},!0),te(t),window.history.replaceState(null,"",`?session=${encodeURIComponent(t)}`),e8(null)},[e6,te]);let tt=(0,n.useCallback)((e,t)=>{e8(null),f(null),k(t),w(e=>e+1),eo(null),ef(null),g&&B(!1),window.history.replaceState(null,"","/")},[l,g]);!function(e){let{onNewSession:t,activeCwd:o}=e;(0,n.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(!a)return;let t=e.target?.tagName;if("TEXTAREA"===t||"INPUT"===t)return;e.preventDefault(),a();return}if("n"===e.key&&e.ctrlKey&&e.altKey){if(!o||!t)return;e.preventDefault(),t(o)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o,t])}({onNewSession:e=>tt(`kb-${Date.now()}`,e),activeCwd:eG});let to=(0,n.useCallback)(e=>{k(null),e8(null);let t=e.projectRoot??e.cwd;t&&e4.current.set(t,e.id),f(e),e.cwd&&eJ(e.cwd),y(e=>e+1),te(e.id),window.history.replaceState(null,"",`?session=${encodeURIComponent(e.id)}`),window.setTimeout(()=>y(e=>e+1),1200),window.setTimeout(()=>y(e=>e+1),4e3)},[l,te]),tr=(0,n.useCallback)(()=>{y(e=>e+1),S(e=>e+1)},[]),tn=(0,n.useCallback)(e=>{y(e=>e+1),w(e=>e+1),k(null),e8(null),f(t=>{let o={...t??{path:"",cwd:"",created:"",modified:"",messageCount:0,firstMessage:""},id:e},r=o.projectRoot??o.cwd;return r&&e4.current.set(r,e),o}),te(e),window.history.replaceState(null,"",`?session=${encodeURIComponent(e)}`)},[l,te]),ts=(0,n.useCallback)(()=>{e1(!0)},[]),ti=(0,n.useCallback)(e=>{if(y(e=>e+1),m?.id===e){let e=m.cwd;f(null),k(e??null),w(e=>e+1),eo(null),ef(null),window.history.replaceState(null,"","/")}},[l,m]),ta=(0,n.useCallback)((e,t,o,r)=>{let n="string"==typeof o||null===o?o:void 0,s="object"==typeof o&&null!==o?o:r,i=`file:${e}`;ew(o=>{let r=o.find(e=>e.id===i);return r?n&&r.sourceSessionId!==n||s?.initialDisplayMode&&r.initialDisplayMode!==s.initialDisplayMode?o.map(e=>e.id===i?{...e,sourceSessionId:n??e.sourceSessionId,initialDisplayMode:s?.initialDisplayMode??e.initialDisplayMode}:e):o:[...o,{id:i,label:t,filePath:e,sourceSessionId:n,initialDisplayMode:s?.initialDisplayMode}]}),eS(i),eT(!0),g&&B(!1)},[g]),tl=(0,n.useCallback)(e=>{ta(e,ec(e),m?.id??null)},[ta,m?.id]),td=(0,n.useCallback)(e=>{ew(t=>{let o=t.filter(t=>t.id!==e);return 0===o.length&&eT(!1),o}),eS(t=>{if(t!==e)return t;let o=eb.filter(t=>t.id!==e);return o.length>0?o[o.length-1].id:null})},[eb]),tc=(0,n.useCallback)(e=>{S(e=>e+1),ta(e,ec(e))},[ta]),tp=(0,n.useCallback)((e,t)=>{S(e=>e+1);let o=e.endsWith("/")?e:e+"/",r=r=>r===e||t&&r.startsWith(o);ew(e=>{let t=e.filter(e=>!r(e.filePath));return 0===t.length&&eT(!1),t}),eS(e=>{if(!e)return e;let t=eb.find(t=>t.id===e);if(!t||!r(t.filePath))return e;let o=eb.filter(e=>!r(e.filePath));return o.length>0?o[o.length-1].id:null})},[eb]),tu=m?tM(m.name||en?.sessionName)||m.firstMessage.slice(0,50)||m.id.slice(0,12):(t=eG??x)?t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean).pop()||t:null,th=(0,n.useCallback)(()=>{m&&window.open(`/api/sessions/${encodeURIComponent(m.id)}/export?inline=1`,"_blank","noopener,noreferrer")},[m]),tg=x??(null===m&&eG?eG:null),tm="validating"!==eY&&"error"!==eY&&(null!==m||null!==tg),tf=m?.cwd??tg,[tx,tv]=(0,n.useState)(!1),ty=(0,n.useCallback)(()=>{g||tv(e=>!e)},[g]),[tb,tw]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!1,t=()=>fetch("/api/features").then(e=>e.ok?e.json():null).then(t=>{!e&&t&&"boolean"==typeof t.tasksBoard&&(tw(t.tasksBoard),t.tasksBoard||tv(!1))}).catch(()=>{});t();let o=()=>t();return window.addEventListener("pi:features-changed",o),()=>{e=!0,window.removeEventListener("pi:features-changed",o)}},[]);let tj=e0&&!tm;(0,n.useEffect)(()=>{let e=()=>{g||tv(!0)};return window.addEventListener(ah,e),()=>window.removeEventListener(ah,e)},[g]),(0,n.useEffect)(()=>{if(E(null),F(!1),$(null),!tf)return;let e=new AbortController;return fetch(`/api/project-trust?cwd=${encodeURIComponent(tf)}`,{signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);E(t)}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to load project trust:",e)}),()=>e.abort()},[tf]);let tS=(0,n.useCallback)(async()=>{if(tf&&!D){N(!0),$(null);try{let e=await fetch("/api/project-trust",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:tf})}),t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);E(t),F(!1),M(e=>e+1),w(e=>e+1)}catch(e){$(e instanceof Error?e.message:String(e))}finally{N(!1)}}},[D,tf]),tC=eb.find(e=>e.id===ej)??null,tT=eG??m?.cwd??x,tR=(0,n.useCallback)(e=>{z(e),T(!0)},[]),tz=(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(t$,{selectedSessionId:m?.id??null,onSelectSession:e7,onNewSession:tt,initialSessionId:eV,onInitialRestoreDone:ts,refreshKey:v,onSessionDeleted:ti,selectedCwd:m?.cwd??x??null,onCwdChange:e3,onOpenFile:ta,selectedSessionStats:en,onOpenSettings:e=>{tR(["models","skills","plugins","chat","features","logs"].includes(e)?e:"models")},explorerRefreshKey:j,onAtMention:eU,onAtMentions:e_,onFileCreated:tc,onFileDeleted:tp,workspaceControlsHosts:{title:K,welcome:X,titleRight:J},showWorkspaceControls:!0})});return(0,r.jsxs)(cv,{children:[(0,r.jsx)("style",{children:`
|
|
36
|
+
${o}`):s=o;let m=s,f=n?.map(e=>({type:"image",source:{type:"base64",media_type:e.mimeType,data:e.data}})),x={role:"user",content:f?.length?[...o.trim()?[{type:"text",text:o}]:[],...f]:o,timestamp:Date.now()};T(e=>[...e,x]),oo.current=ac(x),ot.current=l,"goal"!==eC.current||a||(eI.current=i,eA(e=>({...e,status:"running",goalText:i,turnsUsed:0,noProgressTurns:0,tokensUsed:0})),eL.current=!0),tq.current=!0,U(!0),e5(a?{kind:"running_command"}:{kind:"waiting_model"}),F({type:"start"}),t2.current=!0,e7(!0),t4.current=!0;let k=n?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType})),v=null,y=!1;try{if(u&&r){let e=t_.current??await t9.current,t=e??await ow();if(t){v=t,ob(1,o),ei&&(eZ(ei),e&&await i6(t,{type:"set_model",provider:ei.provider,modelId:ei.modelId}));let r=await Promise.race([oR(t).then(()=>!0).catch(()=>!1),ai(4e3).then(()=>!1)]);y=!0,await i6(t,{type:"prompt",message:m,...k?.length?{images:k}:{}}),r||oL(t,l),"goal"!==eC.current||a||i6(t,{type:"goal_start",goalText:i}).catch(()=>{})}else throw Error("Unable to create a session for this message")}else if(t){v=t.id;let e=await Promise.race([oR(t.id).then(()=>!0).catch(()=>!1),ai(4e3).then(()=>!1)]);y=!0,await i6(t.id,{type:"prompt",message:m,...k?.length?{images:k}:{}}),e||oL(t.id,l),"goal"!==eC.current||a||i6(t.id,{type:"goal_start",goalText:i}).catch(()=>{})}a&&v&&oL(v,l)}catch(t){if(console.error("Failed to send message:",t),y&&v)return void oL(v,l);if(tK.current=!1,oC(),t instanceof as){let e=oo.current;e&&T(t=>{let o=t[t.length-1];return o?.role==="user"&&ac(o)===e?t.slice(0,-1):t}),oM({type:"error",message:t.message})}else{let o=oo.current;o&&T(e=>{let t=e[e.length-1];return t?.role==="user"&&ac(t)===o?e.slice(0,-1):e}),e.chatInputRef?.current?.replaceMessage?.(x),oM({type:"error",message:`Failed to send message: ${t instanceof Error?t.message:String(t)}`})}oo.current=null,tq.current=!1,U(!1),e5(null),F({type:"end"})}},[u,r,ei,t,ow,oR,ob,oL,oM,oS,oC,oc]),oU=(0,n.useCallback)(async(o,r)=>{if(tq.current||tX.current)return;let n=`${r?"!!":"!"}${o}`;tX.current=!0,K({command:o,excludeFromContext:r}),q(!0);try{let e=t_.current??t?.id??await ow();if(!e)throw Error("Unable to create a session for the shell command");ob(1,n),await i6(e,{type:"bash",command:o,excludeFromContext:r}),await ok(e)}catch(t){console.error("Failed to execute shell command:",t),oM({type:"error",message:t instanceof Error?t.message:String(t)}),e.chatInputRef?.current?.insertIfEmpty(n)}finally{tX.current=!1,K(null),q(!1)}},[oM,ow,ok,e.chatInputRef,ob,t]),o_=(0,n.useCallback)(async()=>{let e=t_.current;if(e)try{await i6(e,{type:tX.current?"abort_bash":"abort"})}catch(e){console.error("Failed to abort:",e)}},[]),oq=(0,n.useCallback)(async e=>{let t=t_.current;if(t){eG(e);try{let{cancelled:o,newSessionId:r}=await i6(t,{type:"fork",entryId:e})??{};!o&&r&&a?.(r)}catch(e){console.error("Fork failed:",e)}finally{eG(null)}}},[a]),oV=(0,n.useCallback)(async e=>{let t=t_.current;t&&(i6(t,{type:"navigate_tree",targetId:e}).catch(()=>{}),S(e),await ov(t,e))},[ov]),oK=(0,n.useCallback)(async e=>{S(e);let t=t_.current;t&&(await ov(t,e),e&&i6(t,{type:"navigate_tree",targetId:e}).catch(()=>{}))},[ov]),oG=(0,n.useCallback)(async(e,t)=>{if(u){let o={provider:e,modelId:t};oa.current=o,ea(o),eZ(o);let r=t_.current??await t9.current;if(!r)return;try{await i6(r,{type:"set_model",provider:e,modelId:t})}catch(e){console.error("Failed to set model:",e)}return}let o=t_.current;if(!o)return;let r=++or.current,n=eJ??g?.context.model??null;eY({provider:e,modelId:t});try{await i6(o,{type:"set_model",provider:e,modelId:t})}catch(o){console.error("Failed to set model:",o),or.current===r&&(eY(n&&(n.provider!==e||n.modelId!==t)?n:null),oM({type:"error",message:o instanceof Error?o.message:String(o)}))}},[oM,eJ,g?.context.model,u,ea]),oJ=(0,n.useCallback)(async()=>{let e=t_.current;if(e&&!eQ){e0(!0),e2(null),e6(null);try{let t=await i6(e,{type:"compact"});e6(ap(t,"manual")),await ok(e,!0)}catch(e){e2(e instanceof Error?e.message:String(e)),e6(null)}finally{e0(!1)}}},[eQ,ok]),oY=(0,n.useCallback)(async e=>{let o=++on.current,n=r??t?.cwd??"",s=n?`/api/models?cwd=${encodeURIComponent(n)}`:"/api/models",i=os.current;i?.abort();let a=new AbortController;os.current=a;let l=()=>a.abort();e?.aborted?a.abort():e?.addEventListener("abort",l,{once:!0});try{let e=await fetch(s,{signal:a.signal});if(!e.ok){let t=`HTTP ${e.status}`;try{let o=await e.json();o?.error&&(t=o.error)}catch{}throw Error(t)}let t=await e.json();if(o!==on.current||h!==oi.current)return;es(null),J(t.models),Q(t.thinkingLevels??{}),et(t.thinkingLevelMaps??{}),er(t.modelScopeWarnings??[]);let r=t.modelList??[];if(X(r),u&&!t_.current){let e=(t.defaultModel?r.find(e=>e.id===t.defaultModel?.modelId&&e.provider===t.defaultModel?.provider):void 0)??r[0];ed(e?{provider:e.provider,modelId:e.id}:null);let o=e?t.thinkingLevelPins?.[`${e.provider}/${e.id}`]:void 0;null===ol.current&&eH(o??"auto")}}catch(e){if(a.signal.aborted||o!==on.current||h!==oi.current)return;es(e instanceof Error?e.message:String(e))}finally{e?.removeEventListener("abort",l),os.current===a&&(os.current=null)}},[u,h,r,t?.cwd]),oX=(0,n.useCallback)(async e=>{if(!e.startsWith("/"))return{handled:!1};let t=e.match(/^\/([^\s]+)(?:\s+([\s\S]*))?$/);if(!t)return{handled:!1};let[,o,r=""]=t,n=r.trim(),s=t_.current??await ow(),i=e=>(e.handled&&(e.error?oM({type:"error",message:e.error}):"openSessionStats"!==e.action&&oM({type:"success",message:e.message??"Command completed"})),e);try{switch(o){case"compact":{if(!s||eQ)return i({handled:!0,error:"No active session to compact"});e0(!0),e2(null),e6(null);let e=await i6(s,{type:"compact",...n?{customInstructions:n}:{}});return e6(ap(e,"manual")),await ok(s,!0)&&ob(),i({handled:!0,message:"Compacted context"})}case"reload":if(!s)return i({handled:!0,error:"No active session to reload"});return await i6(s,{type:"reload"}),await Promise.all([ok(s,!1,!0),oy(s),oj(),oY()]),i({handled:!0,message:"Reloaded session resources"});case"name":if(!s)return i({handled:!0,error:"No active session to name"});if(!n)return i({handled:!0,error:"Usage: /name <name>"});return await i6(s,{type:"set_session_name",name:tM(n)}),await ok(s)&&ob(),i({handled:!0,message:`Session renamed to ${n}`});case"session":{if(!s)return i({handled:!0,error:"No active session"});let e=await i6(s,{type:"get_session_stats"});return e&&ti(e),p?.(),i({handled:!0,action:"openSessionStats"})}case"copy":{if(!s)return i({handled:!0,error:"No active session"});let e=await i6(s,{type:"get_last_assistant_text"}),t=e?.text??"";if(!t)return i({handled:!0,error:"No assistant message to copy"});return await navigator.clipboard.writeText(t),i({handled:!0,message:"Copied last assistant message"})}default:return{handled:!1}}}catch(e){return i({handled:!0,error:e instanceof Error?e.message:String(e)})}finally{"compact"===o&&e0(!1)}},[oM,ow,eQ,oY,ok,oj,oy,ob,p]),oZ=(0,n.useCallback)(async e=>{let t=!1;try{let o=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(o.ok){let e=await o.json(),r=e.state;if(e.running&&r&&(r.isStreaming||r.isPromptRunning||r.isBashRunning||r.isCompacting))return;t=!0}}catch{}t?oF():oL(e)},[oL,oF]),oQ=(0,n.useCallback)(async(e,t)=>{let o=t_.current;if(!o)return;let r=t?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));tq.current=!0,U(!0),e5(e=>e??{kind:"waiting_model"});try{await i6(o,{type:"steer",message:e,...r?.length?{images:r}:{}})}catch(e){console.error("Failed to steer:",e),oZ(o)}},[oZ]),o0=(0,n.useCallback)(async(e,t,o)=>{let r=t_.current;if(!r)return;let n=o?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));tq.current=!0,U(!0),e5(e=>e??{kind:"waiting_model"});try{await i6(r,{type:"prompt",message:e,streamingBehavior:t,...n?.length?{images:n}:{}})}catch(e){console.error("Failed to queue prompt:",e),oZ(r)}},[oZ]),o1=(0,n.useCallback)(async(e,t)=>{let o=t_.current;if(!o)return;let r=t?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));tq.current=!0,U(!0),e5(e=>e??{kind:"waiting_model"});try{await i6(o,{type:"follow_up",message:e,...r?.length?{images:r}:{}})}catch(e){console.error("Failed to follow up:",e),oZ(o)}},[oZ]),o2=(0,n.useCallback)(async()=>{let e=t_.current;if(e)try{await i6(e,{type:"abort_compaction"})}catch(e){console.error("Failed to abort compaction:",e)}},[]),o4=(0,n.useCallback)(async()=>{let t=t_.current;if(t)try{let o=await i6(t,{type:"clear_queue"});tx({steering:[],followUp:[]});let r=[...o?.steering??[],...o?.followUp??[]];r.length>0&&e.chatInputRef?.current?.prependText(r.join("\n\n"))}catch(e){console.error("Failed to recall queued messages:",e),oM({type:"error",message:"Failed to recall queued messages"})}},[e.chatInputRef,oM,tx]);(0,n.useEffect)(()=>{0===tk.length&&tF(!1)},[tk.length]);let o6=(0,n.useCallback)(async(e,t,o=!1)=>{let r=t_.current;if(!r)return tk;try{let n=await i6(r,{type:"resolve_recovery",keep:e,discard:t,continueRun:o}),s=n?.remaining??[];return tE(s),o&&e.length>0&&(async()=>{try{let e=await fetch(`/api/agent/${encodeURIComponent(r)}`);if(!e.ok)return;let t=await e.json(),o=t.state;if(!t.running||!o||!o.isStreaming&&!o.isPromptRunning)return;tV.current=!!o.isStreaming,tK.current=!!o.isPromptRunning,tq.current=!0,U(!0),e5(i9(o)),F({type:"start"}),oT(r),!o.isStreaming&&o.isPromptRunning&&oL(r)}catch{}})(),s}catch(e){return console.error("Failed to resolve queued message recovery:",e),oM({type:"error",message:"Failed to resolve queued message recovery"}),tk}},[tk,oM,oT,oL,tE]),o8=(0,n.useCallback)(async()=>{let e=t_.current;if(!e)return null;try{return await i6(e,{type:"export_queue"})}catch(e){return console.error("Failed to export queue:",e),oM({type:"error",message:"Failed to export queue"}),null}},[oM]),o5=(0,n.useCallback)(async e=>{let t=t_.current;if(!t)return null;try{let o=await i6(t,{type:"import_queue",entries:e});return o&&tx(at(o)),o?.imported??0}catch(e){return console.error("Failed to import queue:",e),oM({type:"error",message:"Failed to import queue"}),null}},[oM,tx]),o3=(0,n.useCallback)(async e=>{let t=t_.current;if(!t)return null;try{let o=await i6(t,{type:"stage_recovery",entries:e});return o?.pendingRecovery&&tE(o.pendingRecovery),(o?.staged??0)>0&&tF(!0),o?.staged??0}catch(e){return console.error("Failed to stage imported queue:",e),oM({type:"error",message:"Failed to stage imported queue"}),null}},[oM,tE]),o7=(0,n.useCallback)(async(e,t,o)=>{let r=t_.current;if(!r)return!1;try{let n=await i6(r,{type:"move_queue",kind:e,fromIndex:t,toIndex:o});return n&&tx(at(n)),!0}catch(e){return console.error("Failed to move queued message:",e),oM({type:"error",message:e instanceof Error?e.message:"Failed to move queued message"}),!1}},[oM,tx]),o9=(0,n.useCallback)(async(e,t)=>{let o=t_.current;if(!o)return null;try{let r=await i6(o,{type:"recall_queue_item",kind:e,index:t});return r&&(void 0!==r.steering||void 0!==r.followUp)&&tx(at(r)),r?.entry?{text:r.entry.text,images:r.entry.images?.map(({data:e,mimeType:t})=>({data:e,mimeType:t}))}:null}catch(e){return console.error("Failed to recall queued message:",e),oM({type:"error",message:e instanceof Error?e.message:"Failed to recall queued message"}),null}},[oM,tx]),re=(0,n.useCallback)(async(e,t,o,r)=>{let n=t_.current;if(!n)return!1;try{let s=await i6(n,{type:"requeue_at",kind:e,index:t,text:o,images:r?.map(({data:e,mimeType:t})=>({type:"image",data:e,mimeType:t}))});return s&&tx(at(s)),!0}catch(e){return console.error("Failed to requeue message:",e),oM({type:"error",message:e instanceof Error?e.message:"Failed to requeue message"}),!1}},[oM,tx]),rt=(0,n.useCallback)(async(e,t)=>{let o=t_.current;if(!o)return!1;try{let r=await i6(o,{type:"remove_queue_item",kind:e,index:t});return r&&tx(at(r)),!0}catch(e){return console.error("Failed to remove queued message:",e),oM({type:"error",message:e instanceof Error?e.message:"Failed to remove queued message"}),!1}},[oM,tx]),ro=(0,n.useCallback)(async e=>{if(ol.current="auto"===e?null:e,eH(e),"auto"===e)return;let t=t_.current??await t9.current;if(t)try{await i6(t,{type:"set_thinking_level",level:e})}catch(e){console.error("Failed to set thinking level:",e)}},[]),rr=(0,n.useCallback)(async e=>{let t=(0,i8.xG)(e);ou(e);let o=t_.current??await t9.current;if(o)try{await i6(o,{type:"set_tools",toolNames:t})}catch(e){console.error("Failed to set tools:",e)}},[ou]),rn=(0,n.useRef)(0),rs=(0,n.useCallback)(async e=>{let t=t_.current??await t9.current,o=++rn.current;if(e){if(eg.current="plan"===ec?"default":ec,eh(!0),em.current=!0,eM.current={sessionKey:"",signature:""},t)try{if(await i6(t,{type:"prompt",message:"/plan"}),rn.current!==o)return}catch(e){if(rn.current!==o)return;console.error("Failed to enter plan mode:",e)}}else if(eh(!1),em.current=!1,eM.current={sessionKey:"",signature:""},t){try{if(await i6(t,{type:"prompt",message:"/plan exit"}),rn.current!==o)return}catch(e){if(rn.current!==o)return;console.error("Failed to exit plan mode:",e)}if(rn.current!==o)return;try{let e=eg.current;await i6(t,{type:"set_tools",toolNames:(0,i8.xG)(e)})}catch(e){console.error("Failed to restore tools after plan exit:",e)}}},[ec]),ri=(0,n.useCallback)(e=>{ex(e);let t=t_.current;if(!t){ek.current=e;return}ek.current=null,fetch(`/api/modes?session=${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(e=>{console.error("Failed to persist mode settings:",e)})},[]),ra=(0,n.useCallback)(e=>{if(ri({...eP.current,collaborationMode:tw(e)}),eC.current=tw(e),eM.current={sessionKey:"",signature:""},"goal"!==e){eI.current=null,eL.current=!1,eA(e=>"idle"===e.status?e:{...e,status:"idle",goalText:null});let e=t_.current;e&&i6(e,{type:"goal_stop"}).catch(()=>{})}},[ri]),rl=(0,n.useCallback)(async e=>{ri({...eP.current,tokenMode:tj(e)});let t=t_.current??await t9.current;if(t)try{if("economy"!==e||em.current){if("economy"!==e){let e=em.current?i8.SC:(0,i8.xG)("plan"===ec?"default":ec);await i6(t,{type:"set_tools",toolNames:e})}}else await i6(t,{type:"set_tools",toolNames:[...tC]})}catch(e){console.error("Failed to apply token mode tools:",e)}},[ri,ec]),rd=(0,n.useCallback)(async e=>{ri({...eP.current,toolApprovalMode:tS(e)});let t=t_.current??await t9.current;if(t)try{await i6(t,{type:"set_approval_mode",mode:tS(e)})}catch(e){console.error("Failed to apply approval mode:",e)}},[ri]),rc=(0,n.useCallback)(async e=>{ri({...eP.current,permissionRules:e});let t=t_.current??await t9.current;if(t)try{await i6(t,{type:"set_approval_policy",policy:e})}catch(e){console.error("Failed to apply permission rules:",e)}},[ri]),rp=(0,n.useCallback)(async(e,t,o)=>{let r=t_.current;if(r)try{await i6(r,{type:"resolve_approval",id:e,approve:t,reason:o})}catch(e){console.error("Failed to resolve approval:",e)}finally{eW(t=>t.filter(t=>t.id!==e))}},[]),ru=(0,n.useCallback)(e=>{eI.current=e},[]),rh=(0,n.useCallback)(e=>{let t=e.trim();if(!t)return;eI.current=t,eA(e=>({...e,status:"running",goalText:t,turnsUsed:0,noProgressTurns:0,tokensUsed:0,startedAt:Date.now()}));let o=t_.current;o&&i6(o,{type:"goal_start",goalText:t}).catch(()=>{})},[]),rg=(0,n.useCallback)(()=>{if("running"!==eN.current.status)return;eA(e=>({...e,status:"paused"}));let e=t_.current;e&&i6(e,{type:"goal_pause"}).catch(()=>{})},[]),rm=(0,n.useCallback)(()=>{let e=eN.current;if("paused"!==e.status&&"blocked"!==e.status)return;eA(e=>({...e,status:"running"}));let t=t_.current;t&&i6(t,{type:"goal_resume"}).catch(()=>{})},[]),rf=(0,n.useCallback)(()=>{eL.current=!1,eI.current=null,eA(e=>({...e,status:"idle",goalText:null,turnsUsed:0,noProgressTurns:0}));let e=t_.current;e&&i6(e,{type:"goal_stop"}).catch(()=>{})},[]),rx=(0,n.useCallback)(e=>{let t=e.trim();if(!t)return;eA(e=>({...e,goalText:t}));let o=t_.current;o&&i6(o,{type:"goal_edit",goalText:t}).catch(()=>{})},[]),rk=(0,n.useCallback)(()=>{let e=t7.current,t=t1.current;if(!e||!t)return;let o=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,r=Math.max(0,e.scrollHeight-e.clientHeight),n=Math.min(Math.max(0,o-16),r);t6.current=n>=r-150,t5.current=Date.now()+700,e.scrollTo({top:n,behavior:"smooth"})},[]),rv=(0,n.useCallback)(e=>{if(e instanceof KeyboardEvent){if(!an.has(e.key)||e.target instanceof Element&&e.target.closest("input, textarea, [contenteditable='true']"))return}else if(e instanceof PointerEvent){let t=t7.current;if(t&&e.target instanceof Element&&!t.contains(e.target))return}t8.current=Date.now()+1200},[]),ry=(0,n.useCallback)(()=>{let e=t7.current;if(e){let{scrollTop:t,clientHeight:o,scrollHeight:r}=e;t6.current=t+o>=r-150}if(Date.now()<t8.current){t4.current=!1;return}Date.now()<t5.current||(t4.current=!1)},[]);(0,n.useEffect)(()=>{if(tJ.current=!0,t){t_.current=t.id;let e=eR.current,o=ez.current;("auto"!==e||o.allow.length||o.ask.length||o.deny.length)&&(i6(t.id,{type:"set_approval_mode",mode:e}).catch(()=>{}),i6(t.id,{type:"set_approval_policy",policy:o}).catch(()=>{}));let r=e=>{!tZ.current&&(tZ.current=!0,e.isBashRunning&&(tX.current=!0,q(!0)),oy(t.id),(e.isStreaming||e.isPromptRunning)&&(tV.current=!!e.isStreaming,tK.current=!!e.isPromptRunning,tq.current=!0,U(!0),e5(i9(e)),F({type:"start"}),oT(t.id),!e.isStreaming&&e.isPromptRunning&&oL(t.id)))};(async()=>{try{let e,o=new AbortController,n=setTimeout(()=>o.abort(),2e4);try{e=await fetch(`/api/sessions/${encodeURIComponent(t.id)}/state`,{signal:o.signal})}finally{clearTimeout(n)}if(!e.ok)throw Error(`HTTP ${e.status}`);let s=await e.json();if(!tJ.current||t_.current!==t.id)return;s.running&&s.state&&r(s.state)}catch{}})(),ok(t.id,!0,!0).then(e=>{e?.running&&e.state&&r(e.state),e?.state&&(void 0!==e.state.isCompacting&&e0(e.state.isCompacting),void 0!==e.state.contextUsage&&e_(e.state.contextUsage??null),void 0!==e.state.systemPrompt&&eV(e.state.systemPrompt??null),void 0!==e.state.thinkingLevel&&eH(e.state.thinkingLevel??"auto"),void 0!==e.state.extensionStatuses&&tu(e.state.extensionStatuses??[]),void 0!==e.state.extensionWidgets&&tg(e.state.extensionWidgets??[]),void 0!==e.state.queuedMessages&&tx(at(e.state.queuedMessages)),void 0!==e.state.pendingRecovery&&tE(e.state.pendingRecovery??[])),e?.running||(async()=>{for(let e=0;e<5;e++){if(e>0&&await new Promise(e=>setTimeout(e,2e3)),!tJ.current||t_.current!==t.id||tq.current)return;try{let e=await fetch(`/api/agent/${encodeURIComponent(t.id)}`);if(!e.ok)continue;let o=await e.json();if(!tJ.current||t_.current!==t.id)return;if(o?.running&&o.state)return void r(o.state)}catch{}}})()})}return()=>{tJ.current=!1,f.current?.abort(),k.current?.abort(),oc(),tN(),oS(),oC()}},[oc]),(0,n.useEffect)(()=>{c?.(eq)},[eq,c]),(0,n.useEffect)(()=>{d&&d(g?.tree??[],j,oK)},[g?.tree,j,oK,d]),(0,n.useEffect)(()=>(window.addEventListener("keydown",rv),window.addEventListener("pointerdown",rv,{passive:!0}),()=>{window.removeEventListener("keydown",rv),window.removeEventListener("pointerdown",rv)}),[rv]),(0,n.useEffect)(()=>{let e=t7.current;if(e)return e.addEventListener("wheel",rv,{passive:!0}),e.addEventListener("touchstart",rv,{passive:!0}),e.addEventListener("scroll",ry,{passive:!0}),()=>{e.removeEventListener("wheel",rv),e.removeEventListener("touchstart",rv),e.removeEventListener("scroll",ry)}},[C.length,v,ry,rv]),(0,n.useEffect)(()=>{C.length>0&&(t2.current?(t0.current=!0,t1.current&&(t2.current=!1,rk())):v||!t0.current?(v||(t0.current=!0),oH("instant")):!tq.current&&(t4.current||t6.current)&&(oH("smooth"),rj(e=>e+1)))},[C.length,v,B,oH,rk]);let rb=(0,n.useRef)(null),[rw,rj]=(0,n.useState)(0),rS=`${t?.id??null}#${rw}`;(0,n.useEffect)(()=>{let e;if(v){rb.current=null;return}if(0===C.length||rb.current===rS)return;rb.current=rS;let t=!1,o=!1,r=-1,n=0,s=Date.now(),i=()=>{if(t||o)return;let a=t7.current;if(a){if(Date.now()<t8.current){let{scrollTop:e,clientHeight:t,scrollHeight:r}=a;if(e+t<r-150){o=!0;return}}if(oH("instant"),a.scrollHeight===r){if((n+=1)>=4||Date.now()-s>=3e4)return}else if(r=a.scrollHeight,n=0,Date.now()-s>=3e4)return;e=window.setTimeout(i,n>0?500:250)}};return e=window.setTimeout(i,250),()=>{t=!0,void 0!==e&&window.clearTimeout(e)}},[v,oH,rS]),(0,n.useEffect)(()=>{let e=new AbortController;return oY(e.signal).catch(e=>{if(e instanceof DOMException&&"AbortError"===e.name)return}),()=>e.abort()},[oY,l]),(0,n.useEffect)(()=>{if(!en)return;let e=()=>{"visible"===document.visibilityState&&oY()};return document.addEventListener("visibilitychange",e),window.addEventListener("online",e),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("online",e)}},[en,oY]),(0,n.useEffect)(()=>{if(!e1)return;let e=setTimeout(()=>e2(null),3e3);return()=>clearTimeout(e)},[e1]),(0,n.useEffect)(()=>{if(!e4)return;let e=setTimeout(()=>e6(null),6e3);return()=>clearTimeout(e)},[e4]),(0,n.useEffect)(()=>{if(0===tr.visible.length)return;let e=tr.visible.find(e=>e.exiting);if(e){let t=setTimeout(()=>{tn({type:"remove",id:e.id})},180);return()=>clearTimeout(t)}if(!tr.visible[0])return;let t=setTimeout(()=>{tn({type:"mark_oldest_exiting"})},5e3);return()=>clearTimeout(t)},[tr.visible]),(0,n.useEffect)(()=>{ti(null)},[C.length,eU?.tokens,eU?.percent,eU?.contextWindow]);let rC=g?.tree??[];return{data:g,loading:v,error:b,activeLeafId:j,messages:C,entryIds:R,historyCursor:I,hasEarlierMessages:P,streamState:W,agentRunning:B,bashRunning:_,pendingBash:V,modelNames:G,modelList:Y,modelThinkingLevels:Z,modelThinkingLevelMaps:ee,modelScopeWarnings:eo,modelsError:en,newSessionModel:ei,toolPreset:ec,thinkingLevel:e$,retryInfo:eO,contextUsage:eU,systemPrompt:eq,forkingEntryId:eK,isCompacting:eQ,compactError:e1,compactResult:e4,currentModel:om,displayModel:of,sessionStats:ox,tokenRate:A,planMode:eu,collaborationMode:eb,tokenMode:ew,toolApprovalMode:ej,permissionRules:eS,modeSettings:ef,approvalRequests:eE,handleCollaborationModeChange:ra,handleTokenModeChange:rl,handleToolApprovalModeChange:rd,handlePermissionRulesChange:rc,resolveApproval:rp,setActiveGoalText:ru,goalState:eD,handleGoalStart:rh,handleGoalPause:rg,handleGoalResume:rm,handleGoalStop:rf,handleGoalEdit:rx,slashCommands:e9,slashCommandsLoading:tt,queuedMessages:tm,pendingRecovery:tk,recoveryIsImport:tW,notices:tr.visible,extensionDialog:ta,extensionCustomUi:td,extensionStatuses:tp,extensionWidgets:th,respondToExtensionUi:oz,sendExtensionCustomInput:oI,agentPhase:e8,isNew:u,promptAnchorActive:e3,branchTree:rC,sessionIdRef:t_,eventSourceRef:tL,messagesEndRef:t3,scrollContainerRef:t7,lastUserMsgRef:t1,pendingScrollToUserRef:t2,initialScrollDoneRef:t0,scrollUserMsgToTop:rk,handleSend:oB,executeBash:oU,handleAbort:o_,handleFork:oq,handleNavigate:oV,handleModelChange:oG,handleCompact:oJ,handleSteer:oQ,handleFollowUp:o1,handlePromptWithStreamingBehavior:o0,handleAbortCompaction:o2,handleRecallQueue:o4,resolveRecovery:o6,exportQueueData:o8,importQueueData:o5,stageQueueImport:o3,moveQueuedMessage:o7,recallQueuedMessage:o9,requeueAt:re,removeQueuedMessage:rt,handleBuiltinSlashCommand:oX,handleToolPresetChange:rr,handleThinkingLevelChange:ro,handlePlanModeChange:rs,loadTools:oy,loadSlashCommands:oj,reloadModels:oY,setActiveLeafId:S,setData:m,setMessages:T,loadContext:ov,dispatch:F,setAgentRunning:U,setForkingEntryId:eG,handleLeafChange:oK,handleAgentEventRef:tQ}}({session:e,newSessionCwd:t,onAgentEnd:W,onSessionCreated:i,onSessionForked:l,modelsRefreshKey:d,chatInputRef:c,onBranchDataChange:p,onSystemPromptChange:u,onSessionStatsPanelOpen:g}),[tc,tp]=(0,n.useState)(!1);(0,n.useEffect)(()=>{0===eg.length&&tp(!1)},[eg.length]);let{balance:tu,refresh:th,refreshSoon:tg}=function(){let[e,t]=(0,n.useState)(null),[o,r]=(0,n.useState)(!1),s=(0,n.useRef)(null),i=(0,n.useRef)(null),a=(0,n.useRef)(!0);(0,n.useEffect)(()=>(a.current=!0,()=>{a.current=!1,i.current&&clearTimeout(i.current),s.current?.abort()}),[]);let l=(0,n.useRef)(null),d=(0,n.useCallback)(async()=>{s.current?.abort();let e=new AbortController;s.current=e;try{let o=await fetch("/api/deepseek/balance",{signal:e.signal,cache:"no-store"}),n=await o.json();if(!a.current)return;if(n?.available&&null!=n.totalBalance){let e=l.current;(null===e||e.available!==n.available||e.reason!==n.reason||e.currency!==n.currency||e.totalBalance!==n.totalBalance||e.grantedBalance!==n.grantedBalance||e.toppedUpBalance!==n.toppedUpBalance)&&(l.current=n,t(n)),r(!1)}else null===l.current&&r(!0)}catch{if(!a.current)return;null===l.current&&r(!0)}},[]),c=(0,n.useCallback)(()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null,d()},2e3)},[d]);return{balance:e,failed:o,refresh:d,refreshSoon:c}}(),tm=el?.provider==="deepseek",tf=(0,n.useRef)(null);(0,n.useEffect)(()=>{tm&&th()},[tm,th]),(0,n.useEffect)(()=>{if(tm)for(let e=H.length-1;e>=0;e--){let t=H[e];if("assistant"!==t.role||!t.usage)continue;let o=`${e}:${B[e]??""}`;o!==tf.current&&(tf.current=o,tg());break}},[H,B,tm,tg]);let tx=(0,n.useMemo)(()=>{let e=H.findLast(e=>"assistant"===e.role&&!!e.usage);if(!e?.usage)return null;let t=e.usage;return{model:e.model??"",input:t.input??0,output:t.output??0,cacheRead:t.cacheRead??0,costCNY:r4(e.model)?r6(e.model,t):0,costUSD:r4(e.model)?0:t.cost?.total??0}},[H]),[tk,tP]=(0,n.useState)(!1),[tE,tW]=(0,n.useState)(null),tF=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(!e6){tF.current=!1;return}if(_){tF.current=!0;return}tF.current&&(tF.current=!1,tW(function(e){for(let t=e.length-1;t>=0;t--){let o=e[t];if("assistant"!==o.role)continue;let r=o.content;if("string"==typeof r&&r.trim())return r;if(Array.isArray(r)){let e=r.filter(e=>"text"===e.type).map(e=>e.text??"").join("\n").trim();if(e)return e}}for(let t=e.length-1;t>=0;t--){let o=e[t];if("toolResult"!==o.role)continue;let r=o.content,n="string"==typeof r?r:Array.isArray(r)?r.map(e=>e.text??"").join("\n"):"";if(!n)continue;let s=n.match(/\*\*Proposed Plan\*\*\s*\n+([\s\S]+)/i);if(s?.[1]?.trim())return s[1].trim()}return null}(H)??null),tP(!0))},[_,e6,H]);let tD=(0,n.useCallback)(()=>{tP(!1);let e=tA.current;"plan"===e5&&e7("normal"),e8(!1).then(()=>{e&&eD(I("tasks.planReviewExecutePrompt",{plan:e}))})},[e8,eD,I,e5,e7]),tA=(0,n.useRef)(null);(0,n.useEffect)(()=>{tA.current=tE},[tE]);let tN=(0,n.useCallback)(e=>{tP(!1),eB(e)},[eB]),tL=(0,n.useCallback)(()=>{tP(!1),"plan"===e5&&e7("normal"),e8(!1)},[e8,e5,e7]);(0,n.useEffect)(()=>{ex&&E.current!==ex.id&&(E.current=ex.id,P.current&&M.current())},[ex]),(0,n.useEffect)(()=>(a=_||q?eN:null,()=>void(a=null)),[_,q,eN]);let[t$,tH]=(0,n.useState)(!1),[tO,tB]=(0,n.useState)(!1),[tU,t_]=(0,n.useState)(!1),tq=(0,n.useCallback)(()=>{let e=eM.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;tH(e.scrollTop>1),tB(t>1),t_(t>240)},[eM]),tV=(0,n.useCallback)(()=>{window.requestAnimationFrame(()=>{let e=eM.current,t=eI.current;if(!e||!t)return;let o=Math.max(88,c?.current?.measureHeight?.()??0),r=()=>{if(!e||!t)return;let r=Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop-96-e.clientHeight+o);e.scrollTo({top:r,behavior:"auto"})};r(),tq(),window.setTimeout(r,200)})},[eI,eM,tq,c]);(0,n.useEffect)(()=>{let e=eM.current;if(!e)return;let t=new ResizeObserver(tq);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),e.addEventListener("scroll",tq,{passive:!0}),tq(),()=>{e.removeEventListener("scroll",tq),t.disconnect()}},[H.length,eM,tq]);let tK=(0,n.useRef)(!1);(0,n.useEffect)(()=>{let t=eM.current;if(!t)return;let o=()=>{if(tK.current||!tl||!ta||t.scrollTop>8)return;let o=e?.id;if(!o)return;tK.current=!0;let r=t.scrollHeight-t.scrollTop;td(o,eT,ta).finally(()=>{tK.current=!1,requestAnimationFrame(()=>{let e=t.scrollHeight-r;Math.abs(t.scrollTop-e)>1&&t.scrollTo({top:e,behavior:"auto"})})})};return t.addEventListener("scroll",o,{passive:!0}),()=>t.removeEventListener("scroll",o)},[eM,ta,tl,td,e?.id,eT]);let tG=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(!tl||!ta)return;let t=eM.current,o=e?.id;if(!t||!o||tK.current||tG.current||L||t.scrollTop>8||t.scrollHeight>t.clientHeight+50)return;tG.current=!0;let r=t.scrollHeight-t.scrollTop;td(o,eT,ta).finally(()=>{tG.current=!1,requestAnimationFrame(()=>{let e=t.scrollHeight-r;Math.abs(t.scrollTop-e)>1&&t.scrollTo({top:e,behavior:"auto"})})})},[eM,ta,tl,td,e?.id,eT,L,H.length]);let tJ=(0,n.useRef)(null),tY=(0,n.useRef)([]),tX=(0,n.useMemo)(()=>({getOffsetForIndex:e=>tJ.current?.getOffsetForIndex(e)?.[0]??0,sizeFor:e=>{let t=tJ.current;if(!t)return 0;let o=t.measurementsCache[e];return o?.size??t.options.estimateSize?.(e)??0},totalHeight:()=>tJ.current?.getTotalSize()??0,refToItemIndex:e=>tY.current[e],itemCount:tY.current.length}),[]),tZ=ed?[ed.sessionId,ed.sessionFile??"",ed.sessionName??"",ed.userMessages,ed.assistantMessages,ed.toolCalls,ed.toolResults,ed.totalMessages,ed.tokens.input,ed.tokens.output,ed.tokens.cacheRead,ed.tokens.cacheWrite,ed.tokens.total,ed.cost??0,ed.totalActiveMs??0].join("|"):null,tQ=(0,n.useRef)(ed);tQ.current=ed,(0,n.useEffect)(()=>{h?.(tQ.current)},[tZ,h]),(0,n.useEffect)(()=>()=>{h?.(null)},[h]);let t0=er?`${er.percent??"null"}|${er.contextWindow}|${er.tokens??"null"}`:null,t2=(0,n.useRef)(er);t2.current=er,(0,n.useEffect)(()=>{m?.(t2.current)},[t0,m]),(0,n.useEffect)(()=>()=>{m?.(null)},[m]);let{isDragOver:t4,handleDragEnter:t6,handleDragOver:t3,handleDragLeave:t7,handleDrop:oe}=function(e){let[t,o]=(0,n.useState)(!1),r=(0,n.useRef)(0),s=(0,n.useCallback)(e=>{e.dataTransfer.files.length&&(e.preventDefault(),r.current+=1,o(!0))},[]),i=(0,n.useCallback)(e=>{e.dataTransfer.files.length&&e.preventDefault()},[]);return{isDragOver:t,handleDragEnter:s,handleDragOver:i,handleDragLeave:(0,n.useCallback)(()=>{r.current-=1,r.current<=0&&(r.current=0,o(!1))},[]),handleDrop:(0,n.useCallback)(t=>{t.preventDefault(),r.current=0,o(!1),e(Array.from(t.dataTransfer.files),t.dataTransfer)},[e])}}((0,n.useCallback)((e,t)=>{if(_){let t=e.filter(e=>e.type.startsWith("image/"));t.length&&c?.current?.addImages(t);return}c?.current?.addFiles(e,t)},[_,c])),or=H.filter(e=>"user"===e.role||"assistant"===e.role),on=(0,n.useMemo)(()=>{let e=new Set,t=[];for(let r=H.length-1;r>=0&&t.length<50;r-=1){var o;let n="user"!==(o=H[r]).role?null:("string"==typeof o.content?o.content:o.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n")).trim()||null;!n||e.has(n)||(e.add(n),t.push(n))}return t},[H]),os=(w=or.length,(j=(0,n.useRef)([])).current=Array(w).fill(null).map((e,t)=>j.current[t]??null),j),oi=eS&&0===H.length&&!U.isStreaming&&!_,oa=e?.cwd??t??void 0,ol=(0,n.useMemo)(()=>(function(e,t,o){let r=new Map;for(let t of e)"toolResult"===t.role&&r.set(t.toolCallId,t);let n=-1;for(let t=e.length-1;t>=0;t--)if("user"===e[t].role){n=t;break}let s=new Map,i=0;e.forEach((e,t)=>{("user"===e.role||"assistant"===e.role)&&s.set(t,i++)});let a=[];for(let n=0;n<e.length;){let s,i=e[n],l="custom"===i.role&&"compaction"===i.customType;if(0===n&&"user"!==i.role&&!l){let o=1;for(;o<e.length&&"user"!==e[o].role;)o+=1;let s=Array.from({length:o},(e,t)=>t).filter(t=>ot(e[t])),i=t5(e,t,s,r);if(i.length>0){a.push({kind:"turn",userIdx:-1,endIdx:o,startsCompactionTurn:!1,finalAssistantIdx:-1,visibleProcessIndices:s,processBlocks:i,finalAnswerMessage:null,writtenFiles:void 0}),n=o;continue}}if("user"!==i.role&&!l){a.push({kind:"single",idx:n}),n+=1;continue}let d=n,c=d+1;for(;c<e.length&&"user"!==e[c].role;)c+=1;let p=function(e,t,o){for(let n=o-1;n>t;n--){var r;if("assistant"===(r=e[n]).role&&t1(r).answerBlocks.some(e=>"image"===e.type||"text"===e.type&&e.text.trim().length>0))return n}for(let r=o-1;r>t;r--)if(e[r]?.role==="assistant")return r;return -1}(e,d,c);if(-1===p){let o=Array.from({length:c-d-1},(e,t)=>d+1+t).filter(t=>ot(e[t])),s=t5(e,t,o,r);a.push({kind:"turn",userIdx:d,endIdx:c,startsCompactionTurn:l,finalAssistantIdx:p,visibleProcessIndices:o,processBlocks:s,finalAnswerMessage:null,writtenFiles:void 0}),n=c;continue}let u=[];for(let e=d+1;e<p;e++)u.push(e);let h=u.filter(t=>ot(e[t])),g=e[p],m=t1(g),f=m.processBlocks.length>0?oo(g,m.processBlocks,{omitUsage:!0}):null,x=m.answerBlocks.length>0?oo(g,m.answerBlocks):null,k=t5(e,t,h,r);if(f&&(k=k.concat(t8(g,{messageIndex:p,entryId:t[p],toolResults:r}).processBlocks)),x){let t=[];for(let o=d+1;o<=p;o++){let r=e[o];if(r?.role==="assistant")for(let e of r.content??[])t.push(e)}s=function(e,t,o){let r=new Set,n=[];for(let s of e){if("toolCall"!==s.type||!function(e){let t,o;return"write"===(t=e.toLowerCase())||t.startsWith("write_")||t.endsWith(".write")||t.endsWith("_write")||"edit"===(o=e.toLowerCase())||o.startsWith("edit_")||o.endsWith(".edit")||o.endsWith("_edit")||o.includes("str_replace")||o.includes("replace_editor")}(s.toolName))continue;let e=t?.get(s.toolCallId);if(!e||e.isError)continue;let i=function(e){if(!e)return null;let t=e.file_path??e.path;return"string"==typeof t&&t.length>0?t:null}(s.input);if(!i)continue;let a=function(e,t){let o;if(!e)return null;let r=/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")||void 0!==t&&(/^[a-zA-Z]:[\\/]/.test(t)||t.startsWith("\\\\")),n=e=>r?e.replace(/\\/g,"/"):e,s=n(e),i=t?n(t).replace(/\/+$/,""):void 0,a=/^[a-zA-Z]:\//.test(s),l=s.startsWith("//");if(a||l)o=s;else if(s.startsWith("/")){let e=i?.match(/^([a-zA-Z]:)(?:\/|$)/)?.[1]??i?.match(/^(\/\/[^/]+\/[^/]+)(?:\/|$)/)?.[1];o=e?`${e}${s}`:s}else{if(!i)return null;o=`${i}/${s}`}return t9(o)}(i,o);a&&(r.has(a)||(r.add(a),n.push({filePath:a})))}return n}(t,r,o)}a.push({kind:"turn",userIdx:d,endIdx:c,startsCompactionTurn:l,finalAssistantIdx:p,visibleProcessIndices:h,processBlocks:k,finalAnswerMessage:x,writtenFiles:s}),n=c}return{toolResultsMap:r,lastUserIdx:n,visibleRefIndexByMessage:s,items:a}})(H,B,oa),[H,B,oa]),od=el?J[`${el.provider}:${el.modelId}`]??null:null,oc=el?Y[`${el.provider}:${el.modelId}`]??null:null,op=(0,n.useCallback)(()=>{Q()},[Q]),ou=(0,n.useCallback)(e=>{e8(e),e&&"plan"!==e5?e7("plan"):e||"plan"!==e5||e7("normal")},[e8,e7,e5]),oh=(0,n.useCallback)(e=>{e7(e),"plan"!==e||e6?"plan"!==e&&e6&&e8(!1):e8(!0)},[e7,e8,e6]),og=e?.relation?.kind==="subagent"?(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"14px 16px",borderTop:"1px solid var(--border)",color:"var(--text-dim)",fontSize:12},children:[(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,r.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,r.jsx)("path",{d:"M12 7v4"})]}),I("subagent.readOnlyNotice")]}):(0,r.jsx)(iM,{ref:c,onSend:eD,onBash:eA,tasksBoardEnabled:y,onAbort:eN,onSteer:_?eB:void 0,onFollowUp:_?eU:void 0,onPromptWithStreamingBehavior:_?e_:void 0,isStreaming:_,model:el,modelNames:K,modelList:G,modelScopeWarnings:X,modelsError:Z,onRetryModels:op,onModelChange:eH,compactResult:ea,toolPreset:ee,onToolPresetChange:e||eS?e1:void 0,planMode:e6,onPlanModeChange:ou,collaborationMode:e5,toolApprovalMode:e3,onCollaborationModeChange:oh,goalState:tt,onGoalStart:to,onGoalPause:tr,onGoalResume:tn,onGoalStop:ts,thinkingLevel:et,onThinkingLevelChange:e||eS?e2:void 0,availableThinkingLevels:od,thinkingLevelMap:oc,retryInfo:eo,queuedMessages:eh,inputHistory:on,onRecallQueue:eV,onMoveQueue:eY,onRecallOne:eX,onRequeueAt:eZ,onRemoveQueueItem:eQ,slashCommands:ep,slashCommandsLoading:eu,onLoadSlashCommands:e4,onBuiltinCommand:e0,onAudioUnlock:R,draftKey:e?.id??(t?`new:${t}`:void 0),cwd:e?.cwd??t}),om=ey.filter(e=>"belowEditor"!==e.placement),of=ey.filter(e=>"belowEditor"===e.placement),ox=es?I("desktop.compacting"):function(e,t){if(e?.kind==="running_tools"){let o=e.tools.map(e=>e.name);return 0===o.length?t("desktop.runningTool"):t("desktop.runningTools",{tools:o.length<=3?o.join(", "):`${o.slice(0,2).join(", ")} (+${o.length-2})`})}return e?.kind==="waiting_model"?t("desktop.waitingForModel"):e?.kind==="running_command"?t("desktop.runningCommand"):null}(ej,I);return L?(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-text-muted",children:I("desktop.loadingSession")}):$?(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-red-400",children:$}):(0,r.jsxs)("div",{className:"relative flex h-full min-w-0 flex-col overflow-hidden",onDragEnter:t6,onDragOver:t3,onDragLeave:t7,onDrop:oe,children:[t4&&(0,r.jsxs)("div",{className:"pointer-events-none absolute inset-0 z-50 flex animate-[drop-zone-in_0.15s_ease_both] items-center justify-center bg-[rgba(37,99,235,0.06)] backdrop-blur-[1px]",children:[(0,r.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[0,.8,1.6].map(e=>(0,r.jsx)("div",{className:"absolute h-[720px] w-[720px] rounded-full border-[1.5px] border-solid border-[rgba(37,99,235,0.5)] animate-[drop-ripple_2.4s_ease-out_infinite_backwards]",style:{transformOrigin:"center",animationDelay:`${e}s`}},e))}),(0,r.jsxs)("svg",{width:"280",height:"280",viewBox:"0 0 140 140",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"drop-shadow-[0_6px_18px_rgba(37,99,235,0.18)]",children:[(0,r.jsx)("rect",{x:"28",y:"44",width:"84",height:"60",rx:"8",fill:"rgba(37,99,235,0.08)",stroke:"rgba(37,99,235,0.50)",strokeWidth:"1.8"}),(0,r.jsx)("path",{d:"M36 100 L54 72 L68 88 L80 74 L104 100Z",fill:"rgba(37,99,235,0.16)",stroke:"rgba(37,99,235,0.40)",strokeWidth:"1.4",strokeLinejoin:"round"}),(0,r.jsx)("circle",{cx:"96",cy:"58",r:"8",fill:"rgba(37,99,235,0.22)",stroke:"rgba(37,99,235,0.55)",strokeWidth:"1.6"}),(0,r.jsxs)("g",{stroke:"rgba(37,99,235,0.45)",strokeWidth:"1.4",strokeLinecap:"round",children:[(0,r.jsx)("line",{x1:"96",y1:"46",x2:"96",y2:"43"}),(0,r.jsx)("line",{x1:"96",y1:"70",x2:"96",y2:"73"}),(0,r.jsx)("line",{x1:"84",y1:"58",x2:"81",y2:"58"}),(0,r.jsx)("line",{x1:"108",y1:"58",x2:"111",y2:"58"}),(0,r.jsx)("line",{x1:"87.5",y1:"49.5",x2:"85.4",y2:"47.4"}),(0,r.jsx)("line",{x1:"104.5",y1:"66.5",x2:"106.6",y2:"68.6"}),(0,r.jsx)("line",{x1:"104.5",y1:"49.5",x2:"106.6",y2:"47.4"}),(0,r.jsx)("line",{x1:"87.5",y1:"66.5",x2:"85.4",y2:"68.6"})]})]})]}),ex&&(0,r.jsx)(ak,{request:ex,onRespond:eb}),ek&&(0,r.jsx)(av,{request:ek,onInput:ew}),!eS&&eg.length>0&&!tc&&(0,r.jsx)(iW,{items:eg,sessionId:e?.id,onResolve:eK,onExport:eG,onStageImport:eJ,onDismiss:()=>tp(!0),mode:em?"import":"recovery"}),e9.length>0&&(0,r.jsx)(nI,{request:e9[0]??null,queuedCount:Math.max(0,e9.length-1),busy:!1,onResolve:(e,t)=>{let o=e9[0];o&&te(o.id,e,t)}}),oi?(0,r.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center overflow-y-auto",children:(0,r.jsxs)("div",{className:"w-full max-w-[820px]",children:[(0,r.jsx)("div",{style:{display:"flex",justifyContent:"center",marginBottom:28},children:(0,r.jsxs)("svg",{fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",style:{width:64,height:64,color:"var(--accent)",opacity:.85},"aria-label":"Pi",children:[(0,r.jsx)("title",{children:"Pi"}),(0,r.jsx)("path",{clipRule:"evenodd",d:"M1 1h16.5v11H12v5.5H6.5V23H1V1zm5.5 5.5V12H12V6.5H6.5z"}),(0,r.jsx)("path",{d:"M17.5 12H23v11h-5.5V12z"})]})}),z&&(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:10,marginBottom:18,marginTop:-14},children:[(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:["web ",(0,r.jsxs)("span",{style:{color:"var(--text)"},children:["v","0.17.3"]})]}),(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:["pi ",(0,r.jsxs)("span",{style:{color:"var(--text)"},children:["v","0.85.1"]})]})]}),(0,r.jsx)("div",{style:{padding:"0 34px 6px 7px",paddingRight:z?16:34},children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,r.jsx)("div",{ref:x,style:{display:"flex",alignItems:"center",minWidth:0,flex:1,minHeight:48}}),(0,r.jsxs)("div",{style:{display:z?"none":"flex",flexDirection:"column",alignItems:"flex-end",gap:2,flexShrink:0},children:[(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:["web ",(0,r.jsxs)("span",{style:{color:"var(--text)"},children:["v","0.17.3"]})]}),(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:["pi ",(0,r.jsxs)("span",{style:{color:"var(--text)"},children:["v","0.85.1"]})]})]})]})}),(0,r.jsx)("div",{style:{padding:"0 16px",paddingRight:z?16:34},children:(0,r.jsx)(ax,{notices:ef,align:"right"})}),"goal"===e5&&(0,r.jsx)(nR,{goalState:tt,onPause:tr,onResume:tn,onStop:ts,onEdit:ti}),og,(0,r.jsx)("div",{style:{padding:"0 16px 6px",paddingRight:z?16:34,marginTop:-15},children:(0,r.jsx)(iK,{onViewFullHistory:k,cwd:oa,systemPrompt:v,sessionStats:ed,contextUsage:er,hasSession:!!e,showChat:!0,showSoundLabel:!0,soundEnabled:S,onSoundToggle:C,onCompact:e?eO:void 0,onAbortCompaction:eq,isCompacting:es,compactError:ei,isDeepSeekOfficial:tm,deepseekBalance:tu,lastTurnUsage:tx})})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative flex flex-1 overflow-hidden z-0",children:[(0,r.jsx)("div",{style:{position:"absolute",top:12,left:0,right:18*!z,zIndex:40,padding:"0 16px",pointerEvents:"none"},children:(0,r.jsx)("div",{style:{maxWidth:820,margin:"0 auto"},children:(0,r.jsx)(ax,{notices:ef,floating:!0,align:"right"})})}),(0,r.jsxs)("div",{className:"relative flex-1 min-h-0 min-w-0",children:[(0,r.jsx)("div",{ref:eM,className:"h-full min-w-0 overflow-x-hidden overflow-y-auto pt-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,r.jsx)("div",{style:{minWidth:0,padding:"0 16px"},children:(0,r.jsxs)("div",{style:{width:"100%",minWidth:0,maxWidth:820,margin:"0 auto"},children:[(0,r.jsx)(am,{statuses:ev}),(0,r.jsx)(af,{widgets:om}),(()=>{let{toolResultsMap:t,lastUserIdx:o,visibleRefIndexByMessage:n,items:s}=ol,i=(s,i={})=>{let a=i.messageOverride??H[s];if(!a||"toolResult"===a.role)return null;let l="user"===a.role&&s>0&&"assistant"===H[s-1].role?B[s-1]:void 0,d="user"===a.role||"assistant"===a.role,c=n.get(s),p=i.keyPrefix??"message",u=!1;if("assistant"===a.role){u=!0;for(let e=s+1;e<H.length;e++){let t=H[e].role;if("user"===t)break;if("assistant"===t){u=!1;break}}u&&U.isStreaming&&s===H.length-1&&(u=!1)}void 0!==i.showTimestamp&&(u=i.showTimestamp);let h=(0,r.jsx)(ne,{message:a,toolResults:t,modelNames:K,cwd:oa,onOpenFile:f,entryId:B[s],onFork:_||eS||0===s&&"user"===a.role?void 0:eL,forking:en===B[s],onNavigate:_?void 0:e$,prevAssistantEntryId:_?void 0:l,onEditContent:F,onQuoteReply:D,onOpenSession:b,onCreateTask:N,showTimestamp:u,prevTimestamp:s>0?H[s-1].timestamp:void 0,sessionId:e?.id??ez.current??void 0,writtenFiles:i.writtenFiles},`${p}-view-${s}`);return d&&!1!==i.attachRef&&void 0!==c?(0,r.jsx)("div",{ref:e=>{os.current[c]=e,s===o&&(eP.current=e,e&&eE.current&&(eE.current=!1,eW.current=!0,eF()))},children:h},`${p}-${s}`):h},a=[],l=[],d=[],c=0,p=(e,t,o)=>{null!==e&&(a.push(e),l.push(t),d.push(o))},u=(e,t)=>B[e]||`${t}-${e}`;for(let a of s){if("single"===a.kind){if(H[a.idx]?.role==="toolResult")continue;p(i(a.idx),n.get(a.idx),u(a.idx,"single"));continue}let{userIdx:s,endIdx:l,startsCompactionTurn:d,finalAssistantIdx:h}=a;if((_||U.isStreaming)&&l===H.length&&(s===o||d)){s>=0&&p(i(s),n.get(s),u(s,"user"));let o=U.streamingMessage?.role==="assistant",a=[],d=!o&&h>=0?h:l;for(let e=s+1;e<d;e++)ot(H[e])&&a.push(e);let c=t5(H,B,a,t),g=null;if(!o&&h>=0){let e=H[h],o=t1(e,{isStreaming:!0}),r=t8(e,{messageIndex:h,entryId:B[h],toolResults:t,isStreaming:!0});c=c.concat(r.processBlocks),o.answerBlocks.length>0&&(g=oo(e,o.answerBlocks,{omitUsage:!0}))}if(o){let e=U.streamingMessage,o=t1(e,{isStreaming:!0}),r=t8(e,{messageIndex:H.length,toolResults:t,isStreaming:!0});c=c.concat(r.processBlocks),o.answerBlocks.length>0&&(g=oo(e,o.answerBlocks,{omitUsage:!0}))}if(c.length>0){let t=a.map(e=>n.get(e)).find(e=>"number"==typeof e);p((0,r.jsx)("div",{ref:void 0===t?void 0:e=>{os.current[t]=e},children:(0,r.jsx)(su,{blocks:c,isStreaming:_||U.isStreaming,cwd:oa,onOpenFile:f,sessionId:e?.id??ez.current??void 0,tokenRate:ec})},`live-process-group-${s}`),t,`live-process-${s}-${a[0]??"none"}`)}g&&p((0,r.jsx)(ne,{message:g,isStreaming:!0,modelNames:K,cwd:oa,onOpenFile:f,onQuoteReply:D,onOpenSession:b},`live-answer-${s}`),h>=0?n.get(h):void 0,h>=0?`live-answer-${u(h,"answer")}`:`live-answer-streaming-${s}`);continue}if(-1===h&&0===a.processBlocks.length){if(s>=0)for(let e=s;e<l;e++)p(i(e),n.get(e),u(e,"raw"));continue}s>=0&&p(i(s),n.get(s),u(s,"user"));let{processBlocks:g,finalAnswerMessage:m,writtenFiles:x,visibleProcessIndices:k}=a;if(g.length>0){let t=k.map(e=>n.get(e)).find(e=>"number"==typeof e)??(m?void 0:n.get(h));k[0],p((0,r.jsx)("div",{ref:void 0===t?void 0:e=>{os.current[t]=e},children:(0,r.jsx)(su,{blocks:g,isStreaming:!1,defaultExpanded:!1,onAutoExpanded:void 0,cwd:oa,onOpenFile:f,sessionId:e?.id??ez.current??void 0})},`process-group-${s}-${h}`),t,`process-${s>=0?u(s,"user"):`orphan-${c++}`}`)}if(m&&p(i(h,{messageOverride:m,writtenFiles:x}),n.get(h),u(h,"answer")),h>=0)for(let e=h+1;e<l;e++)p(i(e),n.get(e),u(e,"tail"))}let h=[],g=l.map((e,t)=>({startRef:e,itemIdx:t})).filter(e=>void 0!==e.startRef);return g.forEach((e,t)=>{let o=g[t+1]?.startRef??or.length;for(let t=e.startRef;t<o;t++)h[t]=e.itemIdx}),tY.current=h,(0,r.jsx)(iJ,{scrollElementRef:eM,items:a,itemKeys:d,virtualizerRef:tJ})})(),ox&&(es||_&&!U.streamingMessage)&&(0,r.jsx)("div",{className:"py-2 text-[13px] text-text-muted",children:(0,r.jsxs)("span",{className:"animate-[pulse_1.5s_infinite]",children:[ox,ej?.kind==="waiting_model"&&(0,r.jsx)("span",{style:{display:"inline-block",width:12,height:12,marginLeft:6,verticalAlign:"-2px",border:"1.5px solid var(--text-muted)",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.6s linear infinite"}})]})}),V&&(0,r.jsx)(ne,{message:{role:"bashExecution",command:V.command,output:"",excludeFromContext:V.excludeFromContext},sessionId:e?.id??ez.current??void 0}),q&&!V&&(0,r.jsx)("div",{className:"py-2 text-[13px] text-text-muted",children:(0,r.jsx)("span",{className:"animate-[pulse_1.5s_infinite]",children:I("desktop.runningShellCommand")})}),(0,r.jsx)("div",{style:{height:96}}),(0,r.jsx)("div",{ref:eI}),(0,r.jsx)(nb,{open:tk,planText:tE,busy:_,onExecute:tD,onFeedback:tN,onExit:tL,onClose:()=>tP(!1)})]})})}),t$&&(0,r.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 z-10 h-8 bg-gradient-to-b from-[var(--bg)] to-transparent"}),tO&&(0,r.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-8 bg-gradient-to-t from-[var(--bg)] to-transparent"}),tU&&(0,r.jsxs)("button",{type:"button",onClick:()=>tV(),title:I("desktop.scrollToBottom"),"aria-label":I("desktop.scrollToBottom"),style:{position:"absolute",bottom:14,right:18,zIndex:20,display:"flex",alignItems:"center",gap:6,padding:"5px 10px",border:"1px solid var(--border)",borderRadius:999,background:"color-mix(in srgb, var(--bg-panel) 92%, transparent)",color:"var(--text-muted)",fontSize:11,fontWeight:600,cursor:"pointer",boxShadow:"0 4px 14px rgba(0,0,0,0.14)",backdropFilter:"blur(4px)",transition:"color 0.12s, border-color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)"},children:[(0,r.jsx)(rJ.Z,{size:12,weight:"bold","aria-hidden":"true"}),I("desktop.scrollToBottom")]})]}),z?null:(0,r.jsx)(iZ,{messages:H,streamingMessage:U.streamingMessage,scrollContainer:eM,messageRefs:os,virtualizer:tX})]}),(0,r.jsxs)("div",{className:"relative z-10",children:[(0,r.jsx)("div",{style:{padding:"0 16px",paddingRight:z?16:34},children:(0,r.jsx)("div",{style:{maxWidth:820,margin:"0 auto"},children:(0,r.jsx)(af,{widgets:of})})}),og,(0,r.jsx)("div",{className:`session-info-bar-wrap${z?" is-mobile":""}`,children:(0,r.jsx)("div",{className:"session-info-bar-inner",children:(0,r.jsx)(iK,{onViewFullHistory:k,cwd:oa,systemPrompt:v,sessionStats:ed,contextUsage:er,hasSession:!!e,showChat:!0,soundEnabled:S,onSoundToggle:C,onCompact:e?eO:void 0,onAbortCompaction:eq,isCompacting:es,compactError:ei,branchTree:eC,branchActiveLeafId:eT,onBranchLeafChange:eR,isDeepSeekOfficial:tm,deepseekBalance:tu,lastTurnUsage:tx})})})]})]})]})}function am({statuses:e}){return 0===e.length?null:(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:10},children:e.map(e=>(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,maxWidth:"100%",padding:"4px 8px",border:"1px solid color-mix(in srgb, var(--accent) 24%, var(--border))",borderRadius:6,background:"color-mix(in srgb, var(--accent) 7%, var(--bg))",color:"var(--text-muted)",fontSize:12},children:[(0,r.jsx)("span",{style:{color:"var(--accent)",fontFamily:"var(--font-mono)",fontSize:11},children:e.key}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.text})]},e.key))})}function af({widgets:e}){return 0===e.length?null:(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:10},children:e.map(e=>(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:7,background:"var(--bg-panel)",overflow:"hidden"},children:[(0,r.jsx)("div",{style:{padding:"5px 9px",borderBottom:"1px solid var(--border)",color:"var(--text-dim)",fontSize:11,fontFamily:"var(--font-mono)"},children:e.key}),(0,r.jsx)("pre",{style:{margin:0,padding:"8px 9px",color:"var(--text-muted)",fontSize:12,lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)"},children:e.lines.join("\n")})]},e.key))})}function ax({notices:e,floating:t=!1,align:o="left"}){return 0===e.length?null:(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",alignItems:"right"===o?"flex-end":"stretch",marginBottom:10*!t},children:e.map((o,n)=>{let s="error"===o.type?"#ef4444":"warning"===o.type?"#d97706":"success"===o.type?"#10b981":"var(--accent)";return(0,r.jsxs)("div",{className:"notice-shelf-item",style:{display:"flex",alignItems:"center",gap:10,minHeight:44,maxHeight:180,marginBottom:6*(n!==e.length-1),overflowY:"auto",overflowX:"hidden",borderRadius:14,border:"1px solid color-mix(in srgb, var(--border) 70%, transparent)",background:"var(--bg)",color:"var(--text-muted)",width:"fit-content",maxWidth:"min(100%, 620px)",boxShadow:t?"0 1px 2px rgba(15,23,42,0.05), 0 10px 28px -14px rgba(15,23,42,0.24)":"0 1px 2px rgba(15,23,42,0.04), 0 8px 24px -12px rgba(15,23,42,0.10)",fontSize:13,lineHeight:1.45,transformOrigin:"top center",animation:o.exiting?"notice-shelf-out 0.18s ease-in forwards":"notice-shelf-in 0.18s ease-out both",padding:"0 12px"},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:s,flexShrink:0}}),(0,r.jsx)("span",{style:{padding:"10px 0",minWidth:0,maxWidth:"100%",overflowWrap:"anywhere",whiteSpace:"pre-wrap"},children:o.message})]},o.id)})})}function ak({request:e,onRespond:t}){let{t:o}=(0,A.s)(),[s,i]=(0,n.useState)("editor"===e.method?e.prefill??"":"");(0,n.useEffect)(()=>{i("editor"===e.method?e.prefill??"":"")},[e]);let a=()=>{"confirm"===e.method?t(e,{confirmed:!0}):t(e,{value:s})};return(0,r.jsx)("div",{style:{position:"absolute",inset:0,zIndex:90,display:"flex",alignItems:"center",justifyContent:"center",padding:20,background:"rgba(0,0,0,0.18)"},children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true",style:{width:"min(560px, 100%)",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg)",boxShadow:"0 20px 60px rgba(0,0,0,0.28)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{padding:"12px 14px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("div",{style:{color:"var(--text)",fontSize:14,fontWeight:650},children:e.title}),(0,r.jsx)("div",{style:{marginTop:3,color:"var(--text-dim)",fontSize:11,fontFamily:"var(--font-mono)"},children:o("desktop.extensionRequest")})]}),(0,r.jsxs)("div",{style:{padding:14},children:["confirm"===e.method&&(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontSize:13,lineHeight:1.6,whiteSpace:"pre-wrap"},children:e.message}),"select"===e.method&&(0,r.jsx)("div",{style:{display:"grid",gap:8},children:e.options.map(o=>(0,r.jsx)("button",{onClick:()=>t(e,{value:o}),style:{width:"100%",padding:"9px 10px",borderRadius:7,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text)",cursor:"pointer",textAlign:"left",fontSize:13},children:o},o))}),"input"===e.method&&(0,r.jsx)("input",{autoFocus:!0,value:s,placeholder:e.placeholder,onChange:e=>i(e.target.value),onKeyDown:o=>{"Enter"===o.key&&a(),"Escape"===o.key&&t(e,{cancelled:!0})},style:{width:"100%",padding:"9px 10px",borderRadius:7,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text)",outline:"none",fontSize:13}}),"editor"===e.method&&(0,r.jsx)("textarea",{autoFocus:!0,value:s,onChange:e=>i(e.target.value),onKeyDown:o=>{"Escape"===o.key&&t(e,{cancelled:!0}),(o.metaKey||o.ctrlKey)&&"Enter"===o.key&&a()},style:{width:"100%",minHeight:220,padding:10,borderRadius:7,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text)",outline:"none",resize:"vertical",fontSize:13,lineHeight:1.55,fontFamily:"var(--font-mono)"}})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"10px 14px",borderTop:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,r.jsx)("button",{onClick:()=>t(e,{cancelled:!0}),style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer"},children:o("desktop.cancel")}),"confirm"===e.method?(0,r.jsx)("button",{onClick:a,style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--accent)",background:"var(--accent)",color:"#fff",cursor:"pointer"},children:o("desktop.confirm")}):"select"!==e.method?(0,r.jsx)("button",{onClick:a,style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--accent)",background:"var(--accent)",color:"#fff",cursor:"pointer"},children:o("desktop.submit")}):null]})]})})}function av({request:e,onInput:t}){let{t:o}=(0,A.s)(),s=(0,n.useRef)(null),i=function(e){let t=/^[┌├└╭╰][─┬┴┼]+[┐┤┘╮╯]$/,o=[];for(let r of e){let e=tJ(r).trimEnd();if(t.test(e))continue;let n=r,s=tZ(n);("│"===s||"┃"===s)&&" "===tZ(n=tX(n,0))&&(n=tX(n,0));let i=function(e){let t=tY(e);for(let e=t.length-1;e>=0;e--)if(""!==t[e].char.trim())return e;return -1}(n),a=i>=0?tY(n)[i]?.char:void 0;("│"===a||"┃"===a)&&(n=tX(n,i)),o.push(function(e){let t=e;for(;;){let e=tY(t),o=e[e.length-1];if(!o||""!==o.char.trim())return t;t=t.slice(0,o.start)+t.slice(o.end)}}(n))}for(;o.length>0&&""===tJ(o[0]).trim();)o.shift();for(;o.length>0&&""===tJ(o[o.length-1]).trim();)o.pop();return o.length?o:e}(e.lines);return(0,n.useEffect)(()=>{s.current?.focus()},[e.id]),(0,r.jsx)("div",{style:{position:"absolute",inset:0,zIndex:95,display:"flex",alignItems:"center",justifyContent:"center",padding:20,background:"rgba(0,0,0,0.18)"},children:(0,r.jsxs)("div",{ref:s,tabIndex:0,role:"dialog","aria-modal":"true",onKeyDown:o=>{let r=function(e){if(e.ctrlKey&&!e.metaKey&&!e.altKey&&1===e.key.length){let t=e.key.toLowerCase();if(t>="a"&&t<="z")return String.fromCharCode(t.charCodeAt(0)-96)}switch(e.key){case"ArrowUp":return"\x1b[A";case"ArrowDown":return"\x1b[B";case"ArrowRight":return"\x1b[C";case"ArrowLeft":return"\x1b[D";case"Enter":return"\r";case"Escape":return"\x1b";case"Backspace":return"";case"Tab":return" ";case" ":return" ";default:if(!e.ctrlKey&&!e.metaKey&&!e.altKey&&1===e.key.length)return e.key;return null}}(o);r&&(o.preventDefault(),o.stopPropagation(),t(e,r))},style:{width:"min(920px, 100%)",maxHeight:"min(760px, calc(100vh - 40px))",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg)",boxShadow:"0 20px 60px rgba(0,0,0,0.28)",overflow:"hidden",outline:"none"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("div",{style:{color:"var(--text)",fontSize:13,fontWeight:650},children:o("desktop.extensionPanel")}),(0,r.jsx)("button",{onClick:()=>t(e,"\x03"),style:{padding:"5px 9px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:o("desktop.close")})]}),(0,r.jsx)("pre",{style:{margin:0,padding:14,maxHeight:"calc(min(760px, 100vh - 40px) - 48px)",overflow:"auto",background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.45,whiteSpace:"pre"},children:(i.length?i:[""]).map((e,t,o)=>{var s;return(0,r.jsxs)(n.Fragment,{children:[(s=`line-${t}`,(function(e){let t,o=[],r={},n=0;for(tV.lastIndex=0;null!==(t=tV.exec(e));)t.index>n&&o.push({text:e.slice(n,t.index),style:r}),r=function(e,t){let o={...e};for(let e=0;e<t.length;e++){let r=t[e];if(0===r)for(let e of Object.keys(o))delete o[e];else if(1===r)o.fontWeight=700;else if(2===r)o.opacity=.65;else if(3===r)o.fontStyle="italic";else if(4===r)o.textDecoration="underline";else if(22===r)delete o.fontWeight,delete o.opacity;else if(23===r)delete o.fontStyle;else if(24===r)delete o.textDecoration;else if(39===r)delete o.color;else if(49===r)delete o.backgroundColor;else if(r>=30&&r<=37)o.color=tK[r-30];else if(r>=90&&r<=97)o.color=tG[r-90];else if(r>=40&&r<=47)o.backgroundColor=tK[r-40];else if(r>=100&&r<=107)o.backgroundColor=tG[r-100];else if((38===r||48===r)&&2===t[e+1]){let[n,s,i]=[t[e+2],t[e+3],t[e+4]];[n,s,i].every(e=>"number"==typeof e&&Number.isFinite(e))&&(38===r?o.color=`rgb(${n}, ${s}, ${i})`:o.backgroundColor=`rgb(${n}, ${s}, ${i})`),e+=4}else if((38===r||48===r)&&5===t[e+1]){let n=function(e){if(e>=0&&e<8)return tK[e];if(e>=8&&e<16)return tG[e-8];if(e>=16&&e<=231){let t=e-16,o=Math.floor(t/36),r=Math.floor(t%36/6),n=e=>0===e?0:55+40*e;return`rgb(${n(o)}, ${n(r)}, ${n(t%6)})`}if(e>=232&&e<=255){let t=8+(e-232)*10;return`rgb(${t}, ${t}, ${t})`}}(t[e+2]);n&&(38===r?o.color=n:o.backgroundColor=n),e+=2}}return o}(r,t[1]?t[1].split(";").map(e=>Number(e||"0")):[0]),n=t.index+t[0].length;return n<e.length&&o.push({text:e.slice(n),style:r}),o})(e).map((e,t)=>Object.keys(e.style).length>0?(0,r.jsx)("span",{style:e.style,children:e.text},`${s}-${t}`):e.text)),t<o.length-1?"\n":null]},t)})})]})})}var ay=o(93549);let ab={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif"},aw={mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",oga:"audio/ogg",opus:"audio/ogg",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",weba:"audio/webm"};function aj(e){return(e.replace(/\\/g,"/").split("/").pop()??"").toLowerCase().split(".").pop()??""}function aS(e){let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return t?.closest(".file-source-line[data-line-number]")??null}function aC(e,t){if(!t||t.isCollapsed||0===t.rangeCount)return null;let o=t.getRangeAt(0);if(!e.contains(o.startContainer)||!e.contains(o.endContainer))return null;let r=Number(aS(o.startContainer)?.dataset.lineNumber),n=Number(aS(o.endContainer)?.dataset.lineNumber);return Number.isInteger(r)&&Number.isInteger(n)?r<=n?{startLine:r,endLine:n}:{startLine:n,endLine:r}:null}function aT(e,t,o,r={}){let n=ed(e),s=new URLSearchParams({type:t});for(let[e,t]of(o&&s.set("sessionId",o),Object.entries(r)))void 0!==t&&s.set(e,String(t));return`/api/files/${n}?${s.toString()}`}function aR({filePath:e,sourceSessionId:t}){let{t:o}=(0,A.s)();return(0,r.jsx)("a",{href:aT(e,"download",t),download:ec(e),title:o("desktop.downloadFile"),style:{display:"flex",alignItems:"center",justifyContent:"center",height:20,padding:"0 5px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,textDecoration:"none"},children:(0,r.jsx)(E.z,{size:11,"aria-hidden":"true"})})}let az={fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.6,tabSize:2},aI={fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.6,padding:"12px 0 12px 16px",color:"var(--text-dim)",textAlign:"right",userSelect:"none"};async function aM(e,t){let o=await fetch(`/api/files/${ed(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});if(!o.ok)throw Error((await o.json().catch(()=>({}))).error??`HTTP ${o.status}`);let r=await o.json();return"number"==typeof r.size?r.size:0}let aP={delete:"3px solid var(--git-status-deleted)",add:"3px solid var(--git-status-added)",edit:"3px solid var(--git-status-modified)"},aE="var(--git-status-deleted-bg)",aW="var(--git-status-added-bg)",aF="var(--git-status-added)";function aD(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function aA({oldContent:e,newContent:t}){let{t:o}=(0,A.s)(),n=function(e,t){let o=e.length,r=t.length,n=o+r,s=Array(2*n+1).fill(0),i=[];for(let a=0;a<=n;a++){i.push([...s]);for(let l=-a;l<=a;l+=2){let d,c=(d=l===-a||l!==a&&s[l-1+n]<s[l+1+n]?s[l+1+n]:s[l-1+n]+1)-l;for(;d<o&&c<r&&e[d]===t[c];)d++,c++;if(s[l+n]=d,d>=o&&c>=r){let s=[],l=o,d=r;for(let o=a;o>0;o--){let r,a=i[o-1],c=l-d;r=c===-o||c!==o&&a[c-1+n]<a[c+1+n]?c+1:c-1;let p=a[r+n],u=p-r;for(;l>p&&d>u;)l--,d--,s.unshift({type:"unchanged",text:e[l]});o>0&&(l>p?(l--,s.unshift({type:"removed",text:e[l]})):(d--,s.unshift({type:"added",text:t[d]})))}for(;l>0&&d>0;)l--,d--,s.unshift({type:"unchanged",text:e[l]});return s}}}return[...e.map(e=>({type:"removed",text:e})),...t.map(e=>({type:"added",text:e}))]}(e.split("\n"),t.split("\n"));if(!n.some(e=>"unchanged"!==e.type))return(0,r.jsx)("div",{style:{padding:"12px 16px",fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:o("desktop.noChanges")});let s=new Set(n.flatMap((e,t)=>"unchanged"!==e.type?[t]:[])),i=new Set;for(let e of s)for(let t=Math.max(0,e-3);t<=Math.min(n.length-1,e+3);t++)i.add(t);let a=[],l=0;for(;l<n.length;)if(i.has(l)){let e=[];for(;l<n.length&&i.has(l);)e.push(n[l]),l++;a.push({hidden:!1,lines:e})}else{let e=0;for(;l<n.length&&!i.has(l);)e++,l++;a.push({hidden:!0,count:e})}let d=[],c=1;for(let e of n)"removed"===e.type?d.push(0):d.push(c++);let p=0;return(0,r.jsx)("div",{style:{fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.6,minWidth:"max-content"},children:a.map((e,t)=>{if(e.hidden){let n=(0,r.jsx)("div",{style:{padding:"2px 16px",color:"var(--text-dim)",background:"var(--bg-panel)",fontSize:11,borderTop:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:o("desktop.unchangedLines",{count:e.count})},t);return p+=e.count,n}let n=[],s=[],i=[],a=()=>{if(s.length||i.length){let e=s.length&&i.length?"edit":s.length?"delete":"add";for(let t of s)n.push({key:t.key,kind:"removed",text:t.text,lineNo:null,block:e});for(let t of i)n.push({key:t.key,kind:"added",text:t.text,lineNo:t.lineNo,block:e});s=[],i=[]}};e.lines.forEach((e,o)=>{"unchanged"===e.type?(a(),n.push({key:`${t}:${o}`,kind:"context",text:e.text,lineNo:d[p+o],block:null})):"removed"===e.type?s.push({key:`${t}:${o}`,text:e.text}):i.push({key:`${t}:${o}`,text:e.text,lineNo:d[p+o]})}),a();let l=n.map(e=>{let t="removed"===e.kind?aE:"added"===e.kind?aW:"transparent",o=e.block?aP[e.block]:"3px solid transparent",n="added"===e.kind?aF:"var(--text-dim)";return(0,r.jsxs)("div",{style:{display:"flex",background:t,borderLeft:o},children:[(0,r.jsx)("span",{style:{minWidth:44,padding:"0 8px 0 16px",textAlign:"right",color:n,userSelect:"none",fontSize:11,lineHeight:1.6,flexShrink:0},children:e.lineNo??""}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,padding:"0 8px 0 0",whiteSpace:"pre",color:"var(--text)"},children:e.text||"\xa0"})]},e.key)});return p+=e.lines.length,(0,r.jsx)("div",{children:l},t)})})}function aN({patch:e}){let t=rU(e);if(!t)return null;let o=[],n=[],s=[],i=()=>{if(n.length||s.length){let e=n.length&&s.length?"edit":n.length?"delete":"add";for(let t of n)o.push({key:t.key,kind:"removed",text:t.text,lineNo:null,block:e});for(let t of s)o.push({key:t.key,kind:"added",text:t.text,lineNo:t.lineNo,block:e});n=[],s=[]}};return t.forEach((e,t)=>{e.rows.forEach((e,r)=>{if("hunk"===e.type){i(),o.push({key:`${t}:${r}:h`,kind:"hunk",text:e.text,lineNo:null,block:null});return}let{left:a,right:l}=e;if("context"===a.type&&"context"===l.type){i(),o.push({key:`${t}:${r}:c`,kind:"context",text:a.text,lineNo:l.lineNo,block:null});return}"removed"===a.type&&n.push({key:`${t}:${r}:l`,text:a.text}),"added"===l.type&&s.push({key:`${t}:${r}:r`,text:l.text,lineNo:l.lineNo})})}),i(),(0,r.jsx)("div",{style:{fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,minWidth:"max-content"},children:o.map(e=>{if("hunk"===e.kind)return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{height:"1.55em"}}),(0,r.jsx)("div",{style:{padding:"3px 12px",color:"var(--accent-blue)",background:"var(--bg-secondary)"},children:e.text}),(0,r.jsx)("div",{style:{height:"1.55em"}})]},e.key);let t="removed"===e.kind?aE:"added"===e.kind?aW:"transparent",o=e.block?aP[e.block]:"3px solid transparent",n="added"===e.kind?aF:"var(--text-dim)";return(0,r.jsxs)("div",{style:{display:"flex",background:t,borderLeft:o},children:[(0,r.jsx)("span",{style:{width:44,flexShrink:0,padding:"0 8px 0 16px",textAlign:"right",color:n,userSelect:"none",fontSize:11},children:e.lineNo??""}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,padding:"0 8px 0 0",whiteSpace:"pre",color:"var(--text)"},children:e.text||"\xa0"})]},e.key)})})}function aL({filePath:e,cwd:t,sourceSessionId:o}){let{t:s}=(0,A.s)(),[i,a]=(0,n.useState)(0),[l,d]=(0,n.useState)(null),[c,p]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),g=(0,n.useRef)(null),m=ec(e).toLowerCase().split(".").pop()??"";(0,n.useEffect)(()=>{a(0),d(null),p(null),h(null),g.current&&(g.current.close(),g.current=null);let t=new EventSource(aT(e,"watch",o));return g.current=t,t.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&d(t.size)}catch{}a(e=>e+1)}),()=>{t.close(),g.current=null}},[e,o]);let f=aT(e,"read",o,i?{v:i}:void 0),x=null!=l?aD(l):null;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:ep(e,t)}),(0,r.jsx)("span",{style:{marginLeft:"auto"},children:m||s("desktop.image")}),c&&(0,r.jsxs)("span",{children:[c.w," \xd7 ",c.h]}),x&&(0,r.jsx)("span",{children:x}),(0,r.jsx)(aR,{filePath:e,sourceSessionId:o})]}),(0,r.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg-panel)",display:"flex",alignItems:"center",justifyContent:"center",padding:16,backgroundImage:"linear-gradient(45deg, var(--bg) 25%, transparent 25%), linear-gradient(-45deg, var(--bg) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--bg) 75%), linear-gradient(-45deg, transparent 75%, var(--bg) 75%)",backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px"},children:u?(0,r.jsx)("div",{style:{color:"#f87171",fontSize:13},children:u}):(0,r.jsx)("img",{src:f,alt:e,onLoad:e=>{let t=e.currentTarget;p({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>h(s("desktop.failedToLoadImage")),style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}})})]})}function a$({filePath:e,cwd:t,sourceSessionId:o}){let{t:s}=(0,A.s)(),[i,a]=(0,n.useState)(0),[l,d]=(0,n.useState)(null),[c,p]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),g=(0,n.useRef)(null),m=ec(e).toLowerCase().split(".").pop()??"";(0,n.useEffect)(()=>{a(0),d(null),p(null),h(null),g.current&&(g.current.close(),g.current=null);let t=new EventSource(aT(e,"watch",o));return g.current=t,t.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&d(t.size)}catch{}p(null),h(null),a(e=>e+1)}),()=>{t.close(),g.current=null}},[e,o]);let f=aT(e,"read",o,i?{v:i}:void 0);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:ep(e,t)}),(0,r.jsx)("span",{style:{marginLeft:"auto"},children:m||s("desktop.audio")}),null!=c&&(0,r.jsx)("span",{children:function(e){if(!Number.isFinite(e))return"";let t=Math.round(e),o=Math.floor(t/60);return`${o}:${String(t%60).padStart(2,"0")}`}(c)}),null!=l&&(0,r.jsx)("span",{children:aD(l)}),(0,r.jsx)(aR,{filePath:e,sourceSessionId:o})]}),(0,r.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,background:"var(--bg-panel)"},children:(0,r.jsxs)("div",{style:{width:"min(680px, 100%)"},children:[u&&(0,r.jsx)("div",{style:{color:"#f87171",fontSize:13,marginBottom:12,textAlign:"center"},children:u}),(0,r.jsx)("audio",{controls:!0,preload:"metadata",src:f,onLoadedMetadata:e=>p(e.currentTarget.duration),onError:()=>h(s("desktop.failedToLoadAudio")),style:{width:"100%"}},f)]})})]})}function aH({filePath:e,cwd:t,sourceSessionId:o}){let{t:s}=(0,A.s)(),[i,a]=(0,n.useState)(0),[l,d]=(0,n.useState)(null),[c,p]=(0,n.useState)(null),u=(0,n.useRef)(null),h=aj(e),g="pdf"===h,m=g?aT(e,"read",o,i?{v:i}:void 0):aT(e,"preview",o,i?{v:i}:void 0);return(0,n.useEffect)(()=>{a(0),d(null),p(null),u.current&&(u.current.close(),u.current=null),fetch(aT(e,"meta",o)).then(e=>e.json()).then(e=>{e.error&&p(e.error),"number"==typeof e.size&&(d(e.size),!g&&e.size>0xa00000&&p(s("desktop.docxTooLargeForPreview")))}).catch(e=>p(String(e)));let t=new EventSource(aT(e,"watch",o));return u.current=t,t.addEventListener("change",e=>{try{let t=JSON.parse(e.data);if("number"==typeof t.size&&(d(t.size),!g&&t.size>0xa00000))return void p(s("desktop.docxTooLargeForPreview"))}catch{}p(null),a(e=>e+1)}),()=>{t.close(),u.current=null}},[e,g,o,s]),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e,children:ep(e,t)}),(0,r.jsx)("span",{style:{marginLeft:"auto"},children:"docx"===h?s("desktop.docxPreview"):"pdf"}),null!=l&&(0,r.jsx)("span",{children:aD(l)}),(0,r.jsx)(aR,{filePath:e,sourceSessionId:o})]}),(0,r.jsx)("div",{style:{flex:1,minHeight:0,background:"var(--bg-panel)"},children:c?(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",padding:24,color:"#f87171",fontSize:13,textAlign:"center"},children:c}):(0,r.jsx)("iframe",{src:m,sandbox:g?void 0:"allow-same-origin",title:s("desktop.previewFile",{file:ec(e)}),style:{width:"100%",height:"100%",border:"none",background:g?"var(--bg)":"#eef1f5"}},m)})]})}function aO({filePath:e,cwd:t,sourceSessionId:o,onOpenFile:n,onAtMention:s,onMentionLines:i,initialDisplayMode:a,onFileSaved:l}){let d;return null!==(ab[aj(e)]??null)?(0,r.jsx)(aL,{filePath:e,cwd:t,sourceSessionId:o}):null!==(aw[aj(e)]??null)?(0,r.jsx)(a$,{filePath:e,cwd:t,sourceSessionId:o}):null!==("pdf"===(d=aj(e))||"docx"===d?d:null)?(0,r.jsx)(aH,{filePath:e,cwd:t,sourceSessionId:o}):(0,r.jsx)(aB,{filePath:e,cwd:t,sourceSessionId:o,onOpenFile:n,onAtMention:s,onMentionLines:i,initialDisplayMode:a,onFileSaved:l})}function aB({filePath:e,cwd:t,sourceSessionId:o,onOpenFile:s,onAtMention:i,onMentionLines:a,initialDisplayMode:l,onFileSaved:d}){let c,p,{t:u}=(0,A.s)(),[g,m]=(0,n.useState)(null),[x,k]=(0,n.useState)(null),[v,y]=(0,n.useState)(null),[b,w]=(0,n.useState)(!0),[j,S]=(0,n.useState)(null),[C,T]=(0,n.useState)(!1),[R,z]=(0,n.useState)("source"),[I,M]=(0,n.useState)(!1),[P,E]=(0,n.useState)(0),[W,F]=(0,n.useState)(null),D=(0,n.useRef)(null),N=(0,n.useRef)(null),[L,$]=(0,n.useState)(!1),[H,O]=(0,n.useState)(""),[B,U]=(0,n.useState)(""),[_,q]=(0,n.useState)(!1),[V,K]=(0,n.useState)(null),[G,J]=(0,n.useState)(!1),Y=(0,n.useRef)(null),X=(0,n.useRef)(null),Z=(0,n.useRef)(0),Q=(0,n.useRef)(!1);(0,n.useEffect)(()=>{Q.current=L},[L]);let ee=L&&H!==B,et=!!(g?.content&&g.content.includes("\0")),eo=(0,n.useCallback)(async e=>{if(!t)return void y(null);try{let o=new URLSearchParams({cwd:t,path:e}),r=await fetch(`/api/git/diff?${o.toString()}`),n=await r.json();y(r.ok&&n.supported&&"string"==typeof n.patch?n:null)}catch{y(null)}},[t]),er=(0,n.useCallback)((e,t=!1)=>fetch(aT(e,"read",o)).then(e=>e.json()).then(e=>e.error?(S(e.error),null):(t?(m(t=>(t&&k(t.content),e)),E(e=>e+1)):m(e),e)).catch(e=>(S(String(e)),null)),[o]);(0,n.useEffect)(()=>{w(!0),S(null),m(null),k(null),y(null),T(!1),z("source"),M(!1),E(0),$(!1),O(""),U(""),K(null),J(!1),q(!1),D.current&&(D.current.close(),D.current=null),er(e).then(e=>{(e?.language==="markdown"||e?.language==="html")&&"diff"!==l&&T(!0)}).finally(()=>w(!1)),eo(e);let t=new EventSource(aT(e,"watch",o));return D.current=t,t.addEventListener("change",()=>{Q.current?J(!0):(er(e,!0),eo(e))}),()=>{t.close(),D.current=null}},[e,er,eo,l,o]);let en=(0,n.useCallback)(()=>{g&&!et&&(O(g.content),U(g.content),K(null),J(!1),$(!0))},[g,et]),es=(0,n.useCallback)(()=>{$(!1),O(""),U(""),K(null),J(!1)},[]),ei=(0,n.useCallback)(()=>{(!ee||window.confirm(u("files.unsavedChanges")))&&es()},[ee,es,u]),ea=(0,n.useCallback)(async()=>{if(!g||_)return;let t=++Z.current;q(!0),K(null);try{let o=await aM(e,H);if(t!==Z.current)return;m(e=>e?{...e,content:H,size:o}:e),U(H),q(!1),es(),eo(e),d?.()}catch(e){if(t!==Z.current)return;K(e instanceof Error?e.message:String(e)),q(!1)}},[g,_,H,e,es,eo,d]);(0,n.useEffect)(()=>{if(!L)return;let e=e=>{if((e.metaKey||e.ctrlKey)&&"s"===e.key.toLowerCase()){e.preventDefault(),ea();return}"Escape"===e.key&&(e.preventDefault(),ei())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[L,ea,ei]),(0,n.useEffect)(()=>{if(!ee)return;let e=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[ee]);let ed=(0,n.useCallback)(()=>{let e=Y.current,t=X.current;e&&t&&(t.scrollTop=e.scrollTop)},[]),ec=(0,n.useCallback)(e=>{if("Tab"!==e.key||e.metaKey||e.ctrlKey||e.altKey)return;e.preventDefault();let t=e.currentTarget,{selectionStart:o,selectionEnd:r}=t;O(t.value.slice(0,o)+" "+t.value.slice(r)),requestAnimationFrame(()=>{let e=Y.current;if(!e)return;let t=o+2;e.selectionStart=t,e.selectionEnd=t})},[]),eu=(0,n.useMemo)(()=>ru(g?.content??""),[g?.content]),eh=v?.supported===!0&&"string"==typeof v.patch;(0,n.useEffect)(()=>{"diff"===l&&eh&&z("diff")},[eh,l]);let em=eh&&v?.status==="deleted",ef=(0,n.useCallback)(o=>{a&&o&&a(ep(e,t),o.startLine,o.endLine)},[t,e,a]);if((0,n.useEffect)(()=>{let e=()=>{let e=N.current,t="source"===R&&!C;F(a&&t&&e?aC(e,window.getSelection()):null)};if(e(),a&&"source"===R&&!C)return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[g?.content,a,C,R]),(0,n.useEffect)(()=>{if(!a||"source"!==R||C)return;let e=e=>{if(e.repeat||"i"!==e.key.toLowerCase()||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey)return;let t=e.target;if(t instanceof Element&&t.closest("input, textarea, [contenteditable='true']"))return;let o=N.current,r=o?aC(o,window.getSelection()):null;r&&(e.preventDefault(),ef(r))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[ef,a,C,R]),b)return(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:13},children:u("desktop.loadingFile")});if(em&&!g)return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsx)("div",{style:{padding:"5px 16px",borderBottom:"1px solid var(--border)",color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11},title:e,children:ep(e,t)}),(0,r.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg)"},children:(0,r.jsx)(aN,{patch:v.patch})})]});if(j)return(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#f87171",fontSize:13},children:j});if(!g)return null;let ex="html"===g.language,ek="markdown"===g.language,ev=(p=(c=el(e).replace(/\/+$/,"")).lastIndexOf("/"))<0?"":0===p?"/":2===p&&/^[a-zA-Z]:\//.test(c)?c.slice(0,3):c.slice(0,p),ey=g.content.split("\n"),eb=null!==x&&x!==g.content||eh,ew=!em&&!et&&eg();return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:ep(e,t)}),(0,r.jsx)("span",{style:{marginLeft:"auto"},children:g.language}),"source"===R&&!L&&(0,r.jsx)("span",{children:u("desktop.lines",{count:ey.length})}),(0,r.jsx)("span",{children:aD(g.size)}),eb&&!L&&(0,r.jsxs)("div",{style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:[(0,r.jsx)("button",{onClick:()=>z("source"),style:{padding:"2px 8px",fontSize:11,border:"none",cursor:"pointer",background:"source"===R?"var(--bg-selected)":"var(--bg-hover)",color:"source"===R?"var(--text)":"var(--text-muted)",fontWeight:"source"===R?600:400},children:u("desktop.source")}),(0,r.jsxs)("button",{onClick:()=>z("diff"),style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:"1px solid var(--border)",cursor:"pointer",background:"diff"===R?"var(--bg-selected)":"var(--bg-hover)",color:"diff"===R?"var(--text)":"var(--text-muted)",fontWeight:"diff"===R?600:400},children:[u("desktop.diff")," ",P>0&&(0,r.jsxs)("span",{style:{color:"var(--git-status-added)",marginLeft:2},children:["+",P]})]})]}),"source"===R&&!C&&!L&&(0,r.jsx)("button",{onClick:()=>M(e=>!e),title:I?u("desktop.disableWordWrap"):u("desktop.enableWordWrap"),style:{padding:"2px 8px",fontSize:11,cursor:"pointer",background:I?"var(--bg-selected)":"var(--bg-hover)",color:I?"var(--text)":"var(--text-muted)",border:"1px solid var(--border)",borderRadius:5,fontWeight:I?600:400},children:u("desktop.wrap")}),ex&&"source"===R&&!L&&(0,r.jsxs)("div",{style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:[(0,r.jsx)("button",{onClick:()=>T(!1),style:{padding:"2px 8px",fontSize:11,border:"none",cursor:"pointer",background:C?"var(--bg-hover)":"var(--bg-selected)",color:C?"var(--text-muted)":"var(--text)",fontWeight:C?400:600},children:u("desktop.code")}),(0,r.jsx)("button",{onClick:()=>T(!0),style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:"1px solid var(--border)",cursor:"pointer",background:C?"var(--bg-selected)":"var(--bg-hover)",color:C?"var(--text)":"var(--text-muted)",fontWeight:C?600:400},children:u("desktop.preview")})]}),ek&&"source"===R&&!L&&(0,r.jsxs)("div",{style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:[(0,r.jsx)("button",{onClick:()=>T(!0),style:{padding:"2px 8px",fontSize:11,border:"none",cursor:"pointer",background:C?"var(--bg-selected)":"var(--bg-hover)",color:C?"var(--text)":"var(--text-muted)",fontWeight:C?600:400},children:u("desktop.preview")}),(0,r.jsx)("button",{onClick:()=>T(!1),style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:"1px solid var(--border)",cursor:"pointer",background:C?"var(--bg-hover)":"var(--bg-selected)",color:C?"var(--text-muted)":"var(--text)",fontWeight:C?400:600},children:u("desktop.raw")})]}),L?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onClick:()=>void ea(),disabled:_,title:u("files.saveHint"),"aria-label":u("files.save"),style:{height:20,minWidth:20,padding:"0 5px",display:"inline-flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-selected)",color:"var(--text)",cursor:"pointer"},children:(0,r.jsx)(ay.g,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:ei,disabled:_,title:u("files.cancelEdit"),"aria-label":u("files.cancelEdit"),style:{height:20,minWidth:20,padding:"0 5px",display:"inline-flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer"},children:(0,r.jsx)(h.X,{size:13,"aria-hidden":"true"})})]}):"source"===R&&ew?(0,r.jsx)("button",{type:"button",onClick:en,title:u("files.edit"),"aria-label":u("files.edit"),style:{height:20,minWidth:20,padding:"0 5px",display:"inline-flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer"},children:(0,r.jsx)(f.I,{size:13,"aria-hidden":"true"})}):null,(i||a)&&!L&&(0,r.jsx)("button",{type:"button",onPointerDown:e=>e.preventDefault(),onClick:()=>{W&&a?ef(W):i?.(ep(e,t),!1)},title:W?u("desktop.mentionSelectedLines",{start:W.startLine,end:W.endLine}):u("desktop.mentionFile"),"aria-label":W?u("desktop.mentionSelectedLines",{start:W.startLine,end:W.endLine}):u("desktop.mentionFile"),style:{height:20,minWidth:20,padding:"0 5px",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer"},children:"@"}),!L&&(0,r.jsx)(aR,{filePath:e,sourceSessionId:o})]}),(0,r.jsx)("div",{ref:N,style:{flex:1,overflow:"auto",background:"var(--bg)"},children:L?(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[G&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 12px",borderBottom:"1px solid var(--border)",background:"rgba(214,168,75,0.14)",color:"#d6a84b",fontSize:11,flexShrink:0},children:[(0,r.jsx)("span",{style:{flex:1},children:u("files.externalModified")}),(0,r.jsx)("button",{type:"button",onClick:()=>{(!ee||window.confirm(u("files.reloadOverwriteConfirm")))&&er(e).then(e=>{e&&(O(e.content),U(e.content),J(!1))})},disabled:_,style:{padding:"2px 8px",fontSize:11,border:"1px solid #d6a84b",borderRadius:4,background:"transparent",color:"#d6a84b",cursor:"pointer"},children:u("files.reload")})]}),V&&(0,r.jsx)("div",{style:{padding:"5px 12px",borderBottom:"1px solid var(--border)",background:"rgba(248,113,113,0.14)",color:"#f87171",fontSize:11,flexShrink:0},children:u("files.saveFailed",{error:V})}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(0,r.jsx)("div",{ref:X,"aria-hidden":"true",style:{...aI,height:"100%",overflow:"hidden",whiteSpace:"pre",pointerEvents:"none"},children:H.split("\n").map((e,t)=>`${t+1}
|
|
37
|
+
`).join("")}),(0,r.jsx)("textarea",{ref:Y,value:H,onChange:e=>O(e.target.value),onScroll:ed,onKeyDown:ec,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",wrap:"off",style:{flex:1,height:"100%",resize:"none",border:"none",outline:"none",background:"var(--bg)",color:"var(--text)",...az,whiteSpace:"pre",overflow:"auto",padding:0,tabSize:2}})]})]}):"diff"===R&&eb?eh?(0,r.jsx)(aN,{patch:v.patch}):(0,r.jsx)(aA,{oldContent:x,newContent:g.content}):ex&&C?(0,r.jsx)("iframe",{srcDoc:g.content,sandbox:"allow-scripts",style:{width:"100%",height:"100%",border:"none",background:"var(--bg)"},title:u("desktop.htmlPreview")}):ek&&C?(0,r.jsx)("div",{className:"markdown-body markdown-file-preview",style:{padding:"24px 32px"},children:(0,r.jsx)(on.oz,{remarkPlugins:rm,rehypePlugins:rf,components:{h1:({children:e})=>(0,r.jsx)("h1",{id:rp(e),children:e}),h2:({children:e})=>(0,r.jsx)("h2",{id:rp(e),children:e}),h3:({children:e})=>(0,r.jsx)("h3",{id:rp(e),children:e}),code({className:e,children:t,...o}){let n=e?.replace("language-","").toLowerCase()??"",s=String(t);return e?.includes("language-")||s.includes("\n")?"mermaid"===n?(0,r.jsx)(rE,{code:s.replace(/\n$/,"")}):(0,r.jsx)(rD,{code:s.replace(/\n$/,""),lang:n}):(0,r.jsx)("code",{className:"inline max-w-full whitespace-normal break-words [overflow-wrap:anywhere] align-baseline bg-(--bg-secondary) border border-(--border) px-1.5 py-0.5 text-xs font-mono text-(--accent-blue)",...o,children:t})},pre:({children:e})=>(0,r.jsx)(r.Fragment,{children:e}),a({href:e,children:o,...n}){delete n.node;let i="text-(--accent-blue) underline underline-offset-2 hover:text-(--accent-blue)/80",a=s?oe(e,ev,t??ev):null;return a&&s?(0,r.jsx)("a",{href:e,...n,className:i,onClick:e=>{if(e.defaultPrevented||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.currentTarget.getAttribute("target");t&&"_self"!==t||(e.preventDefault(),s(a))},children:o}):(0,r.jsx)("a",{href:e,...n,className:i,target:"_blank",rel:"noopener noreferrer",children:o})},table:({children:e})=>(0,r.jsx)("div",{className:"my-3 rounded-lg overflow-hidden border border-(--border)",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsx)("table",{className:"w-full text-sm border-collapse [&_tr:last-child>td]:border-b-0",children:e})})})},children:eu})}):(0,r.jsx)(os.A,{language:"text"===g.language?"plaintext":g.language,style:rx,showLineNumbers:!0,lineNumberStyle:{color:"var(--text-dim)",fontStyle:"normal",minWidth:"3em",paddingRight:"1em"},customStyle:{margin:0,padding:"12px 0",background:"var(--bg)",fontSize:13,lineHeight:1.6,fontFamily:"var(--font-mono)",minHeight:"100%"},codeTagProps:{style:{fontFamily:"var(--font-mono)"}},lineProps:e=>({className:"file-source-line","data-line-number":String(e)}),wrapLongLines:I,children:g.content})})]})}function aU({tabs:e,activeTabId:t,onSelectTab:o,onCloseTab:s}){let{t:i}=(0,A.s)(),[a,l]=(0,n.useState)(null);return(0,r.jsx)("div",{role:"tablist",style:{display:"flex",alignItems:"flex-end",background:"var(--bg-panel)",overflowX:"auto",flexShrink:0,height:36},children:e.map(n=>{let d=n.id===t;return(0,r.jsxs)("div",{role:"tab","aria-label":"terminal"===n.kind?i("terminal.tabLabel",{name:n.label}):n.label,"aria-selected":d,tabIndex:d||!t&&e[0].id===n.id?0:-1,onKeyDown:t=>{if(t.target===t.currentTarget){if("Enter"===t.key||" "===t.key)t.preventDefault(),o(n.id);else if(["ArrowLeft","ArrowRight","Home","End"].includes(t.key)){t.preventDefault();let r=e.findIndex(e=>e.id===n.id),s="Home"===t.key?0:"End"===t.key?e.length-1:(r+("ArrowRight"===t.key?1:-1)+e.length)%e.length;o(e[s].id),t.currentTarget.parentElement?.children[s]?.focus()}}},onClick:()=>o(n.id),onMouseDown:e=>{1===e.button&&e.preventDefault()},onAuxClick:e=>{1===e.button&&(e.preventDefault(),e.stopPropagation(),n.closing||s(n.id))},style:{display:"flex",alignItems:"center",gap:6,height:36,paddingLeft:12,paddingRight:6,borderRight:"1px solid var(--border)",background:d?"var(--bg)":"var(--bg-panel)",cursor:"pointer",fontSize:12,color:d?"var(--text)":"var(--text-muted)",whiteSpace:"nowrap",maxWidth:180,minWidth:80,flexShrink:0,userSelect:"none",transition:"background 0.1s, color 0.1s"},children:[(0,r.jsx)("span",{style:{flexShrink:0,opacity:d?1:.7,display:"flex",alignItems:"center"},children:"terminal"===n.kind?(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,r.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}):ea(n.label,13)}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,fontWeight:d?500:400},title:n.filePath,children:n.label}),(0,r.jsx)("button",{disabled:n.closing,onClick:e=>{e.stopPropagation(),s(n.id)},onMouseEnter:()=>l(n.id),onMouseLeave:()=>l(null),style:{display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,background:a===n.id?"var(--bg-hover)":"transparent",border:"none",borderRadius:4,color:a===n.id?"var(--text)":"var(--text-dim)",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.1s, color 0.1s"},title:i("desktop.closeTab"),"aria-label":i("desktop.closeTabWithLabel",{label:n.label}),children:(0,r.jsx)(h.X,{size:11,"aria-hidden":"true"})})]},n.id)})})}var a_=o(27289),aq=o(93534),aV=o(45781),aK=o(68731),aG=o(93912),aJ=o(23675),aY=o(48716),aX=o(47013),aZ=o(51265);let aQ={"restore-script":"restore","generate-cmd":"cmd",keep:"keep","keep-with-warning":"warning",manual:"manual"};function a0({cwd:e}){let{t}=(0,A.s)(),o=(0,n.useRef)(null),[s,i]=(0,n.useState)(!0),[a,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(!1),[p,u]=(0,n.useState)(null),[h,g]=(0,n.useState)(null),[m,f]=(0,n.useState)(new Set),[x,k]=(0,n.useState)(new Set),[v,y]=(0,n.useState)(!1),[b,w]=(0,n.useState)(null),[j,S]=(0,n.useState)(!1),[C,T]=(0,n.useState)(null),[R,z]=(0,n.useState)([]),[I,M]=(0,n.useState)(""),[P,E]=(0,n.useState)(null),[W,F]=(0,n.useState)(null);(0,n.useEffect)(()=>{fetch("/api/models").then(e=>e.json()).then(e=>{let t=Array.isArray(e.modelList)?e.modelList:[];z(t),t.length>0&&M(`${t[0].provider}/${t[0].id}`)}).catch(()=>{})},[]);let D=(0,n.useCallback)(async()=>{c(!0),u(null);try{let e=await fetch("/api/backup/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({includeSecrets:s,includeSessions:a})});if(!e.ok){let t=await e.json();u(t.error??`HTTP ${e.status}`);return}let t=await e.blob(),o=(e.headers.get("Content-Disposition")??"").match(/filename="?([^";]+)"?/),r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download=o?.[1]??"pi-backup.zip",document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(r)}catch{u(String(t("desktop.backupExportFailed")))}finally{c(!1)}},[s,a,t]),N=(0,n.useCallback)(async e=>{if(e){w(null),T(null),g(null);try{let o=new FormData;o.append("phase","parse"),o.append("file",e);let r=await fetch("/api/backup/import",{method:"POST",body:o}),n=await r.json();if(!r.ok||n.error)return void w(n.error??`HTTP ${r.status}`);if("preview"!==n.phase||!n.preview)return void w(String(t("desktop.backupImportFailed")));g(n),f(new Set(n.preview.categories)),k(new Set),y(!1)}catch{w(String(t("desktop.backupImportFailed")))}}},[t]),L=(0,n.useCallback)(async()=>{if(h){S(!0),w(null);try{let e=new FormData;e.append("phase","restore"),e.append("token",h.token),e.append("selections",JSON.stringify({categories:[...m],skippedMcpServers:[...x],reinstallNpm:v}));let r=await fetch("/api/backup/import",{method:"POST",body:e}),n=await r.json();if(!r.ok||n.error)return void w(n.error??`HTTP ${r.status}`);if("report"!==n.phase||!n.report)return void w(String(t("desktop.backupRestoreFailed")));T(n.report),g(null),o.current&&(o.current.value="")}catch{w(String(t("desktop.backupRestoreFailed")))}finally{S(!1)}}},[h,m,x,v,t]),$=(0,n.useCallback)(async o=>{if(o.installPrompt&&e){E(o.name),F(null);try{let t=I.indexOf("/"),r=t>0?I.slice(0,t):void 0,n=t>0?I.slice(t+1):void 0,s=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,message:o.installPrompt,provider:r,modelId:n})}),i=await s.json();if(!s.ok||i.error)return void w(i.error??`HTTP ${s.status}`);F({server:o.name,sessionId:i.sessionId})}catch{w(String(t("desktop.backupInstallSessionFailed")))}finally{E(null)}}},[e,I,t]),H=e=>"win32"===e?"Windows":"darwin"===e?"macOS":"Linux";return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0,overflowY:"auto"},children:[(0,r.jsx)("header",{style:{padding:"18px 22px 14px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("h1",{style:{margin:0,fontSize:16,fontWeight:700,color:"var(--text)"},children:t("desktop.backup")})}),(0,r.jsxs)("section",{style:{padding:"18px 22px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("h2",{style:{margin:0,fontSize:13,fontWeight:600,color:"var(--text)"},children:t("desktop.backupExportTitle")}),(0,r.jsx)("p",{style:{margin:"6px 0 12px",fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:t("desktop.backupExportDescription")}),(0,r.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"flex-start",cursor:"pointer",marginBottom:8},children:[(0,r.jsx)("input",{type:"checkbox",checked:s,onChange:e=>i(e.target.checked),style:{marginTop:2}}),(0,r.jsxs)("span",{style:{fontSize:12,color:"var(--text)"},children:[t("desktop.backupIncludeSecrets"),(0,r.jsx)("span",{style:{display:"block",fontSize:11,color:"#ef4444"},children:t("desktop.backupSecretsWarning")})]})]}),(0,r.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"flex-start",cursor:"pointer",marginBottom:14},children:[(0,r.jsx)("input",{type:"checkbox",checked:a,onChange:e=>l(e.target.checked),style:{marginTop:2}}),(0,r.jsxs)("span",{style:{fontSize:12,color:"var(--text)"},children:[t("desktop.backupIncludeSessions"),(0,r.jsx)("span",{style:{display:"block",fontSize:11,color:"var(--text-dim)"},children:t("desktop.backupSessionsHint")})]})]}),(0,r.jsxs)("button",{type:"button",onClick:D,disabled:d,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 14px",background:"var(--accent)",border:"none",borderRadius:6,color:"#fff",fontSize:12,fontWeight:600,cursor:d?"wait":"pointer"},children:[(0,r.jsx)(aX.f,{size:15,"aria-hidden":"true"}),d?t("desktop.backupExporting"):t("desktop.backupExportButton")]}),p&&(0,r.jsx)("p",{style:{margin:"8px 0 0",fontSize:11,color:"#ef4444"},children:p})]}),(0,r.jsxs)("section",{style:{padding:"18px 22px"},children:[(0,r.jsx)("h2",{style:{margin:0,fontSize:13,fontWeight:600,color:"var(--text)"},children:t("desktop.backupImportTitle")}),(0,r.jsx)("p",{style:{margin:"6px 0 12px",fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:t("desktop.backupImportDescription")}),(0,r.jsx)("input",{ref:o,type:"file",accept:".zip,application/zip",onChange:e=>N(e.target.files?.[0]),style:{display:"none"}}),(0,r.jsxs)("button",{type:"button",onClick:()=>o.current?.click(),style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 14px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,fontWeight:600,cursor:"pointer"},children:[(0,r.jsx)(aZ._,{size:15,"aria-hidden":"true"}),t("desktop.backupImportButton")]}),b&&(0,r.jsx)("p",{style:{margin:"0 0 10px",fontSize:11,color:"#ef4444",lineHeight:1.5},children:b}),h&&(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:8,padding:14,background:"var(--bg-panel)",display:"flex",flexDirection:"column",gap:12},children:[(0,r.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:[(0,r.jsxs)("span",{style:{color:"var(--text)",fontWeight:600},children:[t("desktop.backupManifest"),":"]})," ",new Date(h.preview.manifest.createdAt).toLocaleString()," \xb7 ",H(h.preview.manifest.sourcePlatform)," →",H(navigator.platform.includes("Win")?"win32":navigator.platform.includes("Linux")?"linux":"darwin")," \xb7 pi-web ",h.preview.manifest.piWebVersion,h.preview.manifest.includeSecrets?"":` \xb7 ${t("desktop.backupNoSecrets")}`]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:6},children:t("desktop.backupCategories")}),(0,r.jsx)("div",{style:{display:"flex",gap:14,flexWrap:"wrap"},children:h.preview.categories.map(e=>(0,r.jsxs)("label",{style:{display:"flex",gap:6,alignItems:"center",cursor:"pointer",fontSize:12,color:"var(--text)"},children:[(0,r.jsx)("input",{type:"checkbox",checked:m.has(e),onChange:t=>{let o=new Set(m);t.target.checked?o.add(e):o.delete(e),f(o)}}),t(`desktop.backupCategory${e}`)]},e))})]}),h.preview.servers.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:6},children:t("desktop.backupMcpServers")}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:h.preview.servers.map(o=>(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,fontSize:12},children:[(0,r.jsx)("input",{type:"checkbox",checked:!x.has(o.name),onChange:e=>{let t=new Set(x);e.target.checked?t.delete(o.name):t.add(o.name),k(t)},style:{marginTop:2}}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:2},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("code",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text)"},children:o.name}),(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:8,background:"manual"===o.action||"keep-with-warning"===o.action?"rgba(239,68,68,0.15)":"var(--bg-selected)",color:"manual"===o.action||"keep-with-warning"===o.action?"#ef4444":"var(--text-muted)"},children:aQ[o.action]})]}),(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[(0,r.jsx)("code",{style:{fontFamily:"var(--font-mono)"},children:o.original.command}),o.adapted&&o.adapted.command!==o.original.command&&(0,r.jsxs)(r.Fragment,{children:[" → ",(0,r.jsx)("code",{style:{fontFamily:"var(--font-mono)",color:"var(--text)"},children:o.adapted.command})]})]}),o.reason&&(0,r.jsx)("div",{style:{fontSize:11,color:"#ef4444"},children:o.reason}),"manual"===o.action&&o.installPrompt&&e&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:2,flexWrap:"wrap"},children:[(0,r.jsx)("select",{value:I,onChange:e=>M(e.target.value),style:{fontSize:11,padding:"4px 6px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text)",maxWidth:220},title:t("desktop.backupInstallModel"),children:R.map(e=>(0,r.jsxs)("option",{value:`${e.provider}/${e.id}`,children:[e.provider,"/",e.name||e.id]},`${e.provider}/${e.id}`))}),(0,r.jsx)("button",{type:"button",disabled:P===o.name,onClick:()=>$(o),style:{padding:"4px 10px",fontSize:11,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text)",cursor:P===o.name?"wait":"pointer"},children:P===o.name?"…":t("desktop.backupInstallSession")}),W?.server===o.name&&(0,r.jsx)("a",{href:`?session=${encodeURIComponent(W.sessionId)}`,style:{fontSize:11,color:"var(--accent)"},children:t("desktop.backupOpenSession")})]})]})]},o.name))})]}),h.preview.npmPackages.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:6},children:t("desktop.backupNpmPackages")}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:6},children:h.preview.npmPackages.map(e=>(0,r.jsx)("code",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text)"},children:e},e))}),(0,r.jsxs)("label",{style:{display:"flex",gap:6,alignItems:"flex-start",cursor:"pointer",fontSize:12,color:"var(--text)",lineHeight:1.4},children:[(0,r.jsx)("input",{type:"checkbox",checked:v,onChange:e=>y(e.target.checked),style:{marginTop:2}}),(0,r.jsxs)("span",{children:[t("desktop.backupReinstallNpm"),(0,r.jsx)("span",{style:{display:"block",fontSize:11,color:"var(--text-dim)"},children:t("desktop.backupReinstallNpmHint")})]})]})]}),h.preview.warnings.length>0&&(0,r.jsx)("div",{style:{fontSize:11,color:"#ef4444",lineHeight:1.5},children:h.preview.warnings.map((e,t)=>(0,r.jsxs)("div",{children:["⚠ ",e]},t))}),(0,r.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,r.jsxs)("button",{type:"button",onClick:L,disabled:j||0===m.size,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 14px",background:"var(--accent)",border:"none",borderRadius:6,color:"#fff",fontSize:12,fontWeight:600,cursor:j?"wait":"pointer",opacity:0===m.size?.5:1},children:[(0,r.jsx)(aZ._,{size:15,"aria-hidden":"true"}),j?t("desktop.backupRestoring"):t("desktop.backupRestoreButton")]}),(0,r.jsx)("button",{type:"button",onClick:()=>{g(null),o.current&&(o.current.value="")},disabled:j,style:{padding:"8px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",fontSize:12,cursor:"pointer"},children:t("desktop.cancel")})]})]}),C&&(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:8,padding:14,background:"var(--bg-panel)",display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:"var(--text)"},children:[(0,r.jsx)(rQ.W,{size:16,"aria-hidden":"true"}),t("desktop.backupRestoreReport")]}),C.restored.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{fontSize:11,fontWeight:600,color:"#4ade80",marginBottom:4},children:["✓ ",t("desktop.backupReportRestored")]}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.6,fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:C.restored.join("\n")})]}),C.needsRestart.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{fontSize:11,fontWeight:600,color:"#fbbf24",marginBottom:4},children:["\uD83D\uDD04 ",t("desktop.backupReportRestart")]}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.6,fontFamily:"var(--font-mono)"},children:C.needsRestart.join("\n")})]}),C.manual.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{fontSize:11,fontWeight:600,color:"#ef4444",marginBottom:4},children:[(0,r.jsx)(X.N,{size:12,style:{verticalAlign:-2},"aria-hidden":"true"})," ",t("desktop.backupReportManual")]}),C.manual.map((e,t)=>(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.6},children:[(0,r.jsx)("strong",{style:{color:"var(--text)"},children:e.server}),": ",e.message]},t))]}),C.warnings.length>0&&(0,r.jsx)("div",{style:{fontSize:11,color:"#ef4444",lineHeight:1.6},children:C.warnings.map((e,t)=>(0,r.jsxs)("div",{children:["⚠ ",e]},t))}),C.needsRestart.length>0&&(0,r.jsx)("p",{style:{margin:0,fontSize:11,color:"#fbbf24",lineHeight:1.5},children:t("desktop.backupRestartHint")})]})]})]})}let a1={position:"relative",width:40,height:22,borderRadius:11,border:"none",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.18s ease",outline:"none"},a2={position:"absolute",top:3,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left 0.18s ease, transform 0.18s ease",boxShadow:"0 1px 3px rgba(0,0,0,0.18)"};function a4({checked:e,onChange:t,label:o,description:n}){return(0,r.jsxs)("label",{style:{display:"flex",alignItems:n?"flex-start":"center",justifyContent:"space-between",gap:12,padding:"12px 14px",borderRadius:7,cursor:"pointer",userSelect:"none",transition:"background 0.12s",margin:"0 -14px"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:[(0,r.jsxs)("span",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("span",{style:{display:"block",fontSize:13,fontWeight:550,color:"var(--text)",lineHeight:1.4},children:o}),n&&(0,r.jsx)("span",{style:{display:"block",fontSize:11,lineHeight:1.5,color:"var(--text-muted)",marginTop:2},children:n})]}),(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":e,onClick:o=>{o.preventDefault(),t(!e)},style:{...a1,background:e?"var(--accent)":"color-mix(in srgb, var(--border) 70%, var(--bg))"},children:(0,r.jsx)("span",{style:{...a2,left:e?21:3}})})]})}function a6({title:e,description:t,children:o}){return(0,r.jsxs)("section",{style:{padding:"20px 22px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("h2",{style:{margin:0,fontSize:14,fontWeight:650,color:"var(--text)"},children:e}),(0,r.jsx)("p",{style:{margin:"5px 0 14px",fontSize:12,lineHeight:1.5,color:"var(--text-muted)"},children:t}),(0,r.jsx)("div",{children:o})]})}let a8="pi-input-shortcut";function a5(){try{let e=localStorage.getItem(a8);return"ctrl-enter"===e?"ctrl-enter":"enter"}catch{return"enter"}}function a3(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)(a5);(0,n.useEffect)(()=>{let e=()=>o(a5());return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]);let s=(0,n.useCallback)(e=>{o(e);try{localStorage.setItem(a8,e),window.dispatchEvent(new StorageEvent("storage",{key:a8,newValue:e}))}catch{}},[]);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0,overflowY:"auto"},children:[(0,r.jsx)("header",{style:{padding:"18px 22px 14px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("h1",{style:{margin:0,fontSize:16,fontWeight:700,color:"var(--text)"},children:e("desktop.chat")})}),(0,r.jsx)(a6,{title:e("desktop.inputShortcut"),description:e("desktop.inputShortcutDescription"),children:(0,r.jsx)(a4,{checked:"ctrl-enter"===t,onChange:e=>s(e?"ctrl-enter":"enter"),label:e("desktop.useCtrlEnter"),description:e("desktop.useCtrlEnterDescription")})})]})}var a7=o(95650),a9=o(55803),le=o(23602),lt=o(18613),lo=o(12779);let lr={display:"flex",gap:6,flexWrap:"wrap"};function ln(e,t,o){return{display:"inline-flex",alignItems:"center",gap:7,padding:"7px 14px",border:`1px solid ${e?"var(--accent)":t?"var(--border-hover)":"var(--border)"}`,borderRadius:8,background:e?"color-mix(in srgb, var(--accent) 12%, var(--bg))":t?"var(--bg-hover)":"var(--bg-card)",color:e?"var(--accent)":t?"var(--text)":"var(--text-muted)",fontSize:13,fontWeight:e?600:400,cursor:o?"not-allowed":"pointer",opacity:o?.5:1,transition:"border-color 0.15s, background 0.15s, color 0.15s",outline:"none",whiteSpace:"nowrap"}}function ls({icon:e,label:t,actions:o}){return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10,width:"100%"},children:[(0,r.jsx)("span",{style:{color:"var(--text-dim)",display:"inline-flex",flexShrink:0},children:e}),(0,r.jsx)("span",{style:{fontSize:11,fontWeight:700,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em"},children:t}),o&&(0,r.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:12,marginLeft:"auto"},children:o})]})}let li={display:"inline-flex",alignItems:"center",gap:6,padding:0,border:0,background:"transparent",color:"var(--accent)",fontSize:11,cursor:"pointer",whiteSpace:"nowrap"},la={onMouseEnter:e=>{e.currentTarget.style.textDecoration="underline"},onMouseLeave:e=>{e.currentTarget.style.textDecoration="none"}};function ll({title:e,description:t,children:o}){return(0,r.jsxs)("section",{style:{padding:"20px 22px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("h2",{style:{margin:0,fontSize:14,fontWeight:650,color:"var(--text)"},children:e}),(0,r.jsx)("p",{style:{margin:"5px 0 16px",fontSize:12,lineHeight:1.5,color:"var(--text-muted)"},children:t}),o]})}function ld({depth:e}){let t=e/100;return(0,r.jsxs)("svg",{width:14,height:14,viewBox:"0 0 14 14",style:{flexShrink:0},children:[(0,r.jsx)("rect",{x:1.5,y:1.5,width:11,height:11,rx:2.5,style:{fill:"none",stroke:"var(--text-dim)",strokeWidth:1+2*t,opacity:.2+.8*t}}),(0,r.jsx)("rect",{x:4,y:4,width:6,height:6,rx:1,style:{fill:"var(--text-dim)",opacity:.05+.35*t}})]})}function lc({hasDark:e,hasLight:t,darkColor:o,lightColor:n,t:s}){return(0,r.jsxs)("span",{style:{display:"inline-flex",gap:3,alignItems:"center",flexShrink:0},children:[e&&(0,r.jsx)("span",{title:s("desktop.darkVariant"),style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:o??"#7c6f64"}}),t&&(0,r.jsx)("span",{title:s("desktop.lightVariant"),style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:n??"#d5c4a1",border:"1px solid rgba(0,0,0,0.1)"}})]})}function lp(){let{mode:e,resolvedMode:t,themeName:o,setMode:s,setTheme:i,previewTheme:a,clearPreview:l,isThemeCached:d,borderDepth:c,setBorderDepth:p}=o9(),{locale:u,setLocale:h,t:g}=(0,A.s)(),[m,f]=(0,n.useState)([]),[x,k]=(0,n.useState)(!0),[v,y]=(0,n.useState)(null),[b,w]=(0,n.useState)(null);(0,n.useEffect)(()=>{let e=!1;return fetch("/api/themes").then(e=>e.ok?e.json():null).then(t=>{!e&&t&&f(t.themeSets)}).catch(()=>{}).finally(()=>{e||k(!1)}),()=>{e=!0}},[]);let j=(0,n.useCallback)(e=>{y(e),i(e).finally(()=>y(null))},[i]),S=(0,n.useRef)(null),C=(0,n.useCallback)(e=>{w(e),null!==S.current&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{S.current=null,null!==e?d(e)&&a(e):l()},160)},[a,l,d]),T=(0,n.useCallback)(e=>{s(e)},[s]),R=(0,n.useCallback)(()=>{window.piDesktop?.openThemeFolder()},[]),z=(0,n.useCallback)(()=>{window.piDesktop?window.piDesktop.openThemeDocs():window.open("https://pi.dev/docs/latest/themes","_blank","noopener,noreferrer")},[]);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0,overflowY:"auto"},children:[(0,r.jsx)("header",{style:{padding:"18px 22px 14px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("h1",{style:{margin:0,fontSize:16,fontWeight:700,color:"var(--text)"},children:g("desktop.display")})}),(0,r.jsxs)(ll,{title:g("desktop.theme"),description:g("desktop.themeDescription"),children:[(0,r.jsx)(ls,{icon:(0,r.jsx)(a7.p,{size:14,weight:"fill"}),label:g("desktop.colorScheme"),actions:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button",onClick:R,style:li,...la,children:[(0,r.jsx)(a9.N,{size:12,weight:"regular","aria-hidden":"true"}),g("desktop.openThemeFolder")]}),(0,r.jsxs)("button",{type:"button",onClick:z,style:li,...la,children:[(0,r.jsx)(le.B,{size:12,weight:"regular","aria-hidden":"true"}),g("desktop.learnPiThemes")]})]})}),x?(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-dim)"},children:g("desktop.loadingThemes")}):(0,r.jsxs)("div",{style:lr,children:[(0,r.jsx)("button",{type:"button",onClick:()=>j(""),disabled:null!==v,style:ln(""===o,"__default__"===b,null!==v),onMouseEnter:()=>C(""),onMouseLeave:()=>C(null),children:g("desktop.defaultTheme")}),m.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>j(e.name),disabled:null!==v,style:ln(o===e.name,b===e.name,v===e.name),onMouseEnter:()=>C(e.name),onMouseLeave:()=>C(null),children:[e.displayName,(0,r.jsx)(lc,{hasDark:e.hasDark,hasLight:e.hasLight,darkColor:e.accent,lightColor:e.accentLight,t:g})]},e.name))]}),(0,r.jsxs)("div",{style:{marginTop:20},children:[(0,r.jsx)(ls,{icon:(0,r.jsx)(ld,{depth:c}),label:`${g("desktop.borderVisibility")} (${c})`}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",flexShrink:0},children:g("desktop.borderSubtle")}),(0,r.jsx)("input",{type:"range",min:0,max:100,step:1,value:c,onChange:e=>p(Number(e.target.value)),style:{flex:1,accentColor:"var(--accent)",height:6,cursor:"pointer"}}),(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",flexShrink:0},children:g("desktop.borderBold")})]}),(0,r.jsx)("div",{style:{marginTop:10,display:"flex",gap:10},children:[0,25,50,75,100].map(e=>{let t=c===e,o=e<=50?`color-mix(in srgb, var(--border-orig) ${2*e}%, var(--bg) ${100-2*e}%)`:`color-mix(in srgb, var(--border-orig) ${100-(e-50)*2}%, var(--text) ${(e-50)*2}%)`;return(0,r.jsx)("div",{onClick:()=>p(e),style:{width:28,height:20,border:`2px solid ${t?"var(--accent)":o}`,borderRadius:5,background:"var(--bg-card)",cursor:"pointer",transition:"border-color 0.1s"}},e)})})]}),(0,r.jsxs)("div",{style:{marginTop:20},children:[(0,r.jsx)(ls,{icon:"dark"===t?(0,r.jsx)(lt.A,{size:14,weight:"fill"}):(0,r.jsx)(lo.b,{size:14,weight:"fill"}),label:g("desktop.appearanceMode")}),(0,r.jsx)("div",{style:lr,children:[{value:"light",icon:(0,r.jsx)(lo.b,{size:15,weight:"light"===e?"fill":"regular"})},{value:"dark",icon:(0,r.jsx)(lt.A,{size:15,weight:"dark"===e?"fill":"regular"})},{value:"system",icon:(0,r.jsx)(aq.V,{size:15,weight:"system"===e?"fill":"regular"})}].map(t=>{let o=e===t.value;return(0,r.jsxs)("button",{type:"button",onClick:()=>T(t.value),style:ln(o,b===`mode:${t.value}`),onMouseEnter:()=>w(`mode:${t.value}`),onMouseLeave:()=>w(null),children:[t.icon,g(`desktop.${t.value}`)]},t.value)})})]}),!x&&0===m.length&&(0,r.jsxs)("p",{style:{margin:"14px 0 0",fontSize:11,color:"var(--text-dim)",lineHeight:1.5},children:[g("desktop.noCustomThemes")," ",g("desktop.noCustomThemesHint")," ",(0,r.jsx)("code",{style:{fontSize:10,background:"var(--bg-secondary)",padding:"1px 5px",borderRadius:3,fontFamily:"var(--font-mono)"},children:"~/.pi/agent/themes/*.json"})," ",g("desktop.noCustomThemesHint2")]})]}),(0,r.jsx)(ll,{title:g("desktop.language"),description:g("desktop.languageDescription"),children:(0,r.jsx)("div",{style:lr,children:["en","zh-CN"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>h("zh-CN"===e?"zh-CN":"en"),style:ln("zh-CN"===e?"zh-CN"===u:"zh-CN"!==u,b===`lang:${e}`),onMouseEnter:()=>w(`lang:${e}`),onMouseLeave:()=>w(null),children:"en"===e?g("desktop.english"):g("desktop.chinese")},e))})})]})}var lu=o(94638);function lh({children:e}){return(0,r.jsx)("div",{style:{borderRadius:12,border:"1px solid var(--border)",background:"color-mix(in srgb, var(--bg-panel) 55%, transparent)",overflow:"hidden"},children:e})}function lg({children:e}){return(0,r.jsx)("div",{style:{padding:"0 14px"},children:(0,r.jsx)("div",{style:{borderBottom:"1px solid var(--border)"},children:e})})}function lm({children:e}){return(0,r.jsx)("div",{style:{padding:"0 14px"},children:e})}function lf({children:e}){return(0,r.jsx)("div",{style:{display:"flex",gap:8,borderRadius:10,border:"1px solid var(--border)",background:"color-mix(in srgb, var(--bg-panel) 55%, transparent)",padding:"10px 12px",fontSize:12,lineHeight:1.5,color:"var(--text-muted)"},children:e})}let lx=[{value:"normal",labelKey:"modes.collabNormal"},{value:"plan",labelKey:"modes.collabPlan"},{value:"goal",labelKey:"modes.collabGoal"}],lk=[{value:"economy",labelKey:"modes.tokenEconomy"},{value:"full",labelKey:"modes.tokenFull"},{value:"delivery",labelKey:"modes.tokenDelivery"}],lv=[{value:"ask",labelKey:"modes.approvalAsk"},{value:"auto",labelKey:"modes.approvalAuto"},{value:"yolo",labelKey:"modes.approvalYolo"}];function ly({options:e,value:t,onChange:o,disabled:n,accentFor:s}){let{t:i}=(0,A.s)();return(0,r.jsx)("div",{role:"radiogroup",style:{display:"flex",border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",height:28,flexShrink:0},children:e.map(e=>{let a=e.value===t,l=s?.(e.value);return(0,r.jsx)("button",{type:"button",role:"radio","aria-checked":a,disabled:n,onClick:()=>{e.value!==t&&o(e.value)},style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",padding:"0 12px",background:a?"var(--bg-selected)":"none",border:"none",color:a?l??"var(--accent)":"var(--text-muted)",cursor:n?"not-allowed":"pointer",fontSize:11.5,fontWeight:a?650:500,opacity:n?.5:1,whiteSpace:"nowrap",transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{a||n||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{a||(e.currentTarget.style.background="none")},children:i(e.labelKey)},e.value)})})}function lb(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)({tasksBoard:!0}),[s,i]=(0,n.useState)(null),[a,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=!1;return(async()=>{try{let[t,r]=await Promise.all([fetch("/api/features"),fetch("/api/modes")]);if(!e&&t.ok){let e=await t.json();o(t=>({...t,...e}))}if(!e&&r.ok){let e=await r.json();i({collaborationMode:tw(e.collaborationMode),tokenMode:tj(e.tokenMode),toolApprovalMode:tS(e.toolApprovalMode),permissionRules:e.permissionRules??{allow:[],ask:[],deny:[]}})}e||l(!0)}catch{}})(),()=>{e=!0}},[]);let p=(0,n.useCallback)(async e=>{c(!0);try{let t=await fetch("/api/features",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tasksBoard:e})});if(t.ok){let e=await t.json();o(t=>({...t,...e.features})),window.dispatchEvent(new CustomEvent("pi:features-changed"))}}catch{}finally{c(!1)}},[]),u=(0,n.useCallback)(async e=>{c(!0);try{let t=await fetch("/api/modes",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok){let e=await t.json();i(t=>t?{...t,collaborationMode:tw(e.modes?.collaborationMode??t.collaborationMode),tokenMode:tj(e.modes?.tokenMode??t.tokenMode),toolApprovalMode:tS(e.modes?.toolApprovalMode??t.toolApprovalMode),permissionRules:e.modes?.permissionRules??t.permissionRules}:t),window.dispatchEvent(new CustomEvent("pi:modes-changed"))}}catch{}finally{c(!1)}},[]);return(0,r.jsx)("div",{style:{flex:1,overflow:"auto",minWidth:0,padding:"20px 22px",display:"flex",flexDirection:"column",gap:16},children:(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[a?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lh,{children:(0,r.jsx)(lm,{children:(0,r.jsx)(a4,{checked:t.tasksBoard,onChange:e=>void p(e),label:(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,r.jsx)(lu.x,{size:14,"aria-hidden":"true"}),e("desktop.featuresTasksBoard"),(0,r.jsx)("span",{style:{borderRadius:999,background:"rgba(37,99,235,0.12)",color:"var(--accent)",padding:"1px 7px",fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Beta"})]}),description:e("desktop.featuresTasksBoardDesc")})})}),s&&(0,r.jsxs)(lh,{children:[(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"12px 0"},children:[(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:e("desktop.featuresCollabDefault")}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:e("desktop.featuresCollabDefaultDesc")})]}),(0,r.jsx)(ly,{options:lx,value:s.collaborationMode,onChange:e=>void u({collaborationMode:e}),disabled:d})]})}),(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"12px 0"},children:[(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:e("desktop.featuresTokenDefault")}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:e("desktop.featuresTokenDefaultDesc")})]}),(0,r.jsx)(ly,{options:lk,value:s.tokenMode,onChange:e=>void u({tokenMode:e}),disabled:d})]})}),(0,r.jsx)(lm,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"12px 0"},children:[(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:e("desktop.featuresApprovalDefault")}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:e("desktop.featuresApprovalDefaultDesc")})]}),(0,r.jsx)(ly,{options:lv,value:s.toolApprovalMode,onChange:e=>void u({toolApprovalMode:e}),disabled:d,accentFor:e=>"yolo"===e?"var(--accent-red, #ef4444)":void 0})]})})]})]}):(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.featuresLoading")}),(0,r.jsx)(lf,{children:e("desktop.featuresDesc")}),d&&(0,r.jsx)("div",{style:{padding:"0 2px",fontSize:11,color:"var(--text-muted)"},children:e("desktop.featuresSaving")})]})})}var lw=o(76553);function lj({open:e,onClose:t,children:o}){let[s,i]=(0,n.useState)(!1),[a,l]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{if(e)l(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>i(!0)));else{i(!1);let e=setTimeout(()=>l(!1),250);return()=>clearTimeout(e)}},[e]),a)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{onClick:t,style:{position:"fixed",inset:0,zIndex:1001,background:s?"rgba(0,0,0,0.35)":"rgba(0,0,0,0)",transition:"background 0.25s ease"}}),(0,r.jsxs)("div",{style:{position:"fixed",bottom:0,left:0,right:0,zIndex:1002,maxHeight:"85dvh",borderRadius:"16px 16px 0 0",background:"var(--bg)",boxShadow:"0 -4px 24px rgba(0,0,0,0.15)",transform:s?"translateY(0)":"translateY(100%)",transition:"transform 0.25s cubic-bezier(0.32, 0.72, 0, 1)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,r.jsx)("div",{style:{display:"flex",justifyContent:"center",padding:"10px 0 4px",flexShrink:0},children:(0,r.jsx)("div",{style:{width:36,height:4,borderRadius:2,background:"var(--border)"}})}),(0,r.jsx)("div",{style:{flex:1,overflow:"auto",minHeight:0},children:o})]})]}):null}function lS({onSessionsChanged:e}){let{t}=(0,A.s)(),o=O(),[s,i]=(0,n.useState)(null),[a,l]=(0,n.useState)([]),[p,u]=(0,n.useState)([]),[g,m]=(0,n.useState)(new Set),[f,x]=(0,n.useState)(null),[k,v]=(0,n.useState)({imported:0,skipped:0,errors:0,total:0,done:!1}),[y,b]=(0,n.useState)([]),[w,j]=(0,n.useState)(!1),[S,C]=(0,n.useState)({done:0,total:0}),T=(0,n.useRef)(new Map),R=(0,n.useRef)(!1),[z,I]=(0,n.useState)(!1),[M,P]=(0,n.useState)(null),[W,F]=(0,n.useState)(!1),D=(0,n.useCallback)(async()=>{I(!0),P(null);try{let e=await fetch("/api/import/discover"),t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);l(t.sources),t.reasonix?.available&&(u(t.reasonix.projects),i("reasonix"))}catch(e){P(e instanceof Error?e.message:String(e))}finally{I(!1)}},[]),[N,L]=(0,n.useState)(!1);(0,n.useEffect)(()=>{N||(L(!0),D())},[N,D]);let $=(0,n.useCallback)(async()=>{if(0!==g.size&&s){I(!0),P(null);try{let e=await fetch("/api/import/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:s,projects:[...g]})}),t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);x(t.jobId)}catch(e){P(e instanceof Error?e.message:String(e))}finally{I(!1)}}},[s,g]);(0,n.useEffect)(()=>{let t;if(!f)return;let o=!0,r=async()=>{if(o)try{let n=await fetch(`/api/import/status?jobId=${encodeURIComponent(f)}`),s=await n.json();if(!o)return;v({imported:s.imported??0,skipped:s.skipped??0,errors:s.errors??0,total:s.total??0,done:s.done??!1}),s.done&&s.sessionIds&&(b(s.sessionIds),e?.()),s.done||(t=setTimeout(r,800))}catch{o&&(t=setTimeout(r,2e3))}};return r(),()=>{o=!1,clearTimeout(t)}},[f,e]);let H=(0,n.useCallback)(async()=>{if(w){for(let[e,t]of(R.current=!0,T.current))t.abort(),c(e);return}if(0===y.length)return;R.current=!1,j(!0),C({done:0,total:y.length});let t=0,o=0,r=async()=>{for(;!R.current;){let e=y[t++];if(!e)return;let r=new AbortController;T.current.set(e,r);try{await d(e,r.signal)}catch{}finally{T.current.delete(e),C({done:o+=1,total:y.length})}}};await Promise.all(Array.from({length:Math.min(2,y.length)},r)),T.current.clear(),j(!1),e?.()},[w,y,e]);if(k.done&&y.length>0)return(0,r.jsxs)("div",{style:{padding:"18px 22px",display:"flex",flexDirection:"column",gap:14},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)(nv.r,{size:20,weight:"fill",style:{color:"#4ade80"}}),(0,r.jsx)("span",{style:{fontSize:14,fontWeight:600,color:"var(--text)"},children:t("desktop.importDone")??"导入完成"})]}),(0,r.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:[t("desktop.importedSummary",{imported:k.imported})??`成功导入 ${k.imported} 个会话`,k.skipped>0&&(0,r.jsx)("span",{style:{marginLeft:8},children:t("desktop.importSkippedCount",{skipped:k.skipped})??`,${k.skipped} 个跳过`}),k.errors>0&&(0,r.jsx)("span",{style:{marginLeft:8,color:"#ef4444"},children:t("desktop.importErrorsCount",{errors:k.errors})??`,${k.errors} 个失败`})]}),(0,r.jsxs)("button",{type:"button",onClick:H,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 14px",background:"var(--accent)",border:"none",borderRadius:6,color:"#fff",fontSize:12,fontWeight:600,cursor:"pointer",alignSelf:"flex-start"},children:[w?(0,r.jsx)(K.y,{size:14,style:{animation:"spin 1s linear infinite"}}):(0,r.jsx)(lw.o,{size:15}),w?`${t("desktop.importGeneratingTitles")??"正在生成标题…"} (${S.done}/${S.total}) — ${t("desktop.stop")??"停止"}`:t("desktop.importGenerateTitles")??"为导入的会话生成标题"]}),(0,r.jsx)("button",{type:"button",onClick:()=>{x(null),v({imported:0,skipped:0,errors:0,total:0,done:!1}),b([]),j(!1),C({done:0,total:0})},style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",fontSize:12,cursor:"pointer",alignSelf:"flex-start"},children:t("desktop.importAgain")??"再次导入"})]});let B=(0,r.jsxs)("div",{style:{padding:o?"12px 18px":"18px 22px",display:"flex",flexDirection:"column",gap:14},children:[M&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,fontSize:12,color:"#ef4444",lineHeight:1.5},children:[(0,r.jsx)(X.N,{size:14,style:{flexShrink:0,marginTop:1}}),(0,r.jsx)("span",{children:M})]}),!f&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:t("desktop.importSessionsDesc")??"从其他 AI 编码工具导入历史对话记录到 pi-web。目前支持 Reasonix,更多工具陆续支持中。"}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:a.map(e=>(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",border:"1px solid var(--border)",borderRadius:8,cursor:"available"===e.status?"pointer":"default",background:s===e.key?"var(--bg-selected)":"var(--bg-panel)",opacity:"unavailable"===e.status?.5:"coming-soon"===e.status?.7:1,transition:"background 0.12s"},children:[(0,r.jsx)("input",{type:"radio",name:"import-source",value:e.key,checked:s===e.key,disabled:"available"!==e.status,onChange:()=>i(e.key)}),(0,r.jsxs)("div",{style:{flex:1},children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:e.label}),"coming-soon"===e.status&&(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",marginTop:1},children:t("desktop.comingSoon")??"即将支持"})]}),"reasonix"===e.key&&p.length>0&&(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)"},children:[p.length," ",t("desktop.projects")??"个项目"," \xb7 ",p.reduce((e,t)=>e+t.sessions,0)," ",t("desktop.sessions")??"会话"]})]},e.key))}),"reasonix"===s&&p.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)"},children:t("desktop.importSelectProjects")??"选择要导入的项目"}),(0,r.jsx)("button",{type:"button",onClick:()=>m(new Set(p.map(e=>e.name))),style:lC,children:t("desktop.importSelectAll")??"全选"}),(0,r.jsx)("button",{type:"button",onClick:()=>m(new Set),style:lC,children:t("desktop.importDeselectAll")??"取消全选"})]}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:p.map(e=>(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",border:"1px solid var(--border)",borderRadius:6,cursor:"pointer",background:g.has(e.name)?"var(--bg-selected)":"transparent",transition:"background 0.12s"},children:[(0,r.jsx)("input",{type:"checkbox",checked:g.has(e.name),onChange:()=>{var t;return t=e.name,void m(e=>{let o=new Set(e);return o.has(t)?o.delete(t):o.add(t),o})}}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:500,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)",marginTop:2},children:[e.sessions," ",t("desktop.sessions")??"会话",e.matched&&(0,r.jsxs)("span",{style:{marginLeft:8,color:"var(--accent)"},children:["→ ",t("desktop.importMerged")??"合并到现有项目",e.existingCount>0&&` (${t("desktop.importExistingCount",{count:e.existingCount})??`${e.existingCount} 个已有`})`]}),!e.matched&&(0,r.jsxs)("span",{style:{marginLeft:8,color:"var(--text-muted)"},children:["→ ",t("desktop.importNewProject")??"新建项目"]})]})]})]},e.name))}),(0,r.jsx)("button",{type:"button",onClick:$,disabled:z||0===g.size,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 14px",background:"var(--accent)",border:"none",borderRadius:6,color:"#fff",fontSize:12,fontWeight:600,cursor:0===g.size?"not-allowed":"pointer",alignSelf:"flex-start",opacity:0===g.size?.5:1},children:z?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(K.y,{size:14,style:{animation:"spin 1s linear infinite"}})," ",t("desktop.importing")??"导入中…"]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(E.z,{size:15})," ",t("desktop.importStart")??"开始导入"]})})]}),"reasonix"===s&&0===p.length&&!z&&(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",padding:"12px 0"},children:t("desktop.importNoData")??"未找到 Reasonix 数据。请确认 ~/.reasonix/projects/ 目录存在且包含会话文件。"})]}),f&&!k.done&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text)"},children:[(0,r.jsx)(K.y,{size:14,style:{animation:"spin 1s linear infinite"}}),t("desktop.importing")??"导入中…"]}),(0,r.jsx)("div",{style:{height:6,borderRadius:3,background:"var(--bg-panel)",overflow:"hidden"},children:(0,r.jsx)("div",{style:{height:"100%",borderRadius:3,background:"var(--accent)",width:`${k.total>0?(k.imported+k.skipped+k.errors)/k.total*100:0}%`,transition:"width 0.3s ease"}})}),(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:[k.imported+k.skipped+k.errors," / ",k.total,k.skipped>0&&` \xb7 ${t("desktop.importSkippedCount",{skipped:k.skipped})??`${k.skipped} 跳过`}`]})]})]});return o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button",onClick:()=>F(!0),style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",width:"100%",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text)",fontSize:12,cursor:"pointer"},children:[(0,r.jsx)(E.z,{size:16}),(0,r.jsx)("span",{style:{fontWeight:500},children:t("desktop.importSessions")??"导入会话"})]}),(0,r.jsxs)(lj,{open:W,onClose:()=>F(!1),children:[(0,r.jsxs)("div",{style:{padding:"4px 18px 14px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:t("desktop.importSessions")??"导入会话"}),(0,r.jsx)("button",{onClick:()=>F(!1),style:lT,children:(0,r.jsx)(h.X,{size:18})})]}),B]})]}):B}let lC={background:"none",border:"none",color:"var(--accent)",fontSize:11,cursor:"pointer",padding:"2px 4px"},lT={background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",padding:4,display:"flex"},lR="deepseek-vision",lz={padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",width:"100%",boxSizing:"border-box"};function lI(){return{fontSize:12,color:"var(--text-muted)"}}let lM={padding:"7px 12px",border:"none",borderRadius:6,background:"var(--accent)",color:"#fff",cursor:"pointer",fontSize:12};function lP({sessionId:e}){let{t}=(0,A.s)(),[o,s]=(0,n.useState)(!1),[i,a]=(0,n.useState)(null),[l,d]=(0,n.useState)(!1),[c,p]=(0,n.useState)(null),[u,h]=(0,n.useState)(!1),[g,m]=(0,n.useState)({}),[f,x]=(0,n.useState)(""),[k,v]=(0,n.useState)(""),[y,b]=(0,n.useState)("eager"),[w,j]=(0,n.useState)(!1),[S,C]=(0,n.useState)(null),[T,R]=(0,n.useState)(!1),[z,I]=(0,n.useState)(!1),[M,P]=(0,n.useState)({provider:"custom",baseUrl:"",apiKey:"",model:"",maxTokens:4096,hasApiKey:!1}),[E,W]=(0,n.useState)(""),[F,D]=(0,n.useState)(""),[N,L]=(0,n.useState)(!1),[$,H]=(0,n.useState)(null),[O,B]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=!1;return(async()=>{a(null);try{let[t,o]=await Promise.all([fetch("/api/mcp"),fetch("/api/vision-config")]),r=await t.json();if(!t.ok||r.error)throw Error(r.error??`HTTP ${t.status}`);let n=await o.json();if(!o.ok||n.error)throw Error(n.error??`HTTP ${o.status}`);if(e)return;m(r.mcpServers??{}),x(r.filePath);let i=(r.mcpServers??{})[lR];v(i?.command??""),b(i?.lifecycle==="lazy"?"lazy":"eager"),P({provider:n.provider,baseUrl:n.baseUrl,apiKey:"",model:n.model,maxTokens:n.maxTokens,hasApiKey:n.hasApiKey}),n.path&&D(n.path),s(!0)}catch(t){e||a(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[]);let U=(0,n.useCallback)(async()=>{if(!k.trim())return void C(t("desktop.mcpVisionCommandRequired"));j(!0),C(null),R(!1),I(!1);try{let e=g[lR],t={...g,[lR]:{...e??{},command:k.trim(),args:Array.isArray(e?.args)?e.args:[],transport:"stdio",lifecycle:y}},o=await fetch("/api/mcp",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServers:t})}),r=await o.json();if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);m(t),R(!0)}catch(e){C(e instanceof Error?e.message:String(e))}finally{j(!1)}},[g,k,y,t]),_=(0,n.useCallback)(async()=>{j(!0),C(null),R(!1),I(!1);try{let e={...g};delete e[lR];let t=await fetch("/api/mcp",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServers:e})}),o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);m(e),v(""),b("eager"),I(!0)}catch(e){C(e instanceof Error?e.message:String(e))}finally{j(!1)}},[g]),q=(0,n.useCallback)(async()=>{L(!0),H(null),B(!1);try{let e=await fetch("/api/vision-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...M,...E?{apiKey:E}:{}})}),t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);P({...t,apiKey:"",hasApiKey:t.hasApiKey}),W(""),B(!0)}catch(e){H(e instanceof Error?e.message:String(e))}finally{L(!1)}},[M,E]),V=(0,n.useCallback)(async()=>{if(e){d(!0),p(null),h(!1);try{let t=await fetch("/api/mcp/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:e,name:lR})}),o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);h(!0)}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}},[e]),K=!!g[lR];return(0,r.jsxs)(lh,{children:[(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"12px 0"},children:[(0,r.jsx)(sR.k,{size:15,"aria-hidden":"true"}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:t("desktop.mcpVisionTitle")}),(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:3,background:K?"rgba(37,99,235,0.12)":"rgba(245,158,11,0.12)",color:K?"var(--accent)":"#d97706",textTransform:"capitalize"},children:K?t("desktop.mcpVisionRegistered"):t("desktop.mcpVisionNotRegistered")})]}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:t("desktop.mcpVisionDesc")})]})]})}),o?i?(0,r.jsx)(lm,{children:(0,r.jsx)("div",{style:{padding:"8px 0",fontSize:12,color:"#ef4444"},children:i})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lg,{children:(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",padding:"10px 0 2px"},children:t("desktop.mcpVisionRegistration")})}),(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(120px, 180px) 1fr",gap:8,alignItems:"center",padding:"6px 0"},children:[(0,r.jsxs)("span",{style:lI(),children:[t("desktop.mcpVisionCommand")," *"]}),(0,r.jsx)("input",{value:k,onChange:e=>v(e.target.value),placeholder:"/path/to/deepseek-vision-mcp",style:lz}),(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionLifecycle")}),(0,r.jsxs)("select",{value:y,onChange:e=>b(e.target.value),style:{...lz,fontFamily:"var(--font-mono)"},children:[(0,r.jsx)("option",{value:"eager",children:"eager"}),(0,r.jsx)("option",{value:"lazy",children:"lazy"})]}),(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionTransport")}),(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",fontFamily:"var(--font-mono)",padding:"7px 0"},children:t("desktop.mcpVisionTransportFixed")})]})}),(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"6px 0",flexWrap:"wrap"},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void U(),disabled:w,style:{...lM,cursor:w?"wait":"pointer"},children:w?t("desktop.saving"):t("desktop.mcpVisionSaveReg")}),K&&(0,r.jsx)("button",{type:"button",onClick:()=>void _(),disabled:w,title:t("desktop.mcpVisionRemove"),style:{padding:"7px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"#ef4444",cursor:w?"not-allowed":"pointer",fontSize:12},children:t("desktop.mcpVisionRemove")}),T&&(0,r.jsx)("span",{style:{color:"#22c55e",fontSize:12},children:t("desktop.mcpVisionSavedReg")}),z&&(0,r.jsx)("span",{style:{color:"#22c55e",fontSize:12},children:t("desktop.mcpVisionRemoved")}),S&&(0,r.jsx)("span",{style:{color:"#ef4444",fontSize:12},children:S})]})}),(0,r.jsx)(lg,{children:(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",padding:"10px 0 2px"},children:t("desktop.mcpVisionModelConfig")})}),(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(120px, 180px) 1fr",gap:8,alignItems:"center",padding:"6px 0"},children:[(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionProvider")}),(0,r.jsx)("input",{value:M.provider,onChange:e=>P(t=>({...t,provider:e.target.value})),style:lz}),(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionBaseUrl")}),(0,r.jsx)("input",{value:M.baseUrl,onChange:e=>P(t=>({...t,baseUrl:e.target.value})),style:lz}),(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionApiKey")}),(0,r.jsx)("input",{type:"password",value:E,onChange:e=>W(e.target.value),placeholder:M.hasApiKey?"••••••••":"API key",style:lz}),(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionModel")}),(0,r.jsx)("input",{value:M.model,onChange:e=>P(t=>({...t,model:e.target.value})),style:lz}),(0,r.jsx)("span",{style:lI(),children:t("desktop.mcpVisionMaxTokens")}),(0,r.jsx)("input",{type:"number",min:1,value:M.maxTokens,onChange:e=>P(t=>({...t,maxTokens:Number(e.target.value)||1})),style:lz})]})}),(0,r.jsx)(lm,{children:(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"6px 0"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void q(),disabled:N,style:{...lM,cursor:N?"wait":"pointer"},children:N?t("desktop.saving"):t("desktop.mcpVisionSaveModel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void V(),disabled:l||!e||!K,title:e?t("desktop.mcpVisionRestartTitle"):t("desktop.mcpVisionRestartNoSession"),style:{padding:"7px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:!l&&e&&K?"pointer":"not-allowed",fontSize:12,opacity:!l&&e&&K?1:.5},children:l?t("desktop.mcpVisionRestarting"):t("desktop.mcpVisionRestart")}),O&&(0,r.jsx)("span",{style:{color:"#22c55e",fontSize:12},children:t("desktop.mcpVisionSavedModel")}),u&&(0,r.jsx)("span",{style:{color:"#22c55e",fontSize:12},children:t("desktop.mcpVisionRestarted")}),$&&(0,r.jsx)("span",{style:{color:"#ef4444",fontSize:12},children:$}),c&&(0,r.jsx)("span",{style:{color:"#ef4444",fontSize:12},children:c})]}),(0,r.jsxs)(lf,{children:[t("desktop.mcpVisionModelNote"),F&&(0,r.jsx)("div",{style:{marginTop:4,fontFamily:"var(--font-mono)",fontSize:10},children:F}),f&&(0,r.jsx)("div",{style:{fontFamily:"var(--font-mono)",fontSize:10},children:f})]})]})})]}):(0,r.jsx)(lm,{children:(0,r.jsx)("div",{style:{padding:"8px 0",fontSize:12,color:"var(--text-muted)"},children:t("desktop.loading")})})]})}function lE({sessionId:e,onApplied:t,onBeforeApply:o}){let{t:s}=(0,A.s)(),[i,a]=(0,n.useState)(!1),[l,d]=(0,n.useState)(!1),[c,p]=(0,n.useState)(null),u=(0,n.useCallback)(async()=>{if(e){a(!0),p(null),d(!1);try{await o?.(),await i6(e,{type:"reload"}),d(!0),await t?.()}catch(e){p(e instanceof Error?e.message:String(e))}finally{a(!1)}}},[e,t,o]),h=i||!e;return(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void u(),disabled:h,title:s(e?"desktop.applyNowTitle":"desktop.applyNowNoSession"),style:{padding:"7px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:h?"not-allowed":"pointer",fontSize:12,opacity:h?.5:1,whiteSpace:"nowrap"},children:s(i?"desktop.applyNowApplying":"desktop.applyNow")}),l&&(0,r.jsx)("span",{style:{color:"#22c55e",fontSize:12},children:s("desktop.applyNowDone")}),c&&(0,r.jsx)("span",{style:{color:"#ef4444",fontSize:12},children:c})]})}let lW=["stdio","sse","http"],lF=["eager","lazy"],lD={name:"",command:"",args:"",transport:"stdio",lifecycle:"eager",requestTimeoutMs:"",env:""},lA={padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,fontFamily:"var(--font-mono)",width:"100%",boxSizing:"border-box"};function lN(){return{fontSize:12,color:"var(--text-muted)"}}function lL(e,t){return{fontSize:10,padding:"1px 6px",borderRadius:3,background:t,color:e,flexShrink:0,textTransform:"capitalize"}}function l$({sessionId:e}){let{t}=(0,A.s)(),[o,s]=(0,n.useState)({}),[i,a]=(0,n.useState)(""),[l,d]=(0,n.useState)(!1),[c,p]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),[g,m]=(0,n.useState)(lD),[x,k]=(0,n.useState)(!1),[y,b]=(0,n.useState)(null),[w,j]=(0,n.useState)(!1),S=(0,n.useCallback)(async()=>{p(null);try{let e=await fetch("/api/mcp"),t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);s(t.mcpServers??{}),a(t.filePath)}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!0)}},[]);(0,n.useEffect)(()=>{S()},[S]);let C=(0,n.useCallback)(()=>{m(lD),h({name:"",isNew:!0}),b(null),j(!1)},[]),R=(0,n.useCallback)((e,t)=>{m({name:e,command:t.command??"",args:Array.isArray(t.args)?t.args.join("\n"):"",transport:"string"==typeof t.transport?t.transport:"stdio",lifecycle:"string"==typeof t.lifecycle?t.lifecycle:"eager",requestTimeoutMs:"number"==typeof t.requestTimeoutMs?String(t.requestTimeoutMs):"",env:void 0!==t.env?JSON.stringify(t.env,null,2):""}),h({name:e,isNew:!1}),b(null),j(!1)},[]),z=(0,n.useCallback)(async()=>{if(u){k(!0),b(null),j(!1);try{let e=g.name.trim();if(u.isNew&&!e)return void b("Server name is required");if(u.isNew&&!/^[a-zA-Z0-9_-]+$/.test(e))return void b("Allowed characters: a-z, A-Z, 0-9, _ and -");if(u.isNew&&e===lR)return void b(t("desktop.mcpVisionNameReserved"));let r=function(e){if(!e.command.trim())return{error:"Command is required"};let t=e.args.split("\n").map(e=>e.trim()).filter(Boolean),o={command:e.command.trim(),args:t,transport:lW.includes(e.transport)?e.transport:"stdio",lifecycle:lF.includes(e.lifecycle)?e.lifecycle:"eager"};if(""!==e.requestTimeoutMs.trim()){let t=Number(e.requestTimeoutMs);if(!Number.isFinite(t)||t<=0)return{error:"Request timeout must be a positive number"};o.requestTimeoutMs=t}if(""!==e.env.trim())try{o.env=JSON.parse(e.env)}catch{return{error:"Environment must be valid JSON"}}return{server:o}}(g);if(r.error||!r.server)return void b(r.error??"Invalid server");let n={...o};u.isNew?n[e]=r.server:(delete n[u.name],n[g.name.trim()||u.name]=r.server);let i=await fetch("/api/mcp",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServers:n})}),a=await i.json();if(!i.ok||a.error)throw Error(a.error??`HTTP ${i.status}`);s(n),h(null),j(!0)}catch(e){b(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[u,g,o,t]),I=(0,n.useCallback)(async e=>{k(!0),b(null);try{let t={...o};delete t[e];let r=await fetch("/api/mcp",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServers:t})}),n=await r.json();if(!r.ok||n.error)throw Error(n.error??`HTTP ${r.status}`);s(t),j(!0)}catch(e){b(e instanceof Error?e.message:String(e))}finally{k(!1)}},[o]),M=(0,n.useCallback)((e,t)=>{m(o=>({...o,[e]:t}))},[]),P=Object.entries(o).filter(([e])=>e!==lR);return(0,r.jsx)("div",{style:{flex:1,overflow:"auto",minWidth:0,padding:"20px 22px",display:"flex",flexDirection:"column",gap:16},children:(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:l?c?(0,r.jsx)("div",{style:{fontSize:12,color:"#ef4444"},children:c}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:t("desktop.mcpServers")}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[(0,r.jsx)(lE,{sessionId:e,onApplied:S}),(0,r.jsxs)("button",{type:"button",onClick:C,style:{display:"flex",alignItems:"center",gap:6,padding:"7px 12px",border:"none",borderRadius:6,background:"var(--accent)",color:"#fff",cursor:"pointer",fontSize:12,flexShrink:0},children:[(0,r.jsx)(v.c,{size:13,"aria-hidden":"true"}),t("desktop.mcpAddServer")]})]})]}),(0,r.jsx)(lf,{children:t("desktop.mcpRestartNote")}),(0,r.jsx)(lP,{sessionId:e}),0!==P.length||u?P.map(([e,o])=>(0,r.jsx)(lh,{children:(0,r.jsx)(lm,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 0",minWidth:0},children:[(0,r.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontSize:13,fontWeight:600,color:"var(--text)",fontFamily:"var(--font-mono)"},children:e}),(0,r.jsx)("span",{style:lL("var(--accent)","rgba(37,99,235,0.12)"),children:o.transport??"stdio"}),(0,r.jsx)("span",{style:lL("#d97706","rgba(245,158,11,0.12)"),children:o.lifecycle??"lazy"})]}),(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[o.command,Array.isArray(o.args)&&o.args.length>0?` ${o.args.map(e=>e.includes(" ")?`"${e}"`:e).join(" ")}`:""]})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:6,flexShrink:0},children:[(0,r.jsxs)("button",{type:"button",onClick:()=>R(e,o),disabled:x,style:{display:"flex",alignItems:"center",gap:5,padding:"6px 10px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:x?"not-allowed":"pointer",fontSize:12,opacity:x?.5:1},children:[(0,r.jsx)(f.I,{size:12,"aria-hidden":"true"}),t("desktop.mcpEdit")]}),(0,r.jsx)("button",{type:"button",onClick:()=>void I(e),disabled:x,title:t("desktop.mcpDelete"),"aria-label":t("desktop.mcpDelete"),style:{display:"flex",alignItems:"center",padding:"6px 9px",background:"rgba(239,68,68,0.08)",border:"1px solid var(--border)",borderRadius:6,color:"#ef4444",cursor:x?"not-allowed":"pointer",fontSize:12,opacity:x?.5:1},children:(0,r.jsx)(T.l,{size:12,"aria-hidden":"true"})})]})]})})},e)):(0,r.jsx)(lh,{children:(0,r.jsx)(lm,{children:(0,r.jsx)("div",{style:{padding:"14px 0",fontSize:12,color:"var(--text-dim)"},children:o[lR]?t("desktop.mcpEmptyOther"):t("desktop.mcpEmpty")})})}),u&&(0,r.jsxs)(lh,{children:[(0,r.jsx)(lg,{children:(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)",padding:"12px 0 4px"},children:u.isNew?t("desktop.mcpNewServer"):t("desktop.mcpEditServer",{name:u.name})})}),(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(150px, 220px) 1fr",gap:"8px 12px",alignItems:"center",padding:"8px 0"},children:[(0,r.jsx)("span",{style:lN(),children:t("desktop.mcpServerName")}),(0,r.jsx)("input",{value:g.name,onChange:e=>M("name",e.target.value),disabled:!u.isNew,placeholder:"my-server",style:{...lA,opacity:u.isNew?1:.5}}),(0,r.jsxs)("span",{style:lN(),children:[t("desktop.mcpCommand")," *"]}),(0,r.jsx)("input",{value:g.command,onChange:e=>M("command",e.target.value),placeholder:"npx @modelcontextprotocol/server-foo",style:lA}),(0,r.jsx)("span",{style:lN(),children:t("desktop.mcpArgs")}),(0,r.jsx)("textarea",{value:g.args,onChange:e=>M("args",e.target.value),placeholder:"--port 3000\n--verbose",rows:3,style:{...lA,resize:"vertical",lineHeight:1.5}}),(0,r.jsx)("span",{style:lN(),children:t("desktop.mcpTransport")}),(0,r.jsx)("select",{value:g.transport,onChange:e=>M("transport",e.target.value),style:{...lA,fontFamily:"var(--font-mono)"},children:lW.map(e=>(0,r.jsx)("option",{value:e,children:e},e))}),(0,r.jsx)("span",{style:lN(),children:t("desktop.mcpLifecycle")}),(0,r.jsx)("select",{value:g.lifecycle,onChange:e=>M("lifecycle",e.target.value),style:{...lA,fontFamily:"var(--font-mono)"},children:lF.map(e=>(0,r.jsx)("option",{value:e,children:e},e))}),(0,r.jsx)("span",{style:lN(),children:t("desktop.mcpRequestTimeoutMs")}),(0,r.jsx)("input",{type:"number",min:1,value:g.requestTimeoutMs,onChange:e=>M("requestTimeoutMs",e.target.value),placeholder:"300000",style:lA}),(0,r.jsx)("span",{style:lN(),children:t("desktop.mcpEnv")}),(0,r.jsx)("textarea",{value:g.env,onChange:e=>M("env",e.target.value),placeholder:'{\n "API_KEY": "..."\n}',rows:3,style:{...lA,resize:"vertical",lineHeight:1.5}})]})}),(0,r.jsx)(lm,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0"},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void z(),disabled:x,style:{padding:"7px 12px",border:"none",borderRadius:6,background:"var(--accent)",color:"#fff",cursor:x?"wait":"pointer",fontSize:12},children:x?t("desktop.saving"):t("desktop.mcpSave")}),(0,r.jsx)("button",{type:"button",onClick:()=>h(null),disabled:x,style:{padding:"7px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:x?"not-allowed":"pointer",fontSize:12},children:t("desktop.mcpCancel")}),y&&(0,r.jsx)("span",{style:{color:"#ef4444",fontSize:12},children:y})]})})]}),w&&!u&&(0,r.jsx)("div",{style:{fontSize:12,color:"#22c55e"},children:t("desktop.mcpSavedRestart")})]}):(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)"},children:t("desktop.loading")})})})}var lH=o(9210);function lO(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)(null),[s,i]=(0,n.useState)([]),[a,l]=(0,n.useState)(!0),[d,c]=(0,n.useState)(!1),[p,u]=(0,n.useState)(!1),[h,g]=(0,n.useState)(null);(0,n.useEffect)(()=>{fetch("/api/settings/title-model").then(e=>e.json()).then(e=>{o(e.value),i(e.models??[])}).catch(()=>{}).finally(()=>l(!1))},[]);let m=null!==t&&!s.some(e=>e.label===t),f=(0,n.useCallback)(async t=>{c(!0),g(null),u(!1);try{let e=await fetch("/api/settings/title-model",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:""===t?null:t})}),r=await e.json();if(!e.ok||r.error)return void g(r.error??`HTTP ${e.status}`);o(r.value??null),u(!0),setTimeout(()=>u(!1),2e3)}catch{g(String(e("desktop.titleModelSaveError")))}finally{c(!1)}},[e]),x=[...new Set(s.map(e=>e.provider))];return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 18px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"var(--text)",whiteSpace:"nowrap"},children:e("desktop.titleModel")}),(0,r.jsxs)("select",{value:t??"",disabled:a||d,onChange:e=>f(e.target.value),style:{flex:1,minWidth:200,maxWidth:420,padding:"6px 9px",fontSize:12,color:"var(--text)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5},children:[(0,r.jsx)("option",{value:"",children:e("desktop.titleModelFollowSession")}),m&&null!==t&&(0,r.jsxs)("option",{value:t,style:{color:"#ef4444"},children:[t,"(",e("desktop.titleModelInvalid"),")"]}),x.map(e=>(0,r.jsx)("optgroup",{label:e,children:s.filter(t=>t.provider===e).map(e=>(0,r.jsxs)("option",{value:e.label,children:[e.name||e.id,e.reasoning?"(reasoning)":""]},e.label))},e))]}),d&&(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)"},children:"…"}),!d&&p&&(0,r.jsx)("span",{style:{fontSize:11,color:"#4ade80"},children:e("desktop.titleModelSaved")})]}),(0,r.jsx)("p",{style:{margin:0,fontSize:11,color:"var(--text-muted)",lineHeight:1.5},children:e("desktop.titleModelDescription")}),h&&(0,r.jsx)("p",{style:{margin:0,fontSize:11,color:"#ef4444",lineHeight:1.5},children:h}),m&&null!==t&&(0,r.jsxs)("p",{style:{margin:0,fontSize:11,color:"#ef4444",lineHeight:1.5},children:[t,"(",e("desktop.titleModelInvalid"),")"]})]})}let lB=["name","reasoning","contextWindow","maxTokens","thinkingLevelMap","hidden"];function lU(e){if(""===e.trim())return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}function l_(e){let t=lU(e.contextWindow??""),o=lU(e.maxTokens??""),r=e.thinkingLevelMap&&Object.keys(e.thinkingLevelMap).length>0?{...e.thinkingLevelMap}:void 0;return{...e.name?.trim()?{name:e.name.trim()}:{},..."boolean"==typeof e.reasoning?{reasoning:e.reasoning}:{},...void 0!==t?{contextWindow:t}:{},...void 0!==o?{maxTokens:o}:{},...r?{thinkingLevelMap:r}:{},..."boolean"==typeof e.hidden?{hidden:e.hidden}:{}}}function lq({providerId:e,onRegisterFlush:t,onConfigChange:o}){let{t:s}=(0,A.s)(),i=O(),[a,l]=(0,n.useState)([]),[d,c]=(0,n.useState)({}),[p,u]=(0,n.useState)({}),[h,g]=(0,n.useState)(new Set),[m,f]=(0,n.useState)(!0),[x,k]=(0,n.useState)(!1),[v,y]=(0,n.useState)(null),[b,w]=(0,n.useState)(!1),[j,S]=(0,n.useState)(null),C=(0,n.useRef)(d),T=(0,n.useRef)(p),R=(0,n.useRef)(a),z=(0,n.useRef)(h),I=(0,n.useRef)(0),M=(0,n.useRef)(null);C.current=d,T.current=p,R.current=a,z.current=h,(0,n.useEffect)(()=>{let t=!1;return f(!0),y(null),(async()=>{try{let o=await fetch(`/api/models-config/builtin?provider=${encodeURIComponent(e)}`),r=await o.json();if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);if(t)return;let n={};for(let e of r.models){let t=r.overrides[e.id]??{};n[e.id]={name:"string"==typeof t.name&&t.name.length>0?t.name:e.name,reasoning:"boolean"==typeof t.reasoning?t.reasoning:e.reasoning,contextWindow:"number"==typeof t.contextWindow?String(t.contextWindow):null!=e.contextWindow?String(e.contextWindow):"",maxTokens:"number"==typeof t.maxTokens?String(t.maxTokens):null!=e.maxTokens?String(e.maxTokens):"",hidden:"boolean"==typeof t.hidden&&t.hidden,thinkingLevelMap:t.thinkingLevelMap??e.thinkingLevelMap}}l(r.models),c(n),u(n),g(new Set)}catch(e){t||y(e instanceof Error?e.message:String(e))}finally{t||f(!1)}})(),()=>{t=!0}},[e]);let P=(0,n.useCallback)((e,t)=>{I.current+=1,c(o=>({...o,[e]:{...o[e]??{},...t}})),g(t=>new Set(t).add(e))},[]),E=(0,n.useCallback)(async()=>{let t=M.current;if(t)return t;let r=(async()=>{let t=new Set(z.current);if(0===t.size)return;let r=I.current,n={...C.current},s={},i={};for(let e of R.current){let t=n[e.id],o=T.current[e.id];t&&(s[e.id]=l_(t)),o&&(i[e.id]=l_(o))}let a=function(e,t,o){let r={};for(let n of e){let e=t[n];if(!e)continue;let s=o[n]??{},i={};for(let t of lB){let o=e[t],r=s[t];JSON.stringify(o)!==JSON.stringify(r)&&(i[t]=void 0===o?null:o)}Object.keys(i).length>0&&(r[n]=i)}return r}(t,s,i);if(0===Object.keys(a).length)return void g(new Set);k(!0),y(null),w(!1);try{let s=await fetch("/api/models-config/builtin",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,patches:a})}),i=await s.json();if(!s.ok||i.error)throw Error(i.error??`HTTP ${s.status}`);o?.(i.provider??null);let l={...T.current};for(let e of t){let t=n[e];t&&(l[e]={...t})}T.current=l,u(l),I.current===r&&g(e=>new Set([...e].filter(e=>!t.has(e)))),w(!0),setTimeout(()=>w(!1),2e3)}catch(e){throw y(e instanceof Error?e.message:String(e)),e}finally{k(!1)}})();M.current=r;try{await r}finally{M.current===r&&(M.current=null)}},[o,e]);(0,n.useEffect)(()=>{if(t)return t(e,E)??void 0},[t,e,E]);let[W,F]=(0,n.useState)({phase:"idle"}),[D,N]=(0,n.useState)([]),L=(0,n.useCallback)(async()=>{F({phase:"loading"});try{let t=await fetch("/api/models-config/discover",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerName:e,provider:{}})}),o=await t.json();if(!t.ok||o.error||!o.models)return void F({phase:"error",message:o.error??`HTTP ${t.status}`});let r=new Set(R.current.map(e=>e.id)),n=new Set(o.models.filter(e=>!r.has(e.id)).map(e=>e.id));F({phase:"success",models:o.models,newIds:n}),N(o.models.filter(e=>n.has(e.id)).map(e=>e.id))}catch(e){F({phase:"error",message:e instanceof Error?e.message:String(e)})}},[e]),$=(0,n.useCallback)(async()=>{if(W.models?.length){k(!0),y(null);try{let t=W.models.map(e=>({id:e.id,...e.name?{name:e.name}:{}})),r=await fetch("/api/models-config/builtin",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,models:t})}),n=await r.json();if(!r.ok||n.error)throw Error(n.error??`HTTP ${r.status}`);o?.(n.provider??null),F({phase:"idle"}),N([]);let s=await fetch(`/api/models-config/builtin?provider=${encodeURIComponent(e)}`);if(s.ok){let e=await s.json();if(e.models){l(e.models),R.current=e.models;let t={};for(let o of e.models){let r=e.overrides?.[o.id]??{};t[o.id]={name:"string"==typeof r.name&&r.name.length>0?r.name:o.name,reasoning:"boolean"==typeof r.reasoning?r.reasoning:o.reasoning,contextWindow:"number"==typeof r.contextWindow?String(r.contextWindow):null!=o.contextWindow?String(o.contextWindow):"",maxTokens:"number"==typeof r.maxTokens?String(r.maxTokens):null!=o.maxTokens?String(o.maxTokens):"",hidden:"boolean"==typeof r.hidden&&r.hidden,thinkingLevelMap:r.thinkingLevelMap??o.thinkingLevelMap}}c(t),u(t),g(new Set)}}}catch(e){y(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[W.models,o,e]);return m?(0,r.jsx)("div",{style:{borderTop:"1px solid var(--border)",marginTop:14,paddingTop:12},children:(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-dim)"},children:s("desktop.modelsLoading")})}):(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",marginTop:14,paddingTop:12,display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)"},children:s("desktop.builtinModelsTitle")}),(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",paddingTop:10,display:"flex",flexDirection:"column",gap:8},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("button",{type:"button",onClick:()=>{L()},disabled:"loading"===W.phase,style:{padding:"5px 12px",background:(W.phase,"var(--bg-panel)"),border:"1px solid var(--border)",borderRadius:5,color:"loading"===W.phase?"var(--text-dim)":"var(--text-muted)",cursor:"loading"===W.phase?"not-allowed":"pointer",fontSize:12},children:"loading"===W.phase?s("desktop.modelsDiscoveryFetching"):s("desktop.builtinModelsFetchNew")}),"success"===W.phase&&W.models&&(0,r.jsx)("button",{type:"button",onClick:()=>{$()},disabled:x||0===D.length,style:{padding:"5px 12px",background:D.length>0&&!x?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:D.length>0&&!x?"#fff":"var(--text-dim)",cursor:D.length>0&&!x?"pointer":"not-allowed",fontSize:12,fontWeight:600},children:x?s("desktop.modelsSaving"):`${s("desktop.modelsAddModelManual")} (${D.length})`})]}),"error"===W.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:11,color:"#f87171"},children:W.message}),"success"===W.phase&&W.models&&(0,r.jsx)("div",{style:{maxHeight:200,overflowY:"auto",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)"},children:W.models.map(e=>{let t=W.newIds?.has(e.id)??!1,o=D.includes(e.id);return(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,minHeight:32,padding:"5px 9px",borderBottom:"1px solid var(--border)",cursor:t?"pointer":"default",opacity:t?1:.55},children:[(0,r.jsx)("input",{type:"checkbox",checked:o,disabled:!t,onChange:t=>{N(o=>t.target.checked?[...o,e.id]:o.filter(t=>t!==e.id))},style:{width:13,height:13,accentColor:"var(--accent)",flexShrink:0}}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",fontWeight:t?600:400},children:e.name||e.id}),(0,r.jsx)("code",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:e.id}),t&&(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:8,background:"var(--accent)",color:"#fff",marginLeft:"auto"},children:"新"})]},e.id)})})]}),v&&(0,r.jsx)("p",{style:{margin:0,fontSize:11,color:"#f87171"},children:v}),0===a.length&&!v&&(0,r.jsx)("p",{style:{margin:0,fontSize:11,color:"var(--text-dim)"},children:s("desktop.builtinModelsEmpty")}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:a.map(e=>{let t=d[e.id]??{},o=j===e.id,n=h.has(e.id);return(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",padding:"8px 10px"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsxs)("button",{type:"button",onClick:()=>S(o?null:e.id),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text)",fontSize:12,fontWeight:600,padding:0,textAlign:"left"},children:[t.name||e.name||e.id,n&&(0,r.jsx)("span",{style:{color:"var(--accent)",marginLeft:6},children:"•"})]}),(0,r.jsx)("code",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:e.id}),(t.reasoning??e.reasoning)&&(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:8,background:"var(--bg-selected)",color:"var(--text-muted)"},children:"reasoning"}),(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)"},children:[s("desktop.builtinModelsContext"),": ",(0,r.jsx)("b",{children:t.contextWindow?Number(t.contextWindow).toLocaleString():"—"})," \xb7 ",s("desktop.builtinModelsMaxTokens"),": ",(0,r.jsx)("b",{children:t.maxTokens?Number(t.maxTokens).toLocaleString():"—"})]})]}),o&&(0,r.jsxs)("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsxs)("label",{style:{display:"flex",gap:6,alignItems:"center",fontSize:12,color:"var(--text)",width:"100%"},children:[s("desktop.modelsName"),(0,r.jsx)("input",{type:"text",value:t.name??"",placeholder:e.name||e.id,onChange:t=>P(e.id,{name:t.target.value.trim()||void 0}),style:{flex:1,minWidth:0,padding:"4px 7px",fontSize:11,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text)",fontFamily:"var(--font-mono)"}}),(0,r.jsxs)("label",{style:{display:"flex",gap:4,alignItems:"center",fontSize:11,color:t.hidden?"#f87171":"var(--text-muted)",cursor:"pointer",whiteSpace:"nowrap",marginLeft:8},children:[(0,r.jsx)("input",{type:"checkbox",checked:!0===t.hidden,onChange:t=>P(e.id,{hidden:t.target.checked})}),s("desktop.builtinModelsHide")]})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:16,flexWrap:"wrap",flexDirection:i?"column":"row",alignItems:i?"flex-start":"center"},children:[(0,r.jsxs)("label",{style:{display:"flex",gap:6,alignItems:"center",fontSize:12,color:"var(--text)",cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:!0===t.reasoning,onChange:t=>P(e.id,{reasoning:t.target.checked})}),s("desktop.builtinModelsReasoning")]}),(0,r.jsxs)("label",{style:{display:"flex",gap:6,alignItems:"center",fontSize:12,color:"var(--text)",flex:i?1:void 0,width:i?"100%":void 0},children:[s("desktop.modelsContextWindow"),(0,r.jsx)("input",{type:"number",min:1,value:t.contextWindow??"",placeholder:null!=e.contextWindow?String(e.contextWindow):"",onChange:t=>P(e.id,{contextWindow:t.target.value}),style:{flex:1,minWidth:0,padding:"4px 7px",fontSize:11,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text)",fontFamily:"var(--font-mono)"}})]}),(0,r.jsxs)("label",{style:{display:"flex",gap:6,alignItems:"center",fontSize:12,color:"var(--text)",flex:i?1:void 0,width:i?"100%":void 0},children:[s("desktop.modelsMaxOutputTokens"),(0,r.jsx)("input",{type:"number",min:1,value:t.maxTokens??"",placeholder:null!=e.maxTokens?String(e.maxTokens):"",onChange:t=>P(e.id,{maxTokens:t.target.value}),style:{flex:1,minWidth:0,padding:"4px 7px",fontSize:11,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text)",fontFamily:"var(--font-mono)"}})]})]}),(0,r.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)"},children:s("desktop.builtinModelsThinking")}),(0,r.jsx)(l5,{value:t.thinkingLevelMap,onChange:t=>P(e.id,{thinkingLevelMap:t})})]})]},e.id)})}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,r.jsx)("button",{type:"button",onClick:()=>{E().catch(()=>{})},disabled:x||0===h.size,style:{alignSelf:"flex-start",padding:"5px 14px",background:h.size>0&&!x?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:h.size>0&&!x?"#fff":"var(--text-dim)",cursor:h.size>0&&!x?"pointer":"not-allowed",fontSize:12,fontWeight:600},children:x?s("desktop.modelsSaving"):b?s("desktop.modelsSaved"):s("desktop.modelsSave")}),h.size>0&&(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)"},children:s("desktop.builtinModelsDirty",{count:h.size})})]})]})}let lV=["openai-completions","openai-responses","anthropic-messages","google-generative-ai","mistral-conversations"],lK="__custom__";function lG(){let{t:e}=(0,A.s)();return(0,n.useCallback)((t,o)=>e(t,o),[e])}function lJ({label:e,children:t}){return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:e}),t]})}let lY={padding:"6px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:12,outline:"none",width:"100%",boxSizing:"border-box"};function lX({value:e,onChange:t,placeholder:o,mono:n,inputRef:s}){return(0,r.jsx)("input",{ref:s,value:e,onChange:e=>t(e.target.value),placeholder:o,style:{...lY,fontFamily:n?"var(--font-mono)":"inherit"}})}function lZ({value:e,onChange:t,placeholder:o,mono:s,onKeyDown:i,autoComplete:a="off",spellCheck:l=!1,style:d}){let c=lG(),[p,u]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{e||u(!1)},[e]),(0,r.jsxs)("div",{style:{position:"relative",width:"100%",...d},children:[(0,r.jsx)("input",{type:p?"text":"password",value:e,onChange:e=>t(e.target.value),onKeyDown:i,placeholder:o,style:{...lY,paddingRight:34,fontFamily:s?"var(--font-mono)":"inherit"},autoComplete:a,spellCheck:l}),(0,r.jsx)("button",{type:"button",onClick:()=>u(e=>!e),"aria-label":c(p?"desktop.modelsHideApiKey":"desktop.modelsShowApiKey"),title:c(p?"desktop.modelsHideApiKey":"desktop.modelsShowApiKey"),style:{position:"absolute",right:5,top:"50%",transform:"translateY(-50%)",width:24,height:24,padding:0,border:"none",background:"transparent",color:"var(--text-dim)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:p?(0,r.jsx)(lH.G,{size:15}):(0,r.jsx)(sR.b,{size:15})})]})}function lQ({value:e,onChange:t,placeholder:o}){return(0,r.jsx)("input",{type:"number",value:e,onChange:e=>t(e.target.value),placeholder:o,style:lY})}function l0({value:e,onChange:t,options:o,required:n}){let s=lG();return(0,r.jsxs)("select",{value:e,onChange:e=>t(e.target.value),style:{...lY,color:e?"var(--text)":"var(--text-dim)"},children:[!n&&(0,r.jsx)("option",{value:"",children:s("desktop.modelsInheritNone")}),o.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]})}function l1({label:e,checked:t,onChange:o}){return(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:12,color:"var(--text-muted)"},children:[(0,r.jsx)("input",{type:"checkbox",checked:t,onChange:e=>o(e.target.checked),style:{width:13,height:13,accentColor:"var(--accent)",cursor:"pointer"}}),e]})}function l2({children:e}){return(0,r.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:e})}function l4({name:e,provider:t,onChange:o,onRename:s,onDelete:i,onAddModels:a,onAddModel:l}){let d=lG(),[c,p]=(0,n.useState)(e),[u,h]=(0,n.useState)({phase:"idle"}),[g,m]=(0,n.useState)(""),[f,x]=(0,n.useState)([]),k=(0,n.useRef)(0),v=(0,n.useRef)(null);(0,n.useEffect)(()=>p(e),[e]);let y=(e,r)=>o({...t,[e]:r});(0,n.useEffect)(()=>{t.api||o({...t,api:"openai-completions"})},[t.api]),(0,n.useEffect)(()=>{k.current+=1,h({phase:"idle"}),m(""),x([])},[e,t.baseUrl,t.api,t.apiKey]);let b=(0,n.useCallback)(async()=>{if("loading"===u.phase)return;let o=++k.current;h({phase:"loading"}),x([]);try{let r=await fetch("/api/models-config/discover",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerName:e,provider:{...t,models:void 0}})}),n=await r.json();if(o!==k.current)return;if(!r.ok||n.error||!n.models)return void h({phase:"error",message:n.error??`HTTP ${r.status}`});h({phase:"success",models:n.models,endpoint:n.endpoint??t.baseUrl??""})}catch(e){if(o!==k.current)return;h({phase:"error",message:e instanceof Error?e.message:String(e)})}},[u.phase,e,t]),w=new Set((t.models??[]).map(e=>e.id)),j="success"===u.phase?u.models:[],S=g.trim().toLocaleLowerCase(),C=j.filter(e=>!S||e.id.toLocaleLowerCase().includes(S)||e.name?.toLocaleLowerCase().includes(S)),T=C.slice(0,300),R=T.filter(e=>!w.has(e.id)).map(e=>e.id),z=f.filter(e=>!w.has(e)).length,I=R.length>0&&R.every(e=>f.includes(e)),M=!I&&R.some(e=>f.includes(e));return(0,n.useEffect)(()=>{v.current&&(v.current.indeterminate=M)},[M]),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(l2,{children:d("desktop.modelsProvider")}),(0,r.jsx)("button",{onClick:i,style:{padding:"3px 8px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:4,color:"#ef4444",cursor:"pointer",fontSize:11},children:d("desktop.delete")})]}),(0,r.jsxs)(lJ,{label:d("desktop.modelsProviderName"),children:[(0,r.jsx)(lX,{value:c,onChange:p,placeholder:"provider-name",mono:!0}),c!==e&&c.trim()&&(0,r.jsx)("button",{onClick:()=>s(c.trim()),style:{marginTop:4,padding:"3px 10px",background:"var(--accent)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",fontSize:11,alignSelf:"flex-start"},children:d("desktop.rename")})]}),(0,r.jsx)(lJ,{label:d("desktop.modelsBaseUrl"),children:(0,r.jsx)(lX,{value:t.baseUrl??"",onChange:e=>y("baseUrl",e||void 0),placeholder:"http(s)://host:port/v1",mono:!0})}),(0,r.jsxs)(lJ,{label:d("desktop.modelsApiKey"),children:[(0,r.jsx)(lZ,{value:t.apiKey??"",onChange:e=>y("apiKey",e||void 0),placeholder:d("desktop.modelsApiKeyPlaceholder"),mono:!0}),(0,r.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:d("desktop.modelsApiKeyHelp")})]}),(0,r.jsx)(lJ,{label:d("desktop.modelsApi"),children:(0,r.jsx)(l0,{value:t.api??"openai-completions",onChange:e=>y("api",e),options:lV,required:!0})}),(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",paddingTop:14,display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:["success"!==u.phase&&(0,r.jsx)("button",{onClick:b,disabled:"loading"===u.phase,style:{height:30,padding:"0 12px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)",color:t.baseUrl?.trim()&&"loading"!==u.phase?"var(--text-muted)":"var(--text-dim)",cursor:t.baseUrl?.trim()&&"loading"!==u.phase?"pointer":"not-allowed",fontSize:11},children:"loading"===u.phase?d("desktop.modelsDiscoveryFetching"):d("desktop.modelsDiscoveryFetch")}),(0,r.jsx)("button",{onClick:l,title:d("desktop.modelsAddModelManual"),style:{height:30,padding:"0 12px",border:"none",borderRadius:5,background:"var(--accent)",color:"#fff",cursor:"pointer",fontSize:11,fontWeight:600},children:d("desktop.modelsAddModelManual")})]}),"error"===u.phase&&(0,r.jsx)("div",{style:{padding:"7px 9px",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",fontSize:11,lineHeight:1.4},children:u.message}),"success"===u.phase&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{value:g,onChange:e=>m(e.target.value),placeholder:d("desktop.modelsDiscoveryFilterPlaceholder",{count:u.models.length}),"aria-label":d("desktop.modelsDiscoveryFilter"),style:{...lY,width:"100%",minWidth:0}}),(0,r.jsxs)("div",{style:{maxHeight:220,overflowY:"auto",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)"},children:[(0,r.jsxs)("label",{style:{minHeight:32,padding:"5px 9px",display:"flex",alignItems:"center",gap:8,position:"sticky",top:0,zIndex:1,borderBottom:"1px solid var(--border)",background:"var(--bg)",cursor:R.length?"pointer":"default",color:"var(--text-muted)",fontSize:10,fontWeight:600},children:[(0,r.jsx)("input",{ref:v,type:"checkbox",checked:I,disabled:0===R.length,onChange:()=>{let e=new Set(R);x(t=>I?t.filter(t=>!e.has(t)):Array.from(new Set([...t,...R])))},style:{width:13,height:13,accentColor:"var(--accent)",flexShrink:0}}),d("desktop.modelsDiscoverySelectShown")]}),0===T.length?(0,r.jsx)("div",{style:{padding:12,color:"var(--text-dim)",fontSize:11},children:d("desktop.modelsDiscoveryNoMatches")}):T.map((e,t)=>{let o=w.has(e.id),n=f.includes(e.id);return(0,r.jsxs)("label",{style:{minHeight:36,padding:"6px 9px",display:"flex",alignItems:"center",gap:8,borderTop:0===t?"none":"1px solid var(--border)",cursor:o?"default":"pointer",opacity:o?.65:1},children:[(0,r.jsx)("input",{type:"checkbox",checked:n||o,disabled:o,onChange:()=>{var t;return t=e.id,void x(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},style:{width:13,height:13,accentColor:"var(--accent)",flexShrink:0}}),(0,r.jsxs)("span",{style:{minWidth:0,flex:1},children:[(0,r.jsx)("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)",fontSize:11},children:e.name??e.id}),e.name&&(0,r.jsx)("code",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontSize:10,fontFamily:"var(--font-mono)"},children:e.id})]}),o&&(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10},children:d("desktop.modelsDiscoveryAdded")})]},e.id)})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10},children:[(0,r.jsx)("span",{title:u.endpoint,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontSize:10},children:C.length>T.length?d("desktop.modelsDiscoveryShowing",{shown:T.length,total:C.length}):d("desktop.modelsDiscoveryFetched",{count:u.models.length})}),(0,r.jsx)("button",{onClick:()=>{if("success"!==u.phase)return;let e=new Set(f),t=u.models.filter(t=>e.has(t.id)&&!w.has(t.id));0!==t.length&&(a(t),x([]))},disabled:0===z,style:{height:28,padding:"0 11px",border:"none",borderRadius:5,background:z?"var(--accent)":"var(--bg-panel)",color:z?"#fff":"var(--text-dim)",cursor:z?"pointer":"not-allowed",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:z?d("desktop.modelsDiscoveryAddSelectedCount",{count:z}):d("desktop.modelsDiscoveryAddSelected")})]})]})]})]})}let l6=["off","minimal","low","medium","high","xhigh","max"],l8={off:"var(--text-dim)",minimal:"var(--text-muted)",low:"#60a5fa",medium:"#a78bfa",high:"#f472b6",xhigh:"#fb923c",max:"#ef4444"};function l5({value:e,onChange:t}){let o=lG(),n=e??{},s=(e,o)=>{let r={...n};"omit"===o?delete r[e]:r[e]=o,t(Object.keys(r).length?r:void 0)};return(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:l6.map(e=>{let t=n[e],i=e in n?null===t?"null":"string":"omit",a="string"==typeof t?t:"",l=l8[e],d={padding:"4px 10px",fontSize:10,border:"none",cursor:"pointer",fontWeight:400,transition:"background 0.1s, color 0.1s",whiteSpace:"nowrap",background:"var(--bg-panel)",color:"var(--text-dim)"},c={background:"var(--accent)",color:"#fff",fontWeight:600};return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 4px",borderRadius:6,background:"transparent",border:"1px solid transparent"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,width:68,flexShrink:0},children:[(0,r.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:l,flexShrink:0,opacity:"null"===i?.3:1}}),(0,r.jsx)("span",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:"null"===i?"var(--text-dim)":"var(--text-muted)",textDecoration:"null"===i?"line-through":"none"},children:e})]}),(0,r.jsxs)("div",{style:{display:"flex",borderRadius:5,border:"1px solid var(--border)",overflow:"hidden",flexShrink:0},children:[(0,r.jsx)("button",{onClick:()=>s(e,"omit"),style:{...d,..."omit"===i?c:{}},children:o("desktop.modelsDefault")}),(0,r.jsx)("button",{onClick:()=>s(e,null),style:{...d,borderLeft:"1px solid var(--border)",..."null"===i?{background:"#ef4444",color:"#fff",fontWeight:600}:{}},children:o("desktop.modelsDisabled")})]}),(0,r.jsxs)("div",{style:{display:"flex",borderRadius:5,border:`1px solid ${"string"===i?"var(--accent)":"var(--border)"}`,overflow:"hidden",transition:"border-color 0.1s"},children:[(0,r.jsx)("button",{onClick:()=>s(e,a||e),style:{...d,..."string"===i?c:{},borderRight:"1px solid var(--border)",flexShrink:0},children:o("desktop.modelsCustom")}),(0,r.jsx)("input",{value:a,onChange:t=>s(e,t.target.value),onFocus:()=>{"string"!==i&&s(e,a||e)},placeholder:e,maxLength:10,style:{width:"12ch",background:"string"===i?"var(--bg)":"var(--bg-panel)",border:"none",outline:"none",color:"string"===i?"var(--text)":"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,padding:"4px 7px",transition:"background 0.1s, color 0.1s"}})]})]},e)})})}let l3={thinkingFormat:"deepseek",requiresReasoningContentOnAssistantMessages:!0};function l7({providerName:e,provider:t,model:o,onChange:s,onDelete:i}){let a=lG(),[l,d]=(0,n.useState)({phase:"idle"}),[c,p]=(0,n.useState)({phase:"idle"}),u=(0,n.useRef)(0),h=(0,n.useRef)(null),g=(e,t)=>s({...o,[e]:t}),f=(()=>{if("idle"===l.phase)return null;if("testing"===l.phase)return a("desktop.modelsTestingConnection");let e=[void 0!==l.latencyMs?`${l.latencyMs}ms`:null,void 0!==l.status?`HTTP ${l.status}`:null].filter(Boolean);return"success"===l.phase?[a("desktop.modelsConnected"),...e,l.responseText||null].filter(Boolean).join(" \xb7 "):[a("desktop.modelsFailed"),...e,l.message].filter(Boolean).join(" \xb7 ")})();(0,n.useEffect)(()=>{d({phase:"idle"})},[e,t.baseUrl,t.api,t.apiKey,o.id,o.api]);let x=(0,n.useCallback)(async()=>{if(o.id.trim()&&"testing"!==l.phase){d({phase:"testing"});try{let r=await fetch("/api/models-config/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerName:e,provider:t,model:o})}),n=await r.json();if(!r.ok||!n.ok)return void d({phase:"error",message:n.error??`HTTP ${r.status}`,latencyMs:n.latencyMs,status:n.status});d({phase:"success",latencyMs:n.latencyMs,status:n.status,responseText:n.responseText})}catch(e){d({phase:"error",message:e instanceof Error?e.message:String(e)})}}},[o,t,e,l.phase]);(0,n.useEffect)(()=>{u.current+=1,p({phase:"idle"}),h.current=null},[e,t.baseUrl,o.id]);let k=(0,n.useCallback)(async()=>{let r=o.id.trim();if(!r||"loading"===c.phase)return;let n=++u.current;p({phase:"loading"});try{let i=new URLSearchParams({q:r,provider:e,limit:"50"});t.baseUrl?.trim()&&i.set("baseUrl",t.baseUrl.trim());let a=await fetch(`/api/models-config/catalog?${i}`),l=await a.json();if(n!==u.current)return;if(!a.ok||l.error||!l.recommendation)return void p({phase:"error",message:l.error??`HTTP ${a.status}`});let d=function(e,t){let o={...e},r=0;if(!e.name?.trim()&&t.name&&(o.name=t.name,r+=1),void 0===e.reasoning&&!0===t.reasoning&&(o.reasoning=!0,r+=1),!e.input?.length&&t.input?.length&&(o.input=[...t.input],r+=1),void 0===e.contextWindow&&void 0!==t.contextWindow&&(o.contextWindow=t.contextWindow,r+=1),void 0===e.maxTokens&&void 0!==t.maxTokens&&(o.maxTokens=t.maxTokens,r+=1),t.cost){let n={...e.cost??{}},s=!1;for(let e of["input","output","cacheRead","cacheWrite"])void 0===n[e]&&void 0!==t.cost[e]&&(n[e]=t.cost[e],s=!0,r+=1);s&&(o.cost=n)}return{model:o,appliedCount:r}}(o,l.recommendation.preset);d.appliedCount>0&&(h.current=o,s(d.model)),p({phase:"success",recommendation:l.recommendation,appliedCount:d.appliedCount})}catch(e){if(n!==u.current)return;p({phase:"error",message:e instanceof Error?e.message:String(e)})}},[c.phase,o,s,t.baseUrl,e]),v=(()=>{if("success"!==c.phase)return null;let{recommendation:t,appliedCount:o}=c,r=o>0?a("desktop.modelsCatalogFilled",{count:o}):a("desktop.modelsCatalogNoEmptyFields");if("unreliable"===t.price.status){let e="no-exact-match"===t.price.reason?a("desktop.modelsCatalogNoExactMatch"):a("desktop.modelsCatalogPriceUnreliable");return`${r} \xb7 ${e}`}let n="provider"===t.price.method?a("desktop.modelsCatalogPriceProvider",{provider:t.price.providerName??t.price.providerId??e}):"base-url"===t.price.method?a("desktop.modelsCatalogPriceBaseUrl",{provider:t.price.providerName??t.price.providerId??e}):a("desktop.modelsCatalogPriceConsensus",{support:t.price.support,total:t.price.total});return`${r} \xb7 ${n}`})(),y="error"===c.phase?c.message:v,b="error"===c.phase?"#ef4444":"success"===c.phase&&"unreliable"===c.recommendation.price.status?"#d97706":"var(--text-dim)";return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(l2,{children:a("desktop.modelsModelSection")}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[f&&(0,r.jsx)("span",{title:f,style:{maxWidth:260,height:24,padding:"0 8px",border:`1px solid ${"error"===l.phase?"#fecaca":"success"===l.phase?"#bbf7d0":"var(--border)"}`,borderRadius:4,background:"error"===l.phase?"#fee2e2":"success"===l.phase?"#dcfce7":"#e5e7eb",color:"#111827",fontSize:11,display:"inline-flex",alignItems:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",boxSizing:"border-box"},children:f}),(0,r.jsxs)("button",{onClick:x,disabled:!o.id.trim()||"testing"===l.phase,title:a("desktop.modelsTestConnection"),style:{height:24,padding:"0 8px",background:"success"===l.phase?"#16a34a":"none",border:`1px solid ${"success"===l.phase?"#16a34a":"var(--border)"}`,borderRadius:4,color:"success"===l.phase?"#fff":o.id.trim()&&"testing"!==l.phase?"var(--text-muted)":"var(--text-dim)",cursor:o.id.trim()&&"testing"!==l.phase?"pointer":"not-allowed",fontSize:11,display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",gap:5},children:["success"===l.phase&&(0,r.jsx)(m.S,{size:11}),"testing"===l.phase?a("desktop.modelsTesting"):"success"===l.phase?a("desktop.modelsOk"):a("desktop.modelsTest")]}),(0,r.jsx)("button",{onClick:i,style:{height:24,padding:"0 8px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:4,color:"#ef4444",cursor:"pointer",fontSize:11,boxSizing:"border-box"},children:a("desktop.modelsRemove")})]})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,r.jsx)(lJ,{label:a("desktop.modelsIdRequired"),children:(0,r.jsx)(lX,{value:o.id,onChange:e=>g("id",e),placeholder:"model-id",mono:!0})}),(0,r.jsx)(lJ,{label:a("desktop.modelsName"),children:(0,r.jsx)(lX,{value:o.name??"",onChange:e=>g("name",e||void 0),placeholder:a("desktop.modelsDisplayName")})})]}),(0,r.jsxs)("div",{style:{padding:"10px 0",borderTop:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("button",{onClick:()=>void k(),disabled:!o.id.trim()||"loading"===c.phase,style:{height:28,padding:"0 10px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)",color:o.id.trim()&&"loading"!==c.phase?"var(--text-muted)":"var(--text-dim)",cursor:o.id.trim()&&"loading"!==c.phase?"pointer":"not-allowed",fontSize:11},children:"loading"===c.phase?a("desktop.modelsCatalogFilling"):a("desktop.modelsCatalogFill")}),(0,r.jsx)("a",{href:"https://github.com/anomalyco/models.dev",target:"_blank",rel:"noreferrer",style:{marginLeft:"auto",color:"var(--text-dim)",fontSize:10,textDecoration:"none"},children:a("desktop.modelsCatalogSource")})]}),(0,r.jsxs)("div",{"aria-live":"polite",style:{marginTop:6,height:20,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,color:b,fontSize:10},children:[(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y}),"success"===c.phase&&h.current&&(0,r.jsx)("button",{onClick:()=>{let e=h.current;e&&(h.current=null,s(e),p({phase:"idle"}))},style:{background:"none",border:"none",color:"var(--accent)",cursor:"pointer",fontSize:10,flexShrink:0},children:a("desktop.modelsCatalogUndo")})]})]}),(0,r.jsx)(lJ,{label:a("desktop.modelsApiOverride"),children:(0,r.jsx)(l0,{value:o.api??"",onChange:e=>g("api",e||void 0),options:lV})}),(0,r.jsxs)("div",{style:{display:"flex",gap:20,flexWrap:"wrap"},children:[(0,r.jsx)(l1,{label:a("desktop.modelsReasoningThinking"),checked:o.reasoning??!1,onChange:e=>g("reasoning",e||void 0)}),(0,r.jsx)(l1,{label:a("desktop.modelsImageInput"),checked:o.input?.includes("image")??!1,onChange:e=>g("input",e?["text","image"]:void 0)})]}),o.reasoning&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l1,{label:a("desktop.modelsDeepSeekCompat"),checked:o.compat?.thinkingFormat==="deepseek",onChange:e=>s(function(e,t){if(t)return{...e,compat:{...e.compat??{},...l3}};if(!e.compat)return e;let o={...e.compat};return delete o.thinkingFormat,delete o.requiresReasoningContentOnAssistantMessages,{...e,compat:Object.keys(o).length?o:void 0}}(o,e))}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,r.jsx)(l2,{children:a("desktop.modelsThinkingLevelMap")}),o.thinkingLevelMap&&(0,r.jsx)("button",{onClick:()=>g("thinkingLevelMap",void 0),style:{fontSize:10,padding:"2px 7px",background:"none",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-dim)",cursor:"pointer"},children:a("desktop.modelsClearAll")})]}),(0,r.jsx)(l5,{value:o.thinkingLevelMap,onChange:e=>g("thinkingLevelMap",e)})]})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,r.jsx)(lJ,{label:a("desktop.modelsContextWindow"),children:(0,r.jsx)(lQ,{value:void 0!==o.contextWindow?String(o.contextWindow):"",onChange:e=>g("contextWindow",e?parseInt(e):void 0),placeholder:"128000"})}),(0,r.jsx)(lJ,{label:a("desktop.modelsMaxOutputTokens"),children:(0,r.jsx)(lQ,{value:void 0!==o.maxTokens?String(o.maxTokens):"",onChange:e=>g("maxTokens",e?parseInt(e):void 0),placeholder:"16384"})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(l2,{children:a("desktop.modelsCostPerMillionTokens")}),(0,r.jsx)("div",{style:{marginTop:8,display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:8},children:["input","output","cacheRead","cacheWrite"].map(e=>(0,r.jsx)(lJ,{label:e,children:(0,r.jsx)(lQ,{value:o.cost?.[e]!==void 0?String(o.cost[e]):"",onChange:t=>{let r;return r=parseFloat(t),void s({...o,cost:{...o.cost??{},[e]:isNaN(r)?void 0:r}})},placeholder:"0"})},e))})]})]})}function l9({provider:e,onRefresh:t,onRegisterBuiltinFlush:o,onBuiltinProviderChange:s}){let i=lG(),[a,l]=(0,n.useState)({phase:"idle"}),[d,c]=(0,n.useState)(""),p=(0,n.useRef)(null),u=(0,n.useRef)(null);(0,n.useEffect)(()=>{("auth"===a.phase||"prompt"===a.phase)&&setTimeout(()=>u.current?.focus(),50)},[a.phase]),(0,n.useEffect)(()=>{l({phase:"idle"}),c(""),p.current?.close(),p.current=null},[e.id]),(0,n.useEffect)(()=>()=>{p.current?.close()},[]);let h=(0,n.useCallback)(()=>{p.current?.close(),l({phase:"connecting"}),c("");let o=new EventSource(`/api/auth/login/${encodeURIComponent(e.id)}`);p.current=o,o.onmessage=e=>{let r=JSON.parse(e.data);"auth"===r.type?(l({phase:"auth",url:r.url,instructions:r.instructions??null,token:r.token}),window.open(r.url,"_blank","noopener,noreferrer")):"device_code"===r.type?(l({phase:"device_code",userCode:r.userCode,verificationUri:r.verificationUri,intervalSeconds:r.intervalSeconds??null,expiresInSeconds:r.expiresInSeconds??null}),window.open(r.verificationUri,"_blank","noopener,noreferrer")):"prompt_request"===r.type?l({phase:"prompt",message:r.message,placeholder:r.placeholder??null,token:r.token}):"select_request"===r.type?l({phase:"select",message:r.message,options:r.options??[],token:r.token}):"progress"===r.type?l({phase:"progress",message:r.message}):"success"===r.type?(o.close(),l({phase:"success"}),t()):"error"===r.type?(o.close(),l({phase:"error",message:r.message})):"cancelled"===r.type&&(o.close(),l({phase:"idle"}))},o.onerror=()=>{o.close(),l(e=>"success"===e.phase?e:{phase:"error",message:i("desktop.modelsConnectionLost")})}},[e.id,t,i]),g=(0,n.useCallback)(async()=>{try{let t=await fetch(`/api/auth/logout/${encodeURIComponent(e.id)}`,{method:"POST"});if(t.ok)l({phase:"idle"});else{let e=await t.json().catch(()=>null);l({phase:"error",message:409===t.status?i("desktop.modelsAuthenticationStateChanged"):e?.error??`HTTP ${t.status}`})}}catch(e){l({phase:"error",message:e instanceof Error?e.message:String(e)})}finally{t()}},[e.id,t,i]),m=(0,n.useCallback)(async(t,o)=>{if(o.trim()){l({phase:"progress",message:i("desktop.modelsVerifying")});try{let r=await fetch(`/api/auth/login/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,code:o.trim()})});if(!r.ok){let e=await r.json().catch(()=>({}));l({phase:"error",message:e.error??i("desktop.modelsServerError",{status:r.status})});return}c("")}catch(e){l({phase:"error",message:e instanceof Error?e.message:i("desktop.modelsNetworkError")})}}},[e.id,i]),f=(0,n.useCallback)(async(t,o)=>{l({phase:"progress",message:i("desktop.modelsContinuing")});try{let r=await fetch(`/api/auth/login/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,code:o})});if(!r.ok){let e=await r.json().catch(()=>({}));l({phase:"error",message:e.error??i("desktop.modelsServerError",{status:r.status})})}}catch(e){l({phase:"error",message:e instanceof Error?e.message:i("desktop.modelsNetworkError")})}},[e.id,i]),x="connecting"===a.phase||"progress"===a.phase||"auth"===a.phase||"device_code"===a.phase||"prompt"===a.phase||"select"===a.phase;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(l2,{children:i("desktop.modelsSubscription")}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e.loggedIn?"#4ade80":"var(--border)",display:"inline-block"}}),(0,r.jsx)("span",{style:{fontSize:11,color:e.loggedIn?"#4ade80":"var(--text-dim)"},children:e.loggedIn?i("desktop.modelsConnected"):i("desktop.modelsNotConnected")})]})]}),(0,r.jsxs)("div",{style:{minHeight:48},children:["idle"===a.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:e.loggedIn?i("desktop.modelsAlreadyConnected"):i("desktop.modelsConnectAccount",{provider:e.name})}),"connecting"===a.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)"},children:i("desktop.modelsOpeningBrowser")}),"select"===a.phase&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:a.message}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:a.options.map(e=>(0,r.jsx)("button",{onClick:()=>f(a.token,e.id),style:{padding:"6px 9px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",cursor:"pointer",fontSize:12,textAlign:"left"},children:e.label},e.id))})]}),("auth"===a.phase||"prompt"===a.phase)&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:"auth"===a.phase?i("desktop.modelsCompleteSignIn"):a.message}),"auth"===a.phase&&(0,r.jsxs)("p",{style:{margin:0,fontSize:11,color:"var(--text-dim)",lineHeight:1.5},children:[i("desktop.modelsBrowserDidNotOpen")," ",(0,r.jsx)("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",wordBreak:"break-all"},children:i("desktop.modelsOpenLoginPage")}),"."]}),(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("input",{ref:u,value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&m(a.token,d)},placeholder:"auth"===a.phase?"http://localhost:1455/auth/callback?code=…":a.placeholder??i("desktop.modelsEnterValue"),style:{flex:1,padding:"6px 9px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:12,outline:"none",fontFamily:"var(--font-mono)",boxSizing:"border-box"}}),(0,r.jsx)("button",{onClick:()=>m(a.token,d),disabled:!d.trim(),style:{padding:"6px 12px",background:d.trim()?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:d.trim()?"#fff":"var(--text-dim)",cursor:d.trim()?"pointer":"not-allowed",fontSize:12,fontWeight:600,flexShrink:0},children:i("desktop.submit")})]})]}),"device_code"===a.phase&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:i("desktop.modelsOpenVerificationPage")}),(0,r.jsx)("div",{style:{padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:16,fontWeight:700,fontFamily:"var(--font-mono)",letterSpacing:0},children:a.userCode}),(0,r.jsxs)("p",{style:{margin:0,fontSize:11,color:"var(--text-dim)",lineHeight:1.5},children:[(0,r.jsx)("a",{href:a.verificationUri,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",wordBreak:"break-all"},children:a.verificationUri}),a.expiresInSeconds?` ${i("desktop.modelsExpiresInMinutes",{count:Math.ceil(a.expiresInSeconds/60)})}`:""]})]}),"progress"===a.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)"},children:a.message}),"success"===a.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"#4ade80"},children:i("desktop.modelsConnectedSuccessfully")}),"error"===a.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"#f87171"},children:a.message})]}),(0,r.jsx)("div",{style:{display:"flex",gap:8},children:x?(0,r.jsx)("button",{onClick:()=>{p.current?.close(),l({phase:"idle"})},style:{padding:"5px 12px",background:"none",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:i("desktop.cancel")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:h,style:{padding:"5px 14px",background:"var(--accent)",border:"none",borderRadius:5,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600},children:e.loggedIn?i("desktop.modelsReLogin"):i("desktop.modelsLogin")}),e.loggedIn&&(0,r.jsx)("button",{onClick:g,style:{padding:"5px 12px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",cursor:"pointer",fontSize:12},children:i("desktop.modelsDisconnect")})]})}),(0,r.jsx)(lq,{providerId:e.id,onRegisterFlush:o,onConfigChange:s})]})}function de({provider:e,onRefresh:t,onRegisterBuiltinFlush:o,onBuiltinProviderChange:s}){let i=lG(),[a,l]=(0,n.useState)(""),[d,c]=(0,n.useState)(!1),[p,u]=(0,n.useState)(!1),[h,g]=(0,n.useState)(null),[f,x]=(0,n.useState)(!1);(0,n.useEffect)(()=>{l(""),g(null),x(!1)},[e.id]);let k=(0,n.useCallback)(async()=>{if(a.trim()){c(!0),g(null),x(!1);try{let o=await fetch(`/api/auth/api-key/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:a.trim()})}),r=await o.json();!o.ok||r.error?g(r.error??`HTTP ${o.status}`):(l(""),x(!0),setTimeout(()=>x(!1),2e3),t())}catch(e){g(String(e))}finally{c(!1)}}},[a,e.id,t]),v=(0,n.useCallback)(async()=>{u(!0),g(null);try{let t=await fetch(`/api/auth/api-key/${encodeURIComponent(e.id)}`,{method:"DELETE"}),o=await t.json();(!t.ok||o.error)&&g(409===t.status?i("desktop.modelsAuthenticationStateChanged"):o.error??`HTTP ${t.status}`)}catch(e){g(String(e))}finally{t(),u(!1)}},[e.id,t,i]);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(l2,{children:i("desktop.modelsApiKey")}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e.configured?"#4ade80":"var(--border)",display:"inline-block"}}),(0,r.jsx)("span",{style:{fontSize:11,color:e.configured?"#4ade80":"var(--text-dim)"},children:e.configured?i("desktop.modelsConfigured"):i("desktop.modelsNotConfigured")})]})]}),(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:e.configured?i("desktop.modelsApiKeyStored"):i("desktop.modelsEnableModels",{provider:e.displayName,count:e.modelCount,models:1===e.modelCount?i("desktop.modelsSingular"):i("desktop.modelsPlural")})}),(0,r.jsx)(lJ,{label:i("desktop.modelsApiKey"),children:(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)(lZ,{value:a,onChange:l,onKeyDown:e=>{"Enter"===e.key&&a.trim()&&k()},placeholder:e.configured?i("desktop.modelsEnterNewKey"):"sk-…",style:{flex:1},autoComplete:"off",spellCheck:!1,mono:!0}),(0,r.jsxs)("button",{onClick:k,disabled:d||!a.trim()||f,style:{padding:"6px 12px",background:f?"#16a34a":a.trim()?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:a.trim()||f?"#fff":"var(--text-dim)",cursor:d||!a.trim()||f?"not-allowed":"pointer",fontSize:12,fontWeight:600,flexShrink:0,display:"flex",alignItems:"center",gap:5},children:[f&&(0,r.jsx)(m.S,{size:12}),f?i("desktop.modelsSaved"):d?i("desktop.modelsSaving"):i("desktop.modelsSave")]})]})}),h&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"#f87171"},children:h}),e.configured&&(0,r.jsx)("button",{onClick:v,disabled:p,style:{alignSelf:"flex-start",padding:"5px 12px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",cursor:p?"not-allowed":"pointer",fontSize:12},children:p?i("desktop.modelsRemoving"):i("desktop.modelsDisconnect")}),(0,r.jsx)(lq,{providerId:e.id,onRegisterFlush:o,onConfigChange:s})]})}function dt({oauthProviders:e,apiKeyProviders:t,onSelectOAuth:o,onSelectApiKey:s,onAddCustom:i,onClose:a}){let l=lG(),[d,c]=(0,n.useState)(""),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{setTimeout(()=>p.current?.focus(),30)},[]);let h=d.trim().toLowerCase(),g=e.filter(e=>!e.loggedIn&&(!h||e.name.toLowerCase().includes(h))),m=t.filter(e=>!e.configured&&(!h||e.displayName.toLowerCase().includes(h)||e.id.toLowerCase().includes(h))),f=!h||"custom".includes(h)||"openai-compatible".includes(h)||"anthropic-compatible".includes(h),x=g.length+m.length+ +!!f,k={display:"flex",flexDirection:"row",alignItems:"center",gap:8,padding:"10px 12px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:7,boxSizing:"border-box",cursor:"pointer",minWidth:0,textAlign:"left",transition:"border-color 0.12s, background 0.12s",width:"100%"};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&a()},children:(0,r.jsxs)("div",{style:{width:820,maxWidth:"calc(100vw - 32px)",maxHeight:"min(72vh, calc(100vh - 32px))",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.22)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--border)",flexShrink:0,display:"flex",alignItems:"center",gap:8},children:[(0,r.jsx)(u.$,{size:13,style:{color:"var(--text-dim)",flexShrink:0}}),(0,r.jsx)("input",{ref:p,value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Escape"===e.key&&a()},placeholder:l("desktop.modelsSearchProviders"),style:{flex:1,background:"none",border:"none",outline:"none",color:"var(--text)",fontSize:13,boxSizing:"border-box"}})]}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:14},children:0===x?(0,r.jsx)("div",{style:{padding:"20px 0",fontSize:12,color:"var(--text-dim)",textAlign:"center"},children:l("desktop.modelsNoProvidersMatch")}):(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(240px, 100%), 1fr))",gap:8},children:[f&&(0,r.jsx)("div",{style:{gridColumn:"1 / -1",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:l("desktop.modelsCustom")}),f&&(0,r.jsxs)("button",{onClick:()=>{i(),a()},style:k,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l("desktop.modelsCompatibleProvider")}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:l("desktop.modelsCustomEndpointFormat")})]}),(0,r.jsx)("span",{style:{width:26,height:26,borderRadius:5,background:"var(--bg-hover)",border:"1px dashed var(--border)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,r.jsx)(v.c,{size:13,style:{color:"var(--text-dim)"}})})]}),g.length>0&&(0,r.jsx)("div",{style:{gridColumn:"1 / -1",paddingTop:6*!!f,fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:l("desktop.modelsSubscriptions")}),g.map(e=>(0,r.jsxs)("button",{onClick:()=>{o(e.id),a()},style:k,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:"OAuth"})]}),(0,r.jsx)(is,{id:e.id,size:28})]},e.id)),m.length>0&&(0,r.jsx)("div",{style:{gridColumn:"1 / -1",paddingTop:6*(g.length>0),fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:l("desktop.modelsApiKey")}),m.map(e=>(0,r.jsxs)("button",{onClick:()=>{s(e.id),a()},style:k,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.displayName}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:l("desktop.modelsCount",{count:e.modelCount})})]}),(0,r.jsx)(is,{id:e.id,size:28})]},e.id))]})})]})})}function dr({existingProviders:e,onCancel:t,onSubmit:o}){let s=lG(),[i,a]=(0,n.useState)(""),[l,d]=(0,n.useState)(lV[0]),[c,p]=(0,n.useState)(lV[0]),[u,h]=(0,n.useState)(""),[g,m]=(0,n.useState)(""),[f,x]=(0,n.useState)(void 0),[k,y]=(0,n.useState)(!1),[b,w]=(0,n.useState)(""),[j,S]=(0,n.useState)(""),[C,T]=(0,n.useState)(""),[R,z]=(0,n.useState)(""),I=(0,n.useRef)(null);(0,n.useEffect)(()=>{setTimeout(()=>I.current?.focus(),30)},[]);let M=!u.trim()||/^https?:\/\//i.test(u.trim());return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&t()},children:(0,r.jsxs)("div",{style:{width:480,maxWidth:"calc(100vw - 32px)",maxHeight:"min(82vh, calc(100vh - 32px))",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.22)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:s("desktop.modelsAddCustomTitle")}),(0,r.jsx)("button",{onClick:t,"aria-label":s("desktop.modelsClose"),title:s("desktop.modelsClose"),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),(0,r.jsxs)("div",{style:{padding:16,overflowY:"auto",display:"flex",flexDirection:"column",gap:14},children:[(0,r.jsx)(lJ,{label:s("desktop.modelsProviderNameOptional"),children:(0,r.jsx)(lX,{value:i,onChange:a,placeholder:"new-provider",mono:!0,inputRef:I})}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)(l2,{children:s("desktop.modelsCallFormat")}),(0,r.jsxs)("select",{value:c,onChange:e=>{let t=e.target.value;(p(t),t===lK)?y(!0):d(t)},style:lY,children:[lV.map(e=>(0,r.jsx)("option",{value:e,children:e},e)),(0,r.jsx)("option",{value:lK,children:s("desktop.modelsCustomCallFormat")})]}),(0,r.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:s("desktop.modelsCallFormatHelp")}),c===lK&&(0,r.jsx)("span",{style:{fontSize:10,color:"#d97706",lineHeight:1.4},children:s("desktop.modelsCustomCallFormatHelp")})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)(l2,{children:s("desktop.modelsImportProvider")}),(0,r.jsxs)("select",{value:R,onChange:t=>{var o;let r;return z(o=t.target.value),void((r=e.find(e=>e.name===o))&&(r.provider.api&&(d(r.provider.api),p(r.provider.api)),h(r.provider.baseUrl??""),m(r.provider.apiKey??""),x(r.provider.headers?{...r.provider.headers}:void 0)))},style:{...lY,color:R?"var(--text)":"var(--text-dim)"},children:[(0,r.jsx)("option",{value:"",children:s("desktop.modelsImportProviderPlaceholder")}),e.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name,e.provider.api?` \xb7 ${e.provider.api}`:""]},e.name))]}),R&&(0,r.jsxs)("span",{style:{fontSize:10,color:"#4ade80"},children:[s("desktop.modelsImported"),": ",R]})]}),(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",paddingTop:12,display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)(l2,{children:s("desktop.modelsFullUrl")}),k?(0,r.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,r.jsx)(lX,{value:u,onChange:h,placeholder:s("desktop.modelsUrlPlaceholder"),mono:!0}),(0,r.jsx)("button",{onClick:()=>{y(!1),h("")},title:s("desktop.modelsRemove"),style:{flexShrink:0,width:28,height:28,background:"none",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-dim)",cursor:"pointer",fontSize:14,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"\xd7"})]}):(0,r.jsxs)("button",{onClick:()=>y(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"7px 0",background:"none",border:"1px dashed var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer",fontSize:12},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:[(0,r.jsx)(v.c,{size:12}),s("desktop.modelsAddUrl")]}),u.trim()&&!M&&(0,r.jsx)("span",{style:{fontSize:10,color:"#ef4444"},children:s("desktop.modelsUrlInvalid")}),(0,r.jsxs)(lJ,{label:s("desktop.modelsApiKey"),children:[(0,r.jsx)(lZ,{value:g,onChange:m,placeholder:s("desktop.modelsApiKeyPlaceholder"),mono:!0}),(0,r.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:s("desktop.modelsApiKeyHelp")})]})]}),(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",paddingTop:12,display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)(l2,{children:s("desktop.modelsCustomRequest")}),(0,r.jsxs)(lJ,{label:s("desktop.modelsRequestModelId"),children:[(0,r.jsx)(lX,{value:b,onChange:w,placeholder:"model-id",mono:!0}),(0,r.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:s("desktop.modelsRequestModelIdHelp")})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,r.jsx)(lJ,{label:s("desktop.modelsRequestContextLength"),children:(0,r.jsx)(lQ,{value:j,onChange:S,placeholder:"128000"})}),(0,r.jsx)(lJ,{label:s("desktop.modelsRequestOutputLength"),children:(0,r.jsx)(lQ,{value:C,onChange:T,placeholder:"16384"})})]})]})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"10px 16px",borderTop:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsx)("button",{onClick:t,style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:13},children:s("desktop.cancel")}),(0,r.jsx)("button",{onClick:()=>{let e=b.trim()?{id:b.trim(),...parseInt(j,10)>0?{contextWindow:parseInt(j,10)}:{},...parseInt(C,10)>0?{maxTokens:parseInt(C,10)}:{}}:void 0;o({name:i.trim(),api:l,...u.trim()?{baseUrl:u.trim()}:{},...g.trim()?{apiKey:g.trim()}:{},...f?{headers:f}:{},model:e})},disabled:!M,style:{padding:"6px 16px",background:M?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:6,color:M?"#fff":"var(--text-dim)",cursor:M?"pointer":"not-allowed",fontSize:13,fontWeight:600},children:s("desktop.modelsAdd")})]})]})})}function dn({embedded:e=!1,sessionId:t,onCloseAction:o,onSavedAction:s,onRegisterFlush:i}){let a=lG(),l=O(),[d,c]=(0,n.useState)({providers:{}}),[p,u]=(0,n.useState)(!0),[h,g]=(0,n.useState)(!1),[f,x]=(0,n.useState)(null),[k,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(null),[w,j]=(0,n.useState)([]),[S,C]=(0,n.useState)([]),[T,R]=(0,n.useState)(!1),[I,M]=(0,n.useState)(!1),[P,E]=(0,n.useState)({oauth:!1,apiKey:!1}),W=(0,n.useRef)({providers:{}}),F=(0,n.useRef)(new Map),D=(0,n.useRef)(0),A=(0,n.useRef)(!1);W.current=d;let N=(0,n.useCallback)(e=>{let t=e(W.current);return W.current=t,D.current+=1,c(t),t},[]),L=(0,n.useCallback)(()=>{fetch("/api/auth/combined").then(e=>e.json()).then(e=>{j(e.oauth??[]),C(e.apiKey??[])}).catch(()=>{}).finally(()=>E({oauth:!0,apiKey:!0}))},[]),$=(0,n.useCallback)((e,t)=>(F.current.set(e,t),()=>{F.current.get(e)===t&&F.current.delete(e)}),[]),H=(0,n.useCallback)(async()=>{for(let e of[...F.current.values()])await e()},[]);(0,n.useEffect)(()=>{if(i)return i(H)??void 0},[H,i]);let B=(0,n.useCallback)((e,t)=>{N(o=>{let r={...o.providers??{}};return t?r[e]=t:delete r[e],{...o,providers:r}}),s?.()},[s,N]),U=(0,n.useCallback)(async e=>{if(!A.current){A.current=!0,x(null);try{await H(),b(e)}catch(e){x(e instanceof Error?e.message:String(e))}finally{A.current=!1}}},[H]);(0,n.useEffect)(()=>{fetch("/api/models-config").then(e=>e.json()).then(e=>{let t=e.providers?e:{...e,providers:{}};W.current=t,D.current+=1,c(t)}).catch(()=>{let e={providers:{}};W.current=e,D.current+=1,c(e)}).finally(()=>u(!1)),L()},[L]);let _=(0,n.useCallback)(async e=>{if(!A.current){A.current=!0,x(null);try{await H();let t=e.name.trim()||"new-provider",o=t,r=1;for(;W.current.providers?.[o];)o=`${t}-${r++}`;let n={api:e.api||"openai-completions",...e.baseUrl?{baseUrl:e.baseUrl}:{},...e.apiKey?{apiKey:e.apiKey}:{},...e.headers?{headers:e.headers}:{},...e.model?{models:[e.model]}:{}};N(e=>({...e,providers:{...e.providers??{},[o]:n}})),b({type:"provider",name:o}),M(!1)}catch(e){x(e instanceof Error?e.message:String(e))}finally{A.current=!1}}},[H,N]),q=(0,n.useCallback)((e,t)=>{N(o=>({...o,providers:{...o.providers??{},[e]:t}}))},[N]),V=(0,n.useCallback)((e,t)=>{N(o=>{let r=Object.entries(o.providers??{}),n=r.findIndex(([t])=>t===e);return -1===n?o:(r[n]=[t,r[n][1]],{...o,providers:Object.fromEntries(r)})}),b(o=>o?"provider"===o.type&&o.name===e?{type:"provider",name:t}:"model"===o.type&&o.providerName===e?{...o,providerName:t}:o:o)},[N]),K=(0,n.useCallback)(e=>{let t=Object.keys(N(t=>{let o={...t.providers??{}};return delete o[e],{...t,providers:o}}).providers??{});b(t.length>0?{type:"provider",name:t[0]}:null)},[N]),G=(0,n.useCallback)(async e=>{if(!A.current){A.current=!0,x(null);try{await H();let t=N(t=>{let o=t.providers?.[e]??{},r=[...o.models??[],{id:""}];return{...t,providers:{...t.providers??{},[e]:{...o,models:r}}}}),o=(t.providers?.[e]?.models?.length??1)-1;b({type:"model",providerName:e,index:o})}catch(e){x(e instanceof Error?e.message:String(e))}finally{A.current=!1}}},[H,N]),J=(0,n.useCallback)((e,t)=>{N(o=>{let r=o.providers?.[e]??{},n=[...r.models??[]],s=new Set(n.map(e=>e.id));for(let e of t)s.has(e.id)||(s.add(e.id),n.push({id:e.id,name:e.name}));return{...o,providers:{...o.providers??{},[e]:{...r,models:n}}}})},[N]),Y=(0,n.useCallback)((e,t,o)=>{N(r=>{let n=r.providers?.[e]??{},s=[...n.models??[]];return s[t]=o,{...r,providers:{...r.providers??{},[e]:{...n,models:s}}}})},[N]),X=(0,n.useCallback)(async(e,t)=>{if(!A.current){A.current=!0,x(null);try{await H(),N(o=>{let r=o.providers?.[e]??{},n=[...r.models??[]];return n.splice(t,1),{...o,providers:{...o.providers??{},[e]:{...r,models:n.length?n:void 0}}}}),b({type:"provider",name:e})}catch(e){x(e instanceof Error?e.message:String(e))}finally{A.current=!1}}},[H,N]),Z=(0,n.useCallback)(async()=>{if(!h){g(!0),x(null),v(!1);try{await H();let e=W.current,t=await fetch("/api/models-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);o.config&&(W.current=o.config,D.current+=1,c(o.config)),v(!0),s?.(),setTimeout(()=>v(!1),2e3)}catch(e){x(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[H,s,h]),Q=(0,n.useCallback)(async()=>{try{await H(),o?.()}catch(e){x(e instanceof Error?e.message:String(e))}},[H,o]),ee=Object.entries(d.providers??{}),et=new Set([...w.map(e=>e.id),...S.map(e=>e.id)]),eo=ee.filter(([e])=>!et.has(e)),er=w.filter(e=>e.loggedIn),en=S.filter(e=>e.configured);(0,n.useEffect)(()=>{if(y||p||!P.oauth||!P.apiKey)return;let e=er[0]?{type:"oauth",providerId:er[0].id}:en[0]?{type:"apikey",providerId:en[0].id}:eo[0]?.[0]?{type:"provider",name:eo[0][0]}:null;e&&b(e)},[en,er,eo,p,P.apiKey,P.oauth,y]);let es=(()=>{if(!y)return null;if("oauth"===y.type){let e=w.find(e=>e.id===y.providerId);return e?(0,r.jsx)(l9,{provider:e,onRefresh:L,onRegisterBuiltinFlush:$,onBuiltinProviderChange:t=>B(e.id,t)},e.id):null}if("apikey"===y.type){let e=S.find(e=>e.id===y.providerId);return e?(0,r.jsx)(de,{provider:e,onRefresh:L,onRegisterBuiltinFlush:$,onBuiltinProviderChange:t=>B(e.id,t)},e.id):null}if("provider"===y.type){let e=d.providers?.[y.name];return e?(0,r.jsx)(l4,{name:y.name,provider:e,onChange:e=>q(y.name,e),onRename:e=>V(y.name,e),onDelete:()=>K(y.name),onAddModels:e=>J(y.name,e),onAddModel:()=>{G(y.name)}},y.name):null}let e=d.providers?.[y.providerName],t=e?.models?.[y.index];return t?(0,r.jsx)(l7,{providerName:y.providerName,provider:e,model:t,onChange:e=>Y(y.providerName,y.index,e),onDelete:()=>{X(y.providerName,y.index)}},`${y.providerName}-${y.index}`):null})();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:e?{display:"flex",flex:1,minWidth:0,minHeight:0,overflow:"hidden"}:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:t=>{e||t.target!==t.currentTarget||Q()},children:(0,r.jsxs)("div",{style:e?{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"}:{width:l?"calc(100vw - 16px)":860,maxWidth:"calc(100vw - 16px)",height:l?"calc(100dvh - 16px)":"78vh",maxHeight:"calc(100dvh - 16px)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[!e&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:a("desktop.models")}),(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:"~/.pi/agent/models.json"})]}),(0,r.jsx)("button",{onClick:()=>{Q()},"aria-label":a("desktop.modelsClose"),title:a("desktop.modelsClose"),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),(0,r.jsx)(lO,{}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:l?"column":"row",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{width:l?"100%":210,maxHeight:l?"40vh":void 0,borderRight:l?"none":"1px solid var(--border)",borderBottom:l?"1px solid var(--border)":"none",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,r.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:[er.map(e=>{let t=y?.type==="oauth"&&y.providerId===e.id;return(0,r.jsxs)("div",{onClick:()=>{U({type:"oauth",providerId:e.id})},style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",borderRadius:5,cursor:"pointer",background:t?"var(--bg-selected)":"none"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[(0,r.jsx)(is,{id:e.id,size:16}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.id)}),en.map(e=>{let t=y?.type==="apikey"&&y.providerId===e.id;return(0,r.jsxs)("div",{onClick:()=>{U({type:"apikey",providerId:e.id})},style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",borderRadius:5,cursor:"pointer",background:t?"var(--bg-selected)":"none"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[(0,r.jsx)(is,{id:e.id,size:16}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.displayName})]},e.id)}),(er.length>0||en.length>0)&&eo.length>0&&(0,r.jsx)("div",{style:{margin:"4px 8px",borderTop:"1px solid var(--border)"}}),p?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:a("desktop.modelsLoading")}):eo.map(([e,t])=>{let o=y?.type==="provider"&&y.name===e,n=t.models??[];return(0,r.jsxs)("div",{style:{marginBottom:2},children:[(0,r.jsxs)("div",{onClick:()=>{U({type:"provider",name:e})},style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,cursor:"pointer",background:o?"var(--bg-selected)":"none"},onMouseEnter:e=>{o||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{o||(e.currentTarget.style.background="none")},children:[(0,r.jsx)(z.G,{size:11,style:{color:"var(--text-dim)",flexShrink:0}}),(0,r.jsx)("span",{style:{fontSize:12,fontWeight:o?600:400,color:"var(--text)",fontFamily:"var(--font-mono)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})]}),n.map((t,o)=>{let n=y?.type==="model"&&y.providerName===e&&y.index===o;return(0,r.jsxs)("div",{onClick:()=>{U({type:"model",providerName:e,index:o})},style:{display:"flex",alignItems:"center",gap:6,padding:"5px 8px 5px 26px",borderRadius:5,cursor:"pointer",background:n?"var(--bg-selected)":"none"},onMouseEnter:e=>{n||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{n||(e.currentTarget.style.background="none")},children:[(0,r.jsx)("span",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:t.id?"var(--text-muted)":"var(--text-dim)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.id||a("desktop.modelsNewModel")}),t.reasoning&&(0,r.jsx)("span",{style:{fontSize:9,padding:"1px 4px",background:"rgba(99,102,241,0.12)",color:"rgba(99,102,241,0.8)",borderRadius:3,flexShrink:0},children:"T"})]},o)}),(0,r.jsx)("div",{onClick:t=>{t.stopPropagation(),G(e)},style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px 4px 26px",borderRadius:5,cursor:"pointer",color:"var(--text-dim)"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,r.jsx)("span",{style:{fontSize:11},children:a("desktop.modelsAddModel")})})]},e)})]}),(0,r.jsx)("div",{style:{borderTop:"1px solid var(--border)",padding:"8px 6px"},children:(0,r.jsx)("button",{onClick:()=>R(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,width:"100%",padding:"6px 0",background:"none",border:"1px dashed var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer",fontSize:12},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:a("desktop.modelsAddProvider")})})]}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:p?null:es??(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:a("desktop.modelsSelectProviderOrModel")})})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:10,padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:[f&&(0,r.jsx)("span",{style:{fontSize:12,color:"#f87171",flex:1},children:f}),!e&&(0,r.jsx)("button",{onClick:()=>{Q()},style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:13},children:a("desktop.cancel")}),(0,r.jsx)(lE,{sessionId:t,onBeforeApply:Z}),(0,r.jsxs)("button",{onClick:Z,disabled:h||k,style:{position:"relative",padding:"6px 16px",minWidth:92,background:k?"#16a34a":h?"var(--bg-panel)":"var(--accent)",border:"none",borderRadius:6,color:k?"#fff":h?"var(--text-muted)":"#fff",cursor:h||k?"default":"pointer",fontSize:13,fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,transition:"background-color 0.2s ease, color 0.2s ease",animation:k?"saved-pop 0.45s ease":void 0},children:[k&&(0,r.jsx)(m.S,{size:14,style:{strokeDasharray:18,animation:"saved-check-draw 0.35s ease forwards",flexShrink:0}}),(0,r.jsx)("span",{children:k?a("desktop.modelsSaved"):h?a("desktop.modelsSaving"):a("desktop.modelsSave")})]})]})]})}),T&&(0,r.jsx)(dt,{oauthProviders:w,apiKeyProviders:S,onSelectOAuth:e=>{U({type:"oauth",providerId:e})},onSelectApiKey:e=>{U({type:"apikey",providerId:e})},onAddCustom:()=>{R(!1),M(!0)},onClose:()=>R(!1)}),I&&(0,r.jsx)(dr,{existingProviders:eo.map(([e,t])=>({name:e,provider:t})),onCancel:()=>M(!1),onSubmit:e=>{_(e)}})]})}function ds(e){return e.replace(/^\/(?:Users|home)\/[^/]+/,"~")}function di(e){let t=e.trim().match(/^\$?\s*pi\s+install\s+(\S+)\s*$/);return t?.[1]??e}function da(e){return`${e.scope}\0${e.source}`}function dl(e,t){if(e.disabled)return t("desktop.disabled");let o=[e.counts.extensions?t("desktop.extensionsCount",{count:e.counts.extensions}):"",e.counts.skills?t("desktop.skillsCount",{count:e.counts.skills}):"",e.counts.prompts?t("desktop.promptsCount",{count:e.counts.prompts}):"",e.counts.themes?t("desktop.themesCount",{count:e.counts.themes}):""].filter(Boolean);return o.length?o.join(" \xb7 "):t("desktop.noResources")}function dd(e,t){let o=[];return e.version&&o.push(t("desktop.installedVersion",{version:e.version})),e.configuredVersion&&o.push(t("desktop.configuredVersion",{version:e.configuredVersion})),o.length?o.join(" \xb7 "):t("desktop.unknown")}function dc(e){return"loaded"===e?"var(--accent)":"installed"===e?"#f59e0b":"disabled"===e?"var(--text-dim)":"#ef4444"}function dp({pkg:e}){let{t}=(0,A.s)(),o=[["extension",t("desktop.extensions")],["skill",t("desktop.skills")],["prompt",t("desktop.prompts")],["theme",t("desktop.themes")]].map(([t,o])=>({kind:t,label:o,resources:e.resources.filter(e=>e.kind===t)})).filter(e=>e.resources.length>0);return 0===o.length?(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-dim)"},children:t(e.disabled?"desktop.packageDisabled":"desktop.noResolvedResources")}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:o.map((e,t)=>(0,r.jsxs)("div",{style:{borderTop:0===t?"none":"1px solid var(--border)",paddingTop:12*(0!==t)},children:[(0,r.jsx)("div",{style:{fontSize:10,fontWeight:700,color:"var(--text-dim)",textTransform:"uppercase",marginBottom:6},children:e.label}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.resources.map(e=>(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.path,children:e.name}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:1},title:e.path,children:e.relativePath})]},`${e.kind}:${e.path}`))})]},e.kind))})}function du({scope:e}){let{t}=(0,A.s)();return(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,flexShrink:0,background:"project"===e?"rgba(99,102,241,0.12)":"rgba(120,120,120,0.12)",color:"project"===e?"rgba(99,102,241,0.85)":"var(--text-dim)"},children:t(`desktop.${e}`)})}function dh(e,t){return{padding:"6px 12px",background:t?"rgba(239,68,68,0.08)":"none",border:"1px solid var(--border)",borderRadius:6,color:t?"#ef4444":"var(--text-muted)",cursor:e?"not-allowed":"pointer",fontSize:12,opacity:e?.5:1}}function dg({enabled:e,loading:t,onToggle:o,label:n}){return(0,r.jsx)("button",{type:"button",onClick:o,disabled:t,title:n,"aria-label":n,"aria-pressed":e,style:{flexShrink:0,width:40,height:22,borderRadius:11,border:"none",padding:0,cursor:t?"wait":"pointer",background:e?"var(--accent)":"var(--border)",position:"relative",transition:"background 0.18s",outline:"none",opacity:t?.65:1},children:(0,r.jsx)("span",{style:{position:"absolute",top:3,left:e?21:3,width:16,height:16,borderRadius:"50%",background:"var(--bg)",boxShadow:"0 1px 4px rgba(0,0,0,0.22)",transition:"left 0.18s cubic-bezier(.4,0,.2,1)"}})})}function dm({value:e,onChange:t}){let{t:o}=(0,A.s)();return(0,r.jsx)("div",{style:{display:"inline-flex",border:"1px solid var(--border)",borderRadius:7,overflow:"hidden",height:30},children:["global","project"].map(n=>{let s=e===n;return(0,r.jsx)("button",{onClick:()=>t(n),style:{width:76,border:"none",borderRight:"global"===n?"1px solid var(--border)":"none",background:s?"var(--bg-selected)":"none",color:s?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12},children:o(`desktop.${n}`)},n)})})}function df({cwd:e,source:t,scope:o,busy:s,actionError:i,onSourceChange:a,onScopeChange:l,onInstall:d}){let{t:c}=(0,A.s)(),p=(0,n.useRef)(null);return(0,n.useEffect)(()=>{p.current?.focus()},[]),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:18,maxWidth:660,minHeight:"100%"},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[(0,r.jsx)("div",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:c("desktop.addPluginTitle")}),(0,r.jsx)("a",{href:"https://pi.dev/packages",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",fontSize:12,textDecoration:"none",whiteSpace:"nowrap"},children:"pi.dev/packages ↗"})]}),(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:"project"===o?`${ds(e)}/.pi/agent/{npm,git}`:"~/.pi/agent/{npm,git}"})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:7},children:[(0,r.jsx)("label",{htmlFor:"plugin-source",style:{fontSize:12,fontWeight:600,color:"var(--text-muted)"},children:c("desktop.pluginSource")}),(0,r.jsx)("input",{id:"plugin-source",ref:p,value:t,onChange:e=>a(e.target.value),onPaste:e=>{let t=e.clipboardData.getData("text"),o=di(t);o!==t&&(e.preventDefault(),a(o))},onBlur:e=>a(di(e.currentTarget.value)),placeholder:"npm:@scope/package",style:{width:"100%",height:36,padding:"0 11px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:13,outline:"none"},onKeyDown:e=>{"Enter"===e.key&&t.trim()&&!s&&d()}})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)(dm,{value:o,onChange:l}),(0,r.jsx)("button",{type:"button",onClick:d,disabled:s||!t.trim(),style:{...dh(s||!t.trim()),background:"var(--accent)",color:"white",borderColor:"var(--accent)"},children:c(s?"desktop.installing":"desktop.install")})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:7},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)"},children:c("desktop.examples")}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:["npm:@scope/pi-plugin","git:https://github.com/user/repo","/absolute/path/to/plugin"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>a(e),style:{width:"100%",minHeight:30,textAlign:"left",padding:"6px 9px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-dim)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:11},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-panel)",e.currentTarget.style.color="var(--text-dim)"},children:e},e))})]}),i&&(0,r.jsx)("div",{style:{fontSize:12,color:"#ef4444",whiteSpace:"pre-wrap"},children:i})]})}function dx({pkg:e,cwd:t,busyKey:o,actionError:n,actionMessage:s,sessionId:i,onAction:a,onReloadSession:l}){let{t:d}=(0,A.s)(),c=da(e),p=o?.endsWith(c)??!1,u="reload"===o,h=!e.disabled;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,maxWidth:680},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12,minWidth:0,flexWrap:"wrap"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:180,flex:1},children:[(0,r.jsx)(dg,{enabled:h,loading:p||u,onToggle:()=>a(e.disabled?"enable":"disable",e),label:d(e.disabled?"desktop.enablePackage":"desktop.disablePackage")}),(0,r.jsx)(du,{scope:e.scope}),e.disabled?(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,background:"rgba(120,120,120,0.12)",color:"var(--text-dim)"},children:d("desktop.disabled")}):e.filtered&&(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,background:"rgba(245,158,11,0.12)",color:"#d97706"},children:d("desktop.filtered")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.source})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("button",{onClick:()=>a("update",e),disabled:p||u,style:dh(p||u),children:d(o===`update:${c}`?"desktop.updating":"desktop.update")}),(0,r.jsx)("button",{onClick:l,disabled:!i||u||p,style:dh(!i||u||p),title:d(i?"desktop.reloadCurrentSession":"desktop.openSessionToReload"),children:d(u?"desktop.reloading":"desktop.reloadSession")}),(0,r.jsx)("button",{onClick:()=>a("remove",e),disabled:p||u,style:dh(p||u,!0),children:d(o===`remove:${c}`?"desktop.removing":"desktop.remove")})]})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(96px, 130px) minmax(0, 1fr)",gap:"9px 14px",fontSize:12,lineHeight:1.45},children:[(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:d("desktop.status")}),(0,r.jsx)("div",{style:{color:dc(e.status),textTransform:"capitalize"},children:e.status}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:d("desktop.version")}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:dd(e,d)}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:d("desktop.package")}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",overflowWrap:"anywhere"},children:e.packageName??d("desktop.unknown")}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:d("desktop.resources")}),(0,r.jsx)("div",{style:{color:"var(--text-muted)"},children:dl(e,d)}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:d("desktop.installedPath")}),(0,r.jsx)("div",{style:{color:e.installedPath?"var(--text-muted)":"#ef4444",fontFamily:"var(--font-mono)",overflowWrap:"anywhere"},children:e.installedPath?ds(e.installedPath):d("desktop.notFound")}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:d("desktop.cwd")}),(0,r.jsx)("div",{style:{color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflowWrap:"anywhere"},children:ds(t)})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:700,color:"var(--text)"},children:d("desktop.resolvedResources")}),(0,r.jsx)(dp,{pkg:e})]}),s&&(0,r.jsx)("div",{style:{fontSize:12,color:"#16a34a"},children:s}),n&&(0,r.jsx)("div",{style:{fontSize:12,color:"#ef4444",whiteSpace:"pre-wrap"},children:n})]})}function dk({cwd:e,sessionId:t,embedded:o=!1,onCloseAction:s,onReloadedAction:i}){let a=O(),{t:l}=(0,A.s)(),[d,c]=(0,n.useState)(null),[p,u]=(0,n.useState)(!0),[h,g]=(0,n.useState)(null),[m,f]=(0,n.useState)(null),[x,k]=(0,n.useState)(!1),[y,b]=(0,n.useState)(""),[w,j]=(0,n.useState)("global"),[S,C]=(0,n.useState)(null),[T,R]=(0,n.useState)(null),[z,I]=(0,n.useState)(null),M=(0,n.useMemo)(()=>d?.packages??[],[d?.packages]),P=M.find(e=>da(e)===m)??null,E=(0,n.useMemo)(()=>["project","global"].map(e=>({scope:e,packages:M.filter(t=>t.scope===e)})).filter(e=>e.packages.length>0),[M]),W=(0,n.useCallback)(async()=>{u(!0),g(null);try{let t=await fetch(`/api/plugins?cwd=${encodeURIComponent(e)}`),o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);c(o),k(e=>0===o.packages.length||e),f(e=>e&&o.packages.some(t=>da(t)===e)?e:o.packages[0]?da(o.packages[0]):null)}catch(e){g(e instanceof Error?e.message:String(e))}finally{u(!1)}},[e]);(0,n.useEffect)(()=>{W()},[W]);let F=(0,n.useCallback)(async(t,o)=>{let r=da(o);C(`${t}:${r}`),R(null),I(null);try{let r=await fetch("/api/plugins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,source:o.source,scope:o.scope,cwd:e})}),n=await r.json();if(!r.ok||n.error)throw Error(n.error??`HTTP ${r.status}`);if(c(n),"remove"===t)f(n.packages[0]?da(n.packages[0]):null),0===n.packages.length&&k(!0),I(l("desktop.packageRemoved"));else{let e={install:l("desktop.packageInstalled"),update:l("desktop.packageUpdated"),disable:l("desktop.packageDisabledMessage"),enable:l("desktop.packageEnabled")};I(e[t])}}catch(e){R(e instanceof Error?e.message:String(e))}finally{C(null)}},[e,l]),D=(0,n.useCallback)(async()=>{let t=di(y).trim();if(!t)return;let o=`${w}\0${t}`;C(`install:${o}`),R(null),I(null);try{var r;let n,s,i=await fetch("/api/plugins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"install",source:t,scope:w,cwd:e})}),a=await i.json();if(!i.ok||a.error)throw Error(a.error??`HTTP ${i.status}`);c(a);let d=(r=a.packages,s=(n=t.trim()).startsWith("npm:")?n.slice(4):n,r.find(e=>e.scope===w&&e.source===n)??r.find(e=>e.scope===w&&e.source===`npm:${s}`)??r.find(e=>e.scope===w&&e.source.endsWith(n)));f(d?da(d):o),k(!1),b(""),I(l("desktop.packageInstalled"))}catch(e){R(e instanceof Error?e.message:String(e))}finally{C(null)}},[e,w,y,l]),N=(0,n.useCallback)(async()=>{if(t){C("reload"),R(null),I(null);try{await i6(t,{type:"reload"}),i?.(),await W(),I(l("desktop.sessionReloaded"))}catch(e){R(e instanceof Error?e.message:String(e))}finally{C(null)}}},[W,i,t,l]),L=S?.startsWith("install:")??!1;return(0,r.jsx)("div",{style:o?{display:"flex",flex:1,minWidth:0,minHeight:0,overflow:"hidden"}:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{o||e.target!==e.currentTarget||s?.()},children:(0,r.jsxs)("div",{style:o?{display:"flex",flex:1,minWidth:0,minHeight:0,flexDirection:"column",overflow:"hidden"}:{width:a?"calc(100vw - 16px)":860,maxWidth:"calc(100vw - 16px)",height:a?"calc(100dvh - 16px)":"76vh",maxHeight:"calc(100dvh - 16px)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[!o&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,minWidth:0},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:l("desktop.plugins")}),(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ds(e)})]}),(0,r.jsx)("button",{onClick:s,title:l("desktop.close"),"aria-label":l("desktop.close"),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:a?"column":"row",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{width:a?"100%":245,maxHeight:a?"40vh":void 0,borderRight:a?"none":"1px solid var(--border)",borderBottom:a?"1px solid var(--border)":"none",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:p?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:l("desktop.loading")}):h?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"#ef4444"},children:h}):0===M.length?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"var(--text-dim)"},children:l("desktop.noPluginsConfigured")}):E.map(e=>(0,r.jsxs)("div",{style:{marginBottom:6},children:[(0,r.jsx)("div",{style:{padding:"4px 8px 3px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase"},children:l(`desktop.${e.scope}`)}),e.packages.map(e=>{let t=da(e),o=!x&&m===t;return(0,r.jsxs)("div",{onClick:()=>{f(t),k(!1),R(null),I(null)},style:{display:"flex",alignItems:"center",gap:7,padding:"8px 8px",borderRadius:5,cursor:"pointer",background:o?"var(--bg-selected)":"none"},onMouseEnter:e=>{o||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{o||(e.currentTarget.style.background="none")},children:[(0,r.jsx)("span",{style:{flexShrink:0,width:7,height:7,borderRadius:"50%",background:dc(e.status)}}),(0,r.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:o?600:400,color:"var(--text)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.source}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:2},children:dl(e,l)}),(e.version||e.configuredVersion)&&(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:2},children:dd(e,l)})]})]},t)})]},e.scope))}),(0,r.jsx)("div",{style:{padding:"8px 6px",borderTop:"1px solid var(--border)",flexShrink:0},children:(0,r.jsxs)("button",{type:"button",onClick:()=>{k(!0),R(null),I(null)},style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,border:"none",width:"100%",cursor:"pointer",background:x?"var(--bg-selected)":"none",color:x?"var(--accent)":"var(--text-dim)",fontSize:12},onMouseEnter:e=>{x||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{x||(e.currentTarget.style.background="none")},children:[(0,r.jsx)(v.c,{size:13}),l("desktop.addPlugin")]})})]}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:x?(0,r.jsx)(df,{cwd:e,source:y,scope:w,busy:L,actionError:T,onSourceChange:b,onScopeChange:j,onInstall:D}):p?null:P?(0,r.jsx)(dx,{pkg:P,cwd:e,busyKey:S,actionError:T,actionMessage:z,sessionId:t,onAction:F,onReloadSession:N},da(P)):(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:l("desktop.selectPackage")})})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsx)("div",{style:{minWidth:0,flex:1,fontSize:11,color:"var(--text-dim)",overflow:"hidden"},children:d?.diagnostics.length?(0,r.jsx)("span",{title:d.diagnostics.map(e=>`${e.type}: ${e.source?`${e.source}: `:""}${e.message}`).join("\n"),style:{color:d.diagnostics.some(e=>"error"===e.type)?"#ef4444":"#d97706"},children:l("desktop.diagnosticsCount",{count:d.diagnostics.length,suffix:1===d.diagnostics.length?"":"s"})}):(0,r.jsx)("span",{children:d?l("desktop.pluginResourceTotals",{extensions:d.totals.extensions,skills:d.totals.skills,prompts:d.totals.prompts,themes:d.totals.themes}):""})}),(0,r.jsx)("button",{onClick:()=>void W(),disabled:p||null!==S,style:dh(p||null!==S),children:l("desktop.refresh")}),!o&&(0,r.jsx)("button",{onClick:s,style:dh(!1),children:l("desktop.close")})]})]})})}var dv=o(36282);function dy(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)({enabled:!1,protocol:"http",host:"127.0.0.1",port:7890,username:"",password:"",noProxy:"localhost,127.0.0.1,.local",hasPassword:!1}),[s,i]=(0,n.useState)(!1),[a,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(null),[p,u]=(0,n.useState)(null),[h,g]=(0,n.useState)(null),[m,f]=(0,n.useState)(!1),[x,k]=(0,n.useState)(!1);(0,n.useEffect)(()=>{(async()=>{try{let e=await fetch("/api/proxy");if(e.ok){let t=await e.json();o(e=>({...e,...t,password:""}))}}catch{}})()},[]);let v=(0,n.useCallback)((e,t)=>{o(o=>({...o,[e]:t})),"password"===e&&k(!0),f(!0),u(null),g(null)},[]),y=(0,n.useCallback)(async()=>{i(!0),u(null),g(null);try{let r={...t};delete r.hasPassword,x||delete r.password;let n=await fetch("/api/proxy",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),s=await n.json();if(n.ok){u(!0),f(!1),k(!1);let e=await fetch("/api/proxy");if(e.ok){let t=await e.json();o(e=>({...e,...t,password:""}))}}else u(!1),g(s.error||e("desktop.proxySaveFailed"))}catch(t){u(!1),g(t instanceof Error?t.message:e("desktop.proxySaveFailed"))}finally{i(!1)}},[t,x,e]),b=(0,n.useCallback)(async()=>{l(!0),c(null),m&&await y();try{let t=await fetch("/api/proxy/test",{method:"POST"}),o=await t.json();o.success?c({ok:!0,message:`${e("desktop.proxyTestSuccess")} \xb7 ${o.latencyMs}ms`,latencyMs:o.latencyMs}):c({ok:!1,message:o.error||e("desktop.proxyTestFailed")})}catch(t){c({ok:!1,message:t instanceof Error?t.message:e("desktop.proxyTestFailed")})}finally{l(!1)}},[m,y,e]),w=(0,n.useCallback)(()=>{if(!t.enabled||!t.host||!t.port)return null;let e="";return t.username&&t.password?e=`${t.username}:${"•".repeat(Math.min(t.password.length,8))}@`:t.username&&(e=`${t.username}@`),`${t.protocol}://${e}${t.host}:${t.port}`},[t.enabled,t.host,t.port,t.protocol,t.username,t.password])();return(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",padding:"16px 20px",overflow:"auto",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:4},children:[(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:500,color:"var(--text)",cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:t.enabled,onChange:e=>v("enabled",e.target.checked),style:{width:16,height:16,accentColor:"var(--accent)"}}),e("desktop.proxyEnable")]}),t.enabled&&w&&(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontFamily:"var(--font-mono)",backgroundColor:"var(--bg-hover)",padding:"2px 10px",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"60%"},title:w,children:w})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px 16px",opacity:t.enabled?1:.5,pointerEvents:t.enabled?"auto":"none"},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.proxyProtocol")}),(0,r.jsxs)("select",{value:t.protocol,onChange:e=>v("protocol",e.target.value),style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:13,fontFamily:"var(--font-mono)",outline:"none"},children:[(0,r.jsx)("option",{value:"http",children:"HTTP"}),(0,r.jsx)("option",{value:"https",children:"HTTPS"}),(0,r.jsx)("option",{value:"socks5",children:"SOCKS5"})]})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.proxyHost")}),(0,r.jsx)("input",{type:"text",value:t.host,onChange:e=>v("host",e.target.value),placeholder:"127.0.0.1",style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:13,fontFamily:"var(--font-mono)",outline:"none"}})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.proxyPort")}),(0,r.jsx)("input",{type:"number",value:t.port,onChange:e=>v("port",parseInt(e.target.value,10)||0),placeholder:"7890",min:1,max:65535,style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:13,fontFamily:"var(--font-mono)",outline:"none"}})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.proxyUsername")}),(0,r.jsx)("input",{type:"text",value:t.username,onChange:e=>v("username",e.target.value),placeholder:t.username?"":e("desktop.proxyUsername"),style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:13,fontFamily:"var(--font-mono)",outline:"none"}})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.proxyPassword")}),(0,r.jsx)("input",{type:"password",value:t.password,onChange:e=>v("password",e.target.value),placeholder:t.hasPassword?"••••••••":e("desktop.proxyPassword"),style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:13,fontFamily:"var(--font-mono)",outline:"none"}})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,gridColumn:"1 / -1"},children:[(0,r.jsx)("label",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.proxyNoProxy")}),(0,r.jsx)("input",{type:"text",value:t.noProxy,onChange:e=>v("noProxy",e.target.value),placeholder:"localhost,127.0.0.1,.local",style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:13,fontFamily:"var(--font-mono)",outline:"none"}})]})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:10,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:y,disabled:s,style:{padding:"6px 18px",borderRadius:6,border:"none",background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:500,cursor:s?"not-allowed":"pointer",opacity:s?.5:1,transition:"background 0.15s"},onMouseEnter:e=>{s||(e.currentTarget.style.background="var(--accent-hover)")},onMouseLeave:e=>{s||(e.currentTarget.style.background="var(--accent)")},children:s?e("desktop.proxySaving"):e("desktop.proxySave")}),(0,r.jsx)("button",{type:"button",onClick:b,disabled:a||!t.enabled,style:{padding:"6px 18px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:t.enabled?"var(--text)":"var(--text-muted)",fontSize:13,fontWeight:500,cursor:t.enabled?"pointer":"not-allowed",opacity:t.enabled?1:.5,transition:"background 0.15s"},onMouseEnter:e=>{t.enabled&&(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t.enabled&&(e.currentTarget.style.background="var(--bg)")},children:a?e("desktop.proxyTesting"):e("desktop.proxyTest")})]}),!0===p&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderRadius:6,backgroundColor:"rgba(34, 197, 94, 0.12)",color:"#22c55e",fontSize:13},children:[(0,r.jsx)(nv.r,{size:16,weight:"fill"}),e("desktop.proxySaved")]}),!1===p&&h&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderRadius:6,backgroundColor:"rgba(239, 68, 68, 0.10)",color:"#ef4444",fontSize:13},children:[(0,r.jsx)(iU.J,{size:16,weight:"fill"}),h]}),d&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderRadius:6,backgroundColor:d.ok?"rgba(34, 197, 94, 0.10)":"rgba(239, 68, 68, 0.10)",color:d.ok?"#22c55e":"#ef4444",fontSize:13},children:[d.ok?(0,r.jsx)(nv.r,{size:16,weight:"fill"}):(0,r.jsx)(iU.J,{size:16,weight:"fill"}),d.message,void 0!==d.latencyMs&&(0,r.jsxs)("span",{style:{color:"var(--text-muted)",fontSize:12,marginLeft:4},children:["(",d.latencyMs,"ms)"]})]}),m&&!p&&!h&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 12px",borderRadius:6,backgroundColor:"var(--bg-hover)",color:"var(--text-muted)",fontSize:12},children:[(0,r.jsx)(dv.j,{size:12,weight:"fill"}),e("desktop.proxyUnsaved")]})]})}function db(e){return e.replace(/^\/(?:Users|home)\/[^/]+/,"~")}function dw(e){let t=e.sourceInfo?.source,o=e.sourceInfo?.scope;return"user"===o||"user"===t?"global":"project"===o||"project"===t?"project":"path"}function dj(e){return e.install?`${e.install.scope}\0${e.install.package}`:null}function dS(e,t){return e?e.slice(0,8):t}function dC({enabled:e,loading:t,onToggle:o}){let{t:n}=(0,A.s)();return(0,r.jsx)("button",{onClick:o,disabled:t,title:n(e?"desktop.visibleInModelPrompt":"desktop.hiddenFromModelPrompt"),style:{flexShrink:0,width:40,height:22,borderRadius:11,border:"none",padding:0,cursor:t?"wait":"pointer",background:e?"var(--accent)":"var(--border)",position:"relative",transition:"background 0.18s",outline:"none"},children:(0,r.jsx)("span",{style:{position:"absolute",top:3,left:e?21:3,width:16,height:16,borderRadius:"50%",background:"var(--bg)",boxShadow:"0 1px 4px rgba(0,0,0,0.22)",transition:"left 0.18s cubic-bezier(.4,0,.2,1)"}})})}function dT({skill:e,cwd:t,onToggle:o,toggling:n,saveError:s,updateStatus:i,checkingUpdate:a,updating:l,updateError:d,onCheckUpdate:c,onUpdate:p}){let{t:u}=(0,A.s)(),h=dw(e),g=!e.disableModelInvocation;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7},children:[(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,flexShrink:0,background:"project"===h?"rgba(99,102,241,0.12)":"rgba(120,120,120,0.12)",color:"project"===h?"rgba(99,102,241,0.8)":"var(--text-dim)"},children:u(`desktop.${h}`)}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-dim)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:function(e){if("project"===h&&e.startsWith(t)){let o=e.slice(t.length).replace(/^[/\\]/,"");return`./${o}`}return db(e)}(e.filePath)}),(0,r.jsx)(dC,{enabled:g,loading:n,onToggle:()=>o(e)}),s&&(0,r.jsx)("span",{style:{fontSize:12,color:"#f87171",flexShrink:0},children:s})]}),!g&&(0,r.jsx)("div",{style:{marginTop:-12,color:"var(--text-dim)",fontSize:12},children:u("desktop.hiddenButInvocable")}),e.install?.skillsShUrl&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:u("desktop.pluginSource")}),(0,r.jsx)("a",{href:e.install.skillsShUrl,target:"_blank",rel:"noreferrer",title:e.install.skillsShUrl,style:{display:"flex",alignItems:"center",gap:8,width:"fit-content",maxWidth:"100%",color:"var(--accent)",textDecoration:"none"},children:(0,r.jsxs)("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[e.install.skillsShUrl.replace(/^https?:\/\//,"")," ↗"]})})]}),e.install&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:7},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:u("desktop.version")}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-muted)"},children:dS(i?.currentVersion??e.install.versionHash,u("desktop.unknown"))}),e.install.canCheckForUpdates&&(0,r.jsx)("button",{onClick:c,disabled:a||l,style:{padding:"4px 9px",border:"1px solid var(--border)",borderRadius:5,background:"none",color:"var(--text-muted)",cursor:a||l?"not-allowed":"pointer",opacity:a||l?.5:1,fontSize:11},children:u("desktop.check")}),i?.state==="update-available"&&(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"#d97706"},children:dS(i.latestVersion,u("desktop.unknown"))}),(a||i&&"update-available"!==i.state)&&(0,r.jsx)("span",{style:{fontSize:12,color:a?"var(--accent)":i?.state==="up-to-date"?"#16a34a":i?.state==="error"?"#ef4444":"var(--text-dim)"},children:a?u("desktop.checking"):i?.state==="up-to-date"?u("desktop.upToDate"):i?.state==="unsupported"?u("desktop.automaticChecksUnavailable"):i?.message||u("desktop.checkFailed")}),i?.state==="update-available"&&(0,r.jsx)("button",{onClick:p,disabled:l||a,style:{padding:"4px 10px",border:"none",borderRadius:5,background:"var(--accent)",color:"#fff",cursor:l||a?"not-allowed":"pointer",opacity:l||a?.5:1,fontSize:11,fontWeight:600},children:u(l?"desktop.updating":"desktop.update")})]}),d&&(0,r.jsx)("span",{style:{fontSize:12,color:"#ef4444"},children:d})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:u("desktop.name")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--text)"},children:e.name})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:u("desktop.description")}),(0,r.jsx)("span",{style:{fontSize:14,color:"var(--text-muted)",lineHeight:1.6},children:e.description})]})]})}function dR({cwd:e,installedPackages:t,projectResourcesLoaded:o,onInstalled:s}){let{t:i}=(0,A.s)(),[a,l]=(0,n.useState)(""),[d,c]=(0,n.useState)([]),[p,u]=(0,n.useState)(!1),[h,g]=(0,n.useState)(null),[m,f]=(0,n.useState)(null),[x,k]=(0,n.useState)(null),[v,y]=(0,n.useState)(new Set),[b,w]=(0,n.useState)("global"),j=(0,n.useRef)(null);(0,n.useEffect)(()=>{j.current?.focus()},[]),(0,n.useEffect)(()=>{o||w("global")},[o]);let S=(0,n.useCallback)(async e=>{if(e.trim()){u(!0),g(null),c([]);try{let t=await fetch("/api/skills/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e.trim()})}),o=await t.json();if(o.error)return void g(o.error);c(o.results??[]),0===(o.results??[]).length&&g(i("desktop.noSkillsFound"))}catch(e){g(String(e))}finally{u(!1)}}},[i]),C=(0,n.useCallback)(async t=>{f(t),k(null);try{let o=await fetch("/api/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:t,scope:b,cwd:e})}),r=await o.json();if(!o.ok||r.error)return void k(r.error??`HTTP ${o.status}`);y(e=>new Set(e).add(`${b}:${t}`)),s()}catch(e){k(String(e))}finally{f(null)}},[s,b,e]),T="global"===b?"~/.pi/agent/skills/":`${db(e)}/.pi/skills/`;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:20},children:[(0,r.jsx)("div",{style:{fontSize:14,fontWeight:600,color:"var(--text)"},children:i("desktop.addSkillTitle")}),(0,r.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,r.jsx)("input",{ref:j,value:a,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&S(a)},placeholder:i("desktop.skillSearchPlaceholder"),style:{flex:1,padding:"7px 10px",fontSize:13,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",outline:"none"}}),(0,r.jsx)("button",{onClick:()=>S(a),disabled:p||!a.trim(),style:{padding:"7px 16px",fontSize:13,borderRadius:6,border:"none",background:"var(--accent)",color:"#fff",cursor:p||!a.trim()?"not-allowed":"pointer",opacity:p||!a.trim()?.5:1,flexShrink:0},children:p?i("desktop.searching"):i("desktop.search")})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)("div",{style:{display:"flex",borderRadius:5,border:"1px solid var(--border)",overflow:"hidden",fontSize:12,flexShrink:0},children:["global","project"].map(e=>(0,r.jsx)("button",{onClick:()=>w(e),disabled:"project"===e&&!o,title:"project"!==e||o?void 0:i("desktop.projectSkillInstallUnavailable"),style:{padding:"3px 10px",border:"none",cursor:"project"!==e||o?"pointer":"not-allowed",opacity:"project"!==e||o?1:.5,background:b===e?"var(--bg-selected)":"none",color:b===e?"var(--text)":"var(--text-dim)",fontWeight:b===e?600:400,borderRight:"global"===e?"1px solid var(--border)":"none"},children:i(`desktop.${e}`)},e))}),(0,r.jsxs)("span",{style:{fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["→ ",T]})]}),h&&(0,r.jsx)("div",{style:{fontSize:12,color:"#f87171"},children:h}),x&&(0,r.jsx)("div",{style:{fontSize:12,color:"#f87171",wordBreak:"break-word"},children:x})]}),d.length>0?(0,r.jsx)("div",{style:{flex:1,overflowY:"auto"},children:d.map(e=>{let o=t[b].has(e.package)||v.has(`${b}:${e.package}`),n=m===e.package,s=e.package.indexOf("@"),a=s>-1?e.package.slice(0,s):e.package,l=s>-1?e.package.slice(s+1):null;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"12px 0",borderBottom:"1px solid var(--border)"},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)",marginBottom:3},children:l??a}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-dim)"},children:a}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:e.installs}),e.url&&(0,r.jsx)("a",{href:e.url,target:"_blank",rel:"noreferrer",style:{fontSize:12,color:"var(--accent)",textDecoration:"none"},children:"skills.sh ↗"})]})]}),(0,r.jsx)("button",{onClick:()=>!o&&!n&&C(e.package),disabled:o||n||null!==m,style:{flexShrink:0,padding:"5px 14px",fontSize:12,fontWeight:500,borderRadius:5,border:"1px solid var(--border)",cursor:o||n||null!==m?"not-allowed":"pointer",background:o?"rgba(34,197,94,0.1)":"none",color:o?"#16a34a":n?"var(--accent)":"var(--text-muted)",transition:"color 0.12s"},children:o?`✓ ${i("desktop.installed")}`:n?i("desktop.installing"):i("desktop.install")})]},e.package)})}):!h&&!p&&(0,r.jsxs)("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.8},children:[i("desktop.skillSearchHint").split("skills.sh")[0],(0,r.jsx)("a",{href:"https://skills.sh",target:"_blank",rel:"noreferrer",style:{color:"var(--accent)",textDecoration:"none"},children:"skills.sh"}),i("desktop.skillSearchHint").split("skills.sh")[1]]})]})}function dz({cwd:e,embedded:t=!1,sessionId:o,onCloseAction:s}){let i=O(),{t:a}=(0,A.s)(),[l,d]=(0,n.useState)([]),[c,p]=(0,n.useState)(!0),[u,h]=(0,n.useState)(null),[g,m]=(0,n.useState)(null),[f,x]=(0,n.useState)(new Set),[k,y]=(0,n.useState)(null),[b,w]=(0,n.useState)(!1),[j,S]=(0,n.useState)({}),[C,T]=(0,n.useState)(new Set),[R,z]=(0,n.useState)(!1),[I,M]=(0,n.useState)(null),[P,E]=(0,n.useState)(null),[W,F]=(0,n.useState)(!0),D=(0,n.useCallback)(async()=>{p(!0),h(null);try{let t=await fetch(`/api/skills?cwd=${encodeURIComponent(e)}`),o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);let r=o.skills??[];if(d(r),F(o.projectResourcesLoaded??!0),r.length>0&&!g){let e=r.find(e=>!e.disableModelInvocation)??r[0];m(e.filePath)}return r}catch(e){return h(String(e)),[]}finally{p(!1)}},[e,g]);(0,n.useEffect)(()=>{S({}),E(null),D()},[e]);let N=(0,n.useCallback)(async t=>{let o=(t?[t]:l.filter(e=>!!e.install)).map(dj).filter(e=>!!e);if(0!==o.length){E(null),T(e=>new Set([...e,...o])),t||z(!0);try{let o=await fetch("/api/skills/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,package:t?.install?.package,scope:t?.install?.scope})}),r=await o.json();if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);S(e=>{let t={...e};for(let e of r.updates??[])t[`${e.scope}\0${e.package}`]=e;return t})}catch(e){E(e instanceof Error?e.message:String(e))}finally{T(e=>{let t=new Set(e);for(let e of o)t.delete(e);return t}),t||z(!1)}}},[e,l]),L=(0,n.useCallback)(async t=>{if(!t.install)return;let o=dj(t);M(o),E(null);try{let r=await fetch("/api/skills/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,package:t.install.package,scope:t.install.scope})}),n=await r.json();if(!r.ok||n.error||!n.success)throw Error(n.error??`HTTP ${r.status}`);await D();let s=n.skill?.install?.versionHash;S(e=>({...e,[o]:{package:t.install.package,scope:t.install.scope,state:"up-to-date",currentVersion:s,latestVersion:s}}))}catch(e){E(e instanceof Error?e.message:String(e))}finally{M(null)}},[e,D]),$=(0,n.useCallback)(async t=>{let o=!t.disableModelInvocation;x(e=>new Set(e).add(t.filePath)),y(null);try{let r=await fetch("/api/skills",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,filePath:t.filePath,disableModelInvocation:o})}),n=await r.json();if(!r.ok||n.error)return void y(n.error??`HTTP ${r.status}`);d(e=>e.map(e=>e.filePath===t.filePath?{...e,disableModelInvocation:o}:e))}catch(e){y(String(e))}finally{x(e=>{let o=new Set(e);return o.delete(t.filePath),o})}},[e]),H=l.find(e=>e.filePath===g)??null;return(0,r.jsx)("div",{style:t?{display:"flex",flex:1,minWidth:0,minHeight:0,overflow:"hidden"}:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{t||e.target!==e.currentTarget||s?.()},children:(0,r.jsxs)("div",{style:t?{display:"flex",flex:1,minWidth:0,minHeight:0,flexDirection:"column",overflow:"hidden"}:{width:i?"calc(100vw - 16px)":860,maxWidth:"calc(100vw - 16px)",height:i?"calc(100dvh - 16px)":"78vh",maxHeight:"calc(100dvh - 16px)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[!t&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:a("desktop.skills")}),(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:db(e)})]}),(0,r.jsx)("button",{onClick:s,title:a("desktop.close"),"aria-label":a("desktop.close"),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),!W&&(0,r.jsx)("div",{role:"status",style:{padding:"8px 18px",borderBottom:"1px solid var(--border)",background:"var(--bg-subtle)",color:"var(--text-muted)",fontSize:12},children:a("desktop.projectSkillsRestricted")}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:i?"column":"row",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{width:i?"100%":210,maxHeight:i?"40vh":void 0,borderRight:i?"none":"1px solid var(--border)",borderBottom:i?"1px solid var(--border)":"none",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,r.jsx)("div",{style:{padding:"8px 8px 0",display:"flex",justifyContent:"flex-end"},children:(0,r.jsx)(lE,{sessionId:o,onApplied:D})}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:c?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:a("desktop.loading")}):u?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"#f87171"},children:u}):0===l.length?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"var(--text-dim)"},children:a("desktop.noSkillsFound")}):(()=>{let e=[];for(let{key:t,label:o,matches:r}of[{key:"project / skills.sh",label:`${a("desktop.project")} / skills.sh`,matches:e=>"project"===dw(e)&&!!e.install?.skillsShUrl},{key:"project",label:a("desktop.project"),matches:e=>"project"===dw(e)&&!e.install?.skillsShUrl},{key:"global / skills.sh",label:`${a("desktop.global")} / skills.sh`,matches:e=>"global"===dw(e)&&!!e.install?.skillsShUrl},{key:"global",label:a("desktop.global"),matches:e=>"global"===dw(e)&&!e.install?.skillsShUrl},{key:"path",label:a("desktop.path"),matches:e=>"path"===dw(e)}]){let n=l.filter(r);n.length>0&&e.push({key:t,label:o,skills:n})}return e.map(({key:e,label:t,skills:o})=>(o.filter(e=>e.disableModelInvocation),(0,r.jsxs)("div",{style:{marginBottom:6},children:[(0,r.jsx)("div",{style:{padding:"4px 8px 3px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em"},children:t}),[...o.filter(e=>!e.disableModelInvocation),...o.filter(e=>e.disableModelInvocation)].map(e=>{let t,o,n=!b&&g===e.filePath,s=e.disableModelInvocation;return(0,r.jsxs)("div",{onClick:()=>{m(e.filePath),w(!1)},style:{display:"flex",alignItems:"center",gap:7,padding:"8px 8px",borderRadius:5,cursor:"pointer",background:n?"var(--bg-selected)":"none"},onMouseEnter:e=>{n||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{n||(e.currentTarget.style.background="none")},children:[(0,r.jsx)("span",{style:{flexShrink:0,width:7,height:7,borderRadius:"50%",background:s?"var(--border)":"var(--accent)",boxShadow:s?"none":"0 0 4px var(--accent)",transition:"background 0.15s, box-shadow 0.15s"}}),(0,r.jsx)("span",{style:{fontSize:12,fontWeight:n?600:400,color:s?"var(--text-dim)":"var(--text)",fontFamily:"var(--font-mono)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(o=(t=dj(e))?j[t]:void 0,o?.state!=="update-available"?null:(0,r.jsx)("span",{title:a("desktop.updateAvailable"),style:{color:"#d97706",fontSize:13,lineHeight:1,flexShrink:0},children:"↑"}))]},e.filePath)})]},e)))})()}),(0,r.jsx)("div",{style:{padding:"8px 6px",borderTop:"1px solid var(--border)",flexShrink:0},children:(0,r.jsxs)("div",{onClick:()=>w(!0),style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,cursor:"pointer",background:b?"var(--bg-selected)":"none",color:b?"var(--accent)":"var(--text-dim)",fontSize:12},onMouseEnter:e=>{b||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{b||(e.currentTarget.style.background="none")},children:[(0,r.jsx)(v.c,{size:13}),a("desktop.addSkill")]})})]}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:b?(0,r.jsx)(dR,{cwd:e,installedPackages:{global:new Set(l.filter(e=>e.install?.scope==="global").map(e=>e.install.package)),project:new Set(l.filter(e=>e.install?.scope==="project").map(e=>e.install.package))},projectResourcesLoaded:W,onInstalled:()=>{D()}}):c?null:H?(0,r.jsx)(dT,{skill:H,cwd:e,onToggle:$,toggling:f.has(H.filePath),saveError:k,updateStatus:dj(H)?j[dj(H)]:void 0,checkingUpdate:!!dj(H)&&C.has(dj(H)),updating:I===dj(H),updateError:P,onCheckUpdate:()=>void N(H),onUpdate:()=>void L(H)},H.filePath):(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:a("desktop.selectSkill")})})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[l.some(e=>!!e.install)&&(0,r.jsx)("button",{onClick:()=>void N(),disabled:R||null!==I,style:{padding:"6px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:R||null!==I?"not-allowed":"pointer",opacity:R||null!==I?.5:1,fontSize:12},children:R?a("desktop.checking"):a("desktop.checkUpdates")}),Object.values(j).filter(e=>"update-available"===e.state).length>0&&(0,r.jsx)("span",{style:{fontSize:12,color:"#d97706"},children:a("desktop.updatesCount").replace("{count}",String(Object.values(j).filter(e=>"update-available"===e.state).length)).replace("{suffix}",1===Object.values(j).filter(e=>"update-available"===e.state).length?"":"s")})]}),!t&&(0,r.jsx)("button",{onClick:s,style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:13},children:a("desktop.close")})]})]})})}function dI(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)([]),[s,i]=(0,n.useState)(""),[a,l]=(0,n.useState)(""),[d,c]=(0,n.useState)(""),[p,u]=(0,n.useState)(""),[h,g]=(0,n.useState)(!0),[m,f]=(0,n.useState)(null),x=(0,n.useCallback)(async()=>{g(!0),f(null);try{let e=await fetch("/api/logs?limit=500"),t=await e.json();if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);o(t.entries??[])}catch(e){f(e instanceof Error?e.message:String(e))}finally{g(!1)}},[]);(0,n.useEffect)(()=>{x()},[x]);let k=(0,n.useMemo)(()=>[...new Set(t.map(e=>e.source).filter(Boolean))].sort(),[t]),v=(0,n.useMemo)(()=>[...new Set(t.map(e=>e.statusCode).filter(e=>void 0!==e))].sort((e,t)=>e-t),[t]),y=(0,n.useMemo)(()=>{let e=p.trim().toLocaleLowerCase();return t.filter(e=>!s||e.level===s).filter(e=>!a||e.statusCode===Number(a)).filter(e=>!d||e.source===d).filter(t=>!e||[t.message,t.details,t.provider,t.model,t.source].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e))).slice(0,200)},[t,s,a,d,p]),b=async()=>{try{let e=await fetch("/api/logs",{method:"DELETE"});if(!e.ok)throw Error(`HTTP ${e.status}`);o([])}catch(e){f(e instanceof Error?e.message:String(e))}},w=async e=>{let t=[`[${e.timestamp}] ${e.level.toUpperCase()} ${e.statusCode??"—"}`,`${e.source}${e.provider?` \xb7 ${e.provider}`:""}${e.model?` \xb7 ${e.model}`:""}`,e.message,e.details].filter(Boolean).join("\n");try{await re(t),f(null)}catch(e){f(e instanceof Error?e.message:String(e))}};return(0,r.jsxs)("div",{style:{flex:1,minWidth:0,minHeight:0,overflow:"auto",padding:"18px 20px",display:"flex",flexDirection:"column",gap:12},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsxs)("select",{value:s,onChange:e=>i(e.target.value),style:{padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12},children:[(0,r.jsx)("option",{value:"",children:e("desktop.logsAllLevels")}),["error","warning","info"].map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsxs)("select",{value:a,onChange:e=>l(e.target.value),style:{padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12},children:[(0,r.jsx)("option",{value:"",children:e("desktop.logsAllCodes")}),v.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsxs)("select",{value:d,onChange:e=>c(e.target.value),style:{padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12},children:[(0,r.jsx)("option",{value:"",children:e("desktop.logsAllSources")}),k.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsx)("input",{value:p,onChange:e=>u(e.target.value),placeholder:e("desktop.logsSearch"),style:{flex:1,minWidth:180,padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12}}),(0,r.jsx)("button",{type:"button",onClick:()=>void x(),title:e("desktop.refresh"),"aria-label":e("desktop.refresh"),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:30,height:30,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer"},children:(0,r.jsx)(C.S,{size:14})}),(0,r.jsx)("button",{type:"button",onClick:()=>void b(),title:e("desktop.logsClear"),"aria-label":e("desktop.logsClear"),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:30,height:30,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"#ef4444",cursor:"pointer"},children:(0,r.jsx)(T.l,{size:14})})]}),h&&(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontSize:12},children:e("desktop.loading")}),m&&(0,r.jsx)("div",{style:{color:"#ef4444",fontSize:12},children:m}),!h&&!m&&0===y.length&&(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontSize:12},children:e("desktop.logsEmpty")}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:y.map(t=>(0,r.jsxs)("details",{style:{border:"1px solid var(--border)",borderRadius:7,background:"var(--bg-panel)",padding:"8px 10px"},children:[(0,r.jsxs)("summary",{style:{cursor:"pointer",color:"error"===t.level?"#ef4444":"warning"===t.level?"#f59e0b":"var(--text)",fontSize:12},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",marginRight:8},children:t.statusCode??"—"}),(0,r.jsx)("span",{style:{marginRight:8},children:new Date(t.timestamp).toLocaleString()}),(0,r.jsx)("span",{style:{overflowWrap:"anywhere"},children:t.message.length>180?`${t.message.slice(0,180)}…`:t.message})]}),(0,r.jsxs)("div",{style:{padding:"8px 0 0 18px",color:"var(--text-muted)",fontSize:11,lineHeight:1.5,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:[(0,r.jsxs)("div",{children:[t.source,t.provider?` \xb7 ${t.provider}`:"",t.model?` \xb7 ${t.model}`:""]}),(0,r.jsx)("div",{style:{marginTop:5,maxHeight:260,overflow:"auto"},children:t.message}),t.details&&(0,r.jsx)("div",{style:{marginTop:5,maxHeight:260,overflow:"auto"},children:t.details}),(0,r.jsx)("button",{type:"button",onClick:()=>void w(t),style:{marginTop:8,padding:"4px 7px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer",fontSize:11},children:e("desktop.logsCopy")})]})]},t.id))})]})}let dM={padding:"7px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",fontSize:12,width:"100%"},dP={padding:"6px 12px",border:"none",borderRadius:6,background:"var(--accent)",color:"#fff",cursor:"pointer",fontSize:12};function dE(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)([]),[s,i]=(0,n.useState)(!0),[a,l]=(0,n.useState)(null),[d,c]=(0,n.useState)(""),[p,u]=(0,n.useState)(""),[g,m]=(0,n.useState)(!1),[x,k]=(0,n.useState)(null),y=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/snippets");if(!e.ok)return;let t=await e.json();o(t.snippets??[]),i(!1)}catch{i(!1)}},[]);(0,n.useEffect)(()=>{y()},[y]);let b=(0,n.useCallback)(()=>{window.dispatchEvent(new Event("pi:snippets-changed"))},[]),w=()=>{l(null),c(""),u(""),k(null)},j=(0,n.useCallback)(async()=>{let t=d.trim();if(!t)return void k(e("desktop.snippetNameRequired"));m(!0),k(null);try{if(a){let e=await fetch(`/api/snippets/${encodeURIComponent(a.id)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,content:p})});if(!e.ok)throw Error(`HTTP ${e.status}`)}else{let e=await fetch("/api/snippets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,content:p})});if(!e.ok)throw Error(`HTTP ${e.status}`)}await y(),b(),w()}catch(e){k(e instanceof Error?e.message:String(e))}finally{m(!1)}},[a,d,p,y,b,e]),S=(0,n.useCallback)(async e=>{try{let t=await fetch(`/api/snippets/${encodeURIComponent(e)}`,{method:"DELETE"});if(!t.ok)throw Error(`HTTP ${t.status}`);a?.id===e&&w(),await y(),b()}catch(e){k(e instanceof Error?e.message:String(e))}},[a,y,b]);return(0,r.jsxs)(lh,{children:[(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"12px 0"},children:[(0,r.jsx)(n7.c,{size:15,"aria-hidden":"true"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:e("desktop.snippets")}),(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:e("desktop.snippetsDesc")})]})]})}),(0,r.jsx)(lg,{children:(0,r.jsxs)("div",{style:{width:"100%"},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:8},children:[(0,r.jsx)("button",{type:"button",onClick:w,style:dP,children:(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[(0,r.jsx)(v.F,{size:13})," ",e("desktop.snippetNew")]})}),a&&(0,r.jsx)("button",{type:"button",onClick:w,style:{...dP,background:"var(--bg-hover)",color:"var(--text-muted)"},children:(0,r.jsx)(h.X,{size:13})})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(120px, 200px) 1fr",gap:8,alignItems:"start",marginBottom:8},children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",display:"block",marginBottom:4},children:e("desktop.snippetName")}),(0,r.jsx)("input",{value:d,onChange:e=>c(e.target.value),placeholder:"#name",style:dM})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",display:"block",marginBottom:4},children:e("desktop.snippetContent")}),(0,r.jsx)("textarea",{value:p,onChange:e=>u(e.target.value),rows:3,style:{...dM,resize:"vertical",fontFamily:"var(--font-mono)",fontSize:11}})]})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:10},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void j(),disabled:g,style:{...dP,cursor:g?"wait":"pointer"},children:e("desktop.snippetSave")}),x&&(0,r.jsx)("span",{style:{color:"var(--status-error, #ef4444)",fontSize:12},children:x})]}),s?(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-dim)"},children:e("desktop.loadingThemes")}):0===t.length?(0,r.jsx)(lf,{children:e("desktop.snippetEmpty")}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:t.map(t=>(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6},children:[(0,r.jsx)("span",{style:{color:"var(--accent)",fontFamily:"var(--font-mono)",fontSize:11},children:"#"}),(0,r.jsx)("span",{style:{fontWeight:600,fontSize:12,flexShrink:0},children:t.name}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-muted)",fontSize:11,fontFamily:"var(--font-mono)"},children:t.content.split("\n")[0]}),(0,r.jsx)("button",{type:"button",onClick:()=>{l(t),c(t.name),u(t.content),k(null)},title:e("desktop.snippetEdit"),style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",padding:2},children:(0,r.jsx)(f.I,{size:13})}),(0,r.jsx)("button",{type:"button",onClick:()=>void S(t.id),title:e("desktop.snippetDelete"),style:{background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",padding:2},children:(0,r.jsx)(T.l,{size:13})})]},t.id))})]})}),(0,r.jsx)(lm,{children:(0,r.jsx)(lf,{children:e("desktop.snippetHint")})})]})}let dW={builtin:0,global:1,workspace:2,project:3},dF="pi-web:settings-navigation";function dD(){try{return window.localStorage}catch{return null}}function dA(e){let t=e.getItem(dF);if(!t)return{};try{let e=JSON.parse(t);if(null===e||"object"!=typeof e||Array.isArray(e))return{};return{section:"string"==typeof e.section?e.section:void 0,selections:null===e.selections||"object"!=typeof e.selections||Array.isArray(e.selections)?void 0:e.selections}}catch{return{}}}function dN(e,t){return"models"===e?e:t?JSON.stringify([e,t]):null}function dL(e,t,o=dD()){if(!o)return null;let r=dN(e,t);if(!r)return null;try{let e=dA(o).selections?.[r];return"string"==typeof e&&e.length>0?e:null}catch{return null}}function d$({embedded:e,title:t,subtitle:o,closeLabel:n="Close",onClose:s,children:i,width:a=900,height:l="78vh"}){let d=e?void 0:{"--config-panel-width":`${a}px`,"--config-panel-height":l};return(0,r.jsx)("div",{role:e?void 0:"dialog","aria-modal":e?void 0:"true","aria-label":t,className:`config-panel-root ${e?"is-embedded":"is-modal"}`,onClick:t=>{e||t.target!==t.currentTarget||s()},children:(0,r.jsxs)("div",{className:"config-panel-surface",style:d,children:[!e&&(0,r.jsxs)("div",{className:"config-panel-header",children:[(0,r.jsx)("strong",{className:"config-panel-title",children:t}),o&&(0,r.jsx)("code",{className:"config-panel-subtitle",title:o,children:o}),(0,r.jsx)("button",{type:"button",className:"config-close-button",onClick:s,title:n,"aria-label":n,children:"\xd7"})]}),i]})})}function dH({children:e}){return(0,r.jsx)("div",{className:"config-split-view",children:e})}function dO({children:e}){return(0,r.jsx)("aside",{className:"config-sidebar",children:e})}function dB({children:e}){return(0,r.jsx)("div",{className:"config-sidebar-list",children:e})}function dU({children:e}){return(0,r.jsx)("div",{className:"config-sidebar-group-label",children:e})}function d_({active:e=!1,className:t,children:o,...n}){return(0,r.jsx)("button",{type:"button",...n,"aria-current":e?"page":void 0,className:["config-sidebar-item",t].filter(Boolean).join(" "),children:o})}function dq({className:e,...t}){return(0,r.jsx)("span",{...t,className:["config-sidebar-text",e].filter(Boolean).join(" ")})}function dV({className:e,...t}){return(0,r.jsx)("div",{...t,className:["config-detail-stack",e].filter(Boolean).join(" ")})}function dK({className:e,...t}){return(0,r.jsx)("div",{...t,className:["config-detail-header",e].filter(Boolean).join(" ")})}function dG({className:e,...t}){return(0,r.jsx)("div",{...t,className:["config-detail-header-info",e].filter(Boolean).join(" ")})}function dJ({className:e,...t}){return(0,r.jsx)("div",{...t,className:["config-detail-actions",e].filter(Boolean).join(" ")})}function dY({label:e,children:t,style:o}){return(0,r.jsxs)("div",{className:"config-field",style:o,children:[(0,r.jsx)("span",{className:"config-field-label",children:e}),t]})}function dX({children:e}){return(0,r.jsx)("div",{className:"config-empty-state",children:e})}function dZ({children:e,style:t}){return(0,r.jsx)("div",{className:"config-detail",style:t,children:e})}function dQ({status:e,children:t}){return(0,r.jsxs)("footer",{className:"config-footer",children:[(0,r.jsx)("div",{className:"config-footer-status",children:e}),(0,r.jsx)("div",{className:"config-footer-actions",children:t})]})}function d0({variant:e="secondary",size:t="default",className:o,children:n,...s}){return(0,r.jsx)("button",{type:"button",...s,className:["config-button",`config-button-${e}`,`config-button-${t}`,o].filter(Boolean).join(" "),children:n})}function d1({checked:e,disabled:t=!1,loading:o=!1,label:n,onChange:s}){let i=t||o;return(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":e,"aria-busy":o||void 0,"aria-label":n,title:n,disabled:i,className:`config-switch${o?" is-loading":""}`,onClick:()=>s(!e),children:(0,r.jsx)("span",{className:"config-switch-knob","aria-hidden":"true"})})}function d2({active:e=!1,children:t,className:o,...n}){return(0,r.jsx)("div",{className:"config-list-action",children:(0,r.jsxs)("button",{type:"button",...n,"aria-current":e?"page":void 0,className:["config-list-action-button",o].filter(Boolean).join(" "),children:[(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M12 5v14M5 12h14"})}),t]})})}function d4({active:e,color:t}){return(0,r.jsx)("span",{"aria-hidden":"true",className:`config-status-dot${e?" is-active":!1===e?" is-inactive":""}`,style:t?{backgroundColor:t}:void 0})}let d6=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function d8(e,t){return d6.compare(e.name||e.modelId,t.name||t.modelId)||d6.compare(e.provider,t.provider)||d6.compare(e.modelId,t.modelId)}function d5({options:e,value:t,onChange:o,onClear:s,emptyLabel:i,selectedLabel:a,disabled:l=!1,busy:d=!1,isAutoSelection:c=!1,ariaLabel:p,variant:u="toolbar",placement:h="up"}){let g,m,f,x,k,v,y,b,w,{t:j}=(0,A.s)(),S=O(),C=(0,n.useRef)(null),T=(0,n.useRef)(null),[R,z]=(0,n.useState)(!1),[I,M]=(0,n.useState)(null),[P,E]=(0,n.useState)(""),W=l||d,F=(0,n.useMemo)(()=>[...e].sort(d8),[e]),D=(g=P.trim().toLocaleLowerCase())?F.filter(e=>`${e.name} ${e.modelId}`.toLocaleLowerCase().includes(g)):F,N=F.length>8,L=[];for(let e of D){let t=L.find(t=>t.provider===e.provider);t?t.options.push(e):L.push({provider:e.provider,options:[e]})}let $=a??(t?F.find(e=>e.modelId===t.modelId&&e.provider===t.provider)?.name??t.modelId:i??(F.length>0?"Select model":"No models"));(0,n.useEffect)(()=>{let e=e=>{C.current&&!C.current.contains(e.target)&&T.current&&!T.current.contains(e.target)&&(z(!1),E(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,n.useEffect)(()=>{W&&(z(!1),E(""))},[W]);let H="field"===u?{display:"flex",alignItems:"center",gap:7,width:"100%",minWidth:0,height:34,padding:"0 9px",overflow:"hidden",border:"1px solid var(--border)",borderRadius:5,background:W?"var(--bg-panel)":"var(--bg)",color:W?"var(--text-dim)":"var(--text)",cursor:W?"default":"pointer",fontSize:12,textAlign:"left"}:{display:"flex",alignItems:"center",justifyContent:S?"flex-start":void 0,gap:6,width:S?"100%":void 0,maxWidth:S?"100%":220,height:32,padding:S?"8px 10px":"8px 12px",overflow:"hidden",border:"none",borderRadius:9,background:R?"var(--bg-hover)":"none",color:"var(--text-muted)",cursor:W?"not-allowed":"pointer",fontSize:12,opacity:W?.5:1,transition:"background 0.12s, color 0.12s"};return(0,r.jsxs)("div",{ref:C,className:`model-selector is-${u}${W?" is-disabled":""}`,style:{position:"relative",width:"field"===u||S?"100%":void 0,minWidth:0,flex:"toolbar"===u&&S?"1 1 auto":void 0},onKeyDown:e=>{"Escape"===e.key&&R&&(e.preventDefault(),e.stopPropagation(),E(""),z(!1))},children:[(0,r.jsxs)("button",{type:"button","aria-label":p,"aria-haspopup":"listbox","aria-expanded":R,"aria-busy":d||void 0,disabled:W,title:d?"Switching model":W?$:F.length>0||s?"Change model":"No available models",style:H,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();M({top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width}),z(e=>(e&&E(""),!e))},onMouseEnter:e=>{W||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{if(W){e.currentTarget.style.background="field"===u?"var(--bg-panel)":"none",e.currentTarget.style.color="field"===u?"var(--text-dim)":"var(--text-muted)";return}e.currentTarget.style.background=R?"var(--bg-hover)":"field"===u?"var(--bg)":"none",e.currentTarget.style.color="field"===u?"var(--text)":"var(--text-muted)"},children:[d?(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",style:{animation:"spin 0.8s linear infinite",flexShrink:0},"aria-hidden":"true",children:(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-2.64-6.36"})}):(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flexShrink:0},children:[(0,r.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,r.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,r.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,r.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,r.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,r.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,r.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,r.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,r.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,r.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$}),"field"===u&&(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flexShrink:0,color:"var(--text-dim)"},children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})]}),R&&I&&(m=window.visualViewport?.height??window.innerHeight,f=window.visualViewport?.width??window.innerWidth,x=I.top-8,k=m-I.bottom-8,y=Math.max(120,Math.min((v="up"===h||x>k)?x:k,.6*m)),b=v?{bottom:m-I.top+6}:{top:I.bottom+6},w=S?{left:8,right:8,maxWidth:"calc(100vw - 16px)"}:{left:I.left,width:"max-content",minWidth:I.width,maxWidth:Math.max(I.width,f-I.left-8)},(0,r.jsxs)("div",{ref:T,role:"listbox","aria-label":p,style:{position:"fixed",...b,...w,zIndex:500,display:"flex",flexDirection:"column",maxHeight:y,overflow:"hidden",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg)",boxShadow:v?"0 -4px 16px rgba(0,0,0,0.10)":"0 4px 16px rgba(0,0,0,0.10)"},children:[N&&(0,r.jsx)("div",{style:{flexShrink:0,padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("input",{value:P,onChange:e=>E(e.target.value),placeholder:j("chat.filterModels"),"aria-label":j("chat.filterModels"),autoFocus:!0,autoComplete:"off",spellCheck:!1,style:{boxSizing:"border-box",width:"100%",minWidth:220*!S,padding:"5px 8px",border:"1px solid var(--border)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:11}})}),(0,r.jsxs)("div",{style:{minHeight:0,overflowY:"auto"},children:[s&&!P.trim()&&(0,r.jsx)(d3,{active:!t,label:i??"Default",onClick:()=>{z(!1),E(""),s()}}),0===L.length?(0,r.jsx)("div",{style:{padding:"8px 12px",color:"var(--text-dim)",fontSize:12,whiteSpace:"nowrap"},children:P.trim()?j("chat.noMatchingModels"):"No available models"}):L.map((e,n)=>(0,r.jsxs)("div",{children:[L.length>1&&(0,r.jsx)("div",{style:{padding:"6px 12px 4px",borderTop:n>0||s?"1px solid var(--border)":"none",color:"var(--text-dim)",fontSize:10,fontWeight:600,letterSpacing:0,textTransform:"uppercase"},children:e.provider}),e.options.map(e=>(0,r.jsx)(d3,{active:e.modelId===t?.modelId&&e.provider===t?.provider,label:e.name,onClick:()=>{let r;return r=e.modelId===t?.modelId&&e.provider===t?.provider,void(z(!1),E(""),(!r||c)&&o(e.provider,e.modelId))}},`${e.provider}:${e.modelId}`))]},e.provider))]})]}))]})}function d3({active:e,label:t,onClick:o}){return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":e,onClick:o,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",border:"none",background:e?"var(--bg-selected)":"none",color:e?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:e?600:400,textAlign:"left",whiteSpace:"nowrap"},onMouseEnter:t=>{e||(t.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:t=>{e||(t.currentTarget.style.background="none")},children:[e?(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},"aria-hidden":"true",children:(0,r.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsx)("span",{title:t,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:t})]})}let d7=["read","bash","edit","write","grep","find","ls"],d9=["","off","minimal","low","medium","high","xhigh","max"],ce={name:"custom-agent",displayName:"Custom agent",description:"",systemPrompt:"",tools:["read","bash","edit","write","grep","find","ls"],loadSkills:!1,loadExtensions:!1,inheritContext:!1,runInBackground:!1,enabled:!0},ct={width:"100%",minWidth:0,height:34,padding:"0 9px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg)",color:"var(--text)",fontSize:12,outline:"none"},co={background:"var(--bg-panel)",color:"var(--text-dim)",cursor:"default"};function cr(e){return{name:e.name,displayName:e.displayName,description:e.description,systemPrompt:e.systemPrompt,tools:[...e.tools],loadSkills:e.loadSkills,loadExtensions:e.loadExtensions,...e.model?{model:e.model}:{},...e.thinking?{thinking:e.thinking}:{},...e.maxTurns?{maxTurns:e.maxTurns}:{},inheritContext:e.inheritContext,runInBackground:e.runInBackground,enabled:e.enabled}}function cn(e){return`${e.scope}:${e.name}`}function cs(e){return"global"===e||"project"===e}function ci(e){return e.replace(/^\/(?:Users|home)\/[^/]+/,"~")}function ca({label:e,children:t}){return(0,r.jsx)(dY,{label:e,children:t})}function cl({checked:e,disabled:t,label:o,onChange:n}){return(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:7,color:t?"var(--text-dim)":"var(--text-muted)",fontSize:12,cursor:t?"default":"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:e,disabled:t,onChange:e=>n(e.target.checked)}),o]})}function cd({cwd:e,sessionId:t=null,onClose:o,onReloaded:s,embedded:i=!1}){let a=O(),{t:l}=(0,A.s)(),[d,c]=(0,n.useState)([]),[p,u]=(0,n.useState)([]),[h,g]=(0,n.useState)(!0),[m,f]=(0,n.useState)(null),[x,k]=(0,n.useState)(()=>dL("agents",e)),[v,y]=(0,n.useState)(ce),[b,w]=(0,n.useState)("view"),[j,S]=(0,n.useState)("global"),[C,T]=(0,n.useState)(!0),[R,z]=(0,n.useState)(!1),[I,M]=(0,n.useState)(!1),[P,E]=(0,n.useState)(!1),[W,F]=(0,n.useState)(null),[D,N]=(0,n.useState)(!1),[L,$]=(0,n.useState)(!0),[H,B]=(0,n.useState)(!1),[U,_]=(0,n.useState)(null),[q,V]=(0,n.useState)(!1),[K,G]=(0,n.useState)(!1),J=(0,n.useMemo)(()=>d.find(e=>cn(e)===x)??null,[d,x]),Y=(0,n.useMemo)(()=>p.map(e=>({provider:e.provider,modelId:e.id,name:e.name})),[p]),X=(0,n.useCallback)(async t=>{T(!0),F(null);try{let o=await fetch(`/api/subagents/profiles?cwd=${encodeURIComponent(e)}`,{cache:"no-store"}),r=await o.json();if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);let n=r.profiles??[];c(n);let s=t??dL("agents",e),i=n.find(e=>cn(e)===s)??n.find(e=>"project"===e.scope)??n.find(e=>"global"===e.scope)??n[0]??null;k(i?cn(i):null),i&&(y(cr(i)),w(cs(i.scope)?"edit":"view"),cs(i.scope)&&S(i.scope))}catch(e){F(e instanceof Error?e.message:String(e))}finally{T(!1)}},[e]);(0,n.useEffect)(()=>{X()},[X]),(0,n.useEffect)(()=>{let e=new AbortController;return $(!0),_(null),(async()=>{try{let t=await fetch("/api/subagents/settings",{cache:"no-store",signal:e.signal}),o=await t.json();if(!t.ok||o.error||"boolean"!=typeof o.enabled)throw Error(o.error??`HTTP ${t.status}`);N(o.enabled)}catch(t){if(e.signal.aborted)return;_(t instanceof Error?t.message:String(t))}finally{e.signal.aborted||$(!1)}})(),()=>e.abort()},[]),(0,n.useEffect)(()=>{x&&function(e,t,o,r=dD()){if(!r||!t)return;let n=dN(e,o);if(n)try{let e=dA(r);e.selections={...e.selections,[n]:t},r.setItem(dF,JSON.stringify(e))}catch{}}("agents",x,e)},[e,x]),(0,n.useEffect)(()=>{let t=new AbortController;return g(!0),f(null),(async()=>{try{let o=await fetch(`/api/models?cwd=${encodeURIComponent(e)}`,{signal:t.signal}),r=await o.json();if(!o.ok||r.error)throw Error(r.error??`HTTP ${o.status}`);u(r.modelList??[]),f(r.modelError??null)}catch(e){if(t.signal.aborted)return;f(e instanceof Error?e.message:String(e))}finally{t.signal.aborted||g(!1)}})(),()=>t.abort()},[e]);let Z=async()=>{z(!0),F(null),M(!1);try{let t=await fetch("/api/subagents/profiles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,scope:j,profile:v})}),o=await t.json();if(!t.ok||o.error||!o.profile)throw Error(o.error??`HTTP ${t.status}`);await X(cn(o.profile)),M(!0),setTimeout(()=>M(!1),2e3)}catch(e){F(e instanceof Error?e.message:String(e))}finally{z(!1)}},Q=async()=>{if(J&&cs(J.scope)&&window.confirm(l("agents.deleteConfirm",{name:J.displayName}))){z(!0),F(null);try{let t=await fetch("/api/subagents/profiles",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,scope:J.scope,name:J.name})}),o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);await X()}catch(e){F(e instanceof Error?e.message:String(e))}finally{z(!1)}}},ee="view"!==b,et="create"===b,eo=!ee||R||P,er=et?j:J?.scope,en=et?"global"===j?`~/.pi/agent/agents/${v.name||"..."}.md`:`./.pi/agents/${v.name||"..."}.md`:J?function(e,t){if(!e.filePath)return null;if(("project"===e.scope||"workspace"===e.scope)&&e.filePath.startsWith(t)){let o=e.filePath.slice(t.length).replace(/^[/\\]/,"");return`./${o}`}return ci(e.filePath)}(J,e)??l("agents.builtinPath"):"",es=et?en:J?.filePath??en,ei=!v.model||p.some(e=>`${e.provider}/${e.id}`===v.model),ea=(()=>{if(!v.model)return null;let e=v.model.indexOf("/");return e<0?{provider:"",modelId:v.model}:{provider:v.model.slice(0,e),modelId:v.model.slice(e+1)}})(),el=eo?{...ct,...co}:ct,ed=(e,t)=>{y(o=>({...o,[e]:t}))},ec=async t=>{if(et)return void ed("enabled",t);if(J&&cs(J.scope)){E(!0),F(null);try{let o=await fetch("/api/subagents/profiles",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,scope:J.scope,name:J.name,enabled:t})}),r=await o.json();if(!o.ok||r.error||!r.profile)throw Error(r.error??`HTTP ${o.status}`);let n=r.profile;c(e=>e.map(e=>cn(e)===cn(n)?n:e)),y(e=>({...e,enabled:n.enabled}))}catch(e){F(e instanceof Error?e.message:String(e))}finally{E(!1)}}},ep=async e=>{B(!0),_(null);try{let o=await fetch("/api/subagents/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})}),r=await o.json();if(!o.ok||r.error||"boolean"!=typeof r.enabled)throw Error(r.error??`HTTP ${o.status}`);N(r.enabled),V(!!t)}catch(e){_(e instanceof Error?e.message:String(e))}finally{B(!1)}},eu=async()=>{if(t){G(!0),_(null);try{await i6(t,{type:"reload"}),V(!1),s?.()}catch(e){_(e instanceof Error?e.message:String(e))}finally{G(!1)}}};return(0,r.jsxs)(d$,{embedded:i,title:l("common.agents"),subtitle:ci(e),closeLabel:l("agents.close"),onClose:o,children:[(0,r.jsxs)("div",{className:"agents-feature-setting",children:[(0,r.jsxs)("div",{className:"agents-feature-copy",children:[(0,r.jsx)("strong",{children:l("agents.builtInTitle")}),(0,r.jsx)("span",{children:l("agents.builtInDescription")}),q&&(0,r.jsx)("span",{role:"status",className:"agents-feature-reload-notice",children:l("agents.reloadRequired")})]}),(0,r.jsxs)("div",{className:"agents-feature-actions",children:[q&&t&&(0,r.jsx)(d0,{size:"small",onClick:()=>void eu(),disabled:K||H,children:K?l("agents.reloading"):l("agents.reloadSession")}),(0,r.jsx)(d1,{checked:D,disabled:L||K,loading:H,label:l("agents.builtInTitle"),onChange:e=>void ep(e)})]})]}),(0,r.jsxs)(dH,{children:[(0,r.jsxs)(dO,{children:[(0,r.jsx)(dB,{children:C?(0,r.jsx)("div",{style:{padding:10,color:"var(--text-dim)",fontSize:12},children:l("agents.loading")}):["project","global","workspace","builtin"].map(e=>{let t=d.filter(t=>t.scope===e);return 0===t.length?null:(0,r.jsxs)("div",{className:"config-sidebar-group",children:[(0,r.jsx)(dU,{children:l(`agents.scope.${e}`)}),t.map(e=>{let t,o,n=(t=e.name.toLowerCase(),o=dW[e.scope],d.some(e=>e.name.toLowerCase()===t&&dW[e.scope]>o));return(0,r.jsxs)(d_,{active:x===cn(e)&&!et,onClick:()=>{k(cn(e)),y(cr(e)),w(cs(e.scope)?"edit":"view"),cs(e.scope)&&S(e.scope),F(null)},children:[(0,r.jsx)(d4,{active:e.enabled}),(0,r.jsx)(dq,{className:`is-grow${e.enabled?"":" is-muted"}`,children:e.displayName}),n&&(0,r.jsx)("span",{className:"agents-overridden-label",children:l("agents.overridden")})]},cn(e))})]},e)})}),(0,r.jsx)(d2,{active:et,onClick:()=>{let e="custom-agent",t=2;for(;d.some(t=>t.name===e);)e=`custom-agent-${t++}`;k(null),y({...ce,name:e,displayName:e}),w("create"),S("global"),F(null)},children:l("agents.new")})]}),(0,r.jsx)(dZ,{children:(0,r.jsx)(dV,{className:"is-fill",children:J||et?(0,r.jsxs)(dV,{children:[(0,r.jsxs)(dK,{children:[(0,r.jsxs)(dG,{children:[er&&(0,r.jsx)("span",{className:`config-scope-tag${"project"===er?" is-project":""}`,children:l(`agents.scope.${er}`)}),(0,r.jsx)("span",{title:es,className:"config-detail-path",children:en})]}),(0,r.jsxs)(dJ,{children:[J&&("view"===b||"edit"===b)&&(0,r.jsx)(d0,{size:"small",onClick:()=>{if(!J)return;let e=function(e,t){let o=new Set(t.map(e=>e.name.toLowerCase())),r=`${e}-copy`,n=r,s=2;for(;o.has(n.toLowerCase());)n=`${r}-${s++}`;return n}(J.name,d);k(null),y({...cr(J),name:e,displayName:l("agents.copyName",{name:J.displayName})}),w("create"),S(cs(J.scope)?J.scope:"global"),F(null)},disabled:R||P,children:l("agents.duplicate")}),J&&cs(J.scope)&&"edit"===b&&(0,r.jsx)(d0,{variant:"danger",size:"small",onClick:()=>void Q(),disabled:R||P,children:l("agents.delete")}),(0,r.jsx)(d1,{checked:v.enabled,disabled:eo,label:v.enabled?l("agents.disable"):l("agents.enable"),onChange:e=>void ec(e)})]})]}),et&&(0,r.jsx)(ca,{label:l("agents.saveScope"),children:(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:3,padding:3,border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)"},children:["global","project"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>S(e),disabled:R,style:{height:28,border:"none",borderRadius:4,background:j===e?"var(--bg-selected)":"transparent",color:j===e?"var(--text)":"var(--text-muted)",cursor:R?"default":"pointer",fontSize:11,fontWeight:j===e?600:400},children:l(`agents.scope.${e}`)},e))})}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:a?"1fr":"minmax(0, 1fr) minmax(0, 1fr)",gap:12},children:[(0,r.jsx)(ca,{label:l("agents.name"),children:et?(0,r.jsx)("input",{"aria-label":l("agents.name"),value:v.name,disabled:eo,onChange:e=>ed("name",e.target.value),style:ct}):(0,r.jsx)("code",{style:{minHeight:34,display:"flex",alignItems:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)",fontSize:12},children:v.name})}),(0,r.jsx)(ca,{label:l("agents.displayName"),children:(0,r.jsx)("input",{"aria-label":l("agents.displayName"),value:v.displayName,disabled:eo,onChange:e=>ed("displayName",e.target.value),style:el})})]}),(0,r.jsx)(ca,{label:l("agents.description"),children:(0,r.jsx)("input",{"aria-label":l("agents.description"),value:v.description,disabled:eo,onChange:e=>ed("description",e.target.value),style:el})}),(0,r.jsx)(ca,{label:l("agents.prompt"),children:(0,r.jsx)("textarea",{className:"agents-system-prompt","aria-label":l("agents.prompt"),value:v.systemPrompt,disabled:eo,onChange:e=>ed("systemPrompt",e.target.value),style:{...el,height:195,minHeight:195,maxHeight:"60vh",padding:9,overflow:"auto",resize:eo?"none":"vertical",lineHeight:1.5}})}),(0,r.jsx)(ca,{label:l("agents.tools"),children:(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px"},children:d7.map(e=>(0,r.jsx)(cl,{label:e,disabled:eo,checked:v.tools.includes(e),onChange:t=>ed("tools",t?[...v.tools,e]:v.tools.filter(t=>t!==e))},e))})}),(0,r.jsx)(ca,{label:l("agents.resources"),children:(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 20px"},children:[(0,r.jsx)(cl,{label:l("agents.loadSkills"),disabled:eo,checked:v.loadSkills,onChange:e=>ed("loadSkills",e)}),(0,r.jsx)(cl,{label:l("agents.loadExtensions"),disabled:eo,checked:v.loadExtensions,onChange:e=>ed("loadExtensions",e)})]})}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:a?"1fr":"minmax(0, 1.5fr) minmax(120px, 0.75fr) minmax(100px, 0.5fr)",gap:12},children:[(0,r.jsx)(ca,{label:l("agents.model"),children:(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)(d5,{options:Y,value:ea,onChange:(e,t)=>ed("model",`${e}/${t}`),onClear:()=>ed("model",void 0),emptyLabel:h?l("agents.modelsLoading"):l("agents.inherit"),selectedLabel:v.model&&!ei?l("agents.modelUnavailable",{model:v.model}):void 0,disabled:eo||h||0===p.length&&!v.model,ariaLabel:l("agents.model"),variant:"field",placement:"auto"}),m&&(0,r.jsx)("span",{style:{color:"#ef4444",fontSize:10},children:m})]})}),(0,r.jsx)(ca,{label:l("agents.thinking"),children:(0,r.jsx)("select",{"aria-label":l("agents.thinking"),value:v.thinking??"",disabled:eo,onChange:e=>ed("thinking",e.target.value||void 0),style:el,children:d9.map(e=>(0,r.jsx)("option",{value:e,children:e||l("agents.inherit")},e||"default"))})}),(0,r.jsx)(ca,{label:l("agents.maxTurns"),children:(0,r.jsx)("input",{"aria-label":l("agents.maxTurns"),type:"number",min:1,value:v.maxTurns??"",disabled:eo,onChange:e=>ed("maxTurns",e.target.value?Number(e.target.value):void 0),style:el})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"10px 20px"},children:[(0,r.jsx)(cl,{label:l("agents.inheritContext"),disabled:eo,checked:v.inheritContext,onChange:e=>ed("inheritContext",e)}),(0,r.jsx)(cl,{label:l("agents.background"),disabled:eo,checked:v.runInBackground,onChange:e=>ed("runInBackground",e)})]})]}):(0,r.jsx)(dX,{children:l("agents.empty")})})})]}),(0,r.jsx)(dQ,{status:(U||W)&&(0,r.jsx)("span",{role:"alert",style:{color:"#ef4444"},children:U||W}),children:ee&&(0,r.jsxs)(d0,{variant:"primary",onClick:()=>void Z(),disabled:R||I||P||!v.name.trim(),className:I?"is-success":void 0,children:[I&&(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:"config-button-success-icon",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}),(0,r.jsx)("span",{children:I?l("i18n.saved"):R?l("agents.saving"):l("agents.save")})]})})]})}function cc({sessionId:e,onSessionReloaded:t}){let{t:o}=(0,A.s)(),[s,i]=(0,n.useState)(null),[a,l]=(0,n.useState)(null);(0,n.useEffect)(()=>{let e=!1;return fetch("/api/tools/settings").then(async t=>{let o=await t.json();if(!t.ok||o.error)throw Error(o.error??`HTTP ${t.status}`);e||i(o)}).catch(t=>{e||l(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[]);let d=(0,n.useCallback)(async o=>{l(null);try{let r=await fetch("/api/tools/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:o})}),n=await r.json();if(!r.ok||n.error)throw Error(n.error??`HTTP ${r.status}`);i(n),e&&(await i6(e,{type:"reload"}),t())}catch(e){l(e instanceof Error?e.message:String(e))}},[t,e]);return(0,r.jsx)("div",{style:{padding:16,overflowY:"auto",minHeight:0,flex:1},children:(0,r.jsxs)(lh,{children:[(0,r.jsx)(lg,{children:(0,r.jsx)(a4,{label:o("desktop.usePowerShell"),description:o("desktop.shellToolDescription"),checked:s?.powerShellEnabled??!1,onChange:e=>void d(e)})}),(0,r.jsx)(lm,{children:(0,r.jsx)("div",{style:{padding:"10px 0",fontSize:12,lineHeight:1.5,color:"var(--text-dim)"},children:s?.isWindows?o("desktop.shellToolWindowsOnly"):a??o("desktop.shellToolMacOnly")})})]})})}function cp(e){return null==e?"—":i$(e)}function cu({sessionId:e,cwd:t}){let{t:o}=(0,A.s)(),[s,i]=(0,n.useState)(null),[a,l]=(0,n.useState)(null),[d,c]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let t=!1;return e?(fetch(`/api/agent/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{t||i(e?.state?.contextUsage??null)}).catch(()=>{}),()=>{t=!0}):void i(null)},[e]);let p=(0,n.useCallback)(async()=>{c(!0);try{let e=await fetch("/api/usage");e.ok&&l(await e.json())}catch{}finally{c(!1)}},[]);(0,n.useEffect)(()=>{p()},[p]);let u=(0,n.useMemo)(()=>a?.daily.slice(-14)??[],[a]),h=(0,n.useMemo)(()=>u.reduce((e,t)=>Math.max(e,t.tokens),0),[u]);return(0,r.jsxs)("div",{style:{flex:1,overflow:"auto",minWidth:0,padding:"16px 20px",display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsx)("h3",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text)"},children:o("desktop.usage")}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)"},children:o("desktop.usageSession")}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e?(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:12,border:"1px solid var(--border)",padding:16},children:s?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:16},children:[(0,r.jsxs)("svg",{width:72,height:72,viewBox:"0 0 72 72",style:{flexShrink:0},children:[(0,r.jsx)("circle",{cx:36,cy:36,r:30,fill:"none",stroke:"var(--border)",strokeWidth:7}),(0,r.jsx)("circle",{cx:36,cy:36,r:30,fill:"none",stroke:"var(--accent)",strokeWidth:7,strokeLinecap:"round",strokeDasharray:2*Math.PI*30,strokeDashoffset:2*Math.PI*30*(1-Math.min(1,(s.percent??0)/100)),transform:"rotate(-90 36 36)",style:{transition:"stroke-dashoffset 0.4s ease"}}),(0,r.jsx)("text",{x:36,y:41,textAnchor:"middle",fontSize:15,fontWeight:700,fill:"var(--text)",children:null!=s.percent?`${s.percent.toFixed(0)}%`:"?"})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[(0,r.jsx)("span",{style:{fontSize:13,color:"var(--text)"},children:o("desktop.usageContext",{used:cp(s.tokens),window:cp(s.contextWindow)})}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)"},children:o("desktop.usageContextHint")})]})]})}):(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)"},children:o("desktop.usageNoSessionData")})}):(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)"},children:o("desktop.usageNoSession")}),t&&(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)"},children:o("desktop.usageGlobal")}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:10},children:[{label:o("desktop.usageTotal"),value:cp(a?.totalTokens),sub:a?`${a.totalSessions} ${o("desktop.usageSessions")}`:"…"},{label:o("desktop.usageMessages"),value:a?String(a.messageCount):"…",sub:o("desktop.usageMessagesHint")}].map(e=>(0,r.jsxs)("div",{style:{borderRadius:12,border:"1px solid var(--border)",padding:"12px 14px",background:"var(--bg-panel)"},children:[(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:4},children:e.label}),(0,r.jsx)("div",{style:{fontSize:18,fontWeight:700,color:"var(--text)"},children:e.value}),(0,r.jsx)("div",{style:{fontSize:10.5,color:"var(--text-dim)",marginTop:2},children:e.sub})]},e.label))}),(0,r.jsxs)("div",{style:{borderRadius:12,border:"1px solid var(--border)",padding:"14px 16px"},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",marginBottom:10},children:o("desktop.usageDaily")}),0===u.length?(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)"},children:o(d?"desktop.featuresLoading":"desktop.usageNoData")}):(0,r.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,height:96,overflowX:"auto"},children:u.map(e=>{let t=h>0?Math.max(4,Math.round(e.tokens/h*72)):4;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4,flexShrink:0},children:[(0,r.jsx)("div",{style:{fontSize:9,color:"var(--text-dim)"},children:e.tokens>0?cp(e.tokens):""}),(0,r.jsx)("div",{style:{width:8,height:t,borderRadius:4,background:e.tokens>0?"var(--accent)":"var(--bg-hover)",opacity:e.tokens>0?.85:1},title:`${e.day}: ${cp(e.tokens)}`}),(0,r.jsx)("div",{style:{fontSize:9,color:"var(--text-dim)"},children:e.day.slice(5)})]},e.day)})})]}),(0,r.jsxs)("div",{style:{borderRadius:12,border:"1px solid var(--border)",overflow:"hidden"},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",padding:"10px 14px",borderBottom:"1px solid var(--border)"},children:o("desktop.usageTopSessions")}),a&&0===a.sessions.length?(0,r.jsx)("div",{style:{padding:"14px",fontSize:12,color:"var(--text-muted)"},children:o("desktop.usageNoData")}):(a?.sessions??[]).slice(0,12).map(e=>(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 14px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("span",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name??e.firstMessage??e.id}),(0,r.jsx)("span",{style:{flexShrink:0,fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:cp(e.tokens)})]},e.path))]})]})]})]})}function ch(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)(!1),[s,i]=(0,n.useState)("");(0,n.useEffect)(()=>{o(new URLSearchParams(window.location.search).has("piweb_connected")),i(window.location.host)},[]);let a=(0,n.useCallback)(()=>{window.location.href="piweb-switch://manage"},[]);return t?(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0,overflowY:"auto"},children:[(0,r.jsx)("header",{style:{padding:"18px 22px 14px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("h1",{style:{margin:0,fontSize:16,fontWeight:700,color:"var(--text)"},children:e("desktop.server")})}),(0,r.jsxs)("div",{style:{padding:"18px 22px",display:"flex",flexDirection:"column",gap:14},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,background:"var(--bg-hover)",border:"1px solid var(--border)"},children:[(0,r.jsx)(a_.X,{size:18,color:"var(--accent)"}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)"},children:e("desktop.serverCurrent")}),(0,r.jsx)("div",{style:{fontSize:14,fontWeight:600,color:"var(--text)",fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:s})]})]}),(0,r.jsxs)("button",{type:"button",onClick:a,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"10px 16px",borderRadius:10,background:"linear-gradient(135deg, var(--accent), var(--accent-hover, var(--accent)))",color:"#fff",fontSize:14,fontWeight:600,cursor:"pointer",border:"none"},children:[(0,r.jsx)(lw.o,{size:16}),e("desktop.serverSwitch")]}),(0,r.jsx)("p",{style:{margin:0,fontSize:12.5,lineHeight:1.7,color:"var(--text-muted)"},children:e("desktop.serverSwitchHint")})]})]}):null}let cg=[{id:"server",labelKey:"desktop.server",Icon:a_.X},{id:"display",labelKey:"desktop.display",Icon:aq.V},{id:"chat",labelKey:"desktop.chat",Icon:aV.W},{id:"models",labelKey:"desktop.models",Icon:z.f},{id:"skills",labelKey:"desktop.skills",Icon:I.B},{id:"plugins",labelKey:"desktop.plugins",Icon:M.F},{id:"proxy",labelKey:"desktop.proxy",Icon:aK.l},{id:"features",labelKey:"desktop.features",Icon:g.l},{id:"logs",labelKey:"desktop.logs",Icon:w.B},{id:"snippets",labelKey:"desktop.snippets",Icon:n7.c},{id:"usage",labelKey:"desktop.usage",Icon:aG._},{id:"mcp",labelKey:"desktop.mcp",Icon:aJ.b},{id:"subagents",labelKey:"desktop.subagents",Icon:aY.d},{id:"tools",labelKey:"desktop.tools",Icon:aJ.b},{id:"backup",labelKey:"desktop.backup",Icon:rQ.W},{id:"import",labelKey:"desktop.importSessions",Icon:E.z}];function cm({initialTab:e="models",cwd:t,sessionId:o,onCloseAction:s,onModelsSavedAction:i,onSessionReloadedAction:a,onSessionsChanged:l}){let d=O(),{t:c}=(0,A.s)(),[p,u]=(0,n.useState)("skills"===e||"plugins"===e?t?e:"display":e),[g,m]=(0,n.useState)(!1);(0,n.useEffect)(()=>{m(new URLSearchParams(window.location.search).has("piweb_connected"))},[]);let f=g?cg:cg.filter(({id:e})=>"server"!==e),[x,k]=(0,n.useState)(!1),[v,y]=(0,n.useState)(null),b=(0,n.useRef)(new Set),w=(0,n.useCallback)(e=>(b.current.add(e),()=>{b.current.delete(e)}),[]),j=(0,n.useCallback)(async()=>{if(!x){k(!0),y(null);try{let e=(await Promise.allSettled([...b.current].map(e=>e()))).find(e=>"rejected"===e.status);if(e)throw e.reason;s()}catch(e){y(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[x,s]);return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&j()},children:(0,r.jsxs)("section",{role:"dialog","aria-modal":"true","aria-label":c("desktop.settings"),className:"settings-modal",style:{width:d?"calc(100vw - 16px)":1e3,maxWidth:"calc(100vw - 16px)",height:d?"calc(100dvh - 16px)":"80vh",maxHeight:"calc(100dvh - 16px)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[(0,r.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,minWidth:0},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:c("desktop.settings")}),"models"===p?(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:"~/.pi/agent/models.json"}):t&&(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),(0,r.jsx)("button",{type:"button",onClick:()=>{j()},disabled:x,title:c("desktop.closeSettings"),"aria-label":c("desktop.closeSettings"),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:18,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:d?"column":"row",minHeight:0,overflow:"hidden",pointerEvents:x?"none":void 0},children:[(0,r.jsx)("nav",{"aria-label":c("desktop.settingsSections"),style:{display:"flex",flexDirection:d?"row":"column",gap:4,width:d?"100%":150,padding:8,flexShrink:0,minWidth:0,background:"var(--bg-panel)",borderRight:d?"none":"1px solid var(--border)",borderBottom:d?"1px solid var(--border)":"none",overflowX:d?"auto":void 0,overflowY:d?"hidden":void 0,WebkitOverflowScrolling:d?"touch":void 0},children:f.filter(({id:e})=>!(d&&"import"===e)).map(({id:e,labelKey:o,Icon:n})=>{let s=("skills"===e||"plugins"===e)&&!t,i=p===e;return(0,r.jsxs)("button",{type:"button",disabled:s,onClick:()=>u(e),"aria-current":i?"page":void 0,style:{display:"flex",alignItems:"center",gap:8,flex:d?"0 0 auto":void 0,whiteSpace:"nowrap",width:d?void 0:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:i?"var(--bg-selected)":"none",color:i?"var(--text)":"var(--text-muted)",cursor:s?"not-allowed":"pointer",opacity:s?.4:1,fontSize:12,fontWeight:i?600:400,textAlign:"left",transition:"background 0.12s, color 0.12s"},title:c(o),"aria-label":c(o),onMouseEnter:e=>{i||s||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{i||(e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)")},children:[(0,r.jsx)(n,{size:16,"aria-hidden":"true"}),!d&&(0,r.jsx)("span",{children:c(o)})]},e)})}),(0,r.jsx)("div",{style:{display:"server"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(ch,{})}),(0,r.jsx)("div",{style:{display:"display"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(lp,{})}),(0,r.jsx)("div",{style:{display:"chat"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(a3,{})}),(0,r.jsx)("div",{style:{display:"models"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(dn,{embedded:!0,sessionId:o,onSavedAction:i,onRegisterFlush:w})}),t&&(0,r.jsx)("div",{style:{display:"skills"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(dz,{cwd:t,embedded:!0,sessionId:o})}),t&&(0,r.jsx)("div",{style:{display:"plugins"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(dk,{cwd:t,sessionId:o,embedded:!0,onReloadedAction:a})}),(0,r.jsx)("div",{style:{display:"proxy"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(dy,{})}),(0,r.jsx)("div",{style:{display:"features"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(lb,{})}),(0,r.jsx)("div",{style:{display:"logs"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(dI,{})}),(0,r.jsx)("div",{style:{display:"snippets"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(dE,{})}),(0,r.jsx)("div",{style:{display:"usage"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(cu,{sessionId:o,cwd:t})}),(0,r.jsx)("div",{style:{display:"mcp"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(l$,{sessionId:o})}),(0,r.jsx)("div",{style:{display:"subagents"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(cd,{cwd:t??"",sessionId:o,onClose:s})}),(0,r.jsx)("div",{style:{display:"tools"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(cc,{sessionId:o,onSessionReloaded:a})}),(0,r.jsx)("div",{style:{display:"backup"===p?"flex":"none",flex:1,minWidth:0,minHeight:0},children:(0,r.jsx)(a0,{cwd:t})}),(0,r.jsx)("div",{style:{display:"import"===p?"flex":"none",flex:1,minWidth:0,minHeight:0,overflowY:"auto"},children:(0,r.jsx)(lS,{onSessionsChanged:l})})]}),v&&(0,r.jsx)("div",{style:{padding:"6px 18px",borderTop:"1px solid var(--border)",color:"#f87171",fontSize:11},children:v})]})})}let cf=new Set(["awaiting_input","review","failed"]),cx=(0,n.createContext)(null);function ck(){let e=(0,n.useContext)(cx);if(!e)throw Error("useTasksView must be used within TasksViewProvider");return e}function cv({children:e}){let{t}=(0,A.s)(),o=(0,n.useRef)(t);(0,n.useEffect)(()=>{o.current=t},[t]);let[s,i]=(0,n.useState)([]),[a,l]=(0,n.useState)([]),d=(0,n.useRef)(0),c=(0,n.useCallback)(async()=>{let e=++d.current;try{let t=await (0,sS.Wt)(),o=(await Promise.all(t.map(e=>(0,sS.Vk)(e).catch(()=>[])))).flat().sort((e,t)=>t.id-e.id);if(e!==d.current)return;l(e=>cy(e,t)?e:t),i(e=>cy(e,o)?e:o)}catch{}},[]);(0,n.useEffect)(()=>{c();let e=null,t=!1,o=()=>{t||((e=new EventSource("/api/tasks/events")).onmessage=()=>{c()},e.onerror=()=>{e?.close(),e=null,c(),setTimeout(o,2e3)})};o();let r=()=>{"visible"===document.visibilityState&&c()},n=()=>void c();document.addEventListener("visibilitychange",r),window.addEventListener("online",n);let s=setInterval(()=>void c(),6e4);return()=>{t=!0,e?.close(),document.removeEventListener("visibilitychange",r),window.removeEventListener("online",n),clearInterval(s)}},[c]);let p=(0,n.useMemo)(()=>s.filter(e=>cf.has(e.status)&&null==e.archivedAt).length,[s]),u=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=u.current;if((u.current=new Map(s.map(e=>[e.id,e.status])),e&&0!==s.length)&&"Notification"in window){for(let o of s)if(e.get(o.id)!==o.status&&("review"===o.status||"failed"===o.status)&&null==o.archivedAt&&"visible"!==document.visibilityState)try{let e="review"===o.status?t("tasks.notifyReview",{title:o.title}):t("tasks.notifyFailed",{title:o.title});!function(e,t){new Promise(o=>{if(!("Notification"in window))return void o();let r=()=>{try{new Notification(e,{body:t,tag:"pi-tasks"})}catch{}o()};"granted"===Notification.permission?r():"denied"!==Notification.permission?Notification.requestPermission().then(e=>{"granted"===e?r():o()}):o()})}("Pi Web Tasks",e)}catch{}}},[s,t]);let h=(0,n.useMemo)(()=>({tasks:s,projects:a,attentionCount:p,refetch:c}),[s,a,p,c]);return(0,r.jsx)(cx.Provider,{value:h,children:e})}function cy(e,t){return JSON.stringify(e)===JSON.stringify(t)}var cb=o(4539),cw=o(12449),cj=o(2571);let cS=["todo","inProgress","attention","done"];function cC(e){return"review"===e.status&&0===e.filesChanged}function cT(){return{defaultAgentType:null,modeId:null,configValues:{},autoProcess:!0,maxConcurrent:1,mergeStrategy:"merge",deleteWorktreeDefault:!0,preflightCommand:null,initCommand:null,stagePrompts:null}}let cR=["todo","inProgress","attention","done"],cz={todo:{id:"todo",marker:"var(--text-dim)"},inProgress:{id:"inProgress",marker:"var(--accent)"},attention:{id:"attention",marker:"#f59e0b"},done:{id:"done",marker:"#10b981"}};var cI=o(54775),cM=o(98998),cP=o(36668);function cE({task:e}){let{t}=(0,A.s)(),o=t("failed"===e.status&&"interrupted"===e.failureReason?"tasks.statusInterrupted":function(e){switch(e){case"todo":return"tasks.statusTodo";case"queued":return"tasks.statusQueued";case"preparing":return"tasks.statusPreparing";case"running":return"tasks.statusRunning";case"awaiting_input":return"tasks.statusAwaitingInput";case"review":return"tasks.statusReview";case"merging":return"tasks.statusMerging";case"done":return"tasks.statusDone";case"failed":return"tasks.statusFailed";case"canceled":return"tasks.statusCanceled"}}(e.status)),n={display:"inline-flex",alignItems:"center",gap:4,borderRadius:999,padding:"2px 8px",fontSize:10,fontWeight:600,lineHeight:1.4,flexShrink:0,whiteSpace:"nowrap"};switch(e.status){case"queued":case"preparing":case"running":case"merging":return(0,r.jsxs)("span",{style:{...n,color:"var(--accent)"},children:[(0,r.jsx)(cI.N,{size:11,className:"pi-spin",style:{animation:"pi-spin 1s linear infinite"},"aria-hidden":"true"}),o]});case"awaiting_input":case"review":return(0,r.jsx)("span",{style:{...n,border:"1px solid rgba(245,158,11,0.45)",background:"rgba(245,158,11,0.08)",color:"#d97706"},children:o});case"done":return(0,r.jsxs)("span",{style:{...n,background:"rgba(16,185,129,0.12)",color:"#059669"},children:[(0,r.jsx)(m.J,{size:10,weight:"bold","aria-hidden":"true"}),o]});case"failed":return(0,r.jsx)("span",{style:{...n,background:"rgba(239,68,68,0.12)",color:"#dc2626"},children:o});default:return(0,r.jsx)("span",{style:{...n,background:"var(--bg-hover)",color:"var(--text-muted)"},children:o})}}function cW({task:e}){let t=e.preflight;if(!t||"review"!==e.status)return null;let o="passed"===t.status?{background:"rgba(16,185,129,0.12)",color:"#059669"}:"failed"===t.status?{background:"rgba(239,68,68,0.12)",color:"#dc2626"}:{background:"var(--bg-hover)",color:"var(--text-muted)"};return(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,borderRadius:999,padding:"1px 6px",fontSize:10,fontWeight:500,lineHeight:1.5,maxWidth:"100%",...o},title:t.command,children:["running"===t.status?(0,r.jsx)(cI.N,{size:10,style:{animation:"pi-spin 1s linear infinite"},"aria-hidden":"true"}):"passed"===t.status?(0,r.jsx)(nv.r,{size:10,"aria-hidden":"true"}):(0,r.jsx)(iU.J,{size:10,"aria-hidden":"true"}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.command})]})}function cF({task:e,folderName:t,now:o,onOpen:n,onStart:s,onCancel:i,onRetry:a,onRequeue:l,onViewSession:d,onMerge:c,onArchive:p,onEdit:u}){let{t:h}=(0,A.s)(),g=null!=e.archivedAt,f="running"===e.status||"awaiting_input"===e.status||"merging"===e.status,x=null!=e.filesChanged&&e.filesChanged>0?(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontFamily:"var(--font-mono)",fontSize:10},children:[(0,r.jsxs)("span",{style:{color:"#059669"},children:["+",e.additions??0]}),(0,r.jsxs)("span",{style:{color:"#dc2626"},children:["-",e.deletions??0]})]}):null,k=function(e,t){if(!e)return"";let o=new Date(e).getTime();if(Number.isNaN(o))return"";let r=Math.floor(Math.max(0,t-o)/6e4);if(r<1)return"now";if(r<60)return`${r}m`;let n=Math.floor(r/60);if(n<24)return`${n}h`;let s=Math.floor(n/24);return`${s}d`}(e.finishedAt??e.settledAt??e.startedAt??e.createdAt,o),{primary:v,more:y}=(()=>{let t=[],o=null;if(g)return{primary:o={icon:P.T,label:h("tasks.actionUnarchive"),onClick:p},more:t};switch(e.status){case"todo":o={icon:cj.j,label:h("tasks.actionStart"),onClick:s},t.push({icon:n9.S,label:h("tasks.actionEdit"),onClick:u});break;case"queued":case"preparing":case"running":case"awaiting_input":o={icon:cM.k,label:h("tasks.actionCancel"),onClick:i};break;case"review":o=cC(e)?{icon:m.J,label:h("tasks.actionComplete"),onClick:c}:{icon:cP.r,label:h("tasks.actionMerge"),onClick:c};break;case"merging":break;case"failed":o={icon:C.S,label:h("tasks.actionRetry"),onClick:a},t.push({icon:n9.S,label:h("tasks.actionEdit"),onClick:u}),t.push({icon:P.T,label:h("tasks.actionArchive"),onClick:p});break;case"done":o={icon:P.T,label:h("tasks.actionArchive"),onClick:p};break;case"canceled":o={icon:ny.f,label:h("tasks.actionRequeue"),onClick:l},t.push({icon:P.T,label:h("tasks.actionArchive"),onClick:p})}return{primary:o,more:t}})(),b=[...y];return null!=e.conversationId&&b.push({icon:nk.y,label:h("tasks.actionViewSession"),onClick:d}),(0,r.jsxs)("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),n())},style:{display:"flex",flexDirection:"column",cursor:"pointer",borderRadius:12,border:"1px solid color-mix(in srgb, var(--border) 85%, transparent)",background:"var(--bg-panel)",padding:12,textAlign:"left",transition:"border-color 0.12s",opacity:g?.6:1,boxShadow:"0 1px 2px rgba(0,0,0,0.04)"},className:"task-card-hover",onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="color-mix(in srgb, var(--border) 85%, transparent)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8},children:[(0,r.jsx)("span",{style:{minWidth:0,overflowWrap:"break-word",fontSize:13,fontWeight:500,lineHeight:1.4},children:e.title}),(0,r.jsx)(cE,{task:e})]}),(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"2px 6px",marginTop:6,fontSize:11,color:"var(--text-muted)"},children:[t?(0,r.jsx)("span",{style:{maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t}):null,t&&e.workBranch?(0,r.jsx)("span",{style:{opacity:.5},children:"/"}):null,e.workBranch?(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:180},children:e.workBranch}):null,(t||e.workBranch)&&(x||k)?(0,r.jsx)("span",{style:{opacity:.5},children:"\xb7"}):null,x,x&&k?(0,r.jsx)("span",{style:{opacity:.5},children:"\xb7"}):null,k?(0,r.jsx)("span",{style:{flexShrink:0},children:k}):null,(0,r.jsx)(cW,{task:e})]}),e.lastError&&("failed"===e.status||"review"===e.status)?(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:8,borderRadius:8,background:"rgba(239,68,68,0.08)",padding:"6px 8px",fontSize:11,color:"#dc2626"},children:[(0,r.jsx)(r0.t,{size:13,style:{flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.lastError}),(0,r.jsx)("button",{type:"button",style:{flexShrink:0,fontWeight:600,background:"none",border:"none",cursor:"pointer",color:"inherit",fontSize:11,textDecoration:"underline"},onClick:e=>{e.stopPropagation(),n()},children:h("tasks.errorView")})]}):null,"review"===e.status&&e.resultSummary?(0,r.jsx)("p",{style:{margin:"6px 0 0",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",fontSize:11,lineHeight:1.5,color:"var(--text-muted)"},children:e.resultSummary}):null,f&&e.latestProgress?(0,r.jsx)("p",{style:{margin:"6px 0 0",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",fontSize:11,lineHeight:1.5,color:"var(--text-muted)",fontStyle:"italic"},children:e.latestProgress}):null,v||b.length>0?(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:12,paddingTop:12,borderTop:"1px solid var(--border)"},children:[v?(0,r.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),v.onClick()},style:{display:"inline-flex",alignItems:"center",gap:5,padding:"4px 10px",borderRadius:7,background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer",fontSize:11,fontWeight:600},children:[(0,r.jsx)(v.icon,{size:12,weight:"bold","aria-hidden":"true"}),v.label]}):null,(0,r.jsx)("div",{style:{flex:1}}),b.map(e=>(0,r.jsx)("button",{type:"button",title:e.label,"aria-label":e.label,onClick:t=>{t.stopPropagation(),e.onClick()},style:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,borderRadius:999,background:"none",border:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",opacity:0,transition:"opacity 0.12s, background 0.12s, color 0.12s"},className:"task-card-secondary",onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(e.icon,{size:13,"aria-hidden":"true"})},e.label))]}):null]})}function cD({open:e,onOpenChange:t,task:o}){let{t:s}=(0,A.s)(),{refetch:i}=ck(),[a,l]=(0,n.useState)(""),[d,c]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{e&&(l(""),c(!1))},[e,o]),!e||!o)return null;let p=async()=>{if(!d){c(!0);try{await (0,sS.oQ)(o.id,o.projectRoot,"cancel",{reason:a.trim()||null}),t(!1),i()}catch(e){console.error("cancel failed",e)}finally{c(!1)}}};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:950,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(440px, calc(100vw - 48px))",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:s("tasks.cancelTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":s("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:"14px 16px 16px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,lineHeight:1.5,color:"var(--text-muted)"},children:s("tasks.cancelDescription")}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)"},children:s("tasks.cancelReasonLabel")}),(0,r.jsx)("textarea",{value:a,onChange:e=>l(e.target.value),placeholder:s("tasks.cancelReasonPlaceholder"),rows:3,autoFocus:!0,style:{width:"100%",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px",color:"var(--text)",fontSize:13,outline:"none",fontFamily:"inherit",resize:"vertical"}})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),disabled:d,style:{padding:"8px 14px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:s("tasks.cancelKeep")}),(0,r.jsx)("button",{type:"button",onClick:()=>void p(),disabled:d,style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:s("tasks.cancelSubmit")})]})]})]})})}function cA({open:e,onOpenChange:t,task:o}){let{t:s}=(0,A.s)(),{refetch:i}=ck(),[a,l]=(0,n.useState)(!0),[d,c]=(0,n.useState)(!1),p=o?.worktreePath!=null;if((0,n.useEffect)(()=>{if(!e||!o)return;c(!1);let t=!1;return(0,sS.CG)(o.projectRoot).then(e=>{t||l(e.deleteWorktreeDefault)}).catch(()=>{t||l(!0)}),()=>{t=!0}},[e,o]),!e||!o)return null;let u=async()=>{if(!d){c(!0);try{await (0,sS.ZX)(o.id,o.projectRoot,p&&a),t(!1),i()}catch(e){console.error("complete failed",e)}finally{c(!1)}}};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:950,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(440px, calc(100vw - 48px))",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:s("tasks.completeTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":s("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:"14px 16px 16px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,lineHeight:1.5,color:"var(--text-muted)"},children:s("tasks.completeDescription")}),p?(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:a,onChange:e=>l(e.target.checked),style:{accentColor:"var(--accent)"}}),s("tasks.completeDeleteWorktree")]}):null,(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),disabled:d,style:{padding:"8px 14px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:s("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void u(),disabled:d,style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:s("tasks.completeSubmit")})]})]})]})})}var cN=o(51285),cL=o(16894);function c$({open:e,onOpenChange:t,task:o,onViewSession:s,onMerge:i,onEdit:a,onCancel:l,onRetry:d,onRequeue:c,onComplete:p}){let{t:u}=(0,A.s)(),{refetch:g}=ck(),[f,x]=(0,n.useState)([]),[k,v]=(0,n.useState)([]),[b,w]=(0,n.useState)(null),[j,S]=(0,n.useState)(null),[R,z]=(0,n.useState)(!1),[I,M]=(0,n.useState)(!1),[E,W]=(0,n.useState)(""),[F,D]=(0,n.useState)(!1),[N,L]=(0,n.useState)(!1),[$,H]=(0,n.useState)(!1),O=o?.id??null,B=o?.projectRoot??null,U=(0,n.useCallback)(async()=>{if(null==O||null==B)return;let[e,t]=await Promise.all([(0,sS.HB)(B,O).catch(()=>[]),o?.worktreePath?(0,sS.JH)(B,O).then(e=>e.files).catch(()=>[]):Promise.resolve([])]);x(e),v(t)},[O,B,o?.worktreePath]);(0,n.useEffect)(()=>{if(!e||null==O)return;x([]),v([]),M(!1),W(""),U();let t=window.setInterval(()=>void U(),5e3);return()=>window.clearInterval(t)},[e,O,U]);let _=(0,n.useCallback)(async e=>{H(!0);try{await e()}catch(e){console.error("detail action failed",e)}finally{H(!1),g()}},[g]),q=(0,n.useCallback)(async e=>{if(null!=B&&null!=O){z(!0);try{let t=await (0,sS.h)(B,O,e);S(t.supported&&t.patch?t.patch:null)}catch{S(null)}finally{z(!1)}}},[B,O]),V=async()=>{null!=o&&null!=B&&(await _(()=>(0,sS.bH)(o.id,B,N)),t(!1))},K=async()=>{null!=o&&null!=B&&E.trim()&&(await _(()=>(0,sS.in)(o.id,B,E.trim())),M(!1),W(""))};if(!e||null==o||null==B)return null;let G=[];if(null==o.archivedAt)switch(o.status){case"todo":G.push({label:u("tasks.actionStart"),icon:cj.j,onClick:()=>void _(()=>(0,sS.oQ)(o.id,B,"start")),filled:!0}),G.push({label:u("tasks.actionEdit"),icon:n9.S,onClick:()=>a(o)});break;case"queued":case"preparing":case"running":case"awaiting_input":G.push({label:u("tasks.actionCancel"),icon:cM.k,onClick:()=>l(o),danger:!0});break;case"review":G.push({label:cC(o)?u("tasks.actionComplete"):u("tasks.actionMerge"),icon:cC(o)?m.J:cN.Y,onClick:()=>cC(o)?p(o):i(o),filled:!0}),G.push({label:u("tasks.actionReturn"),icon:ny.f,onClick:()=>M(!0)});break;case"failed":G.push({label:u("tasks.actionRetry"),icon:C.S,onClick:()=>d(o),filled:!0}),G.push({label:u("tasks.actionEdit"),icon:n9.S,onClick:()=>a(o)});break;case"done":G.push({label:u("tasks.actionArchive"),icon:P.T,onClick:()=>void _(()=>(0,sS.et)(o.id,B,!0))});break;case"canceled":G.push({label:u("tasks.actionRequeue"),icon:ny.f,onClick:()=>c(o),filled:!0})}else G.push({label:u("tasks.actionUnarchive"),icon:P.T,onClick:()=>void _(()=>(0,sS.et)(o.id,B,!1))});return null!=o.conversationId&&G.push({label:u("tasks.actionViewSession"),icon:nk.y,onClick:()=>s(o)}),(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:800,background:"rgba(0,0,0,0.35)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 90vw)",background:"var(--bg-panel)",borderLeft:"1px solid var(--border)",display:"flex",flexDirection:"column",boxShadow:"-8px 0 32px rgba(0,0,0,0.2)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12,padding:"16px 16px 0"},children:[(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("h3",{style:{margin:0,fontSize:15,fontWeight:600,lineHeight:1.4,overflowWrap:"break-word"},children:o.title}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6},children:[(0,r.jsx)(cE,{task:o}),o.workBranch?(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-muted)"},children:[(0,r.jsx)(y.Z,{size:12,"aria-hidden":"true"}),o.workBranch]}):null]})]}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":u("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex",flexShrink:0},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,padding:"14px 16px 0"},children:G.map(e=>{let t,o;return(0,r.jsxs)("button",{type:"button",onClick:e.onClick,disabled:$,style:(t=e.filled,o=e.danger,{display:"inline-flex",alignItems:"center",gap:5,padding:"7px 12px",borderRadius:8,fontSize:12,fontWeight:600,cursor:"pointer",background:t?"var(--accent)":o?"rgba(239,68,68,0.1)":"var(--bg-hover)",color:t?"#fff":o?"#dc2626":"var(--text)",border:t||o?"none":"1px solid var(--border)"}),children:[(0,r.jsx)(e.icon,{size:13,weight:"bold","aria-hidden":"true"}),e.label]},e.label)})}),I&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"12px 16px 0"},children:[(0,r.jsx)("textarea",{value:E,onChange:e=>W(e.target.value),placeholder:u("tasks.returnPlaceholder"),rows:3,style:{width:"100%",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px",color:"var(--text)",fontSize:12,resize:"vertical",fontFamily:"inherit"}}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[(0,r.jsx)("button",{type:"button",onClick:()=>M(!1),style:{padding:"6px 12px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:u("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void K(),disabled:!E.trim(),style:{padding:"6px 14px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:u("tasks.returnSubmit")})]})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"14px 16px 0",fontSize:12,color:"var(--text-muted)"},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",width:64},children:u("tasks.metaProject")}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)",fontSize:11},children:o.projectRoot})]}),o.createdAt?(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",width:64},children:u("tasks.metaCreated")}),(0,r.jsx)("span",{children:new Date(o.createdAt).toLocaleString()})]}):null,o.mergeCommit?(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",width:64},children:u("tasks.metaCommit")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11},children:o.mergeCommit})]}):null]}),k.length>0&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"14px 16px 0"},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:u("tasks.changedFiles")}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2,maxHeight:140,overflowY:"auto"},children:k.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>{var t;w(t=e.file),S(null),q(t)},style:{display:"flex",alignItems:"center",gap:8,textAlign:"left",padding:"4px 6px",borderRadius:6,background:"none",border:"none",color:"var(--text)",fontSize:12,cursor:"pointer"},children:[(0,r.jsx)(cL.o,{size:13,style:{flexShrink:0,color:"var(--text-muted)"},"aria-hidden":"true"}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)",fontSize:11},children:e.file}),(0,r.jsxs)("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"#059669",flexShrink:0},children:["+",e.additions]}),(0,r.jsxs)("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"#dc2626",flexShrink:0},children:["-",e.deletions]})]},e.file))})]}),null!=b&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 16px 0",minHeight:0,flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:u("tasks.diff")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:b}),(0,r.jsx)("button",{type:"button",onClick:()=>w(null),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:2,display:"flex"},children:(0,r.jsx)(h.X,{size:12,"aria-hidden":"true"})})]}),R?(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",padding:8},children:u("tasks.loading")}):j?(0,r.jsx)("pre",{style:{margin:0,maxHeight:200,overflow:"auto",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:10,fontSize:11,lineHeight:1.5,fontFamily:"var(--font-mono)",color:"var(--text-muted)",whiteSpace:"pre"},children:j.split("\n").map((e,t)=>{let o;return e.startsWith("+")&&!e.startsWith("+++")?o="#059669":e.startsWith("-")&&!e.startsWith("---")?o="#dc2626":e.startsWith("@@")&&(o="var(--accent)"),(0,r.jsx)("div",{style:{color:o},children:e||" "},t)})}):(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",padding:8},children:u("tasks.noDiff")})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"14px 16px 0",flex:1,minHeight:0},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:u("tasks.timeline")}),(0,r.jsx)("div",{style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:8},children:0===f.length?(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)",padding:8},children:u("tasks.noEvents")}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[...f].reverse().map(e=>{var t;let o,n;return(0,r.jsxs)("div",{style:{display:"flex",gap:8,padding:"4px 6px",borderRadius:6,fontSize:11},children:[(0,r.jsx)("span",{style:{color:"var(--text-dim)",flexShrink:0,fontFamily:"var(--font-mono)",fontSize:10,paddingTop:1},children:new Date(e.createdAt).toLocaleTimeString()}),(0,r.jsx)("span",{style:{color:"var(--text)",flexShrink:0,fontWeight:500},children:(t=e.kind,(n=u(o=`tasks.event_${t}`))===o?t:n)}),e.payload?.feedback?(0,r.jsx)("span",{style:{color:"var(--text-muted)",fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(e.payload.feedback)}):null]},e.id)})})})]}),(0,r.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"10px 16px",borderTop:"1px solid var(--border)",flexShrink:0},children:F?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:N,onChange:e=>L(e.target.checked),style:{accentColor:"var(--accent)"}}),u("tasks.deleteWorktree")]}),(0,r.jsx)("button",{type:"button",onClick:()=>D(!1),style:{padding:"6px 12px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:u("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void V(),disabled:$,style:{padding:"6px 14px",borderRadius:8,background:"#dc2626",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:u("tasks.deleteConfirm")})]}):(0,r.jsxs)("button",{type:"button",onClick:()=>D(!0),style:{display:"inline-flex",alignItems:"center",gap:5,padding:"6px 12px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"#dc2626",fontSize:12,cursor:"pointer"},children:[(0,r.jsx)(T.l,{size:13,"aria-hidden":"true"}),u("tasks.delete")]})})]})})}var cH=o(17757);function cO({open:e,onOpenChange:t,task:o,defaultProject:s,projects:i,prefillTitle:a,prefillPrompt:l,onSubmit:d}){let{t:c}=(0,A.s)(),[p,u]=(0,n.useState)(""),[g,m]=(0,n.useState)(""),[f,x]=(0,n.useState)(""),[k,v]=(0,n.useState)([]),[y,b]=(0,n.useState)(""),[w,j]=(0,n.useState)(!1),S=(0,n.useRef)(!1);if((0,n.useEffect)(()=>{if(!e){S.current=!1;return}S.current||(S.current=!0,u(o?.projectRoot??s??i[0]??""),m(o?.title??a??""),x(o?.config?.prompt??l??""),(0,sS.VB)().then(v).catch(()=>void 0))},[e,o,s,i,a,l]),!e)return null;let C=async()=>{if(p&&g.trim()&&!w){j(!0);try{await d(p,g.trim(),{prompt:f.trim(),agentType:o?.config?.agentType??null,modelId:o?.config?.modelId??null,thinkingLevel:o?.config?.thinkingLevel??null}),t(!1)}catch(e){console.error("submit task failed",e)}finally{j(!1)}}},R=async()=>{if(y.trim()&&g.trim())try{await (0,sS.nY)({name:y.trim(),title:g.trim(),config:{prompt:f.trim()}}),b(""),(0,sS.VB)().then(v).catch(()=>void 0)}catch(e){console.error("save template failed",e)}},z=async e=>{try{await (0,sS.B_)(e),(0,sS.VB)().then(v).catch(()=>void 0)}catch(e){console.error("delete template failed",e)}},I={width:"100%",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px",color:"var(--text)",fontSize:13,outline:"none"};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:900,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(520px, calc(100vw - 48px))",maxHeight:"80vh",overflowY:"auto",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:o?c("tasks.editTitle"):c("tasks.newTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":c("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:"14px 16px 16px"},children:[k.length>0&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:c("tasks.templates")}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:k.map(e=>(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,borderRadius:999,background:"var(--bg-hover)",padding:"3px 8px",fontSize:11},children:[(0,r.jsx)("button",{type:"button",onClick:()=>{m(e.title),x(e.config?.prompt??"")},style:{background:"none",border:"none",cursor:"pointer",color:"var(--text)",fontSize:11,padding:0},children:e.name}),(0,r.jsx)("button",{type:"button",onClick:()=>void z(e.id),"aria-label":c("tasks.deleteTemplate"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-dim)",padding:0,display:"flex"},children:(0,r.jsx)(T.l,{size:10,"aria-hidden":"true"})})]},e.id))})]}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:500,color:"var(--text)"},children:c("tasks.fieldProject")}),(0,r.jsx)("select",{value:p,onChange:e=>u(e.target.value),style:I,children:i.map(e=>(0,r.jsx)("option",{value:e,children:e.split("/").filter(Boolean).pop()??e},e))})]}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:500,color:"var(--text)"},children:c("tasks.fieldTitle")}),(0,r.jsx)("input",{value:g,onChange:e=>m(e.target.value),placeholder:c("tasks.fieldTitlePlaceholder"),style:I,autoFocus:!0})]}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:500,color:"var(--text)"},children:c("tasks.fieldPrompt")}),(0,r.jsx)("textarea",{value:f,onChange:e=>x(e.target.value),placeholder:c("tasks.fieldPromptPlaceholder"),rows:6,style:{...I,resize:"vertical",fontFamily:"inherit",lineHeight:1.5}})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("input",{value:y,onChange:e=>b(e.target.value),placeholder:c("tasks.templateNamePlaceholder"),style:{...I,flex:1}}),(0,r.jsxs)("button",{type:"button",onClick:()=>void R(),disabled:!y.trim()||!g.trim(),style:{display:"inline-flex",alignItems:"center",gap:5,padding:"8px 12px",borderRadius:8,background:"var(--bg-hover)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:[(0,r.jsx)(cH.D,{size:13,"aria-hidden":"true"}),c("tasks.saveAsTemplate")]})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),style:{padding:"8px 14px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:c("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void C(),disabled:!p||!g.trim()||w,style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:c("tasks.save")})]})]})]})})}function cB({open:e,onOpenChange:t,task:o}){let{t:s}=(0,A.s)(),{refetch:i}=ck(),[a,l]=(0,n.useState)(!0),[d,c]=(0,n.useState)(""),[p,u]=(0,n.useState)(!0),[g,m]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{e&&o&&(l(!0),c(o.title),m(!1),(0,sS.CG)(o.projectRoot).then(e=>u(e.deleteWorktreeDefault)).catch(()=>u(!0)))},[e,o]),!e||!o)return null;let f=async()=>{if((a||d.trim())&&!g){m(!0);try{await (0,sS.oB)(o.id,o.projectRoot,a?null:d.trim(),p),t(!1),i()}catch(e){console.error("merge failed",e)}finally{m(!1)}}};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:950,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(440px, calc(100vw - 48px))",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:s("tasks.mergeTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":s("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:"14px 16px 16px"},children:[(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,cursor:"pointer"},children:[(0,r.jsx)("input",{type:"radio",checked:a,onChange:()=>l(!0),style:{accentColor:"var(--accent)"}}),s("tasks.mergeAutoMessage")]}),(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,cursor:"pointer"},children:[(0,r.jsx)("input",{type:"radio",checked:!a,onChange:()=>l(!1),style:{accentColor:"var(--accent)"}}),s("tasks.mergeManualMessage")]}),!a&&(0,r.jsx)("input",{value:d,onChange:e=>c(e.target.value),placeholder:s("tasks.mergeMessagePlaceholder"),style:{width:"100%",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px",color:"var(--text)",fontSize:13,outline:"none",fontFamily:"inherit"}}),(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:p,onChange:e=>u(e.target.checked),style:{accentColor:"var(--accent)"}}),s("tasks.mergeDeleteWorktree")]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),style:{padding:"8px 14px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:s("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void f(),disabled:!a&&!d.trim()||g,style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:s("tasks.mergeConfirm")})]})]})]})})}function cU({open:e,onOpenChange:t,task:o,kind:s}){let{t:i}=(0,A.s)(),{refetch:a}=ck(),[l,d]=(0,n.useState)(""),[c,p]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{e&&(d(""),p(!1))},[e,o]),!e||!o)return null;let u="retry"===s,g=async()=>{if(!c){p(!0);try{await (0,sS.oQ)(o.id,o.projectRoot,s,{note:l.trim()||null}),t(!1),a()}catch(e){console.error("restart failed",e)}finally{p(!1)}}};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:950,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(480px, calc(100vw - 48px))",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:i(u?"tasks.restartTitleRetry":"tasks.restartTitleRequeue")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":i("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:"14px 16px 16px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,lineHeight:1.5,color:"var(--text-muted)"},children:i("tasks.restartDescription")}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)"},children:i("tasks.actionAddNote")}),(0,r.jsx)("textarea",{value:l,onChange:e=>d(e.target.value),placeholder:i(u?"tasks.followUpPlaceholderRetry":"tasks.followUpPlaceholderRequeue"),rows:3,autoFocus:!0,style:{width:"100%",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px",color:"var(--text)",fontSize:13,outline:"none",fontFamily:"inherit",resize:"vertical"}})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),disabled:c,style:{padding:"8px 14px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:i("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void g(),disabled:c,style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:i(u?"tasks.actionRetry":"tasks.actionRequeue")})]})]})]})})}let c_=["work","retry","return","merge"];function cq({open:e,onOpenChange:t,projectRoot:o}){let{t:s}=(0,A.s)(),{projects:i}=ck(),[a,l]=(0,n.useState)(""),[d,c]=(0,n.useState)(()=>cT()),[p,u]=(0,n.useState)(!1),[g,m]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{if(!e)return;let t=o??i[0]??"";l(t),t&&(0,sS.Pf)(t).then(e=>{u(null!=e),c(e??cT())}).catch(()=>{u(!1),c(cT())})},[e,o,i]),!e)return null;let f=(e,t)=>{c(o=>({...o,[e]:t}))},x=async()=>{if(a&&!g){m(!0);try{await (0,sS.eA)(a,d),u(!0),t(!1)}catch(e){console.error("save settings failed",e)}finally{m(!1)}}},k=async()=>{if(a)try{await (0,sS.E)(a),u(!1),c(cT())}catch(e){console.error("reset settings failed",e)}},v={width:"100%",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:"7px 10px",color:"var(--text)",fontSize:12,outline:"none",fontFamily:"inherit"},y={display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 0",borderBottom:"1px solid var(--border)"};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:960,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(560px, calc(100vw - 48px))",maxHeight:"82vh",overflowY:"auto",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:s("tasks.settingsTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":s("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:"14px 16px 16px"},children:[(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:500},children:s("tasks.settingsProject")}),(0,r.jsx)("select",{value:a,onChange:e=>l(e.target.value),style:v,children:i.map(e=>(0,r.jsx)("option",{value:e,children:e.split("/").filter(Boolean).pop()??e},e))})]}),a?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:y,children:[(0,r.jsx)("span",{style:{fontSize:12},children:s("tasks.settingsAutoProcess")}),(0,r.jsx)("input",{type:"checkbox",checked:d.autoProcess,onChange:e=>f("autoProcess",e.target.checked),style:{accentColor:"var(--accent)"}})]}),(0,r.jsxs)("div",{style:y,children:[(0,r.jsx)("span",{style:{fontSize:12},children:s("tasks.settingsMaxConcurrent")}),(0,r.jsx)("input",{type:"number",min:0,value:d.maxConcurrent,onChange:e=>f("maxConcurrent",Math.max(0,Number(e.target.value)||0)),style:{...v,width:90}})]}),(0,r.jsxs)("div",{style:y,children:[(0,r.jsx)("span",{style:{fontSize:12},children:s("tasks.settingsMergeStrategy")}),(0,r.jsxs)("select",{value:d.mergeStrategy,onChange:e=>f("mergeStrategy",e.target.value),style:{...v,width:140},children:[(0,r.jsx)("option",{value:"merge",children:s("tasks.mergeStrategyMerge")}),(0,r.jsx)("option",{value:"squash",children:s("tasks.mergeStrategySquash")})]})]}),(0,r.jsxs)("div",{style:y,children:[(0,r.jsx)("span",{style:{fontSize:12},children:s("tasks.settingsDeleteWorktree")}),(0,r.jsx)("input",{type:"checkbox",checked:d.deleteWorktreeDefault,onChange:e=>f("deleteWorktreeDefault",e.target.checked),style:{accentColor:"var(--accent)"}})]}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:12},children:s("tasks.settingsPreflightCommand")}),(0,r.jsx)("input",{value:d.preflightCommand??"",onChange:e=>f("preflightCommand",e.target.value||null),placeholder:s("tasks.settingsPreflightPlaceholder"),style:{...v,fontFamily:"var(--font-mono)",fontSize:11}})]}),(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:12},children:s("tasks.settingsInitCommand")}),(0,r.jsx)("input",{value:d.initCommand??"",onChange:e=>f("initCommand",e.target.value||null),placeholder:s("tasks.settingsInitPlaceholder"),style:{...v,fontFamily:"var(--font-mono)",fontSize:11}})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,paddingTop:4},children:[(0,r.jsx)("span",{style:{fontSize:12,fontWeight:500},children:s("tasks.settingsStagePrompts")}),c_.map(e=>(0,r.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-muted)"},children:s(`tasks.stage.${e}`)}),(0,r.jsx)("input",{value:d.stagePrompts?.[e]??"",onChange:t=>f("stagePrompts",{...d.stagePrompts??{},[e]:t.target.value}),style:{...v,fontSize:11}})]},e))]}),p&&(0,r.jsx)("button",{type:"button",onClick:()=>void k(),style:{alignSelf:"flex-start",padding:"6px 12px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text-muted)",fontSize:12,cursor:"pointer"},children:s("tasks.settingsReset")})]}):(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",padding:8},children:s("tasks.settingsNoProject")}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),style:{padding:"8px 14px",borderRadius:8,background:"none",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,cursor:"pointer"},children:s("i18n.cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>void x(),disabled:!a||g,style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:s("tasks.save")})]})]})]})})}function cV({open:e,onOpenChange:t,task:o}){let{t:s}=(0,A.s)();return((0,n.useEffect)(()=>{if(!e)return},[e,o]),e&&o)?(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:970,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onMouseDown:e=>{e.target===e.currentTarget&&t(!1)},children:(0,r.jsxs)("div",{style:{width:"min(520px, calc(100vw - 48px))",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"0 16px 48px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 0"},children:[(0,r.jsx)("h3",{style:{fontSize:15,fontWeight:600,margin:0},children:s("tasks.sessionTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),"aria-label":s("i18n.close"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:(0,r.jsx)(h.X,{size:16,"aria-hidden":"true"})})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:"14px 16px 16px",fontSize:12},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:10},children:[(0,r.jsx)("span",{style:{color:"var(--text-muted)"},children:s("tasks.sessionId")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,overflowWrap:"anywhere"},children:o.conversationId??"—"})]}),o.sessionFile?(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,padding:10},children:[(0,r.jsx)("span",{style:{color:"var(--text-muted)"},children:s("tasks.sessionFile")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,overflowWrap:"anywhere"},children:o.sessionFile})]}):null,(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.6},children:s("tasks.sessionHint")}),(0,r.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:4},children:(0,r.jsx)("button",{type:"button",onClick:()=>t(!1),style:{padding:"8px 16px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:s("i18n.close")})})]})]})}):null}let cK="__all__",cG="pi-tasks-board-filter",cJ={showCanceled:!1,showArchived:!1},cY="pi:open-task-settings";function cX(){let{t:e}=(0,A.s)(),{attentionCount:t}=ck();return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,height:36,flexShrink:0,padding:"0 16px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,r.jsxs)("h1",{style:{margin:0,display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:600},children:[(0,r.jsx)(lu.x,{size:15,color:"var(--text-muted)","aria-hidden":"true"}),e("tasks.title"),(0,r.jsx)("span",{style:{borderRadius:999,background:"rgba(37,99,235,0.12)",color:"var(--accent)",padding:"1px 8px",fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Beta"})]}),t>0?(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,borderRadius:999,background:"rgba(239,68,68,0.12)",color:"#dc2626",padding:"1px 8px",fontSize:10,fontWeight:700},children:[t," ",e("tasks.attentionBadge")]}):null,(0,r.jsx)("div",{style:{flex:1}}),(0,r.jsxs)("button",{type:"button",onClick:()=>window.dispatchEvent(new Event(cY)),style:{display:"inline-flex",alignItems:"center",gap:5,height:26,padding:"0 10px",borderRadius:7,background:"none",border:"none",color:"var(--text-muted)",fontSize:12,cursor:"pointer"},title:e("tasks.settingsTitle"),children:[(0,r.jsx)(cb.O,{size:13,"aria-hidden":"true"}),e("tasks.settingsTitle")]})]})}function cZ({activeProject:e}){let{t}=(0,A.s)(),{tasks:s,projects:i,refetch:a}=ck(),[l,d]=(0,n.useState)(null),[c,u]=(0,n.useState)(()=>(function(){try{let e=window.localStorage.getItem(cG);if(e){let t=JSON.parse(e);return{showCanceled:t.showCanceled??!1,showArchived:t.showArchived??!1}}}catch{}return cJ})()),[h,g]=(0,n.useState)(!1);(0,n.useEffect)(()=>{try{window.localStorage.setItem(cG,JSON.stringify(c))}catch{}},[c]);let[m,f]=(0,n.useState)(null),[x,k]=(0,n.useState)(!1),y=(0,n.useRef)(null),b=(0,n.useRef)({x:0,y:0}),w=(0,n.useRef)(null),j=(0,n.useRef)(null),[S,C]=(0,n.useState)(null),T=(0,n.useRef)(null);T.current=S;let R=(0,n.useRef)(!1),z=(0,n.useRef)(!1),[I,M]=(0,n.useState)(()=>Date.now());(0,n.useEffect)(()=>{let e=window.setInterval(()=>M(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let[P,E]=(0,n.useState)(!1),[W,F]=(0,n.useState)(null),[D,N]=(0,n.useState)(null);(0,n.useEffect)(()=>{let e=()=>{let e,t=(e=nP,nP=null,e);t&&(F(null),N(t),E(!0))};return e(),window.addEventListener(nM,e),()=>window.removeEventListener(nM,e)},[]);let[L,$]=(0,n.useState)(null),[H,O]=(0,n.useState)(null),[B,U]=(0,n.useState)(!1),[_,q]=(0,n.useState)(null),[V,K]=(0,n.useState)(!1),[G,J]=(0,n.useState)(null),[Y,X]=(0,n.useState)("retry"),[Z,Q]=(0,n.useState)(!1),[ee,et]=(0,n.useState)(null),[eo,er]=(0,n.useState)(!1),[en,es]=(0,n.useState)(!1),[ei,ea]=(0,n.useState)(null),[el,ed]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=()=>es(!0);return window.addEventListener(cY,e),()=>window.removeEventListener(cY,e)},[]);let ec=(0,n.useMemo)(()=>null==l?s:s.filter(e=>e.projectRoot===l),[s,l]),ep=(0,n.useMemo)(()=>(function(e,t,o=!1){let r={todo:[],inProgress:[],attention:[],done:[]};for(let n of e)("canceled"!==n.status||t)&&(null==n.archivedAt||o)&&r[function(e){switch(e){case"todo":case"queued":return"todo";case"preparing":case"running":return"inProgress";case"awaiting_input":case"review":case"merging":case"failed":return"attention";case"done":case"canceled":return"done"}}(n.status)].push(n);for(let e of cS)r[e].sort((e,t)=>(t.updatedAt??"").localeCompare(e.updatedAt??""));return r})(ec,c.showCanceled,c.showArchived),[ec,c]),eu=(0,n.useMemo)(()=>{let e=ep.todo;if(null==S)return e;let t=new Map(e.map(e=>[e.id,e])),o=S.flatMap(e=>t.get(e)??[]);for(let t of e)S.includes(t.id)||o.push(t);return o},[ep.todo,S]),eh=(0,n.useMemo)(()=>s.find(e=>e.id===L)??null,[s,L]),eg=(0,n.useMemo)(()=>s.find(e=>e.id===ei)??null,[s,ei]),em=(0,n.useCallback)(async e=>{try{await e()}catch(e){console.error("task action failed",e)}finally{a()}},[a]),ef=(0,n.useCallback)(e=>{null!=e.conversationId&&(ea(e.id),ed(!0))},[ea,ed]),ex=(0,n.useCallback)(e=>{O(e),U(!0)},[O,U]),ek=(0,n.useCallback)(()=>{F(null),E(!0)},[F,E]),ev=(0,n.useCallback)((e,t)=>{let o=w.current,r=y.current;o&&r&&(o.style.transform=`translate3d(${e-r.dx}px, ${t-r.dy}px, 0)`)},[]),ey=e=>{let t=e.currentTarget.getBoundingClientRect();y.current={dx:e.clientX-t.left,dy:e.clientY-t.top,width:t.width}},eb=(0,n.useCallback)(e=>{if(f(null),k(!1),e){R.current=!1;return}requestAnimationFrame(()=>{R.current=!1})},[f,k]),ew=(0,n.useCallback)(()=>{z.current=!0,C(null),eb(!0)},[eb,C]);(0,n.useEffect)(()=>{if(!m)return;let e=()=>{document.hidden&&ew()};return window.addEventListener("blur",ew),document.addEventListener("visibilitychange",e),()=>{window.removeEventListener("blur",ew),document.removeEventListener("visibilitychange",e)}},[m,ew]),(0,n.useEffect)(()=>{m&&!eu.some(e=>e.id===m.task.id)&&ew()},[m,eu,ew]);let ej=(0,n.useCallback)((e,t,o)=>{if(z.current){eb(!0),C(null);return}let r=j.current?.getBoundingClientRect(),n=null!=r&&t>=r.left&&t<=r.right&&o>=r.top&&o<=r.bottom;if(eb(!1),n){C(null);let t=s.find(t=>t.id===e.id);t?.status==="todo"&&null!=l&&em(()=>(0,sS.oQ)(e.id,e.projectRoot,"start"));return}let i=T.current;null!=l&&null!=i&&(async()=>{try{await (0,sS.Lu)(l,i)}catch(e){console.error("reorder failed",e)}await a(),C(null)})()},[em,eb,l,a,s]),eS=(0,n.useCallback)(()=>{em(async()=>{let e=await (0,sS.a5)(l);e>0&&console.log(`started ${e} tasks`)})},[em,l]),eC=(0,n.useCallback)(()=>{let e=ep.done.filter(e=>null==e.archivedAt);0!==e.length&&em(()=>Promise.all(e.map(e=>(0,sS.et)(e.id,e.projectRoot,!0))))},[em,ep.done]),eT=+(c.showCanceled!==cJ.showCanceled)+ +(c.showArchived!==cJ.showArchived),eR=s.length>0,ez=(0,n.useMemo)(()=>{let t=new Set(i);return e&&t.add(e),[...t].sort()},[i,e]),eI=(0,n.useMemo)(()=>{let e=new Map;for(let t of ez)e.set(t,t.split("/").filter(Boolean).pop()??t);return e},[ez]);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[eR&&(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8,padding:"14px 16px 8px"},children:[(0,r.jsxs)("select",{value:l??cK,onChange:e=>d(e.target.value===cK?null:e.target.value),style:{height:30,borderRadius:999,padding:"0 10px",background:"var(--bg-panel)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontWeight:500,cursor:"pointer",maxWidth:"14rem"},"aria-label":t("tasks.allFolders"),children:[(0,r.jsx)("option",{value:cK,children:t("tasks.allFolders")}),ez.map(e=>(0,r.jsx)("option",{value:e,children:eI.get(e)??e},e))]}),(0,r.jsxs)("div",{style:{position:"relative"},children:[(0,r.jsxs)("button",{type:"button",onClick:()=>g(e=>!e),style:{display:"inline-flex",alignItems:"center",gap:6,height:30,borderRadius:999,padding:"0 12px",background:"var(--bg-panel)",border:"1px solid var(--border)",color:"var(--text)",fontSize:12,fontWeight:500,cursor:"pointer"},children:[(0,r.jsx)(cw.n,{size:13,"aria-hidden":"true"}),t("tasks.filter"),eT>0?(0,r.jsx)("span",{style:{borderRadius:999,background:"rgba(37,99,235,0.12)",color:"var(--accent)",padding:"1px 6px",fontSize:10,fontWeight:700},children:eT}):null]}),h&&(0,r.jsx)("div",{style:{position:"absolute",top:34,left:0,zIndex:50,width:200,borderRadius:12,padding:6,background:"var(--bg-panel)",border:"1px solid var(--border)",boxShadow:"0 8px 24px rgba(0,0,0,0.16)"},children:[["showCanceled",t("tasks.showCanceled")],["showArchived",t("tasks.showArchived")]].map(([e,t])=>(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:8,cursor:"pointer",fontSize:12},children:[(0,r.jsx)("input",{type:"checkbox",checked:c[e],onChange:t=>u(o=>({...o,[e]:t.target.checked})),style:{accentColor:"var(--accent)"}}),t]},e))})]}),(0,r.jsx)("div",{style:{flex:1}}),(0,r.jsxs)("button",{type:"button",onClick:eS,style:{display:"inline-flex",alignItems:"center",gap:6,height:30,borderRadius:999,padding:"0 12px",background:"none",border:"none",color:"var(--text)",fontSize:12,cursor:"pointer"},title:t("tasks.startAll"),children:[(0,r.jsx)(cj.j,{size:13,"aria-hidden":"true"}),t("tasks.startAll")]}),(0,r.jsxs)("button",{type:"button",onClick:ek,style:{display:"inline-flex",alignItems:"center",gap:6,height:30,borderRadius:999,padding:"0 14px",background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:[(0,r.jsx)(v.F,{size:13,weight:"bold","aria-hidden":"true"}),t("tasks.new")]})]}),eR?(0,r.jsx)("div",{style:{flex:1,minHeight:0,overflowX:"auto"},children:(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:16,minWidth:"56rem",height:"100%",padding:"4px 16px 16px"},children:cR.map(e=>{let o="todo"===e?eu:ep[e],n=cz[e],s=e=>(0,r.jsx)(cF,{task:e,folderName:e.projectRoot?eI.get(e.projectRoot)??null:null,now:I,onOpen:()=>{R.current||$(e.id)},onStart:()=>void em(()=>(0,sS.oQ)(e.id,e.projectRoot,"start")),onCancel:()=>{q(e),K(!0)},onRetry:()=>{J(e),X("retry"),Q(!0)},onRequeue:()=>{J(e),X("requeue"),Q(!0)},onViewSession:()=>ef(e),onMerge:()=>{cC(e)?(et(e),er(!0)):ex(e)},onArchive:()=>void em(()=>(0,sS.et)(e.id,e.projectRoot,null==e.archivedAt)),onEdit:()=>{F(e),E(!0)}},e.id);return(0,r.jsxs)("div",{ref:"inProgress"===e?j:void 0,style:{display:"flex",flexDirection:"column",minHeight:0,gap:8},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,height:24,flexShrink:0,padding:"0 2px"},children:[(0,r.jsx)("span",{style:{width:3,height:14,borderRadius:999,background:n.marker,flexShrink:0},"aria-hidden":"true"}),(0,r.jsx)("h2",{style:{fontSize:12,fontWeight:600,color:"var(--text)"},children:t(`tasks.col${e[0].toUpperCase()}${e.slice(1)}`)}),(0,r.jsx)("span",{style:{borderRadius:999,background:"var(--bg-hover)",padding:"1px 8px",fontSize:10,fontWeight:600,color:"var(--text-muted)"},children:o.length}),(0,r.jsx)("div",{style:{flex:1}}),"done"===e&&ep.done.some(e=>null==e.archivedAt)?(0,r.jsx)("button",{type:"button",onClick:eC,style:{background:"none",border:"none",cursor:"pointer",fontSize:11,color:"var(--text-muted)",padding:"2px 6px",borderRadius:6},children:t("tasks.archiveAllDone")}):null]}),0===o.length?(0,r.jsx)("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:4,borderRadius:12,border:"1px dashed var(--border)",padding:16,textAlign:"center",..."inProgress"===e&&m?x?{borderColor:"var(--accent)",background:"rgba(37,99,235,0.08)"}:{borderColor:"var(--accent)"}:{}},children:(0,r.jsx)("p",{style:{fontSize:12,color:"var(--text-muted)"},children:t(`tasks.emptyCol${e[0].toUpperCase()}${e.slice(1)}`)})}):(0,r.jsx)("div",{style:{flex:1,minHeight:0,overflowY:"auto",borderRadius:12,transition:"background 0.15s, box-shadow 0.15s",..."inProgress"===e&&m?x?{background:"rgba(37,99,235,0.06)",boxShadow:"inset 0 0 0 2px var(--accent)"}:{boxShadow:"inset 0 0 0 1px rgba(37,99,235,0.25)"}:{}},children:(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:16,paddingBottom:4},children:o.map(t=>"todo"===e?(0,r.jsx)("div",{draggable:!0,onDragStart:e=>{var o,r;e.dataTransfer.effectAllowed="move",o=e.clientX,r=e.clientY,R.current=!0,z.current=!1,b.current={x:o,y:r},f({task:t,width:y.current?.width??280})},onDrag:e=>{var t,o;let r,n;return b.current={x:t=e.clientX,y:o=e.clientY},ev(t,o),void((n=null!=(r=j.current?.getBoundingClientRect())&&t>=r.left&&t<=r.right&&o>=r.top&&o<=r.bottom)!==x&&k(n))},onDragEnd:e=>ej(t,e.clientX,e.clientY),onPointerDown:ey,style:{cursor:"grab",opacity:m?.task.id===t.id?.4:1},children:s(t)},t.id):(0,r.jsx)("div",{children:s(t)},t.id))})})]},e)})})}):(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,padding:32,textAlign:"center"},children:[(0,r.jsx)(lu.x,{size:40,color:"var(--text-dim)",opacity:.4,"aria-hidden":"true"}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("p",{style:{fontSize:14,fontWeight:500,color:"var(--text)"},children:t("tasks.empty")}),(0,r.jsx)("p",{style:{maxWidth:320,fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:t("tasks.emptyHint")})]}),(0,r.jsxs)("button",{type:"button",onClick:ek,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 14px",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:[(0,r.jsx)(v.F,{size:13,weight:"bold","aria-hidden":"true"}),t("tasks.new")]})]}),(0,r.jsx)(cO,{open:P,onOpenChange:E,task:W,defaultProject:D?.projectRoot??l??e??null,projects:ez,prefillTitle:D?D.text.slice(0,80):void 0,prefillPrompt:D?D.text:void 0,onSubmit:async(e,t,r)=>{await em(async()=>{let{createTaskApi:n}=await Promise.resolve().then(o.bind(o,23084)),{updateTaskApi:s}=await Promise.resolve().then(o.bind(o,23084));W?await s(W.id,e,{title:t,config:r}):await n({projectRoot:e,title:t,config:r})}),E(!1),N(null)}}),(0,r.jsx)(c$,{open:null!=L,onOpenChange:e=>{e||$(null)},task:eh,onViewSession:ef,onMerge:ex,onEdit:e=>{F(e),E(!0)},onCancel:e=>{q(e),K(!0)},onRetry:e=>{J(e),X("retry"),Q(!0)},onRequeue:e=>{J(e),X("requeue"),Q(!0)},onComplete:e=>{et(e),er(!0)}}),(0,r.jsx)(cB,{open:B,onOpenChange:U,task:H}),(0,r.jsx)(cD,{open:V,onOpenChange:K,task:_}),(0,r.jsx)(cU,{open:Z,onOpenChange:Q,task:G,kind:Y}),(0,r.jsx)(cA,{open:eo,onOpenChange:er,task:ee}),(0,r.jsx)(cV,{open:el&&null!=eg,onOpenChange:ed,task:eg}),(0,r.jsx)(cq,{open:en,onOpenChange:es,projectRoot:l}),m?(0,p.createPortal)((0,r.jsx)("div",{ref:w,style:{position:"fixed",left:0,top:0,zIndex:999,pointerEvents:"none",width:m.width,willChange:"transform"},"aria-hidden":"true",children:(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8,borderRadius:12,border:x?"1px solid var(--accent)":"1px solid var(--border)",background:"var(--bg-panel)",padding:12,boxShadow:"0 8px 24px rgba(0,0,0,0.2)",transform:"rotate(-1deg)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8},children:[(0,r.jsx)("span",{style:{minWidth:0,overflowWrap:"break-word",fontSize:13,fontWeight:500},children:m.task.title}),(0,r.jsx)(cE,{task:m.task})]}),x?(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,color:"var(--accent)"},children:[(0,r.jsx)(cj.j,{size:11,weight:"bold","aria-hidden":"true"}),t("tasks.dropToStart")]}):null]})}),document.body):null]})}var cQ=o(62235),c0=o(1022);function c1(){return!!window.__TAURI_INTERNALS__}let c2=null;function c4(){return c2||(c2=o.e(8518).then(o.bind(o,38518)).then(e=>e.getCurrentWindow())),c2}async function c6(e){let t=await c4();await e(t)}async function c8(){await c6(e=>e.minimize())}async function c5(){await c6(e=>e.toggleMaximize())}async function c3(){await c6(e=>e.startDragging())}async function c7(){await c6(e=>e.close())}async function c9(){return(await c4()).isMaximized()}function pe(){let[e,t]=(0,n.useState)(null);return(0,n.useEffect)(()=>{c1()&&t(function(){if("u"<typeof navigator)return null;let e=navigator.platform||"";return/mac/i.test(e)?"macos":/win/i.test(e)?"windows":/linux/i.test(e)?"linux":null}())},[]),{platform:e,isDesktop:null!==e,isMacOS:"macos"===e,dragRegionProps:e?{"data-tauri-drag-region":!0}:{}}}let pt="pi-web-island-pos";function po(e,t,o,r,n,s){return{x:Math.min(Math.max(0,e),Math.max(0,o-n)),y:Math.min(Math.max(0,t),Math.max(0,r-s))}}let pr={display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",borderRadius:7,transition:"background 0.12s, color 0.12s"};function pn({onRefreshSession:e}={}){let{t:t}=(0,A.s)(),{isDark:o}=o9(),{isDesktop:s,isMacOS:i}=pe(),a=s&&!i,[l,d]=(0,n.useState)(!1),[c,p]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),g=(0,n.useRef)(null),m=(0,n.useRef)(null);(0,n.useEffect)(()=>{a&&c4().then(()=>void 0,e=>{throw c2=null,e}).catch(e=>{console.error("[DynamicIsland] window API preload failed:",e)})},[a]);let f=(0,n.useCallback)(e=>{e().catch(e=>{console.error("[DynamicIsland] window command failed:",e),p(String(e)),window.setTimeout(()=>p(null),4e3)})},[]),x=(0,n.useCallback)(()=>{window.location.reload()},[]);(0,n.useEffect)(()=>{if(!c1()||!a)return;let e=()=>{c9().then(d)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a]),(0,n.useEffect)(()=>{if(a)try{let e=localStorage.getItem(pt);if(e){let t=JSON.parse(e);"number"==typeof t.x&&"number"==typeof t.y&&h(po(t.x,t.y,window.innerWidth,window.innerHeight,168,34))}}catch{}},[a]),(0,n.useEffect)(()=>{if(a&&u)try{localStorage.setItem(pt,JSON.stringify(u))}catch{}},[u,a]);let[k,v]=(0,n.useState)(0);(0,n.useEffect)(()=>{if(!a)return;let e=()=>{v(window.innerWidth),h(e=>e?po(e.x,e.y,window.innerWidth,window.innerHeight,168,34):e)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a]);let y=(0,n.useCallback)(e=>{if(0!==e.button||e.target.closest?.("[data-island-btn]"))return;let t=g.current;if(!t)return;let o=t.getBoundingClientRect();m.current={startX:e.clientX,startY:e.clientY,origX:o.left,origY:o.top},e.currentTarget.setPointerCapture(e.pointerId)},[]),b=(0,n.useCallback)(e=>{let t=m.current;if(!t)return;let o=e.clientX-t.startX,r=e.clientY-t.startY;h(po(t.origX+o,t.origY+r,window.innerWidth,window.innerHeight,168,34))},[]),w=(0,n.useCallback)(e=>{m.current=null;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}},[]),j=(0,n.useCallback)(()=>c5().then(()=>{d(e=>!e)}),[]),S=(0,n.useCallback)(e=>{if(!m.current&&!e.target.closest?.("[data-island-btn]")){h(null);try{localStorage.removeItem(pt)}catch{}}},[]);if(!a)return null;let T=k||window.innerWidth,R=null!==u?u.x:Math.max(0,T-168-14);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{ref:g,role:"toolbar","aria-label":t("desktop.islandLabel"),title:t("desktop.islandResetHint"),onPointerDown:y,onPointerMove:b,onPointerUp:w,onPointerCancel:w,onDoubleClick:S,onMouseDown:e=>e.stopPropagation(),onDoubleClickCapture:e=>e.stopPropagation(),style:{position:"fixed",top:null!==u?u.y:100,left:R,zIndex:700,display:"flex",alignItems:"center",gap:1,padding:"3px 5px",borderRadius:999,background:"color-mix(in srgb, var(--bg-panel) 88%, transparent)",border:"1px solid var(--border)",boxShadow:o?"0 6px 24px rgba(0,0,0,0.45)":"0 6px 20px rgba(0,0,0,0.12)",cursor:"grab",userSelect:"none",touchAction:"none"},children:[(0,r.jsx)("span",{"data-island-grip":!0,"aria-hidden":"true",title:t("desktop.islandDrag"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:12,height:26,flexShrink:0,marginRight:2,color:"var(--text-dim)",cursor:"grab"},children:(0,r.jsxs)("svg",{width:"6",height:"14",viewBox:"0 0 6 14",fill:"currentColor","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"1.5",cy:"2",r:"1.2"}),(0,r.jsx)("circle",{cx:"4.5",cy:"2",r:"1.2"}),(0,r.jsx)("circle",{cx:"1.5",cy:"7",r:"1.2"}),(0,r.jsx)("circle",{cx:"4.5",cy:"7",r:"1.2"}),(0,r.jsx)("circle",{cx:"1.5",cy:"12",r:"1.2"}),(0,r.jsx)("circle",{cx:"4.5",cy:"12",r:"1.2"})]})}),e&&(0,r.jsx)("button",{type:"button","data-island-btn":!0,"aria-label":t("desktop.refreshSession"),title:t("desktop.refreshSession"),onClick:()=>{try{e()}catch(e){console.error("[DynamicIsland] refresh session failed:",e)}},style:pr,onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(c0.P,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button","data-island-btn":!0,"aria-label":t("desktop.reloadPage"),title:t("desktop.reloadPage"),onClick:x,style:pr,onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(C.S,{size:13,"aria-hidden":"true"})}),(0,r.jsx)("span",{"aria-hidden":"true",style:{width:1,height:18,flexShrink:0,background:"var(--border)",margin:"0 3px"}}),(0,r.jsx)("button",{type:"button","data-island-btn":!0,"aria-label":t("desktop.minimize"),title:t("desktop.minimize"),onClick:()=>f(c8),style:pr,onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1",children:(0,r.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})})}),(0,r.jsx)("button",{type:"button","data-island-btn":!0,"aria-label":t(l?"desktop.restore":"desktop.maximize"),title:t(l?"desktop.restore":"desktop.maximize"),onClick:()=>f(j),style:pr,onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:l?(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,r.jsx)("rect",{x:"2",y:"0.5",width:"7.5",height:"7.5"}),(0,r.jsx)("path",{d:"M0.5 2.5 V9.5 H7.5"})]}):(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1",children:(0,r.jsx)("rect",{x:"0.5",y:"0.5",width:"9",height:"9"})})}),(0,r.jsx)("button",{type:"button","data-island-btn":!0,"aria-label":t("desktop.close"),title:t("desktop.close"),onClick:()=>f(c7),style:pr,onMouseEnter:e=>{e.currentTarget.style.background="#e81123",e.currentTarget.style.color="#fff"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,r.jsx)("line",{x1:"0",y1:"0",x2:"10",y2:"10"}),(0,r.jsx)("line",{x1:"10",y1:"0",x2:"0",y2:"10"})]})})]}),c&&(0,r.jsx)("div",{role:"alert",style:{position:"fixed",top:(null!==u?u.y:100)+34+6,left:R,zIndex:700,maxWidth:280,padding:"5px 10px",borderRadius:8,background:"var(--bg-panel)",border:"1px solid var(--status-error, #f85149)",color:"var(--status-error, #f85149)",fontSize:11,lineHeight:1.5,wordBreak:"break-all",boxShadow:o?"0 6px 24px rgba(0,0,0,0.45)":"0 6px 20px rgba(0,0,0,0.12)",pointerEvents:"none"},children:c})]})}function ps(){try{return window.localStorage}catch{return null}}let pi="pi-web:desktop-server-hint-seen";function pa(e=ps()){if(e)try{e.setItem(pi,"1")}catch{}}function pl(){let{t:e}=(0,A.s)(),[t,o]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=!1;try{e=new URLSearchParams(window.location.search).has("piweb_connected")}catch{e=!1}e&&function(e=ps()){if(!e)return!1;try{return"1"!==e.getItem(pi)}catch{return!1}}()&&o(!0)},[]);let s=(0,n.useCallback)(()=>{pa(),o(!1)},[]),i=(0,n.useCallback)(()=>{pa(),o(!1),window.location.href="piweb-switch://manage"},[]);return t?(0,r.jsxs)("div",{role:"status",style:{position:"fixed",top:56,right:16,zIndex:700,width:288,padding:"14px 16px 14px",borderRadius:12,background:"var(--bg-panel)",border:"1px solid var(--border)",boxShadow:"0 12px 36px rgba(0,0,0,0.32)",color:"var(--text)"},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",top:-6,right:28,width:10,height:10,background:"var(--bg-panel)",borderTop:"1px solid var(--border)",borderLeft:"1px solid var(--border)",transform:"rotate(45deg)"}}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[(0,r.jsx)(a_.X,{size:18,color:"var(--accent)",style:{flexShrink:0,marginTop:1}}),(0,r.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,r.jsx)("div",{style:{fontSize:13.5,fontWeight:600,lineHeight:1.45},children:e("desktop.serverHintTitle")}),(0,r.jsx)("p",{style:{margin:"6px 0 0",fontSize:12.5,lineHeight:1.65,color:"var(--text-muted)"},children:e("desktop.serverHintBody")})]}),(0,r.jsx)("button",{type:"button",onClick:s,"aria-label":e("desktop.serverHintDismiss"),title:e("desktop.serverHintDismiss"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,flexShrink:0,background:"none",border:"none",cursor:"pointer",color:"var(--text-dim)"},children:(0,r.jsx)(h.X,{size:14,"aria-hidden":"true"})})]}),(0,r.jsx)("button",{type:"button",onClick:i,style:{marginTop:12,width:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 12px",borderRadius:9,background:"var(--accent)",border:"none",color:"#fff",fontSize:13,fontWeight:600,cursor:"pointer"},children:e("desktop.serverHintAction")})]}):null}function pd({isDark:e,toggleTheme:t,translate:o}){let[s,i]=(0,n.useState)(!1);(0,n.useEffect)(()=>{i(!0)},[]);let a=o(s?e?"desktop.switchToLight":"desktop.switchToDark":"desktop.switchToLight");return(0,r.jsx)("button",{className:"app-no-drag",suppressHydrationWarning:!0,onClick:e=>{let o=e.currentTarget.getBoundingClientRect();t({x:o.left+o.width/2,y:o.top+o.height/2})},title:a,"aria-label":a,"aria-pressed":!s||e,style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:s?e?(0,r.jsx)(lo.b,{size:16,"aria-hidden":"true"}):(0,r.jsx)(lt.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(lo.b,{size:16,"aria-hidden":"true"})})}function pc({topBarRef:e,sidebarOpen:t,onSidebarToggle:o,isDark:s,toggleTheme:i,isMobile:a,showTasks:l,tasksBoardEnabled:d,onToggleTasks:c,systemPrompt:p,activeTopPanel:u,topPanelPos:h,sessionStats:g,selectedSession:f,contextUsage:x,copiedSessionField:k,onCopySessionField:v,rightPanelOpen:y,onToggleFilePanel:b,onRefreshSession:j,onOpenSettings:S,sessionTitle:T,onWorkspaceControlsHostChange:R,onTitleRightHostChange:z,desktopChrome:I,windowDrag:M}){let P,E,W,F,D,N,L,$,H,O,B,{t:U}=(0,A.s)(),[_,q]=(0,n.useState)(!1),[V,K]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{try{K(new URLSearchParams(window.location.search).has("piweb_connected"))}catch{K(!1)}},[]),(0,r.jsxs)(r.Fragment,{children:[V&&(0,r.jsx)(pl,{}),(0,r.jsxs)("div",{ref:e,className:"app-title-bar",...I?.dragRegionProps,...M,style:{display:"flex",alignItems:"center",flexShrink:0,borderBottom:"1px solid var(--border)",height:48,background:"var(--bg-panel)",position:"relative",zIndex:600,paddingLeft:76*!!I?.isMacOS},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",minWidth:0,height:"100%",flex:"0 1 auto",position:"relative",zIndex:1},children:[(0,r.jsx)("button",{className:"app-no-drag",onClick:o,title:t?U("desktop.hideSidebar"):U("desktop.showSidebar"),"aria-label":t?U("desktop.hideSidebar"):U("desktop.showSidebar"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:t?(0,r.jsx)(cQ.V,{size:16,"aria-hidden":"true"}):(0,r.jsx)(w.B,{size:16,"aria-hidden":"true"})}),(0,r.jsx)("div",{className:"app-no-drag",ref:R,style:{flex:"0 1 auto",minWidth:0,maxWidth:"min(60vw, 820px)",height:"100%",display:"flex",alignItems:"center",padding:"0 8px 0 0",overflow:"visible"}})]}),(0,r.jsxs)("div",{className:"app-title-drag",style:{position:"absolute",left:"var(--pi-titlebar-sidebar-offset, 0px)",right:0,top:0,bottom:0,minWidth:0,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 12px",overflow:"hidden",userSelect:"none"},children:[T&&(0,r.jsx)("button",{type:"button",onClick:()=>{a&&q(!0)},title:a?T:void 0,style:{display:"block",flex:"0 1 auto",minWidth:0,maxWidth:"calc(100% - 320px)",fontSize:12,fontWeight:500,color:"var(--text-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",background:"none",border:"none",cursor:"pointer",padding:"2px 6px",borderRadius:5},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="none"},children:T}),(0,r.jsx)("div",{className:"app-no-drag",ref:z,style:{flexShrink:0,display:"flex",alignItems:"center",marginLeft:4}})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:3,minWidth:0,height:"100%",flexShrink:1,overflow:"hidden",marginLeft:"auto",position:"relative",zIndex:1},children:[!a&&d&&(0,r.jsx)("button",{className:"app-no-drag",onClick:c,title:l?U("desktop.hideTaskBoard"):U("desktop.showTaskBoard"),"aria-label":l?U("desktop.hideTaskBoard"):U("desktop.showTaskBoard"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:l?"var(--bg-selected)":"none",border:"none",color:l?"var(--text)":"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background=l?"var(--bg-selected)":"none",e.currentTarget.style.color=l?"var(--text)":"var(--text-muted)"},children:(0,r.jsx)(lu.x,{size:16,"aria-hidden":"true"})}),(0,r.jsx)("button",{className:"app-no-drag",onClick:b,title:y?U("desktop.hideFilePanel"):U("desktop.showFilePanel"),"aria-label":y?U("desktop.hideFilePanel"):U("desktop.showFilePanel"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:y?"var(--bg-selected)":"none",border:"none",color:y?"var(--text)":"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background=y?"var(--bg-selected)":"none",e.currentTarget.style.color=y?"var(--text)":"var(--text-muted)"},children:(0,r.jsx)(cQ.V,{size:16,"aria-hidden":"true",style:{transform:"scaleX(-1)"}})}),(0,r.jsx)(pd,{isDark:s,toggleTheme:i,translate:U}),V&&(0,r.jsx)("button",{className:"app-no-drag",type:"button",onClick:()=>{window.location.href="piweb-switch://manage"},title:U("desktop.serverSwitch"),"aria-label":U("desktop.serverSwitch"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(a_.X,{size:16,"aria-hidden":"true"})}),!V&&(0,r.jsx)("button",{className:"app-no-drag",type:"button",onClick:j,title:U("desktop.refreshSession"),"aria-label":U("desktop.refreshSession"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(C.S,{size:16,"aria-hidden":"true"})}),(0,r.jsx)("button",{className:"app-no-drag",type:"button",onClick:S,title:U("desktop.settings"),"aria-label":U("desktop.settings"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:(0,r.jsx)(cb.O,{size:16,"aria-hidden":"true"})})]})]}),(0,r.jsx)(pn,{onRefreshSession:j}),u&&h&&(0,r.jsxs)("div",{style:{position:"fixed",top:h.top,left:h.left,width:h.width,maxHeight:`calc(100dvh - ${h.top}px)`,overflowY:"auto",zIndex:500},children:["system"===u&&(0,r.jsx)("div",{style:{background:"var(--bg-panel)",borderBottom:"1px solid var(--border)"},children:p?(0,r.jsx)("div",{style:{maxHeight:"min(600px, 75vh)",overflowY:"auto",padding:"12px 16px",color:"var(--text-muted)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap",fontFamily:"var(--font-mono)"},children:p}):""===p?(0,r.jsx)("div",{style:{padding:"10px 16px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:"System prompt is empty (tools are disabled)"}):(0,r.jsx)("div",{style:{padding:"10px 16px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:"Send a message to load the system prompt"})}),"session"===u&&(0,r.jsx)("div",{style:{background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",boxShadow:"0 10px 28px rgba(0,0,0,0.10)",padding:"12px 16px"},children:g?(P=[...g.sessionName?[{label:U("desktop.name"),value:g.sessionName,copyField:null}]:[],{label:U("desktop.sessionInfoFile"),value:g.sessionFile??U("desktop.sessionInfoInMemory"),copyField:"file"},{label:U("desktop.sessionInfoId"),value:g.sessionId,copyField:"id"}],E=[[U("desktop.sessionInfoUser"),g.userMessages.toLocaleString()],[U("desktop.sessionInfoAssistant"),g.assistantMessages.toLocaleString()],[U("desktop.sessionInfoToolCalls"),g.toolCalls.toLocaleString()],[U("desktop.sessionInfoToolResults"),g.toolResults.toLocaleString()],[U("desktop.sessionInfoTotal"),g.totalMessages.toLocaleString()]],W=[[U("desktop.sessionInfoInput"),g.tokens.input.toLocaleString()],[U("desktop.sessionInfoOutput"),g.tokens.output.toLocaleString()],...g.tokens.cacheRead>0?[[U("desktop.sessionInfoCacheRead"),g.tokens.cacheRead.toLocaleString()]]:[],...g.tokens.cacheWrite>0?[[U("desktop.sessionInfoCacheWrite"),g.tokens.cacheWrite.toLocaleString()]]:[],[U("desktop.sessionInfoTotal"),g.tokens.total.toLocaleString()]],F=x??g.contextUsage,N=[...g.cost>0?[[U("desktop.sessionInfoCost"),`$${g.cost.toFixed(4)}`]]:[],...F?.contextWindow?[[U("desktop.sessionInfoContext"),`${null!==F.percent?`${F.percent.toFixed(1)}%`:"?"} / ${(D=F.contextWindow)>=1e6?`${(D/1e6).toFixed(1)}M`:D>=1e3?`${(D/1e3).toFixed(0)}k`:String(D)}`]]:[]],L=(e,t,o="left",n=!1)=>(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:700,color:"var(--text)",marginBottom:6},children:e}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:n?"max-content max-content":"auto minmax(0, 1fr)",columnGap:n?14:12,rowGap:4,justifyContent:n?"start":void 0},children:t.map(([t,s])=>(0,r.jsxs)("div",{style:{display:"contents"},children:[(0,r.jsx)("div",{style:{color:"var(--text-dim)",whiteSpace:"nowrap"},children:t}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",minWidth:0,overflowWrap:n?"normal":"anywhere",textAlign:o,whiteSpace:"right"===o?"nowrap":"normal"},children:s})]},`${e}:${t}`))})]}),$=(e,t)=>{let o=k===e;return(0,r.jsx)("button",{type:"button",title:o?U("desktop.copied"):U({file:"desktop.copyFilePath",id:"desktop.copySessionId",projectDir:"desktop.copyProjectDir",gitBranch:"desktop.copyGitBranch",gitWorktree:"desktop.copyGitWorktree"}[e]),onClick:()=>v(e,t),style:{alignSelf:"start",display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,marginTop:-2,color:o?"var(--accent)":"var(--text-dim)",background:"transparent",border:"1px solid var(--border)",borderRadius:4,cursor:"pointer",flex:"0 0 auto",transition:"color 0.12s, border-color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color=o?"var(--accent)":"var(--text-dim)",e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="transparent"},children:o?(0,r.jsx)(m.J,{size:12,"aria-hidden":"true"}):(0,r.jsx)(or.Q,{size:12,"aria-hidden":"true"})})},H=(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:700,color:"var(--text)",marginBottom:6},children:U("desktop.sessionInfoTitle")}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr) auto",columnGap:12,rowGap:8,alignItems:"start"},children:P.map(e=>(0,r.jsxs)("div",{style:{display:"contents"},children:[(0,r.jsx)("div",{style:{color:"var(--text-dim)",whiteSpace:"nowrap"},children:e.label}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",minWidth:0,overflowWrap:"anywhere",wordBreak:"break-word",whiteSpace:"normal"},children:e.value}),(0,r.jsx)("div",{children:e.copyField?$(e.copyField,e.value):null})]},`session-info:${e.label}`))})]}),B=(O=[...f?[{label:U("desktop.projectDir"),value:f.projectRoot??f.cwd,copyField:"projectDir"}]:[],...f?.branch?[{label:U("desktop.gitBranch"),value:f.branch,copyField:"gitBranch"}]:[],...f?.isWorktree?[{label:U("desktop.gitWorktree"),value:f.cwd,copyField:"gitWorktree"}]:[]]).length>0?(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:700,color:"var(--text)",marginBottom:6},children:U("desktop.projectSection")}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr) auto",columnGap:12,rowGap:8,alignItems:"start"},children:O.map(e=>(0,r.jsxs)("div",{style:{display:"contents"},children:[(0,r.jsx)("div",{style:{color:"var(--text-dim)",whiteSpace:"nowrap"},children:e.label}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",minWidth:0,overflowWrap:"anywhere",wordBreak:"break-word",whiteSpace:"normal"},children:e.value}),(0,r.jsx)("div",{children:e.copyField?$(e.copyField,e.value):null})]},`project-info:${e.label}`))})]}):null,(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:a?"1fr":"minmax(360px, 1.7fr) minmax(140px, 0.55fr) minmax(190px, 0.75fr)",gap:a?16:24,fontSize:12,lineHeight:1.5,fontFamily:"var(--font-mono)"},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:a?16:20,minWidth:0},children:[H,B]}),L(U("desktop.sessionInfoMessages"),E),L(U("desktop.sessionInfoTokens"),[...W,...N],"right",!0)]})):(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:U("desktop.sendMessageForSessionInfo")})})]}),_&&T&&(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:3e3,display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:48,background:"rgba(0,0,0,0.35)"},onMouseDown:e=>{e.target===e.currentTarget&&q(!1)},children:(0,r.jsx)("div",{role:"dialog","aria-label":T,style:{maxWidth:"min(560px, calc(100vw - 32px))",maxHeight:"min(60vh, 400px)",overflow:"auto",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:12,boxShadow:"0 16px 40px rgba(0,0,0,0.3)",padding:"14px 18px",fontSize:13,lineHeight:1.6,color:"var(--text)",wordBreak:"break-word",whiteSpace:"pre-wrap"},children:T})})]})}function pp({cwd:e,busy:t,error:o,onCancelAction:n,onConfirmAction:s}){let{t:i}=(0,A.s)();return(0,r.jsx)("div",{role:"presentation",style:{position:"fixed",inset:0,zIndex:1100,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(0, 0, 0, 0.4)"},onClick:e=>{t||e.target!==e.currentTarget||n()},children:(0,r.jsxs)("section",{role:"dialog","aria-modal":"true","aria-labelledby":"project-trust-title",style:{width:440,maxWidth:"100%",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg-panel)",boxShadow:"0 12px 36px rgba(0, 0, 0, 0.24)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:12,padding:"18px 18px 14px"},children:[(0,r.jsx)(nz.o,{size:21,weight:"duotone",color:"var(--accent-orange)",style:{flexShrink:0,marginTop:1},"aria-hidden":"true"}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("h2",{id:"project-trust-title",style:{margin:0,fontSize:15,fontWeight:700,color:"var(--text)"},children:i("desktop.trustProjectTitle")}),(0,r.jsx)("p",{style:{margin:"7px 0 0",fontSize:12,lineHeight:1.6,color:"var(--text-muted)"},children:i("desktop.trustProjectBody")}),(0,r.jsx)("code",{style:{display:"block",marginTop:10,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:11,overflowWrap:"anywhere"},children:e}),o&&(0,r.jsx)("div",{role:"alert",style:{marginTop:10,color:"var(--accent-red)",fontSize:12,lineHeight:1.5},children:o})]})]}),(0,r.jsxs)("footer",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"10px 18px",borderTop:"1px solid var(--border)"},children:[(0,r.jsx)("button",{type:"button",onClick:n,disabled:t,style:{height:32,padding:"0 12px",border:"1px solid var(--border)",borderRadius:5,background:"transparent",color:"var(--text-muted)",cursor:t?"not-allowed":"pointer",fontSize:12},children:i("desktop.cancel")}),(0,r.jsx)("button",{type:"button",onClick:s,disabled:t,style:{height:32,padding:"0 12px",border:"1px solid var(--accent)",borderRadius:5,background:"var(--accent)",color:"white",cursor:t?"wait":"pointer",opacity:t?.7:1,fontSize:12,fontWeight:600},children:i(t?"desktop.trustingProject":"desktop.trustProject")})]})]})})}function pu(e,t,o){let r=Number.isFinite(e)?e:t,n=Math.max(t,o);return Math.round(Math.max(t,Math.min(n,r)))}function ph(e){return pu(.42*e,360,640)}function pg(e,t){try{window.localStorage.setItem(e,String(t))}catch{}}function pm(e){let{ariaLabel:t,cssVariable:o,defaultWidth:r,getDefaultWidth:s,getMaxWidth:i,growthDirection:a,maxWidth:l,minWidth:d,storageKey:c,widthRef:p}=e,u=(0,n.useRef)(null),h=(0,n.useRef)(null),g=(0,n.useRef)(!1),[m,f]=(0,n.useState)(r),[x,k]=(0,n.useState)(!1),[v,y]=(0,n.useState)(!1);(0,n.useEffect)(()=>{y(!0)},[]);let b=(0,n.useCallback)(()=>Math.min(l,Math.max(d,i())),[i,l,d]),w=(0,n.useCallback)(e=>pu(e,d,b()),[b,d]),j=(0,n.useCallback)(e=>{p.current=e;let t=`${e}px`;u.current?.style.setProperty(o,t),u.current?.parentElement?.style.setProperty(o,t)},[o,p]),S=(0,n.useCallback)((e,t={})=>{let{forcePersist:o=!1,persist:r=!0}=t,n=w(e),s=n!==p.current;return j(n),f(n),r&&(s||o)&&pg(c,n),n},[j,w,c,p]),C=(0,n.useCallback)(e=>{document.body.style.cursor=e.previousCursor,document.body.style.userSelect=e.previousUserSelect},[]),T=(0,n.useCallback)(e=>{let t=h.current;if(t&&t.pointerId===e){h.current=null,C(t),k(!1),S(p.current,{forcePersist:!0});try{t.target.hasPointerCapture(e)&&t.target.releasePointerCapture(e)}catch{}}},[S,C,p]),R=(0,n.useCallback)(e=>{if("mouse"===e.pointerType&&0!==e.button)return;e.preventDefault(),e.stopPropagation();let t=h.current;t&&T(t.pointerId);let o=e.currentTarget;o.focus({preventScroll:!0}),o.setPointerCapture(e.pointerId),h.current={pointerId:e.pointerId,startX:e.clientX,startWidth:p.current,target:o,previousCursor:document.body.style.cursor,previousUserSelect:document.body.style.userSelect},document.body.style.cursor="col-resize",document.body.style.userSelect="none",k(!0)},[T,p]),z=(0,n.useCallback)(e=>{let t=h.current;if(!t||t.pointerId!==e.pointerId)return;if("mouse"===e.pointerType&&0===e.buttons)return void T(e.pointerId);e.preventDefault();let o="right"===a?1:-1,r=w(t.startWidth+(e.clientX-t.startX)*o);j(r),e.currentTarget.setAttribute("aria-valuenow",String(r)),e.currentTarget.setAttribute("aria-valuetext",`${r} px`)},[j,w,T,a]),I=(0,n.useCallback)(e=>{T(e.pointerId)},[T]),M=(0,n.useCallback)(e=>{T(e.pointerId)},[T]),P=(0,n.useCallback)(e=>{T(e.pointerId)},[T]),E=(0,n.useCallback)(()=>{S(s?.()??r,{forcePersist:!0})},[S,r,s]),W=(0,n.useCallback)(()=>{S(p.current)},[S,p]),F=(0,n.useCallback)(e=>{let t=e.shiftKey?32:12,o="right"===a?"ArrowRight":"ArrowLeft",r="right"===a?"ArrowLeft":"ArrowRight";e.key===o?(e.preventDefault(),S(p.current+t,{forcePersist:!0})):e.key===r?(e.preventDefault(),S(p.current-t,{forcePersist:!0})):"Home"===e.key?(e.preventDefault(),S(d,{forcePersist:!0})):"End"===e.key?(e.preventDefault(),S(b(),{forcePersist:!0})):"Enter"===e.key&&(e.preventDefault(),E())},[S,b,a,d,E,p]);return(0,n.useEffect)(()=>{if(g.current)return;g.current=!0;let e=function(e){try{let t=window.localStorage.getItem(e);if(null===t)return null;let o=Number.parseInt(t,10);return Number.isFinite(o)?o:null}catch{return null}}(c),t=S(e??s?.()??r,{persist:!1});null!==e&&e!==t&&pg(c,t)},[S,r,s,c]),(0,n.useEffect)(()=>{if(!g.current)return;S(p.current);let e=()=>{S(p.current)};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[S,p]),(0,n.useEffect)(()=>{if(!x)return;let e=()=>{let e=h.current;e&&T(e.pointerId)},t=()=>{"visible"!==document.visibilityState&&e()};return window.addEventListener("blur",e),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("blur",e),document.removeEventListener("visibilitychange",t)}},[T,x]),(0,n.useEffect)(()=>()=>{let e=h.current;e&&(h.current=null,C(e))},[C]),{isResizing:x,panelRef:u,reclampWidth:W,separatorProps:{"aria-label":t,"aria-orientation":"vertical","aria-valuemax":v?b():l,"aria-valuemin":d,"aria-valuenow":m,"aria-valuetext":`${m} px`,onDoubleClick:E,onKeyDown:F,onLostPointerCapture:P,onPointerCancel:M,onPointerDown:R,onPointerMove:z,onPointerUp:I,role:"separator",tabIndex:0},width:m}}function pf(e){return e.name||e.firstMessage||e.id.slice(0,12)}function px({status:e}){return"running"===e||"starting"===e?(0,r.jsxs)("svg",{className:"animate-spin",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),(0,r.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}):"failed"===e?(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"m9 9 6 6M15 9l-6 6"})]}):"aborted"===e||"interrupted"===e?(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M9 9h6v6H9z"})]}):(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"m8 12 3 3 5-6"})]})}function pk({session:e,main:t,selected:o,running:n,onSelect:s}){let{locale:i,t:a}=(0,A.s)(),l=e.relation?.kind==="subagent"?e.relation:null,d=n?"running":l?.status??"completed",c=t?a("agentSwitcher.main"):l?.description||pf(e),p=t?pf(e):`${l?.profile??a("agentSwitcher.subagent")} \xb7 ${function(e,t){let o=new Date(e).getTime();if(!Number.isFinite(o))return"";let r=Math.round((o-Date.now())/1e3),n=new Intl.RelativeTimeFormat(t,{numeric:"auto"});if(60>Math.abs(r))return n.format(r,"second");let s=Math.round(r/60);if(60>Math.abs(s))return n.format(s,"minute");let i=Math.round(s/60);return 24>Math.abs(i)?n.format(i,"hour"):n.format(Math.round(i/24),"day")}(e.modified,i)}`;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":o,onClick:s,style:{width:"100%",minHeight:56,display:"grid",gridTemplateColumns:"28px minmax(0, 1fr) auto",alignItems:"center",gap:9,padding:"7px 12px",border:"none",borderBottom:"1px solid var(--border)",borderLeft:o?"2px solid var(--accent)":"2px solid transparent",background:o?"var(--bg-selected)":"transparent",color:"var(--text)",cursor:"pointer",textAlign:"left"},onMouseEnter:e=>{o||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{o||(e.currentTarget.style.background="transparent")},children:[(0,r.jsx)("span",{style:{width:28,height:28,display:"grid",placeItems:"center",color:t?"var(--text-muted)":"var(--accent)"},children:t?(0,r.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"8",r:"4"}),(0,r.jsx)("path",{d:"M4 21a8 8 0 0 1 16 0"})]}):(0,r.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("rect",{x:"5",y:"7",width:"14",height:"11",rx:"2"}),(0,r.jsx)("path",{d:"M9 11h.01M15 11h.01M9 15h6M12 7V4M10 4h4"})]})}),(0,r.jsxs)("span",{style:{minWidth:0},children:[(0,r.jsx)("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,fontWeight:o?600:500},title:c,children:c}),(0,r.jsx)("span",{style:{display:"block",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontSize:11},title:p,children:p})]}),(0,r.jsx)("span",{style:{display:"flex",alignItems:"center",gap:6,color:t&&!n?"var(--text-dim)":"running"===d||"starting"===d?"var(--accent)":"completed"===d?"#16a34a":"failed"===d?"#dc2626":"aborted"===d?"#d97706":"var(--text-dim)",fontSize:11,whiteSpace:"nowrap"},children:t&&!n?o?a("agentSwitcher.current"):null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(px,{status:d}),(0,r.jsx)("span",{children:a(`agentSwitcher.status.${d}`)})]})})]})}function pv({rootSession:e,subagents:t,selectedSessionId:o,runningSessionIds:s,onSelectSession:i}){let{t:a}=(0,A.s)(),[l,d]=(0,n.useState)(""),c=(0,n.useMemo)(()=>[...t].sort((e,t)=>{let o=s.has(e.id);return o!==s.has(t.id)?o?-1:1:t.modified.localeCompare(e.modified)}),[s,t]),p=l.trim().toLowerCase(),u=p?c.filter(e=>{let t=e.relation?.kind==="subagent"?e.relation:null;return[t?.description,t?.profile,e.name,e.firstMessage].some(e=>e?.toLowerCase().includes(p))}):c,h=t.filter(e=>s.has(e.id)).length;return(0,r.jsx)("div",{role:"listbox","aria-label":a("agentSwitcher.title"),style:{background:"var(--bg-panel)",borderLeft:"1px solid var(--border)",borderRight:"1px solid var(--border)",borderBottom:"1px solid var(--border)",borderRadius:"0 0 6px 6px",boxShadow:"0 10px 28px rgba(0,0,0,0.10)",overflow:"hidden"},children:(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{minHeight:44,display:"flex",alignItems:"center",gap:8,padding:"7px 12px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("strong",{style:{fontSize:12,fontWeight:600},children:a("agentSwitcher.title")}),(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontSize:11},children:a("agentSwitcher.count",{count:t.length})}),h>0&&(0,r.jsx)("span",{style:{marginLeft:"auto",color:"var(--accent)",fontSize:11},children:a("agentSwitcher.runningCount",{count:h})})]}),t.length>8&&(0,r.jsx)("div",{style:{padding:8,borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("input",{type:"search",value:l,onChange:e=>d(e.target.value),placeholder:a("agentSwitcher.search"),"aria-label":a("agentSwitcher.search"),style:{width:"100%",height:32,padding:"0 10px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg)",color:"var(--text)",fontSize:12,outline:"none"}})}),(0,r.jsxs)("div",{style:{maxHeight:"min(58dvh, 480px)",overflowY:"auto"},children:[(0,r.jsx)(pk,{session:e,main:!0,selected:e.id===o,running:s.has(e.id),onSelect:()=>i(e)}),u.map(e=>(0,r.jsx)(pk,{session:e,selected:e.id===o,running:s.has(e.id),onSelect:()=>i(e)},e.id)),0===u.length&&(0,r.jsx)("div",{style:{padding:"22px 12px",color:"var(--text-dim)",fontSize:12,textAlign:"center"},children:a("agentSwitcher.noMatches")})]})]})})}function py(){var e;let t,o,l=(0,i.useRouter)(),d=(0,i.useSearchParams)(),c=(0,n.useMemo)(()=>{let e;return{requestedCwd:e=d.get("cwd")?.trim()||null,sessionId:e?null:d.get("session")}},[d]),{isDark:p,toggleTheme:u}=o9(),{t:h}=(0,A.s)(),g=O(),[m,f]=(0,n.useState)(null),[x,k]=(0,n.useState)(null),[v,y]=(0,n.useState)(0),[b,w]=(0,n.useState)(0),[j,S]=(0,n.useState)(0),[C,T]=(0,n.useState)(!1),[R,z]=(0,n.useState)("models"),[I,M]=(0,n.useState)(0),[P,E]=(0,n.useState)(null),[W,F]=(0,n.useState)(!1),[D,N]=(0,n.useState)(!1),[L,$]=(0,n.useState)(null),[H,B]=(0,n.useState)(!0),[U,_]=(0,n.useState)(!1);(0,n.useEffect)(()=>{g&&B(!1)},[g]),(0,n.useEffect)(()=>{_(!0)},[]);let q=(0,n.useRef)(null),V=(0,n.useRef)(null),[K,G]=(0,n.useState)(null),[J,Y]=(0,n.useState)(null),[X,Z]=(0,n.useState)(null),Q=pe(),ee=function(){let{isDesktop:e,isMacOS:t}=pe(),o=(0,n.useCallback)(e=>{var t;0===e.button&&(t=e.target).closest("[data-tauri-drag-region]")&&!t.closest('button, a, input, textarea, select, [role="button"], [contenteditable="true"], [data-no-drag]')&&(e.preventDefault(),e.stopPropagation(),2===e.detail?c5():c3())},[]);return e&&!t?{onMouseDown:o}:{}}(),[et,eo]=(0,n.useState)(null),er=(0,n.useCallback)(e=>{eo(e)},[]),[en,es]=(0,n.useState)(null),ei=(0,n.useCallback)(e=>{es(e)},[]),[ea,el]=(0,n.useState)(null),ed=(0,n.useRef)(null),ep=(0,n.useCallback)((e,t)=>{re(t).then(()=>{ed.current&&clearTimeout(ed.current),el(e),ed.current=setTimeout(()=>el(null),1400)})},[]);(0,n.useEffect)(()=>()=>{ed.current&&clearTimeout(ed.current)},[]);let[eu,eh]=(0,n.useState)(null),eg=(0,n.useCallback)(e=>{eh(e)},[]),[em,ef]=(0,n.useState)(null),[ex,ek]=(0,n.useState)(null),ev=(0,n.useCallback)(()=>{g&&B(!1),ef("session")},[g]),ey=(0,n.useCallback)(()=>{g&&ef(null),B(e=>!e)},[g]);(0,n.useEffect)(()=>{if(!em||!V.current)return;let e=()=>{let e=V.current.getBoundingClientRect();ek({top:e.bottom,left:e.left,width:e.width})};e();let t=new ResizeObserver(e);return t.observe(V.current),()=>t.disconnect()},[em]);let[eb,ew]=(0,n.useState)([]),[ej,eS]=(0,n.useState)(null),[eC,eT]=(0,n.useState)(!1),[eR,ez]=(0,n.useState)(!1),[eI,eM]=(0,n.useState)([]),[eP,eE]=(0,n.useState)(()=>new Set);(0,n.useEffect)(()=>{if(!eR)return;let e=!1,t=()=>{fetch("/api/sessions",{cache:"no-store"}).then(e=>e.json()).then(t=>{e||(eM(t.sessions??[]),eE(new Set(t.runningSessionIds??[])))}).catch(()=>{})};t();let o=setInterval(t,3e3);return()=>{e=!0,clearInterval(o)}},[eR,m?.id,v]);let eW=(0,n.useCallback)(async e=>{try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}`,{cache:"no-store"}),o=await t.json();if(!t.ok||!o.info)throw Error(o.error??`HTTP ${t.status}`);e9.current(o.info)}catch(e){console.error("[pi-web] failed to open session:",e instanceof Error?e.message:e)}},[]),eF=(0,n.useRef)(260),eD=(0,n.useRef)(ph(1366)),eA=(0,n.useCallback)(()=>ph(window.innerWidth),[]),eN=(0,n.useCallback)(()=>(function(e){let{viewportWidth:t,rightPanelOpen:o,rightPanelWidth:r}=e;if(t<=640)return 480;let n=t<960;return Math.min(480,t-(n?320:420)-(!n&&o?r:0))})({viewportWidth:window.innerWidth,rightPanelOpen:eC,rightPanelWidth:eD.current}),[eC]),eL=(0,n.useCallback)(()=>(function(e){let{viewportWidth:t,sidebarOpen:o,sidebarWidth:r}=e;return t<960?1200:Math.min(1200,t-420-(o?r:0))})({viewportWidth:window.innerWidth,sidebarOpen:H,sidebarWidth:eF.current}),[H]),e$=pm({ariaLabel:h("desktop.resizeSidebar"),cssVariable:"--sidebar-width",defaultWidth:260,getMaxWidth:eN,growthDirection:"right",maxWidth:480,minWidth:180,storageKey:"pi-sidebar-width",widthRef:eF}),eH=pm({ariaLabel:h("desktop.resizeFilePanel"),cssVariable:"--right-panel-width",defaultWidth:ph(1366),getDefaultWidth:eA,getMaxWidth:eL,growthDirection:"left",maxWidth:1200,minWidth:300,storageKey:"pi-right-panel-width",widthRef:eD}),eO=e$.reclampWidth,eB=eH.reclampWidth;(0,n.useEffect)(()=>{eC&&(eO(),eB())},[eB,eO,eC]);let eU=(0,n.useCallback)((e,t)=>{q.current?.insertText(sj(e,t))},[]),e_=(0,n.useCallback)(e=>{let t=e.map(e=>sj(e,!1)).join("");t&&q.current?.insertText(t)},[]),eq=(0,n.useCallback)((e,t,o)=>{let r,n,s,i;q.current?.insertText((r=Math.max(1,Math.min(t,o)),n=Math.max(1,Math.max(t,o)),s=e.includes(" ")?`@"${e}"`:`@${e}`,i=r===n?`:${r}`:`:${r}-${n}`,`${s}${i} `))},[]),[eV,eK]=(0,n.useState)(()=>c.sessionId),[eG,eJ]=(0,n.useState)(null),[eY,eX]=(0,n.useState)(()=>c.requestedCwd?"validating":"idle"),[eZ,eQ]=(0,n.useState)(null),[e0,e1]=(0,n.useState)(()=>!eV),e2=(0,n.useRef)(!1),e4=(0,n.useRef)(new Map),[e6,e8]=(0,n.useState)(null),e5=(0,n.useRef)("");(0,n.useEffect)(()=>{let e=`${c.requestedCwd??""}|${c.sessionId??""}`;e5.current!==e&&(e5.current=e,eK(c.sessionId),e1(!c.sessionId),c.requestedCwd||eX("idle"),eQ(null))},[c]),(0,n.useEffect)(()=>{let e=c.requestedCwd;if(!e)return;let t=new AbortController;return eX("validating"),eQ(null),fetch("/api/cwd/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e}),signal:t.signal}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok||!t.cwd)throw Error(t.error??`HTTP ${e.status}`);e2.current=!0,k(t.cwd),eX("ready")}).catch(e=>{t.signal.aborted||(eQ(e instanceof Error?e.message:String(e)),eX("error"))}),()=>t.abort()},[c]);let e3=(0,n.useCallback)((e,t)=>{if(!e)return;if(eJ(e),e2.current&&m&&tk(m.projectRoot??m.cwd,t??e)){if(e2.current=!1,m){let e=m.projectRoot??m.cwd;e&&e4.current.set(e,m.id)}return}e2.current=!1;let o=t??e;if(m&&tk(m.projectRoot??m.cwd,o)){(m.projectRoot??m.cwd)&&e4.current.set(o,m.id);return}if(m){let e=m.projectRoot??m.cwd;e&&e4.current.set(e,m.id)}f(null),k(t=>t&&t!==e?null:t),w(e=>e+1),eo(null),ef(null),window.history.replaceState(null,"","/");let r=e4.current.get(o);e8(r?{projectRoot:o,sessionId:r}:null)},[m]);(0,n.useEffect)(()=>{let e=eG?ec(eG)||eG:null;document.title=e?`${e} — Pi Agent Web`:"Pi Agent Web"},[eG]);let e7=(0,n.useCallback)((e,t=!1)=>{if(t||e8(null),!t&&m){let t=tk(m.projectRoot??m.cwd,e.projectRoot??e.cwd);if(m.id===e.id&&t){g&&B(!1);return}}let o=e.projectRoot??e.cwd;o&&e4.current.set(o,e.id),k(null),f(e),w(e=>e+1),eo(null),e1(!0),g&&!t&&B(!1),t&&(e2.current=!0),t||window.history.replaceState(null,"",`?session=${encodeURIComponent(e.id)}`)},[g,m]),e9=(0,n.useRef)(()=>{});(0,n.useEffect)(()=>{e9.current=e7},[e7]);let te=(0,n.useCallback)(e=>{fetch("/api/sessions").then(e=>e.ok?e.json():null).then(t=>{let o=t?.sessions.find(t=>t.id===e);o&&f(t=>!t||t.id!==e||t.projectRoot&&t.name?t:o)}).catch(()=>{})},[]);(0,n.useEffect)(()=>{if(!e6)return;let{projectRoot:e,sessionId:t}=e6;e9.current({path:"",id:t,cwd:e,created:"",modified:"",messageCount:0,firstMessage:"",projectRoot:e},!0),te(t),window.history.replaceState(null,"",`?session=${encodeURIComponent(t)}`),e8(null)},[e6,te]);let tt=(0,n.useCallback)((e,t)=>{e8(null),f(null),k(t),w(e=>e+1),eo(null),ef(null),g&&B(!1),window.history.replaceState(null,"","/")},[l,g]);!function(e){let{onNewSession:t,activeCwd:o}=e;(0,n.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(!a)return;let t=e.target?.tagName;if("TEXTAREA"===t||"INPUT"===t)return;e.preventDefault(),a();return}if("n"===e.key&&e.ctrlKey&&e.altKey){if(!o||!t)return;e.preventDefault(),t(o)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o,t])}({onNewSession:e=>tt(`kb-${Date.now()}`,e),activeCwd:eG});let to=(0,n.useCallback)(e=>{k(null),e8(null);let t=e.projectRoot??e.cwd;t&&e4.current.set(t,e.id),f(e),e.cwd&&eJ(e.cwd),y(e=>e+1),te(e.id),window.history.replaceState(null,"",`?session=${encodeURIComponent(e.id)}`),window.setTimeout(()=>y(e=>e+1),1200),window.setTimeout(()=>y(e=>e+1),4e3)},[l,te]),tr=(0,n.useCallback)(()=>{y(e=>e+1),S(e=>e+1)},[]),tn=(0,n.useCallback)(e=>{y(e=>e+1),w(e=>e+1),k(null),e8(null),f(t=>{let o={...t??{path:"",cwd:"",created:"",modified:"",messageCount:0,firstMessage:""},id:e},r=o.projectRoot??o.cwd;return r&&e4.current.set(r,e),o}),te(e),window.history.replaceState(null,"",`?session=${encodeURIComponent(e)}`)},[l,te]),ts=(0,n.useCallback)(()=>{e1(!0)},[]),ti=(0,n.useCallback)(e=>{if(y(e=>e+1),m?.id===e){let e=m.cwd;f(null),k(e??null),w(e=>e+1),eo(null),ef(null),window.history.replaceState(null,"","/")}},[l,m]),ta=(0,n.useCallback)((e,t,o,r)=>{let n="string"==typeof o||null===o?o:void 0,s="object"==typeof o&&null!==o?o:r,i=`file:${e}`;ew(o=>{let r=o.find(e=>e.id===i);return r?n&&r.sourceSessionId!==n||s?.initialDisplayMode&&r.initialDisplayMode!==s.initialDisplayMode?o.map(e=>e.id===i?{...e,sourceSessionId:n??e.sourceSessionId,initialDisplayMode:s?.initialDisplayMode??e.initialDisplayMode}:e):o:[...o,{id:i,label:t,filePath:e,sourceSessionId:n,initialDisplayMode:s?.initialDisplayMode}]}),eS(i),eT(!0),g&&B(!1)},[g]),tl=(0,n.useCallback)(e=>{ta(e,ec(e),m?.id??null)},[ta,m?.id]),td=(0,n.useCallback)(e=>{ew(t=>{let o=t.filter(t=>t.id!==e);return 0===o.length&&eT(!1),o}),eS(t=>{if(t!==e)return t;let o=eb.filter(t=>t.id!==e);return o.length>0?o[o.length-1].id:null})},[eb]),tc=(0,n.useCallback)(e=>{S(e=>e+1),ta(e,ec(e))},[ta]),tp=(0,n.useCallback)((e,t)=>{S(e=>e+1);let o=e.endsWith("/")?e:e+"/",r=r=>r===e||t&&r.startsWith(o);ew(e=>{let t=e.filter(e=>!r(e.filePath));return 0===t.length&&eT(!1),t}),eS(e=>{if(!e)return e;let t=eb.find(t=>t.id===e);if(!t||!r(t.filePath))return e;let o=eb.filter(e=>!r(e.filePath));return o.length>0?o[o.length-1].id:null})},[eb]),tu=m?tM(m.name||en?.sessionName)||m.firstMessage.slice(0,50)||m.id.slice(0,12):(t=eG??x)?t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean).pop()||t:null,th=(0,n.useCallback)(()=>{m&&window.open(`/api/sessions/${encodeURIComponent(m.id)}/export?inline=1`,"_blank","noopener,noreferrer")},[m]),tg=x??(null===m&&eG?eG:null),tm="validating"!==eY&&"error"!==eY&&(null!==m||null!==tg),tf=m?.cwd??tg,[tx,tv]=(0,n.useState)(!1),ty=(0,n.useCallback)(()=>{g||tv(e=>!e)},[g]),[tb,tw]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!1,t=()=>fetch("/api/features").then(e=>e.ok?e.json():null).then(t=>{!e&&t&&"boolean"==typeof t.tasksBoard&&(tw(t.tasksBoard),t.tasksBoard||tv(!1))}).catch(()=>{});t();let o=()=>t();return window.addEventListener("pi:features-changed",o),()=>{e=!0,window.removeEventListener("pi:features-changed",o)}},[]);let tj=e0&&!tm;(0,n.useEffect)(()=>{let e=()=>{g||tv(!0)};return window.addEventListener(ah,e),()=>window.removeEventListener(ah,e)},[g]),(0,n.useEffect)(()=>{if(E(null),F(!1),$(null),!tf)return;let e=new AbortController;return fetch(`/api/project-trust?cwd=${encodeURIComponent(tf)}`,{signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);E(t)}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to load project trust:",e)}),()=>e.abort()},[tf]);let tS=(0,n.useCallback)(async()=>{if(tf&&!D){N(!0),$(null);try{let e=await fetch("/api/project-trust",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:tf})}),t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);E(t),F(!1),M(e=>e+1),w(e=>e+1)}catch(e){$(e instanceof Error?e.message:String(e))}finally{N(!1)}}},[D,tf]),tC=eb.find(e=>e.id===ej)??null,tT=eG??m?.cwd??x,tR=(0,n.useCallback)(e=>{z(e),T(!0)},[]),tz=(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(t$,{selectedSessionId:m?.id??null,onSelectSession:e7,onNewSession:tt,initialSessionId:eV,onInitialRestoreDone:ts,refreshKey:v,onSessionDeleted:ti,selectedCwd:m?.cwd??x??null,onCwdChange:e3,onOpenFile:ta,selectedSessionStats:en,onOpenSettings:e=>{tR(["models","skills","plugins","chat","features","logs"].includes(e)?e:"models")},explorerRefreshKey:j,onAtMention:eU,onAtMentions:e_,onFileCreated:tc,onFileDeleted:tp,workspaceControlsHosts:{title:K,welcome:X,titleRight:J},showWorkspaceControls:!0})});return(0,r.jsxs)(cv,{children:[(0,r.jsx)("style",{children:`
|
|
38
38
|
@media (max-width: 640px) {
|
|
39
39
|
.sidebar-overlay-backdrop.sidebar-mobile-pending {
|
|
40
40
|
opacity: 0 !important;
|
|
@@ -45,4 +45,4 @@ ${o}`):s=o;let m=s,f=n?.map(e=>({type:"image",source:{type:"base64",media_type:e
|
|
|
45
45
|
box-shadow: none;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
`}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100dvh",overflow:"hidden",background:"var(--bg)","--pi-titlebar-sidebar-offset":`${g||!H?0:e$.width}px`},children:[(0,r.jsx)(pc,{topBarRef:V,sidebarOpen:H,onSidebarToggle:ey,isDark:p,toggleTheme:u,isMobile:g,showTasks:tx,tasksBoardEnabled:tb,onToggleTasks:ty,systemPrompt:et,activeTopPanel:em,topPanelPos:ex,sessionStats:en,selectedSession:m,contextUsage:eu,copiedSessionField:ea,onCopySessionField:ep,rightPanelOpen:eC,onToggleFilePanel:()=>eT(e=>!e),onRefreshSession:()=>w(e=>e+1),onOpenSettings:()=>tR("models"),sessionTitle:tu,onWorkspaceControlsHostChange:G,onTitleRightHostChange:Y,desktopChrome:Q,windowDrag:ee}),tm&&P?.requiresTrust&&!P.trusted&&(0,r.jsxs)("button",{type:"button",onClick:()=>{$(null),F(!0)},title:h("desktop.projectResourcesRestricted"),"aria-label":h("desktop.projectResourcesRestricted"),style:{position:"fixed",top:60,right:g?12:20,zIndex:700,display:"inline-flex",alignItems:"center",gap:7,padding:"8px 11px",border:"1px solid color-mix(in srgb, var(--accent-orange) 52%, var(--border))",borderRadius:7,background:"color-mix(in srgb, var(--accent-orange) 11%, var(--bg-panel))",color:"var(--accent-orange)",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.16)",cursor:"pointer",fontSize:12,fontWeight:600},children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠"}),h("desktop.trustProject")]}),(0,r.jsxs)("div",{style:{"--right-panel-width":`${eH.width}px`,flex:1,display:"flex",overflow:"hidden",minWidth:0,position:"relative"},children:[(0,r.jsx)("div",{className:`sidebar-overlay-backdrop${U?"":" sidebar-mobile-pending"}`,onClick:()=>B(!1),style:{position:"fixed",inset:0,zIndex:199,background:"rgba(0,0,0,0.4)",opacity:+!!H,pointerEvents:H?"auto":"none",transition:"opacity 0.25s ease"}}),(0,r.jsx)("div",{ref:e$.panelRef,className:`sidebar-container${H?" sidebar-open":" sidebar-closed"}${U?"":" sidebar-mobile-pending"}${e$.isResizing?" panel-is-resizing":""}`,style:{"--sidebar-width":`${e$.width}px`,background:"var(--bg-panel)",borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",flexShrink:0,zIndex:200},children:tz}),H&&(0,r.jsx)("div",{...e$.separatorProps,className:"workspace-panel-splitter sidebar-panel-splitter"}),(0,r.jsx)("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:(0,r.jsx)("div",{style:{flex:1,overflow:"hidden",position:"relative"},children:tx&&tb?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(cX,{}),(0,r.jsx)(cZ,{activeProject:eG??void 0})]}):tm?(0,r.jsx)(ag,{session:m,newSessionCwd:tg,onAgentEnd:tr,onSessionCreated:to,onSessionForked:tn,modelsRefreshKey:I,chatInputRef:q,tasksBoardEnabled:tb,onSystemPromptChange:er,onSessionStatsChange:ei,onOpenSession:eW,onSessionStatsPanelOpen:ev,onContextUsageChange:eg,onOpenFile:tl,onWorkspaceControlsHostChange:Z,onViewFullHistory:th,systemPrompt:et},b):"validating"===eY?(0,r.jsxs)("div",{role:"status",style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:24,color:"var(--text-muted)",textAlign:"center"},children:[(0,r.jsx)("div",{style:{fontSize:14,color:"var(--text)"},children:h("desktop.openingWorkspace")}),(0,r.jsx)("div",{style:{maxWidth:"min(720px, 100%)",overflowWrap:"anywhere",fontFamily:"var(--font-mono)",fontSize:12},children:c.requestedCwd})]}):"error"===eY?(0,r.jsxs)("div",{role:"alert",style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:24,color:"var(--text-muted)",textAlign:"center"},children:[(0,r.jsx)("div",{style:{fontSize:14,color:"#dc2626"},children:h("desktop.unableToOpenWorkspace")}),(0,r.jsx)("div",{style:{maxWidth:"min(720px, 100%)",overflowWrap:"anywhere",fontFamily:"var(--font-mono)",fontSize:12},children:c.requestedCwd}),(0,r.jsx)("div",{style:{maxWidth:720,fontSize:12},children:eZ})]}):tj?eG?(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:15},children:h("desktop.selectSessionFromSidebar")}):(0,r.jsxs)("div",{style:{position:"absolute",top:12,left:12,display:"flex",alignItems:"flex-start",gap:8,userSelect:"none",pointerEvents:"none"},children:[(0,r.jsx)(s.n,{size:44,color:"var(--accent)","aria-hidden":"true",style:{opacity:.7,flexShrink:0}}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{fontSize:18,fontWeight:600,color:"var(--text)",marginBottom:8},children:h("desktop.getStarted")}),(0,r.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.8},children:[(0,r.jsx)("span",{style:{color:"var(--text-dim)",marginRight:6},children:"1."}),h("desktop.selectProjectDirectory"),(0,r.jsx)("br",{}),(0,r.jsx)("span",{style:{color:"var(--text-dim)",marginRight:6},children:"2."}),h("desktop.addModelsFromBottom")]})]})]}):null})}),eC&&(0,r.jsx)("div",{...eH.separatorProps,className:"workspace-panel-splitter right-panel-splitter"}),(0,r.jsxs)("div",{ref:eH.panelRef,className:`right-panel-container${eC?" right-panel-open":" right-panel-closed"}${eH.isResizing?" panel-is-resizing":""}`,style:{display:"flex",flexDirection:"column",borderLeft:"1px solid var(--border)",background:"var(--bg)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0,background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",height:36},children:[(0,r.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,r.jsx)(aU,{tabs:eb,activeTabId:ej??"",onSelectTab:eS,onCloseTab:td})}),(0,r.jsxs)("button",{type:"button",onClick:()=>ez(e=>!e),title:h("agentSwitcher.title"),style:{display:"inline-flex",alignItems:"center",gap:5,flexShrink:0,height:28,marginRight:6,padding:"0 10px",border:"1px solid var(--border)",borderRadius:6,background:eR?"var(--bg-selected)":"transparent",color:eR?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:11},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,r.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,r.jsx)("path",{d:"M12 7v4"})]}),h("agentSwitcher.title")]})]}),(0,r.jsx)("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",minHeight:0},children:eR?(o=(e=m?.id)?(function(e){let t=function(e){let t=new Map(e.map(e=>[e.id,e])),o=new Map;for(let r of e){if(o.has(r.id))continue;let e=[],n=new Set,s=r.id,i=null;for(;;){if(o.has(s)){i=o.get(s)??null;break}if(n.has(s))break;n.add(s),e.push(s);let r=t.get(s);if(!r)break;if(r.relation?.kind!=="subagent"){i=r.id;break}s=r.relation.parentSessionId}for(let t of e)o.set(t,i)}return o}(e),o=new Map;for(let t of e)t.relation?.kind!=="subagent"&&o.set(t.id,{root:t,subagents:[],latestModified:t.modified});for(let r of e){if(r.relation?.kind!=="subagent")continue;let e=t.get(r.id),n=e?o.get(e):void 0;n&&(n.subagents.push(r),r.modified>n.latestModified&&(n.latestModified=r.modified))}return[...o.values()].sort((e,t)=>t.latestModified.localeCompare(e.latestModified))})(eI).find(t=>t.root.id===e||t.subagents.some(t=>t.id===e))??null:null)?(0,r.jsx)(pv,{rootSession:o.root,subagents:o.subagents,selectedSessionId:m?.id??"",runningSessionIds:eP,onSelectSession:e=>{ez(!1),e9.current(e)}}):(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:12},children:h("agentSwitcher.noFamily")}):tC?.filePath?(0,r.jsx)(aO,{filePath:tC.filePath,cwd:eG??void 0,sourceSessionId:tC.sourceSessionId,initialDisplayMode:tC.initialDisplayMode,onOpenFile:e=>ta(e,ec(e),tC.sourceSessionId),onAtMention:eU,onMentionLines:eq,onFileSaved:()=>S(e=>e+1)}):(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:12},children:"No file open"})})]})]}),W&&tf&&(0,r.jsx)(pp,{cwd:tf,busy:D,error:L,onCancelAction:()=>{D||F(!1)},onConfirmAction:()=>void tS()}),C&&(0,r.jsx)(cm,{initialTab:R,cwd:tT,sessionId:m?.id??null,onCloseAction:()=>{T(!1),M(e=>e+1)},onModelsSavedAction:()=>M(e=>e+1),onSessionReloadedAction:()=>w(e=>e+1),onSessionsChanged:()=>y(e=>e+1)})]})]})}}
|
|
48
|
+
`}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100dvh",overflow:"hidden",background:"var(--bg)","--pi-titlebar-sidebar-offset":`${g||!H?0:e$.width}px`},children:[(0,r.jsx)(pc,{topBarRef:V,sidebarOpen:H,onSidebarToggle:ey,isDark:p,toggleTheme:u,isMobile:g,showTasks:tx,tasksBoardEnabled:tb,onToggleTasks:ty,systemPrompt:et,activeTopPanel:em,topPanelPos:ex,sessionStats:en,selectedSession:m,contextUsage:eu,copiedSessionField:ea,onCopySessionField:ep,rightPanelOpen:eC,onToggleFilePanel:()=>eT(e=>!e),onRefreshSession:()=>w(e=>e+1),onOpenSettings:()=>tR("models"),sessionTitle:tu,onWorkspaceControlsHostChange:G,onTitleRightHostChange:Y,desktopChrome:Q,windowDrag:ee}),tm&&P?.requiresTrust&&!P.trusted&&(0,r.jsxs)("button",{type:"button",onClick:()=>{$(null),F(!0)},title:h("desktop.projectResourcesRestricted"),"aria-label":h("desktop.projectResourcesRestricted"),style:{position:"fixed",top:60,right:g?12:20,zIndex:700,display:"inline-flex",alignItems:"center",gap:7,padding:"8px 11px",border:"1px solid color-mix(in srgb, var(--accent-orange) 52%, var(--border))",borderRadius:7,background:"color-mix(in srgb, var(--accent-orange) 11%, var(--bg-panel))",color:"var(--accent-orange)",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.16)",cursor:"pointer",fontSize:12,fontWeight:600},children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠"}),h("desktop.trustProject")]}),(0,r.jsxs)("div",{style:{"--right-panel-width":`${eH.width}px`,flex:1,display:"flex",overflow:"hidden",minWidth:0,position:"relative"},children:[(0,r.jsx)("div",{className:`sidebar-overlay-backdrop${U?"":" sidebar-mobile-pending"}`,onClick:()=>B(!1),style:{position:"fixed",inset:0,zIndex:199,background:"rgba(0,0,0,0.4)",opacity:+!!H,pointerEvents:H?"auto":"none",transition:"opacity 0.25s ease"}}),(0,r.jsx)("div",{ref:e$.panelRef,className:`sidebar-container${H?" sidebar-open":" sidebar-closed"}${U?"":" sidebar-mobile-pending"}${e$.isResizing?" panel-is-resizing":""}`,style:{"--sidebar-width":`${e$.width}px`,background:"var(--bg-panel)",borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",flexShrink:0,zIndex:200},children:tz}),H&&(0,r.jsx)("div",{...e$.separatorProps,className:"workspace-panel-splitter sidebar-panel-splitter"}),(0,r.jsx)("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:(0,r.jsx)("div",{style:{flex:1,overflow:"hidden",position:"relative"},children:tx&&tb?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(cX,{}),(0,r.jsx)(cZ,{activeProject:eG??void 0})]}):tm?(0,r.jsx)(ag,{session:m,newSessionCwd:tg,onAgentEnd:tr,onSessionCreated:to,onSessionForked:tn,modelsRefreshKey:I,chatInputRef:q,tasksBoardEnabled:tb,onSystemPromptChange:er,onSessionStatsChange:ei,onOpenSession:eW,onSessionStatsPanelOpen:ev,onContextUsageChange:eg,onOpenFile:tl,onWorkspaceControlsHostChange:Z,onViewFullHistory:th,systemPrompt:et},b):"validating"===eY?(0,r.jsxs)("div",{role:"status",style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:24,color:"var(--text-muted)",textAlign:"center"},children:[(0,r.jsx)("div",{style:{fontSize:14,color:"var(--text)"},children:h("desktop.openingWorkspace")}),(0,r.jsx)("div",{style:{maxWidth:"min(720px, 100%)",overflowWrap:"anywhere",fontFamily:"var(--font-mono)",fontSize:12},children:c.requestedCwd})]}):"error"===eY?(0,r.jsxs)("div",{role:"alert",style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:24,color:"var(--text-muted)",textAlign:"center"},children:[(0,r.jsx)("div",{style:{fontSize:14,color:"#dc2626"},children:h("desktop.unableToOpenWorkspace")}),(0,r.jsx)("div",{style:{maxWidth:"min(720px, 100%)",overflowWrap:"anywhere",fontFamily:"var(--font-mono)",fontSize:12},children:c.requestedCwd}),(0,r.jsx)("div",{style:{maxWidth:720,fontSize:12},children:eZ})]}):tj?eG?(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:15},children:h("desktop.selectSessionFromSidebar")}):(0,r.jsxs)("div",{style:{position:"absolute",top:12,left:12,display:"flex",alignItems:"flex-start",gap:8,userSelect:"none",pointerEvents:"none"},children:[(0,r.jsx)(s.n,{size:44,color:"var(--accent)","aria-hidden":"true",style:{opacity:.7,flexShrink:0}}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{fontSize:18,fontWeight:600,color:"var(--text)",marginBottom:8},children:h("desktop.getStarted")}),(0,r.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.8},children:[(0,r.jsx)("span",{style:{color:"var(--text-dim)",marginRight:6},children:"1."}),h("desktop.selectProjectDirectory"),(0,r.jsx)("br",{}),(0,r.jsx)("span",{style:{color:"var(--text-dim)",marginRight:6},children:"2."}),h("desktop.addModelsFromBottom")]})]})]}):null})}),eC&&(0,r.jsx)("div",{...eH.separatorProps,className:"workspace-panel-splitter right-panel-splitter"}),(0,r.jsxs)("div",{ref:eH.panelRef,className:`right-panel-container${eC?" right-panel-open":" right-panel-closed"}${eH.isResizing?" panel-is-resizing":""}`,style:{display:"flex",flexDirection:"column",borderLeft:"1px solid var(--border)",background:"var(--bg)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0,background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",height:36},children:[(0,r.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,r.jsx)(aU,{tabs:eb,activeTabId:ej??"",onSelectTab:eS,onCloseTab:td})}),(0,r.jsxs)("button",{type:"button",onClick:()=>ez(e=>!e),title:h("agentSwitcher.title"),style:{display:"inline-flex",alignItems:"center",gap:5,flexShrink:0,height:28,marginRight:6,padding:"0 10px",border:"1px solid var(--border)",borderRadius:6,background:eR?"var(--bg-selected)":"transparent",color:eR?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:11},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,r.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,r.jsx)("path",{d:"M12 7v4"})]}),h("agentSwitcher.title")]})]}),(0,r.jsx)("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",minHeight:0},children:eR?(o=(e=m?.id)?(function(e){let t=function(e){let t=new Map(e.map(e=>[e.id,e])),o=new Map;for(let r of e){if(o.has(r.id))continue;let e=[],n=new Set,s=r.id,i=null;for(;;){if(o.has(s)){i=o.get(s)??null;break}if(n.has(s))break;n.add(s),e.push(s);let r=t.get(s);if(!r)break;if(r.relation?.kind!=="subagent"){i=r.id;break}s=r.relation.parentSessionId}for(let t of e)o.set(t,i)}return o}(e),o=new Map;for(let t of e)t.relation?.kind!=="subagent"&&o.set(t.id,{root:t,subagents:[],latestModified:t.modified});for(let r of e){if(r.relation?.kind!=="subagent")continue;let e=t.get(r.id),n=e?o.get(e):void 0;n&&(n.subagents.push(r),r.modified>n.latestModified&&(n.latestModified=r.modified))}return[...o.values()].sort((e,t)=>t.latestModified.localeCompare(e.latestModified))})(eI).find(t=>t.root.id===e||t.subagents.some(t=>t.id===e))??null:null)?(0,r.jsx)(pv,{rootSession:o.root,subagents:o.subagents,selectedSessionId:m?.id??"",runningSessionIds:eP,onSelectSession:e=>{ez(!1),e9.current(e)}}):(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:12},children:h("agentSwitcher.noFamily")}):tC?.filePath?(0,r.jsx)(aO,{filePath:tC.filePath,cwd:eG??void 0,sourceSessionId:tC.sourceSessionId,initialDisplayMode:tC.initialDisplayMode,onOpenFile:e=>ta(e,ec(e),tC.sourceSessionId),onAtMention:eU,onMentionLines:eq,onFileSaved:()=>S(e=>e+1)}):(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:12},children:"No file open"})})]})]}),W&&tf&&(0,r.jsx)(pp,{cwd:tf,busy:D,error:L,onCancelAction:()=>{D||F(!1)},onConfirmAction:()=>void tS()}),C&&(0,r.jsx)(cm,{initialTab:R,cwd:tT,sessionId:m?.id??null,onCloseAction:()=>{T(!1),M(e=>e+1)},onModelsSavedAction:()=>M(e=>e+1),onSessionReloadedAction:()=>w(e=>e+1),onSessionsChanged:()=>y(e=>e+1)})]})]})}}},e=>{e.O(0,[7330,9786,8441,3794,7358],()=>e(e.s=10283)),_N_E=e.O()}]);
|