@surething/cockpit 1.0.272 → 1.0.273
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-prod/BUILD_ID +1 -1
- package/.next-prod/app-path-routes-manifest.json +5 -4
- package/.next-prod/build-manifest.json +2 -2
- package/.next-prod/cockpit-build.json +1 -1
- package/.next-prod/prerender-manifest.json +3 -3
- package/.next-prod/routes-manifest.json +6 -0
- package/.next-prod/server/app/_global-error/page.js +2 -2
- package/.next-prod/server/app/_global-error/page.js.nft.json +1 -1
- package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/_global-error.html +1 -1
- package/.next-prod/server/app/_global-error.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found/page.js +1 -1
- package/.next-prod/server/app/_not-found/page.js.nft.json +1 -1
- package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/_not-found.html +2 -2
- package/.next-prod/server/app/_not-found.rsc +3 -3
- package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next-prod/server/app/api/agent/test/route.js +1 -1
- package/.next-prod/server/app/api/agent/test/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/bash/route.js +1 -1
- package/.next-prod/server/app/api/bash/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/codex/route.js +1 -1
- package/.next-prod/server/app/api/chat/codex/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/deepseek/route.js +1 -1
- package/.next-prod/server/app/api/chat/deepseek/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/glm/route.js +1 -1
- package/.next-prod/server/app/api/chat/glm/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/kimi/route.js +1 -1
- package/.next-prod/server/app/api/chat/kimi/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/ollama/route.js +1 -1
- package/.next-prod/server/app/api/chat/ollama/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/route.js +1 -1
- package/.next-prod/server/app/api/chat/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/stop/route.js +1 -1
- package/.next-prod/server/app/api/chat/stop/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/claude-stats/route.js +1 -1
- package/.next-prod/server/app/api/claude-stats/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/commands/route.js +1 -1
- package/.next-prod/server/app/api/commands/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/comments/route.js +1 -1
- package/.next-prod/server/app/api/comments/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/columns/route.js +1 -1
- package/.next-prod/server/app/api/db/columns/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/connect/route.js +2 -2
- package/.next-prod/server/app/api/db/connect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/disconnect/route.js +1 -1
- package/.next-prod/server/app/api/db/disconnect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/export/route.js +1 -1
- package/.next-prod/server/app/api/db/export/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/query/route.js +1 -1
- package/.next-prod/server/app/api/db/query/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/schemas/route.js +2 -2
- package/.next-prod/server/app/api/db/schemas/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/deepseek/balance/route.js +1 -1
- package/.next-prod/server/app/api/deepseek/balance/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/deepseek/credentials/route.js +1 -1
- package/.next-prod/server/app/api/deepseek/credentials/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/deepseek/models/route.js +1 -1
- package/.next-prod/server/app/api/deepseek/models/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/dev/spans/route.js +1 -1
- package/.next-prod/server/app/api/dev/spans/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/extension/version/route.js +1 -1
- package/.next-prod/server/app/api/extension/version/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/file/route.js +1 -1
- package/.next-prod/server/app/api/file/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/blame/route.js +1 -1
- package/.next-prod/server/app/api/files/blame/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/clipboard/route.js +1 -1
- package/.next-prod/server/app/api/files/clipboard/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/copy/route.js +1 -1
- package/.next-prod/server/app/api/files/copy/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/delete/route.js +1 -1
- package/.next-prod/server/app/api/files/delete/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/expanded/route.js +1 -1
- package/.next-prod/server/app/api/files/expanded/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/index/route.js +1 -1
- package/.next-prod/server/app/api/files/index/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/init/route.js +1 -1
- package/.next-prod/server/app/api/files/init/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/paste/route.js +1 -1
- package/.next-prod/server/app/api/files/paste/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/read/route.js +1 -1
- package/.next-prod/server/app/api/files/read/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/readdir/route.js +1 -1
- package/.next-prod/server/app/api/files/readdir/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/recent/route.js +1 -1
- package/.next-prod/server/app/api/files/recent/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/save/route.js +1 -1
- package/.next-prod/server/app/api/files/save/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/search/route.js +1 -1
- package/.next-prod/server/app/api/files/search/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/stat/route.js +1 -1
- package/.next-prod/server/app/api/files/stat/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/text/route.js +1 -1
- package/.next-prod/server/app/api/files/text/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/blob/route.js +1 -1
- package/.next-prod/server/app/api/git/blob/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/branch-diff/route.js +1 -1
- package/.next-prod/server/app/api/git/branch-diff/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/branches/route.js +1 -1
- package/.next-prod/server/app/api/git/branches/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/commit-diff/route.js +1 -1
- package/.next-prod/server/app/api/git/commit-diff/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/commits/route.js +1 -1
- package/.next-prod/server/app/api/git/commits/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/current-branch/route.js +1 -1
- package/.next-prod/server/app/api/git/current-branch/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/diff/route.js +1 -1
- package/.next-prod/server/app/api/git/diff/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/discard/route.js +1 -1
- package/.next-prod/server/app/api/git/discard/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/stage/route.js +1 -1
- package/.next-prod/server/app/api/git/stage/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/status/route.js +1 -1
- package/.next-prod/server/app/api/git/status/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/unstage/route.js +1 -1
- package/.next-prod/server/app/api/git/unstage/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/worktree/route.js +1 -1
- package/.next-prod/server/app/api/git/worktree/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/glm/credentials/route.js +1 -1
- package/.next-prod/server/app/api/glm/credentials/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/glm/models/route.js +1 -1
- package/.next-prod/server/app/api/glm/models/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/glm/usage/route.js +1 -1
- package/.next-prod/server/app/api/glm/usage/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/global-state/route.js +1 -1
- package/.next-prod/server/app/api/global-state/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/health/route.js +1 -1
- package/.next-prod/server/app/api/health/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/html-apps/[id]/route.js +1 -1
- package/.next-prod/server/app/api/html-apps/[id]/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/html-apps/route.js +1 -1
- package/.next-prod/server/app/api/html-apps/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/kimi/credentials/route.js +1 -1
- package/.next-prod/server/app/api/kimi/credentials/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/kimi/models/route.js +1 -1
- package/.next-prod/server/app/api/kimi/models/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/kimi/usage/route.js +1 -1
- package/.next-prod/server/app/api/kimi/usage/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/definition/route.js +1 -1
- package/.next-prod/server/app/api/lsp/definition/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/hover/route.js +1 -1
- package/.next-prod/server/app/api/lsp/hover/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/references/route.js +1 -1
- package/.next-prod/server/app/api/lsp/references/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/status/route.js +1 -1
- package/.next-prod/server/app/api/lsp/status/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/warmup/route.js +1 -1
- package/.next-prod/server/app/api/lsp/warmup/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/columns/route.js +2 -2
- package/.next-prod/server/app/api/mysql/columns/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/connect/route.js +1 -1
- package/.next-prod/server/app/api/mysql/connect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/disconnect/route.js +1 -1
- package/.next-prod/server/app/api/mysql/disconnect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/export/route.js +1 -1
- package/.next-prod/server/app/api/mysql/export/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/query/route.js +1 -1
- package/.next-prod/server/app/api/mysql/query/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/schemas/route.js +2 -2
- package/.next-prod/server/app/api/mysql/schemas/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/neo4j/connect/route.js +1 -1
- package/.next-prod/server/app/api/neo4j/connect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/neo4j/disconnect/route.js +1 -1
- package/.next-prod/server/app/api/neo4j/disconnect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/neo4j/query/route.js +1 -1
- package/.next-prod/server/app/api/neo4j/query/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/neo4j/schema/route.js +1 -1
- package/.next-prod/server/app/api/neo4j/schema/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/note/route.js +1 -1
- package/.next-prod/server/app/api/note/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/ollama/config/route.js +1 -1
- package/.next-prod/server/app/api/ollama/config/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/ollama/models/route.js +1 -1
- package/.next-prod/server/app/api/ollama/models/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/ollama/start/route.js +1 -1
- package/.next-prod/server/app/api/ollama/start/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/open-cursor/route.js +1 -1
- package/.next-prod/server/app/api/open-cursor/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/open-vscode/route.js +1 -1
- package/.next-prod/server/app/api/open-vscode/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/pick-folder/route.js +1 -1
- package/.next-prod/server/app/api/pick-folder/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/pinned-sessions/route.js +1 -1
- package/.next-prod/server/app/api/pinned-sessions/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/project-settings/route.js +1 -1
- package/.next-prod/server/app/api/project-settings/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/project-state/route.js +1 -1
- package/.next-prod/server/app/api/project-state/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/affected/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/affected/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/callees/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/callees/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/callers/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/callers/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/coedit/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/coedit/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/context/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/context/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/file/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/file/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/file-functions/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/file-functions/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/impact/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/impact/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/related/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/related/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/risk/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/risk/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/search/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/search/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projects/route.js +1 -1
- package/.next-prod/server/app/api/projects/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/prompts/config/route.js +1 -1
- package/.next-prod/server/app/api/prompts/config/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/push/public-key/route.js +1 -1
- package/.next-prod/server/app/api/push/public-key/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/push/subscribe/route.js +1 -1
- package/.next-prod/server/app/api/push/subscribe/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/push/unsubscribe/route.js +1 -1
- package/.next-prod/server/app/api/push/unsubscribe/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/command/route.js +1 -1
- package/.next-prod/server/app/api/redis/command/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/connect/route.js +1 -1
- package/.next-prod/server/app/api/redis/connect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/delete/route.js +1 -1
- package/.next-prod/server/app/api/redis/delete/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/disconnect/route.js +1 -1
- package/.next-prod/server/app/api/redis/disconnect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/get/route.js +1 -1
- package/.next-prod/server/app/api/redis/get/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/keys/route.js +1 -1
- package/.next-prod/server/app/api/redis/keys/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/set/route.js +1 -1
- package/.next-prod/server/app/api/redis/set/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/restart/route.js +1 -1
- package/.next-prod/server/app/api/restart/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/[id]/comments/route.js +1 -1
- package/.next-prod/server/app/api/review/[id]/comments/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/[id]/replies/route.js +1 -1
- package/.next-prod/server/app/api/review/[id]/replies/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/[id]/route.js +1 -1
- package/.next-prod/server/app/api/review/[id]/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/identify/route.js +1 -1
- package/.next-prod/server/app/api/review/identify/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/order/route.js +1 -1
- package/.next-prod/server/app/api/review/order/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/route.js +1 -1
- package/.next-prod/server/app/api/review/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/share-info/route.js +1 -1
- package/.next-prod/server/app/api/review/share-info/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/users/route.js +1 -1
- package/.next-prod/server/app/api/review/users/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/scheduled-tasks/route.js +2 -2
- package/.next-prod/server/app/api/scheduled-tasks/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/services/config/route.js +1 -1
- package/.next-prod/server/app/api/services/config/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/services/scripts/route.js +1 -1
- package/.next-prod/server/app/api/services/scripts/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/fork/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/history/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/session/user-messages/route.js +1 -0
- package/.next-prod/server/app/api/session/user-messages/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/session/user-messages/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/session-by-path/route.js +1 -3
- package/.next-prod/server/app/api/session-by-path/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js +1 -1
- package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/sessions/projects/route.js +1 -1
- package/.next-prod/server/app/api/sessions/projects/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/sessions/route.js +1 -1
- package/.next-prod/server/app/api/sessions/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/settings/route.js +1 -1
- package/.next-prod/server/app/api/settings/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/shutdown/route.js +1 -1
- package/.next-prod/server/app/api/shutdown/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/skills/[id]/route.js +1 -1
- package/.next-prod/server/app/api/skills/[id]/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/skills/content/route.js +1 -1
- package/.next-prod/server/app/api/skills/content/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/skills/route.js +1 -1
- package/.next-prod/server/app/api/skills/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/snapshots/blob/route.js +1 -1
- package/.next-prod/server/app/api/snapshots/blob/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/snapshots/diff/route.js +1 -1
- package/.next-prod/server/app/api/snapshots/diff/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/snapshots/route.js +1 -1
- package/.next-prod/server/app/api/snapshots/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/aliases/route.js +1 -1
- package/.next-prod/server/app/api/terminal/aliases/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/autocomplete/route.js +1 -1
- package/.next-prod/server/app/api/terminal/autocomplete/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/bubble-order/route.js +1 -1
- package/.next-prod/server/app/api/terminal/bubble-order/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/env/route.js +1 -1
- package/.next-prod/server/app/api/terminal/env/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/history/route.js +1 -1
- package/.next-prod/server/app/api/terminal/history/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/update/route.js +1 -1
- package/.next-prod/server/app/api/update/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/update-state/route.js +1 -1
- package/.next-prod/server/app/api/update-state/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/version/route.js +1 -1
- package/.next-prod/server/app/api/version/route.js.nft.json +1 -1
- package/.next-prod/server/app/apps/[...path]/route.js +1 -1
- package/.next-prod/server/app/apps/[...path]/route.js.nft.json +1 -1
- package/.next-prod/server/app/favicon.ico/route.js +1 -1
- package/.next-prod/server/app/favicon.ico/route.js.nft.json +1 -1
- package/.next-prod/server/app/m/page.js +1 -1
- package/.next-prod/server/app/m/page.js.nft.json +1 -1
- package/.next-prod/server/app/m/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/manifest.webmanifest/route.js +2 -2
- package/.next-prod/server/app/manifest.webmanifest/route.js.nft.json +1 -1
- package/.next-prod/server/app/page.js +1 -1
- package/.next-prod/server/app/page.js.nft.json +1 -1
- package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/project/page.js +1 -1
- package/.next-prod/server/app/project/page.js.nft.json +1 -1
- package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/review/[id]/page.js +1 -1
- package/.next-prod/server/app/review/[id]/page.js.nft.json +1 -1
- package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app-paths-manifest.json +5 -4
- package/.next-prod/server/chunks/1237.js +1 -0
- package/.next-prod/server/chunks/4949.js +1 -1
- package/.next-prod/server/chunks/{5766.js → 5433.js} +4 -4
- package/.next-prod/server/chunks/5750.js +13 -13
- package/.next-prod/server/chunks/6548.js +1 -1
- package/.next-prod/server/chunks/8616.js +3 -0
- package/.next-prod/server/middleware-build-manifest.js +1 -1
- package/.next-prod/server/pages/404.html +2 -2
- package/.next-prod/server/pages/500.html +1 -1
- package/.next-prod/server/server-reference-manifest.json +1 -1
- package/.next-prod/static/chunks/5390-e2c2386e8288a254.js +32 -0
- package/.next-prod/static/chunks/7184-8b7ad4ccea8b15a3.js +17 -0
- package/.next-prod/static/chunks/{9200-2d063007a9a86cd2.js → 7570-ebe01cce6f28a79f.js} +2 -2
- package/.next-prod/static/chunks/9092-a942df8114966b59.js +716 -0
- package/.next-prod/static/chunks/app/_global-error/page-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/agent/test/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/bash/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/codex/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/deepseek/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/glm/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/kimi/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/ollama/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/stop/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/claude-stats/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/commands/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/comments/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/db/columns/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/db/connect/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/db/disconnect/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/db/export/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/db/query/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/db/schemas/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/deepseek/balance/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/deepseek/credentials/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/deepseek/models/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/dev/spans/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/extension/version/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/file/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/blame/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/clipboard/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/copy/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/delete/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/expanded/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/index/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/init/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/paste/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/read/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/readdir/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/recent/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/save/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/search/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/stat/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/files/text/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/git/blob/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/git/branch-diff/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/git/branches/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/git/commit-diff/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/git/commits/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/git/current-branch/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/git/diff/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/git/discard/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/git/stage/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/git/status/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/git/unstage/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/git/worktree/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/glm/credentials/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/glm/models/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/glm/usage/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/global-state/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/health/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/html-apps/[id]/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/html-apps/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/kimi/credentials/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/kimi/models/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/kimi/usage/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/definition/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/hover/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/references/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/status/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/warmup/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/columns/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/connect/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/disconnect/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/export/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/query/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/schemas/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/neo4j/connect/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/neo4j/query/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/neo4j/schema/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/note/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/ollama/config/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/ollama/models/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/ollama/start/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/open-cursor/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/open-vscode/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/pick-folder/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/pinned-sessions/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/project-settings/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/project-state/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/affected/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/callees/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/callers/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/context/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/file/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/impact/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/related/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/risk/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/search/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/projects/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/prompts/config/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/push/public-key/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/push/subscribe/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/push/unsubscribe/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/command/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/connect/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/delete/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/disconnect/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/get/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/keys/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/set/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/restart/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/review/[id]/comments/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/review/[id]/replies/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/review/[id]/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/review/identify/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/review/order/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/review/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/review/share-info/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/review/users/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/scheduled-tasks/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/services/config/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/services/scripts/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/session/user-messages/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/session-by-path/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/projects/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/settings/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/shutdown/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/skills/[id]/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/skills/content/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/skills/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/snapshots/blob/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/snapshots/diff/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/snapshots/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/aliases/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/env/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/history/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/update/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/update-state/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/api/version/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/apps/[...path]/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/{layout-4d9685b25807b4c6.js → layout-915635f208cba4b3.js} +1 -1
- package/.next-prod/static/chunks/app/m/{page-af6600597536f9a9.js → page-8442a2605d0feb3f.js} +1 -1
- package/.next-prod/static/chunks/app/manifest.webmanifest/route-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/app/{page-af99426a6c82e466.js → page-48dc2d6146301fd7.js} +1 -1
- package/.next-prod/static/chunks/app/project/{page-af99426a6c82e466.js → page-48dc2d6146301fd7.js} +1 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-0bc5d188dc4650ab.js +1 -0
- package/.next-prod/static/css/ec2765469545dfce.css +1 -0
- package/.next-prod/static/qoIca6xp2OKAJtDEvMaXC/_buildManifest.js +1 -0
- package/.next-prod/trace +14 -14
- package/.next-prod/trace-build +1 -1
- package/.next-prod/types/app/api/session/user-messages/route.ts +353 -0
- package/.next-prod/types/routes.d.ts +2 -1
- package/.next-prod/types/validator.ts +9 -0
- package/dist/{cache-GIQJA4HL.mjs → cache-VBRI47HG.mjs} +28 -0
- package/dist/chunk-UG6WUXIQ.mjs +2907 -0
- package/dist/scheduledTasks.mjs +30 -4
- package/dist/wsServer.mjs +20 -2807
- package/package.json +1 -1
- package/public/html-lib/markdown.css +114 -70
- package/public/html-lib/markdown.js +12 -12
- package/public/tree-sitter/tree-sitter-lean.wasm +0 -0
- package/scripts/copy-tree-sitter-wasms.mjs +33 -3
- package/skills/cg/SKILL.md +140 -14
- package/.next-prod/server/chunks/2540.js +0 -1
- package/.next-prod/static/ZqxwSTxy2HJcALhnBemS7/_buildManifest.js +0 -1
- package/.next-prod/static/chunks/6024-31a42934bf55e9e9.js +0 -32
- package/.next-prod/static/chunks/7184-2a5621de437121a2.js +0 -17
- package/.next-prod/static/chunks/9092-f7267cbb4deb6fd5.js +0 -716
- package/.next-prod/static/chunks/app/_global-error/page-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/agent/test/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/bash/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/codex/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/deepseek/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/glm/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/kimi/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/ollama/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/stop/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/claude-stats/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/commands/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/comments/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/db/columns/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/db/connect/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/db/disconnect/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/db/export/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/db/query/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/db/schemas/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/deepseek/balance/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/deepseek/credentials/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/deepseek/models/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/dev/spans/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/extension/version/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/file/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/blame/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/clipboard/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/copy/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/delete/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/expanded/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/index/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/init/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/paste/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/read/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/readdir/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/recent/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/save/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/search/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/stat/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/files/text/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/git/blob/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/git/branch-diff/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/git/branches/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/git/commit-diff/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/git/commits/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/git/current-branch/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/git/diff/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/git/discard/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/git/stage/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/git/status/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/git/unstage/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/git/worktree/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/glm/credentials/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/glm/models/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/glm/usage/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/global-state/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/health/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/html-apps/[id]/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/html-apps/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/kimi/credentials/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/kimi/models/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/kimi/usage/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/definition/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/hover/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/references/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/status/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/warmup/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/columns/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/connect/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/disconnect/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/export/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/query/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/schemas/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/neo4j/connect/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/neo4j/query/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/neo4j/schema/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/note/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/ollama/config/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/ollama/models/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/ollama/start/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/open-cursor/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/open-vscode/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/pick-folder/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/pinned-sessions/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/project-settings/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/project-state/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/affected/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/callees/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/callers/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/context/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/file/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/impact/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/related/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/risk/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/search/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/projects/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/prompts/config/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/push/public-key/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/push/subscribe/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/push/unsubscribe/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/command/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/connect/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/delete/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/disconnect/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/get/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/keys/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/set/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/restart/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/review/[id]/comments/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/review/[id]/replies/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/review/[id]/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/review/identify/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/review/order/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/review/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/review/share-info/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/review/users/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/scheduled-tasks/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/services/config/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/services/scripts/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/session-by-path/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/sessions/projects/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/sessions/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/settings/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/shutdown/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/skills/[id]/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/skills/content/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/skills/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/snapshots/blob/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/snapshots/diff/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/snapshots/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/aliases/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/env/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/history/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/update/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/update-state/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/api/version/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/apps/[...path]/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/app/manifest.webmanifest/route-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-891e1a9c2b8144f7.js +0 -1
- package/.next-prod/static/css/ea27ccfe01ce807c.css +0 -1
- /package/.next-prod/static/{ZqxwSTxy2HJcALhnBemS7 → qoIca6xp2OKAJtDEvMaXC}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5390],{2228:(e,t,r)=>{r.d(t,{ProjectItem:()=>h});var n=r(95155),s=r(12115),o=r(79114),a=r(86957),l=r(68287),i=r(2111),d=r(53213);function c({number:e,status:t,isActive:r}){return(0,n.jsx)("span",{className:`flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center rounded-[4px] border font-mono text-[10px] font-medium leading-none tabular-nums transition-colors ${(0,l.c)(t,r)}`,"aria-hidden":"true",children:e})}function u({badge:e,onSelect:t}){return(0,n.jsx)("button",{type:"button",onClick:r=>{r.stopPropagation(),t(e.sessionId)},className:`flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border font-mono text-[9px] font-medium leading-none tabular-nums transition-transform hover:scale-125 ${(0,l.c)(e.status,!1)}`,title:e.label,children:e.label})}let m=[],x=()=>{};function h({index:e,name:t,cwd:r,isActive:l,collapsed:f,hasUnread:p,isLoading:g,sessionBadges:b,onClick:v,onSelectSession:j,onRemove:w,onOpenNote:k}){let{t:y}=(0,o.Bd)(),[N,C]=(0,s.useState)(!1),[S,L]=(0,s.useState)(null),M=(0,s.useCallback)(()=>{a.t4.runPromiseExit((0,d.ue)(r)).then(e=>{"Success"===e._tag&&L(e.value.branch)})},[r]);(0,s.useEffect)(()=>{M()},[M]);let E=(0,s.useCallback)(e=>{e?.type==="watch"&&Array.isArray(e.data)&&e.data.some(e=>"git"===e.type)&&M()},[M]);(0,i.h)({url:`/ws/watch?cwd=${encodeURIComponent(r)}`,onMessage:E});let P=b??m,T=S?f?`${t} \xb7 ${S}`:S:r;return(0,n.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1 rounded-lg cursor-pointer transition-colors relative ${f?"justify-center":""} ${l?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary hover:text-foreground"}`,onClick:v,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),"data-tooltip":T,children:[(0,n.jsx)(c,{number:e+1,status:f?g?"loading":p&&!l?"unread":"normal":"normal",isActive:l}),!f&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:`flex-1 truncate text-sm ${l?"text-brand":""}`,children:t}),N&&(0,n.jsxs)("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[k&&(0,n.jsx)("button",{className:"p-1 rounded hover:bg-hover text-muted-foreground hover:text-foreground transition-colors",onClick:e=>{e.stopPropagation(),k()},title:y("workspace.projectNotes"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,n.jsx)("button",{className:"p-1 rounded hover:bg-red-500/20 text-muted-foreground hover:text-red-11 transition-colors",onClick:e=>{e.stopPropagation(),w()},title:y("workspace.closeProject"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),P.length>0?(0,n.jsx)("div",{className:"flex items-center gap-1 flex-shrink-0",children:P.map(e=>(0,n.jsx)(u,{badge:e,onSelect:j??x},e.sessionId))}):l?(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}):null]})]})}},7578:(e,t,r)=>{r.d(t,{S:()=>o,l:()=>a});var n=r(95155),s=r(68287);function o(e){return"loading"===e||"unread"===e?e:"normal"}function a({projectNumber:e,sessionNumber:t,coordinate:r,status:o="normal",statusLabel:l,className:i=""}){if(r){let[n,s]=r.split(".");e??=n,t??=s}if(null==e&&null==t)return null;let d="flex h-4 w-4 items-center justify-center border",c=[e,t].filter(e=>null!=e).join(".");return(0,n.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[9px] font-medium leading-none tabular-nums flex-shrink-0 ${i}`,"aria-label":l?`${c} \xb7 ${l}`:c,children:[null!=e&&(0,n.jsx)("span",{className:`${d} rounded-[4px] ${(0,s.c)("normal",!1)}`,children:e}),null!=t&&(0,n.jsx)("span",{className:`${d} rounded-full ${(0,s.c)(o,!1)}`,title:l,children:t})]})}},11428:(e,t,r)=>{r.d(t,{ProjectSidebar:()=>V});var n=r(95155),s=r(12115),o=r(79114),a=r(2228),l=r(66109),i=r(86957),d=r(83448),c=r(92689),u=r(7578),m=r(84444);function x({isOpen:e,onClose:t,onSwitchProject:r,sessionNumbers:a={}}){let{t:h}=(0,o.Bd)(),[f,p]=(0,s.useState)([]),[g,b]=(0,s.useState)(!1),[v,j]=(0,s.useState)(null),[w,k]=(0,s.useState)(""),y=(0,s.useRef)(null),N=(0,s.useCallback)(async()=>{b(!0),j(null);let e=await i.t4.runPromiseExit((0,d.z2)());"Success"===e._tag?p([...e.value]):j(h("sessions.loadSessionsFailed")),b(!1)},[h]);(0,s.useEffect)(()=>{e&&(N(),setTimeout(()=>{y.current?.focus(),y.current?.select()},100))},[e,N]),(0,s.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,t]);let C=(0,m.H)(f).filter(e=>{if(!w)return!0;let t=w.toLowerCase();return void 0!==e.searchText?e.searchText.includes(t):e.cwd.toLowerCase().includes(t)||(e.title?.toLowerCase().includes(t)??!1)||(e.lastUserMessage?.toLowerCase().includes(t)??!1)||(e.firstMessages?.some(e=>e.toLowerCase().includes(t))??!1)||(e.lastMessages?.some(e=>e.toLowerCase().includes(t))??!1)});return e?(0,n.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:t}),(0,n.jsxs)("div",{className:l.aO,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:h("sessions.recentSessions")})}),(0,n.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("input",{ref:y,type:"text",placeholder:h("sessions.searchSessions"),value:w,onChange:e=>k(e.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),w&&(0,n.jsx)("button",{onClick:()=>{k(""),y.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:h("fileBrowser.clear"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[g&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,n.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,n.jsx)("span",{children:h("sessions.loadingSessions")})]})}),v&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("div",{className:"text-xs text-red-11",children:v})}),!g&&!v&&0===C.length&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:w?h("sessions.noMatchingSessions"):h("sessions.noSessions")})}),!g&&!v&&C.length>0&&(0,n.jsx)("div",{className:l.jL,children:C.map(e=>{let s;return(0,n.jsxs)("div",{onClick:()=>{r(e.cwd,e.sessionId),t()},className:"p-3 rounded border border-border hover:border-brand hover:shadow-lv2 cursor-pointer transition-all",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,n.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${"loading"===e.status?"bg-orange-11":"unread"===e.status?"bg-red-9":"bg-muted-foreground/30"}`}),(0,n.jsx)(c.S,{engine:e.engine}),(0,n.jsx)("h4",{className:"text-xs font-medium text-foreground truncate flex-1","data-tooltip":e.cwd,children:(s=e.cwd).split("/").pop()||s}),(0,n.jsx)(u.l,{coordinate:a[`${e.cwd}
|
|
2
|
+
${e.sessionId}`],status:(0,u.S)(e.status),statusLabel:"loading"===e.status?h("sessions.running"):"unread"===e.status?h("sessions.done"):void 0,className:"ml-auto"})]}),e.title&&(0,n.jsx)("div",{className:"text-xs font-medium text-foreground truncate mb-1","data-tooltip":e.title,children:e.title}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(e.lastActive).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(e.firstMessages?.length??0)>0||(e.lastMessages?.length??0)>0?(0,n.jsxs)("div",{className:"space-y-0.5 text-xs",children:[e.firstMessages?.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground truncate","data-tooltip":e,children:[(0,n.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),e]},`first-${t}`)),(e.lastMessages?.length??0)>0&&(0,n.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),e.lastMessages?.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground truncate","data-tooltip":e,children:[(0,n.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),e]},`last-${t}`))]}):e.lastUserMessage?(0,n.jsxs)("div",{className:"text-xs text-foreground truncate","data-tooltip":e.lastUserMessage,children:[(0,n.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),e.lastUserMessage]}):null]},`${e.cwd}-${e.sessionId}`)})})]})]})]}):null}var h=r(53213);let f=e=>e.split("/").pop()||e;function p({status:e,className:t=""}){return(0,n.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${"loading"===e?"bg-orange-11":"unread"===e?"bg-red-9":"bg-muted-foreground/30"} ${t}`})}function g(e,t){let r=Math.floor((Date.now()-t)/6e4);if(r<1)return e("common.justNow");if(r<60)return e("common.minutesAgo",{count:r});let n=Math.floor(r/60);return n<24?e("common.hoursAgo",{count:n}):e("common.daysAgo",{count:Math.floor(n/24)})}function b(e,t){return"loading"===t?e("sessions.running"):"unread"===t?e("sessions.done"):void 0}function v(){let[e,t]=(0,s.useState)(null),[r,n]=(0,s.useState)({}),o=(0,s.useCallback)((e,r)=>{let s=r.currentTarget.getBoundingClientRect(),o=s.top;o+260>window.innerHeight&&(o=Math.max(8,window.innerHeight-260-8)),t({session:e,top:o,left:s.right+8}),n(t=>e.cwd in t?t:(i.t4.runPromiseExit((0,h.ue)(e.cwd)).then(t=>{"Success"===t._tag&&n(r=>({...r,[e.cwd]:t.value.branch}))}),{...t,[e.cwd]:null}))},[]),a=(0,s.useCallback)(()=>t(null),[]);return{card:e,branch:e?r[e.session.cwd]??null:null,show:o,hide:a}}function j({card:e,branch:t}){if(!e)return null;let{session:r}=e,s=(r.firstMessages?.length??0)>0||(r.lastMessages?.length??0)>0;return(0,n.jsxs)("div",{className:"fixed z-[60] w-72 max-h-[260px] overflow-y-auto bg-popover border border-border rounded-lg shadow-lv2 p-3 pointer-events-none",style:{top:e.top,left:e.left},children:[(0,n.jsx)("div",{className:"text-xs font-medium text-foreground truncate",children:f(r.cwd)}),r.title&&(0,n.jsx)("div",{className:"text-xs font-medium text-foreground truncate mt-0.5",children:r.title}),(0,n.jsx)("div",{className:"text-[10px] text-foreground-faint truncate mt-0.5",children:r.cwd}),t&&(0,n.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-normal min-w-0",children:[(0,n.jsxs)("svg",{className:"w-3 h-3 flex-shrink-0 text-brand",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"6",cy:"6",r:"2.5"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"2.5"}),(0,n.jsx)("circle",{cx:"18",cy:"7",r:"2.5"}),(0,n.jsx)("path",{strokeLinecap:"round",d:"M6 8.5v7M8.5 6.5h4.5a3 3 0 013 3v0"})]}),(0,n.jsx)("span",{className:"truncate",children:t})]}),s?(0,n.jsxs)("div",{className:"space-y-0.5 text-xs border-t border-border/50 mt-2 pt-2",children:[r.firstMessages?.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground/90 truncate",children:[(0,n.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),e]},`f-${t}`)),(r.lastMessages?.length??0)>0&&(0,n.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),r.lastMessages?.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground/90 truncate",children:[(0,n.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),e]},`l-${t}`))]}):r.lastUserMessage?(0,n.jsx)("div",{className:"text-xs text-foreground/90 border-t border-border/50 mt-2 pt-2 line-clamp-3 break-words",children:r.lastUserMessage}):null]})}function w({currentCwd:e,onSwitchProject:t,onResolveSessionNumbers:r,collapsed:a,sessions:l}){let{t:i}=(0,o.Bd)(),d=(0,s.useMemo)(()=>(0,m.H)(l),[l]),[h,k]=(0,s.useState)(!1),[y,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)({}),L=(0,s.useRef)(0),M=(0,s.useRef)(null),E=v(),{show:P,hide:T}=E;(0,s.useEffect)(()=>{h||T()},[h,T]),(0,s.useEffect)(()=>{if(!h)return;let e=e=>{M.current&&!M.current.contains(e.target)&&k(!1)},t=()=>{k(!1)};return document.addEventListener("mousedown",e),window.addEventListener("blur",t),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("blur",t)}},[h]);let $=(0,s.useCallback)(e=>{t(e.cwd,e.sessionId),k(!1)},[t]),R=(0,s.useCallback)(()=>{let e=!h;if(k(e),e){let e=++L.current;S({}),r().then(t=>{L.current===e&&S(t)})}else L.current+=1},[h,r]),B=l.filter(e=>"loading"===e.status).length,F=l.filter(e=>"unread"===e.status).length;return(0,n.jsxs)("div",{className:"relative",ref:M,children:[(0,n.jsxs)("button",{onClick:R,className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${a?"w-full justify-center":"w-full"}`,title:a?i("sessions.recentSessions"):void 0,children:[(0,n.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),!a&&(0,n.jsx)("span",{className:"text-sm flex-1 text-left",children:i("sessions.recentSessions")}),B>0&&(0,n.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-foreground text-xs font-medium rounded-full flex items-center justify-center bg-orange-11/20 animate-pulse ${a?"absolute -top-1 -right-1":""}`,children:B}),F>0&&(0,n.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-foreground text-xs font-medium rounded-full flex items-center justify-center bg-red-9/55 ${a&&!B?"absolute -top-1 -right-1":""}`,children:F})]}),h&&(0,n.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 h-[600px] bg-popover border border-border rounded-lg shadow-lv2 z-50 flex flex-col",children:[(0,n.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg flex items-center",children:[(0,n.jsx)("span",{className:"text-sm font-medium",children:i("sessions.recentSessions")}),B>0&&(0,n.jsxs)("span",{className:"ml-2 text-xs text-orange-11",children:["(",i("sessions.runningCount",{count:B}),")"]}),F>0&&(0,n.jsxs)("span",{className:"ml-2 text-xs text-red-11",children:["(",i("sessions.unreadCount",{count:F}),")"]}),(0,n.jsxs)("button",{onClick:()=>{k(!1),N(!0)},className:"ml-auto flex items-center gap-1 p-1 -mr-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:i("sessions.searchRecentSessions"),children:[(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m21 21-4.35-4.35m2.35-5.4a7.75 7.75 0 1 1-15.5 0 7.75 7.75 0 0 1 15.5 0Z"})}),(0,n.jsx)("span",{className:"text-xs",children:i("sessions.search")})]})]}),(0,n.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===d.length?(0,n.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:i("sessions.noSessions")}):d.map((t,r)=>(0,n.jsxs)("button",{onClick:()=>$(t),onMouseEnter:e=>P(t,e),onMouseLeave:T,className:`w-full px-3 py-2 text-left hover:bg-hover transition-colors flex items-start gap-2 ${r!==d.length-1?"border-b border-border/50":""} ${e===t.cwd?"bg-accent/50":""}`,children:[(0,n.jsx)(p,{status:t.status,className:"mt-1.5"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(c.S,{engine:t.engine}),(0,n.jsx)("span",{className:"font-medium text-sm truncate",children:f(t.cwd)}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:g(i,t.lastActive)}),(0,n.jsx)(u.l,{coordinate:C[`${t.cwd}
|
|
3
|
+
${t.sessionId}`],status:(0,u.S)(t.status),statusLabel:b(i,t.status),className:"ml-auto"})]}),t.title&&(0,n.jsx)("div",{className:"text-xs font-medium text-foreground truncate","data-tooltip":t.title,children:t.title}),t.lastUserMessage&&(0,n.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:t.lastUserMessage})]})]},`${t.cwd}-${t.sessionId}`))})]}),(0,n.jsx)(j,{...E}),(0,n.jsx)(x,{isOpen:y,onClose:()=>N(!1),onSwitchProject:t,sessionNumbers:C})]})}var k=r(49433);let y=(e,t)=>`${e}
|
|
4
|
+
${t}`;function N({collapsed:e,pinnedSessions:t,sessionNumbers:r,currentCwd:a,onSwitchProject:l,onUnpin:m,onUpdateTitle:x,onReorder:h}){let{t:w}=(0,o.Bd)(),[C,S]=(0,s.useState)(!1),L=(0,s.useRef)(null),[M,E]=(0,s.useState)(null),[P,T]=(0,s.useState)(""),$=(0,s.useRef)(null),R=v(),{show:B,hide:F}=R,[I,D]=(0,s.useState)(null),[A,z]=(0,s.useState)(null),[H,W]=(0,s.useState)({});(0,s.useEffect)(()=>{C&&i.t4.runPromise((0,d.z2)().pipe(k.match({onSuccess:e=>W(Object.fromEntries(e.map(e=>[y(e.cwd,e.sessionId),e]))),onFailure:()=>{}})))},[C]),(0,s.useEffect)(()=>{if(!C)return;let e=e=>{L.current&&!L.current.contains(e.target)&&(S(!1),E(null))},t=()=>{S(!1),E(null)};return document.addEventListener("mousedown",e),window.addEventListener("blur",t),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("blur",t)}},[C]),(0,s.useEffect)(()=>{C||F()},[C,F]),(0,s.useEffect)(()=>{M&&($.current?.focus(),$.current?.select())},[M]);let _=(0,s.useCallback)(e=>{M||(l(e.cwd,e.sessionId),S(!1))},[l,M]),O=(0,s.useCallback)((e,t)=>{t.stopPropagation(),F(),E(e.sessionId),T(e.customTitle||"")},[F]),q=(0,s.useCallback)(()=>{M&&P.trim()&&x(M,P.trim()),E(null)},[M,P,x]),V=(0,s.useCallback)(e=>{F(),D(e)},[F]),U=(0,s.useCallback)((e,t)=>{e.preventDefault(),z(t)},[]),K=(0,s.useCallback)(e=>{if(null===I||I===e){D(null),z(null);return}let r=[...t],[n]=r.splice(I,1);r.splice(e,0,n),h(r),D(null),z(null)},[I,t,h]),G=(0,s.useCallback)(()=>{D(null),z(null)},[]);return(0,n.jsxs)("div",{className:"relative",ref:L,children:[(0,n.jsxs)("button",{onClick:()=>S(!C),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${e?"w-full justify-center":"w-full"}`,title:e?w("sessions.favorites"):void 0,children:[(0,n.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})}),!e&&(0,n.jsx)("span",{className:"text-sm flex-1 text-left",children:w("sessions.favorites")}),e&&t.length>0&&(0,n.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-popover border border-border",children:t.length})]}),C&&(0,n.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 max-h-[450px] bg-popover border border-border rounded-lg shadow-lv2 z-50 flex flex-col",children:[(0,n.jsx)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg",children:(0,n.jsx)("span",{className:"text-sm font-medium",children:w("sessions.favorites")})}),(0,n.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===t.length?(0,n.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:w("sessions.noFavorites")}):t.map((e,s)=>{let o=H[y(e.cwd,e.sessionId)],l=M===e.sessionId;return(0,n.jsxs)("div",{draggable:!0,onDragStart:()=>V(s),onDragOver:e=>U(e,s),onDrop:()=>K(s),onDragEnd:G,onClick:()=>_(e),onMouseEnter:t=>{l||B(o??{cwd:e.cwd,sessionId:e.sessionId,title:e.customTitle},t)},onMouseLeave:F,className:`group w-full px-3 py-2 text-left hover:bg-hover transition-colors flex items-start gap-2 cursor-pointer ${s!==t.length-1?"border-b border-border/50":""} ${a===e.cwd?"bg-accent/50":""} ${I===s?"opacity-50":""} ${A===s?"border-t-2 border-brand":""}`,children:[(0,n.jsx)("span",{className:"mt-1.5 text-muted-foreground/30 flex-shrink-0 cursor-grab",children:(0,n.jsxs)("svg",{className:"w-3 h-3",viewBox:"0 0 10 16",fill:"currentColor",children:[(0,n.jsx)("circle",{cx:"3",cy:"2",r:"1.5"}),(0,n.jsx)("circle",{cx:"7",cy:"2",r:"1.5"}),(0,n.jsx)("circle",{cx:"3",cy:"8",r:"1.5"}),(0,n.jsx)("circle",{cx:"7",cy:"8",r:"1.5"}),(0,n.jsx)("circle",{cx:"3",cy:"14",r:"1.5"}),(0,n.jsx)("circle",{cx:"7",cy:"14",r:"1.5"})]})}),(0,n.jsx)(p,{status:o?.status,className:"mt-1.5"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(c.S,{engine:o?.engine}),(0,n.jsx)("span",{className:"font-medium text-sm truncate",children:f(e.cwd)}),o?.lastActive?(0,n.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:g(w,o.lastActive)}):null,(0,n.jsx)(u.l,{coordinate:r?.[y(e.cwd,e.sessionId)],status:(0,u.S)(o?.status),statusLabel:b(w,o?.status),className:"ml-auto"})]}),l?(0,n.jsx)("input",{ref:$,type:"text",value:P,onChange:e=>T(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||("Enter"===e.key&&q(),"Escape"===e.key&&E(null))},onBlur:q,onClick:e=>e.stopPropagation(),className:"w-full text-xs px-1 py-0.5 border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring mt-0.5"}):(0,n.jsx)("div",{className:"text-xs font-medium text-foreground truncate",children:e.customTitle||o?.title||e.sessionId.slice(0,8)}),!l&&o?.lastUserMessage&&(0,n.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:o.lastUserMessage})]}),!l&&(0,n.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity mt-0.5",children:[(0,n.jsx)("button",{onClick:t=>O(e,t),className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:w("sessions.editTitle"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),F(),m(e.sessionId)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:w("sessions.removeFavorite"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},e.sessionId)})})]}),(0,n.jsx)(j,{...R})]})}var C=r(34075),S=r(23121),L=r(93777),M=r(95686),E=r(55779),P=r(67589);function T({task:e,onOpenSession:t}){let{t:r}=(0,o.Bd)(),{cwd:a,sessionId:l}=e,[d,c]=(0,s.useState)(null),u=(0,s.useRef)(void 0);(0,s.useEffect)(()=>{let e=!1,t=async()=>{let t=await i.t4.runPromiseExit((0,P.z)({cwd:a,sessionId:l,limit:20,ifFingerprint:u.current}));if(e)return;if("Success"!==t._tag||!t.value)return void c(e=>e??[]);let r=t.value;r.fingerprint&&(u.current=r.fingerprint),!r.notModified&&r.messages&&c(r.messages)};t();let r=setInterval(t,5e3);return()=>{e=!0,clearInterval(r)}},[a,l]);let m=(0,s.useRef)(null),x=(0,s.useRef)(null),h=(0,s.useRef)(!0),[f,p]=(0,s.useState)(!0),g=(0,s.useCallback)(()=>{let e=m.current;if(!e)return;let t=e.scrollTop+e.clientHeight>=e.scrollHeight-40;h.current=t,p(t||e.scrollTop<=40)},[]);return(0,s.useLayoutEffect)(()=>{let e=m.current;e&&h.current&&(e.scrollTop=e.scrollHeight)},[d]),(0,s.useEffect)(()=>{let e=x.current;if(!e)return;let t=new ResizeObserver(g);return t.observe(e),()=>t.disconnect()},[g,d]),(0,n.jsxs)("div",{className:"flex-1 flex flex-col h-full min-w-0",children:[(0,n.jsx)("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border flex-shrink-0",children:(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-xs font-medium text-foreground truncate","data-tooltip":a,children:(0,S.P_)(a)}),(0,n.jsx)("div",{className:"text-[11px] text-muted-foreground truncate","data-tooltip":(0,S.Q_)(e),children:(0,S.Q_)(e)})]})}),(0,n.jsxs)("div",{className:"relative flex-1 min-h-0 flex",children:[(0,n.jsx)("div",{ref:m,onScroll:g,className:"flex-1 overflow-y-auto px-4 py-3",children:null===d||0===d.length?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-6",children:r(null===d?"common.loading":"scheduledTasks.noTaskMessages")}):(0,n.jsx)("div",{ref:x,className:"[&_a]:pointer-events-none",children:d.map(e=>(0,n.jsx)(E.s,{message:e,cwd:a,disableOverlays:!0},e.id))})}),(0,n.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center pb-4",children:(0,n.jsxs)("button",{onClick:t,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-brand text-white text-sm font-medium shadow-lv3 hover:bg-brand/90 transition-opacity ${f?"opacity-100 pointer-events-auto":"opacity-0"}`,title:r("scheduledTasks.openSession"),children:[(0,n.jsx)("span",{children:r("scheduledTasks.openSession")}),(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7-7 7M3 12h18"})})]})})]})]})}function $(e){return e.engine||"claude"}function R(e){return e.lastFiredAt??e.createdAt}let B=[{key:"pendingReview",labelKey:"scheduledTasks.groupPendingReview"},{key:"upcoming",labelKey:"scheduledTasks.groupUpcoming"},{key:"paused",labelKey:"scheduledTasks.paused"}];function F({collapsed:e,tasks:t,unreadCount:r,sessionNumbers:a,onSwitchProject:m,onPause:x,onResume:h,onTrigger:f,onDelete:p,onMarkRead:g,onUpdateTask:b}){let{t:v}=(0,o.Bd)(),[j,w]=(0,s.useState)(!1),[k,y]=(0,s.useState)(null),N=(0,s.useRef)(null),E=(0,s.useRef)(null),[P,I]=(0,s.useState)(null),D=(0,s.useCallback)(()=>{y(null),N.current=null,I(null)},[]),[A,z]=(0,s.useState)(null),[H,W]=(0,s.useState)(null),[_,O]=(0,s.useState)(null),[q,V]=(0,s.useState)(null),U=t.filter(e=>!e.completed),K=U.filter(e=>!e.paused).length,G=(0,s.useMemo)(()=>(function(e){let t=[],r=[],n=[];for(let s of e)s.unread||s.completed?t.push(s):s.paused?n.push(s):r.push(s);return t.sort((e,t)=>Number(!!t.unread)-Number(!!e.unread)||R(t)-R(e)),r.sort((e,t)=>(e.nextFireTime||Number.MAX_SAFE_INTEGER)-(t.nextFireTime||Number.MAX_SAFE_INTEGER)),n.sort((e,t)=>R(t)-R(e)),{pendingReview:t,upcoming:r,paused:n}})(t),[t]),J=_?t.find(e=>e.id===_)??null:null;(0,s.useEffect)(()=>{if(!j||J)return;let e=G.pendingReview[0]??G.upcoming[0]??G.paused[0];O(e?.id??null)},[j,J,G]);let[,Q]=(0,s.useState)(0);(0,s.useEffect)(()=>{if(!j)return;let e=setInterval(()=>Q(e=>e+1),1e4);return()=>clearInterval(e)},[j]),(0,s.useEffect)(()=>{if(!A)return;let e=!1;return W(null),i.t4.runPromiseExit((0,d.an)(A)).then(t=>{e||("Success"===t._tag&&void 0!==t.value.content?W(t.value.content):((0,C.oR)(v("toast.readFileFailed"),"error"),z(null)))}),()=>{e=!0}},[A,v]);let Z=(0,s.useCallback)(()=>{z(null),W(null)},[]),X=(0,s.useCallback)(async e=>{let t=!!e.taskFile;try{await navigator.clipboard.writeText(t?e.taskFile:e.message),(0,C.oR)(v(t?"common.copiedPath":"toast.copiedMessage"),"success")}catch{(0,C.oR)(v("common.copyFailed"),"error")}},[v]),Y=(0,s.useCallback)(()=>{w(!1),O(null)},[]);(0,s.useEffect)(()=>{if(!j)return;let e=e=>{if("Escape"===e.key){if(A)return void Z();if(k)return void D();Y()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[j,k,A,Z,Y,D]),(0,s.useLayoutEffect)(()=>{if(!k)return;let e=()=>{let e=N.current,t=E.current;if(!e||!t)return;let r=e.getBoundingClientRect();if(!r.width&&!r.height)return;let{width:n,height:s}=t.getBoundingClientRect(),o=r.right+8;if(o+n>window.innerWidth-8){let e=r.left-n-8;o=e>=8?e:Math.max(8,window.innerWidth-n-8)}let a=Math.max(8,Math.min(r.top,window.innerHeight-s-8));I(e=>e&&e.top===a&&e.left===o?e:{top:a,left:o})};e();let t=new ResizeObserver(e);return E.current&&t.observe(E.current),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{t.disconnect(),window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[k]);let ee=(0,s.useCallback)(e=>{m(e.cwd,e.sessionId),e.unread&&g(e.id),Y()},[m,g,Y]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{onClick:()=>w(!0),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${e?"w-full justify-center":"w-full"}`,title:e?v("scheduledTasks.title"):void 0,children:[(0,n.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]}),!e&&(0,n.jsx)("span",{className:"text-sm flex-1 text-left",children:v("scheduledTasks.title")}),r>0?(0,n.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-foreground text-xs font-medium rounded-full flex items-center justify-center bg-red-9/55 ${e?"absolute -top-1 -right-1":""}`,children:r}):e&&t.length>0?(0,n.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-popover border border-border",children:t.length}):null]}),j&&(0,n.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:Y}),(0,n.jsxs)("div",{className:l.aO,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:v("scheduledTasks.title")}),U.length>0&&(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:[v("scheduledTasks.activeCount",{running:K}),U.length-K>0?` \xb7 ${v("scheduledTasks.pausedCount",{paused:U.length-K})}`:""]})]}),(0,n.jsx)("button",{onClick:Y,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("div",{className:"flex-1 flex min-h-0",children:0===t.length?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:v("scheduledTasks.noScheduledTasks")})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"w-full md:w-[360px] flex-shrink-0 md:border-r border-border overflow-y-auto p-3 space-y-4",children:B.map(({key:e,labelKey:t})=>{let r=G[e];return 0===r.length?null:(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"sticky top-0 z-10 -mx-3 px-3 py-1 bg-card text-[11px] font-medium text-muted-foreground",children:[v(t)," (",r.length,")"]}),(0,n.jsx)("div",{className:"mt-1 space-y-2",children:r.map(e=>{let t,r;return t=e.id===_,(0,n.jsxs)("div",{onClick:()=>O(e.id),onMouseLeave:()=>V(t=>t===e.id?null:t),className:`group p-3 rounded border cursor-pointer transition-all hover:border-brand hover:shadow-lv2 ${t?"border-brand bg-brand/5 shadow-lv2":e.unread?"border-brand/40 bg-brand/5":"border-border"} ${e.completed?"opacity-70":""}`,children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,n.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${e.unread?"bg-red-9":e.completed?"bg-muted-foreground/30":e.paused?"bg-amber-9":"error"===e.lastResult?"bg-red-9":"bg-green-9"}`}),(0,n.jsx)(c.S,{engine:$(e),tooltip:(r=$(e),e.model?`${r} \xb7 ${e.model}`:r)}),(0,n.jsx)("h4",{className:"text-xs font-medium text-foreground truncate flex-1","data-tooltip":e.cwd,children:(0,S.P_)(e.cwd)}),(0,n.jsx)(u.l,{coordinate:a?.[`${e.cwd}
|
|
5
|
+
${e.sessionId}`]}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0 group-hover:hidden",children:e.completed?v("scheduledTasks.completed"):e.paused?v("scheduledTasks.paused"):v("common.running")}),q===e.id?(0,n.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-1",children:[(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),V(null),p(e.id)},className:"px-2 py-0.5 text-[10px] rounded bg-red-9 text-white hover:bg-red-10",children:v("common.confirm")}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),V(null)},className:"px-2 py-0.5 text-[10px] rounded border border-border text-muted-foreground hover:text-foreground",children:v("common.cancel")})]}):(0,n.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.taskFile&&(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),z(e.taskFile)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:v("common.preview"),children:(0,n.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),X(e)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:v(e.taskFile?"common.copyPath":"common.copy"),children:(0,n.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),f(e.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-brand",title:v("scheduledTasks.runNow"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M8 5v14l11-7z"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),N.current=t.currentTarget,y(e)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:v("common.edit"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),e.completed?null:e.paused?(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),h(e.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-green-11",title:v("scheduledTasks.resume"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"})})}):(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),x(e.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-amber-11",title:v("scheduledTasks.pause"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 9v6m4-6v6"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),V(e.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:v("common.delete"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,n.jsx)("div",{className:"text-xs text-foreground line-clamp-3 mb-1 whitespace-pre-wrap break-words","data-tooltip":(0,S.Q_)(e),children:(0,S.Q_)(e)}),(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:"truncate",children:function(e,t){if("once"===e.type)return t("scheduledTasks.onceType",{minutes:e.delayMinutes});if("interval"===e.type){let r=t("scheduledTasks.everyNMinutes",{minutes:e.intervalMinutes});return e.activeFrom&&e.activeTo?`${r} (${e.activeFrom}-${e.activeTo})`:r}return"cron"===e.type?e.cron||"cron":e.type}(e,v)}),(0,n.jsx)("span",{children:"\xb7"}),(0,n.jsx)("span",{className:"flex-shrink-0",children:e.completed?"success"===e.lastResult?v("scheduledTasks.success"):v("scheduledTasks.failure"):e.paused?v("scheduledTasks.paused"):function(e,t){if(!e)return"-";let r=e-Date.now();if(r<=0)return t("scheduledTasks.aboutToTrigger");if(r<6e4)return t("scheduledTasks.secondsLater",{count:Math.ceil(r/1e3)});if(r<36e5)return t("scheduledTasks.minutesLater",{count:Math.ceil(r/6e4)});if(r<864e5){let e=Math.floor(r/36e5),n=Math.ceil(r%36e5/6e4);return n>0?t("scheduledTasks.hoursMinutesLater",{h:e,m:n}):t("scheduledTasks.hoursLater",{h:e})}return new Date(e).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(e.nextFireTime,v)}),!e.completed&&e.lastFiredAt&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{children:"\xb7"}),(0,n.jsxs)("span",{className:"flex-shrink-0",children:[v("scheduledTasks.lastResult"),": ","success"===e.lastResult?"✓":"✗"]})]})]})]},e.id)})})]},e)})}),(0,n.jsx)("div",{className:"hidden md:flex flex-1 min-w-0",children:J?(0,n.jsx)(T,{task:J,onOpenSession:()=>ee(J)},J.id):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-xs text-muted-foreground",children:v("scheduledTasks.selectTaskHint")})})]})})]})]}),A&&null!==H&&(0,n.jsx)(M.x,{filePath:A,content:H,cwd:A.slice(0,Math.max(0,A.lastIndexOf("/"))),onClose:Z,zClassName:"z-[80]"}),k&&(0,n.jsx)("div",{ref:E,className:"fixed z-[100]",style:{top:P?.top??0,left:P?.left??0,visibility:P?"visible":"hidden"},children:(0,n.jsx)(L.E,{onClose:D,onCreate:()=>{},editTask:{id:k.id,message:k.message,taskFile:k.taskFile,type:k.type,delayMinutes:k.delayMinutes,intervalMinutes:k.intervalMinutes,activeFrom:k.activeFrom,activeTo:k.activeTo,cron:k.cron},onUpdate:(e,t)=>{b(e,t),D()}})})]})}var I=r(3292),D=r(2111),A=r(76900),z=r(72363),H=r(94852),W=r(60285);function _({className:e=""}){return(0,n.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("rect",{x:"4",y:"4",width:"6",height:"6",rx:"1.5"}),(0,n.jsx)("rect",{x:"4",y:"14",width:"6",height:"6",rx:"1.5"}),(0,n.jsx)("rect",{x:"14",y:"14",width:"6",height:"6",rx:"1.5"}),(0,n.jsx)("path",{d:"M17 3v8"}),(0,n.jsx)("path",{d:"M13 7h8"})]})}function O({item:e,active:t,onClick:r,className:s=""}){return(0,n.jsx)("button",{type:"button",onClick:r,className:`h-8 w-8 rounded-md border bg-transparent text-muted-foreground hover:text-brand hover:border-brand/70 active:scale-95 transition-all flex items-center justify-center ${t?"border-brand/80 text-brand":"border-border/70"} ${s}`,title:`${e.title}
|
|
6
|
+
${e.path}`,children:e.icon?(0,n.jsx)("span",{className:"text-base leading-none",children:e.icon}):(0,n.jsx)(H.A,{className:"w-4 h-4"})})}function q({collapsed:e,previews:t,activePath:r,onOpenApps:a,onShowPreview:l}){let{t:i}=(0,o.Bd)(),[d,c]=(0,s.useState)(null),u=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!d)return;let e=e=>{u.current?.contains(e.target)||c(null)};return document.addEventListener("mousedown",e,!0),()=>document.removeEventListener("mousedown",e,!0)},[d]);let m=t.length>4,x=m?t.slice(0,3):t.slice(0,4),h=m?t.slice(3):[],f=(0,n.jsxs)("button",{type:"button",onClick:()=>{a(),c(null)},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:i("htmlApps.title"),children:[(0,n.jsx)("span",{className:"h-7 w-7 flex-shrink-0 rounded-md border border-border/70 bg-transparent flex items-center justify-center",children:(0,n.jsx)(_,{className:"w-4 h-4"})}),(0,n.jsx)("span",{className:"min-w-0 flex-1",children:(0,n.jsx)("span",{className:"block text-xs font-medium truncate",children:i("htmlApps.title")})})]},"html-apps-list"),p=e=>{l(e),c(null)},g=e=>(0,n.jsxs)("div",{className:"max-h-[19.75rem] overflow-y-auto p-1.5 space-y-1",children:[f,e.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>p(e),className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left hover:bg-hover transition-colors ${r===e.path?"text-brand":"text-muted-foreground hover:text-foreground"}`,title:e.path,children:[(0,n.jsx)("span",{className:"h-7 w-7 flex-shrink-0 rounded-md border border-border/70 bg-transparent flex items-center justify-center",children:e.icon?(0,n.jsx)("span",{className:"text-base leading-none",children:e.icon}):(0,n.jsx)(H.A,{className:"w-4 h-4"})}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block text-xs font-medium truncate",children:e.title}),(0,n.jsx)("span",{className:"block text-[10px] font-mono text-muted-foreground truncate",children:e.path})]})]},e.path))]});return e?(0,n.jsxs)("div",{ref:u,className:"relative p-2 border-t border-border",children:[(0,n.jsx)("button",{type:"button",onClick:()=>c(e=>"collapsed"===e?null:"collapsed"),className:`w-full h-8 rounded-md border bg-transparent text-muted-foreground hover:text-brand hover:border-brand/70 transition-colors flex items-center justify-center ${r?"border-brand/80 text-brand":"border-border/70"}`,title:i("htmlApps.title"),children:(0,n.jsx)(_,{className:"w-4 h-4"})}),"collapsed"===d&&(0,n.jsx)("div",{className:"absolute left-full bottom-0 ml-2 w-64 rounded-lg border border-border bg-card shadow-lv3 z-50",children:g(t)})]}):(0,n.jsx)("div",{ref:u,className:"p-2 border-t border-border",children:(0,n.jsxs)("div",{className:"grid grid-cols-5 gap-1.5",children:[(0,n.jsx)("button",{type:"button",onClick:a,className:"h-8 w-8 rounded-md border border-border/70 bg-transparent text-muted-foreground hover:text-brand hover:border-brand/70 active:scale-95 transition-all flex items-center justify-center",title:i("htmlApps.title"),children:(0,n.jsx)(_,{className:"w-4 h-4"})}),x.map(e=>(0,n.jsx)(O,{item:e,active:r===e.path,onClick:()=>p(e)},e.path)),m&&(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("button",{type:"button",onClick:()=>c(e=>"more"===e?null:"more"),className:"h-8 w-8 rounded-md border border-border/70 bg-transparent text-muted-foreground hover:text-brand hover:border-brand/70 transition-colors flex items-center justify-center",title:i("common.loadMore"),children:(0,n.jsx)(W.A,{className:"w-4 h-4"})}),"more"===d&&(0,n.jsx)("div",{className:"absolute left-0 bottom-full mb-2 w-64 rounded-lg border border-border bg-card shadow-lv3 z-50",children:g(h)})]})]})})}function V({projects:e,activeIndex:t,collapsed:r,currentCwd:l,onSelectProject:d,onRemoveProject:c,onReorderProjects:u,onToggleCollapse:m,onOpenSessionBrowser:x,onOpenSettings:h,onOpenNote:f,onOpenSkills:p,onOpenApps:g,htmlAppPreviews:b,activeHtmlAppPreviewPath:v,onShowHtmlAppPreview:j,onSwitchProject:k,onResolveSessionNumbers:y,sessionOrders:L,sessionNumbers:M}){let E,P,{t:T,i18n:$}=(0,o.Bd)(),{latest:R,hasUpdate:B}=function(){let[e,t]=(0,s.useState)(),[r,n]=(0,s.useState)();(0,s.useEffect)(()=>{let e=!1;i.t4.runPromiseExit((0,A.Wr)()).then(r=>{!e&&"Success"===r._tag&&r.value.version&&t(r.value.version)});let r=new AbortController,s=setTimeout(()=>r.abort(),3e3);return fetch("https://registry.npmjs.org/@surething/cockpit/latest",{signal:r.signal}).then(e=>e.ok?e.json():null).then(t=>{if(e)return;let r=t?.version;"string"==typeof r&&n(r)}).catch(()=>{}).finally(()=>clearTimeout(s)),()=>{e=!0,r.abort(),clearTimeout(s)}},[]);let[o,a]=(0,s.useState)(!1);(0,s.useEffect)(()=>{a(!0===window.__COCKPIT_FORCE_UPDATE__)},[]);let l=!!e&&!!r&&function(e,t){let r=e=>e.replace(/^v/,"").split("-")[0].split(".").map(e=>parseInt(e,10)||0),n=r(e),s=r(t),o=Math.max(n.length,s.length);for(let e=0;e<o;e++){let t=n[e]??0,r=s[e]??0;if(t!==r)return t-r}return 0}(r,e)>0;return{current:e,latest:o?r??"999.0.0":r,hasUpdate:!!o||l}}(),[H,W]=(0,s.useState)(!1),_=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!H)return;let e=e=>{_.current?.contains(e.target)||W(!1)},t=()=>W(!1);return document.addEventListener("mousedown",e,!0),window.addEventListener("blur",t),()=>{document.removeEventListener("mousedown",e,!0),window.removeEventListener("blur",t)}},[H]);let O=(0,s.useCallback)(()=>{navigator.clipboard.writeText("cockpit update"),(0,C.oR)(T("workspace.upgradeCommandCopied")),W(!1)},[T]),{isUpdating:U,start:K}=(E=(0,s.useSyncExternalStore)(z.N4,z.fX,z.fX),P=(0,s.useCallback)(()=>{(0,z._I)()},[]),{isUpdating:E.visible&&"done"!==E.stage&&"failed"!==E.stage,start:P}),G=(0,s.useCallback)(()=>{W(!1),K()},[K]),{pinnedSessions:J,unpinSession:Q,updateTitle:Z,reorder:X}=(0,I.P)(),{tasks:Y,unreadCount:ee,reload:et,pauseTask:er,resumeTask:en,triggerTask:es,deleteTask:eo,updateTask:ea,markRead:el}=(0,S.nS)(),[ei,ed]=(0,s.useState)(null),[ec,eu]=(0,s.useState)(null),[em,ex]=(0,s.useState)([]),eh=(0,s.useRef)(em);(0,s.useEffect)(()=>{eh.current=em});let ef=(0,s.useRef)(et);(0,s.useEffect)(()=>{ef.current=et});let ep=(0,s.useCallback)(e=>{try{if("task-fired"===e.type)return void ef.current();let{data:t}=e;if(!t)return;ex(t.sessions||[])}catch{}},[]);(0,D.h)({url:"/ws/global-state",onMessage:ep});let eg=new Set(em.filter(e=>"loading"===e.status).map(e=>e.cwd)),eb=new Set(em.filter(e=>"unread"===e.status).map(e=>e.cwd)),ev=(0,s.useMemo)(()=>{let t=new Map;for(let r of e){let e=L[r.cwd]??[],n=em.filter(e=>e.cwd===r.cwd&&("loading"===e.status||"unread"===e.status)).map(t=>({session:t,position:e.indexOf(t.sessionId)})).sort((e,t)=>e.position>=0&&t.position>=0?e.position-t.position:e.position>=0?-1:t.position>=0?1:t.session.lastActive-e.session.lastActive).slice(0,3).map(({session:e,position:t})=>({sessionId:e.sessionId,label:t>=0?String(t+1):"\xb7",status:"loading"===e.status?"loading":"unread"}));n.length>0&&t.set(r.cwd,n)}return t},[e,em,L]),ej=(0,s.useCallback)(e=>{ed(e)},[]),ew=(0,s.useCallback)((e,t)=>{e.preventDefault(),null!==ei&&ei!==t&&eu(t)},[ei]),ek=(0,s.useCallback)(t=>{if(null!==ei&&ei!==t){let r=[...e],[n]=r.splice(ei,1);r.splice(t,0,n),u(r)}ed(null),eu(null)},[ei,e,u]),ey=(0,s.useCallback)(()=>{ed(null),eu(null)},[]);return(0,n.jsxs)("div",{className:`h-full bg-card border-r border-border flex flex-col transition-all duration-200 ${r?"w-12":"w-56"}`,children:[(0,n.jsxs)("div",{className:"group p-2 border-b border-border relative",children:[(0,n.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${r?"justify-center":""}`,onClick:x,title:r?T("workspace.openProject"):void 0,children:[(0,n.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M12 10v6m3-3H9m-4 7h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),!r&&(0,n.jsx)("span",{className:"text-sm",children:T("workspace.openProject")})]}),r?(0,n.jsx)("button",{className:"absolute inset-0 m-2 flex items-center justify-center px-2 py-2 rounded-lg bg-popover shadow-lv1 text-foreground transition z-10 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100",onClick:m,title:T("workspace.expandSidebar"),children:(0,n.jsx)("svg",{className:"w-5 h-5 flex-shrink-0 rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}):(0,n.jsx)("button",{className:"absolute top-1/2 -translate-y-1/2 right-2 p-2 rounded-lg bg-popover shadow-lv1 text-foreground transition z-10 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100",onClick:m,title:T("workspace.collapseSidebar"),children:(0,n.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:e.map((e,s)=>{var o;let l;return(0,n.jsx)("div",{draggable:!0,onDragStart:()=>ej(s),onDragOver:e=>ew(e,s),onDrop:()=>ek(s),onDragEnd:ey,className:`${ec===s?"border-t-2 border-brand":""} ${ei===s?"opacity-50":""}`,children:(0,n.jsx)(a.ProjectItem,{index:s,name:(l=(o=e.cwd).split("/").filter(Boolean))[l.length-1]||o,cwd:e.cwd,isActive:s===t,collapsed:r,hasUnread:eb.has(e.cwd),isLoading:eg.has(e.cwd),sessionBadges:ev.get(e.cwd),onClick:()=>d(s),onSelectSession:t=>k(e.cwd,t),onRemove:()=>c(s),onOpenNote:()=>f(e.cwd)})},e.cwd)})}),(0,n.jsx)(q,{collapsed:r,previews:b,activePath:v,onOpenApps:g,onShowPreview:j}),(0,n.jsxs)("div",{className:"p-2 border-t border-border space-y-1",children:[(0,n.jsx)(w,{currentCwd:l,onSwitchProject:k,onResolveSessionNumbers:y,collapsed:r,sessions:em}),(0,n.jsx)(N,{collapsed:r,pinnedSessions:J,sessionNumbers:M,currentCwd:l,onSwitchProject:k,onUnpin:Q,onUpdateTitle:Z,onReorder:X}),(0,n.jsx)(F,{collapsed:r,tasks:Y,unreadCount:ee,sessionNumbers:M,onSwitchProject:k,onPause:er,onResume:en,onTrigger:es,onDelete:eo,onMarkRead:el,onUpdateTask:ea}),(0,n.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${r?"justify-center":""}`,onClick:()=>f(),title:r?T("workspace.notes"):void 0,children:[(0,n.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),!r&&(0,n.jsx)("span",{className:"text-sm",children:T("workspace.notes")})]}),(0,n.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${r?"justify-center":""}`,onClick:p,title:r?T("workspace.skills"):void 0,children:[(0,n.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3l1.9 4.8L19 9l-4.1 3.1L16 18l-4-2.8L8 18l1.1-5.9L5 9l5.1-1.2L12 3z"})}),!r&&(0,n.jsx)("span",{className:"text-sm",children:T("workspace.skills")})]}),(0,n.jsxs)("div",{className:`relative flex items-center gap-2 px-2 py-2 rounded-lg cursor-pointer text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${r?"justify-center":""}`,onClick:h,title:T("workspace.settings"),children:[(0,n.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,n.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),r&&B&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500",title:R?T("workspace.updateAvailable",{version:R}):void 0})]}),!r&&(0,n.jsx)("span",{className:"flex-1 text-sm",children:T("workspace.settings")}),!r&&B&&R&&(0,n.jsxs)("div",{ref:_,className:"relative -mr-2",children:[(0,n.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),W(e=>!e)},className:"px-1.5 py-0.5 rounded text-xs font-mono font-medium text-brand hover:bg-brand/10 transition-colors",title:T("workspace.updateAvailable",{version:R}),"aria-label":T("workspace.updateAvailable",{version:R}),children:["v",R]}),H&&(0,n.jsxs)("div",{className:"absolute left-full bottom-full ml-2 mb-1 w-56 rounded-lg border border-border bg-popover shadow-lv2 p-2 z-50",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("div",{className:"text-xs text-muted-foreground mb-2 px-1",children:T("workspace.updateAvailable",{version:R})}),(0,n.jsxs)("button",{type:"button",onClick:G,disabled:U,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm text-left\n hover:bg-hover transition-colors disabled:opacity-60 disabled:cursor-default",children:[U?(0,n.jsxs)("svg",{className:"w-3.5 h-3.5 flex-shrink-0 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:4}),(0,n.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}):(0,n.jsx)("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),(0,n.jsx)("span",{className:"flex-1",children:U?T("workspace.updating"):T("workspace.updateNow")})]}),(0,n.jsxs)("button",{type:"button",onClick:O,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm text-left hover:bg-hover transition-colors",children:[(0,n.jsxs)("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2})]}),(0,n.jsx)("span",{className:"flex-1",children:T("workspace.copyUpgradeCommand")})]}),(0,n.jsxs)("a",{href:`https://opencockpit.dev/${$.language?.startsWith("zh")?"zh":"en"}/changelog/`,target:"_blank",rel:"noopener",onClick:()=>W(!1),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm hover:bg-hover transition-colors",children:[(0,n.jsx)("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,n.jsx)("span",{className:"flex-1",children:T("workspace.viewChangelog")}),(0,n.jsx)("svg",{className:"w-3 h-3 flex-shrink-0 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]}),!r&&(0,n.jsx)("a",{href:`https://opencockpit.dev/${$.language?.startsWith("zh")?"zh":"en"}/docs/get-started/quickstart/`,target:"_blank",rel:"noopener",className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",onClick:e=>e.stopPropagation(),title:T("workspace.help"),"aria-label":T("workspace.help"),children:(0,n.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),(0,n.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2})]})})]})]})]})}},12786:(e,t,r)=>{r.d(t,{L:()=>s,Mu:()=>o});var n=r(41463);function s(){return!("u"<typeof navigator)&&(/Mac|iPhone|iPad/.test(navigator.platform||"")||navigator.userAgentData?.platform==="macOS")}function o(){return s()?"⌘":"Ctrl+"}n.platform,n.platform,n.platform},21484:(e,t,r)=>{r.d(t,{SettingsModal:()=>x});var n=r(95155),s=r(12115),o=r(79114),a=r(3238),l=r(34075),i=r(12786),d=r(53853),c=r(86957),u=r(49433),m=r(76900);function x({isOpen:e,onClose:t}){let{t:r,i18n:h}=(0,o.Bd)(),{theme:f,setTheme:p}=(0,a.DP)(),g=(0,d.G)(),[b,v]=(0,s.useState)(""),[j,w]=(0,s.useState)(""),[k,y]=(0,s.useState)(null),[N,C]=(0,s.useState)("auto");(0,s.useEffect)(()=>{e&&c.t4.runPromiseExit((0,m.M5)()).then(e=>{"Success"===e._tag&&e.value.language&&C(e.value.language)})},[e]);let S=(0,s.useCallback)(e=>{C(e),c.t4.runFork((0,m.DZ)({language:e}).pipe(u.orElse(()=>u.void)));let t="auto"===e?navigator.language.startsWith("zh")?"zh":"en":e;h.changeLanguage(t)},[h]),L=g?"installed":"not-installed",M=g?.version??null;if((0,s.useEffect)(()=>{e&&c.t4.runPromiseExit((0,m.Wr)()).then(e=>{"Success"===e._tag&&(e.value.version&&w(e.value.version),e.value.agents&&y(e.value.agents))})},[e]),(0,s.useEffect)(()=>{e&&c.t4.runPromiseExit((0,m.Or)()).then(e=>{"Success"===e._tag&&e.value.path&&v(e.value.path)})},[e]),!e)return null;let E=[{value:"system",label:r("settings.themeSystem"),icon:"\uD83D\uDCBB"},{value:"light",label:r("settings.themeLight"),icon:"☀️"},{value:"dark",label:r("settings.themeDark"),icon:"\uD83C\uDF19"}];return(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:t}),(0,n.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-2xl mx-4 overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:r("settings.title")}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsxs)("div",{className:"p-4 space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:r("settings.theme")}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-2",children:E.map(e=>(0,n.jsxs)("button",{onClick:()=>p(e.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${f===e.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,n.jsx)("span",{className:"text-xl",children:e.icon}),(0,n.jsx)("span",{className:"text-xs font-medium",children:e.label})]},e.value))})]}),(0,n.jsx)("div",{className:"border-t border-border"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:r("settings.language")}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{value:"auto",label:r("settings.languageAuto"),icon:"\uD83C\uDF10"},{value:"en",label:"English",icon:"\uD83C\uDDFA\uD83C\uDDF8"},{value:"zh",label:"中文",icon:"\uD83C\uDDE8\uD83C\uDDF3"}].map(e=>(0,n.jsxs)("button",{onClick:()=>S(e.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${N===e.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,n.jsx)("span",{className:"text-xl",children:e.icon}),(0,n.jsx)("span",{className:"text-xs font-medium",children:e.label})]},e.value))})]}),(0,n.jsx)("div",{className:"border-t border-border"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:r("settings.browserExtension")}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${"installed"===L?"bg-green-500":"bg-slate-400"}`}),(0,n.jsxs)("span",{children:["installed"===L&&`${r("settings.extensionInstalled")}${M?` (v${M})`:""}`,"not-installed"===L&&r("settings.extensionNotInstalled")]})]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:r("settings.extensionDescription")}),"installed"!==L&&(0,n.jsxs)("div",{className:"text-xs text-muted-foreground bg-muted/50 rounded-md p-2 space-y-1",children:[(0,n.jsx)("p",{className:"font-medium text-foreground",children:r("settings.installSteps")}),(0,n.jsxs)("p",{children:[r("settings.step1")," ",(0,n.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-foreground",children:"chrome://extensions"})]}),(0,n.jsx)("p",{children:r("settings.step2")}),(0,n.jsx)("p",{children:r("settings.step3")}),(0,i.L)()&&(0,n.jsx)("p",{dangerouslySetInnerHTML:{__html:r("settings.step4mac")}})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{onClick:()=>{let e=b||"chrome-extension";navigator.clipboard.writeText(e),(0,l.oR)(r("toast.copiedName",{name:e}))},className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:r("settings.copyExtensionPath")}),"installed"===L&&(0,n.jsx)("button",{onClick:()=>{g?.id&&window.chrome?.runtime?.sendMessage&&(window.chrome.runtime.sendMessage(g.id,{type:"reload"}),(0,l.oR)(r("toast.pluginReloading")))},className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-muted transition-colors",children:r("settings.reloadExtension")})]}),b&&(0,n.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono truncate",children:b})]})]}),(0,n.jsx)("div",{className:"border-t border-border"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:r("settings.about")}),(0,n.jsxs)("div",{className:"text-xs text-muted-foreground space-y-1",children:[(0,n.jsxs)("p",{children:["Cockpit",j?` v${j}`:""]}),(k?.claude||k?.codex)&&(0,n.jsx)("p",{className:"text-muted-foreground/60",children:[k.claude&&`Claude Code ${k.claude}`,k.codex&&`Codex ${k.codex}`,r("settings.agentsBundled")].filter(Boolean).join(" \xb7 ")}),(0,n.jsx)("p",{className:"text-muted-foreground/60",children:"One seat. One AI. Everything under control."})]})]})]})]})]})}},23121:(e,t,r)=>{r.d(t,{P_:()=>m,Q_:()=>x,nS:()=>p});var n=r(12115),s=r(95045),o=r(75346),a=r(49433),l=r(69809),i=r(34075),d=r(86957),c=r(82680);let u=(e,t,r)=>a.tryPromise({try:async()=>{let n=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()},catch:r=>new c.uV({message:`${t} ${e} failed`,cause:r})});function m(e){return e.split("/").pop()||e}function x(e){return e.resolvedPrompt||e.message||e.taskFile||""}let h="SCHEDULED_TASKS_CHANGED";function f(){(0,s.F)(o.n.ScheduledTasksChanged,{}),document.querySelectorAll("iframe").forEach(e=>{try{e.contentWindow?.postMessage({type:h},"*")}catch{}})}function p(){let[e,t]=(0,n.useState)([]),[r,s]=(0,n.useState)(0),o=(0,n.useCallback)(()=>{let e;d.t4.runPromise((e="/api/scheduled-tasks",a.tryPromise({try:async()=>{let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status}`);return await t.json()},catch:t=>new c.uV({message:`fetch ${e} failed`,cause:t})})).pipe(a.match({onSuccess:e=>{t(e.tasks??[]),s(e.unreadCount??0)},onFailure:()=>{}})))},[]);(0,n.useEffect)(()=>{o()},[o]),(0,n.useEffect)(()=>{let e=e=>{e.data?.type===h&&o()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[o]);let m=(0,n.useCallback)(async e=>{let t=await d.t4.runPromiseExit(u("/api/scheduled-tasks","POST",{language:l.A.language,...e}));if("Success"!==t._tag)return null;let r=t.value;return r.task?(o(),f(),r.task):null},[o]),x=(0,n.useCallback)(async e=>{await d.t4.runPromise(u("/api/scheduled-tasks","PATCH",e).pipe(a.asVoid).pipe(a.orElse(()=>a.void))),o(),f()},[o]),p=(0,n.useCallback)(e=>x({id:e,action:"pause"}),[x]),g=(0,n.useCallback)(e=>x({id:e,action:"resume"}),[x]),b=(0,n.useCallback)(async e=>{await d.t4.runPromise(u("/api/scheduled-tasks","DELETE",{id:e}).pipe(a.asVoid).pipe(a.as(!0),a.orElseSucceed(()=>!1)))||(0,i.oR)(l.A.t("scheduledTasks.deleteFailed"),"error"),o(),f()},[o]),v=(0,n.useCallback)((e,t)=>x({id:e,action:"update",fields:{...t,language:l.A.language}}),[x]),j=(0,n.useCallback)(e=>x({id:e,action:"trigger"}),[x]),w=(0,n.useCallback)(e=>x({id:e,action:"markRead"}),[x]);return{tasks:e,unreadCount:r,reload:o,createTask:m,pauseTask:p,resumeTask:g,triggerTask:j,deleteTask:b,updateTask:v,markRead:w,markAllRead:(0,n.useCallback)(()=>x({action:"markAllRead"}),[x]),reorderTasks:(0,n.useCallback)(e=>x({action:"reorder",fields:{orderedIds:e}}),[x])}}},24058:(e,t,r)=>{r.d(t,{TabBar:()=>x});var n=r(95155),s=r(12115),o=r(68287),a=r(57125),l=r(92689),i=r(94287),d=r(64428),c=r(79114);function u({number:e,status:t,isActive:r}){return(0,n.jsx)("span",{className:`flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border font-mono text-[9px] font-medium leading-none tabular-nums transition-colors ${(0,o.c)(t,r)}`,"aria-hidden":"true",children:e})}function m({onNewTab:e,onNewCodexTab:t,onNewKimiTab:r,onNewGlmTab:o,onNewOllamaTab:l,onNewDeepseekTab:i}){let[c,u]=(0,s.useState)(!1),x=(0,s.useRef)(null),h=(0,s.useRef)(null),[f,p]=(0,s.useState)({top:0,right:0}),g=(0,d.F2)();return(0,s.useEffect)(()=>{if(!c)return;let e=e=>{h.current&&!h.current.contains(e.target)&&x.current&&!x.current.contains(e.target)&&u(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[c]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{ref:x,onClick:()=>{if(!c&&x.current){let e=x.current.getBoundingClientRect(),t=g?.getBoundingClientRect(),r=t?.left??0,n=t?.top??0,s=t?.width??window.innerWidth;p({top:e.bottom+4-n,right:s-(e.right-r)})}u(e=>!e)},className:"flex-shrink-0 p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:"New tab",children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),c&&(0,n.jsx)(d.ZL,{children:(0,n.jsx)("div",{ref:h,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lv2 py-1 min-w-[140px]",style:{top:f.top,right:f.right},children:a.CX.map(s=>(0,n.jsxs)("button",{onClick:()=>{u(!1),"codex"===s?t?.():"kimi"===s?r?.():"glm"===s?o?.():"ollama"===s?l?.():"deepseek"===s?i?.():e()},className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)(a.eV,{engine:s,className:"h-3.5 w-3.5"}),a.H[s]]},s))})})]})}function x({tabs:e,selectedTabId:t,unreadTabs:r,dragTabIndex:s,dragOverTabIndex:o,isPinned:a,onTogglePin:d,onSwitchTab:h,onCloseTab:f,onCloseAllTabs:p,onNewTab:g,onNewCodexTab:b,onNewKimiTab:v,onNewGlmTab:j,onNewOllamaTab:w,onNewDeepseekTab:k,onOpenProjectSessions:y,onDragStart:N,onDragOver:C,onDrop:S,onDragEnd:L,sideBySide:M,onToggleSideBySide:E}){let{t:P}=(0,c.Bd)();return(0,n.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,n.jsxs)("div",{className:"flex items-center px-2 gap-1 overflow-x-auto",children:[e.map((e,c)=>{let m=e.id===t,x=a?.(e.id)??!1,p=x?P("sessions.removeFavorite"):P("sessions.addFavorite"),g=e.isLoading?"loading":r.has(e.id)&&!m?"unread":"normal";return(0,n.jsx)(i.m,{content:e.title,delay:200,className:"flex-1 min-w-16 max-w-[260px]",children:(0,n.jsxs)("div",{draggable:!0,onDragStart:()=>N(c),onDragOver:e=>C(e,c),onDrop:()=>S(c),onDragEnd:L,className:`group flex items-center gap-1 px-3 py-1.5 text-sm cursor-pointer rounded-t-lg border-t-[1.5px] transition-colors ${m?"border-brand bg-slate-4 text-foreground font-medium":"border-transparent text-muted-foreground hover:bg-secondary/50"} ${s===c?"opacity-50":""} ${o===c?"border-l-2 border-brand":""}`,onClick:()=>h(e.id),children:[(0,n.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,n.jsx)(u,{number:c+1,status:g,isActive:m}),d&&e.sessionId&&(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),d(e.id)},className:`absolute -top-1.5 -right-1.5 flex h-4 w-4 items-center justify-center rounded-sm transition-colors duration-150 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${x?"text-amber-9 opacity-100 hover:text-foreground-faint":"text-foreground-faint opacity-0 group-hover:opacity-100 hover:text-amber-9"}`,"data-tooltip":p,"aria-label":p,"aria-pressed":x,children:(0,n.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:x?"currentColor":"none",stroke:"currentColor",strokeWidth:x?1:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})})]}),(0,n.jsx)("span",{className:"flex-1 min-w-0 truncate",children:e.title}),(0,n.jsx)(l.S,{engine:e.engine,size:"sm"}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),f(e.id)},className:"ml-1 p-0.5 rounded hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","data-tooltip":P("tabBar.closeTab"),"aria-label":P("tabBar.closeTab"),children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},e.id)}),(0,n.jsx)(m,{onNewTab:g,onNewCodexTab:b,onNewKimiTab:v,onNewGlmTab:j,onNewOllamaTab:w,onNewDeepseekTab:k}),p&&(0,n.jsx)("button",{onClick:p,className:"flex-shrink-0 p-1.5 text-muted-foreground hover:text-destructive hover:bg-hover rounded transition-colors",title:P("tabBar.closeAll"),"aria-label":P("tabBar.closeAll"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),y&&(0,n.jsx)("button",{onClick:y,className:"flex-shrink-0 p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:P("sessions.projectSessions"),"aria-label":P("sessions.projectSessions"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),E&&(0,n.jsx)("button",{onClick:E,className:"flex-shrink-0 p-1.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:M?P("chat.singlePane"):P("chat.splitPane"),"aria-label":M?P("chat.singlePane"):P("chat.splitPane"),"aria-pressed":M,children:(0,n.jsxs)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",strokeWidth:2}),!M&&(0,n.jsx)("path",{strokeWidth:2,d:"M12 4v16"})]})})]})})}},27068:(e,t,r)=>{r.d(t,{Providers:()=>g});var n=r(95155),s=r(47617),o=r(3238),a=r(34075),l=r(12115),i=r(47650);function d(e){let t=e;for(;t;){let e=t.dataset?.tooltip;if(e)return e;t=t.parentElement}return null}function c(){let[e,t]=(0,l.useState)(null),r=(0,l.useRef)(null);r.current=e;let s=(0,l.useRef)(null),o=(0,l.useRef)(null),[a,c]=(0,l.useState)({left:0,top:0}),[u,m]=(0,l.useState)(!1);return((0,l.useEffect)(()=>m(!0),[]),(0,l.useEffect)(()=>{let e=()=>{s.current&&(clearTimeout(s.current),s.current=null)},n=n=>{let o=d(n.target);if(!o){e(),r.current&&t(null);return}if(r.current&&r.current.text===o)return void t({text:o,x:n.clientX,y:n.clientY});e();let a=n.clientX,l=n.clientY;s.current=setTimeout(()=>{t({text:o,x:a,y:l}),s.current=null},300)},o=n=>{if(!r.current)return;let s=d(n.target);if(!s){e(),t(null);return}t({text:s,x:n.clientX,y:n.clientY})},a=()=>{e(),r.current&&t(null)};return document.addEventListener("mouseover",n,!0),document.addEventListener("mousemove",o),document.addEventListener("mouseleave",a),document.addEventListener("mousedown",a),()=>{document.removeEventListener("mouseover",n,!0),document.removeEventListener("mousemove",o),document.removeEventListener("mouseleave",a),document.removeEventListener("mousedown",a),e()}},[]),(0,l.useLayoutEffect)(()=>{if(!e||!o.current)return;let t=o.current.getBoundingClientRect(),r=window.innerWidth,n=window.innerHeight,s=e.x+12,a=e.y+16;s+t.width>r-8&&(s=r-t.width-8),s<8&&(s=8),a+t.height>n-8&&(a=e.y-t.height-8),c({left:s,top:a})},[e]),u&&e)?(0,i.createPortal)((0,n.jsx)("div",{ref:o,className:"fixed z-[9999] max-w-[min(80vw,64rem)] px-2 py-1 bg-tooltip text-tooltip-foreground text-xs font-mono rounded shadow-lv3 border border-line-1 whitespace-pre-wrap break-words pointer-events-none",style:{left:a.left,top:a.top},children:e.text}),document.body):null}var u=r(79114),m=r(72363),x=r(2111);let h=new Set(["preparing","installing","repairing","rolling-back","restarting"]);function f(){return(0,n.jsxs)("svg",{className:"h-4 w-4 flex-shrink-0 animate-spin text-brand",fill:"none",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:4}),(0,n.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]})}function p(){let{t:e}=(0,u.Bd)(),t=(0,l.useSyncExternalStore)(m.N4,m.fX,m.fX),[r,s]=(0,l.useState)(()=>Date.now()),o=(0,l.useRef)(!1),{stale:i}=function(){let[e,t]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let r=window.__COCKPIT_BUILD_ID__;if(!r)return;let n=!1,s=async()=>{if(!n&&!e)try{let e=await fetch("/api/health",{cache:"no-store",signal:AbortSignal.timeout(3e3)});if(!e.ok)return;let s=await e.json();if(!s.buildId)return;n||s.buildId===r||t(!0)}catch{}},o=(0,x.D)(s);return()=>{n=!0,o()}},[e]),{stale:e}}(),[d,c]=(0,l.useState)(!1),[p,g]=(0,l.useState)(!1);(0,l.useEffect)(()=>{g(window.self===window.top)},[]),(0,l.useEffect)(()=>{p&&!o.current&&(o.current=!0,(0,m.$2)())},[p]);let b=t.visible&&h.has(t.stage);(0,l.useEffect)(()=>{if(!b)return;s(Date.now());let e=window.setInterval(()=>s(Date.now()),1e3);return()=>window.clearInterval(e)},[b]);let v=(0,l.useCallback)(()=>{navigator.clipboard.writeText(t.fixCommand),(0,a.oR)(e("workspace.updateCardFixCopied"))},[t.fixCommand,e]),j=!t.visible&&i&&!d;if(!p||!t.visible&&!j)return null;let w=t.startedAt?Math.max(0,Math.round((r-t.startedAt)/1e3)):0,k=t.baselineMs?Math.round(t.baselineMs/1e3):null,y=j||"done"===t.stage,N=j||!h.has(t.stage),C=y&&!t.upToDate,S=j?e("workspace.serverRestarted"):(()=>{switch(t.stage){case"preparing":return e("workspace.updateCardPreparing");case"installing":return e("workspace.updateCardInstalling");case"repairing":return e("workspace.updateCardRepairing");case"rolling-back":return e("workspace.updateCardRollingBack");case"restarting":return e("workspace.updateCardRestarting");case"done":if(!t.installedVersion)return e("workspace.updateComplete");return t.upToDate?e("workspace.updateCardUpToDate",{version:t.installedVersion}):e("workspace.updateCardDone",{version:t.installedVersion});case"failed":return e("workspace.updateFailed")}})();return(0,n.jsx)("div",{className:"fixed top-4 right-4 z-[110] w-80 rounded-lg border border-border\n bg-background/95 p-3 shadow-lv2 backdrop-blur",role:"status","aria-live":"polite",children:(0,n.jsxs)("div",{className:"flex items-start gap-2.5",children:[b?(0,n.jsx)(f,{}):y?(0,n.jsx)("svg",{className:"h-4 w-4 flex-shrink-0 text-brand",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,n.jsx)("svg",{className:"h-4 w-4 flex-shrink-0 text-destructive",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-sm text-foreground",children:S}),b&&(0,n.jsxs)("div",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:[e("workspace.updateCardElapsed",{seconds:w}),null!==k&&(0,n.jsxs)(n.Fragment,{children:[" \xb7 ",e("workspace.updateCardBaseline",{seconds:k})]})]}),b&&!t.live&&(0,n.jsx)("div",{className:"mt-1 text-[11px] leading-snug text-muted-foreground/80",children:e("workspace.updateCardNoLiveStatus")}),b&&(0,n.jsx)("div",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:e("workspace.updateRestartNote")}),!j&&"failed"===t.stage&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"mt-1 break-words text-[11px] leading-snug text-muted-foreground",children:t.error}),t.rolledBack&&(0,n.jsx)("div",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:e("workspace.updateCardRolledBack")}),(0,n.jsx)("div",{className:"mt-2 text-[11px] leading-snug text-muted-foreground",children:e("workspace.updateCardManualHint")}),(0,n.jsx)("code",{className:"mt-1 block break-all rounded bg-hover px-2 py-1.5 text-[11px]\n leading-snug text-foreground",children:t.fixCommand}),(0,n.jsx)("button",{type:"button",onClick:v,className:"mt-1.5 w-full rounded-md border border-border px-2.5 py-1.5 text-xs\n text-foreground transition-colors hover:bg-hover",children:e("workspace.updateCardCopyFix")}),t.logPath&&(0,n.jsx)("div",{className:"mt-1.5 break-all text-[11px] leading-snug text-muted-foreground/80",children:e("workspace.updateCardLogHint",{path:t.logPath})})]}),C&&(0,n.jsx)("button",{type:"button",onClick:()=>window.location.reload(),className:"mt-2 w-full rounded-md bg-primary px-2.5 py-1.5 text-xs\n text-primary-foreground transition-opacity hover:opacity-90",children:e("workspace.reloadNow")})]}),N&&(0,n.jsx)("button",{type:"button",onClick:()=>{c(!0),j||(0,m.fZ)()},"aria-label":e("common.close"),className:"-mr-1 -mt-1 rounded p-1 text-muted-foreground transition-colors hover:bg-hover",children:(0,n.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})}function g({children:e}){return(0,l.useEffect)(()=>{let e=e=>{e.preventDefault()};return document.addEventListener("contextmenu",e),()=>document.removeEventListener("contextmenu",e)},[]),(0,n.jsx)(s.I18nProvider,{children:(0,n.jsx)(o.NP,{children:(0,n.jsxs)(a.tE,{children:[e,(0,n.jsx)(c,{}),(0,n.jsx)(p,{})]})})})}},41474:(e,t,r)=>{r.d(t,{F:()=>s});var n=r(12115);function s(){let[e,t]=(0,n.useState)(()=>"u"<typeof document||"visible"===document.visibilityState);return(0,n.useEffect)(()=>{let e=()=>{t("visible"===document.visibilityState)};document.addEventListener("visibilitychange",e);let r=e=>{e.data?.type==="IFRAME_VISIBILITY"&&t(!!e.data.visible)};return window.addEventListener("message",r),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("message",r)}},[]),e}},45720:(e,t,r)=>{r.d(t,{X:()=>n});function n(e,t){switch(e){case"codex":return`codex resume ${t}`;case"kimi":case"glm":case"deepseek":case"ollama":return`${e} ${t}`;default:return`claude -r ${t}`}}},47617:(e,t,r)=>{r.d(t,{I18nProvider:()=>d});var n=r(95155),s=r(12115),o=r(79114),a=r(69809),l=r(86957),i=r(76900);function d({children:e}){return(0,s.useEffect)(()=>{l.t4.runPromiseExit((0,i.M5)()).then(e=>{var t;let r="auto"!==(t=("Success"===e._tag?e.value.language:"auto")||"auto")&&t?t:navigator.language.startsWith("zh")?"zh":"en";a.A.language!==r&&a.A.changeLanguage(r)})},[]),(0,s.useEffect)(()=>{let e=e=>(function(e){for(let t of document.querySelectorAll("iframe"))try{t.contentWindow?.postMessage({type:"cockpit:language-change",lang:e},"*")}catch{}})(e);return a.A.on("languageChanged",e),()=>{a.A.off("languageChanged",e)}},[]),(0,s.useEffect)(()=>{if(window===window.parent)return;let e=e=>{e.data?.type==="cockpit:language-change"&&e.data.lang&&a.A.language!==e.data.lang&&a.A.changeLanguage(e.data.lang)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[]),(0,n.jsx)(o.xC,{i18n:a.A,children:e})}},53213:(e,t,r)=>{r.d(t,{Bj:()=>d,CM:()=>v,FK:()=>b,Iz:()=>x,MB:()=>j,Ub:()=>f,X0:()=>h,Zi:()=>c,lv:()=>m,oh:()=>g,r4:()=>l,ue:()=>i,w2:()=>p,yy:()=>u});var n=r(49433),s=r(82680);let o=e=>n.tryPromise({try:async()=>{let t=await fetch(e);if(!t.ok){let e;try{e=(await t.json()).error}catch{}throw Error(e||`HTTP ${t.status}`)}return await t.json()},catch:t=>new s.uV({message:`fetch ${e} failed`,cause:t})}),a=(e,t)=>n.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`)},catch:t=>new s.uV({message:`POST ${e} failed`,cause:t})}),l=e=>o(`/api/git/branches?cwd=${encodeURIComponent(e)}`).pipe(n.flatMap(t=>"Failed to get branches"===t.error?n.fail(new s.m_({resource:"git-repo",id:e})):n.succeed(t))),i=e=>o(`/api/git/current-branch?cwd=${encodeURIComponent(e)}`),d=(e,t,r,n)=>o(`/api/git/commits?cwd=${encodeURIComponent(e)}&branch=${encodeURIComponent(t)}&limit=${r}${"number"==typeof n?`&offset=${n}`:""}`),c=(e,t,r)=>o(`/api/git/commit-diff?cwd=${encodeURIComponent(e)}&hash=${encodeURIComponent(t)}${r?`&file=${encodeURIComponent(r)}`:""}`),u=(e,t,r)=>o(`/api/git/branch-diff?cwd=${encodeURIComponent(e)}&base=${encodeURIComponent(t)}${r?`&file=${encodeURIComponent(r)}`:""}`),m=e=>o(`/api/git/status?cwd=${encodeURIComponent(e)}`),x=(e,t)=>a("/api/git/stage",{cwd:e,files:t}),h=(e,t)=>a("/api/git/unstage",{cwd:e,files:t}),f=(e,t,r)=>a("/api/git/discard",{cwd:e,files:t,isUntracked:r}),p=(e,t,r,n)=>{let s=new URLSearchParams({cwd:e,file:t,type:r});return n&&s.set("oldPath",n),o(`/api/git/diff?${s}`)},g=e=>o(`/api/git/diff?${e.toString()}`),b=e=>o(`/api/git/worktree?cwd=${encodeURIComponent(e)}`),v=e=>n.tryPromise({try:async()=>{let t=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await t.json().catch(()=>null);if(!t.ok)throw Error(r?.error||`HTTP ${t.status}`);return r},catch:e=>new s.uV({message:"POST /api/git/worktree failed",cause:e})}),j=e=>o(`/api/projectGraph/search?${e.toString()}`)},53853:(e,t,r)=>{r.d(t,{G:()=>u,f:()=>m});var n=r(12115);function s(){if("u"<typeof document)return null;let e=document.querySelector('meta[name="cockpit-bridge"]');if(!e)return null;let t=e.dataset.id,r=e.dataset.version;return t?{id:t,version:r||"unknown"}:null}let o=null,a=new Set;function l(){a.forEach(e=>e())}function i(e){a.add(e);let t=s();return t&&!o&&(o=t,Promise.resolve().then(l)),()=>{a.delete(e)}}function d(){return o}function c(){return null}if("u">typeof document&&(o=s()),"u">typeof MutationObserver&&"u">typeof document){let e=new MutationObserver(()=>{let e=s();e&&(!o||e.id!==o.id||e.version!==o.version)&&(o=e,l())}),t=document.head||document.documentElement;t&&e.observe(t,{childList:!0})}function u(){return(0,n.useSyncExternalStore)(i,d,c)}function m(){return o??s()}},59045:(e,t,r)=>{r.d(t,{TabManager:()=>sI});var n=r(95155),s=r(12115),o=r(79114);let a=(0,s.createContext)(null);function l({value:e,children:t}){return(0,n.jsx)(a.Provider,{value:e,children:t})}var i=r(66109),d=r(95045),c=r(75346),u=r(86957),m=r(83448),x=r(92689),h=r(7578);function f({isOpen:e,onClose:t,cwd:r,onSelectSession:a,projectNumber:l,openSessionIds:p=[]}){let{t:g}=(0,o.Bd)(),[b,v]=(0,s.useState)([]),[j,w]=(0,s.useState)(!1),[k,y]=(0,s.useState)(null),[N,C]=(0,s.useState)(""),S=(0,s.useRef)(null),L=(0,s.useCallback)(async()=>{let e;if(!r)return;w(!0),y(null);let t=(e=r.replace(/[^a-zA-Z0-9]/g,"-")).length<=200?e:`${e.slice(0,200)}-${function(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t).toString(36)}(r)}`,n=await u.t4.runPromiseExit((0,m.QW)(t));"Success"===n._tag?v(n.value):y("Failed to load sessions"),w(!1)},[r]);(0,s.useEffect)(()=>{e&&(L(),setTimeout(()=>{S.current?.focus(),S.current?.select()},100))},[e,L]),(0,s.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,t]);let M=b.filter(e=>{if(!N)return!0;let t=N.toLowerCase();return void 0!==e.searchText?e.searchText.includes(t):e.title.toLowerCase().includes(t)||e.firstMessages.some(e=>e.toLowerCase().includes(t))||e.lastMessages.some(e=>e.toLowerCase().includes(t))});return e?(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:t}),(0,n.jsxs)("div",{className:i.iG,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:g("sessions.sessionList")}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground truncate","data-tooltip":r,children:r})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("input",{ref:S,type:"text",placeholder:g("sessions.searchSessions"),value:N,onChange:e=>C(e.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),N&&(0,n.jsx)("button",{onClick:()=>{C(""),S.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:g("fileBrowser.clear"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[j&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,n.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,n.jsx)("span",{children:g("sessions.loadingSessions")})]})}),k&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("div",{className:"text-xs text-red-11",children:k})}),!j&&!k&&0===M.length&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:g(N?"sessions.noMatchingSessions":"sessions.noSessionsYet")})}),!j&&!k&&M.length>0&&(0,n.jsx)("div",{className:i.jL,children:M.map(e=>{let s=e.path.split("/").pop()||"",o=e.sessionId||s.replace(".jsonl",""),i=p.indexOf(o);return(0,n.jsxs)("div",{onClick:()=>{let n,s;return n=e.path.split("/").pop()||"",s=e.sessionId||n.replace(".jsonl",""),void(a?(a(s,e.title),t()):(0,d.F)(c.n.OpenProject,{cwd:r,sessionId:s}))},className:"p-3 rounded border border-border hover:border-brand hover:shadow-lv2 cursor-pointer transition-all",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,n.jsx)(x.S,{engine:e.engine}),(0,n.jsx)("h4",{className:"text-xs font-medium text-foreground truncate","data-tooltip":e.title,children:e.title}),l&&i>=0&&(0,n.jsx)(h.l,{projectNumber:l,sessionNumber:i+1,className:"ml-auto"})]}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(e.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,n.jsxs)("div",{className:"space-y-0.5 text-xs",children:[e.firstMessages.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground truncate","data-tooltip":e,children:[(0,n.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),e]},`first-${t}`)),e.lastMessages.length>0&&(0,n.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),e.lastMessages.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground truncate","data-tooltip":e,children:[(0,n.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),e]},`last-${t}`))]})]},e.path)})})]})]})]}):null}var p=r(47650),g=r(64428),b=r(60938),v=r(51145),j=r(53213),w=r(45619),k=r(24602),y=r(30133),N=r(48661),C=r(88780),S=r(20080);let L=(e,t,r)=>`/api/git/blob?cwd=${encodeURIComponent(e)}&rev=${encodeURIComponent(t)}&file=${encodeURIComponent(r)}`;function M({cwd:e,filePath:t,oldRev:r,newRev:s}){return(0,n.jsx)(S.K,{filePath:t,oldSrc:r?L(e,r,t):null,newSrc:s?L(e,s,t):null})}var E=r(94287),P=r(34075);let T=(0,s.memo)(function({cwd:e,filePath:t,onLocateInTree:r}){let{t:s}=(0,o.Bd)();return(0,n.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground truncate",title:t,children:t}),(0,n.jsx)(E.m,{content:s("common.copyAbsPath"),children:(0,n.jsx)("button",{onClick:r=>{r.stopPropagation(),navigator.clipboard.writeText(`${e}/${t}`),(0,P.oR)(s("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})}),r&&(0,n.jsx)(E.m,{content:s("fileBrowser.locateInTree"),children:(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),r(t)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,n.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})})]})});var $=r(82292),R=r(47215),B=r(56045),F=r(48347),I=r(62111);function D({isOpen:e,onClose:t,commit:r,cwd:a,embedded:l=!1,initialFilePath:i,onContentSearch:d,onLocateInTree:c}){let{t:m}=(0,o.Bd)(),[x,h]=(0,s.useState)([]),[f,p]=(0,s.useState)([]),[g,b]=(0,s.useState)(new Set),[v,S]=(0,s.useState)(null),[L,E]=(0,s.useState)(null),[P,A]=(0,s.useState)(!1),[z,H]=(0,s.useState)(!1),[W,_]=(0,s.useState)(null),[O,q]=(0,s.useState)(null),[V,U]=(0,s.useState)("compact"),[K,G]=(0,s.useState)("unified"),J=(0,s.useRef)(null),Q=(0,B.o)(J),Z=(0,F.r)(),X=r?.shortHash,Y=(0,s.useCallback)(e=>{X&&Z?.sendMessage(m("explain.commitFileMessage",{hash:X,path:e}))},[Z,m,X]);(0,s.useEffect)(()=>{let r=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&W){e.preventDefault(),Q.open();return}if("Escape"===e.key){if(Q.isVisible)return void Q.close();if(O)return void q(null);if(W)return void _(null);(0,I.k)(),t()}};if(e)return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t,O,W,Q]),(0,s.useEffect)(()=>{e&&r&&(queueMicrotask(()=>{h([]),p([]),S(null),E(null),A(!0)}),u.t4.runPromiseExit((0,j.Zi)(a,r.hash)).then(e=>{if("Success"===e._tag){let t=e.value.files??[];h(t);let n=(0,C.Do)(t);if(p(n),b(new Set((0,C.Sz)(n))),i&&t.length>0){let e=t.find(e=>e.path===i);e&&setTimeout(()=>{S(e),u.t4.runPromiseExit((0,j.Zi)(a,r.hash,e.path)).then(e=>{"Success"===e._tag?E(e.value):console.error(e.cause)})},0)}}else console.error(e.cause);A(!1)}))},[e,r,a,i]);let ee=(0,s.useCallback)(e=>{r&&(S(e),H(!0),u.t4.runPromiseExit((0,j.Zi)(a,r.hash,e.path)).then(e=>{"Success"===e._tag?E(e.value):console.error(e.cause),H(!1)}))},[a,r]),et=(0,s.useCallback)(e=>{b(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),er=(0,s.useMemo)(()=>{if(!r)return"";if(r.date){let e,t,n,s,o,a,l;return e=new Date(r.date),t=new Date,n=e.getFullYear()===t.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),a=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0"),n?`${s}-${o} ${a}:${l}`:`${e.getFullYear()}-${s}-${o} ${a}:${l}`}return r.time?new Date(1e3*r.time).toLocaleString():""},[r]),en=L?.filePath,es=(0,s.useMemo)(()=>en?(0,n.jsx)(T,{cwd:a,filePath:en,onLocateInTree:c}):null,[a,en,c]);if(!e||!r)return null;let eo=!!L&&(!0===L.isImage||(0,$.u)(L.filePath)),ea=(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-4 py-3 border-b border-border flex-shrink-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium text-foreground mb-2",children:r.subject}),r.body&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground whitespace-pre-wrap mb-3 max-h-32 overflow-y-auto border-l-2 border-border pl-3",children:r.body}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-4 text-xs text-muted-foreground",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-foreground-subtle",children:m("commitDetail.hash")}),(0,n.jsx)("span",{className:"font-mono bg-accent px-1.5 py-0.5 rounded",children:r.hash})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-foreground-subtle",children:m("commitDetail.author")}),(0,n.jsx)("span",{children:r.author}),(0,n.jsxs)("span",{className:"text-foreground-subtle",children:["<",r.authorEmail,">"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-foreground-subtle",children:m("commitDetail.date")}),(0,n.jsx)("span",{children:er}),r.relativeDate&&(0,n.jsxs)("span",{className:"text-foreground-subtle",children:["(",r.relativeDate,")"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-foreground-subtle",children:m("commitDetail.files")}),(0,n.jsx)("span",{children:m("commitDetail.nChanges",{count:x.length})})]}),!eo&&(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,n.jsx)(y.y,{value:V,onChange:U}),(0,n.jsx)(N.q,{value:K,onChange:G})]})]})]}),(0,n.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,n.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:P?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:m("commitDetail.loadingFiles")}):(0,n.jsx)(C.VO,{files:f,selectedPath:v?.path||null,expandedPaths:g,onSelect:e=>e.file&&ee(e.file),onToggle:et,cwd:a,showChanges:!0,emptyMessage:m("commitDetail.noFileChanges"),className:"py-1",onExplain:Z&&X?Y:void 0,explainDisabled:Z?.isLoading})}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden",children:z?(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:m("commitDetail.loadingDiff")}):L?eo?(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)("div",{className:"flex-shrink-0 px-2 py-1 border-b border-border bg-accent",children:es}),(0,n.jsx)("div",{className:"flex-1 min-h-0",children:(0,n.jsx)(M,{cwd:a,filePath:L.filePath,oldRev:L.oldRev??(L.isNew?null:`${r.hash}^1`),newRev:L.newRev??(L.isDeleted?null:r.hash)})})]}):"unified"===K?(0,n.jsx)(w.xU,{oldContent:L.oldContent,newContent:L.newContent,filePath:L.filePath,cwd:a,enableComments:!0,compact:"compact"===V,headerLeading:es,onPreview:L.isDeleted?void 0:(0,R.aR)(L.filePath)?()=>q({content:L.newContent,filePath:L.filePath}):L.filePath.endsWith(".json")?()=>_({content:L.newContent,filePath:L.filePath}):void 0,previewLabel:(0,R.aR)(L.filePath)?m("common.preview"):m("common.readable"),onContentSearch:d}):(0,n.jsx)(w.xZ,{oldContent:L.oldContent,newContent:L.newContent,filePath:L.filePath,isNew:L.isNew,isDeleted:L.isDeleted,cwd:a,enableComments:!0,compact:"compact"===V,headerLeading:es,onPreview:L.isDeleted?void 0:(0,R.aR)(L.filePath)?()=>q({content:L.newContent,filePath:L.filePath}):L.filePath.endsWith(".json")?()=>_({content:L.newContent,filePath:L.filePath}):void 0,previewLabel:(0,R.aR)(L.filePath)?m("common.preview"):m("common.readable"),onContentSearch:d}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:m("commitDetail.selectFileToView")})})]})]}),el=W&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>_(null),children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90%] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:W.filePath}),(0,n.jsx)("button",{onClick:()=>_(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)(B._,{search:Q}),(0,n.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,n.jsx)("pre",{ref:J,className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,R.xb)(W.content)})})]})}),ei=O&&(0,n.jsx)(k.N,{filePath:O.filePath,content:O.content,cwd:a,onClose:()=>q(null)});return l?(0,n.jsxs)("div",{className:"bg-card w-full h-full flex flex-col relative",children:[(0,n.jsx)("button",{onClick:t,className:"absolute top-2 right-2 z-10 p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",title:m("common.close"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),ea,el,ei]}):(0,n.jsx)("div",{className:"fixed inset-0 z-[60] bg-scrim",onClick:t,children:(0,n.jsxs)("div",{className:"bg-card w-full h-full flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-foreground",children:m("commitDetail.title")}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),ea,el,ei]})})}var A=r(64702),z=r(70188),H=r(14575);let W={M:{text:"text-amber-11",bg:"bg-amber-9/20"},A:{text:"text-green-11",bg:"bg-green-9/20"},D:{text:"text-red-11",bg:"bg-red-9/20"},R:{text:"text-blue-11",bg:"bg-blue-9/20"}},_=s.memo(function({item:e,isSelected:t,isExpanded:r,isLoading:o,onSelect:a,onToggle:l,onContextMenu:i,renderActions:d}){let{node:c,level:u,gitStatus:m,hasChangedChildren:x}=e,h=m?W[m]:null,f=(0,s.useCallback)(()=>{c.isDirectory?l(c.path):a(c.path)},[c.isDirectory,c.path,a,l]),p=(0,s.useCallback)(e=>{i(e,c.path,c.isDirectory)},[c.path,c.isDirectory,i]),g=!c.isDirectory&&(".env"===c.name||c.name.startsWith(".env.")),b=m?h.text:x?"text-amber-11":g?"text-yellow-600 dark:text-yellow-500":t&&!c.isDirectory?"text-brand":"text-foreground";return(0,n.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 cursor-pointer hover:bg-hover ${t?"bg-brand/10":""}`,style:{paddingLeft:`${12*u+8}px`},onClick:f,onContextMenu:p,children:[c.isDirectory?o?(0,n.jsxs)("svg",{className:"w-4 h-4 flex-shrink-0 text-muted-foreground animate-spin",viewBox:"0 0 16 16",fill:"none",children:[(0,n.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.3"}),(0,n.jsx)("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):(0,n.jsx)("svg",{className:`w-4 h-4 flex-shrink-0 text-muted-foreground transition-transform ${r?"rotate-90":""}`,viewBox:"0 0 16 16",fill:"none",children:(0,n.jsx)("path",{d:"M6 4 L10 8 L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):(0,n.jsx)(H.o,{name:c.name,size:16,className:"flex-shrink-0 ml-4"}),(0,n.jsx)("span",{className:`text-sm truncate flex-1 ${b}`,"data-tooltip":c.isSymlink&&c.symlinkTarget?`${c.path} → ${c.symlinkTarget}`:c.path,children:c.name}),c.isSymlink&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:"→"}),m&&(0,n.jsx)("span",{className:`text-xs font-mono px-1 rounded ${h.text} ${h.bg} flex-shrink-0`,children:m}),c.isDirectory&&x&&(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-9 flex-shrink-0"}),d?.(c)]})});function O({files:e,selectedPath:t,expandedPaths:r,matchedPaths:o=null,gitStatusMap:a=null,loadingDirs:l,onSelect:i,onToggle:d,cwd:c,shouldScrollToSelected:u=!1,onScrolledToSelected:m,className:x,renderActions:h,onCreateFile:f,onDelete:p,onRefresh:g,onCopyFile:b,onPaste:v,onExplain:j,explainDisabled:w}){let k=(0,s.useRef)(null),{contextMenu:y,showContextMenu:N,hideContextMenu:C}=(0,z.Ee)(),S=(0,s.useMemo)(()=>(function e(t,r,n,s=null,o=0){let a=[];for(let l of t){if(null!==n&&!n.has(l.path))continue;let t=s?.get(l.path),i=l.isDirectory?function(e,t){if(!t)return!1;let r=e+"/";for(let e of t.keys())if(e.startsWith(r))return!0;return!1}(l.path,s):void 0;a.push({node:l,level:o,gitStatus:t,hasChangedChildren:i}),l.isDirectory&&l.children&&r.has(l.path)&&a.push(...e(l.children,r,n,s,o+1))}return a})(e,r,o,a),[e,r,o,a]),L=(0,A.Te)({count:S.length,getScrollElement:()=>k.current,estimateSize:()=>26,overscan:10}),M=(0,s.useRef)(m);return(M.current=m,(0,s.useEffect)(()=>{if(u&&t&&S.length>0){let e=S.findIndex(e=>e.node.path===t);if(e>=0){let t=setTimeout(()=>{L.scrollToIndex(e,{align:"center"}),M.current?.()},150);return()=>clearTimeout(t)}}},[u,t,S,L]),0===S.length)?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No files"}):(0,n.jsxs)("div",{ref:k,className:x||"h-full overflow-y-auto",style:{willChange:"transform"},children:[(0,n.jsx)("div",{style:{height:`${L.getTotalSize()}px`,width:"100%",position:"relative"},children:L.getVirtualItems().map(e=>{let s=S[e.index];return(0,n.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${e.size}px`,transform:`translateY(${e.start}px)`},children:(0,n.jsx)(_,{item:s,isSelected:t===s.node.path,isExpanded:r.has(s.node.path),isLoading:l?.has(s.node.path),onSelect:i,onToggle:d,onContextMenu:N,renderActions:h})},s.node.path)})}),y&&(0,n.jsx)(z.ft,{x:y.x,y:y.y,path:y.path,cwd:c,isDirectory:y.isDirectory,onClose:C,onCreateFile:f,onDelete:p,onRefresh:g,onCopyFile:b,onPaste:v,onExplain:j,explainDisabled:w})]})}var q=r(38408),V=r(32041),U=r(14341),K=r(42804),G=r(22164),J=r(34582),Q=r(86304),Z=r(10794),X=r(5135),Y=r(85269),ee=r(79968);function et({path:e,matchedIndices:t}){let r=(0,s.useMemo)(()=>new Set(t),[t]),o=e.lastIndexOf("/"),a=o>=0?e.slice(0,o+1):"",l=o>=0?e.slice(o+1):e,i=(e,t,s)=>{let o=[],a="",l=!1;for(let s=0;s<e.length;s++){let i=t+s,d=r.has(i);d!==l&&a&&(o.push(l?(0,n.jsx)("span",{className:"text-brand font-medium",children:a},`${t}-${s}`):(0,n.jsx)("span",{children:a},`${t}-${s}`)),a=""),l=d,a+=e[s]}return a&&o.push(l?(0,n.jsx)("span",{className:"text-brand font-medium",children:a},`${t}-end`):(0,n.jsx)("span",{children:a},`${t}-end`)),(0,n.jsx)("span",{className:s,children:o})};return(0,n.jsxs)("span",{className:"truncate",children:[a&&i(a,0,"text-muted-foreground"),i(l,a.length,"text-foreground")]})}function er({files:e,fileIndex:t,recentFiles:r,onSelectFile:a,onClose:l}){let{t:i}=(0,o.Bd)(),[d,c]=(0,s.useState)(""),[u,m]=(0,s.useState)(0),x=(0,s.useRef)(null),h=(0,s.useRef)(null),f=(0,s.useMemo)(()=>{let r,n;return t??(r=[],(n=e=>{for(let t of e)t.isDirectory&&t.children?n(t.children):t.isDirectory||r.push(t.path)})(e),r)},[t,e]),p=(0,s.useMemo)(()=>{if(!d.trim()){let e=new Set(r);return[...r.map(e=>({path:e,score:0,matchedIndices:[]})),...f.filter(t=>!e.has(t)).slice(0,50).map(e=>({path:e,score:0,matchedIndices:[]}))]}let e=[];for(let t of f){let n=function(e,t){let r=e.toLowerCase(),n=t.toLowerCase(),s=[],o=0,a=0,l=-1;for(let i=0;i<r.length&&o<n.length;i++)r[i]===n[o]&&(s.push(i),l===i-1&&(a+=5),(0===i||"/"===e[i-1]||"."===e[i-1]||"-"===e[i-1]||"_"===e[i-1])&&(a+=10),i>e.lastIndexOf("/")&&(a+=3),e[i]===t[o]&&(a+=1),l=i,o++);return o<n.length?null:(a-=.1*e.length,{path:e,score:a,matchedIndices:s})}(t,d.trim());n&&(r.includes(t)&&(n.score+=20),e.push(n))}return e.sort((e,t)=>t.score-e.score),e.slice(0,50)},[d,f,r]),b=(0,s.useCallback)(e=>{c(e),m(0)},[]);(0,s.useEffect)(()=>{x.current?.focus()},[]),(0,s.useEffect)(()=>{if(h.current){let e=h.current.children[u];e?.scrollIntoView({block:"nearest"})}},[u]);let v=(0,s.useCallback)(e=>{a(e),l()},[a,l]),j=(0,s.useCallback)(e=>{if(!e.nativeEvent.isComposing)switch(e.key){case"ArrowDown":e.preventDefault(),m(e=>Math.min(e+1,p.length-1));break;case"ArrowUp":e.preventDefault(),m(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),p[u]&&v(p[u].path);break;case"Escape":e.preventDefault(),l()}},[p,u,v,l]);return(0,n.jsx)(g.ZL,{children:(0,n.jsx)("div",{className:"fixed inset-0 z-[300] flex items-start justify-center pt-[15vh]",onClick:l,children:(0,n.jsxs)("div",{className:"w-[680px] max-h-[60vh] bg-card border border-border rounded-lg shadow-lv3 overflow-hidden flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[(0,n.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,n.jsx)("input",{ref:x,value:d,onChange:e=>b(e.target.value),onKeyDown:j,placeholder:i("quickFileOpen.placeholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none",autoComplete:"off",autoCorrect:"off",spellCheck:"false"}),(0,n.jsx)("kbd",{className:"text-[10px] text-muted-foreground px-1.5 py-0.5 rounded border border-border bg-secondary",children:"ESC"})]}),(0,n.jsx)("div",{ref:h,className:"flex-1 overflow-y-auto py-1",children:0===p.length?(0,n.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:i("quickFileOpen.noMatch")}):p.map((e,t)=>(0,n.jsxs)("div",{className:`px-3 py-1.5 flex items-center gap-2 cursor-pointer transition-colors ${t===u?"bg-brand/15 text-foreground":"hover:bg-hover text-foreground"}`,"data-tooltip":e.path,onClick:()=>v(e.path),children:[(0,n.jsx)(H.o,{name:e.path.split("/").pop()||"",className:"w-4 h-4 flex-shrink-0"}),(0,n.jsx)(et,{path:e.path,matchedIndices:e.matchedIndices}),!d.trim()&&r.includes(e.path)&&(0,n.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground px-1.5 py-0.5 rounded bg-secondary flex-shrink-0",children:i("quickFileOpen.recent")})]},e.path))}),(0,n.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex items-center gap-3 text-[10px] text-muted-foreground",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"↑↓"})," ",i("quickFileOpen.selectHint")]}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Enter"})," ",i("quickFileOpen.openHint")]}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Esc"})," ",i("quickFileOpen.closeHint")]})]})]})})})}var en=r(2111),es=r(41474),eo=r(61878),ea=r(33210),el=r(48368),ei=r(91958),ed=r(45916),ec=r(31794),eu=r(69048),em=r(97567),ex=r(68806),eh=r(52475);function ef({kind:e,qname:t,className:r}){let s=`${(function(e,t){if("__file__"===t||"__preamble__"===t||t&&t.startsWith("__heading_"))return"text-muted-foreground/60";switch(e){case"function":case"method":return"text-violet-11";case"class":return"text-amber-11";case"interface":return"text-blue-11";default:return"text-muted-foreground/60"}})(e,t)} ${r??""}`.trim();if("__file__"===t)return(0,n.jsx)(el.A,{className:s});if("__preamble__"===t)return(0,n.jsx)(ed.A,{className:s});if(t&&t.startsWith("__heading_"))return(0,n.jsx)(ec.A,{className:s});switch(e){case"function":case"method":return(0,n.jsx)(eu.A,{className:s});case"class":return(0,n.jsx)(em.A,{className:s});case"interface":return(0,n.jsx)(ex.A,{className:s});default:return(0,n.jsx)(eh.A,{className:s})}}var ep=r(49433),eg=r(82680);let eb=new Map,ev=new Map;async function ej(e,t,r=!1){let n=`${e}::${t}`;if(r)!function(e){if(!e){eb.clear(),ev.clear();return}let t=`${e}::`;for(let e of eb.keys())e.startsWith(t)&&eb.delete(e);for(let e of ev.keys())e.startsWith(t)&&ev.delete(e)}(e);else{let e=eb.get(n);if(e)return e;let t=ev.get(n);if(t)return t}let s=ep.tryPromise({try:async()=>{let s=new URLSearchParams({cwd:e,path:t});r&&s.set("refresh","1");let o=await fetch(`/api/projectGraph/file-functions?${s}`);if(404===o.status)return"not-found";if(!o.ok)throw Error((await o.json().catch(()=>({error:`HTTP ${o.status}`}))).error||`HTTP ${o.status}`);let a=await o.json();return eb.set(n,a),a},catch:e=>new eg.uV({message:"fetchFileFunctions failed",cause:e})}),o=u.t4.runPromiseExit(s).then(e=>{if("Success"===e._tag)return e.value;let t="Fail"===e.cause._tag?e.cause.error:null,r=t?.cause;if(r instanceof Error)throw r;throw Error(t?.message??"fetchFileFunctions failed")}).finally(()=>ev.delete(n));return ev.set(n,o),o}function ew(e,t){let[r,n]=(0,s.useState)({state:"idle"}),o=(0,s.useRef)(!0);(0,s.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let a=(0,s.useCallback)((e,t,r)=>{n({state:"loading"}),ej(e,t,r).then(e=>{o.current&&("not-found"===e?n({state:"notFound"}):n({state:"ready",data:e}))}).catch(e=>{o.current&&n({state:"error",message:e.message})})},[]);return(0,s.useEffect)(()=>{e&&t?a(e,t,!1):n({state:"idle"})},[e,t,a]),{state:r,refresh:(0,s.useCallback)(()=>{e&&t&&a(e,t,!0)},[e,t,a])}}function ek({cwd:e}){let{t}=(0,o.Bd)(),[r,a]=(0,s.useState)(null);(0,s.useEffect)(()=>{a(null)},[e]);let l=(0,s.useCallback)(t=>{t?.type==="graphProgress"&&t.data&&t.data.cwd===e&&a(t.data)},[e]);(0,en.h)({url:`/ws/watch?cwd=${encodeURIComponent(e)}`,onMessage:l});let i=(0,s.useRef)("");if(r?.currentFile&&(i.current=r.currentFile),!r)return(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:t("blockViewer.fileMode.loading","Loading…")});let d=t(`blockViewer.buildProgress.${r.phase}`,ey[r.phase]),c=Math.max(0,Math.min(100,Math.round(r.percent)));return(0,n.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-8",children:(0,n.jsxs)("div",{className:"w-full max-w-md flex flex-col gap-2",children:[(0,n.jsxs)("div",{className:"flex items-baseline justify-between text-xs text-muted-foreground",children:[(0,n.jsx)("span",{children:d}),(0,n.jsx)("span",{className:"tabular-nums",children:"parsing"===r.phase&&r.filesTotal>0?`${r.filesDone} / ${r.filesTotal}`:`${c}%`})]}),(0,n.jsx)("div",{className:"h-1 w-full overflow-hidden rounded-full bg-muted",children:(0,n.jsx)("div",{className:"h-full rounded-full bg-primary transition-[width] duration-150 ease-linear",style:{width:`${c}%`}})}),(0,n.jsx)("div",{className:"h-4 truncate text-left font-mono text-[11px] leading-4 text-muted-foreground/70",dir:"rtl",title:"done"===r.phase?"":i.current,children:"done"===r.phase?"":i.current})]})})}let ey={listing:"Listing files…",contexts:"Reading project config…",parsing:"Parsing files",resolving:"Resolving imports…",edges:"Building call graph…",done:"Finishing up…"};var eN=r(1058),eC=r(90717),eS=r(3238),eL=r(17196);function eM({entries:e,onSelect:t,onClear:r}){let{t:s}=(0,o.Bd)();return(0,n.jsxs)("div",{className:"flex-1 min-h-0 bg-card flex flex-col","data-testid":"function-history-drawer",children:[(0,n.jsxs)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border flex items-center justify-between gap-1",children:[(0,n.jsx)("div",{className:"flex items-center text-xs text-muted-foreground font-mono min-w-0",children:(0,n.jsx)("span",{className:"truncate",children:0===e.length?s("blockViewer.history.title"):`${s("blockViewer.history.title")} \xb7 ${e.length}/15`})}),e.length>0&&(0,n.jsx)(E.m,{content:s("blockViewer.history.clear"),children:(0,n.jsx)("button",{onClick:r,className:"flex-shrink-0 text-muted-foreground hover:text-foreground p-0.5 rounded hover:bg-secondary",children:(0,n.jsx)(ea.A,{className:"w-3 h-3"})})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===e.length?(0,n.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:s("blockViewer.history.empty")}):e.map((e,r)=>{var s;let o;return(0,n.jsx)(E.m,{content:`${e.qname} \xb7 ${e.filePath}`,children:(0,n.jsxs)("button",{onClick:()=>t(e),className:"w-full text-left px-2 py-1.5 border-b border-border/50 hover:transition-colors group flex items-start gap-1.5",children:[(0,n.jsx)(ef,{kind:e.kind??"unknown",qname:e.qname,className:"w-3 h-3 mt-0.5 flex-shrink-0"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"text-xs font-mono font-medium truncate",children:e.name}),(0,n.jsxs)("div",{className:"text-[10px] text-muted-foreground/70 truncate",children:[(o=(s=e.filePath).lastIndexOf("/"))>=0?s.slice(o+1):s,e.kind&&(0,n.jsxs)("span",{className:"ml-1 opacity-60",children:["\xb7 ",e.kind]})]})]})]})},`${e.filePath}::${e.qname}::${r}`)})})]})}function eE(e,t){let r=e.filter(e=>e.filePath!==t.filePath||e.qname!==t.qname),n=[t,...r];return n.length>15?n.slice(0,15):n}let eP=new Set(["function","class","method"]);function eT(e){return eP.has(e.kind)}function e$({functions:e,counts:t,totalLines:r,currentQname:a,onSelect:l,notIndexed:i,onRebuild:d}){let{t:c}=(0,o.Bd)(),u=(0,s.useMemo)(()=>e.filter(eT),[e]);return(0,n.jsxs)("div",{className:"flex-1 min-h-0 bg-card flex flex-col","data-testid":"file-toc-section",children:[(0,n.jsxs)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border text-xs text-muted-foreground font-mono truncate",children:[c("blockViewer.toc.title"),u.length>0&&` \xb7 ${u.length}`,null!=r&&` \xb7 ${r} ${c("common.lines")}`]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===u.length?i?(0,n.jsxs)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/80 leading-relaxed flex flex-col gap-2",children:[(0,n.jsx)("span",{className:"italic",children:c("blockViewer.toc.notIndexed")}),d&&(0,n.jsx)("button",{type:"button",onClick:d,className:"self-start px-2 py-1 rounded border border-border bg-secondary/60 hover:bg-secondary text-[10px] text-foreground transition-colors",children:c("blockViewer.refresh")})]}):(0,n.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:c("blockViewer.toc.empty")}):u.map(e=>{let r=a===e.qualifiedName,s=t?.get(e.qualifiedName),o=s?[s.in>0&&["in",s.in,"text-amber-11/80"],s.out>0&&["out",s.out,"text-green-11/80"],s.self>0&&["self",s.self,"text-muted-foreground/60"]].filter(Boolean):[];return(0,n.jsx)(E.m,{content:`${e.qualifiedName} \xb7 L${e.startLine}`,children:(0,n.jsxs)("button",{onClick:()=>l(e.qualifiedName,e.startLine),className:`w-full text-left px-2 py-1 transition-colors flex items-start gap-1.5 min-w-0 ${r?"bg-brand/15 hover:bg-brand/20":"hover:bg-secondary/60"}`,children:[(0,n.jsx)(ef,{kind:e.kind,qname:e.qualifiedName,className:"w-3 h-3 flex-shrink-0 mt-0.5"}),(0,n.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 min-w-0",children:[(0,n.jsx)("span",{className:`flex-1 min-w-0 text-xs font-mono truncate ${r?"font-semibold text-brand":""}`,children:e.name}),(0,n.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground/50 tabular-nums",children:e.endLine-e.startLine+1})]}),o.length>0&&(0,n.jsx)("span",{className:"block text-[10px] font-mono truncate",children:o.map(([e,t,r],s)=>(0,n.jsxs)("span",{className:r,children:[s>0&&(0,n.jsx)("span",{className:"text-muted-foreground/30",children:" \xb7 "}),e," ",t]},e))})]})]})},e.qualifiedName)})})]})}var eR=r(27570),eB=r(96035);function eF({comments:e,startLine:t,endLine:r,lineHeight:s,bodyTopOffset:o,rowOf:a,onCommentClick:l}){let i=new Map;for(let n of e){if(n.endLine<t||n.endLine>r)continue;let e=i.get(n.endLine);e?e.push(n):i.set(n.endLine,[n])}return 0===i.size?null:(0,n.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-6 pointer-events-none",children:Array.from(i.entries()).map(([e,r])=>{let i=a?a(e):e-t,d=r[0],c=r.length-1;return(0,n.jsx)(E.m,{content:1===r.length?d.content:`${r.length} comments — click to view`,children:(0,n.jsxs)("button",{onClick:e=>l(d,e),className:"pointer-events-auto absolute right-1 w-4 h-4 rounded-full bg-amber-9/70 hover:bg-amber-11 text-white flex items-center justify-center shadow-lv1 transition-colors",style:{top:`${o+i*s+s/2-8}px`},children:[(0,n.jsx)(eB.A,{className:"w-2.5 h-2.5"}),c>0&&(0,n.jsx)("span",{className:"absolute -top-1 -right-1 bg-amber-11 text-white rounded-full text-[8px] leading-none w-3 h-3 flex items-center justify-center",children:c+1})]})},e)})})}function eI(e,t){for(let r=0;r<e.blocks.length;r++){let n=e.blocks[r];if(t>=n.startLine&&t<=n.endLine)return e.prefix[r]+(t-n.startLine)}return null}function eD({addedLines:e,blockRanges:t,viewportRange:r,onJumpToLine:o}){let a,l=(0,s.useRef)(null),i=(0,s.useMemo)(()=>(function(e){let t=[...e].sort((e,t)=>e.startLine-t.startLine),r=[0];for(let e of t){let t=Math.max(0,e.endLine-e.startLine+1);r.push(r[r.length-1]+t)}return{blocks:t,prefix:r,total:r[r.length-1]}})(t),[t]),d=(0,s.useMemo)(()=>{if(i.total<=0||0===e.size)return[];let t=[];for(let r of e){let e=i.blocks.find(e=>r>=e.startLine&&r<=e.endLine);e&&t.push({line:r,qname:e.qname})}t.sort((e,t)=>e.line-t.line);let r=[],n=null;for(let e of t)n&&e.line===n.end+1&&e.qname===n.qname?n.end=e.line:(n&&r.push(n),n={start:e.line,end:e.line,qname:e.qname});return n&&r.push(n),r},[e,i]);if(i.total<=0)return null;let c=(e,t)=>{let r=eI(i,e),n=eI(i,t);return null===r||null===n?null:{top:r/i.total*100,heightPct:(n-r+1)/i.total*100}};return(0,n.jsxs)("div",{ref:l,onClick:e=>{let t=l.current;if(!t)return;let r=t.getBoundingClientRect();if(r.height<=0)return;let n=function(e,t){if(e.total<=0)return null;let r=Math.max(0,Math.min(e.total-1,t));for(let t=0;t<e.blocks.length;t++){let n=e.prefix[t],s=e.prefix[t+1];if(r>=n&&r<s){let s=e.blocks[t];return{qname:s.qname,line:s.startLine+Math.round(r-n)}}}return null}(i,(e.clientY-r.top)/r.height*i.total);if(!n)return;let s=n.line,a=d.find(e=>e.qname===n.qname&&s>=e.start&&s<=e.end);if(a)return void o(a.qname,s);if(d.length>0){let e=Math.max(2,Math.round(.05*i.total)),t=eI(i,s);if(null!==t){let r=null,n=1/0;for(let e of d){let s=eI(i,e.start),o=eI(i,e.end);if(null===s||null===o)continue;let a=t<s?s-t:t>o?t-o:0;a<n&&(r=e,n=a)}if(r&&n<=e){let e=s<r.start?r.start:s>r.end?r.end:s;o(r.qname,e);return}}}let c=i.blocks.find(e=>e.qname===n.qname);c&&o(c.qname,c.startLine)},className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",title:"Diff minimap — click to jump",children:[d.map(e=>{let t=c(e.start,e.end);return t?(0,n.jsx)("div",{className:"absolute left-0 right-0 bg-green-9 pointer-events-none",style:{top:`${t.top}%`,height:`${t.heightPct}%`,minHeight:"2px"}},`run:${e.qname}:${e.start}-${e.end}`):null}),r&&r.end>=r.start&&((a=c(r.start,r.end))?(0,n.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border pointer-events-none",style:{top:`${a.top}%`,height:`${Math.max(1.2,a.heightPct)}%`}}):null)]})}var eA=r(19502),ez=r(89109),eH=r(7320),eW=r(37614);function e_(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function eO(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let eq="flex-shrink-0 h-4 leading-4 px-1.5 rounded text-[10px] text-brand hover:bg-brand/10 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent";function eV({symbol:e,fileSource:t,hasChange:r,onHighlighted:a,comments:l,onCommentClick:i,addedLines:d,upstream:c,downstream:u,fold:m,onExpandGap:x}){let{resolvedTheme:h}=(0,eS.DP)(),{t:f}=(0,o.Bd)(),p=(0,F.r)(),g=(c?.length??0)+(u?.length??0)>0,b=(0,s.useMemo)(()=>(0,eL.sQ)(e.filePath),[e.filePath]),[v,j]=(0,s.useState)(null),[w,k]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!t)return void j(null);let r=!1;return(async()=>{try{let n=t.split("\n").slice(e.startLine-1,e.endLine).join("\n"),s=(await (0,eL.kS)()).codeToTokens(n,{lang:b,theme:"dark"===h?"github-dark":"github-light"});r||(j(s.tokens.map(e=>(0,eL.b8)(e))),k(null))}catch(e){r||k(e instanceof Error?e.message:"highlight failed")}})(),()=>{r=!0}},[t,e.startLine,e.endLine,b,h]);let y=(0,s.useMemo)(()=>{if(!v)return null;let t=t=>{let r=v[t-e.startLine]??"",n=d?.has(t)?" bg-green-9/15":"";return`<div class="flex${n}" style="min-width:max-content" data-line="${t}"><span class="select-none pr-3 text-muted-foreground/60 tabular-nums" style="min-width:3.2rem;text-align:right">${t}</span><span class="whitespace-pre">${r}</span></div>`};return m?m.segments.map(e=>{if("gap"===e.kind){var r;let t,n,s;return r=e.startLine,n=eO(f("diffViewer.gap.hidden",{count:t=e.endLine-r+1})),s=eO(f("diffViewer.gap.expandAll",{count:t})),`<div class="flex items-center cursor-pointer select-none hover:bg-hover" style="min-width:max-content;height:${eG}px" data-fold-gap="${r}" title="${s}"><span class="select-none pr-3 text-muted-foreground/40" style="min-width:3.2rem;text-align:right">⋯</span><span class="text-[10px] text-muted-foreground/60 whitespace-pre">${n}</span></div>`}let n="";for(let r=e.startLine;r<=e.endLine;r++)n+=t(r);return n}).join(""):v.map((r,n)=>t(e.startLine+n)).join("")},[v,m,d,e.startLine,f]);(0,s.useEffect)(()=>{(null!==v||null!==w)&&a(e.qualifiedName)},[v,w,e.qualifiedName,a]);let N=(0,s.useCallback)(t=>{if(!x)return;let r=t.target,n=r?.closest?.("[data-fold-gap]");if(!n)return;let s=Number(n.getAttribute("data-fold-gap"));Number.isFinite(s)&&x(e.qualifiedName,s)},[x,e.qualifiedName]);return(0,n.jsxs)("div",{className:"flex-1 min-w-0 bg-card border border-border rounded overflow-hidden relative",children:[(0,n.jsxs)("div",{"data-block-header":!0,className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-border text-xs",children:[(0,n.jsx)(ef,{kind:e.kind,qname:e.qualifiedName,className:"w-3.5 h-3.5 flex-shrink-0"}),!e.qualifiedName.startsWith("__code_")&&(0,n.jsxs)("span",{className:"font-mono truncate min-w-0",children:[(0,n.jsx)("span",{className:"font-medium",children:e.name}),void 0!==e.params&&(0,n.jsxs)("span",{className:"text-muted-foreground/80",children:["(",e.params.join(", "),")"]})]}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 flex-shrink-0",children:["unknown"!==e.kind&&`${e.kind} \xb7 `,e.endLine-e.startLine+1," ",f("common.lines")]}),p&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:()=>p.sendMessage(f("explain.symbolMessage",{name:e.name,path:e.filePath,lines:`${e.startLine}-${e.endLine}`})),disabled:p.isLoading,title:p.isLoading?f("comments.aiResponding"):void 0,className:eq,children:f("explain.action")}),g&&(0,n.jsx)("button",{onClick:()=>p.sendMessage(f("deps.symbolMessage",{name:e.name,path:e.filePath,lines:`${e.startLine}-${e.endLine}`,...function(e,t,r){let n=e=>{switch(e.kind){case"cross":case"self":return`${e.external.name} (${e.external.filePath})`;case"method":return`${e.receiverName}.${e.methodName}()`;case"ext":return null}},s=e=>{let t=e.map(n).filter(e=>null!==e);return t.length?t.join(", "):r},o=new Map;for(let e of t){if("ext"!==e.kind)continue;let t=o.get(e.packageSpec);t?t.push(e.name):o.set(e.packageSpec,[e.name])}let a=[...o].map(([e,t])=>`${e} (${t.join(", ")})`);return{callers:s(e),callees:s(t),externals:a.length?a.join("; "):r}}(c??[],u??[],f("deps.none"))})),disabled:p.isLoading,title:p.isLoading?f("comments.aiResponding"):void 0,className:eq,children:f("deps.action")})]}),(0,n.jsx)("span",{className:"flex-1"}),r&&(0,n.jsx)("span",{className:"flex-shrink-0 w-2 h-2 rounded-full bg-amber-11","data-tooltip":"File has uncommitted change"})]}),(0,n.jsxs)("div",{"data-block-body":!0,className:"text-[11px] font-mono px-2 py-2 overflow-auto",style:{lineHeight:`${eG}px`},onClick:N,children:[!t&&(0,n.jsx)("span",{className:"text-muted-foreground",children:"Loading…"}),w&&(0,n.jsx)("span",{className:"text-red-11",children:w}),y&&(0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:y}})]}),l&&l.length>0&&i&&(0,n.jsx)(eF,{comments:l,startLine:e.startLine,endLine:e.endLine,lineHeight:eG,bodyTopOffset:eJ+eQ,rowOf:m?.rowOf,onCommentClick:i})]})}function eU({side:e,pin:t,accent:r,onClick:s}){let o,a,l,i,d,c,u,m=t.lines.length;"ext"===t.kind?(o="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",a="ext",l="text-muted-foreground/60",i=t.name,d=t.packageSpec,c="external",u=t.packageSpec):"method"===t.kind?(o="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",a="method",l="text-muted-foreground/60",i=`${t.receiverName}.${t.methodName}`,d=null,c="method (unresolved)",u=m>0?`at line${m>1?"s":""} ${t.lines.join(", ")}`:""):"self"===t.kind?(o="bg-secondary/40 border-border hover:border-muted-foreground",a="self",l="text-muted-foreground/70",i=t.external.name,d=null,c="same-file",u=m>0?`at line${m>1?"s":""} ${t.lines.join(", ")}`:""):(o="in"===e?"bg-amber-9/15 border-amber-9/40 hover:border-amber-11":"bg-green-9/15 border-green-9/40 hover:border-green-11",a=e,l="in"===e?"text-amber-11":"text-green-11",i=t.external.name,d=e_(t.external.filePath),c="in"===e?"caller":"callee",u=t.external.filePath);let x=r&&"ext"!==t.kind&&"method"!==t.kind?" ring-1 ring-amber-9/70 ring-offset-0":"";return(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),s()},className:`${o}${x} w-full text-left border rounded px-1.5 py-0.5 text-[10px] font-mono cursor-pointer transition-colors block`,"data-tooltip":`${c} \xb7 ${i}${u?" \xb7 "+u:""}`,children:(0,n.jsxs)("span",{className:"block h-[26px] leading-[13px] overflow-hidden",children:[(0,n.jsx)("span",{className:`${l} float-left mr-1.5 text-[9px] uppercase tracking-wider font-semibold`,children:a}),(d||m>1)&&(0,n.jsxs)("span",{className:"float-right clear-both ml-1.5 max-w-[60%] truncate text-muted-foreground/70",children:[d,m>1&&(0,n.jsxs)("span",{className:"text-muted-foreground/60",children:[d?" ":"","\xb7",m,"\xd7"]})]}),(0,n.jsx)("span",{className:"font-medium break-all",children:i})]})})}let eK="w-44 @min-[900px]:w-52 @min-[1100px]:w-60 @min-[1400px]:w-72 @min-[1800px]:w-80 @min-[2400px]:w-96",eG=18,eJ=29,eQ=8;function eZ(e,t){switch(t.kind){case"cross":return`${e}:x:${t.external.filePath}::${t.external.qualifiedName}`;case"self":return`${e}:s:${t.external.filePath}::${t.external.qualifiedName}`;case"ext":return`${e}:e:${t.packageSpec}::${t.name}`;case"method":return`${e}:m:${t.receiverName}::${t.methodName}`}}function eX(e,t){return"ext"!==e.kind&&"method"!==e.kind&&(t?.has(e.external.qualifiedName)??!1)}function eY(e){return{filePath:e.filePath,qname:e.qualifiedName,name:e.name,kind:e.kind}}function e0({symbol:e,fileSource:t,hasChange:r,upstream:s,downstream:o,onPinClick:a,onHighlighted:l,comments:i,onCommentClick:d,accentQnames:c,addedLines:u,fold:m,onExpandGap:x}){let h=function(e,t,r){if(0===e.length)return[];let n=e.map((e,r)=>{var n,s;return{i:r,line:(n=e.lines[0]??t.startLine,s=t.startLine,Math.max(s,Math.min(t.endLine,n)))}});n.sort((e,t)=>e.line-t.line||e.i-t.i);let s=Array(e.length).fill(0),o=-1/0;for(let{i:e,line:a}of n){let n=Math.max(eJ+eQ+(r?r.rowOf(a):a-t.startLine)*eG,o);s[e]=n,o=n+34}return s}(o,e,m);return(0,n.jsxs)("div",{"data-block-qname":e.qualifiedName,"data-start-line":e.startLine,"data-end-line":e.endLine,className:"flex gap-2 items-stretch scroll-mt-2",children:[(0,n.jsx)("div",{className:`${eK} flex-shrink-0 flex flex-col gap-1 pt-1`,children:0===s.length?(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5",children:"no callers"}):s.map(t=>(0,n.jsx)(eU,{side:"in",pin:t,accent:eX(t,c),onClick:()=>a(t,e)},eZ("in",t)))}),(0,n.jsx)(eV,{symbol:e,fileSource:t,hasChange:r,onHighlighted:l,comments:i,onCommentClick:d,addedLines:u,upstream:s,downstream:o,fold:m,onExpandGap:x}),(0,n.jsx)("div",{className:`${eK} flex-shrink-0 relative`,children:0===o.length?(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5 pt-1",children:"no callees"}):o.map((t,r)=>(0,n.jsx)("div",{className:"absolute left-0 right-0",style:{top:`${h[r]}px`},children:(0,n.jsx)(eU,{side:"out",pin:t,accent:eX(t,c),onClick:()=>a(t,e)})},eZ("out",t)))})]})}function e1({cwd:e,onSelect:t,onClose:r}){let{t:a}=(0,o.Bd)(),[l,i]=(0,s.useState)(""),[d,c]=(0,s.useState)({files:[],symbols:[]}),[m,x]=(0,s.useState)(0),[h,f]=(0,s.useState)(!1),p=(0,s.useMemo)(()=>[...d.files,...d.symbols],[d]);(0,s.useEffect)(()=>{let t=l.trim();if(!t)return void c({files:[],symbols:[]});f(!0);let r=setTimeout(async()=>{let r=new URLSearchParams({cwd:e,q:t,limit:"12"}),n=await u.t4.runPromiseExit((0,j.MB)(r));"Success"===n._tag&&(c(n.value),x(0)),f(!1)},120);return()=>clearTimeout(r)},[l,e]);let g=(0,s.useCallback)(e=>{if("Escape"===e.key)return void r();if(0!==p.length){if("ArrowDown"===e.key)e.preventDefault(),x(e=>Math.min(e+1,p.length-1));else if("ArrowUp"===e.key)e.preventDefault(),x(e=>Math.max(e-1,0));else if("Enter"===e.key){e.preventDefault();let r=p[m];r&&t(r)}}},[p,m,r,t]);return(0,n.jsx)("div",{className:"absolute inset-0 bg-background/40 z-20 flex items-start justify-center pt-24",onClick:r,children:(0,n.jsxs)("div",{className:"w-[480px] max-w-[80%] bg-card border border-border rounded shadow-lv3 overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,n.jsx)(eo.A,{className:"w-4 h-4 text-muted-foreground"}),(0,n.jsx)("input",{autoFocus:!0,value:l,onChange:e=>i(e.target.value),onKeyDown:g,placeholder:a("blockViewer.search.hint","Start typing to search"),className:"flex-1 bg-transparent border-0 outline-none text-sm"}),h&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"…"}),(0,n.jsx)("button",{onClick:r,className:"text-muted-foreground hover:text-foreground",children:(0,n.jsx)(ea.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsxs)("div",{className:"max-h-96 overflow-y-auto",children:[0===p.length&&l&&!h&&(0,n.jsx)("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a("blockViewer.search.noResults","No matches")}),(0,n.jsx)(e2,{label:a("blockViewer.search.files","Files"),hits:d.files,startIdx:0,activeIdx:m,onSelect:t,setActive:x}),(0,n.jsx)(e2,{label:a("blockViewer.search.symbols","Symbols"),hits:d.symbols,startIdx:d.files.length,activeIdx:m,onSelect:t,setActive:x})]})]})})}function e2({label:e,hits:t,startIdx:r,activeIdx:s,onSelect:o,setActive:a}){return 0===t.length?null:(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-secondary/40",children:e}),t.map((e,t)=>{let l=r+t,i=l===s;return(0,n.jsxs)("button",{onMouseEnter:()=>a(l),onClick:()=>o(e),className:`w-full text-left px-3 py-1.5 text-xs flex items-start gap-2 ${i?"bg-secondary":"hover:bg-secondary/60"}`,children:["file"===e.type?(0,n.jsx)(el.A,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-muted-foreground"}):(0,n.jsx)(ef,{kind:e.target.kind,qname:e.target.qualifiedName,className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,n.jsx)("span",{className:"font-mono truncate",children:e.label}),e.hint&&(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground truncate",children:e.hint})]})]},`${e.type}:${e.label}:${t}`)})]})}function e5({cwd:e,highlightedFilePath:t,changedFiles:r,onSwitchToCode:a,enableComments:l=!1,onContentSearch:i,onFocalChange:d,qnameFilter:c,qnameFilterFile:m,accentQnames:x,accentFile:h,addedLines:f,addedLinesFile:p,compact:g=!1,headerExtraLeft:v,headerExtraRight:j}){let{t:w}=(0,o.Bd)(),[k,y]=(0,s.useState)("toc"),[N,C]=(0,s.useState)(null),S=N??t??null;(0,s.useEffect)(()=>{C(null)},[t]),(0,s.useEffect)(()=>{d?.(S)},[S,d]);let{state:L,refresh:M}=ew(e,S),[E,P]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!S)return void P(null);let t=!1;return P(null),(async()=>{let r=new URLSearchParams({cwd:e,path:S}),n=await u.t4.runPromiseExit((0,b.eA)(r));t||("Success"===n._tag?P({content:n.value.content,mtimeMs:n.value.mtimeMs}):console.error("[BlockViewer] failed to load file source for",S,n.cause))})(),()=>{t=!0}},[e,S]);let T=(0,s.useMemo)(()=>E?E.content.split("\n").length:null,[E]),$=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!E||"ready"!==L.state)return;let e=L.data.mtimeMs;!e||E.mtimeMs<=e||$.current!==E.mtimeMs&&($.current=E.mtimeMs,M())},[E,L,M]);let[R,B]=(0,s.useState)([]),[I,D]=(0,s.useState)(!1),[A,z]=(0,s.useState)(null),H=(0,s.useRef)(0),W=(0,s.useRef)(0),[_,O]=(0,s.useState)(()=>new Set),q="ready"===L.state?L.data.filePath:null;(0,s.useEffect)(()=>{O(new Set)},[q]);let V=(0,s.useCallback)(e=>{O(t=>{if(t.has(e))return t;let r=new Set(t);return r.add(e),r})},[]);(0,s.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),D(!0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let U=(0,s.useCallback)((e,t)=>{if("ext"===e.kind||"method"===e.kind){let e=t.filePath;if(!e)return;H.current+=1,z({filePath:e,qname:"__imports__",nonce:H.current});return}let r=eY(t),n=eY(e.external);B(e=>eE(eE(e,r),n)),C(n.filePath),H.current+=1,z({filePath:n.filePath,qname:n.qname,nonce:H.current})},[]),K=(0,s.useCallback)(e=>{C(e.filePath),H.current+=1,z({filePath:e.filePath,qname:e.qname,nonce:H.current})},[]),G=(0,s.useCallback)(e=>{D(!1),C(e.target.filePath),"symbol"===e.type&&(H.current+=1,z({filePath:e.target.filePath,qname:e.target.qualifiedName,line:e.target.startLine,nonce:H.current}))},[]),J=(0,s.useCallback)((e,t)=>{S&&(H.current+=1,z({filePath:S,qname:e,line:t,nonce:H.current}))},[S]),[Q,Z]=(0,s.useState)(()=>new Set),X=(0,s.useCallback)((e,t)=>{Z(r=>{let n=new Set(r);return n.add(`${S}#${e}#${t}`),n})},[S]),[Y,ee]=(0,s.useState)(null),[et,er]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!Y)return;let e=null,t=()=>{e=null;let t=Y.getBoundingClientRect();if(t.height<=0)return;let r=Y.querySelectorAll("[data-block-qname]"),n=1/0,s=-1/0;r.forEach(e=>{let r=e.dataset.startLine,o=e.dataset.endLine;if(!r||!o)return;let a=Number(r),l=Number(o);if(!Number.isFinite(a)||!Number.isFinite(l))return;let i=e.getBoundingClientRect();if(i.height<=0||i.bottom<=t.top||i.top>=t.bottom)return;let d=Math.max(0,t.top-i.top),c=Math.min(i.height,t.bottom-i.top),u=l-a+1,m=Math.floor(d/i.height*u),x=Math.ceil(c/i.height*u)-1,h=a+Math.max(0,m),f=a+Math.min(u-1,Math.max(0,x));h<n&&(n=h),f>s&&(s=f)}),n===1/0||s===-1/0?er(null):er(e=>e&&e.start===n&&e.end===s?e:{start:n,end:s})},r=()=>{null===e&&(e=requestAnimationFrame(t))};r(),Y.addEventListener("scroll",r,{passive:!0});let n=new ResizeObserver(r);n.observe(Y);let s=new MutationObserver(r);return s.observe(Y,{childList:!0,subtree:!0}),()=>{Y.removeEventListener("scroll",r),n.disconnect(),s.disconnect(),null!==e&&cancelAnimationFrame(e)}},[Y]);let en=(0,s.useMemo)(()=>{if("ready"!==L.state||!et)return null;let e=L.data.functions;if(0===e.length)return null;let t=(et.start+et.end)/2;for(let r of e)if(r.startLine<=t&&t<=r.endLine)return r.qualifiedName;let r=null;for(let t of e)t.startLine<=et.start&&(!r||t.startLine>r.startLine)&&(r=t);return r?.qualifiedName??null},[L,et]),es=l&&!!e&&!!S,eo=(0,F.r)(),{comments:ea,addComment:el,updateComment:ei,deleteComment:ed,refresh:ec}=(0,eN._)({cwd:e,filePath:S??""}),[eu,em]=(0,s.useState)(null),{toolbarRef:ex,bumpRef:eh,clearToolbar:ef}=(0,eR.L)({enabled:es,container:eu,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,r=t?.closest("[data-line]");if(!r||!eu||!eu.contains(r))return null;let n=r.getAttribute("data-line");if(!n)return null;let s=parseInt(n,10);return Number.isFinite(s)?{start:s,end:s}:null},buildLineSnapshot:({start:e,end:t})=>{let r=E?.content;return r?r.split("\n").slice(e-1,t).join("\n"):""}}),[ep,eg]=(0,s.useState)(null),[eb,ev]=(0,s.useState)(null),[ej,ey]=(0,s.useState)(null),eS=(0,s.useCallback)(()=>{let e=ex.current;e&&(eg({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),ef())},[ef,ex]),eL=(0,s.useCallback)(()=>{let e=ex.current;e&&(ev({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),ef())},[ef,ex]),eP=(0,s.useCallback)(()=>{let e=ex.current;e&&eo&&S&&(ef(),(0,eC.Ff)(eo.sendMessage,{filePath:S,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},w("explain.selectionMessage")))},[eo,S,ef,ex,w]),eT=(0,s.useCallback)(()=>{let e=ex.current;if(!e||!i)return;let t=e.selectedText.trim();ef(),t&&i(t)},[i,ef,ex]),eB=(0,s.useCallback)(async e=>{ep&&(await el(ep.range.start,ep.range.end,e,ep.selectedText),eg(null))},[ep,el]),eF=(0,s.useCallback)(async(t,r)=>{if(eo&&e&&S)try{let n=(await (0,eC.$3)(e)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));n.push({filePath:S,startLine:t.range.start,endLine:t.range.end,codeContent:t.lineSnapshot});let s=(0,eC.Gw)(n,r);eo.sendMessage(s),await (0,eC.RP)(e),ec()}catch(e){console.error("[BlockViewer] send to AI failed:",e)}},[eo,e,S,ec]),eI=(0,s.useCallback)(e=>{eb&&eF(eb,e)},[eb,eF]),eO=(0,s.useCallback)(e=>{ep&&eF(ep,e)},[ep,eF]),eq=(0,s.useCallback)((e,t)=>{t.stopPropagation(),ey({comment:e,x:t.clientX,y:t.clientY}),ef(),eg(null),ev(null)},[ef]);if((0,s.useEffect)(()=>{if(!A||W.current>=A.nonce||"ready"!==L.state||!E||L.data.filePath!==A.filePath)return;let e=Math.max(1,new Set((m===L.data.filePath&&c?L.data.functions.filter(e=>c.has(e.qualifiedName)):L.data.functions).map(e=>e.qualifiedName)).size);if(_.size<e)return;W.current=A.nonce;let t=null,r=requestAnimationFrame(()=>{let e=A.qname.indexOf(">"),r=e>=0?A.qname.slice(0,e):A.qname,n=document.querySelector(`[data-block-qname="${CSS.escape(r)}"]`);if(!n)return;if("number"==typeof A.line){let e=n.querySelector(`[data-line="${A.line}"]`);if(e instanceof HTMLElement){e.scrollIntoView({behavior:"instant",block:"center"}),e.classList.remove("line-flash"),e.offsetWidth,e.classList.add("line-flash"),t=window.setTimeout(()=>{e.classList.remove("line-flash")},1700);return}}n.scrollIntoView({behavior:"instant",block:"start"});let s=n.querySelector("[data-block-header]");s instanceof HTMLElement&&(s.classList.remove("block-flash"),s.offsetWidth,s.classList.add("block-flash"),t=window.setTimeout(()=>{s.classList.remove("block-flash")},1700))});return()=>{cancelAnimationFrame(r),null!==t&&window.clearTimeout(t)}},[A,L,E,_,c,m]),!S)return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)(e3,{focalFile:null,fileCount:null,onSwitchToCode:a,onSearch:()=>D(!0),onRefresh:M,refreshDisabled:!0,extraLeft:v,extraRight:j}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-sm text-muted-foreground gap-2 px-4 text-center",children:[(0,n.jsx)("span",{children:w("blockViewer.empty.body","Select a file in the left tree to see its function call graph.")}),(0,n.jsx)("span",{className:"text-xs",children:w("blockViewer.empty.hint","or press ⌘K to search.")})]}),I&&(0,n.jsx)(e1,{cwd:e,onSelect:G,onClose:()=>D(!1)})]});if("idle"===L.state||"loading"===L.state)return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)(e3,{focalFile:S,fileCount:null,onSwitchToCode:a,onSearch:()=>D(!0),onRefresh:M,refreshDisabled:!0,extraLeft:v,extraRight:j}),(0,n.jsx)(ek,{cwd:e})]});if("notFound"===L.state)return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)(e3,{focalFile:S,fileCount:null,onSwitchToCode:a,onSearch:()=>D(!0),onRefresh:M,extraLeft:v,extraRight:j}),(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground px-4 text-center",children:w("blockViewer.fileMode.notFound","This file is not indexed (unsupported language or beyond the file cap).")}),I&&(0,n.jsx)(e1,{cwd:e,onSelect:G,onClose:()=>D(!1)})]});if("error"===L.state)return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)(e3,{focalFile:S,fileCount:null,onSwitchToCode:a,onSearch:()=>D(!0),onRefresh:M,extraLeft:v,extraRight:j}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-sm",children:[(0,n.jsx)("span",{className:"text-red-11",children:L.message}),(0,n.jsx)("button",{onClick:M,className:"px-3 py-1 rounded bg-secondary hover:bg-secondary/80",children:w("blockViewer.retry","Retry")})]})]});let eV=L.data,eU=eV.functions;if(0===eU.length&&E){let e=Math.max(1,T??1);eU=[{filePath:eV.filePath,qualifiedName:"__file__",name:e_(eV.filePath),kind:"unknown",startLine:1,endLine:e}]}let eG=m&&m===eV.filePath,eJ=h&&h===eV.filePath,eQ=p&&p===eV.filePath;eG&&c&&(eU=eU.filter(e=>c.has(e.qualifiedName)));let eZ=eJ?x:void 0,eX=eQ?f:void 0,e2=new Map;if(g&&eX)for(let e of eU)e2.set(e.qualifiedName,function(e,t,r,n,s=eA.aj){if(t<e)return null;let o=[];for(let n of r)n>=e&&n<=t&&o.push(n);o.sort((e,t)=>e-t);let a=[];for(let r of o){let n=Math.max(e,r-s),o=Math.min(t,r+s),l=a[a.length-1];l&&n<=l.endLine+1?o>l.endLine&&(l.endLine=o):a.push({startLine:n,endLine:o})}let l=[],i=e;for(let e of a)e.startLine>i&&l.push({startLine:i,endLine:e.startLine-1}),i=e.endLine+1;i<=t&&l.push({startLine:i,endLine:t});let d=[],c=[];for(let e of l)e.endLine-e.startLine+1<2||n(e.startLine)?c.push(e):d.push(e);if(0===d.length)return null;a=function(e){let t=[...e].sort((e,t)=>e.startLine-t.startLine),r=[];for(let e of t){let t=r[r.length-1];t&&e.startLine<=t.endLine+1?e.endLine>t.endLine&&(t.endLine=e.endLine):r.push({...e})}return r}([...a,...c]);let u=[];for(let e of[...a.map(e=>({kind:"lines",...e})),...d.map(e=>({kind:"gap",...e}))].sort((e,t)=>e.startLine-t.startLine))u.push(e);let m=[],x=0;for(let e of u)m.push(x),x+="gap"===e.kind?1:e.endLine-e.startLine+1;let h=x;return{segments:u,visibleRuns:a,hiddenCount:d.reduce((e,t)=>e+(t.endLine-t.startLine+1),0),rowOf:t=>{for(let e=0;e<u.length;e++){let r=u[e];if(t<r.startLine)break;if(t<=r.endLine)return"gap"===r.kind?m[e]:m[e]+(t-r.startLine)}return t<e?0:Math.max(0,h-1)}}}(e.startLine,e.endLine,eX,t=>Q.has(`${eV.filePath}#${e.qualifiedName}#${t}`)));let e6=e4(eV.upstreamCalls),e8=e4(eV.downstreamCalls),e9=new Map(eU.map(e=>[e.qualifiedName,e])),e7=new Map,te=new Map;for(let e of eV.intraCalls){let t=e9.get(e.to),r=e9.get(e.from);if(t){let r=e7.get(e.from),n={kind:"self",external:t,lines:e.lines};r?r.push(n):e7.set(e.from,[n])}if(r){let t=te.get(e.to),n={kind:"self",external:r,lines:e.lines};t?t.push(n):te.set(e.to,[n])}}let tt=new Map;for(let e of eV.externalCalls??[]){let t=tt.get(e.focalQname),r={kind:"ext",name:e.external.name,packageSpec:e.external.packageSpec,lines:e.lines};t?t.push(r):tt.set(e.focalQname,[r])}let tr=new Map;for(let e of eV.methodCalls??[]){let t=tr.get(e.focalQname),r={kind:"method",receiverName:e.receiverName,methodName:e.methodName,lines:e.lines};t?t.push(r):tr.set(e.focalQname,[r])}let tn=new Map;for(let e of eU){let t=e.qualifiedName,r={in:e6.get(t)?.length??0,out:e8.get(t)?.length??0,self:(te.get(t)?.length??0)+(e7.get(t)?.length??0)};(r.in||r.out||r.self)&&tn.set(t,r)}let ts=r.has(eV.filePath);return(0,n.jsxs)("div",{className:"h-full flex flex-col relative",children:[(0,n.jsx)(e3,{focalFile:S,fileCount:eV.fileCount,functionCount:eV.functions.length,upstreamCount:eV.upstreamCalls.length,downstreamCount:eV.downstreamCalls.length,onSwitchToCode:a,onSearch:()=>D(!0),onRefresh:M,extraLeft:v,extraRight:j}),(0,n.jsxs)("div",{ref:em,className:"@container flex-1 relative min-h-0 flex",children:[(0,n.jsxs)("div",{className:`${eK} flex-shrink-0 border-r border-border flex flex-col`,children:[(0,n.jsx)("div",{className:"flex-shrink-0 flex border-b border-border",children:[["toc",w("blockViewer.tabs.toc")],["history",w("blockViewer.tabs.history")]].map(([e,t])=>(0,n.jsx)("button",{onClick:()=>y(e),className:`flex-1 px-2 py-1.5 text-xs font-medium transition-colors ${k===e?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground"}`,children:t},e))}),(0,n.jsx)("div",{className:"toc"===k?"flex-1 min-h-0 flex flex-col":"hidden",children:(0,n.jsx)(e$,{functions:eU,counts:tn,totalLines:T,currentQname:en,onSelect:J,notIndexed:eV.notIndexed,onRebuild:M})}),(0,n.jsx)("div",{className:"history"===k?"flex-1 min-h-0 flex flex-col":"hidden",children:(0,n.jsx)(eM,{entries:R,onSelect:K,onClear:()=>B([])})})]}),(0,n.jsx)("div",{ref:ee,className:"@container flex-1 min-w-0 overflow-auto",children:(0,n.jsx)("div",{className:"flex flex-col gap-3 p-3",children:eU.map(e=>{let t,r,s,o,a,l;return(0,n.jsx)(e0,{symbol:e,fileSource:E?.content??null,hasChange:ts,upstream:(t=e6.get(e.qualifiedName),r=te.get(e.qualifiedName),[...(t??[]).map(e=>({kind:"cross",external:e.external,lines:e.lines})),...r??[]]),downstream:(s=e8.get(e.qualifiedName),o=e7.get(e.qualifiedName),a=tr.get(e.qualifiedName),l=tt.get(e.qualifiedName),[...(s??[]).map(e=>({kind:"cross",external:e.external,lines:e.lines})),...o??[],...a??[],...l??[]]),onPinClick:U,onHighlighted:V,comments:es?ea:void 0,onCommentClick:es?eq:void 0,accentQnames:eZ,addedLines:eX,fold:e2.get(e.qualifiedName),onExpandGap:X},`${e.qualifiedName}#${e.startLine}`)})})}),es&&eu&&(0,n.jsx)(ez.fS,{floatingToolbarRef:ex,bumpRef:eh,container:eu,onAddComment:eS,onSendToAI:eL,onSearch:i?eT:void 0,onExplain:eo&&S?eP:void 0,isChatLoading:eo?.isLoading}),es&&ep&&(0,n.jsx)(eH.t,{x:ep.x,y:ep.y,range:ep.range,filePath:S??void 0,lineSnapshot:ep.lineSnapshot,container:eu,onSubmit:eB,onSendToAI:eo&&S?eO:void 0,onClose:()=>eg(null),isChatLoading:eo?.isLoading}),es&&eb&&S&&(0,n.jsx)(eH.G,{x:eb.x,y:eb.y,range:eb.range,filePath:S,lineSnapshot:eb.lineSnapshot,container:eu,onSubmit:eI,onClose:()=>ev(null),isChatLoading:eo?.isLoading}),es&&ej&&(0,n.jsx)(eW.t,{x:ej.x,y:ej.y,comment:ej.comment,container:eu,onClose:()=>ey(null),onUpdateComment:ei,onDeleteComment:ed}),eX&&eX.size>0&&eU.length>0&&(0,n.jsx)(eD,{addedLines:eX,blockRanges:eU.flatMap(e=>{let t=e2.get(e.qualifiedName);return t?t.visibleRuns.map(t=>({qname:e.qualifiedName,startLine:t.startLine,endLine:t.endLine})):[{qname:e.qualifiedName,startLine:e.startLine,endLine:e.endLine}]}),viewportRange:et,onJumpToLine:J}),I&&(0,n.jsx)(e1,{cwd:e,onSelect:G,onClose:()=>D(!1)})]})]})}function e4(e){let t=new Map;for(let r of e){let e=t.get(r.focalQname);if(!e){t.set(r.focalQname,[r]);continue}e.some(e=>e.external.filePath===r.external.filePath&&e.external.qualifiedName===r.external.qualifiedName)||e.push(r)}return t}function e3({focalFile:e,fileCount:t,functionCount:r,upstreamCount:s,downstreamCount:a,onSwitchToCode:l,onSearch:i,onRefresh:d,refreshDisabled:c,extraLeft:u,extraRight:m}){let{t:x}=(0,o.Bd)(),h={focalFile:e,blockCount:r??0,upstreamCount:s??0,downstreamCount:a??0};return(0,n.jsxs)("div",{className:"flex-shrink-0 px-3 py-2 border-b border-border flex items-center justify-between gap-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0 text-xs text-muted-foreground font-mono",children:[(0,n.jsx)("span",{className:"truncate min-w-0",children:e?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-foreground",children:e}),"number"==typeof r&&(0,n.jsxs)("span",{className:"ml-2",children:["\xb7 ",r," blocks"]}),"number"==typeof s&&"number"==typeof a&&(0,n.jsxs)("span",{className:"ml-2",children:["\xb7 ",s," in \xb7 ",a," out"]})]}):(0,n.jsx)("span",{children:null!==t?`${t} files`:"…"})}),u&&(0,n.jsx)("span",{className:"flex items-center gap-1 flex-shrink-0",children:u(h)})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[m&&(0,n.jsx)("span",{className:"flex items-center gap-1",children:m(h)}),(0,n.jsxs)("button",{onClick:i,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground flex items-center gap-1","data-tooltip":x("blockViewer.search.tooltip","Search (⌘K)"),children:[(0,n.jsx)(eo.A,{className:"w-3 h-3"})," ⌘K"]}),(0,n.jsx)("button",{onClick:d,disabled:c,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:hover:bg-transparent","data-tooltip":x("blockViewer.refresh","Rebuild project graph"),children:(0,n.jsx)(ei.A,{className:"w-3 h-3"})}),l&&(0,n.jsx)("button",{onClick:l,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground",children:x("common.code","Code")})]})]})}var e6=r(22576);function e8(e){let t=0xdeadbeef,r=0x41c6ce57;for(let n=0;n<e.length;n++){let s=e.charCodeAt(n);t=Math.imul(t^s,0x9e3779b1),r=Math.imul(r^s,0x5f356495)}return t=Math.imul(t^t>>>16,0x85ebca6b)^Math.imul(r^r>>>13,0xc2b2ae35),(0x100000000*(2097151&(r=Math.imul(r^r>>>16,0x85ebca6b)^Math.imul(t^t>>>13,0xc2b2ae35)))+(t>>>0)>>>0).toString(16)}function e9(e){return e.replace(/\s+/g," ").trim()}function e7(e,t){return e?`${e}>${t}`:t}function te(e){let t=e.childForFieldName("name");if(t)return t.text;for(let t=0;t<e.namedChildCount;t++){let r=e.namedChild(t);if(r&&("identifier"===r.type||"type_identifier"===r.type||"property_identifier"===r.type))return r.text}return"<anonymous>"}function tt(e,t,r,n,s=[],o){return{qualifiedName:e7(n,t),name:t,kind:r,startLine:e.startPosition.row+1,endLine:e.endPosition.row+1,contentHash:e8(e9(e.text)),children:s,params:o}}function tr(e){let t=e.childForFieldName("parameter");if(t)return[t.text];let r=e.childForFieldName("parameters");if(!r)return;let n=[];for(let e=0;e<r.namedChildCount;e++){let t=r.namedChild(e);t&&n.push(function e(t){switch(t.type){case"required_parameter":case"optional_parameter":{let r=t.childForFieldName("pattern");return r?e(r):t.text}case"assignment_pattern":{let r=t.childForFieldName("left");return r?e(r):t.text}case"default_parameter":case"typed_default_parameter":{let e=t.childForFieldName("name");return e?e.text:t.text}case"typed_parameter":for(let e=0;e<t.namedChildCount;e++){let r=t.namedChild(e);if(r?.type==="identifier")return r.text}return t.text;default:return t.text}}(t))}return n}let tn={theorem:"function",def:"function",abbrev:"function",example:"function",instance:"const",structure:"class",inductive:"type",axiom:"const",opaque:"const",constant:"const"};function ts(e){let t=e.split("/").pop()?.toLowerCase()??"";switch(t.includes(".")?t.split(".").pop():""){case"ts":return"typescript";case"tsx":case"jsx":return"tsx";case"js":case"mjs":case"cjs":return"javascript";case"py":case"pyi":return"python";case"go":return"go";case"rs":return"rust";case"lean":return"lean";default:return null}}var to=r(14066);let ta="/tree-sitter",tl=null,ti=new Map;async function td(e){let t,r=await (!(t=ti.get(e))&&(t=(async()=>(await (!tl&&(tl=to.iX.init({locateFile:e=>`${ta}/${e}`})),tl),to.TM.load(`${ta}/tree-sitter-${e}.wasm`)))(),ti.set(e,t)),t),n=new to.iX;return n.setLanguage(r),n}function tc(e){return e.qualifiedName.startsWith("__code_")||e.qualifiedName.startsWith("__heading_")}function tu(e){return!tc(e)&&"__file__"!==e.qualifiedName}async function tm(e,t){if(!e)return[];let r=ts(t);if(!r)return null;let n=(await td(r)).parse(e);if(!n)return null;try{return function(e,t){var r;let n,s,o=[],a=function(e){let t=[],r=-1,n=-1;for(let s=0;s<e.namedChildCount;s++){let o=e.namedChild(s);if(o){if("import_statement"===o.type||"export_statement"===o.type&&null!==o.childForFieldName("source")||"import_from_statement"===o.type||"future_import_statement"===o.type||"import"===o.type)t.push(o),r<0&&(r=o.startPosition.row+1),n=o.endPosition.row+1;else if(r>=0)break}}return r<0?null:{qualifiedName:"__imports__",name:"imports",kind:"unknown",startLine:r,endLine:n,contentHash:e8(e9(t.map(e=>e.text).join("\n"))),children:[]}}(e);if(a&&o.push(a),"lean"===t)o.push(...function(e){let t=[],r=[];for(let n=0;n<e.namedChildCount;n++){let s=e.namedChild(n);if(!s)continue;switch(s.type){case"namespace":r.push(s.childForFieldName("name")?.text??null);continue;case"section":r.push(null);continue;case"end":r.pop();continue}let o=null;if("declaration"===s.type)for(let e=0;e<s.namedChildCount;e++){let t=s.namedChild(e);if(t&&t.type in tn){o=t;break}}else s.type in tn&&(o=s);if(!o)continue;let a=o.childForFieldName("name")?.text??o.type,l=r.filter(e=>null!==e);t.push({qualifiedName:[...l,a].join("."),name:a,kind:tn[o.type],startLine:s.startPosition.row+1,endLine:function(e){let t=e.endPosition.row+1,r=e.text.replace(/\s+$/,""),n=e.text.slice(r.length);if(!n)return t;let s=n.split("\n").length-1;return Math.max(e.startPosition.row+1,t-s)}(s),contentHash:e8(e9(s.text)),children:[]})}return t}(e));else for(let t=0;t<e.namedChildCount;t++){let r=e.namedChild(t);r&&o.push(...function e(t,r,n=!1){switch(t.type){case"export_statement":case"export_default_declaration":{let n=[];for(let s=0;s<t.namedChildCount;s++){let o=t.namedChild(s);o&&n.push(...e(o,r,!0))}return n}case"function_declaration":case"generator_function_declaration":case"function_definition":return[tt(t,te(t),"function",r,[],tr(t))];case"class_declaration":case"abstract_class_declaration":{let e=te(t),n=e7(r,e),s=function(e,t){if(!e)return[];let r=[];for(let n=0;n<e.namedChildCount;n++){let s=e.namedChild(n);if(s){if("method_definition"===s.type)r.push(tt(s,te(s),"method",t,[],tr(s)));else if("public_field_definition"===s.type){let e=s.childForFieldName("value");e&&("arrow_function"===e.type||"function_expression"===e.type)&&r.push(tt(s,te(s),"method",t,[],tr(e)))}}}return r}(t.childForFieldName("body"),n);return[tt(t,e,"class",r,s)]}case"interface_declaration":return[tt(t,te(t),"interface",r)];case"type_alias_declaration":return[tt(t,te(t),"type",r)];case"enum_declaration":return[tt(t,te(t),"enum",r)];case"lexical_declaration":case"variable_declaration":return function(e,t){let r=[];for(let n=0;n<e.namedChildCount;n++){let s=e.namedChild(n);if(!s||"variable_declarator"!==s.type)continue;let o=s.childForFieldName("name"),a=s.childForFieldName("value");if(!o)continue;let l=o.text,i=a&&("arrow_function"===a.type||"function_expression"===a.type),d=i&&a?tr(a):void 0;if(r.push(tt(e,l,i?"function":"const",t,[],d)),a&&"object"===a.type&&!i){let e=t?`${t}>${l}`:l;for(let t=0;t<a.namedChildCount;t++){let n=a.namedChild(t);if(n){if("pair"===n.type){let t=n.childForFieldName("key"),s=n.childForFieldName("value");if(!t||!s||"property_identifier"!==t.type&&"identifier"!==t.type||"arrow_function"!==s.type&&"function_expression"!==s.type)continue;r.push(tt(n,t.text,"method",e,[],tr(s)))}else if("method_definition"===n.type){let t=te(n);t&&r.push(tt(n,t,"method",e,[],tr(n)))}}}}}return r}(t,r);case"class_definition":{let e=te(t),n=e7(r,e),s=function e(t,r){if(!t)return[];let n=[];for(let s=0;s<t.namedChildCount;s++){let o=t.namedChild(s);if(o){if("function_definition"===o.type)n.push(tt(o,te(o),"method",r,[],tr(o)));else if("decorated_definition"===o.type){let t=o.childForFieldName("definition");if(t?.type==="function_definition")n.push({...tt(t,te(t),"method",r,[],tr(t)),startLine:o.startPosition.row+1,contentHash:e8(e9(o.text))});else if(t?.type==="class_definition"){let s=te(t),a=e7(r,s),l=e(t.childForFieldName("body"),a);n.push({...tt(t,s,"class",r,l),startLine:o.startPosition.row+1,contentHash:e8(e9(o.text))})}}else if("class_definition"===o.type){let t=te(o),s=e7(r,t),a=e(o.childForFieldName("body"),s);n.push(tt(o,t,"class",r,a))}}}return n}(t.childForFieldName("body"),n);return[tt(t,e,"class",r,s)]}case"decorated_definition":{let n=t.childForFieldName("definition");if(!n)return[];return e(n,r,!1).map(e=>({...e,startLine:t.startPosition.row+1,contentHash:e8(e9(t.text))}))}case"expression_statement":{let e=[];for(let n=0;n<t.namedChildCount;n++){let s=t.namedChild(n);if(s?.type==="assignment"){let n=function(e,t,r){let n=t.childForFieldName("left");if(!n||"identifier"!==n.type)return null;let s=n.text;return{qualifiedName:e7(r,s),name:s,kind:"const",startLine:e.startPosition.row+1,endLine:e.endPosition.row+1,contentHash:e8(e9(e.text)),children:[]}}(t,s,r);n&&e.push(n)}}return e.push(...function(e,t){let r=null;for(let t=0;t<e.namedChildCount;t++){let n=e.namedChild(t);if(n){if("call_expression"===n.type){r=n;break}if("await_expression"===n.type){for(let e=0;e<n.namedChildCount;e++){let t=n.namedChild(e);if(t?.type==="call_expression"){r=t;break}}break}}}if(!r)return[];let n=r.childForFieldName("function"),s=r.childForFieldName("arguments");if(!n||!s)return[];let o=null,a=[];for(let e=0;e<s.namedChildCount;e++){let t=s.namedChild(e);if(t){if(null===o&&("string"===t.type||"template_string"===t.type)){let e=t.text;o=e.length>=2&&/^["'`]/.test(e)?e.slice(1,-1):e}("arrow_function"===t.type||"function_expression"===t.type)&&a.push(t)}}if(0===a.length||!o)return[];let l=function e(t){if("identifier"===t.type)return t.text;if("member_expression"===t.type){let e=t.childForFieldName("property");return e?.text??""}if("call_expression"===t.type){let r=t.childForFieldName("function");return r?e(r):""}return""}(n),i=l?`${l} ${o}`:o;return a.map((e,r)=>tt(e,a.length>1?`${i} #${r+1}`:i,"function",t,[],tr(e)))}(t,r)),e}default:return[]}}(r,void 0,!1))}return!function(e,t){let r=new Map;for(let t=0;t<e.namedChildCount;t++){let n=e.namedChild(t);n&&n.type.endsWith("comment")&&r.set(n.endPosition.row+1,n)}if(0===r.size)return;let n=new Set;for(let e of t)for(let t=e.startLine;t<=e.endLine;t++)n.add(t);for(let e of t){if("unknown"===e.kind)continue;let t=e.startLine;for(;;){let e=r.get(t-1);if(!e)break;let s=e.startPosition.row+1,o=!1;for(let e=s;e<=t-1;e++)if(n.has(e)){o=!0;break}if(o)break;t=s}if(t!==e.startLine){for(let r=t;r<e.startLine;r++)n.add(r);e.startLine=t}}}(e,o),o.push(...function(e,t){let r=e.text.split("\n"),n=r.length;if(0===n)return[];let s=new Uint8Array(n+2);for(let e of t){let t=Math.max(1,e.startLine),r=Math.min(n,e.endLine);for(let e=t;e<=r;e++)s[e]=1}let o=[],a=(e,t)=>{let n=!1;for(let s=e;s<=t;s++){let e=r[s-1];if(e&&e.trim().length>0){n=!0;break}}if(!n)return;let s=r.slice(e-1,t).join("\n");o.push({qualifiedName:`__code_${e}_${t}__`,name:"code",kind:"unknown",startLine:e,endLine:t,contentHash:e8(e9(s)),children:[]})},l=-1;for(let e=1;e<=n;e++)s[e]?l>=0&&(a(l,e-1),l=-1):l<0&&(l=e);return l>=0&&a(l,n),o}(e,o)),r=o,n=new Map,(s=e=>{for(let t of e){let e=(n.get(t.qualifiedName)??0)+1;n.set(t.qualifiedName,e),e>1&&(t.qualifiedName=`${t.qualifiedName}#${e}`),s(t.children)}})(r),o}(n.rootNode,r)}finally{n.delete()}}async function tx(e,t,r,n,s){let o=new Set;if(e!==t)for(let r of(0,e6.X)(n?"":e,s?"":t))"added"===r.type&&void 0!==r.newLineNum&&o.add(r.newLineNum);if(!ts(r))return{addedLines:o};let[a,l]=await Promise.all([tm(n?"":e,r),tm(s?"":t,r)]),i=l??[],d=function(e,t){let r=new Map;for(let t of e)r.set(t.qualifiedName,t);let n=new Map;for(let e of t)n.set(e.qualifiedName,e);let s=[];for(let e of t){let t=r.get(e.qualifiedName);t?t.contentHash!==e.contentHash&&s.push({id:`mod:${e.qualifiedName}`,changeKind:"modified",qname:e.qualifiedName}):s.push({id:`add:${e.qualifiedName}`,changeKind:"added",qname:e.qualifiedName})}for(let t of e)n.has(t.qualifiedName)||s.push({id:`del:${t.qualifiedName}`,changeKind:"deleted",qname:t.qualifiedName});return s}((a??[]).filter(tu),i.filter(tu)),c=new Set;for(let e of d)"deleted"!==e.changeKind&&c.add(e.qname);for(let e of function(e,t){if(0===t.size)return[];let r=[];for(let n of e)if(tc(n)){for(let e of t)if(e>=n.startLine&&e<=n.endLine){r.push(n.qualifiedName);break}}return r}(i,o))c.add(e);return{changedQnames:c,addedLines:o}}function th({cwd:e,filePath:t,oldContent:r,newContent:o,isNew:a=!1,isDeleted:l=!1,changedFiles:i,fileGitStatusMap:d,enableComments:c=!1,compact:u=!0,onContentSearch:m,onSwitchToCode:x,headerExtraLeft:h,headerExtraRight:f}){let[p,g]=(0,s.useState)(t);(0,s.useEffect)(()=>{g(t)},[t]);let[b,v]=(0,s.useState)(null);return(0,s.useEffect)(()=>{let n=!1;return v(null),(async()=>{try{let s=await tf(p,t,r,o,a,l,i,d,e);if(n||!s)return;let c=await tx(s.oldContent,s.newContent,p,s.isNew,s.isDeleted);if(n)return;v(c)}catch(e){n||console.error("[BlockDiffViewer] projection failed:",e)}})(),()=>{n=!0}},[p,t,r,o,a,l,i,d,e]),(0,n.jsx)(e5,{cwd:e,highlightedFilePath:t,changedFiles:i,enableComments:c,qnameFilter:u?b?.changedQnames:void 0,qnameFilterFile:p,accentQnames:b?.changedQnames,accentFile:p,addedLines:b?.addedLines,addedLinesFile:p,compact:u,onFocalChange:e=>e&&g(e),onContentSearch:m,onSwitchToCode:x,headerExtraLeft:h,headerExtraRight:f})}async function tf(e,t,r,n,s,o,a,l,i){if(e===t)return{oldContent:r,newContent:n,isNew:s,isDeleted:o};if(!a.has(e))return null;let d=l?.get(e);if(!d)return null;let c=new URLSearchParams({cwd:i,file:e,type:d}),m=await u.t4.runPromiseExit((0,j.oh)(c));if("Success"!==m._tag)return null;let x=m.value;return{oldContent:x.oldContent,newContent:x.newContent,isNew:x.isNew??!1,isDeleted:x.isDeleted??!1}}var tp=r(50860);let tg=(e,t,r)=>`/api/git/blob?cwd=${encodeURIComponent(e)}&rev=${encodeURIComponent(t)}&file=${encodeURIComponent(r)}`;function tb({cwd:e,selected:t,diff:r,showMarkdownPreview:a,setShowMarkdownPreview:l,changedFiles:i,fileGitStatusMap:d,onContentSearch:c,locateInTree:u,jsonPreview:m,setJsonPreview:x,jsonPreviewSearch:h,jsonPreviewPreRef:f,onTokenHover:p,onTokenHoverLeave:g,onTokenHoverCancel:b}){let{t:v}=(0,o.Bd)(),j="unstaged"===t.type?{onTokenHover:p,onTokenHoverLeave:g,onTokenHoverCancel:b}:{},[C,L]=(0,s.useState)(!1),[M,T]=(0,s.useState)("file"),[F,I]=(0,s.useState)("compact"),[D,A]=(0,s.useState)("unified"),z=t.file.path,H=t.file.oldPath||z,W=(0,$.u)(z),_=z.startsWith("/")?z:e?`${e.replace(/\/$/,"")}/${z}`:z,{state:O}=ew(e,z),q=(0,s.useMemo)(()=>{if("ready"===O.state)return O.data.functions.filter(eT).map(e=>({name:e.name,startLine:e.startLine,endLine:e.endLine,params:e.params}))},[O]);return(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[W||"map"!==M?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-4 py-2 border-b border-border flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:z}),(0,n.jsx)(E.m,{content:v("common.copyAbsPath"),children:(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(`${e}/${z}`),(0,P.oR)(v("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})}),(0,n.jsx)(E.m,{content:v("fileBrowser.locateInTree"),children:(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),u(z)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,n.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),(0,n.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${"staged"===t.type?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===t.type?v("fileBrowser.staged"):v("fileBrowser.unstaged")}),(0,n.jsx)("div",{className:"flex-1"}),!W&&(0,n.jsx)(y.y,{value:F,onChange:I}),!W&&"file"===M&&(0,n.jsx)(N.q,{value:D,onChange:A}),!W&&(0,n.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(e=>(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),T(e)},className:`px-2 py-0.5 text-xs transition-colors ${M===e?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:v("file"===e?"common.file":"common.codeMap")},e))})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:W?(0,n.jsx)(S.K,{filePath:z,oldSrc:r.isNew?null:tg(e,"staged"===t.type?"HEAD":":0","staged"===t.type?H:z),newSrc:r.isDeleted||"staged"!==t.type?null:tg(e,":0",z),newNode:r.isDeleted||"staged"===t.type?void 0:(0,n.jsx)(tp.I,{cwd:e,path:z,className:"flex items-center justify-center",imgClassName:"max-w-full max-h-[60vh] object-contain",alt:z})}):"unified"===D?(0,n.jsx)(w.xU,{oldContent:r.oldContent,newContent:r.newContent,filePath:r.filePath,cwd:e,enableComments:!0,compact:"compact"===F,onPreview:!r.isDeleted&&(0,R.e$)(z)?()=>l(!0):!r.isDeleted&&(0,R.aR)(z)?()=>L(!0):!r.isDeleted&&z.endsWith(".json")?()=>x({content:r.newContent,filePath:r.filePath}):void 0,previewLabel:z.endsWith(".json")?v("common.readable"):v("common.preview"),onContentSearch:c,...j}):(0,n.jsx)(w.xZ,{oldContent:r.oldContent,newContent:r.newContent,filePath:r.filePath,isNew:r.isNew,isDeleted:r.isDeleted,cwd:e,enableComments:!0,compact:"compact"===F,symbols:q,onPreview:!r.isDeleted&&(0,R.e$)(z)?()=>l(!0):!r.isDeleted&&(0,R.aR)(z)?()=>L(!0):!r.isDeleted&&z.endsWith(".json")?()=>x({content:r.newContent,filePath:r.filePath}):void 0,previewLabel:z.endsWith(".json")?v("common.readable"):v("common.preview"),onContentSearch:c,...j})})]}):(0,n.jsx)(th,{cwd:e,filePath:r.filePath,oldContent:r.oldContent,newContent:r.newContent,isNew:r.isNew,isDeleted:r.isDeleted,changedFiles:i,fileGitStatusMap:d,enableComments:!0,compact:"compact"===F,onContentSearch:c,headerExtraLeft:({focalFile:t})=>{if(!t)return null;let r=d.get(t);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(E.m,{content:v("common.copyAbsPath"),children:(0,n.jsx)("button",{onClick:r=>{r.stopPropagation(),navigator.clipboard.writeText(`${e}/${t}`),(0,P.oR)(v("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})}),(0,n.jsx)(E.m,{content:v("fileBrowser.locateInTree"),children:(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),u(t)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,n.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),r&&(0,n.jsx)("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${"staged"===r?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===r?v("fileBrowser.staged"):v("fileBrowser.unstaged")})]})},headerExtraRight:()=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(y.y,{value:F,onChange:I}),(0,n.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(e=>(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),T(e)},className:`px-2 py-0.5 text-[11px] transition-colors ${M===e?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:v("file"===e?"common.file":"common.codeMap")},e))})]})}),a&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>l(!1),children:(0,n.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:(0,n.jsx)(X.M,{content:r.newContent,filePath:r.filePath,cwd:e,onClose:()=>l(!1)})})}),C&&(0,n.jsx)(k.N,{filePath:_,content:r.newContent,cwd:e,onClose:()=>L(!1)}),m&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>x(null),children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90%] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:m.filePath}),(0,n.jsx)("button",{onClick:()=>x(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)(B._,{search:h}),(0,n.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,n.jsx)("pre",{ref:f,className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,R.xb)(m.content)})})]})})]})}function tv({branches:e,selectedBranch:t,onSelect:r,isLoading:a,pinnedBranches:l=[]}){let{t:i}=(0,o.Bd)(),[d,c]=(0,s.useState)(!1),[u,m]=(0,s.useState)(""),x=(0,s.useRef)(null),h=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,s.useEffect)(()=>{d&&h.current&&h.current.focus()},[d]);let f=u.toLowerCase(),p=new Set([...e?.local||[],...e?.remote||[]]),g=l.filter(e=>p.has(e)&&e.toLowerCase().includes(f)),b=new Set(g),v=e?.local.filter(e=>!b.has(e)&&e.toLowerCase().includes(f))||[],j=e?.remote.filter(e=>!b.has(e)&&e.toLowerCase().includes(f))||[],w=e=>{r(e),c(!1),m("")};return(0,n.jsxs)("div",{className:"relative",ref:x,children:[(0,n.jsxs)("button",{onClick:()=>c(!d),disabled:a,className:"w-full px-3 py-1.5 text-sm border border-border rounded bg-card text-foreground text-left flex items-center justify-between hover:border-slate-6 dark:hover:border-slate-6 transition-colors",children:[(0,n.jsxs)("span",{className:"truncate flex items-center gap-2",children:[(0,n.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),t||i("git.selectBranch"),e?.current===t&&(0,n.jsxs)("span",{className:"text-xs text-green-11",children:["(",i("git.currentBranch"),")"]})]}),(0,n.jsx)("svg",{className:`w-4 h-4 text-foreground-subtle transition-transform ${d?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),d&&(0,n.jsxs)("div",{className:"absolute z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lv2 max-h-80 flex flex-col",children:[(0,n.jsx)("div",{className:"p-2 border-b border-border",children:(0,n.jsx)("input",{ref:h,type:"text",value:u,onChange:e=>m(e.target.value),placeholder:i("git.searchBranch"),className:"w-full px-2 py-1 text-sm border border-border rounded bg-secondary text-foreground"})}),(0,n.jsxs)("div",{className:"overflow-y-auto flex-1",children:[g.length>0&&g.map(r=>(0,n.jsxs)("div",{onClick:()=>w(r),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${r===t?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,n.jsx)("span",{className:"truncate flex-1",children:r}),r===e?.current&&(0,n.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:i("git.currentBranch")}),r===t&&(0,n.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},`pinned-${r}`)),v.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-popover sticky top-0",children:i("git.localBranches")}),v.map(r=>(0,n.jsxs)("div",{onClick:()=>w(r),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${r===t?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,n.jsx)("span",{className:"truncate flex-1",children:r}),r===e?.current&&(0,n.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:i("git.currentBranch")}),r===t&&(0,n.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},r))]}),j.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-popover sticky top-0",children:i("git.remoteBranches")}),j.map(e=>(0,n.jsxs)("div",{onClick:()=>w(e),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${e===t?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,n.jsx)("span",{className:"truncate flex-1",children:e}),e===t&&(0,n.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},e))]}),0===g.length&&0===v.length&&0===j.length&&(0,n.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:i("git.noMatchingBranches")})]})]})]})}let tj=96/72;function tw({cwd:e,path:t,refreshKey:o}){let a=(0,s.useRef)(null),[l,i]=(0,s.useState)({kind:"loading"}),[d,c]=(0,s.useState)(null),[u,m]=(0,s.useState)(0),[x,h]=(0,s.useState)(null),[f,p]=(0,s.useState)(0),[g,b]=(0,s.useState)({kind:"auto"}),[v,j]=(0,s.useState)(1),[w,k]=(0,s.useState)(!0);(0,s.useEffect)(()=>{let n=!1;i({kind:"loading"}),c(null),m(0),h(null),j(1);let s=null;return(async()=>{try{let a=await Promise.all([r.e(2084),r.e(9304)]).then(r.bind(r,66898));a.GlobalWorkerOptions.workerSrc="/pdfjs/pdf.worker.min.mjs";let l=`/api/files/read?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}&v=${encodeURIComponent(String(o??""))}`;s=a.getDocument({url:l});let d=await s.promise;if(n)return;let u=await Promise.all(Array.from({length:d.numPages},(e,t)=>d.getPage(t+1).then(e=>{let t=e.getViewport({scale:1});return{w:t.width,h:t.height}})));if(n)return;c(d),m(d.numPages),h(u),i({kind:"ready"})}catch(e){n||i({kind:"error",message:e instanceof Error?e.message:"Failed to load PDF"})}})(),()=>{n=!0;try{s?.destroy()}catch{}}},[e,t,o]),(0,s.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>p(Math.max(0,e.clientWidth-32));t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]);let y=(0,s.useMemo)(()=>x?.length?Math.max(...x.map(e=>e.w)):0,[x]),N=Math.min(y>0&&f>0?f/y:tj,tj),C="auto"===g.kind?N:g.factor*tj,S=Math.round(C/tj*100),L=(0,s.useMemo)(()=>x?x.map(e=>e.h*C+16):[],[x,C]),M=y*C,E=(0,s.useRef)(1);E.current=N/tj;let P=(0,s.useRef)(L);P.current=L;let T=(0,A.Te)({count:u,getScrollElement:()=>a.current,estimateSize:e=>P.current[e]??0,overscan:2});(0,s.useEffect)(()=>{L.length>0&&T.measure()},[L,T]);let $=(0,s.useCallback)(()=>{let e=a.current;if(!e||0===u)return;let t=e.scrollTop,r=T.getVirtualItems().find(e=>e.end>t);j((r?r.index:u-1)+1)},[T,u]),R=(0,s.useCallback)(e=>{b(t=>({kind:"fixed",factor:Math.min(4,Math.max(.25,("auto"===t.kind?E.current:t.factor)*e))}))},[]),B=(0,s.useCallback)(()=>R(1.2),[R]),F=(0,s.useCallback)(()=>R(.8333333333333334),[R]),I=(0,s.useCallback)(()=>b({kind:"auto"}),[]),D=(0,s.useCallback)(()=>k(e=>!e),[]),z=(0,s.useCallback)(e=>{T.scrollToIndex(e,{align:"start"}),j(e+1)},[T]),H=T.getVirtualItems(),W=T.getTotalSize(),_=(0,s.useMemo)(()=>(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border text-muted-foreground text-xs select-none",children:[(0,n.jsx)("button",{onClick:D,className:`px-1.5 py-0.5 rounded hover:bg-hover transition-colors ${w?"text-foreground":""}`,title:w?"Hide thumbnails":"Show thumbnails","aria-label":"Toggle thumbnails",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),(0,n.jsx)("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),(0,n.jsx)("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]})}),(0,n.jsx)("span",{className:"tabular-nums",children:u>0?`${v} / ${u}`:"—"}),(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,n.jsx)("button",{onClick:F,className:"px-1.5 py-0.5 rounded hover:bg-hover transition-colors",title:"Zoom out","aria-label":"Zoom out",children:"−"}),(0,n.jsxs)("button",{onClick:I,className:`px-1.5 py-0.5 rounded hover:bg-hover transition-colors tabular-nums min-w-[3.5rem] ${"auto"===g.kind?"":"text-foreground"}`,title:"Reset to automatic zoom",children:[S,"%"]}),(0,n.jsx)("button",{onClick:B,className:"px-1.5 py-0.5 rounded hover:bg-hover transition-colors",title:"Zoom in","aria-label":"Zoom in",children:"+"})]})]}),[u,v,S,g.kind,B,F,I,w,D]);return"error"===l.kind?(0,n.jsxs)("div",{className:"h-full flex flex-col bg-secondary",children:[_,(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("div",{className:"text-sm text-red-11",children:l.message})})]}):(0,n.jsxs)("div",{className:"h-full flex flex-col bg-secondary",children:[_,(0,n.jsxs)("div",{className:"flex-1 flex min-h-0",children:[w&&d&&x&&(0,n.jsx)(tk,{doc:d,numPages:u,sizes:x,maxPageW:y,currentPage:v,onSelect:z}),(0,n.jsx)("div",{ref:a,onScroll:$,className:"flex-1 overflow-auto px-4 py-4",children:"loading"!==l.kind&&d&&x&&!(M<=0)?(0,n.jsx)("div",{style:{height:W,width:Math.max(M,f),position:"relative"},children:H.map(e=>(0,n.jsx)("div",{"data-index":e.index,className:"absolute left-0 top-0 w-full flex justify-center",style:{transform:`translateY(${e.start}px)`,paddingBottom:16},children:(0,n.jsx)(ty,{doc:d,pageNumber:e.index+1,scale:C,width:x[e.index].w*C,height:x[e.index].h*C})},e.key))}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})})})]})]})}function tk({doc:e,numPages:t,sizes:r,maxPageW:o,currentPage:a,onSelect:l}){let i=(0,s.useRef)(null),d=o>0?100/o:0,c=(0,s.useMemo)(()=>r.map(e=>e.h*d+18+12),[r,d]),u=(0,s.useRef)(c);u.current=c;let m=(0,A.Te)({count:t,getScrollElement:()=>i.current,estimateSize:e=>u.current[e]??0,overscan:3});(0,s.useEffect)(()=>{c.length>0&&m.measure()},[c,m]),(0,s.useEffect)(()=>{t>0&&m.scrollToIndex(a-1,{align:"auto"})},[a]);let x=m.getVirtualItems();return(0,n.jsx)("div",{ref:i,className:"shrink-0 overflow-auto border-r border-border py-2",style:{width:132},children:(0,n.jsx)("div",{style:{height:m.getTotalSize(),width:"100%",position:"relative"},children:x.map(t=>{let s=a===t.index+1;return(0,n.jsxs)("div",{className:"absolute left-0 top-0 w-full flex flex-col items-center",style:{transform:`translateY(${t.start}px)`,paddingBottom:12},children:[(0,n.jsx)("button",{onClick:()=>l(t.index),className:`rounded-sm overflow-hidden transition-shadow ${s?"ring-2 ring-brand":"ring-1 ring-border hover:ring-muted-foreground"}`,title:`Page ${t.index+1}`,"aria-label":`Go to page ${t.index+1}`,children:(0,n.jsx)(ty,{doc:e,pageNumber:t.index+1,scale:d,width:r[t.index].w*d,height:r[t.index].h*d})}),(0,n.jsx)("span",{className:`mt-0.5 text-[11px] tabular-nums leading-none ${s?"text-foreground font-medium":"text-muted-foreground"}`,style:{height:18},children:t.index+1})]},t.key)})})})}function ty({doc:e,pageNumber:t,scale:r,width:o,height:a}){let l=(0,s.useRef)(null);return(0,s.useEffect)(()=>{let n=!1,s=null;return(async()=>{let o=await e.getPage(t);if(n)return;let a=l.current;if(!a)return;let i=Math.min(window.devicePixelRatio||1,2),d=o.getViewport({scale:r*i});a.width=Math.floor(d.width),a.height=Math.floor(d.height),a.style.width=`${a.width/i}px`,a.style.height=`${a.height/i}px`,s=o.render({canvas:a,viewport:d});try{await s.promise}catch{}})(),()=>{n=!0;try{s?.cancel()}catch{}}},[e,t,r]),(0,n.jsx)("div",{className:"bg-white shadow-lv2",style:{width:o,height:a},children:(0,n.jsx)("canvas",{ref:l,className:"block"})})}var tN=r(69809);function tC(e){let t=e.split(".").pop()?.toLowerCase();return t?["ts","tsx","js","jsx","mjs","cjs"].includes(t)?"typescript":["py","pyi"].includes(t)?"python":null:null}let tS=(e,t)=>ep.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`);return await r.json()},catch:t=>new eg.uV({message:`${e} failed`,cause:t})});function tL(e){return e.replace(/^\([^)]+\)\s*/,"")}function tM(e){let t=tL(e),r=t.match(/^(?:function|const|let|var|class|interface|type|enum|async function)\s+([a-zA-Z_$][\w$]*)/);if(r)return r[1];let n=e.match(/\([^)]+\)\s+(?:[\w$]+\.)*([a-zA-Z_$][\w$]*)/);if(n)return n[1];let s=t.match(/([a-zA-Z_$][\w$]*)/);return s?s[1]:t.split(/[(\s:]/)[0]}let tE=(0,s.forwardRef)(function({displayString:e,documentation:t,x:r,y:a,container:l,onMouseEnter:i,onMouseLeave:d,onFindReferences:c,onSearch:u,onExplain:m,explainDisabled:x},h){let{t:f}=(0,o.Bd)(),p=(0,s.useRef)(null);(0,s.useImperativeHandle)(h,()=>p.current,[]);let g=l.getBoundingClientRect(),b=r-g.left,v=a-g.top,j=(0,s.useMemo)(()=>tL(e),[e]),w=(0,s.useMemo)(()=>(function(e){let t,r=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b/g,s=[],o=0,a=0,l=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b|"[^"]*"|'[^']*'|\b\d+\b/g;for(;null!==(t=l.exec(e));){t.index>o&&s.push((0,n.jsx)("span",{className:"text-foreground",children:e.slice(o,t.index)},a++));let l=t[0];/^["']/.test(l)?s.push((0,n.jsx)("span",{className:"text-green-11",children:l},a++)):/^\d+$/.test(l)?s.push((0,n.jsx)("span",{className:"text-orange-11",children:l},a++)):r.test(l)?(r.lastIndex=0,s.push((0,n.jsx)("span",{className:"text-violet-11",children:l},a++))):s.push((0,n.jsx)("span",{className:"text-foreground",children:l},a++)),o=t.index+l.length}return o<e.length&&s.push((0,n.jsx)("span",{className:"text-foreground",children:e.slice(o)},a++)),s})(j),[j]);return(0,s.useEffect)(()=>{if(!p.current)return;let e=p.current,t=l.getBoundingClientRect(),n=e.getBoundingClientRect(),s=r-t.left,o=a-t.top;s+n.width>t.width-8&&(s=t.width-n.width-8),s<8&&(s=8),o+n.height>t.height-8&&(o=o-n.height-24),e.style.left=`${s}px`,e.style.top=`${o}px`},[r,a,l]),(0,n.jsxs)("div",{ref:p,className:"absolute z-[200] max-w-lg bg-card border border-border rounded-lg shadow-lv3 px-3 py-2 pointer-events-none",style:{left:b,top:v},children:[(0,n.jsx)("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all leading-relaxed",children:w}),t&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"border-t border-border my-1"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:t})]}),(c||u||m)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"border-t border-border my-1.5"}),(0,n.jsxs)("div",{className:"flex items-center gap-3 pointer-events-auto",onMouseEnter:i,onMouseLeave:d,children:[c&&(0,n.jsx)("button",{onClick:c,className:"text-[11px] text-brand hover:underline cursor-pointer",children:f("hoverTooltip.findReferences")}),u&&(0,n.jsx)("button",{onClick:()=>u(tM(e)),className:"text-[11px] text-brand hover:underline cursor-pointer",children:f("hoverTooltip.search")}),m&&(0,n.jsx)("button",{onClick:()=>m(tM(e)),disabled:x,title:x?f("comments.aiResponding"):void 0,className:"text-[11px] text-brand hover:underline cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:no-underline",children:f("explain.action")})]})]})]})});function tP({references:e,loading:t,onSelect:r,onClose:a}){let{t:l}=(0,o.Bd)(),i=function(e){let[t,r]=(0,s.useState)(new Map),[n,o]=(0,s.useState)(!1),a=(0,s.useRef)(0);return(0,s.useEffect)(()=>{let e=()=>o(document.documentElement.classList.contains("dark"));e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),(0,s.useEffect)(()=>{if(0===e.length)return void queueMicrotask(()=>r(new Map));let t=++a.current,s=n?"github-dark":"github-light";(async()=>{let n=await (0,eL.kS)();if(t!==a.current)return;let o=new Map;for(let t=0;t<e.length;t++){let r=e[t];if(!r.lineText)continue;let a=(0,eL.sQ)(r.file);if("text"!==a)try{let e=n.codeToTokens(r.lineText,{lang:a,theme:s}),l=(0,eL.b8)(e.tokens[0]||[]);l&&o.set(t,l)}catch{}}t===a.current&&r(o)})()},[e,n]),t}(e),d=[],c=new Map;for(let t=0;t<e.length;t++){let r=e[t],n=c.get(r.file);void 0===n&&(n=d.length,c.set(r.file,n),d.push({file:r.file,items:[]})),d[n].items.push({ref:r,idx:t})}return(0,n.jsxs)("div",{className:"border-t border-border bg-card flex flex-col",style:{height:"300px"},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,n.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[l("references.title")," ",!t&&`(${e.length})`]}),(0,n.jsx)("button",{onClick:a,className:"p-0.5 rounded hover:bg-hover text-muted-foreground",children:(0,n.jsx)(ea.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:t?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:l("references.searching")}):0===e.length?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:l("references.notFound")}):d.map(({file:e,items:t})=>(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card sticky top-0",children:e}),t.map(({ref:e,idx:t})=>(0,n.jsxs)("button",{onClick:()=>r(e),className:"w-full text-left px-3 py-0.5 hover:bg-hover flex items-baseline gap-2 group",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:e.line}),i.has(t)?(0,n.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:i.get(t)}}):(0,n.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:e.lineText||""})]},`${e.line}-${e.column}-${t}`))]},e))})]})}function tT({results:e,loading:t,totalMatches:r,onSelect:a,onClose:l,scope:i,onScopeChange:d,selectedPath:c}){let{t:u}=(0,o.Bd)(),m=function(e){let[t,r]=(0,s.useState)(new Map),[n,o]=(0,s.useState)(!1),a=(0,s.useRef)(0);return(0,s.useEffect)(()=>{let e=()=>o(document.documentElement.classList.contains("dark"));e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),(0,s.useEffect)(()=>{if(0===e.length)return void queueMicrotask(()=>r(new Map));let t=++a.current,s=n?"github-dark":"github-light";(async()=>{let n=await (0,eL.kS)(),o=new Map;for(let t of e){let e=(0,eL.sQ)(t.path);if("text"!==e)for(let r of t.matches){if(!r.content)continue;let a=`${t.path}:${r.lineNumber}`;try{let t=n.codeToTokens(r.content,{lang:e,theme:s}),l=(0,eL.b8)(t.tokens[0]||[]);l&&o.set(a,l)}catch{}}}t===a.current&&r(o)})()},[e,n]),t}(e),x="selected"===i?e.filter(e=>e.path===c):e,h=x.reduce((e,t)=>e+t.matches.length,0);return(0,n.jsxs)("div",{className:"border-t border-border bg-card flex flex-col",style:{height:"300px"},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,n.jsxs)("span",{className:"text-xs font-medium text-foreground truncate",children:[u("searchResults.title")," ",!t&&u("searchResults.nMatches",{count:"selected"===i?h:r})]}),(0,n.jsxs)("div",{className:"flex items-center rounded border border-border overflow-hidden text-xs flex-shrink-0",children:[(0,n.jsx)("button",{onClick:()=>d("selected"),className:`px-2 py-0.5 ${"selected"===i?"bg-brand/15 text-brand":"text-muted-foreground hover:bg-hover"}`,children:u("searchResults.scopeSelected")}),(0,n.jsx)("button",{onClick:()=>d("all"),className:`px-2 py-0.5 border-l border-border ${"all"===i?"bg-brand/15 text-brand":"text-muted-foreground hover:bg-hover"}`,children:u("searchResults.scopeAll")})]})]}),(0,n.jsx)("button",{onClick:l,className:"p-0.5 rounded hover:bg-hover text-muted-foreground flex-shrink-0",children:(0,n.jsx)(ea.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:t?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:u("searchResults.searching")}):0===x.length?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:u("searchResults.noResults")}):x.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card sticky top-0",children:e.path}),e.matches.map((t,r)=>{let s=`${e.path}:${t.lineNumber}`,o=m.get(s);return(0,n.jsxs)("button",{onClick:()=>a(e.path,t.lineNumber),className:"w-full text-left px-3 py-0.5 hover:bg-hover flex items-baseline gap-2 group",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:t.lineNumber}),o?(0,n.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:o}}):(0,n.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:t.content||""})]},`${t.lineNumber}-${r}`)})]},e.path))})]})}var t$=r(63728);let tR=s.memo(function({onClose:e,cwd:t,initialTab:r="tree",tabSwitchTrigger:a,initialSearchQuery:l,searchQueryTrigger:i,fileOpenRequest:d}){var c;let m,x,h,f,k,S,L,E,I,A,H,W,{t:_}=(0,o.Bd)(),et=(0,F.r)(),eo=(0,s.useCallback)(e=>{et?.sendMessage(_("explain.fileMessage",{path:e}))},[et,_]),ea=(0,s.useCallback)(e=>{et?.sendMessage(_("explain.stagedFileMessage",{path:e}))},[et,_]),el=(0,s.useCallback)(e=>{et?.sendMessage(_("explain.unstagedFileMessage",{path:e}))},[et,_]),ei=(0,Q.P)(),ed=(0,Z.U)(),{activeView:ec,onViewChange:eu}=(0,t$.R8)(),[em,ex]=(0,s.useState)(r),[eh,ef]=(0,s.useState)("code"),eb=(0,s.useRef)(null),ev=(0,s.useRef)(!1),[ej,ew]=(0,s.useState)(null),[ek,ey]=(0,s.useState)(null),[eN,eC]=(0,s.useState)(!1),eS=(0,s.useRef)(1),eL=(0,s.useRef)(null),[eM,eE]=(0,s.useState)(null),eP=(0,s.useRef)(null),[eT,e$]=(0,s.useState)({isDirty:!1,isSaving:!1}),[eR,eB]=(0,s.useState)(!1),[eF,eI]=(0,s.useState)(null),[eD,eA]=(0,s.useState)("compact"),[ez,eH]=(0,s.useState)("unified"),[eW,e_]=(0,s.useState)("full"),[eO,eq]=(0,s.useState)("unified"),[eV,eU]=(0,s.useState)(320),eK=(0,s.useRef)(null),eG=(0,s.useCallback)(e=>{"mouse"===e.pointerType&&0===e.button&&(e.preventDefault(),eK.current={startX:e.clientX,startWidth:eV},e.currentTarget.setPointerCapture(e.pointerId))},[eV]),eJ=(0,s.useCallback)(e=>{let t=eK.current;t&&eU(Math.min(480,Math.max(320,t.startWidth+(e.clientX-t.startX))))},[]),eQ=(0,s.useCallback)(e=>{eK.current&&(eK.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),eZ=(0,s.useRef)(null),eX=(0,B.o)(eZ),eY=(0,s.useRef)(null),e0=(0,B.o)(eY),e1=function(e){let[t,r]=(0,s.useState)(!1);return{goToDefinition:(0,s.useCallback)(async(t,n,s)=>{r(!0);let o=await u.t4.runPromiseExit(tS("/api/lsp/definition",{cwd:e,filePath:t,line:n,column:s}));return(r(!1),"Success"===o._tag)?o.value.definitions??[]:(console.error("[useLSP] definition error:",o.cause),[])},[e]),loading:t}}(t),e2=function(e){let[t,r]=(0,s.useState)(null),n=(0,s.useRef)(null),o=(0,s.useRef)(null),a=(0,s.useRef)(0),l=(0,s.useRef)(!1),i=(0,s.useRef)(null),d=(0,s.useRef)({x:0,y:0}),c=(0,s.useCallback)(e=>{i.current=e},[]);(0,s.useEffect)(()=>{let e=e=>{d.current.x=e.clientX,d.current.y=e.clientY};return document.addEventListener("mousemove",e),()=>document.removeEventListener("mousemove",e)},[]);let m=(0,s.useRef)(!1),x=(0,s.useRef)(null),h=(0,s.useCallback)(()=>{let e=i.current;e&&m.current&&(e.style.pointerEvents="none"),m.current=!1,x.current&&(i.current?.removeEventListener("mouseleave",x.current),x.current=null)},[]),f=(0,s.useCallback)(()=>{let e=i.current;if(!e||m.current)return;m.current=!0,l.current=!0,e.style.pointerEvents="auto";let t=()=>{l.current=!1,h(),a.current++,r(null)};x.current=t,e.addEventListener("mouseleave",t)},[h]),p=(0,s.useCallback)((t,s,l,i)=>{n.current&&clearTimeout(n.current),o.current&&clearTimeout(o.current);let d=++a.current;n.current=setTimeout(async()=>{let n=await u.t4.runPromiseExit(tS("/api/lsp/hover",{cwd:e,filePath:t,line:s,column:l}));if(d!==a.current||"Success"!==n._tag)return;let o=n.value.hover;o&&o.displayString&&r({...o,x:i.x,y:i.y,filePath:t,line:s,column:l})},300)},[e]),g=(0,s.useCallback)(()=>{n.current&&clearTimeout(n.current),a.current++,o.current=setTimeout(function(){if(l.current)return;let e=i.current;if(e){let t=e.getBoundingClientRect(),{x:r,y:n}=d.current;if(r>=t.left&&r<=t.right&&n>=t.top&&n<=t.bottom)return void f()}r(null)},150)},[f]),b=(0,s.useCallback)(()=>{l.current=!0,o.current&&clearTimeout(o.current)},[]),v=(0,s.useCallback)(()=>{l.current=!1,a.current++,r(null)},[]),j=(0,s.useCallback)(()=>{n.current&&clearTimeout(n.current),o.current&&clearTimeout(o.current),l.current=!1,h(),a.current++,r(null)},[h]);return(0,s.useEffect)(()=>{t||h()},[t,h]),{hoverInfo:t,onTokenMouseEnter:p,onTokenMouseLeave:g,onCardMouseEnter:b,onCardMouseLeave:v,clearHover:j,setTooltipEl:c}}(t),e4=function(e){let[t,r]=(0,s.useState)([]),[n,o]=(0,s.useState)(!1),[a,l]=(0,s.useState)(!1);return{references:t,loading:n,visible:a,findReferences:(0,s.useCallback)(async(t,n,s)=>{o(!0),l(!0);let a=await u.t4.runPromiseExit(tS("/api/lsp/references",{cwd:e,filePath:t,line:n,column:s}));"Success"===a._tag?r(a.value.references??[]):(console.error("[useLSP] references error:",a.cause),r([])),o(!1)},[e]),closeReferences:(0,s.useCallback)(()=>{l(!1),r([])},[])}}(t),e3=(m=(0,s.useRef)([]),x=(0,s.useRef)([]),h=(0,s.useCallback)(e=>{m.current.push(e),m.current.length>50&&(m.current=m.current.slice(-50)),x.current=[]},[]),f=(0,s.useCallback)(e=>{if(0===m.current.length)return null;let t=m.current.pop();return x.current.push(e),x.current.length>50&&(x.current=x.current.slice(-50)),t},[]),k=(0,s.useCallback)(e=>{if(0===x.current.length)return null;let t=x.current.pop();return m.current.push(e),m.current.length>50&&(m.current=m.current.slice(-50)),t},[]),{push:h,goBack:f,goForward:k,canGoBack:(0,s.useCallback)(()=>m.current.length>0,[]),canGoForward:(0,s.useCallback)(()=>x.current.length>0,[])}),e6=(0,es.F)(),e8=function({cwd:e}){let[t,r]=(0,s.useState)([]),[n,o]=(0,s.useState)(null),[a,l]=(0,s.useState)(new Set),[i,d]=(0,s.useState)([]),[c,m]=(0,s.useState)(null),[x,h]=(0,s.useState)(null),[f,p]=(0,s.useState)(new Set),[g,j]=(0,s.useState)(null),[w,k]=(0,s.useState)(""),[y,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(null),[L,M]=(0,s.useState)(!0),[E,P]=(0,s.useState)(!1),[T,R]=(0,s.useState)(null),B=(0,s.useRef)(null),[F,I]=(0,s.useState)(!1),[D,A]=(0,s.useState)(null),[z,H]=(0,s.useState)("center"),[W,_]=(0,s.useState)(null),[O,q]=(0,s.useState)(null),[V,U]=(0,s.useState)(!1),[K,G]=(0,s.useState)([]),[J,Q]=(0,s.useState)(!1),[Z,X]=(0,s.useState)(null),[Y,ee]=(0,s.useState)(null),[et,er]=(0,s.useState)(!0),[en,es]=(0,s.useState)(!1),[eo,ea]=(0,s.useState)(!1),el=(0,s.useMemo)(()=>i.map(e=>e.path).filter(Boolean),[i]),ei=(0,s.useMemo)(()=>(0,$.v3)(el),[el]),ed=(0,s.useMemo)(()=>new Set((0,$.tW)(ei)),[ei]),ec=(0,s.useMemo)(()=>w?n?(0,$.KH)(n,w,y):(0,$.q3)(t,w,y):null,[t,n,w,y]);(0,s.useEffect)(()=>{if(!ec||0===ec.size)return void j(null);let e=new Set;if(n){let t=new Set(n);for(let r of ec)t.has(r)||e.add(r)}else{let r=t=>{for(let n of t)n.isDirectory&&n.children&&ec.has(n.path)&&(e.add(n.path),r(n.children))};r(t)}j(e)},[ec,t,n]);let eu=g??f,em=(0,s.useRef)(null),ex=(0,s.useCallback)(t=>{em.current&&clearTimeout(em.current),em.current=setTimeout(()=>{u.t4.runFork((0,b.Ft)(e,Array.from(t)).pipe(ep.tapError(e=>ep.sync(()=>console.error("Error saving expanded paths:",e))),ep.orElse(()=>ep.void)))},500)},[e]),eh=(0,s.useCallback)(async()=>{M(!0),R(null),await u.t4.runPromise((0,b.mP)(e).pipe(ep.match({onSuccess:e=>{e.error?R(e.error):(r(e.files??[]),e.expandedPaths&&Array.isArray(e.expandedPaths)&&p(new Set(e.expandedPaths)))},onFailure:e=>{console.error("Error loading files:",e),R("Failed to load files")}}))),M(!1)},[e]),ef=(0,s.useCallback)(()=>{u.t4.runPromise((0,b.DZ)(e).pipe(ep.match({onSuccess:e=>{e.paths&&o(e.paths)},onFailure:e=>{console.error("Error loading file index:",e)}})))},[e]),eg=(0,s.useCallback)(async t=>{l(e=>new Set([...e,t])),await u.t4.runPromise((0,b.gZ)(e,t).pipe(ep.match({onSuccess:e=>{e.children&&r(r=>{if(!t){let t=new Map(r.map(e=>[e.path,e]));return e.children.map(e=>{let r=t.get(e.path);return r?.children&&e.isDirectory?{...e,children:r.children}:e})}let n=structuredClone(r),s=(0,$.MB)(n,t);return s&&(s.children=e.children),n})},onFailure:e=>{console.error("Error loading directory:",e)}}))),l(e=>{let r=new Set(e);return r.delete(t),r})},[e]),eb=(0,s.useRef)(a);eb.current=a,(0,s.useEffect)(()=>{for(let e of g??f){let r=(0,$.MB)(t,e);r&&r.isDirectory&&!r.children&&!eb.current.has(e)&&eg(e)}},[t,f,g,eg]);let ev=(0,s.useCallback)(async()=>{await u.t4.runPromise((0,b.r9)(e).pipe(ep.match({onSuccess:e=>d(e.files??[]),onFailure:e=>console.error("Error loading recent files:",e)})))},[e]),ej=(0,s.useCallback)(async t=>{d(e=>{let r=e.filter(e=>e.path!==t);return[{path:t},...r].slice(0,15)}),await u.t4.runPromise((0,b.YW)(e,t).pipe(ep.tapError(e=>ep.sync(()=>console.error("Error adding to recent files:",e))),ep.orElse(()=>ep.void)))},[e]),ew=(0,s.useCallback)((t,r,n,s)=>{d(e=>e.map(e=>e.path===t?{...e,scrollLine:r,cursorLine:n,cursorCol:s}:e)),u.t4.runFork((0,b.YW)(e,t,{scrollLine:r,cursorLine:n,cursorCol:s}).pipe(ep.orElse(()=>ep.void)))},[e]),ek=(0,s.useCallback)(e=>i.find(t=>t.path===e),[i]),ey=(0,s.useCallback)(async t=>{let r=t||c;r&&(Q(!0),X(null),await u.t4.runPromise((0,b.eE)(e,r).pipe(ep.match({onSuccess:e=>{e.error?X(e.error):G(e.blame??[])},onFailure:e=>{console.error("Error loading blame:",e),X("Failed to load blame info")}}))),Q(!1))},[e,c]),eN=(0,s.useCallback)(async t=>{P(!0),h(null),U(!1),G([]),X(null),ee(null);let r=ep.gen(function*(){let r=yield*(0,b.r6)(e,t);if(!r.ok)return{type:"error",message:r.data?.error||"Failed to stat file"};let n=r.data??{};if(!n.exists)return{type:"error",message:"File not found"};if("dir"===n.kind)return{type:"error",message:"Path is a directory"};switch(n.category){case"image":return{type:"image",size:n.size,mtime:n.mtimeMs,...n.isSymlink?{isSymlink:!0,symlinkTarget:n.symlinkTarget}:{}};case"pdf":return{type:"pdf",size:n.size,mtime:n.mtimeMs,...n.isSymlink?{isSymlink:!0,symlinkTarget:n.symlinkTarget}:{}};case"binary":return{type:"binary",message:"Cannot preview binary file",size:n.size,mtime:n.mtimeMs};case"too-large":return{type:"error",message:"File too large to preview",size:n.size,mtime:n.mtimeMs};default:{let r=yield*(0,v.K)(e,t);if(409===r.status)return{type:"binary",message:r.data?.error||"Cannot preview binary file",size:n.size,mtime:n.mtimeMs};if(!r.ok)return{type:"error",message:r.data?.error||"Failed to load file"};let s=r.data??{};return{type:"text",content:s.content,size:s.size,mtime:s.mtimeMs,...s.isSymlink?{isSymlink:!0,symlinkTarget:s.symlinkTarget}:{}}}}});await u.t4.runPromise(r.pipe(ep.match({onSuccess:e=>h(e),onFailure:e=>{console.error("Error loading file content:",e),h({type:"error",message:"Failed to load file"})}}))),ej(t),ey(t),P(!1)},[e,ej,ey]),eC=(0,s.useCallback)(()=>{V?U(!1):(U(!0),0===K.length&&ey())},[V,K.length,ey]),eS=(0,s.useCallback)((e,t)=>{if(!e)return;if(m(e),A(t??null),null==t){let t=i.find(t=>t.path===e);t?.scrollLine?(A(t.scrollLine),H("start"),_(t.cursorLine??null),q(t.cursorCol??null)):(H("center"),_(null),q(null))}else H("center"),_(null),q(null);eN(e);let r=e.split("/");if(r.length>1){let e=[];for(let t=1;t<r.length;t++)e.push(r.slice(0,t).join("/"));p(t=>{let r=new Set(t),n=!1;for(let t of e)r.has(t)||(r.add(t),n=!0);return n&&ex(r),n?r:t})}},[eN,ex,i]),eL=(0,s.useCallback)(e=>{if(g)j(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r});else{let r=!f.has(e);if(p(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),ex(r),r}),r){let r=(0,$.MB)(t,e);r&&r.isDirectory&&!r.children&&eg(e)}}},[g,ex,f,t,eg]);return{files:t,setFiles:r,fileIndex:n,setFileIndex:o,loadingDirs:a,expandedPaths:f,setExpandedPaths:p,searchTreeExpandedPaths:g,setSearchTreeExpandedPaths:j,effectiveExpandedPaths:eu,searchQuery:w,setSearchQuery:k,searchExactMatch:y,setSearchDirExact:N,matchedPaths:ec,creatingItem:C,setCreatingItem:S,isLoadingFiles:L,fileError:T,searchInputRef:B,shouldScrollToSelected:F,setShouldScrollToSelected:I,targetLineNumber:D,setTargetLineNumber:A,targetScrollAlign:z,setTargetScrollAlign:H,initialCursorLine:W,initialCursorCol:O,setInitialCursorLine:_,setInitialCursorCol:q,selectedPath:c,setSelectedPath:m,fileContent:x,setFileContent:h,isLoadingContent:E,recentFiles:i,recentFilePaths:el,setRecentFiles:d,recentFilesTree:ei,recentTreeDirPaths:ed,showBlame:V,setShowBlame:U,blameLines:K,isLoadingBlame:J,blameError:Z,blameSelectedCommit:Y,setBlameSelectedCommit:ee,previewMarkdown:et,setPreviewMarkdown:er,previewHtml:en,setPreviewHtml:es,showEditor:eo,setShowEditor:ea,saveExpandedPaths:ex,loadFiles:eh,loadFileIndex:ef,loadDirectory:eg,loadRecentFiles:ev,addToRecentFiles:ej,updateRecentFilePosition:ew,getRecentFilePosition:ek,loadFileContent:eN,loadBlame:ey,handleToggleBlame:eC,handleSelectFile:eS,handleToggle:eL}}({cwd:t});c=e8.selectedPath,S=(0,s.useRef)(null),(0,s.useEffect)(()=>{c&&c!==S.current&&tC(c)&&(S.current=c,u.t4.runFork(tS("/api/lsp/warmup",{cwd:t,filePath:c}).pipe(ep.asVoid).pipe(ep.orElse(()=>ep.void))))},[t,c]);let e9=(0,s.useMemo)(()=>{let e=e8.fileContent,t=e8.selectedPath;return e&&"text"===e.type&&"string"==typeof e.content&&t&&(0,R.Hz)(t)?(0,R.xb)(e.content,R.cG):null},[e8.fileContent,e8.selectedPath]),[e7,te]=(0,s.useState)({version:0,collapsed:!1});(0,s.useEffect)(()=>{te(e=>e.collapsed?{version:e.version+1,collapsed:!1}:e)},[e8.selectedPath]);let tt=function({cwd:e,onSearchComplete:t}){let[r,n]=(0,s.useState)(""),[o,a]=(0,s.useState)([]),[l,i]=(0,s.useState)(!1),[d,c]=(0,s.useState)(null),[m,x]=(0,s.useState)(new Set),[h,f]=(0,s.useState)({caseSensitive:!1,wholeWord:!1,regex:!1,fileType:""}),[p,g]=(0,s.useState)(null),b=(0,s.useRef)(null),v=(0,s.useCallback)(async r=>{let n=r.trim();if(!n){a([]),g(null);return}if(n.length<2)return void c(tN.A.t("fileBrowser.searchMinChars"));i(!0),c(null);let s=new URLSearchParams({cwd:e,q:r,caseSensitive:String(h.caseSensitive),wholeWord:String(h.wholeWord),regex:String(h.regex),fileType:h.fileType}),o=ep.tryPromise({try:async()=>{let e=await fetch(`/api/files/search?${s}`),t=await e.json();if(t.error)throw Error(t.error);return t},catch:e=>new eg.uV({message:"content search failed",cause:e})});await u.t4.runPromise(o.pipe(ep.match({onSuccess:e=>{a(e.results),g({totalFiles:e.totalFiles,totalMatches:e.totalMatches,truncated:e.truncated}),x(new Set(e.results.map(e=>e.path))),e.results.length>0&&t?.()},onFailure:e=>{c(e.cause instanceof Error?e.cause.message:"Search failed"),a([])}}))),i(!1)},[e,h,t]);return{contentSearchQuery:r,setContentSearchQuery:n,contentSearchResults:o,isSearching:l,searchError:d,searchExpandedPaths:m,searchOptions:h,setSearchOptions:f,searchStats:p,contentSearchInputRef:b,performContentSearch:v,handleSearchToggle:(0,s.useCallback)(e=>{x(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[])}}({cwd:t,onSearchComplete:()=>eB(!0)}),tr=function({cwd:e,addToRecentFiles:t}){let[r,n]=(0,s.useState)(null),[o,a]=(0,s.useState)(!1),[l,i]=(0,s.useState)(null),[d,c]=(0,s.useState)(null),[m,x]=(0,s.useState)(null),[h,f]=(0,s.useState)(!1),[p,g]=(0,s.useState)(new Set),[b,v]=(0,s.useState)(new Set),[w,k]=(0,s.useState)([]),[y,N]=(0,s.useState)([]),S=(0,s.useMemo)(()=>{let e=new Set((0,C.Sz)(w));for(let t of p)e.delete(t);return e},[w,p]),L=(0,s.useMemo)(()=>{let e=new Set((0,C.Sz)(y));for(let t of b)e.delete(t);return e},[y,b]),[M,E]=(0,s.useState)(!1),[T,$]=(0,s.useState)(0),R=(0,s.useCallback)(async()=>{a(!0),i(null),await u.t4.runPromise((0,j.lv)(e).pipe(ep.match({onSuccess:e=>{n(e);let t=(0,C.Do)(e.staged),r=(0,C.Do)(e.unstaged);k(t),N(r)},onFailure:e=>{i(e.cause instanceof Error?e.cause.message:"Unknown error")}}))),a(!1)},[e]),B=(0,s.useCallback)(e=>{g(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),F=(0,s.useCallback)(e=>{v(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),I=(0,s.useCallback)((e,r)=>{c({file:e,type:r}),t(e.path)},[t]),D=(0,s.useCallback)(async(e,t,r,n)=>{let s=await u.t4.runPromiseExit(e);"Success"===s._tag?(await R(),(0,P.oR)(t,"success")):(console.error(r,s.cause),(0,P.oR)(n,"error"))},[R]),A=(0,s.useCallback)(t=>D((0,j.Iz)(e,[t]),tN.A.t("toast.staged"),"Error staging file:",tN.A.t("toast.stageFailed")),[e,D]),z=(0,s.useCallback)(t=>D((0,j.X0)(e,[t]),tN.A.t("toast.unstaged"),"Error unstaging file:",tN.A.t("toast.unstageFailed")),[e,D]),H=(0,s.useCallback)(async t=>{0!==t.length&&await D((0,j.Iz)(e,t),tN.A.t("toast.stagedNFiles",{count:t.length}),"Error staging files:",tN.A.t("toast.stageFailed"))},[e,D]),W=(0,s.useCallback)(async t=>{0!==t.length&&await D((0,j.X0)(e,t),tN.A.t("toast.unstagedNFiles",{count:t.length}),"Error unstaging files:",tN.A.t("toast.unstageFailed"))},[e,D]),_=(0,s.useCallback)(async t=>{if(0===t.length)return;let r=t.filter(e=>"untracked"===e.status).map(e=>e.path),n=t.filter(e=>"untracked"!==e.status).map(e=>e.path),s=ep.gen(function*(){r.length>0&&(yield*(0,j.Ub)(e,r,!0)),n.length>0&&(yield*(0,j.Ub)(e,n,!1))});await D(s,tN.A.t("toast.discardedNFiles",{count:t.length}),"Error discarding files:",tN.A.t("toast.discardFailed"))},[e,D]),O=(0,s.useCallback)(async()=>{r?.unstaged.length&&await D((0,j.Iz)(e,r.unstaged.map(e=>e.path)),tN.A.t("toast.stagedNFiles",{count:r.unstaged.length}),"Error staging all files:",tN.A.t("toast.stageFailed"))},[e,r,D]),q=(0,s.useCallback)(async()=>{r?.staged.length&&await D((0,j.X0)(e,r.staged.map(e=>e.path)),tN.A.t("toast.unstagedNFiles",{count:r.staged.length}),"Error unstaging all files:",tN.A.t("toast.unstageFailed"))},[e,r,D]),V=(0,s.useCallback)(async t=>{let r="untracked"===t.status;await D((0,j.Ub)(e,[t.path],r),r?tN.A.t("toast.deletedFile"):tN.A.t("toast.discardedChanges"),"Error discarding file:",tN.A.t("toast.discardFailed"))},[e,D]),U=(0,s.useCallback)(async()=>{if(!r?.unstaged.length||!await (0,P.lJ)(tN.A.t("git.discardAllConfirm",{count:r.unstaged.length}),{danger:!0}))return;let t=r.unstaged.filter(e=>"untracked"===e.status).map(e=>e.path),n=r.unstaged.filter(e=>"untracked"!==e.status).map(e=>e.path),s=r.unstaged.length,o=ep.gen(function*(){n.length>0&&(yield*(0,j.Ub)(e,n,!1)),t.length>0&&(yield*(0,j.Ub)(e,t,!0))});await D(o,tN.A.t("toast.discardedNFiles",{count:s}),"Error discarding all:",tN.A.t("toast.discardFailed"))},[e,r,D]);return(0,s.useEffect)(()=>{d?(f(!0),u.t4.runPromiseExit((0,j.w2)(e,d.file.path,d.type)).then(e=>{"Success"===e._tag?x(e.value):console.error("Error fetching diff:",e.cause),f(!1)})):x(null)},[d,e,T]),{status:r,setStatus:n,statusLoading:o,statusError:l,statusSelectedFile:d,statusDiff:m,statusDiffLoading:h,stagedExpandedPaths:S,unstagedExpandedPaths:L,stagedTree:w,setStagedTree:k,unstagedTree:y,setUnstagedTree:N,showStatusDiffPreview:M,setShowStatusDiffPreview:E,fetchStatus:R,handleStagedToggle:B,handleUnstagedToggle:F,handleStatusFileSelect:I,handleStage:A,handleUnstage:z,handleStageFiles:H,handleUnstageFiles:W,handleDiscardFiles:_,handleStageAll:O,handleUnstageAll:q,handleDiscardFile:V,handleDiscardAll:U,refreshDiff:(0,s.useCallback)(()=>$(e=>e+1),[])}}({cwd:t,addToRecentFiles:e8.addToRecentFiles}),tn=(0,s.useMemo)(()=>{let e=new Set;if(tr.status){for(let t of tr.status.staged)e.add(t.path);for(let t of tr.status.unstaged)e.add(t.path)}return e},[tr.status]),ts=(0,s.useMemo)(()=>{let e=new Map;if(tr.status){for(let t of tr.status.staged)e.set(t.path,"staged");for(let t of tr.status.unstaged)e.set(t.path,"unstaged")}return e},[tr.status]),to=function({cwd:e,addToRecentFiles:t}){let[r,n]=(0,s.useState)(null),[o,a]=(0,s.useState)(""),[l,i]=(0,s.useState)([]),[d,c]=(0,s.useState)(null),[m,x]=(0,s.useState)([]),[h,f]=(0,s.useState)([]),[p,g]=(0,s.useState)(new Set),[b,v]=(0,s.useState)(null),[w,k]=(0,s.useState)(null),[y,N]=(0,s.useState)(!1),[S,L]=(0,s.useState)(!1),[M,E]=(0,s.useState)(!1),[P,T]=(0,s.useState)(!0),[R,B]=(0,s.useState)(!1),[F,I]=(0,s.useState)(!1),[D,A]=(0,s.useState)(null),z=(0,s.useRef)(null),[H,W]=(0,s.useState)(null),[_,O]=(0,s.useState)(!1),[q,V]=(0,s.useState)(""),[U,K]=(0,s.useState)(""),[G,J]=(0,s.useState)([]),[Q,Z]=(0,s.useState)([]),[X,Y]=(0,s.useState)(new Set),[ee,et]=(0,s.useState)(null),[er,en]=(0,s.useState)(null),[es,eo]=(0,s.useState)(!1),[ea,el]=(0,s.useState)(!1),ei=(0,s.useCallback)(()=>{N(!0),A(null),u.t4.runPromise((0,j.r4)(e).pipe(ep.match({onSuccess:e=>{e.local&&e.current?(n(e),a(e.current),e.upstream&&V(e.upstream)):(A(tN.A.t("git.cannotGetBranches")),n(null))},onFailure:e=>{console.error(e),"NotFoundError"===e._tag?A(tN.A.t("git.notGitRepo")):A(tN.A.t("git.getBranchesFailed")),n(null)}}))).finally(()=>N(!1))},[e]),ed=(0,s.useCallback)(t=>{L(!0),c(null),x([]),f([]),v(null),k(null),T(!0),u.t4.runPromise((0,j.Bj)(e,t,$.B_).pipe(ep.match({onSuccess:e=>{let t=e.commits||[];i(t),T(t.length>=$.B_)},onFailure:e=>{console.error(e)}}))).finally(()=>L(!1))},[e]),ec=(0,s.useCallback)(()=>{if(M||!P||!o)return;E(!0);let t=l.length;u.t4.runPromise((0,j.Bj)(e,o,$.B_,t).pipe(ep.match({onSuccess:e=>{let t=e.commits||[];t.length>0&&i(e=>[...e,...t]),T(t.length>=$.B_)},onFailure:e=>{console.error(e)}}))).finally(()=>E(!1))},[e,o,l.length,M,P]),eu=(0,s.useCallback)(e=>{let{scrollTop:t,scrollHeight:r,clientHeight:n}=e.target;r-t-n<100&&ec()},[ec]),em=(0,s.useCallback)(t=>{c(t),v(null),k(null),B(!0),u.t4.runPromise((0,j.Zi)(e,t.hash).pipe(ep.match({onSuccess:e=>{let t=e.files||[];x(t);let r=(0,C.Do)(t);f(r),g(new Set((0,C.Sz)(r)))},onFailure:e=>{console.error(e)}}))).finally(()=>B(!1))},[e]),ex=(0,s.useCallback)(r=>{d&&(v(r),t(r.path),I(!0),u.t4.runPromise((0,j.Zi)(e,d.hash,r.path).pipe(ep.match({onSuccess:e=>k(e),onFailure:e=>{console.error(e)}}))).finally(()=>I(!1)))},[e,d,t]),eh=(0,s.useCallback)(e=>{g(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),ef=(0,s.useCallback)(t=>{eo(!0),et(null),en(null),u.t4.runPromise((0,j.yy)(e,t).pipe(ep.match({onSuccess:e=>{let t=e.files||[];J(t);let r=(0,C.Do)(t);Z(r),Y(new Set((0,C.Sz)(r)))},onFailure:e=>{console.error(e)}}))).finally(()=>eo(!1))},[e]),eg=(0,s.useCallback)(r=>{et(r),t(r.path),el(!0),u.t4.runPromise((0,j.yy)(e,U,r.path).pipe(ep.match({onSuccess:e=>en(e),onFailure:e=>{console.error(e)}}))).finally(()=>el(!1))},[e,U,t]),eb=(0,s.useCallback)(e=>{Y(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),ev=(0,s.useCallback)(e=>{if(O(e),e){let e="origin/main";K(e),ef(e)}else J([]),Z([]),et(null),en(null),K("")},[q,ef]);return{branches:r,selectedBranch:o,setSelectedBranch:a,commits:l,setCommits:i,selectedCommit:d,setSelectedCommit:c,historyFiles:m,historyFileTree:h,historyExpandedPaths:p,historySelectedFile:b,historyFileDiff:w,isLoadingBranches:y,isLoadingCommits:S,isLoadingMore:M,hasMoreCommits:P,setHasMoreCommits:T,isLoadingHistoryFiles:R,isLoadingHistoryDiff:F,historyError:D,commitListRef:z,tooltipPos:H,loadBranches:ei,loadCommits:ed,loadMoreCommits:ec,handleCommitListScroll:eu,handleSelectCommit:em,handleSelectHistoryFile:ex,handleHistoryToggle:eh,handleCommitInfoMouseMove:(0,s.useCallback)(e=>{W({x:e.clientX,y:e.clientY})},[]),handleCommitInfoMouseLeave:(0,s.useCallback)(()=>{W(null)},[]),compareMode:_,toggleCompareMode:ev,compareBaseBranch:U,setCompareBaseBranch:K,upstreamBranch:q,compareFiles:G,compareFileTree:Q,compareExpandedPaths:X,compareSelectedFile:ee,compareFileDiff:er,isLoadingCompareFiles:es,isLoadingCompareDiff:ea,handleSelectCompareFile:eg,handleCompareToggle:eb,loadCompareFiles:ef}}({cwd:t,addToRecentFiles:e8.addToRecentFiles}),ta=(0,s.useCallback)(e=>{et?.sendMessage(_("explain.compareFileMessage",{base:to.compareBaseBranch,path:e}))},[et,_,to.compareBaseBranch]),tl=(0,s.useRef)(!1),ti=(0,s.useCallback)(e=>{e8.setFileContent(t=>t?.type==="text"?{...t,content:e}:t),e8.showEditor||(tl.current=!0,e8.setShowEditor(!0))},[e8]);(0,s.useEffect)(()=>{e8.showEditor&&tl.current&&(eP.current?.markDirty(),tl.current=!1)},[e8.showEditor]);let td=(0,s.useCallback)(e=>{e8.setShowEditor(!0)},[e8]),tc=(0,s.useCallback)(async()=>{if(!e8.fileContent||"text"!==e8.fileContent.type||!e8.fileContent.content)return;let e=await u.t4.runPromiseExit((0,b.OJ)({cwd:t,path:e8.selectedPath,content:e8.fileContent.content}));try{if("Failure"===e._tag||!e.value.ok)throw Error("Failed to save file");let t=e.value.data?.mtime;t&&e8.setFileContent(e=>e?.type==="text"?{...e,mtime:t}:e),(0,P.oR)(_("toast.savedSuccess"),"success")}catch{(0,P.oR)(_("toast.saveFailed"),"error")}},[t,e8]),tu=(0,s.useCallback)(()=>{if(!e8.selectedPath)return;let e=eS.current,t=eL.current;e>0&&e8.updateRecentFilePosition(e8.selectedPath,e,t?t.cursorLine+1:e,t?t.cursorCol+1:1)},[e8]),tm=(0,s.useCallback)(async(e,t)=>{let r=e!==e8.selectedPath;if(r&&e8.showEditor){if(eT.isDirty&&(!await (0,P.lJ)(_("fileBrowser.saveBeforeSwitch"),{confirmText:_("fileBrowser.saveAndSwitch"),cancelText:_("common.cancel")})||(await eP.current?.save(),eP.current?.isDirty)))return;e8.setShowEditor(!1)}r&&tu(),e8.handleSelectFile(e,t)},[e8,tu,eT.isDirty,_]),tx=(0,s.useMemo)(()=>{let e=tt.contentSearchResults;if(0===e.length)return{files:[],expandDirs:new Set,matchMap:new Map};let t=new Map,r=[];for(let n of e)t.set(n.path,n),r.push(n.path);let n=(0,$.v3)(r),s=new Set((0,$.tW)(n));return{files:n,expandDirs:s,matchMap:t}},[tt.contentSearchResults]),[tf,tg]=(0,s.useState)(new Set);(0,s.useEffect)(()=>{tg(tx.expandDirs)},[tx.expandDirs]);let tj=(0,s.useCallback)(e=>{tg(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),tk=(0,s.useCallback)(e=>{if(e.isDirectory)return null;let t=tx.matchMap.get(e.path);return t?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:t.matches.length}):null},[tx.matchMap]),ty=eR&&tt.contentSearchResults.length>0,[tL,tM]=(0,s.useState)("selected");(0,s.useEffect)(()=>{tM("selected")},[tt.contentSearchResults]);let tR=!!e8.selectedPath&&null!==tC(e8.selectedPath),[tB,tF]=(0,s.useState)(!1),tI=(0,s.useCallback)(async(e,r)=>{if(!e8.selectedPath||!tR)return;let n=await e1.goToDefinition(e8.selectedPath,e,r);if(0===n.length)return;let s=n[0],o=t.endsWith("/")?t:t+"/",a=s.file.startsWith(o)?s.file.slice(o.length):s.file;e3.push({filePath:e8.selectedPath,lineNumber:eS.current}),a===e8.selectedPath?e8.setTargetLineNumber(s.line):tm(a,s.line)},[e8,t,tR,e1,e3]),tD=(0,s.useCallback)((e,t,r,n,s)=>{e&&null!==tC(e)&&(tF(t),e2.onTokenMouseEnter(e,r,n,s))},[e2]),tA=(0,s.useCallback)((e,t,r)=>{tR&&tD(e8.selectedPath,!1,e,t,r)},[e8.selectedPath,tR,tD]),tz=(0,s.useCallback)(e=>{let r=t.endsWith("/")?t:t+"/",n=e.file.startsWith(r)?e.file.slice(r.length):e.file;e8.selectedPath&&e3.push({filePath:e8.selectedPath,lineNumber:eS.current}),n===e8.selectedPath?e8.setTargetLineNumber(e.line):tm(n,e.line)},[e8,t,e3]),tH=(0,s.useMemo)(()=>{if(!tr.status)return null;let e=new Map,t=e=>{switch(e){case"modified":default:return"M";case"added":case"untracked":return"A";case"deleted":return"D";case"renamed":return"R"}};for(let r of tr.status.staged)e.set(r.path,t(r.status));for(let r of tr.status.unstaged)e.set(r.path,t(r.status));return e},[tr.status]),tW=(0,s.useMemo)(()=>{if(!tr.status)return null;let e=new Map;for(let t of tr.status.staged)"renamed"===t.status&&t.oldPath&&e.set(t.path,t.oldPath);return e},[tr.status]),t_=(0,s.useCallback)(e=>{ex("search"),tt.setContentSearchQuery(e),tt.performContentSearch(e)},[tt.setContentSearchQuery,tt.performContentSearch]),tO=function({cwd:e,selectedPath:t,gitStatusMap:r,renameOldPaths:n,isText:o,refreshKey:a}){let l=t?r?.get(t):void 0,i=o&&("M"===l||"R"===l),[d,c]=(0,s.useState)(null),[m,x]=(0,s.useState)(!1),[h,f]=(0,s.useState)(()=>new Set),p=(0,s.useRef)(new Set),g=i&&!!t&&h.has(t);return(0,s.useEffect)(()=>{!t||p.current.has(t)||!r||o&&(p.current.add(t),i&&f(e=>new Set(e).add(t)))},[t,r,o,i]),(0,s.useEffect)(()=>{if(!g||!t)return void c(null);let r=!1;return x(!0),u.t4.runPromiseExit((0,j.w2)(e,t,"worktree",n?.get(t)).pipe(ep.withSpan("explorer.treeFileDiff"))).then(e=>{r||("Success"===e._tag?c(e.value):(console.error("Error fetching tree file diff:",e.cause),c(null)),x(!1))}),()=>{r=!0}},[g,t,e,a,n]),{canDiff:i,showDiff:g,toggleDiff:(0,s.useCallback)(()=>{t&&f(e=>{let r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r})},[t]),diff:d,isLoadingDiff:m}}({cwd:t,selectedPath:e8.selectedPath,gitStatusMap:tH,renameOldPaths:tW,isText:e8.fileContent?.type==="text",refreshKey:e8.fileContent?.mtime}),tq="tree"===em&&tO.showDiff;(0,s.useEffect)(()=>{ew(eb.current)},[]),(0,s.useEffect)(()=>{ex(r)},[r,a]),(0,s.useEffect)(()=>{l&&(ex("search"),tt.setContentSearchQuery(l),tt.performContentSearch(l))},[i]);let tV=(0,s.useCallback)(e=>{ex(e),e8.setBlameSelectedCommit(null),"history"===e&&to.selectedBranch&&to.loadCommits(to.selectedBranch)},[e8,to.selectedBranch,to.loadCommits]),tU=(0,s.useCallback)(()=>{if(!e8.selectedPath)return;let e={filePath:e8.selectedPath,lineNumber:eS.current},t=e3.goBack(e);t&&(t.filePath===e8.selectedPath?e8.setTargetLineNumber(t.lineNumber):tm(t.filePath,t.lineNumber))},[e8,e3]),tK=(0,s.useCallback)(()=>{if(!e8.selectedPath)return;let e={filePath:e8.selectedPath,lineNumber:eS.current},t=e3.goForward(e);t&&(t.filePath===e8.selectedPath?e8.setTargetLineNumber(t.lineNumber):tm(t.filePath,t.lineNumber))},[e8,e3]),tG=(0,s.useCallback)(async e=>{let r=e.split("/").pop()||e;"Success"===(await u.t4.runPromiseExit((0,b.__)({cwd:t,path:e})))._tag?(0,P.oR)(_("toast.copiedName",{name:r}),"success"):(0,P.oR)(_("toast.copyFailed"),"error")},[t,_]),tJ=(0,s.useCallback)(async e=>{let r=await u.t4.runPromiseExit((0,b.dt)());if("Success"!==r._tag||!r.value.path)return void(0,P.oR)(_("toast.noFileToPaste"),"info");let n=r.value.path,s=await u.t4.runPromiseExit((0,b.Nn)({cwd:t,targetDir:e,sourceAbsPath:n}));if("Success"===s._tag)(0,P.oR)(_("toast.pastedFile",{name:s.value.newName}),"success"),e8.loadDirectory(e),e8.loadFileIndex();else{let e="Fail"===s.cause._tag?s.cause.error:null,t=e?.cause,r=t instanceof Error?t.message:_("toast.pasteFailed");(0,P.oR)(r,"error")}},[t,e8,_]),tQ=(0,s.useRef)(0);(0,s.useEffect)(()=>{let t=t=>{let r="explorer"===ec;if(t.ctrlKey&&!t.metaKey&&"Minus"===t.code){if(t.preventDefault(),!r)return;t.shiftKey?tK():tU();return}if((t.metaKey||t.ctrlKey)&&"p"===t.key&&!t.shiftKey&&!t.altKey){t.preventDefault(),r?eC(e=>!e):(eu("explorer"),eC(!0));return}if(r&&(t.metaKey||t.ctrlKey)&&"c"===t.key&&!t.shiftKey){let e=t.target?.tagName,r=window.getSelection()?.toString();if(("tree"===em||"recent"===em)&&e8.selectedPath&&!r&&"INPUT"!==e&&"TEXTAREA"!==e){t.preventDefault(),tG(e8.selectedPath);return}}if(r&&(t.metaKey||t.ctrlKey)&&"v"===t.key){let e=t.target?.tagName;if(("tree"===em||"recent"===em)&&"INPUT"!==e&&"TEXTAREA"!==e&&!t.target?.isContentEditable){t.preventDefault(),tJ((0,$.S7)(e8.selectedPath,e8.files));return}}if(r&&(t.metaKey||t.ctrlKey)&&"f"===t.key){if(eF){t.preventDefault(),e0.open();return}if(e8.previewMarkdown&&e8.selectedPath&&(0,R.Hz)(e8.selectedPath)){t.preventDefault(),eX.open();return}}if(r&&"Escape"===t.key){if(eN)return void eC(!1);if(e0.isVisible)return void e0.close();if(eX.isVisible)return void eX.close();if(eF)return void eI(null);let t=Date.now();if(t-tQ.current<3e3)return;tQ.current=t,e4.visible?e4.closeReferences():eR?eB(!1):e8.blameSelectedCommit?e8.setBlameSelectedCommit(null):e8.showBlame?e8.setShowBlame(!1):e()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,e8.showBlame,e8.blameSelectedCommit,e8,eN,e4.visible,e4.closeReferences,eR,tU,tK,eX,eF,e0,em,tG,tJ,ec,eu]),(0,s.useEffect)(()=>{e8.loadFiles(),e8.loadFileIndex(),e8.loadRecentFiles(),tr.fetchStatus(),to.loadBranches()},[]),(0,s.useEffect)(()=>{let e=()=>{tr.fetchStatus()};return window.addEventListener("git-status-changed",e),()=>window.removeEventListener("git-status-changed",e)},[tr.fetchStatus]);let tZ=(0,s.useRef)(e6);(0,s.useEffect)(()=>{e6&&!tZ.current&&(e8.loadFiles(),e8.loadFileIndex(),e8.loadRecentFiles(),tr.fetchStatus(),to.loadBranches()),tZ.current=e6},[e6]),(0,s.useEffect)(()=>{to.selectedBranch&&to.loadCommits(to.selectedBranch)},[to.selectedBranch,to.loadCommits]);let tX=(0,s.useRef)(em),tY=(0,s.useRef)(!1);(0,s.useEffect)(()=>{let e=tX.current;if(tX.current=em,"tree"===em&&tY.current){tY.current=!1;return}if(("tree"===em||"recent"===em)&&e8.recentFiles.length>0){let t=e8.recentFiles[0].path;e8.selectedPath&&("status"!==e&&"history"!==e||e8.selectedPath===t)||(e8.setShouldScrollToSelected(!0),tm(t))}},[em,e8.recentFiles,e8.selectedPath,tm,e8]);let t0=(0,s.useRef)(to.selectedBranch);t0.current=to.selectedBranch;let t1=(0,s.useRef)(e8.selectedPath);t1.current=e8.selectedPath;let t2=(0,s.useRef)(e8.fileContent?.type);t2.current=e8.fileContent?.type;let t5=(0,s.useCallback)(async e=>{try{let{data:r}=e;if(!Array.isArray(r))return;let n=r.some(e=>"git"===e.type),s=r.some(e=>"file"===e.type),o=[];if((s||n)&&(o.push(u.t4.runPromise((0,b.mP)(t)).then(e=>{e.error||e8.setFiles(t=>(0,$.HR)(e.files??[],t))}).catch(()=>{})),o.push(u.t4.runPromise((0,b.DZ)(t)).then(e=>{e.paths&&e8.setFileIndex(e.paths)}).catch(()=>{})),o.push(u.t4.runPromise((0,b.r9)(t)).then(e=>{e8.setRecentFiles(e.files??[])}).catch(()=>{}))),n||s){o.push(u.t4.runPromise((0,j.lv)(t)).then(e=>{tr.setStatus(e);let t=(0,C.Do)(e.staged),r=(0,C.Do)(e.unstaged);tr.setStagedTree(t),tr.setUnstagedTree(r)}).catch(()=>{})),tr.refreshDiff(),n&&to.loadBranches();let e=t0.current;e&&o.push(u.t4.runPromise((0,j.Bj)(t,e,$.B_)).then(e=>{let t=e.commits??[];to.setCommits(t),to.setHasMoreCommits(t.length>=$.B_)}).catch(()=>{}))}let a=t1.current,l=t2.current;a&&"text"===l&&o.push(u.t4.runPromise((0,v.K)(t,a)).then(e=>{let t=e.ok?e.data:null;t&&"string"==typeof t.content&&e8.setFileContent({type:"text",content:t.content,size:t.size,mtime:t.mtimeMs,...t.isSymlink?{isSymlink:!0,symlinkTarget:t.symlinkTarget}:{}})}).catch(()=>{})),await Promise.all(o)}catch(e){console.error("File watch handler error:",e)}},[t]);(0,en.h)({url:`/ws/watch?cwd=${encodeURIComponent(t)}`,onMessage:t5,enabled:e6});let t4=(0,s.useCallback)(e=>{tm(e),e8.setShouldScrollToSelected(!0),ex("tree")},[e8,tm]),t3=(0,s.useRef)(tm);(0,s.useEffect)(()=>{t3.current=tm},[tm]);let t6=(0,s.useRef)(null),{setPreviewMarkdown:t8,setShouldScrollToSelected:t9}=e8;(0,s.useEffect)(()=>{!d||e8.isLoadingFiles||t6.current!==d.nonce&&(t6.current=d.nonce,tY.current=!0,ef("code"),ex("tree"),null!=d.lineNumber&&t8(!1),t3.current(d.path,d.lineNumber),t9(!0))},[d,e8.isLoadingFiles,t8,t9]);let t7=(0,s.useCallback)(({focalFile:e})=>e&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:r=>{r.stopPropagation(),navigator.clipboard.writeText(`${t}/${e}`),(0,P.oR)(_("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:_("common.copyAbsPath"),children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),t4(e)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:_("fileBrowser.locateInTree"),children:(0,n.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),[t,t4,_]),re=(0,s.useCallback)(({focalFile:e})=>"tree"===em&&tO.canDiff&&e===e8.selectedPath?(0,n.jsxs)(n.Fragment,{children:[tO.showDiff&&(0,n.jsx)(y.y,{value:eW,onChange:e_}),(0,n.jsx)("button",{onClick:tO.toggleDiff,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${tO.showDiff?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,title:tO.showDiff?_("fileBrowser.exitDiff"):_("fileBrowser.viewDiff"),children:_("common.diff")})]}):null,[em,tO.canDiff,tO.showDiff,tO.toggleDiff,e8.selectedPath,eW,_]),[rt,rr]=(0,s.useState)(null),rn=(0,s.useCallback)((e,t)=>{e8.setPreviewMarkdown(!0),t4(e),rr(t),t&&setTimeout(()=>rr(null),400)},[e8,t4]);return(0,n.jsxs)(z.SU,{container:ej,children:[(0,n.jsxs)("div",{ref:eb,className:"bg-card w-full h-full flex flex-col relative",children:[(0,n.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex-shrink-0 flex flex-col overflow-hidden",style:{width:eV},children:[(0,n.jsxs)("div",{className:"flex border-b border-border",children:[(0,n.jsx)("button",{onClick:()=>tV("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===em?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:_("fileBrowser.directoryTree")}),(0,n.jsx)("button",{onClick:()=>tV("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===em?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:_("fileBrowser.searchTab")}),(0,n.jsx)("button",{onClick:()=>tV("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===em?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:_("fileBrowser.recentTab")}),(0,n.jsx)("button",{onClick:()=>tV("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===em?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:_("fileBrowser.changesTab")}),(0,n.jsx)("button",{onClick:()=>tV("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===em?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:_("fileBrowser.historyTab")})]}),"tree"===em&&(0,n.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,n.jsxs)("div",{className:"flex-1 relative",children:[(0,n.jsx)("input",{ref:e8.searchInputRef,type:"text",value:e8.searchQuery,onChange:e=>e8.setSearchQuery(e.target.value),placeholder:_("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),e8.searchQuery&&(0,n.jsx)("button",{onClick:()=>{e8.setSearchQuery(""),e8.searchInputRef.current?.focus()},className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:_("fileBrowser.clear"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("button",{onClick:()=>e8.setSearchDirExact(e=>!e),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${e8.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:e8.searchExactMatch?_("fileBrowser.exactMatchOn"):_("fileBrowser.exactMatchOff"),children:"ab"}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:()=>e8.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:_("fileBrowser.refreshTree"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,n.jsx)("button",{onClick:()=>e8.searchTreeExpandedPaths?e8.setSearchTreeExpandedPaths(new Set):e8.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:_("fileBrowser.collapseAll"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===em&&(0,n.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)("div",{className:"flex-1 relative",children:[(0,n.jsx)("input",{ref:tt.contentSearchInputRef,type:"text",value:tt.contentSearchQuery,onChange:e=>tt.setContentSearchQuery(e.target.value),onKeyDown:e=>{"Enter"===e.key&&tt.performContentSearch(tt.contentSearchQuery)},placeholder:_("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),tt.contentSearchQuery&&(0,n.jsx)("button",{onClick:()=>{tt.setContentSearchQuery(""),tt.contentSearchInputRef.current?.focus()},className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:_("fileBrowser.clear"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("button",{onClick:()=>tt.performContentSearch(tt.contentSearchQuery),disabled:tt.isSearching||!tt.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:tt.isSearching?"...":_("common.search")})]}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:tt.searchOptions.caseSensitive,onChange:e=>tt.setSearchOptions(t=>({...t,caseSensitive:e.target.checked})),className:"w-3 h-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:_("fileBrowser.caseSensitive")})]}),(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:tt.searchOptions.wholeWord,onChange:e=>tt.setSearchOptions(t=>({...t,wholeWord:e.target.checked})),className:"w-3 h-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:_("fileBrowser.wholeWord")})]}),(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:tt.searchOptions.regex,onChange:e=>tt.setSearchOptions(t=>({...t,regex:e.target.checked})),className:"w-3 h-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:_("fileBrowser.regex")})]}),(0,n.jsx)("input",{type:"text",value:tt.searchOptions.fileType,onChange:e=>tt.setSearchOptions(t=>({...t,fileType:e.target.value})),placeholder:_("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground"})]})]}),"history"===em&&(0,n.jsx)("div",{className:"p-3 border-b border-border",children:to.compareMode?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,n.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,n.jsx)("span",{className:"truncate",children:to.branches?.current||"HEAD"}),(0,n.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:"HEAD"})]}),(0,n.jsx)("button",{onClick:()=>to.toggleCompareMode(!1),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors bg-brand text-white",title:_("fileBrowser.compareModeOff"),children:_("fileBrowser.compareMode")})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0 pl-1",children:"vs"}),(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)(tv,{branches:to.branches,selectedBranch:to.compareBaseBranch,onSelect:e=>{to.setCompareBaseBranch(e),to.loadCompareFiles(e)},isLoading:to.isLoadingBranches,pinnedBranches:["origin/main",...to.upstreamBranch&&"origin/main"!==to.upstreamBranch?[to.upstreamBranch]:[]]})})]})]}):(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)(tv,{branches:to.branches,selectedBranch:to.selectedBranch,onSelect:e=>{to.setSelectedBranch(e)},isLoading:to.isLoadingBranches,pinnedBranches:["origin/main",...to.upstreamBranch&&"origin/main"!==to.upstreamBranch?[to.upstreamBranch]:[]]})}),(0,n.jsx)("button",{onClick:()=>to.toggleCompareMode(!0),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors text-muted-foreground hover:text-foreground hover:bg-hover border border-border",title:_("fileBrowser.compareModeOn"),children:_("fileBrowser.compareMode")})]})}),(0,n.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,n.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===em?"":"hidden"}`,children:[e8.creatingItem&&(0,n.jsxs)("div",{className:"px-2 py-1.5 border-b border-border flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:e8.creatingItem.parentPath?_("fileBrowser.createFileIn",{path:e8.creatingItem.parentPath}):_("fileBrowser.createFile")}),(0,n.jsx)("input",{type:"text",autoFocus:!0,placeholder:_("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{ev.current=!0},onCompositionEnd:()=>{ev.current=!1},onKeyDown:async e=>{if("Enter"===e.key){if(ev.current)return;let r=e.target.value.trim();if(!r)return;let n=e8.creatingItem.parentPath,s=n?`${n}/${r}`:r,o=await u.t4.runPromiseExit((0,b.OJ)({cwd:t,path:s,content:""}));if("Success"===o._tag&&o.value.ok)(0,P.oR)(_("toast.createdFile",{name:r}),"success"),e8.setCreatingItem(null),e8.loadDirectory(n),e8.loadFileIndex(),n&&e8.setExpandedPaths(e=>new Set([...e,n])),tm(s);else if("Success"===o._tag){let e=o.value.data?.error;(0,P.oR)(e||_("toast.createFailed"),"error")}else(0,P.oR)(_("toast.createFailed"),"error")}else"Escape"===e.key&&e8.setCreatingItem(null)},onBlur:()=>e8.setCreatingItem(null)})]}),e8.isLoadingFiles&&0===e8.files.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:_("common.loading")}):e8.fileError?(0,n.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:e8.fileError}):(0,n.jsx)(O,{files:e8.files,selectedPath:e8.selectedPath,expandedPaths:e8.effectiveExpandedPaths,matchedPaths:e8.matchedPaths,gitStatusMap:tH,loadingDirs:e8.loadingDirs,onSelect:e=>{e8.setShouldScrollToSelected(!1),tm(e)},onToggle:e8.handleToggle,cwd:t,shouldScrollToSelected:e8.shouldScrollToSelected,onScrolledToSelected:()=>e8.setShouldScrollToSelected(!1),onCreateFile:e=>e8.setCreatingItem({type:"file",parentPath:e}),onDelete:(e,t,r)=>ey({path:e,isDirectory:t,name:r}),onRefresh:()=>e8.loadFiles(),onCopyFile:tG,onPaste:tJ,onExplain:et?eo:void 0,explainDisabled:et?.isLoading})]}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===em?"":"hidden"}`,children:tt.isSearching?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):tt.searchError?(0,n.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:tt.searchError}):0===tt.contentSearchResults.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:tt.contentSearchQuery?_("fileBrowser.noContentSearchResults"):_("fileBrowser.enterKeywordToSearch")}):(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[tt.searchStats&&(0,n.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground border-b border-border flex-shrink-0",children:[_("fileBrowser.nFilesNMatches",{files:tt.searchStats.totalFiles,matches:tt.searchStats.totalMatches}),tt.searchStats.truncated&&(0,n.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",_("fileBrowser.resultsTruncated"),")"]})]}),(0,n.jsx)(O,{files:tx.files,selectedPath:e8.selectedPath,expandedPaths:tf,onSelect:e=>{let t=tx.matchMap.get(e);tm(e,t?.matches[0]?.lineNumber),eR||eB(!0)},onToggle:tj,cwd:t,onExplain:et?eo:void 0,explainDisabled:et?.isLoading,renderActions:tk,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===em?"":"hidden"}`,children:0===e8.recentFiles.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:_("fileBrowser.noRecentFiles")}):(0,n.jsx)(O,{files:e8.recentFilesTree,selectedPath:e8.selectedPath,expandedPaths:e8.recentTreeDirPaths,onSelect:tm,onToggle:$.tE,cwd:t,onExplain:et?eo:void 0,explainDisabled:et?.isLoading})}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===em?"":"hidden"}`,children:tr.statusLoading?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):tr.statusError?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,n.jsx)("span",{className:"text-red-11 text-sm",children:tr.statusError})}):(0,n.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,n.jsxs)("div",{className:"border-b border-border",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:_("fileBrowser.stagingArea",{count:tr.status?.staged.length||0})}),(0,n.jsx)("button",{onClick:()=>tr.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:_("fileBrowser.refreshChanges"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),(tr.status?.staged.length||0)>0&&(0,n.jsx)("button",{onClick:tr.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:_("fileBrowser.unstageAll")})]}),(0,n.jsx)(C.VO,{files:tr.stagedTree,selectedPath:tr.statusSelectedFile?.type==="staged"?tr.statusSelectedFile.file.path:null,expandedPaths:tr.stagedExpandedPaths,onSelect:e=>e.file&&tr.handleStatusFileSelect(e.file,"staged"),onToggle:tr.handleStagedToggle,cwd:t,emptyMessage:_("fileBrowser.noStagedFiles"),className:"py-1",onExplain:et?ea:void 0,explainDisabled:et?.isLoading,renderActions:e=>{if(e.isDirectory){let t=(0,C.wI)(e);return 0===t.length?null:(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),tr.handleUnstageFiles(t.map(e=>e.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:_("fileBrowser.unstageNFiles",{count:t.length}),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),tr.handleUnstage(e.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:_("fileBrowser.unstageFile"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:_("fileBrowser.workspace",{count:tr.status?.unstaged.length||0})}),(tr.status?.unstaged.length||0)>0&&(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:tr.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:_("fileBrowser.discardAll")}),(0,n.jsx)("button",{onClick:tr.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:_("fileBrowser.stageAll")})]})]}),(0,n.jsx)(C.VO,{files:tr.unstagedTree,selectedPath:tr.statusSelectedFile?.type==="unstaged"?tr.statusSelectedFile.file.path:null,expandedPaths:tr.unstagedExpandedPaths,onSelect:e=>e.file&&tr.handleStatusFileSelect(e.file,"unstaged"),onToggle:tr.handleUnstagedToggle,cwd:t,emptyMessage:_("fileBrowser.noUnstagedChanges"),className:"py-1",onExplain:et?el:void 0,explainDisabled:et?.isLoading,renderActions:e=>{if(e.isDirectory){let t=(0,C.wI)(e);if(0===t.length)return null;let r=t.map(e=>e.file).filter(Boolean);return(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),tr.handleDiscardFiles(r)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:_("fileBrowser.discardNFiles",{count:t.length}),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),tr.handleStageFiles(t.map(e=>e.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:_("fileBrowser.stageNFiles",{count:t.length}),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return e.file?(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),tr.handleDiscardFile(e.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:_("fileBrowser.discardChanges"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),tr.handleStage(e.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:_("fileBrowser.stageFile"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===em?"":"hidden"}`,children:to.historyError?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("svg",{className:"w-16 h-16 mx-auto text-foreground-faint mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,n.jsx)("p",{className:"text-muted-foreground",children:to.historyError})]})}):to.compareMode?(0,n.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:to.isLoadingCompareFiles?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:_("fileBrowser.loadingDiff")}):0===to.compareFiles.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:_("fileBrowser.noDiffFiles")}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:_("fileBrowser.nFilesChanged",{count:to.compareFiles.length,branch:to.compareBaseBranch})})}),(0,n.jsx)(C.VO,{files:to.compareFileTree,expandedPaths:to.compareExpandedPaths,onToggle:to.handleCompareToggle,selectedPath:to.compareSelectedFile?.path||null,onSelect:e=>{e.file&&to.handleSelectCompareFile(e.file)},cwd:t,showChanges:!0,onExplain:et?ta:void 0,explainDisabled:et?.isLoading})]})}):(0,n.jsx)("div",{ref:to.commitListRef,className:"flex-1 overflow-y-auto",onScroll:to.handleCommitListScroll,children:to.isLoadingCommits?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:_("fileBrowser.loadingCommits")}):0===to.commits.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:_("fileBrowser.noCommits")}):(0,n.jsxs)(n.Fragment,{children:[to.commits.map(e=>(0,n.jsxs)("div",{onClick:()=>to.handleSelectCommit(e),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${to.selectedCommit?.hash===e.hash?"bg-brand/10":""}`,children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-mono text-xs text-brand",children:e.shortHash}),(0,n.jsxs)("span",{className:"text-xs text-foreground-subtle","data-tooltip":e.date,children:[e.relativeDate," \xb7 ",(0,$.r6)(e.date)]})]}),(0,n.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":e.subject,children:e.subject}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:e.author})]},e.hash)),to.isLoadingMore&&(0,n.jsx)("div",{className:"p-3 text-center",children:(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!to.hasMoreCommits&&to.commits.length>0&&(0,n.jsx)("div",{className:"p-3 text-center text-xs text-foreground-subtle",children:_("fileBrowser.allLoaded",{count:to.commits.length})})]})})})]})]}),(0,n.jsx)("div",{onPointerDown:eG,onPointerMove:eJ,onPointerUp:eQ,onPointerCancel:eQ,className:"w-[5px] flex-shrink-0 relative cursor-col-resize group",children:(0,n.jsx)("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border group-hover:bg-brand transition-colors"})}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[("tree"===em||"search"===em||"recent"===em)&&(e8.blameSelectedCommit?(0,n.jsx)(D,{isOpen:!0,onClose:()=>e8.setBlameSelectedCommit(null),commit:e8.blameSelectedCommit,cwd:t,embedded:!0,initialFilePath:e8.selectedPath||void 0,onLocateInTree:t4,onContentSearch:e=>{ex("search"),tt.setContentSearchQuery(e),tt.performContentSearch(e)}}):"map"===eh?tq&&tO.diff?(0,n.jsx)(th,{cwd:t,filePath:tO.diff.filePath,oldContent:tO.diff.oldContent,newContent:tO.diff.newContent,isNew:tO.diff.isNew,isDeleted:tO.diff.isDeleted,changedFiles:tn,fileGitStatusMap:ts,compact:"compact"===eW,enableComments:!0,onSwitchToCode:()=>ef("code"),onContentSearch:t_,headerExtraLeft:t7,headerExtraRight:re}):(0,n.jsx)(e5,{cwd:t,highlightedFilePath:e8.selectedPath,changedFiles:tn,onSwitchToCode:()=>ef("code"),enableComments:!0,onContentSearch:t_,headerExtraLeft:t7,headerExtraRight:re}):e8.selectedPath?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-4 py-2 border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:e8.selectedPath}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(`${t}/${e8.selectedPath}`),(0,P.oR)(_("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:_("common.copyAbsPath"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),t4(e8.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:_("fileBrowser.locateInTree"),children:(0,n.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,n.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:e8.showEditor?(0,n.jsxs)(n.Fragment,{children:[eT.isDirty&&(0,n.jsx)("span",{className:"text-xs text-amber-11",children:_("fileBrowser.unsaved")}),(0,n.jsx)("button",{onClick:()=>eP.current?.save(),disabled:!eT.isDirty||eT.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${eT.isDirty&&!eT.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:eT.isSaving?(0,n.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):_("common.save")}),(0,n.jsx)("button",{onClick:()=>eP.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:_("fileBrowser.closeEdit"),children:_("fileBrowser.closeBtn")})]}):tq?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(y.y,{value:eW,onChange:e_}),(0,n.jsx)(N.q,{value:eO,onChange:eq}),!(0,R.e$)(e8.selectedPath)&&!(0,R.aR)(e8.selectedPath)&&!(0,R.Hz)(e8.selectedPath)&&!(0,R.Zy)(e8.selectedPath)&&(0,n.jsx)("button",{onClick:()=>ef("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:_("blockViewer.viewerToggle.toBlock"),children:_("common.codeMap")}),(0,n.jsx)("button",{onClick:tO.toggleDiff,className:"px-1.5 py-0.5 text-xs rounded transition-colors bg-brand text-white",children:_("fileBrowser.exitDiff")})]}):(0,n.jsxs)(n.Fragment,{children:["tree"===em&&tO.canDiff&&(0,n.jsx)("button",{onClick:tO.toggleDiff,className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:_("fileBrowser.viewDiff"),children:_("common.diff")}),e8.fileContent?.type==="text"&&(0,R.e$)(e8.selectedPath)&&(0,n.jsx)(ee.ShareReviewToggle,{content:e8.fileContent.content||"",sourceFile:e8.selectedPath&&t&&e8.selectedPath.startsWith(t)?e8.selectedPath.slice(t.endsWith("/")?t.length:t.length+1):e8.selectedPath||""}),e8.fileContent?.type==="text"&&(0,R.Hz)(e8.selectedPath)&&e8.previewMarkdown&&!e8.showBlame&&(0,n.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:[!0,!1].map(e=>(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),te(t=>({version:t.version+1,collapsed:e}))},className:`px-2 py-0.5 text-xs transition-colors ${e7.collapsed===e?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:_(e?"fileBrowser.collapseAllJson":"fileBrowser.expandAllJson")},String(e)))}),e8.fileContent?.type==="text"&&((0,R.e$)(e8.selectedPath)||(0,R.aR)(e8.selectedPath)||(0,R.Hz)(e8.selectedPath)||(0,R.Zy)(e8.selectedPath))&&(E=(L=(0,R.aR)(e8.selectedPath))?e8.previewHtml:e8.previewMarkdown,(0,n.jsx)("button",{onClick:()=>L?e8.setPreviewHtml(e=>!e):e8.setPreviewMarkdown(e=>!e),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${E?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:E?_("fileBrowser.exitPreview"):_("common.preview")})),e8.fileContent?.type==="text"&&(0,R.C_)(e8.selectedPath||"")&&(A=(I=e8.selectedPath||"").startsWith("/")?I:t?`${t.replace(/\/$/,"")}/${I}`:I,(0,n.jsx)("button",{onClick:()=>ed(A),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:_("skills.addTooltip"),children:(0,n.jsx)(U.A,{className:"w-3.5 h-3.5"})})),e8.fileContent?.type==="text"&&(0,R.aR)(e8.selectedPath)&&(W=(H=e8.selectedPath||"").startsWith("/")?H:t?`${t.replace(/\/$/,"")}/${H}`:H,(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:()=>ei(W),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:_("htmlApps.addTooltip"),children:(0,n.jsx)(U.A,{className:"w-3.5 h-3.5"})}),(0,n.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:W}})),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:_("common.openInConsole"),children:(0,n.jsx)(K.A,{className:"w-3.5 h-3.5"})}),(0,n.jsx)("button",{onClick:()=>{let e=(0,J.Xe)(W);window.open((0,J.PB)(e,window.location.origin),"_blank")},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:_("browser.openInNewWindow"),children:(0,n.jsx)(G.A,{className:"w-3.5 h-3.5"})})]})),e8.fileContent?.type==="text"&&!(e8.previewMarkdown&&((0,R.e$)(e8.selectedPath)||(0,R.Hz)(e8.selectedPath)||(0,R.Zy)(e8.selectedPath))||e8.previewHtml&&(0,R.aR)(e8.selectedPath))&&(0,n.jsx)("button",{onClick:e8.handleToggleBlame,disabled:e8.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${e8.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-hover"} disabled:opacity-50`,title:_("fileBrowser.viewBlame"),children:e8.isLoadingBlame?(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),e8.fileContent?.type==="text"&&!(e8.previewMarkdown&&((0,R.e$)(e8.selectedPath)||(0,R.Hz)(e8.selectedPath)||(0,R.Zy)(e8.selectedPath))||e8.previewHtml&&(0,R.aR)(e8.selectedPath))&&(0,n.jsx)("button",{onClick:()=>e8.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:_("fileBrowser.editFile"),children:_("common.edit")}),e8.fileContent?.type==="text"&&e8.fileContent.content&&(0,n.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(e8.fileContent.content),(0,P.oR)(_("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:_("fileBrowser.copyFileContent"),children:_("common.copy")}),e8.fileContent?.type==="text"&&!(0,R.e$)(e8.selectedPath)&&!(0,R.aR)(e8.selectedPath)&&!(0,R.Hz)(e8.selectedPath)&&!(0,R.Zy)(e8.selectedPath)&&(0,n.jsx)("button",{onClick:()=>ef("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:_("blockViewer.viewerToggle.toBlock"),children:_("common.codeMap")})]})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden",children:e8.isLoadingContent?(0,n.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):e8.fileContent?"text"===e8.fileContent.type&&"string"==typeof e8.fileContent.content?tq?tO.isLoadingDiff&&!tO.diff?(0,n.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):tO.diff?"unified"===eO?(0,n.jsx)(w.xU,{oldContent:tO.diff.oldContent,newContent:tO.diff.newContent,filePath:tO.diff.filePath,cwd:t,enableComments:!0,compact:"compact"===eW,onContentSearch:t_,onTokenHover:(e,t,r)=>tD(tO.diff?.filePath,!0,e,t,r),onTokenHoverLeave:e2.onTokenMouseLeave,onTokenHoverCancel:e2.clearHover}):(0,n.jsx)(w.xZ,{oldContent:tO.diff.oldContent,newContent:tO.diff.newContent,filePath:tO.diff.filePath,isNew:tO.diff.isNew,isDeleted:tO.diff.isDeleted,cwd:t,enableComments:!0,compact:"compact"===eW,onContentSearch:t_,onTokenHover:(e,t,r)=>tD(tO.diff?.filePath,!0,e,t,r),onTokenHoverLeave:e2.onTokenMouseLeave,onTokenHoverCancel:e2.clearHover}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("p",{children:_("fileBrowser.diffLoadFailed")}),(0,n.jsx)("button",{onClick:tO.toggleDiff,className:"mt-2 text-brand hover:underline text-sm",children:_("fileBrowser.exitDiff")})]})}):e8.showBlame&&e8.blameError?(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("p",{className:"text-red-11",children:e8.blameError}),(0,n.jsx)("button",{onClick:()=>e8.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:_("fileBrowser.backToPreview")})]})}):e8.showBlame&&0===e8.blameLines.length&&e8.isLoadingBlame?(0,n.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):e8.previewMarkdown&&(0,R.Hz)(e8.selectedPath)&&!e8.showBlame?(0,n.jsxs)("div",{className:"h-full flex flex-col bg-background text-foreground",children:[(0,n.jsx)(B._,{search:eX}),(0,n.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,n.jsx)("pre",{ref:eZ,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,n.jsx)(R.d9.Provider,{value:e7,children:e9})})})]}):e8.previewMarkdown&&(0,R.Zy)(e8.selectedPath)&&!e8.showBlame?(0,n.jsx)(V.C0,{content:e8.fileContent.content,filePath:e8.selectedPath,className:"h-full"}):e8.previewMarkdown&&(0,R.e$)(e8.selectedPath)&&!e8.showBlame?(0,n.jsx)("div",{className:"h-full flex flex-col",children:(0,n.jsx)(X.M,{content:e8.fileContent.content,filePath:e8.selectedPath,cwd:t,embedded:!0,onLocalMdLink:rn,scrollToAnchor:rt})}):e8.previewHtml&&(0,R.aR)(e8.selectedPath)&&!e8.showBlame?(0,n.jsx)(Y.O,{content:e8.fileContent.content,filePath:e8.selectedPath,cwd:t,onContentSearch:e=>{ex("search"),tt.setContentSearchQuery(e),tt.performContentSearch(e)}}):(0,n.jsx)(q.Cv,{ref:eP,content:e8.fileContent.content,filePath:e8.selectedPath,cwd:t,enableComments:!0,scrollToLine:eM??e8.targetLineNumber,scrollToLineAlign:null!=eM?"start":e8.targetScrollAlign,onScrollToLineComplete:()=>{eE(null),e8.setTargetLineNumber(null)},highlightKeyword:"search"===em?tt.contentSearchQuery:null,visibleLineRef:eS,viStateRef:eL,initialCursorLine:e8.initialCursorLine,initialCursorCol:e8.initialCursorCol,onInitialCursorSet:()=>{e8.setInitialCursorLine(null),e8.setInitialCursorCol(null)},onCmdClick:tR?tI:void 0,onTokenHover:tR?tA:void 0,onTokenHoverLeave:tR?e2.onTokenMouseLeave:void 0,onTokenHoverCancel:tR?e2.clearHover:void 0,blameLines:e8.showBlame&&e8.blameLines.length>0?e8.blameLines:void 0,inlineBlameLines:e8.blameLines.length>0?e8.blameLines:void 0,onSelectCommit:e8.setBlameSelectedCommit,editable:e8.showEditor,initialMtime:e8.fileContent.mtime,onEditorClose:e=>{e8.setShowEditor(!1),eE(e)},onSaved:()=>{let e=eS.current??1;e8.loadFileContent(e8.selectedPath),e8.setShowEditor(!1),eE(e)},onEditorStateChange:e$,viMode:!0,onContentMutate:ti,onEnterInsertMode:td,onViSave:tc,onContentSearch:e=>{ex("search"),tt.setContentSearchQuery(e),tt.performContentSearch(e)}}):"image"===e8.fileContent.type&&e8.selectedPath?(0,n.jsx)(tp.I,{cwd:t,path:e8.selectedPath,refreshKey:e8.fileContent.mtime,alt:e8.selectedPath}):"pdf"===e8.fileContent.type&&e8.selectedPath?(0,n.jsx)(tw,{cwd:t,path:e8.selectedPath,refreshKey:e8.fileContent.mtime}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("svg",{className:"w-16 h-16 mx-auto text-foreground-faint mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,n.jsx)("p",{children:e8.fileContent.message||_("fileBrowser.cannotPreview")})]})}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:_("fileBrowser.selectFileToPreview")})})]}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("svg",{className:"w-16 h-16 mx-auto text-foreground-faint mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,n.jsx)("p",{children:_("fileBrowser.selectFileToPreview")})]})})),"status"===em&&(tr.statusSelectedFile&&tr.statusDiff?(0,n.jsx)(tb,{cwd:t,selected:tr.statusSelectedFile,diff:tr.statusDiff,showMarkdownPreview:tr.showStatusDiffPreview,setShowMarkdownPreview:tr.setShowStatusDiffPreview,changedFiles:tn,fileGitStatusMap:ts,onContentSearch:e=>{ex("search"),tt.setContentSearchQuery(e),tt.performContentSearch(e)},locateInTree:t4,jsonPreview:eF,setJsonPreview:eI,jsonPreviewSearch:e0,jsonPreviewPreRef:eY,onTokenHover:(e,t,r)=>tD(tr.statusDiff?.filePath,!0,e,t,r),onTokenHoverLeave:e2.onTokenMouseLeave,onTokenHoverCancel:e2.clearHover}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,n.jsx)("span",{children:_("fileBrowser.selectFileToViewDiff")})})),"history"===em&&!to.historyError&&(to.compareMode?to.isLoadingCompareDiff?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:_("fileBrowser.loadingDiffContent")}):to.compareFileDiff?(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border flex-shrink-0",children:[(0,n.jsx)(T,{cwd:t,filePath:to.compareFileDiff.filePath,onLocateInTree:t4}),!(0,$.u)(to.compareFileDiff.filePath)&&(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,n.jsx)(y.y,{value:eD,onChange:eA}),(0,n.jsx)(N.q,{value:ez,onChange:eH})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,$.u)(to.compareFileDiff.filePath)?(0,n.jsx)(M,{cwd:t,filePath:to.compareFileDiff.filePath,oldRev:to.compareFileDiff.oldRev??(to.compareFileDiff.isNew?null:to.compareBaseBranch),newRev:to.compareFileDiff.newRev??(to.compareFileDiff.isDeleted?null:"HEAD")}):"unified"===ez?(0,n.jsx)(w.xU,{oldContent:to.compareFileDiff.oldContent,newContent:to.compareFileDiff.newContent,filePath:to.compareFileDiff.filePath,cwd:t,enableComments:!0,compact:"compact"===eD,onPreview:!to.compareFileDiff.isDeleted&&to.compareFileDiff.filePath.endsWith(".json")?()=>eI({content:to.compareFileDiff.newContent,filePath:to.compareFileDiff.filePath}):void 0,previewLabel:_("common.readable"),onContentSearch:e=>{ex("search"),tt.setContentSearchQuery(e),tt.performContentSearch(e)}}):(0,n.jsx)(w.xZ,{oldContent:to.compareFileDiff.oldContent,newContent:to.compareFileDiff.newContent,filePath:to.compareFileDiff.filePath,isNew:to.compareFileDiff.isNew,isDeleted:to.compareFileDiff.isDeleted,cwd:t,enableComments:!0,compact:"compact"===eD,onPreview:!to.compareFileDiff.isDeleted&&to.compareFileDiff.filePath.endsWith(".json")?()=>eI({content:to.compareFileDiff.newContent,filePath:to.compareFileDiff.filePath}):void 0,previewLabel:_("common.readable"),onContentSearch:e=>{ex("search"),tt.setContentSearchQuery(e),tt.performContentSearch(e)}})})]}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,n.jsx)("span",{children:to.compareFiles.length>0?_("fileBrowser.selectFileToViewDiff"):_("fileBrowser.clickCompareToLoad")})}):to.selectedCommit?(0,n.jsx)(D,{isOpen:!0,onClose:()=>to.setSelectedCommit(null),commit:to.selectedCommit,cwd:t,embedded:!0,onLocateInTree:t4,onContentSearch:e=>{ex("search"),tt.setContentSearchQuery(e),tt.performContentSearch(e)}}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,n.jsx)("span",{children:_("fileBrowser.selectCommitToView")})}))]})]}),eN&&(0,n.jsx)(er,{files:e8.files,fileIndex:e8.fileIndex,recentFiles:e8.recentFilePaths,onSelectFile:e=>{tm(e),e8.setShouldScrollToSelected(!0),ex("tree")},onClose:()=>eC(!1)}),(ty||e4.visible)&&(0,n.jsxs)("div",{className:`flex ${e4.visible&&ty?"":"flex-col"}`,children:[ty&&(0,n.jsx)("div",{className:e4.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,n.jsx)(tT,{results:tt.contentSearchResults,loading:tt.isSearching,totalMatches:tt.searchStats?.totalMatches??0,onSelect:(e,t)=>{e8.selectedPath&&e3.push({filePath:e8.selectedPath,lineNumber:eS.current}),ef("code"),tm(e,t)},onClose:()=>eB(!1),scope:tL,onScopeChange:tM,selectedPath:e8.selectedPath})}),e4.visible&&(0,n.jsx)("div",{className:ty?"flex-1 min-w-0":"",children:(0,n.jsx)(tP,{references:e4.references,loading:e4.loading,onSelect:tz,onClose:e4.closeReferences})})]})]}),ek&&(0,n.jsx)(g.ZL,{children:(0,n.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim",onClick:()=>ey(null),children:(0,n.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-lv3 p-4 max-w-sm w-full mx-4",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:_("fileBrowser.confirmDelete")}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:_("fileBrowser.confirmDeleteMessage",{name:ek.name}).split(/<\/?file>/g).map((e,t)=>1===t?(0,n.jsx)("span",{className:"font-mono text-foreground",children:e},t):e)}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)("button",{onClick:()=>ey(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-hover transition-colors",children:_("common.cancel")}),(0,n.jsx)("button",{onClick:async()=>{let{path:e,name:r}=ek;ey(null);let n=await u.t4.runPromiseExit((0,b.VK)({cwd:t,path:e}));if("Success"===n._tag){(0,P.oR)(_("toast.movedToTrash",{name:r}),"success");let t=e.includes("/")?e.substring(0,e.lastIndexOf("/")):"";e8.loadDirectory(t),e8.loadFileIndex(),e8.selectedPath===e&&tm("")}else{let e="Fail"===n.cause._tag?n.cause.error:null,t=e?.cause,r=t instanceof Error?t.message:_("toast.deleteFailed");(0,P.oR)(r,"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:_("common.delete")})]})]})})}),e2.hoverInfo&&ej&&(0,p.createPortal)((0,n.jsx)(tE,{ref:e2.setTooltipEl,displayString:e2.hoverInfo.displayString,documentation:e2.hoverInfo.documentation,x:e2.hoverInfo.x,y:e2.hoverInfo.y,container:ej,onMouseEnter:e2.onCardMouseEnter,onMouseLeave:e2.onCardMouseLeave,onFindReferences:tB?void 0:()=>{let{filePath:e,line:t,column:r}=e2.hoverInfo;e2.clearHover(),e4.findReferences(e,t,r)},onSearch:e=>{e2.clearHover(),ex("search"),tt.setContentSearchQuery(e),tt.performContentSearch(e)},onExplain:et?e=>{let{filePath:t,line:r}=e2.hoverInfo;e2.clearHover(),et.sendMessage(_("explain.symbolMessage",{name:e,path:t,lines:String(r)}))}:void 0,explainDisabled:et?.isLoading}),ej)]})});function tB({isOpen:e,onClose:t,cwd:r}){let a,{t:l}=(0,o.Bd)(),[i,m]=(0,s.useState)([]),[x,h]=(0,s.useState)(null),[f,p]=(0,s.useState)(null),[g,b]=(0,s.useState)(!1),[v,w]=(0,s.useState)(!1),[k,y]=(0,s.useState)(null),[N,C]=(0,s.useState)(!1),[S,L]=(0,s.useState)(""),[M,E]=(0,s.useState)(!1),[T,R]=(0,s.useState)([]),[B,F]=(0,s.useState)(""),[I,D]=(0,s.useState)(!1),A=(0,s.useCallback)((e,t)=>e?._tag==="Fail"&&e.error?.cause instanceof Error?e.error.cause.message:l(t),[l]),z=(0,s.useCallback)(async()=>{b(!0);let e=await u.t4.runPromiseExit((0,j.FK)(r));if("Success"===e._tag){let t=e.value;m(t.worktrees),h(t.nextPath),p(t.nextRandomWord),t.gitUserName&&L(t.gitUserName)}else console.error("Failed to load worktrees:",e.cause),(0,P.oR)(l("toast.worktreeLoadFailed"),"error");b(!1)},[r,l]),H=(0,s.useCallback)(e=>{let{local:t,remote:r}=e;return r.includes("origin/main")?"origin/main":r.includes("origin/master")?"origin/master":t.includes("main")?"main":t.includes("master")?"master":r.length>0?r[0]:t.length>0?t[0]:"main"},[]);(0,s.useEffect)(()=>{e&&(z(),y(null))},[e,z]);let W=async()=>{if(!x)return;let e="origin/main",t=await u.t4.runPromiseExit((0,j.r4)(r));"Success"===t._tag&&(e=H(t.value));let n=f||function(){let e="bcdfghjklmnprstvwz",t=["a","e","i","o","u","ai","au","ea","ee","ia","io","oa","oo","ou","ui"],r="";for(let n=0;n<2;n++)r+=e[Math.floor(Math.random()*e.length)],r+=t[Math.floor(Math.random()*t.length)];return r}(),s=S?`${S}/${n}`:n;w(!0);let o=await u.t4.runPromiseExit((0,j.CM)({action:"add",cwd:r,path:x,newBranch:s,baseBranch:e}));"Success"===o._tag?((0,P.oR)(l("toast.worktreeCreateSuccess",{name:s}),"success"),z()):(console.error("Failed to create worktree:",o.cause),(0,P.oR)(A(o.cause,"toast.worktreeCreateFailed"),"error")),w(!1)},_=async()=>{D(!0),F(""),E(!0);let e=await u.t4.runPromiseExit((0,j.r4)(r));if("Success"===e._tag){let t=e.value,r=t.local??[],n=t.remote??[],s=new Set(i.map(e=>e.branch).filter(Boolean));R([...r.filter(e=>!s.has(e)),...n.filter(e=>!s.has(e)&&!r.includes(e.replace(/^origin\//,"")))])}else(0,P.oR)(l("toast.loadBranchFailed"),"error");D(!1)},O=async e=>{if(!x)return;E(!1),w(!0);let t=await u.t4.runPromiseExit((0,j.CM)({action:"add",cwd:r,path:x,branch:e}));"Success"===t._tag?((0,P.oR)(l("toast.worktreeCreateSuccess",{name:e}),"success"),z()):(console.error("Failed to create worktree:",t.cause),(0,P.oR)(A(t.cause,"toast.worktreeCreateFailed"),"error")),w(!1)},q=async()=>{if(!k)return;C(!0);let e=await u.t4.runPromiseExit((0,j.CM)({action:"remove",cwd:r,path:k.path}));"Success"===e._tag?((0,P.oR)(l("toast.worktreeDeleted"),"success"),y(null),z()):(console.error("Failed to delete worktree:",e.cause),(0,P.oR)(A(e.cause,"toast.worktreeDeleteFailed"),"error")),C(!1)},V=async e=>{let t=e.isLocked?"unlock":"lock",n=await u.t4.runPromiseExit((0,j.CM)({action:t,cwd:r,path:e.path}));"Success"===n._tag?((0,P.oR)(e.isLocked?l("toast.worktreeUnlocked"):l("toast.worktreeLocked"),"success"),z()):(console.error("Failed to toggle lock:",n.cause),(0,P.oR)(A(n.cause,"toast.operationFailed"),"error"))};return e?(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:t,children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-[480px] max-h-[80vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Git Worktrees"}),(0,n.jsx)("button",{onClick:t,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:l("common.close"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("div",{className:"flex-1 p-4 overflow-y-auto",children:g?(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):(0,n.jsx)("div",{className:"space-y-2",children:i.map(e=>{let s,o=e.path===r;return(0,n.jsxs)("div",{className:`group p-3 rounded-lg border transition-colors ${o?"border-brand bg-brand/5":"border-border hover:bg-hover cursor-pointer"}`,onClick:()=>{e.path!==r&&((0,d.F)(c.n.OpenProject,{cwd:e.path}),t())},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,n.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${o?"bg-brand":"bg-muted-foreground/30"}`}),(0,n.jsx)("span",{className:"font-medium text-foreground truncate",children:e.branch||(e.isDetached?"detached":"unknown")}),e.isLocked&&(0,n.jsx)("span",{className:"text-amber-11",title:l("git.worktree.locked"),children:"\uD83D\uDD12"}),o&&(0,n.jsxs)("span",{className:"text-xs text-brand",children:["(",l("common.current"),")"]})]}),(0,n.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:!o&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),V(e)},className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-secondary rounded transition-colors",title:e.isLocked?l("git.worktree.unlock"):l("git.worktree.lock"),children:e.isLocked?(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"})}):(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),y(e)},className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-secondary rounded transition-colors",title:l("common.delete"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})})]}),(0,n.jsxs)("div",{className:"mt-1 flex items-center justify-between gap-2 pl-4",children:[(0,n.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:e.path}),null!=e.createdAt&&(s=(0,$.fw)(e.createdAt/1e3),(0,n.jsx)("span",{className:`text-xs flex-shrink-0 ${"just now"===s?"text-brand":"text-muted-foreground/70"}`,"data-tooltip":new Date(e.createdAt).toLocaleString(),children:s}))]}),e.isDetached&&(0,n.jsx)("div",{className:"mt-1 text-xs text-amber-11 pl-4",children:"(detached HEAD)"})]},e.path)})})}),M&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-3 flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,n.jsx)("input",{value:B,onChange:e=>F(e.target.value),placeholder:l("git.worktree.searchBranch"),className:"flex-1 bg-secondary text-sm text-foreground rounded px-2.5 py-1.5 outline-none",autoFocus:!0,autoComplete:"off",spellCheck:"false"}),(0,n.jsx)("button",{onClick:()=>E(!1),className:"text-xs text-muted-foreground hover:text-foreground px-2 py-1.5",children:l("common.cancel")})]}),(0,n.jsx)("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:I?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:l("common.loading")}):0===(a=T.filter(e=>e.toLowerCase().includes(B.toLowerCase()))).length?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:l("git.worktree.noBranches")}):a.map(e=>(0,n.jsx)("button",{onClick:()=>O(e),className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-hover transition-colors truncate",children:(0,n.jsx)("span",{className:`${e.startsWith("origin/")?"text-muted-foreground":"text-foreground"}`,children:e})},e))})]}),(0,n.jsxs)("div",{className:"px-4 py-3 border-t border-border flex items-center justify-between flex-shrink-0",children:[(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:l("git.worktree.count",{count:i.length})}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:_,disabled:!x||v,className:`px-3 py-1.5 text-sm rounded transition-colors ${x&&!v?"bg-secondary text-foreground hover:bg-hover":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:l("git.worktree.selectBranch")}),(0,n.jsx)("button",{onClick:W,disabled:!x||v,className:`px-3 py-1.5 text-sm rounded transition-colors ${x&&!v?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:v?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):l("git.worktree.addWorktree")})]})]}),k&&(0,n.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-scrim rounded-lg",onClick:()=>y(null),children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-[360px] p-4",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("div",{className:"text-sm font-medium text-foreground mb-3",children:l("git.worktree.confirmDelete")}),(0,n.jsxs)("div",{className:"text-sm text-muted-foreground mb-4",children:[(0,n.jsx)("p",{className:"mb-2",children:l("git.worktree.confirmDeleteMsg")}),(0,n.jsxs)("p",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-muted-foreground",children:l("git.worktree.path")}),(0,n.jsx)("span",{className:"text-foreground",children:k.path})]}),(0,n.jsxs)("p",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-muted-foreground",children:l("git.worktree.branch")}),(0,n.jsx)("span",{className:"text-foreground",children:k.branch||"detached"})]})]}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,n.jsx)("button",{onClick:()=>y(null),className:"px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:l("common.cancel")}),(0,n.jsx)("button",{onClick:q,disabled:N,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 transition-colors disabled:opacity-50",children:N?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):l("common.delete")})]})]})})]})}):null}var tF=r(67635),tI=r(73300),tD=r(20986),tA=r(9921),tz=r(66088),tH=r(42790);function tW(e){let t=function(e){let t=0xffffffff;for(let r=0;r<e.length;r++){t^=e.charCodeAt(r);for(let e=0;e<8;e++)t=t>>>1^(1&t?0xedb88320:0)}return(0xffffffff^t)>>>0}(e),r="",n=t;for(let e=0;e<4;e++)r+=String.fromCharCode(97+n%26),n=Math.floor(n/26);return r}function t_({open:e,anchorRef:t,initialValue:r,onCancel:a,onSave:l}){let{t:i}=(0,o.Bd)(),[d,c]=(0,s.useState)(r),[u,m]=(0,s.useState)(!1),[x,h]=(0,s.useState)(null),f=(0,s.useRef)(null),g=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(e){c(r),m(!1);let e=requestAnimationFrame(()=>{f.current?.focus(),f.current?.select()});return()=>cancelAnimationFrame(e)}h(null)},[e,r]);let b=(0,s.useCallback)(()=>{let e=t.current;if(!e)return;let r=e.getBoundingClientRect(),n=g.current?.offsetHeight??0,s=r.bottom+4;if(n&&s+n>window.innerHeight-8){let e=r.top-4-n;e>=8&&(s=e)}let o=r.left;h({top:s,left:o=Math.max(o=Math.min(o,window.innerWidth-260-8),8)})},[t]);if((0,s.useLayoutEffect)(()=>{if(e)return b(),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),()=>{window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}},[e,b]),(0,s.useEffect)(()=>{if(!e)return;let r=e=>{"Escape"===e.key&&(e.preventDefault(),a())},n=e=>{let r=e.target;g.current?.contains(r)||t.current?.contains(r)||a()};return window.addEventListener("keydown",r),document.addEventListener("mousedown",n,!0),()=>{window.removeEventListener("keydown",r),document.removeEventListener("mousedown",n,!0)}},[e,a,t]),!e||"u"<typeof document)return null;let v=async()=>{if(!u){m(!0);try{await l(d.trim())}finally{m(!1)}}};return(0,p.createPortal)((0,n.jsxs)("div",{ref:g,style:{top:x?.top??0,left:x?.left??0,width:260,visibility:x?"visible":"hidden"},className:"fixed z-[100] rounded-lg border border-border bg-card p-3 shadow-lv3",children:[(0,n.jsx)("div",{className:"mb-2 text-sm font-medium text-foreground",children:i("shortIdBadge.dialogTitle")}),(0,n.jsx)("input",{ref:f,type:"text",value:d,onChange:e=>c(e.target.value.slice(0,64)),onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||229===e.keyCode||(e.preventDefault(),v())},placeholder:i("shortIdBadge.dialogPlaceholder"),maxLength:64,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm font-mono outline-none focus:border-brand"}),(0,n.jsxs)("div",{className:"mt-3 flex justify-end gap-2 text-sm",children:[(0,n.jsx)("button",{onClick:a,className:"rounded px-3 py-1 text-muted-foreground hover:bg-hover",disabled:u,children:i("common.cancel")}),(0,n.jsx)("button",{onClick:()=>void v(),className:"rounded bg-brand px-3 py-1 text-white hover:opacity-90 disabled:opacity-50",disabled:u,children:u?"…":i("common.save")})]})]}),document.body)}let tO=e=>ep.tryPromise({try:async()=>{let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status}`);return await t.json()},catch:t=>new eg.uV({message:`fetch ${e} failed`,cause:t})}),tq=(e,t)=>ep.tryPromise({try:async()=>{let r=await fetch(e,t);if(!r.ok)throw Error(`HTTP ${r.status}`)},catch:r=>new eg.uV({message:`${t.method} ${e} failed`,cause:r})}),tV=(e,t)=>tq(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),tU=(e,t)=>ep.gen(function*(){let r=new URLSearchParams({cwd:e});t&&r.set("tabId",t);let n=yield*tO(`/api/terminal/env?${r}`);return{env:n.env||{},home:n.home||""}}),tK=()=>tO("/api/terminal/aliases").pipe(ep.map(e=>e.aliases||{})),tG=(e,t)=>`/api/terminal/bubble-order?cwd=${encodeURIComponent(e)}&tabId=${encodeURIComponent(t)}`,tJ=(e,t,r,n)=>tV("/api/terminal/bubble-order",{cwd:e,tabId:t,order:r,sourceId:n}),tQ=(e,t,r,n)=>tV("/api/terminal/history",{cwd:e,tabId:t,entry:r,sourceId:n}),tZ=(e,t,r,n)=>tq(`/api/terminal/history?cwd=${encodeURIComponent(e)}&tabId=${encodeURIComponent(t)}&commandId=${encodeURIComponent(r)}${n?`&sourceId=${encodeURIComponent(n)}`:""}`,{method:"DELETE"}),tX=e=>tO(`/api/services/config?cwd=${encodeURIComponent(e)}`),tY=e=>{let t;return t="/api/services/config",ep.tryPromise({try:async()=>{let r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw Error(`HTTP ${r.status}`);return await r.json()},catch:e=>new eg.uV({message:`POST ${t} failed`,cause:e})})},t0=(0,s.memo)(function({shortId:e,type:t,onRegister:r,onUnregister:a,fullId:l,projectCwd:i,tabId:d,registered:c}){let{t:m}=(0,o.Bd)(),[x,h]=(0,s.useState)(!1),f=c??x,[p,g]=(0,s.useState)(""),[b,v]=(0,s.useState)(!1),j=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!l||!i||!d)return;let e=!1;return u.t4.runPromiseExit(tO(tG(i,d)).pipe(ep.map(e=>e.titles||{}))).then(t=>{if(e||"Success"!==t._tag)return;let r=t.value[l];"string"==typeof r&&g(r)}),()=>{e=!0}},[l,i,d]),(0,en.h)({url:"/ws/global-state",enabled:!!l&&!!i&&!!d,onMessage:e=>{"console-delta"!==e.type||"rename"!==e.op||e.cwd!==i||e.tabId!==d||e.titles&&l&&Object.prototype.hasOwnProperty.call(e.titles,l)&&g(e.titles[l]??"")}});let w=(0,s.useCallback)(async n=>{if(n.stopPropagation(),f)await a(),h(!1),(0,P.oR)(m("toast.disconnected",{id:e}));else{await r(),h(!0);let n=`${"3456"===window.location.port?"cockpit-dev":"cockpit"} ${t} ${e}`;navigator.clipboard.writeText(n),(0,P.oR)(m("toast.copiedCommand",{command:n}))}},[f,e,t,r,a,m]),k=!!(l&&i&&d),y=(0,s.useCallback)(e=>{e.stopPropagation(),k&&v(!0)},[k]),N=(0,s.useCallback)(async e=>{l&&i&&d&&("Success"===(await u.t4.runPromiseExit(tV("/api/terminal/bubble-order",{cwd:i,tabId:d,titles:{[l]:e}})))._tag&&g(e),v(!1))},[l,i,d]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{onClick:w,onDoubleClick:e=>e.stopPropagation(),className:"inline-flex items-center gap-1 text-[10px] font-mono leading-none px-1.5 py-0.5 rounded flex-shrink-0 transition-colors bg-muted/60 hover:bg-muted text-muted-foreground",title:f?m("shortIdBadge.clickToDisconnect"):m("shortIdBadge.clickToRegister"),children:[(0,n.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${f?"bg-green-500":"bg-muted-foreground/40"}`}),e]}),k&&(p?(0,n.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[10px] leading-none flex-shrink-0 text-muted-foreground",title:m("shortIdBadge.titleSet",{title:p})||p,children:[(0,n.jsx)("span",{className:"px-1 py-0.5 rounded bg-muted/40 max-w-[120px] truncate",children:p}),(0,n.jsx)("button",{ref:j,onClick:y,className:"opacity-50 hover:opacity-100 transition-opacity","aria-label":m("shortIdBadge.editTitle"),title:m("shortIdBadge.editTitle"),children:"✎"})]}):(0,n.jsxs)("button",{ref:j,onClick:y,className:"inline-flex items-center gap-0.5 text-[10px] leading-none flex-shrink-0 text-muted-foreground/50 hover:text-muted-foreground italic transition-colors",title:m("shortIdBadge.setTitle"),children:["(",m("shortIdBadge.setTitlePlaceholder"),") ✎"]})),(0,n.jsx)(t_,{open:b,anchorRef:j,initialValue:p,onCancel:()=>v(!1),onSave:N})]})});var t1=r(12786);let t2=(0,s.lazy)(()=>Promise.all([r.e(3888),r.e(1959)]).then(r.bind(r,71959)).then(e=>({default:e.XtermRenderer}))),t5={c:"\x03",d:"\x04",z:"\x1a",l:"\f",a:"\x01",e:"\x05",u:"\x15",w:"\x17"},t4=/\x1b\[[0-9;]*m/g;function t3({output:e,query:t,mode:r,currentIdx:o,matchListRef:a}){let l=(0,s.useRef)(null);l.current||(l.current=new tH.v,l.current.use_classes=!0);let i=e.split("\n"),d=t.toLowerCase(),c=0;return a.current=[],(0,n.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap break-words select-text",children:i.map((e,t)=>{let s=e.replace(t4,""),i=s.toLowerCase().includes(d);if("filter"===r&&!i)return null;if(!i){let r=l.current.ansi_to_html(e);return(0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:r}},t)}let u=[],m=0,x=s.toLowerCase(),h=0;for(;h<x.length;){let e=x.indexOf(d,h);if(-1===e)break;e>m&&u.push((0,n.jsx)("span",{children:s.slice(m,e)},`t${m}`));let t=c++,r=t===o;u.push((0,n.jsx)("mark",{ref:e=>{a.current[t]=e},className:r?"bg-brand/40 text-foreground":"bg-yellow-300/40 text-foreground",children:s.slice(e,e+d.length)},`m${e}`)),h=m=e+d.length}return m<s.length&&u.push((0,n.jsx)("span",{children:s.slice(m)},`t${m}`)),(0,n.jsx)("div",{children:u},t)})})}let t6=(0,s.memo)(function({commandId:e,tabId:t,projectCwd:r,command:a,output:l,exitCode:i,isRunning:d,selected:c,onSelect:m,onInterrupt:x,onStdin:h,onDelete:f,onRerun:p,timestamp:g,usePty:b,subscribePtyOutput:v,subscribePtyReset:j,subscribePtyRefresh:w,onPtyResize:k,onToggleMaximize:y,maximized:N,expandedHeight:C,bubbleContentHeight:S,onTitleMouseDown:L}){let{t:M}=(0,o.Bd)(),E=(0,s.useRef)(null),T=(0,s.useRef)(null),$=(0,s.useRef)(!0),R=(0,s.useRef)(null),B=(0,s.useRef)(null),F=(e=>{if(!e)return"";let t=new Date(e);if(isNaN(t.getTime()))return"";let r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${r}-${n} ${s}:${o}`})(g),I=e&&t?tW(t+e):void 0,[D,A]=(0,s.useState)(!1),[z,H]=(0,s.useState)(""),W=(0,s.useRef)(null),_=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!v||!e)return;let t=()=>W.current?v(e,W.current.write):null,r=t();if(r)return r;let n=setInterval(()=>{(r=t())&&clearInterval(n)},50);return()=>{clearInterval(n),r?.()}},[v,e]),(0,s.useEffect)(()=>{if(!j||!e)return;let t=()=>W.current?j(e,W.current.reset):null,r=t();if(r)return r;let n=setInterval(()=>{(r=t())&&clearInterval(n)},50);return()=>{clearInterval(n),r?.()}},[j,e]),(0,s.useEffect)(()=>{if(!w||!e)return;let t=()=>W.current?w(e,W.current.refresh):null,r=t();if(r)return r;let n=setInterval(()=>{(r=t())&&clearInterval(n)},50);return()=>{clearInterval(n),r?.()}},[w,e]);let[O,q]=(0,s.useState)(!1),[V,U]=(0,s.useState)(""),[K,G]=(0,s.useState)("search"),[J,Q]=(0,s.useState)(0),Z=(0,s.useRef)([]),X=(0,s.useRef)(null),Y=(0,s.useRef)(0);(0,s.useEffect)(()=>{X.current||(X.current=new tH.v,X.current.use_classes=!0)},[]),(0,s.useLayoutEffect)(()=>{let e=T.current;if(e&&X.current){if(l.length<Y.current&&(X.current=new tH.v,X.current.use_classes=!0,Y.current=0,e.innerHTML=""),l.length>Y.current){let t=l.slice(Y.current),r=X.current.ansi_to_html(t);Y.current=l.length,e.insertAdjacentHTML("beforeend",r)}if(E.current){let e=E.current.scrollHeight>E.current.clientHeight;A(e),e&&(E.current.scrollTop=E.current.scrollHeight)}}},[l]),(0,s.useEffect)(()=>(d&&$.current&&E.current&&(null!==R.current&&cancelAnimationFrame(R.current),R.current=requestAnimationFrame(()=>{E.current&&(E.current.scrollTop=E.current.scrollHeight),R.current=null})),()=>{null!==R.current&&cancelAnimationFrame(R.current)}),[l,d]),(0,s.useEffect)(()=>{if(!N)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),y?.())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[N,y]);let ee=l?l.split("\n").length:0,et=(0,s.useCallback)(()=>{q(!0),requestAnimationFrame(()=>_.current?.focus())},[]),er=(0,s.useCallback)(()=>{q(!1),U(""),Q(0),W.current?.clearSearch()},[]),en=(0,s.useCallback)(e=>{e.trim()&&(b?W.current?.findNext(e):Q(e=>{let t=e+1,r=Z.current[t];return r?(r.scrollIntoView({block:"nearest"}),t):(Z.current[0]?.scrollIntoView({block:"nearest"}),0)}))},[b]),es=(0,s.useCallback)(e=>{e.trim()&&(b?W.current?.findPrevious(e):Q(e=>{let t=e-1;if(t>=0)return Z.current[t]?.scrollIntoView({block:"nearest"}),t;let r=Z.current.length-1;return r>=0&&Z.current[r]?.scrollIntoView({block:"nearest"}),Math.max(r,0)}))},[b]);(0,s.useEffect)(()=>{if(!c)return;let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key){e.preventDefault(),e.stopPropagation(),et();return}if("Escape"===e.key&&O){e.preventDefault(),e.stopPropagation(),er();return}};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[c,O,et,er]);let el=N&&C?C-41:S??360;return(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-card text-foreground dark:text-slate-11 relative overflow-hidden border transition-colors cursor-pointer ${N?"rounded-none border-0":"rounded-2xl rounded-bl-md rounded-br-md"} ${N?"":c?"border-brand":"border-brand/30"}`,onClick:m,children:[N?(0,n.jsxs)("div",{onDoubleClick:()=>y?.(),className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41,flexShrink:0},children:[(0,n.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded bg-muted text-muted-foreground",children:">_"}),(0,n.jsx)("span",{className:"flex-1 text-xs text-muted-foreground truncate font-mono",children:a}),d&&(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse"}),M("console.runningText")]}),d&&x&&(0,n.jsx)("button",{onClick:x,className:"text-xs px-3 py-1 rounded-md font-medium bg-destructive text-destructive-foreground transition-all duration-150 hover:bg-destructive/80 hover:shadow-lv2 active:scale-95 active:bg-destructive/70 cursor-pointer select-none",children:"Ctrl+C"}),(0,n.jsx)("button",{onClick:()=>y?.(),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:M("console.restoreTooltip",{modKey:(0,t1.Mu)()}),children:(0,n.jsx)(ea.A,{className:"w-4 h-4"})})]}):(0,n.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>L?.(),onDoubleClick:e=>{e.stopPropagation(),y?.()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing ${c?"border-brand":"border-brand/30"}`,children:[(0,n.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:">_"}),I&&e&&t&&(0,n.jsx)(t0,{shortId:I,type:"terminal",onRegister:()=>{u.t4.runFork(tV("/api/terminal/register",{tabId:t,commandId:e,command:a,projectCwd:r}).pipe(ep.orElse(()=>ep.void)))},onUnregister:()=>{u.t4.runFork(tV("/api/terminal/unregister",{commandId:e}).pipe(ep.orElse(()=>ep.void)))},fullId:e,projectCwd:r,tabId:t}),(0,n.jsx)("span",{className:"font-mono text-foreground truncate",children:a}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(a),(0,P.oR)(M("toast.copiedCmd"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:M("console.copyCommand"),children:(0,n.jsx)(tF.A,{className:"w-3.5 h-3.5"})}),(0,n.jsx)("span",{className:"flex-1"}),D&&!d&&(0,n.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:M("console.totalLines",{count:ee})}),l&&(0,n.jsx)("button",{onClick:e=>{let t;e.stopPropagation(),t=l.replace(/\x1b\[[0-9;]*m/g,""),navigator.clipboard.writeText(t),(0,P.oR)(M("toast.copiedOutput"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:M("console.copyOutput"),children:(0,n.jsx)(tI.A,{className:"w-3.5 h-3.5"})}),p&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),p()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:M("console.rerun"),children:(0,n.jsx)(tD.A,{className:"w-3.5 h-3.5"})}),f&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),f()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:M("console.deleteRecord"),children:(0,n.jsx)(ea.A,{className:"w-3.5 h-3.5"})})]}),O&&(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card",style:{flexShrink:0},children:[(0,n.jsx)(eo.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,n.jsx)("input",{ref:_,value:V,onChange:e=>{let t=e.target.value;U(t),Q(0),b&&(t.trim()?W.current?.findNext(t):W.current?.clearSearch())},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?es(V):en(V))},placeholder:M("console.searchPlaceholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none",autoComplete:"off",spellCheck:"false"}),!b&&(0,n.jsxs)("div",{className:"flex items-center gap-0.5 text-xs flex-shrink-0",children:[(0,n.jsx)("button",{onClick:()=>G("search"),className:`px-1.5 py-0.5 rounded transition-colors ${"search"===K?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:M("console.searchMode")}),(0,n.jsx)("button",{onClick:()=>G("filter"),className:`px-1.5 py-0.5 rounded transition-colors ${"filter"===K?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:M("console.filterMode")})]}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:()=>es(V),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:M("console.prevShiftEnter"),children:(0,n.jsx)(tA.A,{className:"w-3.5 h-3.5"})}),(0,n.jsx)("button",{onClick:()=>en(V),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:M("console.nextEnter"),children:(0,n.jsx)(tz.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsx)("button",{onClick:er,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,n.jsx)(ea.A,{className:"w-3.5 h-3.5"})})]}),b?(0,n.jsxs)("div",{className:"relative group",style:{height:el,overflow:"hidden"},children:[(0,n.jsx)(s.Suspense,{fallback:(0,n.jsx)("div",{className:"px-4 py-2 text-xs text-muted-foreground",style:{height:el},children:M("console.loadingTerminal")}),children:(0,n.jsx)(t2,{ref:W,output:l,isRunning:d,onInput:h,onResize:k,maximized:N,height:el,directWrite:!!v})}),!d&&(0,n.jsx)("div",{className:"absolute inset-0 bg-background/50 pointer-events-none"}),!d&&p&&(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",onClick:e=>{e.stopPropagation(),p()},children:(0,n.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-tooltip text-tooltip-foreground text-xs",children:[(0,n.jsx)(tD.A,{className:"w-3.5 h-3.5"}),M("console.rerun")]})})]}):(0,n.jsx)("div",{ref:E,className:"overflow-auto px-4 py-2",style:{height:el},onScroll:()=>{if(E.current){let{scrollTop:e,scrollHeight:t,clientHeight:r}=E.current;$.current=t-e-r<50}},children:O&&V.trim()?(0,n.jsx)(t3,{output:l,query:V,mode:K,currentIdx:J,matchListRef:Z}):(0,n.jsx)("pre",{ref:T,className:"text-sm font-mono whitespace-pre-wrap break-words select-text"})}),d&&!N&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse flex-shrink-0"}),b?(0,n.jsx)("span",{className:"text-xs text-muted-foreground flex-1",children:M("console.clickToInput")}):h?(0,n.jsx)("input",{ref:B,value:z,onChange:e=>H(e.target.value),onKeyDown:e=>{if(e.ctrlKey&&!e.metaKey&&!e.altKey){let t=t5[e.key.toLowerCase()];if(t){e.preventDefault(),e.stopPropagation(),h(t);return}}"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),h(z+"\n"),H("")),"Tab"===e.key&&(e.preventDefault(),h(" "))},placeholder:M("console.stdinPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs font-mono text-foreground outline-none",autoComplete:"off",spellCheck:"false"}):(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:M("console.runningText")}),x&&(0,n.jsx)("button",{onClick:x,className:"flex-shrink-0 text-xs text-destructive hover:brightness-125 transition-colors cursor-pointer select-none",children:"Ctrl+C"}),F&&(0,n.jsx)("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:F})]}),!d&&void 0!==i&&!N&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${0===i?"bg-green-500":"bg-red-500"}`}),(0,n.jsx)("span",{children:M("console.exitCode",{code:i})}),(0,n.jsx)("span",{className:"flex-1"}),F&&(0,n.jsx)("span",{className:"text-[11px] flex-shrink-0",children:F})]})]})})}),t8=new Map;function t9(e){t8.set(e.type,e)}function t7(e){return t8.get(e)}function re(e){for(let t of t8.values())if(t.match(e))return t;return null}let rt=(e,t)=>ep.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`)},catch:t=>new eg.uV({message:`POST ${e} failed`,cause:t})}),rr=(e,t)=>u.t4.runPromise(rt(`/api/${e}/disconnect`,{id:t}).pipe(ep.orElse(()=>ep.void))),rn=e=>u.t4.runPromise(rt("/api/browser/unregister",{id:e}).pipe(ep.orElse(()=>ep.void))),rs=e=>u.t4.runPromise(e.pipe(ep.catchAll(e=>ep.sync(()=>{if(e.cause instanceof Error)throw e.cause;throw Error(e.message)})))),ro=(e,t)=>{if(e&&"object"==typeof e&&"error"in e){let t=e.error;if("string"==typeof t&&t.length>0)return t;if(t&&"object"==typeof t){let e=t.message;if("string"==typeof e&&e.length>0)return e;let r=t._tag;if("string"==typeof r&&r.length>0)return r}}return`HTTP ${t}`},ra=(e,t)=>rs(ep.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await r.json();if(!r.ok)throw Error(ro(n,r.status));return n},catch:t=>new eg.uV({message:`POST ${e} failed`,cause:t})})),rl=(e,t)=>rs(ep.tryPromise({try:async()=>{let r=new URLSearchParams(t),n=await fetch(`${e}?${r}`),s=await n.json();if(!n.ok)throw Error(ro(s,n.status));return s},catch:t=>new eg.uV({message:`GET ${e} failed`,cause:t})})),ri=(e,t)=>rs(ep.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`);return r.blob()},catch:t=>new eg.uV({message:`POST blob ${e} failed`,cause:t})}));var rd=r(53853);function rc(e){let t=e.trim().toLowerCase();return t.startsWith("http://")||t.startsWith("https://")}function ru(e){if(!e)return e;try{let t=new URL(e);return t.searchParams.set("_cockpit","1"),t.toString()}catch{let t=e.includes("?")?"&":"?";return`${e}${t}_cockpit=1`}}function rm(e){if(!e)return e;try{let t=new URL(e);return t.searchParams.delete("_cockpit"),t.toString()}catch{return e.replace(/[?&]_cockpit=1/,"")}}async function rx(e){let t=(0,rd.f)()?.id??null;return!!t&&new Promise(r=>{try{let n=globalThis.chrome?.runtime;if(!n?.sendMessage)return void r(!1);let s=setTimeout(()=>r(!1),2e3);n.sendMessage(t,{type:"prepare-iframe",url:e},e=>{clearTimeout(s),r(e?.ok??!1)})}catch{r(!1)}})}function rh(e){try{let t=new URL(e).hostname;return"localhost"===t||"127.0.0.1"===t}catch{return!1}}function rf({url:e,id:t,selected:r,maximized:a,expandedHeight:l,bubbleContentHeight:i,onSelect:u,onClose:m,onToggleMaximize:x,onNewTab:h,timestamp:f,onTitleMouseDown:p,initialSleeping:g,onSleep:b,onWake:v,projectCwd:j,baseCwd:w,tabId:k,autoConnect:y}){let{t:N,i18n:C}=(0,o.Bd)(),[S,L]=(0,s.useState)(!1),[M,E]=(0,s.useState)(null),[T,$]=(0,s.useState)(e),[R,B]=(0,s.useState)(null),[F,I]=(0,s.useState)(g??!1),D=(0,s.useRef)(null),A=(0,s.useRef)(null),z=(0,s.useRef)(null);(0,s.useEffect)(()=>{$(e)},[e]);let H=(0,s.useRef)(!0),W=(0,s.useCallback)(()=>{F||(I(!0),B(null),b?.(t))},[F,t,b]),_=(0,s.useCallback)(()=>{D.current&&(clearTimeout(D.current),D.current=null)},[]),{shortId:O,connected:q,connect:V,disconnect:U}=function(e,t,r,n,o){let a=(0,s.useMemo)(()=>tW(e),[e]),[l,i]=(0,s.useState)(!1),u=(0,s.useRef)(null),m=(0,s.useRef)([]),x=(0,s.useRef)(null),h=(0,s.useRef)(!1),f=(0,s.useRef)(r);(0,s.useEffect)(()=>{f.current=r});let p=(0,s.useRef)([]);(0,s.useEffect)(()=>{let e=e=>{if(e.data?.type==="cockpit:cmd-result"){let{reqId:t,ok:r,data:n,error:s}=e.data,o=u.current;o&&o.readyState===WebSocket.OPEN&&o.send(JSON.stringify({type:"browser:cmd-result",reqId:t,ok:r,data:n,error:s}));return}if(e.data?.type==="cockpit:prepare-screenshot"){let r=t.current;if(!r?.contentWindow)return;let n=new URLSearchParams(window.location.search).get("cwd")||"";window.dispatchEvent(new CustomEvent("cockpit-screenshot-state",{detail:{active:!0}})),(0,d.F)(c.n.ScreenshotPrepare,{cwd:n}),requestAnimationFrame(()=>requestAnimationFrame(()=>requestAnimationFrame(()=>{setTimeout(()=>{let t=r.getBoundingClientRect(),n=window.devicePixelRatio||1,s=t.x,o=t.y;try{let e=window;for(;e!==e.top;){let t=e.frameElement;if(t){let e=t.getBoundingClientRect();s+=e.x,o+=e.y}e=e.parent}}catch{}r.contentWindow?.postMessage({type:"cockpit:screenshot-bounds",reqId:e.data.reqId,bounds:{x:Math.round(s*n),y:Math.round(o*n),width:Math.round(t.width*n),height:Math.round(t.height*n),dpr:n}},"*")},150)})));return}if(e.data?.type==="cockpit:screenshot-done"){window.dispatchEvent(new CustomEvent("cockpit-screenshot-state",{detail:{active:!1}})),(0,d.F)(c.n.ScreenshotDone,{});return}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[]);let g=(0,s.useCallback)(e=>{let r=t.current;if(!r?.contentWindow){let t=u.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify({type:"browser:cmd-result",reqId:e.reqId,ok:!1,error:"iframe not available (page may be sleeping)"}));return}r.contentWindow.postMessage({type:"cockpit:cmd",reqId:e.reqId,action:e.action,params:e.params},"*")},[t]);(0,s.useEffect)(()=>{if(!l)return;let r=!1;return h.current=!0,!function s(){if(r||!h.current)return;let a="https:"===window.location.protocol?"wss:":"ws:",l=new URLSearchParams({fullId:e});n&&l.set("projectCwd",n),o&&l.set("tabId",o);let i=new WebSocket(`${a}//${window.location.host}/ws/browser?${l.toString()}`);u.current=i,i.onopen=()=>{for(let e of p.current)e();if(p.current=[],m.current.length>0){for(let e of m.current)g(e);m.current=[]}},i.onmessage=e=>{let r;try{r=JSON.parse(e.data)}catch{return}if("browser:cmd"===r.type){let e=r;t.current?.contentWindow&&f.current?g(e):m.current.push(e)}},i.onclose=()=>{u.current=null,!r&&h.current&&(x.current=setTimeout(s,3e3))},i.onerror=()=>i.close()}(),()=>{r=!0,h.current=!1,x.current&&clearTimeout(x.current),u.current&&(u.current.close(),u.current=null),p.current=[]}},[l,e,t,g,n,o]),(0,s.useEffect)(()=>{if(r&&m.current.length>0){for(let e of m.current)g(e);m.current=[]}},[r,g]);let b=(0,s.useCallback)(()=>l&&u.current?.readyState===WebSocket.OPEN?Promise.resolve():new Promise(e=>{p.current.push(e),l||i(!0)}),[l]);return{shortId:a,connected:l,connect:b,disconnect:(0,s.useCallback)(()=>{i(!1)},[])}}(t,z,!!R&&!F&&!S,j,k),K=(0,s.useRef)(q);K.current=q;let G=(0,s.useRef)(!1);(0,s.useEffect)(()=>{y&&!G.current&&(G.current=!0,V())},[y,V]),(0,s.useEffect)(()=>{let e=A.current;if(!e||F)return;let t=new IntersectionObserver(([e])=>{H.current=e.isIntersecting,e.isIntersecting||K.current?_():(D.current&&clearTimeout(D.current),D.current=setTimeout(W,3e5))});return t.observe(e),()=>t.disconnect()},[F,W,_]),(0,s.useEffect)(()=>{F?U():q?_():H.current||(D.current&&clearTimeout(D.current),D.current=setTimeout(W,3e5))},[q,F,U,_,W]),(0,s.useEffect)(()=>{g&&B(null)},[]);let Q=(0,s.useCallback)(()=>{if(I(!1),v?.(t),!rc(e))return void B((0,J.Kx)(e)?(0,J.hE)(e,w):(0,J.Xe)(e,w));let r=ru(e);rh(e)?B(r):rx(e).then(()=>B(r))},[e,t,v,w]);(0,s.useEffect)(()=>{if(!e||F){e||B(null);return}if(!rc(e))return void B((0,J.Kx)(e)?(0,J.hE)(e,w):(0,J.Xe)(e,w));let t=ru(e);if(rh(e))return void B(t);let r=!1;return rx(e).then(()=>{r||B(t)}),()=>{r=!0}},[e,F,w]);let Z=(0,s.useCallback)(()=>{L(!1);let e=z.current?.contentWindow;if(!e)return;let t=document.documentElement.classList.contains("dark");e.postMessage({type:"THEME_CHANGE",theme:t?"dark":"light"},"*"),e.postMessage({type:"cockpit:language-change",lang:C.language},"*")},[C]);(0,s.useEffect)(()=>{let e=A.current;if(!e)return;let t=null,r=e.parentElement;for(;r;){let{overflowY:e}=getComputedStyle(r);if("auto"===e||"scroll"===e){t=r;break}r=r.parentElement}if(!t)return;let n="",s=0,o=!1,a=()=>{o&&t&&(t.scrollTop=s)},l=()=>{n=t.style.overflow,s=t.scrollTop,o=!0,t.style.overflow="hidden",t.addEventListener("scroll",a)},i=()=>{o=!1,t.removeEventListener("scroll",a),t.style.overflow=n};return e.addEventListener("mouseenter",l),e.addEventListener("mouseleave",i),()=>{e.removeEventListener("mouseenter",l),e.removeEventListener("mouseleave",i),t.removeEventListener("scroll",a),o&&(t.style.overflow=n)}},[]),(0,s.useEffect)(()=>{let e=e=>{if(!e.data||"string"!=typeof e.data.type||!e.data.type.startsWith("cockpit:"))return;let r=A.current?.querySelector("iframe");if(!r||e.source!==r.contentWindow)return;let n=e.data.type;"cockpit:new-tab"===n&&e.data.url?h?.(rm(e.data.url),t):("cockpit:navigate"===n||"cockpit:loaded"===n)&&e.data.url&&$(rm(e.data.url))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[t,h]);let X=(0,s.useCallback)(()=>{L(!1),E(N("browser.pageLoadFailed"))},[]),Y=(0,s.useCallback)(()=>{if(F)return void Q();let e=A.current?.querySelector("iframe");if(e&&R){L(!0),E(null);let t=e.src;e.src="",setTimeout(()=>{e.src=t},0)}},[F,Q,R]);(0,s.useEffect)(()=>{e&&!F&&(L(!0),E(null))},[e,F]);let ee=(0,s.useCallback)(()=>{if(!T)return;let e=rc(T)?T:(0,J.Kx)(T)?(0,J.hE)(T,w):(0,J.Xe)(T,w);window.open((0,J.PB)(e,window.location.origin),"_blank")},[T,w]);(0,s.useEffect)(()=>{if(!r&&!a)return;let e=e=>{"Escape"===e.key&&a&&(e.stopPropagation(),x()),"m"===e.key&&(e.metaKey||e.ctrlKey)&&r&&(e.preventDefault(),e.stopPropagation(),x())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[a,r,x]);let et=function(e){if(!e)return"";try{let t=new URL(e);return t.port?`${t.hostname}:${t.port}`:t.hostname}catch{return e.split("/").pop()||e}}(T),er=a&&l?l-41:i??360;return(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
7
|
+
relative transition-colors cursor-pointer
|
|
8
|
+
${a?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
9
|
+
${a?"":r?"border-brand":"border-brand/30"}`,onClick:a?void 0:u,children:[a?(0,n.jsxs)("div",{onDoubleClick:x,className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41},children:[(0,n.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})})}),O&&(0,n.jsx)(t0,{shortId:O,type:"browser",registered:q,onRegister:()=>V(),onUnregister:async()=>{U(),await rn(O)},fullId:t,projectCwd:j,tabId:k}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground truncate font-mono",children:T||N("browser.blankPage")}),T&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(T),(0,P.oR)(N("toast.copiedUrl"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("browser.copyUrl"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,n.jsx)("span",{className:"flex-1"}),S&&(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),(0,n.jsx)("button",{onClick:Y,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("common.refresh"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,n.jsx)("button",{onClick:ee,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("browser.openInNewWindow"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),(0,n.jsx)("button",{onClick:x,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("browser.exitMaximize",{modKey:(0,t1.Mu)()}),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})})})]}):(0,n.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>p?.(),onDoubleClick:e=>{e.stopPropagation(),x()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing
|
|
10
|
+
${r?"border-brand":"border-brand/30"}`,children:[(0,n.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:(0,n.jsx)("svg",{className:"w-3 h-3 inline-block",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})})}),O&&(0,n.jsx)(t0,{shortId:O,type:"browser",registered:q,onRegister:()=>V(),onUnregister:async()=>{U(),await rn(O)},fullId:t,projectCwd:j,tabId:k}),(0,n.jsx)("span",{className:"font-mono text-foreground truncate",children:T||N("browser.blankPage")}),T&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(T),(0,P.oR)(N("toast.copiedUrl"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("browser.copyUrl"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,n.jsx)("span",{className:"flex-1"}),S&&(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),ee()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("browser.openInNewWindow"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),Y()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:N("common.refresh"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),m()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:N("common.close"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("div",{ref:A,className:"w-full",style:{height:er},children:F?(0,n.jsxs)("div",{className:"relative overflow-hidden cursor-pointer group h-full",onClick:e=>{e.stopPropagation(),Y()},children:[(0,n.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-muted/30",children:[(0,n.jsx)("svg",{className:"w-10 h-10 mb-2 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground/60",children:et})]}),(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:(0,n.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-black/60 text-white text-xs",children:[(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),N("browser.clickToWake")]})})]}):e?M?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center text-muted-foreground p-6 h-full",children:[(0,n.jsx)("svg",{className:"w-10 h-10 mb-3 text-red-11",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,n.jsx)("p",{className:"text-xs",children:M}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),Y()},className:"mt-2 px-3 py-1 text-xs bg-secondary text-foreground rounded hover:bg-hover transition-colors",children:N("common.retry")})]}):(0,n.jsxs)("div",{className:"relative overflow-hidden h-full",style:{contain:"strict"},children:[S&&(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-card/80 z-10",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),R?(0,n.jsx)("iframe",{ref:z,src:R,className:"border-0 bg-white",allow:"clipboard-write; clipboard-read",style:a?{width:"100%",height:"100%"}:{position:"absolute",top:0,left:0,width:"200%",height:"200%",transform:"scale(0.5)",transformOrigin:"top left"},onLoad:Z,onError:X,title:`Browser: ${et}`,"data-browser-id":t}):(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})})]}):(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center text-muted-foreground h-full",children:[(0,n.jsx)("svg",{className:"w-10 h-10 mb-2 text-foreground-faint",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),(0,n.jsx)("p",{className:"text-xs",children:N("browser.blankPage")})]})}),!a&&e&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${F?"bg-yellow-500":S?"bg-brand animate-pulse":M?"bg-red-500":"bg-green-500"}`}),(0,n.jsx)("span",{className:"truncate",children:F?N("browser.sleeping"):S?N("browser.loadingPage"):M?N("browser.loadFailed"):et}),(0,n.jsx)("span",{className:"flex-1"}),f&&(0,n.jsx)("span",{className:"text-[11px] flex-shrink-0",children:function(e){if(!e)return"";let t=new Date(e);if(isNaN(t.getTime()))return"";let r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${r}-${n} ${s}:${o}`}(f)})]})]})})}t9({type:"browser",idPrefix:"browser",match(e){let t=e.trim().toLowerCase();return!!(t.startsWith("http://")||t.startsWith("https://"))||t.endsWith(".html")||t.endsWith(".htm")||(0,J.Kx)(t)},parse:e=>({url:e.trim(),cwd:""}),fromHistory:e=>({url:e.url,cwd:e.cwd??"",autoConnect:!!e.autoConnect}),toHistory:e=>({url:e.url,cwd:e.cwd??"",...e.autoConnect?{autoConnect:!0}:{}}),Component:function({item:e,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:a,onSelect:l,onClose:i,onToggleMaximize:d,onTitleMouseDown:c,extra:u}){return(0,n.jsx)(rf,{id:e.id,url:e.url,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:a,onSelect:l,onClose:i,onToggleMaximize:d,onTitleMouseDown:c,onNewTab:u?.addBrowserItem,initialSleeping:u?.initialSleeping,onSleep:u?.onSleep,onWake:u?.onWake,projectCwd:u?.projectCwd,baseCwd:e.cwd||u?.projectCwd,tabId:u?.tabId,autoConnect:e.autoConnect})}});let rp=[{value:"=",label:"="},{value:"!=",label:"≠"},{value:">",label:">"},{value:"<",label:"<"},{value:">=",label:"≥"},{value:"<=",label:"≤"},{value:"LIKE",label:"LIKE"},{value:"NOT LIKE",label:"NOT LIKE"},{value:"IN",label:"IN"},{value:"IS NULL",label:"IS NULL"},{value:"IS NOT NULL",label:"IS NOT NULL"}];function rg(e){if(!e)return"";let t=new Date(e);if(isNaN(t.getTime()))return"";let r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${r}-${n} ${s}:${o}`}function rb(e){return`"${e.replace(/"/g,'""')}"`}function rv(e){return null==e?"":"object"==typeof e?JSON.stringify(e):String(e)}function rj({text:e}){let[t,r]=(0,s.useState)(!1),[o,a]=(0,s.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),l=(0,s.useRef)(null),i=(0,s.useRef)(null),d=(0,s.useRef)(!1),c=(0,g.F2)(),u=(0,s.useCallback)(()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{d.current||r(!1)},80)},[]),m=(0,s.useCallback)(()=>{i.current&&clearTimeout(i.current),d.current=!1,i.current=setTimeout(()=>{let e=l.current;if(!e||e.scrollWidth<=e.clientWidth)return;let t=e.getBoundingClientRect(),n=c?.getBoundingClientRect(),s=n?.left??0,o=n?.top??0,i=n?.width??window.innerWidth,d=n?.height??window.innerHeight,u=t.left-s,m=t.top-o,x=t.bottom-o,h=Math.min(600,i-u-8),f=m-8,p=d-x-8,g=f>p&&f>80,b=g?f-4:p-4;a({x:h<200?Math.max(8,i-600-8):u,y:g?m-4:x+4,maxW:h<200?Math.min(600,i-16):h,maxH:Math.max(60,b),above:g}),r(!0)},350)},[c]),x=(0,s.useCallback)(()=>{u()},[u]),h=(0,s.useCallback)(()=>{d.current=!0,i.current&&clearTimeout(i.current)},[]),f=(0,s.useCallback)(()=>{d.current=!1,u()},[u]);return(0,n.jsxs)("span",{ref:l,className:"block truncate",onMouseEnter:m,onMouseLeave:x,children:[e,t&&(0,n.jsx)(g.ZL,{children:(0,n.jsx)("div",{className:"fixed z-[9999] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lv2 whitespace-pre-wrap break-all select-text cursor-text",style:{left:o.x,top:o.y,maxWidth:o.maxW,maxHeight:o.maxH,transform:o.above?"translateY(-100%)":void 0},onMouseEnter:h,onMouseLeave:f,children:function(e){try{let t=JSON.parse(e);if("object"==typeof t&&null!==t)return JSON.stringify(t,null,2)}catch{}return e}(e)})})]})}function rw({id:e,connectionString:t,displayName:r,selected:a,maximized:l,expandedHeight:i,bubbleContentHeight:d,onSelect:c,onClose:u,onToggleMaximize:m,timestamp:x,onTitleMouseDown:h}){let{t:f}=(0,o.Bd)(),{showToast:p}=(0,P.dj)(),[g,b]=(0,s.useState)("connecting"),[v,j]=(0,s.useState)(""),[w,k]=(0,s.useState)([]),[y,N]=(0,s.useState)("public"),[C,S]=(0,s.useState)([]),[L,M]=(0,s.useState)(null),[E,T]=(0,s.useState)("table"),[$,R]=(0,s.useState)("data"),[B,F]=(0,s.useState)([]),[I,D]=(0,s.useState)([]),[A,z]=(0,s.useState)([]),[H,W]=(0,s.useState)([]),[_,O]=(0,s.useState)(null),[q,V]=(0,s.useState)(0),[U,K]=(0,s.useState)(!1),[G,J]=(0,s.useState)(0),[Q,Z]=(0,s.useState)(new Set),[X,Y]=(0,s.useState)(!1),[ee,et]=(0,s.useState)(null),[er,en]=(0,s.useState)({}),[es,eo]=(0,s.useState)(!1),[ea,el]=(0,s.useState)({}),[ei,ed]=(0,s.useState)({}),[ec,eu]=(0,s.useState)(null),[em,ex]=(0,s.useState)(""),[eh,ef]=(0,s.useState)(null),[ep,eg]=(0,s.useState)(""),[eb,ev]=(0,s.useState)(!1),ej=(0,s.useRef)(null),ew=(0,s.useCallback)(async()=>{b("connecting"),j("");try{let r=await ra("/api/db/connect",{id:e,connectionString:t});k(r.schemas||[]),r.schemas?.length>0&&!r.schemas.includes("public")&&N(r.schemas[0]),b("connected")}catch(e){j(e instanceof Error?e.message:String(e)),b("error")}},[e,t]);(0,s.useEffect)(()=>{ew()},[ew]);let ek=(0,s.useCallback)(async()=>{if("connected"===g)try{let r=await rl("/api/db/schemas",{id:e,connectionString:t,schema:y});S(r.tables||[])}catch{}},[e,t,y,g]);(0,s.useEffect)(()=>{ek()},[ek]);let ey=(0,s.useCallback)(async(r,n,s,o)=>{K(!0);let a=s??ei,l=void 0!==o?o:ec;try{let s=`${rb(y)}.${rb(r)}`,{where:o,params:i}=function(e){let t=[],r=[],n=1;for(let[s,o]of Object.entries(e)){if(!o.enabled)continue;let e=rb(s);if("IS NULL"===o.op)t.push(`${e} IS NULL`);else if("IS NOT NULL"===o.op)t.push(`${e} IS NOT NULL`);else if("IN"===o.op){let s=o.value.split(",").map(e=>e.trim()).filter(Boolean);if(0===s.length)continue;let a=s.map(e=>(r.push(e),`$${n++}`));t.push(`${e}::text IN (${a.join(", ")})`)}else"LIKE"===o.op||o.op,t.push(`${e}::text ${o.op} $${n++}`),r.push(o.value)}return{where:t.length>0?` WHERE ${t.join(" AND ")}`:"",params:r}}(a),d=l?` ORDER BY ${rb(l.column)} ${l.dir}`:"",c=`SELECT * FROM ${s}${o}${d} LIMIT 50 OFFSET ${50*n}`,u=await ra("/api/db/query",{id:e,connectionString:t,sql:c,params:i});O(u);let m=`SELECT count(*)::int AS cnt FROM ${s}${o}`,x=await ra("/api/db/query",{id:e,connectionString:t,sql:m,params:i});J(x.rows?.[0]?.cnt??0)}catch{}K(!1)},[e,t,y,ei,ec]),eN=(0,s.useCallback)(async r=>{M(r),V(0),et(null),eo(!1),Z(new Set),Y(!1),ed({}),eu(null);try{let n=await rl("/api/db/columns",{id:e,connectionString:t,schema:y,table:r});F(n.columns||[]),D(n.primaryKeys||[]),z(n.foreignKeys||[]),W(n.indexes||[])}catch{}ey(r,0,{},null)},[e,t,y,ey]),eC=(0,s.useCallback)(async()=>{if(em.trim()){ev(!0),eg(""),ef(null);try{let r=await ra("/api/db/query",{id:e,connectionString:t,sql:em});ef(r)}catch(e){eg(e instanceof Error?e.message:String(e))}ev(!1)}},[e,t,em]),eS=(0,s.useCallback)(async()=>{if(null===ee||!_||!L)return;let r=_.rows[ee],n=[],s=[],o=1;for(let e of B)void 0!==er[e.name]&&er[e.name]!==rv(r[e.name]??"")&&(n.push(`${rb(e.name)} = $${o}`),s.push(""===er[e.name]&&e.nullable?null:er[e.name]),o++);if(0===n.length)return void et(null);let a=I.length>0?I:B.map(e=>e.name),l=[];for(let e of a)null===r[e]||void 0===r[e]?l.push(`${rb(e)} IS NULL`):(l.push(`${rb(e)} = $${o}`),s.push(r[e]),o++);let i=`UPDATE ${rb(y)}.${rb(L)} SET ${n.join(", ")} WHERE ${l.join(" AND ")}`;try{await ra("/api/db/query",{id:e,connectionString:t,sql:i,params:s}),et(null),ey(L,q,ei,ec)}catch(e){alert(`Update failed: ${e instanceof Error?e.message:String(e)}`)}},[ee,_,L,B,I,er,e,t,y,ey,q,ei,ec]),eL=(0,s.useCallback)(async()=>{if(!L)return;let r=[],n=[],s=[],o=1;for(let e of B)void 0!==ea[e.name]&&""!==ea[e.name]&&(r.push(rb(e.name)),n.push(ea[e.name]),s.push(`$${o}`),o++);if(0===r.length)return;let a=`INSERT INTO ${rb(y)}.${rb(L)} (${r.join(", ")}) VALUES (${s.join(", ")})`;try{await ra("/api/db/query",{id:e,connectionString:t,sql:a,params:n}),eo(!1),el({}),ey(L,q,ei,ec)}catch(e){alert(`Insert failed: ${e instanceof Error?e.message:String(e)}`)}},[L,B,ea,e,t,y,ey,q,ei,ec]),eM=(0,s.useCallback)(async()=>{if(0===Q.size||!_||!L)return;let r=I.length>0?I:B.map(e=>e.name),n=0;for(let s of Array.from(Q).sort((e,t)=>t-e)){let o=_.rows[s];if(!o)continue;let a=[],l=[],i=1;for(let e of r)null===o[e]||void 0===o[e]?a.push(`${rb(e)} IS NULL`):(a.push(`${rb(e)} = $${i}`),l.push(o[e]),i++);let d=`DELETE FROM ${rb(y)}.${rb(L)} WHERE ctid = (SELECT ctid FROM ${rb(y)}.${rb(L)} WHERE ${a.join(" AND ")} LIMIT 1)`;try{await ra("/api/db/query",{id:e,connectionString:t,sql:d,params:l})}catch{n++}}Z(new Set),Y(!1),ey(L,q,ei,ec),n>0&&alert(f("database.deleteRowsFailed",{count:n}))},[Q,_,L,I,B,e,t,y,ey,q,ei,ec]),eE=(0,s.useCallback)(async r=>{if(!L)return;if(Q.size>0&&_){let e,t=_.fields.map(e=>e.name),n=Array.from(Q).sort((e,t)=>e-t).map(e=>_.rows[e]).filter(Boolean);if("json"===r)e=JSON.stringify(n,null,2);else{let r=[t.join(",")];for(let e of n)r.push(t.map(t=>{let r=e[t];if(null==r)return"";let n="object"==typeof r?JSON.stringify(r):String(r);return n.includes(",")||n.includes('"')||n.includes("\n")?`"${n.replace(/"/g,'""')}"`:n}).join(","));e=r.join("\n")}navigator.clipboard.writeText(e);return}let n=`SELECT * FROM ${rb(y)}.${rb(L)}`;try{let s=await ri("/api/db/export",{id:e,connectionString:t,sql:n,format:r}),o=URL.createObjectURL(s),a=document.createElement("a");a.href=o,a.download=`${L}.${r}`,a.click(),URL.revokeObjectURL(o)}catch(e){alert(`Export failed: ${e instanceof Error?e.message:String(e)}`)}},[L,e,t,y,Q,_]),eP=(0,s.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),eC())},[eC]),eT=Math.max(1,Math.ceil(G/50)),e$=(0,s.useCallback)(e=>{L&&(V(e),ey(L,e,ei,ec))},[L,ey,ei,ec]),eR=(0,s.useCallback)((e,t)=>{let r={...ei};t?r[e]=t:delete r[e],ed(r),V(0),Z(new Set),L&&ey(L,0,r,ec)},[ei,ec,L,ey]),eB=(0,s.useCallback)(()=>{ed({}),V(0),Z(new Set),L&&ey(L,0,{},ec)},[ec,L,ey]),eF=(0,s.useCallback)(e=>{eu(e),V(0),Z(new Set),L&&ey(L,0,ei,e)},[ei,L,ey]);return(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
11
|
+
relative transition-colors cursor-pointer
|
|
12
|
+
${l?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
13
|
+
${l?"":a?"border-brand":"border-brand/30"}`,onClick:l?void 0:c,children:[(0,n.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:m,onMouseDown:h,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${l?"bg-card":"bg-card/50"}`,style:l?{height:41}:void 0,children:[(0,n.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDC18"}),(0,n.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:r}),"connecting"===g&&(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===g&&(0,n.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:f("database.connectionFailed")}),"connected"===g&&(0,n.jsx)("span",{className:"text-[10px] text-green-11 flex-shrink-0",children:f("database.connected")}),(0,n.jsx)("span",{className:"flex-1"}),x&&(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:rg(x)}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),m()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:l?f("browser.exitMaximize",{modKey:(0,t1.Mu)()}):f("browser.maximize",{modKey:(0,t1.Mu)()}),children:l?(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),u()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:f("common.close"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsxs)("div",{style:{height:l&&i?i-41:d??360},className:"flex overflow-hidden",children:["connecting"===g&&(0,n.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),f("database.connecting")]}),"error"===g&&(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,n.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:v}),(0,n.jsx)("button",{onClick:ew,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:f("common.retry")})]}),"connected"===g&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[w.length>1?(0,n.jsx)("select",{value:y,onChange:e=>{N(e.target.value),M(null)},className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1",children:w.map(e=>(0,n.jsx)("option",{value:e,children:e},e))}):(0,n.jsx)("span",{className:"flex-1 min-w-0 text-xs text-muted-foreground truncate",children:y}),(0,n.jsx)("button",{onClick:ek,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-hover active:bg-active transition-colors",title:f("database.refreshTableList"),children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M1 1v5h5"}),(0,n.jsx)("path",{d:"M15 15v-5h-5"}),(0,n.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,n.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,n.jsx)("div",{className:"flex items-center border-b border-border",children:["table","view"].map(e=>(0,n.jsx)("button",{onClick:()=>T(e),className:`flex-1 py-1 text-[10px] font-medium transition-colors ${E===e?"text-brand border-b border-brand":"text-muted-foreground hover:text-foreground"}`,children:{table:f("database.filterTable"),view:f("database.filterView")}[e]},e))}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[C.filter(e=>"table"===E?"view"!==e.type:"view"===e.type).map(e=>(0,n.jsxs)("div",{onClick:()=>eN(e.name),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer truncate transition-colors ${L===e.name?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,n.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground",children:"view"===e.type?"V":"T"}),(0,n.jsx)("span",{className:"truncate min-w-0 flex-1",children:(0,n.jsx)(rj,{text:e.name})}),(0,n.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:e.rowEstimate>0?`~${e.rowEstimate}`:""})]},e.name)),0===C.length&&(0,n.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:f("database.noTables")})]})]}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["structure","data","sql"].map(e=>(0,n.jsx)("button",{onClick:()=>R(e),className:`px-3 py-1.5 text-xs transition-colors ${$===e?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{structure:f("database.tabStructure"),data:f("database.tabData"),sql:"SQL"}[e]},e)),L&&"data"===$&&(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[Object.values(ei).some(e=>e.enabled)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-[10px] text-brand",children:f("database.filterActive",{count:Object.values(ei).filter(e=>e.enabled).length})}),(0,n.jsx)("button",{onClick:eB,className:"px-1 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",title:f("database.clearAllFilters"),children:"✕"}),(0,n.jsx)("span",{className:"text-border",children:"|"})]}),Q.size>0&&!X&&(0,n.jsx)("button",{onClick:()=>Y(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:f("database.deleteNRows",{count:Q.size})}),X&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-[10px] text-destructive",children:f("database.confirmDeleteRows")}),(0,n.jsx)("button",{onClick:eM,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:f("common.confirm")}),(0,n.jsx)("button",{onClick:()=>Y(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:f("common.cancel")})]}),(0,n.jsx)("button",{onClick:()=>eE("csv"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:Q.size>0?f("database.copyCsvSelected"):f("database.copyCsvAll"),children:Q.size>0?f("database.copyCSV"):f("database.CSV")}),(0,n.jsx)("button",{onClick:()=>eE("json"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:Q.size>0?f("database.copyJsonSelected"):f("database.copyJsonAll"),children:Q.size>0?f("database.copyJSON"):f("database.JSON")})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:L||"sql"===$?"structure"===$?(0,n.jsx)(rk,{columns:B,primaryKeys:I,foreignKeys:A,indexes:H}):"data"===$?(0,n.jsx)(rN,{result:_,loading:U,columns:B,page:q,totalPages:eT,totalRows:G,onPageChange:e$,filters:ei,sort:ec,onFilterChange:eR,onSortChange:eF,selectedRows:Q,onSelectedRowsChange:e=>{Z(e),Y(!1)},editingRowIdx:ee,editValues:er,onStartEdit:e=>{if(!_)return;let t=_.rows[e],r={};for(let e of B)r[e.name]=null==t[e.name]?"":rv(t[e.name]);en(r),et(e)},onEditChange:(e,t)=>en(r=>({...r,[e]:t})),onSaveEdit:eS,onCancelEdit:()=>et(null),isAddingRow:es,newRowValues:ea,onStartAdd:()=>{eo(!0),el({})},onNewRowChange:(e,t)=>el(r=>({...r,[e]:t})),onSaveNewRow:eL,onCancelAdd:()=>{eo(!1),el({})},onCellCopy:e=>{navigator.clipboard.writeText(e),p(f("common.copied"))}}):(0,n.jsx)(rC,{sqlInput:em,onSqlChange:ex,onExecute:eC,onKeyDown:eP,result:eh,error:ep,loading:eb,sqlRef:ej,onCellCopy:e=>{navigator.clipboard.writeText(e),p(f("common.copied"))}}):(0,n.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:f("database.selectTable")})})]})]})]}),!l&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===g?"bg-green-500":"error"===g?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,n.jsx)("span",{children:{connecting:f("common.connecting"),connected:f("common.connected"),error:f("common.connectionFailed")}[g]}),"connected"===g&&L&&(0,n.jsx)("span",{className:"text-muted-foreground/70",children:L}),(0,n.jsx)("span",{className:"flex-1"}),x&&(0,n.jsx)("span",{className:"text-[11px] flex-shrink-0",children:rg(x)})]})]})})}function rk({columns:e,primaryKeys:t,foreignKeys:r,indexes:s}){let{t:a}=(0,o.Bd)();return 0===e.length?(0,n.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:a("database.selectTableToView")}):(0,n.jsxs)("div",{className:"p-2 space-y-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:a("database.columns")}),(0,n.jsxs)("table",{className:"w-full text-xs",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border",children:[(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:a("database.colName")}),(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:a("database.colType")}),(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:a("database.colNullable")}),(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:a("database.colDefault")})]})}),(0,n.jsx)("tbody",{children:e.map(e=>(0,n.jsxs)("tr",{className:"border-b border-border/50 hover:bg-hover",children:[(0,n.jsxs)("td",{className:"px-1.5 py-1 font-mono",children:[e.isPrimaryKey&&(0,n.jsx)("span",{className:"text-amber-11 mr-1",title:a("database.primaryKey"),children:"\uD83D\uDD11"}),e.name]}),(0,n.jsxs)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono",children:[e.type,e.maxLength?`(${e.maxLength})`:""]}),(0,n.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground",children:e.nullable?"YES":"NO"}),(0,n.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono truncate max-w-[120px]",children:e.default||""})]},e.name))})]})]}),r.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:a("database.foreignKeys")}),(0,n.jsx)("div",{className:"space-y-0.5",children:r.map((e,t)=>(0,n.jsxs)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground",children:[e.column," → ",e.refSchema,".",e.refTable,".",e.refColumn]},t))})]}),s.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:a("database.indexes")}),(0,n.jsx)("div",{className:"space-y-0.5",children:s.map(e=>(0,n.jsx)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground truncate","data-tooltip":e.definition,children:e.name},e.name))})]})]})}function ry({filter:e,onApply:t,onClear:r,onToggle:a,onClose:l,colName:i,anchorRect:d}){let{t:c}=(0,o.Bd)(),[u,m]=(0,s.useState)(e?.op||"="),[x,h]=(0,s.useState)(e?.value||""),f=(0,s.useRef)(null),p=(0,g.F2)();(0,s.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&l()};return document.addEventListener("mousedown",e,!0),()=>document.removeEventListener("mousedown",e,!0)},[l]);let b="IS NULL"!==u&&"IS NOT NULL"!==u,v=()=>{(!b||x.trim())&&t({op:u,value:x.trim(),enabled:!0})},j=p?.getBoundingClientRect(),w=j?.left??0,k=j?.top??0,y=j?.width??window.innerWidth,N=d.left-w;N+220>y-8&&(N=y-220-8),N<8&&(N=8);let C=d.bottom+2-k;return(0,n.jsx)(g.ZL,{children:(0,n.jsxs)("div",{ref:f,className:"fixed z-[9998] w-[220px] bg-popover border border-border rounded-md shadow-lv2 p-2 space-y-2",style:{left:N,top:C},onClick:e=>e.stopPropagation(),children:[e&&(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:e.enabled,onChange:e=>a(e.target.checked),className:"w-3 h-3 accent-brand"}),c("database.enable")]}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono truncate max-w-[120px]",children:i})]}),(0,n.jsx)("select",{value:u,onChange:e=>m(e.target.value),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-ring",children:rp.map(e=>(0,n.jsx)("option",{value:e.value,children:e.label},e.value))}),b&&(0,n.jsx)("input",{type:"text",value:x,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),v())},placeholder:c("IN"===u?"database.commaValues":"LIKE"===u?"database.likePattern":"database.valuePlaceholder"),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("button",{onClick:v,disabled:b&&!x.trim(),className:"flex-1 px-2 py-1 text-[10px] bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-40 transition-colors",children:c("database.apply")}),e&&(0,n.jsx)("button",{onClick:r,className:"flex-1 px-2 py-1 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground transition-colors",children:c("database.clearFilter")})]})]})})}function rN({result:e,loading:t,columns:r,page:a,totalPages:l,totalRows:i,onPageChange:d,filters:c,sort:u,onFilterChange:m,onSortChange:x,selectedRows:h,onSelectedRowsChange:f,editingRowIdx:p,editValues:g,onStartEdit:b,onEditChange:v,onSaveEdit:j,onCancelEdit:w,isAddingRow:k,newRowValues:y,onStartAdd:N,onNewRowChange:C,onSaveNewRow:S,onCancelAdd:L,onCellCopy:M}){let{t:E}=(0,o.Bd)(),[P,T]=(0,s.useState)(null),[$,R]=(0,s.useState)({left:0,bottom:0});if((0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(null!==P?(e.stopPropagation(),T(null)):null!==p?(e.stopPropagation(),w()):k&&(e.stopPropagation(),L()))};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[P,p,k,w,L]),!e&&!t)return(0,n.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:E("database.selectTableForData")});let B=e?.fields||[],F=e?.rows||[],I={};for(let e of r)I[e.name]=e.type+(e.maxLength?`(${e.maxLength})`:"");let D=F.length>0&&h.size===F.length,A=h.size>0&&!D;return(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"flex-1 overflow-auto relative",children:[t&&(0,n.jsx)("div",{className:"absolute inset-0 bg-background/50 flex items-center justify-center z-10",children:(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),(0,n.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,n.jsx)("thead",{className:"sticky top-0 bg-card z-[2]",children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"px-1 py-1 border-b border-border w-8 text-center",children:(0,n.jsx)("input",{type:"checkbox",checked:D,ref:e=>{e&&(e.indeterminate=A)},onChange:()=>{D?f(new Set):f(new Set(F.map((e,t)=>t)))},className:"w-3 h-3 accent-brand cursor-pointer"})}),B.map(e=>{let t=u?.column===e.name?u.dir:null,r=c[e.name],s=r?.enabled;return(0,n.jsxs)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono relative",children:[(0,n.jsxs)("span",{className:"cursor-pointer select-none hover:text-foreground transition-colors",onClick:()=>{var t;return t=e.name,void(u?.column===t?"ASC"===u.dir?x({column:t,dir:"DESC"}):x(null):x({column:t,dir:"ASC"}))},children:[e.name,I[e.name]&&(0,n.jsx)("span",{className:"ml-1 text-[9px] text-muted-foreground/60 font-normal",children:I[e.name]}),"ASC"===t&&(0,n.jsx)("span",{className:"ml-0.5 text-brand",children:"↑"}),"DESC"===t&&(0,n.jsx)("span",{className:"ml-0.5 text-brand",children:"↓"})]}),(0,n.jsx)("button",{onClick:t=>{if(t.stopPropagation(),P===e.name)return void T(null);let r=t.currentTarget.closest("th").getBoundingClientRect();R({left:r.left,bottom:r.bottom}),T(e.name)},className:`ml-1 inline-flex items-center transition-colors ${s?"text-brand":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:(0,n.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,n.jsx)("path",{d:"M1 2h14l-5.5 6.5V14l-3-2v-3.5z"})})}),P===e.name&&(0,n.jsx)(ry,{filter:r||null,onApply:t=>{m(e.name,t),T(null)},onClear:()=>{m(e.name,null),T(null)},onToggle:t=>{r&&m(e.name,{...r,enabled:t})},onClose:()=>T(null),colName:e.name,anchorRect:$})]},e.name)})]})}),(0,n.jsxs)("tbody",{children:[k&&(0,n.jsxs)("tr",{className:"bg-emerald-500/5",children:[(0,n.jsx)("td",{className:"px-1 py-0.5 border-b border-border text-center",children:(0,n.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,n.jsx)("button",{onClick:S,className:"text-[10px] text-green-11 hover:text-green-9",title:E("common.save"),children:"✓"}),(0,n.jsx)("button",{onClick:L,className:"text-[10px] text-muted-foreground hover:text-foreground",title:E("common.cancel"),children:"✕"})]})}),B.map(e=>(0,n.jsx)("td",{className:"px-0.5 py-0.5 border-b border-border",children:(0,n.jsx)("input",{type:"text",value:y[e.name]??"",onChange:t=>C(e.name,t.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]",placeholder:"NULL"})},e.name))]}),F.map((e,t)=>(0,n.jsxs)("tr",{className:`hover:bg-hover ${h.has(t)?"bg-brand/5":""} ${p===t?"bg-blue-500/5":""}`,children:[(0,n.jsx)("td",{className:"px-1 py-0.5 border-b border-border/50 text-center",children:p===t?(0,n.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,n.jsx)("button",{onClick:j,className:"text-[10px] text-green-11 hover:text-green-9",title:E("common.save"),children:"✓"}),(0,n.jsx)("button",{onClick:w,className:"text-[10px] text-muted-foreground hover:text-foreground",title:E("common.cancel"),children:"✕"})]}):(0,n.jsx)("input",{type:"checkbox",checked:h.has(t),onChange:()=>{let e;(e=new Set(h)).has(t)?e.delete(t):e.add(t),f(e)},className:"w-3 h-3 accent-brand cursor-pointer"})}),B.map(r=>(0,n.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onDoubleClick:()=>{null===p&&b(t)},onContextMenu:t=>{t.preventDefault(),M(rv(e[r.name]))},children:p===t?(0,n.jsx)("input",{type:"text",value:g[r.name]??"",onChange:e=>v(r.name,e.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]"}):null===e[r.name]||void 0===e[r.name]?(0,n.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,n.jsx)(rj,{text:rv(e[r.name])})},r.name))]},t))]})]}),0===F.length&&!t&&(0,n.jsx)("div",{className:"p-4 text-xs text-muted-foreground text-center",children:E("common.noData")})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-t border-border text-[10px] text-muted-foreground bg-card/30 flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:N,disabled:k,className:"px-1.5 py-0.5 text-[10px] text-green-11 hover:text-green-9 disabled:opacity-30",children:E("database.addRow")}),(0,n.jsx)("span",{children:E("database.totalRows",{count:i})}),e?.duration!==void 0&&(0,n.jsxs)("span",{children:[e.duration,"ms"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("button",{onClick:()=>d(a-1),disabled:0===a,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"◀"}),(0,n.jsxs)("span",{children:[a+1," / ",l]}),(0,n.jsx)("button",{onClick:()=>d(a+1),disabled:a>=l-1,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"▶"})]})]})]})}function rC({sqlInput:e,onSqlChange:t,onExecute:r,onKeyDown:s,result:a,error:l,loading:i,sqlRef:d,onCellCopy:c}){let{t:u}=(0,o.Bd)();return(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"flex-shrink-0 p-2 border-b border-border",children:[(0,n.jsx)("textarea",{ref:d,value:e,onChange:e=>t(e.target.value),onKeyDown:s,placeholder:u("database.sqlPlaceholder",{modKey:(0,t1.Mu)()}),className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,n.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,n.jsx)("button",{onClick:r,disabled:i||!e.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:u(i?"database.executing":"database.execute")}),a?.duration!==void 0&&(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[a.command&&!a.fields?u("database.rowsAffected",{command:a.command,count:a.rowCount,duration:a.duration}):u("database.queryRows",{count:a.rows?.length??0,duration:a.duration}),a.truncated&&` ${u("database.resultTruncated")}`]})]})]}),l&&(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-destructive bg-destructive/5 border-b border-border break-all",children:l}),a?.fields&&a.rows&&(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:(0,n.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,n.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,n.jsx)("tr",{children:a.fields.map(e=>(0,n.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:e.name},e.name))})}),(0,n.jsx)("tbody",{children:a.rows.map((e,t)=>(0,n.jsx)("tr",{className:"hover:bg-hover",children:a.fields.map(t=>(0,n.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onContextMenu:r=>{r.preventDefault(),c(rv(e[t.name]))},children:null===e[t.name]||void 0===e[t.name]?(0,n.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,n.jsx)(rj,{text:rv(e[t.name])})},t.name))},t))})]})})]})}t9({type:"database",idPrefix:"db",match(e){let t=e.trim().toLowerCase();return t.startsWith("postgresql://")||t.startsWith("postgres://")},parse(e){let t=e.trim(),r=t;try{let e=new URL(t),n=e.pathname.replace(/^\//,"")||"postgres";r=`${n}@${e.hostname}${e.port?":"+e.port:""}`}catch{}return{connectionString:t,displayName:r}},fromHistory:e=>({connectionString:e.connectionString,displayName:e.displayName||e.connectionString}),toHistory:e=>({connectionString:e.connectionString,displayName:e.displayName}),Component:function({item:e,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:a,onSelect:l,onClose:i,onToggleMaximize:d,onTitleMouseDown:c}){return(0,n.jsx)(rw,{id:e.id,connectionString:e.connectionString,displayName:e.displayName,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:a,onSelect:l,onClose:i,onToggleMaximize:d,onTitleMouseDown:c})},async onClose(e){await rr("db",e.id)}});let rS=[{value:"=",label:"="},{value:"!=",label:"!="},{value:">",label:">"},{value:"<",label:"<"},{value:">=",label:">="},{value:"<=",label:"<="},{value:"LIKE",label:"LIKE"},{value:"NOT LIKE",label:"NOT LIKE"},{value:"IN",label:"IN"},{value:"IS NULL",label:"IS NULL"},{value:"IS NOT NULL",label:"IS NOT NULL"}];function rL(e){if(!e)return"";let t=new Date(e);if(isNaN(t.getTime()))return"";let r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${r}-${n} ${s}:${o}`}function rM(e){return`\`${e.replace(/`/g,"``")}\``}function rE(e){try{let t=e.match(/\/\/[^/]+\/([^?]+)/);if(t)return t[1]}catch{}return""}function rP(e){return null==e?"":"object"==typeof e?JSON.stringify(e):String(e)}function rT({text:e}){let[t,r]=(0,s.useState)(!1),[o,a]=(0,s.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),l=(0,s.useRef)(null),i=(0,s.useRef)(null),d=(0,s.useRef)(!1),c=(0,g.F2)(),u=(0,s.useCallback)(()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{d.current||r(!1)},80)},[]),m=(0,s.useCallback)(()=>{i.current&&clearTimeout(i.current),d.current=!1,i.current=setTimeout(()=>{let e=l.current;if(!e||e.scrollWidth<=e.clientWidth)return;let t=e.getBoundingClientRect(),n=c?.getBoundingClientRect(),s=n?.left??0,o=n?.top??0,i=n?.width??window.innerWidth,d=n?.height??window.innerHeight,u=t.left-s,m=t.top-o,x=t.bottom-o,h=Math.min(600,i-u-8),f=m-8,p=d-x-8,g=f>p&&f>80,b=g?f-4:p-4;a({x:h<200?Math.max(8,i-600-8):u,y:g?m-4:x+4,maxW:h<200?Math.min(600,i-16):h,maxH:Math.max(60,b),above:g}),r(!0)},350)},[c]),x=(0,s.useCallback)(()=>{u()},[u]),h=(0,s.useCallback)(()=>{d.current=!0,i.current&&clearTimeout(i.current)},[]),f=(0,s.useCallback)(()=>{d.current=!1,u()},[u]);return(0,n.jsxs)("span",{ref:l,className:"block truncate",onMouseEnter:m,onMouseLeave:x,children:[e,t&&(0,n.jsx)(g.ZL,{children:(0,n.jsx)("div",{className:"fixed z-[9999] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lv2 whitespace-pre-wrap break-all select-text cursor-text",style:{left:o.x,top:o.y,maxWidth:o.maxW,maxHeight:o.maxH,transform:o.above?"translateY(-100%)":void 0},onMouseEnter:h,onMouseLeave:f,children:function(e){try{let t=JSON.parse(e);if("object"==typeof t&&null!==t)return JSON.stringify(t,null,2)}catch{}return e}(e)})})]})}function r$({id:e,connectionString:t,displayName:r,selected:a,maximized:l,expandedHeight:i,bubbleContentHeight:d,onSelect:c,onClose:u,onToggleMaximize:m,timestamp:x,onTitleMouseDown:h}){let{t:f}=(0,o.Bd)(),{showToast:p}=(0,P.dj)(),[g,b]=(0,s.useState)("connecting"),[v,j]=(0,s.useState)(""),[w,k]=(0,s.useState)([]),[y,N]=(0,s.useState)(()=>rE(t)),[C,S]=(0,s.useState)([]),[L,M]=(0,s.useState)(null),[E,T]=(0,s.useState)("table"),[$,R]=(0,s.useState)("data"),[B,F]=(0,s.useState)([]),[I,D]=(0,s.useState)([]),[A,z]=(0,s.useState)([]),[H,W]=(0,s.useState)([]),[_,O]=(0,s.useState)(null),[q,V]=(0,s.useState)(0),[U,K]=(0,s.useState)(!1),[G,J]=(0,s.useState)(0),[Q,Z]=(0,s.useState)(new Set),[X,Y]=(0,s.useState)(!1),[ee,et]=(0,s.useState)(null),[er,en]=(0,s.useState)({}),[es,eo]=(0,s.useState)(!1),[ea,el]=(0,s.useState)({}),[ei,ed]=(0,s.useState)({}),[ec,eu]=(0,s.useState)(null),[em,ex]=(0,s.useState)(""),[eh,ef]=(0,s.useState)(null),[ep,eg]=(0,s.useState)(""),[eb,ev]=(0,s.useState)(!1),ej=(0,s.useRef)(null),ew=(0,s.useCallback)(async()=>{b("connecting"),j("");try{let r=await ra("/api/mysql/connect",{id:e,connectionString:t});k(r.schemas||[]);let n=rE(t);r.schemas?.length>0&&n&&r.schemas.includes(n)?N(n):r.schemas?.length>0&&N(r.schemas[0]),b("connected")}catch(e){j(e instanceof Error?e.message:String(e)),b("error")}},[e,t]);(0,s.useEffect)(()=>{ew()},[ew]);let ek=(0,s.useCallback)(async()=>{if("connected"===g)try{let r=await rl("/api/mysql/schemas",{id:e,connectionString:t,schema:y});S(r.tables||[])}catch{}},[e,t,y,g]);(0,s.useEffect)(()=>{ek()},[ek]);let ey=(0,s.useCallback)(async(r,n,s,o)=>{K(!0);let a=s??ei,l=void 0!==o?o:ec;try{let s=`${rM(y)}.${rM(r)}`,{where:o,params:i}=function(e){let t=[],r=[];for(let[n,s]of Object.entries(e)){if(!s.enabled)continue;let e=rM(n);if("IS NULL"===s.op)t.push(`${e} IS NULL`);else if("IS NOT NULL"===s.op)t.push(`${e} IS NOT NULL`);else if("IN"===s.op){let n=s.value.split(",").map(e=>e.trim()).filter(Boolean);if(0===n.length)continue;let o=n.map(e=>(r.push(e),"?"));t.push(`${e} IN (${o.join(", ")})`)}else"LIKE"===s.op||s.op,t.push(`${e} ${s.op} ?`),r.push(s.value)}return{where:t.length>0?` WHERE ${t.join(" AND ")}`:"",params:r}}(a),d=l?` ORDER BY ${rM(l.column)} ${l.dir}`:"",c=`SELECT * FROM ${s}${o}${d} LIMIT 50 OFFSET ${50*n}`,u=await ra("/api/mysql/query",{id:e,connectionString:t,sql:c,params:i});O(u);let m=`SELECT count(*) AS cnt FROM ${s}${o}`,x=await ra("/api/mysql/query",{id:e,connectionString:t,sql:m,params:i});J(x.rows?.[0]?.cnt??0)}catch{}K(!1)},[e,t,y,ei,ec]),eN=(0,s.useCallback)(async r=>{M(r),V(0),et(null),eo(!1),Z(new Set),Y(!1),ed({}),eu(null);try{let n=await rl("/api/mysql/columns",{id:e,connectionString:t,schema:y,table:r});F(n.columns||[]),D(n.primaryKeys||[]),z(n.foreignKeys||[]),W(n.indexes||[])}catch{}ey(r,0,{},null)},[e,t,y,ey]),eC=(0,s.useCallback)(async()=>{if(em.trim()){ev(!0),eg(""),ef(null);try{let r=await ra("/api/mysql/query",{id:e,connectionString:t,sql:em});ef(r)}catch(e){eg(e instanceof Error?e.message:String(e))}ev(!1)}},[e,t,em]),eS=(0,s.useCallback)(async()=>{if(null===ee||!_||!L)return;let r=_.rows[ee],n=[],s=[];for(let e of B)void 0!==er[e.name]&&er[e.name]!==rP(r[e.name]??"")&&(n.push(`${rM(e.name)} = ?`),s.push(""===er[e.name]&&e.nullable?null:er[e.name]));if(0===n.length)return void et(null);let o=I.length>0?I:B.map(e=>e.name),a=[];for(let e of o)null===r[e]||void 0===r[e]?a.push(`${rM(e)} IS NULL`):(a.push(`${rM(e)} = ?`),s.push(r[e]));let l=`UPDATE ${rM(y)}.${rM(L)} SET ${n.join(", ")} WHERE ${a.join(" AND ")}`;try{await ra("/api/mysql/query",{id:e,connectionString:t,sql:l,params:s}),et(null),ey(L,q,ei,ec)}catch(e){alert(`Update failed: ${e instanceof Error?e.message:String(e)}`)}},[ee,_,L,B,I,er,e,t,y,ey,q,ei,ec]),eL=(0,s.useCallback)(async()=>{if(!L)return;let r=[],n=[],s=[];for(let e of B)void 0!==ea[e.name]&&""!==ea[e.name]&&(r.push(rM(e.name)),n.push(ea[e.name]),s.push("?"));if(0===r.length)return;let o=`INSERT INTO ${rM(y)}.${rM(L)} (${r.join(", ")}) VALUES (${s.join(", ")})`;try{await ra("/api/mysql/query",{id:e,connectionString:t,sql:o,params:n}),eo(!1),el({}),ey(L,q,ei,ec)}catch(e){alert(`Insert failed: ${e instanceof Error?e.message:String(e)}`)}},[L,B,ea,e,t,y,ey,q,ei,ec]),eM=(0,s.useCallback)(async()=>{if(0===Q.size||!_||!L)return;let r=I.length>0?I:B.map(e=>e.name),n=0;for(let s of Array.from(Q).sort((e,t)=>t-e)){let o=_.rows[s];if(!o)continue;let a=[],l=[];for(let e of r)null===o[e]||void 0===o[e]?a.push(`${rM(e)} IS NULL`):(a.push(`${rM(e)} = ?`),l.push(o[e]));let i=`DELETE FROM ${rM(y)}.${rM(L)} WHERE ${a.join(" AND ")} LIMIT 1`;try{await ra("/api/mysql/query",{id:e,connectionString:t,sql:i,params:l})}catch{n++}}Z(new Set),Y(!1),ey(L,q,ei,ec),n>0&&alert(f("mysql.deleteRowsFailed",{count:n}))},[Q,_,L,I,B,e,t,y,ey,q,ei,ec]),eE=(0,s.useCallback)(async r=>{if(!L)return;if(Q.size>0&&_){let e,t=_.fields.map(e=>e.name),n=Array.from(Q).sort((e,t)=>e-t).map(e=>_.rows[e]).filter(Boolean);if("json"===r)e=JSON.stringify(n,null,2);else{let r=[t.join(",")];for(let e of n)r.push(t.map(t=>{let r=e[t];if(null==r)return"";let n="object"==typeof r?JSON.stringify(r):String(r);return n.includes(",")||n.includes('"')||n.includes("\n")?`"${n.replace(/"/g,'""')}"`:n}).join(","));e=r.join("\n")}navigator.clipboard.writeText(e);return}let n=`SELECT * FROM ${rM(y)}.${rM(L)}`;try{let s=await ri("/api/mysql/export",{id:e,connectionString:t,sql:n,format:r}),o=URL.createObjectURL(s),a=document.createElement("a");a.href=o,a.download=`${L}.${r}`,a.click(),URL.revokeObjectURL(o)}catch(e){alert(`Export failed: ${e instanceof Error?e.message:String(e)}`)}},[L,e,t,y,Q,_]),eP=(0,s.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),eC())},[eC]),eT=Math.max(1,Math.ceil(G/50)),e$=(0,s.useCallback)(e=>{L&&(V(e),ey(L,e,ei,ec))},[L,ey,ei,ec]),eR=(0,s.useCallback)((e,t)=>{let r={...ei};t?r[e]=t:delete r[e],ed(r),V(0),Z(new Set),L&&ey(L,0,r,ec)},[ei,ec,L,ey]),eB=(0,s.useCallback)(()=>{ed({}),V(0),Z(new Set),L&&ey(L,0,{},ec)},[ec,L,ey]),eF=(0,s.useCallback)(e=>{eu(e),V(0),Z(new Set),L&&ey(L,0,ei,e)},[ei,L,ey]);return(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
14
|
+
relative transition-colors cursor-pointer
|
|
15
|
+
${l?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
16
|
+
${l?"":a?"border-brand":"border-brand/30"}`,onClick:l?void 0:c,children:[(0,n.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:m,onMouseDown:h,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${l?"bg-card":"bg-card/50"}`,style:l?{height:41}:void 0,children:[(0,n.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDC2C"}),(0,n.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:r}),"connecting"===g&&(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===g&&(0,n.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:f("mysql.connectionFailed")}),"connected"===g&&(0,n.jsx)("span",{className:"text-[10px] text-green-11 flex-shrink-0",children:f("mysql.connected")}),(0,n.jsx)("span",{className:"flex-1"}),x&&(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:rL(x)}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),m()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:l?f("browser.exitMaximize",{modKey:(0,t1.Mu)()}):f("browser.maximize",{modKey:(0,t1.Mu)()}),children:l?(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),u()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:f("common.close"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsxs)("div",{style:{height:l&&i?i-41:d??360},className:"flex overflow-hidden",children:["connecting"===g&&(0,n.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),f("mysql.connecting")]}),"error"===g&&(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,n.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:v}),(0,n.jsx)("button",{onClick:ew,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:f("common.retry")})]}),"connected"===g&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[w.length>1?(0,n.jsx)("select",{value:y,onChange:e=>{N(e.target.value),M(null)},className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1",children:w.map(e=>(0,n.jsx)("option",{value:e,children:e},e))}):(0,n.jsx)("span",{className:"flex-1 min-w-0 text-xs text-muted-foreground truncate",children:y}),(0,n.jsx)("button",{onClick:ek,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-hover active:bg-active transition-colors",title:f("mysql.refreshTableList"),children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M1 1v5h5"}),(0,n.jsx)("path",{d:"M15 15v-5h-5"}),(0,n.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,n.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,n.jsx)("div",{className:"flex items-center border-b border-border",children:["table","view"].map(e=>(0,n.jsx)("button",{onClick:()=>T(e),className:`flex-1 py-1 text-[10px] font-medium transition-colors ${E===e?"text-brand border-b border-brand":"text-muted-foreground hover:text-foreground"}`,children:{table:f("mysql.filterTable"),view:f("mysql.filterView")}[e]},e))}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[C.filter(e=>"table"===E?"view"!==e.type:"view"===e.type).map(e=>(0,n.jsxs)("div",{onClick:()=>eN(e.name),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer truncate transition-colors ${L===e.name?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,n.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground",children:"view"===e.type?"V":"T"}),(0,n.jsx)("span",{className:"truncate min-w-0 flex-1",children:(0,n.jsx)(rT,{text:e.name})}),(0,n.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:e.rowEstimate>0?`~${e.rowEstimate}`:""})]},e.name)),0===C.length&&(0,n.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:f("mysql.noTables")})]})]}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["structure","data","sql"].map(e=>(0,n.jsx)("button",{onClick:()=>R(e),className:`px-3 py-1.5 text-xs transition-colors ${$===e?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{structure:f("mysql.tabStructure"),data:f("mysql.tabData"),sql:"SQL"}[e]},e)),L&&"data"===$&&(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[Object.values(ei).some(e=>e.enabled)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-[10px] text-brand",children:f("mysql.filterActive",{count:Object.values(ei).filter(e=>e.enabled).length})}),(0,n.jsx)("button",{onClick:eB,className:"px-1 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",title:f("mysql.clearAllFilters"),children:"✕"}),(0,n.jsx)("span",{className:"text-border",children:"|"})]}),Q.size>0&&!X&&(0,n.jsx)("button",{onClick:()=>Y(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:f("mysql.deleteNRows",{count:Q.size})}),X&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-[10px] text-destructive",children:f("mysql.confirmDeleteRows")}),(0,n.jsx)("button",{onClick:eM,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:f("common.confirm")}),(0,n.jsx)("button",{onClick:()=>Y(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:f("common.cancel")})]}),(0,n.jsx)("button",{onClick:()=>eE("csv"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:Q.size>0?f("mysql.copyCsvSelected"):f("mysql.copyCsvAll"),children:Q.size>0?f("mysql.copyCSV"):f("mysql.CSV")}),(0,n.jsx)("button",{onClick:()=>eE("json"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:Q.size>0?f("mysql.copyJsonSelected"):f("mysql.copyJsonAll"),children:Q.size>0?f("mysql.copyJSON"):f("mysql.JSON")})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:L||"sql"===$?"structure"===$?(0,n.jsx)(rR,{columns:B,primaryKeys:I,foreignKeys:A,indexes:H}):"data"===$?(0,n.jsx)(rF,{result:_,loading:U,columns:B,page:q,totalPages:eT,totalRows:G,onPageChange:e$,filters:ei,sort:ec,onFilterChange:eR,onSortChange:eF,selectedRows:Q,onSelectedRowsChange:e=>{Z(e),Y(!1)},editingRowIdx:ee,editValues:er,onStartEdit:e=>{if(!_)return;let t=_.rows[e],r={};for(let e of B)r[e.name]=null==t[e.name]?"":rP(t[e.name]);en(r),et(e)},onEditChange:(e,t)=>en(r=>({...r,[e]:t})),onSaveEdit:eS,onCancelEdit:()=>et(null),isAddingRow:es,newRowValues:ea,onStartAdd:()=>{eo(!0),el({})},onNewRowChange:(e,t)=>el(r=>({...r,[e]:t})),onSaveNewRow:eL,onCancelAdd:()=>{eo(!1),el({})},onCellCopy:e=>{navigator.clipboard.writeText(e),p(f("common.copied"))}}):(0,n.jsx)(rI,{sqlInput:em,onSqlChange:ex,onExecute:eC,onKeyDown:eP,result:eh,error:ep,loading:eb,sqlRef:ej,onCellCopy:e=>{navigator.clipboard.writeText(e),p(f("common.copied"))}}):(0,n.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:f("mysql.selectTable")})})]})]})]}),!l&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===g?"bg-green-500":"error"===g?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,n.jsx)("span",{children:{connecting:f("common.connecting"),connected:f("common.connected"),error:f("common.connectionFailed")}[g]}),"connected"===g&&L&&(0,n.jsx)("span",{className:"text-muted-foreground/70",children:L}),(0,n.jsx)("span",{className:"flex-1"}),x&&(0,n.jsx)("span",{className:"text-[11px] flex-shrink-0",children:rL(x)})]})]})})}function rR({columns:e,primaryKeys:t,foreignKeys:r,indexes:s}){let{t:a}=(0,o.Bd)();return 0===e.length?(0,n.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:a("mysql.selectTableToView")}):(0,n.jsxs)("div",{className:"p-2 space-y-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:a("mysql.columns")}),(0,n.jsxs)("table",{className:"w-full text-xs",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border",children:[(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:a("mysql.colName")}),(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:a("mysql.colType")}),(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:a("mysql.colNullable")}),(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:a("mysql.colDefault")})]})}),(0,n.jsx)("tbody",{children:e.map(e=>(0,n.jsxs)("tr",{className:"border-b border-border/50 hover:bg-hover",children:[(0,n.jsxs)("td",{className:"px-1.5 py-1 font-mono",children:[e.isPrimaryKey&&(0,n.jsx)("span",{className:"text-amber-11 mr-1",title:a("mysql.primaryKey"),children:"\uD83D\uDD11"}),e.name]}),(0,n.jsxs)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono",children:[e.type,e.maxLength?`(${e.maxLength})`:""]}),(0,n.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground",children:e.nullable?"YES":"NO"}),(0,n.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono truncate max-w-[120px]",children:e.default||""})]},e.name))})]})]}),r.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:a("mysql.foreignKeys")}),(0,n.jsx)("div",{className:"space-y-0.5",children:r.map((e,t)=>(0,n.jsxs)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground",children:[e.column," → ",e.refSchema,".",e.refTable,".",e.refColumn]},t))})]}),s.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:a("mysql.indexes")}),(0,n.jsx)("div",{className:"space-y-0.5",children:s.map(e=>(0,n.jsx)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground truncate","data-tooltip":e.definition,children:e.name},e.name))})]})]})}function rB({filter:e,onApply:t,onClear:r,onToggle:a,onClose:l,colName:i,anchorRect:d}){let{t:c}=(0,o.Bd)(),[u,m]=(0,s.useState)(e?.op||"="),[x,h]=(0,s.useState)(e?.value||""),f=(0,s.useRef)(null),p=(0,g.F2)();(0,s.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&l()};return document.addEventListener("mousedown",e,!0),()=>document.removeEventListener("mousedown",e,!0)},[l]);let b="IS NULL"!==u&&"IS NOT NULL"!==u,v=()=>{(!b||x.trim())&&t({op:u,value:x.trim(),enabled:!0})},j=p?.getBoundingClientRect(),w=j?.left??0,k=j?.top??0,y=j?.width??window.innerWidth,N=d.left-w;N+220>y-8&&(N=y-220-8),N<8&&(N=8);let C=d.bottom+2-k;return(0,n.jsx)(g.ZL,{children:(0,n.jsxs)("div",{ref:f,className:"fixed z-[9998] w-[220px] bg-popover border border-border rounded-md shadow-lv2 p-2 space-y-2",style:{left:N,top:C},onClick:e=>e.stopPropagation(),children:[e&&(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:e.enabled,onChange:e=>a(e.target.checked),className:"w-3 h-3 accent-brand"}),c("mysql.enable")]}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono truncate max-w-[120px]",children:i})]}),(0,n.jsx)("select",{value:u,onChange:e=>m(e.target.value),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-ring",children:rS.map(e=>(0,n.jsx)("option",{value:e.value,children:e.label},e.value))}),b&&(0,n.jsx)("input",{type:"text",value:x,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),v())},placeholder:c("IN"===u?"mysql.commaValues":"LIKE"===u?"mysql.likePattern":"mysql.valuePlaceholder"),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("button",{onClick:v,disabled:b&&!x.trim(),className:"flex-1 px-2 py-1 text-[10px] bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-40 transition-colors",children:c("mysql.apply")}),e&&(0,n.jsx)("button",{onClick:r,className:"flex-1 px-2 py-1 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground transition-colors",children:c("mysql.clearFilter")})]})]})})}function rF({result:e,loading:t,columns:r,page:a,totalPages:l,totalRows:i,onPageChange:d,filters:c,sort:u,onFilterChange:m,onSortChange:x,selectedRows:h,onSelectedRowsChange:f,editingRowIdx:p,editValues:g,onStartEdit:b,onEditChange:v,onSaveEdit:j,onCancelEdit:w,isAddingRow:k,newRowValues:y,onStartAdd:N,onNewRowChange:C,onSaveNewRow:S,onCancelAdd:L,onCellCopy:M}){let{t:E}=(0,o.Bd)(),[P,T]=(0,s.useState)(null),[$,R]=(0,s.useState)({left:0,bottom:0});if((0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(null!==P?(e.stopPropagation(),T(null)):null!==p?(e.stopPropagation(),w()):k&&(e.stopPropagation(),L()))};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[P,p,k,w,L]),!e&&!t)return(0,n.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:E("mysql.selectTableForData")});let B=e?.fields||[],F=e?.rows||[],I={};for(let e of r)I[e.name]=e.type+(e.maxLength?`(${e.maxLength})`:"");let D=F.length>0&&h.size===F.length,A=h.size>0&&!D;return(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"flex-1 overflow-auto relative",children:[t&&(0,n.jsx)("div",{className:"absolute inset-0 bg-background/50 flex items-center justify-center z-10",children:(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),(0,n.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,n.jsx)("thead",{className:"sticky top-0 bg-card z-[2]",children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"px-1 py-1 border-b border-border w-8 text-center",children:(0,n.jsx)("input",{type:"checkbox",checked:D,ref:e=>{e&&(e.indeterminate=A)},onChange:()=>{D?f(new Set):f(new Set(F.map((e,t)=>t)))},className:"w-3 h-3 accent-brand cursor-pointer"})}),B.map(e=>{let t=u?.column===e.name?u.dir:null,r=c[e.name],s=r?.enabled;return(0,n.jsxs)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono relative",children:[(0,n.jsxs)("span",{className:"cursor-pointer select-none hover:text-foreground transition-colors",onClick:()=>{var t;return t=e.name,void(u?.column===t?"ASC"===u.dir?x({column:t,dir:"DESC"}):x(null):x({column:t,dir:"ASC"}))},children:[e.name,I[e.name]&&(0,n.jsx)("span",{className:"ml-1 text-[9px] text-muted-foreground/60 font-normal",children:I[e.name]}),"ASC"===t&&(0,n.jsx)("span",{className:"ml-0.5 text-brand",children:"↑"}),"DESC"===t&&(0,n.jsx)("span",{className:"ml-0.5 text-brand",children:"↓"})]}),(0,n.jsx)("button",{onClick:t=>{if(t.stopPropagation(),P===e.name)return void T(null);let r=t.currentTarget.closest("th").getBoundingClientRect();R({left:r.left,bottom:r.bottom}),T(e.name)},className:`ml-1 inline-flex items-center transition-colors ${s?"text-brand":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:(0,n.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,n.jsx)("path",{d:"M1 2h14l-5.5 6.5V14l-3-2v-3.5z"})})}),P===e.name&&(0,n.jsx)(rB,{filter:r||null,onApply:t=>{m(e.name,t),T(null)},onClear:()=>{m(e.name,null),T(null)},onToggle:t=>{r&&m(e.name,{...r,enabled:t})},onClose:()=>T(null),colName:e.name,anchorRect:$})]},e.name)})]})}),(0,n.jsxs)("tbody",{children:[k&&(0,n.jsxs)("tr",{className:"bg-emerald-500/5",children:[(0,n.jsx)("td",{className:"px-1 py-0.5 border-b border-border text-center",children:(0,n.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,n.jsx)("button",{onClick:S,className:"text-[10px] text-green-11 hover:text-green-9",title:E("common.save"),children:"✓"}),(0,n.jsx)("button",{onClick:L,className:"text-[10px] text-muted-foreground hover:text-foreground",title:E("common.cancel"),children:"✕"})]})}),B.map(e=>(0,n.jsx)("td",{className:"px-0.5 py-0.5 border-b border-border",children:(0,n.jsx)("input",{type:"text",value:y[e.name]??"",onChange:t=>C(e.name,t.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]",placeholder:"NULL"})},e.name))]}),F.map((e,t)=>(0,n.jsxs)("tr",{className:`hover:bg-hover ${h.has(t)?"bg-brand/5":""} ${p===t?"bg-blue-500/5":""}`,children:[(0,n.jsx)("td",{className:"px-1 py-0.5 border-b border-border/50 text-center",children:p===t?(0,n.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,n.jsx)("button",{onClick:j,className:"text-[10px] text-green-11 hover:text-green-9",title:E("common.save"),children:"✓"}),(0,n.jsx)("button",{onClick:w,className:"text-[10px] text-muted-foreground hover:text-foreground",title:E("common.cancel"),children:"✕"})]}):(0,n.jsx)("input",{type:"checkbox",checked:h.has(t),onChange:()=>{let e;(e=new Set(h)).has(t)?e.delete(t):e.add(t),f(e)},className:"w-3 h-3 accent-brand cursor-pointer"})}),B.map(r=>(0,n.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onDoubleClick:()=>{null===p&&b(t)},onContextMenu:t=>{t.preventDefault(),M(rP(e[r.name]))},children:p===t?(0,n.jsx)("input",{type:"text",value:g[r.name]??"",onChange:e=>v(r.name,e.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]"}):null===e[r.name]||void 0===e[r.name]?(0,n.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,n.jsx)(rT,{text:rP(e[r.name])})},r.name))]},t))]})]}),0===F.length&&!t&&(0,n.jsx)("div",{className:"p-4 text-xs text-muted-foreground text-center",children:E("common.noData")})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-t border-border text-[10px] text-muted-foreground bg-card/30 flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:N,disabled:k,className:"px-1.5 py-0.5 text-[10px] text-green-11 hover:text-green-9 disabled:opacity-30",children:E("mysql.addRow")}),(0,n.jsx)("span",{children:E("mysql.totalRows",{count:i})}),e?.duration!==void 0&&(0,n.jsxs)("span",{children:[e.duration,"ms"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("button",{onClick:()=>d(a-1),disabled:0===a,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"◀"}),(0,n.jsxs)("span",{children:[a+1," / ",l]}),(0,n.jsx)("button",{onClick:()=>d(a+1),disabled:a>=l-1,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"▶"})]})]})]})}function rI({sqlInput:e,onSqlChange:t,onExecute:r,onKeyDown:s,result:a,error:l,loading:i,sqlRef:d,onCellCopy:c}){let{t:u}=(0,o.Bd)();return(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"flex-shrink-0 p-2 border-b border-border",children:[(0,n.jsx)("textarea",{ref:d,value:e,onChange:e=>t(e.target.value),onKeyDown:s,placeholder:u("mysql.sqlPlaceholder",{modKey:(0,t1.Mu)()}),className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,n.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,n.jsx)("button",{onClick:r,disabled:i||!e.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:u(i?"mysql.executing":"mysql.execute")}),a?.duration!==void 0&&(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[a.command&&!a.fields?u("mysql.rowsAffected",{command:a.command,count:a.rowCount,duration:a.duration}):u("mysql.queryRows",{count:a.rows?.length??0,duration:a.duration}),a.truncated&&` ${u("mysql.resultTruncated")}`]})]})]}),l&&(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-destructive bg-destructive/5 border-b border-border break-all",children:l}),a?.fields&&a.rows&&(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:(0,n.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,n.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,n.jsx)("tr",{children:a.fields.map(e=>(0,n.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:e.name},e.name))})}),(0,n.jsx)("tbody",{children:a.rows.map((e,t)=>(0,n.jsx)("tr",{className:"hover:bg-hover",children:a.fields.map(t=>(0,n.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onContextMenu:r=>{r.preventDefault(),c(rP(e[t.name]))},children:null===e[t.name]||void 0===e[t.name]?(0,n.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,n.jsx)(rT,{text:rP(e[t.name])})},t.name))},t))})]})})]})}t9({type:"mysql",idPrefix:"mysql",match:e=>e.trim().toLowerCase().startsWith("mysql://"),parse(e){let t=e.trim(),r=t;try{let e=new URL(t),n=e.pathname.replace(/^\//,"")||"mysql";r=`${n}@${e.hostname}${e.port?":"+e.port:""}`}catch{}return{connectionString:t,displayName:r}},fromHistory:e=>({connectionString:e.connectionString,displayName:e.displayName||e.connectionString}),toHistory:e=>({connectionString:e.connectionString,displayName:e.displayName}),Component:function({item:e,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:a,onSelect:l,onClose:i,onToggleMaximize:d,onTitleMouseDown:c}){return(0,n.jsx)(r$,{id:e.id,connectionString:e.connectionString,displayName:e.displayName,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:a,onSelect:l,onClose:i,onToggleMaximize:d,onTitleMouseDown:c})},async onClose(e){await rr("mysql",e.id)}});let rD={string:{label:"S",color:"text-emerald-600 dark:text-emerald-400 bg-emerald-500/15"},hash:{label:"H",color:"text-blue-600 dark:text-blue-400 bg-blue-500/15"},list:{label:"L",color:"text-orange-600 dark:text-orange-400 bg-orange-500/15"},set:{label:"SET",color:"text-teal-600 dark:text-teal-400 bg-teal-500/15"},zset:{label:"Z",color:"text-purple-600 dark:text-purple-400 bg-purple-500/15"},stream:{label:"STR",color:"text-pink-600 dark:text-pink-400 bg-pink-500/15"}};function rA({type:e}){let t=rD[e]||{label:"?",color:"text-muted-foreground bg-muted"};return(0,n.jsx)("span",{className:`inline-block text-[9px] font-mono font-bold leading-none px-1 py-0.5 rounded flex-shrink-0 ${t.color}`,children:t.label})}function rz({text:e}){let[t,r]=(0,s.useState)(!1),[o,a]=(0,s.useState)({x:0,y:0,above:!0}),l=(0,s.useRef)(null),i=(0,s.useRef)(null),d=(0,g.F2)(),c=(0,s.useCallback)(()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{let e=l.current;if(!e||e.scrollWidth<=e.clientWidth)return;let t=e.getBoundingClientRect(),n=d?.getBoundingClientRect(),s=n?.left??0,o=n?.top??0,i=n?.height??window.innerHeight,c=t.top-o,u=t.bottom-o,m=c>i/2;a({x:t.left-s,y:m?c-4:u+4,above:m}),r(!0)},350)},[d]),u=(0,s.useCallback)(()=>{i.current&&clearTimeout(i.current),r(!1)},[]);return(0,n.jsxs)("span",{ref:l,className:"block truncate",onMouseEnter:c,onMouseLeave:u,children:[e,t&&(0,n.jsx)(g.ZL,{children:(0,n.jsx)("div",{className:"fixed z-[9999] max-w-[500px] max-h-[200px] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lv2 whitespace-pre-wrap break-all select-text",style:{left:o.x,top:o.y,transform:o.above?"translateY(-100%)":void 0},children:e})})]})}function rH({id:e,connectionString:t,displayName:r,selected:a,maximized:l,expandedHeight:i,bubbleContentHeight:d,onSelect:c,onClose:u,onToggleMaximize:m,timestamp:x,onTitleMouseDown:h}){var f;let{t:p}=(0,o.Bd)(),{showToast:g}=(0,P.dj)(),[b,v]=(0,s.useState)("connecting"),[j,w]=(0,s.useState)(""),[k,y]=(0,s.useState)(null),[N,C]=(0,s.useState)([]),[S,L]=(0,s.useState)("0"),[M,E]=(0,s.useState)(!1),[T,$]=(0,s.useState)("*"),[R,B]=(0,s.useState)(!1),[F,I]=(0,s.useState)(null),[D,A]=(0,s.useState)(null),[z,H]=(0,s.useState)(!1),[W,_]=(0,s.useState)(null),[O,q]=(0,s.useState)(!1),[V,U]=(0,s.useState)("data"),[K,G]=(0,s.useState)(""),[J,Q]=(0,s.useState)(""),[Z,X]=(0,s.useState)([]),[Y,ee]=(0,s.useState)(!1),et=(0,s.useRef)(null),er=(0,s.useRef)(null),en=(0,s.useCallback)(async()=>{v("connecting"),w("");try{let r=await ra("/api/redis/connect",{id:e,connectionString:t});y(r),v("connected")}catch(e){w(e instanceof Error?e.message:String(e)),v("error")}},[e,t]);(0,s.useEffect)(()=>{en()},[en]);let es=(0,s.useCallback)(async(r,n,s)=>{B(!0);try{let o=await ra("/api/redis/keys",{id:e,connectionString:t,pattern:r,cursor:n,count:200});C(e=>s?[...e,...o.keys]:o.keys),L(o.cursor),E(o.hasMore)}catch{}B(!1)},[e,t]);(0,s.useEffect)(()=>{"connected"===b&&es(T,"0",!1)},[b]);let eo=(0,s.useCallback)(()=>{I(null),A(null),es(T,"0",!1)},[T,es]),ea=(0,s.useCallback)(async r=>{I(r),H(!0),_(null),q(!1);try{let n=await ra("/api/redis/get",{id:e,connectionString:t,key:r});A(n)}catch(e){A(null),g(e instanceof Error?e.message:p("redis.loadFailed"))}H(!1)},[e,t,g]),el=(0,s.useCallback)(async()=>{if(F)try{await ra("/api/redis/delete",{id:e,connectionString:t,keys:[F]}),I(null),A(null),q(!1),es(T,"0",!1)}catch(e){g(e instanceof Error?e.message:p("redis.deleteFailed"))}},[F,e,t,T,es,g]),ei=(0,s.useCallback)(async()=>{if(F&&null!==W)try{await ra("/api/redis/set",{id:e,connectionString:t,key:F,value:W,type:"string"}),_(null),ea(F),g(p("common.saved"))}catch(e){g(e instanceof Error?e.message:p("redis.saveFailed"))}},[F,W,e,t,ea,g]),ed=(0,s.useCallback)(async()=>{try{let r=await ra("/api/redis/command",{id:e,connectionString:t,command:"INFO"});G("string"==typeof r.result?r.result:String(r.result))}catch{}},[e,t]);(0,s.useEffect)(()=>{"connected"===b&&"info"===V&&ed()},[b,V,ed]);let ec=(0,s.useCallback)(async()=>{let r,n=J.trim();if(!n)return;ee(!0),Q("");let s=[],o=/(?:"([^"]*)")|(?:'([^']*)')|(\S+)/g;for(;null!==(r=o.exec(n));)s.push(r[1]??r[2]??r[3]);let a=s[0]||"",l=s.slice(1);try{let r=await ra("/api/redis/command",{id:e,connectionString:t,command:a,args:l});X(e=>[...e,{command:n,result:r.result,duration:r.duration,isError:!1}])}catch(e){X(t=>[...t,{command:n,result:e instanceof Error?e.message:String(e),duration:0,isError:!0}])}ee(!1)},[J,e,t]);return(0,s.useEffect)(()=>{et.current?.scrollIntoView({behavior:"smooth"})},[Z]),(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
17
|
+
relative transition-colors cursor-pointer
|
|
18
|
+
${l?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
19
|
+
${l?"":a?"border-brand":"border-brand/30"}`,onClick:l?void 0:c,children:[(0,n.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:m,onMouseDown:h,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${l?"bg-card":"bg-card/50"}`,style:l?{height:41}:void 0,children:[(0,n.jsx)("span",{className:"text-sm flex-shrink-0",children:"♦"}),(0,n.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:r}),"connecting"===b&&(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===b&&(0,n.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:p("common.connectionFailed")}),"connected"===b&&k&&(0,n.jsxs)("span",{className:"text-[10px] text-red-11 flex-shrink-0",children:["v",k.version," \xb7 ",k.dbSize," keys \xb7 ",k.memory]}),(0,n.jsx)("span",{className:"flex-1"}),x&&(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:function(e){if(!e)return"";let t=new Date(e);if(isNaN(t.getTime()))return"";let r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${r}-${n} ${s}:${o}`}(x)}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),m()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:l?p("browser.exitMaximize",{modKey:(0,t1.Mu)()}):p("browser.maximize",{modKey:(0,t1.Mu)()}),children:l?(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),u()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:p("common.close"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsxs)("div",{style:{height:l&&i?i-41:d??360},className:"flex overflow-hidden",children:["connecting"===b&&(0,n.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),p("common.connecting"),"..."]}),"error"===b&&(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,n.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:j}),(0,n.jsx)("button",{onClick:en,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:p("common.retry")})]}),"connected"===b&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[(0,n.jsx)("input",{type:"text",value:T,onChange:e=>$(e.target.value),onKeyDown:e=>{"Enter"===e.key&&eo()},placeholder:p("redis.scanPlaceholder"),className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring"}),(0,n.jsx)("button",{onClick:eo,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-hover active:bg-active transition-colors",title:p("redis.scanSearch"),children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"6.5",cy:"6.5",r:"4.5"}),(0,n.jsx)("path",{d:"M10 10l4 4"})]})}),(0,n.jsx)("button",{onClick:()=>es(T,"0",!1),className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-hover active:bg-active transition-colors",title:p("common.refresh"),children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M1 1v5h5"}),(0,n.jsx)("path",{d:"M15 15v-5h-5"}),(0,n.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,n.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[N.map(e=>(0,n.jsxs)("div",{onClick:()=>ea(e.key),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer transition-colors ${F===e.key?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,n.jsx)(rA,{type:e.type}),(0,n.jsx)("span",{className:"truncate min-w-0 flex-1 font-mono",children:(0,n.jsx)(rz,{text:e.key})})]},e.key)),0===N.length&&!R&&(0,n.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:p("redis.noKeys")}),R&&(0,n.jsx)("div",{className:"p-2 flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"})}),M&&!R&&(0,n.jsx)("button",{onClick:()=>es(T,S,!0),className:"w-full py-1.5 text-[10px] text-brand hover:text-brand/80 transition-colors",children:p("redis.loadMore")})]}),(0,n.jsxs)("div",{className:"px-2 py-1 border-t border-border text-[10px] text-muted-foreground",children:[N.length," keys",M?"+":"",k?` / ${k.dbSize} total`:""]})]}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["data","info","cli"].map(e=>(0,n.jsx)("button",{onClick:()=>U(e),className:`px-3 py-1.5 text-xs transition-colors ${V===e?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{data:p("redis.tabData"),info:p("redis.tabInfo"),cli:"CLI"}[e]},e)),F&&"data"===V&&(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[D&&(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:["TTL: ",function(e,t){if(-1===e)return t("redis.neverExpires");if(-2===e)return t("redis.expired");if(e<60)return`${e}s`;if(e<3600)return`${Math.floor(e/60)}m${e%60>0?` ${e%60}s`:""}`;let r=Math.floor(e/3600),n=Math.floor(e%3600/60);return`${r}h${n>0?` ${n}m`:""}`}(D.ttl,p),null!==D.size?` \xb7 ${null==(f=D.size)?"":f<1024?`${f} B`:f<1048576?`${(f/1024).toFixed(1)} KB`:`${(f/1048576).toFixed(1)} MB`}`:""]}),O?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"text-[10px] text-destructive",children:[p("common.confirm"),"?"]}),(0,n.jsx)("button",{onClick:el,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:p("common.confirm")}),(0,n.jsx)("button",{onClick:()=>q(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:p("common.cancel")})]}):(0,n.jsx)("button",{onClick:()=>q(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:p("common.delete")})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:"data"===V?(0,n.jsx)(rW,{selectedKey:F,keyValue:D,keyLoading:z,editingValue:W,onStartEdit:e=>_(e),onEditChange:_,onSaveEdit:ei,onCancelEdit:()=>_(null),onCellCopy:e=>{navigator.clipboard.writeText(e),g(p("common.copied"))}}):"info"===V?(0,n.jsx)(r_,{infoText:K,onRefresh:ed}):(0,n.jsx)(rO,{cliInput:J,onInputChange:Q,onExecute:ec,history:Z,loading:Y,endRef:et,inputRef:er})})]})]})]})]})})}function rW({selectedKey:e,keyValue:t,keyLoading:r,editingValue:s,onStartEdit:a,onEditChange:l,onSaveEdit:i,onCancelEdit:d,onCellCopy:c}){let{t:u}=(0,o.Bd)();if(!e)return(0,n.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:u("redis.selectKey")});if(r)return(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})});if(!t)return(0,n.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:u("redis.keyNotExist")});let{type:m,value:x}=t;if("string"===m){let t=String(x??""),r=null!==s;return(0,n.jsxs)("div",{className:"p-3 h-full flex flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,n.jsx)(rA,{type:"string"}),(0,n.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e}),(0,n.jsx)("span",{className:"flex-1"}),r?(0,n.jsxs)("div",{className:"flex gap-1",children:[(0,n.jsx)("button",{onClick:i,className:"px-2 py-0.5 text-[10px] text-white bg-brand rounded hover:bg-brand/90",children:u("common.save")}),(0,n.jsx)("button",{onClick:d,className:"px-2 py-0.5 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground",children:u("common.cancel")})]}):(0,n.jsx)("button",{onClick:()=>a(t),className:"px-2 py-0.5 text-[10px] text-brand hover:text-brand/80 bg-brand/10 rounded transition-colors",children:u("common.edit")})]}),r?(0,n.jsx)("textarea",{value:s,onChange:e=>l(e.target.value),className:"flex-1 w-full px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-none focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}):(0,n.jsx)("pre",{className:"flex-1 overflow-auto text-xs font-mono bg-muted/30 rounded p-2 whitespace-pre-wrap break-all select-text cursor-text",onContextMenu:e=>{e.preventDefault(),c(t)},children:t})]})}if("hash"===m){let t=Object.entries(x||{});return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,n.jsx)(rA,{type:"hash"}),(0,n.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[t.length," fields"]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:(0,n.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,n.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border w-1/3",children:"Field"}),(0,n.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Value"})]})}),(0,n.jsx)("tbody",{children:t.map(([e,t])=>(0,n.jsxs)("tr",{className:"hover:bg-hover",children:[(0,n.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[150px]",onContextMenu:t=>{t.preventDefault(),c(e)},children:(0,n.jsx)(rz,{text:e})}),(0,n.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[300px]",onContextMenu:e=>{e.preventDefault(),c(t)},children:(0,n.jsx)(rz,{text:t})})]},e))})]})})]})}if("list"===m){let t=x?.items||[],r=x?.total||0;return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,n.jsx)(rA,{type:"list"}),(0,n.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[u("redis.nItems",{total:r}),t.length<r?` (${u("redis.showingN",{count:t.length})})`:""]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:(0,n.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,n.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border w-16",children:"#"}),(0,n.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Value"})]})}),(0,n.jsx)("tbody",{children:t.map((e,t)=>(0,n.jsxs)("tr",{className:"hover:bg-hover",children:[(0,n.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 text-muted-foreground",children:t}),(0,n.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[300px]",onContextMenu:t=>{t.preventDefault(),c(e)},children:(0,n.jsx)(rz,{text:e})})]},t))})]})})]})}if("set"===m){let t=x?.items||[],r=x?.total||0;return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,n.jsx)(rA,{type:"set"}),(0,n.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[u("redis.nMembers",{total:r}),t.length<r?` (${u("redis.showingN",{count:t.length})})`:""]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:(0,n.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,n.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,n.jsx)("tr",{children:(0,n.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Member"})})}),(0,n.jsx)("tbody",{children:t.map((e,t)=>(0,n.jsx)("tr",{className:"hover:bg-hover",children:(0,n.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[400px]",onContextMenu:t=>{t.preventDefault(),c(e)},children:(0,n.jsx)(rz,{text:e})})},t))})]})})]})}if("zset"===m){let t=x?.items||[],r=x?.total||0;return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,n.jsx)(rA,{type:"zset"}),(0,n.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[u("redis.nMembers",{total:r}),t.length<r?` (${u("redis.showingN",{count:t.length})})`:""]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:(0,n.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,n.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Member"}),(0,n.jsx)("th",{className:"px-2 py-1 text-right text-muted-foreground font-medium border-b border-border w-28",children:"Score"})]})}),(0,n.jsx)("tbody",{children:t.map((e,t)=>(0,n.jsxs)("tr",{className:"hover:bg-hover",children:[(0,n.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[300px]",onContextMenu:t=>{t.preventDefault(),c(e.member)},children:(0,n.jsx)(rz,{text:e.member})}),(0,n.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono text-right text-muted-foreground",children:e.score})]},t))})]})})]})}if("stream"===m){let t=x?.entries||[],r=x?.total||0;return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border",children:[(0,n.jsx)(rA,{type:"stream"}),(0,n.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[u("redis.nEntries",{total:r}),t.length<r?` (${u("redis.showingN",{count:t.length})})`:""]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:(0,n.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,n.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border w-40",children:"ID"}),(0,n.jsx)("th",{className:"px-2 py-1 text-left text-muted-foreground font-medium border-b border-border",children:"Fields"})]})}),(0,n.jsx)("tbody",{children:t.map(([e,t])=>{let r=[];for(let e=0;e<t.length;e+=2)r.push(`${t[e]}: ${t[e+1]}`);return(0,n.jsxs)("tr",{className:"hover:bg-hover",children:[(0,n.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono text-muted-foreground",children:e}),(0,n.jsx)("td",{className:"px-2 py-0.5 border-b border-border/50 font-mono truncate max-w-[300px]",children:(0,n.jsx)(rz,{text:r.join(", ")})})]},e)})})]})})]})}return(0,n.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:u("redis.unsupportedType",{type:m})})}function r_({infoText:e,onRefresh:t}){let{t:r}=(0,o.Bd)();if(!e)return(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})});let s=[],a=null;for(let t of e.split("\n")){let e=t.trim();if(e){if(e.startsWith("#"))a={title:e.replace(/^#\s*/,""),items:[]},s.push(a);else if(a&&e.includes(":")){let t=e.indexOf(":");a.items.push({key:e.slice(0,t),value:e.slice(t+1)})}}}return(0,n.jsxs)("div",{className:"p-2 space-y-3 overflow-auto h-full",children:[(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)("button",{onClick:t,className:"px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:r("common.refresh")})}),s.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1 font-medium",children:e.title}),(0,n.jsx)("div",{className:"space-y-0",children:e.items.map(({key:e,value:t})=>(0,n.jsxs)("div",{className:"flex items-start gap-2 px-1.5 py-0.5 text-xs hover:bg-hover rounded",children:[(0,n.jsx)("span",{className:"text-muted-foreground font-mono flex-shrink-0 w-48 truncate",children:e}),(0,n.jsx)("span",{className:"font-mono text-foreground break-all",children:t})]},e))})]},e.title))]})}function rO({cliInput:e,onInputChange:t,onExecute:r,history:s,loading:a,endRef:l,inputRef:i}){let{t:d}=(0,o.Bd)();return(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"flex-1 overflow-auto p-2 font-mono text-xs space-y-2",onClick:()=>i.current?.focus(),children:[0===s.length&&(0,n.jsx)("div",{className:"text-muted-foreground text-center py-4",children:d("redis.cliHint")}),s.map((e,t)=>(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"text-brand",children:[(0,n.jsx)("span",{className:"text-muted-foreground mr-1",children:">"}),e.command,e.duration>0&&(0,n.jsxs)("span",{className:"text-muted-foreground/50 ml-2",children:["(",e.duration,"ms)"]})]}),(0,n.jsx)("pre",{className:`whitespace-pre-wrap break-all mt-0.5 ${e.isError?"text-destructive":"text-foreground"}`,children:e.isError?`(error) ${e.result}`:function e(t,r=0){let n=" ".repeat(r);return null===t?`${n}(nil)`:"number"==typeof t?`${n}(integer) ${t}`:"string"==typeof t?`${n}"${t}"`:Array.isArray(t)?0===t.length?`${n}(empty array)`:t.map((t,r)=>`${n}${r+1}) ${e(t,0)}`).join("\n"):`${n}${String(t)}`}(e.result)})]},t)),(0,n.jsx)("div",{ref:l})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 border-t border-border bg-card/30 flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-xs text-brand font-mono flex-shrink-0",children:">"}),(0,n.jsx)("input",{ref:i,type:"text",value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{"Enter"!==e.key||a||r()},placeholder:d("redis.cliPlaceholder"),className:"flex-1 min-w-0 text-xs font-mono bg-transparent border-0 focus:outline-none",autoComplete:"off",spellCheck:!1,disabled:a}),a&&(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"})]})]})}t9({type:"redis",idPrefix:"redis",match(e){let t=e.trim().toLowerCase();return t.startsWith("redis://")||t.startsWith("rediss://")},parse(e){let t=e.trim(),r=t;try{let e=new URL(t),n=e.pathname.replace(/^\//,"")||"0";r=`db${n}@${e.hostname}${e.port?":"+e.port:":6379"}`}catch{}return{connectionString:t,displayName:r}},fromHistory:e=>({connectionString:e.connectionString,displayName:e.displayName||e.connectionString}),toHistory:e=>({connectionString:e.connectionString,displayName:e.displayName}),Component:function({item:e,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:a,onSelect:l,onClose:i,onToggleMaximize:d,onTitleMouseDown:c}){return(0,n.jsx)(rH,{id:e.id,connectionString:e.connectionString,displayName:e.displayName,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:a,onSelect:l,onClose:i,onToggleMaximize:d,onTitleMouseDown:c})},async onClose(e){await rr("redis",e.id)}});let rq=/^([\d.]+)\s+([\d.]+)%\s+([\d.]+)%$/;function rV(e,t,r){if(!e)return r;let n=getComputedStyle(e).getPropertyValue(t).trim();if(!n)return r;let s=rq.exec(n);if(!s)return n;let o=Number(s[1]),a=Number(s[2])/100,l=Number(s[3])/100,i=(1-Math.abs(2*l-1))*a,d=i*(1-Math.abs(o/60%2-1)),c=l-i/2,[u,m,x]=[[i,d,0],[d,i,0],[0,i,d],[0,d,i],[d,0,i],[i,0,d]][Math.floor(o/60)%6],h=e=>Math.round((e+c)*255).toString(16).padStart(2,"0");return`#${h(u)}${h(m)}${h(x)}`}let rU=["#4C8BF5","#E74C3C","#2ECC71","#F39C12","#9B59B6","#1ABC9C","#E67E22","#3498DB","#E91E63","#00BCD4"];function rK(e,t){return rU[t.indexOf(e)%rU.length]}function rG(e){if(!e)return"";let t=new Date(e);return isNaN(t.getTime())?"":`${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")} ${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function rJ({nodes:e,rels:t,allLabels:r}){let o=(0,s.useRef)(null),a=(0,s.useRef)(null),l=(0,eS.Ql)()?.resolvedTheme??"dark",i=(0,s.useRef)([]),d=(0,s.useRef)(0),c=(0,s.useRef)(null),u=(0,s.useRef)({w:0,h:0}),m=(0,s.useRef)(new Map),[x,h]=(0,s.useState)(null),f=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=o.current;if(!e)return;let t=new ResizeObserver(e=>{let{width:t,height:r}=e[0].contentRect,n=u.current;if(t===n.w&&r===n.h)return;if(n.w>0&&n.h>0&&i.current.length>0){let e=t/n.w,s=r/n.h;i.current.forEach(t=>{t.x=(t.x||0)*e,t.y=(t.y||0)*s})}u.current={w:t,h:r};let s=a.current;s&&(s.width=t,s.height=r)});return t.observe(e),()=>t.disconnect()},[]),(0,s.useEffect)(()=>{let{w:t,h:r}=u.current,n=t||o.current?.clientWidth||600,s=r||o.current?.clientHeight||400;0===t&&(u.current={w:n,h:s}),i.current=e.map((t,r)=>({...t,x:t.x??n/2+Math.cos(2*r*Math.PI/e.length)*Math.min(n,s)*.3,y:t.y??s/2+Math.sin(2*r*Math.PI/e.length)*Math.min(n,s)*.3,vx:0,vy:0})),m.current=new Map(i.current.map(e=>[e.id,e]))},[e]),(0,s.useEffect)(()=>{let e=m.current,n=a.current,s=rV(n,"--foreground-faint","#666"),o=rV(n,"--foreground-subtle","#999"),l=rV(n,"--accent","#27272a"),x=rV(n,"--foreground","#fff");return d.current=requestAnimationFrame(function n(){let{w:m,h}=u.current;if(0===m||0===h){d.current=requestAnimationFrame(n);return}let p=i.current;p.forEach(e=>{e.vx=(e.vx||0)+(m/2-(e.x||0))*.001,e.vy=(e.vy||0)+(h/2-(e.y||0))*.001});for(let e=0;e<p.length;e++)for(let t=e+1;t<p.length;t++){let r=(p[e].x||0)-(p[t].x||0),n=(p[e].y||0)-(p[t].y||0),s=Math.sqrt(r*r+n*n)||1,o=2e3/(s*s),a=r/s*o,l=n/s*o;p[e].vx+=a,p[t].vx-=a,p[e].vy+=l,p[t].vy-=l}t.forEach(t=>{let r=e.get(t.startId),n=e.get(t.endId);if(!r||!n)return;let s=(n.x||0)-(r.x||0),o=(n.y||0)-(r.y||0),a=Math.sqrt(s*s+o*o)||1,l=(a-100)*.01,i=s/a*l,d=o/a*l;r.vx+=i,n.vx-=i,r.vy+=d,n.vy-=d}),p.forEach(e=>{c.current?.nodeId!==e.id&&(e.vx=.6*(e.vx||0),e.vy=.6*(e.vy||0),e.x=Math.max(20,Math.min(m-20,(e.x||0)+.1*(e.vx||0))),e.y=Math.max(20,Math.min(h-20,(e.y||0)+.1*(e.vy||0))))});let g=a.current?.getContext("2d");g&&(g.clearRect(0,0,m,h),g.lineWidth=1.5,t.forEach(t=>{let r=e.get(t.startId),n=e.get(t.endId);if(!r||!n)return;g.strokeStyle=s,g.beginPath(),g.moveTo(r.x,r.y),g.lineTo(n.x,n.y),g.stroke();let a=Math.atan2(n.y-r.y,n.x-r.x),l=n.x-24*Math.cos(a),i=n.y-24*Math.sin(a);g.fillStyle=s,g.beginPath(),g.moveTo(l,i),g.lineTo(l-8*Math.cos(a-.3),i-8*Math.sin(a-.3)),g.lineTo(l-8*Math.cos(a+.3),i-8*Math.sin(a+.3)),g.closePath(),g.fill(),g.font="9px system-ui",g.fillStyle=o,g.textAlign="center",g.fillText(t.type,(r.x+n.x)/2,(r.y+n.y)/2-4)}),p.forEach(e=>{let t=e.labels[0]||"",n=t?rK(t,r):"#6b7280";g.beginPath(),g.arc(e.x,e.y,20,0,2*Math.PI),g.fillStyle=n,g.fill();let s=f.current?.id===e.id;g.strokeStyle=s?x:l,g.lineWidth=s?2.5:1,g.stroke(),g.font="10px system-ui",g.fillStyle="#fff",g.textAlign="center",g.textBaseline="middle";let o=String(e.properties.name||e.properties.title||e.properties.id||t||e.id);g.fillText(o.length>8?o.slice(0,7)+"…":o,e.x,e.y)}),d.current=requestAnimationFrame(n))}),()=>cancelAnimationFrame(d.current)},[e,t,r,l]);let p=(0,s.useCallback)(e=>{let t=a.current?.getBoundingClientRect();if(!t)return null;let r=e.clientX-t.left,n=e.clientY-t.top;return i.current.find(e=>{let t=(e.x||0)-r,s=(e.y||0)-n;return t*t+s*s<400})||null},[]);return(0,n.jsxs)("div",{ref:o,className:"relative w-full h-full",children:[(0,n.jsx)("canvas",{ref:a,className:"cursor-grab active:cursor-grabbing absolute inset-0",onMouseDown:e=>{let t=p(e);if(t){let r=a.current.getBoundingClientRect();c.current={nodeId:t.id,offsetX:e.clientX-r.left-(t.x||0),offsetY:e.clientY-r.top-(t.y||0)}}},onMouseMove:e=>{if(c.current){let t=a.current.getBoundingClientRect(),r=i.current.find(e=>e.id===c.current.nodeId);r&&(r.x=e.clientX-t.left-c.current.offsetX,r.y=e.clientY-t.top-c.current.offsetY,r.vx=0,r.vy=0)}else{let t=p(e);f.current=t,h(t)}},onMouseUp:()=>{c.current=null},onMouseLeave:()=>{c.current=null,f.current=null,h(null)}}),x&&!c.current&&(0,n.jsxs)("div",{className:"absolute top-2 left-2 bg-popover text-popover-foreground border border-border rounded px-2 py-1 text-xs max-w-[300px] pointer-events-none",children:[(0,n.jsxs)("div",{className:"font-medium",children:[x.labels.join(", ")," #",String(x.id)]}),Object.entries(x.properties).slice(0,8).map(([e,t])=>(0,n.jsxs)("div",{className:"truncate",children:[(0,n.jsxs)("span",{className:"text-muted-foreground",children:[e,":"]})," ",String(t)]},e))]})]})}function rQ({id:e,connectionString:t,displayName:r,selected:o,maximized:a,expandedHeight:l,bubbleContentHeight:i,onSelect:d,onClose:c,onToggleMaximize:u,timestamp:m,onTitleMouseDown:x}){let[h,f]=(0,s.useState)("connecting"),[p,g]=(0,s.useState)(""),[b,v]=(0,s.useState)(null),[j,w]=(0,s.useState)(null),[k,y]=(0,s.useState)(!1),[N,C]=(0,s.useState)("labels"),[S,L]=(0,s.useState)(""),[M,E]=(0,s.useState)(null),[P,T]=(0,s.useState)(!1),[$,R]=(0,s.useState)(""),B=(0,s.useRef)(null),[F,I]=(0,s.useState)([]),[D,A]=(0,s.useState)([]),[z,H]=(0,s.useState)("schema"),W=(0,s.useCallback)(async()=>{f("connecting");try{let r=await ra("/api/neo4j/connect",{id:e,connectionString:t});v(r),f("connected")}catch(e){g(e instanceof Error?e.message:String(e)),f("error")}},[e,t]);(0,s.useEffect)(()=>{W()},[W]);let _=(0,s.useCallback)(async()=>{y(!0);try{let r=await ra("/api/neo4j/schema",{id:e,connectionString:t});w(r)}catch{}y(!1)},[e,t]);(0,s.useEffect)(()=>{"connected"===h&&_()},[h,_]);let O=(0,s.useCallback)(async r=>{let n=r||S.trim();if(n){T(!0),R("");try{var s;let r,o,a=await ra("/api/neo4j/query",{id:e,connectionString:t,cypher:n});E(a);let{nodes:l,rels:i}=(s=a.records,r=new Map,o=[],s.forEach(e=>Object.values(e).forEach(function e(t){if(t&&"object"==typeof t)if("node"===t._type){let e=t._id;r.has(e)||r.set(e,{id:e,labels:t._labels||[],properties:Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith("_")))})}else if("relationship"===t._type)o.push({id:t._id,type:t._relType,startId:t._start,endId:t._end,properties:Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith("_")))});else if("path"===t._type){let r=t.segments;r?.forEach(t=>{e(t.start),e(t.relationship),e(t.end)})}else Array.isArray(t)&&t.forEach(e)})),{nodes:Array.from(r.values()),rels:o});l.length>0&&(I(l),A(i))}catch(e){R(e instanceof Error?e.message:String(e))}T(!1)}},[e,t,S]),q=(0,s.useCallback)(e=>{let t=`MATCH (n:\`${e}\`) RETURN n LIMIT 25`;L(t),H("cypher"),O(t)},[O]),V=(0,s.useCallback)(e=>{let t=`MATCH (a)-[r:\`${e}\`]->(b) RETURN a, r, b LIMIT 25`;L(t),H("graph"),O(t)},[O]);return(0,n.jsx)("div",{className:"flex flex-col items-start",onClick:d,children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground relative transition-colors ${o?"ring-1 ring-ring":""} rounded-lg overflow-hidden`,children:[(0,n.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:u,onMouseDown:x,className:"flex items-center gap-2 px-4 py-1.5 border-b border-border cursor-grab active:cursor-grabbing select-none",children:[(0,n.jsx)("span",{className:"text-sm flex-shrink-0",children:"⬡"}),(0,n.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:r}),"connecting"===h&&(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"connected"===h&&(0,n.jsx)("span",{className:"text-[10px] text-green-11 flex-shrink-0",children:"Connected"}),"error"===h&&(0,n.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:"Error"}),m&&(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:rG(m)}),"connected"===h&&b&&(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:["v",b.version," \xb7 ",b.nodeCount.toLocaleString(),"n \xb7 ",b.relationshipCount.toLocaleString(),"r"]}),(0,n.jsx)("span",{className:"flex-1"}),"connected"===h&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),_(),W()},disabled:k,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0 disabled:opacity-40",title:"Refresh",children:(0,n.jsx)("svg",{className:`w-3.5 h-3.5 ${k?"animate-spin":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),u()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a?(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"}):(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),c()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsxs)("div",{style:{height:a&&l?l-41:i??360},className:"flex flex-col overflow-hidden",children:["connecting"===h&&(0,n.jsxs)("div",{className:"flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Connecting..."]}),"error"===h&&(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-xs p-4 gap-2",children:[(0,n.jsx)("p",{className:"text-destructive",children:p}),(0,n.jsx)("button",{onClick:W,className:"px-3 py-1 rounded text-xs bg-brand text-white hover:bg-brand/90 transition-colors",children:"Retry"})]}),"connected"===h&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:["schema","cypher","graph"].map(e=>(0,n.jsx)("button",{onClick:()=>H(e),className:`px-3 py-1.5 text-xs transition-colors ${z===e?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{schema:"Schema",cypher:"Cypher",graph:"Graph"}[e]},e))}),(0,n.jsxs)("div",{className:"flex-1 overflow-hidden flex",children:["schema"===z&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"w-40 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:(0,n.jsx)("div",{className:"flex-1 overflow-y-auto text-xs",children:[{key:"labels",label:"Labels",count:j?.labels.length},{key:"relationships",label:"Relationships",count:j?.relationshipTypes.length},{key:"properties",label:"Properties",count:j?.propertyKeys.length},{key:"indexes",label:"Indexes",count:j?.indexes.length},{key:"constraints",label:"Constraints",count:j?.constraints.length}].map(e=>(0,n.jsxs)("div",{onClick:()=>C(e.key),className:`flex items-center gap-1.5 px-2 py-1.5 cursor-pointer truncate transition-colors ${N===e.key?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,n.jsx)("span",{className:"truncate min-w-0 flex-1",children:e.label}),(0,n.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:e.count??0})]},e.key))})}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[k&&(0,n.jsxs)("div",{className:"flex items-center justify-center p-4 gap-2 text-muted-foreground",children:[(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"})," Loading..."]}),!k&&"labels"===N&&j?.labels.map(e=>(0,n.jsxs)("div",{onClick:()=>q(e.name),className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer hover:bg-brand/10 transition-colors",children:[(0,n.jsx)("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:rK(e.name,j.labels.map(e=>e.name))}}),(0,n.jsx)("span",{className:"truncate min-w-0 flex-1 font-mono",children:e.name}),(0,n.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:e.count.toLocaleString()})]},e.name)),!k&&"relationships"===N&&j?.relationshipTypes.map(e=>(0,n.jsxs)("div",{onClick:()=>V(e.name),className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer hover:bg-brand/10 transition-colors",children:[(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:"→"}),(0,n.jsx)("span",{className:"truncate min-w-0 flex-1 font-mono",children:e.name}),(0,n.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:e.count.toLocaleString()})]},e.name)),!k&&"properties"===N&&j?.propertyKeys.map(e=>(0,n.jsx)("div",{className:"px-2 py-1 font-mono text-muted-foreground hover:bg-brand/10 transition-colors",children:e},e)),!k&&"indexes"===N&&j?.indexes.map(e=>(0,n.jsxs)("div",{className:"px-2 py-1 border-b border-border/50 hover:bg-brand/10 transition-colors",children:[(0,n.jsx)("div",{className:"font-mono text-foreground",children:e.name}),(0,n.jsxs)("div",{className:"text-muted-foreground",children:[e.type," \xb7 ",e.labelsOrTypes?.join(", ")," \xb7 (",e.properties?.join(", "),") \xb7 ",e.state]})]},e.name)),!k&&"constraints"===N&&j?.constraints.map(e=>(0,n.jsxs)("div",{className:"px-2 py-1 border-b border-border/50 hover:bg-brand/10 transition-colors",children:[(0,n.jsx)("div",{className:"font-mono text-foreground",children:e.name}),(0,n.jsxs)("div",{className:"text-muted-foreground",children:[e.type," \xb7 ",e.labelsOrTypes?.join(", ")," \xb7 (",e.properties?.join(", "),")"]})]},e.name))]})]}),"cypher"===z&&(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"p-2 border-b border-border flex-shrink-0",children:[(0,n.jsx)("textarea",{ref:B,value:S,onChange:e=>L(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),O())},placeholder:`Enter Cypher query (${(0,t1.Mu)()}+Enter to run)`,className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,n.jsxs)("div",{className:"flex items-center justify-between mt-1",children:[(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[(0,t1.Mu)(),"+Enter to execute"]}),(0,n.jsx)("button",{onClick:()=>O(),disabled:P||!S.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:P?"Running...":"Execute"})]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-auto",children:[$&&(0,n.jsx)("div",{className:"p-2 text-xs text-destructive",children:$}),M&&!$&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-2 py-1 text-[10px] text-muted-foreground border-b border-border flex items-center gap-2",children:[(0,n.jsxs)("span",{children:[M.records.length," rows"]}),(0,n.jsxs)("span",{children:[M.duration,"ms"]}),Object.entries(M.counters).filter(([,e])=>e>0).map(([e,t])=>(0,n.jsxs)("span",{children:[e,": ",t]},e))]}),M.records.length>0&&(0,n.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,n.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,n.jsx)("tr",{children:M.keys.map(e=>(0,n.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:e},e))})}),(0,n.jsx)("tbody",{children:M.records.map((e,t)=>(0,n.jsx)("tr",{className:"hover:bg-hover",children:M.keys.map(t=>(0,n.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",children:null===e[t]?(0,n.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):function(e){if(null==e)return"null";if("object"==typeof e){if("node"===e._type){let t=e._labels?.[0]||"",r=e.name||e.title||e.id||"";return`(${t}${r?": "+r:""})`}return"relationship"===e._type?`[${e._relType}]`:JSON.stringify(e)}return String(e)}(e[t])},t))},t))})]})]})]})]}),"graph"===z&&(0,n.jsx)("div",{className:"flex-1 relative",children:0===F.length?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-xs text-muted-foreground gap-2",children:[(0,n.jsx)("p",{children:"Run a Cypher query that returns nodes to visualize"}),(0,n.jsx)("button",{onClick:()=>{let e="MATCH (a)-[r]->(b) RETURN a, r, b LIMIT 50";L(e),O(e)},className:"px-3 py-1 rounded text-xs bg-brand text-white hover:bg-brand/90 transition-colors",children:"Load sample graph"})]}):(0,n.jsx)(rJ,{nodes:F,rels:D,allLabels:j?.labels.map(e=>e.name)||[]})})]})]})]}),!a&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===h?"bg-green-500":"error"===h?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,n.jsx)("span",{children:{connecting:"Connecting",connected:"Connected",error:"Error"}[h]}),"connected"===h&&b&&(0,n.jsx)("span",{className:"text-muted-foreground/70",children:b.edition}),(0,n.jsx)("span",{className:"flex-1"}),m&&(0,n.jsx)("span",{className:"text-[11px] flex-shrink-0",children:rG(m)})]})]})})}t9({type:"neo4j",idPrefix:"neo4j",match(e){let t=e.trim().toLowerCase();return t.startsWith("neo4j://")||t.startsWith("neo4j+s://")||t.startsWith("bolt://")||t.startsWith("bolt+s://")},parse(e){let t=e.trim(),r=t;try{let e=new URL(t);r=`${e.hostname}${e.port?":"+e.port:":7687"}`}catch{}return{connectionString:t,displayName:r}},fromHistory:e=>({connectionString:e.connectionString,displayName:e.displayName||e.connectionString}),toHistory:e=>({connectionString:e.connectionString,displayName:e.displayName}),Component:function({item:e,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:a,onSelect:l,onClose:i,onToggleMaximize:d,onTitleMouseDown:c}){return(0,n.jsx)(rQ,{id:e.id,connectionString:e.connectionString,displayName:e.displayName,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:a,onSelect:l,onClose:i,onToggleMaximize:d,onTitleMouseDown:c})},async onClose(e){await rr("neo4j",e.id)}});let rZ=null,rX="",rY=0,r0=null,r1=!1,r2=new Map,r5=null,r4=null;function r3(e){let t;try{t=JSON.parse(e.data)}catch{return}let r=t.type;if("ping"===r)return;if("running"===r){r5&&(r5(t.commands),r5=null);return}let n=t.commandId;if(!n)return;let s=r2.get(n);if(s){if("error"===r)s.onError(t.error);else{let{commandId:e,type:n,...o}=t;s.onData(r,o)}("exit"===r||"error"===r)&&r2.delete(n)}}function r6(e){rZ?.readyState===WebSocket.OPEN&&rZ.send(JSON.stringify(e))}function r8(e){let t,r=(t="https:"===window.location.protocol?"wss:":"ws:",`${t}//${window.location.host}/ws/terminal?projectCwd=${encodeURIComponent(e)}`);rX===r&&rZ||(no(),r1=!1,rX=r,function e(){if(r1||!rX)return;let t=new WebSocket(rX);rZ=t,t.onopen=()=>{for(let e of(rY=0,r2.keys()))t.send(JSON.stringify({type:"attach",commandId:e}))},t.onmessage=r3,t.onclose=()=>{if(rZ!==t||(rZ=null,r1))return;r0&&clearTimeout(r0);let r=Math.min(1e3*Math.pow(1.5,rY),1e4);rY++,r0=setTimeout(e,r)},t.onerror=()=>{}}())}function r9(){return new Promise((e,t)=>{if(rZ?.readyState===WebSocket.OPEN)return void e();let r=setInterval(()=>{rZ?.readyState===WebSocket.OPEN&&(clearInterval(r),clearTimeout(n),e())},50),n=setTimeout(()=>{clearInterval(r),t(Error("WebSocket connection timeout"))},5e3)})}async function r7(e){let{cwd:t,command:r,commandId:n,tabId:s,projectCwd:o,env:a,usePty:l,cols:i,rows:d,sourceId:c,onData:u,onError:m}=e;r8(o);try{await r9()}catch{m("WebSocket connection failed");return}r2.delete(n),r2.set(n,{onData:u,onError:m}),r6({type:"exec",commandId:n,command:r,cwd:t,tabId:s,env:a,...l?{usePty:!0}:{},...i?{cols:i,rows:d}:{},...c?{sourceId:c}:{}})}async function ne(e){let{commandId:t,projectCwd:r,onData:n,onError:s}=e;r8(r);try{await r9()}catch{s("WebSocket connection failed");return}r2.set(t,{onData:n,onError:s}),r6({type:"attach",commandId:t})}function nt(e,t){r6({type:"stdin",commandId:e,data:t})}function nr(e,t,r){r6({type:"resize",commandId:e,cols:t,rows:r})}function nn(e){r6({type:"interrupt",pid:e})}async function ns(e){try{r8(e);try{await r9()}catch{return[]}return await new Promise(e=>{r5=t=>{e(t)},r6({type:"running"}),setTimeout(()=>{r5&&(r5=null,e([]))},3e3)})}finally{r4=null}}function no(){if(r1=!0,r0&&(clearTimeout(r0),r0=null),rZ){let e=rZ;rZ=null,e.close()}r2.clear(),r5&&(r5([]),r5=null),r4=null,rX="",rY=0}let na=(0,s.memo)(function({item:e,selected:t,maximized:r,initialSleeping:s,tabId:o,projectCwd:a,expandedHeight:l,bubbleContentHeight:i,onDragStart:d,onDragOver:c,onDragEnter:u,onDragLeave:m,onDrop:x,onDragEnd:h,onSelectId:f,onInterruptId:p,onStdin:g,onDeleteCommand:b,onRerun:v,subscribePtyOutput:j,subscribePtyReset:w,subscribePtyRefresh:k,ptySizeRef:y,resizePty:N,onToggleMaximizeId:C,onTitleMouseDown:S,onClosePlugin:L,addBrowserItem:M,onSleep:E,onWake:P}){let T={draggable:!0,onDragStart:t=>d(t,e.data.id),onDragOver:t=>c(t,e.data.id),onDragEnter:u,onDragLeave:m,onDrop:x,onDragEnd:h};if("command"===e.type){let s=e.data;return(0,n.jsx)("div",{"data-bubble-id":s.id,className:"group/cmd rounded-lg transition-shadow",...T,children:(0,n.jsx)(t6,{commandId:s.id,tabId:o,projectCwd:a,command:s.command,output:s.output,exitCode:s.exitCode,isRunning:s.isRunning,selected:t,onSelect:()=>{f(s.id)},onInterrupt:s.isRunning?()=>p(s.id):void 0,onStdin:s.isRunning?e=>g(s.id,e):void 0,onDelete:()=>{s.isRunning&&s.pid&&nn(s.pid),b(s.id)},onRerun:()=>v(s.id),timestamp:s.timestamp,usePty:s.usePty,subscribePtyOutput:s.usePty?j:void 0,subscribePtyReset:s.usePty?w:void 0,subscribePtyRefresh:s.usePty?k:void 0,onPtyResize:(e,t)=>{y.current.set(s.id,{cols:e,rows:t}),N(s.id,e,t)},onToggleMaximize:()=>C(s.id),maximized:r,expandedHeight:l,bubbleContentHeight:i,onTitleMouseDown:S})})}let $=t7(e.type);if(!$)return null;let R=$.Component,B=e.data;return(0,n.jsx)("div",{"data-bubble-id":B.id,className:"rounded-lg transition-shadow",...T,children:(0,n.jsx)(R,{item:B,selected:t,maximized:r,expandedHeight:l,bubbleContentHeight:i,timestamp:B.timestamp,onSelect:()=>{f(B.id)},onClose:()=>L(B.id),onToggleMaximize:()=>C(B.id),onTitleMouseDown:S,extra:{addBrowserItem:M,initialSleeping:s,onSleep:E,onWake:P,projectCwd:a,tabId:o}})})});var nl=r(68459),ni=r(51914);function nd({cwd:e,tabId:t,onClose:r,onSave:a}){let{t:l}=(0,o.Bd)(),[i,d]=(0,s.useState)({}),[c,m]=(0,s.useState)(""),[x,h]=(0,s.useState)(""),[f,p]=(0,s.useState)(!0),g=(0,s.useCallback)(async()=>{p(!0);let r=await u.t4.runPromiseExit(tU(e,t));"Success"===r._tag?d(r.value.env):console.error("Failed to load env:",r.cause),p(!1)},[e,t]);(0,s.useEffect)(()=>{g()},[g]);let b=()=>{c.trim()&&(d(e=>({...e,[c.trim()]:x})),m(""),h(""))},v=async()=>{let n=await u.t4.runPromiseExit(tV("/api/terminal/env",{cwd:e,tabId:t,env:i}));"Success"===n._tag?(a(i),r()):console.error("Failed to save env:",n.cause)};return(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim flex items-center justify-center z-50",children:(0,n.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-lv3 w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:l("envManager.title")}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:t?l("envManager.tabScope"):l("envManager.globalScope")})]}),(0,n.jsx)("button",{onClick:r,className:"p-1 rounded hover:bg-hover transition-colors",children:(0,n.jsx)(ea.A,{className:"w-5 h-5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:f?(0,n.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:l("common.loading")}):(0,n.jsxs)("div",{className:"space-y-3",children:[Object.entries(i).map(([e,t])=>(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)("input",{type:"text",value:e,disabled:!0,className:"flex-1 px-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"}),(0,n.jsx)("input",{type:"text",value:t,onChange:t=>{var r;return r=t.target.value,void d(t=>({...t,[e]:r}))},placeholder:l("envManager.valuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"}),(0,n.jsx)("button",{onClick:()=>{d(t=>{let r={...t};return delete r[e],r})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors",children:(0,n.jsx)(nl.A,{className:"w-4 h-4"})})]},e)),(0,n.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,n.jsx)("input",{type:"text",value:c,onChange:e=>m(e.target.value),placeholder:l("envManager.varNamePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),b())}}),(0,n.jsx)("input",{type:"text",value:x,onChange:e=>h(e.target.value),placeholder:l("envManager.varValuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),b())}}),(0,n.jsx)("button",{onClick:b,disabled:!c.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,n.jsx)(ni.A,{className:"w-4 h-4"})})]}),0===Object.keys(i).length&&(0,n.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:l("envManager.noVars")})]})}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,n.jsx)("button",{onClick:r,className:"px-4 py-2 rounded-lg text-sm hover:bg-hover transition-colors",children:l("common.cancel")}),(0,n.jsx)("button",{onClick:v,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:l("common.save")})]})]})})}var nc=r(10762);function nu({onClose:e,onSave:t}){let{t:r}=(0,o.Bd)(),[a,l]=(0,s.useState)({}),[i,d]=(0,s.useState)(""),[c,m]=(0,s.useState)(""),[x,h]=(0,s.useState)(!0),f=(0,s.useCallback)(async()=>{h(!0);let e=await u.t4.runPromiseExit(tK());"Success"===e._tag?l(e.value):console.error("Failed to load aliases:",e.cause),h(!1)},[]);(0,s.useEffect)(()=>{f()},[f]);let p=()=>{i.trim()&&c.trim()&&(l(e=>({...e,[i.trim()]:c.trim()})),d(""),m(""))},g=async()=>{let r=await u.t4.runPromiseExit(tV("/api/terminal/aliases",{aliases:a}));"Success"===r._tag?(t(a),e()):console.error("Failed to save aliases:",r.cause)};return(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim flex items-center justify-center z-50",children:(0,n.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-lv3 w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,n.jsx)(nc.A,{className:"w-5 h-5"}),r("aliasManager.title")]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:r("aliasManager.description")})]}),(0,n.jsx)("button",{onClick:e,className:"p-1 rounded hover:bg-hover transition-colors",children:(0,n.jsx)(ea.A,{className:"w-5 h-5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:x?(0,n.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:r("common.loading")}):(0,n.jsxs)("div",{className:"space-y-3",children:[Object.entries(a).map(([e,t])=>(0,n.jsxs)("div",{className:"flex items-start gap-2 group",children:[(0,n.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,n.jsx)("input",{type:"text",value:e,disabled:!0,className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"})]}),(0,n.jsx)("input",{type:"text",value:t,onChange:t=>{var r;return r=t.target.value,void l(t=>({...t,[e]:r}))},placeholder:r("aliasManager.fullCommandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"})]}),(0,n.jsx)("button",{onClick:()=>{l(t=>{let r={...t};return delete r[e],r})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors opacity-0 group-hover:opacity-100",children:(0,n.jsx)(nl.A,{className:"w-4 h-4"})})]},e)),(0,n.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,n.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,n.jsx)("input",{type:"text",value:i,onChange:e=>d(e.target.value),placeholder:r("aliasManager.aliasPlaceholder"),className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),p())}})]}),(0,n.jsx)("input",{type:"text",value:c,onChange:e=>m(e.target.value),placeholder:r("aliasManager.commandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),p())}})]}),(0,n.jsx)("button",{onClick:p,disabled:!i.trim()||!c.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,n.jsx)(ni.A,{className:"w-4 h-4"})})]}),(0,n.jsxs)("div",{className:"mt-4 p-3 bg-accent rounded-lg",children:[(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,n.jsx)("strong",{children:r("aliasManager.usage")}),r("aliasManager.usageDesc")]}),(0,n.jsxs)("div",{className:"mt-2 space-y-1 text-xs text-muted-foreground",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ ll"}),(0,n.jsx)("span",{children:"→"}),(0,n.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"ls -la"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ gs"}),(0,n.jsx)("span",{children:"→"}),(0,n.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"git status"})]})]})]}),0===Object.keys(a).length&&(0,n.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:r("aliasManager.noAliases")})]})}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,n.jsx)("button",{onClick:e,className:"px-4 py-2 rounded-lg text-sm hover:bg-hover transition-colors",children:r("common.cancel")}),(0,n.jsx)("button",{onClick:g,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:r("common.save")})]})]})})}var nm=r(53961),nx=r(15813),nh=r(37595),nf=r(49698),np=r(20232);function ng({onAdd:e,onCancel:t}){let{t:r}=(0,o.Bd)(),[a,l]=(0,s.useState)(""),[i,d]=(0,s.useState)("");return(0,n.jsxs)("div",{className:"flex gap-1 mb-1",children:[(0,n.jsx)("input",{type:"text",value:a,onChange:e=>l(e.target.value),placeholder:r("console.namePlaceholder"),className:"w-24 flex-shrink-0 px-2 py-1 text-xs rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0,onKeyDown:e=>{"Escape"===e.key&&t()}}),(0,n.jsx)("input",{type:"text",value:i,onChange:e=>d(e.target.value),placeholder:r("console.commandPlaceholder"),className:"flex-1 min-w-0 px-2 py-1 text-xs font-mono rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring",onKeyDown:r=>{"Enter"!==r.key||r.nativeEvent.isComposing?"Escape"===r.key&&t():(r.preventDefault(),r.stopPropagation(),a.trim()&&i.trim()&&e(a.trim(),i.trim()))}})]})}function nb({label:e,commands:t,isAdding:r,onStartAdd:s,onAdd:a,onCancelAdd:l,onDelete:i,onExecute:d}){let{t:c}=(0,o.Bd)();return(0,n.jsxs)("div",{className:"p-2",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,n.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1",children:e}),(0,n.jsx)("button",{type:"button",onClick:s,className:"p-0.5 text-muted-foreground hover:text-foreground rounded",children:(0,n.jsx)(ni.A,{className:"w-3.5 h-3.5"})})]}),r&&(0,n.jsx)(ng,{onAdd:(e,t)=>a(e,t),onCancel:l}),0===t.length&&!r&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:c("console.noCustomCommands")}),t.map((e,t)=>(0,n.jsx)(E.m,{content:e.command,children:(0,n.jsxs)("div",{className:"flex items-center group min-w-0",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>d(e.command),className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1.5 text-left text-sm rounded hover:bg-hover transition-colors",children:[(0,n.jsx)(np.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"truncate",children:e.name})]}),(0,n.jsx)("button",{type:"button",onClick:()=>i(t),className:"p-1 text-muted-foreground hover:text-destructive rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:(0,n.jsx)(ea.A,{className:"w-3 h-3"})})]})},t))]})}function nv({cwd:e,show:t,onClose:r,onExecute:a,onAddPluginItem:l}){let{t:i}=(0,o.Bd)(),[d,c]=(0,s.useState)([]),[m,x]=(0,s.useState)([]),[h,f]=(0,s.useState)(null),p=(0,s.useRef)(null),g=(0,s.useCallback)(async()=>{let[t,r]=await Promise.all([u.t4.runPromiseExit(tO("/api/services/config?scope=global")),u.t4.runPromiseExit(tX(e))]);"Success"===t._tag&&c(t.value.customCommands||[]),"Success"===r._tag&&x(r.value.customCommands||[])},[e]);(0,s.useEffect)(()=>{t&&queueMicrotask(()=>g())},[t,g]),(0,s.useEffect)(()=>{if(!t)return;let e=e=>{p.current&&!p.current.contains(e.target)&&(r(),f(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t,r]);let b=(0,s.useCallback)(async e=>{c(e);let t=await u.t4.runPromiseExit(tY({scope:"global",customCommands:e}));"Failure"===t._tag?console.error("Failed to save global commands:",t.cause):t.value?.customCommands&&c(t.value.customCommands)},[]),v=(0,s.useCallback)(async t=>{x(t);let r=await u.t4.runPromiseExit(tY({cwd:e,customCommands:t}));"Failure"===r._tag?console.error("Failed to save project commands:",r.cause):r.value?.customCommands&&x(r.value.customCommands)},[e]),j=(0,s.useCallback)(e=>{r();let t=re(e);t?l?.(t.type,e.trim()):a(e)},[r,a,l]);return t?(0,n.jsxs)("div",{ref:p,className:"absolute bottom-full left-0 mb-2 w-72 bg-popover border border-border rounded-lg shadow-lv2 z-50 max-h-[70vh] overflow-y-auto",children:[(0,n.jsx)(nb,{label:i("console.globalCommands"),commands:d,isAdding:"global"===h,onStartAdd:()=>f("global"),onAdd:(e,t)=>{b([...d,{name:e,command:t}]),f(null)},onCancelAdd:()=>f(null),onDelete:e=>b(d.filter((t,r)=>r!==e)),onExecute:j}),(0,n.jsx)("div",{className:"border-t border-border"}),(0,n.jsx)(nb,{label:i("console.projectCommands"),commands:m,isAdding:"project"===h,onStartAdd:()=>f("project"),onAdd:(e,t)=>{v([...m,{name:e,command:t}]),f(null)},onCancelAdd:()=>f(null),onDelete:e=>v(m.filter((t,r)=>r!==e)),onExecute:j})]}):null}var nj=r(63040);function nw({cwd:e,currentCwd:t,commandHistoryRef:r,gridLayout:a,onGridLayoutChange:l,onExecute:i,onAddPluginItem:d,onShowEnvManager:c,onOpenShell:m,onOpenNote:x}){let{t:h}=(0,o.Bd)(),[f,p]=(0,s.useState)(""),[g,b]=(0,s.useState)(-1),[v,j]=(0,s.useState)(""),[w,k]=(0,s.useState)([]),[y,N]=(0,s.useState)(0),[C,S]=(0,s.useState)(!1),[L,M]=(0,s.useState)(!1),[E,P]=(0,s.useState)([]),[T,$]=(0,s.useState)([]),[R,B]=(0,s.useState)(!1),[F,I]=(0,s.useState)(0),D=(0,s.useRef)(null),A=(0,s.useRef)(null),z=(0,s.useRef)(!1),{projectCommands:H,globalCommands:W,expandCustomCommand:_,loadQuickCommands:O}=function(e){let[t,r]=(0,s.useState)([]),[n,o]=(0,s.useState)([]),a=(0,s.useCallback)(async()=>{let[t,n]=await Promise.all([u.t4.runPromiseExit(tX(e)),u.t4.runPromiseExit(tO("/api/services/config?scope=global"))]);"Success"===t._tag&&r(t.value.customCommands||[]),"Success"===n._tag&&o(n.value.customCommands||[])},[e]);(0,s.useEffect)(()=>{queueMicrotask(()=>a())},[a]);let l=[...t,...n],i=(0,s.useCallback)(e=>{let r=e.trim().split(/\s+/),s=r[0];if(!s.startsWith("/")||s.length<=1)return null;let o=s.slice(1),a=t.find(e=>e.name===o)??n.find(e=>e.name===o);return a?a.command+(r.length>1?" "+r.slice(1).join(" "):""):null},[t,n]);return{quickCustomCommands:l,projectCommands:t,globalCommands:n,expandCustomCommand:i,loadQuickCommands:a}}(e);(0,s.useEffect)(()=>{D.current?.focus()},[]),(0,s.useEffect)(()=>{let e=!1,t=()=>{u.t4.runPromiseExit((0,nj.mi)()).then(t=>{e||"Success"!==t._tag||P(t.value.filter(e=>!1!==e.valid&&e.name&&e.path).map(e=>({name:e.name,path:e.path})))})};t();let r=null;return"u">typeof BroadcastChannel&&(r=new BroadcastChannel("cockpit-html-apps")).addEventListener("message",e=>{e.data?.type==="changed"&&t()}),()=>{e=!0,r?.close()}},[]),(0,s.useEffect)(()=>{if(f.startsWith("/")){let e=f.slice(1).toLowerCase(),t=E.filter(t=>t.name.toLowerCase().startsWith(e)).map(e=>({kind:"html",name:e.name,path:e.path})),r=t=>"string"==typeof t?.name&&t.name.toLowerCase().startsWith(e),n=[...t,...[...H.filter(r).map(e=>({...e,scope:"project"})),...W.filter(r).map(e=>({...e,scope:"global"}))].map(e=>({kind:"cmd",cmd:e}))];queueMicrotask(()=>{$(n),B(n.length>0),I(0)})}else queueMicrotask(()=>B(!1))},[f,H,W,E]),(0,s.useEffect)(()=>{if(R&&A.current){let e=A.current.children[F];e?.scrollIntoView({block:"nearest"})}},[F,R]);let q=(0,s.useCallback)(e=>{if(B(!1),"html"===e.kind){d?.("browser",e.path),p("");return}let t=e.cmd.command,r=re(t);r?d?.(r.type,t.trim()):i(t),p("")},[i,d]),V=(0,s.useCallback)(e=>{if(e.preventDefault(),z.current||!f.trim())return;if(f.startsWith("/")){let e=f.slice(1).trim(),t=E.find(t=>t.name===e);if(t){d?.("browser",t.path),p(""),b(-1),j(""),B(!1);return}}let t=_(f)??f,r=re(t);r?d?.(r.type,t.trim()):i(t),p(""),b(-1),j("")},[f,i,d,_,E]),U=(0,s.useCallback)(async()=>{let e;if(!D.current)return;let r=D.current.selectionStart||0,n=await u.t4.runPromiseExit((e={cwd:t,input:f,cursorPosition:r},ep.tryPromise({try:async()=>{let t=await fetch("/api/terminal/autocomplete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(`HTTP ${t.status}`);return await t.json()},catch:e=>new eg.uV({message:"POST /api/terminal/autocomplete failed",cause:e})})));if("Success"===n._tag){let e=n.value,t=e.suggestions;if(t&&t.length>0&&(k(t),N(0),S(!0),1===t.length)){let n=f.substring(0,e.replaceStart??0),s=f.substring(e.replaceEnd??r);p(n+t[0]+s),S(!1),setTimeout(()=>{if(D.current){let r=(e.replaceStart??0)+t[0].length;D.current.setSelectionRange(r,r)}},0)}}else console.error("Autocomplete error:",n.cause)},[t,f]),K=(0,s.useCallback)(e=>{if(!D.current)return;let t=D.current.selectionStart||0,r=f.substring(0,t),n=f.substring(t),s=r.split(/\s+/),o=t-(s[s.length-1]||"").length;p(f.substring(0,o)+e+n),S(!1),setTimeout(()=>{if(D.current){let t=o+e.length;D.current.setSelectionRange(t,t)}},0)},[f]),G=(0,s.useCallback)(e=>{if(e.nativeEvent.isComposing)return;if(R&&T.length>0){if("ArrowUp"===e.key){e.preventDefault(),I(e=>(e-1+T.length)%T.length);return}if("ArrowDown"===e.key){e.preventDefault(),I(e=>(e+1)%T.length);return}if("Tab"===e.key||"Enter"===e.key){e.preventDefault(),q(T[F]);return}if("Escape"===e.key){e.preventDefault(),B(!1);return}}if("Tab"===e.key){if(e.preventDefault(),C&&w.length>0){let e=(y+1)%w.length;N(e),K(w[e])}else U();return}if("Escape"===e.key&&C){e.preventDefault(),S(!1);return}let t=r.current;if(t&&0!==t.length){if("ArrowUp"===e.key){e.preventDefault(),-1===g&&j(f);let r=-1===g?t.length-1:Math.max(0,g-1);b(r),p(t[r])}else if("ArrowDown"===e.key){if(e.preventDefault(),-1===g)return;let r=g+1;r>=t.length?(b(-1),p(v)):(b(r),p(t[r]))}}},[g,f,v,C,w,y,U,K,R,T,F,q,r]);return(0,n.jsx)("div",{className:"border-t border-border p-4",children:(0,n.jsxs)("form",{onSubmit:V,className:"relative flex gap-2 items-center",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{L||O(),M(!L)},className:`p-2 rounded-lg transition-all ${L?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:h("console.quickCommands"),children:(0,n.jsx)(nm.A,{className:"w-4 h-4"})}),(0,n.jsx)(nv,{cwd:e,show:L,onClose:()=>M(!1),onExecute:i,onAddPluginItem:d})]}),x&&(0,n.jsx)("button",{type:"button",onClick:x,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:h("chat.projectNotes"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,n.jsx)("button",{type:"button",onClick:()=>l(!a),className:`p-2 rounded-lg transition-all ${a?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:a?h("console.singleColumn"):h("console.dualColumn"),children:a?(0,n.jsx)(nx.A,{className:"w-4 h-4"}):(0,n.jsx)(nh.A,{className:"w-4 h-4"})}),(0,n.jsx)("button",{type:"button",onClick:c,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:h("console.envVars"),children:(0,n.jsx)(nf.A,{className:"w-4 h-4"})}),(0,n.jsx)("button",{type:"button",onClick:m,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:h("console.launchShell"),children:(0,n.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,n.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}),(0,n.jsx)("input",{ref:D,type:"text",value:f,onChange:e=>{p(e.target.value),-1!==g&&(b(-1),j("")),S(!1)},onKeyDown:G,onCompositionStart:()=>{z.current=!0},onCompositionEnd:()=>{z.current=!1},placeholder:h("console.inputPlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring font-mono"}),R&&T.length>0&&(0,n.jsx)("div",{ref:A,className:"absolute bottom-full left-0 right-0 mb-1 max-h-64 overflow-y-auto bg-popover border border-border rounded-lg shadow-lv2 z-50",children:T.map((e,t)=>(0,n.jsx)("div",{onClick:()=>q(e),className:`flex items-center gap-3 px-3 py-1.5 cursor-pointer text-sm ${t===F?"bg-brand/10":"hover:bg-hover"}`,children:"html"===e.kind?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"font-mono font-medium text-foreground",children:["/",e.name]}),(0,n.jsx)("span",{className:"flex-1 text-muted-foreground truncate",children:e.path}),(0,n.jsx)("span",{className:"text-[10px] text-brand/70 flex-shrink-0",children:"HTML"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"font-mono font-medium text-foreground",children:["/",e.cmd.name]}),(0,n.jsx)("span",{className:"flex-1 text-muted-foreground truncate",children:e.cmd.command}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground/60 flex-shrink-0",children:"project"===e.cmd.scope?h("console.scopeProject"):h("console.scopeGlobal")})]})},"html"===e.kind?`html-${e.name}`:`cmd-${e.cmd.scope}-${e.cmd.name}`))}),C&&w.length>1&&(0,n.jsxs)("div",{className:"absolute bottom-full left-0 mb-1 bg-popover border border-border rounded-lg shadow-lv2 max-h-48 overflow-y-auto z-50",children:[(0,n.jsx)("div",{className:"py-1",children:w.map((e,t)=>(0,n.jsx)("button",{type:"button",onClick:()=>K(e),className:`w-full px-3 py-1.5 text-left text-sm font-mono hover:bg-hover transition-colors ${t===y?"bg-accent":""}`,children:e},t))}),(0,n.jsx)("div",{className:"border-t border-border px-3 py-1 text-xs text-muted-foreground",children:h("console.tabSwitchEscClose")})]})]})})}function nk({showTop:e,showBottom:t,onScrollTop:r,onScrollBottom:s}){let{t:a}=(0,o.Bd)();return(0,n.jsxs)(n.Fragment,{children:[e&&(0,n.jsx)("button",{onClick:r,className:"absolute top-2 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-lv2 rounded-full transition-all hover:shadow-lv2 active:scale-95 z-10",title:a("chat.jumpToStart"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),t&&(0,n.jsx)("button",{onClick:s,className:"absolute bottom-20 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-lv2 rounded-full transition-all hover:shadow-lv2 active:scale-95 z-10",title:a("chat.jumpToLatest"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})}var ny=r(50605);function nN(){return`cmd-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}let nC="__cockpit_open_preferred_shell__",nS="shell",nL=new Set([nC,"zsh","bash","sh","fish","nu","python","python3","node","irb","lua","vim","nvim","vi","nano","emacs","top","htop","less","man"]),nM=[{key:"command",label:"console.bubbleCommand",triggers:["ls","git status","npm run dev"]},{key:"pty",label:"console.bubbleInteractive",triggers:["zsh","bash","vim","python"]},{key:"browser",label:"console.bubbleBrowser",triggers:["https://…","*.html"],notes:["console.bubbleBrowserNoteIframe","console.bubbleBrowserNoteCookie"]},{key:"database",label:"console.bubbleDatabase",triggers:["postgresql://","mysql://","redis://","neo4j://"]},{key:"filePreview",label:"console.bubbleFilePreview",triggers:[...J.GV]}],nE=(0,s.memo)(function({cwd:e,initialShellCwd:t,tabId:r,onCwdChange:a,onOpenNote:l}){let{t:i}=(0,o.Bd)(),{consoleItems:d,scrollRef:c,selectedCommandId:m,setSelectedCommandId:x,interruptCommand:h,sendStdin:f,deleteCommand:p,rerunCommand:g,ptySizeRef:b,resizePty:v,executeCommand:j,addPluginItem:w,closePluginItem:k,sleepingBubbles:y,handleBubbleSleep:N,handleBubbleWake:C,scrollToBottom:S,currentCwd:L,commandHistoryRef:M,setCustomEnv:E,setAliases:P,saveBubbleOrder:T,hasMoreHistory:$,loadHistory:R,currentPage:B,isLoadingHistory:F,subscribePtyOutput:I,subscribePtyReset:D,subscribePtyRefresh:A}=function({cwd:e,initialShellCwd:t,tabId:r,onCwdChange:n}){let[o,a]=(0,s.useState)([]),[l,i]=(0,s.useState)([]),[d,c]=(0,s.useState)(new Set),[m,x]=(0,s.useState)(t||e),[h,f]=(0,s.useState)(!1),[p,g]=(0,s.useState)(!1),[b,v]=(0,s.useState)(0),[j,w]=(0,s.useState)(null),[k,y]=(0,s.useState)({}),N=(0,s.useRef)(""),[C,S]=(0,s.useState)({}),[L,M]=(0,s.useState)(null),E=(0,s.useRef)(null),P=(0,s.useRef)(new Map),T=(0,s.useRef)(new Map),$=(0,s.useRef)(new Set),R=(0,s.useRef)([]),B=(0,s.useRef)(new Map),F=(0,s.useRef)(new Map),I=(0,s.useRef)(new Map),D=(0,s.useRef)(null),A=(0,s.useRef)(null),z=(0,s.useRef)([]),H=(0,s.useRef)("");H.current||(H.current="u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():`s_${Date.now()}_${Math.random().toString(36).slice(2)}`);let W=(0,s.useRef)(null);(0,s.useEffect)(()=>{n?.(e)},[]);let _=(0,s.useCallback)(()=>{if(P.current.size>0){let e=new Map(P.current);P.current.clear(),a(t=>t.map(t=>{let r=e.get(t.id);return void 0!==r?{...t,output:r}:t}))}E.current=null},[]),O=(0,s.useCallback)((e,t)=>{if($.current.has(e)){let r=F.current.get(e);if(r&&r.size>0)for(let e of r)e(t);else I.current.has(e)||I.current.set(e,[]),I.current.get(e).push(t);return}let r=(T.current.get(e)||"")+t;if(r.length>2097152){let t=function(e){let t=e.slice(-2097152),r=0;if(t.length>0){let e=t.charCodeAt(0);e>=56320&&e<=57343&&(r=1)}let n=Math.min(t.length,64);for(let e=r;e<n;e++){let n=t.charCodeAt(e);if(27===n){r=e;break}if((!(n>=48)||!(n<=63))&&59!==n&&63!==n&&32!==n){n>=64&&n<=126&&(r=e+1);break}}return r>0?t.slice(r):t}(r);T.current.set(e,t),P.current.set(e,t)}else T.current.set(e,r),P.current.set(e,r);null===E.current&&(E.current=requestAnimationFrame(_))},[_]),q=(0,s.useCallback)((e,t=!1)=>{T.current.delete(e),$.current.delete(e),P.current.delete(e),I.current.delete(e),t||(F.current.delete(e),U.current.delete(e))},[]),V=(0,s.useCallback)((e,t)=>{F.current.has(e)||F.current.set(e,new Set),F.current.get(e).add(t);let r=I.current.get(e);if(r&&r.length>0){for(let e of r)t(e);I.current.delete(e)}return()=>{F.current.get(e)?.delete(t)}},[]),U=(0,s.useRef)(new Map),K=(0,s.useCallback)((e,t)=>(U.current.has(e)||U.current.set(e,new Set),U.current.get(e).add(t),()=>{U.current.get(e)?.delete(t)}),[]),G=(0,s.useRef)(new Map),J=(0,s.useCallback)((e,t)=>(G.current.has(e)||G.current.set(e,new Set),G.current.get(e).add(t),()=>{G.current.get(e)?.delete(t)}),[]);(0,s.useEffect)(()=>{if(!L)return;let e=requestAnimationFrame(()=>{for(let e of G.current.values())for(let t of e)t()});return()=>cancelAnimationFrame(e)},[L]);let Q=(0,s.useCallback)(e=>(null!==E.current&&(cancelAnimationFrame(E.current),E.current=null),_(),T.current.get(e)||""),[_]),Z=(0,s.useCallback)(()=>{W.current&&(W.current.scrollTop=W.current.scrollHeight)},[]),X=(0,s.useCallback)(async(t=0)=>{if(r){f(!0);try{let n=await u.t4.runPromise(((e,t,r,n=100)=>tO(`/api/terminal/history?cwd=${encodeURIComponent(e)}&tabId=${encodeURIComponent(t)}&page=${r}&pageSize=${n}`))(e,r,t,100)).catch(e=>(console.error("Failed to load history:",e),null));if(n){let e=[],r=[],s=new Set;for(let t of n.entries){let n=t7(t.type);if(n){let e=n.fromHistory(t);r.push({id:t.id,_type:t.type,timestamp:t.timestamp,...e}),t.sleeping&&s.add(t.id)}else{if(t.running)continue;let r=t.id.includes("-")&&3===t.id.split("-").length?t.id:nN();e.push({id:r,command:t.command,output:t.output,exitCode:t.exitCode,isRunning:!1,timestamp:t.timestamp,cwd:t.cwd,usePty:t.usePty})}}0===t?(a(e),i(r),s.size>0&&c(s)):(a(t=>{let r=new Set(t.map(e=>e.id)),n=e.filter(e=>!r.has(e.id));return[...t,...n]}),i(e=>{let t=new Set(e.map(e=>e.id)),n=r.filter(e=>!t.has(e.id));return[...e,...n]})),g(n.hasMore),v(t)}}catch(e){console.error("Failed to load history:",e)}finally{f(!1)}}},[e,r]),Y=(0,s.useCallback)(async t=>{r&&await u.t4.runPromise(tQ(e,r,{id:t.id,command:t.command,output:t.output,exitCode:t.exitCode,timestamp:t.timestamp,cwd:m},H.current).pipe(ep.tapError(e=>ep.sync(()=>console.error("Failed to save cd history:",e))),ep.orElse(()=>ep.void)))},[e,r,m]),ee=(0,s.useCallback)(async t=>{try{let n=await (r4||(r4=ns(e)));if(t.current)return;for(let s of n){if(r&&s.tabId!==r)continue;if(t.current)break;let n=s.commandId;a(e=>e.find(e=>e.id===n)?e.map(e=>e.id===n?{...e,isRunning:!0,exitCode:void 0,pid:s.pid,...s.usePty?{usePty:!0}:{}}:e):[...e,{id:n,command:s.command,output:"",isRunning:!0,pid:s.pid,timestamp:s.timestamp,cwd:s.cwd,...s.usePty?{usePty:!0}:{}}]),T.current.set(n,""),s.usePty&&$.current.add(n),await ne({commandId:n,projectCwd:e,onData:(e,t)=>{if("pid"===e)"string"==typeof t.command&&a(e=>e.map(e=>e.id===n?{...e,command:t.command}:e));else if("stdout"===e||"stderr"===e)O(n,t.data);else if("exit"===e){let e=Q(n);q(n),a(r=>r.map(r=>r.id===n?{...r,output:e,exitCode:t.code,isRunning:!1,pid:void 0}:r))}},onError:()=>{a(e=>e.map(e=>e.id===n&&e.isRunning?{...e,isRunning:!1}:e))}})}}catch{}},[e,r,O,Q,q]),et=(0,s.useCallback)((t,r)=>{T.current.set(t,""),r&&$.current.add(t),ne({commandId:t,projectCwd:e,onData:(e,r)=>{if("pid"===e)a(e=>e.map(e=>e.id===t?{...e,pid:r.pid,..."string"==typeof r.command?{command:r.command}:{}}:e));else if("stdout"===e||"stderr"===e)O(t,r.data);else if("exit"===e){let e=Q(t);q(t),a(n=>n.map(n=>n.id===t?{...n,output:e,exitCode:r.code,isRunning:!1,pid:void 0}:n))}},onError:()=>{a(e=>e.map(e=>e.id===t&&e.isRunning?{...e,isRunning:!1}:e))}}).catch(()=>{})},[e,O,Q,q]),er=(0,s.useCallback)(e=>{let t=e?.id;if(!e||!t||z.current.some(e=>e.data.id===t))return;let r=e.type,n=r?t7(r):void 0;if(n)i(s=>s.some(e=>e.id===t)?s:[...s,{id:t,_type:r,timestamp:e.timestamp??new Date().toISOString(),...n.fromHistory(e)}]),e.sleeping&&c(e=>new Set(e).add(t));else{let r=!!e.running;a(n=>n.some(e=>e.id===t)?n:[...n,{id:t,command:e.command??"",output:e.output??"",exitCode:e.exitCode,isRunning:r,timestamp:e.timestamp??new Date().toISOString(),cwd:e.cwd,usePty:e.usePty}]),r&&et(t,!!e.usePty)}M(e=>e&&!e.includes(t)?[...e,t]:e)},[et]),es=(0,s.useCallback)(e=>{if("add"===e.op)e.entry&&er(e.entry);else if("rerun"===e.op){let t=e.entry,r=t?.id;if(!t||!r)return;if(!z.current.some(e=>e.data.id===r))return void er(t);let n=!!t.usePty;if(n){let e=U.current.get(r);if(e)for(let t of e)t()}q(r,n),a(e=>e.map(e=>e.id===r?{...e,output:"",exitCode:void 0,isRunning:!0,pid:void 0}:e)),et(r,n)}else if("update"===e.op){let t=e.id,r=e.fields;if(!t||!r)return;void 0!==r.sleeping&&c(e=>{let n=new Set(e);return r.sleeping?n.add(t):n.delete(t),n}),(void 0!==r.exitCode||void 0!==r.running)&&a(e=>e.map(e=>e.id===t?{...e,...void 0!==r.exitCode?{exitCode:r.exitCode}:{},...void 0!==r.running?{isRunning:r.running}:{}}:e))}else if("delete"===e.op){let t=e.id;if(!t)return;a(e=>e.filter(e=>e.id!==t)),i(e=>e.filter(e=>e.id!==t)),M(e=>e?e.filter(e=>e!==t):e),c(e=>{if(!e.has(t))return e;let r=new Set(e);return r.delete(t),r}),q(t)}else"clear"===e.op?(a([]),i([]),M([]),c(new Set)):"reorder"===e.op&&Array.isArray(e.order)&&M(e.order)},[er,et,q]);(0,en.h)({url:"/ws/global-state",enabled:!!e&&!!r,onMessage:t=>{"console-delta"!==t.type||t.cwd!==e||t.tabId!==r||t.sourceId&&t.sourceId===H.current||es(t)}});let eo=(0,s.useCallback)(async t=>{let s,o=t.trim().split(/\s+/),l=o[0],i=t;C[l]&&(i=C[l]+(o.length>1?" "+o.slice(1).join(" "):""));let d=re(i);if(d)return void A.current?.(d.type,i.trim());let c=nN(),u=new Date().toISOString(),h=(s=i.trim().split(/\s+/)[0],nL.has(s)),f={id:c,command:i===nC?nS:t,output:i!==t&&i!==nC?`→ ${i}
|
|
20
|
+
`:"",isRunning:!0,timestamp:u,cwd:m,...h?{usePty:!0}:{}};if(a(e=>e.some(e=>e.id===c)?e:[...e,f]),w(c),T.current.set(c,f.output),h&&$.current.add(c),setTimeout(Z,100),i.trim().startsWith("cd ")){let e=i.trim().substring(3).trim(),t=m;(0,ny.P)(e)?t=N.current?(0,ny.D)(e,N.current):m:e.startsWith("/")?t=e:".."===e?t=m.split("/").slice(0,-1).join("/")||"/":"."!==e&&(t=`${m}/${e}`.replace(/\/+/g,"/")),x(t),n?.(t),a(e=>e.map(e=>{if(e.id===c){let r={...e,output:`Changed directory to: ${t}`,exitCode:0,isRunning:!1};return Y(r),r}return e}));return}try{await r7({cwd:m,command:i,commandId:c,tabId:r||"",projectCwd:e,env:k,usePty:h,sourceId:H.current,onData:(e,t)=>{if("pid"===e)a(e=>e.map(e=>e.id===c?{...e,pid:t.pid,..."string"==typeof t.command?{command:t.command}:{}}:e));else if("stdout"===e||"stderr"===e)O(c,t.data);else if("exit"===e){let e=Q(c);q(c),a(r=>r.map(r=>r.id===c?{...r,output:e,exitCode:t.code,isRunning:!1,pid:void 0}:r))}},onError:e=>{let t=Q(c);q(c),a(r=>r.map(r=>r.id===c?{...r,output:t+`
|
|
21
|
+
Error: ${e}`,exitCode:1,isRunning:!1,pid:void 0}:r))}})}catch(t){let e=Q(c);q(c),a(r=>r.map(r=>r.id===c?{...r,output:e+`
|
|
22
|
+
Error: ${t.message}`,exitCode:1,isRunning:!1,pid:void 0}:r))}},[C,m,k,r,e,O,Q,q,Z,n,Y]),ea=(0,s.useCallback)(e=>{let t=o.find(t=>t.id===e);t?.isRunning&&t.pid&&nn(t.pid)},[o]),el=(0,s.useCallback)(async t=>{let n=o.find(e=>e.id===t);if(!n)return;n.isRunning&&n.pid&&(nn(n.pid),await new Promise(e=>setTimeout(e,200)));let s=n.command.trim().split(/\s+/),l=s[0],i=n.usePty&&n.command===nS,d=i?nC:n.command;!i&&C[l]&&(d=C[l]+(s.length>1?" "+s.slice(1).join(" "):""));let c=n.usePty||!1;if(c){let e=U.current.get(t);if(e)for(let t of e)t()}q(t,c);let u=d!==n.command?`→ ${d}
|
|
23
|
+
`:"";c||T.current.set(t,u),c&&$.current.add(t),a(e=>e.map(e=>e.id===t?{...e,output:c?"":u,exitCode:void 0,isRunning:!0,pid:void 0}:e));let x=B.current.get(t);try{await r7({cwd:n.cwd||m,command:d,commandId:t,tabId:r||"",projectCwd:e,env:k,usePty:c,sourceId:H.current,...c&&x?{cols:x.cols,rows:x.rows}:{},onData:(e,r)=>{if("pid"===e)a(e=>e.map(e=>e.id===t?{...e,pid:r.pid,..."string"==typeof r.command?{command:r.command}:{}}:e));else if("stdout"===e||"stderr"===e)O(t,r.data);else if("exit"===e){let e=Q(t);q(t),a(n=>n.map(n=>n.id===t?{...n,output:e,exitCode:r.code,isRunning:!1,pid:void 0}:n))}},onError:e=>{let r=Q(t);q(t),a(n=>n.map(n=>n.id===t?{...n,output:r+`
|
|
24
|
+
Error: ${e}`,exitCode:1,isRunning:!1,pid:void 0}:n))}})}catch(r){let e=Q(t);q(t),a(n=>n.map(n=>n.id===t?{...n,output:e+`
|
|
25
|
+
Error: ${r.message}`,exitCode:1,isRunning:!1,pid:void 0}:n))}},[o,C,m,k,r,e,O,Q,q]),ei=(0,s.useCallback)(async t=>{a(e=>e.filter(e=>e.id!==t)),q(t),r&&await u.t4.runPromise(tZ(e,r,t,H.current).pipe(ep.tapError(e=>ep.sync(()=>console.error("Failed to delete command:",e))),ep.orElse(()=>ep.void)))},[e,r,q]),ed=(0,s.useCallback)((t,n,s)=>{var o;let a=t7(t);if(!a)return;let l=a.parse(n);"cwd"in l&&!l.cwd&&(l.cwd=m);let d={id:(o=a.idPrefix,`${o}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`),_type:t,timestamp:new Date().toISOString(),...l};if(i(e=>[...e,d]),w(d.id),setTimeout(Z,100),s){let t=L&&L.length>0?[...L]:z.current.map(e=>e.data.id),n=t.indexOf(s);-1!==n?t.splice(n+1,0,d.id):t.push(d.id),M(t),r&&u.t4.runFork(tJ(e,r,t,H.current).pipe(ep.orElse(()=>ep.void)))}if(r){let n=a.toHistory(d);u.t4.runFork(tQ(e,r,{type:t,id:d.id,timestamp:d.timestamp,...n},H.current).pipe(ep.tapError(e=>ep.sync(()=>console.error(`Failed to save ${t} item:`,e))),ep.orElse(()=>ep.void)))}},[Z,e,r,L]),ec=(0,s.useCallback)(async t=>{let n=l.find(e=>e.id===t);if(i(e=>e.filter(e=>e.id!==t)),w(e=>e===t?null:e),c(e=>{let r=new Set(e);return r.delete(t),r}),n){let e=t7(n._type);e?.onClose?.(n)}r&&u.t4.runFork(tZ(e,r,t,H.current).pipe(ep.tapError(e=>ep.sync(()=>console.error("Failed to delete plugin item:",e))),ep.orElse(()=>ep.void)))},[l,e,r]);A.current=ed,D.current=eo;let eu=(0,s.useCallback)((t,n)=>{let s,o,a,l;r&&u.t4.runFork((s=e,o=r,a=t,l={sleeping:n},tq("/api/terminal/history",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:s,tabId:o,id:a,fields:l,sourceId:H.current})})).pipe(ep.orElse(()=>ep.void)))},[e,r]),em=(0,s.useCallback)(e=>{c(t=>new Set(t).add(e)),eu(e,!0)},[eu]),ex=(0,s.useCallback)(e=>{c(t=>{let r=new Set(t);return r.delete(e),r}),eu(e,!1)},[eu]),eh=(0,s.useCallback)(async t=>{M(t),r&&await u.t4.runPromise(tJ(e,r,t,H.current).pipe(ep.orElse(()=>ep.void)))},[e,r]),ef=(0,s.useMemo)(()=>{let e=[...o.map(e=>({type:"command",data:e})),...l.map(e=>({type:e._type,data:e}))];if(!L||0===L.length)return e.sort((e,t)=>new Date(e.data.timestamp).getTime()-new Date(t.data.timestamp).getTime());let t=new Map(L.map((e,t)=>[e,t])),r=[],n=[];for(let s of e)t.has(s.data.id)?r.push(s):n.push(s);return r.sort((e,r)=>t.get(e.data.id)-t.get(r.data.id)),n.sort((e,t)=>new Date(e.data.timestamp).getTime()-new Date(t.data.timestamp).getTime()),[...r,...n]},[o,l,L]);z.current=ef,(0,s.useEffect)(()=>{R.current=o.filter(e=>!e.isRunning&&e.command.trim()).map(e=>e.command)},[o]);let eg=async()=>{let t=await u.t4.runPromise(tU(e,r).pipe(ep.tapError(e=>ep.sync(()=>console.error("Failed to load env:",e))),ep.orElseSucceed(()=>({env:{},home:""}))));y(t.env),N.current=t.home},eb=async()=>{S(await u.t4.runPromise(tK().pipe(ep.tapError(e=>ep.sync(()=>console.error("Failed to load aliases:",e))),ep.orElseSucceed(()=>({})))))},ev=async()=>{if(!r)return;let t=await u.t4.runPromise(tO(tG(e,r)).pipe(ep.map(e=>e.order||[])).pipe(ep.orElseSucceed(()=>[])));t.length>0&&M(t)};return(0,s.useEffect)(()=>{let e={current:!1};return(async()=>{await X(0),e.current||await ee(e)})(),eg(),eb(),ev(),()=>{e.current=!0}},[X,ee]),(0,s.useEffect)(()=>()=>{null!==E.current&&cancelAnimationFrame(E.current)},[]),(0,s.useEffect)(()=>()=>{no()},[]),{commands:o,pluginItems:l,sleepingBubbles:d,consoleItems:ef,currentCwd:m,selectedCommandId:j,setSelectedCommandId:w,customEnv:k,setCustomEnv:y,aliases:C,setAliases:S,isLoadingHistory:h,hasMoreHistory:p,currentPage:b,scrollRef:W,commandHistoryRef:R,ptySizeRef:B,executeCommandRef:D,executeCommand:eo,interruptCommand:ea,rerunCommand:el,deleteCommand:ei,addPluginItem:ed,closePluginItem:ec,handleBubbleSleep:em,handleBubbleWake:ex,loadHistory:X,scrollToBottom:Z,saveBubbleOrder:eh,sendStdin:nt,resizePty:nr,subscribePtyOutput:V,subscribePtyReset:K,subscribePtyRefresh:J}}({cwd:e,initialShellCwd:t,tabId:r,onCwdChange:a}),[z,H]=(0,s.useState)(null),[W,_]=(0,s.useState)(0),[O,q]=(0,s.useState)(0),[V,U]=(0,s.useState)(!0),[K,G]=(0,s.useState)(!1),[J,Q]=(0,s.useState)(!1),[Z,X]=(0,s.useState)(!1),[Y,ee]=(0,s.useState)(!1),et=(0,s.useRef)(null),er=(0,s.useRef)(null),es=(0,s.useRef)(null),eo=(0,s.useRef)(!1),ea=(0,s.useRef)(null),el=(0,s.useRef)(null),ei=(0,s.useRef)([]);(0,s.useEffect)(()=>{ei.current=d},[d]);let ed=(0,s.useCallback)(()=>{let e=c.current;return!e||e.scrollHeight-e.scrollTop-e.clientHeight<50},[c]),ec=(0,s.useCallback)(()=>{let e=c.current;return!e||e.scrollTop<50},[c]),eu=(0,s.useCallback)(()=>{X(!ec()),ee(!ed())},[ed,ec]),em=(0,s.useCallback)(()=>{er.current?.scrollIntoView({behavior:"smooth"})},[]),ex=async()=>{let t=await u.t4.runPromiseExit(tO(`/api/project-settings?cwd=${encodeURIComponent(e)}`));if("Success"===t._tag){let e=t.value.settings;e?.gridLayout!==void 0&&U(e.gridLayout)}else console.error("Failed to load project settings:",t.cause)};(0,s.useEffect)(()=>{queueMicrotask(()=>ex())},[]);let eh=(0,s.useCallback)(()=>{eo.current=!0},[]),ef=(0,s.useCallback)((e,t)=>{if(!eo.current)return void e.preventDefault();eo.current=!1,ea.current=t,e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",t),e.currentTarget.style.opacity="0.4";let r=e.currentTarget.querySelector("[data-drag-handle]");if(r){let t=r.cloneNode(!0);t.style.cssText="position:fixed;top:-9999px;left:-9999px;width:"+r.offsetWidth+"px;background:hsl(var(--card));color:hsl(var(--foreground));box-shadow:var(--elevation-2);border-radius:8px;padding:4px 12px;opacity:0.9;",document.body.appendChild(t),e.dataTransfer.setDragImage(t,20,16),requestAnimationFrame(()=>document.body.removeChild(t))}},[]),eg=(0,s.useCallback)((e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",el.current=t},[]),eb=(0,s.useCallback)(e=>{e.preventDefault(),e.currentTarget.classList.add("ring-2","ring-brand")},[]),ev=(0,s.useCallback)(e=>{e.currentTarget.classList.remove("ring-2","ring-brand")},[]),ej=(0,s.useCallback)(e=>{e.preventDefault(),e.currentTarget.classList.remove("ring-2","ring-brand")},[]),ew=(0,s.useCallback)(e=>{e.currentTarget.style.opacity="1";let t=ea.current,r=el.current;if(ea.current=null,el.current=null,!t||!r||t===r)return;let n=ei.current.map(e=>e.data.id),s=n.indexOf(t),o=n.indexOf(r);if(-1===s||-1===o)return;let a=[...n];a[s]=r,a[o]=t,T(a)},[T]),ek=(0,s.useCallback)(e=>{H(t=>t===e?null:e)},[]),ey=(0,s.useCallback)((e,t)=>w("browser",e,t),[w]);(0,s.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"m"===e.key&&!e.shiftKey&&!e.altKey&&(e.preventDefault(),m&&ek(m))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[m,ek]),(0,s.useEffect)(()=>{let e=c.current;if(!e)return;let t=new ResizeObserver(([e])=>{q(e.contentRect.height)});return t.observe(e),q(e.clientHeight),()=>t.disconnect()},[c]),(0,s.useEffect)(()=>{let e=c.current;if(e)return z?_(e.clientHeight):(e.style.overflow="",_(0)),()=>{e&&(e.style.overflow="")}},[z,c]),(0,s.useEffect)(()=>{let e=c.current;if(!e||!z||!W)return;let t=requestAnimationFrame(()=>{let t=e.querySelector(`[data-bubble-id="${z}"]`);t&&t.scrollIntoView({block:"start"}),e.style.overflow="hidden"});return()=>cancelAnimationFrame(t)},[z,W,c]),(0,s.useEffect)(()=>{let e=e=>{let t=e.detail?.command;t&&j(t)};return window.addEventListener("execute-terminal-command",e),()=>window.removeEventListener("execute-terminal-command",e)},[j]),(0,s.useEffect)(()=>{let e=e=>{let t=e.detail?.url;t&&w("browser",t)};return window.addEventListener("console-open-browser",e),()=>window.removeEventListener("console-open-browser",e)},[w]);let eN=O>0?Math.floor((O-32-12)/2-41):void 0;return(0,n.jsxs)("div",{ref:et,className:"h-full flex flex-col bg-background relative",children:[(0,n.jsx)("div",{ref:c,onScroll:eu,className:`console-scroll-root flex-1 overflow-y-auto ${z?"":"py-4 px-4"}`,children:0===d.length?(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsxs)("div",{className:"w-full max-w-md flex flex-col gap-4 text-sm",children:[(0,n.jsx)("p",{className:"text-muted-foreground",children:i("console.emptyIntro")}),(0,n.jsx)("ul",{className:"flex flex-col gap-2",children:nM.map(e=>(0,n.jsxs)("li",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"w-16 flex-shrink-0 text-foreground font-medium",children:i(e.label)}),(0,n.jsxs)("span",{className:"flex-1 flex flex-col gap-1",children:[(0,n.jsx)("span",{className:"flex flex-wrap gap-1",children:e.triggers.map(e=>(0,n.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-xs font-mono text-muted-foreground",children:e},e))}),e.notes?.map(e=>(0,n.jsx)("span",{className:"text-xs leading-snug text-muted-foreground/70",children:i(e)},e))]})]},e.key))}),(0,n.jsxs)("button",{type:"button",onClick:()=>j(nC),title:i("console.launchShell"),className:"self-start flex items-center gap-2 px-4 py-2 rounded-lg border border-input bg-background text-sm text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 transition-all",children:[(0,n.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,n.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}),"New PTY"]})]})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{ref:er}),$&&(0,n.jsx)("div",{className:"flex justify-center mb-4",children:(0,n.jsx)("button",{onClick:()=>R(B+1),disabled:F,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors disabled:opacity-50",children:F?i("console.loadingMore"):i("console.loadMoreHistory")})}),(0,n.jsx)("div",{className:z?"flex flex-col gap-3":V?"grid grid-cols-2 gap-3":"flex flex-col gap-3",children:d.map(t=>(0,n.jsx)(na,{item:t,selected:m===t.data.id,maximized:z===t.data.id,initialSleeping:y.has(t.data.id),tabId:r,projectCwd:e,expandedHeight:W,bubbleContentHeight:eN,onDragStart:ef,onDragOver:eg,onDragEnter:eb,onDragLeave:ev,onDrop:ej,onDragEnd:ew,onSelectId:x,onInterruptId:h,onStdin:f,onDeleteCommand:p,onRerun:g,subscribePtyOutput:I,subscribePtyReset:D,subscribePtyRefresh:A,ptySizeRef:b,resizePty:v,onToggleMaximizeId:ek,onTitleMouseDown:eh,onClosePlugin:k,addBrowserItem:ey,onSleep:N,onWake:C},t.data.id))}),(0,n.jsx)("div",{ref:es})]})}),!z&&d.length>0&&(0,n.jsx)(nk,{showTop:Z,showBottom:Y,onScrollTop:em,onScrollBottom:S}),(0,n.jsx)(nw,{cwd:e,currentCwd:L,commandHistoryRef:M,gridLayout:V,onGridLayoutChange:t=>{U(t);u.t4.runFork(tV("/api/project-settings",{cwd:e,settings:{gridLayout:t}}).pipe(ep.tapError(e=>ep.sync(()=>console.error("Failed to save project settings:",e))),ep.orElse(()=>ep.void)))},onExecute:j,onAddPluginItem:w,onShowEnvManager:()=>G(!0),onOpenShell:()=>j(nC),onOpenNote:l}),K&&(0,n.jsx)(nd,{cwd:e,tabId:r,onClose:()=>G(!1),onSave:e=>E(e)}),J&&(0,n.jsx)(nu,{onClose:()=>Q(!1),onSave:e=>P(e)})]})});var nP=r(83897),nT=r(38987),n$=r(89039),nR=r(76412),nB=r(24058),nF=r(1709),nI=r(98307),nD=r(65153),nA=r(45720);function nz({cwd:e,sessionId:t,engine:r,onOpenProjectSessions:a,onOpenSessionBrowser:l,onOpenSettings:i}){let{t:d}=(0,o.Bd)(),[c,u]=(0,s.useState)(!1),m=t?(0,nA.X)(r,t):null;return(0,n.jsx)("div",{className:"border-b border-border px-4 py-3 bg-card",children:(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6"}),(0,n.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"One seat. One AI. Everything under control."})]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[e&&(0,n.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help","data-tooltip":`CWD: ${e}`,children:e}),!e&&t&&(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Session: ",t.slice(0,8),"..."]}),e&&(0,n.jsx)("button",{onClick:a,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:d("sessions.projectSessions"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),(0,n.jsx)("button",{onClick:l,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:d("sessions.browseAllSessions"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),m&&(0,n.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(m).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)})},className:`p-2 rounded-lg transition-colors ${c?"text-green-11 bg-green-500/10":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:c?d("chat.copiedCommandTooltip"):d("chat.copyCommandTooltip",{command:m}),children:c?(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),(0,n.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:d("settings.title"),children:(0,n.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})]})})}function nH({tokenUsage:e,rateLimitInfo:t}){let{t:r}=(0,o.Bd)(),[a,l]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{if(!t?.resetsAt)return;let e=setInterval(()=>l(Date.now()),3e4);return()=>clearInterval(e)},[t?.resetsAt]);let i=t?.status==="rejected"?"text-red-11":t?.status==="allowed_warning"?"text-amber-11":"text-muted-foreground",d=t?.status==="rejected"?r("chat.rateLimitRejected","Rate Limited"):t?.status==="allowed_warning"?r("chat.rateLimitWarning","Approaching Limit"):null,c=e=>{if(!e)return"";let t=(e<1e12?1e3*e:e)-a;if(t<=0)return"";let r=Math.ceil(t/6e4);if(r<60)return`${r}m`;let n=Math.floor(r/60),s=r%60;return s>0?`${n}h${s}m`:`${n}h`},u=e=>e?e.replace(/_/g," "):"";return(0,n.jsx)("div",{className:"px-4 py-1.5 border-t border-border ",children:(0,n.jsxs)("div",{className:"flex items-center justify-end gap-4 text-xs text-muted-foreground",children:[t&&d&&(0,n.jsxs)("span",{className:`flex items-center gap-1 ${i}`,"data-tooltip":[t.rateLimitType&&`Type: ${u(t.rateLimitType)}`,null!=t.utilization&&`Usage: ${(100*t.utilization).toFixed(0)}%`,t.resetsAt&&`Resets in: ${c(t.resetsAt)}`,t.isUsingOverage&&"Using overage"].filter(Boolean).join(" \xb7 "),children:["rejected"===t.status?(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}):(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:d}),null!=t.utilization&&` ${(100*t.utilization).toFixed(0)}%`,t.resetsAt&&` \xb7 ${c(t.resetsAt)}`]})]}),t&&!d&&t.resetsAt&&(0,n.jsxs)("span",{className:"flex items-center gap-1.5","data-tooltip":[t.rateLimitType&&u(t.rateLimitType),null!=t.utilization&&`Usage: ${(100*t.utilization).toFixed(0)}%`,`Resets in: ${c(t.resetsAt)}`].filter(Boolean).join(" \xb7 "),children:[(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),null!=t.utilization?(0,n.jsxs)("span",{children:[(100*t.utilization).toFixed(0),"%"]}):(0,n.jsx)("span",{children:c(t.resetsAt)})]}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,n.jsxs)("span",{children:[r("chat.context"),": ",(0,n.jsx)("strong",{className:"text-foreground",children:(e.inputTokens+e.cacheReadInputTokens+e.cacheCreationInputTokens).toLocaleString()})]})]}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),(0,n.jsxs)("span",{children:[r("chat.output"),": ",(0,n.jsx)("strong",{className:"text-foreground",children:e.outputTokens.toLocaleString()})]})]}),(e.cacheReadInputTokens>0||e.cacheCreationInputTokens>0)&&(0,n.jsxs)("span",{className:"flex items-center gap-1 text-brand",children:[(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})}),(0,n.jsxs)("span",{children:["Cache: ",(e.cacheReadInputTokens/(e.inputTokens+e.cacheReadInputTokens+e.cacheCreationInputTokens)*100).toFixed(0),"%"]})]}),e.totalCostUsd>0&&(0,n.jsxs)("span",{className:"flex items-center gap-1 text-green-11",children:[(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,n.jsxs)("span",{children:["$",e.totalCostUsd.toFixed(4)]})]})]})})}function nW({isOpen:e,onClose:t,cwd:r,sessionId:a,onSelectMessage:l}){let{t:i}=(0,o.Bd)(),[d,c]=(0,s.useState)(null),[x,h]=(0,s.useState)(!1),[f,p]=(0,s.useState)(""),[b,v]=(0,s.useState)(null),j=(0,s.useRef)(null),w=(0,s.useRef)(null);(0,I.E)(t,e),(0,s.useEffect)(()=>{if(!e){c(null),h(!1),p(""),v(null);return}if(!r||!a)return void c([]);let t=!1;return u.t4.runPromiseExit((0,m.nM)(r,a)).then(e=>{t||("Success"===e._tag?c(e.value.messages):(console.error("Failed to load user message index:",e.cause),h(!0),c([])))}),()=>{t=!0}},[e,r,a]);let k=(0,s.useMemo)(()=>{if(!d)return[];let e=d.map((e,t)=>({entry:e,ordinal:t+1})),t=f.trim().toLowerCase();return t?e.filter(e=>e.entry.content.toLowerCase().includes(t)):e},[d,f]),y=f.trim().length>0;(0,s.useEffect)(()=>{if(!e||y||!d)return;let t=j.current;t&&(t.scrollTop=t.scrollHeight)},[e,y,d]);let N=(0,s.useCallback)(async e=>{v(e.id);try{await l(e)}finally{v(null)}t()},[l,t]);if(!e)return null;let C=null===d,S=(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:t,children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-2xl max-h-[85vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-foreground",children:i("userMessages.title")}),d&&d.length>0&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:i("userMessages.count",{shown:k.length,total:d.length})})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("input",{ref:w,type:"text",autoFocus:!0,placeholder:i("userMessages.searchPlaceholder"),value:f,onChange:e=>p(e.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),f&&(0,n.jsx)("button",{onClick:()=>{p(""),w.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:i("fileBrowser.clear"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,n.jsx)("div",{ref:j,className:"flex-1 overflow-y-auto",children:C?(0,n.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground text-sm",children:i("common.loading")}):x?(0,n.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground text-sm",children:i("userMessages.loadFailed")}):0===d.length?(0,n.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:i("userMessages.noMessages")}):0===k.length?(0,n.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:i("userMessages.noResults")}):(0,n.jsx)("div",{className:"divide-y divide-border",children:k.map(({entry:e,ordinal:t})=>{let r=e.timestamp?function(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return"";let r=new Date;return t.toDateString()===r.toDateString()?t.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}(e.timestamp):"";return(0,n.jsx)("button",{onClick:()=>{N(e)},className:"w-full px-4 py-3 text-left hover:bg-hover transition-colors",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsxs)("span",{className:"text-xs text-muted-foreground font-mono w-6 shrink-0 pt-0.5",children:[t,"."]}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("p",{className:"text-sm text-foreground truncate",children:e.content.replace(/\s+/g," ").trim()}),b===e.id&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:i("userMessages.jumping")})]}),r&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground shrink-0 pt-0.5",children:r})]})},e.id)})})})]})});return(0,n.jsx)(g.ZL,{children:S})}var n_=r(67589),nO=r(20917),nq=r(74086),nV=r(46266);function nU({image:e,onClose:t}){let{t:r}=(0,o.Bd)(),s=async t=>{t.stopPropagation();try{var n;if(!navigator.clipboard?.write||"u"<typeof ClipboardItem)throw Error("Clipboard image write is unavailable");let t=await (n=e.preview,new Promise((e,t)=>{let r=new Image;r.onload=()=>{let n=document.createElement("canvas");n.width=r.naturalWidth,n.height=r.naturalHeight;let s=n.getContext("2d");s?(s.drawImage(r,0,0),n.toBlob(r=>{r?e(r):t(Error("Could not encode image"))},"image/png")):t(Error("Canvas is unavailable"))},r.onerror=()=>t(Error("Could not load image")),r.src=n}));await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),(0,P.oR)(r("imagePreview.copiedImage"),"success")}catch{(0,P.oR)(r("common.copyFailed"),"error")}},a=(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[(0,n.jsxs)("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:s,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:r("imagePreview.copyImage"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V5a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2M7 7h6a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z"})})}),(0,n.jsx)("button",{type:"button",onClick:t,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:r("common.close"),children:(0,n.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("img",{src:e.preview,alt:r("imagePreview.previewImage"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]});return(0,n.jsx)(g.ZL,{children:a})}function nK({images:e,onRemove:t,disabled:r}){let{t:a}=(0,o.Bd)(),[l,i]=(0,s.useState)(null);return 0===e.length?null:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"flex flex-wrap gap-2 p-2 border-b border-border",children:e.map(e=>(0,n.jsxs)("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-border cursor-pointer",onClick:()=>i(e),children:[(0,n.jsx)("img",{src:e.preview,alt:a("imagePreview.previewImage"),className:"w-full h-full object-cover hover:opacity-90 transition-opacity"}),(0,n.jsx)("button",{onClick:r=>{r.stopPropagation(),t(e.id)},className:"absolute top-0 right-0 w-5 h-5 bg-black/60 hover:bg-black/80 text-white text-xs flex items-center justify-center rounded-bl-lg opacity-0 group-hover:opacity-100 transition-opacity",title:a("imagePreview.deleteImage"),children:"✕"})]},e.id))}),l&&(0,n.jsx)(nU,{image:l,onClose:()=>i(null)})]})}var nG=r(93777),nJ=r(59883),nQ=r(56204),nZ=r(36351),nX=r(49387);function nY({initialValue:e,placeholder:t,onCommit:r,onCancel:o}){let[a,l]=(0,s.useState)(e),i=(0,s.useCallback)(e=>{if("Enter"!==e.key||e.nativeEvent.isComposing)"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),o());else{e.preventDefault(),e.stopPropagation();let t=a.trim();t&&r(t)}},[a,r,o]);return(0,n.jsx)("input",{type:"text",value:a,onChange:e=>l(e.target.value),onKeyDown:i,placeholder:t,autoFocus:!0,className:"w-full min-w-0 px-2 py-1 mb-1 text-xs rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring"})}function n0({label:e,prompts:t,isAdding:r,onStartAdd:a,onCancelAdd:l,onAdd:i,onUpdate:d,onDelete:c,onReorder:u,onSelect:m,onInsert:x}){let{t:h}=(0,o.Bd)(),[f,p]=(0,s.useState)(null),[g,b]=(0,s.useState)(null),[v,j]=(0,s.useState)(null),w=(0,s.useCallback)(()=>{b(null),j(null)},[]),k=(0,s.useCallback)((e,t)=>{e.preventDefault(),j(t)},[]),y=(0,s.useCallback)(e=>{if(null===g||g===e)return void w();let r=[...t],[n]=r.splice(g,1);r.splice(e,0,n),w(),p(null),u(r)},[g,t,u,w]);return(0,n.jsxs)("div",{className:"p-2",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,n.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1",children:e}),(0,n.jsx)("button",{type:"button",onClick:()=>{p(null),a()},className:"p-0.5 text-muted-foreground hover:text-foreground rounded",title:h("chat.addQuickPrompt"),children:(0,n.jsx)(ni.A,{className:"w-3.5 h-3.5"})})]}),r&&(0,n.jsx)(nY,{initialValue:"",placeholder:h("chat.quickPromptPlaceholder"),onCommit:i,onCancel:l}),0===t.length&&!r&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:h("chat.noQuickPrompts")}),t.map((e,t)=>f===t?(0,n.jsx)(nY,{initialValue:e,placeholder:h("chat.quickPromptPlaceholder"),onCommit:e=>{p(null),d(t,e)},onCancel:()=>p(null)},`edit-${t}`):(0,n.jsxs)("div",{draggable:!0,onDragStart:()=>b(t),onDragOver:e=>k(e,t),onDrop:()=>y(t),onDragEnd:w,className:`flex items-center group min-w-0 rounded transition-opacity ${g===t?"opacity-50":""} ${v===t&&g!==t?"border-t-2 border-brand":""}`,children:[(0,n.jsx)(nJ.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"}),(0,n.jsx)(E.m,{content:e,children:(0,n.jsxs)("button",{type:"button",onClick:()=>m(e),className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1.5 text-left text-sm rounded hover:bg-hover transition-colors",children:[(0,n.jsx)(nQ.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"truncate",children:e})]})}),(0,n.jsx)("button",{type:"button",onClick:()=>x(e),className:"p-1 text-muted-foreground hover:text-foreground rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",title:h("chat.insertQuickPrompt"),children:(0,n.jsx)(nZ.A,{className:"w-3 h-3"})}),(0,n.jsx)("button",{type:"button",onClick:()=>p(t),className:"p-1 text-muted-foreground hover:text-foreground rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",title:h("common.edit"),children:(0,n.jsx)(nX.A,{className:"w-3 h-3"})}),(0,n.jsx)("button",{type:"button",onClick:()=>{p(null),c(t)},className:"p-1 text-muted-foreground hover:text-destructive rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",title:h("common.delete"),children:(0,n.jsx)(ea.A,{className:"w-3 h-3"})})]},t))]})}function n1({cwd:e,anchorRef:t,onClose:r,onSelect:a,onInsert:l}){let{t:i}=(0,o.Bd)(),[d,c]=(0,s.useState)([]),[x,h]=(0,s.useState)([]),[f,p]=(0,s.useState)(null);(0,s.useEffect)(()=>{let t=!1;return(async()=>{let[r,n]=await Promise.all([u.t4.runPromiseExit((0,m.XO)()),e?u.t4.runPromiseExit((0,m.tf)(e)):null]);!t&&("Success"===r._tag?c(r.value.prompts??[]):console.error("Failed to load global prompts:",r.cause),n&&"Success"===n._tag?h(n.value.prompts??[]):n&&console.error("Failed to load project prompts:",n.cause))})(),()=>{t=!0}},[e]),(0,s.useEffect)(()=>{let e=e=>{let n=t.current;n&&!n.contains(e.target)&&r()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t,r]);let g=(0,s.useCallback)(async(t,r)=>{let n="global"===t?c:h;n(r);let s=await u.t4.runPromiseExit((0,m.tY)("global"===t?{scope:"global",prompts:r}:{cwd:e,prompts:r}));"Failure"===s._tag?console.error(`Failed to save ${t} prompts:`,s.cause):s.value?.prompts&&n(s.value.prompts)},[e]),b=(0,s.useCallback)(e=>{r(),a(e)},[r,a]),v=(0,s.useCallback)(e=>{r(),l(e)},[r,l]);return(0,n.jsxs)("div",{className:"absolute bottom-full left-0 mb-2 w-80 max-w-[calc(100vw-1.5rem)] bg-popover border border-border rounded-lg shadow-lv2 z-50 max-h-[70vh] overflow-y-auto",children:[(0,n.jsx)(n0,{label:i("chat.globalPrompts"),prompts:d,isAdding:"global"===f,onStartAdd:()=>p("global"),onCancelAdd:()=>p(null),onAdd:e=>{g("global",[...d,e]),p(null)},onUpdate:(e,t)=>g("global",d.map((r,n)=>n===e?t:r)),onDelete:e=>g("global",d.filter((t,r)=>r!==e)),onReorder:e=>g("global",e),onSelect:b,onInsert:v}),e&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"border-t border-border"}),(0,n.jsx)(n0,{label:i("chat.projectPrompts"),prompts:x,isAdding:"project"===f,onStartAdd:()=>p("project"),onCancelAdd:()=>p(null),onAdd:e=>{g("project",[...x,e]),p(null)},onUpdate:(e,t)=>g("project",x.map((r,n)=>n===e?t:r)),onDelete:e=>g("project",x.filter((t,r)=>r!==e)),onReorder:e=>g("project",e),onSelect:b,onInsert:v})]})]})}var n2=r(96625);let n5=(0,s.memo)(function({onSend:e,disabled:t,cwd:r,engine:a,onShowGitStatus:l,onShowComments:i,onShowUserMessages:d,onOpenNote:c,onCreateScheduledTask:u,draft:m,setDraft:x,draftImages:h,setDraftImages:f}){let{t:p}=(0,o.Bd)(),g=(0,s.useState)(""),b=(0,s.useState)([]),[v,j]=void 0!==m&&x?[m,x]:g,[w,k]=void 0!==h&&f?[h,f]:b,[y,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),L=(0,s.useRef)(null),M=(0,s.useRef)(null),E=(0,s.useCallback)(()=>{let e=L.current;if(!e)return;e.style.height="auto";let t=Math.max(38,Math.min(e.scrollHeight,200));e.style.height=`${t}px`},[]);(0,s.useLayoutEffect)(()=>{E()},[v,E]);let P=(0,s.useMemo)(()=>a&&"claude"!==a?[]:[{name:"/plan",description:"Enable plan mode (read-only). /plan <task> to plan a task; /plan off to disable.",source:"builtin",argumentHint:"[task|off]"}],[a]),T=(0,n2.n)({value:v,onChange:j,textareaRef:L,extraCommands:P}),$=(0,s.useCallback)(()=>{let r=v.trim();(r||w.length>0)&&!t&&(e(r,w.length>0?w:void 0),j(""),k([]),L.current&&(L.current.style.height="auto"))},[v,w,t,e]),R=(0,s.useCallback)(r=>{t||e(r)},[t,e]),B=(0,s.useCallback)(e=>{j(t=>{let r=t.replace(/\s+$/,"");return r?`${r}
|
|
26
|
+
${e}`:e}),requestAnimationFrame(()=>{let e=L.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))})},[]),F=(0,s.useCallback)(e=>{e.nativeEvent.isComposing||!T.handleKeyDown(e)&&("Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),$()))},[T,$]),I=(0,s.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let r=["image/png","image/jpeg","image/webp","image/gif"];for(let n of Array.from(t)){let t=r.find(e=>n.type===e);if(t){e.preventDefault();let r=n.getAsFile();if(!r)continue;if(r.size>5242880){alert(p("chat.imageSizeLimit",{size:(r.size/1024/1024).toFixed(2)}));continue}let s=new FileReader;s.onload=e=>{let r=e.target?.result;if(!r)return;let n=r.replace(/^data:image\/\w+;base64,/,""),s={id:`img-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,data:n,preview:r,media_type:t};k(e=>[...e,s])},s.readAsDataURL(r)}}},[p]),D=(0,s.useCallback)(e=>{k(t=>t.filter(t=>t.id!==e))},[]);return(0,n.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,n.jsx)(nK,{images:w,onRemove:D,disabled:t}),(0,n.jsx)(n2.V,{ac:T,className:"absolute bottom-full left-0 right-0 mx-4 mb-2 max-h-64"}),(0,n.jsxs)("div",{className:"flex gap-2 items-end p-4",children:[l&&(0,n.jsx)("button",{onClick:l,className:"p-2 text-brand hover:text-teal-10 hover:bg-brand/10 active:bg-brand/20 active:scale-95 rounded-lg transition-all",title:p("chat.viewGitChanges"),children:(0,n.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"6",cy:"6",r:"2",strokeWidth:2}),(0,n.jsx)("circle",{cx:"18",cy:"6",r:"2",strokeWidth:2}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"2",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 8v10M18 8v4c0 2-2 4-6 4"})]})}),i&&(0,n.jsx)("button",{onClick:i,className:"p-2 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95 rounded-lg transition-all",title:p("chat.viewAllComments"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),d&&(0,n.jsx)("button",{onClick:d,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:p("chat.userMessages"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),c&&(0,n.jsx)("button",{onClick:c,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:p("chat.projectNotes"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),u&&(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("button",{onClick:()=>N(!y),className:`p-2 rounded-lg transition-all ${y?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:p("chat.scheduledTasks"),children:(0,n.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]})}),y&&(0,n.jsx)(nG.E,{onClose:()=>N(!1),onCreate:u})]}),(0,n.jsxs)("div",{className:"relative",ref:M,children:[(0,n.jsx)("button",{onClick:()=>S(!C),className:`p-2 rounded-lg transition-all ${C?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:p("chat.quickPrompts"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),C&&(0,n.jsx)(n1,{cwd:r,anchorRef:M,onClose:()=>S(!1),onSelect:R,onInsert:B})]}),(0,n.jsx)("textarea",{ref:L,value:v,onChange:e=>{j(e.target.value),T.trackCaret(e.target)},onSelect:e=>T.trackCaret(e.currentTarget),onKeyDown:F,onPaste:I,placeholder:t?p("chat.placeholderDisabled"):p("chat.placeholder"),rows:1,className:"flex-1 resize-none px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-ring bg-card text-foreground"})]})]})});var n4=r(57125);function n3(e){return"env"===e?"from env var":"default"===e?"default":null}function n6({currentModel:e,onModelChange:t}){let[r,o]=(0,s.useState)(!1),[a,l]=(0,s.useState)([]),[i,d]=(0,s.useState)(!1),[c,x]=(0,s.useState)(null),[h,f]=(0,s.useState)(!1),[p,b]=(0,s.useState)(!1),[v,j]=(0,s.useState)(!1),[w,k]=(0,s.useState)(null),[y,N]=(0,s.useState)(""),[C,S]=(0,s.useState)("default"),[L,M]=(0,s.useState)(!1),[E,P]=(0,s.useState)(""),[T,$]=(0,s.useState)("default"),[R,B]=(0,s.useState)(""),[F,I]=(0,s.useState)(!1),D=(0,s.useRef)(null),A=(0,s.useRef)(null),z=(0,s.useRef)(null),[H,W]=(0,s.useState)({top:0,left:0}),_=(0,g.F2)();(0,s.useEffect)(()=>{if(!r)return;let e=e=>{A.current&&!A.current.contains(e.target)&&D.current&&!D.current.contains(e.target)&&o(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]);let O=(0,s.useCallback)(async()=>{d(!0),x(null);let e=await u.t4.runPromiseExit((0,m.qD)(()=>f(!0)));if(f(!1),"Failure"===e._tag)x("Connection error");else{let t=e.value;switch(t._tag){case"ok":l(t.models);break;case"not-installed":case"error":x(t.message);break;case"not-running":x("Ollama is not running")}}d(!1)},[]),q=(0,s.useCallback)(e=>{N(e.baseUrl),S(e.baseUrlSource),M(e.hasKey),P(e.maskedKey),$(e.keySource),B(""),I(!1)},[]),V=(0,s.useCallback)(async()=>{b(!0),k(null);let e=await u.t4.runPromiseExit((0,m.F4)());"Failure"===e._tag?k("Failed to load config"):q(e.value),b(!1)},[q]),U=async()=>{j(!0),k(null);let e=await u.t4.runPromiseExit((0,m.yS)({baseUrl:y}));"Failure"===e._tag?k("Save failed"):(q(e.value),await O()),j(!1)},K=async()=>{let e=R.trim();if(!e)return;j(!0),k(null);let t=await u.t4.runPromiseExit((0,m.yS)({apiKey:e}));"Failure"===t._tag?k("Save failed"):q(t.value),j(!1)},G=async()=>{j(!0),k(null);let e=await u.t4.runPromiseExit((0,m.yS)({apiKey:""}));"Failure"===e._tag?k("Clear failed"):q(e.value),j(!1)},J=e?e.replace(/:latest$/,""):"Select model",Q=n3(C),Z=n3(T),X=r?(0,n.jsx)(g.ZL,{children:(0,n.jsxs)("div",{ref:A,className:`${n4.ys} min-w-[300px]`,style:{top:H.top,left:H.left},children:[(0,n.jsxs)("div",{className:"px-3 py-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,n.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Server URL"}),Q&&!p&&(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:Q})]}),p?(0,n.jsxs)("div",{className:"flex items-center gap-2 py-1 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{type:"text",value:y,onChange:e=>N(e.target.value),onKeyDown:e=>{"Enter"===e.key&&U()},placeholder:"http://127.0.0.1:11434",spellCheck:!1,className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${n4.Fx}`}),(0,n.jsx)("button",{onClick:U,disabled:v,className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${n4.$T}`,children:v?"...":"Save"})]})]}),(0,n.jsxs)("div",{className:"px-3 py-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,n.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"API Key"}),Z&&L&&!p&&(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:Z})]}),p?null:L&&!F?(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:E}),(0,n.jsx)("button",{onClick:()=>{I(!0),B(""),setTimeout(()=>z.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-hover text-foreground transition-colors",disabled:v,children:"Edit"}),(0,n.jsx)("button",{onClick:G,className:"text-[11px] px-2 py-1 rounded text-red-11 hover:bg-red-500/10 transition-colors",disabled:v,children:"Clear"})]}):(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{ref:z,type:"password",value:R,onChange:e=>B(e.target.value),onKeyDown:e=>{"Enter"===e.key&&K()},placeholder:"optional — for authenticated servers",spellCheck:!1,className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${n4.Fx}`}),(0,n.jsx)("button",{onClick:K,disabled:v||!R.trim(),className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${n4.$T}`,children:v?"...":"Save"}),L&&(0,n.jsx)("button",{onClick:()=>{I(!1),B("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),w&&(0,n.jsx)("div",{className:"mt-1 text-[11px] text-red-11",children:w})]}),(0,n.jsx)("div",{className:"my-1 border-t border-border"}),(0,n.jsx)("div",{className:"px-3 pt-1 pb-0.5",children:(0,n.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Model"})}),(0,n.jsx)("div",{className:"max-h-[240px] overflow-y-auto",children:i||h?(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),h?"Starting Ollama...":"Loading models..."]}):c?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-red-11",children:c}):0===a.length?(0,n.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models found. Run ",(0,n.jsx)("code",{className:"bg-secondary px-1 rounded",children:"ollama pull <model>"})]}):a.map(r=>{var s;let a=r.name===e;return(0,n.jsxs)("button",{onClick:()=>{t(r.name),o(!1)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors ${a?n4.yI:"text-foreground hover:bg-hover"}`,children:[(0,n.jsx)(n4.hG,{selected:a}),(0,n.jsx)("span",{className:"truncate",children:r.name.replace(/:latest$/,"")}),(0,n.jsx)("span",{className:"ml-auto pl-2 text-muted-foreground flex-shrink-0",children:r.parameter_size||((s=r.size)<1e9?`${(s/1e6).toFixed(0)}M`:`${(s/1e9).toFixed(1)}G`)})]},r.name)})})]})}):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(n4.XY,{buttonRef:D,label:J,title:"Configure Ollama",onClick:()=>{if(!r){if(D.current){let e=D.current.getBoundingClientRect(),t=_?.getBoundingClientRect(),r=t?.left??0,n=t?.top??0;W({top:e.bottom+4-n,left:e.left-r})}V(),O()}o(e=>!e)},icon:(0,n.jsx)(n4.eV,{engine:"ollama"}),testId:"ollama-config-picker"}),X]})}let n8={deepseek:{label:"DeepSeek",apiKeysUrl:"https://platform.deepseek.com/api_keys",modelsEndpoint:"/v1/models"},kimi:{label:"Kimi",apiKeysUrl:"https://www.kimi.com/code/console",modelsEndpoint:"/coding/v1/models"},glm:{label:"GLM",apiKeysUrl:"https://bigmodel.cn/apikey/platform",modelsEndpoint:"/coding/paas/v4/models",regions:[{id:"cn",label:"中国大陆",hint:"open.bigmodel.cn"},{id:"global",label:"International",hint:"api.z.ai"}]}};function n9({engine:e,currentModel:t,onModelChange:r,onHasKeyChange:o}){let a=n8[e],[l,i]=(0,s.useState)(!1),[d,c]=(0,s.useState)(!1),[x,h]=(0,s.useState)(""),[f,p]=(0,s.useState)(""),[b,v]=(0,s.useState)(!1),[j,w]=(0,s.useState)(!1),[k,y]=(0,s.useState)(!1),[N,C]=(0,s.useState)(null),[S,L]=(0,s.useState)(!1),[M,E]=(0,s.useState)([]),[P,T]=(0,s.useState)(null),[$,R]=(0,s.useState)(null),B=(0,s.useRef)(null),F=(0,s.useRef)(null),I=(0,s.useRef)(null),D=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{D.current&&clearTimeout(D.current)},[]);let A=(0,s.useRef)(t),z=(0,s.useRef)(r),H=(0,s.useRef)(o);(0,s.useEffect)(()=>{A.current=t,z.current=r,H.current=o}),(0,s.useEffect)(()=>{H.current?.(d)},[d]);let[W,_]=(0,s.useState)({top:0,left:0}),O=(0,g.F2)();(0,s.useEffect)(()=>{let t=!1;return(async()=>{let[r,n]=await Promise.all([u.t4.runPromiseExit((0,m.Hw)(e)),u.t4.runPromiseExit((0,m.td)())]);if(t||"Failure"===r._tag)return;c(r.value.hasKey),h(r.value.maskedKey);let s="Success"===n._tag?n.value?.engines?.[e]:void 0,o=s?.builtinModel;!A.current&&o&&z.current(o)})(),()=>{t=!0}},[e]),(0,s.useEffect)(()=>{if(!l)return;let e=e=>{F.current&&!F.current.contains(e.target)&&B.current&&!B.current.contains(e.target)&&i(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[l]);let q=(0,s.useCallback)(async()=>{w(!0),C(null),T(null);let[n,s]=await Promise.all([u.t4.runPromiseExit((0,m.Hw)(e)),u.t4.runPromiseExit((0,m.td)())]);if("Failure"===n._tag){C("Failed to load settings"),w(!1);return}c(n.value.hasKey),h(n.value.maskedKey),p(""),v(!1);let o="Success"===s._tag?s.value:void 0,l=o?.engines?.[e],i=l?.builtinModel;a.regions&&R(l?.region??("en"===o?.language?"global":"cn"));let d=[];if(n.value.hasKey){let t=await u.t4.runPromiseExit((0,m.Fi)(e));"Success"===t._tag?d=t.value.models:T("Failed to load models — check the API key")}E(d);let x=d.map(e=>e.id),f=i&&x.includes(i)?i:x[0];!f||t&&x.includes(t)||r(f),w(!1)},[e,t,r,a.regions]),V=(0,s.useCallback)(async t=>{let r=await u.t4.runPromiseExit((0,m.td)()),n=("Success"===r._tag?r.value:{}).engines||{},s={...n,[e]:{...n[e]||{},builtinModel:t}};if("Failure"===(await u.t4.runPromiseExit((0,m.em)({engines:s})))._tag)throw Error("Failed to save settings")},[e]),U=(0,s.useCallback)(async t=>{R(t);let r=await u.t4.runPromiseExit((0,m.td)()),n=("Success"===r._tag?r.value:{}).engines||{};"Failure"===(await u.t4.runPromiseExit((0,m.em)({engines:{...n,[e]:{...n[e]||{},region:t}}})))._tag?C("Failed to save region"):q()},[e,q]),K=async()=>{let t=f.trim();if(!t)return;y(!0),C(null);let r=await u.t4.runPromiseExit((0,m.dQ)(e,t));"Failure"===r._tag?C("Save failed"):(c(r.value.hasKey),h(r.value.maskedKey),p(""),v(!1),q()),y(!1)},G=async()=>{y(!0),C(null);let t=await u.t4.runPromiseExit((0,m.dQ)(e,""));"Failure"===t._tag?C("Clear failed"):(c(t.value.hasKey),h(t.value.maskedKey),p(""),v(!1),E([])),y(!1)},J=async()=>{let t=await u.t4.runPromiseExit((0,m.Ny)(e));if("Failure"===t._tag||!t.value.apiKey)return void C("Copy failed");try{await navigator.clipboard.writeText(t.value.apiKey)}catch{C("Clipboard unavailable");return}C(null),L(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>L(!1),1500)},Q=async e=>{r(e);try{await V(e)}catch{}},Z=d?t||"Select model":"Set API key",X=d?void 0:n4.Aw,Y=t||"",ee=l?(0,n.jsx)(g.ZL,{children:(0,n.jsx)("div",{ref:F,className:`${n4.ys} min-w-[280px]`,style:{top:W.top,left:W.left},children:j?(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-3 py-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,n.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"API Key"}),(0,n.jsx)("a",{href:a.apiKeysUrl,target:"_blank",rel:"noopener","data-testid":`${e}-api-keys-link`,title:`Open ${a.label} API keys page`,"aria-label":`Open ${a.label} API keys page`,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]}),d&&!b?(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:x}),(0,n.jsx)("button",{onClick:J,"data-testid":`${e}-copy-api-key`,title:S?"Copied":"Copy API key","aria-label":"Copy API key",className:`p-1 rounded transition-colors ${S?"text-green-11":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,disabled:k,children:S?(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,n.jsx)("button",{onClick:()=>{v(!0),p(""),setTimeout(()=>I.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-hover text-foreground transition-colors",disabled:k,children:"Edit"}),(0,n.jsx)("button",{onClick:G,className:"text-[11px] px-2 py-1 rounded text-red-11 hover:bg-red-500/10 transition-colors",disabled:k,children:"Clear"})]}):(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{ref:I,type:"password",value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"===e.key&&K()},placeholder:"sk-...",className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${n4.Fx}`,autoFocus:!0}),(0,n.jsx)("button",{onClick:K,disabled:k||!f.trim(),className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${n4.$T}`,children:k?"Saving...":"Save"}),d&&(0,n.jsx)("button",{onClick:()=>{v(!1),p("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),N&&(0,n.jsx)("div",{className:"mt-1 text-[11px] text-red-11",children:N})]}),(0,n.jsx)("div",{className:"my-1 border-t border-border"}),a.regions&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-3 py-1.5",children:[(0,n.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Region"}),(0,n.jsx)("div",{className:"inline-flex rounded-md border border-border overflow-hidden text-xs",role:"group","data-testid":`${e}-region-toggle`,children:a.regions.map(t=>(0,n.jsx)("button",{type:"button","data-testid":`${e}-region-${t.id}`,onClick:()=>U(t.id),title:t.hint,className:`px-2 py-0.5 ${$===t.id?"bg-brand text-white":"bg-transparent text-muted-foreground hover:bg-hover"}`,children:t.label},t.id))})]}),(0,n.jsx)("div",{className:"my-1 border-t border-border"})]}),(0,n.jsxs)("div",{className:"px-3 py-1.5",children:[(0,n.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Model"}),P&&(0,n.jsx)("div",{className:"mb-1 text-[11px] text-red-11",children:P}),!P&&0===M.length&&(0,n.jsx)("div",{className:"mb-1 text-[11px] text-muted-foreground",children:d?`No models returned by ${a.modelsEndpoint}`:"Save an API key to list models"}),(0,n.jsx)("div",{className:"flex flex-col gap-0.5",children:M.map(e=>{var t;let r=Y===e.id,s=(t=e.contextTokens)&&!(t<=0)?t>=1048576?`${Math.round(t/1048576)}M`:`${Math.round(t/1024)}K`:null;return(0,n.jsxs)("button",{onClick:()=>Q(e.id),className:`flex items-center gap-2 px-2 py-1 text-xs rounded transition-colors ${r?n4.yI:"text-foreground hover:bg-hover"}`,children:[(0,n.jsx)(n4.hG,{selected:r}),(0,n.jsx)("span",{className:"truncate",children:e.id}),e.label&&e.label!==e.id&&(0,n.jsx)("span",{className:"truncate text-[10px] text-muted-foreground",children:e.label}),s&&(0,n.jsx)("span",{className:"ml-auto pl-2 text-[10px] text-muted-foreground flex-shrink-0",children:s})]},e.id)})})]})]})})}):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(n4.XY,{buttonRef:B,label:Z,labelClassName:X,title:`Configure ${a.label}`,onClick:()=>{if(!l){if(B.current){let e=B.current.getBoundingClientRect(),t=O?.getBoundingClientRect(),r=t?.left??0,n=t?.top??0;_({top:e.bottom+4-n,left:e.left-r})}q()}i(e=>!e)},icon:(0,n.jsx)(n4.eV,{engine:e}),testId:`${e}-config-picker`}),ee]})}let n7="claude-opus-5",se="gpt-5.6-sol",st=[{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra High"},{id:"max",label:"Max"},{id:"ultracode",label:"Ultracode"},{id:"ultrathink",label:"Ultrathink"}],sr=[{id:"claude-sonnet-5",label:"Claude Sonnet 5",effort:["low","medium","high","xhigh","max","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"200k"},{id:"claude-opus-5",label:"Claude Opus 5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m",fast:!0},{id:"claude-fable-5-1",label:"Claude Fable 5.1",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m"},{id:"claude-fable-5",label:"Claude Fable 5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m"},{id:"claude-opus-4-8",label:"Claude Opus 4.8",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",fast:!0},{id:"claude-opus-4-7",label:"Claude Opus 4.7",effort:["low","medium","high","xhigh","max","ultrathink"],defaultEffort:"xhigh",fast:!0},{id:"claude-opus-4-6",label:"Claude Opus 4.6",effort:["low","medium","high","max","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m",fast:!0},{id:"claude-sonnet-4-6",label:"Claude Sonnet 4.6",effort:["low","medium","high","max","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"200k"},{id:"claude-haiku-4-5",label:"Claude Haiku 4.5",thinking:!0}],sn=[{id:"minimal",label:"Minimal"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra High"},{id:"max",label:"Max"},{id:"ultra",label:"Ultra"}],ss=[{id:"gpt-6-astra",label:"GPT-6-Astra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"low"},{id:"gpt-5.6-sol",label:"GPT-5.6-Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"medium"},{id:"gpt-5.6-terra",label:"GPT-5.6-Terra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"medium"},{id:"gpt-5.6-luna",label:"GPT-5.6-Luna",reasoning:["low","medium","high","xhigh","max"],defaultReasoning:"medium"}];function so(e){return ss.find(t=>t.id===e)?.defaultReasoning??"low"}function sa(e,t){let r=ss.find(t=>t.id===e)?.reasoning;return t&&(!r||r.includes(t))?t:so(e)}function sl(e,t){return e.find(e=>e.id===t)?.label??t}function si(e){return sr.find(t=>t.id===e)?.fast===!0}function sd(e){return sr.find(t=>t.id===e)?.thinking===!0}function sc(e){let t=sr.find(t=>t.id===e);return t?t.defaultEffort:"high"}function su(e,t){let r=sr.find(t=>t.id===e),n=r?.effort;return t&&(!r||n?.includes(t))?t:sc(e)}function sm(e){let t=sr.find(t=>t.id===e);return t?t.defaultContext:"200k"}function sx(e,t){let r=sr.find(t=>t.id===e),n=r?.context;return t&&(!r||n?.includes(t))?t:sm(e)}function sh({value:e,selected:t,label:r,defaultValue:s,onSelect:o}){return(0,n.jsxs)("button",{type:"button",onClick:()=>o(e),className:`flex w-full items-start gap-2 px-3 py-2 text-left text-xs transition-colors ${t?n4.yI:"text-muted-foreground hover:bg-hover hover:text-foreground"}`,children:[(0,n.jsx)("span",{className:"mt-0.5",children:(0,n.jsx)(n4.hG,{selected:t})}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:r}),(0,n.jsx)("span",{className:"shrink-0",children:s&&(0,n.jsx)("span",{className:"rounded bg-muted px-1.5 text-[10px] font-medium text-muted-foreground",children:"Default"})})]})}function sf({title:e,selected:t,value:r,items:o,onSelect:a,icon:l,testId:i}){let d=(0,s.useRef)(null),c=(0,s.useRef)(null),[u,m]=(0,s.useState)(!1),[x,h]=(0,s.useState)({top:0,left:0}),f=(0,g.F2)(),p=()=>{let e=d.current?.getBoundingClientRect();if(!e)return;let t=f?.getBoundingClientRect(),r=t?.left??0,n=t?.top??0;h({top:e.bottom+4-n,left:e.left-r})};return(0,s.useEffect)(()=>{if(!u)return;let e=e=>{let t=e.target;c.current?.contains(t)||d.current?.contains(t)||m(!1)},t=()=>p();return document.addEventListener("mousedown",e),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[u]),(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(n4.XY,{buttonRef:d,label:r,labelMaxWidth:"max-w-[180px]",title:`${e}: ${r}`,onClick:()=>{u||p(),m(e=>!e)},icon:l,testId:i}),u&&(0,n.jsx)(g.ZL,{children:(0,n.jsxs)("div",{ref:c,className:`${n4.ys} min-w-[190px]`,style:{top:x.top,left:x.left},children:[(0,n.jsx)("div",{className:"px-3 pb-1 text-[11px] font-medium text-muted-foreground",children:e}),(0,n.jsx)("div",{className:"flex flex-col",children:o.map(e=>(0,n.jsx)(sh,{value:e.id,selected:t===e.id,label:e.label,defaultValue:e.defaultValue,onSelect:e=>{a(e),m(!1)}},e.id))})]})})]})}function sp(e){let t,r,s=e.engine??"claude",o=e.claudeModel??n7,a=sc(o),l=(t=sr.find(e=>e.id===o)?.effort)?t.map(e=>st.find(t=>t.id===e)??{id:e,label:e}):[],i=su(o,e.claudeEffort),d=sm(o),c=sr.find(e=>e.id===o)?.context??[],u=sx(o,e.claudeContextWindow),m=e.claudeFastMode??!1,x=e.claudeThinking??!1,h=e.codexModel??se,f=so(h),p=(r=ss.find(e=>e.id===h)?.reasoning)?r.map(e=>sn.find(t=>t.id===e)??{id:e,label:e}):sn,g=sa(h,e.codexReasoningEffort);return"claude"!==s?(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,n.jsx)(sf,{title:"Model",selected:h,value:sl(ss,h),items:ss.map(e=>({id:e.id,label:e.label,defaultValue:e.id===se})),onSelect:t=>{e.onCodexModelChange?.(t),e.onCodexReasoningEffortChange?.(so(t))},icon:(0,n.jsx)(n4.eV,{engine:"codex"}),testId:"codex-model-picker"}),(0,n.jsx)(sf,{title:"Reasoning",selected:g,value:sl(sn,g),items:p.map(e=>({...e,defaultValue:e.id===f})),onSelect:t=>e.onCodexReasoningEffortChange?.(t),testId:"codex-reasoning-picker"})]}):(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,n.jsx)(sf,{title:"Model",selected:o,value:sl(sr,o),items:sr.map(e=>({id:e.id,label:e.label,defaultValue:e.id===n7})),onSelect:t=>{e.onClaudeModelChange?.(t);let r=sc(t),n=sm(t);r&&e.onClaudeEffortChange?.(r),n&&e.onClaudeContextWindowChange?.(n),si(t)||e.onClaudeFastModeChange?.(!1),sd(t)||e.onClaudeThinkingChange?.(!1)},icon:(0,n.jsx)(n4.eV,{engine:"claude"}),testId:"claude-model-picker"}),i&&l.length>0&&(0,n.jsx)(sf,{title:"Reasoning",selected:i,value:sl(st,i),items:l.map(e=>({...e,defaultValue:e.id===a})),onSelect:t=>e.onClaudeEffortChange?.(t),testId:"claude-reasoning-picker"}),u&&c.length>0&&(0,n.jsx)(sf,{title:"Context Window",selected:u,value:"1m"===u?"1M":"200K",items:c.map(e=>({id:e,label:"1m"===e?"1M":"200K",defaultValue:e===d})),onSelect:t=>e.onClaudeContextWindowChange?.(t),testId:"claude-context-picker"}),si(o)&&(0,n.jsx)(sf,{title:"Fast Mode",selected:m?"on":"off",value:m?"Fast On":"Fast Off",items:[{id:"on",label:"On"},{id:"off",label:"Off",defaultValue:!0}],onSelect:t=>e.onClaudeFastModeChange?.("on"===t),testId:"claude-fast-mode-picker"}),sd(o)&&(0,n.jsx)(sf,{title:"Thinking",selected:x?"on":"off",value:x?"Thinking On":"Thinking Off",items:[{id:"on",label:"On"},{id:"off",label:"Off",defaultValue:!0}],onSelect:t=>e.onClaudeThinkingChange?.("on"===t),testId:"claude-thinking-picker"})]})}let sg={CNY:"\xa5",USD:"$"};function sb({hasKey:e}){let{t}=(0,o.Bd)(),[r,a]=(0,s.useState)(!1),[l,i]=(0,s.useState)(null),[d,c]=(0,s.useState)(null),x=(0,s.useCallback)(async()=>{a(!0),c(null);let e=await u.t4.runPromiseExit((0,m.he)());"Failure"===e._tag?(i(null),c(t("chat.balanceFailed",{defaultValue:"Query failed — check the API key"}))):i(e.value),a(!1)},[t]),h=l?l.balances.map(e=>`${sg[e.currency]??(e.currency?`${e.currency} `:"")}${e.totalBalance}`).join(" / "):"",f=!!(l&&!l.isAvailable);return(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[r&&(0,n.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),!r&&d&&(0,n.jsx)("span",{className:"text-xs text-red-11",children:d}),!r&&!d&&l&&(0,n.jsx)("span",{className:`text-xs font-mono ${f?"text-red-11":n4.pe.deepseek}`,"data-tooltip":f?t("chat.balanceUnavailable",{defaultValue:"Account is not available for requests"}):void 0,"data-testid":"deepseek-balance-value",children:h||t("chat.balanceEmpty",{defaultValue:"No balance returned"})}),(0,n.jsx)("button",{type:"button","data-testid":"deepseek-balance-button",disabled:!e||r,onClick:x,"data-tooltip":e?void 0:t("chat.balanceNeedsKey",{defaultValue:"Set a DeepSeek API key first"}),className:"px-2 py-0.5 text-xs rounded border border-border text-muted-foreground hover:bg-hover hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:t("chat.checkBalance",{defaultValue:"Check balance"})}),(0,n.jsx)("a",{href:"https://platform.deepseek.com/usage",target:"_blank",rel:"noopener","data-testid":"deepseek-usage-link",title:t("chat.openUsagePage",{defaultValue:"Open DeepSeek usage console"}),"aria-label":t("chat.openUsagePage",{defaultValue:"Open DeepSeek usage console"}),className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]})}let sv={kimi:"https://www.kimi.com/code/console",glm:"https://bigmodel.cn/coding-plan/personal/usage"};function sj(e){let t=e.remaining??"?",r=e.limit??"?";return`${e.label} ${t}/${r}`}function sw({engine:e,hasKey:t}){let{t:r}=(0,o.Bd)(),[a,l]=(0,s.useState)(!1),[i,d]=(0,s.useState)(null),[c,x]=(0,s.useState)(null),h=(0,s.useCallback)(async()=>{l(!0),x(null);let t=await u.t4.runPromiseExit((0,m.dM)(e));"Failure"===t._tag?(d(null),x(r("chat.quotaFailed",{defaultValue:"Quota unavailable — check the API key"}))):d(t.value),l(!1)},[r,e]),f=i?.windows??[],p=[i?.tier,...f.map(sj)].filter(Boolean).join(" \xb7 "),g=function(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:`${t.getMonth()+1}/${t.getDate()} ${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}(f.reduce((e,t)=>t.resetTime&&(!e||t.resetTime>e)?t.resetTime:e,null)),b=f.some(e=>0===e.remaining);return(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[a&&(0,n.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),!a&&c&&(0,n.jsx)("span",{className:"text-xs text-red-11",children:c}),!a&&!c&&i&&(0,n.jsx)("span",{className:`text-xs font-mono ${b?"text-red-11":n4.pe[e]}`,"data-tooltip":g?r("chat.quotaResetAt",{defaultValue:"Resets {{time}}",time:g}):void 0,"data-testid":`${e}-quota-value`,children:p||r("chat.quotaEmpty",{defaultValue:"No quota returned"})}),(0,n.jsx)("button",{type:"button","data-testid":`${e}-quota-button`,disabled:!t||a,onClick:h,"data-tooltip":t?void 0:r("chat.quotaNeedsKey",{defaultValue:"Set an API key first"}),className:"px-2 py-0.5 text-xs rounded border border-border text-muted-foreground hover:bg-hover hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:r("chat.checkQuota",{defaultValue:"Check quota"})}),(0,n.jsx)("a",{href:sv[e],target:"_blank",rel:"noopener","data-testid":`${e}-console-link`,title:r("chat.openProviderConsole",{defaultValue:"Open the provider console"}),"aria-label":r("chat.openProviderConsole",{defaultValue:"Open the provider console"}),className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]})}var sk=r(67889),sy=r(46456);function sN(e){if(0===e.length)return"";let t=[tN.A.t("comments.codeRef"),""],r=e.filter(e=>e.filePath===eC.Un),n=e.filter(e=>e.filePath!==eC.Un);for(let e of(n.length>0&&n.forEach((e,r)=>{let n=e.startLine>0||e.endLine>0?`:${e.startLine}-${e.endLine}`:"";t.push(`[${r+1}] ${e.filePath}${n}`),t.push("```"),t.push(e.codeContent),t.push("```"),e.content&&t.push(tN.A.t("comments.note",{content:e.content})),t.push("")}),r)){let r=e.codeContent.split("\n").map(e=>`> ${e}`).join("\n");t.push(r),e.content&&t.push(e.content),t.push("")}return t.join("\n").trim()}function sC({isOpen:e,onClose:t,cwd:r,onNavigateToComment:a}){let{t:l}=(0,o.Bd)(),i=(0,F.r)(),[d,c]=(0,s.useState)([]),[m,x]=(0,s.useState)(!1),[h,f]=(0,s.useState)(null),[p,b]=(0,s.useState)(!1),[j,w]=(0,s.useState)(!1),k=(0,s.useCallback)(async()=>{if(!r)return;x(!0);let e=await u.t4.runPromiseExit((0,sy.$)(r));"Success"===e._tag?c(e.value.comments??[]):console.error("Failed to load comments:",e.cause),x(!1)},[r]);(0,s.useEffect)(()=>{e&&k()},[e,k]);let y=async e=>{let t=await u.t4.runPromiseExit((0,sy.Tu)(r,e));"Success"===t._tag?(c(t=>t.filter(t=>t.id!==e)),(0,eC.Cm)()):console.error("Failed to delete comment:",t.cause)},N=async e=>{f(e.id);try{let t="";if(e.selectedText)t=e.selectedText;else{let n=await u.t4.runPromiseExit((0,v.K)(r,e.filePath));if("Success"!==n._tag||!n.value.ok)throw Error("Failed to read file");t=(n.value.data?.content||"").split("\n").slice(e.startLine-1,e.endLine).join("\n")}let n={filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,content:e.content,codeContent:t},s=sN([n]);await navigator.clipboard.writeText(s),(0,P.oR)(l("toast.copiedComment"))}catch(e){console.error("Failed to copy comment:",e)}finally{f(null)}},C=async()=>{if(0!==d.length){b(!0);try{let e=await (0,eC.$3)(r),t=sN(e);await navigator.clipboard.writeText(t),(0,P.oR)(l("toast.copiedAllComments"))}catch(e){console.error("Failed to copy all comments:",e)}finally{b(!1)}}},S=async()=>{if(0!==d.length&&i&&!i.isLoading&&!j){w(!0);try{let e=(await (0,eC.$3)(r)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0})),n=(0,eC.Gw)(e,"");i.sendMessage(n),await (0,eC.RP)(r),c([]),t()}catch(e){console.error("Failed to send comments to AI:",e)}finally{w(!1)}}},L=d.reduce((e,t)=>(e[t.filePath]||(e[t.filePath]=[]),e[t.filePath].push(t),e),{});if(!e)return null;let M=(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:t,children:(0,n.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-lv3 flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border ",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:l("comments.allComments")}),d.length>0&&(0,n.jsx)("button",{onClick:C,disabled:p,className:"p-1 rounded hover:bg-hover text-muted-foreground disabled:opacity-50",title:l("comments.copyAllComments"),children:p?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,n.jsx)("button",{onClick:t,className:"p-1 rounded hover:bg-hover text-muted-foreground",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:m?(0,n.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:l("common.loading")}):0===d.length?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,n.jsx)("svg",{className:"w-12 h-12 mb-3 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,n.jsx)("span",{children:l("comments.noComments")})]}):(0,n.jsx)("div",{className:"space-y-4",children:Object.entries(L).map(([e,t])=>(0,n.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-3 py-2 border-b border-border",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-foreground font-mono",children:e===eC.Un?l("comments.aiReply"):e}),(0,n.jsxs)("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",l("comments.nComments",{count:t.length}),")"]})]}),(0,n.jsx)("div",{className:"divide-y divide-border",children:t.map(e=>{var t;return(0,n.jsx)("div",{className:"px-3 py-2 hover:bg-hover cursor-pointer group",onClick:()=>a?.(e),children:(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[e.startLine>0||e.endLine>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"text-xs text-brand font-mono",children:[l("common.line")," ",e.startLine===e.endLine?e.startLine:`${e.startLine}-${e.endLine}`]}),(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",l("comments.linesCount",{count:e.endLine-e.startLine+1}),")"]})]}):e.selectedText?(0,n.jsxs)("span",{className:"text-xs text-muted-foreground italic truncate max-w-[200px]",children:["“",e.selectedText.slice(0,50),e.selectedText.length>50?"...":"","”"]}):null,(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:(t=e.updatedAt||e.createdAt)?new Date(t).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):""})]}),(0,n.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:e.content||(0,n.jsx)("span",{className:"text-muted-foreground italic",children:l("comments.noContent")})})]}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),N(e)},disabled:h===e.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-hover text-muted-foreground transition-opacity disabled:opacity-50",title:l("common.copy"),children:h===e.id?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),y(e.id)},className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-hover text-muted-foreground hover:text-red-9 transition-opacity",title:l("common.delete"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})},e.id)})})]},e))})}),(0,n.jsxs)("div",{className:"px-4 py-3 border-t border-border flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:l("comments.totalComments",{count:d.length})}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[i&&(0,n.jsx)("button",{onClick:S,disabled:0===d.length||i.isLoading||j,className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",title:i.isLoading?l("comments.aiResponding"):void 0,children:j?l("comments.submitting"):l("comments.sendToAI")}),(0,n.jsx)("button",{onClick:async()=>{0===d.length||await (0,eC.RP)(r)&&c([])},disabled:0===d.length,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 disabled:opacity-50 disabled:cursor-not-allowed",children:l("comments.clearAll")})]})]})]})});return(0,n.jsx)(g.ZL,{children:M})}let sS=`${sk.o} pl-3 pr-8 bg-card/50`;function sL({tabId:e,initialCwd:t,initialSessionId:r,engine:l,onEngineChange:i,ollamaModel:x,onOllamaModelChange:h,deepseekModel:g,onDeepseekModelChange:b,kimiModel:v,onKimiModelChange:j,glmModel:w,onGlmModelChange:k,claudeModel:y,onClaudeModelChange:N,claudeEffort:C,onClaudeEffortChange:S,claudeContextWindow:L,onClaudeContextWindowChange:M,claudeFastMode:E,onClaudeFastModeChange:T,claudeThinking:$,onClaudeThinkingChange:R,codexModel:B,onCodexModelChange:F,codexReasoningEffort:I,onCodexReasoningEffortChange:D,planMode:A,onPlanModeChange:z,noHistory:H,onNoHistoryChange:W,hideHeader:_,hideSidebar:O,isActive:q=!0,isFocused:V=q,peerTabId:U,peerSide:K,refreshSignal:G,onLoadingChange:J,onSessionIdChange:Q,onTitleChange:Z,onShowGitStatus:X,onOpenNote:Y,onCreateScheduledTask:ee,onOpenSession:et,onContentSearch:er,onShowFileDiff:en,onOpenFileLink:es,onOpenSessionBrowser:eo,onOpenSettings:ea}){let el,{t:ei}=(0,o.Bd)(),ed=(0,s.useContext)(a),[ec,eu]=(0,s.useState)(""),[em,ex]=(0,s.useState)([]),eh=(0,nP.nH)(),[ef,ep]=(0,s.useState)([]),[eg,eb]=(0,s.useState)(null),[ev,ej]=(0,s.useState)(!1),[ew,ek]=(0,s.useState)(!1),[ey,eN]=(0,s.useState)(!1),[eC,eS]=(0,s.useState)(!1),[eL,eM]=(0,s.useState)(null),[eE,eP]=(0,s.useState)(!1),eT=A??eE,e$=(0,s.useCallback)(e=>{eP(e),z?.(e)},[z]),[eR,eB]=(0,s.useState)(!1),eF=H??eR,eI=(0,s.useCallback)(e=>{eB(e),W?.(e)},[W]),[eD,eA]=(0,s.useState)(!1),ez=(0,s.useRef)(null),eH=(0,s.useRef)(null),eW=(0,s.useCallback)(async e=>{if(!t)return;let r=await u.t4.runPromiseExit((0,m.n_)({cwd:t,sessionId:e}));"Success"===r._tag&&r.value&&"string"==typeof r.value.title?Z?.(r.value.title):"Failure"===r._tag&&console.error("Failed to fetch session title:",r.cause)},[t,Z]),e_=(0,s.useRef)(null),[eO,eq]=(0,s.useState)(!1),[eV,eU]=(0,s.useState)(null),[eK,eG]=(0,s.useState)(null),[eJ,eQ]=(0,s.useState)(nO.R),eZ=(0,s.useMemo)(()=>(0,nq.hC)(),[]),eX=(0,s.useRef)(!1);(0,s.useEffect)(()=>{eX.current=eO},[eO]);let{isLoadingHistory:eY,isLoadingMore:e0,hasMoreHistory:e1,loadMoreHistory:e2,ensureTurnLoaded:e5,loadHistoryByCwdAndSessionId:e4,loadedSessionId:e3,loadedEngine:e6}=(0,n_.m)(ef,ep,eg,{cwd:t,initialSessionId:r,onSessionId:eb,onTitleChange:Z,onTokenUsage:eM,liveRunningRef:eX}),e8=e6??l??void 0,e9=!e8||"claude"===e8,e7="codex"===e8,te=y??n7,tt=su(te,C),tr=sx(te,L),tn=B??se,ts=sa(tn,I),to="deepseek"===e8||"kimi"===e8||"glm"===e8?e8:null,ta="kimi"===to?v:"glm"===to?w:g,tl="kimi"===to?j:"glm"===to?k:b,ti="ollama"===e8||null!==to||e9||e7;(0,s.useEffect)(()=>{e6&&l!==e6&&i?.(e6)},[l,e6,i]);let{isLoading:td,tokenUsage:tc,liveOutputTokens:tu,runningStartedAt:tm,rateLimitInfo:tx,apiRetryInfo:th,backgroundTasks:tf,handleSend:tp,handleStop:tg}=(0,nO.e)(ef,ep,{sessionId:eg,cwd:t,engine:e8,planMode:eT,noHistory:eF,ollamaModel:x,engineModel:ta,claudeModel:te,claudeEffort:tt,claudeContextWindow:tr,claudeFastMode:E,claudeThinking:$,codexModel:tn,codexReasoningEffort:ts,onSessionId:eb,onFetchTitle:eW,onRunComplete:()=>e_.current?.(),taskStore:eZ}),tb=(0,s.useCallback)(async(e,r)=>{let n=e.split("\n")[0];if(e9){let t=/^\/plan(?:\s+([\s\S]*))?$/.exec(e.trim());if(t){let e=(t[1]??"").trim();"off"===e.toLowerCase()?(e$(!1),(0,P.oR)(ei("chat.planModeOff",{defaultValue:"Plan mode off"}),"info")):""===e?(e$(!0),(0,P.oR)(ei("chat.planModeOn",{defaultValue:"Plan mode on"}),"success")):(e$(!0),tp(e,r,{permissionMode:"plan"}));return}}if(n.startsWith("!")&&n.length>1){let s=n.slice(1).trim();if(!s)return void tp(e,r);let o=e.split("\n").slice(1).join("\n").trim(),a=await u.t4.runPromiseExit((0,m.JC)({command:s,cwd:t}));if("Success"===a._tag){let e=a.value,t=[e.stdout,e.stderr].filter(Boolean).join("\n")||"(no output)",n=ei("chat.executedCommand",{command:s,exitInfo:e.exitCode?` (exit code: ${e.exitCode})`:"",output:t});o&&(n+=`
|
|
27
|
+
|
|
28
|
+
${o}`),tp(n,r)}else tp(ei("chat.executedCommandFailed",{command:s,error:a.cause}),r);return}tp(e,r)},[tp,t,ei,e9,e$]),tv=(0,s.useCallback)(()=>{e$(!1),tp(ei("chat.approvePlanPrompt",{defaultValue:"已批准,按上述计划开始执行。"}),void 0,{permissionMode:null})},[tp,e$,ei]),tj=e3||eg,tw=q&&!td&&!!tj;(0,nD.u)(tj,ep,tw,e8,{onRunningChange:e=>{eX.current=e,eq(e)},onLiveOutputTokens:eU,onRunStartedAt:eG,onBackgroundTasks:e=>eQ(e.length?e:nO.R),taskStore:eZ,onComplete:()=>{t&&tj&&e4(t,tj,!0,10)}}),(0,s.useEffect)(()=>{tw||(eq(!1),eU(null),eG(null),eQ(nO.R))},[tw]),(0,s.useEffect)(()=>{e_.current=()=>{t&&tj&&e4(t,tj,!0,10)}},[t,tj,e4]);let tk=(0,s.useRef)(q);(0,s.useEffect)(()=>{q&&!tk.current&&eg&&t&&!td&&!eO&&e4(t,eg,!0,10),tk.current=q},[q,eg,t,td,eO,e4]);let ty=(0,s.useRef)(0);(0,s.useEffect)(()=>{if(!G||G.nonce===ty.current)return;ty.current=G.nonce;let e=eg||e3;!t||!e||G.sessionId!==eg&&G.sessionId!==e3||td||eO||e4(t,e,!0,10,void 0,!0)},[G,eg,e3,t,td,eO,e4]);let tN=tc||eL,tC=td?tu:eO?eV:null,tS=td?tm:eO?eK:null,tL=td?tf:eO?eJ:nO.R;(0,s.useEffect)(()=>{eg&&Q?.(eg)},[eg,Q]);let tM=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(J?.(td),tM.current&&!td&&t&&eg){let e;for(let t=ef.length-1;t>=0;t--)if("user"===ef[t].role&&ef[t].content){e=ef[t].content.slice(0,100);break}(0,d.F)(c.n.SessionComplete,{cwd:t,sessionId:eg,lastUserMessage:e})}tM.current=td},[td,J,t]),(0,s.useEffect)(()=>{if(e&&eh&&(eh.setChatLoading(e,q&&td),q))return()=>{eh.setChatLoading(e,!1)}},[e,td,q,eh]),(0,s.useEffect)(()=>{if(e&&eh)return eh.registerChat(e=>{eH.current?.(e)},e),()=>{eh.unregisterChat(e)}},[e,eh]),(0,s.useEffect)(()=>{e&&q&&V&&eh&&eh.setActiveTab(e)},[e,q,V,eh]),(0,s.useEffect)(()=>{eH.current=tb},[tb]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&ev&&(td||eO)&&tg()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[ev,td,eO,tg]);let tE=(0,s.useCallback)(async(e,r)=>{let n=e3??eg;if(!t||!n)return;let s=await u.t4.runPromiseExit((0,m.Zr)(n,{cwd:t,fromMessageUuid:e,scope:r}));if("Success"===s._tag&&s.value.newSessionId){let e=s.value.newSessionId;et?et(e,"single"===r?"Excerpt":"Fork"):(0,d.F)(c.n.OpenProject,{cwd:t,sessionId:e})}else"Failure"===s._tag&&(console.error("Fork failed:",s.cause),(0,P.oR)("single"===r?ei("toast.excerptFailed",{defaultValue:"Failed to excerpt this turn"}):ei("toast.forkFailed",{defaultValue:"Failed to fork session"}),"error"))},[t,e3,eg,et,ei]),tP=(0,s.useRef)(tE);tP.current=tE;let tT=(0,s.useRef)((e,t)=>tP.current(e,t)).current,t$=(0,s.useCallback)(e=>{if(U&&eh){if(!eh.sendToTab(U,e))return void(0,P.oR)(ei("toast.sendToPeerFailed",{defaultValue:"Failed to send to the other pane"}),"error");(0,P.oR)(ei("toast.sentToPeer",{defaultValue:"Sent to the other pane"}),"success")}},[U,eh,ei]),tR=(0,s.useRef)(t$);tR.current=t$;let tB=(0,s.useRef)(e=>tR.current(e)).current,tF=(0,s.useCallback)(()=>{eN(!0)},[]),tI=(0,s.useCallback)(()=>{eS(!0)},[]),tD=(0,s.useRef)(ef);tD.current=ef;let tA=(0,s.useCallback)(async e=>{if(tD.current.some(t=>t.id===e.id))return void ez.current?.scrollToMessage(e.id);await e5(e.turnIndex);for(let t=0;t<30;t++)if(await new Promise(e=>requestAnimationFrame(()=>e())),ez.current?.scrollToMessage(e.id))return},[e5]),tz=(0,s.useMemo)(()=>{if(ee&&t&&e)return r=>{ee({...r,cwd:t,tabId:e,sessionId:eg??crypto.randomUUID(),engine:e8,..."ollama"===e8&&x&&{model:x},...to&&ta&&{model:ta},...e9&&{model:te},...e7&&{model:tn}})}},[ee,t,e,eg,e8,x,to,ta,e9,te,e7,tn]),tH=ti?(0,n.jsxs)("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer select-none",title:ei("chat.noHistoryHint",{defaultValue:"Independent task: each message is sent to the model on its own, with no prior conversation. The transcript above still records everything."}),children:[(0,n.jsx)("input",{type:"checkbox","data-testid":"nohistory-toggle",checked:eF,onChange:e=>eI(e.target.checked),className:"accent-brand"}),(0,n.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,n.jsx)(nF.A,{className:"w-3.5 h-3.5"}),ei("chat.noHistory",{defaultValue:"Independent task"})]}),(0,n.jsx)("span",{className:"text-muted-foreground",children:ei("chat.noHistoryDesc",{defaultValue:"no history sent"})})]}):null;return(0,n.jsx)(nq.I$.Provider,{value:eZ,children:(0,n.jsxs)("div",{className:`flex ${_&&O?"h-full":"h-screen"} bg-card`,children:[(0,n.jsxs)("div",{id:"chat-screen",className:"flex-1 flex flex-col min-w-0 relative",onMouseEnter:()=>ej(!0),onMouseLeave:()=>ej(!1),children:[!_&&(0,n.jsx)(nz,{cwd:t,sessionId:eg,engine:e8,onOpenProjectSessions:()=>ek(!0),onOpenSessionBrowser:eo,onOpenSettings:ea}),(e9||e7)&&(0,n.jsxs)("div",{className:sS,children:[(0,n.jsx)(sp,{engine:e7?"codex":"claude",claudeModel:te,onClaudeModelChange:N,claudeEffort:tt,onClaudeEffortChange:S,claudeContextWindow:tr,onClaudeContextWindowChange:M,claudeFastMode:E,onClaudeFastModeChange:T,claudeThinking:$,onClaudeThinkingChange:R,codexModel:tn,onCodexModelChange:F,codexReasoningEffort:ts,onCodexReasoningEffortChange:D}),e9&&(0,n.jsxs)("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer select-none",title:ei("chat.planModeHint",{defaultValue:"Plan mode: read-only exploration that produces a plan without editing. Uncheck and resend to implement."}),children:[(0,n.jsx)("input",{type:"checkbox","data-testid":"planmode-toggle",checked:eT,onChange:e=>e$(e.target.checked),className:"accent-brand"}),(0,n.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,n.jsx)(nI.A,{className:"w-3.5 h-3.5"}),ei("chat.planMode",{defaultValue:"Plan mode"})]}),(0,n.jsx)("span",{className:"text-muted-foreground",children:ei("chat.planModeDesc",{defaultValue:"read-only \xb7 plan first, no edits"})})]}),tH]}),"ollama"===e8&&(0,n.jsxs)("div",{className:sS,children:[h&&(0,n.jsx)(n6,{currentModel:x,onModelChange:h}),tH]}),to&&(0,n.jsxs)("div",{className:sS,children:[tl&&(0,n.jsx)(n9,{engine:to,currentModel:ta,onModelChange:tl,onHasKeyChange:eA}),tH,(0,n.jsx)("div",{className:"ml-auto pl-2",children:"deepseek"===to?(0,n.jsx)(sb,{hasKey:eD}):(0,n.jsx)(sw,{engine:to,hasKey:eD})})]}),eY?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("span",{className:"text-muted-foreground",children:ei("sessions.loadingHistory")})}):(0,n.jsx)(nV.M,{ref:ez,messages:ef,isLoading:td||eO,liveOutputTokens:tC,runningStartedAt:tS,cwd:t,sessionId:eg,engine:e8,apiRetryInfo:th,backgroundTasks:tL,hasMoreHistory:e1,isLoadingMore:e0,onLoadMore:e2,onFork:tT,onSendToPeer:tB,peerSide:K,isActive:q,onContentSearch:er,onShowFileDiff:en,onOpenFileLink:es,onApprovePlan:tv}),tN&&(0,n.jsx)(nH,{tokenUsage:tN,rateLimitInfo:tx}),ed&&!V?null:(el=(0,n.jsx)(n5,{onSend:tb,disabled:td||eO,cwd:t,engine:e8,onShowGitStatus:X,onShowComments:t?tF:void 0,onShowUserMessages:tI,onOpenNote:Y,onCreateScheduledTask:tz,draft:ec,setDraft:eu,draftImages:em,setDraftImages:ex}),ed?(0,p.createPortal)(el,ed):el)]}),!_&&t&&(0,n.jsx)(f,{isOpen:ew,onClose:()=>ek(!1),cwd:t}),t&&(0,n.jsx)(sC,{isOpen:ey,onClose:()=>eN(!1),cwd:t}),(0,n.jsx)(nW,{isOpen:eC,onClose:()=>eS(!1),cwd:t,sessionId:e3??eg,onSelectMessage:tA})]})})}function sM({tabId:e,cwd:t,sessionId:r,engine:o,onEngineChange:a,ollamaModel:l,onOllamaModelChange:i,deepseekModel:d,onDeepseekModelChange:c,kimiModel:u,onKimiModelChange:m,glmModel:x,onGlmModelChange:h,claudeModel:f,onClaudeModelChange:p,claudeEffort:g,onClaudeEffortChange:b,claudeContextWindow:v,onClaudeContextWindowChange:j,claudeFastMode:w,onClaudeFastModeChange:k,claudeThinking:y,onClaudeThinkingChange:N,codexModel:C,onCodexModelChange:S,codexReasoningEffort:L,onCodexReasoningEffortChange:M,planMode:E,onPlanModeChange:P,noHistory:T,onNoHistoryChange:$,isActive:R,isFocused:B,peerTabId:F,peerSide:I,refreshSignal:D,onStateChange:A,onShowGitStatus:z,onOpenNote:H,onCreateScheduledTask:W,onOpenSession:_,onContentSearch:O,onShowFileDiff:q,onOpenFileLink:V}){let U=(0,s.useCallback)(t=>{A(e,{isLoading:t})},[e,A]),K=(0,s.useCallback)(t=>{A(e,{sessionId:t})},[e,A]),G=(0,s.useCallback)(t=>{A(e,{title:t})},[e,A]),J=(0,s.useCallback)(t=>{a?.(e,t)},[e,a]),Q=(0,s.useCallback)(t=>{i?.(e,t)},[e,i]),Z=(0,s.useCallback)(t=>{c?.(e,t)},[e,c]),X=(0,s.useCallback)(t=>{m?.(e,t)},[e,m]),Y=(0,s.useCallback)(t=>{h?.(e,t)},[e,h]),ee=(0,s.useCallback)(t=>{p?.(e,t)},[e,p]),et=(0,s.useCallback)(t=>{b?.(e,t)},[e,b]),er=(0,s.useCallback)(t=>{j?.(e,t)},[e,j]),en=(0,s.useCallback)(t=>{k?.(e,t)},[e,k]),es=(0,s.useCallback)(t=>{N?.(e,t)},[e,N]),eo=(0,s.useCallback)(t=>{S?.(e,t)},[e,S]),ea=(0,s.useCallback)(t=>{M?.(e,t)},[e,M]),el=(0,s.useCallback)(t=>{P?.(e,t)},[e,P]),ei=(0,s.useCallback)(t=>{$?.(e,t)},[e,$]);return(0,n.jsx)(sL,{tabId:e,initialCwd:t,initialSessionId:r,engine:o,onEngineChange:J,ollamaModel:l,onOllamaModelChange:Q,deepseekModel:d,onDeepseekModelChange:Z,kimiModel:u,onKimiModelChange:X,glmModel:x,onGlmModelChange:Y,claudeModel:f,onClaudeModelChange:ee,claudeEffort:g,onClaudeEffortChange:et,claudeContextWindow:v,onClaudeContextWindowChange:er,claudeFastMode:w,onClaudeFastModeChange:en,claudeThinking:y,onClaudeThinkingChange:es,codexModel:C,onCodexModelChange:eo,codexReasoningEffort:L,onCodexReasoningEffortChange:ea,planMode:E,onPlanModeChange:el,noHistory:T,onNoHistoryChange:ei,hideHeader:!0,hideSidebar:!0,isActive:R,isFocused:B,peerTabId:F,peerSide:I,refreshSignal:D,onLoadingChange:U,onSessionIdChange:K,onTitleChange:G,onShowGitStatus:z,onOpenNote:H,onCreateScheduledTask:W,onOpenSession:_,onContentSearch:O,onShowFileDiff:q,onOpenFileLink:V})}var sE=r(3292),sP=r(23121),sT=r(88292),s$=r(76900),sR=r(96472);function sB(e,t){if(!t.split)return{};let r=t.panes.indexOf(e);return -1===r?{}:{peerTabId:t.panes[1-r],peerSide:0===r?"right":"left"}}function sF({tabId:e,panes:t,activePane:r,row:s,onFocusPane:a,onClosePane:l,children:i}){let{t:d}=(0,o.Bd)(),c=t.indexOf(e),u=t.length>1;return(0,n.jsxs)("div",{onMouseDownCapture:u?()=>a(c):void 0,style:s&&-1!==c?{order:c}:void 0,className:`group/pane relative ${function(e,t,r,n){let s=t.indexOf(e);if(-1===s)return"hidden";if(!n)return"h-full block";let o=t.length>1?` border-y ${s===r?"border-y-brand":"border-y-transparent"}`:"";return`h-full flex-1 min-w-0${o}${s>0?" border-l border-border":""}`}(e,t,r,s)}`,children:[u&&-1!==c&&(0,n.jsx)("button",{type:"button",onClick:()=>l(c),title:d("chat.closePane"),"aria-label":d("chat.closePane"),className:"absolute top-1 right-1 z-20 flex items-center justify-center w-6 h-6 text-muted-foreground opacity-0 pointer-events-none transition-opacity hover:text-foreground focus-visible:opacity-100 focus-visible:pointer-events-auto group-hover/pane:opacity-100 group-hover/pane:pointer-events-auto",children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),i]})}function sI({initialCwd:e,initialSessionId:t,initialView:r}){let{t:a}=(0,o.Bd)(),[i,d]=(0,s.useState)(r??"agent"),[m,x]=(0,s.useState)(null),{tabs:h,activeTabId:p,activeTab:b,paneTabIds:v,activePane:j,toggleSideBySide:w,focusPane:k,closePane:y,unreadTabs:N,dragTabIndex:C,dragOverTabIndex:S,closeTab:L,closeAllTabs:M,switchTab:E,handleSelectSession:P,handleNewTab:T,handleNewCodexTab:$,handleNewKimiTab:R,handleNewGlmTab:B,handleNewOllamaTab:F,handleNewDeepseekTab:I,handleOpenSession:D,updateTabState:A,updateTabEngine:z,updateTabOllamaModel:H,updateTabDeepseekModel:W,updateTabKimiModel:_,updateTabGlmModel:O,updateTabClaudeModel:q,updateTabClaudeEffort:V,updateTabClaudeContextWindow:U,updateTabClaudeFastMode:K,updateTabClaudeThinking:G,updateTabCodexModel:J,updateTabCodexReasoningEffort:Q,updateTabPlanMode:Z,updateTabNoHistory:X,handleTabDragStart:Y,handleTabDragOver:ee,handleTabDrop:et,handleTabDragEnd:er}=(0,n$.useTabState)({initialCwd:e,initialSessionId:t,activeView:i}),{isPinned:es,pinSession:eo,unpinSession:ea}=(0,sE.P)(),{createTask:el}=(0,sP.nS)(),ei=(0,s.useCallback)(e=>{let t=h.find(t=>t.id===e);return!!t?.sessionId&&es(t.sessionId)},[h,es]),ed=(0,s.useCallback)(t=>{let r=h.find(e=>e.id===t);r?.sessionId&&(es(r.sessionId)?ea(r.sessionId):eo(r.sessionId,r.cwd||e||"",r.title))},[h,es,eo,ea,e]),[ec,eu]=(0,s.useState)(!1),[em,ex]=(0,s.useState)(!1),[eh,ef]=(0,s.useState)(!1),[eg,eb]=(0,s.useState)(null),[ev,ej]=(0,s.useState)(!1),[ew,ek]=(0,s.useState)("tree"),[ey,eN]=(0,s.useState)(0),[eC,eS]=(0,s.useState)(null),[eL,eM]=(0,s.useState)(0),[eE,eP]=(0,s.useState)(null),[eT,e$]=(0,s.useState)(null),eR=null!==eT,eB=(0,s.useMemo)(()=>{let e;return{panes:e=eR?[p]:v,activePane:eR?0:j,row:e.length>1||eR,split:e.length>1,diffOrder:e.length}},[v,j,p,eR]),[eF,eI]=(0,s.useState)(null),[eD,eA]=(0,s.useState)();(0,s.useEffect)(()=>{window.parent.postMessage({type:"GET_PROJECT_NUMBER",cwd:e},"*")},[e]),(0,s.useEffect)(()=>{e&&!r&&u.t4.runPromiseExit((0,s$.D0)(e)).then(e=>{if("Success"===e._tag){let t=e.value.settings;t?.activeView&&d(t.activeView)}})},[e,r]);let[ez,eH]=(0,s.useState)(!1),eW=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=e=>{let{active:t}=e.detail;t?(eW.current=i,d("console"),eH(!0)):(eH(!1),eW.current&&"console"!==eW.current&&d(eW.current),eW.current=null)};return window.addEventListener("cockpit-screenshot-state",e),()=>window.removeEventListener("cockpit-screenshot-state",e)},[i]);let e_=(0,s.useCallback)(t=>{d(t),e&&(u.t4.runFork((0,s$.Yn)({cwd:e,settings:{activeView:t}}).pipe(ep.orElse(()=>ep.void))),u.t4.runFork(ep.flatMap(sT.d,r=>r.publish(c.n.ViewChange,{cwd:e,view:t}))))},[e]);(0,s.useEffect)(()=>{let e=()=>e_("console");return window.addEventListener("console-open-browser",e),()=>window.removeEventListener("console-open-browser",e)},[e_]);let eO=(0,s.useCallback)(async()=>{if(!e)return;let t=await u.t4.runPromiseExit((0,s$.b2)(e));if("Success"===t._tag){let r=t.value;if(ej(!!r.isGitRepo),r.isGitRepo&&r.worktrees&&r.worktrees.length>0){let t=r.worktrees.find(t=>t.path===e);t&&eb(t.branch)}}else console.error("Failed to load git info:",t.cause)},[e]);(0,s.useEffect)(()=>{queueMicrotask(()=>eO())},[eO]);let eq=(0,s.useCallback)(e=>{let{data:t}=e;Array.isArray(t)&&t.some(e=>"git"===e.type)&&eO()},[eO]);(0,en.h)({url:`/ws/watch?cwd=${encodeURIComponent(e||"")}`,onMessage:eq,enabled:!!e}),(0,s.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&("1"===e.key?(e.preventDefault(),e_("agent")):"2"===e.key?(e.preventDefault(),e_("explorer")):"3"===e.key?(e.preventDefault(),e_("console")):"s"===e.key&&e.preventDefault())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),(0,s.useEffect)(()=>{e&&window.parent!==window&&window.parent.postMessage({type:"SESSION_NUMBERS",cwd:e,sessionIds:h.map(e=>e.sessionId??null)},"*")},[e,h]),(0,s.useEffect)(()=>{let t=t=>{if(t.data?.type==="PROJECT_NUMBER"&&"number"==typeof t.data?.projectNumber)return void eA(t.data.projectNumber);if(t.data?.type==="IFRAME_VISIBILITY"&&"number"==typeof t.data?.projectNumber&&eA(t.data.projectNumber),t.data?.type==="GET_SESSION_NUMBERS"&&t.data?.requestId&&e)return void window.parent.postMessage({type:"SESSION_NUMBERS",requestId:t.data.requestId,cwd:e,sessionIds:h.map(e=>e.sessionId??null)},"*");if(t.data?.type==="SWITCH_SESSION"){let{sessionId:r,switchToAgent:n}=t.data;if(r){P(r),n&&e_("agent");let t=h.find(e=>e.sessionId===r);t&&eI(e=>({sessionId:r,nonce:(e?.nonce??0)+1})),e&&!t?.isLoading&&(u.t4.runFork((0,sR.KJ)(e,r,"normal").pipe(ep.orElse(()=>ep.void))),u.t4.runFork((0,sR.M2)(r).pipe(ep.orElse(()=>ep.void))))}}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[P,e_,e,h]);let eV=(0,s.useCallback)(()=>{ek("status"),eN(e=>e+1),e_("explorer")},[e_]),eU=(0,s.useCallback)(e=>{eS(e),eM(e=>e+1),e_("explorer")},[e_]),eK=(0,s.useCallback)(()=>e_("agent"),[e_]),[eG,eJ]=(0,s.useState)(!1),eQ=(0,s.useCallback)(()=>eJ(e=>!e),[]),eZ=(0,s.useCallback)(()=>{e$(null),eJ(!1)},[]),eX=(0,s.useRef)(eR);(0,s.useEffect)(()=>{eX.current=eR},[eR]);let eY=(0,s.useCallback)(()=>{eX.current?eZ():w()},[w,eZ]),e0=(0,s.useCallback)((e,t,r,n,s,o)=>{e$(a=>{var l;return l={messageId:e,toolCalls:t,cwd:r,sessionId:n,runId:s},!0!==o?l:a?.messageId!==l.messageId?a:{...a,toolCalls:l.toolCalls}}),o||e_("agent")},[e_]),e1=(0,s.useCallback)(e=>{eP({...e,nonce:Date.now()}),e_("explorer")},[e_]),e2=(0,s.useCallback)(()=>{e&&u.t4.runFork(ep.flatMap(sT.d,t=>t.publish(c.n.OpenNote,{cwd:e})))},[e]);return(0,n.jsx)(nP.k_,{children:(0,n.jsx)(t$.fY,{activeView:i,onViewChange:e_,children:(0,n.jsxs)("div",{className:"flex h-screen bg-card",children:[(0,n.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,n.jsx)(nR.TabManagerTopBar,{initialCwd:e,activeTab:b,isGitRepo:ev,currentBranch:eg,onOpenWorktree:()=>ex(!0),onOpenAliasManager:()=>ef(!0),onBranchSwitched:eO}),ez&&(0,n.jsxs)("div",{className:"flex items-center justify-center gap-2 py-1 bg-brand/15 text-brand text-xs font-medium border-b border-brand/20",children:[(0,n.jsx)("span",{className:"animate-pulse",children:"●"}),a("console.screenshotting")]}),e?(0,n.jsxs)(t$.c0,{children:[(0,n.jsx)("div",{className:"w-1/3 h-full flex flex-col overflow-hidden",children:(0,n.jsx)(g.a9,{children:(0,n.jsxs)("div",{className:"w-full h-full flex flex-col",children:[(0,n.jsx)(nB.TabBar,{tabs:h,selectedTabId:p,sideBySide:eB.split,onToggleSideBySide:eY,unreadTabs:N,dragTabIndex:C,dragOverTabIndex:S,isPinned:ei,onTogglePin:ed,onSwitchTab:E,onCloseTab:L,onCloseAllTabs:M,onNewTab:T,onNewCodexTab:$,onNewKimiTab:R,onNewGlmTab:B,onNewOllamaTab:F,onNewDeepseekTab:I,onOpenProjectSessions:()=>eu(!0),onDragStart:Y,onDragOver:ee,onDrop:et,onDragEnd:er}),(0,n.jsx)(l,{value:eB.split?m:null,children:(0,n.jsxs)("div",{className:`flex-1 overflow-hidden relative ${eB.row?"flex":""}`,children:[h.map(e=>(0,n.jsx)(sF,{tabId:e.id,panes:eB.panes,activePane:eB.activePane,row:eB.row,onFocusPane:k,onClosePane:y,children:(0,n.jsx)(sM,{tabId:e.id,...sB(e.id,eB),cwd:e.cwd,sessionId:e.sessionId,engine:e.engine,onEngineChange:z,ollamaModel:e.ollamaModel,onOllamaModelChange:H,deepseekModel:e.deepseekModel,onDeepseekModelChange:W,kimiModel:e.kimiModel,onKimiModelChange:_,glmModel:e.glmModel,onGlmModelChange:O,claudeModel:e.claudeModel,onClaudeModelChange:q,claudeEffort:e.claudeEffort,onClaudeEffortChange:V,claudeContextWindow:e.claudeContextWindow,onClaudeContextWindowChange:U,claudeFastMode:e.claudeFastMode,onClaudeFastModeChange:K,claudeThinking:e.claudeThinking,onClaudeThinkingChange:G,codexModel:e.codexModel,onCodexModelChange:J,codexReasoningEffort:e.codexReasoningEffort,onCodexReasoningEffortChange:Q,planMode:e.planMode,onPlanModeChange:Z,noHistory:e.noHistory,onNoHistoryChange:X,isActive:v.includes(e.id)&&"agent"===i,isFocused:e.id===p,refreshSignal:eF,onStateChange:A,onShowGitStatus:eV,onContentSearch:eU,onShowFileDiff:e0,onOpenFileLink:e1,onOpenNote:e2,onCreateScheduledTask:el,onOpenSession:D})},e.id)),eT&&(0,n.jsx)("div",{className:eG?"absolute inset-0 z-30 bg-card":"h-full flex-1 min-w-0 border-l border-border",style:eG?void 0:{order:eB.diffOrder},children:(0,n.jsx)(nT.e$,{toolCalls:eT.toolCalls,cwd:eT.cwd,sessionId:eT.sessionId,runId:eT.runId,onClose:eZ,onContentSearch:eU,fullscreen:eG,onToggleFullscreen:eQ},eT.messageId)})]})}),eB.split&&(0,n.jsx)("div",{ref:x,className:"flex-shrink-0"})]})})}),(0,n.jsx)("div",{className:"w-1/3 h-full overflow-hidden relative",children:(0,n.jsx)(g.a9,{children:(0,n.jsx)(tR,{onClose:eK,cwd:e,initialTab:ew,tabSwitchTrigger:ey,initialSearchQuery:eC,searchQueryTrigger:eL,fileOpenRequest:eE})})}),(0,n.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,n.jsx)(g.a9,{children:(0,n.jsx)(nE,{cwd:e,tabId:"default",onOpenNote:e2})})})]}):(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,n.jsx)(nB.TabBar,{tabs:h,selectedTabId:p,sideBySide:eB.split,onToggleSideBySide:eY,unreadTabs:N,dragTabIndex:C,dragOverTabIndex:S,isPinned:ei,onTogglePin:ed,onSwitchTab:E,onCloseTab:L,onCloseAllTabs:M,onNewTab:T,onNewCodexTab:$,onNewKimiTab:R,onNewGlmTab:B,onNewDeepseekTab:I,onDragStart:Y,onDragOver:ee,onDrop:et,onDragEnd:er}),(0,n.jsx)(l,{value:eB.split?m:null,children:(0,n.jsx)("div",{className:`flex-1 overflow-hidden relative ${eB.row?"flex":""}`,children:h.map(e=>(0,n.jsx)(sF,{tabId:e.id,panes:eB.panes,activePane:eB.activePane,row:eB.row,onFocusPane:k,onClosePane:y,children:(0,n.jsx)(sM,{tabId:e.id,...sB(e.id,eB),cwd:e.cwd,sessionId:e.sessionId,engine:e.engine,onEngineChange:z,ollamaModel:e.ollamaModel,onOllamaModelChange:H,deepseekModel:e.deepseekModel,onDeepseekModelChange:W,kimiModel:e.kimiModel,onKimiModelChange:_,glmModel:e.glmModel,onGlmModelChange:O,claudeModel:e.claudeModel,onClaudeModelChange:q,claudeEffort:e.claudeEffort,onClaudeEffortChange:V,claudeContextWindow:e.claudeContextWindow,onClaudeContextWindowChange:U,claudeFastMode:e.claudeFastMode,onClaudeFastModeChange:K,claudeThinking:e.claudeThinking,onClaudeThinkingChange:G,codexModel:e.codexModel,onCodexModelChange:J,codexReasoningEffort:e.codexReasoningEffort,onCodexReasoningEffortChange:Q,planMode:e.planMode,onPlanModeChange:Z,noHistory:e.noHistory,onNoHistoryChange:X,isActive:v.includes(e.id),isFocused:e.id===p,refreshSignal:eF,onStateChange:A,onCreateScheduledTask:el,onOpenSession:D})},e.id))})}),eB.split&&(0,n.jsx)("div",{ref:x,className:"flex-shrink-0"})]})]}),e&&(0,n.jsx)(f,{isOpen:ec,onClose:()=>eu(!1),cwd:e,onSelectSession:P,projectNumber:eD,openSessionIds:h.map(e=>e.sessionId)}),e&&ev&&(0,n.jsx)(tB,{isOpen:em,onClose:()=>ex(!1),cwd:e}),eh&&(0,n.jsx)(nu,{onClose:()=>ef(!1),onSave:()=>ef(!1)})]})})})}},60865:(e,t,r)=>{r.d(t,{NoteModal:()=>es});var n=r(95155),s=r(12115),o=r(79114),a=r(69809),l=r(13439),i=r(58940),d=r(43561),c=r(5989),u=r(76065),m=r(43203),x=r(6268),h=r(48434),f=r(82159),p=r(44695);let g={todo:"doing",doing:"done",done:"todo"},b={todo:"false",doing:"mixed",done:"true"},v=/^\s*(\[([ x/])?\])\s$/,j=p.L.extend({addAttributes:()=>({status:{default:"todo",keepOnSplit:!1,parseHTML:e=>(function(e){let t=e.getAttribute("data-status");if("todo"===t||"doing"===t||"done"===t)return t;let r=e.getAttribute("data-checked");return""===r||"true"===r?"done":"todo"})(e),renderHTML:e=>({"data-status":e.status,"data-checked":"done"===e.status?"true":"false"})}}),addStorage:()=>({markdown:{serialize(e,t){var r;e.write(`${"done"===(r=t.attrs.status)?"[x]":"doing"===r?"[/]":"[ ]"} `),e.renderContent(t)}}}),addInputRules(){return[(0,f.tG)({find:v,type:this.type,getAttributes:e=>{let t=e[e.length-1];return{status:"x"===t?"done":"/"===t?"doing":"todo"}}})]},renderHTML({HTMLAttributes:e}){return["li",(0,f.KV)(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},addNodeView(){return({node:e,getPos:t,editor:r})=>{let n=document.createElement("li");n.setAttribute("data-type",this.name);let s=document.createElement("label");s.classList.add("task-marker"),s.contentEditable="false";let o=document.createElement("span");o.classList.add("task-marker-box"),o.setAttribute("role","checkbox"),s.appendChild(o);let a=document.createElement("div");n.append(s,a);let l=e=>{let t=e.attrs.status??"todo";n.dataset.status=t,n.dataset.checked="done"===t?"true":"false",o.setAttribute("aria-checked",b[t])};return l(e),s.addEventListener("mousedown",e=>e.preventDefault()),s.addEventListener("click",e=>{if(e.preventDefault(),!r.isEditable||"function"!=typeof t)return;let n=t();"number"==typeof n&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=e.doc.nodeAt(n);if(!t)return!1;let r=t.attrs.status??"todo";return e.setNodeMarkup(n,void 0,{...t.attrs,status:g[r]}),!0}).run()}),{dom:n,contentDOM:a,update:t=>t.type===e.type&&(l(t),!0)}}}});var w=r(59265),k=r(26932),y=r(27050),N=r(52740),C=r(76865),S=r(63197);let L=new C.hs("headingFold");function M(e){let t=e.attrs.foldState;return"folded"===t||"children"===t?t:"expanded"}function E(e){let t=[],r=[];return e.forEach((e,n)=>{let s=n+e.nodeSize;if("heading"===e.type.name){let o=e.attrs.level;for(;r.length&&r[r.length-1].level>=o;)r.pop();let a=M(e),l=r.some(e=>"folded"===e.state),i=["note-heading"];"expanded"!==a&&i.push("is-collapsed"),l&&i.push("note-folded-hidden"),t.push(S.NZ.node(n,s,{class:i.join(" ")})),t.push(S.NZ.widget(n+1,(e,t)=>{let r;return(r=document.createElement("span")).className="note-fold-toggle",r.contentEditable="false",r.setAttribute("data-fold-state",a),r.addEventListener("mousedown",r=>{r.preventDefault(),r.stopPropagation();let n=t();if(null==n)return;let s=n-1,o=e.state.doc.nodeAt(s);o&&"heading"===o.type.name&&e.dispatch(e.state.tr.setNodeMarkup(s,void 0,{...o.attrs,foldState:"expanded"===M(o)?"folded":"expanded"}))}),r},{side:-1,key:`fold-${n}-${a}`})),r.push({level:o,state:a})}else r.some(e=>"folded"===e.state||"children"===e.state)&&t.push(S.NZ.node(n,s,{class:"note-folded-hidden"}))}),S.zF.create(e,t)}let P=N.A.extend({addAttributes(){return{...this.parent?.(),foldState:{default:"expanded",keepOnSplit:!1,parseHTML:e=>"true"===e.getAttribute("data-collapsed")?"folded":"expanded",renderHTML:e=>e.foldState&&"expanded"!==e.foldState?{"data-collapsed":"true"}:{}}}},addKeyboardShortcuts(){let e=this.name;return{Tab:()=>{var t;let r,n,s,{state:o}=this.editor,{$from:a}=o.selection;if(a.parent.type.name!==e)return!1;let l=a.before(a.depth),i=o.doc.nodeAt(l);if(!i||i.type.name!==e)return!1;let d=i.attrs.level,c=(t=o.doc,n=[],s=!1,t.forEach((t,r)=>{if(r===l){s=!0;return}if(s&&t.type.name===e){if(t.attrs.level<=d){s=!1;return}n.push(r)}}),n),u=c.length>0,m=M(i),x=null;return u?"expanded"===m?r="folded":(r="folded"===m?"children":"expanded",x="expanded"):r="expanded"===m?"folded":"expanded",this.editor.chain().command(({tr:t})=>{if(t.setNodeMarkup(l,void 0,{...i.attrs,foldState:r}),x)for(let r of c){let n=t.doc.nodeAt(r);n&&n.type.name===e&&t.setNodeMarkup(r,void 0,{...n.attrs,foldState:x})}return!0}).run()}}},addStorage:()=>({markdown:{serialize(e,t){e.write(e.repeat("#",t.attrs.level)+" "),e.renderInline(t,!1),"expanded"!==M(t)&&e.write(" \x3c!-- fold --\x3e"),e.closeBlock(t)},parse:{updateDOM(e){e.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach(e=>{let t=e.lastChild;for(;t&&3===t.nodeType&&!(t.textContent||"").trim();){let r=t.previousSibling;e.removeChild(t),t=r}if(t&&8===t.nodeType&&/^\s*fold\s*$/.test(t.textContent||"")){let r=t.previousSibling;e.removeChild(t),r&&3===r.nodeType&&(r.textContent=(r.textContent||"").replace(/\s+$/,"")),e.setAttribute("data-collapsed","true")}})}}}}),addProseMirrorPlugins:()=>[new C.k_({key:L,state:{init:(e,{doc:t})=>E(t),apply:(e,t)=>e.docChanged?E(e.doc):t},props:{decorations:e=>L.getState(e)}})]});function T(e){let t=[];return e.forEach((e,r)=>t.push({node:e,start:r,end:r+e.nodeSize})),t}function $(e,t){return"heading"===e.type.name&&e.attrs.level<=t}function R(e){for(let t=e.depth;t>0;t--){let r=e.node(t).type.name;if("listItem"===r||"taskItem"===r)return t}return -1}function B(e,t,r,n,s){let o=t.slice(r,n),a=t.slice(n,s);e.replaceWith(r,s,a.content.append(o.content))}function F(e,t){let r=Math.max(0,Math.min(t,e.doc.content.size));e.setSelection(C.U3.near(e.doc.resolve(r)))}let I=new Set(["paragraph","bulletList","orderedList","taskList"]);function D(e,t,r){let{doc:n,selection:s}=e,o=s.$from,a=o.before(1),l=T(n),i=l.findIndex(e=>e.start===a);if(i<0)return!1;let d=i;for(;d>0&&I.has(l[d-1].node.type.name);)d--;let c=i;for(;c<l.length-1&&I.has(l[c+1].node.type.name);)c++;let u=[],m=-1,x="paragraph"===l[i].node.type.name?-1:o.index(1);for(let e=d;e<=c;e++){let t=l[e].node;if("paragraph"===t.type.name)e===i&&(m=u.length),u.push({kind:"paragraph",node:t});else{let r=t.type.name,n=0;t.forEach(t=>{e===i&&n===x&&(m=u.length),u.push({kind:r,node:t}),n++})}}if(m<0)return!1;let h=m+(r>0?1:-1);if(h<0||h>=u.length)return!1;if(t){let r,n,s,a=u[m];u[m]=u[h],u[h]=a;let i=function(e,t){let r=[],n=0;for(;n<e.length;){if("paragraph"===e[n].kind){r.push(e[n].node),n++;continue}let s=e[n].kind,o=[];for(;n<e.length&&e[n].kind===s;)o.push(e[n].node),n++;r.push(t.schema.nodes[s].create(null,o))}return y.FK.from(r)}(u,e),x=l[d].start,f=l[c].end,p=e.tr;p.replaceWith(x,f,i);let g=(r=0,n=0,s=-1,i.forEach(e=>{if(!(s>=0))if("paragraph"===e.type.name)r===h&&(s=n+1),r++,n+=e.nodeSize;else{let t=n+1;e.forEach(e=>{s>=0||(r===h&&(s=t+2),r++,t+=e.nodeSize)}),n+=e.nodeSize}}),s);F(p,g>=0?x+g+o.parentOffset:x),t(p.scrollIntoView())}return!0}function A(e,t,r){let n=e.selection.$from;if(1===n.depth&&"heading"===n.parent.type.name)return function(e,t,r){let{doc:n,selection:s}=e,o=s.$from.before(1),a=T(n),l=a.findIndex(e=>e.start===o);if(l<0)return!1;let i=a[l].node.attrs.level,d=l+1;for(;d<a.length&&!$(a[d].node,i);)d++;let c=a[l].start,u=a[d-1].end;if(r>0){if(d>=a.length)return!1;let r=a[d].node.attrs.level,o=d+1;for(;o<a.length&&!$(a[o].node,r);)o++;let l=a[o-1].end;if(t){let r=e.tr,o=n.slice(u,l).content.size;B(r,n,c,u,l),F(r,c+o+(s.from-c)),t(r.scrollIntoView())}return!0}if(0===l)return!1;let m=l-1;for(;m>=0&&!$(a[m].node,i);)m--;if(m<0||a[m].node.attrs.level<i)return!1;let x=a[m].start;if(t){let r=e.tr;B(r,n,x,c,u),F(r,x+(s.from-c)),t(r.scrollIntoView())}return!0}(e,t,r);let s=R(n);if(s>0){let o=n.node(s-1),a=n.index(s-1);return(r>0?a<o.childCount-1:a>0)?function(e,t,r,n){let{doc:s,selection:o}=e,a=o.$from,l=a.node(n),i=a.node(n-1),d=a.index(n-1),c=a.before(n),u=c+l.nodeSize;if(r>0){if(d>=i.childCount-1)return!1;let r=u+i.child(d+1).nodeSize;if(t){let n=e.tr,a=s.slice(u,r).content.size;B(n,s,c,u,r),F(n,c+a+(o.from-c)),t(n.scrollIntoView())}return!0}if(d<=0)return!1;let m=c-i.child(d-1).nodeSize;if(t){let r=e.tr;B(r,s,m,c,u),F(r,m+(o.from-c)),t(r.scrollIntoView())}return!0}(e,t,r,s):2===s&&D(e,t,r)}let o=n.depth>=1?n.node(n.depth-1).type.name:"doc";return"paragraph"===n.parent.type.name&&"doc"===o&&D(e,t,r)}function z(e,t){let{state:r}=e,n=r.selection.$from,s=n.parent.type.name;if("doc"===(n.depth>=1?n.node(n.depth-1).type.name:"doc")&&("heading"===s||"paragraph"===s)){let r=(("heading"===s?n.parent.attrs.level-1:3)+(t>0?1:-1)+4)%4;return 3===r?e.chain().setParagraph().run():e.chain().setHeading({level:r+1}).run()}let o=R(n);if(o>0){let r=n.node(o).type.name;return t<0?e.commands.liftListItem(r):e.commands.sinkListItem(r)}return!1}function H(e,t){let{state:r}=e,n=r.selection;if(!n.empty)return!1;let s=n.$from,o=t>0?1:-1;for(let t=s.depth;t>0;t--)if("taskItem"===s.node(t).type.name){let n=s.before(t),a=r.doc.nodeAt(n);if(!a)return!1;let l=a.attrs.status??"todo",i=(("doing"===l?2:"done"===l?3:1)+o+4)%4;if(0===i)return e.chain().toggleTaskList().run();let d=2===i?"doing":3===i?"done":"todo";return e.chain().command(({tr:e})=>{let t=e.doc.nodeAt(n);return!!t&&(e.setNodeMarkup(n,void 0,{...t.attrs,status:d}),!0)}).run()}if("paragraph"!==s.parent.type.name)return!1;let a=s.depth>=1?s.node(s.depth-1).type.name:"doc";return("doc"===a||"listItem"===a)&&(1==(0+o+4)%4?e.chain().toggleTaskList().run():e.chain().toggleTaskList().command(({tr:e})=>(function(e,t){let r=e.selection.$from;for(let n=r.depth;n>0;n--)if("taskItem"===r.node(n).type.name){let s=r.before(n),o=e.doc.nodeAt(s);o&&e.setNodeMarkup(s,void 0,{...o.attrs,status:t});break}return!0})(e,"done")).run())}let W=f.YY.create({name:"noteOrgKeymap",addKeyboardShortcuts(){return{"Alt-ArrowUp":()=>this.editor.commands.command(({state:e,dispatch:t})=>A(e,t,-1)),"Alt-ArrowDown":()=>this.editor.commands.command(({state:e,dispatch:t})=>A(e,t,1)),"Alt-ArrowLeft":()=>z(this.editor,-1),"Alt-ArrowRight":()=>z(this.editor,1),"Shift-ArrowRight":()=>H(this.editor,1),"Shift-ArrowLeft":()=>H(this.editor,-1)}}});function _(e){return e.storage.markdown.getMarkdown()}function O(){return[{label:a.A.t("slashCommands.heading1"),icon:"H1",description:a.A.t("slashCommands.heading1Desc"),action:e=>e.chain().focus().toggleHeading({level:1}).run()},{label:a.A.t("slashCommands.heading2"),icon:"H2",description:a.A.t("slashCommands.heading2Desc"),action:e=>e.chain().focus().toggleHeading({level:2}).run()},{label:a.A.t("slashCommands.heading3"),icon:"H3",description:a.A.t("slashCommands.heading3Desc"),action:e=>e.chain().focus().toggleHeading({level:3}).run()},{label:a.A.t("slashCommands.bulletList"),icon:"•",description:a.A.t("slashCommands.bulletListDesc"),action:e=>e.chain().focus().toggleBulletList().run()},{label:a.A.t("slashCommands.orderedList"),icon:"1.",description:a.A.t("slashCommands.orderedListDesc"),action:e=>e.chain().focus().toggleOrderedList().run()},{label:a.A.t("slashCommands.taskList"),icon:"☑",description:a.A.t("slashCommands.taskListDesc"),action:e=>e.chain().focus().toggleTaskList().run()},{label:a.A.t("slashCommands.blockquote"),icon:"❝",description:a.A.t("slashCommands.blockquoteDesc"),action:e=>e.chain().focus().toggleBlockquote().run()},{label:a.A.t("slashCommands.codeBlock"),icon:"<>",description:a.A.t("slashCommands.codeBlockDesc"),action:e=>e.chain().focus().toggleCodeBlock().run()},{label:a.A.t("slashCommands.table"),icon:"▦",description:a.A.t("slashCommands.tableDesc"),action:e=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{label:a.A.t("slashCommands.horizontalRule"),icon:"──",description:a.A.t("slashCommands.horizontalRuleDesc"),action:e=>e.chain().focus().setHorizontalRule().run()},{label:a.A.t("slashCommands.link"),icon:"\uD83D\uDD17",description:a.A.t("slashCommands.linkDesc"),action:e=>{window.dispatchEvent(new CustomEvent("tiptap-insert-link"))}}]}function q({editor:e,query:t,position:r,onClose:o}){let[a,l]=(0,s.useState)(0),i=(0,s.useRef)(null),d=O().filter(e=>e.label.toLowerCase().includes(t.toLowerCase())||e.description.toLowerCase().includes(t.toLowerCase()));(0,s.useEffect)(()=>{queueMicrotask(()=>l(0))},[t]);let c=r=>{e.chain().focus().deleteRange({from:e.state.selection.from-t.length-1,to:e.state.selection.from}).run(),r.action(e),o()};return((0,s.useEffect)(()=>{let e=e=>{"ArrowDown"===e.key?(e.preventDefault(),l(e=>(e+1)%d.length)):"ArrowUp"===e.key?(e.preventDefault(),l(e=>(e-1+d.length)%d.length)):"Enter"===e.key?(e.preventDefault(),d[a]&&c(d[a])):"Escape"===e.key&&(e.preventDefault(),o())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[d,a,o]),0===d.length)?null:(0,n.jsx)("div",{ref:i,className:"slash-command-menu fixed z-[60] bg-popover border border-border rounded-lg shadow-lv2 py-1 w-56 max-h-64 overflow-y-auto",style:{top:r.top,left:r.left},children:d.map((e,t)=>(0,n.jsxs)("button",{className:`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors ${t===a?"bg-accent text-foreground":"text-muted-foreground hover:bg-hover hover:text-foreground"}`,onClick:()=>c(e),onMouseEnter:()=>l(t),children:[(0,n.jsx)("span",{className:"w-6 text-center text-xs font-mono flex-shrink-0",children:e.icon}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"font-medium",children:e.label}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:e.description})]})]},e.label))})}O();var V=r(76043),U=r(86957),K=r(49433),G=r(34075),J=r(76900);let Q=/^\s*[-*+]\s+(?:\\?\[ \\?\]|\\?\[[xX/]\\?\])\s*$/,Z=/^\s*(```|~~~)/;function X(e){return e.classList.contains("task-list-item")}let Y=/^\s*\[\/\]\s?/,ee=f.YY.create({name:"markdownTaskListFix",addStorage:()=>({markdown:{parse:{updateDOM(e){var t;for(let r of Array.from(e.querySelectorAll("li"))){if(X(r))continue;let e=r.parentElement;e&&"UL"===e.tagName&&(t=r.textContent||"",/^\s*\[\/\]/.test(t)&&(!function(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=t.nextNode();for(;r&&!(r.nodeValue&&""!==r.nodeValue.trim());)r=t.nextNode();r&&r.nodeValue&&(r.nodeValue=r.nodeValue.replace(Y,""))}(r),r.classList.add("task-list-item"),r.setAttribute("data-type","taskItem"),r.setAttribute("data-status","doing"),e.classList.add("contains-task-list")))}!function(e){for(let t of Array.from(e.querySelectorAll("ul.contains-task-list"))){let e=Array.from(t.children).filter(e=>"LI"===e.tagName);if(0===e.length)continue;let r=function(e){let t=[];for(let r of e){let e=t[t.length-1];e&&e.isTask===r.isTask?e.items.push(r):t.push({isTask:r.isTask,items:[r]})}return t}(e.map(e=>({isTask:X(e),el:e})));if(r.length<=1){r[0]?.isTask&&t.setAttribute("data-type","taskList");continue}let n=t.ownerDocument,s=n.createDocumentFragment();for(let e of r){let t=n.createElement("ul");for(let{el:r}of(e.isTask&&(t.setAttribute("class","contains-task-list"),t.setAttribute("data-type","taskList")),e.items))t.appendChild(r);s.appendChild(t)}t.replaceWith(s)}}(e)}}}})});var et=r(8242);let er=new Set(["taskItem","listItem"]),en=f.YY.create({name:"dropShellCleanup",addProseMirrorPlugins:()=>[new C.k_({key:new C.hs("dropShellCleanup"),appendTransaction(e,t,r){let n=[];if(e.forEach((t,r)=>{let s;if("drop"!==t.getMeta("uiEvent")||!t.docChanged)return;let o=(s=[],t.steps.forEach((e,r)=>{e instanceof et.Ln&&(0!==e.slice.size||e.from>=e.to||s.push(t.mapping.slice(r+1).map(e.from)))}),s);for(let t=r+1;t<e.length;t++)o=o.map(r=>e[t].mapping.map(r));n.push(...o)}),0===n.length)return null;let s=r.tr,o=!1;for(let e of n){let t=function(e,t){if(t<0||t>e.content.size)return null;let r=e.resolve(t);for(let e=r.depth;e>0;e--){var n;if(n=r.node(e),!er.has(n.type.name)||1!==n.childCount||null===n.firstChild||!n.firstChild.isTextblock||0!==n.firstChild.content.size)continue;let t=e;for(;t>1&&1===r.node(t-1).childCount;)t--;return{from:r.before(t),to:r.after(t)}}return null}(s.doc,s.mapping.map(e));if(t)try{s.delete(t.from,t.to),o=!0}catch{}}return o?s:null}})]});function es({isOpen:e,onClose:t,projectCwd:r,projectName:f}){let{t:p}=(0,o.Bd)(),[g,b]=(0,s.useState)(!0),[v,N]=(0,s.useState)(!1),C=(0,s.useRef)(null),S=(0,s.useRef)(!1),L=(0,s.useRef)(void 0),[M,E]=(0,s.useState)(null),T=(0,s.useRef)(null),$=(0,s.useCallback)(async e=>{let t=function(e){if(!e)return e;let t=e.split("\n"),r=[],n=!1;for(let e of t){if(Z.test(e)){n=!n,r.push(e);continue}if(n){r.push(e);continue}Q.test(e)||r.push(e)}let s=[],o=0,a=!1;for(let e of r){if(Z.test(e)){a=!a,s.push(e),o=0;continue}if(!a&&""===e.trim()){if((o+=1)>=2)continue;s.push(e);continue}o=0,s.push(e)}return s.join("\n")}(e);N(!0);let n=await U.t4.runPromiseExit((0,J.Cq)(r,t,L.current).pipe(K.tapError(e=>K.sync(()=>console.error("Failed to save note:",e)))));if("Success"===n._tag){let e=n.value;e.conflict?(F.current?.commands.setContent(e.content,{emitUpdate:!1}),L.current=e.mtime,S.current=!1,(0,G.oR)(p("editor.conflictReloaded"),"info")):(L.current=e.mtime,S.current=!1)}N(!1)},[r,p]),R=(0,s.useCallback)(e=>{S.current=!0,C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{$(e)},5e3)},[$]),B=(0,l.hG)({immediatelyRender:!1,extensions:[i.A.configure({heading:!1,link:!1}),P.configure({levels:[1,2,3]}),W,d.A.configure({placeholder:()=>a.A.t("editor.placeholder")}),c.XI.configure({resizable:!0}),u.H,m.n,x.A,h._,w.Ay.configure({autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"tiptap-link",target:"_blank",rel:"noopener noreferrer"}}),j.configure({nested:!0}),ee,en,k.o.configure({html:!0,transformCopiedText:!1,transformPastedText:!0})],editorProps:{attributes:{class:"tiptap-editor focus:outline-none min-h-[60vh] px-6 py-4"},clipboardTextSerializer:e=>e.content.textBetween(0,e.content.size,"\n").replace(/\n+$/,""),transformCopied:e=>{let t=e=>!!e&&e.isTextblock&&0===e.content.size,r=e.content,{openStart:n,openEnd:s}=e;for(;r.childCount>1&&t(r.lastChild);)r=r.cut(0,r.size-r.lastChild.nodeSize),s=0;for(;r.childCount>1&&t(r.firstChild);)r=r.cut(r.firstChild.nodeSize),n=0;return new y.Ji(r,n,s)},handleClick:(e,t,r)=>{if(r.metaKey||r.ctrlKey){let r=e.state.doc.resolve(t).marks().find(e=>"link"===e.type.name)?.attrs;if(r?.href)return window.open(r.href,"_blank","noopener,noreferrer"),!0}return!1},handleKeyDown:(e,t)=>{if("Backspace"===t.key&&F.current){let e=F.current;if(e.isActive("codeBlock")){let{$from:t}=e.state.selection,r=t.node(t.depth);if("codeBlock"===r.type.name&&""===r.textContent)return e.chain().focus().toggleCodeBlock().run(),!0}}return"/"!==t.key||M||setTimeout(()=>{if(!F.current)return;let{from:e}=F.current.state.selection;if("/"===F.current.state.doc.textBetween(Math.max(0,e-1),e,"\n")){T.current=e;let t=F.current.view.coordsAtPos(e);E({query:"",position:{top:t.bottom+4,left:t.left}})}},0),!1}},onUpdate:({editor:e})=>{if(R(_(e)),null!==T.current){let{from:t}=e.state.selection;if(t<T.current)E(null),T.current=null;else{let r=e.state.doc.textBetween(T.current,t,"\n");r.includes(" ")||r.includes("\n")?(E(null),T.current=null):E(e=>e?{...e,query:r}:null)}}}}),F=(0,s.useRef)(null);(0,s.useEffect)(()=>{F.current=B},[B]),(0,s.useEffect)(()=>{e&&B&&(b(!0),E(null),T.current=null,U.t4.runPromiseExit((0,J.zF)(r)).then(e=>{"Success"===e._tag?(B.commands.setContent(e.value.content||"",{emitUpdate:!1}),L.current=e.value.mtime,C.current&&(clearTimeout(C.current),C.current=null),S.current=!1):console.error("Failed to load note:",e.cause),b(!1)}))},[e,B,r]);let I=(0,s.useCallback)(()=>{C.current&&(clearTimeout(C.current),C.current=null),S.current&&B&&$(_(B)),E(null),T.current=null,t()},[B,$,t]);return((0,s.useEffect)(()=>()=>{C.current&&clearTimeout(C.current)},[]),(0,s.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&(M?(E(null),T.current=null):I())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,I,M]),e)?(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:I}),(0,n.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-6xl h-[90vh] mx-4 flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:f?p("editor.noteTitle",{name:f}):p("editor.noteUntitled")}),v&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:p("editor.saving")})]}),(0,n.jsx)("button",{onClick:I,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)(V.NoteToolbar,{editor:B}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:g?(0,n.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:(0,n.jsx)("span",{children:p("common.loading")})}):(0,n.jsx)(l.$Z,{editor:B})})]}),M&&B&&(0,n.jsx)(q,{editor:B,query:M.query,position:M.position,onClose:()=>{E(null),T.current=null}})]}):null}},63728:(e,t,r)=>{r.d(t,{R8:()=>i,c0:()=>c,fY:()=>d,gT:()=>u});var n=r(95155),s=r(12115);let o=["agent","explorer","console"],a={agent:"AGENT",explorer:"EXPLORER",console:"CONSOLE"},l=(0,s.createContext)(null);function i(){let e=(0,s.useContext)(l);if(!e)throw Error("useSwipeContext must be used within SwipeableViewContainer");return e}function d({activeView:e,onViewChange:t,children:r}){let a=(0,s.useRef)(null),i=(0,s.useRef)(!1),c=(0,s.useRef)(0),[u,m]=(0,s.useState)(0),[x,h]=(0,s.useState)(!1),f=o.indexOf(e),p=o.length-1;(0,s.useEffect)(()=>{c.current=0,queueMicrotask(()=>m(0))},[e]),(0,s.useEffect)(()=>{let e=e=>{if(Math.abs(e.deltaX)>Math.abs(e.deltaY)&&Math.abs(e.deltaX)>2){let r=e.target;if("IFRAME"===r.tagName||function(e){for(;e;){let t=window.getComputedStyle(e).overflowX;if(("auto"===t||"scroll"===t)&&e.scrollWidth>e.clientWidth)return!0;e=e.parentElement}return!1}(r))return;e.preventDefault(),e.stopPropagation(),i.current&&(i.current=!1);let n=window.innerWidth,s=c.current-6*e.deltaX;!(f>0)&&s>0&&(s=0),!(f<p)&&s<0&&(s=0),c.current=s=Math.max(-n,Math.min(n,s)),m(s),h(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{let e=c.current,r=.12*n;h(!1),i.current=!0;let s=f;e<-r&&f<p?s=f+1:e>r&&f>0&&(s=f-1),c.current=0,m(0),s!==f&&t(o[s]),setTimeout(()=>{i.current=!1},80)},60)}};return document.addEventListener("wheel",e,{passive:!1,capture:!0}),()=>document.removeEventListener("wheel",e,{capture:!0})},[f,p,t]);let[g,b]=(0,s.useState)(!1);(0,s.useEffect)(()=>{queueMicrotask(()=>b(!0))},[]);let v={activeView:e,onViewChange:t,dragOffset:(()=>{if(!g)return 0;let e=window.innerWidth;return e?u/e:0})(),isDragging:g&&x};return(0,n.jsx)(l.Provider,{value:v,children:r})}function c({children:e}){let t,r,{activeView:a,dragOffset:l,isDragging:d}=i(),u=(0,s.useRef)(null),m=(0,s.useRef)(null),x=o.indexOf(a),h=o.length;return(0,s.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{0!==e.scrollLeft&&(e.scrollLeft=0)};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[]),(0,n.jsx)("div",{ref:u,className:"flex-1 overflow-hidden relative",style:{overscrollBehaviorX:"none"},children:(0,n.jsx)("div",{ref:m,className:d?"flex":"flex transition-transform duration-100 ease-out",style:{position:"absolute",top:"0px",bottom:"0px",left:"0px",width:`${100*o.length}%`,transform:(t=l/h*100,r=-(100/h*x)+(Number.isFinite(t)?t:0),`translateX(${r}%)`)},children:e})})}function u(){let{activeView:e,onViewChange:t,dragOffset:r,isDragging:l}=i(),d=(0,s.useRef)(null),c=(0,s.useRef)([]),[u,m]=(0,s.useState)({left:0,width:0}),x=o.indexOf(e),h=()=>{if(!d.current||0===c.current.length)return{left:0,width:0};let e=d.current.getBoundingClientRect(),t=c.current.filter(Boolean);if(t.length!==o.length)return{left:0,width:0};let n=Number.isFinite(r)?r:0,s=Math.max(0,Math.min(o.length-1,x-n)),a=Math.floor(s),l=Math.ceil(s),i=s-a,u=t[a],m=t[l];if(!u||!m)return{left:0,width:0};let h=u.getBoundingClientRect(),f=m.getBoundingClientRect();return{left:h.left+(f.left-h.left)*i-e.left,width:h.width+(f.width-h.width)*i}};(0,s.useEffect)(()=>{queueMicrotask(()=>m(h()))},[x,r]),(0,s.useEffect)(()=>{let e=()=>{m(h())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[x,r]);let f=Number.isFinite(r)?r:0,p=Math.round(Math.max(0,Math.min(o.length-1,x-f)));return(0,n.jsxs)("div",{ref:d,className:"relative flex gap-4",children:[o.map((e,r)=>(0,n.jsx)("button",{ref:e=>{c.current[r]=e},onClick:()=>t(e),className:`px-4 py-1 text-sm font-medium transition-colors ${p===r?"text-brand":"text-muted-foreground hover:text-foreground"}`,children:a[e]},e)),(0,n.jsx)("div",{className:`absolute bottom-0 h-0.5 bg-brand ${l?"":"transition-all duration-100 ease-out"}`,style:{left:u.left,width:u.width}})]})}},66109:(e,t,r)=>{r.d(t,{aO:()=>n,iG:()=>s,jL:()=>o});let n="relative w-full max-w-[calc((100vw_-_28rem)*0.9)] h-[90vh] mx-4 bg-card rounded-lg shadow-lv3 flex flex-col overflow-hidden",s="relative w-full max-w-[calc((100vw_-_14rem)*0.9)] h-[90vh] mx-4 bg-card rounded-lg shadow-lv3 flex flex-col overflow-hidden",o="grid grid-cols-[repeat(auto-fill,minmax(320px,1fr))] gap-3"},68287:(e,t,r)=>{r.d(t,{c:()=>n});function n(e,t){return"loading"===e?"border-transparent bg-orange-11/20 text-foreground animate-pulse":"unread"===e?"border-transparent bg-red-9/55 text-foreground":t?"border-transparent bg-brand/15 text-brand":"border-transparent bg-muted-foreground/15 text-muted-foreground"}},72363:(e,t,r)=>{r.d(t,{$2:()=>j,N4:()=>c,_I:()=>v,fX:()=>u,fZ:()=>m});let n="cockpit update",s={visible:!1,stage:"preparing",startedAt:0,baselineMs:null,installedVersion:null,upToDate:!1,error:null,rolledBack:!1,fixCommand:n,logPath:null,live:!1},o="cockpit:update-seen-at",a=s,l=new Set,i=!1;function d(e){a={...a,...e},l.forEach(e=>e())}function c(e){return l.add(e),()=>l.delete(e)}function u(){return a}function m(){try{window.localStorage.setItem(o,String(Date.now()))}catch{}d({visible:!1})}let x=e=>new Promise(t=>setTimeout(t,e));async function h(){try{let e=await fetch("/api/health",{cache:"no-store",signal:AbortSignal.timeout(2e3)});if(!e.ok)return null;let t=await e.json();return{pid:"number"==typeof t.pid?t.pid:null,version:t.version??null}}catch{return null}}async function f(){try{let e=await fetch("/api/update-state",{cache:"no-store",signal:AbortSignal.timeout(2e3)});if(!e.ok)return{state:null,logPath:null};let t=await e.json();return{state:t.state??null,logPath:t.logPath??null}}catch{return{state:null,logPath:null}}}async function p(e){try{let t=await fetch(`http://127.0.0.1:${e}/`,{cache:"no-store",signal:AbortSignal.timeout(1500)});if(!t.ok)return null;return await t.json()}catch{return null}}function g(e){switch(e){case"installing":return"installing";case"repairing":return"repairing";case"rolling-back":return"rolling-back";case"restarting":case"done":return"restarting";default:return"preparing"}}function b(e,t={}){d({stage:"failed",error:e,...t})}async function v(){if(!i){i=!0,d({...s,visible:!0,stage:"preparing",startedAt:Date.now()});try{let e=await f();d({baselineMs:e.state?.installMs??e.state?.prevInstallMs??null,logPath:e.logPath});let t=await h(),r=t?.pid??null,s=t?.version??null,o=await fetch("/api/update",{method:"POST"});if(!o.ok){let e=await o.json().catch(()=>({}));b(e.error??`HTTP ${o.status}`);return}let l=await o.json().catch(()=>({})),i=l.statusPort??null;d({logPath:l.logPath??a.logPath});let c=0,u=null!==i,m=Date.now()+3e5;for(;Date.now()<m;){if(await x(1e3),u&&null!==i){let e=await p(i);if(e){if(c=0,d({live:!0}),"failed"===e.phase)return void b(e.error??"install failed",{rolledBack:!0===e.rolledBack,fixCommand:e.fixCommand??n,live:!0});d({stage:g(e.phase),installedVersion:e.installed??a.installedVersion,baselineMs:a.baselineMs??e.prevInstallMs??null})}else++c>=3&&(u=!1,d({live:!1}))}let e=await h();if(e?.pid!=null&&(null===r||e.pid!==r)){let{state:t}=await f();if(t?.phase==="failed")return void b(t.error??"update failed",{rolledBack:!0===t.rolledBack,fixCommand:t.fixCommand??n});let r=e.version??a.installedVersion;d({stage:"done",installedVersion:r,upToDate:null!==r&&r===s});return}}b("timeout")}catch(e){b(e instanceof Error?e.message:String(e))}finally{i=!1}}}async function j(){if(i||a.visible)return;let{state:e,logPath:t}=await f();if(!e?.phase||"done"===e.phase)return;let r=e.startedAt??0,l=e.installMs??e.prevInstallMs??null;if("failed"===e.phase){let a=0;try{a=Number(window.localStorage.getItem(o))||0}catch{}if((e.finishedAt??0)<=a)return;d({...s,visible:!0,stage:"failed",startedAt:r,baselineMs:l,error:e.error??"unknown error",rolledBack:!0===e.rolledBack,fixCommand:e.fixCommand??n,logPath:t});return}if(!(!r||Date.now()-r>6e5)){i=!0,d({...s,visible:!0,stage:g(e.phase),startedAt:r,baselineMs:l,logPath:t});try{let e=r+3e5;for(;Date.now()<e;){await x(1e3);let{state:e}=await f();if(e?.phase){if("failed"===e.phase)return void b(e.error??"install failed",{rolledBack:!0===e.rolledBack,fixCommand:e.fixCommand??n});if("done"===e.phase)return void d({stage:"done",installedVersion:e.installed??null,upToDate:!0===e.unchanged});d({stage:g(e.phase)})}}b("timeout")}finally{i=!1}}}},76043:(e,t,r)=>{r.d(t,{NoteToolbar:()=>l});var n=r(95155),s=r(12115),o=r(79114);function a({editor:e,onClose:t,position:r}){let{t:l}=(0,o.Bd)(),[i,d]=(0,s.useState)(()=>e.getAttributes("link").href||""),c=(0,s.useRef)(null);(0,s.useEffect)(()=>{c.current?.focus()},[]);let u=()=>{let r=i.trim();if(r){let t=r.match(/^https?:\/\//)?r:`https://${r}`;e.chain().focus().extendMarkRange("link").setLink({href:t}).run()}else e.chain().focus().extendMarkRange("link").unsetLink().run();t()},m=r?{top:r.top,left:r.left}:{};return(0,n.jsxs)("div",{className:`${r?"fixed":"absolute top-full left-0 mt-1"} z-[60] bg-popover border border-border rounded-lg shadow-lv2 p-2 flex items-center gap-2`,style:m,children:[(0,n.jsx)("input",{ref:c,type:"text",value:i,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),u()):"Escape"===e.key&&(e.preventDefault(),t())},placeholder:l("editor.linkPlaceholder"),className:"bg-background border border-border rounded px-2 py-1 text-sm w-64 outline-none focus:border-brand"}),(0,n.jsx)("button",{onClick:u,className:"p-1 rounded text-sm font-medium text-brand hover:bg-brand/10 transition-colors",title:l("editor.confirmLink"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})})}),e.isActive("link")&&(0,n.jsx)("button",{onClick:()=>{e.chain().focus().extendMarkRange("link").unsetLink().run(),t()},className:"p-1 rounded text-sm font-medium text-red-11 hover:bg-red-500/10 transition-colors",title:l("editor.removeLink"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})}function l({editor:e}){let{t}=(0,o.Bd)(),[r,i]=(0,s.useState)(!1),d=(0,s.useRef)(null),[,c]=(0,s.useState)(0);if((0,s.useEffect)(()=>{if(!e)return;let t=()=>c(e=>e+1);return e.on("selectionUpdate",t),e.on("transaction",t),()=>{e.off("selectionUpdate",t),e.off("transaction",t)}},[e]),(0,s.useEffect)(()=>{let e=()=>i(!0);return window.addEventListener("tiptap-insert-link",e),()=>window.removeEventListener("tiptap-insert-link",e)},[]),!e)return null;let u=e=>`p-1.5 rounded text-xs font-medium transition-colors ${e?"bg-brand/15 text-brand":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,m="w-px h-5 bg-border mx-0.5",x=e.isActive("table");return(0,n.jsxs)("div",{className:"flex items-center gap-0.5 px-4 py-1.5 border-b border-border flex-shrink-0 flex-wrap",children:[(0,n.jsx)("button",{className:u(e.isActive("heading",{level:1})),onClick:()=>e.chain().focus().toggleHeading({level:1}).run(),title:t("editor.heading1"),children:"H1"}),(0,n.jsx)("button",{className:u(e.isActive("heading",{level:2})),onClick:()=>e.chain().focus().toggleHeading({level:2}).run(),title:t("editor.heading2"),children:"H2"}),(0,n.jsx)("button",{className:u(e.isActive("heading",{level:3})),onClick:()=>e.chain().focus().toggleHeading({level:3}).run(),title:t("editor.heading3"),children:"H3"}),(0,n.jsx)("div",{className:m}),(0,n.jsx)("button",{className:u(e.isActive("bold")),onClick:()=>e.chain().focus().toggleBold().run(),title:t("editor.bold"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"})})}),(0,n.jsx)("button",{className:u(e.isActive("italic")),onClick:()=>e.chain().focus().toggleItalic().run(),title:t("editor.italic"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"})})}),(0,n.jsx)("button",{className:u(e.isActive("strike")),onClick:()=>e.chain().focus().toggleStrike().run(),title:t("editor.strikethrough"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"})})}),(0,n.jsx)("button",{className:u(e.isActive("code")),onClick:()=>e.chain().focus().toggleCode().run(),title:t("editor.inlineCode"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"})})}),(0,n.jsx)("div",{className:m}),(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("button",{ref:d,className:u(e.isActive("link")),onClick:()=>i(!r),title:t("editor.link"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})})}),r&&(0,n.jsx)(a,{editor:e,onClose:()=>i(!1),position:null})]}),(0,n.jsx)("div",{className:m}),(0,n.jsx)("button",{className:u(e.isActive("bulletList")),onClick:()=>e.chain().focus().toggleBulletList().run(),title:t("editor.bulletList"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"})})}),(0,n.jsx)("button",{className:u(e.isActive("orderedList")),onClick:()=>e.chain().focus().toggleOrderedList().run(),title:t("editor.orderedList"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"})})}),(0,n.jsx)("button",{className:u(e.isActive("taskList")),onClick:()=>e.chain().focus().toggleTaskList().run(),title:t("editor.taskList"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM17.99 9l-1.41-1.42-6.59 6.59-2.58-2.57-1.42 1.41 4 3.99z"})})}),(0,n.jsx)("div",{className:m}),(0,n.jsx)("button",{className:u(e.isActive("blockquote")),onClick:()=>e.chain().focus().toggleBlockquote().run(),title:t("editor.blockquote"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})}),(0,n.jsx)("button",{className:u(e.isActive("codeBlock")),onClick:()=>e.chain().focus().toggleCodeBlock().run(),title:t("editor.codeBlock"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H4V5h16v14zm-7.5-4.5L15 12l-2.5-2.5L11 11l1.5 1.5L11 14l1.5 1.5zM9.5 14.5L7 12l2.5-2.5L11 11 9.5 12.5 11 14l-1.5.5z"})})}),(0,n.jsx)("button",{className:u(!1),onClick:()=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:t("editor.table"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-9 15H4v-4h7v4zm0-6H4V7h7v4zm9 6h-7v-4h7v4zm0-6h-7V7h7v4z"})})}),(0,n.jsx)("button",{className:u(!1),onClick:()=>e.chain().focus().setHorizontalRule().run(),title:t("editor.horizontalRule"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M4 11h16v2H4z"})})}),x&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:m}),(0,n.jsx)("button",{className:u(!1),onClick:()=>e.chain().focus().addRowBefore().run(),title:t("editor.insertRowAbove"),children:(0,n.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zM11 17H4v-2h7v2zm0-4H4v-2h7v2zm9 4h-7v-2h7v2zm0-4h-7v-2h7v2z"}),(0,n.jsx)("path",{d:"M14 1h-4v2H8v2h2v2h4V5h2V3h-2z",opacity:".6"})]})}),(0,n.jsx)("button",{className:u(!1),onClick:()=>e.chain().focus().addRowAfter().run(),title:t("editor.insertRowBelow"),children:(0,n.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v10h20V6c0-1.1-.9-2-2-2zM11 12H4v-2h7v2zm0-4H4V6h7v2zm9 4h-7v-2h7v2zm0-4h-7V6h7v2z"}),(0,n.jsx)("path",{d:"M14 19h-4v2H8v2h2v-2h4v2h2v-2h-2z",opacity:".6"})]})}),(0,n.jsx)("button",{className:u(!1),onClick:()=>e.chain().focus().addColumnBefore().run(),title:t("editor.insertColumnLeft"),children:(0,n.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 11H10v-2h7v2zm0-4H10V9h7v2z"}),(0,n.jsx)("path",{d:"M1 14v-4h2V8h2v2h-2v4h2v2H3v-2z",opacity:".6"})]})}),(0,n.jsx)("button",{className:u(!1),onClick:()=>e.chain().focus().addColumnAfter().run(),title:t("editor.insertColumnRight"),children:(0,n.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("path",{d:"M4 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h10V4H4zm7 11H4v-2h7v2zm0-4H4V9h7v2z"}),(0,n.jsx)("path",{d:"M18 4v20h2c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-2z"}),(0,n.jsx)("path",{d:"M21 14v-4h2V8h2v2h-2v4h2v2h-2v-2z",opacity:".6"})]})}),(0,n.jsx)("div",{className:m}),(0,n.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-11 hover:bg-orange-500/10",onClick:()=>e.chain().focus().deleteRow().run(),title:t("editor.deleteRow"),children:(0,n.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zm-8 8H4v-2h8v2z"}),(0,n.jsx)("path",{d:"M15 13l-1.41 1.41L15.17 16l-1.58 1.59L15 19l1.59-1.59L18.17 19l1.42-1.41L18 16l1.59-1.59L18.17 13 16.59 14.41z",fill:"currentColor"})]})}),(0,n.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-11 hover:bg-orange-500/10",onClick:()=>e.chain().focus().deleteColumn().run(),title:t("editor.deleteColumn"),children:(0,n.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 7H10V9h7v2z"}),(0,n.jsx)("path",{d:"M13 16l-1.41 1.41L13.17 19l-1.58 1.59L13 22l1.59-1.59L16.17 22l1.42-1.41L16 19l1.59-1.59L16.17 16l-1.58 1.41z",fill:"currentColor"})]})}),(0,n.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-11 hover:bg-red-500/10",onClick:()=>e.chain().focus().deleteTable().run(),title:t("editor.deleteTable"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]}),e.isActive("codeBlock")&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:m}),(0,n.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-11 hover:bg-red-500/10",onClick:()=>e.chain().focus().toggleCodeBlock().run(),title:t("editor.deleteCodeBlock"),children:(0,n.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})]})}},76288:(e,t,r)=>{r.d(t,{EmptyState:()=>o});var n=r(95155),s=r(79114);function o({onBrowseProjects:e}){let{t}=(0,s.Bd)();return(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-5 bg-card",children:[(0,n.jsx)("svg",{className:"w-14 h-14 text-muted-foreground/40",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7a2 2 0 012-2h4l2 2h8a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V7z"})}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:t("workspace.selectProject")}),(0,n.jsxs)("button",{onClick:e,className:"flex items-center gap-2 px-4 py-2 text-sm rounded-lg bg-primary text-primary-foreground hover:opacity-90 transition-opacity",children:[(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m3-3H9m-4 7h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),t("workspace.openProject")]})]})}},76412:(e,t,r)=>{r.d(t,{TabManagerTopBar:()=>v});var n=r(95155),s=r(12115),o=r(63728),a=r(82032),l=r(34075),i=r(79114),d=r(95045),c=r(75346),u=r(49433),m=r(86957),x=r(53213),h=r(45720),f=r(76900);function p({className:e}){return(0,n.jsxs)("svg",{className:e,fill:"none",viewBox:"0 0 100 100","aria-hidden":"true",children:[(0,n.jsx)("path",{fill:"#0065A9",d:"M96.461 10.796 75.857.876a6.23 6.23 0 0 0-7.107 1.207l-67.451 61.5a4.167 4.167 0 0 0 .004 6.162l5.51 5.009a4.167 4.167 0 0 0 5.32.236l81.228-61.62c2.725-2.067 6.639-.124 6.639 3.297v-.24a6.25 6.25 0 0 0-3.539-5.63Z"}),(0,n.jsx)("path",{fill:"#007ACC",d:"m96.461 89.204-20.604 9.92a6.229 6.229 0 0 1-7.107-1.207l-67.451-61.5a4.167 4.167 0 0 1 .004-6.162l5.51-5.009a4.167 4.167 0 0 1 5.32-.236l81.228 61.62c2.725 2.067 6.639.124 6.639-3.297v.24a6.25 6.25 0 0 0-3.539 5.63Z"}),(0,n.jsx)("path",{fill:"#1F9CF0",d:"M75.858 99.126a6.232 6.232 0 0 1-7.108-1.21c2.306 2.307 6.25.674 6.25-2.588V4.672c0-3.262-3.944-4.895-6.25-2.589a6.232 6.232 0 0 1 7.108-1.21l20.6 9.908A6.25 6.25 0 0 1 100 16.413v67.174a6.25 6.25 0 0 1-3.541 5.633l-20.601 9.906Z"})]})}function g({className:e}){return(0,n.jsx)("svg",{className:e,viewBox:"0 0 466.73 532.09",fill:"currentColor","aria-hidden":"true",children:(0,n.jsx)("path",{d:"M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"})})}function b({cwd:e,currentBranch:t,onSwitched:r}){let{t:o}=(0,i.Bd)(),[a,d]=(0,s.useState)(!1),[c,u]=(0,s.useState)([]),[h,p]=(0,s.useState)(!1),[g,v]=(0,s.useState)(!1),[j,w]=(0,s.useState)(""),k=(0,s.useRef)(null),y=(0,s.useRef)(null),N=(0,s.useCallback)(async()=>{p(!0);let t=await m.t4.runPromiseExit((0,x.r4)(e));if("Success"===t._tag){let e=t.value,r=e.local??[];u([...r,...(e.remote??[]).filter(e=>!r.includes(e.replace(/^origin\//,"")))])}else(0,l.oR)(o("toast.loadBranchFailed"),"error");p(!1)},[e,o]),C=(0,s.useCallback)(()=>{d(!0),w(""),N()},[N]),S=(0,s.useCallback)(()=>{d(!1)},[]);(0,s.useEffect)(()=>{if(!a)return;let e=e=>{k.current&&!k.current.contains(e.target)&&S()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a,S]),(0,s.useEffect)(()=>{a&&setTimeout(()=>y.current?.focus(),50)},[a]);let L=async t=>{v(!0);let n=await m.t4.runPromiseExit((0,f.Kl)({action:"checkout",cwd:e,path:e,branch:t}));if("Success"===n._tag){let e=t.replace(/^origin\//,"");(0,l.oR)(o("toast.switchedToBranch",{branch:e}),"success"),S(),r()}else{let e="Fail"===n.cause._tag?n.cause.error:null,t=e?.cause,r=t instanceof Error?t.message:o("toast.switchBranchFailed");(0,l.oR)(r,"error")}v(!1)},M=c.filter(e=>e!==t&&e.toLowerCase().includes(j.toLowerCase()));return(0,n.jsxs)("div",{className:"relative",ref:k,children:[(0,n.jsx)("button",{onClick:a?S:C,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:o("git.switchBranch"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})}),a&&(0,n.jsxs)("div",{className:"absolute top-full left-0 mt-1 w-64 bg-popover border border-border rounded-lg shadow-lv2 z-50 overflow-hidden",children:[(0,n.jsx)("div",{className:"p-2 border-b border-border",children:(0,n.jsx)("input",{ref:y,type:"text",value:j,onChange:e=>w(e.target.value),placeholder:o("git.searchBranch"),className:"w-full px-2.5 py-1.5 text-sm bg-muted rounded border-none outline-none",onKeyDown:e=>{"Escape"===e.key&&S()}})}),(0,n.jsx)("div",{className:"max-h-60 overflow-y-auto p-1",children:h?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:o("common.loading")}):0===M.length?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:j?o("git.noMatchingBranches"):o("git.noBranches")}):M.map(e=>(0,n.jsx)("button",{onClick:()=>L(e),disabled:g,className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-hover transition-colors truncate disabled:opacity-50",children:(0,n.jsx)("span",{className:e.startsWith("origin/")?"text-muted-foreground":"text-foreground",children:e})},e))})]})]})}function v({initialCwd:e,activeTab:t,isGitRepo:r,currentBranch:s,onOpenWorktree:x,onOpenAliasManager:j,onBranchSwitched:w}){let{t:k}=(0,i.Bd)(),y=t?.sessionId?(0,h.X)(t.engine,t.sessionId):null;return(0,n.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 relative",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6 cursor-pointer",title:k("tabManagerTopBar.copyPageUrl"),onClick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>{(0,l.oR)(k("toast.copiedPageUrl"),"success")})}}),e?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help","data-tooltip":`CWD: ${e}`,children:e}),(0,n.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(e),(0,l.oR)(k("toast.copiedDirPath"))},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:k("tabManagerTopBar.copyDirPath"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}):(0,n.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"})]}),r&&e&&(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsxs)("button",{onClick:x,className:"flex items-center gap-1.5 px-2 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:"Git Worktrees",children:[(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 17h8m0 0l-4-4m4 4l-4 4M3 7v6a4 4 0 004 4h5"})}),(0,n.jsx)("span",{className:"text-sm",children:s||"main"})]}),(0,n.jsx)(b,{cwd:e,currentBranch:s,onSwitched:()=>w?.()})]})]}),(0,n.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2",children:(0,n.jsx)(o.gT,{})}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(a.ReviewDropdown,{cwd:e}),(0,n.jsx)("button",{onClick:()=>window.location.reload(),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:k("tabManagerTopBar.refreshProject"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,n.jsx)("button",{onClick:()=>{t?.cwd&&m.t4.runFork((0,f.em)(t.cwd).pipe(u.orElse(()=>u.void)))},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:k("tabManagerTopBar.openInVSCode"),children:(0,n.jsx)(p,{className:"w-4 h-4"})}),(0,n.jsx)("button",{onClick:()=>{t?.cwd&&m.t4.runFork((0,f.Q1)(t.cwd).pipe(u.orElse(()=>u.void)))},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:k("tabManagerTopBar.openInCursor"),children:(0,n.jsx)(g,{className:"w-4 h-4"})}),y&&(0,n.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(y).then(()=>{(0,l.oR)(k("toast.copiedCommand",{command:y}),"success")})},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:k("chat.copyCommandTooltip",{command:y}),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,n.jsx)("button",{onClick:j,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:k("tabManagerTopBar.aliasesGlobal"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 12h-6m-4 0a8 8 0 1116 0 8 8 0 01-16 0zm4 0h.01"})})}),(0,n.jsx)("button",{onClick:()=>(0,d.F)(c.n.OpenTokenStats,{}),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:k("tabManagerTopBar.tokenStats"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),(0,n.jsx)("button",{onClick:()=>window.open("https://surething.io?from=cockpit","_blank"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:k("tabManagerTopBar.openSurething"),children:(0,n.jsx)("img",{src:"https://surething.io/logo.png?from=cockpit",alt:"Surething",className:"w-5 h-5 rounded-sm"})})]})]})})}},76900:(e,t,r)=>{r.d(t,{Cq:()=>x,D0:()=>p,DZ:()=>i,H7:()=>h,It:()=>b,Kl:()=>k,M5:()=>l,Or:()=>c,Q1:()=>j,QW:()=>f,Wr:()=>d,Yn:()=>g,b2:()=>w,em:()=>v,zF:()=>m});var n=r(49433),s=r(82680);let o=(e,t)=>n.tryPromise({try:async()=>{let r=await fetch(e,t);if(!r.ok)throw Error(`HTTP ${r.status}`);return await r.json()},catch:r=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:r})}),a=(e,t)=>o(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=()=>o("/api/settings"),i=e=>o("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),d=()=>o("/api/version"),c=()=>o("/api/extension/version"),u=e=>e?`/api/note?cwd=${encodeURIComponent(e)}`:"/api/note",m=e=>o(u(e)),x=(e,t,r)=>n.tryPromise({try:async()=>{let n=u(e),s=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,baseMtime:r})});if(409===s.status){let e=await s.json();return{conflict:!0,content:e.content??"",mtime:e.mtime}}if(!s.ok)throw Error(`HTTP ${s.status}`);return{conflict:!1,mtime:(await s.json()).mtime}},catch:t=>new s.uV({message:`POST ${u(e)} failed`,cause:t})}),h=()=>o("/api/sessions/projects"),f=e=>o(`/api/sessions/projects/${encodeURIComponent(e)}`),p=e=>o(`/api/project-settings?cwd=${encodeURIComponent(e)}`),g=e=>a("/api/project-settings",e),b=()=>o("/api/pick-folder"),v=e=>a("/api/open-vscode",{cwd:e}),j=e=>a("/api/open-cursor",{cwd:e}),w=e=>o(`/api/git/worktree?cwd=${encodeURIComponent(e)}`),k=e=>a("/api/git/worktree",e)},83678:(e,t,r)=>{r.d(t,{SessionBrowser:()=>x});var n=r(95155),s=r(12115),o=r(79114),a=r(66109),l=r(95045),i=r(75346),d=r(86957),c=r(76900),u=r(7578),m=r(92689);function x({isOpen:e,onClose:t,onSelectSession:r,onAddProject:h,sessionNumbers:f={},projectNumbers:p={}}){let{t:g}=(0,o.Bd)(),[b,v]=(0,s.useState)(!1),[j,w]=(0,s.useState)([]),[k,y]=(0,s.useState)({}),[N,C]=(0,s.useState)(!1),[S,L]=(0,s.useState)(null),[M,E]=(0,s.useState)(""),P=(0,s.useRef)(null),T=(0,s.useCallback)(async()=>{C(!0),L(null),y({});let e=await d.t4.runPromiseExit((0,c.H7)());"Success"===e._tag?w(e.value):L("Failed to load projects"),C(!1)},[]),$=(0,s.useCallback)(async e=>{y(t=>({...t,[e]:{...t[e],isExpanded:!0,isLoading:!0,sessions:[],error:null}}));let t=await d.t4.runPromiseExit((0,c.QW)(e));"Success"===t._tag?y(r=>({...r,[e]:{...r[e],isLoading:!1,sessions:t.value}})):y(t=>({...t,[e]:{...t[e],isLoading:!1,error:"Failed to load sessions"}}))},[]),R=(0,s.useCallback)(e=>{let t=k[e];t?.isExpanded?y(t=>({...t,[e]:{...t[e],isExpanded:!1}})):t?.sessions?.length?y(t=>({...t,[e]:{...t[e],isExpanded:!0}})):$(e)},[k,$]);(0,s.useEffect)(()=>{e&&(T(),setTimeout(()=>{P.current?.focus(),P.current?.select()},100))},[e,T]);let B=(0,s.useCallback)(async()=>{if(b)return;v(!0);let e=await d.t4.runPromiseExit((0,c.It)());"Success"===e._tag&&e.value.folder&&h&&(h(e.value.folder),t()),v(!1)},[b,h,t]);return((0,s.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,t]),e)?(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:t}),(0,n.jsxs)("div",{className:a.aO,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:g("sessions.projectList")}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("input",{ref:P,type:"text",placeholder:g("workspace.searchProjectPath"),value:M,onChange:e=>E(e.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),M&&(0,n.jsx)("button",{onClick:()=>{E(""),P.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:g("fileBrowser.clear"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h&&(0,n.jsxs)("button",{onClick:B,disabled:b,className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors disabled:opacity-50",children:[(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m3-3H9m-4 7h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),b?g("sessions.selectingFolder"):g("sessions.openFolder")]}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[N&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,n.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,n.jsx)("span",{children:g("workspace.loadingProjects")})]})}),S&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("div",{className:"text-xs text-red-11",children:S})}),!N&&!S&&0===j.length&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:g("workspace.projectNotFound")})}),!N&&!S&&j.filter(e=>e.fullPath.toLowerCase().includes(M.toLowerCase())).map(e=>{let t=k[e.encodedPath]||{isExpanded:!1,isLoading:!1,sessions:[],error:null},s=p[e.fullPath];return(0,n.jsxs)("div",{className:"mb-3",children:[(0,n.jsxs)("button",{onClick:()=>R(e.encodedPath),className:"w-full flex items-center gap-2 p-2 rounded hover:bg-hover transition-colors text-left",children:[(0,n.jsx)("svg",{className:`w-3 h-3 text-muted-foreground transition-transform ${t.isExpanded?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,n.jsx)("svg",{className:"w-4 h-4 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),s&&(0,n.jsx)(u.l,{projectNumber:s}),(0,n.jsx)("span",{className:"flex-1 text-xs font-medium text-foreground truncate","data-tooltip":e.fullPath,children:e.fullPath}),(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",e.sessionCount,")"]})]}),t.isExpanded&&(0,n.jsxs)("div",{className:"ml-6 mt-2",children:[t.isLoading&&(0,n.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,n.jsxs)("svg",{className:"animate-spin h-3 w-3",fill:"none",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,n.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,n.jsx)("span",{children:g("sessions.loadingSessions")})]}),t.error&&(0,n.jsx)("div",{className:"p-3 text-xs text-red-11",children:t.error}),!t.isLoading&&!t.error&&(0,n.jsx)("div",{className:a.jL,children:t.sessions.map(t=>{let s=t.path.split("/").pop()||"",o=t.sessionId||s.replace(".jsonl",""),a=f[`${e.fullPath}
|
|
29
|
+
${o}`],[d,c]=a?.split(".")??[];return(0,n.jsxs)("div",{onClick:()=>{var n;let s,o;return n=e.fullPath,s=t.path.split("/").pop()||"",o=t.sessionId||s.replace(".jsonl",""),void(r?r(n,o):(0,l.F)(i.n.OpenProject,{cwd:n,sessionId:o}))},className:"p-3 rounded border border-border hover:border-brand hover:shadow-lv2 cursor-pointer transition-all",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,n.jsx)(m.S,{engine:t.engine}),(0,n.jsx)("h4",{className:"text-xs font-medium text-foreground truncate","data-tooltip":t.title,children:t.title}),a&&(0,n.jsx)(u.l,{projectNumber:d,sessionNumber:c,className:"ml-auto"})]}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(t.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,n.jsxs)("div",{className:"space-y-0.5 text-xs",children:[t.firstMessages.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground truncate","data-tooltip":e,children:[(0,n.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),e]},`first-${t}`)),t.lastMessages.length>0&&(0,n.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),t.lastMessages.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground truncate","data-tooltip":e,children:[(0,n.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),e]},`last-${t}`))]})]},t.path)})})]})]},e.encodedPath)})]})]})]}):null}},86481:(e,t,r)=>{r.d(t,{Workspace:()=>ed});var n=r(95155),s=r(12115),o=r(79114),a=r(11428),l=r(76288),i=r(83678),d=r(21484),c=r(34075),u=r(66109),m=r(61878),x=r(33210),h=r(51914),f=r(94852),p=r(67635),g=r(60241),b=r(42804),v=r(22164),j=r(20986),w=r(68459),k=r(86957),y=r(34582),N=r(85269),C=r(63563),S=r(63040);function L({isOpen:e,htmlAppPreviews:t,activeHtmlAppPreviewPath:r,onShowHtmlAppPreview:a,onMinimizeHtmlAppPreview:l,onCloseHtmlAppPreview:i,onClose:d,onOpenApp:w}){let{t:E,i18n:P}=(0,o.Bd)(),[T,$]=(0,s.useState)([]),[R,B]=(0,s.useState)(!1),[F,I]=(0,s.useState)(""),[D,A]=(0,s.useState)(!1),[z,H]=(0,s.useState)(""),[W,_]=(0,s.useState)(!1),[O,q]=(0,s.useState)({}),V=(0,s.useRef)(null),U=(0,s.useCallback)(async()=>{B(!0);let e=await k.t4.runPromiseExit((0,S.mi)());"Success"===e._tag?$(e.value):console.error("Failed to load html apps",e.cause),B(!1)},[]);(0,s.useEffect)(()=>{e&&(U(),setTimeout(()=>{V.current?.focus(),V.current?.select()},100))},[e,U]);let K=(0,s.useCallback)(()=>{A(!1),d()},[d]);(0,s.useEffect)(()=>{if(!e&&!r)return;let t=e=>{if("Escape"===e.key){if(r)return void i(r);if(D){A(!1),H("");return}K()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,r,K,i,D]);let G=(0,s.useMemo)(()=>{let e=F.trim().toLowerCase();return e?T.filter(t=>t.name.toLowerCase().includes(e)||t.title.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)):T},[T,F]),J=(0,s.useMemo)(()=>T.filter(e=>!e.builtin).length,[T]),Q=F.trim().length>0,Z=P.resolvedLanguage?.startsWith("zh")?"https://opencockpit.dev/zh/docs/agent/html-apps/":"https://opencockpit.dev/en/docs/agent/html-apps/",X=(0,s.useCallback)(async()=>{let e=z.trim();if(!e)return;_(!0);let t=await k.t4.runPromiseExit((0,S.ot)(e));if("Success"===t._tag)t.value.alreadyExists?(0,c.oR)(E("htmlApps.alreadyAdded"),"info"):((0,c.oR)(E("htmlApps.added"),"success"),(0,C.N)()),H(""),A(!1),await U();else{let e="Fail"===t.cause._tag?t.cause.error:null,r=e?.cause,n=r instanceof Error?r.message:E("htmlApps.addFailed");(0,c.oR)(n,"error")}_(!1)},[z,U,E]),Y=(0,s.useCallback)(async e=>{"Success"===(await k.t4.runPromiseExit((0,S.m3)(e)))._tag?($(t=>t.filter(t=>t.id!==e)),(0,C.N)()):(0,c.oR)(E("common.deleteFailed"),"error")},[E]),ee=(0,s.useCallback)(e=>{w?w(e):window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:e}})),K()},[K,w]),et=(0,s.useCallback)(e=>{w?w(e):window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:e}})),l()},[l,w]),er=(0,s.useCallback)(e=>{let t=(0,y.Xe)(e);window.open((0,y.PB)(t,window.location.origin),"_blank")},[]),en=(0,s.useCallback)(e=>{q(t=>({...t,[e]:(t[e]||0)+1}))},[]),es=(0,s.useCallback)(async e=>{try{await navigator.clipboard.writeText(e),(0,c.oR)(E("common.copiedPath"),"success")}catch{(0,c.oR)(E("common.copyFailed"),"error")}},[E]);return(0,n.jsxs)(n.Fragment,{children:[e&&(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:K}),(0,n.jsxs)("div",{className:u.aO,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:E("htmlApps.title")}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(m.A,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-foreground-subtle pointer-events-none"}),(0,n.jsx)("input",{ref:V,type:"text",value:F,onChange:e=>I(e.target.value),placeholder:E("htmlApps.searchPlaceholder"),className:"pl-7 pr-6 py-1 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),F&&(0,n.jsx)("button",{onClick:()=>{I(""),V.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:E("fileBrowser.clear"),children:(0,n.jsx)(x.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsxs)("button",{onClick:()=>A(!0),className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:E("htmlApps.addHtmlApp"),children:[(0,n.jsx)(h.A,{className:"w-4 h-4"})," ",E("htmlApps.add")]}),(0,n.jsx)("button",{onClick:K,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",title:E("common.close"),children:(0,n.jsx)(x.A,{className:"w-5 h-5"})})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:R?(0,n.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:E("common.loading")}):(0,n.jsxs)(n.Fragment,{children:[G.length>0&&(0,n.jsx)("div",{className:u.jL,children:G.map(e=>(0,n.jsx)(M,{app:e,onOpenConsole:()=>ee(e.path),onOpenExternal:()=>er(e.path),onPreview:()=>{a({path:e.path,title:e.title,icon:e.icon}),K()},onDelete:()=>Y(e.id),onCopyPath:()=>es(e.path)},e.id))}),0===G.length&&Q&&(0,n.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:E("htmlApps.emptyNoMatch")}),!Q&&0===J&&(0,n.jsxs)("div",{className:`text-center text-muted-foreground py-8 text-sm space-y-2${G.length>0?" mt-4 border-t border-border/60":""}`,children:[(0,n.jsx)("p",{children:E("htmlApps.emptyNoApps")}),(0,n.jsxs)("p",{children:[E("htmlApps.emptyCreatePrefix")," ",(0,n.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-foreground font-mono text-xs",children:"/html"})," ",E("htmlApps.emptyCreateSuffix")]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("button",{type:"button",onClick:()=>A(!0),className:"text-brand hover:underline",children:E("htmlApps.addExisting")})," \xb7 ",(0,n.jsx)("a",{href:Z,target:"_blank",rel:"noreferrer",className:"text-brand hover:underline",children:E("htmlApps.viewDocs")})]})]})]})})]})]}),e&&D&&(0,n.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:()=>{W||(A(!1),H(""))}}),(0,n.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-lg mx-4 p-5",children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-foreground mb-3",children:E("htmlApps.addHtmlApp")}),(0,n.jsx)("label",{className:"block text-xs text-muted-foreground mb-1",children:E("htmlApps.pathLabel")}),(0,n.jsx)("input",{type:"text",value:z,onChange:e=>H(e.target.value),onKeyDown:e=>{"Enter"!==e.key||W||X()},placeholder:"/Users/you/.../report.html",autoFocus:!0,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-md bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,n.jsx)("button",{onClick:()=>{A(!1),H("")},disabled:W,className:"px-3 py-1.5 text-sm rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors disabled:opacity-50",children:E("common.cancel")}),(0,n.jsx)("button",{onClick:X,disabled:W||!z.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-brand text-white hover:bg-teal-10 transition-colors disabled:opacity-50",children:W?E("htmlApps.adding"):E("htmlApps.add")})]})]})]}),t.map(e=>{let t=r===e.path;return(0,n.jsx)("div",{className:t?"fixed inset-0 z-[60] flex items-center justify-center bg-scrim p-0 md:p-4":"hidden",onClick:l,children:(0,n.jsxs)("div",{className:"bg-card shadow-lv3 border border-brand/30 w-full h-full md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.icon?(0,n.jsx)("span",{className:"text-base leading-none flex-shrink-0",children:e.icon}):(0,n.jsx)(f.A,{className:"w-4 h-4 flex-shrink-0"}),(0,n.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[35%]","data-tooltip":e.title,children:e.title}),(0,n.jsx)("span",{className:"text-sm text-muted-foreground flex-shrink-0","aria-hidden":"true",children:"-"}),(0,n.jsx)("span",{className:"font-mono text-sm text-muted-foreground truncate min-w-0","data-tooltip":e.path,children:e.path}),(0,n.jsx)("button",{onClick:()=>es(e.path),className:"text-muted-foreground hover:text-foreground p-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:E("common.copyPath"),"aria-label":E("common.copyPath"),children:(0,n.jsx)(p.A,{className:"w-4 h-4"})})]}),(0,n.jsx)("button",{onClick:l,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:E("common.minimize"),children:(0,n.jsx)(g.A,{className:"w-4 h-4"})}),(0,n.jsx)("button",{onClick:()=>et(e.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:E("common.openInConsole"),children:(0,n.jsx)(b.A,{className:"w-4 h-4"})}),(0,n.jsx)("button",{onClick:()=>er(e.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:E("browser.openInNewWindow"),children:(0,n.jsx)(v.A,{className:"w-4 h-4"})}),(0,n.jsx)("button",{onClick:()=>en(e.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:E("common.refresh"),children:(0,n.jsx)(j.A,{className:"w-4 h-4"})}),(0,n.jsx)("button",{onClick:()=>i(e.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,n.jsx)(x.A,{className:"w-4 h-4"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,n.jsx)(N.O,{filePath:e.path,reloadKey:O[e.path]||0})})]})},e.path)})]})}function M({app:e,onOpenConsole:t,onOpenExternal:r,onPreview:a,onDelete:l,onCopyPath:i}){let{t:d}=(0,o.Bd)(),[c,u]=(0,s.useState)(!1);return(0,n.jsxs)("div",{className:`group flex flex-col h-full border border-border rounded-lg p-3 hover:border-brand hover:shadow-lv2 transition-all cursor-pointer ${e.valid?"":"opacity-60"}`,onClick:()=>e.valid&&a(),children:[(0,n.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,n.jsx)("div",{className:"w-9 h-9 flex-shrink-0 flex items-center justify-center rounded-md bg-brand/10 text-brand text-lg",children:e.icon?(0,n.jsx)("span",{children:e.icon}):(0,n.jsx)(v.A,{className:"w-5 h-5"})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium text-foreground truncate","data-tooltip":e.title,children:e.title}),(0,n.jsxs)("div",{className:"font-mono text-[11px] text-muted-foreground truncate","data-tooltip":`/${e.name}`,children:["/",e.name]})]}),!e.valid&&(0,n.jsx)("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-red-9/15 text-red-11",children:d("htmlApps.invalid")}),e.builtin&&(0,n.jsx)("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:d("htmlApps.builtin")}),(0,n.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("button",{onClick:t,disabled:!e.valid,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:d("common.openInConsole"),children:(0,n.jsx)(b.A,{className:"w-4 h-4"})}),(0,n.jsx)("button",{onClick:r,disabled:!e.valid,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:d("browser.openInNewWindow"),children:(0,n.jsx)(v.A,{className:"w-4 h-4"})}),e.builtin?null:c?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:()=>{u(!1),l()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:d("common.confirm")}),(0,n.jsx)("button",{onClick:()=>u(!1),className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:d("common.cancel")})]}):(0,n.jsx)("button",{onClick:()=>u(!0),className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:d("common.delete"),children:(0,n.jsx)(w.A,{className:"w-4 h-4"})})]})]}),(0,n.jsxs)("div",{className:"font-mono text-xs text-muted-foreground mt-2 break-all",children:[e.path,(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),i()},className:"inline-flex align-middle ml-1 p-0.5 hover:text-foreground hover:bg-hover rounded transition-colors",title:d("common.copyPath"),children:(0,n.jsx)(p.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground mt-2 pt-2 border-t border-border/60 break-words whitespace-pre-wrap",children:e.description||(0,n.jsx)("span",{className:"italic opacity-60",children:d("htmlApps.noDescription")})})]})}var E=r(3238),P=r(62111),T=r(83448);let $={"claude-fable-5-1":{input:10,output:50,cacheRead:.25,cacheWrite:12.5},"claude-mythos-5-1":{input:10,output:50,cacheRead:.25,cacheWrite:12.5},"claude-fable-5":{input:10,output:50,cacheRead:1,cacheWrite:12.5},"claude-mythos-5":{input:10,output:50,cacheRead:1,cacheWrite:12.5},"claude-opus-5":{input:5,output:25,cacheRead:.5,cacheWrite:6.25},"claude-opus-4-8":{input:5,output:25,cacheRead:.5,cacheWrite:6.25},"claude-opus-4-7":{input:5,output:25,cacheRead:.5,cacheWrite:6.25},"claude-opus-4-6":{input:5,output:25,cacheRead:.5,cacheWrite:6.25},"claude-opus-4-5":{input:5,output:25,cacheRead:.5,cacheWrite:6.25},"claude-sonnet-5":{input:2,output:10,cacheRead:.2,cacheWrite:2.5},"claude-sonnet-4-6":{input:3,output:15,cacheRead:.3,cacheWrite:3.75},"claude-sonnet-4-5":{input:3,output:15,cacheRead:.3,cacheWrite:3.75},"claude-haiku-4-5":{input:1,output:5,cacheRead:.1,cacheWrite:1.25}},R={input:3,output:15,cacheRead:.3,cacheWrite:3.75};function B(e){return e.replace(/^claude-/,"").replace(/-\d{8}$/,"").replace(/(\d)-(?=\d)/g,"$1.").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}let F={light:["#2a78d6","#eb6834","#1baf7a","#eda100","#e87ba4","#008300","#4a3aa7","#e34948"],dark:["#3987e5","#d95926","#199e70","#c98500","#d55181","#008300","#9085e9","#e66767"]},I={light:{messages:"#2a78d6",toolCalls:"#1baf7a",messagesRgb:"42, 120, 214"},dark:{messages:"#3987e5",toolCalls:"#199e70",messagesRgb:"57, 135, 229"}};function D(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function A(e){return e>=1e3?`$${e.toFixed(0)}`:e>=100?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function z({data:e,height:t=200,formatValue:r=D}){let o=(0,s.useRef)(null),a=(0,s.useRef)(null),[l,i]=(0,s.useState)(null),d=(0,s.useRef)([]),c=(0,s.useCallback)(()=>{let n=o.current,s=a.current;if(!n||!s)return;let l=window.devicePixelRatio||1,i=s.getBoundingClientRect().width;n.width=i*l,n.height=t*l,n.style.width=`${i}px`,n.style.height=`${t}px`;let c=n.getContext("2d");c.scale(l,l),c.clearRect(0,0,i,t);let{labels:u,datasets:m}=e;if(0===u.length)return;let x=i-50-12,h=t-8-28,f=function(e){if(e<=0)return 1;let t=Math.pow(10,Math.floor(Math.log10(e))),r=e/t;return r<=1?t:r<=2?2*t:r<=5?5*t:10*t}(Math.max(1,...u.map((e,t)=>m.reduce((e,r)=>e+r.data[t],0))));c.fillStyle=getComputedStyle(n).getPropertyValue("color")||"#888",c.font="10px ui-monospace, monospace",c.textAlign="right",c.textBaseline="middle";for(let e=0;e<=4;e++){var p;let t=f/4*e,s=8+h-t/f*h;c.fillText(r(t),44,s),c.strokeStyle=(p="--line-2",getComputedStyle(n).getPropertyValue(p).trim()||"#333"),c.lineWidth=.5,c.beginPath(),c.moveTo(50,s),c.lineTo(50+x,s),c.stroke()}let g=x/u.length,b=Math.max(4,Math.min(.6*g,32)),v=[];u.forEach((e,t)=>{let r=50+t*g+(g-b)/2,s=0;m.forEach(n=>{var o,a,l,i,d,u;let m=n.data[t];if(m<=0)return;let x=Math.max(1,m/f*h),p=8+h-s-x;c.fillStyle=n.color,o=c,a=r,l=p,i=b,u=2,(d=x)<1||(u=Math.min(u,d/2,i/2),o.beginPath(),o.moveTo(a+u,l),o.lineTo(a+i-u,l),o.quadraticCurveTo(a+i,l,a+i,l+u),o.lineTo(a+i,l+d-u),o.quadraticCurveTo(a+i,l+d,a+i-u,l+d),o.lineTo(a+u,l+d),o.quadraticCurveTo(a,l+d,a,l+d-u),o.lineTo(a,l+u),o.quadraticCurveTo(a,l,a+u,l),o.fill()),v.push({x:r,y:p,w:b,h:x,label:e,value:m,dataset:n.label,color:n.color}),s+=x}),c.fillStyle=getComputedStyle(n).getPropertyValue("color")||"#888",c.font="9px ui-monospace, monospace",c.textAlign="center",c.textBaseline="top",t%(u.length>20?Math.ceil(u.length/15):1)==0&&c.fillText(e,r+b/2,8+h+6)}),d.current=v},[e,t,r]);(0,s.useEffect)(()=>{c();let e=new ResizeObserver(()=>c());return a.current&&e.observe(a.current),()=>e.disconnect()},[c]);let u=(0,s.useCallback)(e=>{let t=o.current?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left,s=e.clientY-t.top,a=d.current.find(e=>n>=e.x&&n<=e.x+e.w&&s>=e.y&&s<=e.y+e.h);a?i({x:e.clientX-t.left,y:a.y-4,content:`${a.dataset}: ${r(a.value)}`}):i(null)},[r]);return(0,n.jsxs)("div",{ref:a,className:"relative w-full text-muted-foreground",children:[(0,n.jsx)("canvas",{ref:o,className:"w-full",style:{height:t},onMouseMove:u,onMouseLeave:()=>i(null)}),l&&(0,n.jsx)("div",{className:"absolute pointer-events-none bg-popover text-popover-foreground text-[10px] px-2 py-1 rounded shadow-lv2 border border-border whitespace-nowrap z-10",style:{left:l.x,top:l.y,transform:"translate(-50%, -100%)"},children:l.content})]})}function H({hourCounts:e}){let{t}=(0,o.Bd)(),{resolvedTheme:r}=(0,E.DP)(),s=I[r],a=Math.max(1,...Object.values(e)),l=Array.from({length:24},(e,t)=>t);return(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:t("tokenStats.activeHours")}),(0,n.jsx)("div",{className:"flex gap-[2px] items-end h-16",children:l.map(r=>{let o=e[String(r)]||0,l=o/a;return(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center gap-0.5",title:t("tokenStats.hourSessions",{h:r,count:o}),children:[(0,n.jsx)("div",{className:"w-full rounded-sm transition-all",style:{height:`${Math.max(2,48*l)}px`,backgroundColor:l>0?`rgba(${s.messagesRgb}, ${.2+.8*l})`:"var(--muted)"}}),r%3==0&&(0,n.jsx)("span",{className:"text-[8px] text-muted-foreground",children:r})]},r)})})]})}function W({isOpen:e,onClose:t}){var r;let a,l,{t:i}=(0,o.Bd)(),[d,c]=(0,s.useState)(null),[u,m]=(0,s.useState)(!0),[x,h]=(0,s.useState)("day"),[f,p]=(0,s.useState)("tokens"),[g,b]=(0,s.useState)(null),{resolvedTheme:v}=(0,E.DP)();(0,s.useEffect)(()=>{e&&(queueMicrotask(()=>m(!0)),k.t4.runPromiseExit((0,T.Cr)()).then(e=>{if("Success"===e._tag){let t=e.value;t.error||queueMicrotask(()=>c(t))}queueMicrotask(()=>m(!1))}))},[e]);let j=(0,s.useMemo)(()=>{var e;let t,r,n=Object.keys(d?.modelUsage||{}).filter(e=>!e.startsWith("<")),s=new Map;for(let e of d?.dailyModelTokens||[])for(let[t,r]of Object.entries(e.tokensByModel)){let n=s.get(t);r>0&&(!n||e.date<n)&&s.set(t,e.date)}return e=[...n].sort((e,t)=>(s.get(e)??"").localeCompare(s.get(t)??"")||e.localeCompare(t)),t=F[v],r={},e.forEach((e,n)=>{r[e]=t[n%t.length]}),r},[d,v]),w=(0,s.useMemo)(()=>d?.modelUsage?Object.entries(d.modelUsage).filter(([e])=>!e.startsWith("<")).map(([e,t])=>{let r;return{id:e,label:B(e),color:j[e],usage:t,cost:(r=function(e){let t=e.replace(/-\d{8}$/,""),r=$[t];if(r)return r;let n=t.toLowerCase();return n.includes("fable")||n.includes("mythos")?{input:10,output:50,cacheRead:1,cacheWrite:12.5}:n.includes("opus")?{input:5,output:25,cacheRead:.5,cacheWrite:6.25}:n.includes("haiku")?{input:1,output:5,cacheRead:.1,cacheWrite:1.25}:R}(e),t.inputTokens/1e6*r.input+t.outputTokens/1e6*r.output+t.cacheReadInputTokens/1e6*r.cacheRead+t.cacheCreationInputTokens/1e6*r.cacheWrite),totalTokens:t.inputTokens+t.outputTokens+t.cacheReadInputTokens+t.cacheCreationInputTokens}}).sort((e,t)=>t.cost-e.cost):[],[d,j]),y=(0,s.useMemo)(()=>w.reduce((e,t)=>e+t.cost,0),[w]),N=(0,s.useMemo)(()=>w.map(e=>e.id),[w]),C=(0,s.useMemo)(()=>{let e={};for(let t of w)e[t.id]=t.totalTokens>0?t.cost/t.totalTokens:0;return e},[w]),{activityChart:S,tokenChart:L,costChart:M}=(0,s.useMemo)(()=>{let e=d?.dailyActivity||[],t=d?.dailyModelTokens||[];if("day"===x){let r=e.slice(-60),n=t.slice(-60),s={labels:r.map(e=>e.date.slice(5)),datasets:[{label:i("tokenStats.messages"),data:r.map(e=>e.messageCount),color:I[v].messages},{label:i("tokenStats.toolCalls"),data:r.map(e=>e.toolCallCount),color:I[v].toolCalls}]},o=n.map(e=>e.date.slice(5));return{activityChart:s,tokenChart:{labels:o,datasets:N.map(e=>({id:e,label:B(e),data:n.map(t=>t.tokensByModel[e]||0),color:j[e]}))},costChart:{labels:o,datasets:N.map(e=>({id:e,label:B(e),data:n.map(t=>(t.tokensByModel[e]||0)*(C[e]||0)),color:j[e]}))}}}if("week"===x){let r=function(e,t){let r=new Map;for(let t of e){let e=new Date(t.date),n=new Date(e);n.setDate(e.getDate()-e.getDay());let s=n.toISOString().slice(0,10),o=s.slice(5);r.has(s)||r.set(s,{label:o,messages:0,sessions:0,tools:0,tokensByModel:{}});let a=r.get(s);a.messages+=t.messageCount,a.sessions+=t.sessionCount,a.tools+=t.toolCallCount}for(let e of t){let t=new Date(e.date),n=new Date(t);n.setDate(t.getDate()-t.getDay());let s=n.toISOString().slice(0,10);r.has(s)||r.set(s,{label:s.slice(5),messages:0,sessions:0,tools:0,tokensByModel:{}});let o=r.get(s);for(let[t,r]of Object.entries(e.tokensByModel))o.tokensByModel[t]=(o.tokensByModel[t]||0)+r}return Array.from(r.values()).sort((e,t)=>e.label.localeCompare(t.label))}(e,t),n=r.map(e=>e.label),s={labels:n,datasets:[{label:i("tokenStats.messages"),data:r.map(e=>e.messages),color:I[v].messages},{label:i("tokenStats.toolCalls"),data:r.map(e=>e.tools),color:I[v].toolCalls}]};return{activityChart:s,tokenChart:{labels:n,datasets:N.map(e=>({id:e,label:B(e),data:r.map(t=>t.tokensByModel[e]||0),color:j[e]}))},costChart:{labels:n,datasets:N.map(e=>({id:e,label:B(e),data:r.map(t=>(t.tokensByModel[e]||0)*(C[e]||0)),color:j[e]}))}}}let r=function(e,t){let r=new Map;for(let t of e){let e=t.date.slice(0,7);r.has(e)||r.set(e,{label:e,messages:0,sessions:0,tools:0,tokensByModel:{}});let n=r.get(e);n.messages+=t.messageCount,n.sessions+=t.sessionCount,n.tools+=t.toolCallCount}for(let e of t){let t=e.date.slice(0,7);r.has(t)||r.set(t,{label:t,messages:0,sessions:0,tools:0,tokensByModel:{}});let n=r.get(t);for(let[t,r]of Object.entries(e.tokensByModel))n.tokensByModel[t]=(n.tokensByModel[t]||0)+r}return Array.from(r.values()).sort((e,t)=>e.label.localeCompare(t.label))}(e,t),n=r.map(e=>e.label),s={labels:n,datasets:[{label:i("tokenStats.messages"),data:r.map(e=>e.messages),color:I[v].messages},{label:i("tokenStats.toolCalls"),data:r.map(e=>e.tools),color:I[v].toolCalls}]};return{activityChart:s,tokenChart:{labels:n,datasets:N.map(e=>({id:e,label:B(e),data:r.map(t=>t.tokensByModel[e]||0),color:j[e]}))},costChart:{labels:n,datasets:N.map(e=>({id:e,label:B(e),data:r.map(t=>(t.tokensByModel[e]||0)*(C[e]||0)),color:j[e]}))}}},[d,x,N,C,j,i]),O=g&&j[g]?g:null,q=(0,s.useMemo)(()=>{let e="tokens"===f?L:M;return O?{...e,datasets:e.datasets.filter(e=>e.id===O)}:e},[L,M,f,O]);if((0,P.E)(t,e),!e)return null;let V=[{key:"day",label:i("tokenStats.day")},{key:"week",label:i("tokenStats.week")},{key:"month",label:i("tokenStats.month")}];return(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:t}),(0,n.jsxs)("div",{className:"relative bg-card rounded-xl shadow-lv3 w-full max-w-4xl mx-4 max-h-[90vh] flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-6 py-3 border-b border-border flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:i("tokenStats.title")}),(0,n.jsx)("div",{className:"flex bg-muted rounded-md p-0.5",children:V.map(e=>(0,n.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${x===e.key?"bg-background text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,onClick:()=>h(e.key),children:e.label},e.key))})]}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-6",children:u?(0,n.jsx)("div",{className:"text-center text-muted-foreground py-12",children:i("common.loading")}):d?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"grid grid-cols-5 gap-3",children:[(0,n.jsx)(_,{label:i("tokenStats.totalSessions"),value:String(d.totalSessions??0)}),(0,n.jsx)(_,{label:i("tokenStats.totalMessages"),value:D(d.totalMessages??0)}),(0,n.jsx)(_,{label:i("tokenStats.equivalentApiCost"),value:A(y),highlight:!0}),(0,n.jsx)(_,{label:i("tokenStats.longestSession"),value:d.longestSession?(a=Math.floor((r=d.longestSession.duration)/36e5),l=Math.floor(r%36e5/6e4),a>0?`${a}h ${l}m`:`${l}m`):"-"}),(0,n.jsx)(_,{label:i("tokenStats.firstUse"),value:d.firstSessionDate?d.firstSessionDate.slice(0,10):"-"})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,n.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:i("tokenStats.activityTrend")}),(0,n.jsxs)("div",{className:"flex items-center gap-3 text-[10px]",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:I[v].messages}}),i("tokenStats.messages")]}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:I[v].toolCalls}}),i("tokenStats.toolCalls")]})]})]}),(0,n.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,n.jsx)(z,{data:S,height:180})})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:i("tokenStats.byModel")}),(0,n.jsxs)("div",{className:"flex bg-muted rounded-md p-0.5",children:[(0,n.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${"tokens"===f?"bg-background text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,onClick:()=>p("tokens"),children:i("tokenStats.tokenUsage")}),(0,n.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${"cost"===f?"bg-background text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,onClick:()=>p("cost"),children:i("tokenStats.equivalentCost")})]})]}),(0,n.jsx)("div",{className:"flex items-center gap-3 text-[10px] flex-wrap",children:w.map(e=>(0,n.jsxs)("button",{onClick:()=>b(O===e.id?null:e.id),className:`flex items-center gap-1 rounded-sm transition-opacity hover:opacity-100 ${O&&O!==e.id?"opacity-40":""}`,children:[(0,n.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:e.color}}),e.label]},e.id))})]}),(0,n.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,n.jsx)(z,{data:q,height:180,formatValue:"tokens"===f?D:A})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:i("tokenStats.modelCostDetail")}),(0,n.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,n.jsxs)("table",{className:"w-full text-xs",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"bg-muted/50 text-muted-foreground",children:[(0,n.jsx)("th",{className:"text-left px-3 py-2 font-medium",children:i("tokenStats.model")}),(0,n.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Input"}),(0,n.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Output"}),(0,n.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Cache Read"}),(0,n.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Cache Write"}),(0,n.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:i("tokenStats.share")}),(0,n.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:i("tokenStats.equivalentCost")})]})}),(0,n.jsxs)("tbody",{children:[w.map(e=>(0,n.jsxs)("tr",{className:"border-t border-border",children:[(0,n.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e.color}}),e.label]})}),(0,n.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:D(e.usage.inputTokens)}),(0,n.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:D(e.usage.outputTokens)}),(0,n.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:D(e.usage.cacheReadInputTokens)}),(0,n.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:D(e.usage.cacheCreationInputTokens)}),(0,n.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:y>0?`${(e.cost/y*100).toFixed(1)}%`:"-"}),(0,n.jsx)("td",{className:"px-3 py-2 text-right font-medium text-foreground",children:A(e.cost)})]},e.id)),(0,n.jsxs)("tr",{className:"border-t-2 border-border bg-muted/30",children:[(0,n.jsx)("td",{className:"px-3 py-2 font-medium text-foreground",children:i("tokenStats.total")}),(0,n.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:D(w.reduce((e,t)=>e+t.usage.inputTokens,0))}),(0,n.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:D(w.reduce((e,t)=>e+t.usage.outputTokens,0))}),(0,n.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:D(w.reduce((e,t)=>e+t.usage.cacheReadInputTokens,0))}),(0,n.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:D(w.reduce((e,t)=>e+t.usage.cacheCreationInputTokens,0))}),(0,n.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:"100%"}),(0,n.jsx)("td",{className:"px-3 py-2 text-right font-bold text-foreground",children:A(y)})]})]})]})})]}),d.hourCounts&&Object.keys(d.hourCounts).length>0&&(0,n.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,n.jsx)(H,{hourCounts:d.hourCounts})})]}):(0,n.jsx)("div",{className:"text-center text-muted-foreground py-12",children:i("tokenStats.notFound")})})]})]})}function _({label:e,value:t,highlight:r}){return(0,n.jsxs)("div",{className:"bg-muted/30 rounded-lg px-3 py-2.5",children:[(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground",children:e}),(0,n.jsx)("div",{className:`text-sm font-semibold mt-0.5 ${r?"text-brand":"text-foreground"}`,children:t})]})}var O=r(60865),q=r(48764),V=r(58250),U=r(5135),K=r(38408);function G({skillId:e,onClose:t}){let{t:r}=(0,o.Bd)(),[a,l]=(0,s.useState)(null),[i,d]=(0,s.useState)(!0),[u,m]=(0,s.useState)("preview");(0,s.useEffect)(()=>{let t=!1;return d(!0),k.t4.runPromiseExit((0,q.Bz)(e)).then(e=>{t||("Success"===e._tag?l(e.value):console.error("Failed to load skill content",e.cause),d(!1))}),()=>{t=!0}},[e]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(e.stopPropagation(),(0,P.k)(),t())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t]);let x=(0,s.useCallback)(async()=>{if(a?.path)try{await navigator.clipboard.writeText(a.path),(0,c.oR)(r("common.copiedPath"),"success")}catch{(0,c.oR)(r("common.copyFailed"),"error")}},[a,r]);return(0,n.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:t}),(0,n.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-[70%] h-[90vh] mx-4 flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground truncate",children:a?.name?`/${a.name}`:r("skills.previewTitle")}),(0,n.jsx)("button",{onClick:x,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:r("skills.copyPath"),children:(0,n.jsxs)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})})]}),a?.path&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground font-mono truncate mt-0.5",children:a.path})]}),(0,n.jsxs)("div",{className:"flex items-center rounded-md border border-border overflow-hidden text-xs flex-shrink-0",children:[(0,n.jsx)("button",{onClick:()=>m("preview"),className:`px-3 py-1 transition-colors ${"preview"===u?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:r("common.preview")}),(0,n.jsx)("button",{onClick:()=>m("source"),className:`px-3 py-1 transition-colors ${"source"===u?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:r("skills.source")})]}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors flex-shrink-0",title:r("common.close"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:r("common.loading")}):a&&a.valid?"preview"===u?(0,n.jsx)(U.M,{content:a.content,filePath:a.path,cwd:a.path.slice(0,Math.max(0,a.path.lastIndexOf("/"))),embedded:!0,onClose:t}):(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:(0,n.jsx)(K.XO,{content:a.content,filePath:a.path,className:"min-h-full"})}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:r("skills.cannotRead")})]})]})}function J({isOpen:e,onClose:t}){let{t:r,i18n:a}=(0,o.Bd)(),[l,i]=(0,s.useState)([]),[d,m]=(0,s.useState)(!1),[x,h]=(0,s.useState)(""),[f,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(""),[v,j]=(0,s.useState)(!1),[w,y]=(0,s.useState)(null),N=(0,s.useRef)(null),C=(0,s.useCallback)(async()=>{m(!0);let e=await k.t4.runPromiseExit((0,q.Hy)());"Success"===e._tag?i(e.value):console.error("Failed to load skills",e.cause),m(!1)},[]);(0,s.useEffect)(()=>{e&&(C(),setTimeout(()=>{N.current?.focus(),N.current?.select()},100))},[e,C]),(0,s.useEffect)(()=>{if(!e)return;let r=e=>{if("Escape"===e.key&&!w){if(f){p(!1),b("");return}t()}};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t,f,w]);let S=(0,s.useMemo)(()=>{let e=x.trim().toLowerCase();return e?l.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)):l},[l,x]),L=a.resolvedLanguage?.startsWith("zh")?"https://opencockpit.dev/zh/docs/agent/skills/":"https://opencockpit.dev/en/docs/agent/skills/",M=(0,s.useCallback)(async()=>{let e=g.trim();if(!e)return;j(!0);let t=await k.t4.runPromiseExit((0,q.L5)(e));if("Success"===t._tag)(0,c.oR)(t.value.alreadyExists?r("skills.alreadyAdded"):r("skills.added"),t.value.alreadyExists?"info":"success"),b(""),p(!1),await C(),t.value.alreadyExists||(0,V.k)();else{let e="Fail"===t.cause._tag?t.cause.error:null,n=e?.cause,s=n instanceof Error?n.message:r("skills.addFailed");(0,c.oR)(s,"error")}j(!1)},[g,C,r]),E=(0,s.useCallback)(async e=>{"Success"===(await k.t4.runPromiseExit((0,q.hp)(e)))._tag?(i(t=>t.filter(t=>t.id!==e)),(0,V.k)()):(0,c.oR)(r("common.deleteFailed"),"error")},[r]),P=(0,s.useCallback)(async e=>{try{await navigator.clipboard.writeText(e),(0,c.oR)(r("common.copiedPath"),"success")}catch{(0,c.oR)(r("common.copyFailed"),"error")}},[r]);return e?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:t}),(0,n.jsxs)("div",{className:u.aO,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:r("skills.title")}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("input",{ref:N,type:"text",value:x,onChange:e=>h(e.target.value),placeholder:r("skills.searchPlaceholder"),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),x&&(0,n.jsx)("button",{onClick:()=>{h(""),N.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:r("skills.clearSearch"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsxs)("button",{onClick:()=>p(!0),className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:[(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),r("skills.addSkill")]}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",title:r("common.close"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:d?(0,n.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:r("common.loading")}):0===S.length?(0,n.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm space-y-2",children:0===l.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:r("skills.emptyNoSkills")}),(0,n.jsxs)("p",{children:[r("skills.emptyIntroPrefix")," ",(0,n.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-foreground font-mono text-xs",children:"/skillify"})," ",r("skills.emptyIntroSuffix")]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("button",{type:"button",onClick:()=>p(!0),className:"text-brand hover:underline",children:r("skills.addSkill")})," \xb7 ",(0,n.jsx)("a",{href:L,target:"_blank",rel:"noreferrer",className:"text-brand hover:underline",children:r("skills.viewDocs")})]})]}):r("skills.emptyNoMatch")}):(0,n.jsx)("div",{className:u.jL,children:S.map(e=>(0,n.jsx)(Q,{skill:e,onPreview:()=>y(e.id),onDelete:()=>E(e.id),onCopyPath:()=>P(e.path)},e.id))})})]})]}),f&&(0,n.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:()=>{v||(p(!1),b(""))}}),(0,n.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-lg mx-4 p-5",children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-foreground mb-3",children:r("skills.addSkill")}),(0,n.jsx)("label",{className:"block text-xs text-muted-foreground mb-1",children:r("skills.pathLabel")}),(0,n.jsx)("input",{type:"text",value:g,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"!==e.key||v||M()},placeholder:r("skills.pathPlaceholder"),autoFocus:!0,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-md bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,n.jsx)("button",{onClick:()=>{p(!1),b("")},disabled:v,className:"px-3 py-1.5 text-sm rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors disabled:opacity-50",children:r("common.cancel")}),(0,n.jsx)("button",{onClick:M,disabled:v||!g.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-brand text-white hover:bg-teal-10 transition-colors disabled:opacity-50",children:v?r("skills.adding"):r("skills.add")})]})]})]}),w&&(0,n.jsx)(G,{skillId:w,onClose:()=>y(null)})]}):null}function Q({skill:e,onPreview:t,onDelete:r,onCopyPath:a}){let{t:l}=(0,o.Bd)(),[i,d]=(0,s.useState)(!1);return(0,n.jsxs)("div",{onClick:e.valid?t:void 0,role:e.valid?"button":void 0,tabIndex:e.valid?0:void 0,onKeyDown:r=>{e.valid&&("Enter"===r.key||" "===r.key)&&(r.preventDefault(),t())},className:`group flex flex-col h-56 border border-border rounded-lg p-3 hover:border-brand hover:shadow-lv2 transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-ring ${e.valid?"cursor-pointer":"opacity-60"}`,children:[(0,n.jsxs)("div",{className:"flex items-center gap-2.5 flex-shrink-0",children:[(0,n.jsx)("div",{className:"w-9 h-9 flex-shrink-0 flex items-center justify-center rounded-md bg-brand/10 text-brand text-lg",children:e.icon?(0,n.jsx)("span",{children:e.icon}):(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3l1.9 4.8L19 9l-4.1 3.1L16 18l-4-2.8L8 18l1.1-5.9L5 9l5.1-1.2L12 3z"})})}),(0,n.jsxs)("span",{className:"font-mono text-sm font-medium text-foreground truncate flex-1 min-w-0","data-tooltip":`/${e.name}`,children:["/",e.name]}),!e.valid&&(0,n.jsx)("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-red-9/15 text-red-11",children:l("skills.invalid")}),(0,n.jsx)("div",{className:"flex items-center gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",children:i?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),d(!1),r()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:l("common.confirm")}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),d(!1)},className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:l("common.cancel")})]}):(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),d(!0)},className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:l("common.delete"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6M1 7h22M9 7V4a1 1 0 011-1h4a1 1 0 011 1v3"})})})})]}),(0,n.jsxs)("div",{className:"font-mono text-xs text-muted-foreground mt-2 flex-shrink-0 break-all line-clamp-2","data-tooltip":e.path,children:[e.path,(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),a()},className:"inline-flex align-middle ml-1 p-0.5 hover:text-foreground hover:bg-hover rounded transition-colors",title:l("skills.copyPath"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground mt-2 pt-2 border-t border-border/60 break-words line-clamp-4","data-tooltip":e.description||void 0,children:e.description||(0,n.jsx)("span",{className:"italic opacity-60",children:l("skills.noDescription")})}),e.argumentHint&&(0,n.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-auto pt-1 truncate flex-shrink-0","data-tooltip":e.argumentHint,children:e.argumentHint})]})}var Z=r(47650),X=r(7578);let Y=[],ee=[];function et(){ee.forEach(e=>e())}function er(e){Y=Y.filter(t=>t.id!==e),et()}function en({onNavigate:e}){let t=function(){let[,e]=(0,s.useState)(0);return(0,s.useEffect)(()=>{let t=()=>e(e=>e+1);return ee.push(t),()=>{ee=ee.filter(e=>e!==t)}},[]),Y}();return 0===t.length?null:(0,Z.createPortal)((0,n.jsx)("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col gap-2 pointer-events-none",children:t.map(t=>(0,n.jsx)(es,{item:t,onNavigate:e,onRemove:er},t.id))}),document.body)}function es({item:e,onNavigate:t,onRemove:r}){let{t:a}=(0,o.Bd)(),[l,i]=(0,s.useState)(!1),d=(0,s.useRef)(void 0),c=(0,s.useCallback)(()=>{i(!0),setTimeout(()=>r(e.id),300)},[e.id,r]);(0,s.useEffect)(()=>(d.current=setTimeout(c,5e3),()=>clearTimeout(d.current)),[c]);let u=(0,s.useCallback)(()=>{clearTimeout(d.current),t(e.cwd,e.sessionId),r(e.id)},[e,t,r]),m=(0,s.useCallback)(()=>{clearTimeout(d.current)},[]),x=(0,s.useCallback)(()=>{d.current=setTimeout(c,2e3)},[c]);return(0,n.jsxs)("div",{className:`group pointer-events-auto relative bg-popover border border-border rounded-lg shadow-lv3 px-3 py-3 min-h-[84px] min-w-[260px] max-w-[340px] cursor-pointer transition-all ${l?"opacity-0 -translate-x-4":"opacity-100 translate-x-0"}`,style:{animation:l?void 0:"slideInLeft 0.3s ease-out"},onClick:u,onMouseEnter:m,onMouseLeave:x,children:[(0,n.jsx)("div",{className:"pointer-events-none absolute inset-0 rounded-lg bg-hover opacity-0 group-hover:opacity-100 transition-opacity"}),(0,n.jsxs)("div",{className:"relative flex items-start gap-2",children:[(0,n.jsx)("svg",{className:"w-4 h-4 text-green-9 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),(0,n.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:e.projectName}),(0,n.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:a("common.done")}),(0,n.jsx)(X.l,{projectNumber:e.projectNumber,sessionNumber:e.sessionNumber,className:"ml-auto"}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),c()},className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.message&&(0,n.jsx)("div",{className:"relative text-xs text-muted-foreground line-clamp-2 break-words mt-1 ml-6",children:e.message})]})}var eo=r(77725),ea=r(49433),el=r(82680);let ei=ea.tryPromise({try:async()=>{let e=await fetch("/api/projects");if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()},catch:e=>new el.uV({message:"fetch /api/projects failed",cause:e})});function ed({initialCwd:e,initialSessionId:t}){let{t:c}=(0,o.Bd)(),[u,m]=(0,s.useState)([]),[x,h]=(0,s.useState)(0),[f,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(!1),[v,j]=(0,s.useState)(!1),[w,k]=(0,s.useState)(!1),[y,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(null),[M,E]=(0,s.useState)(!1),[P,T]=(0,s.useState)(!1),[$,R]=(0,s.useState)([]),[B,F]=(0,s.useState)(null),[I,D]=(0,s.useState)({}),[A,z]=(0,s.useState)({}),[H,_]=(0,s.useState)(!1),[q,V]=(0,s.useState)(new Set),U=(0,s.useRef)(new Map),K=(0,s.useRef)(new Map),G=(0,s.useRef)(new Map),Q=(0,s.useRef)(null),Z=(0,eo.Z)(ei,[]);(0,s.useEffect)(()=>{if("success"===Z.status){let e=Z.data;m([...e.projects||[]]),h(e.activeIndex||0),p(e.collapsed||!1),_(!0)}else"error"===Z.status&&(console.error("Failed to load projects:",Z.error),_(!0))},[Z]);let X=(0,s.useCallback)(async(e,t,n)=>{let s,{Effect:o}=await r.e(9012).then(r.bind(r,49012)),{BrowserRuntime:a}=await r.e(7562).then(r.bind(r,47562)),l=await a.runPromise((s={projects:e,activeIndex:t,collapsed:n},ea.tryPromise({try:async()=>{let e=await fetch("/api/projects",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!e.ok)throw Error(`HTTP ${e.status}`)},catch:e=>new el.uV({message:"save /api/projects failed",cause:e})})).pipe(o.either));"Left"===l._tag&&console.error("Failed to save projects:",l.left)},[]);(0,s.useEffect)(()=>{let e=u[x]?.cwd;e&&V(t=>t.has(e)?t:new Set(t).add(e))},[x,u]),(0,s.useEffect)(()=>{for(let[e,t]of U.current.entries()){let r=u[x]?.cwd===e;t.contentWindow?.postMessage({type:"IFRAME_VISIBILITY",visible:r,projectNumber:u.findIndex(t=>t.cwd===e)+1},"*")}},[x,u]);let ee=(0,s.useCallback)(e=>{let t=u[x]?.cwd,r=t?U.current.get(t):null,n=r?.contentWindow;if(!n)return;let s=n.document.createEvent("CustomEvent");s.initCustomEvent("console-open-browser",!1,!1,{url:e}),n.dispatchEvent(s)},[x,u]),er=(0,s.useCallback)(e=>{R(t=>t.some(t=>t.path===e.path)?t:[...t,e]),F(e.path)},[]),es=(0,s.useCallback)(()=>{F(null)},[]),ec=(0,s.useCallback)(e=>{R(t=>t.filter(t=>t.path!==e)),F(t=>t===e?null:t)},[]);(0,s.useEffect)(()=>{let e=e=>{if(e.data?.type!=="SESSION_NUMBERS")return;let t=e.data.cwd;if("string"!=typeof t||!Array.isArray(e.data.sessionIds))return;let r=e.data.sessionIds.map(e=>"string"==typeof e?e:null);z(e=>{let n=e[t];return n&&n.length===r.length&&n.every((e,t)=>e===r[t])?e:{...e,[t]:r}})};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[]);let eu=(0,s.useMemo)(()=>{let e={};return u.forEach((t,r)=>{(A[t.cwd]??[]).forEach((n,s)=>{n&&(e[`${t.cwd}
|
|
30
|
+
${n}`]=`${r+1}.${s+1}`)})}),e},[u,A]),em=(0,s.useCallback)(()=>{let e=crypto.randomUUID(),t=new Map(u.map((e,t)=>[e.cwd,t+1])),r=[...U.current.values()];return 0===r.length?Promise.resolve({}):new Promise(n=>{let s={},o=new Set(r.map(e=>e.contentWindow).filter(Boolean)),a=()=>{window.removeEventListener("message",l),clearTimeout(i),D(s),n(s)},l=r=>{if(r.data?.type!=="SESSION_NUMBERS"||r.data?.requestId!==e||!o.delete(r.source))return;let n=t.get(r.data.cwd);n&&Array.isArray(r.data.sessionIds)&&r.data.sessionIds.forEach((e,t)=>{"string"==typeof e&&(s[`${r.data.cwd}
|
|
31
|
+
${e}`]=`${n}.${t+1}`)}),0===o.size&&a()};window.addEventListener("message",l);let i=window.setTimeout(a,300);r.forEach(t=>t.contentWindow?.postMessage({type:"GET_SESSION_NUMBERS",requestId:e},"*"))})},[u]),ex=Object.fromEntries(u.map((e,t)=>[e.cwd,t+1]));(0,s.useEffect)(()=>{g&&em()},[g,em]);let eh=(0,s.useCallback)((e,t)=>{let r=new URL(window.location.href);r.searchParams.set("cwd",e),t?r.searchParams.set("sessionId",t):r.searchParams.delete("sessionId"),window.history.replaceState({},"",r.toString());let n=e.split("/").filter(Boolean).pop();document.title=n||"Cockpit"},[]),ef=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(!H||ef.current||!e)return;ef.current=!0,t&&(K.current.set(e,{sessionId:t}),G.current.set(e,t));let r=u.findIndex(t=>t.cwd===e);if(r>=0)r!==x&&(h(r),X(u,r,f));else{let t=[...u,{cwd:e}],r=t.length-1;m(t),h(r),X(t,r,f)}eh(e,t)},[H,e,t,u,x,f,X,eh]),(0,s.useEffect)(()=>{let e=e=>{if(e.data?.type==="GET_PROJECT_NUMBER"){let t=u.findIndex(t=>t.cwd===e.data.cwd);t>=0&&e.source&&"postMessage"in e.source&&e.source.postMessage({type:"PROJECT_NUMBER",projectNumber:t+1},"*");return}if(e.data?.type==="SESSION_CHANGE"&&e.data?.cwd&&e.data?.sessionId){let{cwd:t,sessionId:r}=e.data;G.current.set(t,r);let n=u[x];n?.cwd===t&&eh(t,r)}if(e.data?.type==="SESSION_COMPLETE"&&e.data?.cwd&&e.data?.sessionId){let{cwd:t,sessionId:r,lastUserMessage:n}=e.data,s=u[x];if(s?.cwd!==t){let e=t.split("/").pop()||t;em().then(s=>{let o,[a,l]=s[`${t}
|
|
32
|
+
${r}`]?.split(".")??[],i=u.findIndex(e=>e.cwd===t);o=`session-toast-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,Y=[...Y,{projectName:e,message:n,cwd:t,sessionId:r,projectNumber:a??(i>=0?i+1:void 0),sessionNumber:l,id:o}],et()})}}if(e.data?.type==="OPEN_TOKEN_STATS"&&k(!0),e.data?.type==="OPEN_NOTE"&&e.data?.cwd&&(S(e.data.cwd),N(!0)),e.data?.type==="SCREENSHOT_PREPARE"&&e.data?.cwd){Q.current=x;let t=e.data.cwd,r=u.findIndex(e=>e.cwd===t);r>=0&&r!==x&&h(r);return}if(e.data?.type==="SCREENSHOT_DONE"){null!==Q.current&&Q.current!==x&&h(Q.current),Q.current=null;return}if(e.data?.type==="OPEN_PROJECT"&&e.data?.cwd){let{cwd:t,sessionId:r}=e.data,n=r||"";G.current.set(t,n);let s=u.findIndex(e=>e.cwd===t);if(s>=0){if(n){let e=U.current.get(t);e?.contentWindow?e.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:n},"*"):K.current.set(t,{sessionId:n})}s!==x&&(h(s),X(u,s,f))}else{let e=[...u,{cwd:t}],r=e.length-1;m(e),h(r),X(e,r,f),n&&K.current.set(t,{sessionId:n})}eh(t,n)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[u,x,f,eh,X,em]),(0,s.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&!e.altKey){if(!e.shiftKey&&("p"===e.key||"f"===e.key||"s"===e.key))return void e.preventDefault();e.ctrlKey&&!e.metaKey&&"Minus"===e.code&&e.preventDefault()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let ep=(0,s.useCallback)(e=>{h(e),X(u,e,f);let t=u[e];if(t?.cwd){let e=G.current.get(t.cwd);eh(t.cwd,e)}},[u,f,X,eh]),eg=(0,s.useCallback)(e=>{let t=u.filter((t,r)=>r!==e),r=x;e<x?r=x-1:e===x&&r>=t.length&&(r=Math.max(0,t.length-1)),m(t),h(r),X(t,r,f)},[u,x,f,X]),eb=(0,s.useCallback)(e=>{let t=u[x],r=e.findIndex(e=>e.cwd===t?.cwd);m(e),h(r>=0?r:0),X(e,r>=0?r:0,f)},[u,x,f,X]),ev=(0,s.useCallback)(()=>{let e=!f;p(e),X(u,x,e)},[u,x,f,X]),ej=(0,s.useCallback)((e,t)=>{G.current.set(e,t);let r=u.findIndex(t=>t.cwd===e);if(r>=0){let n=U.current.get(e);n?.contentWindow?n.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:t,switchToAgent:!0},"*"):K.current.set(e,{sessionId:t,switchToAgent:!0}),h(r),X(u,r,f)}else{let r=[...u,{cwd:e}],n=r.length-1;m(r),h(n),X(r,n,f),K.current.set(e,{sessionId:t,switchToAgent:!0})}eh(e,t),b(!1)},[u,f,X,eh]),ew=(0,s.useCallback)((e,t)=>{G.current.set(e,t);let r=u.findIndex(t=>t.cwd===e);if(r>=0){let n=U.current.get(e);n?.contentWindow?n.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:t,switchToAgent:!0},"*"):K.current.set(e,{sessionId:t,switchToAgent:!0}),r!==x&&(h(r),X(u,r,f))}else{let r=[...u,{cwd:e}],n=r.length-1;m(r),h(n),X(r,n,f),K.current.set(e,{sessionId:t,switchToAgent:!0})}eh(e,t)},[u,x,f,X,eh]);return H?(0,n.jsxs)("div",{className:"h-screen flex bg-background overflow-hidden",children:[(0,n.jsx)(a.ProjectSidebar,{projects:u,activeIndex:x,collapsed:f,currentCwd:u[x]?.cwd,onSelectProject:ep,onRemoveProject:eg,onReorderProjects:eb,onToggleCollapse:ev,onOpenSessionBrowser:()=>b(!0),onOpenSettings:()=>j(!0),onOpenNote:e=>{S(e??null),N(!0)},onOpenSkills:()=>E(!0),onOpenApps:()=>T(!0),htmlAppPreviews:$,activeHtmlAppPreviewPath:B,onShowHtmlAppPreview:er,onSwitchProject:ew,onResolveSessionNumbers:em,sessionOrders:A,sessionNumbers:eu}),(0,n.jsx)("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:0===u.length?(0,n.jsx)(l.EmptyState,{onBrowseProjects:()=>b(!0)}):(0,n.jsx)("div",{className:"flex-1 relative overflow-hidden",children:u.map((e,t)=>{let r,s;return q.has(e.cwd)&&(0,n.jsx)("iframe",{ref:t=>{t?U.current.set(e.cwd,t):U.current.delete(e.cwd)},src:(r=`/project?cwd=${encodeURIComponent(e.cwd)}`,s=K.current.get(e.cwd),s?.sessionId&&(r+=`&sessionId=${encodeURIComponent(s.sessionId)}`,s.switchToAgent&&(r+="&view=agent")),r),className:`absolute inset-0 w-full h-full border-0 ${t===x?"block":"hidden"}`,title:`Project: ${e.cwd}`},e.cwd)})})}),(0,n.jsx)(i.SessionBrowser,{isOpen:g,onClose:()=>b(!1),onSelectSession:ej,sessionNumbers:I,projectNumbers:ex,onAddProject:e=>{let t=u.findIndex(t=>t.cwd===e);if(t>=0)h(t),X(u,t,f);else{let t=[...u,{cwd:e}],r=t.length-1;m(t),h(r),X(t,r,f)}b(!1)}}),(0,n.jsx)(d.SettingsModal,{isOpen:v,onClose:()=>j(!1)}),(0,n.jsx)(W,{isOpen:w,onClose:()=>k(!1)}),(0,n.jsx)(O.NoteModal,{isOpen:y,onClose:()=>{N(!1),S(null)},projectCwd:C,projectName:C?C.split("/").pop():null}),(0,n.jsx)(J,{isOpen:M,onClose:()=>E(!1)}),(0,n.jsx)(L,{isOpen:P,htmlAppPreviews:$,activeHtmlAppPreviewPath:B,onShowHtmlAppPreview:er,onMinimizeHtmlAppPreview:es,onCloseHtmlAppPreview:ec,onClose:()=>T(!1),onOpenApp:ee}),(0,n.jsx)(en,{onNavigate:ew})]}):(0,n.jsx)("div",{className:"h-screen flex items-center justify-center bg-card",children:(0,n.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,n.jsxs)("svg",{className:"animate-spin h-5 w-5",fill:"none",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,n.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,n.jsx)("span",{children:c("workspace.loadingText")})]})})}},89039:(e,t,r)=>{r.d(t,{useTabState:()=>h});var n=r(12115),s=r(41474),o=r(2111),a=r(95045),l=r(75346),i=r(49433),d=r(86957),c=r(96472);let u=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\.jsonl)?$/i;function m(e){let t=e.match(u);return t?.[1]??e}function x(e,t,r){let n=new Set(t.map(e=>e.id)),s=new Set(e.filter(e=>n.has(e))),o=[],a=[];for(let l of e){if(n.has(l)&&!a.includes(l)){a.push(l);continue}let e=new Set([...a,...s]),i=[...t].reverse().find(t=>!e.has(t.id));if(i){a.push(i.id),s.add(i.id);continue}let d={id:`tab-${Date.now()}-pane${o.length}`,cwd:r,title:"New Chat"};o.push(d),a.push(d.id)}return{panes:a,created:o}}function h({initialCwd:e,initialSessionId:t,activeView:r}){let u=(0,n.useRef)(!1),f=(0,n.useRef)(!0),[p,g]=(0,n.useState)(!1),b=(0,n.useCallback)(()=>{f.current=!1,g(!0)},[]),v=(0,n.useRef)(r);(0,n.useEffect)(()=>{v.current=r},[r]);let j=(0,s.F)(),w=(0,n.useRef)(j);(0,n.useEffect)(()=>{w.current=j},[j]);let[k,y]=(0,n.useState)(()=>[{id:`tab-${Date.now()}`,cwd:e,sessionId:t,title:t?`Session ${t.slice(0,6)}...`:"New Chat"}]),[N,C]=(0,n.useState)(()=>[k[0]?.id??""]),[S,L]=(0,n.useState)(0),M=(0,n.useRef)(S);(0,n.useEffect)(()=>{M.current=S},[S]);let E=(0,n.useRef)(N);(0,n.useEffect)(()=>{E.current=N},[N]);let P=N[S]??N[0]??"",T=(0,n.useCallback)(e=>{C(t=>{let r=t.indexOf(e);if(-1!==r)return r!==M.current&&L(r),t;let n=[...t];return n[M.current]=e,n})},[]),[$,R]=(0,n.useState)(new Set),B=(0,n.useRef)(k);(0,n.useEffect)(()=>{B.current=k},[k]);let F=(0,n.useRef)(P);(0,n.useEffect)(()=>{F.current=P},[P]);let I=(0,n.useRef)(new Set),D=(0,n.useCallback)((t,r)=>{e&&t&&d.t4.runFork((0,c.KJ)(e,t,r).pipe(i.catchAll(()=>i.void)))},[e]),[A,z]=(0,n.useState)(null),[H,W]=(0,n.useState)(null);(0,n.useEffect)(()=>{!e||u.current||(u.current=!0,(async()=>{let r=await d.t4.runPromise((0,c.n8)(e).pipe(i.catchAll(()=>i.succeed(null))));if(r){let n=r.engines||{},s={};for(let[e,t]of Object.entries(n))s["codex"===t?m(e):e]=t;let o=[];for(let e of r.sessions||[]){let t="codex"===n[e]?m(e):e;o.includes(t)||o.push(t)}let a=r.activeSessionId&&"codex"===n[r.activeSessionId]?m(r.activeSessionId):r.activeSessionId,l=r.ollamaModels||{},i=r.deepseekModels||{},d=r.kimiModels||{},c=r.glmModels||{},u=r.claudeModels||{},h=r.claudeEfforts||{},f=r.claudeContextWindows||{},p=r.claudeFastModes||{},g=r.claudeThinkings||{},v=r.codexModels||{},j=r.codexReasoningEfforts||{},w=r.planModes||{},k=r.noHistories||{},N=[...o];if(t&&!N.includes(t)&&(N=[t,...N]),N.length>0){let o=B.current,S=N.map((t,r)=>{let n=o.find(e=>e.sessionId===t);return{id:`tab-${Date.now()}-${r}`,cwd:e,sessionId:t,title:`Session ${t.slice(0,6)}...`,engine:s[t]||n?.engine||void 0,ollamaModel:l[t]||n?.ollamaModel||void 0,deepseekModel:i[t]||n?.deepseekModel||void 0,kimiModel:d[t]||n?.kimiModel||void 0,glmModel:c[t]||n?.glmModel||void 0,claudeModel:u[t]||n?.claudeModel||void 0,claudeEffort:h[t]||n?.claudeEffort||void 0,claudeContextWindow:f[t]||n?.claudeContextWindow||void 0,claudeFastMode:p[t]??n?.claudeFastMode,claudeThinking:g[t]??n?.claudeThinking,codexModel:v[t]||n?.codexModel||void 0,codexReasoningEffort:j[t]||n?.codexReasoningEffort||void 0,planMode:w[t]??n?.planMode,noHistory:k[t]??n?.noHistory}}),M=t||a,E=M?N.indexOf(M):-1;E<0&&(E=0);let P=S[E].id,$=r.paneSessionIds;if(Array.isArray($)&&$.length>1){let{panes:t,created:r}=x($.slice(0,2).map(e=>{let t=e&&"codex"===n[e]?m(e):e;return t&&S.find(e=>e.sessionId===t)?.id||""}),S,e),s=t.indexOf(P);-1===s&&(t[0]=P,s=0);let o=t[0]===t[1];y([...S,...r]),C(o?[t[0]]:t),L(o?0:s)}else y(S),T(P);setTimeout(b,0)}else b()}else b()})())},[e,t,b]),(0,n.useEffect)(()=>{if(!p||!e)return;let t=k.map(e=>e.sessionId).filter(e=>!!e),r=k.find(e=>e.id===P),n=r?.sessionId,s={},o={},a={},l={},u={},m={},x={},h={},f={},g={},b={},v={},j={},w={};for(let e of k)e.sessionId&&e.engine&&(s[e.sessionId]=e.engine),e.sessionId&&e.ollamaModel&&(o[e.sessionId]=e.ollamaModel),e.sessionId&&e.deepseekModel&&(a[e.sessionId]=e.deepseekModel),e.sessionId&&e.kimiModel&&(l[e.sessionId]=e.kimiModel),e.sessionId&&e.glmModel&&(u[e.sessionId]=e.glmModel),e.sessionId&&e.claudeModel&&(m[e.sessionId]=e.claudeModel),e.sessionId&&e.claudeEffort&&(x[e.sessionId]=e.claudeEffort),e.sessionId&&e.claudeContextWindow&&(h[e.sessionId]=e.claudeContextWindow),e.sessionId&&e.codexModel&&(b[e.sessionId]=e.codexModel),e.sessionId&&e.codexReasoningEffort&&(v[e.sessionId]=e.codexReasoningEffort),e.sessionId&&(void 0!==e.planMode&&(j[e.sessionId]=e.planMode),void 0!==e.noHistory&&(w[e.sessionId]=e.noHistory),void 0!==e.claudeFastMode&&(f[e.sessionId]=e.claudeFastMode),void 0!==e.claudeThinking&&(g[e.sessionId]=e.claudeThinking));let y=[...I.current],C=N.map(e=>k.find(t=>t.id===e)?.sessionId??null);d.t4.runFork((0,c.ej)({cwd:e,sessions:t,activeSessionId:n,paneSessionIds:C,engines:s,ollamaModels:o,deepseekModels:a,kimiModels:l,glmModels:u,claudeModels:m,claudeEfforts:x,claudeContextWindows:h,claudeFastModes:f,claudeThinkings:g,codexModels:b,codexReasoningEfforts:v,planModes:j,noHistories:w,...y.length?{closedSessionIds:y}:{}}).pipe(i.tap(()=>i.sync(()=>{for(let e of y)I.current.delete(e)})),i.tapError(e=>i.sync(()=>console.error("Failed to save sessions:",e))),i.catchAll(()=>i.void)))},[k,P,N,e,p]),(0,n.useEffect)(()=>{if(f.current||!e)return;let t=k.find(e=>e.id===P);t?.sessionId&&(0,a.F)(l.n.SessionChange,{cwd:e,sessionId:t.sessionId})},[P,k,e]);let _=(0,n.useCallback)(t=>{e&&d.t4.runPromise((0,c.n8)(e).pipe(i.catchAll(()=>i.succeed(null)))).then(r=>{if(!r)return;let n=r.engines||{},s={};for(let[e,t]of Object.entries(n))s["codex"===t?m(e):e]=t;let o=[];for(let e of r.sessions||[]){let t="codex"===n[e]?m(e):e;o.includes(t)||o.push(t)}let a=r.ollamaModels||{},l=r.deepseekModels||{},i=r.kimiModels||{},d=r.glmModels||{},c=r.claudeModels||{},u=r.claudeEfforts||{},h=r.claudeContextWindows||{},f=r.claudeFastModes||{},p=r.claudeThinkings||{},g=r.codexModels||{},b=r.codexReasoningEfforts||{},v=r.planModes||{},j=r.noHistories||{},w=B.current,k=new Set(t),N=w.filter(e=>!e.sessionId||!k.has(e.sessionId)),S=new Set(N.map(e=>e.sessionId).filter(Boolean)),L=o.filter(e=>!S.has(e));if(N.length===w.length&&0===L.length)return;let M=[...N,...L.map((t,r)=>({id:`tab-${Date.now()}-sync-${r}`,cwd:e,sessionId:t,title:`Session ${t.slice(0,6)}...`,engine:s[t]||void 0,ollamaModel:a[t]||void 0,deepseekModel:l[t]||void 0,kimiModel:i[t]||void 0,glmModel:d[t]||void 0,claudeModel:c[t]||void 0,claudeEffort:u[t]||void 0,claudeContextWindow:h[t]||void 0,claudeFastMode:f[t]??void 0,claudeThinking:p[t]??void 0,codexModel:g[t]||void 0,codexReasoningEffort:b[t]||void 0,planMode:v[t]||void 0,noHistory:j[t]||void 0}))];0===M.length&&(M=[{id:`tab-${Date.now()}`,cwd:e,title:"New Chat"}]);let{panes:P,created:T}=x(E.current,M,e);T.length&&(M=[...M,...T]),y(M),C(P)})},[e]);(0,o.h)({url:"/ws/global-state",enabled:!!e,onMessage:t=>{f.current||!e||"project-state-changed"===t.type&&t.cwd===e&&_(t.closedSessionIds??[])}});let O=(0,n.useCallback)((e,t,r,n)=>{let{engine:s,ollamaModel:o,deepseekModel:a,kimiModel:l,glmModel:i,claudeModel:d,claudeEffort:c,claudeContextWindow:u,claudeFastMode:m,claudeThinking:x,codexModel:h,codexReasoningEffort:f,planMode:p,noHistory:g,appendToEnd:b=!1}=n??{},v={id:`tab-${Date.now()}`,cwd:e,sessionId:t,title:r||(t?`Session ${t.slice(0,6)}...`:"New Chat"),engine:s,ollamaModel:o,deepseekModel:a,kimiModel:l,glmModel:i,claudeModel:d,claudeEffort:c,claudeContextWindow:u,claudeFastMode:m,claudeThinking:x,codexModel:h,codexReasoningEffort:f,planMode:p,noHistory:g};y(e=>{if(b)return[...e,v];let t=e.findIndex(e=>e.id===P);if(-1===t)return[...e,v];let r=[...e];return r.splice(t+1,0,v),r}),T(v.id)},[P]),q=(0,n.useCallback)(t=>{let r=B.current.find(e=>e.id===t);r?.sessionId&&I.current.add(r.sessionId);let n=B.current.filter(e=>e.id!==t),{panes:s,created:o}=x(E.current,n,e);y([...n,...o]),C(s)},[e]),V=(0,n.useCallback)(()=>{L(0),B.current.forEach(e=>{e.sessionId&&I.current.add(e.sessionId)});let t={id:`tab-${Date.now()}`,cwd:e,title:"New Chat"};T(t.id),y([t])},[e]),U=(0,n.useCallback)((t,r)=>{let n=k.find(e=>e.sessionId===t);n?T(n.id):e?d.t4.runPromise((0,c.n8)(e).pipe(i.catchAll(()=>i.succeed(null)))).then(n=>{let s=B.current.find(e=>e.sessionId===t);s?T(s.id):O(e,t,r,{engine:n?.engines?.[t],ollamaModel:n?.ollamaModels?.[t],deepseekModel:n?.deepseekModels?.[t],kimiModel:n?.kimiModels?.[t],glmModel:n?.glmModels?.[t],claudeModel:n?.claudeModels?.[t],claudeEffort:n?.claudeEfforts?.[t],claudeContextWindow:n?.claudeContextWindows?.[t],claudeFastMode:n?.claudeFastModes?.[t],claudeThinking:n?.claudeThinkings?.[t],codexModel:n?.codexModels?.[t],codexReasoningEffort:n?.codexReasoningEfforts?.[t],planMode:n?.planModes?.[t],noHistory:n?.noHistories?.[t],appendToEnd:!0})}):O(e,t,r,{appendToEnd:!0})},[k,e,O]),K=(0,n.useCallback)(()=>{O(e,void 0,void 0,{appendToEnd:!0})},[e,O]),G=(0,n.useCallback)(()=>{O(e,void 0,"New Codex Chat",{engine:"codex",appendToEnd:!0})},[e,O]),J=(0,n.useCallback)(()=>{O(e,void 0,"New Kimi Chat",{engine:"kimi",kimiModel:"k3",appendToEnd:!0})},[e,O]),Q=(0,n.useCallback)(()=>{O(e,void 0,"New GLM Chat",{engine:"glm",glmModel:"glm-5.3",appendToEnd:!0})},[e,O]),Z=(0,n.useCallback)(t=>{O(e,void 0,t?`New Ollama (${t})`:"New Ollama Chat",{engine:"ollama",ollamaModel:t,appendToEnd:!0})},[e,O]),X=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e&&r.engine!==t?{...r,engine:t}:r))},[]),Y=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,ollamaModel:t}:r))},[]),ee=(0,n.useCallback)(()=>{O(e,void 0,"New DeepSeek Chat",{engine:"deepseek",deepseekModel:"deepseek-v4-flash",appendToEnd:!0})},[e,O]),et=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,deepseekModel:t}:r))},[]),er=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,kimiModel:t}:r))},[]),en=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,glmModel:t}:r))},[]),es=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,claudeModel:t}:r))},[]),eo=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,claudeEffort:t}:r))},[]),ea=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,claudeContextWindow:t}:r))},[]),el=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,claudeFastMode:t}:r))},[]),ei=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,claudeThinking:t}:r))},[]),ed=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,codexModel:t}:r))},[]),ec=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,codexReasoningEffort:t}:r))},[]),eu=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,planMode:t}:r))},[]),em=(0,n.useCallback)((e,t)=>{y(r=>r.map(r=>r.id===e?{...r,noHistory:t}:r))},[]),ex=(0,n.useCallback)((t,r)=>{let n=B.current.find(e=>e.id===F.current);O(e,t,r,{engine:n?.engine,ollamaModel:n?.ollamaModel,deepseekModel:n?.deepseekModel,kimiModel:n?.kimiModel,glmModel:n?.glmModel,claudeModel:n?.claudeModel,claudeEffort:n?.claudeEffort,claudeContextWindow:n?.claudeContextWindow,claudeFastMode:n?.claudeFastMode,claudeThinking:n?.claudeThinking,codexModel:n?.codexModel,codexReasoningEffort:n?.codexReasoningEffort})},[e,O]),eh=(0,n.useCallback)((e,t)=>{y(r=>{let n=r.find(t=>t.id===e);if(n?.isLoading&&!1===t.isLoading){let r=!v.current||"agent"===v.current;if(e===P&&r&&w.current){let e=n.sessionId||t.sessionId;e&&D(e,"normal")}else R(t=>new Set(t).add(e))}return r.map(r=>r.id===e?{...r,...t}:r)})},[P,D]);(0,n.useEffect)(()=>{(!r||"agent"===r)&&j&&R(e=>{if(!e.has(P))return e;let t=new Set(e);t.delete(P);let r=B.current.find(e=>e.id===P);return r?.sessionId&&(D(r.sessionId,"normal"),d.t4.runFork((0,c.M2)(r.sessionId).pipe(i.catchAll(()=>i.void)))),t})},[r,P,j,D]);let ef=(0,n.useCallback)(()=>{let t=E.current;if(t.length>1){C([t[M.current]]),L(0);return}let r=B.current,n=r.findIndex(e=>e.id===t[0]),s=r[n+1]??r[n-1];if(s){C([t[0],s.id]),L(0);return}let o={id:`tab-${Date.now()}`,cwd:e,title:"New Chat"};y(e=>[...e,o]),C([t[0],o.id]),L(1)},[e]),ep=(0,n.useCallback)(e=>{let t=E.current;t.length<2||(C(t.filter((t,r)=>r!==e)),L(0))},[]),eg=(0,n.useCallback)(e=>{L(e)},[]),eb=(0,n.useCallback)(e=>{T(e),R(t=>{if(!t.has(e))return t;let r=new Set(t);r.delete(e);let n=B.current.find(t=>t.id===e);return n?.sessionId&&(D(n.sessionId,"normal"),d.t4.runFork((0,c.M2)(n.sessionId).pipe(i.catchAll(()=>i.void)))),r})},[D]),ev=(0,n.useCallback)(e=>{z(e)},[]),ej=(0,n.useCallback)((e,t)=>{e.preventDefault(),null!==A&&A!==t&&W(t)},[A]),ew=(0,n.useCallback)(e=>{null!==A&&A!==e&&y(t=>{let r=[...t],[n]=r.splice(A,1);return r.splice(e,0,n),r}),z(null),W(null)},[A]),ek=(0,n.useCallback)(()=>{z(null),W(null)},[]),ey=k.find(e=>e.id===P);return{tabs:k,activeTabId:P,activeTab:ey,paneTabIds:N,activePane:S,unreadTabs:$,dragTabIndex:A,dragOverTabIndex:H,addTab:O,toggleSideBySide:ef,focusPane:eg,closePane:ep,closeTab:q,closeAllTabs:V,switchTab:eb,handleSelectSession:U,handleNewTab:K,handleNewCodexTab:G,handleNewKimiTab:J,handleNewGlmTab:Q,handleNewOllamaTab:Z,handleNewDeepseekTab:ee,handleOpenSession:ex,updateTabState:eh,updateTabEngine:X,updateTabOllamaModel:Y,updateTabDeepseekModel:et,updateTabKimiModel:er,updateTabGlmModel:en,updateTabClaudeModel:es,updateTabClaudeEffort:eo,updateTabClaudeContextWindow:ea,updateTabClaudeFastMode:el,updateTabClaudeThinking:ei,updateTabCodexModel:ed,updateTabCodexReasoningEffort:ec,updateTabPlanMode:eu,updateTabNoHistory:em,handleTabDragStart:ev,handleTabDragOver:ej,handleTabDrop:ew,handleTabDragEnd:ek}}},92689:(e,t,r)=>{r.d(t,{S:()=>o});var n=r(95155),s=r(57125);function o({engine:e,tooltip:t,size:r="md"}){let a=e||"claude";return(0,s.ch)(a)?(0,n.jsx)("span",{className:"shrink-0 inline-flex items-center","data-tooltip":t??s.H[a],children:(0,n.jsx)(s.eV,{engine:a,className:"sm"===r?"h-3 w-3":"h-3.5 w-3.5"})}):(0,n.jsx)("span",{className:"shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded bg-muted text-muted-foreground","data-tooltip":t??a,children:a})}},93777:(e,t,r)=>{r.d(t,{E:()=>c});var n=r(95155),s=r(12115),o=r(79114),a=r(69809),l=r(12786),i=r(96625);let d={once:[{labelKey:"scheduledTasks.5minLater",value:5},{labelKey:"scheduledTasks.15minLater",value:15},{labelKey:"scheduledTasks.30minLater",value:30},{labelKey:"scheduledTasks.1hourLater",value:60}],interval:[{labelKey:"scheduledTasks.every15min",value:15},{labelKey:"scheduledTasks.every30min",value:30},{labelKey:"scheduledTasks.every1hour",value:60},{labelKey:"scheduledTasks.every2hours",value:120}],cron:[{labelKey:"scheduledTasks.daily9am",value:"0 9 * * *"},{labelKey:"scheduledTasks.daily6pm",value:"0 18 * * *"},{labelKey:"scheduledTasks.weeklyMon9am",value:"0 9 * * 1"},{labelKey:"scheduledTasks.monthly1st9am",value:"0 9 1 * *"}]};function c({onClose:e,onCreate:t,editTask:r,onUpdate:u}){let{t:m}=(0,o.Bd)(),x=!!r,[h,f]=(0,s.useState)(r?.type||"once"),[p,g]=(0,s.useState)(r?.message||""),[b,v]=(0,s.useState)(r?.taskFile?"file":"message"),[j,w]=(0,s.useState)(r?.taskFile||""),[k,y]=(0,s.useState)(r?String(r.delayMinutes||r.intervalMinutes||""):""),[N,C]=(0,s.useState)(r?.cron||""),[S,L]=(0,s.useState)(r?.activeFrom||"09:00"),[M,E]=(0,s.useState)(r?.activeTo||"18:00"),[P,T]=(0,s.useState)(!!(r?.activeFrom&&r?.activeTo)),[$,R]=(0,s.useState)(null),B=(0,s.useRef)(null),F=(0,s.useRef)(null),I=(0,i.n)({value:p,onChange:g,textareaRef:F});(0,s.useEffect)(()=>{F.current?.focus()},[]),(0,s.useEffect)(()=>{let t=t=>{B.current&&!B.current.contains(t.target)&&e()};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[e]);let D=(0,s.useCallback)(()=>{let n="file"===b,s=n?{message:"",taskFile:j.trim()}:{message:p.trim(),taskFile:""};if(n?!s.taskFile:!s.message)return;let o=null;if("once"===h){let e=$||parseInt(k,10);if(!e||e<=0)return;o={...s,type:"once",delayMinutes:e}}else if("interval"===h){let e=$||parseInt(k,10);if(!e||e<=0)return;o={...s,type:"interval",intervalMinutes:e,...P?{activeFrom:S,activeTo:M}:{}}}else if("cron"===h){let e=$||N.trim();if(!e)return;o={...s,type:"cron",cron:e}}o&&(x&&r&&u?u(r.id,o):t(o),e())},[p,b,j,h,$,k,N,P,S,M,t,e,x,r,u]);return(0,n.jsxs)("div",{ref:B,className:`w-[28rem] max-w-[calc(100vw-1.5rem)] bg-popover border border-border rounded-lg shadow-lv2 z-50 ${x?"":"absolute bottom-full left-0 mb-2"}`,onKeyDown:t=>{"Escape"===t.key?e():"Enter"===t.key&&(t.metaKey||t.ctrlKey)&&D()},children:[(0,n.jsx)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 rounded-t-lg",children:(0,n.jsx)("span",{className:"text-sm font-medium",children:x?m("scheduledTasks.editTask"):m("scheduledTasks.createTask")})}),(0,n.jsxs)("div",{className:"p-4 space-y-4 max-h-[min(52rem,calc(100vh-3rem))] overflow-y-auto",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"flex gap-1 mb-1.5",children:["message","file"].map(e=>(0,n.jsx)("button",{onClick:()=>v(e),className:`px-2 py-1 text-xs rounded transition-colors ${b===e?"bg-brand text-white":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"message"===e?m("scheduledTasks.sendMessage"):m("scheduledTasks.taskFile")},e))}),"message"===b?(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("textarea",{ref:F,value:p,onChange:e=>{g(e.target.value),I.trackCaret(e.target)},onSelect:e=>I.trackCaret(e.currentTarget),onKeyDown:e=>{I.handleKeyDown(e)},placeholder:m("scheduledTasks.messagePlaceholder"),rows:5,className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring resize-y min-h-[6rem]"}),(0,n.jsx)(i.V,{ac:I,className:"absolute top-full left-0 right-0 mt-1 max-h-48 z-10"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("input",{type:"text",value:j,onChange:e=>w(e.target.value),placeholder:m("scheduledTasks.taskFilePlaceholder"),className:"w-full px-2 py-1.5 text-sm font-mono border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:m("scheduledTasks.taskFileHint")})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:m("scheduledTasks.type")}),(0,n.jsx)("div",{className:"flex gap-1",children:["once","interval","cron"].map(e=>(0,n.jsx)("button",{onClick:()=>{f(e),R(null),y(""),C("")},className:`flex-1 px-2 py-1 text-xs rounded transition-colors ${h===e?"bg-brand text-white":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"once"===e?m("scheduledTasks.once"):"interval"===e?m("scheduledTasks.interval"):"Cron"},e))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:m("scheduledTasks.quickSelect")}),(0,n.jsx)("div",{className:"grid grid-cols-2 gap-1",children:d[h].map(e=>(0,n.jsx)("button",{onClick:()=>{R(e.value),"cron"===h?C(String(e.value)):y(String(e.value))},className:`px-2 py-1 text-xs rounded border transition-colors ${$===e.value?"border-brand bg-brand/10 text-brand":"border-border text-muted-foreground hover:text-foreground hover:border-foreground/30"}`,children:m(e.labelKey)},e.labelKey))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:"cron"===h?m("scheduledTasks.customCron"):m("scheduledTasks.customMinutes")}),"cron"===h?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("input",{type:"text",value:N,onChange:e=>{C(e.target.value),R(null)},placeholder:m("scheduledTasks.cronPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring font-mono"}),N.trim()&&(0,n.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:function(e){let t=a.A.t,r=e.trim().split(/\s+/);if(5!==r.length)return null;let[n,s,o,l,i]=r,d={0:t("cron.dowSun"),1:t("cron.dowMon"),2:t("cron.dowTue"),3:t("cron.dowWed"),4:t("cron.dowThu"),5:t("cron.dowFri"),6:t("cron.dowSat")},c={1:`1${t("cron.monthPrefix")}`,2:`2${t("cron.monthPrefix")}`,3:`3${t("cron.monthPrefix")}`,4:`4${t("cron.monthPrefix")}`,5:`5${t("cron.monthPrefix")}`,6:`6${t("cron.monthPrefix")}`,7:`7${t("cron.monthPrefix")}`,8:`8${t("cron.monthPrefix")}`,9:`9${t("cron.monthPrefix")}`,10:`10${t("cron.monthPrefix")}`,11:`11${t("cron.monthPrefix")}`,12:`12${t("cron.monthPrefix")}`};try{let e="";if(n.includes("/")||s.includes("/")){if("*"===s&&n.includes("/"))return t("cron.everyNMinutes",{n:n.split("/")[1]});if("0"===n&&s.includes("/"))return t("cron.everyNHours",{n:s.split("/")[1]});return null}let r=parseInt(s,10),a=parseInt(n,10);if(isNaN(r)&&"*"!==s||isNaN(a)&&"*"!==n)return null;e="*"===s&&"*"===n?t("cron.everyMinute"):"*"===s?t("cron.everyHourAtMin",{m:a}):"*"===n?t("cron.hourlyEveryMin",{h:r}):`${String(r).padStart(2,"0")}:${String(a).padStart(2,"0")}`;let u=[];if("*"!==l){let e=l.split(",").map(e=>c[e]||`${e}${t("cron.monthPrefix")}`);u.push(e.join(", "))}if("*"!==o)if(o.includes("-")){let[e,r]=o.split("-");u.push(t("cron.dayRange",{a:e,b:r}))}else o.includes(",")?u.push(o.split(",").map(e=>`${e}${t("cron.dayOfMonth")}`).join(", ")):u.push(`${o}${t("cron.dayOfMonth")}`);if("*"!==i)if("1-5"===i)u.push(t("cron.weekdays"));else if("0,6"===i||"6,0"===i)u.push(t("cron.weekends"));else{let e=i.split(",").map(e=>{if(e.includes("-")){let[r,n]=e.split("-");return t("cron.weekdayRange",{a:d[r]||r,b:d[n]||n})}return`${t("cron.weekdayPrefix")}${d[e]||e}`});u.push(e.join(", "))}if(0===u.length&&"*"===o&&"*"===l&&"*"===i)return t("cron.daily",{time:e});return`${u.join(" ")} ${e}`}catch{return null}}(N.trim())||(0,n.jsx)("span",{className:"text-destructive",children:m("scheduledTasks.cronFormat")})})]}):(0,n.jsx)("input",{type:"number",value:k,onChange:e=>{y(e.target.value),R(null)},placeholder:m("scheduledTasks.minutesPlaceholder"),min:1,className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]}),"interval"===h&&(0,n.jsxs)("div",{children:[(0,n.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:P,onChange:e=>T(e.target.checked),className:"rounded border-border"}),m("scheduledTasks.limitTimeRange")]}),P&&(0,n.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,n.jsx)("input",{type:"time",value:S,onChange:e=>L(e.target.value),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:m("scheduledTasks.to")}),(0,n.jsx)("input",{type:"time",value:M,onChange:e=>E(e.target.value),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]})]}),(0,n.jsx)("button",{onClick:D,disabled:!(("file"===b?!!j.trim():!!p.trim())&&("once"===h||"interval"===h?!!($||k&&parseInt(k,10)>0):"cron"===h&&!!($||N.trim()))),className:"w-full py-1.5 text-sm font-medium rounded bg-brand text-white hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:x?m("scheduledTasks.saveBtn",{modKey:(0,l.Mu)()}):m("scheduledTasks.createBtn",{modKey:(0,l.Mu)()})})]})]})}},96472:(e,t,r)=>{r.d(t,{KJ:()=>l,M2:()=>i,ej:()=>a,n8:()=>o});var n=r(49433),s=r(82680);let o=e=>n.tryPromise({try:async()=>{let t=await fetch(`/api/project-state?cwd=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`HTTP ${t.status}`);return await t.json()},catch:e=>new s.uV({message:"loadProjectState failed",cause:e})}),a=e=>n.tryPromise({try:async()=>{let t=await fetch("/api/project-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(`HTTP ${t.status}`)},catch:e=>new s.uV({message:"saveProjectState failed",cause:e})}),l=(e,t,r)=>n.tryPromise({try:async()=>{let n=await fetch("/api/global-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,sessionId:t,status:r})});if(!n.ok)throw Error(`HTTP ${n.status}`)},catch:e=>new s.uV({message:"updateSessionStatus failed",cause:e})}),i=e=>n.tryPromise({try:async()=>{let t=await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"markReadBySessionId",fields:{sessionId:e}})});if(!t.ok)throw Error(`HTTP ${t.status}`)},catch:e=>new s.uV({message:"markScheduledTasksReadBySession failed",cause:e})})},96625:(e,t,r)=>{r.d(t,{V:()=>c,n:()=>d});var n=r(95155),s=r(12115),o=r(79114),a=r(58250),l=r(86957),i=r(83448);function d({value:e,onChange:t,textareaRef:r,extraCommands:n}){let[o,c]=(0,s.useState)(e.length),[u,m]=(0,s.useState)([]),[x,h]=(0,s.useState)([]),[f,p]=(0,s.useState)(0),[g,b]=(0,s.useState)(()=>e.length>0),v=(0,s.useRef)(null);(0,s.useEffect)(()=>{l.t4.runPromiseExit((0,i.M5)()).then(e=>{"Success"===e._tag?m(e.value):console.error("Failed to load commands:",e.cause)})},[]);let j=(0,s.useCallback)(async()=>{let e=await l.t4.runPromiseExit((0,i.l1)());if("Success"===e._tag){let t=e.value.skills??e.value;h((Array.isArray(t)?t:[]).filter(e=>e.valid&&!!e.name).map(e=>({name:`/${e.name}`,description:e.description||"",source:"skill",skillPath:e.path,argumentHint:e.argumentHint})))}else console.error("Failed to load skills:",e.cause)},[]);(0,s.useEffect)(()=>(j(),(0,a.U)(j)),[j]);let w=(0,s.useMemo)(()=>{let t=0===o?0:e.lastIndexOf("\n",o-1)+1,r=e.indexOf("\n",o),n=-1===r?e.length:r;return{text:e.slice(t,n),start:t,end:n}},[e,o]),k=(0,s.useMemo)(()=>{let e=w.text.match(/^\s*([/@])([a-zA-Z0-9-]*)$/);return e?{marker:e[1],verb:e[2].toLowerCase()}:null},[w.text]),y=(0,s.useMemo)(()=>{if(!k)return[];let{verb:e}=k,t=t=>t.name.slice(1).toLowerCase().startsWith(e);return[...(n??[]).filter(t),...u.filter(t),...x.filter(t)]},[k,n,u,x]),N=!g&&!!k&&y.length>0,C=(0,s.useRef)(e);(0,s.useLayoutEffect)(()=>{C.current!==e&&(queueMicrotask(()=>p(0)),g&&queueMicrotask(()=>b(!1)),C.current=e)},[e,g]),(0,s.useLayoutEffect)(()=>{if(N&&v.current){let e=v.current.children[f];e&&e.scrollIntoView({block:"nearest"})}},[f,N]);let S=(0,s.useCallback)(e=>{c(e.selectionStart??0)},[]),L=(0,s.useCallback)(n=>{let s=k?.marker??"/",o=`${s}${n.name.slice(1)} `,a=e.slice(0,w.start),l=e.slice(w.end),i=a.length+o.length;t(a+o+l),c(i),requestAnimationFrame(()=>{let e=r.current;e&&(e.focus(),e.setSelectionRange(i,i))})},[e,w,k,t,r]),M=(0,s.useCallback)(e=>{if(e.nativeEvent.isComposing||!N||0===y.length)return!1;let t=()=>{e.preventDefault(),e.stopPropagation()};return"ArrowDown"===e.key?(t(),p(e=>(e+1)%y.length),!0):"ArrowUp"===e.key?(t(),p(e=>(e-1+y.length)%y.length),!0):"Enter"===e.key||"Tab"===e.key?(t(),L(y[f]),!0):"Escape"===e.key&&(t(),b(!0),!0)},[N,y,f,L]);return{isOpen:N,items:y,selectedIndex:f,marker:k?.marker??"/",listRef:v,selectCommand:L,handleKeyDown:M,trackCaret:S}}function c({ac:e,className:t=""}){let{t:r}=(0,o.Bd)(),{isOpen:s,items:a,selectedIndex:l,marker:i,listRef:d,selectCommand:u}=e;return s&&0!==a.length?(0,n.jsx)("div",{ref:d,className:`overflow-y-auto bg-card border border-border rounded-lg shadow-lv2 ${t}`,children:a.map((e,t)=>{let s=t>0?a[t-1]:null,o="skill"===e.source&&(!s||"skill"!==s.source),d="skill"!==e.source&&0===t;return(0,n.jsxs)("div",{children:[d&&(0,n.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Commands"}),o&&(0,n.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Skills"}),(0,n.jsxs)("div",{onClick:()=>u(e),className:`px-4 py-2 cursor-pointer ${t===l?"bg-brand/10":"hover:bg-hover"}`,children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("span",{className:"font-mono text-sm font-medium text-foreground",children:i+e.name.slice(1)}),(0,n.jsx)("span",{className:"flex-1 text-sm text-muted-foreground truncate",children:"builtin"===e.source?r(`commands.${e.name.slice(1)}`,{defaultValue:e.description}):e.description}),(0,n.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${(e=>{switch(e){case"builtin":return"bg-brand/15 text-brand dark:bg-brand/25 dark:text-teal-11";case"skill":return"bg-purple-9/15 text-purple-11 dark:bg-purple-9/25 dark:text-purple-11"}})(e.source)}`,children:(e=>{switch(e){case"builtin":return r("common.builtin");case"skill":return"Skill"}})(e.source)})]}),"skill"===e.source&&e.argumentHint&&(0,n.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 pl-0 truncate",children:e.argumentHint})]})]},e.name)})}):null}}}]);
|