@surething/cockpit 1.0.175
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 -0
- package/.next-prod/app-path-routes-manifest.json +99 -0
- package/.next-prod/build-manifest.json +20 -0
- package/.next-prod/diagnostics/build-diagnostics.json +6 -0
- package/.next-prod/diagnostics/framework.json +1 -0
- package/.next-prod/export-marker.json +6 -0
- package/.next-prod/images-manifest.json +67 -0
- package/.next-prod/next-minimal-server.js.nft.json +1 -0
- package/.next-prod/next-server.js.nft.json +1 -0
- package/.next-prod/package.json +1 -0
- package/.next-prod/prerender-manifest.json +119 -0
- package/.next-prod/react-loadable-manifest.json +4241 -0
- package/.next-prod/required-server-files.js +326 -0
- package/.next-prod/required-server-files.json +326 -0
- package/.next-prod/routes-manifest.json +641 -0
- package/.next-prod/server/app/_global-error/page.js +3 -0
- package/.next-prod/server/app/_global-error/page.js.nft.json +1 -0
- package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/_global-error.html +2 -0
- package/.next-prod/server/app/_global-error.meta +16 -0
- package/.next-prod/server/app/_global-error.rsc +12 -0
- package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +12 -0
- package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +5 -0
- package/.next-prod/server/app/_global-error.segments/_global-error.segment.rsc +4 -0
- package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +5 -0
- package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +4 -0
- package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -0
- package/.next-prod/server/app/_not-found/page.js +2 -0
- package/.next-prod/server/app/_not-found/page.js.nft.json +1 -0
- package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/_not-found.html +18 -0
- package/.next-prod/server/app/_not-found.meta +16 -0
- package/.next-prod/server/app/_not-found.rsc +18 -0
- package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +18 -0
- package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +6 -0
- package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +6 -0
- package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -0
- package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +4 -0
- package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +5 -0
- package/.next-prod/server/app/api/bash/route.js +1 -0
- package/.next-prod/server/app/api/bash/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/bash/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/chat/route.js +5 -0
- package/.next-prod/server/app/api/chat/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/chat/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/claude-stats/route.js +1 -0
- package/.next-prod/server/app/api/claude-stats/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/claude-stats/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/commands/route.js +1 -0
- package/.next-prod/server/app/api/commands/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/commands/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/comments/route.js +1 -0
- package/.next-prod/server/app/api/comments/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/comments/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/db/columns/route.js +15 -0
- package/.next-prod/server/app/api/db/columns/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/db/columns/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/db/connect/route.js +1 -0
- package/.next-prod/server/app/api/db/connect/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/db/connect/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/db/disconnect/route.js +1 -0
- package/.next-prod/server/app/api/db/disconnect/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/db/disconnect/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/db/export/route.js +1 -0
- package/.next-prod/server/app/api/db/export/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/db/export/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/db/query/route.js +1 -0
- package/.next-prod/server/app/api/db/query/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/db/query/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/db/schemas/route.js +8 -0
- package/.next-prod/server/app/api/db/schemas/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/db/schemas/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/extension/version/route.js +1 -0
- package/.next-prod/server/app/api/extension/version/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/extension/version/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/file/route.js +1 -0
- package/.next-prod/server/app/api/file/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/file/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/blame/route.js +1 -0
- package/.next-prod/server/app/api/files/blame/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/blame/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/clipboard/route.js +1 -0
- package/.next-prod/server/app/api/files/clipboard/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/clipboard/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/copy/route.js +1 -0
- package/.next-prod/server/app/api/files/copy/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/copy/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/delete/route.js +1 -0
- package/.next-prod/server/app/api/files/delete/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/delete/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/expanded/route.js +1 -0
- package/.next-prod/server/app/api/files/expanded/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/expanded/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/index/route.js +1 -0
- package/.next-prod/server/app/api/files/index/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/index/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/init/route.js +1 -0
- package/.next-prod/server/app/api/files/init/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/init/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/paste/route.js +1 -0
- package/.next-prod/server/app/api/files/paste/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/paste/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/read/route.js +1 -0
- package/.next-prod/server/app/api/files/read/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/read/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/readdir/route.js +1 -0
- package/.next-prod/server/app/api/files/readdir/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/readdir/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/recent/route.js +1 -0
- package/.next-prod/server/app/api/files/recent/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/recent/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/save/route.js +1 -0
- package/.next-prod/server/app/api/files/save/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/save/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/files/search/route.js +1 -0
- package/.next-prod/server/app/api/files/search/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/files/search/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/git/branch-diff/route.js +1 -0
- package/.next-prod/server/app/api/git/branch-diff/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/git/branch-diff/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/git/branches/route.js +1 -0
- package/.next-prod/server/app/api/git/branches/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/git/branches/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/git/commit-diff/route.js +1 -0
- package/.next-prod/server/app/api/git/commit-diff/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/git/commit-diff/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/git/commits/route.js +1 -0
- package/.next-prod/server/app/api/git/commits/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/git/commits/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/git/diff/route.js +1 -0
- package/.next-prod/server/app/api/git/diff/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/git/diff/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/git/discard/route.js +1 -0
- package/.next-prod/server/app/api/git/discard/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/git/discard/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/git/stage/route.js +1 -0
- package/.next-prod/server/app/api/git/stage/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/git/stage/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/git/status/route.js +1 -0
- package/.next-prod/server/app/api/git/status/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/git/status/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/git/unstage/route.js +1 -0
- package/.next-prod/server/app/api/git/unstage/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/git/unstage/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/git/worktree/route.js +1 -0
- package/.next-prod/server/app/api/git/worktree/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/git/worktree/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/global-state/route.js +1 -0
- package/.next-prod/server/app/api/global-state/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/global-state/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/jupyter/load/route.js +1 -0
- package/.next-prod/server/app/api/jupyter/load/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/jupyter/load/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/jupyter/save/route.js +1 -0
- package/.next-prod/server/app/api/jupyter/save/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/jupyter/save/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/jupyter/shutdown/route.js +1 -0
- package/.next-prod/server/app/api/jupyter/shutdown/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/jupyter/shutdown/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/lsp/definition/route.js +1 -0
- package/.next-prod/server/app/api/lsp/definition/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/lsp/definition/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/lsp/hover/route.js +1 -0
- package/.next-prod/server/app/api/lsp/hover/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/lsp/hover/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/lsp/references/route.js +1 -0
- package/.next-prod/server/app/api/lsp/references/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/lsp/references/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/lsp/status/route.js +1 -0
- package/.next-prod/server/app/api/lsp/status/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/lsp/status/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/lsp/warmup/route.js +1 -0
- package/.next-prod/server/app/api/lsp/warmup/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/lsp/warmup/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/mysql/columns/route.js +9 -0
- package/.next-prod/server/app/api/mysql/columns/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/mysql/columns/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/mysql/connect/route.js +1 -0
- package/.next-prod/server/app/api/mysql/connect/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/mysql/connect/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/mysql/disconnect/route.js +1 -0
- package/.next-prod/server/app/api/mysql/disconnect/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/mysql/disconnect/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/mysql/export/route.js +1 -0
- package/.next-prod/server/app/api/mysql/export/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/mysql/export/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/mysql/query/route.js +1 -0
- package/.next-prod/server/app/api/mysql/query/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/mysql/query/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/mysql/schemas/route.js +6 -0
- package/.next-prod/server/app/api/mysql/schemas/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/mysql/schemas/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/note/route.js +1 -0
- package/.next-prod/server/app/api/note/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/note/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/open-cursor/route.js +1 -0
- package/.next-prod/server/app/api/open-cursor/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/open-cursor/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/open-vscode/route.js +1 -0
- package/.next-prod/server/app/api/open-vscode/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/open-vscode/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/pick-folder/route.js +1 -0
- package/.next-prod/server/app/api/pick-folder/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/pick-folder/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/pinned-sessions/route.js +1 -0
- package/.next-prod/server/app/api/pinned-sessions/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/pinned-sessions/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/project-settings/route.js +1 -0
- package/.next-prod/server/app/api/project-settings/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/project-settings/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/project-state/route.js +1 -0
- package/.next-prod/server/app/api/project-state/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/project-state/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/projects/route.js +1 -0
- package/.next-prod/server/app/api/projects/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/projects/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/redis/command/route.js +1 -0
- package/.next-prod/server/app/api/redis/command/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/redis/command/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/redis/connect/route.js +1 -0
- package/.next-prod/server/app/api/redis/connect/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/redis/connect/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/redis/delete/route.js +1 -0
- package/.next-prod/server/app/api/redis/delete/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/redis/delete/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/redis/disconnect/route.js +1 -0
- package/.next-prod/server/app/api/redis/disconnect/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/redis/disconnect/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/redis/get/route.js +1 -0
- package/.next-prod/server/app/api/redis/get/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/redis/get/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/redis/keys/route.js +1 -0
- package/.next-prod/server/app/api/redis/keys/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/redis/keys/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/redis/set/route.js +1 -0
- package/.next-prod/server/app/api/redis/set/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/redis/set/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/review/[id]/comments/route.js +1 -0
- package/.next-prod/server/app/api/review/[id]/comments/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/review/[id]/comments/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/review/[id]/replies/route.js +1 -0
- package/.next-prod/server/app/api/review/[id]/replies/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/review/[id]/replies/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/review/[id]/route.js +1 -0
- package/.next-prod/server/app/api/review/[id]/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/review/[id]/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/review/identify/route.js +1 -0
- package/.next-prod/server/app/api/review/identify/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/review/identify/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/review/order/route.js +1 -0
- package/.next-prod/server/app/api/review/order/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/review/order/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/review/route.js +1 -0
- package/.next-prod/server/app/api/review/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/review/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/review/share-info/route.js +1 -0
- package/.next-prod/server/app/api/review/share-info/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/review/share-info/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/review/users/route.js +1 -0
- package/.next-prod/server/app/api/review/users/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/review/users/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/scheduled-tasks/route.js +1 -0
- package/.next-prod/server/app/api/scheduled-tasks/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/scheduled-tasks/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/services/config/route.js +1 -0
- package/.next-prod/server/app/api/services/config/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/services/config/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/services/scripts/route.js +1 -0
- package/.next-prod/server/app/api/services/scripts/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/services/scripts/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -0
- package/.next-prod/server/app/api/session/[sessionId]/fork/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/session/[sessionId]/fork/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -0
- package/.next-prod/server/app/api/session/[sessionId]/history/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/session/[sessionId]/history/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/session-by-path/route.js +1 -0
- package/.next-prod/server/app/api/session-by-path/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/session-by-path/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js +1 -0
- package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/sessions/projects/route.js +1 -0
- package/.next-prod/server/app/api/sessions/projects/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/sessions/projects/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/sessions/route.js +1 -0
- package/.next-prod/server/app/api/sessions/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/sessions/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/settings/route.js +1 -0
- package/.next-prod/server/app/api/settings/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/settings/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/terminal/aliases/route.js +1 -0
- package/.next-prod/server/app/api/terminal/aliases/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/terminal/aliases/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/terminal/autocomplete/route.js +1 -0
- package/.next-prod/server/app/api/terminal/autocomplete/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/terminal/autocomplete/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/terminal/bubble-order/route.js +1 -0
- package/.next-prod/server/app/api/terminal/bubble-order/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/terminal/bubble-order/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/terminal/env/route.js +1 -0
- package/.next-prod/server/app/api/terminal/env/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/terminal/env/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/terminal/history/route.js +1 -0
- package/.next-prod/server/app/api/terminal/history/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/terminal/history/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/version/route.js +1 -0
- package/.next-prod/server/app/api/version/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/version/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/favicon.ico/route.js +1 -0
- package/.next-prod/server/app/favicon.ico/route.js.nft.json +1 -0
- package/.next-prod/server/app/favicon.ico.body +0 -0
- package/.next-prod/server/app/favicon.ico.meta +1 -0
- package/.next-prod/server/app/manifest.webmanifest/route.js +16 -0
- package/.next-prod/server/app/manifest.webmanifest/route.js.nft.json +1 -0
- package/.next-prod/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/manifest.webmanifest.body +1 -0
- package/.next-prod/server/app/manifest.webmanifest.meta +1 -0
- package/.next-prod/server/app/page.js +97 -0
- package/.next-prod/server/app/page.js.nft.json +1 -0
- package/.next-prod/server/app/page_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/project/page.js +29 -0
- package/.next-prod/server/app/project/page.js.nft.json +1 -0
- package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/review/[id]/page.js +2 -0
- package/.next-prod/server/app/review/[id]/page.js.nft.json +1 -0
- package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -0
- package/.next-prod/server/app-paths-manifest.json +99 -0
- package/.next-prod/server/chunks/1639.js +1 -0
- package/.next-prod/server/chunks/1667.js +1 -0
- package/.next-prod/server/chunks/1813.js +1 -0
- package/.next-prod/server/chunks/1912.js +1 -0
- package/.next-prod/server/chunks/2325.js +82 -0
- package/.next-prod/server/chunks/2376.js +36 -0
- package/.next-prod/server/chunks/2816.js +1 -0
- package/.next-prod/server/chunks/2840.js +62 -0
- package/.next-prod/server/chunks/3434.js +1 -0
- package/.next-prod/server/chunks/3441.js +24 -0
- package/.next-prod/server/chunks/3503.js +29 -0
- package/.next-prod/server/chunks/3863.js +1 -0
- package/.next-prod/server/chunks/3932.js +56 -0
- package/.next-prod/server/chunks/4042.js +1 -0
- package/.next-prod/server/chunks/4073.js +1 -0
- package/.next-prod/server/chunks/4097.js +136 -0
- package/.next-prod/server/chunks/4098.js +1 -0
- package/.next-prod/server/chunks/4268.js +4 -0
- package/.next-prod/server/chunks/4272.js +5 -0
- package/.next-prod/server/chunks/4309.js +141 -0
- package/.next-prod/server/chunks/4345.js +1 -0
- package/.next-prod/server/chunks/4367.js +1 -0
- package/.next-prod/server/chunks/4388.js +24 -0
- package/.next-prod/server/chunks/4442.js +1 -0
- package/.next-prod/server/chunks/4490.js +26 -0
- package/.next-prod/server/chunks/4741.js +22 -0
- package/.next-prod/server/chunks/4793.js +1 -0
- package/.next-prod/server/chunks/5152.js +1 -0
- package/.next-prod/server/chunks/5460.js +201 -0
- package/.next-prod/server/chunks/5481.js +1 -0
- package/.next-prod/server/chunks/5536.js +148 -0
- package/.next-prod/server/chunks/5733.js +5 -0
- package/.next-prod/server/chunks/582.js +1 -0
- package/.next-prod/server/chunks/5958.js +1 -0
- package/.next-prod/server/chunks/6062.js +1 -0
- package/.next-prod/server/chunks/6117.js +13 -0
- package/.next-prod/server/chunks/6142.js +287 -0
- package/.next-prod/server/chunks/6346.js +1 -0
- package/.next-prod/server/chunks/6443.js +1 -0
- package/.next-prod/server/chunks/6804.js +43 -0
- package/.next-prod/server/chunks/7265.js +93 -0
- package/.next-prod/server/chunks/7284.js +1 -0
- package/.next-prod/server/chunks/7307.js +1 -0
- package/.next-prod/server/chunks/7483.js +1 -0
- package/.next-prod/server/chunks/7484.js +64 -0
- package/.next-prod/server/chunks/7514.js +31 -0
- package/.next-prod/server/chunks/7800.js +166 -0
- package/.next-prod/server/chunks/8068.js +63 -0
- package/.next-prod/server/chunks/8351.js +23 -0
- package/.next-prod/server/chunks/8491.js +5 -0
- package/.next-prod/server/chunks/8585.js +198 -0
- package/.next-prod/server/chunks/887.js +215 -0
- package/.next-prod/server/chunks/911.js +1 -0
- package/.next-prod/server/chunks/9116.js +65 -0
- package/.next-prod/server/chunks/925.js +68 -0
- package/.next-prod/server/chunks/9298.js +139 -0
- package/.next-prod/server/chunks/9401.js +1 -0
- package/.next-prod/server/chunks/9408.js +1 -0
- package/.next-prod/server/functions-config-manifest.json +24 -0
- package/.next-prod/server/interception-route-rewrite-manifest.js +1 -0
- package/.next-prod/server/middleware-build-manifest.js +1 -0
- package/.next-prod/server/middleware-manifest.json +6 -0
- package/.next-prod/server/middleware-react-loadable-manifest.js +1 -0
- package/.next-prod/server/next-font-manifest.js +1 -0
- package/.next-prod/server/next-font-manifest.json +1 -0
- package/.next-prod/server/pages/404.html +18 -0
- package/.next-prod/server/pages/500.html +2 -0
- package/.next-prod/server/pages-manifest.json +4 -0
- package/.next-prod/server/server-reference-manifest.js +1 -0
- package/.next-prod/server/server-reference-manifest.json +1 -0
- package/.next-prod/server/webpack-runtime.js +1 -0
- package/.next-prod/static/DV3WCL3Yj_UIBxTQ3r93N/_buildManifest.js +1 -0
- package/.next-prod/static/DV3WCL3Yj_UIBxTQ3r93N/_ssgManifest.js +1 -0
- package/.next-prod/static/chunks/10.6cf001c181ce1098.js +1 -0
- package/.next-prod/static/chunks/1078.02294b2934d5bf21.js +1 -0
- package/.next-prod/static/chunks/1142.17e45d200709420d.js +1 -0
- package/.next-prod/static/chunks/1161.06b33878b495da50.js +1 -0
- package/.next-prod/static/chunks/1184.e80a999422621ed9.js +1 -0
- package/.next-prod/static/chunks/1188.1d4ce94ddc297119.js +1 -0
- package/.next-prod/static/chunks/1198.2a5c215f01a8b74d.js +1 -0
- package/.next-prod/static/chunks/1215.88ed89521e915107.js +1 -0
- package/.next-prod/static/chunks/1219.e27b0bd10b029e40.js +1 -0
- package/.next-prod/static/chunks/123.d6fe9c2353baf42b.js +1 -0
- package/.next-prod/static/chunks/1247.64e212daa5bb3925.js +1 -0
- package/.next-prod/static/chunks/1248.36af3903f037c1f5.js +1 -0
- package/.next-prod/static/chunks/1274.ce6906b1fe2e04b8.js +1 -0
- package/.next-prod/static/chunks/1280.1651bb5167170457.js +1 -0
- package/.next-prod/static/chunks/1310.c38c5fbf05820fcd.js +166 -0
- package/.next-prod/static/chunks/1335.716cc5924662708e.js +1 -0
- package/.next-prod/static/chunks/1365.d7391145ca7f8791.js +1 -0
- package/.next-prod/static/chunks/1379.03e1e0f31bdaa2cc.js +1 -0
- package/.next-prod/static/chunks/1409.9f81cd6d2cab4b67.js +1 -0
- package/.next-prod/static/chunks/1413.117c5958c59cc695.js +1 -0
- package/.next-prod/static/chunks/142.e09e154342f02da4.js +4 -0
- package/.next-prod/static/chunks/1453.3c24c777a3deca2d.js +1 -0
- package/.next-prod/static/chunks/1456.a1f849b334fff0da.js +1 -0
- package/.next-prod/static/chunks/1501.549af2c91a889a08.js +1 -0
- package/.next-prod/static/chunks/1534.918a25b2e3daab22.js +1 -0
- package/.next-prod/static/chunks/1556.96abc9ff91b0c383.js +1 -0
- package/.next-prod/static/chunks/1583.03a06dbdde85ac56.js +1 -0
- package/.next-prod/static/chunks/1590.05549e036336164c.js +65 -0
- package/.next-prod/static/chunks/1593-7902218f5b10761f.js +1 -0
- package/.next-prod/static/chunks/1595.ee61519fde230f60.js +1 -0
- package/.next-prod/static/chunks/1656.a9efc78185a5a85f.js +1 -0
- package/.next-prod/static/chunks/1664.6d5b5e3112b66906.js +1 -0
- package/.next-prod/static/chunks/1898.e07b2b1c5e789b06.js +1 -0
- package/.next-prod/static/chunks/1932.b0aea9b52cabe5e8.js +1 -0
- package/.next-prod/static/chunks/194.dace825a3ddbbbff.js +1 -0
- package/.next-prod/static/chunks/1948.bf7e0d9ede202530.js +29 -0
- package/.next-prod/static/chunks/1977.a06c8e8d2198f765.js +1 -0
- package/.next-prod/static/chunks/1987.226da043eabc8911.js +5 -0
- package/.next-prod/static/chunks/1991.d869abe5092c9011.js +1 -0
- package/.next-prod/static/chunks/1cd6e1d3.8121a74b2042bff3.js +1 -0
- package/.next-prod/static/chunks/2013.598558c40e51e107.js +1 -0
- package/.next-prod/static/chunks/2020.46a0112747939389.js +1 -0
- package/.next-prod/static/chunks/2031.3877441c49bff5cd.js +1 -0
- package/.next-prod/static/chunks/2041.00f4fa0ab26c6ba5.js +1 -0
- package/.next-prod/static/chunks/2062.4a0ab3400fea0e34.js +1 -0
- package/.next-prod/static/chunks/2072-37a80cb92f1ee2d4.js +4 -0
- package/.next-prod/static/chunks/2107.c627112b02b9e1c8.js +1 -0
- package/.next-prod/static/chunks/2130.441ae0f68863efeb.js +1 -0
- package/.next-prod/static/chunks/214.f6bba63dfa159e01.js +1 -0
- package/.next-prod/static/chunks/2160.e38d781fd5c4cde0.js +1 -0
- package/.next-prod/static/chunks/2179.1bf5fe315e6e132c.js +1 -0
- package/.next-prod/static/chunks/2215.9d2d6fbe90ffcc80.js +1 -0
- package/.next-prod/static/chunks/2235.b4453110c06e2b09.js +1 -0
- package/.next-prod/static/chunks/2349.ca15d465c4260b4b.js +1 -0
- package/.next-prod/static/chunks/2374.7560cc5c4b8ed6b0.js +1 -0
- package/.next-prod/static/chunks/2403.3dda71b6482dce3b.js +1 -0
- package/.next-prod/static/chunks/2485.3188870375e9fbee.js +1 -0
- package/.next-prod/static/chunks/2489.fcc70bd67329a70e.js +1 -0
- package/.next-prod/static/chunks/2501.4e65b56602faa956.js +1 -0
- package/.next-prod/static/chunks/2503.bb9d3528c3c7ccae.js +1 -0
- package/.next-prod/static/chunks/252.a9e22657cbf67b42.js +1 -0
- package/.next-prod/static/chunks/254.8b4308512ac955b5.js +24 -0
- package/.next-prod/static/chunks/2614.8349e4b407470a30.js +1 -0
- package/.next-prod/static/chunks/2710.fe0656d4ebae4d30.js +1 -0
- package/.next-prod/static/chunks/2728.5fed9ac13dfcd1d1.js +1 -0
- package/.next-prod/static/chunks/2729.826909b4d5229ba6.js +68 -0
- package/.next-prod/static/chunks/2735.5a3e65a580bd5af9.js +1 -0
- package/.next-prod/static/chunks/2747.1d85d388314f2904.js +1 -0
- package/.next-prod/static/chunks/2765.2c6d9772af50feed.js +1 -0
- package/.next-prod/static/chunks/2783.e8bbf2c794ef9750.js +1 -0
- package/.next-prod/static/chunks/2812.dcd8179a6b1d76c9.js +1 -0
- package/.next-prod/static/chunks/2821.fa74c6e87f6e759a.js +1 -0
- package/.next-prod/static/chunks/2839.a832cb0d77a9d298.js +1 -0
- package/.next-prod/static/chunks/2895.0339e755e79ee794.js +1 -0
- package/.next-prod/static/chunks/2921.26016c4c7eb031e8.js +1 -0
- package/.next-prod/static/chunks/2954.7d8daeae6410d4a4.js +1 -0
- package/.next-prod/static/chunks/2964.1a0e15f7327680a2.js +1 -0
- package/.next-prod/static/chunks/2ff9d716.93c18c265de76cfb.js +136 -0
- package/.next-prod/static/chunks/305-fced91c3443b6178.js +1 -0
- package/.next-prod/static/chunks/3072.b6da96c10080c967.js +1 -0
- package/.next-prod/static/chunks/3074.911584369786c26c.js +1 -0
- package/.next-prod/static/chunks/3077.bf82c0c332cc9fec.js +1 -0
- package/.next-prod/static/chunks/3082.159e4ab8f0572597.js +1 -0
- package/.next-prod/static/chunks/3095.8cd478c42cee505a.js +1 -0
- package/.next-prod/static/chunks/3111.1cf85db2faeb20cc.js +1 -0
- package/.next-prod/static/chunks/3126.c89ab7ce8e10978e.js +1 -0
- package/.next-prod/static/chunks/3175.538ce7aec634bddb.js +1 -0
- package/.next-prod/static/chunks/3186.3665756f8aae3eb7.js +1 -0
- package/.next-prod/static/chunks/3194.5a331fb5e3dc34e9.js +1 -0
- package/.next-prod/static/chunks/3229.5e91f7d0b135266b.js +1 -0
- package/.next-prod/static/chunks/327.8ecab0b86d52b597.js +1 -0
- package/.next-prod/static/chunks/3274.858f7f9216c8b074.js +1 -0
- package/.next-prod/static/chunks/3286.196c508356bb0b66.js +1 -0
- package/.next-prod/static/chunks/3288.f210cd6796271d4f.js +1 -0
- package/.next-prod/static/chunks/3290.b5ba2646ad49c9fd.js +1 -0
- package/.next-prod/static/chunks/3304.16305e84f4ff6598.js +1 -0
- package/.next-prod/static/chunks/3313.471138e5504646a9.js +1 -0
- package/.next-prod/static/chunks/3324.85e21e3313d0901c.js +1 -0
- package/.next-prod/static/chunks/3392.460f5a753531f501.js +1 -0
- package/.next-prod/static/chunks/34.ce581867cf95e24b.js +1 -0
- package/.next-prod/static/chunks/3419.78b520dab7e2f96d.js +1 -0
- package/.next-prod/static/chunks/3437.0ad1ecc8c5b8a679.js +1 -0
- package/.next-prod/static/chunks/3476.246c30b47bded3b7.js +1 -0
- package/.next-prod/static/chunks/3483.fc2a0b1185dbaa5d.js +1 -0
- package/.next-prod/static/chunks/3492.ca55498822ad7796.js +1 -0
- package/.next-prod/static/chunks/3530-6d8abfd0e950d439.js +14 -0
- package/.next-prod/static/chunks/36.b4a553bf2106f6d3.js +1 -0
- package/.next-prod/static/chunks/3613.9a37e282a0b018d7.js +1 -0
- package/.next-prod/static/chunks/3682.d8c0079db560c625.js +1 -0
- package/.next-prod/static/chunks/3695-f14fb3e48483755c.js +18 -0
- package/.next-prod/static/chunks/376.9e742ff6919b2b54.js +1 -0
- package/.next-prod/static/chunks/3782.8de9ba0149339c0c.js +1 -0
- package/.next-prod/static/chunks/3787.78ebe68a043f50ce.js +1 -0
- package/.next-prod/static/chunks/3794-337d1ca25ad99a89.js +2 -0
- package/.next-prod/static/chunks/3860.be5b243bf7d6618c.js +1 -0
- package/.next-prod/static/chunks/3873.72a9a21509f713f7.js +1 -0
- package/.next-prod/static/chunks/392.3cad93691f1b7360.js +1 -0
- package/.next-prod/static/chunks/3942.00e2e29e2d62b039.js +1 -0
- package/.next-prod/static/chunks/3979.cea8623f6e9f83ea.js +1 -0
- package/.next-prod/static/chunks/400.59979e0d3ae126e4.js +1 -0
- package/.next-prod/static/chunks/4053.90d71fcbe4ffd852.js +1 -0
- package/.next-prod/static/chunks/4080.08a21dae9e93c547.js +1 -0
- package/.next-prod/static/chunks/4163.c6ebefdd9aa5c358.js +1 -0
- package/.next-prod/static/chunks/4174.9e84de8f8816fe01.js +1 -0
- package/.next-prod/static/chunks/4223.c10556cd92fc8018.js +1 -0
- package/.next-prod/static/chunks/4240-38a224bd376cc8a0.js +1 -0
- package/.next-prod/static/chunks/4242.3a66c58375424a5b.js +1 -0
- package/.next-prod/static/chunks/425.9a3434a28926566a.js +1 -0
- package/.next-prod/static/chunks/4275.8f2e531757c2a813.js +1 -0
- package/.next-prod/static/chunks/4295.6c0f4838b0c9c69d.js +1 -0
- package/.next-prod/static/chunks/4309.a887a10e84c44f9e.js +1 -0
- package/.next-prod/static/chunks/4350.b9d80827e8eee01a.js +1 -0
- package/.next-prod/static/chunks/4357.05060a5a3fea9ff1.js +1 -0
- package/.next-prod/static/chunks/4358.f15dd467571f7594.js +1 -0
- package/.next-prod/static/chunks/4367.2610339aa03a9fb3.js +1 -0
- package/.next-prod/static/chunks/4370.ac13b62c811f7ede.js +1 -0
- package/.next-prod/static/chunks/4402d2ac.d0d1b1777a45e0b2.js +1 -0
- package/.next-prod/static/chunks/4474.053807fa34066566.js +1 -0
- package/.next-prod/static/chunks/4539.559c223da16b0282.js +1 -0
- package/.next-prod/static/chunks/4540.03df20c499bca840.js +1 -0
- package/.next-prod/static/chunks/4553.a16dba8d6d03226c.js +1 -0
- package/.next-prod/static/chunks/4567.d405b50b917bd2c2.js +1 -0
- package/.next-prod/static/chunks/4583.2a5df6eb3a6ea30b.js +1 -0
- package/.next-prod/static/chunks/4593.676ac488744e1af5.js +1 -0
- package/.next-prod/static/chunks/4608.1ff246d6b4c771f8.js +1 -0
- package/.next-prod/static/chunks/4634.0332a56fdb8e26c0.js +1 -0
- package/.next-prod/static/chunks/4650.61aec912b756287b.js +1 -0
- package/.next-prod/static/chunks/4659.b8e05ba7cbf46556.js +1 -0
- package/.next-prod/static/chunks/4678.867dfae26694be02.js +1 -0
- package/.next-prod/static/chunks/4699.8603b2742a761084.js +1 -0
- package/.next-prod/static/chunks/4823.907850963b2bcb70.js +1 -0
- package/.next-prod/static/chunks/4829.402ec60139d36417.js +1 -0
- package/.next-prod/static/chunks/4892.1674cc00200143ba.js +1 -0
- package/.next-prod/static/chunks/4900.b723a916eafdf743.js +1 -0
- package/.next-prod/static/chunks/4903.004f583a12223dac.js +1 -0
- package/.next-prod/static/chunks/4963.0f6678151a159143.js +1 -0
- package/.next-prod/static/chunks/4969.1cb10af9489ea295.js +1 -0
- package/.next-prod/static/chunks/4976.8870319ffbd1c31f.js +1 -0
- package/.next-prod/static/chunks/4bd1b696-e5d7c65570c947b7.js +1 -0
- package/.next-prod/static/chunks/4ca0cff5.07efe2bc8f09d72e.js +1 -0
- package/.next-prod/static/chunks/5005.cf839e066f3d3efe.js +1 -0
- package/.next-prod/static/chunks/5019.2906d96e77b98f68.js +198 -0
- package/.next-prod/static/chunks/5025.b597364f0cf8b85a.js +1 -0
- package/.next-prod/static/chunks/5061.025d30c3123eeaf6.js +1 -0
- package/.next-prod/static/chunks/5136.ac897c2a56ee392f.js +1 -0
- package/.next-prod/static/chunks/5139.83dc2c84aeea716b.js +63 -0
- package/.next-prod/static/chunks/5183.2e5c895a2be76262.js +1 -0
- package/.next-prod/static/chunks/5199.5faac6a2cc104a4c.js +36 -0
- package/.next-prod/static/chunks/5269.25d99df0164521ad.js +23 -0
- package/.next-prod/static/chunks/5318.d48b9096df0171df.js +1 -0
- package/.next-prod/static/chunks/5320.191be461ff110fb3.js +1 -0
- package/.next-prod/static/chunks/5325.aad15a16a5d57787.js +1 -0
- package/.next-prod/static/chunks/5331.4d5d42e5253dbee2.js +1 -0
- package/.next-prod/static/chunks/5338.76f7773c317f3142.js +1 -0
- package/.next-prod/static/chunks/5347.3192e0021174aaa8.js +1 -0
- package/.next-prod/static/chunks/5364.2e5ba480c24d7854.js +148 -0
- package/.next-prod/static/chunks/5375.ebc026e6140b52f1.js +1 -0
- package/.next-prod/static/chunks/5394.9d260f733e336357.js +287 -0
- package/.next-prod/static/chunks/53c1bd3f.2911e2bac119d910.js +1 -0
- package/.next-prod/static/chunks/541.cfa15b606745131a.js +1 -0
- package/.next-prod/static/chunks/5424.4d62f7ee887cd8b9.js +1 -0
- package/.next-prod/static/chunks/5482.0907421e6bf5eeec.js +1 -0
- package/.next-prod/static/chunks/5491.5cc285c4b84dac30.js +1 -0
- package/.next-prod/static/chunks/5493-9f80ad2c7c9cf840.js +1 -0
- package/.next-prod/static/chunks/5498.fa0a196807d6cd2f.js +1 -0
- package/.next-prod/static/chunks/54a60aa6-f60235f3d6b54466.js +79 -0
- package/.next-prod/static/chunks/5518.6c3dc9afe81a566b.js +1 -0
- package/.next-prod/static/chunks/5520.eab85d7487e77510.js +1 -0
- package/.next-prod/static/chunks/5553.75df19e3cc1246d6.js +1 -0
- package/.next-prod/static/chunks/5575.3d90c643343a1329.js +1 -0
- package/.next-prod/static/chunks/5645.9002948124d25d41.js +1 -0
- package/.next-prod/static/chunks/5670.2a1b27a6fdb7aa6b.js +1 -0
- package/.next-prod/static/chunks/5690.d30877807cf5c7eb.js +1 -0
- package/.next-prod/static/chunks/570e4624.a82467c542429379.js +1 -0
- package/.next-prod/static/chunks/5712.574fca2d5f06483a.js +1 -0
- package/.next-prod/static/chunks/5728.8ef773d61765855e.js +1 -0
- package/.next-prod/static/chunks/5750.aa57d25b74640d23.js +1 -0
- package/.next-prod/static/chunks/5755.00015c284ed6fb39.js +1 -0
- package/.next-prod/static/chunks/5788.e5d5040b65e5edf3.js +1 -0
- package/.next-prod/static/chunks/579.33fc87fb95163c6a.js +1 -0
- package/.next-prod/static/chunks/583.5061a2f9e7b7e97d.js +1 -0
- package/.next-prod/static/chunks/5920.9db223329ee9e11a.js +1 -0
- package/.next-prod/static/chunks/5922.0d75c174139a59a4.js +1 -0
- package/.next-prod/static/chunks/5937.0827b5b3eb831ff0.js +1 -0
- package/.next-prod/static/chunks/5968.63d5869783fad06f.js +1 -0
- package/.next-prod/static/chunks/5997.226c07d9e6c496e0.js +1 -0
- package/.next-prod/static/chunks/6026.4027a04696ef04db.js +1 -0
- package/.next-prod/static/chunks/6046.00d36aea7fd5b147.js +1 -0
- package/.next-prod/static/chunks/6089.2dd351186ec85cc3.js +1 -0
- package/.next-prod/static/chunks/6099.43e6595fcf24fc33.js +1 -0
- package/.next-prod/static/chunks/6110.5ce3f75fced27aaf.js +1 -0
- package/.next-prod/static/chunks/6144.f967a8228bcdf663.js +1 -0
- package/.next-prod/static/chunks/6155.e6cf0ef7c818caa9.js +1 -0
- package/.next-prod/static/chunks/6166.ecd82a9dcb484b97.js +1 -0
- package/.next-prod/static/chunks/624.2dd909fbfce98c5e.js +1 -0
- package/.next-prod/static/chunks/6290.e14cf4fc52dd4539.js +1 -0
- package/.next-prod/static/chunks/6293.5914fa73a9f7e777.js +1 -0
- package/.next-prod/static/chunks/6311.5b9c1f74df9a8f67.js +1 -0
- package/.next-prod/static/chunks/6331.758f2f66b92cada9.js +1 -0
- package/.next-prod/static/chunks/6339.bc9301cc22898be0.js +1 -0
- package/.next-prod/static/chunks/6360.ff0a9063773daeeb.js +1 -0
- package/.next-prod/static/chunks/6383.ca3e074feb80c69c.js +1 -0
- package/.next-prod/static/chunks/640.5bf1e25d0bddf875.js +1 -0
- package/.next-prod/static/chunks/6402.a0070d7688ed986b.js +1 -0
- package/.next-prod/static/chunks/6412.089ee787a294d10b.js +1 -0
- package/.next-prod/static/chunks/6455.12b78a2660d609eb.js +1 -0
- package/.next-prod/static/chunks/6460.8ce93fe47320f6c5.js +1 -0
- package/.next-prod/static/chunks/6563.5d618b608750f4dc.js +1 -0
- package/.next-prod/static/chunks/6572.ca2463823b9b01a0.js +1 -0
- package/.next-prod/static/chunks/6580.75d53830b434451f.js +1 -0
- package/.next-prod/static/chunks/6588.0fbca957af7d9e6a.js +1 -0
- package/.next-prod/static/chunks/6647.584c5d5cd8dfdb5a.js +1 -0
- package/.next-prod/static/chunks/6686.796c782c33ab8ca9.js +1 -0
- package/.next-prod/static/chunks/6701.bff0efb979f71a17.js +1 -0
- package/.next-prod/static/chunks/6704.f280f0ad0f5d8644.js +1 -0
- package/.next-prod/static/chunks/6729.0f91dcaaaffa2ed4.js +1 -0
- package/.next-prod/static/chunks/6741.06fdaf122961074e.js +1 -0
- package/.next-prod/static/chunks/6846.91283f709c40802c.js +1 -0
- package/.next-prod/static/chunks/6859.bacad166ee995fe0.js +1 -0
- package/.next-prod/static/chunks/6871.38519003bd87ac1c.js +62 -0
- package/.next-prod/static/chunks/6887.6c81234d73740fb9.js +1 -0
- package/.next-prod/static/chunks/6927.aa3914b5fb0d14d4.js +1 -0
- package/.next-prod/static/chunks/6931.3c90e9fe0f7f1e66.js +1 -0
- package/.next-prod/static/chunks/6938.0ccf683bd8aa8410.js +1 -0
- package/.next-prod/static/chunks/6948.2719ed8731963209.js +1 -0
- package/.next-prod/static/chunks/6959.5a803faf27f88e9f.js +1 -0
- package/.next-prod/static/chunks/6962.3bbd080592d4efa0.js +64 -0
- package/.next-prod/static/chunks/698.e0dda03fd303b96b.js +1 -0
- package/.next-prod/static/chunks/700.65a02f6a597083dc.js +9 -0
- package/.next-prod/static/chunks/7021.b71240b1d5f6fbe4.js +1 -0
- package/.next-prod/static/chunks/7040.b8e05ba7cbf46556.js +1 -0
- package/.next-prod/static/chunks/7041.174bf29bd837f06d.js +1 -0
- package/.next-prod/static/chunks/7082.fc816f91214026d7.js +1 -0
- package/.next-prod/static/chunks/7084.921c9737b83f55eb.js +1 -0
- package/.next-prod/static/chunks/7085.b16e7c0e24741232.js +215 -0
- package/.next-prod/static/chunks/70e0d97a-6903b8594c742784.js +1 -0
- package/.next-prod/static/chunks/7113.86e40b60c804b8c5.js +1 -0
- package/.next-prod/static/chunks/7130.8d24694735826c22.js +1 -0
- package/.next-prod/static/chunks/7142.dbd2cf8141eece5e.js +1 -0
- package/.next-prod/static/chunks/7152.c7b7f1f5e9622f21.js +1 -0
- package/.next-prod/static/chunks/7182.b747e3ef1524157a.js +1 -0
- package/.next-prod/static/chunks/7227.a6b2f01487bb3d9d.js +1 -0
- package/.next-prod/static/chunks/7258.6cbe24c3bcb63d1d.js +1 -0
- package/.next-prod/static/chunks/7425.8b47c8e398a12dd8.js +1 -0
- package/.next-prod/static/chunks/7443.124211e5abc05d3f.js +93 -0
- package/.next-prod/static/chunks/7455.71d54397710b923c.js +1 -0
- package/.next-prod/static/chunks/7465.867e8ff655666413.js +1 -0
- package/.next-prod/static/chunks/7479.433d3878625aba75.js +24 -0
- package/.next-prod/static/chunks/7524.9528295a19a5837a.js +1 -0
- package/.next-prod/static/chunks/7525.f433aaf1fe40c90a.js +1 -0
- package/.next-prod/static/chunks/7547.54b68d37b50c2f21.js +43 -0
- package/.next-prod/static/chunks/7557.bdc743175125b3d8.js +1 -0
- package/.next-prod/static/chunks/7610.b1439345dbcf285d.js +1 -0
- package/.next-prod/static/chunks/7625.ab66bd50d2fb61a4.js +1 -0
- package/.next-prod/static/chunks/7635.166d83de1d29e758.js +1 -0
- package/.next-prod/static/chunks/7636.bf91320a9ff695af.js +1 -0
- package/.next-prod/static/chunks/7650.18f74243e9325242.js +1 -0
- package/.next-prod/static/chunks/7785.1402a4110c300764.js +1 -0
- package/.next-prod/static/chunks/7799.f90cda9aba4e0e77.js +1 -0
- package/.next-prod/static/chunks/7819.3c56f48c0dc5ad5d.js +1 -0
- package/.next-prod/static/chunks/7844.2bb29faa262f313e.js +1 -0
- package/.next-prod/static/chunks/7846.c9705c044ab8f87a.js +1 -0
- package/.next-prod/static/chunks/7874.8db6929b94cdf697.js +1 -0
- package/.next-prod/static/chunks/7884.79af1a2f4511cea5.js +1 -0
- package/.next-prod/static/chunks/7889.af3e581842f34c28.js +1 -0
- package/.next-prod/static/chunks/7921.c361f794cc208e06.js +1 -0
- package/.next-prod/static/chunks/794.06b1ae4fc9cc10a9.js +1 -0
- package/.next-prod/static/chunks/7977.80e4daa080a79c39.js +1 -0
- package/.next-prod/static/chunks/799ebd4e.ccb85c56e9216a38.js +1 -0
- package/.next-prod/static/chunks/7d29de82.30ff86a90cbfd921.js +1 -0
- package/.next-prod/static/chunks/8113.907baefc7227cfb8.js +1 -0
- package/.next-prod/static/chunks/8132.74491162f08af899.js +1 -0
- package/.next-prod/static/chunks/816.ccc7dc455fcaf7c0.js +1 -0
- package/.next-prod/static/chunks/8192.5918d83ac6a0e2dc.js +1 -0
- package/.next-prod/static/chunks/8243.aa3ccfb41335eb1f.js +1 -0
- package/.next-prod/static/chunks/8257.dd8f651f1a43fee2.js +1 -0
- package/.next-prod/static/chunks/8288.8ff86c6a3bee6b7c.js +1 -0
- package/.next-prod/static/chunks/830.e49b226c07876df4.js +1 -0
- package/.next-prod/static/chunks/8317.9c6f22e0c8cd07a8.js +141 -0
- package/.next-prod/static/chunks/8318.a70d7a81445f8cf9.js +1 -0
- package/.next-prod/static/chunks/840.a9c535f8868cc4bd.js +1 -0
- package/.next-prod/static/chunks/8406.955ccfbb4b70b8c3.js +1 -0
- package/.next-prod/static/chunks/8430.b1f802dcffa41626.js +1 -0
- package/.next-prod/static/chunks/8432.bd66ac287c569996.js +1 -0
- package/.next-prod/static/chunks/8457.b61d96d8d30215fc.js +1 -0
- package/.next-prod/static/chunks/8496.046efd6301dd804f.js +1 -0
- package/.next-prod/static/chunks/8545.be0c9eea6aae5971.js +1 -0
- package/.next-prod/static/chunks/8555.ab3ee6358f1d64da.js +1 -0
- package/.next-prod/static/chunks/862.7cd3197e1ba5fd00.js +1 -0
- package/.next-prod/static/chunks/8656.2ceb4e5ff5df2fca.js +1 -0
- package/.next-prod/static/chunks/8670.90ede75068758e82.js +1 -0
- package/.next-prod/static/chunks/8704.a1003918da6654da.js +1 -0
- package/.next-prod/static/chunks/8773.614f1f4f0f845c5e.js +1 -0
- package/.next-prod/static/chunks/8776.6fb12270eca03fd3.js +149 -0
- package/.next-prod/static/chunks/8848.b0a10ee0b0a2b91b.js +1 -0
- package/.next-prod/static/chunks/8863.4a09596cf95e996a.js +82 -0
- package/.next-prod/static/chunks/893.c469257bbbbca4f5.js +1 -0
- package/.next-prod/static/chunks/8947.31d3d834d8281fd9.js +1 -0
- package/.next-prod/static/chunks/9005.473ce947d16e7f65.js +1 -0
- package/.next-prod/static/chunks/9006.11537833945ec4b8.js +1 -0
- package/.next-prod/static/chunks/9015.c4e40321a6503a1b.js +1 -0
- package/.next-prod/static/chunks/90542734.58d84d15ab7a8c98.js +1 -0
- package/.next-prod/static/chunks/9114-abef8471519b7dee.js +1 -0
- package/.next-prod/static/chunks/9136.191be42a2fee842c.js +1 -0
- package/.next-prod/static/chunks/9178.48a90097ee3f0b0c.js +1 -0
- package/.next-prod/static/chunks/9186.3af6fcd13ab752fa.js +1 -0
- package/.next-prod/static/chunks/9189.3e9d29bf275ec462.js +1 -0
- package/.next-prod/static/chunks/9220.0206dd0432eca784.js +1 -0
- package/.next-prod/static/chunks/9224.401f9320ee58570b.js +1 -0
- package/.next-prod/static/chunks/9233.124321d2f404e01c.js +1 -0
- package/.next-prod/static/chunks/9240.d38ddbe94e0bf128.js +1 -0
- package/.next-prod/static/chunks/9261.303cbbe69262a995.js +1 -0
- package/.next-prod/static/chunks/9267.fbfd65ea31e7448c.js +1 -0
- package/.next-prod/static/chunks/9294.a20485f3282321b3.js +1 -0
- package/.next-prod/static/chunks/92e53eb0.097194be4a0e7d55.js +1 -0
- package/.next-prod/static/chunks/9302.726b065f2df0323a.js +1 -0
- package/.next-prod/static/chunks/9318.ba24787a52cefe4c.js +56 -0
- package/.next-prod/static/chunks/9373.6206c440af44002a.js +1 -0
- package/.next-prod/static/chunks/9377.f9db706e76f04afe.js +1 -0
- package/.next-prod/static/chunks/9382.bc0e11ecc88dd62c.js +1 -0
- package/.next-prod/static/chunks/9421.a5c1dbcfbfdd8f52.js +1 -0
- package/.next-prod/static/chunks/9448.2668b3cd408e86de.js +1 -0
- package/.next-prod/static/chunks/9466.3dacf5969d47ba2c.js +1 -0
- package/.next-prod/static/chunks/9521.e1240eb862eb32dc.js +1 -0
- package/.next-prod/static/chunks/9547.7729788fff21926f.js +1 -0
- package/.next-prod/static/chunks/9565.8de0671f99d12abe.js +1 -0
- package/.next-prod/static/chunks/9569.2f36b2b1c2f838d7.js +1 -0
- package/.next-prod/static/chunks/9615.3b62c13af671f714.js +1 -0
- package/.next-prod/static/chunks/9648.8235b6fea7087b3a.js +1 -0
- package/.next-prod/static/chunks/966.57e4cd93c2368d34.js +1 -0
- package/.next-prod/static/chunks/9666.a515fa6d89a71f1c.js +1 -0
- package/.next-prod/static/chunks/968.29d4ba7ee8bd5ccb.js +1 -0
- package/.next-prod/static/chunks/9680.d5ceac8967e0b6a8.js +1 -0
- package/.next-prod/static/chunks/9690.7773c72f0eff6dec.js +1 -0
- package/.next-prod/static/chunks/9841.422321143547591a.js +1 -0
- package/.next-prod/static/chunks/9842.3b71b65b30d8ef2a.js +1 -0
- package/.next-prod/static/chunks/9996.18b7bca2f0ab222e.js +1 -0
- package/.next-prod/static/chunks/aaea2bcf-6b3391c26b869501.js +1 -0
- package/.next-prod/static/chunks/af7f6608.85a7e1eb0d4130b0.js +53 -0
- package/.next-prod/static/chunks/app/_global-error/page-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/_not-found/page-511b5b7e4ffc7ac9.js +1 -0
- package/.next-prod/static/chunks/app/api/bash/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/claude-stats/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/commands/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/comments/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/db/columns/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/db/connect/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/db/disconnect/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/db/export/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/db/query/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/db/schemas/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/extension/version/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/file/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/blame/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/clipboard/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/copy/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/delete/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/expanded/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/index/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/init/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/paste/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/read/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/readdir/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/recent/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/save/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/files/search/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/git/branch-diff/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/git/branches/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/git/commit-diff/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/git/commits/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/git/diff/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/git/discard/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/git/stage/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/git/status/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/git/unstage/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/git/worktree/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/global-state/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/jupyter/load/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/jupyter/save/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/jupyter/shutdown/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/definition/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/hover/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/references/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/status/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/warmup/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/columns/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/connect/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/disconnect/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/export/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/query/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/schemas/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/note/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/open-cursor/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/open-vscode/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/pick-folder/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/pinned-sessions/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/project-settings/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/project-state/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/projects/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/command/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/connect/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/delete/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/disconnect/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/get/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/keys/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/set/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/review/[id]/comments/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/review/[id]/replies/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/review/[id]/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/review/identify/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/review/order/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/review/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/review/share-info/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/review/users/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/scheduled-tasks/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/services/config/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/services/scripts/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/session-by-path/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/projects/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/settings/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/aliases/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/env/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/history/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/api/version/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/global-error-3c48d7d42c672863.js +1 -0
- package/.next-prod/static/chunks/app/layout-44210aade5d56585.js +1 -0
- package/.next-prod/static/chunks/app/manifest.webmanifest/route-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/app/page-cc2bf3ca4c337090.js +1 -0
- package/.next-prod/static/chunks/app/project/page-fb1ff1d5d382977d.js +25 -0
- package/.next-prod/static/chunks/app/review/[id]/page-64f18d8d2476753c.js +1 -0
- package/.next-prod/static/chunks/ce16f5a9.5c7821b201f35593.js +1 -0
- package/.next-prod/static/chunks/cee15710.869cef5f741d40c2.js +1 -0
- package/.next-prod/static/chunks/cfdf2ac7.4506d3f72b310564.js +1 -0
- package/.next-prod/static/chunks/d1c28714.f52cffdd449a2d14.js +1 -0
- package/.next-prod/static/chunks/d3ac728e-d1ae8819b8f0be6a.js +1 -0
- package/.next-prod/static/chunks/e868780c.a081703edc1bc551.js +18 -0
- package/.next-prod/static/chunks/framework-81b2e59ffe13bb24.js +1 -0
- package/.next-prod/static/chunks/main-ac50dc1e450895a2.js +5 -0
- package/.next-prod/static/chunks/main-app-b76c0df33a946918.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-f2ae9d2d29d5fe08.js +1 -0
- package/.next-prod/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/.next-prod/static/chunks/webpack-67d02a2a41508d41.js +1 -0
- package/.next-prod/static/css/2163ab5e45fedc6a.css +1 -0
- package/.next-prod/static/css/dd86f60184ab34a9.css +3 -0
- package/.next-prod/static/media/0086f8992871c45b-s.woff2 +0 -0
- package/.next-prod/static/media/03b436aa846269de-s.woff2 +0 -0
- package/.next-prod/static/media/08aedeceaf1dcd57-s.woff2 +0 -0
- package/.next-prod/static/media/0aa834ed78bf6d07-s.woff2 +0 -0
- package/.next-prod/static/media/19cfc7226ec3afaa-s.woff2 +0 -0
- package/.next-prod/static/media/21350d82a1f187e9-s.woff2 +0 -0
- package/.next-prod/static/media/36008747766f78c6-s.woff2 +0 -0
- package/.next-prod/static/media/5c0c2bcbaa4149ca-s.p.woff2 +0 -0
- package/.next-prod/static/media/67957d42bae0796d-s.woff2 +0 -0
- package/.next-prod/static/media/6d38f9d4e0f4772b-s.woff2 +0 -0
- package/.next-prod/static/media/886030b0b59bc5a7-s.woff2 +0 -0
- package/.next-prod/static/media/8e9860b6e62d6359-s.woff2 +0 -0
- package/.next-prod/static/media/939c4f875ee75fbb-s.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_AMS-Regular.1608a09b.woff +0 -0
- package/.next-prod/static/media/KaTeX_AMS-Regular.4aafdb68.ttf +0 -0
- package/.next-prod/static/media/KaTeX_AMS-Regular.a79f1c31.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Caligraphic-Bold.b6770918.woff +0 -0
- package/.next-prod/static/media/KaTeX_Caligraphic-Bold.cce5b8ec.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Caligraphic-Bold.ec17d132.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Caligraphic-Regular.07ef19e7.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Caligraphic-Regular.55fac258.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Caligraphic-Regular.dad44a7f.woff +0 -0
- package/.next-prod/static/media/KaTeX_Fraktur-Bold.9f256b85.woff +0 -0
- package/.next-prod/static/media/KaTeX_Fraktur-Bold.b18f59e1.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Fraktur-Bold.d42a5579.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Fraktur-Regular.7c187121.woff +0 -0
- package/.next-prod/static/media/KaTeX_Fraktur-Regular.d3c882a6.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Fraktur-Regular.ed38e79f.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Main-Bold.b74a1a8b.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Main-Bold.c3fb5ac2.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Main-Bold.d181c465.woff +0 -0
- package/.next-prod/static/media/KaTeX_Main-BoldItalic.6f2bb1df.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Main-BoldItalic.70d8b0a5.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Main-BoldItalic.e3f82f9d.woff +0 -0
- package/.next-prod/static/media/KaTeX_Main-Italic.47373d1e.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Main-Italic.8916142b.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Main-Italic.9024d815.woff +0 -0
- package/.next-prod/static/media/KaTeX_Main-Regular.0462f03b.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Main-Regular.7f51fe03.woff +0 -0
- package/.next-prod/static/media/KaTeX_Main-Regular.b7f8fe9b.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Math-BoldItalic.572d331f.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Math-BoldItalic.a879cf83.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Math-BoldItalic.f1035d8d.woff +0 -0
- package/.next-prod/static/media/KaTeX_Math-Italic.5295ba48.woff +0 -0
- package/.next-prod/static/media/KaTeX_Math-Italic.939bc644.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Math-Italic.f28c23ac.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_SansSerif-Bold.8c5b5494.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_SansSerif-Bold.94e1e8dc.ttf +0 -0
- package/.next-prod/static/media/KaTeX_SansSerif-Bold.bf59d231.woff +0 -0
- package/.next-prod/static/media/KaTeX_SansSerif-Italic.3b1e59b3.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_SansSerif-Italic.7c9bc82b.woff +0 -0
- package/.next-prod/static/media/KaTeX_SansSerif-Italic.b4c20c84.ttf +0 -0
- package/.next-prod/static/media/KaTeX_SansSerif-Regular.74048478.woff +0 -0
- package/.next-prod/static/media/KaTeX_SansSerif-Regular.ba21ed5f.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_SansSerif-Regular.d4d7ba48.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Script-Regular.03e9641d.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Script-Regular.07505710.woff +0 -0
- package/.next-prod/static/media/KaTeX_Script-Regular.fe9cbbe1.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Size1-Regular.e1e279cb.woff +0 -0
- package/.next-prod/static/media/KaTeX_Size1-Regular.eae34984.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Size1-Regular.fabc004a.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Size2-Regular.57727022.woff +0 -0
- package/.next-prod/static/media/KaTeX_Size2-Regular.5916a24f.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Size2-Regular.d6b476ec.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Size3-Regular.9acaf01c.woff +0 -0
- package/.next-prod/static/media/KaTeX_Size3-Regular.a144ef58.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Size3-Regular.b4230e7e.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Size4-Regular.10d95fd3.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Size4-Regular.7a996c9d.woff +0 -0
- package/.next-prod/static/media/KaTeX_Size4-Regular.fbccdabe.ttf +0 -0
- package/.next-prod/static/media/KaTeX_Typewriter-Regular.6258592b.woff +0 -0
- package/.next-prod/static/media/KaTeX_Typewriter-Regular.a8709e36.woff2 +0 -0
- package/.next-prod/static/media/KaTeX_Typewriter-Regular.d97aaf4a.ttf +0 -0
- package/.next-prod/static/media/ab00a911ac2adf48-s.woff2 +0 -0
- package/.next-prod/static/media/ba9851c3c22cd980-s.woff2 +0 -0
- package/.next-prod/static/media/bb3ef058b751a6ad-s.p.woff2 +0 -0
- package/.next-prod/static/media/c5fe6dc8356a8c31-s.woff2 +0 -0
- package/.next-prod/static/media/df0a9ae256c0569c-s.woff2 +0 -0
- package/.next-prod/static/media/e4af272ccee01ff0-s.p.woff2 +0 -0
- package/.next-prod/static/media/f911b923c6adde36-s.woff2 +0 -0
- package/.next-prod/trace +12 -0
- package/.next-prod/trace-build +1 -0
- package/.next-prod/types/app/api/bash/route.ts +350 -0
- package/.next-prod/types/app/api/chat/route.ts +350 -0
- package/.next-prod/types/app/api/claude-stats/route.ts +350 -0
- package/.next-prod/types/app/api/commands/route.ts +350 -0
- package/.next-prod/types/app/api/comments/route.ts +350 -0
- package/.next-prod/types/app/api/db/columns/route.ts +350 -0
- package/.next-prod/types/app/api/db/connect/route.ts +350 -0
- package/.next-prod/types/app/api/db/disconnect/route.ts +350 -0
- package/.next-prod/types/app/api/db/export/route.ts +350 -0
- package/.next-prod/types/app/api/db/query/route.ts +350 -0
- package/.next-prod/types/app/api/db/schemas/route.ts +350 -0
- package/.next-prod/types/app/api/extension/version/route.ts +350 -0
- package/.next-prod/types/app/api/file/route.ts +350 -0
- package/.next-prod/types/app/api/files/blame/route.ts +350 -0
- package/.next-prod/types/app/api/files/clipboard/route.ts +350 -0
- package/.next-prod/types/app/api/files/copy/route.ts +350 -0
- package/.next-prod/types/app/api/files/delete/route.ts +350 -0
- package/.next-prod/types/app/api/files/expanded/route.ts +350 -0
- package/.next-prod/types/app/api/files/index/route.ts +350 -0
- package/.next-prod/types/app/api/files/init/route.ts +350 -0
- package/.next-prod/types/app/api/files/paste/route.ts +350 -0
- package/.next-prod/types/app/api/files/read/route.ts +350 -0
- package/.next-prod/types/app/api/files/readdir/route.ts +350 -0
- package/.next-prod/types/app/api/files/recent/route.ts +350 -0
- package/.next-prod/types/app/api/files/save/route.ts +350 -0
- package/.next-prod/types/app/api/files/search/route.ts +350 -0
- package/.next-prod/types/app/api/git/branch-diff/route.ts +350 -0
- package/.next-prod/types/app/api/git/branches/route.ts +350 -0
- package/.next-prod/types/app/api/git/commit-diff/route.ts +350 -0
- package/.next-prod/types/app/api/git/commits/route.ts +350 -0
- package/.next-prod/types/app/api/git/diff/route.ts +350 -0
- package/.next-prod/types/app/api/git/discard/route.ts +350 -0
- package/.next-prod/types/app/api/git/stage/route.ts +350 -0
- package/.next-prod/types/app/api/git/status/route.ts +350 -0
- package/.next-prod/types/app/api/git/unstage/route.ts +350 -0
- package/.next-prod/types/app/api/git/worktree/route.ts +350 -0
- package/.next-prod/types/app/api/global-state/route.ts +350 -0
- package/.next-prod/types/app/api/jupyter/load/route.ts +350 -0
- package/.next-prod/types/app/api/jupyter/save/route.ts +350 -0
- package/.next-prod/types/app/api/jupyter/shutdown/route.ts +350 -0
- package/.next-prod/types/app/api/lsp/definition/route.ts +350 -0
- package/.next-prod/types/app/api/lsp/hover/route.ts +350 -0
- package/.next-prod/types/app/api/lsp/references/route.ts +350 -0
- package/.next-prod/types/app/api/lsp/status/route.ts +350 -0
- package/.next-prod/types/app/api/lsp/warmup/route.ts +350 -0
- package/.next-prod/types/app/api/mysql/columns/route.ts +350 -0
- package/.next-prod/types/app/api/mysql/connect/route.ts +350 -0
- package/.next-prod/types/app/api/mysql/disconnect/route.ts +350 -0
- package/.next-prod/types/app/api/mysql/export/route.ts +350 -0
- package/.next-prod/types/app/api/mysql/query/route.ts +350 -0
- package/.next-prod/types/app/api/mysql/schemas/route.ts +350 -0
- package/.next-prod/types/app/api/note/route.ts +350 -0
- package/.next-prod/types/app/api/open-cursor/route.ts +350 -0
- package/.next-prod/types/app/api/open-vscode/route.ts +350 -0
- package/.next-prod/types/app/api/pick-folder/route.ts +350 -0
- package/.next-prod/types/app/api/pinned-sessions/route.ts +350 -0
- package/.next-prod/types/app/api/project-settings/route.ts +350 -0
- package/.next-prod/types/app/api/project-state/route.ts +350 -0
- package/.next-prod/types/app/api/projects/route.ts +350 -0
- package/.next-prod/types/app/api/redis/command/route.ts +350 -0
- package/.next-prod/types/app/api/redis/connect/route.ts +350 -0
- package/.next-prod/types/app/api/redis/delete/route.ts +350 -0
- package/.next-prod/types/app/api/redis/disconnect/route.ts +350 -0
- package/.next-prod/types/app/api/redis/get/route.ts +350 -0
- package/.next-prod/types/app/api/redis/keys/route.ts +350 -0
- package/.next-prod/types/app/api/redis/set/route.ts +350 -0
- package/.next-prod/types/app/api/review/[id]/comments/route.ts +350 -0
- package/.next-prod/types/app/api/review/[id]/replies/route.ts +350 -0
- package/.next-prod/types/app/api/review/[id]/route.ts +350 -0
- package/.next-prod/types/app/api/review/identify/route.ts +350 -0
- package/.next-prod/types/app/api/review/order/route.ts +350 -0
- package/.next-prod/types/app/api/review/route.ts +350 -0
- package/.next-prod/types/app/api/review/share-info/route.ts +350 -0
- package/.next-prod/types/app/api/review/users/route.ts +350 -0
- package/.next-prod/types/app/api/scheduled-tasks/route.ts +350 -0
- package/.next-prod/types/app/api/services/config/route.ts +350 -0
- package/.next-prod/types/app/api/services/scripts/route.ts +350 -0
- package/.next-prod/types/app/api/session/[sessionId]/fork/route.ts +350 -0
- package/.next-prod/types/app/api/session/[sessionId]/history/route.ts +350 -0
- package/.next-prod/types/app/api/session-by-path/route.ts +350 -0
- package/.next-prod/types/app/api/sessions/projects/[encodedPath]/route.ts +350 -0
- package/.next-prod/types/app/api/sessions/projects/route.ts +350 -0
- package/.next-prod/types/app/api/sessions/route.ts +350 -0
- package/.next-prod/types/app/api/settings/route.ts +350 -0
- package/.next-prod/types/app/api/terminal/aliases/route.ts +350 -0
- package/.next-prod/types/app/api/terminal/autocomplete/route.ts +350 -0
- package/.next-prod/types/app/api/terminal/bubble-order/route.ts +350 -0
- package/.next-prod/types/app/api/terminal/env/route.ts +350 -0
- package/.next-prod/types/app/api/terminal/history/route.ts +350 -0
- package/.next-prod/types/app/api/version/route.ts +350 -0
- package/.next-prod/types/app/page.ts +86 -0
- package/.next-prod/types/app/project/page.ts +86 -0
- package/.next-prod/types/app/review/[id]/page.ts +86 -0
- package/.next-prod/types/package.json +1 -0
- package/.next-prod/types/routes.d.ts +164 -0
- package/.next-prod/types/validator.ts +898 -0
- package/LICENSE +21 -0
- package/README.md +94 -0
- package/README.zh.md +100 -0
- package/bin/cock-browser.mjs +435 -0
- package/bin/cock-dev.mjs +6 -0
- package/bin/cock-terminal.mjs +215 -0
- package/bin/cock.mjs +99 -0
- package/bin/postinstall.mjs +29 -0
- package/chrome-extension/automation.js +684 -0
- package/chrome-extension/background.js +364 -0
- package/chrome-extension/content.js +224 -0
- package/chrome-extension/disguise.js +14 -0
- package/chrome-extension/icons/icon128.png +0 -0
- package/chrome-extension/icons/icon16.png +0 -0
- package/chrome-extension/icons/icon48.png +0 -0
- package/chrome-extension/manifest.json +42 -0
- package/chrome-extension/network-capture.js +197 -0
- package/chrome-extension/rules.json +56 -0
- package/dist/JupyterKernelManager-475VNVA5.mjs +248 -0
- package/dist/chunk-OER3N6H7.mjs +250 -0
- package/dist/scheduledTasks.mjs +418 -0
- package/dist/wsServer.mjs +1441 -0
- package/next.config.ts +18 -0
- package/package.json +122 -0
- package/public/favicon.ico +0 -0
- package/public/icons/dev/icon-128x128.png +0 -0
- package/public/icons/dev/icon-144x144.png +0 -0
- package/public/icons/dev/icon-152x152.png +0 -0
- package/public/icons/dev/icon-192x192.png +0 -0
- package/public/icons/dev/icon-384x384.png +0 -0
- package/public/icons/dev/icon-512x512.png +0 -0
- package/public/icons/dev/icon-72x72.png +0 -0
- package/public/icons/dev/icon-96x96.png +0 -0
- package/public/icons/icon-128x128.png +0 -0
- package/public/icons/icon-144x144.png +0 -0
- package/public/icons/icon-152x152.png +0 -0
- package/public/icons/icon-192x192.png +0 -0
- package/public/icons/icon-384x384.png +0 -0
- package/public/icons/icon-512x512.png +0 -0
- package/public/icons/icon-72x72.png +0 -0
- package/public/icons/icon-96x96.png +0 -0
- package/server.mjs +135 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6500],{60499:(e,t,r)=>{Promise.resolve().then(r.bind(r,94864))},94864:(e,t,r)=>{"use strict";r.d(t,{TabManager:()=>nS});var n=r(95155),s=r(12115),o=r(79114);function l({isOpen:e,onClose:t,cwd:r,onSelectSession:l}){let{t:a}=(0,o.Bd)(),[i,c]=(0,s.useState)([]),[d,u]=(0,s.useState)(!1),[h,m]=(0,s.useState)(null),[x,f]=(0,s.useState)(""),p=(0,s.useRef)(null),g=(0,s.useCallback)(async()=>{if(r){u(!0),m(null);try{let e=r.replace(/\//g,"-"),t=await fetch(`/api/sessions/projects/${encodeURIComponent(e)}`);if(!t.ok)throw Error("Failed to load sessions");let n=await t.json();c(n)}catch(e){m(e instanceof Error?e.message:"Unknown error")}finally{u(!1)}}},[r]);(0,s.useEffect)(()=>{e&&(g(),setTimeout(()=>{p.current?.focus()},100))},[e,g]),(0,s.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,t]);let b=i.filter(e=>{if(!x)return!0;let t=x.toLowerCase();return 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-black/50 backdrop-blur-sm",onClick:t}),(0,n.jsxs)("div",{className:"relative w-full max-w-6xl h-[90vh] mx-4 bg-card rounded-lg shadow-xl flex flex-col overflow-hidden",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:a("sessions.sessionList")}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:r,children:r})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,n.jsx)("input",{ref:p,type:"text",placeholder:a("sessions.searchSessions"),value:x,onChange:e=>f(e.target.value),className:"px-2 py-1 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent 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:[d&&(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:a("sessions.loadingSessions")})]})}),h&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("div",{className:"text-xs text-red-11",children:h})}),!d&&!h&&0===b.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:a(x?"sessions.noMatchingSessions":"sessions.noSessionsYet")})}),!d&&!h&&b.length>0&&(0,n.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:b.map(e=>(0,n.jsxs)("div",{onClick:()=>{let n;return n=(e.path.split("/").pop()||"").replace(".jsonl",""),void(l?(l(n,e.title),t()):window.parent.postMessage({type:"OPEN_PROJECT",cwd:r,sessionId:n},"*"))},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,n.jsx)("h4",{className:"text-xs font-medium text-foreground mb-1 truncate",title:e.title,children:e.title}),(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",title:e,children:[(0,n.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),e]},`first-${t}`)),e.lastMessages.length>0&&(0,n.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),e.lastMessages.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground truncate",title:e,children:[(0,n.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),e]},`last-${t}`))]})]},e.path))})]})]})]}):null}var a=r(47650),i=r(64702),c=r(87918);let d=new Set;function u(){d.forEach(e=>e())}async function h(e){let t=await fetch(`/api/comments?cwd=${encodeURIComponent(e)}`);if(!t.ok)throw Error("Failed to fetch comments");let r=(await t.json()).comments||[];if(0===r.length)return[];let n=new Map;for(let e of r)e.selectedText||(n.has(e.filePath)||n.set(e.filePath,[]),n.get(e.filePath).push(e));let s=new Map;await Promise.all(Array.from(n.keys()).map(async t=>{try{let r=await fetch(`/api/files/read?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`);if(r.ok){let e=await r.json();"text"===e.type&&e.content&&s.set(t,e.content.split("\n"))}}catch(e){console.error(`Failed to read file ${t}:`,e)}}));let o=[];for(let e of r){if(e.selectedText){o.push({...e,codeContent:e.selectedText});continue}let t=s.get(e.filePath),r="";if(t){let n=Math.max(0,e.startLine-1),s=Math.min(t.length,e.endLine);r=t.slice(n,s).join("\n")}o.push({...e,codeContent:r})}return o}async function m(e){try{if((await fetch(`/api/comments?cwd=${encodeURIComponent(e)}&all=true`,{method:"DELETE"})).ok)return u(),!0;return!1}catch(e){return console.error("Failed to clear comments:",e),!1}}let x="__chat__";function f(e,t){let r=e.filter(e=>e.filePath===x),n=e.filter(e=>e.filePath!==x),s=[];for(let e of(n.length>0&&(s.push(`${c.A.t("comments.codeRef")}`,""),n.forEach((e,t)=>{s.push(`[${t+1}] ${e.filePath}:${e.startLine}-${e.endLine}`),s.push("```"),s.push(e.codeContent),s.push("```"),e.note&&s.push(c.A.t("comments.note",{content:e.note})),s.push("")})),r)){let t=e.codeContent.split("\n").map(e=>`> ${e}`).join("\n");s.push(t),e.note&&s.push(e.note),s.push("")}return s.push(c.A.t("comments.question",{question:t})),s.join("\n")}function p({cwd:e,filePath:t}){let[r,n]=(0,s.useState)([]),[o,l]=(0,s.useState)(!1),[a,i]=(0,s.useState)(null),c=(0,s.useCallback)(async()=>{if(e&&t){l(!0),i(null);try{let r=await fetch(`/api/comments?cwd=${encodeURIComponent(e)}&filePath=${encodeURIComponent(t)}`);if(r.ok){let e=await r.json();n(e.comments||[])}else i("Failed to load comments")}catch(e){i(e instanceof Error?e.message:"Unknown error")}finally{l(!1)}}},[e,t]);(0,s.useEffect)(()=>{c()},[c]),(0,s.useEffect)(()=>{var e;return e=()=>{c()},d.add(e),()=>d.delete(e)},[c]);let u=(0,s.useCallback)(async(r,s,o,l)=>{try{let a=await fetch("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,filePath:t,startLine:r,endLine:s,content:o,...l?{selectedText:l}:{}})});if(a.ok){let e=await a.json();return n(t=>[...t,e.comment]),e.comment}}catch(e){console.error("Failed to add comment:",e)}return null},[e,t]),h=(0,s.useCallback)(async(t,r)=>{try{let s=await fetch("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,id:t,content:r})});if(s.ok){let e=await s.json();return n(r=>r.map(r=>r.id===t?e.comment:r)),!0}}catch(e){console.error("Failed to update comment:",e)}return!1},[e]),m=(0,s.useCallback)(async t=>{try{if((await fetch(`/api/comments?cwd=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`,{method:"DELETE"})).ok)return n(e=>e.filter(e=>e.id!==t)),!0}catch(e){console.error("Failed to delete comment:",e)}return!1},[e]),x=(0,s.useCallback)(e=>r.filter(t=>e>=t.startLine&&e<=t.endLine),[r]);return{comments:r,isLoading:o,error:a,addComment:u,updateComment:h,deleteComment:m,refresh:c,getCommentsForLine:x}}var g=r(38093);let b=(0,s.createContext)(null);function v({container:e,children:t}){return(0,n.jsx)(b.Provider,{value:e,children:t})}function j(){return(0,s.useContext)(b)}function w({x:e,y:t,path:r,cwd:l,isDirectory:i,onClose:c,onCreateFile:d,onDelete:u,onRefresh:h,onCopyFile:m,onPaste:x}){let{t:f}=(0,o.Bd)(),p=(0,s.useRef)(null),v=(0,s.useContext)(b),j=r.split("/").pop()||r,w=`${l}/${r}`,y=r.includes("/")?r.substring(0,r.lastIndexOf("/")):"",k=y?`${l}/${y}`:l,N=i?r:y,C=i?w:k;(0,s.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&c()},t=e=>{"Escape"===e.key&&c()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[c]);let[S,L]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(p.current&&v){let r=v.getBoundingClientRect(),n=p.current.getBoundingClientRect(),s=e-r.left,o=t-r.top;s=Math.min(s,r.width-n.width-8),o=Math.min(o,r.height-n.height-8),L({x:s=Math.max(8,s),y:o=Math.max(8,o)})}else if(p.current){let r=p.current.getBoundingClientRect();L({x:Math.max(8,Math.min(e,window.innerWidth-r.width-8)),y:Math.max(8,Math.min(t,window.innerHeight-r.height-8))})}},[e,t,v]);let E=(0,s.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(e),(0,g.oR)(f("toast.copiedName",{name:t}),"success")}catch{(0,g.oR)(f("toast.copyFailed"),"error")}c()},[c,f]),M=i?r:y,T=[{label:f("fileContextMenu.copyRelativePath"),value:r},{label:f("fileContextMenu.copyAbsolutePath"),value:w},{label:f("fileContextMenu.copyRelativeDirPath"),value:N||"."},{label:f("fileContextMenu.copyAbsoluteDirPath"),value:C},{label:i?f("fileContextMenu.copyFolderName"):f("fileContextMenu.copyFileName"),value:j}],$=(0,n.jsxs)("div",{ref:p,className:"absolute z-[200] bg-card border border-border rounded-lg shadow-lg py-1 w-fit whitespace-nowrap",style:{left:S.x,top:S.y},children:[d&&(0,n.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>{c(),d(M)},children:f("fileContextMenu.createFile")}),m&&(0,n.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>{c(),m(r)},children:i?f("fileContextMenu.copyFolder"):f("fileContextMenu.copyFile")}),x&&(0,n.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>{c(),x(M)},children:f("fileContextMenu.pasteHere")}),u&&(0,n.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-destructive hover:bg-accent transition-colors",onClick:()=>{c(),u(r,i,j)},children:i?f("fileContextMenu.deleteFolder"):f("fileContextMenu.deleteFile")}),(d||u||m||x)&&(0,n.jsx)("div",{className:"my-1 border-t border-border"}),T.map((e,t)=>(0,n.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-accent transition-colors",onClick:()=>E(e.value,e.label),children:e.label},t))]});return v?(0,a.createPortal)($,v):$}function y(){let[e,t]=(0,s.useState)(null);return{contextMenu:e,showContextMenu:(0,s.useCallback)((e,r,n)=>{e.preventDefault(),e.stopPropagation(),t({x:e.clientX,y:e.clientY,path:r,isDirectory:n})},[]),hideContextMenu:(0,s.useCallback)(()=>{t(null)},[])}}let k=(0,s.createContext)(null);function N({children:e}){let t=(0,s.useRef)(new Map),r=(0,s.useRef)(null),[o,l]=(0,s.useState)(!1),a=(0,s.useCallback)((e,r)=>{t.current.set(r,e)},[]),i=(0,s.useCallback)(e=>{t.current.delete(e)},[]),c=(0,s.useCallback)(e=>{r.current=e},[]),d=(0,s.useCallback)(e=>{let n=r.current;if(!n)return void console.warn("No active tab to send message");let s=t.current.get(n);s?s(e):console.warn(`No chat sender registered for tab ${n}`)},[]),u=(0,s.useMemo)(()=>({sendMessage:d,isLoading:o,registerChat:a,unregisterChat:i,setActiveTab:c,setIsLoading:l}),[d,o,a,i,c]);return(0,n.jsx)(k.Provider,{value:u,children:e})}function C(){return(0,s.useContext)(k)}function S({x:e,y:t,range:r,codeContent:l,container:a,onSubmit:i,onClose:c}){let{t:d}=(0,o.Bd)(),[u,h]=(0,s.useState)(""),[m,x]=(0,s.useState)(!1),f=(0,s.useRef)(null),p=(0,s.useRef)(null),[g,b]=(0,s.useState)({x:0,y:0}),v=l?.split("\n").slice(0,5).join("\n"),j=!!l&&l.split("\n").length>5;return(0,s.useEffect)(()=>{if(f.current&&a){let r=a.getBoundingClientRect(),n=f.current.getBoundingClientRect(),s=e-r.left,o=t-r.top;s+n.width>r.width-16&&(s=r.width-n.width-16),s<16&&(s=16),o+n.height>r.height-16&&(o=o-n.height-8),o<16&&(o=16),queueMicrotask(()=>b({x:s,y:o}))}},[e,t,a]),(0,s.useEffect)(()=>{p.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{m||!f.current||f.current.contains(e.target)||c()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[c,m]),(0,n.jsxs)("div",{ref:f,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:g.x,top:g.y},children:[(0,n.jsx)("div",{className:"px-3 py-2 bg-amber-9/10 border-b border-border",children:(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-xs font-medium text-amber-11",children:d("comments.addComment")}),(r.start>0||r.end>0)&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:d("comments.lineRange",{start:r.start,end:r.end})})]})}),l&&(0,n.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,n.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[v,j&&(0,n.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,n.jsxs)("div",{className:"p-2",children:[(0,n.jsx)("textarea",{ref:p,value:u,onChange:e=>h(e.target.value),placeholder:d("comments.inputPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:m,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!m&&u.trim()&&(x(!0),i(u.trim()))),"Escape"!==e.key||m||c()}}),(0,n.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:d(m?"comments.submitting":"comments.enterSubmit")})]})]})}function L({x:e,y:t,range:r,filePath:l,codeContent:a,container:i,onSubmit:c,onClose:d,isChatLoading:u}){let{t:h}=(0,o.Bd)(),[m,x]=(0,s.useState)(""),f=(0,s.useRef)(null),p=(0,s.useRef)(null),[g,b]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(f.current&&i){let r=i.getBoundingClientRect(),n=f.current.getBoundingClientRect(),s=e-r.left,o=t-r.top;s+n.width>r.width-16&&(s=r.width-n.width-16),s<16&&(s=16),o+n.height>r.height-16&&(o=o-n.height-8),o<16&&(o=16),queueMicrotask(()=>b({x:s,y:o}))}},[e,t,i]),(0,s.useEffect)(()=>{p.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&d()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[d]);let v=a?.split("\n").slice(0,5).join("\n"),j=!!a&&a.split("\n").length>5;return(0,n.jsxs)("div",{ref:f,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:g.x,top:g.y},children:[(0,n.jsxs)("div",{className:"px-3 py-2 bg-brand/10 border-b border-border",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-xs font-medium text-brand",children:h("comments.askAI")}),(r.start>0||r.end>0)&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:h("comments.lineRange",{start:r.start,end:r.end})})]}),l&&(0,n.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:l})]}),a&&(0,n.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,n.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[v,j&&(0,n.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,n.jsxs)("div",{className:"p-2",children:[(0,n.jsx)("textarea",{ref:p,value:m,onChange:e=>x(e.target.value),placeholder:h("comments.inputQuestion"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:u,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!u&&m.trim()&&(c(m.trim()),d())),"Escape"===e.key&&d()}}),(0,n.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:h(u?"comments.aiGenerating":"comments.enterSend")})]})]})}function E(e,t){let r=e.split("\n"),n=t.split("\n"),s=[],o=r.length,l=n.length,a=Array(o+1).fill(null).map(()=>Array(l+1).fill(0));for(let e=1;e<=o;e++)for(let t=1;t<=l;t++)r[e-1]===n[t-1]?a[e][t]=a[e-1][t-1]+1:a[e][t]=Math.max(a[e-1][t],a[e][t-1]);let i=o,c=l,d=[];for(;i>0||c>0;)i>0&&c>0&&r[i-1]===n[c-1]?(d.push({type:"unchanged",content:r[i-1],oldLineNum:i,newLineNum:c}),i--,c--):c>0&&(0===i||a[i][c-1]>=a[i-1][c])?(d.push({type:"added",content:n[c-1],newLineNum:c}),c--):(d.push({type:"removed",content:r[i-1],oldLineNum:i}),i--);for(;d.length>0;)s.push(d.pop());return s}var M=r(67014);let T=null,$=["typescript","tsx","javascript","jsx","html","css","scss","json","yaml","python","go","rust","java","ruby","php","bash","shell","markdown","sql","c","cpp","swift","kotlin","dart","lua","graphql","xml"];function R(){return T||(T=(0,M.O_)({themes:["github-dark","github-light"],langs:[...$]})),T}function P(e){let t=e.split("/").pop()?.toLowerCase()||"",r=t.split(".").pop()?.toLowerCase();if(".env"===t||t.startsWith(".env.")||"dockerfile"===t||t.startsWith("dockerfile.")||"makefile"===t)return"bash";let n={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",css:"css",scss:"scss",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",rb:"ruby",php:"php",cs:"cpp",cpp:"cpp",c:"c",h:"c",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",sql:"sql",swift:"swift",dart:"dart",lua:"lua",graphql:"graphql",gql:"graphql",toml:"yaml",sass:"scss",less:"css",scala:"java",r:"python",vim:"bash",env:"bash"}[r||""]||"text";return $.includes(n)?n:"text"}function I(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(e){return e.map(e=>e.color?`<span style="color:${e.color}">${I(e.content)}</span>`:I(e.content)).join("")}function B(e,t){let[r,n]=(0,s.useState)([]),[o,l]=(0,s.useState)(!1),a=(0,s.useRef)("");(0,s.useEffect)(()=>{let e=()=>{l(document.documentElement.classList.contains("dark"))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);let i=e.join("\n");return(0,s.useEffect)(()=>{if(0===e.length)return;let r=`${i}:${t}:${o}`;if(r===a.current)return;a.current=r,n(e.map(e=>I(e||" ")));let s=!1;return(async()=>{try{let r=await R();if(s)return;let l=P(t),a=e.join("\n"),i=r.codeToTokens(a,{lang:l,theme:o?"github-dark":"github-light"}),c=[];for(let e=0;e<i.tokens.length;e++)if(c[e]=D(i.tokens[e]),e%500==0&&e>0&&(await new Promise(e=>setTimeout(e,0)),s))return;n(c)}catch(e){console.error("Line highlight error:",e)}})(),()=>{s=!0}},[i,t,o]),r}function F({lines:e,containerRef:t}){let r=(0,s.useRef)(null),[o,l]=(0,s.useState)({top:0,height:0});if((0,s.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{let{scrollTop:t,scrollHeight:n,clientHeight:s}=e,o=r.current?.clientHeight||0;if(n<=s)l({top:0,height:o});else{let e=o/n;l({top:t*e,height:s*e})}};return n(),e.addEventListener("scroll",n),window.addEventListener("resize",n),()=>{e.removeEventListener("scroll",n),window.removeEventListener("resize",n)}},[t]),0===e.length)return null;let a=100/e.length;return(0,n.jsxs)("div",{ref:r,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:e=>{let n=t.current,s=r.current;if(!n||!s)return;let o=s.getBoundingClientRect(),l=(e.clientY-o.top)/o.height*n.scrollHeight-n.clientHeight/2;n.scrollTo({top:Math.max(0,l),behavior:"smooth"})},children:[e.map((e,t)=>"unchanged"!==e.type&&(0,n.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===e.type?"bg-red-9":"bg-green-9"}`,style:{top:`${t*a}%`,height:`${Math.max(a,.5)}%`,minHeight:"2px"}},t)),(0,n.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${o.top}px`,height:`${Math.max(o.height,10)}px`}})]})}function O({x:e,y:t,visible:r,container:s,onAddComment:l,onSendToAI:a,onSearch:i,isChatLoading:c}){let{t:d}=(0,o.Bd)(),u=s.getBoundingClientRect(),h=e-u.left,m=Math.max(0,t-u.top-40);return(0,n.jsxs)("div",{className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-xl p-1.5",style:{left:h+8,top:m,visibility:r?"visible":"hidden",pointerEvents:r?"auto":"none"},children:[(0,n.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:l,children:d("floatingToolbar.addComment")}),(0,n.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:a,disabled:c,title:d(c?"comments.aiResponding":"floatingToolbar.sendToAI"),children:d("floatingToolbar.sendToAI")}),i&&(0,n.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",onClick:i,children:d("floatingToolbar.search")})]})}let A=(0,s.memo)(function({floatingToolbarRef:e,bumpRef:t,container:r,onAddComment:o,onSendToAI:l,onSearch:a,isChatLoading:i}){let[c,d]=(0,s.useState)(0);(0,s.useEffect)(()=>{t.current=()=>d(e=>e+1)},[t]);let u=(0,s.useMemo)(()=>e.current,[c]);return(0,n.jsx)(O,{x:u?.x??0,y:u?.y??0,visible:!!u,container:r,onAddComment:o,onSendToAI:l,onSearch:a,isChatLoading:i})});function W({x:e,y:t,comment:r,container:l,onClose:a,onUpdateComment:i,onDeleteComment:c}){let{t:d}=(0,o.Bd)(),[u,h]=(0,s.useState)(!1),[m,x]=(0,s.useState)(r.content),f=(0,s.useRef)(null),[p,g]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(f.current&&l){let r=l.getBoundingClientRect(),n=f.current.getBoundingClientRect(),s=e-r.left,o=t-r.top;s+n.width>r.width-16&&(s=r.width-n.width-16),s<16&&(s=16),o+n.height>r.height-16&&(o=o-n.height-8),o<16&&(o=16),queueMicrotask(()=>g({x:s,y:o}))}},[e,t,l]),(0,s.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&a()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a]);let b=async()=>{m.trim()&&(await i(r.id,m.trim()),h(!1))},v=async()=>{await c(r.id),a()};return(0,n.jsx)("div",{ref:f,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:p.x,top:p.y},children:(0,n.jsx)("div",{className:"p-3",children:u?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("textarea",{value:m,onChange:e=>x(e.target.value),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring",rows:3,autoFocus:!0,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),b()),"Escape"===e.key&&(h(!1),x(r.content))}}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)("button",{onClick:()=>{h(!1),x(r.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:d("common.cancel")}),(0,n.jsx)("button",{onClick:b,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:d("common.save")})]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:r.content}),(0,n.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:d("comments.lineRange",{start:r.startLine,end:r.endLine})}),(0,n.jsxs)("div",{className:"flex gap-1",children:[(0,n.jsx)("button",{onClick:()=>h(!0),className:"p-1 rounded hover:bg-accent text-muted-foreground",title:d("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"})})}),(0,n.jsx)("button",{onClick:v,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-red-9",title:d("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:"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"})})})]})]})]})})})}let z=(0,s.memo)(function({floatingToolbarRef:e,bumpRef:t,container:r,onAddComment:o,onSendToAI:l,onSearch:a,isChatLoading:i}){let[c,d]=(0,s.useState)(0);(0,s.useEffect)(()=>{t.current=()=>d(e=>e+1)},[t]);let u=(0,s.useMemo)(()=>e.current,[c]);return(0,n.jsx)(O,{x:u?.x??0,y:u?.y??0,visible:!!u,container:r,onAddComment:o,onSendToAI:l,onSearch:a,isChatLoading:i})});function H({oldContent:e,newContent:t,filePath:r,isNew:l=!1,isDeleted:c=!1,cwd:d,enableComments:u=!1,onPreview:x,previewLabel:b,onContentSearch:v}){let{t:w}=(0,o.Bd)(),y=b??w("common.preview"),k=(0,s.useMemo)(()=>E(e,t),[e,t]),N=(0,s.useRef)(null),M=(0,s.useRef)(null),T=(0,s.useRef)(null),$=(0,s.useRef)(!1),[R,P]=(0,s.useState)(!1),D=j(),O=C(),A=u&&!!d,{comments:H,addComment:_,updateComment:U,deleteComment:q,refresh:V}=p({cwd:d||"",filePath:r}),[K,J]=(0,s.useState)(null),X=(0,s.useRef)(null),Y=(0,s.useRef)(()=>{}),[Q,G]=(0,s.useState)(null),[Z,ee]=(0,s.useState)(null);(0,s.useEffect)(()=>{P(!0)},[]);let et=(0,s.useMemo)(()=>{let e=new Set;for(let t of H)for(let r=t.startLine;r<=t.endLine;r++)e.add(r);return e},[H]),er=(0,s.useMemo)(()=>{let e=new Map;for(let t of H){let r=t.endLine;e.has(r)||e.set(r,[]),e.get(r).push(t)}return e},[H]);(0,s.useEffect)(()=>{if(!A)return;let e=T.current,t=!1,r=0,n=0,s=e=>{t=!0,r=e.clientX,n=e.clientY,X.current&&(X.current=null,Y.current())},o=e=>{t=!1;let s=e.target;if(s.closest?.(".floating-toolbar"))return;let o=Math.abs(e.clientX-r)>5||Math.abs(e.clientY-n)>5,l=window.getSelection();if(!l||l.isCollapsed||!l.toString().trim()||!o){X.current&&(X.current=null,Y.current());return}let a=l.getRangeAt(0),i=T.current;if(!i||!i.contains(a.commonAncestorContainer))return;let c=e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;for(;t&&t!==i;){let e=t.closest("[data-new-line]");if(e)return parseInt(e.getAttribute("data-new-line")||"0",10);t=t.parentElement}return null},d=c(a.startContainer),u=c(a.endContainer);if(d&&u){let t=Math.min(d,u),r=Math.max(d,u),n=[],s=0;for(let e of k)("unchanged"===e.type||"added"===e.type)&&++s>=t&&s<=r&&n.push(e.content);let o=n.join("\n");X.current={x:e.clientX,y:e.clientY,range:{start:t,end:r},codeContent:o},Y.current()}},l=()=>{if(t||!X.current)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||(X.current=null,Y.current())};return e?.addEventListener("mousedown",s),document.addEventListener("mouseup",o),document.addEventListener("selectionchange",l),()=>{e?.removeEventListener("mousedown",s),document.removeEventListener("mouseup",o),document.removeEventListener("selectionchange",l)}},[A,k]);let en=(0,s.useCallback)((e,t)=>{t.stopPropagation(),J({comment:e,x:t.clientX,y:t.clientY}),X.current=null,Y.current(),G(null),ee(null)},[]),es=(0,s.useCallback)(()=>{let e=X.current;e&&(G({x:e.x,y:e.y,range:e.range,codeContent:e.codeContent}),X.current=null,Y.current())},[]),eo=(0,s.useCallback)(()=>{let e=X.current;e&&(ee({x:e.x,y:e.y,range:e.range,codeContent:e.codeContent}),X.current=null,Y.current())},[]),el=(0,s.useCallback)(()=>{let e=X.current;if(!e||!v)return;let t=e.codeContent.trim();X.current=null,Y.current(),t&&v(t)},[v]),ea=(0,s.useCallback)(async e=>{if(Z&&O&&d)try{let t=await h(d),n=[];for(let e of t)n.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});n.push({filePath:r,startLine:Z.range.start,endLine:Z.range.end,codeContent:Z.codeContent});let s=f(n,e);O.sendMessage(s),await m(d),V(),ee(null)}catch(e){console.error("Failed to send to AI:",e)}},[Z,O,r,d,V]),ei=(0,s.useCallback)(async e=>{Q&&(await _(Q.range.start,Q.range.end,e),G(null))},[Q,_]);(0,s.useEffect)(()=>{let e=M.current,t=T.current;if(!e||!t)return;let r=(e,t)=>{$.current||($.current=!0,t.scrollLeft=e.scrollLeft,requestAnimationFrame(()=>{$.current=!1}))},n=()=>r(e,t),s=()=>r(t,e);return e.addEventListener("scroll",n),t.addEventListener("scroll",s),()=>{e.removeEventListener("scroll",n),t.removeEventListener("scroll",s)}},[]);let{leftLines:ec,rightLines:ed}=(0,s.useMemo)(()=>{let e=[],t=[],r=0,n=0;for(let s=0;s<k.length;s++){let o=k[s];if("unchanged"===o.type){for(;e.length<t.length;)e.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;t.length<e.length;)t.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});r++,n++,e.push({lineNum:r,content:o.content,type:"unchanged",originalIdx:s}),t.push({lineNum:n,content:o.content,type:"unchanged",originalIdx:s})}else"removed"===o.type?(r++,e.push({lineNum:r,content:o.content,type:"removed",originalIdx:s})):"added"===o.type&&(n++,t.push({lineNum:n,content:o.content,type:"added",originalIdx:s}))}for(;e.length<t.length;)e.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;t.length<e.length;)t.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});return{leftLines:e,rightLines:t}},[k]),eu=B((0,s.useMemo)(()=>k.map(e=>e.content),[k]),r),eh=(0,i.Te)({count:ec.length,getScrollElement:()=>N.current,estimateSize:()=>20,overscan:20}),em=l?"w-1/4":c?"w-3/4":"w-1/2",ex=l?"w-3/4":c?"w-1/4":"w-1/2",ef=(0,s.useMemo)(()=>ec.map((e,t)=>{let r=ed[t];return"removed"===e.type?{type:"removed"}:r?.type==="added"?{type:"added"}:{type:"unchanged"}}),[ec,ed]),ep=eh.getTotalSize(),eg=eh.getVirtualItems();return(0,n.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(0,n.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,n.jsx)("div",{className:`${em} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:l?"(New File)":c?"Deleted":"Old"}),(0,n.jsxs)("div",{className:`${ex} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,n.jsx)("span",{className:"block text-center",children:c?"(Deleted)":"New"}),(0,n.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[x&&(0,n.jsx)("button",{onClick:x,className:"text-muted-foreground hover:text-foreground transition-colors",children:y}),!c&&t&&(0,n.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,g.oR)(w("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:w("common.copy")})]})]}),(0,n.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,n.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,n.jsx)("div",{ref:N,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,n.jsxs)("div",{className:"flex",style:{height:`${ep}px`},children:[(0,n.jsx)("div",{ref:M,className:`${em} overflow-x-auto border-r border-border`,children:(0,n.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eg.map(e=>{let t=ec[e.index];return(0,n.jsxs)("div",{style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${e.size}px`,transform:`translateY(${e.start}px)`},className:`flex ${"removed"===t.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,n.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:t.lineNum||""}),(0,n.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:t.originalIdx>=0&&eu[t.originalIdx]||I(t.content||" ")}})]},e.key)})})}),(0,n.jsx)("div",{ref:T,className:`${ex} overflow-x-auto`,children:(0,n.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eg.map(e=>{let t=ed[e.index],r=t?.lineNum||0,s=r>0&&et.has(r),o=er.get(r),l=o?.[0],a=Q&&r>=Q.range.start&&r<=Q.range.end,i=Z&&r>=Z.range.start&&r<=Z.range.end,c=a||i;return(0,n.jsxs)("div",{"data-new-line":r||void 0,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${e.size}px`,transform:`translateY(${e.start}px)`},className:`flex ${c?"bg-blue-9/20":s?"bg-amber-9/10":t?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,n.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-slate-9 select-none border-r border-border ${c?"bg-blue-9/30":""}`,style:{width:A?"52px":"40px"},children:[A&&r>0&&s&&l&&(0,n.jsx)("button",{onClick:e=>en(l,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:w("codeViewer.nComments",{count:o?.length}),children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,n.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),A&&r>0&&!s&&(0,n.jsx)("span",{className:"w-4"}),(0,n.jsx)("span",{className:"flex-1 text-right pr-1",children:r||""})]}),(0,n.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:t?.originalIdx>=0&&eu[t.originalIdx]||I(t?.content||" ")}})]},e.key)})})})]})}),(0,n.jsx)(F,{lines:ef,containerRef:N})]}),R&&D&&(0,a.createPortal)((0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(z,{floatingToolbarRef:X,bumpRef:Y,container:D,onAddComment:es,onSendToAI:eo,onSearch:v?el:void 0,isChatLoading:O?.isLoading??!1}),Q&&(0,n.jsx)(S,{x:Q.x,y:Q.y,range:Q.range,codeContent:Q.codeContent,container:D,onSubmit:ei,onClose:()=>G(null)}),Z&&(0,n.jsx)(L,{x:Z.x,y:Z.y,range:Z.range,container:D,onSubmit:ea,onClose:()=>ee(null)}),K&&(0,n.jsx)(W,{x:K.x,y:K.y,comment:K.comment,container:D,onClose:()=>J(null),onUpdateComment:U,onDeleteComment:q})]}),D)]})}function _({oldContent:e,newContent:t,filePath:r}){let o=(0,s.useMemo)(()=>E(e,t),[e,t]),l=(0,s.useRef)(null),a=B((0,s.useMemo)(()=>o.map(e=>e.content),[o]),r),c=(0,i.Te)({count:o.length,getScrollElement:()=>l.current,estimateSize:()=>20,overscan:20});return(0,n.jsx)("div",{ref:l,className:"font-mono text-sm overflow-auto h-full",children:(0,n.jsx)("div",{style:{height:`${c.getTotalSize()}px`,position:"relative"},children:c.getVirtualItems().map(e=>{let t=o[e.index];return(0,n.jsxs)("div",{style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${e.size}px`,transform:`translateY(${e.start}px)`},className:`flex ${"removed"===t.type?"bg-red-9/15 dark:bg-red-9/25":"added"===t.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,n.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"added"!==t.type?t.oldLineNum:""}),(0,n.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"removed"!==t.type?t.newLineNum:""}),(0,n.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===t.type?"text-red-11":"added"===t.type?"text-green-11":"text-slate-9"}`,children:"removed"===t.type?"-":"added"===t.type?"+":" "}),(0,n.jsx)("span",{className:"flex-1 whitespace-pre pl-1",dangerouslySetInnerHTML:{__html:a[e.index]||I(t.content||" ")}})]},e.key)})})})}let U={ts:"#3178c6",tsx:"#3178c6",js:"#f1e05a",jsx:"#61dafb",mjs:"#f1e05a",cjs:"#f1e05a",html:"#e44d26",css:"#563d7c",scss:"#cd6799",sass:"#cd6799",less:"#1d365d",vue:"#41b883",svelte:"#ff3e00",json:"#cbcb41",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4121",xml:"#e37933",env:"#ecd53f",md:"#519aba",mdx:"#519aba",txt:"#89898a",py:"#3572a5",go:"#00add8",rs:"#dea584",java:"#b07219",kt:"#a97bff",kts:"#a97bff",c:"#555555",h:"#555555",cpp:"#f34b7d",hpp:"#f34b7d",rb:"#701516",php:"#4f5d95",sh:"#89e051",bash:"#89e051",zsh:"#89e051",png:"#a074c4",jpg:"#a074c4",jpeg:"#a074c4",gif:"#a074c4",svg:"#ffb13b",webp:"#a074c4",ico:"#a074c4",lock:"#89898a",gitignore:"#f14e32",dockerfile:"#2496ed",sql:"#e38c00",graphql:"#e535ab",gql:"#e535ab",default:"#8a8a8a"},q={"package.json":"#cb3837","package-lock.json":"#cb3837","tsconfig.json":"#3178c6","jsconfig.json":"#f1e05a",".gitignore":"#f14e32",".eslintrc":"#4b32c3",".eslintrc.js":"#4b32c3",".eslintrc.json":"#4b32c3",".prettierrc":"#56b3b4",dockerfile:"#2496ed",".env":"#ecd53f",".env.local":"#ecd53f",".env.development":"#ecd53f",".env.production":"#ecd53f","readme.md":"#519aba",license:"#d4af37",makefile:"#6d8086","cargo.toml":"#dea584","go.mod":"#00add8","go.sum":"#00add8","requirements.txt":"#3572a5","yarn.lock":"#2c8ebb","pnpm-lock.yaml":"#f9ad00","vite.config.ts":"#646cff","vite.config.js":"#646cff","next.config.js":"#000000","next.config.mjs":"#000000","tailwind.config.js":"#38bdf8","tailwind.config.ts":"#38bdf8"};function V({name:e,className:t="",size:r=16}){let s,o=q[s=e.toLowerCase()]?q[s]:U[e.split(".").pop()?.toLowerCase()||""]||U.default,l=e.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:o}),(0,n.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:o}),(0,n.jsx)("path",{d:"M10 10v6c0 1-1 2-2 2M14 10v4c0 2 4 2 4 0v-4",stroke:"#323330",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):"jsx"===l||"tsx"===l&&e.includes("component")?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,n.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M6 4C4 4 4 6 4 8v2c0 1-1 2-2 2 1 0 2 1 2 2v2c0 2 0 4 2 4",stroke:o,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,n.jsx)("path",{d:"M18 4c2 0 2 2 2 4v2c0 1 1 2 2 2-1 0-2 1-2 2v2c0 2 0 4-2 4",stroke:o,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:o})]}):["md","mdx"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M5 15V9l3 4 3-4v6M17 12l-2-3v6M17 12l2-3v6",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["py","pyi","pyx"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M12 4c-4 0-4 2-4 3v2h5v1H6c-2 0-3 2-3 4s1 4 3 4h2v-2c0-2 1-3 3-3h4c1 0 2-1 2-2V7c0-2-2-3-5-3z",fill:"#3572a5"}),(0,n.jsx)("path",{d:"M12 20c4 0 4-2 4-3v-2h-5v-1h7c2 0 3-2 3-4s-1-4-3-4h-2v2c0 2-1 3-3 3h-4c-1 0-2 1-2 2v4c0 2 2 3 5 3z",fill:"#ffd43b"}),(0,n.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,n.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:o}),(0,n.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,n.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,n.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,n.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:o,strokeWidth:"2",fill:"none"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:o}),(0,n.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:o}),(0,n.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:o,strokeWidth:"1.5",fill:"none"})]}):"html"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:o}),(0,n.jsx)("path",{d:"M8 7h8l-.5 6-3.5 1-3.5-1-.2-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["css","scss","sass","less"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:o}),(0,n.jsx)("path",{d:"M15 8H9l.3 3h5.2l-.4 4-2.1.7-2.1-.7-.1-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["yaml","yml"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,n.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===l||".gitignore"===e.toLowerCase()?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:o}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,n.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===l||"dockerfile"===e.toLowerCase()||e.toLowerCase().startsWith("dockerfile")?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:o}),(0,n.jsx)("path",{d:"M21 13c-1-2-3-2-4-2h-1c0-1 0-2-2-3h-1v1c0 1-1 2-2 2H3c-1 3 0 6 2 8s5 3 9 3c5 0 8-2 10-6",stroke:o,strokeWidth:"1.5",fill:"none"})]}):"env"===l||e.startsWith(".env")?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:o}),(0,n.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:o,strokeWidth:"1.5",fill:"none"})]}):"vue"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:o}),(0,n.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M14 3v5h5",stroke:o,strokeWidth:"1.5",fill:"none"})]})}function K({status:e}){let{label:t,className:r}={added:{label:"A",className:"text-green-11"},untracked:{label:"A",className:"text-green-11"},modified:{label:"M",className:"text-amber-11"},deleted:{label:"D",className:"text-red-11"},renamed:{label:"R",className:"text-brand"}}[e]||{label:"?",className:"text-muted-foreground"};return(0,n.jsx)("span",{className:`text-xs font-bold ${r}`,children:t})}let J=s.memo(function e({node:t,level:r,selectedPath:o,expandedPaths:l,onSelect:a,onToggle:i,onContextMenu:c,showChanges:d=!1,renderActions:u}){let h=o===t.path,m=l.has(t.path),x=(0,s.useCallback)(()=>{t.isDirectory?i(t.path):a(t)},[t,a,i]),f=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),c(e,t.path,t.isDirectory)},[t.path,t.isDirectory,c]);return t.isDirectory?(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-accent cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*r+8}px`},onClick:x,onContextMenu:f,children:[(0,n.jsx)("span",{className:"text-slate-9 text-xs",children:m?"▼":"▶"}),(0,n.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":t.path,children:t.name}),u&&u(t)]}),m&&t.children.map(t=>(0,n.jsx)(e,{node:t,level:r+1,selectedPath:o,expandedPaths:l,onSelect:a,onToggle:i,onContextMenu:c,showChanges:d,renderActions:u},t.path))]}):(0,n.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${h?"bg-brand/10":"hover:bg-accent"}`,style:{paddingLeft:`${12*r+8}px`},onClick:x,onContextMenu:f,children:[(0,n.jsx)(V,{name:t.name,size:16,className:"flex-shrink-0"}),(0,n.jsx)("span",{className:`text-sm flex-1 truncate ${h?"text-brand":"text-foreground"}`,"data-tooltip":t.path,children:t.name}),t.status&&(0,n.jsx)(K,{status:t.status}),d&&void 0!==t.additions&&void 0!==t.deletions&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"text-xs text-green-11",children:["+",t.additions]}),(0,n.jsxs)("span",{className:"text-xs text-red-11",children:["-",t.deletions]})]}),u&&u(t)]})});function X({files:e,selectedPath:t,expandedPaths:r,onSelect:s,onToggle:l,cwd:a,showChanges:i=!1,renderActions:c,emptyMessage:d,className:u}){let{t:h}=(0,o.Bd)(),m=d??h("gitFileTree.noFiles"),{contextMenu:x,showContextMenu:f,hideContextMenu:p}=y();return 0===e.length?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-slate-9",children:m}):(0,n.jsxs)("div",{className:u||"py-1 overflow-y-auto h-full min-w-max",children:[e.map(e=>(0,n.jsx)(J,{node:e,level:0,selectedPath:t,expandedPaths:r,onSelect:s,onToggle:l,onContextMenu:f,showChanges:i,renderActions:c},e.path)),x&&(0,n.jsx)(w,{x:x.x,y:x.y,path:x.path,cwd:a,isDirectory:x.isDirectory,onClose:p})]})}function Y(e){let t=[];for(let r of e){let e=r.path.split("/"),n=t;for(let t=0;t<e.length;t++){let s=e[t],o=t===e.length-1,l=e.slice(0,t+1).join("/"),a=n.find(e=>e.name===s);a||(a={name:s,path:l,isDirectory:!o,children:[],...o&&{status:r.status,additions:r.additions,deletions:r.deletions,oldPath:r.oldPath,file:r}},n.push(a)),o||(n=a.children)}}let r=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>r(e.children))};return r(t),t}function Q(e){let t=[],r=e=>{for(let n of e)n.isDirectory&&(t.push(n.path),r(n.children))};return r(e),t}function G(e){let t=[],r=e=>{if(e.isDirectory)for(let t of e.children)r(t);else t.push(e)};return r(e),t}function Z(e){try{let t=JSON.parse(e);return el(t,0)}catch{return e}}let ee="#79c0ff",et="#a5d6ff",er="#ff7b72",en="#8b949e",es=(e,t)=>s.createElement("span",{style:{color:e}},t);function eo({label:e,labelColor:t,value:r,indent:n}){let[o,l]=s.useState(!1),[a,i]=s.useState({x:0,y:0}),d="string"==typeof r&&r.replace(/\\n/g,"\n").split("\n").length>3,u={onMouseDown:e=>{i({x:e.clientX,y:e.clientY})},onClick:e=>{let t=e.clientX-a.x,r=e.clientY-a.y;t*t+r*r>25||(e.stopPropagation(),l(e=>!e))},style:{cursor:"pointer"}};if(d&&o&&"string"==typeof r){let n=r.replace(/\\n/g,"\n").split("\n")[0],o=r.replace(/\\n/g,"\n").split("\n").length;return s.createElement("span",u,es(t,e),es(en,": "),es(et,n),es("#6e7681",` ${c.A.t("toolCall.foldedLines",{count:o})}`))}let h=s.createElement(s.Fragment,null,es(t,e),es(en,": "),el(r,n));return d?s.createElement("span",u,h):h}function el(e,t){let r=" ".repeat(t);if(null===e)return es(er,"null");if(void 0===e)return es(er,"undefined");if("string"==typeof e)return es(et,e.replace(/\\n/g,"\n").replace(/\n/g,"\n"+r));if("number"==typeof e)return es("#79c0ff",String(e));if("boolean"==typeof e)return es(er,String(e));if(Array.isArray(e))return 0===e.length?es(en,"[]"):s.createElement(s.Fragment,null,es(en,"["),"\n",...e.map((n,o)=>s.createElement("span",{key:o},r+" ",s.createElement(eo,{label:`[${o}]`,labelColor:ee,value:n,indent:t+1}),o<e.length-1?s.createElement(s.Fragment,null,es(en,","),"\n"):"\n")),r,es(en,"]"));if("object"==typeof e){let n=Object.entries(e);return 0===n.length?es(en,"{}"):s.createElement(s.Fragment,null,es(en,"{"),"\n",...n.map(([e,o],l)=>s.createElement("span",{key:e},r+" ",s.createElement(eo,{label:e,labelColor:ee,value:o,indent:t+1}),l<n.length-1?s.createElement(s.Fragment,null,es(en,","),"\n"):"\n")),r,es(en,"}"))}return String(e)}let ea=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function ei(e){let t=e.slice(e.lastIndexOf(".")).toLowerCase();return ea.has(t)}function ec(e){return e.toLowerCase().endsWith(".md")}let ed="json-search-highlight-style";function eu(e){let[t,r]=(0,s.useState)(!1),[n,o]=(0,s.useState)(""),[l,a]=(0,s.useState)(!1),[i,c]=(0,s.useState)(0),[d,u]=(0,s.useState)(0),h=(0,s.useRef)(null),m=(0,s.useRef)([]),x=(0,s.useCallback)(()=>{let t;CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),m.current=[];let r=e.current;if(!r||!n){c(0),u(0);return}!function(){if(document.getElementById(ed))return;let e=document.createElement("style");e.id=ed,e.textContent="::highlight(json-search){background:rgba(217,119,6,.3)}::highlight(json-search-current){background:rgba(217,119,6,.5)}",document.head.appendChild(e)}();let s=r.textContent||"",o=l?n:n.toLowerCase(),a=l?s:s.toLowerCase(),i=[],d=0;for(;d<a.length;){let e=a.indexOf(o,d);if(-1===e)break;i.push([e,e+o.length]),d=e+1}if(0===i.length){c(0),u(0);return}let h=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),x=0,f=0,p=[],g=null,b=0;for(;(t=h.nextNode())&&f<i.length;){let e=t.textContent?.length||0,r=x,n=x+e;for(;f<i.length;){let[e,s]=i[f];if(e>=n)break;if(!g)if(e>=r)(g=document.createRange()).setStart(t,e-r),b=s;else break;if(b<=n)g.setEnd(t,b-r),p.push(g),g=null,f++;else break}x=n}m.current=p,c(p.length),u(e=>p.length>0?Math.min(e,p.length-1):0),CSS.highlights&&p.length>0&&CSS.highlights.set("json-search",new Highlight(...p))},[e,n,l]),f=(0,s.useCallback)((e,t)=>{let r=e.getBoundingClientRect();(t.top<r.top||t.bottom>r.bottom)&&(e.scrollTop+=t.top-r.top-r.height/2+t.height/2)},[]),p=(0,s.useCallback)(t=>{CSS.highlights?.delete("json-search-current");let r=m.current[t];if(!r||!CSS.highlights)return;CSS.highlights.set("json-search-current",new Highlight(r));let n=r.getBoundingClientRect(),s=e.current?.parentElement;s&&f(s,n)},[e,f]);(0,s.useEffect)(()=>{queueMicrotask(()=>x())},[x]),(0,s.useEffect)(()=>{p(d)},[d,i,p]),(0,s.useEffect)(()=>{let t=e.current;if(!t||!n)return;let r=new MutationObserver(()=>x());return r.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[e,n,x]),(0,s.useEffect)(()=>{t||(CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),m.current=[])},[t]),(0,s.useEffect)(()=>()=>{CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current")},[]);let g=(0,s.useCallback)(()=>{0!==i&&u(e=>(e+1)%i)},[i]),b=(0,s.useCallback)(()=>{0!==i&&u(e=>(e-1+i)%i)},[i]),v=(0,s.useCallback)(()=>{r(!0),setTimeout(()=>h.current?.focus(),0)},[]),j=(0,s.useCallback)(()=>{r(!1),o(""),u(0)},[]),w=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?b():g()),"Escape"===e.key&&(e.preventDefault(),j())},[g,b,j]);return{isVisible:t,query:n,setQuery:o,caseSensitive:l,setCaseSensitive:a,matchCount:i,currentIndex:d,searchInputRef:h,open:v,close:j,goToNext:g,goToPrev:b,handleKeyDown:w}}function eh({search:e}){return e.isVisible?s.createElement("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border"},s.createElement("input",{ref:e.searchInputRef,type:"text",value:e.query,onChange:t=>e.setQuery(t.target.value),onKeyDown:e.handleKeyDown,placeholder:c.A.t("codeViewer.searchPlaceholder"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),s.createElement("button",{onClick:()=>e.setCaseSensitive(e=>!e),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${e.caseSensitive?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:c.A.t("codeViewer.caseSensitive")},"Aa"),s.createElement("span",{className:"text-xs text-muted-foreground"},e.matchCount>0?`${e.currentIndex+1}/${e.matchCount}`:c.A.t("common.noMatch")),s.createElement("button",{onClick:e.goToPrev,disabled:0===e.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:c.A.t("common.previous")},s.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}))),s.createElement("button",{onClick:e.goToNext,disabled:0===e.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:c.A.t("common.next")},s.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),s.createElement("button",{onClick:e.close,className:"p-1 rounded hover:bg-accent",title:c.A.t("common.close")},s.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))):null}function em({isOpen:e,onClose:t,commit:r,cwd:l,embedded:a=!1,initialFilePath:i,onContentSearch:c}){let{t:d}=(0,o.Bd)(),[u,h]=(0,s.useState)([]),[m,x]=(0,s.useState)([]),[f,p]=(0,s.useState)(new Set),[g,b]=(0,s.useState)(null),[v,j]=(0,s.useState)(null),[w,y]=(0,s.useState)(!1),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(null),L=(0,s.useRef)(null),E=eu(L);(0,s.useEffect)(()=>{let r=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&C){e.preventDefault(),E.open();return}if("Escape"===e.key){if(E.isVisible)return void E.close();if(C)return void S(null);t()}};if(e)return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t,C,E]),(0,s.useEffect)(()=>{e&&r&&(queueMicrotask(()=>{h([]),x([]),b(null),j(null),y(!0)}),fetch(`/api/git/commit-diff?cwd=${encodeURIComponent(l)}&hash=${r.hash}`).then(e=>e.json()).then(e=>{let t=e.files||[];h(t);let n=Y(t);if(x(n),p(new Set(Q(n))),i&&t.length>0){let e=t.find(e=>e.path===i);e&&setTimeout(()=>{b(e),fetch(`/api/git/commit-diff?cwd=${encodeURIComponent(l)}&hash=${r.hash}&file=${encodeURIComponent(e.path)}`).then(e=>e.json()).then(e=>j(e)).catch(console.error)},0)}}).catch(console.error).finally(()=>y(!1)))},[e,r,l,i]);let M=(0,s.useCallback)(e=>{r&&(b(e),N(!0),fetch(`/api/git/commit-diff?cwd=${encodeURIComponent(l)}&hash=${r.hash}&file=${encodeURIComponent(e.path)}`).then(e=>e.json()).then(e=>j(e)).catch(console.error).finally(()=>N(!1)))},[l,r]),T=(0,s.useCallback)(e=>{p(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),$=(0,s.useMemo)(()=>{if(!r)return"";if(r.date){let e,t,n,s,o,l,a;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"),l=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),n?`${s}-${o} ${l}:${a}`:`${e.getFullYear()}-${s}-${o} ${l}:${a}`}return r.time?new Date(1e3*r.time).toLocaleString():""},[r]);if(!e||!r)return null;let R=(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 bg-secondary 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-slate-9",children:d("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-slate-9",children:d("commitDetail.author")}),(0,n.jsx)("span",{children:r.author}),(0,n.jsxs)("span",{className:"text-slate-9",children:["<",r.authorEmail,">"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-slate-9",children:d("commitDetail.date")}),(0,n.jsx)("span",{children:$}),r.relativeDate&&(0,n.jsxs)("span",{className:"text-slate-9",children:["(",r.relativeDate,")"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-slate-9",children:d("commitDetail.files")}),(0,n.jsx)("span",{children:d("commitDetail.nChanges",{count:u.length})})]})]})]}),(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:w?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:d("commitDetail.loadingFiles")}):(0,n.jsx)(X,{files:m,selectedPath:g?.path||null,expandedPaths:f,onSelect:e=>e.file&&M(e.file),onToggle:T,cwd:l,showChanges:!0,emptyMessage:d("commitDetail.noFileChanges"),className:"py-1"})}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden",children:k?(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:d("commitDetail.loadingDiff")}):v?(0,n.jsx)(H,{oldContent:v.oldContent,newContent:v.newContent,filePath:v.filePath,isNew:v.isNew,isDeleted:v.isDeleted,cwd:l,enableComments:!0,onPreview:!v.isDeleted&&v.filePath.endsWith(".json")?()=>S({content:v.newContent,filePath:v.filePath}):void 0,previewLabel:d("common.readable"),onContentSearch:c}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:d("commitDetail.selectFileToView")})})]})]}),P=C&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>S(null),children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl 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:C.filePath}),(0,n.jsx)("button",{onClick:()=>S(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent 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)(eh,{search:E}),(0,n.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,n.jsx)("pre",{ref:L,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:Z(C.content)})})]})});return a?(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-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",title:d("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"})})}),R,P]}):(0,n.jsx)("div",{className:"fixed inset-0 z-[60] bg-black/50",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:d("commitDetail.title")}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent 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"})})})]}),R,P]})})}let ex={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"},"?":{text:"text-slate-9",bg:"bg-slate-9/20"},R:{text:"text-blue-11",bg:"bg-blue-9/20"}},ef=s.memo(function({item:e,isSelected:t,isExpanded:r,isLoading:o,onSelect:l,onToggle:a,onContextMenu:i,renderActions:c}){let{node:d,level:u,gitStatus:h,hasChangedChildren:m}=e,x=h?ex[h]:null,f=(0,s.useCallback)(()=>{d.isDirectory?a(d.path):l(d.path)},[d.isDirectory,d.path,l,a]),p=(0,s.useCallback)(e=>{i(e,d.path,d.isDirectory)},[d.path,d.isDirectory,i]),g=!d.isDirectory&&(".env"===d.name||d.name.startsWith(".env.")),b=h?x.text:m?"text-amber-11":g?"text-yellow-600 dark:text-yellow-500":t&&!d.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-accent ${t?"bg-brand/10":""}`,style:{paddingLeft:`${12*u+8}px`},onClick:f,onContextMenu:p,children:[d.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)(V,{name:d.name,size:16,className:"flex-shrink-0 ml-4"}),(0,n.jsx)("span",{className:`text-sm truncate flex-1 ${b}`,"data-tooltip":d.isSymlink&&d.symlinkTarget?`${d.path} → ${d.symlinkTarget}`:d.path,children:d.name}),d.isSymlink&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:"→"}),h&&(0,n.jsx)("span",{className:`text-xs font-mono px-1 rounded ${x.text} ${x.bg} flex-shrink-0`,children:h}),d.isDirectory&&m&&(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-9 flex-shrink-0"}),c?.(d)]})});function ep({files:e,selectedPath:t,expandedPaths:r,matchedPaths:o=null,gitStatusMap:l=null,loadingDirs:a,onSelect:c,onToggle:d,cwd:u,shouldScrollToSelected:h=!1,onScrolledToSelected:m,className:x,renderActions:f,onCreateFile:p,onDelete:g,onRefresh:b,onCopyFile:v,onPaste:j}){let k=(0,s.useRef)(null),{contextMenu:N,showContextMenu:C,hideContextMenu:S}=y(),L=(0,s.useMemo)(()=>(function e(t,r,n,s=null,o=0){let l=[];for(let a of t){if(null!==n&&!n.has(a.path))continue;let t=s?.get(a.path),i=a.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}(a.path,s):void 0;l.push({node:a,level:o,gitStatus:t,hasChangedChildren:i}),a.isDirectory&&a.children&&r.has(a.path)&&l.push(...e(a.children,r,n,s,o+1))}return l})(e,r,o,l),[e,r,o,l]),E=(0,i.Te)({count:L.length,getScrollElement:()=>k.current,estimateSize:()=>26,overscan:10}),M=(0,s.useRef)(m);return(M.current=m,(0,s.useEffect)(()=>{if(h&&t&&L.length>0){let e=L.findIndex(e=>e.node.path===t);if(e>=0){let t=setTimeout(()=>{E.scrollToIndex(e,{align:"center"}),M.current?.()},150);return()=>clearTimeout(t)}}},[h,t,L,E]),0===L.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:`${E.getTotalSize()}px`,width:"100%",position:"relative"},children:E.getVirtualItems().map(e=>{let s=L[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)(ef,{item:s,isSelected:t===s.node.path,isExpanded:r.has(s.node.path),isLoading:a?.has(s.node.path),onSelect:c,onToggle:d,onContextMenu:C,renderActions:f})},s.node.path)})}),N&&(0,n.jsx)(w,{x:N.x,y:N.y,path:N.path,cwd:u,isDirectory:N.isDirectory,onClose:S,onCreateFile:p,onDelete:g,onRefresh:b,onCopyFile:v,onPaste:j})]})}function eg({blame:e,onClick:t}){let{t:r}=(0,o.Bd)(),l=(0,s.useRef)(null),i=(0,s.useRef)(null),d=(0,s.useRef)(!1),u=(0,s.useRef)(!1),h=(0,s.useRef)(null),m=(0,s.useRef)(null),x=(0,s.useRef)(null),f=(0,s.useRef)(e);(0,s.useEffect)(()=>{f.current=e},[e]);let p=(0,s.useRef)(t);(0,s.useEffect)(()=>{p.current=t},[t]);let g=(0,s.useCallback)(()=>{let e,t=i.current,r=l.current;if(!t||!r)return;let n=r.getBoundingClientRect(),s=t.getBoundingClientRect(),o=window.innerWidth,a=window.innerHeight,c=n.left;c+s.width>o-8&&(c=o-s.width-8),c<8&&(c=8),(e=n.top-s.height-4<0?n.bottom+4:n.top-s.height-4)+s.height>a-8&&(e=a-s.height-8),t.style.left=`${c}px`,t.style.top=`${e}px`},[]),b=(0,s.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null),m.current&&(clearTimeout(m.current),m.current=null),d.current=!1,u.current=!1,i.current&&(i.current.style.display="none"),x.current&&(document.removeEventListener("mousedown",x.current.down),document.removeEventListener("mouseup",x.current.up),x.current=null)},[]),v=(0,s.useCallback)(()=>{let e=i.current;if(!e||d.current)return;d.current=!0,e.style.left="-9999px",e.style.top="-9999px",e.style.display="block",requestAnimationFrame(()=>requestAnimationFrame(g));let t=0,r=0,n=e=>{t=e.clientX,r=e.clientY},s=e=>{if(!(Math.abs(e.clientX-t)>5||Math.abs(e.clientY-r)>5)){let t;t=e.target,i.current?.contains(t)||l.current?.contains(t)||b()}};document.addEventListener("mousedown",n),document.addEventListener("mouseup",s),x.current={down:n,up:s}},[g,b]),j=(0,s.useCallback)(()=>{if(h.current&&clearTimeout(h.current),m.current&&(clearTimeout(m.current),m.current=null),d.current)return;let e=window.getSelection();(!e||e.isCollapsed)&&(h.current=setTimeout(v,500))},[v]),w=(0,s.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null),d.current&&(m.current=setTimeout(()=>{u.current||b()},200))},[b]),y=(0,s.useCallback)(()=>{u.current=!0,m.current&&(clearTimeout(m.current),m.current=null)},[]),k=(0,s.useCallback)(()=>{u.current=!1,b()},[b]),N=(0,s.useCallback)(e=>{e.stopPropagation();let t=window.getSelection();t&&t.toString().length>0&&i.current?.contains(t.anchorNode)||(p.current?.(f.current),b())},[b]);(0,s.useEffect)(()=>()=>b(),[b]);let C=e.message.split("\n")[0]||"",S=e.message.split("\n").slice(1).join("\n").trim();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{ref:l,className:"select-none text-xs text-muted-foreground/50 ml-6 cursor-default hover:text-muted-foreground/80",onMouseEnter:j,onMouseLeave:w,children:[e.author.split(" ")[0],", ",function(e){let t=c.A.t,r=Math.floor((Date.now()-1e3*e)/1e3);if(r<60)return t("common.justNow");let n=Math.floor(r/60);if(n<60)return t("common.minutesAgo",{count:n});let s=Math.floor(n/60);if(s<24)return t("common.hoursAgo",{count:s});let o=Math.floor(s/24);if(o<30)return t("common.daysAgo",{count:o});let l=Math.floor(o/30);return l<12?t("common.monthsAgo",{count:l}):t("common.yearsAgo",{count:Math.floor(l/12)})}(e.time)," \xb7 ",C]}),(0,a.createPortal)((0,n.jsxs)("div",{ref:i,className:"fixed z-[9999] bg-card border border-border rounded-lg shadow-xl p-3 text-xs text-foreground whitespace-pre-wrap max-w-md select-text",style:{display:"none",minWidth:280,cursor:"text"},"data-inline-blame-tip":"",onMouseEnter:y,onMouseLeave:k,children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,n.jsx)("span",{className:"font-mono text-brand",children:e.hash}),(0,n.jsx)("span",{className:"text-muted-foreground",children:e.author}),(0,n.jsx)("span",{className:"text-muted-foreground/60",children:new Date(1e3*e.time).toLocaleString()})]}),(0,n.jsx)("div",{className:"font-medium",children:C}),S&&(0,n.jsx)("div",{className:"mt-1 text-muted-foreground",children:S}),(0,n.jsx)("div",{className:"mt-2 text-[11px] text-brand border-t border-border pt-2 cursor-pointer hover:underline",onClick:N,children:r("codeViewer.clickToViewDetails")})]}),document.body)]})}let eb=[{bg:"rgba(59, 130, 246, 0.15)",border:"rgb(59, 130, 246)"},{bg:"rgba(16, 185, 129, 0.15)",border:"rgb(16, 185, 129)"},{bg:"rgba(245, 158, 11, 0.15)",border:"rgb(245, 158, 11)"},{bg:"rgba(239, 68, 68, 0.15)",border:"rgb(239, 68, 68)"},{bg:"rgba(168, 85, 247, 0.15)",border:"rgb(168, 85, 247)"},{bg:"rgba(236, 72, 153, 0.15)",border:"rgb(236, 72, 153)"},{bg:"rgba(20, 184, 166, 0.15)",border:"rgb(20, 184, 166)"},{bg:"rgba(249, 115, 22, 0.15)",border:"rgb(249, 115, 22)"}];function ev(e,t){let r,n=document.caretRangeFromPoint(e.clientX,e.clientY);if(!n||!t.contains(n.startContainer))return 1;let s=n.startContainer,o=n.startOffset,l=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),a=1;for(;r=l.nextNode();){if(r===s){a+=o;break}a+=r.textContent?.length||0}return a}let ej=(0,s.memo)(function({virtualKey:e,lineNum:t,highlightedHtml:r,hasComments:l,firstComment:a,lineCommentsCount:i,isInRange:c,showLineNumbers:d,lineNumChars:u,commentsEnabled:h,virtualItemSize:m,virtualItemStart:x,onCommentBubbleClick:f,onCmdClick:p,onTokenHover:g,onTokenHoverLeave:b,flashLine:v,blameLine:j,showBlameInfo:w,blameAuthorColor:y,isBlameHovered:k,onBlameClick:N,onBlameMouseEnter:C,onBlameMouseLeave:S,inlineBlameData:L,onInlineBlameClick:E,isCursorLine:M,cursorCol:T}){let{t:$}=(0,o.Bd)(),R=(0,s.useMemo)(()=>M&&null!=T?function(e,t){let r=0,n=0;for(;n<e.length;){if("<"===e[n]){let t=e.indexOf(">",n);if(-1!==t){n=t+1;continue}}if(r===t){let t;if("&"===e[n]){let r=e.indexOf(";",n);t=-1!==r&&r-n<10?r+1:n+1}else t=n+1;let r=e.substring(n,t);return e.substring(0,n)+'<span class="vi-char-cursor">'+r+"</span>"+e.substring(t)}if("&"===e[n]){let t=e.indexOf(";",n);n=-1!==t&&t-n<10?t+1:n+1}else n++;r++}return e+'<span class="vi-char-cursor"> </span>'}(r,T):r,[r,M,T]),P=(0,s.useCallback)(e=>{if(!e.metaKey||!p)return;e.preventDefault(),e.stopPropagation();let r=e.currentTarget,n=ev(e,r);window.getSelection()?.removeAllRanges(),p(t,n)},[t,p]),I=(0,s.useCallback)(e=>{if(!g||0!==e.buttons)return;let r=window.getSelection();if(r&&!r.isCollapsed)return;let n=e.target;if("SPAN"!==n.tagName||!n.style.color)return;let s=e.currentTarget,o=ev(e,s),l=n.getBoundingClientRect();g(t,o,{x:l.left,y:l.bottom+4})},[t,g]),D=(0,s.useCallback)(()=>{j&&N&&N(j)},[j,N]),B=(0,s.useCallback)(e=>{j&&C&&C(j,e)},[j,C]);return(0,n.jsxs)("div",{"data-line":t,style:{position:"absolute",top:0,left:0,width:"100%",height:`${m}px`,transform:`translateY(${x}px)`,backgroundColor:k&&y?y.bg:void 0},className:`flex ${v===t?"flash-line":""} ${M?"vi-cursor-line":""} ${c?"bg-blue-9/20":l?"bg-amber-9/10":"hover:bg-accent/50"}`,children:[(0,n.jsxs)("div",{className:"flex shrink-0 sticky left-0 z-[2] bg-secondary",style:{backgroundColor:k&&y?y.bg:void 0},children:[j&&y&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"w-1 flex-shrink-0",style:{backgroundColor:y.border}}),(0,n.jsx)("div",{className:"w-48 flex-shrink-0 px-2 flex items-center gap-2 border-r border-border text-muted-foreground cursor-pointer hover:bg-accent/50",onMouseEnter:B,onMouseLeave:S,onClick:D,title:$("codeViewer.clickToViewCommit"),children:w?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"font-medium",style:{color:y.border},children:j.hash}),(0,n.jsx)("span",{className:"truncate flex-1",children:j.author.split(" ")[0]})]}):null})]}),d&&(0,n.jsxs)("span",{className:`flex-shrink-0 flex items-center justify-end gap-0.5 pr-2 select-none border-r border-border font-variant-tabular ${c?"bg-blue-9/30 text-blue-11":"bg-card/50 text-slate-9"}`,children:[h&&l&&a&&(0,n.jsx)("button",{onClick:e=>f(a,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:$("codeViewer.nComments",{count:i}),children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,n.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),h&&!l&&(0,n.jsx)("span",{className:"w-4"}),(0,n.jsx)("span",{className:"text-right",style:{minWidth:`${u}ch`},children:t})]})]}),(0,n.jsxs)("span",{className:"flex-1 px-3 whitespace-pre select-text",onClick:P,onMouseOver:I,onMouseLeave:b,"data-code-content":!0,children:[(0,n.jsx)("span",{dangerouslySetInnerHTML:{__html:R}}),L&&(0,n.jsx)(eg,{blame:L,onClick:E})]})]},e)});function ew(e,t,r){let n,s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=0;for(;(n=s.nextNode())&&n!==t;)o+=n.textContent.length;return o+r}function ey(e,t){let r,n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=t,o=null;for(;r=n.nextNode();){o=r;let e=r.textContent.length;if(s<=e)return{node:r,offset:s};s-=e}return o?{node:o,offset:o.textContent.length}:null}function ek(e,t){for(let r of e){if(r.path===t)return r;if(r.children){let e=ek(r.children,t);if(e)return e}}return null}function eN(e){let t=[];for(let r of e){let e=r.split("/"),n=t;for(let t=0;t<e.length;t++){let r=e[t],s=t===e.length-1,o=e.slice(0,t+1).join("/"),l=n.find(e=>e.name===r);l||(l={name:r,path:o,isDirectory:!s,children:s?void 0:[]},n.push(l)),!s&&l.children&&(n=l.children)}}let r=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>{e.children&&r(e.children)})};return r(t),t}function eC(e){let t=[],r=e=>{for(let n of e)n.isDirectory&&(t.push(n.path),n.children&&r(n.children))};return r(e),t}let eS=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp"]),eL=()=>{},eE="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function eM(e){let t=window.getSelection();if(!t?.rangeCount)return null;let r=t.getRangeAt(0),n=r.startContainer;for(;n&&n.parentElement!==e;)n=n.parentElement;if(!n)return null;let s=Array.from(e.children).indexOf(n);if(s<0)return null;let o=document.createRange();return o.selectNodeContents(n),o.setEnd(r.startContainer,r.startOffset),{line:s,offset:o.toString().length}}function eT(e,t){let r,n=e.children[t.line];if(!n)return;let s=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),o=t.offset;for(;r=s.nextNode();){let e=r.textContent?.length||0;if(o<=e){let e=window.getSelection(),t=document.createRange();t.setStart(r,o),t.collapse(!0),e?.removeAllRanges(),e?.addRange(t);return}o-=e}let l=window.getSelection(),a=document.createRange();a.selectNodeContents(n),a.collapse(!1),l?.removeAllRanges(),l?.addRange(a)}function e$(e){return e.map(e=>`<div style="${eE}">${e}</div>`).join("")}let eR=(0,s.forwardRef)(function({content:e,filePath:t,showLineNumbers:r=!0,showSearch:l=!0,className:c="",cwd:d,enableComments:u=!1,scrollToLine:x=null,scrollToLineAlign:b="center",onScrollToLineComplete:v,highlightKeyword:w=null,visibleLineRef:y,onCmdClick:k,onTokenHover:N,onTokenHoverLeave:E,onTokenHoverCancel:M,blameLines:T,inlineBlameLines:$,onSelectCommit:F,editable:O=!1,initialMtime:z,onEditorClose:H,onSaved:_,onEditorStateChange:U,viMode:q=!1,onContentMutate:V,onEnterInsertMode:K,onViSave:J,viStateRef:X,initialCursorLine:Y,initialCursorCol:Q,onInitialCursorSet:G,onContentSearch:Z},ee){var et;let er,en,es,eo,el,{t:ea}=(0,o.Bd)(),ei=(0,s.useRef)(e),ec=(0,s.useRef)(!1),[ed,eu]=(0,s.useState)(!1),[eh,em]=(0,s.useState)(!1),[ex,ef]=(0,s.useState)(()=>e.split("\n").length),ep=(0,s.useRef)(e.split("\n").length),[eg,ev]=(0,s.useState)({show:!1}),ek=(0,s.useRef)(null),eN=(0,s.useRef)(null),eC=(0,s.useRef)(z),eS=(0,s.useRef)(null),eL=(0,s.useRef)(!1),eR=(0,s.useRef)(!1),{parentRef:eP,containerRef:eI,searchInputRef:eD,floatingToolbarRef:eB,suppressHoverRef:eF,bumpToolbarRef:eO,savedSelectionRef:eA,highlightedLines:eW,isMounted:ez,cmdHeld:eH,flashLine:e_,isSearchVisible:eU,searchQuery:eq,caseSensitive:eV,wholeWord:eK,currentMatchIndex:eJ,viewingComment:eX,addCommentInput:eY,sendToAIInput:eQ,chatContext:eG,commentsEnabled:eZ,updateComment:e0,deleteComment:e1,lines:e2,matches:e5,rowData:e4,virtualizer:e3,commentsByEndLine:e6,linesWithComments:e8,setIsSearchVisible:e9,setSearchQuery:e7,setCaseSensitive:te,setWholeWord:tt,setViewingComment:tr,setAddCommentInput:tn,setSendToAIInput:ts,goToNextMatch:to,goToPrevMatch:tl,handleSearchKeyDown:ta,handleCommentBubbleClick:ti,handleToolbarAddComment:tc,handleToolbarSendToAI:td,handleToolbarSearch:tu,handleCommentSubmit:th,handleSendToAISubmit:tm,getHighlightedLineHtml:tx,suppressMatchScrollRef:tf,inlineBlameLineRef:tp,inlineBlameVersion:tg}=function({content:e,filePath:t,showSearch:r=!0,cwd:n,enableComments:o=!1,scrollToLine:l=null,scrollToLineAlign:a="center",onScrollToLineComplete:c,visibleLineRef:d,onContentSearch:u}){let[x,g]=(0,s.useState)(!1),b=(0,s.useRef)(null),v=(0,s.useRef)(null),j=(0,s.useRef)(null),w=C();(0,s.useEffect)(()=>{g(!0)},[]);let[y,k]=(0,s.useState)(!1),[N,S]=(0,s.useState)(null),L=(0,s.useRef)(null),[E,M]=(0,s.useState)(!1),[T,$]=(0,s.useState)(""),[R,P]=(0,s.useState)(!1),[D,F]=(0,s.useState)(!1),[O,A]=(0,s.useState)(0),[W,z]=(0,s.useState)(0),H=(0,s.useRef)(!1),[_,U]=(0,s.useState)(null),q=(0,s.useRef)(null),V=(0,s.useRef)(()=>{}),K=(0,s.useRef)(!1),J=(0,s.useRef)(null),[X,Y]=(0,s.useState)(null),[Q,G]=(0,s.useState)(null),Z=(0,s.useRef)(null),[ee,et]=(0,s.useState)(0),er=o&&!!n,{comments:en,addComment:es,updateComment:eo,deleteComment:el,refresh:ea}=p({cwd:n||"",filePath:t}),ei=(0,s.useMemo)(()=>e.split("\n"),[e]),ec=B(ei,t),ed=(0,s.useMemo)(()=>{let e=new Map;for(let t of en){let r=t.endLine;e.has(r)||e.set(r,[]),e.get(r).push(t)}return e},[en]),eu=(0,s.useMemo)(()=>{let e=new Set;for(let t of en)for(let r=t.startLine;r<=t.endLine;r++)e.add(r);return e},[en]),eh=(0,s.useMemo)(()=>(function(e,t,r,n){if(!t)return[];let s=[],o=r?t:t.toLowerCase();for(let t=0;t<e.length;t++){let l=r?e[t]:e[t].toLowerCase(),a=0;for(;;){let e=l.indexOf(o,a);if(-1===e)break;let r=e+o.length;if(n){let n=e>0?l[e-1]:" ",o=r<l.length?l[r]:" ",a=!/\w/.test(n),i=!/\w/.test(o);a&&i&&s.push({lineIndex:t,startCol:e,endCol:r})}else s.push({lineIndex:t,startCol:e,endCol:r});a=e+1}}return s})(ei,T,R,D),[ei,T,R,D]);(0,s.useEffect)(()=>{eh.length>0&&A(0)},[eh.length,T,R,D]);let em=(0,s.useMemo)(()=>{let e=[];for(let t=0;t<ei.length;t++)e.push({type:"code",lineIndex:t});return e},[ei.length]),ex=(0,i.Te)({count:em.length,getScrollElement:()=>b.current,estimateSize:()=>20,overscan:10});(0,s.useEffect)(()=>{if(!d)return;let e=b.current;if(!e)return;let t=()=>{if(!ex.range)return;let t=e.scrollTop;for(let e of ex.getVirtualItems())if(e.start>=t){let t=em[e.index];t?.type==="code"&&(d.current=t.lineIndex+1);return}};return e.addEventListener("scroll",t,{passive:!0}),t(),()=>e.removeEventListener("scroll",t)},[d,em]),(0,s.useEffect)(()=>{let e=e=>{"Meta"===e.key&&k(!0)},t=e=>{"Meta"===e.key&&k(!1)},r=()=>k(!1);return window.addEventListener("keydown",e),window.addEventListener("keyup",t),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t),window.removeEventListener("blur",r)}},[]),(0,s.useEffect)(()=>{if(!r)return;let e=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),M(!0),setTimeout(()=>j.current?.focus(),0)),"Escape"===e.key&&(E?(M(!1),$("")):Q?G(null):X?Y(null):q.current?(q.current=null,V.current()):_&&U(null))},t=v.current;if(t)return t.addEventListener("keydown",e),()=>t.removeEventListener("keydown",e)},[r,E,Q,X,_]),(0,s.useEffect)(()=>{if(H.current){H.current=!1;return}if(eh.length>0&&O>=0&&O<eh.length){let e=eh[O],t=em.findIndex(t=>"code"===t.type&&t.lineIndex===e.lineIndex);t>=0&&ex.scrollToIndex(t,{align:"center"})}},[O,eh,ex,em,W]);let ef=(0,s.useCallback)(()=>{0!==eh.length&&(A(e=>(e+1)%eh.length),z(e=>e+1))},[eh.length]),ep=(0,s.useCallback)(()=>{0!==eh.length&&(A(e=>(e-1+eh.length)%eh.length),z(e=>e+1))},[eh.length]),eg=(0,s.useRef)(l);eg.current=l,(0,s.useEffect)(()=>{if(null!==eg.current&&eg.current>0&&em.length>0){let e=eg.current,t=e-1,r=em.findIndex(e=>"code"===e.type&&e.lineIndex===t);if(r>=0){let t=()=>{ex.scrollToIndex(r,{align:a}),"center"===a&&(L.current&&clearTimeout(L.current),S(e),L.current=setTimeout(()=>S(null),500)),c?.()};"start"===a?requestAnimationFrame(t):setTimeout(t,150)}}},[l,a,em.length,ex,c]);let eb=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?ep():ef()),"Escape"===e.key&&(M(!1),$(""))},[ef,ep]),ev=(0,s.useCallback)((e,t)=>{er&&(t.stopPropagation(),U({comment:e,x:t.clientX,y:t.clientY}),q.current=null,V.current(),Y(null),G(null))},[er]);(0,s.useEffect)(()=>{if(!er)return;let e=b.current,t=!1,r=0,n=0,s=e=>{t=!0,r=e.clientX,n=e.clientY,J.current=null,K.current=!0,q.current&&(q.current=null,V.current())},o=e=>{t=!1;let s=e.target;if(s.closest?.(".floating-toolbar"))return;let o=Math.abs(e.clientX-r)>5||Math.abs(e.clientY-n)>5,l=window.getSelection();if(!l||l.isCollapsed){K.current=!1,q.current&&(q.current=null,V.current());return}let a=l.toString();if(!a.trim()||!o){K.current=!1,q.current&&(q.current=null,V.current());return}let i=l.getRangeAt(0),c=b.current;if(!c||!c.contains(i.commonAncestorContainer))return;let d=i.startContainer,u=i.endContainer,h=e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;if(!t)return null;let r=t.closest("[data-line]");return r?parseInt(r.getAttribute("data-line")||"0",10):null},m=h(d),x=h(u);if(m&&x){let t=Math.min(m,x),r=Math.max(m,x);q.current={x:e.clientX,y:e.clientY,range:{start:t,end:r},selectedText:a},K.current=!0,V.current();let n=d.nodeType===Node.TEXT_NODE?d.parentElement?.closest("[data-line]"):d.closest("[data-line]"),s=u.nodeType===Node.TEXT_NODE?u.parentElement?.closest("[data-line]"):u.closest("[data-line]");n&&s&&(J.current={startLine:m,startOffset:ew(n,i.startContainer,i.startOffset),endLine:x,endOffset:ew(s,i.endContainer,i.endOffset)})}},l=()=>{if(t||!q.current)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||(q.current=null,J.current=null,K.current=!1,V.current())};return e?.addEventListener("mousedown",s),document.addEventListener("mouseup",o),document.addEventListener("selectionchange",l),()=>{e?.removeEventListener("mousedown",s),document.removeEventListener("mouseup",o),document.removeEventListener("selectionchange",l)}},[er]),(0,s.useEffect)(()=>{let e=b.current;if(!e)return;let t=t=>{let r,n;if(!e.contains(t.target)){if(t.target.closest?.("[data-inline-blame-tip]"))return;null!==Z.current&&(Z.current=null,et(e=>e+1));return}let s=window.getSelection();if(s&&!s.isCollapsed&&s.toString().trim())return;let o=(r=t.target,(n=r.closest?.("[data-line]"))?parseInt(n.getAttribute("data-line")||"0",10):null);o!==Z.current&&(Z.current=o,requestAnimationFrame(()=>et(e=>e+1)))};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]);let ej=(0,s.useCallback)(()=>{let e=q.current;e&&(Y({x:e.x,y:e.y,range:e.range,codeContent:e.selectedText}),q.current=null,V.current())},[]),ey=(0,s.useCallback)(()=>{let e=q.current;if(!e)return;let t=e.selectedText;G({x:e.x,y:e.y,range:e.range,codeContent:t}),q.current=null,V.current()},[]),ek=(0,s.useCallback)(()=>{let e=q.current;if(!e||!u)return;let t=e.selectedText.trim();q.current=null,V.current(),t&&u(t)},[u]),eN=(0,s.useCallback)(async e=>{X&&(await es(X.range.start,X.range.end,e),Y(null))},[X,es]),eC=(0,s.useCallback)(async e=>{if(Q&&w&&n)try{let r=await h(n),s=[];for(let e of r)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});s.push({filePath:t,startLine:Q.range.start,endLine:Q.range.end,codeContent:Q.codeContent});let o=f(s,e);w.sendMessage(o),await m(n),ea(),G(null)}catch(e){console.error("Failed to send to AI:",e)}},[Q,w,t,n,ea]),eS=(0,s.useCallback)((e,t,r)=>{let n=ei[e];if(!n)return t;let s=[];if(T&&eh.length>0)for(let t of eh.filter(t=>t.lineIndex===e)){let r=eh[O]?.lineIndex===e&&eh[O]?.startCol===t.startCol;s.push({start:t.startCol,end:t.endCol,cls:r?"hl-cur":"hl-m"})}if(r&&!T&&r.length>=1){let e=r.toLowerCase(),t=n.toLowerCase(),o=0;for(;-1!==(o=t.indexOf(e,o));)s.push({start:o,end:o+r.length,cls:"hl-kw"}),o+=1}if(0===s.length)return t;s.sort((e,t)=>e.start-t.start||e.end-t.end);let o=[],l=0;for(let e of s){if(e.start<l)continue;e.start>l&&o.push(I(n.substring(l,e.start)));let t=I(n.substring(e.start,e.end));o.push(`<span class="${e.cls}">${t}</span>`),l=e.end}if(l<n.length&&o.push(I(n.substring(l))),t!==I(n)){let e=t;for(let t of s){let r=I(n.substring(t.start,t.end)),s=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=RegExp(`(?<=>)([^<]*?)(${s})`,""),l=`$1<span class="${t.cls}">${r}</span>`,a=e.replace(o,l);a.length>e.length+200||(e=a)}return e}return o.join("")},[T,eh,O,ei]);return{parentRef:b,containerRef:v,searchInputRef:j,floatingToolbarRef:q,suppressHoverRef:K,savedSelectionRef:J,highlightedLines:ec,isMounted:x,cmdHeld:y,flashLine:N,isSearchVisible:E,searchQuery:T,caseSensitive:R,wholeWord:D,currentMatchIndex:O,viewingComment:_,bumpToolbarRef:V,addCommentInput:X,sendToAIInput:Q,chatContext:w,commentsEnabled:er,comments:en,updateComment:eo,deleteComment:el,lines:ei,matches:eh,rowData:em,virtualizer:ex,commentsByEndLine:ed,linesWithComments:eu,setIsSearchVisible:M,setSearchQuery:$,suppressMatchScrollRef:H,setCaseSensitive:P,setWholeWord:F,setViewingComment:U,setAddCommentInput:Y,setSendToAIInput:G,goToNextMatch:ef,goToPrevMatch:ep,handleSearchKeyDown:eb,handleCommentBubbleClick:ev,handleToolbarAddComment:ej,handleToolbarSendToAI:ey,handleToolbarSearch:ek,handleCommentSubmit:eN,handleSendToAISubmit:eC,getHighlightedLineHtml:eS,inlineBlameLineRef:Z,inlineBlameVersion:ee}}({content:e,filePath:t,showSearch:l,cwd:d,enableComments:!O&&u,scrollToLine:O?null:x,scrollToLineAlign:O?"center":b,onScrollToLineComplete:O?void 0:v,visibleLineRef:O?void 0:y,onContentSearch:Z}),tb=j(),tv=(0,s.useRef)(null),tj=(0,s.useRef)(null),tw=(0,s.useRef)({line:0,col:0}),ty=function({lines:e,enabled:t,onContentChange:r,onEnterInsert:n,onSave:o,getVisibleLineCount:l,scrollToLine:a,onSearchExecute:i,onSearchNext:c,onSearchPrev:d,onSearchClear:u}){let[h,m]=(0,s.useState)("normal"),[x,f]=(0,s.useState)(-1),[p,g]=(0,s.useState)(0),[b,v]=(0,s.useState)(!1),[j,w]=(0,s.useState)(""),[y,k]=(0,s.useState)(""),[N,C]=(0,s.useState)(""),[S,L]=(0,s.useState)(""),E=(0,s.useRef)([]),M=(0,s.useRef)([]),T=(0,s.useRef)([]),$=(0,s.useRef)(null),R=(0,s.useRef)(e);(0,s.useEffect)(()=>{R.current=e}),(0,s.useEffect)(()=>{0!==e.length&&queueMicrotask(()=>f(t=>Math.min(t,e.length-1)))},[e.length]);let P=(0,s.useCallback)((e,t)=>Math.max(0,Math.min(t,Math.max(0,(R.current[e]??"").length-1))),[]),I=(0,s.useRef)(e.length);(0,s.useEffect)(()=>{let t=Math.abs(e.length-I.current);I.current=e.length,t>10&&(queueMicrotask(()=>{f(-1),g(0),v(!1)}),E.current=[],M.current=[],T.current=[])},[e]);let D=(0,s.useCallback)(()=>{$.current&&(clearTimeout($.current),$.current=null),w("")},[]),B=(0,s.useCallback)(()=>{$.current&&clearTimeout($.current),$.current=setTimeout(()=>{w(""),$.current=null},500)},[]),F=(0,s.useCallback)((e,t)=>{E.current.push(t),M.current=[],v(!0),r(e.join("\n"))},[r]),O=(0,s.useCallback)((e,t)=>{let r=Math.max(0,Math.min(e,R.current.length-1));f(r),g(P(r,t??0)),a(r,"auto")},[a,P]),A=(0,s.useCallback)(e=>{f(t=>{let r=Math.max(0,Math.min(t+e,R.current.length-1));return a(r,"auto"),g(e=>Math.max(0,Math.min(e,Math.max(0,(R.current[r]??"").length-1)))),r})},[a]),W=(0,s.useCallback)(()=>{let e=R.current,t=Math.min(x,e.length-1);if(0===e.length)return;let r=e[t];T.current=[r];let n=[...e];n.splice(t,1),0===n.length&&n.push("");let s=Math.min(t,n.length-1);F(n,{lineIndex:t,oldLines:[r],newLines:[],cursorLine:t}),f(s),g(0)},[x,F]),z=(0,s.useCallback)(()=>{let e=R.current,t=Math.min(x,e.length-1);e.length>0&&(T.current=[e[t]])},[x]),H=(0,s.useCallback)(()=>{let e=T.current;if(0===e.length)return;let t=R.current,r=Math.min(x,t.length-1)+1,n=[...t];n.splice(r,0,...e),F(n,{lineIndex:r,oldLines:[],newLines:[...e],cursorLine:x}),f(r),g(0),a(r,"auto")},[x,F,a]),_=(0,s.useCallback)(()=>{let e=R.current,t=Math.min(x,e.length-1),r=e[t];if(!r||0===r.length)return;let n=r.substring(1),s=[...e];s[t]=n,F(s,{lineIndex:t,oldLines:[r],newLines:[n],cursorLine:x})},[x,F]),U=(0,s.useCallback)(()=>{let e=E.current;if(0===e.length)return;let t=e.pop(),n=[...R.current];0===t.newLines.length&&t.oldLines.length>0?n.splice(t.lineIndex,0,...t.oldLines):0===t.oldLines.length&&t.newLines.length>0?(n.splice(t.lineIndex,t.newLines.length),0===n.length&&n.push("")):n.splice(t.lineIndex,t.newLines.length,...t.oldLines),M.current.push(t),r(n.join("\n")),f(Math.min(t.cursorLine,n.length-1)),a(Math.min(t.cursorLine,n.length-1),"auto"),0===e.length&&v(!1)},[r,a]),q=(0,s.useCallback)(()=>{let e=M.current;if(0===e.length)return;let t=e.pop(),n=[...R.current];0===t.newLines.length&&t.oldLines.length>0?(n.splice(t.lineIndex,t.oldLines.length),0===n.length&&n.push("")):0===t.oldLines.length&&t.newLines.length>0?n.splice(t.lineIndex,0,...t.newLines):n.splice(t.lineIndex,t.oldLines.length,...t.newLines),E.current.push(t),v(!0),r(n.join("\n"));let s=t.lineIndex+Math.max(0,t.newLines.length-1);f(Math.min(s,n.length-1)),a(Math.min(s,n.length-1),"auto")},[r,a]),V=(0,s.useCallback)(e=>{let t=R.current,r=Math.min(x,t.length-1);if("o"===e||"O"===e){let n="o"===e?r+1:r,s=[...t];s.splice(n,0,""),F(s,{lineIndex:n,oldLines:[],newLines:[""],cursorLine:x}),r=n,f(n)}m("insert"),n(r,p,e)},[x,p,F,n]),K=(0,s.useCallback)(()=>{m("normal"),D()},[D]),J=(0,s.useCallback)(()=>{m("command"),k("")},[]),X=(0,s.useCallback)(()=>{m("normal"),k("")},[]),Y=(0,s.useCallback)(()=>{m("search"),C("")},[]),Q=(0,s.useCallback)(()=>{m("normal"),C("")},[]),G=(0,s.useCallback)(e=>{let t=e.trim();if("w"===t){o?.(),m("normal"),k("");return}if("q"===t){m("normal"),k("");return}if("wq"===t){o?.(),m("normal"),k("");return}if("noh"===t||"nohlsearch"===t){u?.(),m("normal"),k("");return}let r=parseInt(t,10);if(!isNaN(r)&&r>0){let e=Math.min(r-1,R.current.length-1);f(e),a(e,"center"),m("normal"),k("");return}m("normal"),k("")},[o,u,a]),Z=(0,s.useCallback)(e=>{if(!e){m("normal"),C("");return}L(e),i?.(e),m("normal"),C("")},[i]),ee=(0,s.useCallback)(e=>{if(!t)return!1;let r=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;if("insert"===h)return("Escape"===e.key||!!r)&&(K(),!0);if("command"===h)return!e.isComposing&&("Escape"===e.key||r?X():"Enter"===e.key?G(y):"Backspace"===e.key?0===y.length?X():k(e=>e.slice(0,-1)):1!==e.key.length||e.metaKey||e.ctrlKey||k(t=>t+e.key),!0);if("search"===h)return!e.isComposing&&("Escape"===e.key||r?Q():"Enter"===e.key?Z(N):"Backspace"===e.key?0===N.length?Q():C(e=>e.slice(0,-1)):1!==e.key.length||e.metaKey||e.ctrlKey||C(t=>t+e.key),!0);if(x<0&&(f(0),g(0)),e.metaKey)return!1;if(e.ctrlKey)return"d"===e.key?(A(Math.max(1,Math.floor(l()/2))),D(),!0):"u"===e.key?(A(-Math.max(1,Math.floor(l()/2))),D(),!0):"r"===e.key&&(q(),D(),!0);let n=e.key,s=j+n;if("g"===s)return w("g"),B(),!0;if("gg"===s)return O(0),D(),!0;if("d"===s)return w("d"),B(),!0;if("dd"===s)return W(),D(),!0;if("y"===s)return w("y"),B(),!0;if("yy"===s)return z(),D(),!0;if(j&&s!==n&&D(),"j"===n||"ArrowDown"===n)return A(1),!0;if("k"===n||"ArrowUp"===n)return A(-1),!0;if("h"===n||"ArrowLeft"===n)return g(e=>Math.max(0,e-1)),!0;if("l"===n||"ArrowRight"===n){let e=Math.max(0,(R.current[x]??"").length-1);return g(t=>Math.min(e,t+1)),!0}if("0"===n)return g(0),!0;if("$"===n)return g(Math.max(0,(R.current[x]??"").length-1)),!0;if("^"===n){let e=(R.current[x]??"").search(/\S/);return g(e>=0?e:0),!0}return"G"===n?(O(R.current.length-1),!0):"x"===n?(_(),!0):"p"===n?(H(),!0):"u"===n?(U(),!0):"i"===n||"a"===n||"I"===n||"A"===n||"o"===n||"O"===n?(V(n),!0):"/"===n?(Y(),!0):"n"===n?(c?.(),!0):"N"===n?(d?.(),!0):":"===n?(J(),!0):"Escape"!==n&&1===n.length},[t,h,j,y,N,x,K,V,J,X,Y,Q,G,Z,A,O,l,W,z,H,_,U,q,D,B,c,d]);return{state:{mode:h,cursorLine:x,cursorCol:p,isDirty:b,keyBuffer:j,commandInput:y,searchInput:N,lastSearch:S},handleKeyDown:ee,enterNormal:K,enterInsert:V,setCursorLine:f,setCursorCol:g,setCommandInput:k,setSearchInput:C,setIsDirty:v,clearUndoHistory:(0,s.useCallback)(()=>{E.current=[],M.current=[]},[])}}({lines:e2,enabled:q&&!O,onContentChange:e=>{V?.(e)},onEnterInsert:(e,t,r)=>{let n=t;if("a"===r)n=t+1;else if("A"===r)n=(e2[e]??"").length;else if("I"===r){let t=(e2[e]??"").search(/\S/);n=t>=0?t:0}else("o"===r||"O"===r)&&(n=0);tw.current={line:e,col:n},K?.(e)},onSave:J,getVisibleLineCount:()=>{let e=eP.current;return e?Math.floor(e.clientHeight/20):20},scrollToLine:(e,t)=>{let r=e4.findIndex(t=>"code"===t.type&&t.lineIndex===e);r>=0&&e3.scrollToIndex(r,{align:t||"auto"})},onSearchExecute:e=>{e7(e),e9(!1)},onSearchNext:to,onSearchPrev:tl,onSearchClear:()=>{e7("")}});(0,s.useEffect)(()=>{X&&(X.current={cursorLine:ty.state.cursorLine,cursorCol:ty.state.cursorCol})},[X,ty.state.cursorLine,ty.state.cursorCol]);let tk=(0,s.useRef)(null);(0,s.useEffect)(()=>{q&&!O&&null!=Y&&t&&tk.current!==t&&(tk.current=t,ty.setCursorLine(Y-1),null!=Q&&ty.setCursorCol(Q-1),G?.())},[q,O,Y,Q,t]),(0,s.useEffect)(()=>{if(!q||O)return;let e=eI.current;if(!e)return;let t=e=>{let t=e.target;"TEXTAREA"===t.tagName||"INPUT"===t.tagName||t.isContentEditable||ty.handleKeyDown(e)&&(e.preventDefault(),e.stopPropagation())};return e.addEventListener("keydown",t,!0),()=>e.removeEventListener("keydown",t,!0)},[q,O,ty.handleKeyDown]),(0,s.useEffect)(()=>{if(!q||O)return;let e=eI.current;e&&"normal"===ty.state.mode&&requestAnimationFrame(()=>{let t=document.activeElement;t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName||t.isContentEditable)||e.focus()})},[q,O,ty.state.mode,e]);let tN=(0,s.useCallback)(e=>{if(!q||O)return;let t=e.target.closest("[data-line]");if(t){let r=parseInt(t.getAttribute("data-line"),10);if(!isNaN(r)){ty.setCursorLine(r-1);let n=t.querySelector("[data-code-content]");if(n){let t=document.caretRangeFromPoint(e.clientX,e.clientY);if(t&&n.contains(t.startContainer)){let e,s=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),o=0;for(;e=s.nextNode();){if(e===t.startContainer){o+=t.startOffset;break}o+=e.textContent?.length||0}let l=e2[r-1]??"";ty.setCursorCol(Math.max(0,Math.min(o,Math.max(0,l.length-1))))}}}}let r=e.target;if("TEXTAREA"===r.tagName||"INPUT"===r.tagName||r.isContentEditable)return;let n=eI.current;n&&n.focus()},[q,O,ty.setCursorLine,ty.setCursorCol,e2]),tC=(0,s.useCallback)(e=>{q&&!O&&requestAnimationFrame(()=>{let e=window.getSelection(),t=e?.toString().trim();t&&/^\S+$/.test(t)&&(tf.current=!0,e7(t))})},[q,O,e7,tf]);(0,s.useEffect)(()=>{"command"===ty.state.mode?setTimeout(()=>tv.current?.focus(),0):"search"===ty.state.mode&&setTimeout(()=>tj.current?.focus(),0)},[ty.state.mode]),(0,s.useEffect)(()=>{let e=eP.current;if(!e)return;let t=()=>{(M??E)?.()};return e.addEventListener("mousedown",t),()=>e.removeEventListener("mousedown",t)},[M,E]),(0,s.useEffect)(()=>{eY||eQ?(eF.current=!0,E?.()):eB.current||(eF.current=!1)},[eY,eQ,E]),(0,s.useLayoutEffect)(()=>{let e=eA.current;if(!e)return;let t=window.getSelection();if(t&&!t.isCollapsed)return;let r=eP.current;if(!r)return;let n=r.querySelector(`[data-line="${e.startLine}"]`),s=r.querySelector(`[data-line="${e.endLine}"]`);if(!n||!s)return;let o=ey(n,e.startOffset),l=ey(s,e.endOffset);if(o&&l)try{let e=document.createRange();e.setStart(o.node,o.offset),e.setEnd(l.node,l.offset),t?.removeAllRanges(),t?.addRange(e)}catch{}});let tS=(0,s.useCallback)((e,t,r)=>{eF.current||N?.(e,t,r)},[N]),tL=(0,s.useCallback)((e,t)=>{eF.current||k?.(e,t)},[k]),tE=Math.max(4,String(O?ex:e2.length).length),tM=(0,s.useMemo)(()=>{let e=0;for(let t of e2){let r=0;for(let e=0;e<t.length;e++)" "===t[e]?r+=2-r%2:r+=1;r>e&&(e=r)}return e},[e2]);(0,s.useEffect)(()=>{if(O){ei.current=e;let t=e.split("\n").length;ep.current=t,ef(t),ec.current=!1,eu(!1),ev({show:!1}),eC.current=z}},[O,e,z]),(0,s.useEffect)(()=>{if(!O)return;let t=ek.current;if(!t)return;let r=e.split("\n");t.innerHTML=e$(r.map((e,t)=>eW[t]||I(e||" "))),requestAnimationFrame(()=>{let e,n;q?(e=Math.max(0,Math.min(tw.current.line,r.length-1)),n=tw.current.col):(e=Math.max(0,Math.min((y?.current??1)-1,r.length-1)),n=0),t.focus(),eT(t,{line:e,offset:n});let s=y?.current??1;eN.current&&(eN.current.scrollTop=(s-1)*20)})},[O]),(0,s.useEffect)(()=>{O&&U?.({isDirty:ed,isSaving:eh})},[O,ed,eh,U]);let tT=(0,s.useCallback)(()=>{let e=ek.current;if(!e)return ei.current;let t=[];for(let r of e.childNodes){let e=r.textContent||"";t.push(" "===e?"":e)}return t.join("\n")},[]),t$=(0,s.useCallback)(()=>{eS.current&&clearTimeout(eS.current),eS.current=setTimeout(async()=>{let e=ek.current;if(e&&!eR.current){ei.current=tT();try{let r=await R(),n=P(t),s=document.documentElement.classList.contains("dark"),o=ei.current.split("\n"),l=r.codeToTokens(o.join("\n"),{lang:n,theme:s?"github-dark":"github-light"}).tokens.map(e=>D(e)),a=eM(e);eL.current=!0,e.innerHTML=e$(l),eL.current=!1,a&&eT(e,a)}catch{}}},300)},[t,tT]);(0,s.useEffect)(()=>{if(O)return()=>{eS.current&&clearTimeout(eS.current)}},[O]);let tR=(0,s.useCallback)(()=>{let e=ek.current;if(!e)return;ec.current||(ec.current=!0,eu(!0));let t=e.children.length;t!==ep.current&&(ep.current=t,ef(t))},[]),tP=(0,s.useCallback)(()=>{eL.current||eR.current||(tR(),t$())},[tR,t$]),tI=(0,s.useCallback)(e=>{if(!e.nativeEvent.isComposing&&("Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," ")),"Enter"===e.key)){e.preventDefault();let t=ek.current;if(!t)return;let r=window.getSelection();if(!r?.rangeCount)return;let n=r.getRangeAt(0);n.deleteContents();let s=n.startContainer;for(;s&&s.parentElement!==t;)s=s.parentElement;if(!s||!(s instanceof HTMLElement))return;let o=eM(t),l=Array.from(t.children).indexOf(s),a=s.textContent||"",i=o?.offset??a.length,c=a.substring(0,i),d=a.substring(i);s.innerHTML=I(c||" ");let u=document.createElement("div");u.setAttribute("style",eE),u.innerHTML=I(d||" "),s.after(u),eT(t,{line:l+1,offset:0}),tR(),t$()}},[tR,t$]),tD=(0,s.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)},[]),tB=(0,s.useCallback)(async(e=!1)=>{if(d){ei.current=tT(),em(!0);try{let r=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:d,path:t,content:ei.current,expectedMtime:e?void 0:eC.current})}),n=await r.json();if(409===r.status&&n.conflict){try{let e=await fetch(`/api/files/read?cwd=${encodeURIComponent(d)}&path=${encodeURIComponent(t)}`),r=await e.json();ev({show:!0,diskContent:"text"===r.type?r.content:void 0})}catch{ev({show:!0})}return}if(!r.ok)throw Error("Failed to save file");n.mtime&&(eC.current=n.mtime),ec.current=!1,eu(!1),ev({show:!1}),(0,g.oR)(ea("toast.savedSuccess"),"success"),_?.()}catch(e){console.error("Error saving file:",e),(0,g.oR)(ea("toast.saveFailed"),"error")}finally{em(!1)}}},[d,t,tT,_]),tF=(0,s.useCallback)(async()=>{ed&&!eh&&await tB(!1)},[ed,eh,tB]),tO=(0,s.useCallback)(async()=>{ev({show:!1}),await tB(!0)},[tB]),tA=(0,s.useCallback)(()=>{if(void 0!==eg.diskContent){ei.current=eg.diskContent;let t=eg.diskContent.split("\n").length;ep.current=t,ef(t);let r=eg.diskContent!==e;ec.current=r,eu(r);let n=ek.current;n&&(n.innerHTML=e$(eg.diskContent.split("\n").map(e=>I(e||" "))),t$())}ev({show:!1}),_?.()},[eg.diskContent,e,_,t$]),tW=(0,s.useCallback)(()=>{let e=eN.current;return e?Math.floor(e.scrollTop/20)+1:y?.current??1},[y]),tz=(0,s.useCallback)(async()=>{(!ed||await (0,g.lJ)(ea("codeViewer.unsavedConfirm"),{danger:!0,confirmText:ea("codeViewer.discardChanges"),cancelText:ea("codeViewer.continueEditing")}))&&H?.(tW())},[ed,H,tW]);(0,s.useEffect)(()=>{if(!O)return;let e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&(e.preventDefault(),tF())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[O,tF]);let tH=(0,s.useCallback)(()=>{let e=tT();V?.(e);let t=ek.current,r=t?eM(t):null,n=tW();if(ty.enterNormal(),r){ty.setCursorLine(r.line);let t=e.split("\n")[r.line]??"";ty.setCursorCol(Math.max(0,Math.min(r.offset,Math.max(0,t.length-1))))}else ty.setCursorLine(Math.max(0,n-1));H?.(n)},[tT,V,tW,H,ty]);(0,s.useEffect)(()=>{if(!O)return;let e=e=>{let t="Escape"===e.key,r=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;(t||q&&r)&&(e.preventDefault(),e.stopPropagation(),q?ec.current?(0,g.lJ)(ea("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:ea("codeViewer.discardChanges"),cancelText:ea("codeViewer.continueEditing")}).then(e=>{e&&tH()}):tH():tz())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[O,q,tz,tH]),(0,s.useImperativeHandle)(ee,()=>({save:tF,close:tz,get isDirty(){return ed},get isSaving(){return eh}}),[tF,tz,ed,eh]);let t_=!!(T&&T.length>0),tU=(0,s.useMemo)(()=>{if(!T)return new Map;let e=[...new Set(T.map(e=>e.author))],t=new Map;return e.forEach((e,r)=>{t.set(e,eb[r%eb.length])}),t},[T]),[tq,tV]=(0,s.useState)(null),[tK,tJ]=(0,s.useState)(null);(0,s.useEffect)(()=>{tV(null),tJ(null)},[T]);let tX=(0,s.useCallback)((e,t)=>{tV(e.author);let r=t.currentTarget.getBoundingClientRect();tJ({line:e,x:r.right+8,y:r.top})},[]),tY=(0,s.useCallback)(()=>{tV(null),tJ(null)},[]),tQ=(0,s.useCallback)(e=>{F&&(F({hash:e.hashFull,shortHash:e.hash,author:e.author,authorEmail:e.authorEmail,date:new Date(1e3*e.time).toISOString(),subject:e.message.split("\n")[0]||"",body:e.message.split("\n").slice(1).join("\n").trim(),time:e.time}),tJ(null))},[F]),tG=`${tE+2}ch`;return(0,n.jsxs)("div",{ref:eI,className:`h-full flex flex-col outline-none ${c}`,tabIndex:0,onClick:tN,onDoubleClick:tC,children:[O&&eg.show&&(0,n.jsxs)("div",{className:"px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 flex items-center gap-3 flex-shrink-0",children:[(0,n.jsx)("svg",{className:"w-5 h-5 text-amber-500 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 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),(0,n.jsx)("span",{className:"text-sm text-foreground flex-1",children:ea("codeViewer.fileModifiedExternally")}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:tA,className:"px-3 py-1 text-sm rounded border border-border hover:bg-accent transition-colors",children:ea("codeViewer.useDiskVersion")}),(0,n.jsx)("button",{onClick:tO,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:ea("codeViewer.forceOverwrite")})]})]}),!O&&l&&eU&&(0,n.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border",children:[(0,n.jsx)("input",{ref:eD,type:"text",value:eq,onChange:e=>e7(e.target.value),onKeyDown:ta,placeholder:ea("codeViewer.searchPlaceholder"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,n.jsx)("button",{onClick:()=>te(!eV),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${eV?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:ea("codeViewer.caseSensitive"),children:"Aa"}),(0,n.jsx)("button",{onClick:()=>tt(!eK),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${eK?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:ea("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:e5.length>0?`${eJ+1}/${e5.length}`:ea("common.noMatch")}),(0,n.jsx)("button",{onClick:tl,disabled:0===e5.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:ea("common.previous"),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"})})}),(0,n.jsx)("button",{onClick:to,disabled:0===e5.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:ea("common.next"),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"})})}),(0,n.jsx)("button",{onClick:()=>{e9(!1),e7("")},className:"p-1 rounded hover:bg-accent",title:ea("common.close"),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"})})})]}),O?(0,n.jsx)("div",{ref:eN,className:"flex-1 overflow-auto bg-secondary",children:(0,n.jsxs)("div",{className:"flex",style:{minHeight:"100%"},children:[(0,n.jsx)("div",{className:"flex-shrink-0 font-mono text-sm select-none sticky left-0 z-[2] bg-secondary",style:{width:tG},children:Array.from({length:ex},(e,t)=>(0,n.jsx)("div",{className:"text-right text-muted-foreground/50 pr-3",style:{height:20,lineHeight:"20px"},children:t+1},t))}),(0,n.jsx)("div",{ref:ek,contentEditable:!0,suppressContentEditableWarning:!0,onInput:tP,onKeyDown:tI,onPaste:tD,onCompositionStart:()=>{eR.current=!0},onCompositionEnd:()=>{eR.current=!1,tP()},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",className:"flex-1 font-mono text-sm outline-none",style:{caretColor:"var(--foreground)",tabSize:2}})]})}):(0,n.jsx)("div",{ref:eP,className:`flex-1 overflow-auto font-mono text-sm bg-secondary${eH?" cmd-held-container":""}`,children:(0,n.jsx)("div",{style:{height:`${e3.getTotalSize()}px`,minWidth:"100%",width:t_?`calc(${tE+tM+10}ch + 13rem)`:`${tE+tM+10}ch`,position:"relative"},children:e3.getVirtualItems().map(e=>{let t=e4[e.index];if("code"!==t.type)return null;let s=t.lineIndex,o=s+1,l=eW[s]||I(e2[s]||""),a=tx(s,l,w),i=e8.has(o),c=e6.get(o),d=c?.[0],u=!!(eY&&o>=eY.range.start&&o<=eY.range.end),h=tg>=0?tp.current:null,m=!O&&$&&h===o?$[s]??null:null,x=t_?T[s]:void 0,f=t_&&s>0?T[s-1]:void 0,p=!!x&&(!f||f.hash!==x.hash),g=x?tU.get(x.author):void 0;return(0,n.jsx)(ej,{virtualKey:e.key,lineNum:o,highlightedHtml:a,hasComments:i,firstComment:d,lineCommentsCount:c?.length,isInRange:u,showLineNumbers:r,lineNumChars:tE,commentsEnabled:eZ,virtualItemSize:e.size,virtualItemStart:e.start,onCommentBubbleClick:ti,onCmdClick:tL,onTokenHover:tS,onTokenHoverLeave:E,flashLine:e_,blameLine:x,showBlameInfo:p,blameAuthorColor:g,isBlameHovered:!!(x&&tq===x.author),onBlameClick:tQ,onBlameMouseEnter:tX,onBlameMouseLeave:tY,inlineBlameData:m,onInlineBlameClick:tQ,isCursorLine:q&&!O&&ty.state.cursorLine===s,cursorCol:q&&!O&&ty.state.cursorLine===s?ty.state.cursorCol:void 0},e.key)})})}),q&&(0,n.jsxs)("div",{className:"vi-status-bar flex-shrink-0 h-6 bg-card border-t border-border flex items-center px-3 text-xs font-mono select-none",children:["normal"===ty.state.mode&&(0,n.jsx)("span",{className:"text-green-11 font-medium",children:"NORMAL"}),"insert"===ty.state.mode&&(0,n.jsx)("span",{className:"text-blue-11 font-medium",children:"INSERT"}),"command"===ty.state.mode&&(0,n.jsxs)("div",{className:"flex items-center flex-1",children:[(0,n.jsx)("span",{className:"text-foreground",children:":"}),(0,n.jsx)("input",{ref:tv,value:ty.state.commandInput,onChange:e=>ty.setCommandInput(e.target.value),onKeyDown:e=>{if(e.nativeEvent.isComposing)return;let t=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;("Enter"===e.key||"Escape"===e.key||t)&&(e.preventDefault(),e.stopPropagation(),ty.handleKeyDown(e.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),"search"===ty.state.mode&&(0,n.jsxs)("div",{className:"flex items-center flex-1",children:[(0,n.jsx)("span",{className:"text-foreground",children:"/"}),(0,n.jsx)("input",{ref:tj,value:ty.state.searchInput,onChange:e=>ty.setSearchInput(e.target.value),onKeyDown:e=>{if(e.nativeEvent.isComposing)return;let t=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;("Enter"===e.key||"Escape"===e.key||t)&&(e.preventDefault(),e.stopPropagation(),ty.handleKeyDown(e.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),ty.state.keyBuffer&&"normal"===ty.state.mode&&(0,n.jsx)("span",{className:"ml-2 text-muted-foreground",children:ty.state.keyBuffer}),ty.state.isDirty&&("normal"===ty.state.mode||"command"===ty.state.mode)&&(0,n.jsx)("span",{className:"ml-2 text-amber-11",children:"[+]"}),(0,n.jsxs)("span",{className:"ml-auto text-muted-foreground",children:[ty.state.cursorLine+1,":",ty.state.cursorCol+1]})]}),ez&&tb&&(0,a.createPortal)((0,n.jsxs)(n.Fragment,{children:[!O&&(0,n.jsx)(A,{floatingToolbarRef:eB,bumpRef:eO,container:tb,onAddComment:tc,onSendToAI:td,onSearch:Z?tu:void 0,isChatLoading:eG?.isLoading}),!O&&eY&&(0,n.jsx)(S,{x:eY.x,y:eY.y,range:eY.range,codeContent:eY.codeContent,container:tb,onSubmit:th,onClose:()=>tn(null)}),!O&&eQ&&(0,n.jsx)(L,{x:eQ.x,y:eQ.y,range:eQ.range,filePath:t,codeContent:eQ.codeContent,container:tb,onSubmit:tm,onClose:()=>ts(null),isChatLoading:eG?.isLoading}),!O&&eX&&(0,n.jsx)(W,{x:eX.x,y:eX.y,comment:eX.comment,container:tb,onClose:()=>tr(null),onUpdateComment:e0,onDeleteComment:e1}),tK&&(0,n.jsxs)("div",{className:"fixed z-50 bg-card border border-border rounded-lg shadow-lg p-3 max-w-lg",style:{left:Math.min(tK.x,window.innerWidth-450),top:Math.max(8,Math.min(tK.y,window.innerHeight-200))},children:[(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("div",{className:"px-2 py-0.5 rounded text-xs font-mono font-medium text-white flex-shrink-0",style:{backgroundColor:tU.get(tK.line.author)?.border||"#666"},children:tK.line.hash}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium text-foreground",children:tK.line.author}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:tK.line.authorEmail})]})]}),(0,n.jsx)("div",{className:"mt-2 text-sm text-foreground whitespace-pre-wrap max-h-48 overflow-y-auto",children:tK.line.message}),(0,n.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground border-t border-border pt-2",children:[(et=tK.line.time,eo=Math.floor((es=Math.floor((en=Math.floor((er=Math.floor(Math.floor((Date.now()-1e3*et)/1e3)/60))/60))/24))/30),(el=Math.floor(es/365))>0?`${el}y ago`:eo>0?`${eo}mo ago`:es>0?`${es}d ago`:en>0?`${en}h ago`:er>0?`${er}m ago`:"just now")," \xb7 ",new Date(1e3*tK.line.time).toLocaleString(),(0,n.jsx)("span",{className:"ml-2 text-brand",children:ea("codeViewer.clickToViewDetails")})]})]})]}),tb)]})});var eP=r(26108),eI=r(95766),eD=r(94002);function eB({content:e,sourceFile:t}){let r,l,a,i,c,{t:d}=(0,o.Bd)(),[u,h]=(0,s.useState)(null),[m,x]=(0,s.useState)(!0),[f,p]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!t)return void x(!1);let e=!1;return fetch("/api/review").then(e=>e.ok?e.json():Promise.reject()).then(r=>{if(e)return;let n=r.reviews.find(e=>e.sourceFile===t);h(n?{id:n.id,active:n.active,updatedAt:n.updatedAt}:null)}).catch(()=>{}).finally(()=>{e||x(!1)}),()=>{e=!0}},[t]);let b=u?.active===!0,v=(0,s.useCallback)(async()=>{p(!0);try{let r=t.split("/").pop()||t,n=await fetch("/api/review",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r,content:e,sourceFile:t})});if(!n.ok)throw Error("Failed");let s=(await n.json()).review;h({id:s.id,active:!0,updatedAt:s.updatedAt||s.createdAt});try{let e=await fetch("/api/review/share-info"),t=await e.json(),r=t.shareBase?`${t.shareBase}/review/${s.id}`:`${window.location.origin}/review/${s.id}`;await navigator.clipboard.writeText(r)}catch{}(0,g.oR)(s.existing?d("toast.reviewUpdated"):d("toast.reviewCreated"),"success")}catch{(0,g.oR)(d("toast.reviewCreateFailed"),"error")}finally{p(!1)}},[e,t]),j=(0,s.useCallback)(async()=>{if(u){p(!0);try{if(!(await fetch(`/api/review/${u.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({active:!1})})).ok)throw Error("Failed");h(e=>e?{...e,active:!1}:null),(0,g.oR)(d("toast.sharingClosed"),"success")}catch{(0,g.oR)(d("toast.sharingCloseFailed"),"error")}finally{p(!1)}}},[u]),w=(0,s.useCallback)(()=>{f||(b?j():v())},[f,b,v,j]),y=(0,s.useCallback)(()=>{u&&window.open(`${window.location.origin}/review/${u.id}`,"_blank")},[u]);return m?null:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:w,disabled:f,className:`relative inline-flex h-4 w-7 items-center rounded-full transition-colors ${f?"opacity-50 cursor-wait":"cursor-pointer"} ${b?"bg-green-500":"bg-muted-foreground/30"}`,title:b?d("review.closeSharing"):d("review.enableSharing"),children:(0,n.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white transition-transform ${b?"translate-x-3.5":"translate-x-0.5"}`})}),(0,n.jsx)("span",{className:`text-[11px] ${b?"text-green-600 dark:text-green-400":"text-muted-foreground"}`,children:b?d("review.sharing"):d("review.notShared")}),u&&u.updatedAt&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(l=String((r=new Date(u.updatedAt)).getMonth()+1).padStart(2,"0"),a=String(r.getDate()).padStart(2,"0"),i=String(r.getHours()).padStart(2,"0"),c=String(r.getMinutes()).padStart(2,"0"),`${l}-${a} ${i}:${c}`)}),(0,n.jsx)("button",{onClick:y,className:"text-[11px] text-brand hover:underline",children:d("review.view")})]})]})}function eF(e){let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;if(!t||!("closest"in t))return null;let r=t.closest("[data-source-start]");if(!r)return null;let n=r.getAttribute("data-source-start"),s=r.getAttribute("data-source-end");return n&&s?{start:parseInt(n,10),end:parseInt(s,10)}:null}let eO=[eI.W];function eA({content:e,filePath:t,cwd:r,onClose:l,sourceFile:i}){let c=i||(r&&t.startsWith(r)?t.slice(r.endsWith("/")?r.length:r.length+1):t),{t:d}=(0,o.Bd)(),u=(0,s.useRef)(null),x=(0,s.useRef)(null),g=(0,s.useRef)(()=>{}),b=j(),v=C(),{comments:w,addComment:y,updateComment:k,deleteComment:N,refresh:E}=p({cwd:r,filePath:t}),[M,T]=(0,s.useState)(!1),[$,R]=(0,s.useState)(null),[P,I]=(0,s.useState)(null),[D,B]=(0,s.useState)(null),F=(0,s.useMemo)(()=>e.split("\n"),[e]);(0,s.useEffect)(()=>{queueMicrotask(()=>T(!0))},[]),(0,s.useEffect)(()=>{let e=u.current;if(!e)return;let t=!1,r=0,n=0,s=e=>{t=!0,r=e.clientX,n=e.clientY,x.current&&(x.current=null,g.current())},o=s=>{t=!1;let o=s.target;if(o.closest?.(".floating-toolbar")||o.closest?.("[data-comment-card]"))return;let l=Math.abs(s.clientX-r)>5||Math.abs(s.clientY-n)>5,a=window.getSelection();if(!a||a.isCollapsed){x.current=null,g.current();return}let i=a.toString();if(!i.trim()||!l){x.current=null,g.current();return}let c=a.getRangeAt(0);if(!e.contains(c.commonAncestorContainer))return;let d=eF(c.startContainer),u=eF(c.endContainer);if(d&&u){let e=Math.min(d.start,u.start),t=Math.max(d.end,u.end);x.current={x:s.clientX,y:s.clientY,range:{start:e,end:t},selectedText:i},g.current()}},l=()=>{if(t||!x.current)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||(x.current=null,g.current())};return e.addEventListener("mousedown",s),document.addEventListener("mouseup",o),document.addEventListener("selectionchange",l),()=>{e.removeEventListener("mousedown",s),document.removeEventListener("mouseup",o),document.removeEventListener("selectionchange",l)}},[]);let O=(0,s.useCallback)(()=>{let e=x.current;e&&(R({x:e.x,y:e.y,range:e.range,codeContent:e.selectedText}),x.current=null,g.current())},[]),z=(0,s.useCallback)(()=>{let e=x.current;e&&(I({x:e.x,y:e.y,range:e.range,codeContent:e.selectedText}),x.current=null,g.current())},[]),H=(0,s.useCallback)(async e=>{$&&(await y($.range.start,$.range.end,e),R(null))},[$,y]),_=(0,s.useCallback)(async e=>{if(P&&v)try{let n=await h(r),s=[];for(let e of n)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});let o=Math.max(0,P.range.start-1),l=Math.min(F.length,P.range.end),a=F.slice(o,l).join("\n");s.push({filePath:t,startLine:P.range.start,endLine:P.range.end,codeContent:a});let i=f(s,e);v.sendMessage(i),await m(r),E(),I(null)}catch(e){console.error("Failed to send to AI:",e)}},[P,v,t,r,F,E]),U=(0,s.useMemo)(()=>{if(0===w.length)return[];let e=new Map;for(let t of w){let r=`${t.startLine}-${t.endLine}`;e.has(r)||e.set(r,[]),e.get(r).push(t)}return Array.from(e.entries()).map(([e,t])=>({key:e,startLine:t[0].startLine,endLine:t[0].endLine,comments:t}))},[w]),[q,V]=(0,s.useState)([]);return(0,s.useEffect)(()=>{if(0===U.length||!u.current)return void queueMicrotask(()=>V([]));let e=setTimeout(()=>{let e=u.current;if(!e)return;let t=[],r=e.querySelectorAll("[data-source-start]");for(let n of U){let s=null,o=1/0;for(let e of r){let t=parseInt(e.getAttribute("data-source-start"),10),r=parseInt(e.getAttribute("data-source-end"),10);if(t<=n.startLine&&r>=n.endLine){let n=r-t;n<o&&(o=n,s=e)}}if(s){let r=e.getBoundingClientRect(),o=s.getBoundingClientRect();t.push({key:n.key,top:o.top-r.top+e.scrollTop,comments:n.comments})}}V(t)},100);return()=>clearTimeout(e)},[U,e]),(0,s.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(P){I(null),e.stopPropagation();return}if($){R(null),e.stopPropagation();return}if(x.current){x.current=null,g.current(),e.stopPropagation();return}if(D){B(null),e.stopPropagation();return}l()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[P,$,D,l]),(0,n.jsxs)(n.Fragment,{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 truncate",children:t}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(eB,{content:e,sourceFile:c}),(0,n.jsx)("button",{onClick:l,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:d("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.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,n.jsx)(eD.l,{content:e,containerRef:u}),(0,n.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:u,children:[(0,n.jsx)("div",{className:"p-6",children:(0,n.jsx)(eP.T,{content:e,rehypePlugins:eO})}),q.map(({key:e,top:t,comments:r})=>(0,n.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:t},onClick:e=>{e.stopPropagation(),B({comment:r[0],x:e.clientX,y:e.clientY})},children:(0,n.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-sm hover:bg-amber-500 transition-colors",children:r.length})},e))]})]}),M&&b&&(0,a.createPortal)((0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(A,{floatingToolbarRef:x,bumpRef:g,container:b,onAddComment:O,onSendToAI:z,isChatLoading:v?.isLoading}),$&&(0,n.jsx)(S,{x:$.x,y:$.y,range:$.range,codeContent:$.codeContent,container:b,onSubmit:H,onClose:()=>R(null)}),P&&(0,n.jsx)(L,{x:P.x,y:P.y,range:P.range,filePath:t,codeContent:P.codeContent,container:b,onSubmit:_,onClose:()=>I(null),isChatLoading:v?.isLoading}),D&&(0,n.jsx)(W,{x:D.x,y:D.y,comment:D.comment,container:b,onClose:()=>B(null),onUpdateComment:k,onDeleteComment:N})]}),b)]})}function eW({path:e,matchedIndices:t}){let r=(0,s.useMemo)(()=>new Set(t),[t]),o=e.lastIndexOf("/"),l=o>=0?e.slice(0,o+1):"",a=o>=0?e.slice(o+1):e,i=(e,t,s)=>{let o=[],l="",a=!1;for(let s=0;s<e.length;s++){let i=t+s,c=r.has(i);c!==a&&l&&(o.push(a?(0,n.jsx)("span",{className:"text-brand font-medium",children:l},`${t}-${s}`):(0,n.jsx)("span",{children:l},`${t}-${s}`)),l=""),a=c,l+=e[s]}return l&&o.push(a?(0,n.jsx)("span",{className:"text-brand font-medium",children:l},`${t}-end`):(0,n.jsx)("span",{children:l},`${t}-end`)),(0,n.jsx)("span",{className:s,children:o})};return(0,n.jsxs)("span",{className:"truncate",children:[l&&i(l,0,"text-muted-foreground"),i(a,l.length,"text-foreground")]})}function ez({files:e,fileIndex:t,recentFiles:r,onSelectFile:l,onClose:i}){let{t:c}=(0,o.Bd)(),[d,u]=(0,s.useState)(""),[h,m]=(0,s.useState)(0),x=(0,s.useRef)(null),f=(0,s.useRef)(null),p=(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]),g=(0,s.useMemo)(()=>{if(!d.trim()){let e=new Set(r);return[...r.map(e=>({path:e,score:0,matchedIndices:[]})),...p.filter(t=>!e.has(t)).slice(0,50).map(e=>({path:e,score:0,matchedIndices:[]}))]}let e=[];for(let t of p){let n=function(e,t){let r=e.toLowerCase(),n=t.toLowerCase(),s=[],o=0,l=0,a=-1;for(let i=0;i<r.length&&o<n.length;i++)r[i]===n[o]&&(s.push(i),a===i-1&&(l+=5),(0===i||"/"===e[i-1]||"."===e[i-1]||"-"===e[i-1]||"_"===e[i-1])&&(l+=10),i>e.lastIndexOf("/")&&(l+=3),e[i]===t[o]&&(l+=1),a=i,o++);return o<n.length?null:(l-=.1*e.length,{path:e,score:l,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,p,r]),b=(0,s.useCallback)(e=>{u(e),m(0)},[]);(0,s.useEffect)(()=>{x.current?.focus()},[]),(0,s.useEffect)(()=>{if(f.current){let e=f.current.children[h];e?.scrollIntoView({block:"nearest"})}},[h]);let v=(0,s.useCallback)(e=>{l(e),i()},[l,i]),j=(0,s.useCallback)(e=>{if(!e.nativeEvent.isComposing)switch(e.key){case"ArrowDown":e.preventDefault(),m(e=>Math.min(e+1,g.length-1));break;case"ArrowUp":e.preventDefault(),m(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),g[h]&&v(g[h].path);break;case"Escape":e.preventDefault(),i()}},[g,h,v,i]);return(0,a.createPortal)((0,n.jsx)("div",{className:"fixed inset-0 z-[300] flex items-start justify-center pt-[15vh]",onClick:i,children:(0,n.jsxs)("div",{className:"w-[680px] max-h-[60vh] bg-card border border-border rounded-lg shadow-2xl 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:c("quickFileOpen.placeholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",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:f,className:"flex-1 overflow-y-auto py-1",children:0===g.length?(0,n.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:c("quickFileOpen.noMatch")}):g.map((e,t)=>(0,n.jsxs)("div",{className:`px-3 py-1.5 flex items-center gap-2 cursor-pointer transition-colors ${t===h?"bg-brand/15 text-foreground":"hover:bg-accent text-foreground"}`,"data-tooltip":e.path,onClick:()=>v(e.path),children:[(0,n.jsx)(V,{name:e.path.split("/").pop()||"",className:"w-4 h-4 flex-shrink-0"}),(0,n.jsx)(eW,{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:c("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:"↑↓"})," ",c("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"})," ",c("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"})," ",c("quickFileOpen.closeHint")]})]})]})}),document.body)}var eH=r(22552);function e_(){let[e,t]=(0,s.useState)(()=>"u"<typeof document||"visible"===document.visibilityState);return(0,s.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}function eU({branches:e,selectedBranch:t,onSelect:r,isLoading:l}){let{t:a}=(0,o.Bd)(),[i,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)(""),h=(0,s.useRef)(null),m=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=e=>{h.current&&!h.current.contains(e.target)&&c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,s.useEffect)(()=>{i&&m.current&&m.current.focus()},[i]);let x=e?.local.filter(e=>e.toLowerCase().includes(d.toLowerCase()))||[],f=e?.remote.filter(e=>e.toLowerCase().includes(d.toLowerCase()))||[],p=e=>{r(e),c(!1),u("")};return(0,n.jsxs)("div",{className:"relative",ref:h,children:[(0,n.jsxs)("button",{onClick:()=>c(!i),disabled:l,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||a("git.selectBranch"),e?.current===t&&(0,n.jsxs)("span",{className:"text-xs text-green-11",children:["(",a("git.currentBranch"),")"]})]}),(0,n.jsx)("svg",{className:`w-4 h-4 text-slate-9 transition-transform ${i?"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"})})]}),i&&(0,n.jsxs)("div",{className:"absolute z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lg max-h-80 flex flex-col",children:[(0,n.jsx)("div",{className:"p-2 border-b border-border",children:(0,n.jsx)("input",{ref:m,type:"text",value:d,onChange:e=>u(e.target.value),placeholder:a("git.searchBranch"),className:"w-full px-2 py-1 text-sm border border-border rounded bg-secondary text-foreground placeholder-slate-9"})}),(0,n.jsxs)("div",{className:"overflow-y-auto flex-1",children:[x.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:a("git.localBranches")}),x.map(r=>(0,n.jsxs)("div",{onClick:()=>p(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-accent 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:a("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))]}),f.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:a("git.remoteBranches")}),f.map(e=>(0,n.jsxs)("div",{onClick:()=>p(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-accent 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===x.length&&0===f.length&&(0,n.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:a("git.noMatchingBranches")})]})]})]})}function eq(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}function eV(e){return e.replace(/^\([^)]+\)\s*/,"")}let eK=(0,s.forwardRef)(function({displayString:e,documentation:t,x:r,y:l,container:a,onMouseEnter:i,onMouseLeave:c,onFindReferences:d,onSearch:u},h){let{t:m}=(0,o.Bd)(),x=(0,s.useRef)(null);(0,s.useImperativeHandle)(h,()=>x.current,[]);let f=a.getBoundingClientRect(),p=r-f.left,g=l-f.top,b=(0,s.useMemo)(()=>eV(e),[e]),v=(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,l=0,a=/\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=a.exec(e));){t.index>o&&s.push((0,n.jsx)("span",{className:"text-foreground",children:e.slice(o,t.index)},l++));let a=t[0];/^["']/.test(a)?s.push((0,n.jsx)("span",{className:"text-green-400",children:a},l++)):/^\d+$/.test(a)?s.push((0,n.jsx)("span",{className:"text-orange-300",children:a},l++)):r.test(a)?(r.lastIndex=0,s.push((0,n.jsx)("span",{className:"text-pink-400",children:a},l++))):s.push((0,n.jsx)("span",{className:"text-foreground",children:a},l++)),o=t.index+a.length}return o<e.length&&s.push((0,n.jsx)("span",{className:"text-foreground",children:e.slice(o)},l++)),s})(b),[b]);return(0,s.useEffect)(()=>{if(!x.current)return;let e=x.current,t=a.getBoundingClientRect(),n=e.getBoundingClientRect(),s=r-t.left,o=l-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,l,a]),(0,n.jsxs)("div",{ref:x,className:"absolute z-[200] max-w-lg bg-card border border-border rounded-lg shadow-xl px-3 py-2 pointer-events-none",style:{left:p,top:g},children:[(0,n.jsx)("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all leading-relaxed",children:v}),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})]}),(d||u)&&(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:c,children:[d&&(0,n.jsx)("button",{onClick:d,className:"text-[11px] text-brand hover:underline cursor-pointer",children:m("hoverTooltip.findReferences")}),u&&(0,n.jsx)("button",{onClick:()=>u(function(e){let t=eV(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]}(e)),className:"text-[11px] text-brand hover:underline cursor-pointer",children:m("hoverTooltip.search")})]})]})]})});var eJ=r(33210);function eX({references:e,loading:t,onSelect:r,onClose:l}){let{t:a}=(0,o.Bd)(),i=function(e){let[t,r]=(0,s.useState)(new Map),[n,o]=(0,s.useState)(!1),l=(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=++l.current,s=n?"github-dark":"github-light";(async()=>{let n=await R();if(t!==l.current)return;let o=new Map;for(let t=0;t<e.length;t++){let r=e[t];if(!r.lineText)continue;let l=P(r.file);if("text"!==l)try{let e=n.codeToTokens(r.lineText,{lang:l,theme:s}),a=D(e.tokens[0]||[]);a&&o.set(t,a)}catch{}}t===l.current&&r(o)})()},[e,n]),t}(e),c=[],d=new Map;for(let t=0;t<e.length;t++){let r=e[t],n=d.get(r.file);void 0===n&&(n=c.length,d.set(r.file,n),c.push({file:r.file,items:[]})),c[n].items.push({ref:r,idx:t})}return(0,n.jsxs)("div",{className:"border-t border-border bg-secondary 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:[a("references.title")," ",!t&&`(${e.length})`]}),(0,n.jsx)("button",{onClick:l,className:"p-0.5 rounded hover:bg-accent text-muted-foreground",children:(0,n.jsx)(eJ.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:a("references.searching")}):0===e.length?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:a("references.notFound")}):c.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/30 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-accent/50 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 eY({results:e,loading:t,totalMatches:r,onSelect:l,onClose:a}){let{t:i}=(0,o.Bd)(),c=function(e){let[t,r]=(0,s.useState)(new Map),[n,o]=(0,s.useState)(!1),l=(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=++l.current,s=n?"github-dark":"github-light";(async()=>{let n=await R(),o=new Map;for(let t of e){let e=P(t.path);if("text"!==e)for(let r of t.matches){if(!r.content)continue;let l=`${t.path}:${r.lineNumber}`;try{let t=n.codeToTokens(r.content,{lang:e,theme:s}),a=D(t.tokens[0]||[]);a&&o.set(l,a)}catch{}}}t===l.current&&r(o)})()},[e,n]),t}(e);return(0,n.jsxs)("div",{className:"border-t border-border bg-secondary 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:[i("searchResults.title")," ",!t&&i("searchResults.nMatches",{count:r})]}),(0,n.jsx)("button",{onClick:a,className:"p-0.5 rounded hover:bg-accent text-muted-foreground",children:(0,n.jsx)(eJ.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:i("searchResults.searching")}):0===e.length?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("searchResults.noResults")}):e.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/30 sticky top-0",children:e.path}),e.matches.map((t,r)=>{let s=`${e.path}:${t.lineNumber}`,o=c.get(s);return(0,n.jsxs)("button",{onClick:()=>l(e.path,t.lineNumber),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 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))})]})}let eQ=["agent","explorer","console"],eG={agent:"AGENT",explorer:"EXPLORER",console:"CONSOLE"},eZ=(0,s.createContext)(null);function e0(){let e=(0,s.useContext)(eZ);if(!e)throw Error("useSwipeContext must be used within SwipeableViewContainer");return e}function e1({activeView:e,onViewChange:t,children:r}){let o=(0,s.useRef)(null),l=(0,s.useRef)(!1),a=(0,s.useRef)(0),[i,c]=(0,s.useState)(0),[d,u]=(0,s.useState)(!1),h=eQ.indexOf(e),m=eQ.length-1;(0,s.useEffect)(()=>{a.current=0,queueMicrotask(()=>c(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(),l.current&&(l.current=!1);let n=window.innerWidth,s=a.current-6*e.deltaX;!(h>0)&&s>0&&(s=0),!(h<m)&&s<0&&(s=0),a.current=s=Math.max(-n,Math.min(n,s)),c(s),u(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{let e=a.current,r=.12*n;u(!1),l.current=!0;let s=h;e<-r&&h<m?s=h+1:e>r&&h>0&&(s=h-1),a.current=0,c(0),s!==h&&t(eQ[s]),setTimeout(()=>{l.current=!1},80)},60)}};return document.addEventListener("wheel",e,{passive:!1,capture:!0}),()=>document.removeEventListener("wheel",e,{capture:!0})},[h,m,t]);let[x,f]=(0,s.useState)(!1);(0,s.useEffect)(()=>{queueMicrotask(()=>f(!0))},[]);let p={activeView:e,onViewChange:t,dragOffset:(()=>{if(!x)return 0;let e=window.innerWidth;return e?i/e:0})(),isDragging:x&&d};return(0,n.jsx)(eZ.Provider,{value:p,children:r})}function e2({children:e}){let t,r,{activeView:o,dragOffset:l,isDragging:a}=e0(),i=(0,s.useRef)(null),c=(0,s.useRef)(null),d=eQ.indexOf(o),u=eQ.length;return(0,s.useEffect)(()=>{let e=i.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:i,className:"flex-1 overflow-hidden relative",style:{overscrollBehaviorX:"none"},children:(0,n.jsx)("div",{ref:c,className:a?"flex":"flex transition-transform duration-100 ease-out",style:{position:"absolute",top:"0px",bottom:"0px",left:"0px",width:`${100*eQ.length}%`,transform:(t=l/u*100,r=-(100/u*d)+(Number.isFinite(t)?t:0),`translateX(${r}%)`)},children:e})})}function e5(){let{activeView:e,onViewChange:t,dragOffset:r,isDragging:o}=e0(),l=(0,s.useRef)(null),a=(0,s.useRef)([]),[i,c]=(0,s.useState)({left:0,width:0}),d=eQ.indexOf(e),u=()=>{if(!l.current||0===a.current.length)return{left:0,width:0};let e=l.current.getBoundingClientRect(),t=a.current.filter(Boolean);if(t.length!==eQ.length)return{left:0,width:0};let n=Number.isFinite(r)?r:0,s=Math.max(0,Math.min(eQ.length-1,d-n)),o=Math.floor(s),i=Math.ceil(s),c=s-o,u=t[o],h=t[i];if(!u||!h)return{left:0,width:0};let m=u.getBoundingClientRect(),x=h.getBoundingClientRect();return{left:m.left+(x.left-m.left)*c-e.left,width:m.width+(x.width-m.width)*c}};(0,s.useEffect)(()=>{queueMicrotask(()=>c(u()))},[d,r]),(0,s.useEffect)(()=>{let e=()=>{c(u())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[d,r]);let h=Number.isFinite(r)?r:0,m=Math.round(Math.max(0,Math.min(eQ.length-1,d-h)));return(0,n.jsxs)("div",{ref:l,className:"relative flex gap-4",children:[eQ.map((e,r)=>(0,n.jsx)("button",{ref:e=>{a.current[r]=e},onClick:()=>t(e),className:`px-4 py-1 text-sm font-medium transition-colors ${m===r?"text-brand":"text-muted-foreground hover:text-foreground"}`,children:eG[e]},e)),(0,n.jsx)("div",{className:`absolute bottom-0 h-0.5 bg-brand ${o?"":"transition-all duration-100 ease-out"}`,style:{left:i.left,width:i.width}})]})}function e4({onClose:e,cwd:t,initialTab:r="tree",tabSwitchTrigger:l,initialSearchQuery:i,searchQueryTrigger:d}){var u,h;let m,x,f,p,b,j,w,{t:y}=(0,o.Bd)(),{activeView:k}=e0(),[N,C]=(0,s.useState)(r),S=(0,s.useRef)(null),L=(0,s.useRef)(!1),[E,M]=(0,s.useState)(null),[T,$]=(0,s.useState)(null),[R,P]=(0,s.useState)(!1),[I,D]=(0,s.useState)(null),B=(0,s.useRef)(1),F=(0,s.useRef)(null),[O,A]=(0,s.useState)(null),W=(0,s.useRef)(null),[z,_]=(0,s.useState)({isDirty:!1,isSaving:!1}),[U,q]=(0,s.useState)(!1),[V,K]=(0,s.useState)(!1),[J,ee]=(0,s.useState)(null),et=(0,s.useRef)(null),er=eu(et),en=(0,s.useRef)(null),es=eu(en),eo=function(e){let[t,r]=(0,s.useState)(!1);return{goToDefinition:(0,s.useCallback)(async(t,n,s)=>{r(!0);try{let r=await fetch("/api/lsp/definition",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,filePath:t,line:n,column:s})});return(await r.json()).definitions||[]}catch(e){return console.error("[useLSP] definition error:",e),[]}finally{r(!1)}},[e]),loading:t}}(t),el=function(e){let[t,r]=(0,s.useState)(null),n=(0,s.useRef)(null),o=(0,s.useRef)(null),l=(0,s.useRef)(0),a=(0,s.useRef)(!1),i=(0,s.useRef)(null),c=(0,s.useRef)({x:0,y:0});(0,s.useEffect)(()=>{let e=e=>{c.current.x=e.clientX,c.current.y=e.clientY};return document.addEventListener("mousemove",e),()=>document.removeEventListener("mousemove",e)},[]);let d=(0,s.useRef)(!1),u=(0,s.useRef)(null),h=(0,s.useCallback)(()=>{let e=i.current;e&&d.current&&(e.style.pointerEvents="none"),d.current=!1,u.current&&(i.current?.removeEventListener("mouseleave",u.current),u.current=null)},[]),m=(0,s.useCallback)(()=>{let e=i.current;if(!e||d.current)return;d.current=!0,a.current=!0,e.style.pointerEvents="auto";let t=()=>{a.current=!1,h(),l.current++,r(null)};u.current=t,e.addEventListener("mouseleave",t)},[h]),x=(0,s.useCallback)((t,s,a,i)=>{n.current&&clearTimeout(n.current),o.current&&clearTimeout(o.current);let c=++l.current;n.current=setTimeout(async()=>{try{let n=await fetch("/api/lsp/hover",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,filePath:t,line:s,column:a})}),o=await n.json();if(c!==l.current)return;o.hover&&o.hover.displayString&&r({...o.hover,x:i.x,y:i.y,filePath:t,line:s,column:a})}catch{}},300)},[e]),f=(0,s.useCallback)(()=>{n.current&&clearTimeout(n.current),l.current++,o.current=setTimeout(function(){if(a.current)return;let e=i.current;if(e){let t=e.getBoundingClientRect(),{x:r,y:n}=c.current;if(r>=t.left&&r<=t.right&&n>=t.top&&n<=t.bottom)return void m()}r(null)},150)},[m]),p=(0,s.useCallback)(()=>{a.current=!0,o.current&&clearTimeout(o.current)},[]),g=(0,s.useCallback)(()=>{a.current=!1,l.current++,r(null)},[]),b=(0,s.useCallback)(()=>{n.current&&clearTimeout(n.current),o.current&&clearTimeout(o.current),a.current=!1,h(),l.current++,r(null)},[h]);return(0,s.useEffect)(()=>{t||h()},[t,h]),{hoverInfo:t,onTokenMouseEnter:x,onTokenMouseLeave:f,onCardMouseEnter:p,onCardMouseLeave:g,clearHover:b,tooltipElRef:i}}(t),ea=function(e){let[t,r]=(0,s.useState)([]),[n,o]=(0,s.useState)(!1),[l,a]=(0,s.useState)(!1);return{references:t,loading:n,visible:l,findReferences:(0,s.useCallback)(async(t,n,s)=>{o(!0),a(!0);try{let o=await fetch("/api/lsp/references",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,filePath:t,line:n,column:s})}),l=await o.json();r(l.references||[])}catch(e){console.error("[useLSP] references error:",e),r([])}finally{o(!1)}},[e]),closeReferences:(0,s.useCallback)(()=>{a(!1),r([])},[])}}(t),ei=(m=(0,s.useRef)([]),x=(0,s.useRef)([]),f=(0,s.useCallback)(e=>{m.current.push(e),m.current.length>50&&(m.current=m.current.slice(-50)),x.current=[]},[]),p=(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},[]),b=(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:f,goBack:p,goForward:b,canGoBack:(0,s.useCallback)(()=>m.current.length>0,[]),canGoForward:(0,s.useCallback)(()=>x.current.length>0,[])}),ed=e_(),ex=function({cwd:e}){let[t,r]=(0,s.useState)([]),[n,o]=(0,s.useState)(null),[l,a]=(0,s.useState)(new Set),[i,c]=(0,s.useState)([]),[d,u]=(0,s.useState)(null),[h,m]=(0,s.useState)(null),[x,f]=(0,s.useState)(new Set),[p,g]=(0,s.useState)(null),[b,v]=(0,s.useState)(""),[j,w]=(0,s.useState)(!1),[y,k]=(0,s.useState)(null),[N,C]=(0,s.useState)(!1),[S,L]=(0,s.useState)(!1),[E,M]=(0,s.useState)(null),T=(0,s.useRef)(null),[$,R]=(0,s.useState)(!1),[P,I]=(0,s.useState)(null),[D,B]=(0,s.useState)("center"),[F,O]=(0,s.useState)(null),[A,W]=(0,s.useState)(null),[z,H]=(0,s.useState)(!1),[_,U]=(0,s.useState)([]),[q,V]=(0,s.useState)(!1),[K,J]=(0,s.useState)(null),[X,Y]=(0,s.useState)(null),[Q,G]=(0,s.useState)(!1),[Z,ee]=(0,s.useState)(!1),et=(0,s.useMemo)(()=>i.map(e=>e.path).filter(Boolean),[i]),er=(0,s.useMemo)(()=>eN(et),[et]),en=(0,s.useMemo)(()=>new Set(eC(er)),[er]),es=(0,s.useMemo)(()=>b?n?function(e,t,r=!1){let n=new Set;if(!t)return n;let s=t.toLowerCase();for(let t of e){let e=t.split("/");for(let t=0;t<e.length;t++){let o=e[t].toLowerCase();if(r?o===s:o.includes(s)){for(let t=0;t<=e.length-1;t++)n.add(e.slice(0,t+1).join("/"));break}}}return n}(n,b,j):function(e,t,r=!1){let n=new Set;if(!t)return n;let s=t.toLowerCase(),o=e=>{if(n.add(e.path),e.children)for(let t of e.children)o(t)},l=(e,t)=>{let a=e.name.toLowerCase(),i=r?a===s:a.includes(s);if(i&&e.children)return o(e),t.forEach(e=>n.add(e)),!0;let c=!1;if(e.children)for(let r of e.children)l(r,[...t,e.path])&&(c=!0);return(!!i||!!c)&&(n.add(e.path),t.forEach(e=>n.add(e)),!0)};for(let t of e)l(t,[]);return n}(t,b,j):null,[t,n,b,j]);(0,s.useEffect)(()=>{if(!es||0===es.size)return void g(null);let e=new Set;if(n){let t=new Set(n);for(let r of es)t.has(r)||e.add(r)}else{let r=t=>{for(let n of t)n.isDirectory&&n.children&&es.has(n.path)&&(e.add(n.path),r(n.children))};r(t)}g(e)},[es,t,n]);let eo=p??x,el=(0,s.useRef)(null),ea=(0,s.useCallback)(t=>{el.current&&clearTimeout(el.current),el.current=setTimeout(async()=>{try{await fetch("/api/files/expanded",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,paths:Array.from(t)})})}catch(e){console.error("Error saving expanded paths:",e)}},500)},[e]),ei=(0,s.useCallback)(async()=>{C(!0),M(null);try{let t=await fetch(`/api/files/init?cwd=${encodeURIComponent(e)}`),n=await t.json();n.error?M(n.error):(r(n.files||[]),n.expandedPaths&&Array.isArray(n.expandedPaths)&&f(new Set(n.expandedPaths)))}catch(e){console.error("Error loading files:",e),M("Failed to load files")}finally{C(!1)}},[e]),ec=(0,s.useCallback)(async()=>{try{let t=await fetch(`/api/files/index?cwd=${encodeURIComponent(e)}`),r=await t.json();r.paths&&o(r.paths)}catch(e){console.error("Error loading file index:",e)}},[e]),ed=(0,s.useCallback)(async t=>{a(e=>new Set([...e,t]));try{let n=await fetch(`/api/files/readdir?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`),s=await n.json();s.children&&r(e=>{if(!t){let t=new Map(e.map(e=>[e.path,e]));return s.children.map(e=>{let r=t.get(e.path);return r?.children&&e.isDirectory?{...e,children:r.children}:e})}let r=structuredClone(e),n=ek(r,t);return n&&(n.children=s.children),r})}catch(e){console.error("Error loading directory:",e)}finally{a(e=>{let r=new Set(e);return r.delete(t),r})}},[e]),eu=(0,s.useRef)(l);eu.current=l,(0,s.useEffect)(()=>{for(let e of p??x){let r=ek(t,e);r&&r.isDirectory&&!r.children&&!eu.current.has(e)&&ed(e)}},[t,x,p,ed]);let eh=(0,s.useCallback)(async()=>{try{let t=await fetch(`/api/files/recent?cwd=${encodeURIComponent(e)}`),r=await t.json();c(r.files||[])}catch(e){console.error("Error loading recent files:",e)}},[e]),em=(0,s.useCallback)(async t=>{c(e=>{let r=e.filter(e=>e.path!==t);return[{path:t},...r].slice(0,15)});try{await fetch("/api/files/recent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,file:t})})}catch(e){console.error("Error adding to recent files:",e)}},[e]),ex=(0,s.useCallback)((t,r,n,s)=>{c(e=>e.map(e=>e.path===t?{...e,scrollLine:r,cursorLine:n,cursorCol:s}:e)),fetch("/api/files/recent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,file:t,scrollLine:r,cursorLine:n,cursorCol:s})}).catch(()=>{})},[e]),ef=(0,s.useCallback)(e=>i.find(t=>t.path===e),[i]),ep=(0,s.useCallback)(async t=>{let r=t||d;if(r){V(!0),J(null);try{let t=await fetch(`/api/files/blame?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(r)}`),n=await t.json();n.error?J(n.error):U(n.blame||[])}catch(e){console.error("Error loading blame:",e),J("Failed to load blame info")}finally{V(!1)}}},[e,d]),eg=(0,s.useCallback)(async t=>{L(!0),m(null),H(!1),U([]),J(null),Y(null);try{let r=await fetch(`/api/files/read?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`),n=await r.json();m(n),em(t),ep(t)}catch(e){console.error("Error loading file content:",e),m({type:"error",message:"Failed to load file"})}finally{L(!1)}},[e,em,ep]),eb=(0,s.useCallback)(()=>{z?H(!1):(H(!0),0===_.length&&ep())},[z,_.length,ep]),ev=(0,s.useCallback)((e,t)=>{if(!e)return;if(u(e),I(t??null),null==t){let t=i.find(t=>t.path===e);t?.scrollLine?(I(t.scrollLine),B("start"),O(t.cursorLine??null),W(t.cursorCol??null)):(B("center"),O(null),W(null))}else B("center"),O(null),W(null);eg(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("/"));f(t=>{let r=new Set(t),n=!1;for(let t of e)r.has(t)||(r.add(t),n=!0);return n&&ea(r),n?r:t})}},[eg,ea,i]),ej=(0,s.useCallback)(e=>{if(p)g(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r});else{let r=!x.has(e);if(f(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),ea(r),r}),r){let r=ek(t,e);r&&r.isDirectory&&!r.children&&ed(e)}}},[p,ea,x,t,ed]);return{files:t,setFiles:r,fileIndex:n,setFileIndex:o,loadingDirs:l,expandedPaths:x,setExpandedPaths:f,searchTreeExpandedPaths:p,setSearchTreeExpandedPaths:g,effectiveExpandedPaths:eo,searchQuery:b,setSearchQuery:v,searchExactMatch:j,setSearchDirExact:w,matchedPaths:es,creatingItem:y,setCreatingItem:k,isLoadingFiles:N,fileError:E,searchInputRef:T,shouldScrollToSelected:$,setShouldScrollToSelected:R,targetLineNumber:P,setTargetLineNumber:I,targetScrollAlign:D,setTargetScrollAlign:B,initialCursorLine:F,initialCursorCol:A,setInitialCursorLine:O,setInitialCursorCol:W,selectedPath:d,setSelectedPath:u,fileContent:h,setFileContent:m,isLoadingContent:S,recentFiles:i,recentFilePaths:et,setRecentFiles:c,recentFilesTree:er,recentTreeDirPaths:en,showBlame:z,setShowBlame:H,blameLines:_,isLoadingBlame:q,blameError:K,blameSelectedCommit:X,setBlameSelectedCommit:Y,showMarkdownPreview:Q,setShowMarkdownPreview:G,showEditor:Z,setShowEditor:ee,saveExpandedPaths:ea,loadFiles:ei,loadFileIndex:ec,loadDirectory:ed,loadRecentFiles:eh,addToRecentFiles:em,updateRecentFilePosition:ex,getRecentFilePosition:ef,loadFileContent:eg,loadBlame:ep,handleToggleBlame:eb,handleSelectFile:ev,handleToggle:ej}}({cwd:t});u=ex.selectedPath,j=(0,s.useRef)(null),(0,s.useEffect)(()=>{!u||u===j.current||eq(u)&&(j.current=u,fetch("/api/lsp/warmup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t,filePath:u})}).catch(()=>{}))},[t,u]);let ef=function({cwd:e,onSearchComplete:t}){let[r,n]=(0,s.useState)(""),[o,l]=(0,s.useState)([]),[a,i]=(0,s.useState)(!1),[d,u]=(0,s.useState)(null),[h,m]=(0,s.useState)(new Set),[x,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){l([]),g(null);return}if(n.length<2)return void u(c.A.t("fileBrowser.searchMinChars"));i(!0),u(null);try{let n=new URLSearchParams({cwd:e,q:r,caseSensitive:String(x.caseSensitive),wholeWord:String(x.wholeWord),regex:String(x.regex),fileType:x.fileType}),s=await fetch(`/api/files/search?${n}`),o=await s.json();if(o.error)throw Error(o.error);l(o.results),g({totalFiles:o.totalFiles,totalMatches:o.totalMatches,truncated:o.truncated});let a=new Set(o.results.map(e=>e.path));m(a),o.results.length>0&&t?.()}catch(e){u(e instanceof Error?e.message:"Search failed"),l([])}finally{i(!1)}},[e,x,t]);return{contentSearchQuery:r,setContentSearchQuery:n,contentSearchResults:o,isSearching:a,searchError:d,searchExpandedPaths:h,searchOptions:x,setSearchOptions:f,searchStats:p,contentSearchInputRef:b,performContentSearch:v,handleSearchToggle:(0,s.useCallback)(e=>{m(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[])}}({cwd:t,onSearchComplete:()=>q(!0)}),eg=function({cwd:e,addToRecentFiles:t}){let[r,n]=(0,s.useState)(null),[o,l]=(0,s.useState)(!1),[a,i]=(0,s.useState)(null),[d,u]=(0,s.useState)(null),[h,m]=(0,s.useState)(null),[x,f]=(0,s.useState)(!1),[p,b]=(0,s.useState)(new Set),[v,j]=(0,s.useState)([]),[w,y]=(0,s.useState)([]),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(0),L=(0,s.useCallback)(async()=>{l(!0),i(null);try{let t=`/api/git/status?cwd=${encodeURIComponent(e)}`,r=await fetch(t);if(!r.ok){let e=await r.json();throw Error(e.error||"Failed to fetch git status")}let s=await r.json();n(s);let o=Y(s.staged),l=Y(s.unstaged);j(o),y(l);let a=new Set([...Q(o),...Q(l)]);b(a)}catch(e){i(e instanceof Error?e.message:"Unknown error")}finally{l(!1)}},[e]),E=(0,s.useCallback)(e=>{b(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),M=(0,s.useCallback)((e,r)=>{u({file:e,type:r}),t(e.path)},[t]),T=(0,s.useCallback)(async t=>{try{if(!(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,files:[t]})})).ok)throw Error("Failed to stage file");await L(),(0,g.oR)(c.A.t("toast.staged"),"success")}catch(e){console.error("Error staging file:",e),(0,g.oR)(c.A.t("toast.stageFailed"),"error")}},[e,L]),$=(0,s.useCallback)(async t=>{try{if(!(await fetch("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,files:[t]})})).ok)throw Error("Failed to unstage file");await L(),(0,g.oR)(c.A.t("toast.unstaged"),"success")}catch(e){console.error("Error unstaging file:",e),(0,g.oR)(c.A.t("toast.unstageFailed"),"error")}},[e,L]),R=(0,s.useCallback)(async t=>{if(0!==t.length)try{if(!(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,files:t})})).ok)throw Error("Failed to stage files");await L(),(0,g.oR)(c.A.t("toast.stagedNFiles",{count:t.length}),"success")}catch(e){console.error("Error staging files:",e),(0,g.oR)(c.A.t("toast.stageFailed"),"error")}},[e,L]),P=(0,s.useCallback)(async t=>{if(0!==t.length)try{if(!(await fetch("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,files:t})})).ok)throw Error("Failed to unstage files");await L(),(0,g.oR)(c.A.t("toast.unstagedNFiles",{count:t.length}),"success")}catch(e){console.error("Error unstaging files:",e),(0,g.oR)(c.A.t("toast.unstageFailed"),"error")}},[e,L]),I=(0,s.useCallback)(async t=>{if(0!==t.length)try{let r=t.filter(e=>"untracked"===e.status).map(e=>e.path),n=t.filter(e=>"untracked"!==e.status).map(e=>e.path);if(r.length>0&&!(await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,files:r,isUntracked:!0})})).ok)throw Error("Failed to discard untracked files");if(n.length>0&&!(await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,files:n,isUntracked:!1})})).ok)throw Error("Failed to discard tracked files");await L(),(0,g.oR)(c.A.t("toast.discardedNFiles",{count:t.length}),"success")}catch(e){console.error("Error discarding files:",e),(0,g.oR)(c.A.t("toast.discardFailed"),"error")}},[e,L]),D=(0,s.useCallback)(async()=>{if(r?.unstaged.length)try{if(!(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,files:r.unstaged.map(e=>e.path)})})).ok)throw Error("Failed to stage all files");await L(),(0,g.oR)(c.A.t("toast.stagedNFiles",{count:r.unstaged.length}),"success")}catch(e){console.error("Error staging all files:",e),(0,g.oR)(c.A.t("toast.stageFailed"),"error")}},[e,r,L]),B=(0,s.useCallback)(async()=>{if(r?.staged.length)try{if(!(await fetch("/api/git/unstage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,files:r.staged.map(e=>e.path)})})).ok)throw Error("Failed to unstage all files");await L(),(0,g.oR)(c.A.t("toast.unstagedNFiles",{count:r.staged.length}),"success")}catch(e){console.error("Error unstaging all files:",e),(0,g.oR)(c.A.t("toast.unstageFailed"),"error")}},[e,r,L]),F=(0,s.useCallback)(async t=>{try{let r="untracked"===t.status;if(!(await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,files:[t.path],isUntracked:r})})).ok)throw Error("Failed to discard file");await L(),(0,g.oR)(r?c.A.t("toast.deletedFile"):c.A.t("toast.discardedChanges"),"success")}catch(e){console.error("Error discarding file:",e),(0,g.oR)(c.A.t("toast.discardFailed"),"error")}},[e,L]),O=(0,s.useCallback)(async()=>{if(r?.unstaged.length&&await (0,g.lJ)(c.A.t("git.discardAllConfirm",{count:r.unstaged.length}),{danger:!0}))try{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);n.length>0&&await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,files:n,isUntracked:!1})}),t.length>0&&await fetch("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,files:t,isUntracked:!0})}),await L(),(0,g.oR)(c.A.t("toast.discardedNFiles",{count:r.unstaged.length}),"success")}catch(e){console.error("Error discarding all:",e),(0,g.oR)(c.A.t("toast.discardFailed"),"error")}},[e,r,L]);return(0,s.useEffect)(()=>{d?(async()=>{f(!0);try{let t=new URLSearchParams({file:d.file.path,type:d.type});t.set("cwd",e);let r=await fetch(`/api/git/diff?${t}`);if(!r.ok)throw Error("Failed to fetch diff");let n=await r.json();m(n)}catch(e){console.error("Error fetching diff:",e)}finally{f(!1)}})():m(null)},[d,e,C]),{status:r,setStatus:n,statusLoading:o,statusError:a,statusSelectedFile:d,statusDiff:h,statusDiffLoading:x,statusExpandedPaths:p,setStatusExpandedPaths:b,stagedTree:v,setStagedTree:j,unstagedTree:w,setUnstagedTree:y,showStatusDiffPreview:k,setShowStatusDiffPreview:N,fetchStatus:L,handleStatusToggle:E,handleStatusFileSelect:M,handleStage:T,handleUnstage:$,handleStageFiles:R,handleUnstageFiles:P,handleDiscardFiles:I,handleStageAll:D,handleUnstageAll:B,handleDiscardFile:F,handleDiscardAll:O,refreshDiff:(0,s.useCallback)(()=>S(e=>e+1),[])}}({cwd:t,addToRecentFiles:ex.addToRecentFiles}),eb=function({cwd:e,addToRecentFiles:t}){let[r,n]=(0,s.useState)(null),[o,l]=(0,s.useState)(""),[a,i]=(0,s.useState)([]),[d,u]=(0,s.useState)(null),[h,m]=(0,s.useState)([]),[x,f]=(0,s.useState)([]),[p,g]=(0,s.useState)(new Set),[b,v]=(0,s.useState)(null),[j,w]=(0,s.useState)(null),[y,k]=(0,s.useState)(!1),[N,C]=(0,s.useState)(!1),[S,L]=(0,s.useState)(!1),[E,M]=(0,s.useState)(!0),[T,$]=(0,s.useState)(!1),[R,P]=(0,s.useState)(!1),[I,D]=(0,s.useState)(null),B=(0,s.useRef)(null),[F,O]=(0,s.useState)(null),[A,W]=(0,s.useState)(!1),[z,H]=(0,s.useState)(""),[_,U]=(0,s.useState)(""),[q,V]=(0,s.useState)([]),[K,J]=(0,s.useState)([]),[X,G]=(0,s.useState)(new Set),[Z,ee]=(0,s.useState)(null),[et,er]=(0,s.useState)(null),[en,es]=(0,s.useState)(!1),[eo,el]=(0,s.useState)(!1),ea=(0,s.useCallback)(()=>{k(!0),D(null),fetch(`/api/git/branches?cwd=${encodeURIComponent(e)}`).then(e=>e.json()).then(e=>{e.error?(D("Failed to get branches"===e.error?c.A.t("git.notGitRepo"):e.error),n(null)):e.local&&e.current?(n(e),l(e.current),e.upstream&&U(e.upstream)):(D(c.A.t("git.cannotGetBranches")),n(null))}).catch(e=>{console.error(e),D(c.A.t("git.getBranchesFailed")),n(null)}).finally(()=>k(!1))},[e]),ei=(0,s.useCallback)(t=>{C(!0),u(null),m([]),f([]),v(null),w(null),M(!0),fetch(`/api/git/commits?cwd=${encodeURIComponent(e)}&branch=${encodeURIComponent(t)}&limit=50`).then(e=>e.json()).then(e=>{let t=e.commits||[];i(t),M(t.length>=50)}).catch(console.error).finally(()=>C(!1))},[e]),ec=(0,s.useCallback)(()=>{if(S||!E||!o)return;L(!0);let t=a.length;fetch(`/api/git/commits?cwd=${encodeURIComponent(e)}&branch=${encodeURIComponent(o)}&limit=50&offset=${t}`).then(e=>e.json()).then(e=>{let t=e.commits||[];t.length>0&&i(e=>[...e,...t]),M(t.length>=50)}).catch(console.error).finally(()=>L(!1))},[e,o,a.length,S,E]),ed=(0,s.useCallback)(e=>{let{scrollTop:t,scrollHeight:r,clientHeight:n}=e.target;r-t-n<100&&ec()},[ec]),eu=(0,s.useCallback)(t=>{u(t),v(null),w(null),$(!0),fetch(`/api/git/commit-diff?cwd=${encodeURIComponent(e)}&hash=${t.hash}`).then(e=>e.json()).then(e=>{let t=e.files||[];m(t);let r=Y(t);f(r),g(new Set(Q(r)))}).catch(console.error).finally(()=>$(!1))},[e]),eh=(0,s.useCallback)(r=>{d&&(v(r),t(r.path),P(!0),fetch(`/api/git/commit-diff?cwd=${encodeURIComponent(e)}&hash=${d.hash}&file=${encodeURIComponent(r.path)}`).then(e=>e.json()).then(e=>w(e)).catch(console.error).finally(()=>P(!1)))},[e,d,t]),em=(0,s.useCallback)(e=>{g(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),ex=(0,s.useCallback)(t=>{es(!0),ee(null),er(null),fetch(`/api/git/branch-diff?cwd=${encodeURIComponent(e)}&base=${encodeURIComponent(t)}`).then(e=>e.json()).then(e=>{let t=e.files||[];V(t);let r=Y(t);J(r),G(new Set(Q(r)))}).catch(console.error).finally(()=>es(!1))},[e]),ef=(0,s.useCallback)(r=>{ee(r),t(r.path),el(!0),fetch(`/api/git/branch-diff?cwd=${encodeURIComponent(e)}&base=${encodeURIComponent(o)}&file=${encodeURIComponent(r.path)}`).then(e=>e.json()).then(e=>er(e)).catch(console.error).finally(()=>el(!1))},[e,o,t]),ep=(0,s.useCallback)(e=>{G(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),eg=(0,s.useCallback)(e=>{if(W(e),e){H(o);let e=_||"origin/main";l(e),ex(e)}else V([]),J([]),ee(null),er(null),z&&(l(z),ei(z))},[o,z,_,ex,ei]);return{branches:r,selectedBranch:o,setSelectedBranch:l,commits:a,setCommits:i,selectedCommit:d,setSelectedCommit:u,historyFiles:h,historyFileTree:x,historyExpandedPaths:p,historySelectedFile:b,historyFileDiff:j,isLoadingBranches:y,isLoadingCommits:N,isLoadingMore:S,hasMoreCommits:E,setHasMoreCommits:M,isLoadingHistoryFiles:T,isLoadingHistoryDiff:R,historyError:I,commitListRef:B,tooltipPos:F,loadBranches:ea,loadCommits:ei,loadMoreCommits:ec,handleCommitListScroll:ed,handleSelectCommit:eu,handleSelectHistoryFile:eh,handleHistoryToggle:em,handleCommitInfoMouseMove:(0,s.useCallback)(e=>{O({x:e.clientX,y:e.clientY})},[]),handleCommitInfoMouseLeave:(0,s.useCallback)(()=>{O(null)},[]),compareMode:A,toggleCompareMode:eg,compareFiles:q,compareFileTree:K,compareExpandedPaths:X,compareSelectedFile:Z,compareFileDiff:et,isLoadingCompareFiles:en,isLoadingCompareDiff:eo,handleSelectCompareFile:ef,handleCompareToggle:ep,loadCompareFiles:ex}}({cwd:t,addToRecentFiles:ex.addToRecentFiles}),ev=(0,s.useCallback)(e=>{ex.setFileContent(t=>t?.type==="text"?{...t,content:e}:t)},[ex]),ej=(0,s.useCallback)(e=>{ex.setShowEditor(!0)},[ex]),ew=(0,s.useCallback)(async()=>{if(ex.fileContent&&"text"===ex.fileContent.type&&ex.fileContent.content)try{let e=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t,path:ex.selectedPath,content:ex.fileContent.content})});if(!e.ok)throw Error("Failed to save file");let r=await e.json();r.mtime&&ex.setFileContent(e=>e?.type==="text"?{...e,mtime:r.mtime}:e),(0,g.oR)(y("toast.savedSuccess"),"success")}catch{(0,g.oR)(y("toast.saveFailed"),"error")}},[t,ex]),ey=(0,s.useCallback)(()=>{if(!ex.selectedPath)return;let e=B.current,t=F.current;e>0&&ex.updateRecentFilePosition(ex.selectedPath,e,t?t.cursorLine+1:e,t?t.cursorCol+1:1)},[ex]),eE=(0,s.useCallback)((e,t)=>{e!==ex.selectedPath&&ey(),ex.handleSelectFile(e,t)},[ex,ey]),eM=(0,s.useMemo)(()=>{let e=ef.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=eN(r),s=new Set(eC(n));return{files:n,expandDirs:s,matchMap:t}},[ef.contentSearchResults]),[eT,e$]=(0,s.useState)(new Set);(0,s.useEffect)(()=>{e$(eM.expandDirs)},[eM.expandDirs]);let eP=(0,s.useCallback)(e=>{e$(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),eI=(0,s.useCallback)(e=>{if(e.isDirectory)return null;let t=eM.matchMap.get(e.path);return t?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:t.matches.length}):null},[eM.matchMap]),eD=U&&ef.contentSearchResults.length>0,eB=!!ex.selectedPath&&null!==eq(ex.selectedPath),eF=(0,s.useCallback)(async(e,r)=>{if(!ex.selectedPath||!eB)return;let n=await eo.goToDefinition(ex.selectedPath,e,r);if(0===n.length)return;let s=n[0],o=t.endsWith("/")?t:t+"/",l=s.file.startsWith(o)?s.file.slice(o.length):s.file;ei.push({filePath:ex.selectedPath,lineNumber:B.current}),l===ex.selectedPath?ex.setTargetLineNumber(s.line):eE(l,s.line)},[ex,t,eB,eo,ei]),eO=(0,s.useCallback)((e,t,r)=>{ex.selectedPath&&eB&&el.onTokenMouseEnter(ex.selectedPath,e,t,r)},[ex.selectedPath,eB,el]),eW=(0,s.useCallback)(e=>{let r=t.endsWith("/")?t:t+"/",n=e.file.startsWith(r)?e.file.slice(r.length):e.file;ex.selectedPath&&ei.push({filePath:ex.selectedPath,lineNumber:B.current}),n===ex.selectedPath?ex.setTargetLineNumber(e.line):eE(n,e.line)},[ex,t,ei]),eV=(0,s.useMemo)(()=>{if(!eg.status)return null;let e=new Map,t=e=>{switch(e){case"modified":default:return"M";case"added":return"A";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?"}};for(let r of eg.status.staged)e.set(r.path,t(r.status));for(let r of eg.status.unstaged)e.set(r.path,t(r.status));return e},[eg.status]);(0,s.useEffect)(()=>{M(S.current)},[]),(0,s.useEffect)(()=>{let e=S.current;if(!e)return;let t=t=>{let r=t;for(;r&&r!==e;){if(r.dataset.tooltip)return r.dataset.tooltip;r=r.parentElement}return null},r=e=>{let r=t(e.target);r?D({text:r,x:e.clientX,y:e.clientY}):D(null)},n=e=>{D(r=>{if(!r)return null;let n=t(e.target);return n?{text:n,x:e.clientX,y:e.clientY}:null})},s=r=>{let n=r.relatedTarget;n&&e.contains(n)&&t(n)||D(null)};return e.addEventListener("mouseover",r),e.addEventListener("mousemove",n),e.addEventListener("mouseout",s),()=>{e.removeEventListener("mouseover",r),e.removeEventListener("mousemove",n),e.removeEventListener("mouseout",s)}},[]),(0,s.useEffect)(()=>{C(r)},[r,l]),(0,s.useEffect)(()=>{i&&(C("search"),ef.setContentSearchQuery(i),ef.performContentSearch(i))},[d]);let eJ=(0,s.useCallback)(e=>{C(e),ex.setBlameSelectedCommit(null),"history"===e&&eb.selectedBranch&&eb.loadCommits(eb.selectedBranch)},[ex,eb.selectedBranch,eb.loadCommits]),eQ=(0,s.useCallback)(()=>{if(!ex.selectedPath)return;let e={filePath:ex.selectedPath,lineNumber:B.current},t=ei.goBack(e);t&&(t.filePath===ex.selectedPath?ex.setTargetLineNumber(t.lineNumber):eE(t.filePath,t.lineNumber))},[ex,ei]),eG=(0,s.useCallback)(()=>{if(!ex.selectedPath)return;let e={filePath:ex.selectedPath,lineNumber:B.current},t=ei.goForward(e);t&&(t.filePath===ex.selectedPath?ex.setTargetLineNumber(t.lineNumber):eE(t.filePath,t.lineNumber))},[ex,ei]),eZ=(0,s.useCallback)(async e=>{let r=e.split("/").pop()||e;try{await fetch("/api/files/clipboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t,path:e})}),(0,g.oR)(y("toast.copiedName",{name:r}),"success")}catch{(0,g.oR)(y("toast.copyFailed"),"error")}},[t]),e1=(0,s.useCallback)(async e=>{try{let r=await fetch("/api/files/clipboard"),n=await r.json();if(!n.path)return void(0,g.oR)(y("toast.noFileToPaste"),"info");let s=await fetch("/api/files/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t,targetDir:e,sourceAbsPath:n.path})}),o=await s.json();s.ok?((0,g.oR)(y("toast.pastedFile",{name:o.newName}),"success"),ex.loadDirectory(e),ex.loadFileIndex()):(0,g.oR)(o.error||y("toast.pasteFailed"),"error")}catch{(0,g.oR)(y("toast.pasteFailed"),"error")}},[t,ex]),e2=(0,s.useRef)(0);(0,s.useEffect)(()=>{let t=t=>{let r="explorer"===k;if(r&&t.ctrlKey&&!t.metaKey&&"Minus"===t.code){t.preventDefault(),t.shiftKey?eG():eQ();return}if(r&&(t.metaKey||t.ctrlKey)&&"p"===t.key){t.preventDefault(),P(e=>!e);return}if(r&&(t.metaKey||t.ctrlKey)&&"c"===t.key&&!t.shiftKey){let e=t.target?.tagName,r=window.getSelection()?.toString();if(("tree"===N||"recent"===N)&&ex.selectedPath&&!r&&"INPUT"!==e&&"TEXTAREA"!==e){t.preventDefault(),eZ(ex.selectedPath);return}}if(r&&(t.metaKey||t.ctrlKey)&&"v"===t.key){let e=t.target?.tagName;if(("tree"===N||"recent"===N)&&"INPUT"!==e&&"TEXTAREA"!==e){t.preventDefault(),e1(function(e,t){if(!e)return"";let r=ek(t,e);if(r?.isDirectory)return e;let n=e.split("/");return n.pop(),n.join("/")}(ex.selectedPath,ex.files));return}}if(r&&(t.metaKey||t.ctrlKey)&&"f"===t.key){if(J){t.preventDefault(),es.open();return}if(V&&ex.selectedPath?.endsWith(".json")){t.preventDefault(),er.open();return}}if(r&&"Escape"===t.key){if(R)return void P(!1);if(es.isVisible)return void es.close();if(er.isVisible)return void er.close();if(J)return void ee(null);let t=Date.now();if(t-e2.current<3e3)return;e2.current=t,ea.visible?ea.closeReferences():U?q(!1):ex.blameSelectedCommit?ex.setBlameSelectedCommit(null):ex.showBlame?ex.setShowBlame(!1):e()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,ex.showBlame,ex.blameSelectedCommit,ex,R,ea.visible,ea.closeReferences,U,eQ,eG,V,er,J,es,N,eZ,e1,k]),(0,s.useEffect)(()=>{ex.loadFiles(),ex.loadFileIndex(),ex.loadRecentFiles(),eg.fetchStatus(),eb.loadBranches()},[]),(0,s.useEffect)(()=>{let e=()=>{eg.fetchStatus()};return window.addEventListener("git-status-changed",e),()=>window.removeEventListener("git-status-changed",e)},[eg.fetchStatus]);let e5=(0,s.useRef)(ed);(0,s.useEffect)(()=>{ed&&!e5.current&&(ex.loadFiles(),ex.loadFileIndex(),ex.loadRecentFiles(),eg.fetchStatus(),eb.loadBranches()),e5.current=ed},[ed]),(0,s.useEffect)(()=>{eb.selectedBranch&&eb.loadCommits(eb.selectedBranch)},[eb.selectedBranch,eb.loadCommits]);let e4=(0,s.useRef)(N);(0,s.useEffect)(()=>{let e=e4.current;if(e4.current=N,("tree"===N||"recent"===N)&&ex.recentFiles.length>0){let t=ex.recentFiles[0].path;ex.selectedPath&&("status"!==e&&"history"!==e||ex.selectedPath===t)||(ex.setShouldScrollToSelected(!0),eE(t))}},[N,ex.recentFiles,ex.selectedPath,eE,ex]);let e3=(0,s.useRef)(eb.selectedBranch);e3.current=eb.selectedBranch;let e6=(0,s.useRef)(ex.selectedPath);e6.current=ex.selectedPath;let e8=(0,s.useRef)(ex.fileContent?.type);e8.current=ex.fileContent?.type;let e9=(0,s.useCallback)(async e=>{try{let{data:r}=e;if(!r)return;let n=r.some(e=>"git"===e.type),s=r.some(e=>"file"===e.type),o=[];if((s||n)&&(o.push(fetch(`/api/files/init?cwd=${encodeURIComponent(t)}`).then(e=>e.json()).then(e=>{e.error||ex.setFiles(e.files||[])})),o.push(fetch(`/api/files/index?cwd=${encodeURIComponent(t)}`).then(e=>e.json()).then(e=>{e.paths&&ex.setFileIndex(e.paths)})),o.push(fetch(`/api/files/recent?cwd=${encodeURIComponent(t)}`).then(e=>e.json()).then(e=>{ex.setRecentFiles(e.files||[])}))),n||s){o.push(fetch(`/api/git/status?cwd=${encodeURIComponent(t)}`).then(e=>{if(e.ok)return e.json().then(e=>{eg.setStatus(e);let t=Y(e.staged),r=Y(e.unstaged);eg.setStagedTree(t),eg.setUnstagedTree(r);let n=new Set([...Q(t),...Q(r)]);eg.setStatusExpandedPaths(e=>new Set([...e,...n]))})})),eg.refreshDiff(),n&&eb.loadBranches();let e=e3.current;e&&o.push(fetch(`/api/git/commits?cwd=${encodeURIComponent(t)}&branch=${encodeURIComponent(e)}&limit=50`).then(e=>e.json()).then(e=>{let t=e.commits||[];eb.setCommits(t),eb.setHasMoreCommits(t.length>=50)}))}let l=e6.current,a=e8.current;l&&"text"===a&&o.push(fetch(`/api/files/read?cwd=${encodeURIComponent(t)}&path=${encodeURIComponent(l)}`).then(e=>e.json()).then(e=>{"text"===e.type&&ex.setFileContent(e)})),await Promise.all(o)}catch(e){console.error("File watch handler error:",e)}},[t]);(0,eH.h)({url:`/ws/watch?cwd=${encodeURIComponent(t)}`,onMessage:e9,enabled:ed});let e7=(0,s.useCallback)(e=>{let t=e.split("/");if(t.length>1){let e=[];for(let r=1;r<t.length;r++)e.push(t.slice(0,r).join("/"));ex.setExpandedPaths(t=>{let r=new Set(t);for(let t of e)r.add(t);return ex.saveExpandedPaths(r),r})}ex.setSelectedPath(e),ex.setShouldScrollToSelected(!0),C("tree")},[ex]);return(0,n.jsxs)(v,{container:E,children:[(0,n.jsxs)("div",{ref:S,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:"w-80 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex border-b border-border",children:[(0,n.jsx)("button",{onClick:()=>eJ("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===N?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.directoryTree")}),(0,n.jsx)("button",{onClick:()=>eJ("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===N?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.searchTab")}),(0,n.jsx)("button",{onClick:()=>eJ("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===N?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.recentTab")}),(0,n.jsx)("button",{onClick:()=>eJ("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===N?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.changesTab")}),(0,n.jsx)("button",{onClick:()=>eJ("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===N?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.historyTab")})]}),"tree"===N&&(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:ex.searchInputRef,type:"text",value:ex.searchQuery,onChange:e=>ex.setSearchQuery(e.target.value),placeholder:y("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),ex.searchQuery&&(0,n.jsx)("button",{onClick:()=>ex.setSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:y("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:()=>ex.setSearchDirExact(e=>!e),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${ex.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:ex.searchExactMatch?y("fileBrowser.exactMatchOn"):y("fileBrowser.exactMatchOff"),children:"ab"}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:()=>ex.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:y("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:()=>ex.searchTreeExpandedPaths?ex.setSearchTreeExpandedPaths(new Set):ex.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:y("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"===N&&(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:ef.contentSearchInputRef,type:"text",value:ef.contentSearchQuery,onChange:e=>ef.setContentSearchQuery(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ef.performContentSearch(ef.contentSearchQuery)},placeholder:y("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),ef.contentSearchQuery&&(0,n.jsx)("button",{onClick:()=>ef.setContentSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:y("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:()=>ef.performContentSearch(ef.contentSearchQuery),disabled:ef.isSearching||!ef.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:ef.isSearching?"...":y("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:ef.searchOptions.caseSensitive,onChange:e=>ef.setSearchOptions(t=>({...t,caseSensitive:e.target.checked})),className:"w-3 h-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:y("fileBrowser.caseSensitive")})]}),(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:ef.searchOptions.wholeWord,onChange:e=>ef.setSearchOptions(t=>({...t,wholeWord:e.target.checked})),className:"w-3 h-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:y("fileBrowser.wholeWord")})]}),(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:ef.searchOptions.regex,onChange:e=>ef.setSearchOptions(t=>({...t,regex:e.target.checked})),className:"w-3 h-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:y("fileBrowser.regex")})]}),(0,n.jsx)("input",{type:"text",value:ef.searchOptions.fileType,onChange:e=>ef.setSearchOptions(t=>({...t,fileType:e.target.value})),placeholder:y("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9"})]})]}),"history"===N&&(0,n.jsx)("div",{className:"p-3 border-b border-border",children:(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)(eU,{branches:eb.branches,selectedBranch:eb.selectedBranch,onSelect:e=>{eb.setSelectedBranch(e),eb.compareMode&&eb.loadCompareFiles(e)},isLoading:eb.isLoadingBranches})}),(0,n.jsx)("button",{onClick:()=>eb.toggleCompareMode(!eb.compareMode),className:`flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors ${eb.compareMode?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-accent border border-border"}`,title:eb.compareMode?y("fileBrowser.compareModeOff"):y("fileBrowser.compareModeOn"),children:y("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"===N?"":"hidden"}`,children:[ex.creatingItem&&(0,n.jsxs)("div",{className:"px-2 py-1.5 border-b border-border bg-secondary flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:ex.creatingItem.parentPath?y("fileBrowser.createFileIn",{path:ex.creatingItem.parentPath}):y("fileBrowser.createFile")}),(0,n.jsx)("input",{type:"text",autoFocus:!0,placeholder:y("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:()=>{L.current=!0},onCompositionEnd:()=>{L.current=!1},onKeyDown:async e=>{if("Enter"===e.key){if(L.current)return;let r=e.target.value.trim();if(!r)return;let n=ex.creatingItem.parentPath,s=n?`${n}/${r}`:r;try{let e=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t,path:s,content:""})});if(e.ok)(0,g.oR)(y("toast.createdFile",{name:r}),"success"),ex.setCreatingItem(null),ex.loadDirectory(n),ex.loadFileIndex(),n&&ex.setExpandedPaths(e=>new Set([...e,n])),eE(s);else{let t=await e.json();(0,g.oR)(t.error||y("toast.createFailed"),"error")}}catch(e){(0,g.oR)(y("toast.createFailed"),"error")}}else"Escape"===e.key&&ex.setCreatingItem(null)},onBlur:()=>ex.setCreatingItem(null)})]}),ex.isLoadingFiles?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("common.loading")}):ex.fileError?(0,n.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:ex.fileError}):(0,n.jsx)(ep,{files:ex.files,selectedPath:ex.selectedPath,expandedPaths:ex.effectiveExpandedPaths,matchedPaths:ex.matchedPaths,gitStatusMap:eV,loadingDirs:ex.loadingDirs,onSelect:e=>{ex.setShouldScrollToSelected(!1),eE(e)},onToggle:ex.handleToggle,cwd:t,shouldScrollToSelected:ex.shouldScrollToSelected,onScrolledToSelected:()=>ex.setShouldScrollToSelected(!1),onCreateFile:e=>ex.setCreatingItem({type:"file",parentPath:e}),onDelete:(e,t,r)=>$({path:e,isDirectory:t,name:r}),onRefresh:()=>ex.loadFiles(),onCopyFile:eZ,onPaste:e1})]}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===N?"":"hidden"}`,children:ef.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"})}):ef.searchError?(0,n.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:ef.searchError}):0===ef.contentSearchResults.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ef.contentSearchQuery?y("fileBrowser.noContentSearchResults"):y("fileBrowser.enterKeywordToSearch")}):(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[ef.searchStats&&(0,n.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-secondary border-b border-border flex-shrink-0",children:[y("fileBrowser.nFilesNMatches",{files:ef.searchStats.totalFiles,matches:ef.searchStats.totalMatches}),ef.searchStats.truncated&&(0,n.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",y("fileBrowser.resultsTruncated"),")"]})]}),(0,n.jsx)(ep,{files:eM.files,selectedPath:ex.selectedPath,expandedPaths:eT,onSelect:e=>{let t=eM.matchMap.get(e);eE(e,t?.matches[0]?.lineNumber),U||q(!0)},onToggle:eP,cwd:t,renderActions:eI,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"===N?"":"hidden"}`,children:0===ex.recentFiles.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.noRecentFiles")}):(0,n.jsx)(ep,{files:ex.recentFilesTree,selectedPath:ex.selectedPath,expandedPaths:ex.recentTreeDirPaths,onSelect:eE,onToggle:eL,cwd:t})}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===N?"":"hidden"}`,children:eg.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"})}):eg.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:eg.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:y("fileBrowser.stagingArea",{count:eg.status?.staged.length||0})}),(0,n.jsx)("button",{onClick:()=>eg.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:y("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"})})})]}),(eg.status?.staged.length||0)>0&&(0,n.jsx)("button",{onClick:eg.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:y("fileBrowser.unstageAll")})]}),(0,n.jsx)(X,{files:eg.stagedTree,selectedPath:eg.statusSelectedFile?.type==="staged"?eg.statusSelectedFile.file.path:null,expandedPaths:eg.statusExpandedPaths,onSelect:e=>e.file&&eg.handleStatusFileSelect(e.file,"staged"),onToggle:eg.handleStatusToggle,cwd:t,emptyMessage:y("fileBrowser.noStagedFiles"),className:"py-1",renderActions:e=>{if(e.isDirectory){let t=G(e);return 0===t.length?null:(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),eg.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:y("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(),eg.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:y("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:y("fileBrowser.workspace",{count:eg.status?.unstaged.length||0})}),(eg.status?.unstaged.length||0)>0&&(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:eg.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:y("fileBrowser.discardAll")}),(0,n.jsx)("button",{onClick:eg.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:y("fileBrowser.stageAll")})]})]}),(0,n.jsx)(X,{files:eg.unstagedTree,selectedPath:eg.statusSelectedFile?.type==="unstaged"?eg.statusSelectedFile.file.path:null,expandedPaths:eg.statusExpandedPaths,onSelect:e=>e.file&&eg.handleStatusFileSelect(e.file,"unstaged"),onToggle:eg.handleStatusToggle,cwd:t,emptyMessage:y("fileBrowser.noUnstagedChanges"),className:"py-1",renderActions:e=>{if(e.isDirectory){let t=G(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(),eg.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:y("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(),eg.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:y("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(),eg.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:y("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(),eg.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:y("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"===N?"":"hidden"}`,children:eb.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-slate-7 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:eb.historyError})]})}):eb.compareMode?(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:eb.isLoadingCompareFiles?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.loadingDiff")}):0===eb.compareFiles.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("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:y("fileBrowser.nFilesChanged",{count:eb.compareFiles.length,branch:eb.selectedBranch})})}),(0,n.jsx)(X,{files:eb.compareFileTree,expandedPaths:eb.compareExpandedPaths,onToggle:eb.handleCompareToggle,selectedPath:eb.compareSelectedFile?.path||null,onSelect:e=>{e.file&&eb.handleSelectCompareFile(e.file)},cwd:t,showChanges:!0})]})}):(0,n.jsx)("div",{ref:eb.commitListRef,className:"flex-1 overflow-y-auto",onScroll:eb.handleCommitListScroll,children:eb.isLoadingCommits?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.loadingCommits")}):0===eb.commits.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.noCommits")}):(0,n.jsxs)(n.Fragment,{children:[eb.commits.map(e=>{let t,r,s,o,l,a,i;return(0,n.jsxs)("div",{onClick:()=>eb.handleSelectCommit(e),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-accent ${eb.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-slate-9",title:e.date,children:[e.relativeDate," \xb7 ",(t=new Date(e.date),r=new Date,s=t.getFullYear()===r.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),s?`${o}-${l} ${a}:${i}`:`${t.getFullYear()}-${o}-${l} ${a}:${i}`)]})]}),(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)}),eb.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"})}),!eb.hasMoreCommits&&eb.commits.length>0&&(0,n.jsx)("div",{className:"p-3 text-center text-xs text-slate-9",children:y("fileBrowser.allLoaded",{count:eb.commits.length})})]})})})]})]}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[("tree"===N||"search"===N||"recent"===N)&&(ex.blameSelectedCommit?(0,n.jsx)(em,{isOpen:!0,onClose:()=>ex.setBlameSelectedCommit(null),commit:ex.blameSelectedCommit,cwd:t,embedded:!0,initialFilePath:ex.selectedPath||void 0,onContentSearch:e=>{C("search"),ef.setContentSearchQuery(e),ef.performContentSearch(e)}}):ex.selectedPath?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-4 py-2 bg-secondary 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:ex.selectedPath}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(`${t}/${ex.selectedPath}`),(0,g.oR)(y("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:y("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(),e7(ex.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:y("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:ex.showEditor?(0,n.jsxs)(n.Fragment,{children:[z.isDirty&&(0,n.jsx)("span",{className:"text-xs text-amber-11",children:y("fileBrowser.unsaved")}),(0,n.jsx)("button",{onClick:()=>W.current?.save(),disabled:!z.isDirty||z.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${z.isDirty&&!z.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:z.isSaving?(0,n.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):y("common.save")}),(0,n.jsx)("button",{onClick:()=>W.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("fileBrowser.closeEdit"),children:y("fileBrowser.closeBtn")})]}):(0,n.jsxs)(n.Fragment,{children:[ex.fileContent?.type==="text"&&ex.fileContent.content&&(0,n.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(ex.fileContent.content),(0,g.oR)(y("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("fileBrowser.copyFileContent"),children:y("common.copy")}),ex.selectedPath?.endsWith(".json")&&ex.fileContent?.type==="text"&&(0,n.jsx)("button",{onClick:()=>K(e=>!e),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${V?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,title:y("fileBrowser.toggleJsonReadable"),children:y("common.readable")}),ex.fileContent?.type==="text"&&ec(ex.selectedPath)&&(0,n.jsx)("button",{onClick:()=>ex.setShowMarkdownPreview(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("fileBrowser.previewMarkdown"),children:y("common.preview")}),ex.fileContent?.type==="text"&&(0,n.jsx)("button",{onClick:ex.handleToggleBlame,disabled:ex.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${ex.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-accent"} disabled:opacity-50`,title:y("fileBrowser.viewBlame"),children:ex.isLoadingBlame?(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),ex.fileContent?.type==="text"&&(0,n.jsx)("button",{onClick:()=>ex.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("fileBrowser.editFile"),children:y("common.edit")})]})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden",children:ex.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"})}):ex.fileContent?"text"===ex.fileContent.type&&"string"==typeof ex.fileContent.content?ex.showBlame&&ex.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:ex.blameError}),(0,n.jsx)("button",{onClick:()=>ex.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:y("fileBrowser.backToPreview")})]})}):ex.showBlame&&0===ex.blameLines.length&&ex.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"})}):V&&ex.selectedPath?.endsWith(".json")?(0,n.jsxs)("div",{className:"h-full flex flex-col bg-[#0d1117]",children:[(0,n.jsx)(eh,{search:er}),(0,n.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,n.jsx)("pre",{ref:et,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:Z(ex.fileContent.content)})})]}):(0,n.jsx)(eR,{ref:W,content:ex.fileContent.content,filePath:ex.selectedPath,cwd:t,enableComments:!0,scrollToLine:O??ex.targetLineNumber,scrollToLineAlign:null!=O?"start":ex.targetScrollAlign,onScrollToLineComplete:()=>{A(null),ex.setTargetLineNumber(null)},highlightKeyword:"search"===N?ef.contentSearchQuery:null,visibleLineRef:B,viStateRef:F,initialCursorLine:ex.initialCursorLine,initialCursorCol:ex.initialCursorCol,onInitialCursorSet:()=>{ex.setInitialCursorLine(null),ex.setInitialCursorCol(null)},onCmdClick:eB?eF:void 0,onTokenHover:eB?eO:void 0,onTokenHoverLeave:eB?el.onTokenMouseLeave:void 0,onTokenHoverCancel:eB?el.clearHover:void 0,blameLines:ex.showBlame&&ex.blameLines.length>0?ex.blameLines:void 0,inlineBlameLines:ex.blameLines.length>0?ex.blameLines:void 0,onSelectCommit:ex.setBlameSelectedCommit,editable:ex.showEditor,initialMtime:ex.fileContent.mtime,onEditorClose:e=>{ex.setShowEditor(!1),A(e)},onSaved:()=>{let e=B.current??1;ex.loadFileContent(ex.selectedPath),ex.setShowEditor(!1),A(e)},onEditorStateChange:_,viMode:!0,onContentMutate:ev,onEnterInsertMode:ej,onViSave:ew,onContentSearch:e=>{C("search"),ef.setContentSearchQuery(e),ef.performContentSearch(e)}}):"image"===ex.fileContent.type&&ex.fileContent.content?(0,n.jsx)("div",{className:"h-full flex items-center justify-center p-4 bg-secondary",children:(0,n.jsx)("img",{src:ex.fileContent.content,alt:ex.selectedPath,className:"max-w-full max-h-full object-contain"})}):(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-slate-7 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:ex.fileContent.message||y("fileBrowser.cannotPreview")})]})}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:y("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-slate-7 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:y("fileBrowser.selectFileToPreview")})]})})),"status"===N&&(eg.statusSelectedFile&&eg.statusDiff?(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:eg.statusSelectedFile.file.path}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(`${t}/${eg.statusSelectedFile.file.path}`),(0,g.oR)(y("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:y("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(),e7(eg.statusSelectedFile.file.path)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:y("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)("span",{className:`text-xs px-1.5 py-0.5 rounded ${"staged"===eg.statusSelectedFile.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"===eg.statusSelectedFile.type?y("fileBrowser.staged"):y("fileBrowser.unstaged")}),(0,n.jsx)("div",{className:"flex-1"})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:(h=eg.statusSelectedFile.file.path,w=h.split(".").pop()?.toLowerCase(),eS.has(w||""))?(0,n.jsx)("div",{className:"p-4 flex items-center justify-center",children:(0,n.jsx)("img",{src:`/api/files/read?cwd=${encodeURIComponent(t)}&path=${encodeURIComponent(eg.statusSelectedFile.file.path)}&raw=1`,alt:eg.statusSelectedFile.file.path,className:"max-w-full max-h-[60vh] object-contain"})}):(0,n.jsx)(H,{oldContent:eg.statusDiff.oldContent,newContent:eg.statusDiff.newContent,filePath:eg.statusDiff.filePath,isNew:eg.statusDiff.isNew,isDeleted:eg.statusDiff.isDeleted,cwd:t,enableComments:!0,onPreview:!eg.statusDiff.isDeleted&&ec(eg.statusSelectedFile.file.path)?()=>eg.setShowStatusDiffPreview(!0):!eg.statusDiff.isDeleted&&eg.statusSelectedFile.file.path.endsWith(".json")?()=>ee({content:eg.statusDiff.newContent,filePath:eg.statusDiff.filePath}):void 0,previewLabel:eg.statusSelectedFile.file.path.endsWith(".json")?y("common.readable"):y("common.preview"),onContentSearch:e=>{C("search"),ef.setContentSearchQuery(e),ef.performContentSearch(e)}})}),eg.showStatusDiffPreview&&eg.statusDiff&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>eg.setShowStatusDiffPreview(!1),children:(0,n.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:(0,n.jsx)(eA,{content:eg.statusDiff.newContent,filePath:eg.statusDiff.filePath,cwd:t,onClose:()=>eg.setShowStatusDiffPreview(!1)})})}),J&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>ee(null),children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl 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:J.filePath}),(0,n.jsx)("button",{onClick:()=>ee(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent 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)(eh,{search:es}),(0,n.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,n.jsx)("pre",{ref:en,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:Z(J.content)})})]})})]}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,n.jsx)("span",{children:y("fileBrowser.selectFileToViewDiff")})})),"history"===N&&!eb.historyError&&(eb.compareMode?eb.isLoadingCompareDiff?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:y("fileBrowser.loadingDiffContent")}):eb.compareFileDiff?(0,n.jsx)(H,{oldContent:eb.compareFileDiff.oldContent,newContent:eb.compareFileDiff.newContent,filePath:eb.compareFileDiff.filePath,isNew:eb.compareFileDiff.isNew,isDeleted:eb.compareFileDiff.isDeleted,cwd:t,enableComments:!0,onPreview:!eb.compareFileDiff.isDeleted&&eb.compareFileDiff.filePath.endsWith(".json")?()=>ee({content:eb.compareFileDiff.newContent,filePath:eb.compareFileDiff.filePath}):void 0,previewLabel:y("common.readable"),onContentSearch:e=>{C("search"),ef.setContentSearchQuery(e),ef.performContentSearch(e)}}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,n.jsx)("span",{children:eb.compareFiles.length>0?y("fileBrowser.selectFileToViewDiff"):y("fileBrowser.clickCompareToLoad")})}):eb.selectedCommit?(0,n.jsx)(em,{isOpen:!0,onClose:()=>eb.setSelectedCommit(null),commit:eb.selectedCommit,cwd:t,embedded:!0,onContentSearch:e=>{C("search"),ef.setContentSearchQuery(e),ef.performContentSearch(e)}}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,n.jsx)("span",{children:y("fileBrowser.selectCommitToView")})}))]})]}),ex.showMarkdownPreview&&ex.fileContent?.type==="text"&&ex.selectedPath&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>ex.setShowMarkdownPreview(!1),children:(0,n.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:(0,n.jsx)(eA,{content:ex.fileContent.content||"",filePath:ex.selectedPath,cwd:t,onClose:()=>ex.setShowMarkdownPreview(!1)})})}),R&&(0,n.jsx)(ez,{files:ex.files,fileIndex:ex.fileIndex,recentFiles:ex.recentFilePaths,onSelectFile:e=>{eE(e),ex.setShouldScrollToSelected(!0),C("tree")},onClose:()=>P(!1)}),(eD||ea.visible)&&(0,n.jsxs)("div",{className:`flex ${ea.visible&&eD?"":"flex-col"}`,children:[eD&&(0,n.jsx)("div",{className:ea.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,n.jsx)(eY,{results:ef.contentSearchResults,loading:ef.isSearching,totalMatches:ef.searchStats?.totalMatches??0,onSelect:(e,t)=>{ex.selectedPath&&ei.push({filePath:ex.selectedPath,lineNumber:B.current}),eE(e,t)},onClose:()=>q(!1)})}),ea.visible&&(0,n.jsx)("div",{className:eD?"flex-1 min-w-0":"",children:(0,n.jsx)(eX,{references:ea.references,loading:ea.loading,onSelect:eW,onClose:ea.closeReferences})})]})]}),I&&(0,a.createPortal)((0,n.jsx)("div",{className:"fixed z-[9999] px-2 py-1 bg-popover text-popover-foreground text-xs font-mono rounded shadow-lg border border-brand whitespace-nowrap pointer-events-none",style:{left:I.x+12,top:I.y+16},children:I.text}),document.body),T&&(0,a.createPortal)((0,n.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-black/50",onClick:()=>$(null),children:(0,n.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl 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:y("fileBrowser.confirmDelete")}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:y("fileBrowser.confirmDeleteMessage",{name:T.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:()=>$(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-accent transition-colors",children:y("common.cancel")}),(0,n.jsx)("button",{onClick:async()=>{let{path:e,name:r}=T;$(null);try{let n=await fetch("/api/files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t,path:e})});if(n.ok){(0,g.oR)(y("toast.movedToTrash",{name:r}),"success");let t=e.includes("/")?e.substring(0,e.lastIndexOf("/")):"";ex.loadDirectory(t),ex.loadFileIndex(),ex.selectedPath===e&&eE("")}else{let e=await n.json();(0,g.oR)(e.error||y("toast.deleteFailed"),"error")}}catch{(0,g.oR)(y("toast.deleteFailed"),"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:y("common.delete")})]})]})}),document.body),el.hoverInfo&&E&&(0,a.createPortal)((0,n.jsx)(eK,{ref:e=>{el.tooltipElRef.current=e},displayString:el.hoverInfo.displayString,documentation:el.hoverInfo.documentation,x:el.hoverInfo.x,y:el.hoverInfo.y,container:E,onMouseEnter:el.onCardMouseEnter,onMouseLeave:el.onCardMouseLeave,onFindReferences:()=>{let{filePath:e,line:t,column:r}=el.hoverInfo;el.clearHover(),ea.findReferences(e,t,r)},onSearch:e=>{el.clearHover(),C("search"),ef.setContentSearchQuery(e),ef.performContentSearch(e)}}),E)]})}function e3({isOpen:e,onClose:t,cwd:r}){let l,{t:a}=(0,o.Bd)(),[i,c]=(0,s.useState)([]),[d,u]=(0,s.useState)(null),[h,m]=(0,s.useState)(null),[x,f]=(0,s.useState)(!1),[p,b]=(0,s.useState)(!1),[v,j]=(0,s.useState)(null),[w,y]=(0,s.useState)(!1),[k,N]=(0,s.useState)(""),[C,S]=(0,s.useState)(!1),[L,E]=(0,s.useState)([]),[M,T]=(0,s.useState)(""),[$,R]=(0,s.useState)(!1),P=(0,s.useCallback)(async()=>{f(!0);try{let e=await fetch(`/api/git/worktree?cwd=${encodeURIComponent(r)}`);if(e.ok){let t=await e.json();c(t.worktrees),u(t.nextPath),m(t.nextRandomWord),t.gitUserName&&N(t.gitUserName)}}catch(e){console.error("Failed to load worktrees:",e),(0,g.oR)(a("toast.worktreeLoadFailed"),"error")}finally{f(!1)}},[r]),I=(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&&(P(),j(null))},[e,P]);let D=async()=>{if(!d)return;let e="origin/main";try{let t=await fetch(`/api/git/branches?cwd=${encodeURIComponent(r)}`);if(t.ok){let r=await t.json();e=I(r)}}catch{}let t=h||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}(),n=k?`${k}/${t}`:t;b(!0);try{let t=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"add",cwd:r,path:d,newBranch:n,baseBranch:e})});if(t.ok)(0,g.oR)(a("toast.worktreeCreateSuccess",{name:n}),"success"),P();else{let e=await t.json();(0,g.oR)(e.error||a("toast.worktreeCreateFailed"),"error")}}catch(e){console.error("Failed to create worktree:",e),(0,g.oR)(a("toast.worktreeCreateFailed"),"error")}finally{b(!1)}},B=async()=>{R(!0),T(""),S(!0);try{let e=await fetch(`/api/git/branches?cwd=${encodeURIComponent(r)}`);if(e.ok){let t=await e.json(),r=new Set(i.map(e=>e.branch).filter(Boolean)),n=[...t.local.filter(e=>!r.has(e)),...t.remote.filter(e=>!r.has(e)&&!t.local.includes(e.replace(/^origin\//,"")))];E(n)}}catch{(0,g.oR)(a("toast.loadBranchFailed"),"error")}finally{R(!1)}},F=async e=>{if(d){S(!1),b(!0);try{let t=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"add",cwd:r,path:d,branch:e})});if(t.ok)(0,g.oR)(a("toast.worktreeCreateSuccess",{name:e}),"success"),P();else{let e=await t.json();(0,g.oR)(e.error||a("toast.worktreeCreateFailed"),"error")}}catch(e){console.error("Failed to create worktree:",e),(0,g.oR)(a("toast.worktreeCreateFailed"),"error")}finally{b(!1)}}},O=async()=>{if(v){y(!0);try{let e=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"remove",cwd:r,path:v.path})});if(e.ok)(0,g.oR)(a("toast.worktreeDeleted"),"success"),j(null),P();else{let t=await e.json();(0,g.oR)(t.error||a("toast.worktreeDeleteFailed"),"error")}}catch(e){console.error("Failed to delete worktree:",e),(0,g.oR)(a("toast.worktreeDeleteFailed"),"error")}finally{y(!1)}}},A=async e=>{let t=e.isLocked?"unlock":"lock";try{let n=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,cwd:r,path:e.path})});if(n.ok)(0,g.oR)(e.isLocked?a("toast.worktreeUnlocked"):a("toast.worktreeLocked"),"success"),P();else{let e=await n.json();(0,g.oR)(e.error||a("toast.operationFailed"),"error")}}catch(e){console.error("Failed to toggle lock:",e),(0,g.oR)(a("toast.operationFailed"),"error")}};return e?(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t,children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl 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-accent rounded transition-colors",title:a("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:x?(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=e.path===r;return(0,n.jsxs)("div",{className:`group p-3 rounded-lg border transition-colors ${s?"border-brand bg-brand/5":"border-border hover:bg-accent cursor-pointer"}`,onClick:()=>{e.path!==r&&(window.parent.postMessage({type:"OPEN_PROJECT",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 ${s?"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:a("git.worktree.locked"),children:"\uD83D\uDD12"}),s&&(0,n.jsxs)("span",{className:"text-xs text-brand",children:["(",a("common.current"),")"]})]}),(0,n.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:!s&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),A(e)},className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-secondary rounded transition-colors",title:e.isLocked?a("git.worktree.unlock"):a("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(),j(e)},className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-secondary rounded transition-colors",title:a("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.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate pl-4",children:e.path}),e.isDetached&&(0,n.jsx)("div",{className:"mt-1 text-xs text-amber-11 pl-4",children:"(detached HEAD)"})]},e.path)})})}),C&&(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:M,onChange:e=>T(e.target.value),placeholder:a("git.worktree.searchBranch"),className:"flex-1 bg-secondary text-sm text-foreground rounded px-2.5 py-1.5 outline-none placeholder:text-muted-foreground",autoFocus:!0,autoComplete:"off",spellCheck:"false"}),(0,n.jsx)("button",{onClick:()=>S(!1),className:"text-xs text-muted-foreground hover:text-foreground px-2 py-1.5",children:a("common.cancel")})]}),(0,n.jsx)("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:$?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:a("common.loading")}):0===(l=L.filter(e=>e.toLowerCase().includes(M.toLowerCase()))).length?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:a("git.worktree.noBranches")}):l.map(e=>(0,n.jsx)("button",{onClick:()=>F(e),className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-accent 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:a("git.worktree.count",{count:i.length})}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:B,disabled:!d||p,className:`px-3 py-1.5 text-sm rounded transition-colors ${d&&!p?"bg-secondary text-foreground hover:bg-accent":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:a("git.worktree.selectBranch")}),(0,n.jsx)("button",{onClick:D,disabled:!d||p,className:`px-3 py-1.5 text-sm rounded transition-colors ${d&&!p?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:p?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):a("git.worktree.addWorktree")})]})]}),v&&(0,n.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-black/50 rounded-lg",onClick:()=>j(null),children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-[360px] p-4",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("div",{className:"text-sm font-medium text-foreground mb-3",children:a("git.worktree.confirmDelete")}),(0,n.jsxs)("div",{className:"text-sm text-muted-foreground mb-4",children:[(0,n.jsx)("p",{className:"mb-2",children:a("git.worktree.confirmDeleteMsg")}),(0,n.jsxs)("p",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-muted-foreground",children:a("git.worktree.path")}),(0,n.jsx)("span",{className:"text-foreground",children:v.path})]}),(0,n.jsxs)("p",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-muted-foreground",children:a("git.worktree.branch")}),(0,n.jsx)("span",{className:"text-foreground",children:v.branch||"detached"})]})]}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,n.jsx)("button",{onClick:()=>j(null),className:"px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:a("common.cancel")}),(0,n.jsx)("button",{onClick:O,disabled:w,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 transition-colors disabled:opacity-50",children:w?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):a("common.delete")})]})]})})]})}):null}var e6=r(67635),e8=r(73300),e9=r(20986),e7=r(61878),te=r(9921),tt=r(66088),tr=r(42790);function tn(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}let ts=(0,s.memo)(function({shortId:e,type:t,onRegister:r,onUnregister:l}){let{t:a}=(0,o.Bd)(),[i,c]=(0,s.useState)(!1),d=(0,s.useCallback)(async n=>{if(n.stopPropagation(),i)await l(),c(!1),(0,g.oR)(a("toast.disconnected",{id:e}));else{await r(),c(!0);let n=`${"3456"===window.location.port?"cock-dev":"cock"} ${t} ${e}`;navigator.clipboard.writeText(n),(0,g.oR)(a("toast.copiedCommand",{command:n}))}},[i,e,t,r,l,a]);return(0,n.jsxs)("button",{onClick:d,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:i?a("shortIdBadge.clickToDisconnect"):a("shortIdBadge.clickToRegister"),children:[(0,n.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${i?"bg-green-500":"bg-muted-foreground/40"}`}),e]})});var to=r(72588);let tl=(0,s.lazy)(()=>Promise.all([r.e(3888),r.e(700)]).then(r.bind(r,80700)).then(e=>({default:e.XtermRenderer}))),ta={c:"\x03",d:"\x04",z:"\x1a",l:"\f",a:"\x01",e:"\x05",u:"\x15",w:"\x17"},ti=/\x1b\[[0-9;]*m/g;function tc({output:e,query:t,mode:r,currentIdx:o,matchRefs:l}){let a=(0,s.useRef)(null);a.current||(a.current=new tr.v,a.current.use_classes=!0);let i=e.split("\n"),c=t.toLowerCase(),d=0;return l.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(ti,""),i=s.toLowerCase().includes(c);if("filter"===r&&!i)return null;if(!i){let r=a.current.ansi_to_html(e);return(0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:r}},t)}let u=[],h=0,m=s.toLowerCase(),x=0;for(;x<m.length;){let e=m.indexOf(c,x);if(-1===e)break;e>h&&u.push((0,n.jsx)("span",{children:s.slice(h,e)},`t${h}`));let t=d++,r=t===o;u.push((0,n.jsx)("mark",{ref:e=>{l.current[t]=e},className:r?"bg-brand/40 text-foreground":"bg-yellow-300/40 text-foreground",children:s.slice(e,e+c.length)},`m${e}`)),x=h=e+c.length}return h<s.length&&u.push((0,n.jsx)("span",{children:s.slice(h)},`t${h}`)),(0,n.jsx)("div",{children:u},t)})})}let td=(0,s.memo)(function({commandId:e,tabId:t,projectCwd:r,command:l,output:a,exitCode:i,isRunning:c,selected:d,onSelect:u,onInterrupt:h,onStdin:m,onDelete:x,onRerun:f,timestamp:p,usePty:b,onPtyResize:v,onToggleMaximize:j,maximized:w,expandedHeight:y,bubbleContentHeight:k,onTitleMouseDown:N}){let{t:C}=(0,o.Bd)(),S=(0,s.useRef)(null),L=(0,s.useRef)(null),E=(0,s.useRef)(!0),M=(0,s.useRef)(null),T=(0,s.useRef)(null),$=(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}`})(p),R=e&&t?tn(t+e):void 0,[P,I]=(0,s.useState)(!1),[D,B]=(0,s.useState)(""),F=(0,s.useRef)(null),O=(0,s.useRef)(null),[A,W]=(0,s.useState)(!1),[z,H]=(0,s.useState)(""),[_,U]=(0,s.useState)("search"),[q,V]=(0,s.useState)(0),K=(0,s.useRef)([]),J=(0,s.useRef)(null),X=(0,s.useRef)(0);(0,s.useEffect)(()=>{J.current||(J.current=new tr.v,J.current.use_classes=!0)},[]),(0,s.useLayoutEffect)(()=>{let e=L.current;if(e&&J.current){if(a.length<X.current&&(J.current=new tr.v,J.current.use_classes=!0,X.current=0,e.innerHTML=""),a.length>X.current){let t=a.slice(X.current),r=J.current.ansi_to_html(t);X.current=a.length,e.insertAdjacentHTML("beforeend",r)}if(S.current){let e=S.current.scrollHeight>S.current.clientHeight;I(e),e&&(S.current.scrollTop=S.current.scrollHeight)}}},[a]),(0,s.useEffect)(()=>(c&&E.current&&S.current&&(null!==M.current&&cancelAnimationFrame(M.current),M.current=requestAnimationFrame(()=>{S.current&&(S.current.scrollTop=S.current.scrollHeight),M.current=null})),()=>{null!==M.current&&cancelAnimationFrame(M.current)}),[a,c]),(0,s.useEffect)(()=>{if(!w)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),j?.())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[w,j]);let Y=a?a.split("\n").length:0,Q=(0,s.useCallback)(()=>{W(!0),requestAnimationFrame(()=>O.current?.focus())},[]),G=(0,s.useCallback)(()=>{W(!1),H(""),V(0),F.current?.clearSearch()},[]),Z=(0,s.useCallback)(e=>{e.trim()&&(b?F.current?.findNext(e):V(e=>{let t=e+1,r=K.current[t];return r?(r.scrollIntoView({block:"nearest"}),t):(K.current[0]?.scrollIntoView({block:"nearest"}),0)}))},[b]),ee=(0,s.useCallback)(e=>{e.trim()&&(b?F.current?.findPrevious(e):V(e=>{let t=e-1;if(t>=0)return K.current[t]?.scrollIntoView({block:"nearest"}),t;let r=K.current.length-1;return r>=0&&K.current[r]?.scrollIntoView({block:"nearest"}),Math.max(r,0)}))},[b]);(0,s.useEffect)(()=>{if(!d)return;let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key){e.preventDefault(),e.stopPropagation(),Q();return}if("Escape"===e.key&&A){e.preventDefault(),e.stopPropagation(),G();return}};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[d,A,Q,G]);let et=w&&y?y-41:k??360;return(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground dark:text-slate-11 relative overflow-hidden border transition-colors cursor-pointer ${w?"rounded-none border-0":"rounded-2xl rounded-bl-md rounded-br-md"} ${w?"":d?"border-brand":"border-brand/30"}`,onClick:u,children:[w?(0,n.jsxs)("div",{onDoubleClick:()=>j?.(),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:l}),c&&(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"}),C("console.runningText")]}),c&&h&&(0,n.jsx)("button",{onClick:h,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-md active:scale-95 active:bg-destructive/70 cursor-pointer select-none",children:"Ctrl+C"}),(0,n.jsx)("button",{onClick:()=>j?.(),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:C("console.restoreTooltip",{modKey:(0,to.Mu)()}),children:(0,n.jsx)(eJ.A,{className:"w-4 h-4"})})]}):(0,n.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>N?.(),onDoubleClick:e=>{e.stopPropagation(),j?.()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing ${d?"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:">_"}),R&&e&&t&&(0,n.jsx)(ts,{shortId:R,type:"terminal",onRegister:()=>{fetch("/api/terminal/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tabId:t,commandId:e,command:l,projectCwd:r})}).catch(()=>{})},onUnregister:()=>{fetch("/api/terminal/unregister",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandId:e})}).catch(()=>{})}}),(0,n.jsx)("span",{className:"font-mono text-foreground truncate",children:l}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(l),(0,g.oR)(C("toast.copiedCmd"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:C("console.copyCommand"),children:(0,n.jsx)(e6.A,{className:"w-3.5 h-3.5"})}),(0,n.jsx)("span",{className:"flex-1"}),P&&!c&&(0,n.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:C("console.totalLines",{count:Y})}),a&&(0,n.jsx)("button",{onClick:e=>{let t;e.stopPropagation(),t=a.replace(/\x1b\[[0-9;]*m/g,""),navigator.clipboard.writeText(t),(0,g.oR)(C("toast.copiedOutput"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:C("console.copyOutput"),children:(0,n.jsx)(e8.A,{className:"w-3.5 h-3.5"})}),f&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),f()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:C("console.rerun"),children:(0,n.jsx)(e9.A,{className:"w-3.5 h-3.5"})}),x&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),x()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:C("console.deleteRecord"),children:(0,n.jsx)(eJ.A,{className:"w-3.5 h-3.5"})})]}),A&&(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)(e7.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,n.jsx)("input",{ref:O,value:z,onChange:e=>{let t=e.target.value;H(t),V(0),b&&(t.trim()?F.current?.findNext(t):F.current?.clearSearch())},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?ee(z):Z(z))},placeholder:C("console.searchPlaceholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",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:()=>U("search"),className:`px-1.5 py-0.5 rounded transition-colors ${"search"===_?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:C("console.searchMode")}),(0,n.jsx)("button",{onClick:()=>U("filter"),className:`px-1.5 py-0.5 rounded transition-colors ${"filter"===_?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:C("console.filterMode")})]}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:()=>ee(z),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:C("console.prevShiftEnter"),children:(0,n.jsx)(te.A,{className:"w-3.5 h-3.5"})}),(0,n.jsx)("button",{onClick:()=>Z(z),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:C("console.nextEnter"),children:(0,n.jsx)(tt.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsx)("button",{onClick:G,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",children:(0,n.jsx)(eJ.A,{className:"w-3.5 h-3.5"})})]}),b?(0,n.jsx)("div",{style:{height:et,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:et},children:C("console.loadingTerminal")}),children:(0,n.jsx)(tl,{ref:F,output:a,isRunning:c,onInput:m,onResize:v,maximized:w,height:et})})}):(0,n.jsx)("div",{ref:S,className:"overflow-auto px-4 py-2",style:{height:et},onScroll:()=>{if(S.current){let{scrollTop:e,scrollHeight:t,clientHeight:r}=S.current;E.current=t-e-r<50}},children:A&&z.trim()?(0,n.jsx)(tc,{output:a,query:z,mode:_,currentIdx:q,matchRefs:K}):(0,n.jsx)("pre",{ref:L,className:"text-sm font-mono whitespace-pre-wrap break-words select-text"})}),c&&!w&&(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:C("console.clickToInput")}):m?(0,n.jsx)("input",{ref:T,value:D,onChange:e=>B(e.target.value),onKeyDown:e=>{if(e.ctrlKey&&!e.metaKey&&!e.altKey){let t=ta[e.key.toLowerCase()];if(t){e.preventDefault(),e.stopPropagation(),m(t);return}}"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),m(D+"\n"),B("")),"Tab"===e.key&&(e.preventDefault(),m(" "))},placeholder:C("console.stdinPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs font-mono text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}):(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:C("console.runningText")}),h&&(0,n.jsx)("button",{onClick:h,className:"flex-shrink-0 text-xs text-destructive hover:brightness-125 transition-colors cursor-pointer select-none",children:"Ctrl+C"}),$&&(0,n.jsx)("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:$})]}),!c&&void 0!==i&&!w&&(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:C("console.exitCode",{code:i})}),(0,n.jsx)("span",{className:"flex-1"}),$&&(0,n.jsx)("span",{className:"text-[11px] flex-shrink-0",children:$})]})]})})});var tu=r(68459),th=r(51914);function tm({cwd:e,tabId:t,onClose:r,onSave:l}){let{t:a}=(0,o.Bd)(),[i,c]=(0,s.useState)({}),[d,u]=(0,s.useState)(""),[h,m]=(0,s.useState)(""),[x,f]=(0,s.useState)(!0);(0,s.useEffect)(()=>{p()},[e,t]);let p=async()=>{f(!0);try{let r=new URLSearchParams({cwd:e});t&&r.set("tabId",t);let n=await fetch(`/api/terminal/env?${r}`);if(n.ok){let e=await n.json();c(e.env||{})}}catch(e){console.error("Failed to load env:",e)}finally{f(!1)}},g=()=>{d.trim()&&(c(e=>({...e,[d.trim()]:h})),u(""),m(""))},b=async()=>{try{(await fetch("/api/terminal/env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,tabId:t,env:i})})).ok&&(l(i),r())}catch(e){console.error("Failed to save env:",e)}};return(0,n.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,n.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl 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:a("envManager.title")}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:t?a("envManager.tabScope"):a("envManager.globalScope")})]}),(0,n.jsx)("button",{onClick:r,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,n.jsx)(eJ.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:a("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 c(t=>({...t,[e]:r}))},placeholder:a("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:()=>{c(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)(tu.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:d,onChange:e=>u(e.target.value),placeholder:a("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(),g())}}),(0,n.jsx)("input",{type:"text",value:h,onChange:e=>m(e.target.value),placeholder:a("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(),g())}}),(0,n.jsx)("button",{onClick:g,disabled:!d.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)(th.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:a("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-accent transition-colors",children:a("common.cancel")}),(0,n.jsx)("button",{onClick:b,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:a("common.save")})]})]})})}var tx=r(10762);function tf({onClose:e,onSave:t}){let{t:r}=(0,o.Bd)(),[l,a]=(0,s.useState)({}),[i,c]=(0,s.useState)(""),[d,u]=(0,s.useState)(""),[h,m]=(0,s.useState)(!0);(0,s.useEffect)(()=>{x()},[]);let x=async()=>{m(!0);try{let e=await fetch("/api/terminal/aliases");if(e.ok){let t=await e.json();a(t.aliases||{})}}catch(e){console.error("Failed to load aliases:",e)}finally{m(!1)}},f=()=>{i.trim()&&d.trim()&&(a(e=>({...e,[i.trim()]:d.trim()})),c(""),u(""))},p=async()=>{try{(await fetch("/api/terminal/aliases",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({aliases:l})})).ok&&(t(l),e())}catch(e){console.error("Failed to save aliases:",e)}};return(0,n.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,n.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl 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)(tx.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-accent transition-colors",children:(0,n.jsx)(eJ.A,{className:"w-5 h-5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:h?(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(l).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 a(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:()=>{a(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)(tu.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=>c(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(),f())}})]}),(0,n.jsx)("input",{type:"text",value:d,onChange:e=>u(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(),f())}})]}),(0,n.jsx)("button",{onClick:f,disabled:!i.trim()||!d.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)(th.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(l).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-accent transition-colors",children:r("common.cancel")}),(0,n.jsx)("button",{onClick:p,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 tp=r(53961),tg=r(15813),tb=r(37595),tv=r(49698),tj=r(20232),tw=r(80777);let ty=null,tk="",tN=0,tC=null,tS=!1,tL=new Map,tE=null,tM=null;function tT(e){let t;try{t=JSON.parse(e.data)}catch{return}let r=t.type;if("ping"===r)return;if("running"===r){tE&&(tE(t.commands),tE=null);return}let n=t.commandId;if(!n)return;let s=tL.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)&&tL.delete(n)}}function t$(e){ty?.readyState===WebSocket.OPEN&&ty.send(JSON.stringify(e))}function tR(e){let t,r=(t="https:"===window.location.protocol?"wss:":"ws:",`${t}//${window.location.host}/ws/terminal?projectCwd=${encodeURIComponent(e)}`);tk===r&&ty||(tW(),tS=!1,tk=r,function e(){if(tS||!tk)return;let t=new WebSocket(tk);ty=t,t.onopen=()=>{tN=0},t.onmessage=tT,t.onclose=()=>{if(ty!==t||(ty=null,tS))return;tC&&clearTimeout(tC);let r=Math.min(1e3*Math.pow(1.5,tN),1e4);tN++,tC=setTimeout(e,r)},t.onerror=()=>{}}())}function tP(){return new Promise((e,t)=>{if(ty?.readyState===WebSocket.OPEN)return void e();let r=setInterval(()=>{ty?.readyState===WebSocket.OPEN&&(clearInterval(r),clearTimeout(n),e())},50),n=setTimeout(()=>{clearInterval(r),t(Error("WebSocket connection timeout"))},5e3)})}async function tI(e){let{cwd:t,command:r,commandId:n,tabId:s,projectCwd:o,env:l,usePty:a,cols:i,rows:c,onData:d,onError:u}=e;tR(o);try{await tP()}catch{u("WebSocket connection failed");return}tL.delete(n),tL.set(n,{onData:d,onError:u}),t$({type:"exec",commandId:n,command:r,cwd:t,tabId:s,env:l,...a?{usePty:!0}:{},...i?{cols:i,rows:c}:{}})}async function tD(e){let{commandId:t,projectCwd:r,onData:n,onError:s}=e;tR(r);try{await tP()}catch{s("WebSocket connection failed");return}tL.set(t,{onData:n,onError:s}),t$({type:"attach",commandId:t})}function tB(e,t){t$({type:"stdin",commandId:e,data:t})}function tF(e,t,r){t$({type:"resize",commandId:e,cols:t,rows:r})}function tO(e){t$({type:"interrupt",pid:e})}async function tA(e){try{tR(e);try{await tP()}catch{return[]}return await new Promise(e=>{tE=t=>{e(t)},t$({type:"running"}),setTimeout(()=>{tE&&(tE=null,e([]))},3e3)})}finally{tM=null}}function tW(){if(tS=!0,tC&&(clearTimeout(tC),tC=null),ty){let e=ty;ty=null,e.close()}tL.clear(),tE&&(tE([]),tE=null),tM=null,tk="",tN=0}let tz=new Map;function tH(e){tz.set(e.type,e)}function t_(e){return tz.get(e)}function tU(e){for(let t of tz.values())if(t.match(e))return t;return null}var tq=r(10611);function tV(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 tK(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 tJ(e){let t=(0,tq.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 tX(e){try{let t=new URL(e).hostname;return"localhost"===t||"127.0.0.1"===t}catch{return!1}}function tY({url:e,id:t,selected:r,maximized:l,expandedHeight:a,bubbleContentHeight:i,onSelect:c,onClose:d,onToggleMaximize:u,onNewTab:h,timestamp:m,onTitleMouseDown:x,initialSleeping:f,onSleep:p,onWake:b}){let{t:v}=(0,o.Bd)(),[j,w]=(0,s.useState)(!1),[y,k]=(0,s.useState)(null),[N,C]=(0,s.useState)(e),[S,L]=(0,s.useState)(null),[E,M]=(0,s.useState)(f??!1),T=(0,s.useRef)(null),$=(0,s.useRef)(null),R=(0,s.useRef)(null);(0,s.useEffect)(()=>{C(e)},[e]);let P=(0,s.useRef)(!0),I=(0,s.useCallback)(()=>{E||(M(!0),L(null),p?.(t))},[E,t,p]),D=(0,s.useCallback)(()=>{T.current&&(clearTimeout(T.current),T.current=null)},[]),{shortId:B,connected:F,connect:O,disconnect:A}=function(e,t,r){let n=(0,s.useMemo)(()=>tn(e),[e]),[o,l]=(0,s.useState)(!1),a=(0,s.useRef)(null),i=(0,s.useRef)([]),c=(0,s.useRef)(null),d=(0,s.useRef)(!1),u=(0,s.useRef)(r);(0,s.useEffect)(()=>{u.current=r});let h=(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=a.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}})),window.parent.postMessage({type:"SCREENSHOT_PREPARE",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}})),window.parent.postMessage({type:"SCREENSHOT_DONE"},"*");return}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[]);let m=(0,s.useCallback)(e=>{let r=t.current;if(!r?.contentWindow){let t=a.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(!o)return;let r=!1;return d.current=!0,!function n(){if(r||!d.current)return;let s="https:"===window.location.protocol?"wss:":"ws:",o=new WebSocket(`${s}//${window.location.host}/ws/browser?fullId=${encodeURIComponent(e)}`);a.current=o,o.onopen=()=>{for(let e of h.current)e();if(h.current=[],i.current.length>0){for(let e of i.current)m(e);i.current=[]}},o.onmessage=e=>{let r;try{r=JSON.parse(e.data)}catch{return}if("browser:cmd"===r.type){let e=r;t.current?.contentWindow&&u.current?m(e):i.current.push(e)}},o.onclose=()=>{a.current=null,!r&&d.current&&(c.current=setTimeout(n,3e3))},o.onerror=()=>o.close()}(),()=>{r=!0,d.current=!1,c.current&&clearTimeout(c.current),a.current&&(a.current.close(),a.current=null),h.current=[]}},[o,e,t,m]),(0,s.useEffect)(()=>{if(r&&i.current.length>0){for(let e of i.current)m(e);i.current=[]}},[r,m]);let x=(0,s.useCallback)(()=>o&&a.current?.readyState===WebSocket.OPEN?Promise.resolve():new Promise(e=>{h.current.push(e),o||l(!0)}),[o]);return{shortId:n,connected:o,connect:x,disconnect:(0,s.useCallback)(()=>{l(!1)},[])}}(t,R,!!S&&!E&&!j),W=(0,s.useRef)(F);W.current=F,(0,s.useEffect)(()=>{let e=$.current;if(!e||E)return;let t=new IntersectionObserver(([e])=>{P.current=e.isIntersecting,e.isIntersecting||W.current?D():(T.current&&clearTimeout(T.current),T.current=setTimeout(I,3e5))});return t.observe(e),()=>t.disconnect()},[E,I,D]),(0,s.useEffect)(()=>{E?A():F?D():P.current||(T.current&&clearTimeout(T.current),T.current=setTimeout(I,3e5))},[F,E,A,D,I]),(0,s.useEffect)(()=>{f&&L(null)},[]);let z=(0,s.useCallback)(()=>{M(!1),b?.(t);let r=tV(e);tX(e)?L(r):tJ(e).then(()=>L(r))},[e,t,b]);(0,s.useEffect)(()=>{if(!e||E){e||L(null);return}let t=tV(e);if(tX(e))return void L(t);let r=!1;return tJ(e).then(()=>{r||L(t)}),()=>{r=!0}},[e,E]);let H=(0,s.useCallback)(()=>w(!1),[]);(0,s.useEffect)(()=>{let e=$.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,l=()=>{o&&t&&(t.scrollTop=s)},a=()=>{n=t.style.overflow,s=t.scrollTop,o=!0,t.style.overflow="hidden",t.addEventListener("scroll",l)},i=()=>{o=!1,t.removeEventListener("scroll",l),t.style.overflow=n};return e.addEventListener("mouseenter",a),e.addEventListener("mouseleave",i),()=>{e.removeEventListener("mouseenter",a),e.removeEventListener("mouseleave",i),t.removeEventListener("scroll",l),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=$.current?.querySelector("iframe");if(!r||e.source!==r.contentWindow)return;let n=e.data.type;"cockpit:new-tab"===n&&e.data.url?h?.(tK(e.data.url),t):("cockpit:navigate"===n||"cockpit:loaded"===n)&&e.data.url&&C(tK(e.data.url))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[t,h]);let _=(0,s.useCallback)(()=>{w(!1),k(v("browser.pageLoadFailed"))},[]),U=(0,s.useCallback)(()=>{if(E)return void z();let e=$.current?.querySelector("iframe");if(e&&S){w(!0),k(null);let t=e.src;e.src="",setTimeout(()=>{e.src=t},0)}},[E,z,S]);(0,s.useEffect)(()=>{e&&!E&&(w(!0),k(null))},[e,E]);let q=(0,s.useCallback)(()=>{N&&window.open(N,"_blank")},[N]);(0,s.useEffect)(()=>{if(!r&&!l)return;let e=e=>{"Escape"===e.key&&l&&(e.stopPropagation(),u()),"m"===e.key&&(e.metaKey||e.ctrlKey)&&r&&(e.preventDefault(),e.stopPropagation(),u())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[l,r,u]);let V=function(e){if(!e)return"";try{let t=new URL(e);return t.port?`${t.hostname}:${t.port}`:t.hostname}catch{return e}}(N),K=l&&a?a-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
|
|
2
|
+
relative transition-colors cursor-pointer
|
|
3
|
+
${l?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
4
|
+
${l?"":r?"border-brand":"border-brand/30"}`,onClick:l?void 0:c,children:[l?(0,n.jsxs)("div",{onDoubleClick:u,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"})})}),B&&(0,n.jsx)(ts,{shortId:B,type:"browser",onRegister:()=>O(),onUnregister:async()=>{A(),await fetch("/api/browser/unregister",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:B})}).catch(()=>{})}}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground truncate font-mono",children:N||v("browser.blankPage")}),N&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(N),(0,g.oR)(v("toast.copiedUrl"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:v("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"}),j&&(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:U,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:v("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:q,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:v("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:u,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:v("browser.exitMaximize",{modKey:(0,to.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:()=>x?.(),onDoubleClick:e=>{e.stopPropagation(),u()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing
|
|
5
|
+
${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"})})}),B&&(0,n.jsx)(ts,{shortId:B,type:"browser",onRegister:()=>O(),onUnregister:async()=>{A(),await fetch("/api/browser/unregister",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:B})}).catch(()=>{})}}),(0,n.jsx)("span",{className:"font-mono text-foreground truncate",children:N||v("browser.blankPage")}),N&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(N),(0,g.oR)(v("toast.copiedUrl"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:v("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"}),j&&(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(),q()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:v("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(),U()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:v("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(),d()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:v("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:$,className:"w-full",style:{height:K},children:E?(0,n.jsxs)("div",{className:"relative overflow-hidden cursor-pointer group h-full",onClick:e=>{e.stopPropagation(),U()},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:V})]}),(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"})}),v("browser.clickToWake")]})})]}):e?y?(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-400",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:y}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),U()},className:"mt-2 px-3 py-1 text-xs bg-secondary text-foreground rounded hover:bg-accent transition-colors",children:v("common.retry")})]}):(0,n.jsxs)("div",{className:"relative overflow-hidden h-full",style:{contain:"strict"},children:[j&&(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-white/80 dark:bg-slate-900/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"})}),S?(0,n.jsx)("iframe",{ref:R,src:S,className:"border-0",allow:"clipboard-write; clipboard-read",style:l?{width:"100%",height:"100%"}:{position:"absolute",top:0,left:0,width:"200%",height:"200%",transform:"scale(0.5)",transformOrigin:"top left"},onLoad:H,onError:_,title:`Browser: ${V}`,"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-slate-300 dark:text-slate-700",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:v("browser.blankPage")})]})}),!l&&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 ${E?"bg-yellow-500":j?"bg-brand animate-pulse":y?"bg-red-500":"bg-green-500"}`}),(0,n.jsx)("span",{className:"truncate",children:E?v("browser.sleeping"):j?v("browser.loadingPage"):y?v("browser.loadFailed"):V}),(0,n.jsx)("span",{className:"flex-1"}),m&&(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}`}(m)})]})]})})}tH({type:"browser",idPrefix:"browser",match(e){let t=e.trim().toLowerCase();return t.startsWith("http://")||t.startsWith("https://")},parse:e=>({url:e.trim()}),fromHistory:e=>({url:e.url}),toHistory:e=>({url:e.url}),Component:function({item:e,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:l,onSelect:a,onClose:i,onToggleMaximize:c,onTitleMouseDown:d,extra:u}){return(0,n.jsx)(tY,{id:e.id,url:e.url,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:l,onSelect:a,onClose:i,onToggleMaximize:c,onTitleMouseDown:d,onNewTab:u?.addBrowserItem,initialSleeping:u?.initialSleeping,onSleep:u?.onSleep,onWake:u?.onWake})}});let tQ=[{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 tG(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 tZ(e){return`"${e.replace(/"/g,'""')}"`}function t0(e){return null==e?"":"object"==typeof e?JSON.stringify(e):String(e)}function t1({text:e}){let[t,r]=(0,s.useState)(!1),[o,l]=(0,s.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),i=(0,s.useRef)(null),c=(0,s.useRef)(null),d=(0,s.useRef)(!1),u=(0,s.useCallback)(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d.current||r(!1)},80)},[]),h=(0,s.useCallback)(()=>{c.current&&clearTimeout(c.current),d.current=!1,c.current=setTimeout(()=>{let e=i.current;if(!e||e.scrollWidth<=e.clientWidth)return;let t=e.getBoundingClientRect(),n=window.innerWidth,s=Math.min(600,n-t.left-8),o=s<200?Math.max(8,n-600-8):t.left,a=s<200?Math.min(600,n-16):s,c=window.innerHeight,d=t.top-8,u=c-t.bottom-8,h=d>u&&d>80;l({x:o,y:h?t.top-4:t.bottom+4,maxW:a,maxH:Math.max(60,h?d-4:u-4),above:h}),r(!0)},350)},[]),m=(0,s.useCallback)(()=>{u()},[u]),x=(0,s.useCallback)(()=>{d.current=!0,c.current&&clearTimeout(c.current)},[]),f=(0,s.useCallback)(()=>{d.current=!1,u()},[u]);return(0,n.jsxs)("span",{ref:i,className:"block truncate",onMouseEnter:h,onMouseLeave:m,children:[e,t&&(0,a.createPortal)((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-lg 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:x,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)}),document.body)]})}async function t2(e,t){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(n.error||`HTTP ${r.status}`);return n}async function t5(e,t){let r=new URLSearchParams(t),n=await fetch(`${e}?${r}`),s=await n.json();if(!n.ok)throw Error(s.error||`HTTP ${n.status}`);return s}function t4({id:e,connectionString:t,displayName:r,selected:l,maximized:a,expandedHeight:i,bubbleContentHeight:c,onSelect:d,onClose:u,onToggleMaximize:h,timestamp:m,onTitleMouseDown:x}){let{t:f}=(0,o.Bd)(),{showToast:p}=(0,g.dj)(),[b,v]=(0,s.useState)("connecting"),[j,w]=(0,s.useState)(""),[y,k]=(0,s.useState)([]),[N,C]=(0,s.useState)("public"),[S,L]=(0,s.useState)([]),[E,M]=(0,s.useState)(null),[T,$]=(0,s.useState)("table"),[R,P]=(0,s.useState)("data"),[I,D]=(0,s.useState)([]),[B,F]=(0,s.useState)([]),[O,A]=(0,s.useState)([]),[W,z]=(0,s.useState)([]),[H,_]=(0,s.useState)(null),[U,q]=(0,s.useState)(0),[V,K]=(0,s.useState)(!1),[J,X]=(0,s.useState)(0),[Y,Q]=(0,s.useState)(new Set),[G,Z]=(0,s.useState)(!1),[ee,et]=(0,s.useState)(null),[er,en]=(0,s.useState)({}),[es,eo]=(0,s.useState)(!1),[el,ea]=(0,s.useState)({}),[ei,ec]=(0,s.useState)({}),[ed,eu]=(0,s.useState)(null),[eh,em]=(0,s.useState)(""),[ex,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()=>{v("connecting"),w("");try{let r=await t2("/api/db/connect",{id:e,connectionString:t});k(r.schemas||[]),r.schemas?.length>0&&!r.schemas.includes("public")&&C(r.schemas[0]),v("connected")}catch(e){w(e instanceof Error?e.message:String(e)),v("error")}},[e,t]);(0,s.useEffect)(()=>{ew()},[ew]);let ey=(0,s.useCallback)(async()=>{if("connected"===b)try{let r=await t5("/api/db/schemas",{id:e,connectionString:t,schema:N});L(r.tables||[])}catch{}},[e,t,N,b]);(0,s.useEffect)(()=>{ey()},[ey]);let ek=(0,s.useCallback)(async r=>{M(r),q(0),et(null),eo(!1),Q(new Set),Z(!1),ec({}),eu(null);try{let n=await t5("/api/db/columns",{id:e,connectionString:t,schema:N,table:r});D(n.columns||[]),F(n.primaryKeys||[]),A(n.foreignKeys||[]),z(n.indexes||[])}catch{}eN(r,0,{},null)},[e,t,N]),eN=(0,s.useCallback)(async(r,n,s,o)=>{K(!0);let l=s??ei,a=void 0!==o?o:ed;try{let s=`${tZ(N)}.${tZ(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=tZ(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 l=s.map(e=>(r.push(e),`$${n++}`));t.push(`${e}::text IN (${l.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}}(l),c=a?` ORDER BY ${tZ(a.column)} ${a.dir}`:"",d=`SELECT * FROM ${s}${o}${c} LIMIT 50 OFFSET ${50*n}`,u=await t2("/api/db/query",{id:e,connectionString:t,sql:d,params:i});_(u);let h=`SELECT count(*)::int AS cnt FROM ${s}${o}`,m=await t2("/api/db/query",{id:e,connectionString:t,sql:h,params:i});X(m.rows?.[0]?.cnt??0)}catch{}K(!1)},[e,t,N,ei,ed]),eC=(0,s.useCallback)(async()=>{if(eh.trim()){ev(!0),eg(""),ef(null);try{let r=await t2("/api/db/query",{id:e,connectionString:t,sql:eh});ef(r)}catch(e){eg(e instanceof Error?e.message:String(e))}ev(!1)}},[e,t,eh]),eS=(0,s.useCallback)(async()=>{if(null===ee||!H||!E)return;let r=H.rows[ee],n=[],s=[],o=1;for(let e of I)void 0!==er[e.name]&&er[e.name]!==t0(r[e.name]??"")&&(n.push(`${tZ(e.name)} = $${o}`),s.push(""===er[e.name]&&e.nullable?null:er[e.name]),o++);if(0===n.length)return void et(null);let l=B.length>0?B:I.map(e=>e.name),a=[];for(let e of l)null===r[e]||void 0===r[e]?a.push(`${tZ(e)} IS NULL`):(a.push(`${tZ(e)} = $${o}`),s.push(r[e]),o++);let i=`UPDATE ${tZ(N)}.${tZ(E)} SET ${n.join(", ")} WHERE ${a.join(" AND ")}`;try{await t2("/api/db/query",{id:e,connectionString:t,sql:i,params:s}),et(null),eN(E,U,ei,ed)}catch(e){alert(`Update failed: ${e instanceof Error?e.message:String(e)}`)}},[ee,H,E,I,B,er,e,t,N,eN,U,ei,ed]),eL=(0,s.useCallback)(async()=>{if(!E)return;let r=[],n=[],s=[],o=1;for(let e of I)void 0!==el[e.name]&&""!==el[e.name]&&(r.push(tZ(e.name)),n.push(el[e.name]),s.push(`$${o}`),o++);if(0===r.length)return;let l=`INSERT INTO ${tZ(N)}.${tZ(E)} (${r.join(", ")}) VALUES (${s.join(", ")})`;try{await t2("/api/db/query",{id:e,connectionString:t,sql:l,params:n}),eo(!1),ea({}),eN(E,U,ei,ed)}catch(e){alert(`Insert failed: ${e instanceof Error?e.message:String(e)}`)}},[E,I,el,e,t,N,eN,U,ei,ed]),eE=(0,s.useCallback)(async()=>{if(0===Y.size||!H||!E)return;let r=B.length>0?B:I.map(e=>e.name),n=0;for(let s of Array.from(Y).sort((e,t)=>t-e)){let o=H.rows[s];if(!o)continue;let l=[],a=[],i=1;for(let e of r)null===o[e]||void 0===o[e]?l.push(`${tZ(e)} IS NULL`):(l.push(`${tZ(e)} = $${i}`),a.push(o[e]),i++);let c=`DELETE FROM ${tZ(N)}.${tZ(E)} WHERE ctid = (SELECT ctid FROM ${tZ(N)}.${tZ(E)} WHERE ${l.join(" AND ")} LIMIT 1)`;try{await t2("/api/db/query",{id:e,connectionString:t,sql:c,params:a})}catch{n++}}Q(new Set),Z(!1),eN(E,U,ei,ed),n>0&&alert(f("database.deleteRowsFailed",{count:n}))},[Y,H,E,B,I,e,t,N,eN,U,ei,ed]),eM=(0,s.useCallback)(async r=>{if(!E)return;if(Y.size>0&&H){let e,t=H.fields.map(e=>e.name),n=Array.from(Y).sort((e,t)=>e-t).map(e=>H.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 ${tZ(N)}.${tZ(E)}`;try{let s=await fetch("/api/db/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,connectionString:t,sql:n,format:r})});if(!s.ok)throw Error("Export failed");let o=await s.blob(),l=URL.createObjectURL(o),a=document.createElement("a");a.href=l,a.download=`${E}.${r}`,a.click(),URL.revokeObjectURL(l)}catch(e){alert(`Export failed: ${e instanceof Error?e.message:String(e)}`)}},[E,e,t,N,Y,H]),eT=(0,s.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),eC())},[eC]),e$=Math.max(1,Math.ceil(J/50)),eR=(0,s.useCallback)(e=>{E&&(q(e),eN(E,e,ei,ed))},[E,eN,ei,ed]),eP=(0,s.useCallback)((e,t)=>{let r={...ei};t?r[e]=t:delete r[e],ec(r),q(0),Q(new Set),E&&eN(E,0,r,ed)},[ei,ed,E,eN]),eI=(0,s.useCallback)(()=>{ec({}),q(0),Q(new Set),E&&eN(E,0,{},ed)},[ed,E,eN]),eD=(0,s.useCallback)(e=>{eu(e),q(0),Q(new Set),E&&eN(E,0,ei,e)},[ei,E,eN]);return(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
6
|
+
relative transition-colors cursor-pointer
|
|
7
|
+
${a?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
8
|
+
${a?"":l?"border-brand":"border-brand/30"}`,onClick:a?void 0:d,children:[(0,n.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:h,onMouseDown:x,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${a?"bg-card":"bg-card/50"}`,style:a?{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"===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:f("database.connectionFailed")}),"connected"===b&&(0,n.jsx)("span",{className:"text-[10px] text-emerald-500 flex-shrink-0",children:f("database.connected")}),(0,n.jsx)("span",{className:"flex-1"}),m&&(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:tG(m)}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),h()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:a?f("browser.exitMaximize",{modKey:(0,to.Mu)()}):f("browser.maximize",{modKey:(0,to.Mu)()}),children:a?(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:a&&i?i-41:c??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"}),f("database.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: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"===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:[y.length>1?(0,n.jsx)("select",{value:N,onChange:e=>{C(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:y.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:N}),(0,n.jsx)("button",{onClick:ey,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent active:bg-accent/50 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:()=>$(e),className:`flex-1 py-1 text-[10px] font-medium transition-colors ${T===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:[S.filter(e=>"table"===T?"view"!==e.type:"view"===e.type).map(e=>(0,n.jsxs)("div",{onClick:()=>ek(e.name),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer truncate transition-colors ${E===e.name?"bg-brand/10 text-brand":"hover:bg-accent 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)(t1,{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===S.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:()=>P(e),className:`px-3 py-1.5 text-xs transition-colors ${R===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)),E&&"data"===R&&(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:eI,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:"|"})]}),Y.size>0&&!G&&(0,n.jsx)("button",{onClick:()=>Z(!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:Y.size})}),G&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-[10px] text-destructive",children:f("database.confirmDeleteRows")}),(0,n.jsx)("button",{onClick:eE,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:()=>Z(!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:()=>eM("csv"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:Y.size>0?f("database.copyCsvSelected"):f("database.copyCsvAll"),children:Y.size>0?f("database.copyCSV"):f("database.CSV")}),(0,n.jsx)("button",{onClick:()=>eM("json"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:Y.size>0?f("database.copyJsonSelected"):f("database.copyJsonAll"),children:Y.size>0?f("database.copyJSON"):f("database.JSON")})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:E||"sql"===R?"structure"===R?(0,n.jsx)(t3,{columns:I,primaryKeys:B,foreignKeys:O,indexes:W}):"data"===R?(0,n.jsx)(t8,{result:H,loading:V,columns:I,page:U,totalPages:e$,totalRows:J,onPageChange:eR,filters:ei,sort:ed,onFilterChange:eP,onSortChange:eD,selectedRows:Y,onSelectedRowsChange:e=>{Q(e),Z(!1)},editingRowIdx:ee,editValues:er,onStartEdit:e=>{if(!H)return;let t=H.rows[e],r={};for(let e of I)r[e.name]=null==t[e.name]?"":t0(t[e.name]);en(r),et(e)},onEditChange:(e,t)=>en(r=>({...r,[e]:t})),onSaveEdit:eS,onCancelEdit:()=>et(null),isAddingRow:es,newRowValues:el,onStartAdd:()=>{eo(!0),ea({})},onNewRowChange:(e,t)=>ea(r=>({...r,[e]:t})),onSaveNewRow:eL,onCancelAdd:()=>{eo(!1),ea({})},onCellCopy:e=>{navigator.clipboard.writeText(e),p(f("common.copied"))}}):(0,n.jsx)(t9,{sqlInput:eh,onSqlChange:em,onExecute:eC,onKeyDown:eT,result:ex,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")})})]})]})]}),!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"===b?"bg-green-500":"error"===b?"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")}[b]}),"connected"===b&&E&&(0,n.jsx)("span",{className:"text-muted-foreground/70",children:E}),(0,n.jsx)("span",{className:"flex-1"}),m&&(0,n.jsx)("span",{className:"text-[11px] flex-shrink-0",children:tG(m)})]})]})})}function t3({columns:e,primaryKeys:t,foreignKeys:r,indexes:s}){let{t:l}=(0,o.Bd)();return 0===e.length?(0,n.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:l("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:l("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:l("database.colName")}),(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:l("database.colType")}),(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:l("database.colNullable")}),(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:l("database.colDefault")})]})}),(0,n.jsx)("tbody",{children:e.map(e=>(0,n.jsxs)("tr",{className:"border-b border-border/50 hover:bg-accent/50",children:[(0,n.jsxs)("td",{className:"px-1.5 py-1 font-mono",children:[e.isPrimaryKey&&(0,n.jsx)("span",{className:"text-amber-500 mr-1",title:l("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:l("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:l("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",title:e.definition,children:e.name},e.name))})]})]})}function t6({filter:e,onApply:t,onClear:r,onToggle:l,onClose:i,colName:c,anchorRect:d}){let{t:u}=(0,o.Bd)(),[h,m]=(0,s.useState)(e?.op||"="),[x,f]=(0,s.useState)(e?.value||""),p=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&i()};return document.addEventListener("mousedown",e,!0),()=>document.removeEventListener("mousedown",e,!0)},[i]);let g="IS NULL"!==h&&"IS NOT NULL"!==h,b=()=>{(!g||x.trim())&&t({op:h,value:x.trim(),enabled:!0})},v=window.innerWidth,j=d.left;return j+220>v-8&&(j=v-220-8),j<8&&(j=8),(0,a.createPortal)((0,n.jsxs)("div",{ref:p,className:"fixed z-[9998] w-[220px] bg-popover border border-border rounded-md shadow-lg p-2 space-y-2",style:{left:j,top:d.bottom+2},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=>l(e.target.checked),className:"w-3 h-3 accent-brand"}),u("database.enable")]}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono truncate max-w-[120px]",children:c})]}),(0,n.jsx)("select",{value:h,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:tQ.map(e=>(0,n.jsx)("option",{value:e.value,children:e.label},e.value))}),g&&(0,n.jsx)("input",{type:"text",value:x,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),b())},placeholder:u("IN"===h?"database.commaValues":"LIKE"===h?"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:b,disabled:g&&!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:u("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:u("database.clearFilter")})]})]}),document.body)}function t8({result:e,loading:t,columns:r,page:l,totalPages:a,totalRows:i,onPageChange:c,filters:d,sort:u,onFilterChange:h,onSortChange:m,selectedRows:x,onSelectedRowsChange:f,editingRowIdx:p,editValues:g,onStartEdit:b,onEditChange:v,onSaveEdit:j,onCancelEdit:w,isAddingRow:y,newRowValues:k,onStartAdd:N,onNewRowChange:C,onSaveNewRow:S,onCancelAdd:L,onCellCopy:E}){let{t:M}=(0,o.Bd)(),[T,$]=(0,s.useState)(null),[R,P]=(0,s.useState)({left:0,bottom:0});if((0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(null!==T?(e.stopPropagation(),$(null)):null!==p?(e.stopPropagation(),w()):y&&(e.stopPropagation(),L()))};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[T,p,y,w,L]),!e&&!t)return(0,n.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:M("database.selectTableForData")});let I=e?.fields||[],D=e?.rows||[],B={};for(let e of r)B[e.name]=e.type+(e.maxLength?`(${e.maxLength})`:"");let F=D.length>0&&x.size===D.length,O=x.size>0&&!F;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:F,ref:e=>{e&&(e.indeterminate=O)},onChange:()=>{F?f(new Set):f(new Set(D.map((e,t)=>t)))},className:"w-3 h-3 accent-brand cursor-pointer"})}),I.map(e=>{let t=u?.column===e.name?u.dir:null,r=d[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?m({column:t,dir:"DESC"}):m(null):m({column:t,dir:"ASC"}))},children:[e.name,B[e.name]&&(0,n.jsx)("span",{className:"ml-1 text-[9px] text-muted-foreground/60 font-normal",children:B[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(),T===e.name)return void $(null);let r=t.currentTarget.closest("th").getBoundingClientRect();P({left:r.left,bottom:r.bottom}),$(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"})})}),T===e.name&&(0,n.jsx)(t6,{filter:r||null,onApply:t=>{h(e.name,t),$(null)},onClear:()=>{h(e.name,null),$(null)},onToggle:t=>{r&&h(e.name,{...r,enabled:t})},onClose:()=>$(null),colName:e.name,anchorRect:R})]},e.name)})]})}),(0,n.jsxs)("tbody",{children:[y&&(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-emerald-500 hover:text-emerald-400",title:M("common.save"),children:"✓"}),(0,n.jsx)("button",{onClick:L,className:"text-[10px] text-muted-foreground hover:text-foreground",title:M("common.cancel"),children:"✕"})]})}),I.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:k[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))]}),D.map((e,t)=>(0,n.jsxs)("tr",{className:`hover:bg-accent/50 ${x.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-emerald-500 hover:text-emerald-400",title:M("common.save"),children:"✓"}),(0,n.jsx)("button",{onClick:w,className:"text-[10px] text-muted-foreground hover:text-foreground",title:M("common.cancel"),children:"✕"})]}):(0,n.jsx)("input",{type:"checkbox",checked:x.has(t),onChange:()=>{let e;(e=new Set(x)).has(t)?e.delete(t):e.add(t),f(e)},className:"w-3 h-3 accent-brand cursor-pointer"})}),I.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(),E(t0(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)(t1,{text:t0(e[r.name])})},r.name))]},t))]})]}),0===D.length&&!t&&(0,n.jsx)("div",{className:"p-4 text-xs text-muted-foreground text-center",children:M("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:y,className:"px-1.5 py-0.5 text-[10px] text-emerald-500 hover:text-emerald-400 disabled:opacity-30",children:M("database.addRow")}),(0,n.jsx)("span",{children:M("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:()=>c(l-1),disabled:0===l,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"◀"}),(0,n.jsxs)("span",{children:[l+1," / ",a]}),(0,n.jsx)("button",{onClick:()=>c(l+1),disabled:l>=a-1,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"▶"})]})]})]})}function t9({sqlInput:e,onSqlChange:t,onExecute:r,onKeyDown:s,result:l,error:a,loading:i,sqlRef:c,onCellCopy:d}){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:c,value:e,onChange:e=>t(e.target.value),onKeyDown:s,placeholder:u("database.sqlPlaceholder",{modKey:(0,to.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")}),l?.duration!==void 0&&(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[l.command&&!l.fields?u("database.rowsAffected",{command:l.command,count:l.rowCount,duration:l.duration}):u("database.queryRows",{count:l.rows?.length??0,duration:l.duration}),l.truncated&&` ${u("database.resultTruncated")}`]})]})]}),a&&(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-destructive bg-destructive/5 border-b border-border break-all",children:a}),l?.fields&&l.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:l.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:l.rows.map((e,t)=>(0,n.jsx)("tr",{className:"hover:bg-accent/50",children:l.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(),d(t0(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)(t1,{text:t0(e[t.name])})},t.name))},t))})]})})]})}tH({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:l,onSelect:a,onClose:i,onToggleMaximize:c,onTitleMouseDown:d}){return(0,n.jsx)(t4,{id:e.id,connectionString:e.connectionString,displayName:e.displayName,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:l,onSelect:a,onClose:i,onToggleMaximize:c,onTitleMouseDown:d})},async onClose(e){try{await fetch("/api/db/disconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})})}catch{}}});var t7=r(91334),re=r(38194),rt=r(88522),rr=r(72816);let rn=new tr.v;function rs(e){return e?Array.isArray(e)?e.join(""):e:""}function ro(e,t){return e&&e[t]?rs(e[t]):""}rn.use_classes=!0;let rl=(0,s.memo)(function({output:e}){if("stream"===e.output_type){let t=rs(e.text);if(!t)return null;let r=rn.ansi_to_html(t);return(0,n.jsx)("pre",{className:`text-xs leading-relaxed whitespace-pre-wrap break-all px-3 py-1 ${"stderr"===e.name?"text-amber-500":"text-foreground"}`,dangerouslySetInnerHTML:{__html:r}})}if("error"===e.output_type){let t=(e.traceback||[]).join("\n"),r=rn.ansi_to_html(t);return(0,n.jsx)("pre",{className:"text-xs leading-relaxed whitespace-pre-wrap break-all px-3 py-1 text-red-400 bg-red-500/5 rounded",dangerouslySetInnerHTML:{__html:r}})}if("execute_result"===e.output_type||"display_data"===e.output_type||"update_display_data"===e.output_type){let t=e.data;if(!t)return null;let r=ro(t,"image/png"),s=ro(t,"image/jpeg"),o=ro(t,"image/svg+xml"),l=ro(t,"text/html"),a=ro(t,"text/markdown"),i=ro(t,"text/latex"),c=ro(t,"text/plain");if(r)return(0,n.jsx)("div",{className:"px-3 py-1",children:(0,n.jsx)("img",{src:`data:image/png;base64,${r}`,alt:"output",className:"max-w-full"})});if(s)return(0,n.jsx)("div",{className:"px-3 py-1",children:(0,n.jsx)("img",{src:`data:image/jpeg;base64,${s}`,alt:"output",className:"max-w-full"})});if(o)return(0,n.jsx)("div",{className:"px-3 py-1",dangerouslySetInnerHTML:{__html:o}});if(l)return(0,n.jsx)("div",{className:"px-3 py-1 overflow-x-auto notebook-html-output",dangerouslySetInnerHTML:{__html:l}});if(a)return(0,n.jsx)("div",{className:"px-3 py-1",children:(0,n.jsx)(eP.T,{content:a})});if(i)return(0,n.jsx)("div",{className:"px-3 py-1",children:(0,n.jsx)(eP.T,{content:`$$${i}$$`})});if(c)return(0,n.jsx)("pre",{className:"text-xs leading-relaxed whitespace-pre-wrap break-all px-3 py-1 text-foreground",children:c})}return null}),ra=(0,s.memo)(function({cell:e,isActive:t,isEditing:r,onSelect:o,onEdit:l,onStopEdit:a,onSourceChange:i,onRun:c,onDelete:d,onMoveUp:u,onMoveDown:h,onToggleType:m,isFirst:x,isLast:f}){let{resolvedTheme:p}=(0,rr.D)(),g=(0,s.useRef)(null),[b,v]=(0,s.useState)(e.source),j=(0,s.useCallback)(()=>{v(e.source),l()},[e.source,l]);(0,s.useEffect)(()=>{if(r&&g.current){g.current.focus();let e=g.current.value.length;g.current.setSelectionRange(e,e)}},[r]);let w=(0,s.useCallback)(()=>{let e=g.current;e&&(e.style.height="auto",e.style.height=e.scrollHeight+"px")},[]);(0,s.useEffect)(()=>{r&&w()},[r,b,w]);let y=(0,s.useCallback)(e=>{v(e.target.value),w()},[w]),k=(0,s.useCallback)(()=>{b!==e.source&&i(b),a()},[b,e.source,i,a]),N=(0,s.useCallback)(t=>{if("Enter"===t.key&&t.shiftKey)t.preventDefault(),b!==e.source&&i(b),c();else if("Enter"===t.key&&(t.metaKey||t.ctrlKey))t.preventDefault(),b!==e.source&&i(b),c();else if("Escape"===t.key)t.preventDefault(),k();else if("Tab"===t.key){t.preventDefault();let e=g.current;if(e){let t=e.selectionStart,r=e.selectionEnd;v(b.substring(0,t)+" "+b.substring(r)),requestAnimationFrame(()=>{e.selectionStart=e.selectionEnd=t+4})}}},[b,e.source,i,c,k]),C=e.isExecuting?"*":e.execution_count??" ",S="code"===e.cell_type?"Code":"markdown"===e.cell_type?"Md":"Raw";return(0,n.jsxs)("div",{className:`group relative border rounded-lg transition-colors ${t?"border-brand/50 bg-brand/5":"border-border/50 hover:border-border"}`,onClick:o,children:[(0,n.jsxs)("div",{className:`absolute -top-3 right-2 flex items-center gap-0.5 text-[10px] z-10 bg-surface-secondary rounded px-1 py-0.5 border border-border/50 transition-opacity ${t?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:[(0,n.jsx)("button",{onClick:c,className:"px-1 hover:text-brand",title:"Run (Shift+Enter)",children:e.isExecuting?"⬛":"▶"}),(0,n.jsx)("button",{onClick:m,className:"px-1 hover:text-brand",title:"Toggle type",children:S}),!x&&(0,n.jsx)("button",{onClick:u,className:"px-1 hover:text-brand",title:"Move up",children:"↑"}),!f&&(0,n.jsx)("button",{onClick:h,className:"px-1 hover:text-brand",title:"Move down",children:"↓"}),(0,n.jsx)("button",{onClick:d,className:"px-1 hover:text-red-400",title:"Delete",children:"\xd7"})]}),(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)("div",{className:"flex-shrink-0 w-10 text-center py-2 text-[10px] text-muted-foreground select-none cursor-pointer border-r border-border/30",onClick:e=>{e.stopPropagation(),c()},title:"code"===e.cell_type?"Click to run":void 0,children:"code"===e.cell_type?(0,n.jsxs)("span",{className:e.isExecuting?"text-brand animate-pulse":"",children:["[",C,"]"]}):(0,n.jsx)("span",{className:"text-muted-foreground/50",children:S})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"cursor-text",onDoubleClick:e=>{e.stopPropagation(),j()},children:r?(0,n.jsx)("textarea",{ref:g,value:b,onChange:y,onBlur:k,onKeyDown:N,className:"w-full bg-transparent text-xs font-mono leading-relaxed px-3 py-2 resize-none outline-none text-foreground",spellCheck:!1,style:{minHeight:"1.5rem"}}):"code"===e.cell_type?(0,n.jsx)("div",{className:"text-xs [&_pre]:!m-0 [&_pre]:!p-2 [&_pre]:!bg-transparent [&_code]:!bg-transparent",children:(0,n.jsx)(t7.A,{language:"python",style:"dark"===p?re.A:rt.A,customStyle:{margin:0,padding:"8px 12px",background:"transparent",fontSize:"12px"},wrapLongLines:!0,children:e.source||" "})}):"markdown"===e.cell_type?e.source.trim()?(0,n.jsx)("div",{className:"px-3 py-2 text-sm prose prose-sm dark:prose-invert max-w-none",children:(0,n.jsx)(eP.T,{content:e.source})}):(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground italic",children:"Empty markdown cell"}):(0,n.jsx)("pre",{className:"text-xs font-mono px-3 py-2 text-muted-foreground whitespace-pre-wrap",children:e.source||" "})}),e.outputs.length>0&&(0,n.jsx)("div",{className:"border-t border-border/30",children:e.outputs.map((e,t)=>(0,n.jsx)(rl,{output:e},t))})]})]})]})});function ri({id:e,filePath:t,displayName:r,cwd:o,selected:l,maximized:a,expandedHeight:i,bubbleContentHeight:c,timestamp:d,onSelect:u,onClose:h,onToggleMaximize:m,onTitleMouseDown:x}){let{showToast:f}=(0,g.dj)(),[p,b]=(0,s.useState)([]),[v,j]=(0,s.useState)(!0),[w,y]=(0,s.useState)(null),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[L,E]=(0,s.useState)(null),[M,T]=(0,s.useState)(null),[$,R]=(0,s.useState)("disconnected"),[P,I]=(0,s.useState)(null),D=(0,s.useRef)(null),B=(0,s.useRef)(new Map),F=(0,s.useRef)(null),O=(0,s.useRef)(p);O.current=p;let A=(0,s.useCallback)(async()=>{j(!0),y(null);try{let e=await fetch("/api/jupyter/load",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:t,cwd:o})}),r=await e.json();if(!e.ok)throw Error(r.error||"Failed to load notebook");b(r.cells.map((e,t)=>({...e,index:t,isExecuting:!1}))),N(!1)}catch(e){y(e.message)}finally{j(!1)}},[t,o]);(0,s.useEffect)(()=>{A()},[A]);let W=(0,s.useCallback)(async()=>{if(!C){S(!0);try{let e=await fetch("/api/jupyter/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:t,cwd:o,cells:p.map(e=>({cell_type:e.cell_type,source:e.source,outputs:e.outputs,execution_count:e.execution_count,metadata:e.metadata}))})}),r=await e.json();if(!e.ok)throw Error(r.error||"Failed to save");N(!1),f("Saved","success")}catch(e){f(e.message,"error")}finally{S(!1)}}},[t,o,p,C,f]);(0,s.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&(e.preventDefault(),W())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[W]);let z=(0,s.useCallback)(()=>{if(D.current&&D.current.readyState<=1)return;R("starting"),I(null);let t="https:"===window.location.protocol?"wss:":"ws:",r=new WebSocket(`${t}//${window.location.host}/ws/jupyter?bubbleId=${encodeURIComponent(e)}&cwd=${encodeURIComponent(o)}`);D.current=r,r.onopen=()=>{},r.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=t.type;if("ready"===r)R("idle"),I(null);else if("status"===r){let e=t.execution_state;"idle"===e?R("idle"):"busy"===e&&R("busy")}else if("output"===r){let e=t.msg_id,r=t.msg_type,n=t.content,s=B.current.get(e);if(void 0===s)return;b(e=>e.map((e,t)=>{if(t!==s)return e;let o={output_type:"execute_result"===r?"execute_result":"display_data"===r?"display_data":"update_display_data"===r?"update_display_data":"stream"===r?"stream":"error"===r?"error":"display_data"};return"stream"===r?(o.name=n.name,o.text=n.text):"error"===r?(o.ename=n.ename,o.evalue=n.evalue,o.traceback=n.traceback):(o.data=n.data,o.metadata=n.metadata,"execute_result"===r&&(o.execution_count=n.execution_count)),{...e,outputs:[...e.outputs,o]}}))}else if("kernel_error"===r)R("error"),I(t.message);else if("kernel_died"===r){for(let[,e]of(R("dead"),I("Kernel died"),B.current))b(t=>t.map((t,r)=>r===e?{...t,isExecuting:!1}:t));B.current.clear()}},r.onclose=()=>{"error"!==$&&"dead"!==$&&R("disconnected")},r.onerror=()=>{R("error")}},[e,o,$]);(0,s.useEffect)(()=>()=>{D.current?.close()},[]);let H=(0,s.useCallback)(e=>{let t=O.current[e];if(!t||"code"!==t.cell_type)return;if(!D.current||D.current.readyState!==WebSocket.OPEN){z();let t=setInterval(()=>{D.current?.readyState===WebSocket.OPEN&&(clearInterval(t),H(e))},200);setTimeout(()=>clearInterval(t),15e3);return}let r=`cell-${e}-${Date.now()}`;B.current.set(r,e),b(t=>t.map((t,r)=>r===e?{...t,outputs:[],isExecuting:!0,execution_count:null}:t)),D.current.send(JSON.stringify({type:"execute",msg_id:r,code:t.source})),setTimeout(()=>{B.current.has(r)&&(B.current.delete(r),b(t=>t.map((t,r)=>r===e?{...t,isExecuting:!1}:t)))},3e5)},[z]);(0,s.useEffect)(()=>{let e=D.current;if(!e)return;let t=e=>{let t=B.current.get(e);void 0!==t&&(B.current.delete(e),b(e=>e.map((e,r)=>{if(r!==t)return e;let n=e.outputs.find(e=>"execute_result"===e.output_type);return{...e,isExecuting:!1,execution_count:n?.execution_count??e.execution_count}})))},r=e=>{let r;try{r=JSON.parse(e.data)}catch{return}if("status"===r.type&&"idle"===r.execution_state)for(let[e]of B.current)t(e)};return e.addEventListener("message",r),()=>{e.removeEventListener("message",r)}},[$]);let _=(0,s.useCallback)(()=>{let e=[...p.map((e,t)=>({cell:e,index:t})).filter(e=>"code"===e.cell.cell_type)],t=()=>{if(0===e.length)return;let{index:r}=e.shift();H(r);let n=setInterval(()=>{let e=O.current[r];e&&!e.isExecuting&&(clearInterval(n),t())},200)};t()},[p,H]),U=(0,s.useCallback)(()=>{D.current?.send(JSON.stringify({type:"interrupt"}))},[]),q=(0,s.useCallback)((e,t)=>{b(r=>r.map((r,n)=>n===e?{...r,source:t}:r)),N(!0)},[]),V=(0,s.useCallback)(e=>{b(t=>t.filter((t,r)=>r!==e)),N(!0),L===e&&E(null)},[L]),K=(0,s.useCallback)((e,t)=>{b(r=>{let n=[...r],s="up"===t?e-1:e+1;return s<0||s>=n.length?r:([n[e],n[s]]=[n[s],n[e]],n)}),N(!0),E("up"===t?e-1:e+1)},[]),J=(0,s.useCallback)(e=>{b(t=>t.map((t,r)=>{if(r!==e)return t;let n="code"===t.cell_type?"markdown":"markdown"===t.cell_type?"raw":"code";return{...t,cell_type:n,outputs:"code"===n?t.outputs:[]}})),N(!0)},[]),X=(0,s.useCallback)((e,t)=>{let r={index:0,cell_type:e,source:"",outputs:[],execution_count:null,metadata:{},isExecuting:!1};b(e=>{let n=[...e],s=void 0!==t?t+1:n.length;return n.splice(s,0,r),n}),N(!0);let n=void 0!==t?t+1:p.length;E(n),T(n)},[p.length]),Y=(0,s.useMemo)(()=>{switch($){case"idle":return(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500 inline-block",title:"Kernel idle"});case"busy":return(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse inline-block",title:"Kernel busy"});case"starting":return(0,n.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin inline-block",title:"Starting kernel"});case"error":return(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-500 inline-block",title:P||"Kernel error"});case"dead":return(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-500 inline-block",title:"Kernel died"});default:return(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-gray-500 inline-block",title:"Disconnected"})}},[$,P]);return(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
9
|
+
relative transition-colors cursor-pointer
|
|
10
|
+
${a?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
11
|
+
${a?"":l?"border-brand":"border-brand/30"}`,onClick:a?void 0:u,children:[(0,n.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:m,onMouseDown:x,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${a?"bg-card":"bg-card/50"}`,style:a?{height:41}:void 0,children:[(0,n.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDCD3"}),(0,n.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:r}),Y,k&&(0,n.jsx)("span",{className:"text-[10px] text-amber-500 flex-shrink-0",children:"unsaved"}),(0,n.jsx)("span",{className:"flex-1"}),d&&(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}`}(d)}),(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:a?`Exit maximize (${(0,to.Mu)()}+M)`:`Maximize (${(0,to.Mu)()}+M)`,children:a?(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(),h()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:"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",{className:"flex items-center gap-1 px-3 py-1 border-b border-border/50 bg-surface-secondary/50 text-[11px]",children:[(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),_()},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Run All",children:"▶ All"}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),U()},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Interrupt",disabled:"busy"!==$,children:"⬛ Stop"}),(0,n.jsx)("div",{className:"w-px h-3 bg-border/50 mx-1"}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),X("code",L??p.length-1)},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Add code cell",children:"+ Code"}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),X("markdown",L??p.length-1)},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Add markdown cell",children:"+ Md"}),(0,n.jsx)("div",{className:"w-px h-3 bg-border/50 mx-1"}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),W()},className:`px-1.5 py-0.5 rounded hover:bg-accent transition-colors ${k?"text-brand":"text-muted-foreground hover:text-foreground"}`,title:`Save (${(0,to.Mu)()}+S)`,disabled:C,children:C?"Saving...":"Save"}),(0,n.jsx)("span",{className:"flex-1"}),P&&(0,n.jsx)("span",{className:"text-[10px] text-red-400 truncate max-w-[50%]",title:P,children:P}),"dead"===$&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),z()},className:"px-1.5 py-0.5 rounded text-brand hover:bg-accent transition-colors",children:"Restart"})]}),(0,n.jsx)("div",{ref:F,className:"overflow-y-auto",style:{height:(a&&i?i-41:c??360)-30},children:v?(0,n.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground text-sm",children:"Loading notebook..."}):w?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center h-32 gap-2",children:[(0,n.jsx)("span",{className:"text-red-400 text-sm",children:w}),(0,n.jsx)("button",{onClick:A,className:"text-xs text-brand hover:underline",children:"Retry"})]}):0===p.length?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center h-32 gap-2 text-muted-foreground text-sm",children:[(0,n.jsx)("span",{children:"Empty notebook"}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{onClick:()=>X("code"),className:"text-xs text-brand hover:underline",children:"+ Code cell"}),(0,n.jsx)("button",{onClick:()=>X("markdown"),className:"text-xs text-brand hover:underline",children:"+ Markdown cell"})]})]}):(0,n.jsxs)("div",{className:"flex flex-col gap-1 p-2",children:[p.map((e,t)=>(0,n.jsx)(ra,{cell:e,isActive:L===t,isEditing:M===t,onSelect:()=>E(t),onEdit:()=>{E(t),T(t)},onStopEdit:()=>T(null),onSourceChange:e=>q(t,e),onRun:()=>{"code"===e.cell_type&&H(t),t<p.length-1&&E(t+1)},onDelete:()=>V(t),onMoveUp:()=>K(t,"up"),onMoveDown:()=>K(t,"down"),onToggleType:()=>J(t),isFirst:0===t,isLast:t===p.length-1},`${t}-${e.cell_type}`)),(0,n.jsxs)("div",{className:"flex justify-center gap-2 py-2 opacity-0 hover:opacity-100 transition-opacity",children:[(0,n.jsx)("button",{onClick:()=>X("code",p.length-1),className:"text-[10px] text-muted-foreground hover:text-foreground px-2 py-0.5 rounded border border-border/50 hover:border-border transition-colors",children:"+ Code"}),(0,n.jsx)("button",{onClick:()=>X("markdown",p.length-1),className:"text-[10px] text-muted-foreground hover:text-foreground px-2 py-0.5 rounded border border-border/50 hover:border-border transition-colors",children:"+ Markdown"})]})]})})]})}tH({type:"jupyter",idPrefix:"nb",match:e=>e.trim().endsWith(".ipynb"),parse(e){let t=e.trim(),r=t.split("/"),n=r[r.length-1]||t;return{filePath:t,displayName:n,cwd:""}},fromHistory:e=>({filePath:e.filePath,displayName:e.displayName||"",cwd:e.cwd||""}),toHistory:e=>({filePath:e.filePath,displayName:e.displayName,cwd:e.cwd}),Component:function({item:e,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:l,onSelect:a,onClose:i,onToggleMaximize:c,onTitleMouseDown:d}){return(0,n.jsx)(ri,{id:e.id,filePath:e.filePath,displayName:e.displayName,cwd:e.cwd,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:l,onSelect:a,onClose:i,onToggleMaximize:c,onTitleMouseDown:d})},async onClose(e){try{await fetch("/api/jupyter/shutdown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bubbleId:e.id})})}catch{}}});let rc=[{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 rd(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 ru(e){return`\`${e.replace(/`/g,"``")}\``}function rh(e){try{let t=e.match(/\/\/[^/]+\/([^?]+)/);if(t)return t[1]}catch{}return""}function rm(e){return null==e?"":"object"==typeof e?JSON.stringify(e):String(e)}function rx({text:e}){let[t,r]=(0,s.useState)(!1),[o,l]=(0,s.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),i=(0,s.useRef)(null),c=(0,s.useRef)(null),d=(0,s.useRef)(!1),u=(0,s.useCallback)(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d.current||r(!1)},80)},[]),h=(0,s.useCallback)(()=>{c.current&&clearTimeout(c.current),d.current=!1,c.current=setTimeout(()=>{let e=i.current;if(!e||e.scrollWidth<=e.clientWidth)return;let t=e.getBoundingClientRect(),n=window.innerWidth,s=Math.min(600,n-t.left-8),o=s<200?Math.max(8,n-600-8):t.left,a=s<200?Math.min(600,n-16):s,c=window.innerHeight,d=t.top-8,u=c-t.bottom-8,h=d>u&&d>80;l({x:o,y:h?t.top-4:t.bottom+4,maxW:a,maxH:Math.max(60,h?d-4:u-4),above:h}),r(!0)},350)},[]),m=(0,s.useCallback)(()=>{u()},[u]),x=(0,s.useCallback)(()=>{d.current=!0,c.current&&clearTimeout(c.current)},[]),f=(0,s.useCallback)(()=>{d.current=!1,u()},[u]);return(0,n.jsxs)("span",{ref:i,className:"block truncate",onMouseEnter:h,onMouseLeave:m,children:[e,t&&(0,a.createPortal)((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-lg 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:x,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)}),document.body)]})}async function rf(e,t){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(n.error||`HTTP ${r.status}`);return n}async function rp(e,t){let r=new URLSearchParams(t),n=await fetch(`${e}?${r}`),s=await n.json();if(!n.ok)throw Error(s.error||`HTTP ${n.status}`);return s}function rg({id:e,connectionString:t,displayName:r,selected:l,maximized:a,expandedHeight:i,bubbleContentHeight:c,onSelect:d,onClose:u,onToggleMaximize:h,timestamp:m,onTitleMouseDown:x}){let{t:f}=(0,o.Bd)(),{showToast:p}=(0,g.dj)(),[b,v]=(0,s.useState)("connecting"),[j,w]=(0,s.useState)(""),[y,k]=(0,s.useState)([]),[N,C]=(0,s.useState)(()=>rh(t)),[S,L]=(0,s.useState)([]),[E,M]=(0,s.useState)(null),[T,$]=(0,s.useState)("table"),[R,P]=(0,s.useState)("data"),[I,D]=(0,s.useState)([]),[B,F]=(0,s.useState)([]),[O,A]=(0,s.useState)([]),[W,z]=(0,s.useState)([]),[H,_]=(0,s.useState)(null),[U,q]=(0,s.useState)(0),[V,K]=(0,s.useState)(!1),[J,X]=(0,s.useState)(0),[Y,Q]=(0,s.useState)(new Set),[G,Z]=(0,s.useState)(!1),[ee,et]=(0,s.useState)(null),[er,en]=(0,s.useState)({}),[es,eo]=(0,s.useState)(!1),[el,ea]=(0,s.useState)({}),[ei,ec]=(0,s.useState)({}),[ed,eu]=(0,s.useState)(null),[eh,em]=(0,s.useState)(""),[ex,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()=>{v("connecting"),w("");try{let r=await rf("/api/mysql/connect",{id:e,connectionString:t});k(r.schemas||[]);let n=rh(t);r.schemas?.length>0&&n&&r.schemas.includes(n)?C(n):r.schemas?.length>0&&C(r.schemas[0]),v("connected")}catch(e){w(e instanceof Error?e.message:String(e)),v("error")}},[e,t]);(0,s.useEffect)(()=>{ew()},[ew]);let ey=(0,s.useCallback)(async()=>{if("connected"===b)try{let r=await rp("/api/mysql/schemas",{id:e,connectionString:t,schema:N});L(r.tables||[])}catch{}},[e,t,N,b]);(0,s.useEffect)(()=>{ey()},[ey]);let ek=(0,s.useCallback)(async r=>{M(r),q(0),et(null),eo(!1),Q(new Set),Z(!1),ec({}),eu(null);try{let n=await rp("/api/mysql/columns",{id:e,connectionString:t,schema:N,table:r});D(n.columns||[]),F(n.primaryKeys||[]),A(n.foreignKeys||[]),z(n.indexes||[])}catch{}eN(r,0,{},null)},[e,t,N]),eN=(0,s.useCallback)(async(r,n,s,o)=>{K(!0);let l=s??ei,a=void 0!==o?o:ed;try{let s=`${ru(N)}.${ru(r)}`,{where:o,params:i}=function(e){let t=[],r=[];for(let[n,s]of Object.entries(e)){if(!s.enabled)continue;let e=ru(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}}(l),c=a?` ORDER BY ${ru(a.column)} ${a.dir}`:"",d=`SELECT * FROM ${s}${o}${c} LIMIT 50 OFFSET ${50*n}`,u=await rf("/api/mysql/query",{id:e,connectionString:t,sql:d,params:i});_(u);let h=`SELECT count(*) AS cnt FROM ${s}${o}`,m=await rf("/api/mysql/query",{id:e,connectionString:t,sql:h,params:i});X(m.rows?.[0]?.cnt??0)}catch{}K(!1)},[e,t,N,ei,ed]),eC=(0,s.useCallback)(async()=>{if(eh.trim()){ev(!0),eg(""),ef(null);try{let r=await rf("/api/mysql/query",{id:e,connectionString:t,sql:eh});ef(r)}catch(e){eg(e instanceof Error?e.message:String(e))}ev(!1)}},[e,t,eh]),eS=(0,s.useCallback)(async()=>{if(null===ee||!H||!E)return;let r=H.rows[ee],n=[],s=[];for(let e of I)void 0!==er[e.name]&&er[e.name]!==rm(r[e.name]??"")&&(n.push(`${ru(e.name)} = ?`),s.push(""===er[e.name]&&e.nullable?null:er[e.name]));if(0===n.length)return void et(null);let o=B.length>0?B:I.map(e=>e.name),l=[];for(let e of o)null===r[e]||void 0===r[e]?l.push(`${ru(e)} IS NULL`):(l.push(`${ru(e)} = ?`),s.push(r[e]));let a=`UPDATE ${ru(N)}.${ru(E)} SET ${n.join(", ")} WHERE ${l.join(" AND ")}`;try{await rf("/api/mysql/query",{id:e,connectionString:t,sql:a,params:s}),et(null),eN(E,U,ei,ed)}catch(e){alert(`Update failed: ${e instanceof Error?e.message:String(e)}`)}},[ee,H,E,I,B,er,e,t,N,eN,U,ei,ed]),eL=(0,s.useCallback)(async()=>{if(!E)return;let r=[],n=[],s=[];for(let e of I)void 0!==el[e.name]&&""!==el[e.name]&&(r.push(ru(e.name)),n.push(el[e.name]),s.push("?"));if(0===r.length)return;let o=`INSERT INTO ${ru(N)}.${ru(E)} (${r.join(", ")}) VALUES (${s.join(", ")})`;try{await rf("/api/mysql/query",{id:e,connectionString:t,sql:o,params:n}),eo(!1),ea({}),eN(E,U,ei,ed)}catch(e){alert(`Insert failed: ${e instanceof Error?e.message:String(e)}`)}},[E,I,el,e,t,N,eN,U,ei,ed]),eE=(0,s.useCallback)(async()=>{if(0===Y.size||!H||!E)return;let r=B.length>0?B:I.map(e=>e.name),n=0;for(let s of Array.from(Y).sort((e,t)=>t-e)){let o=H.rows[s];if(!o)continue;let l=[],a=[];for(let e of r)null===o[e]||void 0===o[e]?l.push(`${ru(e)} IS NULL`):(l.push(`${ru(e)} = ?`),a.push(o[e]));let i=`DELETE FROM ${ru(N)}.${ru(E)} WHERE ${l.join(" AND ")} LIMIT 1`;try{await rf("/api/mysql/query",{id:e,connectionString:t,sql:i,params:a})}catch{n++}}Q(new Set),Z(!1),eN(E,U,ei,ed),n>0&&alert(f("mysql.deleteRowsFailed",{count:n}))},[Y,H,E,B,I,e,t,N,eN,U,ei,ed]),eM=(0,s.useCallback)(async r=>{if(!E)return;if(Y.size>0&&H){let e,t=H.fields.map(e=>e.name),n=Array.from(Y).sort((e,t)=>e-t).map(e=>H.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 ${ru(N)}.${ru(E)}`;try{let s=await fetch("/api/mysql/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,connectionString:t,sql:n,format:r})});if(!s.ok)throw Error("Export failed");let o=await s.blob(),l=URL.createObjectURL(o),a=document.createElement("a");a.href=l,a.download=`${E}.${r}`,a.click(),URL.revokeObjectURL(l)}catch(e){alert(`Export failed: ${e instanceof Error?e.message:String(e)}`)}},[E,e,t,N,Y,H]),eT=(0,s.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),eC())},[eC]),e$=Math.max(1,Math.ceil(J/50)),eR=(0,s.useCallback)(e=>{E&&(q(e),eN(E,e,ei,ed))},[E,eN,ei,ed]),eP=(0,s.useCallback)((e,t)=>{let r={...ei};t?r[e]=t:delete r[e],ec(r),q(0),Q(new Set),E&&eN(E,0,r,ed)},[ei,ed,E,eN]),eI=(0,s.useCallback)(()=>{ec({}),q(0),Q(new Set),E&&eN(E,0,{},ed)},[ed,E,eN]),eD=(0,s.useCallback)(e=>{eu(e),q(0),Q(new Set),E&&eN(E,0,ei,e)},[ei,E,eN]);return(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
12
|
+
relative transition-colors cursor-pointer
|
|
13
|
+
${a?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
14
|
+
${a?"":l?"border-brand":"border-brand/30"}`,onClick:a?void 0:d,children:[(0,n.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:h,onMouseDown:x,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${a?"bg-card":"bg-card/50"}`,style:a?{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"===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:f("mysql.connectionFailed")}),"connected"===b&&(0,n.jsx)("span",{className:"text-[10px] text-emerald-500 flex-shrink-0",children:f("mysql.connected")}),(0,n.jsx)("span",{className:"flex-1"}),m&&(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:rd(m)}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),h()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:a?f("browser.exitMaximize",{modKey:(0,to.Mu)()}):f("browser.maximize",{modKey:(0,to.Mu)()}),children:a?(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:a&&i?i-41:c??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"}),f("mysql.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: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"===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:[y.length>1?(0,n.jsx)("select",{value:N,onChange:e=>{C(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:y.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:N}),(0,n.jsx)("button",{onClick:ey,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent active:bg-accent/50 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:()=>$(e),className:`flex-1 py-1 text-[10px] font-medium transition-colors ${T===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:[S.filter(e=>"table"===T?"view"!==e.type:"view"===e.type).map(e=>(0,n.jsxs)("div",{onClick:()=>ek(e.name),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer truncate transition-colors ${E===e.name?"bg-brand/10 text-brand":"hover:bg-accent 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)(rx,{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===S.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:()=>P(e),className:`px-3 py-1.5 text-xs transition-colors ${R===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)),E&&"data"===R&&(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:eI,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:"|"})]}),Y.size>0&&!G&&(0,n.jsx)("button",{onClick:()=>Z(!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:Y.size})}),G&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-[10px] text-destructive",children:f("mysql.confirmDeleteRows")}),(0,n.jsx)("button",{onClick:eE,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:()=>Z(!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:()=>eM("csv"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:Y.size>0?f("mysql.copyCsvSelected"):f("mysql.copyCsvAll"),children:Y.size>0?f("mysql.copyCSV"):f("mysql.CSV")}),(0,n.jsx)("button",{onClick:()=>eM("json"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:Y.size>0?f("mysql.copyJsonSelected"):f("mysql.copyJsonAll"),children:Y.size>0?f("mysql.copyJSON"):f("mysql.JSON")})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:E||"sql"===R?"structure"===R?(0,n.jsx)(rb,{columns:I,primaryKeys:B,foreignKeys:O,indexes:W}):"data"===R?(0,n.jsx)(rj,{result:H,loading:V,columns:I,page:U,totalPages:e$,totalRows:J,onPageChange:eR,filters:ei,sort:ed,onFilterChange:eP,onSortChange:eD,selectedRows:Y,onSelectedRowsChange:e=>{Q(e),Z(!1)},editingRowIdx:ee,editValues:er,onStartEdit:e=>{if(!H)return;let t=H.rows[e],r={};for(let e of I)r[e.name]=null==t[e.name]?"":rm(t[e.name]);en(r),et(e)},onEditChange:(e,t)=>en(r=>({...r,[e]:t})),onSaveEdit:eS,onCancelEdit:()=>et(null),isAddingRow:es,newRowValues:el,onStartAdd:()=>{eo(!0),ea({})},onNewRowChange:(e,t)=>ea(r=>({...r,[e]:t})),onSaveNewRow:eL,onCancelAdd:()=>{eo(!1),ea({})},onCellCopy:e=>{navigator.clipboard.writeText(e),p(f("common.copied"))}}):(0,n.jsx)(rw,{sqlInput:eh,onSqlChange:em,onExecute:eC,onKeyDown:eT,result:ex,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")})})]})]})]}),!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"===b?"bg-green-500":"error"===b?"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")}[b]}),"connected"===b&&E&&(0,n.jsx)("span",{className:"text-muted-foreground/70",children:E}),(0,n.jsx)("span",{className:"flex-1"}),m&&(0,n.jsx)("span",{className:"text-[11px] flex-shrink-0",children:rd(m)})]})]})})}function rb({columns:e,primaryKeys:t,foreignKeys:r,indexes:s}){let{t:l}=(0,o.Bd)();return 0===e.length?(0,n.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:l("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:l("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:l("mysql.colName")}),(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:l("mysql.colType")}),(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:l("mysql.colNullable")}),(0,n.jsx)("th",{className:"px-1.5 py-1 font-medium",children:l("mysql.colDefault")})]})}),(0,n.jsx)("tbody",{children:e.map(e=>(0,n.jsxs)("tr",{className:"border-b border-border/50 hover:bg-accent/50",children:[(0,n.jsxs)("td",{className:"px-1.5 py-1 font-mono",children:[e.isPrimaryKey&&(0,n.jsx)("span",{className:"text-amber-500 mr-1",title:l("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:l("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:l("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",title:e.definition,children:e.name},e.name))})]})]})}function rv({filter:e,onApply:t,onClear:r,onToggle:l,onClose:i,colName:c,anchorRect:d}){let{t:u}=(0,o.Bd)(),[h,m]=(0,s.useState)(e?.op||"="),[x,f]=(0,s.useState)(e?.value||""),p=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&i()};return document.addEventListener("mousedown",e,!0),()=>document.removeEventListener("mousedown",e,!0)},[i]);let g="IS NULL"!==h&&"IS NOT NULL"!==h,b=()=>{(!g||x.trim())&&t({op:h,value:x.trim(),enabled:!0})},v=window.innerWidth,j=d.left;return j+220>v-8&&(j=v-220-8),j<8&&(j=8),(0,a.createPortal)((0,n.jsxs)("div",{ref:p,className:"fixed z-[9998] w-[220px] bg-popover border border-border rounded-md shadow-lg p-2 space-y-2",style:{left:j,top:d.bottom+2},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=>l(e.target.checked),className:"w-3 h-3 accent-brand"}),u("mysql.enable")]}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono truncate max-w-[120px]",children:c})]}),(0,n.jsx)("select",{value:h,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:rc.map(e=>(0,n.jsx)("option",{value:e.value,children:e.label},e.value))}),g&&(0,n.jsx)("input",{type:"text",value:x,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),b())},placeholder:u("IN"===h?"mysql.commaValues":"LIKE"===h?"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:b,disabled:g&&!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:u("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:u("mysql.clearFilter")})]})]}),document.body)}function rj({result:e,loading:t,columns:r,page:l,totalPages:a,totalRows:i,onPageChange:c,filters:d,sort:u,onFilterChange:h,onSortChange:m,selectedRows:x,onSelectedRowsChange:f,editingRowIdx:p,editValues:g,onStartEdit:b,onEditChange:v,onSaveEdit:j,onCancelEdit:w,isAddingRow:y,newRowValues:k,onStartAdd:N,onNewRowChange:C,onSaveNewRow:S,onCancelAdd:L,onCellCopy:E}){let{t:M}=(0,o.Bd)(),[T,$]=(0,s.useState)(null),[R,P]=(0,s.useState)({left:0,bottom:0});if((0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(null!==T?(e.stopPropagation(),$(null)):null!==p?(e.stopPropagation(),w()):y&&(e.stopPropagation(),L()))};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[T,p,y,w,L]),!e&&!t)return(0,n.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:M("mysql.selectTableForData")});let I=e?.fields||[],D=e?.rows||[],B={};for(let e of r)B[e.name]=e.type+(e.maxLength?`(${e.maxLength})`:"");let F=D.length>0&&x.size===D.length,O=x.size>0&&!F;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:F,ref:e=>{e&&(e.indeterminate=O)},onChange:()=>{F?f(new Set):f(new Set(D.map((e,t)=>t)))},className:"w-3 h-3 accent-brand cursor-pointer"})}),I.map(e=>{let t=u?.column===e.name?u.dir:null,r=d[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?m({column:t,dir:"DESC"}):m(null):m({column:t,dir:"ASC"}))},children:[e.name,B[e.name]&&(0,n.jsx)("span",{className:"ml-1 text-[9px] text-muted-foreground/60 font-normal",children:B[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(),T===e.name)return void $(null);let r=t.currentTarget.closest("th").getBoundingClientRect();P({left:r.left,bottom:r.bottom}),$(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"})})}),T===e.name&&(0,n.jsx)(rv,{filter:r||null,onApply:t=>{h(e.name,t),$(null)},onClear:()=>{h(e.name,null),$(null)},onToggle:t=>{r&&h(e.name,{...r,enabled:t})},onClose:()=>$(null),colName:e.name,anchorRect:R})]},e.name)})]})}),(0,n.jsxs)("tbody",{children:[y&&(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-emerald-500 hover:text-emerald-400",title:M("common.save"),children:"✓"}),(0,n.jsx)("button",{onClick:L,className:"text-[10px] text-muted-foreground hover:text-foreground",title:M("common.cancel"),children:"✕"})]})}),I.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:k[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))]}),D.map((e,t)=>(0,n.jsxs)("tr",{className:`hover:bg-accent/50 ${x.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-emerald-500 hover:text-emerald-400",title:M("common.save"),children:"✓"}),(0,n.jsx)("button",{onClick:w,className:"text-[10px] text-muted-foreground hover:text-foreground",title:M("common.cancel"),children:"✕"})]}):(0,n.jsx)("input",{type:"checkbox",checked:x.has(t),onChange:()=>{let e;(e=new Set(x)).has(t)?e.delete(t):e.add(t),f(e)},className:"w-3 h-3 accent-brand cursor-pointer"})}),I.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(),E(rm(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)(rx,{text:rm(e[r.name])})},r.name))]},t))]})]}),0===D.length&&!t&&(0,n.jsx)("div",{className:"p-4 text-xs text-muted-foreground text-center",children:M("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:y,className:"px-1.5 py-0.5 text-[10px] text-emerald-500 hover:text-emerald-400 disabled:opacity-30",children:M("mysql.addRow")}),(0,n.jsx)("span",{children:M("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:()=>c(l-1),disabled:0===l,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"◀"}),(0,n.jsxs)("span",{children:[l+1," / ",a]}),(0,n.jsx)("button",{onClick:()=>c(l+1),disabled:l>=a-1,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"▶"})]})]})]})}function rw({sqlInput:e,onSqlChange:t,onExecute:r,onKeyDown:s,result:l,error:a,loading:i,sqlRef:c,onCellCopy:d}){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:c,value:e,onChange:e=>t(e.target.value),onKeyDown:s,placeholder:u("mysql.sqlPlaceholder",{modKey:(0,to.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")}),l?.duration!==void 0&&(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[l.command&&!l.fields?u("mysql.rowsAffected",{command:l.command,count:l.rowCount,duration:l.duration}):u("mysql.queryRows",{count:l.rows?.length??0,duration:l.duration}),l.truncated&&` ${u("mysql.resultTruncated")}`]})]})]}),a&&(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-destructive bg-destructive/5 border-b border-border break-all",children:a}),l?.fields&&l.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:l.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:l.rows.map((e,t)=>(0,n.jsx)("tr",{className:"hover:bg-accent/50",children:l.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(),d(rm(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)(rx,{text:rm(e[t.name])})},t.name))},t))})]})})]})}async function ry(e,t){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(n.error||`HTTP ${r.status}`);return n}tH({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:l,onSelect:a,onClose:i,onToggleMaximize:c,onTitleMouseDown:d}){return(0,n.jsx)(rg,{id:e.id,connectionString:e.connectionString,displayName:e.displayName,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:l,onSelect:a,onClose:i,onToggleMaximize:c,onTitleMouseDown:d})},async onClose(e){try{await fetch("/api/mysql/disconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})})}catch{}}});let rk={string:{label:"S",color:"text-emerald-500 bg-emerald-500/10"},hash:{label:"H",color:"text-blue-500 bg-blue-500/10"},list:{label:"L",color:"text-orange-500 bg-orange-500/10"},set:{label:"SET",color:"text-teal-500 bg-teal-500/10"},zset:{label:"Z",color:"text-purple-500 bg-purple-500/10"},stream:{label:"STR",color:"text-pink-500 bg-pink-500/10"}};function rN({type:e}){let t=rk[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 rC({text:e}){let[t,r]=(0,s.useState)(!1),[o,l]=(0,s.useState)({x:0,y:0,above:!0}),i=(0,s.useRef)(null),c=(0,s.useRef)(null),d=(0,s.useCallback)(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{let e=i.current;if(!e||e.scrollWidth<=e.clientWidth)return;let t=e.getBoundingClientRect(),n=t.top>window.innerHeight/2;l({x:t.left,y:n?t.top-4:t.bottom+4,above:n}),r(!0)},350)},[]),u=(0,s.useCallback)(()=>{c.current&&clearTimeout(c.current),r(!1)},[]);return(0,n.jsxs)("span",{ref:i,className:"block truncate",onMouseEnter:d,onMouseLeave:u,children:[e,t&&(0,a.createPortal)((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-lg whitespace-pre-wrap break-all select-text",style:{left:o.x,top:o.y,transform:o.above?"translateY(-100%)":void 0},children:e}),document.body)]})}function rS({id:e,connectionString:t,displayName:r,selected:l,maximized:a,expandedHeight:i,bubbleContentHeight:c,onSelect:d,onClose:u,onToggleMaximize:h,timestamp:m,onTitleMouseDown:x}){var f;let{t:p}=(0,o.Bd)(),{showToast:b}=(0,g.dj)(),[v,j]=(0,s.useState)("connecting"),[w,y]=(0,s.useState)(""),[k,N]=(0,s.useState)(null),[C,S]=(0,s.useState)([]),[L,E]=(0,s.useState)("0"),[M,T]=(0,s.useState)(!1),[$,R]=(0,s.useState)("*"),[P,I]=(0,s.useState)(!1),[D,B]=(0,s.useState)(null),[F,O]=(0,s.useState)(null),[A,W]=(0,s.useState)(!1),[z,H]=(0,s.useState)(null),[_,U]=(0,s.useState)(!1),[q,V]=(0,s.useState)("data"),[K,J]=(0,s.useState)(""),[X,Y]=(0,s.useState)(""),[Q,G]=(0,s.useState)([]),[Z,ee]=(0,s.useState)(!1),et=(0,s.useRef)(null),er=(0,s.useRef)(null),en=(0,s.useCallback)(async()=>{j("connecting"),y("");try{let r=await ry("/api/redis/connect",{id:e,connectionString:t});N(r),j("connected")}catch(e){y(e instanceof Error?e.message:String(e)),j("error")}},[e,t]);(0,s.useEffect)(()=>{en()},[en]);let es=(0,s.useCallback)(async(r,n,s)=>{I(!0);try{let o=await ry("/api/redis/keys",{id:e,connectionString:t,pattern:r,cursor:n,count:200});S(e=>s?[...e,...o.keys]:o.keys),E(o.cursor),T(o.hasMore)}catch{}I(!1)},[e,t]);(0,s.useEffect)(()=>{"connected"===v&&es($,"0",!1)},[v]);let eo=(0,s.useCallback)(()=>{B(null),O(null),es($,"0",!1)},[$,es]),el=(0,s.useCallback)(async r=>{B(r),W(!0),H(null),U(!1);try{let n=await ry("/api/redis/get",{id:e,connectionString:t,key:r});O(n)}catch(e){O(null),b(e instanceof Error?e.message:p("redis.loadFailed"))}W(!1)},[e,t,b]),ea=(0,s.useCallback)(async()=>{if(D)try{await ry("/api/redis/delete",{id:e,connectionString:t,keys:[D]}),B(null),O(null),U(!1),es($,"0",!1)}catch(e){b(e instanceof Error?e.message:p("redis.deleteFailed"))}},[D,e,t,$,es,b]),ei=(0,s.useCallback)(async()=>{if(D&&null!==z)try{await ry("/api/redis/set",{id:e,connectionString:t,key:D,value:z,type:"string"}),H(null),el(D),b(p("common.saved"))}catch(e){b(e instanceof Error?e.message:p("redis.saveFailed"))}},[D,z,e,t,el,b]),ec=(0,s.useCallback)(async()=>{try{let r=await ry("/api/redis/command",{id:e,connectionString:t,command:"INFO"});J("string"==typeof r.result?r.result:String(r.result))}catch{}},[e,t]);(0,s.useEffect)(()=>{"connected"===v&&"info"===q&&ec()},[v,q,ec]);let ed=(0,s.useCallback)(async()=>{let r,n=X.trim();if(!n)return;ee(!0),Y("");let s=[],o=/(?:"([^"]*)")|(?:'([^']*)')|(\S+)/g;for(;null!==(r=o.exec(n));)s.push(r[1]??r[2]??r[3]);let l=s[0]||"",a=s.slice(1);try{let r=await ry("/api/redis/command",{id:e,connectionString:t,command:l,args:a});G(e=>[...e,{command:n,result:r.result,duration:r.duration,isError:!1}])}catch(e){G(t=>[...t,{command:n,result:e instanceof Error?e.message:String(e),duration:0,isError:!0}])}ee(!1)},[X,e,t]);return(0,s.useEffect)(()=>{et.current?.scrollIntoView({behavior:"smooth"})},[Q]),(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
15
|
+
relative transition-colors cursor-pointer
|
|
16
|
+
${a?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
17
|
+
${a?"":l?"border-brand":"border-brand/30"}`,onClick:a?void 0:d,children:[(0,n.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:h,onMouseDown:x,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${a?"bg-card":"bg-card/50"}`,style:a?{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"===v&&(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"===v&&(0,n.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:p("common.connectionFailed")}),"connected"===v&&k&&(0,n.jsxs)("span",{className:"text-[10px] text-red-500 flex-shrink-0",children:["v",k.version," \xb7 ",k.dbSize," keys \xb7 ",k.memory]}),(0,n.jsx)("span",{className:"flex-1"}),m&&(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}`}(m)}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),h()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:a?p("browser.exitMaximize",{modKey:(0,to.Mu)()}):p("browser.maximize",{modKey:(0,to.Mu)()}),children:a?(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:a&&i?i-41:c??360},className:"flex overflow-hidden",children:["connecting"===v&&(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"===v&&(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:w}),(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"===v&&(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:$,onChange:e=>R(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-accent active:bg-accent/50 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($,"0",!1),className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent active:bg-accent/50 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:[C.map(e=>(0,n.jsxs)("div",{onClick:()=>el(e.key),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer transition-colors ${D===e.key?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,n.jsx)(rN,{type:e.type}),(0,n.jsx)("span",{className:"truncate min-w-0 flex-1 font-mono",children:(0,n.jsx)(rC,{text:e.key})})]},e.key)),0===C.length&&!P&&(0,n.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:p("redis.noKeys")}),P&&(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&&!P&&(0,n.jsx)("button",{onClick:()=>es($,L,!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:[C.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:()=>V(e),className:`px-3 py-1.5 text-xs transition-colors ${q===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)),D&&"data"===q&&(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[F&&(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`:""}`}(F.ttl,p),null!==F.size?` \xb7 ${null==(f=F.size)?"":f<1024?`${f} B`:f<1048576?`${(f/1024).toFixed(1)} KB`:`${(f/1048576).toFixed(1)} MB`}`:""]}),_?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"text-[10px] text-destructive",children:[p("common.confirm"),"?"]}),(0,n.jsx)("button",{onClick:ea,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:()=>U(!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:()=>U(!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"===q?(0,n.jsx)(rL,{selectedKey:D,keyValue:F,keyLoading:A,editingValue:z,onStartEdit:e=>H(e),onEditChange:H,onSaveEdit:ei,onCancelEdit:()=>H(null),onCellCopy:e=>{navigator.clipboard.writeText(e),b(p("common.copied"))}}):"info"===q?(0,n.jsx)(rE,{infoText:K,onRefresh:ec}):(0,n.jsx)(rM,{cliInput:X,onInputChange:Y,onExecute:ed,history:Q,loading:Z,endRef:et,inputRef:er})})]})]})]})]})})}function rL({selectedKey:e,keyValue:t,keyLoading:r,editingValue:s,onStartEdit:l,onEditChange:a,onSaveEdit:i,onCancelEdit:c,onCellCopy:d}){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:h,value:m}=t;if("string"===h){let t=String(m??""),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)(rN,{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:c,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:()=>l(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=>a(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(),d(t)},children:t})]})}if("hash"===h){let t=Object.entries(m||{});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)(rN,{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-accent/50",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(),d(e)},children:(0,n.jsx)(rC,{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(),d(t)},children:(0,n.jsx)(rC,{text:t})})]},e))})]})})]})}if("list"===h){let t=m?.items||[],r=m?.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)(rN,{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-accent/50",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(),d(e)},children:(0,n.jsx)(rC,{text:e})})]},t))})]})})]})}if("set"===h){let t=m?.items||[],r=m?.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)(rN,{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-accent/50",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(),d(e)},children:(0,n.jsx)(rC,{text:e})})},t))})]})})]})}if("zset"===h){let t=m?.items||[],r=m?.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)(rN,{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-accent/50",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(),d(e.member)},children:(0,n.jsx)(rC,{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"===h){let t=m?.entries||[],r=m?.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)(rN,{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-accent/50",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)(rC,{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:h})})}function rE({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=[],l=null;for(let t of e.split("\n")){let e=t.trim();if(e){if(e.startsWith("#"))l={title:e.replace(/^#\s*/,""),items:[]},s.push(l);else if(l&&e.includes(":")){let t=e.indexOf(":");l.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-accent/50 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 rM({cliInput:e,onInputChange:t,onExecute:r,history:s,loading:l,endRef:a,inputRef:i}){let{t:c}=(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:c("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:a})]}),(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||l||r()},placeholder:c("redis.cliPlaceholder"),className:"flex-1 min-w-0 text-xs font-mono bg-transparent border-0 focus:outline-none",autoComplete:"off",spellCheck:!1,disabled:l}),l&&(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"})]})]})}function rT(){return`cmd-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}tH({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:l,onSelect:a,onClose:i,onToggleMaximize:c,onTitleMouseDown:d}){return(0,n.jsx)(rS,{id:e.id,connectionString:e.connectionString,displayName:e.displayName,selected:t,maximized:r,expandedHeight:s,bubbleContentHeight:o,timestamp:l,onSelect:a,onClose:i,onToggleMaximize:c,onTitleMouseDown:d})},async onClose(e){try{await fetch("/api/redis/disconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})})}catch{}}});let r$=new Set(["zsh","bash","sh","fish","nu","python","python3","node","irb","lua","vim","nvim","vi","nano","emacs","top","htop","less","man"]);function rR({onAdd:e,onCancel:t}){let{t:r}=(0,o.Bd)(),[l,a]=(0,s.useState)(""),[i,c]=(0,s.useState)("");return(0,n.jsxs)("div",{className:"flex gap-1 mb-1",children:[(0,n.jsx)("input",{type:"text",value:l,onChange:e=>a(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=>c(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(),l.trim()&&i.trim()&&e(l.trim(),i.trim()))}})]})}function rP({label:e,commands:t,isAdding:r,onStartAdd:s,onAdd:l,onCancelAdd:a,onDelete:i,onExecute:c}){let{t:d}=(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)(th.A,{className:"w-3.5 h-3.5"})})]}),r&&(0,n.jsx)(rR,{onAdd:(e,t)=>l(e,t),onCancel:a}),0===t.length&&!r&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:d("console.noCustomCommands")}),t.map((e,t)=>(0,n.jsx)(tw.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:()=>c(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-accent transition-colors",children:[(0,n.jsx)(tj.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)(eJ.A,{className:"w-3 h-3"})})]})},t))]})}function rI({cwd:e,show:t,onClose:r,onExecute:l,onAddPluginItem:a}){let{t:i}=(0,o.Bd)(),[c,d]=(0,s.useState)([]),[u,h]=(0,s.useState)([]),[m,x]=(0,s.useState)(null),f=(0,s.useRef)(null),p=(0,s.useCallback)(async()=>{try{let[t,r]=await Promise.all([fetch("/api/services/config?scope=global"),fetch(`/api/services/config?cwd=${encodeURIComponent(e)}`)]);if(t.ok){let e=await t.json();d(e.customCommands||[])}if(r.ok){let e=await r.json();h(e.customCommands||[])}}catch(e){console.error("Failed to load commands:",e)}},[e]);(0,s.useEffect)(()=>{t&&queueMicrotask(()=>p())},[t,p]),(0,s.useEffect)(()=>{if(!t)return;let e=e=>{f.current&&!f.current.contains(e.target)&&(r(),x(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t,r]);let g=(0,s.useCallback)(async e=>{d(e);try{await fetch("/api/services/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:"global",customCommands:e})})}catch(e){console.error("Failed to save global commands:",e)}},[]),b=(0,s.useCallback)(async t=>{h(t);try{await fetch("/api/services/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,customCommands:t})})}catch(e){console.error("Failed to save project commands:",e)}},[e]),v=(0,s.useCallback)(e=>{r();let t=tU(e);t?a?.(t.type,e.trim()):l(e)},[r,l,a]);return t?(0,n.jsxs)("div",{ref:f,className:"absolute bottom-full left-0 mb-2 w-72 bg-popover border border-border rounded-lg shadow-lg z-50 max-h-[70vh] overflow-y-auto",children:[(0,n.jsx)(rP,{label:i("console.globalCommands"),commands:c,isAdding:"global"===m,onStartAdd:()=>x("global"),onAdd:(e,t)=>{g([...c,{name:e,command:t}]),x(null)},onCancelAdd:()=>x(null),onDelete:e=>g(c.filter((t,r)=>r!==e)),onExecute:v}),(0,n.jsx)("div",{className:"border-t border-border"}),(0,n.jsx)(rP,{label:i("console.projectCommands"),commands:u,isAdding:"project"===m,onStartAdd:()=>x("project"),onAdd:(e,t)=>{b([...u,{name:e,command:t}]),x(null)},onCancelAdd:()=>x(null),onDelete:e=>b(u.filter((t,r)=>r!==e)),onExecute:v})]}):null}function rD({cwd:e,currentCwd:t,commandHistoryRef:r,gridLayout:l,onGridLayoutChange:a,onExecute:i,onAddPluginItem:c,onShowEnvManager:d,onOpenZsh:u,onOpenNote:h}){let{t:m}=(0,o.Bd)(),[x,f]=(0,s.useState)(""),[p,g]=(0,s.useState)(-1),[b,v]=(0,s.useState)(""),[j,w]=(0,s.useState)([]),[y,k]=(0,s.useState)(0),[N,C]=(0,s.useState)(!1),[S,L]=(0,s.useState)(!1),[E,M]=(0,s.useState)([]),[T,$]=(0,s.useState)(!1),[R,P]=(0,s.useState)(0),I=(0,s.useRef)(null),D=(0,s.useRef)(null),B=(0,s.useRef)(!1),{projectCommands:F,globalCommands:O,expandCustomCommand:A,loadQuickCommands:W}=function(e){let[t,r]=(0,s.useState)([]),[n,o]=(0,s.useState)([]),l=(0,s.useCallback)(async()=>{try{let[t,n]=await Promise.all([fetch(`/api/services/config?cwd=${encodeURIComponent(e)}`),fetch("/api/services/config?scope=global")]);if(t.ok){let e=await t.json();r(e.customCommands||[])}if(n.ok){let e=await n.json();o(e.customCommands||[])}}catch{}},[e]);(0,s.useEffect)(()=>{queueMicrotask(()=>l())},[l]);let a=[...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),l=t.find(e=>e.name===o)??n.find(e=>e.name===o);return l?l.command+(r.length>1?" "+r.slice(1).join(" "):""):null},[t,n]);return{quickCustomCommands:a,projectCommands:t,globalCommands:n,expandCustomCommand:i,loadQuickCommands:l}}(e);(0,s.useEffect)(()=>{I.current?.focus()},[]),(0,s.useEffect)(()=>{if(x.startsWith("/")){let e=x.slice(1).toLowerCase(),t=[...F.filter(t=>t.name.toLowerCase().startsWith(e)).map(e=>({...e,scope:"project"})),...O.filter(t=>t.name.toLowerCase().startsWith(e)).map(e=>({...e,scope:"global"}))];queueMicrotask(()=>{M(t),$(t.length>0),P(0)})}else queueMicrotask(()=>$(!1))},[x,F,O]),(0,s.useEffect)(()=>{if(T&&D.current){let e=D.current.children[R];e?.scrollIntoView({block:"nearest"})}},[R,T]);let z=(0,s.useCallback)(e=>{$(!1);let t=e.command,r=tU(t);r?c?.(r.type,t.trim()):i(t),f("")},[i,c]),H=(0,s.useCallback)(e=>{if(e.preventDefault(),B.current||!x.trim())return;let t=A(x)??x,r=tU(t);r?c?.(r.type,t.trim()):i(t),f(""),g(-1),v("")},[x,i,c,A]),_=(0,s.useCallback)(async()=>{if(!I.current)return;let e=I.current.selectionStart||0;try{let r=await fetch("/api/terminal/autocomplete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t,input:x,cursorPosition:e})});if(r.ok){let e=await r.json();if(e.suggestions&&e.suggestions.length>0&&(w(e.suggestions),k(0),C(!0),1===e.suggestions.length)){let t=x.substring(0,e.replaceStart),r=x.substring(e.replaceEnd),n=t+e.suggestions[0]+r;f(n),C(!1),setTimeout(()=>{if(I.current){let t=e.replaceStart+e.suggestions[0].length;I.current.setSelectionRange(t,t)}},0)}}}catch(e){console.error("Autocomplete error:",e)}},[t,x]),U=(0,s.useCallback)(e=>{if(!I.current)return;let t=I.current.selectionStart||0,r=x.substring(0,t),n=x.substring(t),s=r.split(/\s+/),o=t-(s[s.length-1]||"").length;f(x.substring(0,o)+e+n),C(!1),setTimeout(()=>{if(I.current){let t=o+e.length;I.current.setSelectionRange(t,t)}},0)},[x]),q=(0,s.useCallback)(e=>{if(e.nativeEvent.isComposing)return;if(T&&E.length>0){if("ArrowUp"===e.key){e.preventDefault(),P(e=>(e-1+E.length)%E.length);return}if("ArrowDown"===e.key){e.preventDefault(),P(e=>(e+1)%E.length);return}if("Tab"===e.key||"Enter"===e.key){e.preventDefault(),z(E[R]);return}if("Escape"===e.key){e.preventDefault(),$(!1);return}}if("Tab"===e.key){if(e.preventDefault(),N&&j.length>0){let e=(y+1)%j.length;k(e),U(j[e])}else _();return}if("Escape"===e.key&&N){e.preventDefault(),C(!1);return}let t=r.current;if(t&&0!==t.length){if("ArrowUp"===e.key){e.preventDefault(),-1===p&&v(x);let r=-1===p?t.length-1:Math.max(0,p-1);g(r),f(t[r])}else if("ArrowDown"===e.key){if(e.preventDefault(),-1===p)return;let r=p+1;r>=t.length?(g(-1),f(b)):(g(r),f(t[r]))}}},[p,x,b,N,j,y,_,U,T,E,R,z,r]);return(0,n.jsx)("div",{className:"border-t border-border p-4",children:(0,n.jsxs)("form",{onSubmit:H,className:"relative flex gap-2 items-center",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{S||W(),L(!S)},className:`p-2 rounded-lg transition-all ${S?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95"}`,title:m("console.quickCommands"),children:(0,n.jsx)(tp.A,{className:"w-4 h-4"})}),(0,n.jsx)(rI,{cwd:e,show:S,onClose:()=>L(!1),onExecute:i,onAddPluginItem:c})]}),h&&(0,n.jsx)("button",{type:"button",onClick:h,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:m("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:()=>a(!l),className:`p-2 rounded-lg transition-all ${l?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95"}`,title:l?m("console.singleColumn"):m("console.dualColumn"),children:l?(0,n.jsx)(tg.A,{className:"w-4 h-4"}):(0,n.jsx)(tb.A,{className:"w-4 h-4"})}),(0,n.jsx)("button",{type:"button",onClick:d,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:m("console.envVars"),children:(0,n.jsx)(tv.A,{className:"w-4 h-4"})}),(0,n.jsx)("button",{type:"button",onClick:u,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:m("console.launchZsh"),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:I,type:"text",value:x,onChange:e=>{f(e.target.value),-1!==p&&(g(-1),v("")),C(!1)},onKeyDown:q,onCompositionStart:()=>{B.current=!0},onCompositionEnd:()=>{B.current=!1},placeholder:m("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"}),T&&E.length>0&&(0,n.jsx)("div",{ref:D,className:"absolute bottom-full left-0 right-0 mb-1 max-h-64 overflow-y-auto bg-popover border border-border rounded-lg shadow-lg z-50",children:E.map((e,t)=>(0,n.jsxs)("div",{onClick:()=>z(e),className:`flex items-center gap-3 px-3 py-1.5 cursor-pointer text-sm ${t===R?"bg-brand/10":"hover:bg-accent"}`,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.command}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground/60 flex-shrink-0",children:"project"===e.scope?m("console.scopeProject"):m("console.scopeGlobal")})]},`${e.scope}-${e.name}`))}),N&&j.length>1&&(0,n.jsxs)("div",{className:"absolute bottom-full left-0 mb-1 bg-popover border border-border rounded-lg shadow-lg max-h-48 overflow-y-auto z-50",children:[(0,n.jsx)("div",{className:"py-1",children:j.map((e,t)=>(0,n.jsx)("button",{type:"button",onClick:()=>U(e),className:`w-full px-3 py-1.5 text-left text-sm font-mono hover:bg-accent 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:m("console.tabSwitchEscClose")})]})]})})}function rB({showTop:e,showBottom:t,onScrollTop:r,onScrollBottom:s}){let{t:l}=(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-md rounded-full transition-all hover:shadow-lg active:scale-95 z-10",title:l("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-md rounded-full transition-all hover:shadow-lg active:scale-95 z-10",title:l("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"})})})]})}function rF({cwd:e,initialShellCwd:t,tabId:r,onCwdChange:l,onOpenNote:a}){let{t:i}=(0,o.Bd)(),{consoleItems:c,scrollRef:d,selectedCommandId:u,setSelectedCommandId:h,interruptCommand:m,sendStdin:x,deleteCommand:f,rerunCommand:p,ptySizeRef:g,resizePty:b,executeCommand:v,addPluginItem:j,closePluginItem:w,sleepingBubbles:y,handleBubbleSleep:k,handleBubbleWake:N,scrollToBottom:C,currentCwd:S,commandHistoryRef:L,setCustomEnv:E,setAliases:M,saveBubbleOrder:T,hasMoreHistory:$,loadHistory:R,currentPage:P,isLoadingHistory:I}=function({cwd:e,initialShellCwd:t,tabId:r,onCwdChange:n}){let[o,l]=(0,s.useState)([]),[a,i]=(0,s.useState)([]),[c,d]=(0,s.useState)(new Set),[u,h]=(0,s.useState)(t||e),[m,x]=(0,s.useState)(!1),[f,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(0),[v,j]=(0,s.useState)(null),[w,y]=(0,s.useState)({}),[k,N]=(0,s.useState)({}),[C,S]=(0,s.useState)(null),L=(0,s.useRef)(null),E=(0,s.useRef)(new Map),M=(0,s.useRef)(new Map),T=(0,s.useRef)(new Set),$=(0,s.useRef)([]),R=(0,s.useRef)(new Map),P=(0,s.useRef)(null),I=(0,s.useRef)(null),D=(0,s.useRef)([]),B=(0,s.useRef)(null);(0,s.useEffect)(()=>{n?.(e)},[]);let F=(0,s.useCallback)(()=>{if(E.current.size>0){let e=new Map(E.current);E.current.clear(),l(t=>t.map(t=>{let r=e.get(t.id);return void 0!==r?{...t,output:r}:t}))}L.current=null},[]),O=(0,s.useCallback)((e,t)=>{let r=(M.current.get(e)||"")+t,n=T.current.has(e)?5242880:2097152;if(r.length>n){let t=function(e,t){let r=e.slice(-t),n=0;if(r.length>0){let e=r.charCodeAt(0);e>=56320&&e<=57343&&(n=1)}let s=Math.min(r.length,64);for(let e=n;e<s;e++){let t=r.charCodeAt(e);if(27===t){n=e;break}if((!(t>=48)||!(t<=63))&&59!==t&&63!==t&&32!==t){t>=64&&t<=126&&(n=e+1);break}}return n>0?r.slice(n):r}(r,n);M.current.set(e,t),E.current.set(e,t)}else M.current.set(e,r),E.current.set(e,r);null===L.current&&(L.current=requestAnimationFrame(F))},[F]),A=(0,s.useCallback)(e=>{M.current.delete(e),T.current.delete(e),E.current.delete(e)},[]),W=(0,s.useCallback)(e=>(null!==L.current&&(cancelAnimationFrame(L.current),L.current=null),F(),M.current.get(e)||""),[F]),z=(0,s.useCallback)(()=>{B.current&&(B.current.scrollTop=B.current.scrollHeight)},[]),H=(0,s.useCallback)(async(t=0)=>{if(r){x(!0);try{let n=await fetch(`/api/terminal/history?cwd=${encodeURIComponent(e)}&tabId=${encodeURIComponent(r)}&page=${t}&pageSize=100`);if(n.ok){let e=await n.json(),r=[],s=[],o=new Set;for(let t of e.entries){let e=t_(t.type);if(e){let r=e.fromHistory(t);s.push({id:t.id,_type:t.type,timestamp:t.timestamp,...r}),t.sleeping&&o.add(t.id)}else{if(t.running)continue;r.push({id:t.id.includes("-")&&3===t.id.split("-").length?t.id:rT(),command:t.command,output:t.output,exitCode:t.exitCode,isRunning:!1,timestamp:t.timestamp,cwd:t.cwd,usePty:t.usePty})}}0===t?(l(r),i(s),o.size>0&&d(o)):(l(e=>{let t=new Set(e.map(e=>e.id)),n=r.filter(e=>!t.has(e.id));return[...e,...n]}),i(e=>{let t=new Set(e.map(e=>e.id)),r=s.filter(e=>!t.has(e.id));return[...e,...r]})),p(e.hasMore),b(t)}}catch(e){console.error("Failed to load history:",e)}finally{x(!1)}}},[e,r]),_=(0,s.useCallback)(async t=>{if(r)try{await fetch("/api/terminal/history",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,tabId:r,entry:{id:t.id,command:t.command,output:t.output,exitCode:t.exitCode,timestamp:t.timestamp,cwd:u}})})}catch(e){console.error("Failed to save cd history:",e)}},[e,r,u]),U=(0,s.useCallback)(async t=>{try{let n=await (tM||(tM=tA(e)));if(t.current)return;for(let s of n){if(r&&s.tabId!==r)continue;if(t.current)break;let n=s.commandId;l(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}:{}}]),M.current.set(n,""),s.usePty&&T.current.add(n),await tD({commandId:n,projectCwd:e,onData:(e,t)=>{if("pid"===e);else if("stdout"===e||"stderr"===e)O(n,t.data);else if("exit"===e){let e=W(n);A(n),l(r=>r.map(r=>r.id===n?{...r,output:e,exitCode:t.code,isRunning:!1,pid:void 0}:r))}},onError:()=>{l(e=>e.map(e=>e.id===n&&e.isRunning?{...e,isRunning:!1}:e))}})}}catch{}},[e,r,O,W,A]),q=(0,s.useCallback)(async t=>{let s,o=t.trim().split(/\s+/),a=o[0],i=t;k[a]&&(i=k[a]+(o.length>1?" "+o.slice(1).join(" "):""));let c=tU(i);if(c)return void I.current?.(c.type,i.trim());let d=rT(),m=new Date().toISOString(),x=(s=i.trim().split(/\s+/)[0],r$.has(s)),f={id:d,command:t,output:i!==t?`→ ${i}
|
|
18
|
+
`:"",isRunning:!0,timestamp:m,cwd:u,...x?{usePty:!0}:{}};if(l(e=>e.some(e=>e.id===d)?e:[...e,f]),j(d),M.current.set(d,f.output),x&&T.current.add(d),setTimeout(z,100),i.trim().startsWith("cd ")){let e=i.trim().substring(3).trim(),t=u;e.startsWith("/")?t=e:".."===e?t=u.split("/").slice(0,-1).join("/")||"/":"."!==e&&(t=`${u}/${e}`.replace(/\/+/g,"/")),h(t),n?.(t),l(e=>e.map(e=>{if(e.id===d){let r={...e,output:`Changed directory to: ${t}`,exitCode:0,isRunning:!1};return _(r),r}return e}));return}try{await tI({cwd:u,command:i,commandId:d,tabId:r||"",projectCwd:e,env:w,usePty:x,onData:(e,t)=>{if("pid"===e)l(e=>e.map(e=>e.id===d?{...e,pid:t.pid}:e));else if("stdout"===e||"stderr"===e)O(d,t.data);else if("exit"===e){let e=W(d);A(d),l(r=>r.map(r=>r.id===d?{...r,output:e,exitCode:t.code,isRunning:!1,pid:void 0}:r))}},onError:e=>{let t=W(d);A(d),l(r=>r.map(r=>r.id===d?{...r,output:t+`
|
|
19
|
+
Error: ${e}`,exitCode:1,isRunning:!1,pid:void 0}:r))}})}catch(t){let e=W(d);A(d),l(r=>r.map(r=>r.id===d?{...r,output:e+`
|
|
20
|
+
Error: ${t.message}`,exitCode:1,isRunning:!1,pid:void 0}:r))}},[k,u,w,r,e,O,W,A,z,n,_]),V=(0,s.useCallback)(e=>{let t=o.find(t=>t.id===e);t?.isRunning&&t.pid&&tO(t.pid)},[o]),K=(0,s.useCallback)(async t=>{let n=o.find(e=>e.id===t);if(!n)return;n.isRunning&&n.pid&&(tO(n.pid),await new Promise(e=>setTimeout(e,200)));let s=n.command.trim().split(/\s+/),a=s[0],i=n.command;k[a]&&(i=k[a]+(s.length>1?" "+s.slice(1).join(" "):"")),A(t);let c=i!==n.command?`→ ${i}
|
|
21
|
+
`:"";M.current.set(t,c),l(e=>e.map(e=>e.id===t?{...e,output:c,exitCode:void 0,isRunning:!0,pid:void 0}:e));let d=n.usePty||!1,h=R.current.get(t);try{await tI({cwd:n.cwd||u,command:i,commandId:t,tabId:r||"",projectCwd:e,env:w,usePty:d,...d&&h?{cols:h.cols,rows:h.rows}:{},onData:(e,r)=>{if("pid"===e)l(e=>e.map(e=>e.id===t?{...e,pid:r.pid}:e));else if("stdout"===e||"stderr"===e)O(t,r.data);else if("exit"===e){let e=W(t);A(t),l(n=>n.map(n=>n.id===t?{...n,output:e,exitCode:r.code,isRunning:!1,pid:void 0}:n))}},onError:e=>{let r=W(t);A(t),l(n=>n.map(n=>n.id===t?{...n,output:r+`
|
|
22
|
+
Error: ${e}`,exitCode:1,isRunning:!1,pid:void 0}:n))}})}catch(r){let e=W(t);A(t),l(n=>n.map(n=>n.id===t?{...n,output:e+`
|
|
23
|
+
Error: ${r.message}`,exitCode:1,isRunning:!1,pid:void 0}:n))}},[o,k,u,w,r,e,O,W,A]),J=(0,s.useCallback)(async t=>{if(l(e=>e.filter(e=>e.id!==t)),A(t),r)try{await fetch(`/api/terminal/history?cwd=${encodeURIComponent(e)}&tabId=${encodeURIComponent(r)}&commandId=${encodeURIComponent(t)}`,{method:"DELETE"})}catch(e){console.error("Failed to delete command:",e)}},[e,r,A]),X=(0,s.useCallback)((t,n,s)=>{var o;let l=t_(t);if(!l)return;let a=l.parse(n);"cwd"in a&&!a.cwd&&(a.cwd=u);let c={id:(o=l.idPrefix,`${o}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`),_type:t,timestamp:new Date().toISOString(),...a};if(i(e=>[...e,c]),j(c.id),setTimeout(z,100),s){let t=C&&C.length>0?[...C]:D.current.map(e=>e.data.id),n=t.indexOf(s);-1!==n?t.splice(n+1,0,c.id):t.push(c.id),S(t),r&&fetch("/api/terminal/bubble-order",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,tabId:r,order:t})}).catch(()=>{})}if(r){let n=l.toHistory(c);fetch("/api/terminal/history",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,tabId:r,entry:{type:t,id:c.id,timestamp:c.timestamp,...n}})}).catch(e=>console.error(`Failed to save ${t} item:`,e))}},[z,e,r,C]),Y=(0,s.useCallback)(async t=>{let n=a.find(e=>e.id===t);if(i(e=>e.filter(e=>e.id!==t)),j(e=>e===t?null:e),d(e=>{let r=new Set(e);return r.delete(t),r}),n){let e=t_(n._type);e?.onClose?.(n)}r&&fetch(`/api/terminal/history?cwd=${encodeURIComponent(e)}&tabId=${encodeURIComponent(r)}&commandId=${encodeURIComponent(t)}`,{method:"DELETE"}).catch(e=>console.error("Failed to delete plugin item:",e))},[a,e,r]);I.current=X,P.current=q;let Q=(0,s.useCallback)((t,n)=>{r&&fetch("/api/terminal/history",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,tabId:r,id:t,fields:{sleeping:n}})}).catch(()=>{})},[e,r]),G=(0,s.useCallback)(e=>{d(t=>new Set(t).add(e)),Q(e,!0)},[Q]),Z=(0,s.useCallback)(e=>{d(t=>{let r=new Set(t);return r.delete(e),r}),Q(e,!1)},[Q]),ee=(0,s.useCallback)(async t=>{if(S(t),r)try{await fetch("/api/terminal/bubble-order",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,tabId:r,order:t})})}catch{}},[e,r]),et=(0,s.useMemo)(()=>{let e=[...o.map(e=>({type:"command",data:e})),...a.map(e=>({type:e._type,data:e}))];if(!C||0===C.length)return e.sort((e,t)=>new Date(e.data.timestamp).getTime()-new Date(t.data.timestamp).getTime());let t=new Map(C.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,a,C]);D.current=et,(0,s.useEffect)(()=>{$.current=o.filter(e=>!e.isRunning&&e.command.trim()).map(e=>e.command)},[o]);let er=async()=>{try{let t=new URLSearchParams({cwd:e});r&&t.set("tabId",r);let n=await fetch(`/api/terminal/env?${t}`);if(n.ok){let e=await n.json();y(e.env||{})}}catch(e){console.error("Failed to load env:",e)}},en=async()=>{try{let e=await fetch("/api/terminal/aliases");if(e.ok){let t=await e.json();N(t.aliases||{})}}catch(e){console.error("Failed to load aliases:",e)}},es=async()=>{if(r)try{let t=await fetch(`/api/terminal/bubble-order?cwd=${encodeURIComponent(e)}&tabId=${encodeURIComponent(r)}`);if(t.ok){let e=await t.json();e.order&&e.order.length>0&&S(e.order)}}catch{}};return(0,s.useEffect)(()=>{let e={current:!1};return(async()=>{await H(0),e.current||await U(e)})(),er(),en(),es(),()=>{e.current=!0}},[H,U]),(0,s.useEffect)(()=>()=>{null!==L.current&&cancelAnimationFrame(L.current)},[]),(0,s.useEffect)(()=>()=>{tW()},[]),{commands:o,pluginItems:a,sleepingBubbles:c,consoleItems:et,currentCwd:u,selectedCommandId:v,setSelectedCommandId:j,customEnv:w,setCustomEnv:y,aliases:k,setAliases:N,isLoadingHistory:m,hasMoreHistory:f,currentPage:g,scrollRef:B,commandHistoryRef:$,ptySizeRef:R,executeCommandRef:P,executeCommand:q,interruptCommand:V,rerunCommand:K,deleteCommand:J,addPluginItem:X,closePluginItem:Y,handleBubbleSleep:G,handleBubbleWake:Z,loadHistory:H,scrollToBottom:z,saveBubbleOrder:ee,sendStdin:tB,resizePty:tF}}({cwd:e,initialShellCwd:t,tabId:r,onCwdChange:l}),[D,B]=(0,s.useState)(null),[F,O]=(0,s.useState)(0),[A,W]=(0,s.useState)(0),[z,H]=(0,s.useState)(!0),[_,U]=(0,s.useState)(!1),[q,V]=(0,s.useState)(!1),[K,J]=(0,s.useState)(!1),[X,Y]=(0,s.useState)(!1),Q=(0,s.useRef)(null),G=(0,s.useRef)(null),Z=(0,s.useRef)(null),ee=(0,s.useRef)(!1),et=(0,s.useRef)(null),er=(0,s.useRef)(null),en=(0,s.useRef)([]);(0,s.useEffect)(()=>{en.current=c},[c]);let es=(0,s.useCallback)(()=>{let e=d.current;return!e||e.scrollHeight-e.scrollTop-e.clientHeight<50},[d]),eo=(0,s.useCallback)(()=>{let e=d.current;return!e||e.scrollTop<50},[d]),el=(0,s.useCallback)(()=>{J(!eo()),Y(!es())},[es,eo]),ea=(0,s.useCallback)(()=>{G.current?.scrollIntoView({behavior:"smooth"})},[]),ei=async()=>{try{let t=await fetch(`/api/project-settings?cwd=${encodeURIComponent(e)}`);if(t.ok){let e=await t.json();e.settings?.gridLayout!==void 0&&H(e.settings.gridLayout)}}catch(e){console.error("Failed to load project settings:",e)}},ec=async t=>{try{await fetch("/api/project-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,settings:t})})}catch(e){console.error("Failed to save project settings:",e)}};(0,s.useEffect)(()=>{queueMicrotask(()=>ei())},[]);let ed=(0,s.useCallback)(()=>{ee.current=!0},[]),eu=(0,s.useCallback)((e,t)=>{if(!ee.current)return void e.preventDefault();ee.current=!1,et.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:var(--card);border-radius:8px;padding:4px 12px;opacity:0.9;",document.body.appendChild(t),e.dataTransfer.setDragImage(t,20,16),requestAnimationFrame(()=>document.body.removeChild(t))}},[]),eh=(0,s.useCallback)((e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",er.current=t},[]),em=(0,s.useCallback)(e=>{e.preventDefault(),e.currentTarget.classList.add("ring-2","ring-brand")},[]),ex=(0,s.useCallback)(e=>{e.currentTarget.classList.remove("ring-2","ring-brand")},[]),ef=(0,s.useCallback)(e=>{e.preventDefault(),e.currentTarget.classList.remove("ring-2","ring-brand")},[]),ep=(0,s.useCallback)(e=>{e.currentTarget.style.opacity="1";let t=et.current,r=er.current;if(et.current=null,er.current=null,!t||!r||t===r)return;let n=en.current.map(e=>e.data.id),s=n.indexOf(t),o=n.indexOf(r);if(-1===s||-1===o)return;let l=[...n];l[s]=r,l[o]=t,T(l)},[T]),eg=(0,s.useCallback)(e=>{B(t=>t===e?null:e)},[]);(0,s.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"m"===e.key&&!e.shiftKey&&!e.altKey&&(e.preventDefault(),u&&eg(u))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u,eg]),(0,s.useEffect)(()=>{let e=d.current;if(!e)return;let t=new ResizeObserver(([e])=>{W(e.contentRect.height)});return t.observe(e),W(e.clientHeight),()=>t.disconnect()},[d]),(0,s.useEffect)(()=>{let e=d.current;if(e)return D?O(e.clientHeight):(e.style.overflow="",O(0)),()=>{e&&(e.style.overflow="")}},[D,d]),(0,s.useEffect)(()=>{let e=d.current;if(!e||!D||!F)return;let t=requestAnimationFrame(()=>{let t=e.querySelector(`[data-bubble-id="${D}"]`);t&&t.scrollIntoView({block:"start"}),e.style.overflow="hidden"});return()=>cancelAnimationFrame(t)},[D,F,d]),(0,s.useEffect)(()=>{let e=e=>{let t=e.detail?.command;t&&v(t)};return window.addEventListener("execute-terminal-command",e),()=>window.removeEventListener("execute-terminal-command",e)},[v]);let eb=A>0?Math.floor((A-32-12)/2-41):void 0;return(0,n.jsxs)("div",{ref:Q,className:"h-full flex flex-col bg-background relative",children:[(0,n.jsx)("div",{ref:d,onScroll:el,className:`flex-1 overflow-y-auto ${D?"":"py-4 px-4"}`,children:0===c.length?(0,n.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:i("console.enterCommandOrUrl")}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{ref:G}),$&&(0,n.jsx)("div",{className:"flex justify-center mb-4",children:(0,n.jsx)("button",{onClick:()=>R(P+1),disabled:I,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-50",children:i(I?"console.loadingMore":"console.loadMoreHistory")})}),(0,n.jsx)("div",{className:D?"flex flex-col gap-3":z?"grid grid-cols-2 gap-3":"flex flex-col gap-3",children:c.map(t=>{let s={draggable:!0,onDragStart:e=>eu(e,t.data.id),onDragOver:e=>eh(e,t.data.id),onDragEnter:em,onDragLeave:ex,onDrop:ef,onDragEnd:ep};if("command"===t.type){let o=t.data;return(0,n.jsx)("div",{"data-bubble-id":o.id,className:"group/cmd rounded-lg transition-shadow",...s,children:(0,n.jsx)(td,{commandId:o.id,tabId:r,projectCwd:e,command:o.command,output:o.output,exitCode:o.exitCode,isRunning:o.isRunning,selected:u===o.id,onSelect:()=>{h(o.id)},onInterrupt:o.isRunning?()=>m(o.id):void 0,onStdin:o.isRunning?e=>x(o.id,e):void 0,onDelete:()=>{o.isRunning&&o.pid&&tO(o.pid),f(o.id)},onRerun:()=>p(o.id),timestamp:o.timestamp,usePty:o.usePty,onPtyResize:(e,t)=>{g.current.set(o.id,{cols:e,rows:t}),b(o.id,e,t)},onToggleMaximize:()=>eg(o.id),maximized:D===o.id,expandedHeight:F,bubbleContentHeight:eb,onTitleMouseDown:ed})},o.id)}let o=t_(t.type);if(!o)return null;let l=o.Component,a=t.data;return(0,n.jsx)("div",{"data-bubble-id":a.id,className:"rounded-lg transition-shadow",...s,children:(0,n.jsx)(l,{item:a,selected:u===a.id,maximized:D===a.id,expandedHeight:F,bubbleContentHeight:eb,timestamp:a.timestamp,onSelect:()=>{h(a.id)},onClose:()=>w(a.id),onToggleMaximize:()=>eg(a.id),onTitleMouseDown:ed,extra:{addBrowserItem:(e,t)=>j("browser",e,t),initialSleeping:y.has(a.id),onSleep:k,onWake:N}})},a.id)})}),(0,n.jsx)("div",{ref:Z})]})}),!D&&c.length>0&&(0,n.jsx)(rB,{showTop:K,showBottom:X,onScrollTop:ea,onScrollBottom:C}),(0,n.jsx)(rD,{cwd:e,currentCwd:S,commandHistoryRef:L,gridLayout:z,onGridLayoutChange:e=>{H(e),ec({gridLayout:e})},onExecute:v,onAddPluginItem:j,onShowEnvManager:()=>U(!0),onOpenZsh:()=>v("zsh"),onOpenNote:a}),_&&(0,n.jsx)(tm,{cwd:e,tabId:r,onClose:()=>U(!1),onSave:e=>E(e)}),q&&(0,n.jsx)(tf,{onClose:()=>V(!1),onSave:e=>M(e)})]})}var rO=r(24750);let rA="review-last-viewed";function rW(){try{return JSON.parse(localStorage.getItem(rA)||"{}")}catch{return{}}}function rz(e,t){if(!e.lastCommentAt)return!1;let r=t[e.id];return!r||e.lastCommentAt>r}function rH({cwd:e}){let{t}=(0,o.Bd)(),[r,l]=(0,s.useState)(!1),[a,i]=(0,s.useState)([]),[c,d]=(0,s.useState)(!1),[u,h]=(0,s.useState)(null),[m,x]=(0,s.useState)({}),[f,p]=(0,s.useState)({open:!1,comments:[],title:"",userNameMap:{}}),g=(0,s.useRef)(null),b=(0,s.useRef)(null),[v,j]=(0,s.useState)(null);(0,s.useEffect)(()=>{queueMicrotask(()=>x(rW()))},[]),(0,s.useEffect)(()=>{if(!r)return;let e=e=>{g.current&&!g.current.contains(e.target)&&l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]);let w=(0,s.useCallback)(async()=>{d(!0);try{let e=await fetch("/api/review");if(e.ok){let t=await e.json();i(t.reviews||[])}}catch{}d(!1)},[]);(0,s.useEffect)(()=>{r&&queueMicrotask(()=>w())},[r,w]);let y=(0,s.useCallback)(e=>{let{data:t}=e;t?.some(e=>"review"===e.type)&&w()},[w]);(0,eH.h)({url:`/ws/watch?cwd=${encodeURIComponent(e||"/")}`,onMessage:y,enabled:!!e}),(0,s.useEffect)(()=>{queueMicrotask(()=>w())},[w]);let k=(0,s.useMemo)(()=>a.filter(e=>e.active),[a]),N=(0,s.useMemo)(()=>k.some(e=>rz(e,m)),[k,m]),C=(0,s.useCallback)(e=>{let t;(t=rW())[e]=Date.now(),localStorage.setItem(rA,JSON.stringify(t)),x(rW()),window.open(`${window.location.origin}/review/${e}`,"_blank")},[]),S=(0,s.useCallback)(async(e,t)=>{e.stopPropagation();try{let[e,r]=await Promise.all([fetch(`/api/review/${t}`),fetch("/api/review/users")]);if(!e.ok)return;let{review:n}=await e.json(),s={};if(r.ok){let{users:e}=await r.json();for(let[t,r]of Object.entries(e))s[t]=r.name}p({open:!0,comments:n.comments||[],title:n.title,userNameMap:s})}catch{}},[]),L=(0,s.useCallback)((e,t)=>{b.current=t,e.dataTransfer.effectAllowed="move";let r=e.currentTarget;requestAnimationFrame(()=>r.classList.add("opacity-30"))},[]),E=(0,s.useCallback)(e=>{b.current=null,j(null),e.currentTarget instanceof HTMLElement&&e.currentTarget.classList.remove("opacity-30")},[]),M=(0,s.useCallback)((e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",b.current&&b.current!==t&&j(t)},[]),T=(0,s.useCallback)((e,t)=>{e.preventDefault(),j(null);let r=b.current;b.current=null,r&&r!==t&&i(e=>{let n=[...e],s=n.findIndex(e=>e.id===r),o=n.findIndex(e=>e.id===t);if(-1===s||-1===o)return e;let[l]=n.splice(s,1);return n.splice(o,0,l),fetch("/api/review/order",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:n.map(e=>e.id)})}).catch(()=>{}),n})},[]);return(0,n.jsxs)("div",{ref:g,className:"relative",children:[(0,n.jsxs)("button",{onClick:()=>l(e=>!e),className:`relative p-2 rounded-lg transition-colors ${r?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:t("review.reviewManagement"),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 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),N&&(0,n.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 bg-red-500 rounded-full"})]}),r&&(0,n.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-64 bg-popover border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:t("review.allReviews")}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground/60 ml-1.5",children:k.length})]}),(0,n.jsx)("button",{onClick:w,className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",title:t("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)("div",{className:"max-h-80 overflow-y-auto",children:c&&0===a.length?(0,n.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center",children:t("common.loading")}):0===k.length?(0,n.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center",children:t("review.noOpenReviews")}):k.map(e=>{let r,s,o,l,a,i=rz(e,m);return(0,n.jsxs)("div",{draggable:!0,onDragStart:t=>L(t,e.id),onDragEnd:E,onDragOver:t=>M(t,e.id),onDrop:t=>T(t,e.id),onMouseEnter:t=>{let r=t.currentTarget.getBoundingClientRect();h({id:e.id,text:e.title,top:r.top+r.height/2,left:r.left})},onMouseLeave:()=>h(t=>t?.id===e.id?null:t),onClick:()=>C(e.id),className:`group px-3 py-2 cursor-pointer border-b transition-colors ${v===e.id?"border-b-brand border-t border-t-transparent":"border-b-border/50"} hover:bg-accent/30`,children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,n.jsx)("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${i?"bg-red-500":"bg-green-500"}`}),(0,n.jsx)("span",{className:`text-xs truncate flex-1 ${i?"font-medium text-foreground":""}`,children:e.title}),e.commentCount>0&&(0,n.jsx)("button",{onClick:t=>S(t,e.id),className:"flex-shrink-0 p-0.5 rounded text-muted-foreground/0 group-hover:text-muted-foreground/60 hover:!text-brand hover:!bg-brand/10 transition-colors",title:t("review.viewComments"),children:(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{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)("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground/50 mt-0.5 pl-3",children:[(0,n.jsx)("span",{children:(s=String((r=new Date(e.updatedAt||e.createdAt)).getMonth()+1).padStart(2,"0"),o=String(r.getDate()).padStart(2,"0"),l=String(r.getHours()).padStart(2,"0"),a=String(r.getMinutes()).padStart(2,"0"),`${s}-${o} ${l}:${a}`)}),e.commentCount>0&&(0,n.jsx)("span",{children:t("review.nComments",{count:e.commentCount})})]})]},e.id)})})]}),u&&r&&(0,n.jsx)("div",{className:"fixed z-[60] px-2 py-1 text-xs bg-popover text-popover-foreground border border-border rounded shadow-md whitespace-nowrap pointer-events-none",style:{top:u.top,left:u.left-8,transform:"translate(-100%, -50%)"},children:u.text}),(0,n.jsx)(rO._,{isOpen:f.open,onClose:()=>p(e=>({...e,open:!1})),comments:f.comments,reviewTitle:f.title,userNameMap:f.userNameMap})]})}function r_({cwd:e,currentBranch:t,onSwitched:r}){let{t:l}=(0,o.Bd)(),[a,i]=(0,s.useState)(!1),[c,d]=(0,s.useState)([]),[u,h]=(0,s.useState)(!1),[m,x]=(0,s.useState)(!1),[f,p]=(0,s.useState)(""),b=(0,s.useRef)(null),v=(0,s.useRef)(null),j=(0,s.useCallback)(async()=>{h(!0);try{let t=await fetch(`/api/git/branches?cwd=${encodeURIComponent(e)}`);if(t.ok){let e=await t.json(),r=[...e.local||[],...(e.remote||[]).filter(t=>!e.local.includes(t.replace(/^origin\//,"")))];d(r)}}catch{(0,g.oR)(l("toast.loadBranchFailed"),"error")}finally{h(!1)}},[e]),w=(0,s.useCallback)(()=>{i(!0),p(""),j()},[j]),y=(0,s.useCallback)(()=>{i(!1)},[]);(0,s.useEffect)(()=>{if(!a)return;let e=e=>{b.current&&!b.current.contains(e.target)&&y()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a,y]),(0,s.useEffect)(()=>{a&&setTimeout(()=>v.current?.focus(),50)},[a]);let k=async t=>{x(!0);try{let n=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"checkout",cwd:e,path:e,branch:t})});if(n.ok){let e=t.replace(/^origin\//,"");(0,g.oR)(l("toast.switchedToBranch",{branch:e}),"success"),y(),r()}else{let e=await n.json();(0,g.oR)(e.error||l("toast.switchBranchFailed"),"error")}}catch{(0,g.oR)(l("toast.switchBranchFailed"),"error")}finally{x(!1)}},N=c.filter(e=>e!==t&&e.toLowerCase().includes(f.toLowerCase()));return(0,n.jsxs)("div",{className:"relative",ref:b,children:[(0,n.jsx)("button",{onClick:a?y:w,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:l("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-lg z-50 overflow-hidden",children:[(0,n.jsx)("div",{className:"p-2 border-b border-border",children:(0,n.jsx)("input",{ref:v,type:"text",value:f,onChange:e=>p(e.target.value),placeholder:l("git.searchBranch"),className:"w-full px-2.5 py-1.5 text-sm bg-muted rounded border-none outline-none placeholder:text-muted-foreground",onKeyDown:e=>{"Escape"===e.key&&y()}})}),(0,n.jsx)("div",{className:"max-h-60 overflow-y-auto p-1",children:u?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:l("common.loading")}):0===N.length?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:f?l("git.noMatchingBranches"):l("git.noBranches")}):N.map(e=>(0,n.jsx)("button",{onClick:()=>k(e),disabled:m,className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-accent transition-colors truncate disabled:opacity-50",children:(0,n.jsx)("span",{className:e.startsWith("origin/")?"text-muted-foreground":"text-foreground",children:e})},e))})]})]})}function rU({initialCwd:e,activeTab:t,isGitRepo:r,currentBranch:s,onOpenWorktree:l,onOpenProjectSessions:a,onOpenAliasManager:i,onBranchSwitched:c}){let{t:d}=(0,o.Bd)();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:d("tabManagerTopBar.copyPageUrl"),onClick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>{(0,g.oR)(d("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",title:`CWD: ${e}`,children:e}),(0,n.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(e),(0,g.oR)(d("toast.copiedDirPath"))},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:d("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:l,className:"flex items-center gap-1.5 px-2 py-1.5 text-muted-foreground hover:text-foreground hover:bg-accent 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)(r_,{cwd:e,currentBranch:s,onSwitched:()=>c?.()})]})]}),(0,n.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2",children:(0,n.jsx)(e5,{})}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(rH,{cwd:e}),(0,n.jsx)("button",{onClick:()=>window.location.reload(),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:d("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"})})}),e&&(0,n.jsx)("button",{onClick:a,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent 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:async()=>{if(t?.cwd)try{await fetch("/api/open-vscode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t.cwd})})}catch{}},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:d("tabManagerTopBar.openInVSCode"),children:(0,n.jsx)("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M17.583 2.213L12 7.393 6.417 2.213 1 6.17v11.66l5.417 3.957L12 16.607l5.583 5.18L23 17.83V6.17l-5.417-3.957zM6.417 17.83L3 15.33V8.67l3.417-2.5v11.66zm11.166 0V6.17L21 8.67v6.66l-3.417 2.5z"})})}),(0,n.jsx)("button",{onClick:async()=>{if(t?.cwd)try{await fetch("/api/open-cursor",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t.cwd})})}catch{}},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:d("tabManagerTopBar.openInCursor"),children:(0,n.jsx)("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M4.5 2L20.5 12L4.5 22V2Z"})})}),t?.sessionId&&(0,n.jsx)("button",{onClick:()=>{let e=`claude -r ${t.sessionId}`;navigator.clipboard.writeText(e).then(()=>{(0,g.oR)(d("toast.copiedCommand",{command:e}),"success")})},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:d("chat.copyCommandTooltip",{sessionId:t.sessionId}),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:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:d("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:()=>window.parent.postMessage({type:"OPEN_TOKEN_STATS"},"*"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:d("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-accent rounded-lg transition-colors",title:d("tabManagerTopBar.openSurething"),children:(0,n.jsx)("img",{src:"https://surething.io/logo.png?from=cockpit",alt:"Surething",className:"w-5 h-5 rounded-sm"})})]})]})})}function rq({number:e,isActive:t}){return(0,n.jsxs)("svg",{className:`w-5 h-5 flex-shrink-0 ${t?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,n.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:e})]})}function rV({tabs:e,activeTabId:t,unreadTabs:r,dragTabIndex:s,dragOverTabIndex:l,isPinned:a,onTogglePin:i,onSwitchTab:c,onCloseTab:d,onNewTab:u,onDragStart:h,onDragOver:m,onDrop:x,onDragEnd:f}){let{t:p}=(0,o.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((o,u)=>(0,n.jsx)(tw.m,{content:o.title,delay:200,children:(0,n.jsxs)("div",{draggable:!0,onDragStart:()=>h(u),onDragOver:e=>m(e,u),onDrop:()=>x(u),onDragEnd:f,className:`group flex items-center gap-1 px-3 py-1.5 text-sm cursor-pointer rounded-t-lg transition-colors ${o.id===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary"} ${s===u?"opacity-50":""} ${l===u?"border-l-2 border-brand":""}`,onClick:()=>c(o.id),children:[(0,n.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,n.jsx)(rq,{number:u+1,isActive:o.id===t}),o.isLoading&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"}),!o.isLoading&&r.has(o.id)&&o.id!==t&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),i&&a?.(o.id)&&!o.isLoading&&!(r.has(o.id)&&o.id!==t)&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),i(o.id)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center rounded-full bg-card text-amber-500 hover:text-destructive transition-colors",title:p("tabBar.unpin"),children:(0,n.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M16 4h-2V2h-4v2H8c-.55 0-1 .45-1 1v4l-2 3v2h5.97v7l1 1 1-1v-7H19v-2l-2-3V5c0-.55-.45-1-1-1z"})})}),i&&!a?.(o.id)&&!o.isLoading&&!(r.has(o.id)&&o.id!==t)&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),i(o.id)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center rounded-full bg-card text-muted-foreground opacity-0 group-hover:opacity-60 hover:!opacity-100 hover:!text-brand transition-all",title:p("tabBar.pin"),children:(0,n.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,children:(0,n.jsx)("path",{d:"M16 4h-2V2h-4v2H8c-.55 0-1 .45-1 1v4l-2 3v2h5.97v7l1 1 1-1v-7H19v-2l-2-3V5c0-.55-.45-1-1-1z"})})})]}),(0,n.jsx)("span",{className:"max-w-32 truncate",children:o.title}),e.length>1&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),d(o.id)},className:"ml-1 p-0.5 rounded hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title: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"})})})]})},o.id)),(0,n.jsx)("button",{onClick:u,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:p("tabBar.newTab"),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"})})})]})})}var rK=r(44810),rJ=r(12651),rX=r(81165),rY=r(16950),rQ=r(11019),rG=r(12612);function rZ({filePath:e}){let[t,r]=(0,s.useState)(null),[o,l]=(0,s.useState)(!0),[a,i]=(0,s.useState)(null),c=(0,s.useRef)(!1),d=ec(e),u=ei(e);if((0,s.useEffect)(()=>{u?l(!1):c.current||(c.current=!0,(async()=>{l(!0),i(null);try{let t=await fetch(`/api/file?path=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Failed to load file: ${t.statusText}`);let n=await t.json();r(n.content)}catch(e){i(e instanceof Error?e.message:"Unknown error")}finally{l(!1),c.current=!1}})())},[e,u]),a)return(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("div",{className:"text-xs text-red-11",children:a})});if(o)return(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})});if(ei(e)){let t=`/api/file?path=${encodeURIComponent(e)}&raw=true`;return(0,n.jsx)("div",{className:"flex items-center justify-center h-full overflow-auto",children:(0,n.jsx)("img",{src:t,alt:e.split("/").pop()||"image",className:"max-w-full max-h-full object-contain"})})}return t?d?(0,n.jsx)(r1,{content:t}):(0,n.jsx)(eR,{content:t,filePath:e,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}let r0=[eI.W];function r1({content:e}){let t=(0,s.useRef)(null);return(0,n.jsxs)("div",{className:"h-full flex",children:[(0,n.jsx)(eD.l,{content:e,containerRef:t}),(0,n.jsx)("div",{ref:t,className:"flex-1 overflow-auto p-4",children:(0,n.jsx)(eP.T,{content:e,rehypePlugins:r0})})]})}function r2({title:e,content:t,toolName:r,onClose:l}){let{t:a}=(0,o.Bd)(),i=function(e){try{return JSON.parse(e),!0}catch{return!1}}(t),c=function(e){try{let t=JSON.parse(e);if(t&&"string"==typeof t.file_path&&"string"==typeof t.old_string&&"string"==typeof t.new_string)return t}catch{}return null}(t),d=function(e){try{let t=JSON.parse(e);if(t&&"string"==typeof t.file_path)return t.file_path}catch{let t=e.trim();if(t.startsWith("/")&&!t.includes("\n")&&t.length<500)return t}return null}(t),u=!!c,h=!!d,[m,x]=(0,s.useState)(("Read"===r||"Write"===r)&&h?"file":u?"diff-unified":i?"readable":"json"),f=(0,s.useRef)(null),p=eu(f);(0,s.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&"readable"===m&&i){e.preventDefault(),p.open();return}if("Escape"===e.key){if(p.isVisible)return void p.close();document.activeElement instanceof HTMLElement&&document.activeElement.blur(),l()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[l,m,i,p]);let b=(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:l,children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col transition-all",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)("h3",{className:"text-sm font-medium text-foreground",children:e}),d&&(0,n.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(d),(0,g.oR)(a("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:a("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.jsxs)("div",{className:"flex items-center gap-3",children:[i&&(0,n.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[u&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:()=>x("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===m?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:a("diffViewer.sideBySide"),children:"Split"}),(0,n.jsx)("button",{onClick:()=>x("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===m?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:a("diffViewer.unified"),children:"Unified"})]}),h&&(0,n.jsx)("button",{onClick:()=>x("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===m?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:a("diffViewer.previewFile"),children:"File"}),(0,n.jsx)("button",{onClick:()=>x("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===m?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a("common.readable")}),(0,n.jsx)("button",{onClick:()=>x("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===m?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,n.jsx)("button",{onClick:l,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent 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-auto p-4",children:"file"===m&&d?(0,n.jsx)(rZ,{filePath:d}):"diff-unified"===m&&c?(0,n.jsx)(_,{oldContent:c.old_string,newContent:c.new_string,filePath:c.file_path}):"diff-split"===m&&c?(0,n.jsx)(H,{oldContent:c.old_string,newContent:c.new_string,filePath:c.file_path}):"readable"===m&&i?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eh,{search:p}),(0,n.jsx)("pre",{ref:f,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:Z(t)})]}):(0,n.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:i?function(e){try{let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}(t):t})})]})});return(0,n.jsx)(rK.Z,{children:b})}let r5={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D"};function r4({toolCall:e,cwd:t}){let r,{t:l}=(0,o.Bd)(),[a,i]=(0,s.useState)(!1),[c,d]=(0,s.useState)(null),u=r5[e.name]||"\uD83D\uDD27",h=(r=e.input,"Bash"===e.name&&r.command&&"string"==typeof r.command?r.command:"Glob"===e.name&&r.pattern&&"string"==typeof r.pattern||"Grep"===e.name&&r.pattern&&"string"==typeof r.pattern?r.pattern:r.file_path&&"string"==typeof r.file_path?r.file_path:r.path&&"string"==typeof r.path?r.path:null),m="Glob"===e.name||"Grep"===e.name||"Bash"===e.name,x=h?m?h:(e=>{if(t&&e.startsWith(t)){let r=e.slice(t.length);return r.startsWith("/")?r.slice(1):r}let r=e.split("/");return r.length>2?".../"+r.slice(-2).join("/"):e})(h):null,f=t=>{let r="input"===t?l("toolCall.inputParams"):l("toolCall.resultLabel"),n="input"===t?JSON.stringify(e.input,null,2):"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2);d({title:`${e.name}${x?` ${x}`:""} - ${r}`,content:n,toolName:e.name})};return(0,n.jsxs)("div",{className:"my-2 border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,n.jsxs)("button",{onClick:()=>i(!a),className:"w-full px-3 py-2 flex items-center gap-2 text-left hover:bg-accent transition-colors",children:[(0,n.jsx)("span",{className:"text-base",children:u}),(0,n.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:e.name}),x&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:h||"",children:x}),(0,n.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),h&&(navigator.clipboard.writeText(h),(0,g.oR)(l("common.copiedPath")))},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),h&&(navigator.clipboard.writeText(h),(0,g.oR)(l("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0 cursor-pointer",title:l("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.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[a&&!e.isLoading&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),f("input")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),f("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:l("toolCall.inputParamsTitle"),children:l("toolCall.input")}),e.result&&(0,n.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),f("result")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),f("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:l("toolCall.resultTitle"),children:l("toolCall.result")})]}),e.isLoading?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,n.jsx)("span",{className:"text-slate-9 text-xs",children:a?"▲":"▼"})]})]}),a&&(0,n.jsxs)("div",{className:"border-t border-border",children:[(0,n.jsxs)("div",{className:"px-3 py-2",children:[(0,n.jsx)("div",{className:"mb-1",children:(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:[l("toolCall.inputParams"),":"]})}),(0,n.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(e.input,null,2)})]}),e.result&&(0,n.jsxs)("div",{className:"px-3 py-2 border-t border-border",children:[(0,n.jsx)("div",{className:"mb-1",children:(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:[l("toolCall.resultLabel"),":"]})}),(0,n.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2)})]})]}),c&&(0,n.jsx)(r2,{title:c.title,content:c.content,toolName:c.toolName,onClose:()=>d(null)})]})}var r3=r(48368),r6=r(21362);function r8(e,t){if(t&&e.startsWith(t)){let r=e.slice(t.length);return r.startsWith("/")?r.slice(1):r}return e}function r9({node:e,selectedUid:t,onSelect:r,depth:o=0}){let[l,a]=(0,s.useState)(!0);if(e.isFile&&e.change){let s=t===e.change.uid;return(0,n.jsxs)("button",{onClick:()=>r(e.change),className:`w-full flex items-center gap-1.5 px-2 py-1 text-xs text-left rounded transition-colors ${s?"bg-brand/15 text-brand":"text-foreground hover:bg-accent"}`,style:{paddingLeft:`${12*o+8}px`},"data-tooltip":e.fullPath,children:[(0,n.jsx)(r3.A,{className:"w-3.5 h-3.5 flex-shrink-0 opacity-60"}),(0,n.jsx)("span",{className:"truncate",children:e.name}),(0,n.jsx)("span",{className:`ml-auto text-[10px] flex-shrink-0 ${"write"===e.change.type?"text-green-500":"text-yellow-500"}`,children:"write"===e.change.type?"new":"edit"})]})}return(0,n.jsxs)("div",{children:[(0,n.jsxs)("button",{onClick:()=>a(!l),className:"w-full flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors",style:{paddingLeft:`${12*o+8}px`},children:[l?(0,n.jsx)(tt.A,{className:"w-3 h-3"}):(0,n.jsx)(r6.A,{className:"w-3 h-3"}),(0,n.jsx)("span",{className:"truncate",children:e.name})]}),l&&e.children.map((e,s)=>(0,n.jsx)(r9,{node:e,selectedUid:t,onSelect:r,depth:o+1},e.isFile&&e.change?e.change.uid:`${e.fullPath}-${s}`))]})}function r7({toolCalls:e,cwd:t,onClose:r}){let{t:l}=(0,o.Bd)(),a=(0,s.useMemo)(()=>(function(e,t){let r=[],n=0;for(let s of e)if("Edit"===s.name){let e=s.input;e.file_path&&"string"==typeof e.old_string&&"string"==typeof e.new_string&&r.push({filePath:r8(e.file_path,t),uid:`change-${n++}`,type:"edit",old_string:e.old_string,new_string:e.new_string})}else if("Write"===s.name){let e=s.input;e.file_path&&"string"==typeof e.content&&r.push({filePath:r8(e.file_path,t),uid:`change-${n++}`,type:"write",old_string:"",new_string:e.content})}return r})(e,t),[e,t]),i=(0,s.useMemo)(()=>(function e(t){return t.map(t=>{if(!t.isFile&&1===t.children.length&&!t.children[0].isFile){let r=t.children[0];return{...r,name:t.name+"/"+r.name,children:e(r.children)}}return{...t,children:e(t.children)}})})(function(e){let t=[];for(let r of e){let e=r.filePath.split("/").filter(Boolean),n=t;for(let t=0;t<e.length;t++){let s=e[t],o=t===e.length-1,l=e.slice(0,t+1).join("/");if(o){let e={name:s,fullPath:l,isFile:!0,children:[],change:r};n.push(e)}else{let e=n.find(e=>e.name===s&&!e.isFile);e||(e={name:s,fullPath:l,isFile:!1,children:[]},n.push(e)),n=e.children}}}return t}(a)),[a]),[c,d]=(0,s.useState)(a[0]||null),[u,h]=(0,s.useState)("unified"),[m,x]=(0,s.useState)(null),f=(0,s.useRef)(null);if((0,s.useEffect)(()=>{let e=f.current;if(!e)return;let t=t=>{let r=t;for(;r&&r!==e;){if(r.dataset.tooltip)return r.dataset.tooltip;r=r.parentElement}return null},r=e=>{let r=t(e.target);x(r?{text:r,x:e.clientX,y:e.clientY}:null)},n=e=>{x(r=>{if(!r)return null;let n=t(e.target);return n?{text:n,x:e.clientX,y:e.clientY}:null})},s=r=>{let n=r.relatedTarget;n&&e.contains(n)&&t(n)||x(null)};return e.addEventListener("mouseover",r),e.addEventListener("mousemove",n),e.addEventListener("mouseout",s),()=>{e.removeEventListener("mouseover",r),e.removeEventListener("mousemove",n),e.removeEventListener("mouseout",s)}},[]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r]),0===a.length)return null;let p=(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:r,children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col transition-all",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)("div",{className:"flex items-center gap-2",children:(0,n.jsx)("h3",{className:"text-sm font-medium text-foreground",children:l("diffViewer.fileChanges",{count:a.length})})}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[(0,n.jsx)("button",{onClick:()=>h("unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"unified"===u?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Unified"}),(0,n.jsx)("button",{onClick:()=>h("split"),className:`px-2 py-1 text-xs rounded transition-colors ${"split"===u?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Split"})]}),(0,n.jsx)("button",{onClick:r,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)(eJ.A,{className:"w-5 h-5"})})]})]}),(0,n.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,n.jsx)("div",{ref:f,className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto py-2",children:i.map((e,t)=>(0,n.jsx)(r9,{node:e,selectedUid:c?.uid||"",onSelect:d},e.isFile&&e.change?e.change.uid:`${e.fullPath}-${t}`))}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:c?"unified"===u?(0,n.jsx)(_,{oldContent:c.old_string,newContent:c.new_string,filePath:c.filePath}):(0,n.jsx)(H,{oldContent:c.old_string,newContent:c.new_string,filePath:c.filePath,isNew:"write"===c.type}):(0,n.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:l("diffViewer.selectFileToView")})})]})]})});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(rK.Z,{children:p}),m&&(0,n.jsx)(rK.Z,{children:(0,n.jsx)("div",{className:"fixed z-[9999] px-2 py-1 bg-popover text-popover-foreground text-xs font-mono rounded shadow-lg border border-brand whitespace-nowrap pointer-events-none",style:{left:m.x+12,top:m.y+16},children:m.text})})]})}var ne=r(58515),nt=r(36201),nr=r(55804),nn=r(37618);function ns(e){let t=e.input?.questions||[],r=e.input?.answers||{},n={};if(e.result)try{let t=JSON.parse(e.result);t?.answers&&(n=t.answers)}catch{}return{questions:t,answers:{...r,...n}}}function no(e,t){return`${e}-${t}`}function nl({toolCalls:e,onClose:t}){let{t:r}=(0,o.Bd)(),[l,a]=(0,s.useState)({}),[i,c]=(0,s.useState)({}),[d,u]=(0,s.useState)({}),[h,m]=(0,s.useState)({});(0,s.useEffect)(()=>{let t={};e.forEach((e,r)=>{let{questions:n,answers:s}=ns(e);n.forEach((e,n)=>{let o=s[e.question];if(o){let s=no(r,n);t[s]=o,e.options.some(e=>e.label===o)||(c(e=>({...e,[s]:!0})),u(e=>({...e,[s]:o})))}})}),queueMicrotask(()=>a(t))},[e]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&t()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t]);let x=e.reduce((e,t)=>{let{questions:r}=ns(t);return e+r.length},0),f=Object.values(h).filter(Boolean).length,p=(0,s.useCallback)((e,t)=>{a(r=>({...r,[e]:t})),c(t=>({...t,[e]:!1}))},[]),b=(0,s.useCallback)(e=>{c(t=>{let r=!t[e];if(r){let t=d[e]||"";t&&a(r=>({...r,[e]:t}))}return{...t,[e]:r}})},[d]),v=(0,s.useCallback)((e,t)=>{u(r=>({...r,[e]:t})),t&&a(r=>({...r,[e]:t}))},[]),j=(0,s.useCallback)(e=>{m(t=>({...t,[e]:!t[e]}))},[]),w=(0,s.useCallback)(()=>{let t=f>0,n=[];e.forEach((e,s)=>{let{questions:o}=ns(e);o.forEach((e,o)=>{let a=no(s,o);if(t&&!h[a])return;let i=l[a];n.push(`Q: ${e.question}`),n.push(`A: ${i||r("askQuestion.notSelected")}`),n.push("")})}),navigator.clipboard.writeText(n.join("\n").trim()),(0,g.oR)(t?r("toast.copiedQA",{count:f}):r("toast.copiedAllQA"))},[e,l,h,f,r]),y=(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:t,children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] 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 flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r("askQuestion.title")}),(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r("askQuestion.nQuestions",{count:x}),f>0&&` \xb7 ${r("askQuestion.checkedN",{count:f})}`]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:w,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:f>0?r("askQuestion.copyChecked",{count:f}):r("askQuestion.copyAll"),children:(0,n.jsx)(e6.A,{className:"w-4 h-4"})}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)(eJ.A,{className:"w-5 h-5"})})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:e.map((t,s)=>{let{questions:o}=ns(t);return o.map((t,a)=>{let c=no(s,a),u=l[c],m=i[c]||!1,x=h[c]||!1;return(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)("button",{onClick:()=>j(c),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-accent transition-colors",title:r("askQuestion.checkToCopy"),children:x?(0,n.jsx)(ne.A,{className:"w-4 h-4 text-brand"}):(0,n.jsx)(nt.A,{className:"w-4 h-4 text-muted-foreground"})}),t.header&&(0,n.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-brand/10 text-brand flex-shrink-0 mt-0.5",children:t.header}),(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:t.question})]}),(0,n.jsxs)("div",{className:"space-y-1 ml-7",children:[t.options.map((e,t)=>{let r=u===e.label&&!m;return(0,n.jsxs)("button",{onClick:()=>p(c,e.label),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${r?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,n.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:r?(0,n.jsx)(nr.A,{className:"w-3.5 h-3.5 text-brand"}):(0,n.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:`text-sm ${r?"text-foreground font-medium":"text-foreground"}`,children:e.label}),e.description&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:e.description})]})]},t)}),(0,n.jsxs)("button",{onClick:()=>b(c),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${m?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,n.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:m?(0,n.jsx)(nr.A,{className:"w-3.5 h-3.5 text-brand"}):(0,n.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(nn.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:r("askQuestion.custom")})]})]}),m&&(0,n.jsx)("div",{className:"ml-6 mt-1",children:(0,n.jsx)("input",{type:"text",autoFocus:!0,value:d[c]||"",onChange:e=>v(c,e.target.value),placeholder:r("askQuestion.customPlaceholder"),className:"w-full px-3 py-1.5 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-brand text-foreground placeholder:text-muted-foreground"})})]}),(s!==e.length-1||a!==o.length-1)&&(0,n.jsx)("div",{className:"border-b border-border/50 mt-3"})]},c)})})})]})});return(0,n.jsx)(rK.Z,{children:y})}function na({image:e,onClose:t}){let{t:r}=(0,o.Bd)(),s=(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[(0,n.jsx)("button",{onClick:t,className:"absolute top-4 right-4 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",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:`data:${e.media_type};base64,${e.data}`,alt:r("chat.imagePreview"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]});return(0,n.jsx)(rK.Z,{children:s})}function ni({filePath:e,content:t,cwd:r,onClose:o}){let[l,a]=(0,s.useState)(null);return(0,n.jsx)(rK.Z,{children:(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:o,children:(0,n.jsx)("div",{ref:a,className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col relative",onClick:e=>e.stopPropagation(),children:(0,n.jsx)(v,{container:l,children:(0,n.jsx)(eA,{content:t,filePath:e,cwd:r,onClose:o})})})})})}let nc=(0,s.memo)(function({message:e,cwd:t,sessionId:r,onFork:l}){let a,i,c,{t:d}=(0,o.Bd)(),[u,h]=(0,s.useState)(null),[m,x]=(0,s.useState)(!1),[f,p]=(0,s.useState)(!1),[b,v]=(0,s.useState)(!1),j="user"===e.role,w=e.images&&e.images.length>0,y=e.toolCalls?.length||0,k=y>1,N=!!r&&!!t&&!!l,C=(0,s.useMemo)(()=>e.toolCalls?.some(e=>"Edit"===e.name||"Write"===e.name)||!1,[e.toolCalls]),S=(0,s.useMemo)(()=>{if(!e.toolCalls)return null;for(let t=e.toolCalls.length-1;t>=0;t--)if("TodoWrite"===e.toolCalls[t].name)return e.toolCalls[t];return null},[e.toolCalls]),L=(0,s.useMemo)(()=>e.toolCalls?e.toolCalls.filter(e=>"AskUserQuestion"===e.name):[],[e.toolCalls]),E=(0,s.useMemo)(()=>{if(!e.toolCalls)return[];let t=new Set,r=[];for(let n of e.toolCalls)if("Read"===n.name||"Edit"===n.name||"Write"===n.name){let e=n.input.file_path;e&&e.toLowerCase().endsWith(".md")&&!t.has(e)&&(t.add(e),r.push(e))}return r},[e.toolCalls]),[M,T]=(0,s.useState)(null),[$,R]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!M)return void queueMicrotask(()=>R(null));let e=!1;return fetch(`/api/file?path=${encodeURIComponent(M)}`).then(e=>e.ok?e.json():Promise.reject()).then(t=>{e||R(t.content)}).catch(()=>{e||((0,g.oR)(d("toast.readFileFailed"),"error"),T(null))}),()=>{e=!0}},[M]);let P=()=>{e.content&&(navigator.clipboard.writeText(e.content),(0,g.oR)(d("toast.copiedMessage")))},I=()=>{N&&l(e.id)},D=(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}`})(e.timestamp);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:`flex flex-col ${j?"items-end":"items-start"} mb-4 group`,"data-role":e.role,children:[D&&(0,n.jsx)("span",{className:"text-[11px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity mb-0.5 px-1",children:D}),(0,n.jsxs)("div",{className:`flex ${j?"justify-end":"justify-start"} w-full`,children:[j&&(0,n.jsxs)("div",{className:"self-start mt-2 mr-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.content&&(0,n.jsx)("button",{onClick:P,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:d("chat.copyMessage"),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 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"})})}),N&&(0,n.jsx)("button",{onClick:I,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:d("chat.forkSession"),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)("circle",{cx:"12",cy:"18",r:"3"}),(0,n.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,n.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,n.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,n.jsx)("path",{d:"M12 12v3"})]})})]}),(0,n.jsxs)("div",{className:`max-w-[80%] ${j?"bg-accent text-foreground border border-brand rounded-2xl rounded-br-md":"bg-accent text-foreground dark:text-slate-11 rounded-2xl rounded-bl-md"} px-4 py-2`,children:[w&&(0,n.jsx)("div",{className:`flex flex-wrap gap-2 ${e.content?"mb-2":""}`,children:e.images.map((e,t)=>(0,n.jsx)("div",{className:"relative w-16 h-16 rounded-lg overflow-hidden border border-white/20 cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>h(e),children:(0,n.jsx)("img",{src:`data:${e.media_type};base64,${e.data}`,alt:d("chat.imageN",{index:t+1}),className:"w-full h-full object-cover"})},t))}),e.content&&(0,n.jsxs)("div",{className:"break-words",children:[(0,n.jsx)(eP.T,{content:e.content,isUser:j,isStreaming:e.isStreaming}),e.isStreaming&&(0,n.jsx)("span",{className:"inline-block w-2 h-4 ml-1 bg-current animate-pulse"})]}),S&&(i=(a=S.input?.todos||[]).filter(e=>"completed"===e.status).length,c=a.length,(0,n.jsx)("div",{className:`${e.content||w?"mt-2":""}`,children:(0,n.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50 px-3 py-2 space-y-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,n.jsx)("div",{className:"flex-1 h-1 bg-secondary rounded-full overflow-hidden",children:(0,n.jsx)("div",{className:"h-full bg-green-500 rounded-full transition-all duration-300",style:{width:`${c>0?i/c*100:0}%`}})}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[i,"/",c]})]}),a.map((e,t)=>(0,n.jsxs)("div",{className:`flex items-center gap-1.5 ${"completed"===e.status?"opacity-50":""}`,children:["completed"===e.status?(0,n.jsx)(rJ.A,{className:"w-3 h-3 text-green-500 flex-shrink-0"}):"in_progress"===e.status?(0,n.jsx)(rX.A,{className:"w-3 h-3 text-brand flex-shrink-0 animate-spin"}):(0,n.jsx)(rY.A,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),(0,n.jsx)("span",{className:`text-xs truncate ${"completed"===e.status?"text-muted-foreground":"text-foreground"}`,children:"in_progress"===e.status&&e.activeForm?e.activeForm:e.content})]},t))]})})),E.length>0&&(0,n.jsx)("div",{className:`${e.content||w||S?"mt-2":""}`,children:(0,n.jsx)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary/50 px-3 py-2 space-y-0.5",children:E.map(e=>(0,n.jsxs)("button",{onClick:()=>T(e),className:"flex items-center gap-1.5 w-full text-left hover:bg-accent rounded px-1 py-0.5 transition-colors group/md",children:[(0,n.jsx)("svg",{className:"w-3.5 h-3.5 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:"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:"text-xs text-muted-foreground group-hover/md:text-foreground truncate",children:e.split("/").pop()})]},e))})}),e.toolCalls&&e.toolCalls.length>0&&(0,n.jsx)("div",{className:`${e.content||w?"mt-2":""}`,children:k?(0,n.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsxs)("button",{onClick:()=>x(!m),className:"flex-1 px-3 py-2 flex items-center gap-2 text-left hover:bg-accent transition-colors active:bg-muted",children:[(0,n.jsx)("span",{className:"text-lg",children:"\uD83D\uDD27"}),(0,n.jsx)("span",{className:"font-medium text-foreground",children:d("chat.toolCalls",{count:y})}),(0,n.jsx)("span",{className:"ml-auto text-muted-foreground text-sm",children:m?d("chat.collapse"):d("chat.expand")})]}),L.length>0&&(0,n.jsx)("button",{onClick:()=>v(!0),className:"px-3 py-2 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l border-border",title:d("chat.viewQuestions"),children:(0,n.jsx)(rQ.A,{className:"w-4 h-4"})}),C&&(0,n.jsx)("button",{onClick:()=>p(!0),className:"px-3 py-2 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l border-border",title:d("chat.viewAllFileChanges"),children:(0,n.jsx)(rG.A,{className:"w-4 h-4"})})]}),m&&(0,n.jsx)("div",{className:"border-t border-border p-2 space-y-1",children:e.toolCalls.map((e,r)=>(0,n.jsx)(r4,{toolCall:e,cwd:t},`${e.id}-${r}`))})]}):e.toolCalls.map((e,r)=>(0,n.jsx)(r4,{toolCall:e,cwd:t},`${e.id}-${r}`))})]}),!j&&(0,n.jsxs)("div",{className:"self-start mt-2 ml-1 flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.content&&(0,n.jsx)("button",{onClick:P,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:d("chat.copyMessage"),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 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"})})}),N&&(0,n.jsx)("button",{onClick:I,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent",title:d("chat.forkSession"),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)("circle",{cx:"12",cy:"18",r:"3"}),(0,n.jsx)("circle",{cx:"6",cy:"6",r:"3"}),(0,n.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,n.jsx)("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),(0,n.jsx)("path",{d:"M12 12v3"})]})})]})]})]}),u&&(0,n.jsx)(na,{image:u,onClose:()=>h(null)}),f&&e.toolCalls&&(0,n.jsx)(r7,{toolCalls:e.toolCalls,cwd:t,onClose:()=>p(!1)}),b&&L.length>0&&(0,n.jsx)(nl,{toolCalls:L,onClose:()=>v(!1)}),M&&null!==$&&(0,n.jsx)(ni,{filePath:M,content:$,cwd:t||"",onClose:()=>T(null)})]})}),nd=(0,s.forwardRef)(function({messages:e,isLoading:t,cwd:r,sessionId:l,hasMoreHistory:a,isLoadingMore:i,onLoadMore:c,onFork:d,isActive:u=!0,onContentSearch:g},b){let{t:v}=(0,o.Bd)(),j=(0,s.useRef)(null),w=(0,s.useRef)(null),y=(0,s.useRef)(null),k=(0,s.useRef)(null),[N,E]=(0,s.useState)(null),[M,T]=(0,s.useState)(!0),[$,R]=(0,s.useState)(!1),[P,I]=(0,s.useState)(!1);(0,s.useEffect)(()=>{E(k.current)},[]);let{isSearchVisible:D,searchQuery:B,setSearchQuery:F,matches:O,currentMatchIndex:W,goToNextMatch:z,goToPrevMatch:H,closeSearch:_,searchInputRef:U,handleSearchKeyDown:q}=function(e){let[t,r]=(0,s.useState)(!1),[n,o]=(0,s.useState)(""),[l,a]=(0,s.useState)([]),[i,c]=(0,s.useState)(0),d=(0,s.useRef)(null),u=(0,s.useRef)([]),h=(0,s.useCallback)(()=>{let t=e.current;t&&(t.querySelectorAll("mark.chat-search-match, mark.chat-search-current").forEach(e=>{let t=e.parentNode;t&&(t.replaceChild(document.createTextNode(e.textContent||""),e),t.normalize())}),u.current=[])},[e]),m=(0,s.useCallback)(t=>{if(h(),!t||!e.current){a([]),c(0);return}let r=[],n=[],s=t.toLowerCase();e.current.querySelectorAll("[data-message-id]").forEach(e=>{let o,l=e.getAttribute("data-message-id")||"",a=0,i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),c=[];for(;o=i.nextNode();)c.push(o);for(let e of c){let o=(e.textContent||"").toLowerCase(),i=0,c=[];for(;;){let e=o.indexOf(s,i);if(-1===e)break;c.push({start:e,end:e+t.length}),i=e+1}if(0!==c.length)for(let t=c.length-1;t>=0;t--){let s=c[t];e.splitText(s.end);let o=e.splitText(s.start),i=document.createElement("mark");i.className="chat-search-match",i.textContent=o.textContent,o.parentNode.replaceChild(i,o),r.push({messageId:l,markIndex:a}),n.push(i),a++}}}),r.reverse(),n.reverse(),u.current=n,a(r),c(r.length>0?0:-1)},[e,h]);(0,s.useEffect)(()=>{queueMicrotask(()=>m(n))},[n,m]),(0,s.useEffect)(()=>{let e=u.current;e.forEach((e,t)=>{e.className=t===i?"chat-search-current":"chat-search-match"}),i>=0&&i<e.length&&e[i].scrollIntoView({behavior:"smooth",block:"center"})},[i,l]);let x=(0,s.useCallback)(()=>{0!==l.length&&c(e=>(e+1)%l.length)},[l.length]),f=(0,s.useCallback)(()=>{0!==l.length&&c(e=>(e-1+l.length)%l.length)},[l.length]),p=(0,s.useCallback)(()=>{r(!0),setTimeout(()=>d.current?.focus(),0)},[]),g=(0,s.useCallback)(()=>{r(!1),o(""),h(),a([]),c(0)},[h]),b=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?f():x()),"Escape"===e.key&&g()},[x,f,g]);return(0,s.useEffect)(()=>{let t=e.current;if(!t)return;let r=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),e.stopPropagation(),p())};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)},[e,p]),{isSearchVisible:t,searchQuery:n,setSearchQuery:o,matches:l,currentMatchIndex:i,goToNextMatch:x,goToPrevMatch:f,openSearch:p,closeSearch:g,searchInputRef:d,handleSearchKeyDown:b}}(k),V=C(),K=(0,s.useRef)(null),J=(0,s.useRef)(()=>{}),{addComment:X,refresh:Y}=p({cwd:r||"",filePath:x}),[Q,G]=(0,s.useState)(null),[Z,ee]=(0,s.useState)(null),et=(0,s.useCallback)(e=>{if(Q||Z)return;let t=window.getSelection();if(!t||t.isCollapsed||!t.rangeCount){K.current=null,J.current();return}let r=t.toString().trim();if(!r){K.current=null,J.current();return}let n=t.anchorNode instanceof HTMLElement?t.anchorNode:t.anchorNode?.parentElement;if(n?.closest('[data-role="user"]')){K.current=null,J.current();return}K.current={x:e.clientX,y:e.clientY,range:{start:0,end:0},selectedText:r},J.current()},[Q,Z]),er=(0,s.useCallback)(e=>{let t=e.target;!(t.closest(".floating-toolbar")||t.closest('[class*="z-[200]"]'))&&K.current&&(K.current=null,J.current())},[]),en=(0,s.useCallback)(()=>{let e=K.current;e&&(G({x:e.x,y:e.y,text:e.selectedText}),K.current=null,J.current(),window.getSelection()?.removeAllRanges())},[]),es=(0,s.useCallback)(()=>{let e=K.current;e&&(ee({x:e.x,y:e.y,text:e.selectedText}),K.current=null,J.current(),window.getSelection()?.removeAllRanges())},[]),eo=(0,s.useCallback)(()=>{let e=K.current;if(!e||!g)return;let t=e.selectedText.trim();K.current=null,J.current(),window.getSelection()?.removeAllRanges(),t&&g(t)},[g]),el=(0,s.useCallback)(async e=>{Q&&(await X(0,0,e,Q.text),G(null))},[Q,X]),ea=(0,s.useCallback)(async e=>{if(Z&&V&&r)try{let t=(await h(r)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));t.push({filePath:x,startLine:0,endLine:0,codeContent:Z.text});let n=f(t,e);V.sendMessage(n),await m(r),Y(),ee(null)}catch(e){console.error("Failed to send to AI:",e)}},[Z,V,r,Y]),ei=(0,s.useMemo)(()=>{let t=new Set;return e.filter(e=>!t.has(e.id)&&(t.add(e.id),!0))},[e]),ec=(0,s.useRef)(0),ed=(0,s.useRef)(!1),eu=(0,s.useCallback)(()=>{let e=y.current;return!e||e.scrollHeight-e.scrollTop-e.clientHeight<50},[]),eh=(0,s.useCallback)(()=>{let e=y.current;return!e||e.scrollTop<50},[]),em=(0,s.useCallback)(()=>{let e=eu(),t=eh();if(T(e),R(!t),I(!e),t&&a&&!i&&c){let e=y.current;e&&(ec.current=e.scrollHeight,ed.current=!0),c()}},[eu,eh,a,i,c]),ex=(0,s.useCallback)(()=>{w.current?.scrollIntoView({behavior:"smooth"})},[]),ef=(0,s.useCallback)(()=>{j.current?.scrollIntoView({behavior:"smooth"})},[]),ep=(0,s.useCallback)(e=>{let t=y.current;if(!t)return;let r=t.querySelector(`[data-message-id="${e}"]`);r&&(r.scrollIntoView({behavior:"smooth",block:"center"}),r.classList.add("ring-2","ring-brand","ring-offset-2"),setTimeout(()=>{r.classList.remove("ring-2","ring-brand","ring-offset-2")},2e3))},[]);(0,s.useImperativeHandle)(b,()=>({scrollToMessage:ep}),[ep]);let eg=(0,s.useRef)(0),eb=(0,s.useRef)(!0);(0,s.useEffect)(()=>{let t=eg.current,r=e.length;eg.current=r,!eb.current&&M&&r>t&&j.current?.scrollIntoView({behavior:"smooth"})},[e,M]),(0,s.useEffect)(()=>{M&&t&&j.current?.scrollIntoView({behavior:"smooth"})},[t,M]),(0,s.useEffect)(()=>{if(ed.current&&!i){let e=y.current;if(e){let t=e.scrollHeight-ec.current;e.scrollTop=t,ed.current=!1}}},[e,i]);let ev=(0,s.useRef)(!1);return(0,s.useEffect)(()=>{u&&ev.current&&e.length>0&&(ev.current=!1,j.current?.scrollIntoView({behavior:"instant"}))},[u,e.length]),(0,s.useEffect)(()=>{eb.current&&e.length>0&&(eb.current=!1,u?j.current?.scrollIntoView({behavior:"instant"}):ev.current=!0)},[e.length,u]),(0,n.jsxs)("div",{ref:k,className:"relative flex-1 min-h-0 overflow-hidden flex flex-col outline-none",tabIndex:-1,onMouseUp:et,onMouseDown:er,children:[D&&(0,n.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border",children:[(0,n.jsx)("input",{ref:U,type:"text",value:B,onChange:e=>F(e.target.value),onKeyDown:q,placeholder:v("codeViewer.searchChat"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:O.length>0?`${W+1}/${O.length}`:v("common.noMatch")}),(0,n.jsx)("button",{onClick:H,disabled:0===O.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:v("codeViewer.prevShiftEnter"),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"})})}),(0,n.jsx)("button",{onClick:z,disabled:0===O.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:v("codeViewer.nextEnter"),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"})})}),(0,n.jsx)("button",{onClick:_,className:"p-1 rounded hover:bg-accent",title:v("codeViewer.closeEsc"),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)("div",{ref:y,onScroll:em,className:"relative flex-1 min-h-0 overflow-y-auto p-4",children:0!==e.length||t?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{ref:w}),a&&(0,n.jsx)("div",{className:"flex justify-center py-3",children:i?(0,n.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",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.jsx)("span",{children:v("chat.loadMoreHistory")})]}):(0,n.jsx)("button",{onClick:c,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:v("chat.scrollUpForMore")})}),ei.map(e=>(0,n.jsx)("div",{"data-message-id":e.id,className:"transition-[box-shadow] duration-300",children:(0,n.jsx)(nc,{message:e,cwd:r,sessionId:l,onFork:d})},e.id)),t&&(0,n.jsx)("div",{className:"flex justify-start mb-4",children:(0,n.jsx)("div",{className:"bg-accent rounded-2xl rounded-bl-md px-4 py-3",children:(0,n.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,n.jsx)("span",{className:"inline-block w-5 h-5 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,n.jsx)("span",{className:"text-sm",children:v("chat.claudeThinking")})]})})}),(0,n.jsx)("div",{ref:j})]}):(0,n.jsx)("div",{className:"flex items-center justify-center h-full text-slate-9",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("div",{className:"text-4xl mb-4",children:"\uD83D\uDCAC"}),(0,n.jsx)("div",{children:v("chat.startConversation")})]})})}),$&&e.length>0&&(0,n.jsx)("button",{onClick:ex,className:"absolute top-2 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-md rounded-full transition-all hover:shadow-lg active:scale-95",title:v("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"})})}),P&&e.length>0&&(0,n.jsx)("button",{onClick:ef,className:"absolute bottom-2 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-md rounded-full transition-all hover:shadow-lg active:scale-95",title:v("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"})})}),N&&(0,n.jsx)(A,{floatingToolbarRef:K,bumpRef:J,container:N,onAddComment:en,onSendToAI:es,onSearch:g?eo:void 0,isChatLoading:V?.isLoading}),Q&&N&&(0,n.jsx)(S,{x:Q.x,y:Q.y,range:{start:0,end:0},codeContent:Q.text,container:N,onSubmit:el,onClose:()=>G(null)}),Z&&N&&(0,n.jsx)(L,{x:Z.x,y:Z.y,range:{start:0,end:0},codeContent:Z.text,container:N,onSubmit:ea,onClose:()=>ee(null),isChatLoading:V?.isLoading})]})});function nu({image:e,onClose:t}){let{t:r}=(0,o.Bd)(),s=(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:t,children:(0,n.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,n.jsx)("img",{src:e.preview,alt:r("imagePreview.previewImage"),className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:e=>e.stopPropagation()}),(0,n.jsx)("button",{onClick:t,className:"absolute -top-3 -right-3 w-8 h-8 bg-card text-foreground hover:text-foreground rounded-full shadow-lg flex items-center justify-center 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"})})})]})});return(0,n.jsx)(rK.Z,{children:s})}function nh({images:e,onRemove:t,disabled:r}){let{t:l}=(0,o.Bd)(),[a,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 bg-secondary 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:l("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:l("imagePreview.deleteImage"),children:"✕"})]},e.id))}),a&&(0,n.jsx)(nu,{image:a,onClose:()=>i(null)})]})}var nm=r(28147);let nx=(0,s.memo)(function({onSend:e,disabled:t,cwd:r,onShowGitStatus:l,onShowComments:a,onShowUserMessages:i,onOpenNote:c,onCreateScheduledTask:d}){let{t:u}=(0,o.Bd)(),[h,m]=(0,s.useState)(""),[x,f]=(0,s.useState)([]),[p,b]=(0,s.useState)([]),[v,j]=(0,s.useState)(!1),[w,y]=(0,s.useState)(0),[k,N]=(0,s.useState)(!1),C=(0,s.useRef)(null),S=(0,s.useRef)(null),L=(0,s.useCallback)(()=>{let e=C.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)(()=>{L()},[h,L]),(0,s.useEffect)(()=>{(async()=>{try{let e=r?`/api/commands?cwd=${encodeURIComponent(r)}`:"/api/commands",t=await fetch(e);if(t.ok){let e=await t.json();b(e)}}catch(e){console.error("Failed to load commands:",e)}})()},[r]);let E=(0,s.useMemo)(()=>{if(!h.startsWith("/"))return[];let e=h.toLowerCase();return p.filter(t=>t.name.toLowerCase().startsWith(e))},[h,p]),M=!k&&h.startsWith("/")&&E.length>0,T=(0,s.useRef)(h);(0,s.useLayoutEffect)(()=>{T.current!==h&&(queueMicrotask(()=>y(0)),k&&queueMicrotask(()=>N(!1)),T.current=h)},[h,k]),(0,s.useLayoutEffect)(()=>{if(M&&S.current){let e=S.current.children[w];e&&e.scrollIntoView({block:"nearest"})}},[w,M]);let $=(0,s.useCallback)(()=>{let r=h.trim();(r||x.length>0)&&!t&&(e(r,x.length>0?x:void 0),m(""),f([]),C.current&&(C.current.style.height="auto"))},[h,x,t,e]),R=(0,s.useCallback)(e=>{m(e.name+" "),C.current?.focus()},[]),P=(0,s.useCallback)(e=>{if(!e.nativeEvent.isComposing){if(M&&E.length>0){if("ArrowDown"===e.key){e.preventDefault(),y(e=>(e+1)%E.length);return}if("ArrowUp"===e.key){e.preventDefault(),y(e=>(e-1+E.length)%E.length);return}if("Enter"===e.key){e.preventDefault(),R(E[w]);return}if("Escape"===e.key){e.preventDefault(),N(!0);return}if("Tab"===e.key){e.preventDefault(),R(E[w]);return}}"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),$())}},[M,E,w,R,$]),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(u("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};f(e=>[...e,s])},s.readAsDataURL(r)}}},[u]),D=(0,s.useCallback)(e=>{f(t=>t.filter(t=>t.id!==e))},[]);return(0,n.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,n.jsx)(nh,{images:x,onRemove:D,disabled:t}),M&&E.length>0&&(0,n.jsx)("div",{ref:S,className:"absolute bottom-full left-0 right-0 mx-4 mb-2 max-h-64 overflow-y-auto bg-card border border-border rounded-lg shadow-lg",children:E.map((e,t)=>(0,n.jsxs)("div",{onClick:()=>R(e),className:`flex items-center gap-3 px-4 py-2 cursor-pointer ${t===w?"bg-brand/10":"hover:bg-accent"}`,children:[(0,n.jsx)("span",{className:"font-mono text-sm font-medium text-foreground",children:e.name}),(0,n.jsx)("span",{className:"flex-1 text-sm text-muted-foreground truncate",children: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"global":return"bg-green-9/15 text-green-11 dark:bg-green-9/25 dark:text-green-11";case"project":return"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25 dark:text-amber-11"}})(e.source)}`,children:(e=>{switch(e){case"builtin":return u("common.builtin");case"global":return u("common.global");case"project":return u("common.project")}})(e.source)})]},e.name))}),(0,n.jsxs)("div",{className:"flex gap-2 items-end p-4",children:[(0,n.jsx)("button",{onClick:async()=>{try{(await fetch("/api/git/stage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:r,files:["."]})})).ok?((0,g.oR)(u("toast.stagedAllFiles"),"success"),window.dispatchEvent(new CustomEvent("git-status-changed"))):(0,g.oR)(u("toast.stageFailed"),"error")}catch(e){console.error("Error staging files:",e),(0,g.oR)(u("toast.stageFailed"),"error")}},className:"p-2 text-green-11 hover:text-green-10 hover:bg-green-9/10 active:bg-green-9/20 active:scale-95 rounded-lg transition-all",title:u("chat.stageAll"),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:"M12 4v16m8-8H4"})})}),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:u("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"})]})}),a&&(0,n.jsx)("button",{onClick:a,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:u("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"})})}),i&&(0,n.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:u("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-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:u("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"})})}),d&&(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("button",{onClick:()=>j(!v),className:`p-2 rounded-lg transition-all ${v?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95"}`,title:u("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"})]})}),v&&(0,n.jsx)(nm.E,{onClose:()=>j(!1),onCreate:d})]}),(0,n.jsx)("textarea",{ref:C,value:h,onChange:e=>m(e.target.value),onKeyDown:P,onPaste:I,placeholder:t?u("chat.placeholderDisabled"):u("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 placeholder-slate-9"})]})]})});var nf=r(97440),np=r(31914);function ng(e){if(0===e.length)return"";let t=[c.A.t("comments.codeRef"),""],r=e.filter(e=>e.filePath===x),n=e.filter(e=>e.filePath!==x);for(let e of(n.length>0&&n.forEach((e,r)=>{t.push(`[${r+1}] ${e.filePath}:${e.startLine}-${e.endLine}`),t.push("```"),t.push(e.codeContent),t.push("```"),e.content&&t.push(c.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 nb({isOpen:e,onClose:t,cwd:r,onNavigateToComment:l}){let{t:a}=(0,o.Bd)(),[i,c]=(0,s.useState)([]),[d,f]=(0,s.useState)(!1),[p,b]=(0,s.useState)(null),[v,j]=(0,s.useState)(!1),w=(0,s.useCallback)(async()=>{if(r){f(!0);try{let e=await fetch(`/api/comments?cwd=${encodeURIComponent(r)}&all=true`);if(e.ok){let t=await e.json();c(t.comments||[])}}catch(e){console.error("Failed to load comments:",e)}finally{f(!1)}}},[r]);(0,s.useEffect)(()=>{e&&w()},[e,w]);let y=async e=>{try{(await fetch(`/api/comments?cwd=${encodeURIComponent(r)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&(c(t=>t.filter(t=>t.id!==e)),u())}catch(e){console.error("Failed to delete comment:",e)}},k=async e=>{b(e.id);try{let t="";if(e.selectedText)t=e.selectedText;else{let n=await fetch(`/api/files/read?cwd=${encodeURIComponent(r)}&path=${encodeURIComponent(e.filePath)}`);if(!n.ok)throw Error("Failed to read file");t=((await n.json()).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=ng([n]);await navigator.clipboard.writeText(s),(0,g.oR)(a("toast.copiedComment"))}catch(e){console.error("Failed to copy comment:",e)}finally{b(null)}},N=async()=>{if(0!==i.length){j(!0);try{let e=await h(r),t=ng(e);await navigator.clipboard.writeText(t),(0,g.oR)(a("toast.copiedAllComments"))}catch(e){console.error("Failed to copy all comments:",e)}finally{j(!1)}}},C=i.reduce((e,t)=>(e[t.filePath]||(e[t.filePath]=[]),e[t.filePath].push(t),e),{});if(!e)return null;let S=(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 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-xl 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 bg-secondary",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:a("comments.allComments")}),i.length>0&&(0,n.jsx)("button",{onClick:N,disabled:v,className:"p-1 rounded hover:bg-accent text-muted-foreground disabled:opacity-50",title:a("comments.copyAllComments"),children:v?(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-accent 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:d?(0,n.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:a("common.loading")}):0===i.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:a("comments.noComments")})]}):(0,n.jsx)("div",{className:"space-y-4",children:Object.entries(C).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 bg-secondary border-b border-border",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-foreground font-mono",children:e===x?a("comments.aiReply"):e}),(0,n.jsxs)("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",a("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-accent/50 cursor-pointer group",onClick:()=>l?.(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:[a("common.line")," ",e.startLine===e.endLine?e.startLine:`${e.startLine}-${e.endLine}`]}),(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",a("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:a("comments.noContent")})})]}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),k(e)},disabled:p===e.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-accent text-muted-foreground transition-opacity disabled:opacity-50",title:a("common.copy"),children:p===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-accent text-muted-foreground hover:text-red-9 transition-opacity",title:a("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 bg-secondary flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:a("comments.totalComments",{count:i.length})}),(0,n.jsx)("button",{onClick:async()=>{0===i.length||await m(r)&&c([])},disabled:0===i.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:a("comments.clearAll")})]})]})});return(0,n.jsx)(rK.Z,{children:S})}function nv({isOpen:e,onClose:t,messages:r,onSelectMessage:l}){let{t:a}=(0,o.Bd)();if((0,s.useEffect)(()=>{if(!e)return;let r=e=>{"Escape"===e.key&&t()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t]),!e)return null;let i=r.filter(e=>"user"===e.role),c=(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:t,children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-lg max-h-[70vh] 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.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a("userMessages.title")}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent 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",children:0===i.length?(0,n.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:a("userMessages.noMessages")}):(0,n.jsx)("div",{className:"divide-y divide-border",children:i.map((e,r)=>{let s,o,a,i=(s=e.id.match(/^user-(\d+)/))?parseInt(s[1],10):null,c=i?(o=new Date(i),a=new Date,o.toDateString()===a.toDateString()?o.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):o.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})):"";return(0,n.jsx)("button",{onClick:()=>{l(e.id),t()},className:"w-full px-4 py-3 text-left hover:bg-accent 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:[r+1,"."]}),(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)("p",{className:"text-sm text-foreground break-words",children:function(e,t=50){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:r.slice(0,t)+"..."}(e.content)})}),c&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground shrink-0 pt-0.5",children:c})]})},e.id)})})})]})});return(0,n.jsx)(rK.Z,{children:c})}function nj({cwd:e,sessionId:t,onOpenProjectSessions:r,onOpenSessionBrowser:l,onOpenSettings:a}){let{t:i}=(0,o.Bd)(),[c,d]=(0,s.useState)(!1);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",title:`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:r,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:i("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-accent rounded-lg transition-colors",title:i("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"})})}),t&&(0,n.jsx)("button",{onClick:()=>{let e=`claude -r ${t}`;navigator.clipboard.writeText(e).then(()=>{d(!0),setTimeout(()=>d(!1),2e3)})},className:`p-2 rounded-lg transition-colors ${c?"text-green-500 bg-green-500/10":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:c?i("chat.copiedCommandTooltip"):i("chat.copyCommandTooltip",{sessionId:t}),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:a,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:i("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 nw({tokenUsage:e}){let{t}=(0,o.Bd)();return(0,n.jsx)("div",{className:"px-4 py-1.5 border-t border-border bg-secondary",children:(0,n.jsxs)("div",{className:"flex items-center justify-end gap-4 text-xs text-muted-foreground",children:[(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:[t("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:[t("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 ny({tabId:e,initialCwd:t,initialSessionId:r,hideHeader:a,hideSidebar:i,isActive:d=!0,onLoadingChange:u,onSessionIdChange:h,onTitleChange:m,onShowGitStatus:x,onOpenNote:f,onCreateScheduledTask:p,onOpenSession:g,onContentSearch:b}){let{t:v}=(0,o.Bd)(),j=C(),[w,y]=(0,s.useState)([]),[k,N]=(0,s.useState)(null),[S,L]=(0,s.useState)(!1),[E,M]=(0,s.useState)(!1),[T,$]=(0,s.useState)(!1),[R,P]=(0,s.useState)(!1),[I,D]=(0,s.useState)(!1),[B,F]=(0,s.useState)(!1),[O,A]=(0,s.useState)(null),W=(0,s.useRef)(null),z=(0,s.useRef)(null),H=(0,s.useCallback)(async e=>{if(t)try{let r=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t,sessionId:e})});if(r.ok){let e=await r.json();e.title&&m?.(e.title)}}catch(e){console.error("Failed to fetch session title:",e)}},[t,m]),{isLoading:_,tokenUsage:U,handleSend:q,handleStop:V}=function(e,t,{sessionId:r,cwd:n,onSessionId:o,onFetchTitle:l}){let[a,i]=(0,s.useState)(!1),[d,u]=(0,s.useState)(null),h=(0,s.useRef)(null),m=(0,s.useRef)(r);m.current=r;let x=(0,s.useRef)(null),f=(0,s.useRef)(null),p=(0,s.useCallback)(()=>{let e=x.current;if(e&&e.text){let{messageId:r,text:n}=e;t(e=>e.map(e=>e.id===r?{...e,content:(e.content||"")+n}:e)),x.current={messageId:r,text:""}}f.current=null},[t]),g=(0,s.useCallback)(()=>{h.current&&(h.current.abort(),h.current=null)},[]),b=(0,s.useCallback)((e,r)=>{let s=e.type;if("system"===s&&"init"===e.subtype){let t=e.session_id;o(t),m.current=t;return}if("stream_event"===s){let t=e.event;if(t?.type==="content_block_delta"&&t.delta?.type==="text_delta"){let e=t.delta.text||"";x.current&&x.current.messageId===r?x.current.text+=e:x.current={messageId:r,text:e},f.current||(f.current=setTimeout(p,50))}return}if("assistant"===s){let n=e.message;if(n?.content){for(let e of n.content)if("name"in e&&e.name){let n={id:e.id||`tool-${Date.now()}`,name:e.name,input:e.input||{},isLoading:!0};t(e=>e.map(e=>e.id!==r||e.toolCalls?.some(e=>e.id===n.id)?e:{...e,toolCalls:[...e.toolCalls||[],n]}))}}}if("user"===s){let n=e.message;if(n?.content){for(let e of n.content)if("tool_use_id"in e&&e.tool_use_id){let n=e.tool_use_id,s="string"==typeof e.content?e.content:JSON.stringify(e.content);t(e=>e.map(e=>e.id===r?{...e,toolCalls:e.toolCalls?.map(e=>e.id===n?{...e,result:s,isLoading:!1}:e)}:e))}}}if("result"===s){f.current&&(clearTimeout(f.current),f.current=null),p();let s=m.current;s&&n&&t(e=>(2===e.length&&l(s),e));let o=e.usage,a=e.total_cost_usd;o&&u({inputTokens:o.input_tokens||0,outputTokens:o.output_tokens||0,cacheCreationInputTokens:o.cache_creation_input_tokens||0,cacheReadInputTokens:o.cache_read_input_tokens||0,totalCostUsd:a||0}),t(e=>e.map(e=>e.id===r?{...e,isStreaming:!1,toolCalls:e.toolCalls?.map(e=>({...e,isLoading:!1}))}:e))}},[t,p,o,l,n]);return{isLoading:a,tokenUsage:d,handleSend:(0,s.useCallback)(async(e,r)=>{let s=r?.map(e=>({type:"base64",media_type:e.media_type,data:e.data})),o={id:`user-${Date.now()}`,role:"user",content:e,images:s};t(e=>[...e,o]),i(!0);let l=`assistant-${Date.now()}`,a={id:l,role:"assistant",content:"",toolCalls:[],isStreaming:!0};t(e=>[...e,a]),h.current=new AbortController;try{let t=await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,sessionId:m.current,images:s,cwd:n}),signal:h.current.signal});if(!t.ok)throw Error(c.A.t("chat.requestFailed"));let r=t.body?.getReader();if(!r)throw Error(c.A.t("chat.cannotReadStream"));let o=new TextDecoder,a="";for(;;){let{done:e,value:t}=await r.read();if(e)break;let n=(a+=o.decode(t,{stream:!0})).split("\n");for(let e of(a=n.pop()||"",n))if(e.startsWith("data: ")){let t=e.slice(6);if("[DONE]"===t)continue;try{let e=JSON.parse(t);b(e,l)}catch{}}}}catch(e){e instanceof Error&&"AbortError"===e.name||(console.error("Chat error:",e),t(e=>e.map(e=>e.id===l?{...e,content:c.A.t("chat.errorRetry"),isStreaming:!1}:e)))}finally{h.current=null,i(!1),t(e=>e.map(e=>e.id===l?{...e,isStreaming:!1}:e))}},[n,t,b]),handleStop:g,abortControllerRef:h}}(0,y,{sessionId:k,cwd:t,onSessionId:N,onFetchTitle:H}),K=(0,s.useCallback)(async(e,r)=>{let n=e.split("\n")[0];if(n.startsWith("!")&&n.length>1){let s=n.slice(1).trim();if(!s)return void q(e,r);let o=e.split("\n").slice(1).join("\n").trim();try{let e=await fetch("/api/bash",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:s,cwd:t})}),n=await e.json(),l=[n.stdout,n.stderr].filter(Boolean).join("\n")||"(no output)",a=n.exitCode?` (exit code: ${n.exitCode})`:"",i=v("chat.executedCommand",{command:s,exitInfo:a,output:l});o&&(i+=`
|
|
24
|
+
|
|
25
|
+
${o}`),q(i,r)}catch(e){q(v("chat.executedCommandFailed",{command:s,error:e}),r)}return}q(e,r)},[q,t,v]),{isLoadingHistory:J,isLoadingMore:X,hasMoreHistory:Y,loadMoreHistory:Q,loadHistoryByCwdAndSessionId:G}=function(e,t,r,{cwd:n,initialSessionId:o,onSessionId:l,onTitleChange:a,onTokenUsage:i}){let[c,d]=(0,s.useState)(!1),[u,h]=(0,s.useState)(!1),[m,x]=(0,s.useState)(!1),[f,p]=(0,s.useState)(void 0),[g,b]=(0,s.useState)(0),v=(0,s.useRef)(a);v.current=a;let j=(0,s.useRef)(i);j.current=i;let w=(0,s.useRef)(void 0),y=(0,s.useRef)(0),k=(0,s.useCallback)(async(e,r,n=!1,s,o)=>{if(n){let e=Date.now();if(e-y.current<5e3)return;y.current=e}n||d(!0);try{let a={cwd:e,sessionId:r,limit:s,beforeTurnIndex:o};n&&w.current&&(a.ifFingerprint=w.current);let i=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(i.ok){let e=await i.json();if(e.notModified)return;e.fingerprint&&(w.current=e.fingerprint),void 0!==e.totalTurns&&b(e.totalTurns),void 0!==e.hasMore&&x(e.hasMore),e.messages&&e.messages.length>0&&(n?t(t=>{let r=e.messages;if(t.length===r.length&&t.length>0&&t[t.length-1].content===r[r.length-1].content)return t;let n=0;for(let e=0;e<Math.min(t.length,r.length)&&t[e].id===r[e].id&&t[e].content===r[e].content;e++)n=e+1;return n===t.length&&n<r.length?[...t,...r.slice(n)]:r}):t(e.messages)),e.sessionId&&l(e.sessionId),e.title&&v.current?.(e.title),e.usage&&j.current?.({inputTokens:e.usage.input_tokens||0,outputTokens:e.usage.output_tokens||0,cacheCreationInputTokens:e.usage.cache_creation_input_tokens||0,cacheReadInputTokens:e.usage.cache_read_input_tokens||0,totalCostUsd:0})}}catch(e){console.error("Failed to load history by cwd and sessionId:",e)}finally{n||d(!1)}},[t,l]),N=(0,s.useCallback)(async()=>{if(n&&r&&!u&&m){h(!0);try{let s=void 0!==f?f:g-Math.ceil(e.filter(e=>"user"===e.role).length),o=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:n,sessionId:r,limit:10,beforeTurnIndex:s>0?s:void 0})});if(o.ok){let e=await o.json();if(e.messages&&e.messages.length>0){t(t=>[...e.messages,...t]);let r=e.messages.filter(e=>"user"===e.role).length;p(s-r)}void 0!==e.hasMore&&x(e.hasMore),e.fingerprint&&(w.current=e.fingerprint)}}catch(e){console.error("Failed to load more history:",e)}finally{h(!1)}}},[n,r,u,m,f,g,e,t]),C=(0,s.useCallback)(async e=>{d(!0);try{let r=await fetch(`/api/session/${e}/history`);if(r.ok){let e=await r.json();e.messages&&e.messages.length>0&&t(e.messages)}}catch(e){console.error("Failed to load history:",e)}finally{d(!1)}},[t]);return(0,s.useEffect)(()=>{n&&o&&k(n,o,!1,10)},[]),{isLoadingHistory:c,isLoadingMore:u,hasMoreHistory:m,loadMoreHistory:N,loadHistory:C,loadHistoryByCwdAndSessionId:k}}(w,y,k,{cwd:t,initialSessionId:r,onSessionId:N,onTitleChange:m,onTokenUsage:A}),Z=(0,s.useRef)(d);(0,s.useEffect)(()=>{d&&!Z.current&&k&&t&&!_&&G(t,k,!0,10),Z.current=d},[d,k,t,_,G]);let ee=U||O;(0,s.useEffect)(()=>{k&&h?.(k)},[k,h]);let et=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(u?.(_),et.current&&!_&&t&&k){let e;for(let t=w.length-1;t>=0;t--)if("user"===w[t].role&&w[t].content){e=w[t].content.slice(0,100);break}window.parent.postMessage({type:"SESSION_COMPLETE",cwd:t,sessionId:k,lastUserMessage:e},"*")}et.current=_},[_,u,t]),(0,s.useEffect)(()=>{d&&j?.setIsLoading(_)},[_,d,j]),(0,s.useEffect)(()=>{if(e&&j)return j.registerChat(e=>{z.current?.(e)},e),()=>{j.unregisterChat(e)}},[e,j]),(0,s.useEffect)(()=>{e&&d&&j&&j.setActiveTab(e)},[e,d,j]),(0,s.useEffect)(()=>{z.current=K},[K]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&S&&_&&V()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[S,_,V]);let er=(0,s.useCallback)(async e=>{if(t&&k)try{let r=await fetch(`/api/session/${k}/fork`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t,fromMessageUuid:e})});if(r.ok){let e=await r.json();g?g(e.newSessionId,"Fork"):window.parent.postMessage({type:"OPEN_PROJECT",cwd:t,sessionId:e.newSessionId},"*")}else console.error("Fork failed:",await r.text())}catch(e){console.error("Fork error:",e)}},[t,k,g]),en=(0,s.useCallback)(()=>{D(!0)},[]),es=(0,s.useCallback)(()=>{F(!0)},[]),eo=(0,s.useMemo)(()=>{if(p&&t&&e&&k)return r=>{p({...r,cwd:t,tabId:e,sessionId:k})}},[p,t,e,k]);return(0,n.jsxs)("div",{className:`flex ${a&&i?"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:()=>L(!0),onMouseLeave:()=>L(!1),children:[!a&&(0,n.jsx)(nj,{cwd:t,sessionId:k,onOpenProjectSessions:()=>$(!0),onOpenSessionBrowser:()=>M(!0),onOpenSettings:()=>P(!0)}),J?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("span",{className:"text-muted-foreground",children:v("sessions.loadingHistory")})}):(0,n.jsx)(nd,{ref:W,messages:w,isLoading:_,cwd:t,sessionId:k,hasMoreHistory:Y,isLoadingMore:X,onLoadMore:Q,onFork:er,isActive:d,onContentSearch:b}),ee&&(0,n.jsx)(nw,{tokenUsage:ee}),(0,n.jsx)(nx,{onSend:K,disabled:_,cwd:t,onShowGitStatus:x,onShowComments:t?en:void 0,onShowUserMessages:es,onOpenNote:f,onCreateScheduledTask:eo})]}),!a&&(0,n.jsx)(nf.r,{isOpen:E,onClose:()=>M(!1)}),!a&&t&&(0,n.jsx)(l,{isOpen:T,onClose:()=>$(!1),cwd:t}),!a&&(0,n.jsx)(np.b,{isOpen:R,onClose:()=>P(!1)}),t&&(0,n.jsx)(nb,{isOpen:I,onClose:()=>D(!1),cwd:t}),(0,n.jsx)(nv,{isOpen:B,onClose:()=>F(!1),messages:w,onSelectMessage:e=>{W.current?.scrollToMessage(e)}})]})}function nk({tabId:e,cwd:t,sessionId:r,isActive:o,onStateChange:l,onShowGitStatus:a,onOpenNote:i,onCreateScheduledTask:c,onOpenSession:d,onContentSearch:u}){let h=(0,s.useCallback)(t=>{l(e,{isLoading:t})},[e,l]),m=(0,s.useCallback)(t=>{l(e,{sessionId:t})},[e,l]),x=(0,s.useCallback)(t=>{l(e,{title:t})},[e,l]);return(0,n.jsx)(ny,{tabId:e,initialCwd:t,initialSessionId:r,hideHeader:!0,hideSidebar:!0,isActive:o,onLoadingChange:h,onSessionIdChange:m,onTitleChange:x,onShowGitStatus:a,onOpenNote:i,onCreateScheduledTask:c,onOpenSession:d,onContentSearch:u})}var nN=r(36998),nC=r(18658);function nS({initialCwd:e,initialSessionId:t}){let{t:r}=(0,o.Bd)(),[a,i]=(0,s.useState)("agent"),{tabs:c,activeTabId:d,activeTab:u,unreadTabs:h,dragTabIndex:m,dragOverTabIndex:x,closeTab:f,switchTab:p,handleSelectSession:g,handleNewTab:b,handleOpenSession:v,updateTabState:j,handleTabDragStart:w,handleTabDragOver:y,handleTabDrop:k,handleTabDragEnd:C}=function({initialCwd:e,initialSessionId:t,activeView:r}){let n=(0,s.useRef)(!1),o=(0,s.useRef)(!0),l=(0,s.useRef)(r);(0,s.useEffect)(()=>{l.current=r},[r]);let a=e_(),i=(0,s.useRef)(a);(0,s.useEffect)(()=>{i.current=a},[a]);let[c,d]=(0,s.useState)(()=>[{id:`tab-${Date.now()}`,cwd:e,title:"New Chat"}]),[u,h]=(0,s.useState)(c[0].id),[m,x]=(0,s.useState)(new Set),f=(0,s.useRef)(c);(0,s.useEffect)(()=>{f.current=c},[c]);let p=(0,s.useCallback)((t,r)=>{e&&t&&fetch("/api/global-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,sessionId:t,status:r})}).catch(()=>{})},[e]),[g,b]=(0,s.useState)(null),[v,j]=(0,s.useState)(null);(0,s.useEffect)(()=>{!e||n.current||(n.current=!0,(async()=>{try{let r=await fetch(`/api/project-state?cwd=${encodeURIComponent(e)}`);if(r.ok){let n=await r.json(),s=n.sessions||[],l=n.activeSessionId,a=[...s];if(t&&!a.includes(t)&&(a=[t,...a]),a.length>0){let r=a.map((t,r)=>({id:`tab-${Date.now()}-${r}`,cwd:e,sessionId:t,title:`Session ${t.slice(0,6)}...`})),n=t||l,s=n?a.indexOf(n):-1;s<0&&(s=0);let i=r[s].id;d(r),h(i),setTimeout(()=>{o.current=!1},0)}else o.current=!1}}catch(e){console.error("Failed to load sessions:",e),o.current=!1}})())},[e,t]),(0,s.useEffect)(()=>{if(o.current||!e)return;let t=c.map(e=>e.sessionId).filter(e=>!!e),r=c.find(e=>e.id===u);fetch("/api/project-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,sessions:t,activeSessionId:r?.sessionId})}).catch(e=>{console.error("Failed to save sessions:",e)})},[c,u,e]),(0,s.useEffect)(()=>{if(o.current||!e)return;let t=c.find(e=>e.id===u);t?.sessionId&&window.parent.postMessage({type:"SESSION_CHANGE",cwd:e,sessionId:t.sessionId},"*")},[u,c,e]);let w=(0,s.useCallback)((e,t,r)=>{let n={id:`tab-${Date.now()}`,cwd:e,sessionId:t,title:r||(t?`Session ${t.slice(0,6)}...`:"New Chat")};d(e=>{let t=e.findIndex(e=>e.id===u);if(-1===t)return[...e,n];let r=[...e];return r.splice(t+1,0,n),r}),h(n.id)},[u]),y=(0,s.useCallback)(t=>{d(r=>{let n=r.filter(e=>e.id!==t);if(t===u&&n.length>0&&h(n[n.length-1].id),0===n.length){let t={id:`tab-${Date.now()}`,cwd:e,title:"New Chat"};return h(t.id),[t]}return n})},[u,e]),k=(0,s.useCallback)((t,r)=>{let n=c.find(e=>e.sessionId===t);n?h(n.id):w(e,t,r)},[c,e,w]),N=(0,s.useCallback)(()=>{w(e)},[e,w]),C=(0,s.useCallback)((t,r)=>{w(e,t,r)},[e,w]),S=(0,s.useCallback)((e,t)=>{d(r=>{let n=r.find(t=>t.id===e);if(n?.isLoading&&!1===t.isLoading){let r=!l.current||"agent"===l.current;if(e===u&&r&&i.current){let e=n.sessionId||t.sessionId;e&&p(e,"normal")}else x(t=>new Set(t).add(e))}return r.map(r=>r.id===e?{...r,...t}:r)})},[u,p]);(0,s.useEffect)(()=>{(!r||"agent"===r)&&a&&x(e=>{if(!e.has(u))return e;let t=new Set(e);t.delete(u);let r=f.current.find(e=>e.id===u);return r?.sessionId&&p(r.sessionId,"normal"),t})},[r,u,a,p]);let L=(0,s.useCallback)(e=>{h(e),x(t=>{if(!t.has(e))return t;let r=new Set(t);r.delete(e);let n=f.current.find(t=>t.id===e);return n?.sessionId&&p(n.sessionId,"normal"),r})},[p]),E=(0,s.useCallback)(e=>{b(e)},[]),M=(0,s.useCallback)((e,t)=>{e.preventDefault(),null!==g&&g!==t&&j(t)},[g]),T=(0,s.useCallback)(e=>{null!==g&&g!==e&&d(t=>{let r=[...t],[n]=r.splice(g,1);return r.splice(e,0,n),r}),b(null),j(null)},[g]),$=(0,s.useCallback)(()=>{b(null),j(null)},[]),R=c.find(e=>e.id===u);return{tabs:c,activeTabId:u,activeTab:R,unreadTabs:m,dragTabIndex:g,dragOverTabIndex:v,addTab:w,closeTab:y,switchTab:L,handleSelectSession:k,handleNewTab:N,handleOpenSession:C,updateTabState:S,handleTabDragStart:E,handleTabDragOver:M,handleTabDrop:T,handleTabDragEnd:$}}({initialCwd:e,initialSessionId:t,activeView:a}),{isPinned:S,pinSession:L,unpinSession:E}=(0,nN.P)(),{createTask:M}=(0,nC.n)(),T=(0,s.useCallback)(e=>{let t=c.find(t=>t.id===e);return!!t?.sessionId&&S(t.sessionId)},[c,S]),$=(0,s.useCallback)(t=>{let r=c.find(e=>e.id===t);r?.sessionId&&(S(r.sessionId)?E(r.sessionId):L(r.sessionId,r.cwd||e||"",r.title))},[c,S,L,E,e]),[R,P]=(0,s.useState)(!1),[I,D]=(0,s.useState)(!1),[B,F]=(0,s.useState)(!1),[O,A]=(0,s.useState)(null),[W,z]=(0,s.useState)(!1),[H,_]=(0,s.useState)("tree"),[U,q]=(0,s.useState)(0),[V,K]=(0,s.useState)(null),[J,X]=(0,s.useState)(0);(0,s.useEffect)(()=>{e&&fetch(`/api/project-settings?cwd=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e?.settings?.activeView&&i(e.settings.activeView)}).catch(()=>{})},[e]);let[Y,Q]=(0,s.useState)(!1),G=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=e=>{let{active:t}=e.detail;t?(G.current=a,i("console"),Q(!0)):(Q(!1),G.current&&"console"!==G.current&&i(G.current),G.current=null)};return window.addEventListener("cockpit-screenshot-state",e),()=>window.removeEventListener("cockpit-screenshot-state",e)},[a]);let Z=(0,s.useCallback)(t=>{i(t),e&&(fetch("/api/project-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,settings:{activeView:t}})}).catch(()=>{}),window.parent.postMessage({type:"VIEW_CHANGE",cwd:e,view:t},"*"))},[e]),ee=(0,s.useCallback)(async()=>{if(e)try{let t=await fetch(`/api/git/worktree?cwd=${encodeURIComponent(e)}`);if(t.ok){let r=await t.json();if(z(r.isGitRepo),r.isGitRepo&&r.worktrees.length>0){let t=r.worktrees.find(t=>t.path===e);t&&A(t.branch)}}}catch(e){console.error("Failed to load git info:",e)}},[e]);(0,s.useEffect)(()=>{queueMicrotask(()=>ee())},[ee]);let et=(0,s.useCallback)(e=>{let{data:t}=e;t?.some(e=>"git"===e.type)&&ee()},[ee]);(0,eH.h)({url:`/ws/watch?cwd=${encodeURIComponent(e||"")}`,onMessage:et,enabled:!!e}),(0,s.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&("1"===e.key?(e.preventDefault(),Z("agent")):"2"===e.key?(e.preventDefault(),Z("explorer")):"3"===e.key&&(e.preventDefault(),Z("console")))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),(0,s.useEffect)(()=>{let t=t=>{if(t.data?.type==="SWITCH_SESSION"){let{sessionId:r,switchToAgent:n}=t.data;if(r){g(r),n&&Z("agent");let t=c.find(e=>e.sessionId===r);e&&!t?.isLoading&&fetch("/api/global-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,sessionId:r,status:"normal"})}).catch(()=>{})}}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[g,Z,e,c]);let er=(0,s.useCallback)(()=>{_("status"),q(e=>e+1),Z("explorer")},[Z]),en=(0,s.useCallback)(e=>{K(e),X(e=>e+1),Z("explorer")},[Z]),es=(0,s.useCallback)(()=>{e&&window.parent.postMessage({type:"OPEN_NOTE",cwd:e},"*")},[e]);return(0,n.jsx)(N,{children:(0,n.jsx)(e1,{activeView:a,onViewChange:Z,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)(rU,{initialCwd:e,activeTab:u,isGitRepo:W,currentBranch:O,onOpenWorktree:()=>D(!0),onOpenProjectSessions:()=>P(!0),onOpenAliasManager:()=>F(!0),onBranchSwitched:ee}),Y&&(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:"●"}),r("console.screenshotting")]}),e?(0,n.jsxs)(e2,{children:[(0,n.jsxs)("div",{className:"w-1/3 h-full flex flex-col overflow-hidden",children:[(0,n.jsx)(rV,{tabs:c,activeTabId:d,unreadTabs:h,dragTabIndex:m,dragOverTabIndex:x,isPinned:T,onTogglePin:$,onSwitchTab:p,onCloseTab:f,onNewTab:b,onDragStart:w,onDragOver:y,onDrop:k,onDragEnd:C}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden relative",children:c.map(e=>(0,n.jsx)("div",{className:`h-full ${e.id===d?"block":"hidden"}`,children:(0,n.jsx)(nk,{tabId:e.id,cwd:e.cwd,sessionId:e.sessionId,isActive:e.id===d&&"agent"===a,onStateChange:j,onShowGitStatus:er,onContentSearch:en,onOpenNote:es,onCreateScheduledTask:M,onOpenSession:v})},e.id))})]}),(0,n.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,n.jsx)(e4,{onClose:()=>Z("agent"),cwd:e,initialTab:H,tabSwitchTrigger:U,initialSearchQuery:V,searchQueryTrigger:J})}),(0,n.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,n.jsx)(rF,{cwd:e,tabId:"default",onOpenNote:es})})]}):(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,n.jsx)(rV,{tabs:c,activeTabId:d,unreadTabs:h,dragTabIndex:m,dragOverTabIndex:x,isPinned:T,onTogglePin:$,onSwitchTab:p,onCloseTab:f,onNewTab:b,onDragStart:w,onDragOver:y,onDrop:k,onDragEnd:C}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden relative",children:c.map(e=>(0,n.jsx)("div",{className:`h-full ${e.id===d?"block":"hidden"}`,children:(0,n.jsx)(nk,{tabId:e.id,cwd:e.cwd,sessionId:e.sessionId,isActive:e.id===d,onStateChange:j,onCreateScheduledTask:M,onOpenSession:v})},e.id))})]})]}),e&&(0,n.jsx)(l,{isOpen:R,onClose:()=>P(!1),cwd:e,onSelectSession:g}),e&&W&&(0,n.jsx)(e3,{isOpen:I,onClose:()=>D(!1),cwd:e}),B&&(0,n.jsx)(tf,{onClose:()=>F(!1),onSave:()=>F(!1)})]})})})}}},e=>{e.O(0,[8653,7330,9114,305,2072,3530,5493,1593,8441,3794,7358],()=>e(e.s=60499)),_N_E=e.O()}]);
|