@surething/cockpit 1.1.10 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next-prod/BUILD_ID +1 -1
- package/.next-prod/app-path-routes-manifest.json +4 -2
- package/.next-prod/build-manifest.json +2 -2
- package/.next-prod/cockpit-build.json +1 -1
- package/.next-prod/prerender-manifest.json +3 -3
- package/.next-prod/routes-manifest.json +12 -0
- package/.next-prod/server/app/_global-error/page.js +2 -2
- package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/_global-error.html +1 -1
- package/.next-prod/server/app/_global-error.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found/page.js +1 -1
- package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/agent/test/route.js +1 -1
- package/.next-prod/server/app/api/bash/route.js +1 -1
- package/.next-prod/server/app/api/bots/[id]/route.js +1 -1
- package/.next-prod/server/app/api/bots/files/route.js +1 -1
- package/.next-prod/server/app/api/bots/route.js +1 -1
- package/.next-prod/server/app/api/chat/codex/route.js +1 -1
- package/.next-prod/server/app/api/chat/deepseek/route.js +1 -1
- package/.next-prod/server/app/api/chat/glm/route.js +1 -1
- package/.next-prod/server/app/api/chat/grok/route.js +1 -1
- package/.next-prod/server/app/api/chat/kimi/route.js +1 -1
- package/.next-prod/server/app/api/chat/ollama/route.js +1 -1
- package/.next-prod/server/app/api/chat/route.js +1 -1
- package/.next-prod/server/app/api/chat/stop/route.js +1 -1
- package/.next-prod/server/app/api/claude-stats/route.js +1 -1
- package/.next-prod/server/app/api/commands/route.js +1 -1
- package/.next-prod/server/app/api/comments/route.js +1 -1
- package/.next-prod/server/app/api/db/columns/route.js +1 -1
- package/.next-prod/server/app/api/db/connect/route.js +1 -1
- package/.next-prod/server/app/api/db/disconnect/route.js +1 -1
- package/.next-prod/server/app/api/db/export/route.js +1 -1
- package/.next-prod/server/app/api/db/query/route.js +1 -1
- package/.next-prod/server/app/api/db/schemas/route.js +2 -2
- package/.next-prod/server/app/api/deepseek/balance/route.js +1 -1
- package/.next-prod/server/app/api/deepseek/credentials/route.js +1 -1
- package/.next-prod/server/app/api/deepseek/models/route.js +1 -1
- package/.next-prod/server/app/api/dev/spans/route.js +1 -1
- package/.next-prod/server/app/api/extension/version/route.js +1 -1
- package/.next-prod/server/app/api/file/route.js +1 -1
- package/.next-prod/server/app/api/files/blame/route.js +1 -1
- package/.next-prod/server/app/api/files/clipboard/route.js +1 -1
- package/.next-prod/server/app/api/files/copy/route.js +1 -1
- package/.next-prod/server/app/api/files/delete/route.js +1 -1
- package/.next-prod/server/app/api/files/expanded/route.js +1 -1
- package/.next-prod/server/app/api/files/index/route.js +1 -1
- package/.next-prod/server/app/api/files/init/route.js +1 -1
- package/.next-prod/server/app/api/files/paste/route.js +1 -1
- package/.next-prod/server/app/api/files/read/route.js +1 -1
- package/.next-prod/server/app/api/files/readdir/route.js +1 -1
- package/.next-prod/server/app/api/files/recent/route.js +1 -1
- package/.next-prod/server/app/api/files/save/route.js +1 -1
- package/.next-prod/server/app/api/files/search/route.js +1 -1
- package/.next-prod/server/app/api/files/stat/route.js +1 -1
- package/.next-prod/server/app/api/files/text/route.js +1 -1
- package/.next-prod/server/app/api/fs/dirs/route.js +1 -1
- package/.next-prod/server/app/api/git/blob/route.js +1 -1
- package/.next-prod/server/app/api/git/branch-diff/route.js +1 -1
- package/.next-prod/server/app/api/git/branches/route.js +1 -1
- package/.next-prod/server/app/api/git/commit-diff/route.js +1 -1
- package/.next-prod/server/app/api/git/commits/route.js +1 -1
- package/.next-prod/server/app/api/git/current-branch/route.js +1 -1
- package/.next-prod/server/app/api/git/diff/route.js +1 -1
- package/.next-prod/server/app/api/git/discard/route.js +1 -1
- package/.next-prod/server/app/api/git/stage/route.js +1 -1
- package/.next-prod/server/app/api/git/status/route.js +1 -1
- package/.next-prod/server/app/api/git/unstage/route.js +1 -1
- package/.next-prod/server/app/api/git/worktree/route.js +1 -1
- package/.next-prod/server/app/api/glm/credentials/route.js +1 -1
- package/.next-prod/server/app/api/glm/models/route.js +1 -1
- package/.next-prod/server/app/api/glm/usage/route.js +1 -1
- package/.next-prod/server/app/api/global-state/route.js +2 -2
- package/.next-prod/server/app/api/grok/models/route.js +1 -1
- package/.next-prod/server/app/api/health/route.js +1 -1
- package/.next-prod/server/app/api/html-apps/[id]/route.js +1 -1
- package/.next-prod/server/app/api/html-apps/files/route.js +1 -1
- package/.next-prod/server/app/api/html-apps/route.js +1 -1
- package/.next-prod/server/app/api/instructions/config/route.js +1 -1
- package/.next-prod/server/app/api/kimi/credentials/route.js +1 -1
- package/.next-prod/server/app/api/kimi/models/route.js +1 -1
- package/.next-prod/server/app/api/kimi/usage/route.js +1 -1
- package/.next-prod/server/app/api/lsp/definition/route.js +1 -1
- package/.next-prod/server/app/api/lsp/hover/route.js +1 -1
- package/.next-prod/server/app/api/lsp/references/route.js +1 -1
- package/.next-prod/server/app/api/lsp/status/route.js +1 -1
- package/.next-prod/server/app/api/lsp/warmup/route.js +1 -1
- package/.next-prod/server/app/api/mobile-link/route.js +1 -1
- package/.next-prod/server/app/api/mysql/columns/route.js +2 -2
- package/.next-prod/server/app/api/mysql/connect/route.js +1 -1
- package/.next-prod/server/app/api/mysql/disconnect/route.js +1 -1
- package/.next-prod/server/app/api/mysql/export/route.js +1 -1
- package/.next-prod/server/app/api/mysql/query/route.js +1 -1
- package/.next-prod/server/app/api/mysql/schemas/route.js +2 -2
- package/.next-prod/server/app/api/neo4j/connect/route.js +1 -1
- package/.next-prod/server/app/api/neo4j/disconnect/route.js +1 -1
- package/.next-prod/server/app/api/neo4j/query/route.js +1 -1
- package/.next-prod/server/app/api/neo4j/schema/route.js +1 -1
- package/.next-prod/server/app/api/note/list/route.js +1 -1
- package/.next-prod/server/app/api/note/route.js +1 -1
- package/.next-prod/server/app/api/ollama/config/route.js +1 -1
- package/.next-prod/server/app/api/ollama/default-model/route.js +1 -1
- package/.next-prod/server/app/api/ollama/models/route.js +1 -1
- package/.next-prod/server/app/api/ollama/start/route.js +1 -1
- package/.next-prod/server/app/api/open-cursor/route.js +1 -1
- package/.next-prod/server/app/api/open-vscode/route.js +1 -1
- package/.next-prod/server/app/api/pi/thinking/route.js +1 -1
- package/.next-prod/server/app/api/pinned-sessions/route.js +1 -1
- package/.next-prod/server/app/api/project-settings/route.js +1 -1
- package/.next-prod/server/app/api/project-state/route.js +2 -2
- package/.next-prod/server/app/api/projectGraph/affected/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/callees/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/callers/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/clones/route.js +1 -0
- package/.next-prod/server/app/api/projectGraph/clones/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/projectGraph/clones/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/projectGraph/coedit/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/crap/route.js +1 -0
- package/.next-prod/server/app/api/projectGraph/crap/route.js.nft.json +1 -0
- package/.next-prod/server/app/api/projectGraph/crap/route_client-reference-manifest.js +1 -0
- package/.next-prod/server/app/api/projectGraph/edges/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/file/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/file-functions/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/impact/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/maps/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/related/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/search/route.js +1 -1
- package/.next-prod/server/app/api/projectGraph/symbols/route.js +1 -1
- package/.next-prod/server/app/api/projects/route.js +1 -1
- package/.next-prod/server/app/api/push/public-key/route.js +1 -1
- package/.next-prod/server/app/api/push/subscribe/route.js +1 -1
- package/.next-prod/server/app/api/push/unsubscribe/route.js +1 -1
- package/.next-prod/server/app/api/redis/command/route.js +1 -1
- package/.next-prod/server/app/api/redis/connect/route.js +1 -1
- package/.next-prod/server/app/api/redis/delete/route.js +1 -1
- package/.next-prod/server/app/api/redis/disconnect/route.js +1 -1
- package/.next-prod/server/app/api/redis/get/route.js +1 -1
- package/.next-prod/server/app/api/redis/keys/route.js +1 -1
- package/.next-prod/server/app/api/redis/set/route.js +1 -1
- package/.next-prod/server/app/api/restart/route.js +1 -1
- package/.next-prod/server/app/api/scheduled-tasks/route.js +2 -2
- package/.next-prod/server/app/api/services/config/route.js +1 -1
- package/.next-prod/server/app/api/services/scripts/route.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/turn/route.js +2 -2
- package/.next-prod/server/app/api/session/image/route.js +1 -1
- package/.next-prod/server/app/api/session/user-messages/route.js +1 -1
- package/.next-prod/server/app/api/session-bots/route.js +1 -1
- package/.next-prod/server/app/api/session-by-path/route.js +1 -1
- package/.next-prod/server/app/api/session-context/route.js +2 -2
- package/.next-prod/server/app/api/session-title/route.js +1 -1
- package/.next-prod/server/app/api/session-title/suggest/route.js +1 -1
- package/.next-prod/server/app/api/sessions/delegate/route.js +1 -1
- package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js +1 -1
- package/.next-prod/server/app/api/sessions/projects/route.js +1 -1
- package/.next-prod/server/app/api/sessions/search/route.js +1 -1
- package/.next-prod/server/app/api/sessions/status/route.js +1 -1
- package/.next-prod/server/app/api/settings/route.js +1 -1
- package/.next-prod/server/app/api/shutdown/route.js +1 -1
- package/.next-prod/server/app/api/skills/[id]/route.js +1 -1
- package/.next-prod/server/app/api/skills/builtin/route.js +1 -1
- package/.next-prod/server/app/api/skills/content/route.js +1 -1
- package/.next-prod/server/app/api/skills/files/route.js +1 -1
- package/.next-prod/server/app/api/skills/route.js +1 -1
- package/.next-prod/server/app/api/snapshots/blob/route.js +1 -1
- package/.next-prod/server/app/api/snapshots/diff/route.js +1 -1
- package/.next-prod/server/app/api/snapshots/mark/route.js +1 -1
- package/.next-prod/server/app/api/snapshots/range-diff/route.js +1 -1
- package/.next-prod/server/app/api/snapshots/restore/route.js +1 -1
- package/.next-prod/server/app/api/snapshots/route.js +1 -1
- package/.next-prod/server/app/api/terminal/aliases/route.js +1 -1
- package/.next-prod/server/app/api/terminal/autocomplete/route.js +1 -1
- package/.next-prod/server/app/api/terminal/bubble-order/route.js +1 -1
- package/.next-prod/server/app/api/terminal/env/route.js +1 -1
- package/.next-prod/server/app/api/terminal/history/route.js +1 -1
- package/.next-prod/server/app/api/terminal/running/route.js +1 -1
- package/.next-prod/server/app/api/update/route.js +1 -1
- package/.next-prod/server/app/api/update-state/route.js +1 -1
- package/.next-prod/server/app/api/version/route.js +1 -1
- package/.next-prod/server/app/apps/[...path]/route.js +1 -1
- package/.next-prod/server/app/favicon.ico/route.js +1 -1
- package/.next-prod/server/app/m/page.js +1 -1
- package/.next-prod/server/app/m/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/manifest.webmanifest/route.js +1 -1
- package/.next-prod/server/app/page.js +1 -1
- package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/project/page.js +1 -1
- package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app-paths-manifest.json +4 -2
- package/.next-prod/server/chunks/4949.js +1 -1
- package/.next-prod/server/chunks/6610.js +11 -11
- package/.next-prod/server/middleware-build-manifest.js +1 -1
- package/.next-prod/server/pages/500.html +1 -1
- package/.next-prod/server/server-reference-manifest.json +1 -1
- package/.next-prod/static/Dj5ykXLzxdIQZcSyjppsm/_buildManifest.js +1 -0
- package/.next-prod/static/chunks/{92000-31efb4d63c10446f.js → 60169-2e401ccea5e39a00.js} +21 -21
- package/.next-prod/static/chunks/{98596-ffbe0304646a9336.js → 98596-43e9fe35436097c6.js} +6 -6
- package/.next-prod/static/chunks/app/_global-error/{page-6af5bc188af96106.js → page-b40b02f6a2592427.js} +1 -1
- package/.next-prod/static/chunks/app/api/agent/test/{route-6af5bc188af96106.js → route-b40b02f6a2592427.js} +1 -1
- package/.next-prod/static/chunks/app/api/bash/{route-6af5bc188af96106.js → route-b40b02f6a2592427.js} +1 -1
- package/.next-prod/static/chunks/app/api/bots/[id]/{route-6af5bc188af96106.js → route-b40b02f6a2592427.js} +1 -1
- package/.next-prod/static/chunks/app/api/bots/files/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/bots/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/codex/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/deepseek/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/glm/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/grok/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/kimi/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/ollama/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/chat/stop/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/claude-stats/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/commands/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/comments/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/db/columns/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/db/connect/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/db/disconnect/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/db/export/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/db/query/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/db/schemas/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/deepseek/balance/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/deepseek/credentials/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/deepseek/models/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/dev/spans/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/extension/version/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/file/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/blame/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/clipboard/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/copy/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/delete/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/expanded/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/index/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/init/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/paste/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/read/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/readdir/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/recent/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/save/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/search/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/stat/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/files/text/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/fs/dirs/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/git/blob/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/git/branch-diff/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/git/branches/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/git/commit-diff/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/git/commits/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/git/current-branch/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/git/diff/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/git/discard/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/git/stage/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/git/status/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/git/unstage/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/git/worktree/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/glm/credentials/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/glm/models/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/glm/usage/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/global-state/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/grok/models/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/health/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/html-apps/[id]/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/html-apps/files/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/html-apps/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/instructions/config/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/kimi/credentials/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/kimi/models/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/kimi/usage/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/definition/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/hover/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/references/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/status/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/lsp/warmup/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/mobile-link/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/columns/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/connect/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/disconnect/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/export/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/query/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/mysql/schemas/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/neo4j/connect/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/neo4j/query/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/neo4j/schema/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/note/list/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/note/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/ollama/config/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/ollama/default-model/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/ollama/models/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/ollama/start/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/open-cursor/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/open-vscode/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/pi/thinking/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/pinned-sessions/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/project-settings/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/project-state/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/affected/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/callees/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/callers/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/clones/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/crap/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/edges/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/file/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/impact/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/maps/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/related/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/search/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projectGraph/symbols/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/projects/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/push/public-key/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/push/subscribe/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/push/unsubscribe/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/command/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/connect/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/delete/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/disconnect/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/get/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/keys/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/redis/set/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/restart/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/scheduled-tasks/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/services/config/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/services/scripts/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/session/[sessionId]/turn/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/session/image/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/session/user-messages/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/session-bots/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/session-by-path/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/session-context/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/session-title/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/session-title/suggest/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/delegate/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/projects/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/search/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/sessions/status/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/settings/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/shutdown/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/skills/[id]/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/skills/builtin/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/skills/content/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/skills/files/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/skills/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/snapshots/blob/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/snapshots/diff/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/snapshots/mark/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/snapshots/range-diff/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/snapshots/restore/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/snapshots/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/aliases/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/env/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/history/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/terminal/running/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/update/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/update-state/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/api/version/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/apps/[...path]/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/{layout-7107ed4eeac1f693.js → layout-a568d04e8d2707c3.js} +1 -1
- package/.next-prod/static/chunks/app/manifest.webmanifest/route-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/app/{page-338a2c84319778b1.js → page-6675d44ff6c5ebc6.js} +1 -1
- package/.next-prod/static/chunks/app/project/{page-338a2c84319778b1.js → page-6675d44ff6c5ebc6.js} +1 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-b40b02f6a2592427.js +1 -0
- package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-b40b02f6a2592427.js +1 -0
- package/.next-prod/trace +86 -86
- package/.next-prod/trace-build +1 -1
- package/.next-prod/types/app/api/projectGraph/clones/route.ts +353 -0
- package/.next-prod/types/app/api/projectGraph/crap/route.ts +353 -0
- package/.next-prod/types/routes.d.ts +3 -1
- package/.next-prod/types/validator.ts +18 -0
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/bin/cock-codegraph.mjs +111 -27
- package/bin/cockpit.mjs +1 -1
- package/bin/managed-npm-updater.mjs +0 -1
- package/desktop-checksums.json +4 -4
- package/dist/scheduledTasks.mjs +22 -10
- package/dist/wsServer.mjs +899 -160
- package/package.json +1 -1
- package/scripts/copy-tree-sitter-wasms.mjs +2 -2
- package/skills/ar/SKILL.md +293 -0
- package/skills/ar/boundary.md +48 -0
- package/skills/ar/evolution.md +38 -0
- package/skills/ar/legibility.md +52 -0
- package/skills/ar/reviewer.md +261 -0
- package/skills/ar/structure.md +38 -0
- package/skills/cg/SKILL.md +85 -14
- package/skills/cr/SKILL.md +62 -293
- package/skills/cr/reviewer.md +303 -0
- package/skills/rf/SKILL.md +6 -5
- package/skills/rf/axes.md +24 -2
- package/skills/rf/fix.md +58 -10
- package/skills/rf/lenses.md +27 -6
- package/skills/rf/sources.md +86 -24
- package/.next-prod/static/IlC_BH61CJ0hFaOu_akE9/_buildManifest.js +0 -1
- package/.next-prod/static/chunks/app/api/bots/files/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/bots/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/codex/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/deepseek/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/glm/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/grok/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/kimi/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/ollama/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/chat/stop/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/claude-stats/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/commands/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/comments/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/db/columns/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/db/connect/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/db/disconnect/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/db/export/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/db/query/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/db/schemas/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/deepseek/balance/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/deepseek/credentials/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/deepseek/models/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/dev/spans/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/extension/version/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/file/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/blame/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/clipboard/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/copy/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/delete/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/expanded/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/index/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/init/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/paste/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/read/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/readdir/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/recent/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/save/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/search/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/stat/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/files/text/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/fs/dirs/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/git/blob/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/git/branch-diff/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/git/branches/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/git/commit-diff/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/git/commits/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/git/current-branch/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/git/diff/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/git/discard/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/git/stage/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/git/status/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/git/unstage/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/git/worktree/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/glm/credentials/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/glm/models/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/glm/usage/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/global-state/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/grok/models/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/health/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/html-apps/[id]/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/html-apps/files/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/html-apps/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/instructions/config/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/kimi/credentials/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/kimi/models/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/kimi/usage/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/definition/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/hover/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/references/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/status/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/lsp/warmup/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/mobile-link/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/columns/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/connect/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/disconnect/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/export/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/query/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/mysql/schemas/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/neo4j/connect/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/neo4j/query/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/neo4j/schema/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/note/list/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/note/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/ollama/config/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/ollama/default-model/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/ollama/models/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/ollama/start/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/open-cursor/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/open-vscode/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/pi/thinking/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/pinned-sessions/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/project-settings/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/project-state/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/affected/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/callees/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/callers/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/edges/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/file/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/impact/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/maps/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/related/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/search/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projectGraph/symbols/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/projects/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/push/public-key/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/push/subscribe/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/push/unsubscribe/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/command/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/connect/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/delete/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/disconnect/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/get/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/keys/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/redis/set/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/restart/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/scheduled-tasks/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/services/config/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/services/scripts/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/session/[sessionId]/turn/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/session/image/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/session/user-messages/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/session-bots/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/session-by-path/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/session-context/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/session-title/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/session-title/suggest/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/sessions/delegate/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/sessions/projects/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/sessions/search/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/sessions/status/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/settings/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/shutdown/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/skills/[id]/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/skills/builtin/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/skills/content/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/skills/files/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/skills/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/snapshots/blob/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/snapshots/diff/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/snapshots/mark/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/snapshots/range-diff/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/snapshots/restore/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/snapshots/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/aliases/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/env/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/history/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/terminal/running/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/update/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/update-state/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/api/version/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/apps/[...path]/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/app/manifest.webmanifest/route-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-6af5bc188af96106.js +0 -1
- package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-6af5bc188af96106.js +0 -1
- /package/.next-prod/static/{IlC_BH61CJ0hFaOu_akE9 → Dj5ykXLzxdIQZcSyjppsm}/_ssgManifest.js +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[98596],{1058:(e,t,n)=>{n.d(t,{_:()=>l});var r=n(12115),s=n(90717),o=n(86957),a=n(46456);function l({cwd:e,filePath:t}){let[n,i]=(0,r.useState)([]),[d,c]=(0,r.useState)(!1),[u,m]=(0,r.useState)(null),h=(0,r.useCallback)(async()=>{if(!e||!t)return;c(!0),m(null);let n=await o.t4.runPromiseExit((0,a.lb)(e,t));if("Success"===n._tag)i(n.value.comments??[]);else{let e="Fail"===n.cause._tag?n.cause.error:null,t=e?.cause;m(t instanceof Error?t.message:"Failed to load comments")}c(!1)},[e,t]);(0,r.useEffect)(()=>{h()},[h]),(0,r.useEffect)(()=>(0,s.zL)(()=>{h()}),[h]);let p=(0,r.useCallback)(async(n,r,l,d)=>{let c=await o.t4.runPromiseExit((0,a.BC)({cwd:e,filePath:t,startLine:n,endLine:r,content:l,...d?{selectedText:d}:{}}));if("Success"===c._tag&&c.value.comment){let e=c.value.comment;return i(t=>[...t,e]),(0,s.Cm)(),e}return"Failure"===c._tag&&console.error("Failed to add comment:",c.cause),null},[e,t]),f=(0,r.useCallback)(async(t,n)=>{let r=await o.t4.runPromiseExit((0,a.vv)(e,t,n));if("Success"===r._tag&&r.value.comment){let e=r.value.comment;return i(n=>n.map(n=>n.id===t?e:n)),!0}return"Failure"===r._tag&&console.error("Failed to update comment:",r.cause),!1},[e]),g=(0,r.useCallback)(async t=>{let n=await o.t4.runPromiseExit((0,a.Tu)(e,t));return"Success"===n._tag?(i(e=>e.filter(e=>e.id!==t)),(0,s.Cm)(),!0):(console.error("Failed to delete comment:",n.cause),!1)},[e]),x=(0,r.useCallback)(e=>n.filter(t=>e>=t.startLine&&e<=t.endLine),[n]);return{comments:n,isLoading:d,error:u,addComment:p,updateComment:f,deleteComment:g,refresh:h,getCommentsForLine:x}}},2111:(e,t,n)=>{n.d(t,{D:()=>i,h:()=>d});var r=n(12115),s=n(91281),o=n(36196);s.EV(o.YA(1),1.5).pipe(s.gP(s.ji(o.YA(10))),s.y$(s.t5(10))),s.EV(o.ne(200),2).pipe(s.gP(s.ji(o.YA(5))),s.y$(s.t5(5))),s.EV(o.YA(1),2).pipe(s.et,s.gP(s.ji(o.YA(30))),s.y$(s.t5(8))),s.ji(o.YA(30)),s.ji(o.YA(1)),s.ji(o.YA(30)),o.ne(50),s.BW;let a=new Map,l=new Set;function i(e){return l.add(e),()=>{l.delete(e)}}function d({url:e,onMessage:t,onOpen:n,enabled:s=!0}){let o=(0,r.useRef)(t),i=(0,r.useRef)(n);(0,r.useEffect)(()=>{o.current=t}),(0,r.useEffect)(()=>{i.current=n}),(0,r.useEffect)(()=>{if(!s)return;let t=e=>o.current(e),n=()=>i.current?.(),r=function(e){let t=a.get(e);if(t)return t;let n={ws:null,listeners:new Set,openListeners:new Set,retryCount:0,retryTimer:null,connect(){let t="https:"===window.location.protocol?"wss:":"ws:",r=new WebSocket(`${t}//${window.location.host}${e}`);r.onopen=()=>{let e=n.retryCount>0;n.retryCount=0,n.openListeners.forEach(e=>{try{e()}catch(e){console.error("[useWebSocket] open listener threw",e)}}),e&&l.forEach(e=>{try{e()}catch(e){console.error("[useWebSocket] reconnect listener threw",e)}})},r.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}t?.type!=="ping"&&n.listeners.forEach(e=>{try{e(t)}catch(e){console.error("[useWebSocket] listener threw; other listeners unaffected",e)}})},r.onclose=()=>{if(0===n.listeners.size)return;let e=Math.min(1e3*Math.pow(1.5,n.retryCount),1e4);n.retryCount++,n.retryTimer=setTimeout(()=>n.connect(),e)},r.onerror=()=>{},n.ws=r},destroy(){n.retryTimer&&clearTimeout(n.retryTimer),n.ws&&n.ws.close(),n.ws=null,a.delete(e)}};return a.set(e,n),n.connect(),n}(e);return r.listeners.add(t),r.openListeners.add(n),r.ws?.readyState===WebSocket.OPEN&&n(),()=>{r.listeners.delete(t),r.openListeners.delete(n),0===r.listeners.size&&r.destroy()}},[e,s])}},3238:(e,t,n)=>{n.d(t,{DP:()=>a,NP:()=>i,Ql:()=>l});var r=n(95155),s=n(12115);let o=(0,s.createContext)(null);function a(){let e=(0,s.useContext)(o);if(!e)throw Error("useTheme must be used within a ThemeProvider");return e}function l(){return(0,s.useContext)(o)}function i({children:e}){let[t,n]=(0,s.useState)("system"),[a,l]=(0,s.useState)("light"),d=(0,s.useCallback)(()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[]),c=(0,s.useCallback)(e=>{let t=document.documentElement;t.classList.remove("light","dark"),t.classList.add(e),l(e);let n=document.querySelector('meta[name="theme-color"]'),r="dark"===e?"#111113":"#f9f9fb";n&&n.setAttribute("content",r)},[]),u=(0,s.useCallback)(e=>{n(e),localStorage.setItem("theme",e),c("system"===e?d():e),document.querySelectorAll("iframe").forEach(t=>{t.contentWindow?.postMessage({type:"THEME_CHANGE",theme:e},"*")})},[d,c]);return(0,s.useEffect)(()=>{let e=localStorage.getItem("theme")||"dark";queueMicrotask(()=>{n(e),c("system"===e?d():e)})},[d,c]),(0,s.useEffect)(()=>{if("system"!==t)return;let e=window.matchMedia("(prefers-color-scheme: dark)"),n=e=>{c(e.matches?"dark":"light")};return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[t,c]),(0,s.useEffect)(()=>{let e=e=>{if(e.data?.type==="THEME_CHANGE"){let t=e.data.theme;n(t),localStorage.setItem("theme",t),c("system"===t?d():t)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[d,c]),(0,r.jsx)(o.Provider,{value:{theme:t,resolvedTheme:a,setTheme:u},children:e})}},3939:(e,t,n)=>{n.d(t,{iy:()=>s,ke:()=>l});let r="http://cockpit.invalid";function s(e,t){let n;if(!e)return null;let s=e.trim();try{if(s.startsWith("/")){if((n=new URL(s,r)).origin!==r)return null}else if(!t||(n=new URL(s)).origin!==t)return null}catch{return null}if("/project"!==n.pathname)return null;let o=n.searchParams.get("cwd"),a=n.searchParams.get("sessionId");return o&&a?{cwd:o,sessionId:a}:null}let o=/(?<![\w/.~%=&+@-])\/project\?[\w\-.~%!$&*+,;=:@/?#]+/g,a=/[.,;:!?]+$/;function l(e){let t=[],n=0;for(let r of e.matchAll(o)){let o=r[0].replace(a,""),l=s(o);if(!l)continue;let i=r.index;i>n&&t.push({kind:"text",text:e.slice(n,i)}),t.push({kind:"link",text:o,target:l}),n=i+o.length}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}},4055:(e,t,n)=>{n.d(t,{h:()=>s});let r=new Set(["Read","Grep","Glob","LS","WebSearch","WebFetch","NotebookRead","TodoRead","AskUserQuestion","ExitPlanMode","TodoWrite","Skill"]),s=e=>!r.has(e)},4768:(e,t,n)=>{n.d(t,{O:()=>r});function r(e){let t=e.replace(/[^a-zA-Z0-9]/g,"-");return t.length<=200?t:`${t.slice(0,200)}-${function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t).toString(36)}(e)}`}},5135:(e,t,n)=>{n.d(t,{M:()=>E});var r=n(95155),s=n(12115),o=n(79114),a=n(14341),l=n(47650),i=n(70188),d=n(34075),c=n(89109),u=n(7320),m=n(37614),h=n(1058),p=n(48347),f=n(90717),g=n(69809),x=n(6744),b=n(34582),v=n(97251),y=n(11890),w=n(47215),k=n(43595),C=n(88403),j=n(47176),N=n(27570),S=n(79237);let T=[v.W];function E({content:e,filePath:t,cwd:n,onClose:v,sourceFile:R,embedded:M=!1,onLocalFileLink:L,scrollToAnchor:I,tocDefaultCollapsed:A=!1}){let P=R||n&&(0,S.y)(n,t)||t,{t:F}=(0,o.Bd)(),$=(0,i.iN)(),D=(0,p.r)(),_=(0,k.U)(),B=(0,C.Q)(),{comments:O,addComment:H,updateComment:V,deleteComment:U,refresh:W}=(0,h._)({cwd:n,filePath:t}),[q,z]=(0,s.useState)(!1),[K,G]=(0,s.useState)(null),[Q,J]=(0,s.useState)(null),[Y,X]=(0,s.useState)(null),Z=(0,s.useMemo)(()=>e.split("\n"),[e]),ee=(0,s.useMemo)(()=>(0,b.J4)(t,n),[t,n]);(0,s.useEffect)(()=>{queueMicrotask(()=>z(!0))},[]);let[et,en]=(0,s.useState)(null),er=(0,s.useRef)(null);(0,s.useEffect)(()=>{er.current!==et&&en(er.current)});let es=(0,s.useRef)({onLocalFileLink:L,sourceFile:P});es.current={onLocalFileLink:L,sourceFile:P};let eo=(0,s.useRef)(e=>{let{onLocalFileLink:t,sourceFile:n}=es.current;if(!t||e.startsWith("//")||/^[a-z][a-z0-9+.-]*:/i.test(e))return!1;let r=e.indexOf("#"),s=r>=0?e.slice(0,r):e,o=r>=0?e.slice(r+1):null;if(!s)return!1;let a=s;try{a=decodeURIComponent(s)}catch{}return t((0,w.WU)(n,a),(0,w.e$)(a)?o:null),!0}).current;(0,s.useEffect)(()=>{if(!I)return;let e=setTimeout(()=>{(0,y.O)(er.current,I)},80);return()=>clearTimeout(e)},[I,e]);let{toolbarRef:ea,bumpRef:el,clearToolbar:ei}=(0,N.L)({enabled:!0,container:et,resolveLineRange:e=>{let t=function(e){let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;if(!t||!("closest"in t))return null;let n=t.closest("[data-source-start]");if(!n)return null;let r=n.getAttribute("data-source-start"),s=n.getAttribute("data-source-end");return r&&s?{start:parseInt(r,10),end:parseInt(s,10)}:null}(e);return t?{start:t.start,end:t.end}:null},buildLineSnapshot:({start:e,end:t})=>{let n=Math.max(0,e-1),r=Math.min(Z.length,t);return Z.slice(n,r).join("\n")}}),ed=(0,s.useCallback)(()=>{let e=ea.current;e&&(G({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),ei())},[ei,ea]),ec=(0,s.useCallback)(()=>{let e=ea.current;e&&(J({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),ei())},[ei,ea]),eu=(0,s.useCallback)(()=>{let e=ea.current;e&&D&&(ei(),(0,f.Ff)(D.sendMessage,{filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},g.A.t("explain.selectionMessage")))},[D,t,ei,ea]),em=(0,s.useCallback)(async e=>{K&&(await H(K.range.start,K.range.end,e,K.selectedText),G(null))},[K,H]),eh=(0,s.useCallback)(async(e,r)=>{if(D)try{let s=await (0,f.$3)(n),o=[];for(let e of s)o.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});o.push({filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot});let a=(0,f.Gw)(o,r);D.sendMessage(a),await (0,f.RP)(n),W()}catch(e){console.error("Failed to send to AI:",e)}},[D,t,n,W]),ep=(0,s.useCallback)(e=>{Q&&eh(Q,e)},[Q,eh]),ef=(0,s.useCallback)(e=>{K&&eh(K,e)},[K,eh]),eg=(0,s.useMemo)(()=>{if(0===O.length)return[];let e=new Map;for(let t of O){let n=`${t.startLine}-${t.endLine}`;e.has(n)||e.set(n,[]),e.get(n).push(t)}return Array.from(e.entries()).map(([e,t])=>({key:e,startLine:t[0].startLine,endLine:t[0].endLine,comments:t}))},[O]),[ex,eb]=(0,s.useState)([]);return(0,s.useEffect)(()=>{if(0===eg.length||!er.current)return void queueMicrotask(()=>eb([]));let e=setTimeout(()=>{let e=er.current;if(!e)return;let t=[],n=e.querySelectorAll("[data-source-start]");for(let r of eg){let s=null,o=1/0;for(let e of n){let t=parseInt(e.getAttribute("data-source-start"),10),n=parseInt(e.getAttribute("data-source-end"),10);if(t<=r.startLine&&n>=r.endLine){let r=n-t;r<o&&(o=r,s=e)}}if(s){let n=e.getBoundingClientRect(),o=s.getBoundingClientRect();t.push({key:r.key,top:o.top-n.top+e.scrollTop,comments:r.comments})}}eb(t)},100);return()=>clearTimeout(e)},[eg,e]),(0,s.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(Q){J(null),e.stopPropagation();return}if(K){G(null),e.stopPropagation();return}if(ea.current){ea.current=null,el.current(),e.stopPropagation();return}if(Y){X(null),e.stopPropagation();return}v?.()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[Q,K,Y,v]),(0,r.jsxs)(r.Fragment,{children:[!M&&(0,r.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-brand transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":t,onClick:()=>{navigator.clipboard.writeText(t),(0,d.oR)(F("common.copiedPath"))},children:(0,r.jsx)("bdi",{dir:"ltr",children:t})}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[((0,w.C_)(t)||(0,w.OG)(t))&&(0,r.jsx)("button",{onClick:()=>{let e=t.startsWith("/")||!n?t:`${n.replace(/\/$/,"")}/${t}`;(0,w.OG)(t)?B(e):_(e)},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:F((0,w.OG)(t)?"bots.addTooltip":"skills.addTooltip"),children:(0,r.jsx)(a.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:v,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:F("common.close"),children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,r.jsx)(j.l,{content:e,containerRef:er,defaultCollapsed:A}),(0,r.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:er,children:[(0,r.jsx)("div",{className:"p-6",children:(0,r.jsx)(x.T,{content:e,basePath:ee,rehypePlugins:T,onLinkClick:eo})}),ex.map(({key:e,top:t,comments:n})=>(0,r.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:t},onClick:e=>{e.stopPropagation(),X({comment:n[0],x:e.clientX,y:e.clientY})},children:(0,r.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-lv1 hover:bg-amber-500 transition-colors",children:n.length})},e))]})]}),q&&$&&(0,l.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c.fS,{floatingToolbarRef:ea,bumpRef:el,container:$,onAddComment:ed,onSendToAI:ec,onExplain:D?eu:void 0,isChatLoading:D?.isLoading}),K&&(0,r.jsx)(u.t,{x:K.x,y:K.y,range:K.range,filePath:t,lineSnapshot:K.lineSnapshot,container:$,onSubmit:em,onSendToAI:D?ef:void 0,onClose:()=>G(null),isChatLoading:D?.isLoading}),Q&&(0,r.jsx)(u.G,{x:Q.x,y:Q.y,range:Q.range,filePath:t,lineSnapshot:Q.lineSnapshot,container:$,onSubmit:ep,onClose:()=>J(null),isChatLoading:D?.isLoading}),Y&&(0,r.jsx)(m.t,{x:Y.x,y:Y.y,comment:Y.comment,container:$,onClose:()=>X(null),onUpdateComment:V,onDeleteComment:U})]}),$)]})}},6744:(e,t,n)=>{n.d(t,{T:()=>B});var r=n(95155),s=n(46361),o=n(79204),a=n(98164),l=n(77815),i=n(97720),d=n(88374);n(84559),n(21227);var c=n(91334),u=n(38194),m=n(88522),h=n(12115),p=n(34582),f=n(3939),g=n(3238),x=n(11890),b=n(73620);function v(e){return{type:"tableCell",children:[{type:"text",value:e}]}}let y=[n(54152).A,function(){return e=>{let t=e.children;for(let e=0;e<t.length;e++){let n=t[e];if("yaml"!==n.type)continue;let r=null;try{let e=b.Ay.load(n.value??"");e&&"object"==typeof e&&!Array.isArray(e)&&(r=e)}catch{r=null}let s=r?Object.entries(r):[];if(0===s.length){t.splice(e,1),e--;continue}let o={type:"tableRow",children:[v("Field"),v("Value")]},a=s.map(([e,t])=>({type:"tableRow",children:[v(e),v(function(e){if(null==e)return"";if("string"==typeof e)return e.replace(/\s*\n\s*/g," ").trim();if("number"==typeof e||"boolean"==typeof e)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}(t))]}));t[e]={type:"table",align:["left","left"],children:[o,...a]}}}}];function w(e){return!(!e.trim()||/\n[ \t]*\n/.test(e)||e.includes("$"))}function k(e){if(!e.includes("\\(")&&!e.includes("\\["))return e;let t=[],n=e=>(t.push(e),`\u0000MATHMASK${t.length-1}\u0000`);return e.replace(/```[\s\S]*?```/g,n).replace(/~~~[\s\S]*?~~~/g,n).replace(/`[^`\n]+`/g,n).replace(/\\\[([^\u0000]*?)\\\]/g,(e,t)=>w(t)?`$$${t}$$`:e).replace(/\\\(([^\u0000]*?)\\\)/g,(e,t)=>w(t)?`$${t}$`:e).replace(/\u0000MATHMASK(\d+)\u0000/g,(e,n)=>t[+n])}var C=n(44902),j=n(70570);let N=[C.A,j.A];var S=n(48250),T=n(20768);let E="data-session-link";function R(){return e=>{(0,S.YR)(e,"text",(e,t,n)=>{if(!n||void 0===t||!e.value?.includes("/project?")||"link"===n.type||"linkReference"===n.type)return;let r=(0,f.ke)(e.value);if(!r.some(e=>"link"===e.kind))return;let s=r.map(e=>"text"===e.kind?{type:"text",value:e.text}:{type:"link",url:e.text,children:[{type:"text",value:e.text}],data:{hProperties:{[E]:""}}});return n.children.splice(t,1,...s),[T._Z,t+s.length]})}}var M=n(69924);let L=[...y,o.A,...N,a.A,function(){return(e,t)=>{let n=String(t?.value??"");n&&function e(t,n){let r=t.children;if(r)for(let s=0;s<r.length;s++)n(r[s],s,t),e(r[s],n)}(e,(e,t,r)=>{var s;if("inlineMath"!==e.type)return;let o=e.position?.start?.offset,a=e.position?.end?.offset;void 0!==o&&void 0!==a&&(s=e.value??"","$$"!==n.slice(o,o+2)&&(!s||/^\s|\s$/.test(s)||/\d/.test(n[o-1]??"")||/\d/.test(n[a]??"")||0)&&(r.children[t]={type:"text",value:n.slice(o,a),position:e.position}))})}},l.jb,R],I=[...y,o.A,...N,l.jb,R],A=[i.A,d.A],P=[i.A];function F(e){let t=[],n=e=>(t.push(e),` MASK${t.length-1} `);return e.replace(/```[\s\S]*?```/g,e=>n(e)).replace(/~~~[\s\S]*?~~~/g,e=>n(e)).replace(/^(\|.+\|)$/gm,e=>/^\|[\s:|-]+\|$/.test(e)?e:e.replace(/`([^`]*)`/g,(e,t)=>t.includes("|")?"`"+t.replace(/\|/g,"\\|")+"`":e)).replace(/ MASK(\d+) /g,(e,n)=>t[+n])}let $=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clippath","defs","ellipse","g","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","text","tspan","use"]);function D(e){let t=[],n=e=>(t.push(e),`\u0000MASK${t.length-1}\u0000`);return e.replace(/```[\s\S]*?```/g,e=>n(e)).replace(/~~~[\s\S]*?~~~/g,e=>n(e)).replace(/`[^`\n]+`/g,e=>n(e)).replace(/<\/?([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(e,t)=>{let n=t.toLowerCase();return $.has(n)||n.includes("-")?e:e.replace(/</g,"<").replace(/>/g,">")}).replace(/\u0000MASK(\d+)\u0000/g,(e,n)=>t[+n])}function _({code:e}){let[t,n]=(0,h.useState)(!1),s=(0,h.useRef)(null);return(0,h.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]),(0,r.jsx)("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{n(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>n(!1),1500)})},title:t?"Copied":"Copy","aria-label":"Copy code",className:"absolute top-2 right-2 p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-foreground/10 opacity-0 group-hover/code:opacity-100 focus-visible:opacity-100 transition-opacity",children:(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t?(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})})}let B=(0,h.memo)(function({content:e,isUser:t=!1,isStreaming:n=!1,enableMath:o=!0,isDark:a,rehypePlugins:l,onLinkClick:i,basePath:d}){let b=(0,g.Ql)(),v=a??b?.resolvedTheme==="dark",y=(0,h.useRef)(null),w=(0,h.useMemo)(()=>({code({className:e,children:t,node:n,...s}){let o=/language-(\w+)/.exec(e||"");if(!("string"==typeof t||"number"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e||"number"==typeof e)))return(0,r.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent font-mono",...s,children:t});let a=String(t);if(!o&&!e&&!a.includes("\n"))return(0,r.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent font-mono",...s,children:t});let l=a.replace(/\n$/,""),i=o?.[1]||"text",d=Number(s["data-source-start"])||0,h=d?d+1:0,p=0;return(0,r.jsxs)("div",{className:"group/code relative font-mono",style:{margin:"1.35em 0"},children:[(0,r.jsx)(c.A,{style:v?u.A:m.A,language:i,PreTag:"div",className:"md-figure",customStyle:{margin:0,borderRadius:"0.375rem",fontSize:"0.92em",fontFamily:"inherit"},codeTagProps:{className:`language-${i}`,style:{fontFamily:"inherit"}},wrapLines:!0,lineProps:()=>{let e=h+p;return p++,{"data-source-start":e,"data-source-end":e,style:{display:"block"}}},children:l}),(0,r.jsx)(_,{code:l})]})},p:({children:e,node:t,...n})=>(0,r.jsx)("p",{...n,children:e}),h1:({children:e,node:t,...n})=>(0,r.jsx)("h1",{...n,children:e}),h2:({children:e,node:t,...n})=>(0,r.jsx)("h2",{...n,children:e}),h3:({children:e,node:t,...n})=>(0,r.jsx)("h3",{...n,children:e}),ul:({children:e,node:t,...n})=>(0,r.jsx)("ul",{className:"list-disc",...n,children:e}),ol:({children:e,node:t,...n})=>(0,r.jsx)("ol",{className:"list-decimal",...n,children:e}),li:({children:e,node:t,...n})=>(0,r.jsx)("li",{...n,children:e}),blockquote:({children:e,node:t,...n})=>(0,r.jsx)("blockquote",{className:"border-l-2 border-border pl-4 text-muted-foreground",...n,children:e}),a:({href:e,children:t,node:n,...s})=>{let o=e&&E in s?(0,f.iy)(e):null;return o?(0,r.jsx)(M.B,{href:e,target:o,newTab:!0,onClick:t=>{i?.(e)&&t.preventDefault()}}):(0,r.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand hover:underline",...s,onClick:t=>{if(e){if(e.startsWith("#")){(0,x.O)(y.current,e.slice(1))&&t.preventDefault();return}i?.(e)&&t.preventDefault()}},children:t})},table:({children:e,node:t,...n})=>(0,r.jsx)("div",{className:"md-figure overflow-x-auto",...n,children:(0,r.jsx)("table",{className:"min-w-full border border-border",children:e})}),thead:({children:e,node:t,...n})=>(0,r.jsx)("thead",{className:"bg-accent",...n,children:e}),th:({children:e,node:t,...n})=>(0,r.jsx)("th",{className:"px-4 py-2 text-left font-semibold border-b border-border",...n,children:e}),td:({children:e,node:t,...n})=>(0,r.jsx)("td",{className:"px-4 py-2 border-b border-border",...n,children:e}),hr:({node:e,...t})=>(0,r.jsx)("hr",{className:"border-border",...t}),img:({src:e,alt:t,node:n,height:s,width:o,style:a,...l})=>{let i=d&&"string"==typeof e?(0,p.xh)(e,d):e;if(!(s||o||a))return(0,r.jsx)("img",{src:i,alt:t||"",className:"max-w-full h-auto rounded-lg my-3",...l});let c=e=>e?/^\d+$/.test(String(e))?`${e}px`:String(e):void 0,u={...a,height:c(s)??a?.height,width:c(o)??a?.width};return(0,r.jsx)("img",{src:i,alt:t||"",style:u,className:"inline-block align-middle",...l})},strong:({children:e,node:t,...n})=>(0,r.jsx)("strong",{className:"font-bold",...n,children:e}),em:({children:e,node:t,...n})=>(0,r.jsx)("em",{className:"italic",...n,children:e}),del:({children:e,node:t,...n})=>(0,r.jsx)("del",{className:"line-through",...n,children:e})}),[v,i,d]),C=o?L:I,j=o?A:P,N=(0,h.useMemo)(()=>{if(t||n)return D(e);let r=D(F(!function(e){if(/^\|[\s:|-]+\|$/m.test(e))return!1;if(/[┌┐└┘│─├┤┬┴┼╔╗╚╝║═╭╮╯╰▲▼◀▶△▽◁▷]/.test(e)||/\+[-=]{2,}\+/.test(e))return!0;let t=e.split("\n").filter(e=>/^\s*\||\|\s*$/.test(e));if(t.length>=3){let e=t.map(e=>(e.match(/\|/g)||[]).length);return!e.every(t=>t===e[0])||!(e[0]>=3)}return!1}(e)||/^```[\s\S]*```$/m.test(e.trim())?e:"```text\n"+e.trim()+"\n```"));return o?k(r):r},[e,t,n,o]),S=(0,h.useMemo)(()=>l?.length?[...j,...l]:j,[l,j]);if(t)return(0,r.jsx)("div",{className:"reading-measure whitespace-pre-wrap break-words",children:e});if(n){let t=e.lastIndexOf("\n");if(-1===t)return(0,r.jsx)("div",{className:"reading-measure whitespace-pre-wrap break-words",children:e});let n=e.slice(0,t+1),a=e.slice(t+1);return(0,r.jsxs)("div",{className:"markdown-body",ref:y,children:[(0,r.jsx)(s.oz,{remarkPlugins:C,rehypePlugins:j,components:w,children:o?k(D(F(n))):D(F(n))}),a&&(0,r.jsx)("span",{className:"md-tail whitespace-pre-wrap",children:a})]})}return(0,r.jsx)("div",{className:"markdown-body",ref:y,children:(0,r.jsx)(s.oz,{remarkPlugins:C,rehypePlugins:S,components:w,children:N})})})},7320:(e,t,n)=>{n.d(t,{G:()=>l,t:()=>a});var r=n(95155),s=n(12115),o=n(79114);function a({x:e,y:t,range:n,filePath:l,lineSnapshot:i,container:d,onSubmit:c,onSendToAI:u,onClose:m,isChatLoading:h}){let{t:p}=(0,o.Bd)(),[f,g]=(0,s.useState)(""),[x,b]=(0,s.useState)(!1),v=(0,s.useRef)(null),y=(0,s.useRef)(null),[w,k]=(0,s.useState)({x:0,y:0}),C=i?.split("\n").slice(0,5).join("\n"),j=!!i&&i.split("\n").length>5;(0,s.useEffect)(()=>{if(v.current&&d){let n=d.getBoundingClientRect(),r=v.current.getBoundingClientRect(),s=e-n.left,o=t-n.top;s+r.width>n.width-16&&(s=n.width-r.width-16),s<16&&(s=16),o+r.height>n.height-16&&(o=o-r.height-8),o<16&&(o=16),queueMicrotask(()=>k({x:s,y:o}))}},[e,t,d]),(0,s.useEffect)(()=>{y.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{x||!v.current||v.current.contains(e.target)||m()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[m,x]);let N=()=>{!x&&f.trim()&&(b(!0),c(f.trim()))};return(0,r.jsxs)("div",{ref:v,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:w.x,top:w.y},children:[(0,r.jsxs)("div",{className:"px-3 py-2 bg-amber-9/10 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-amber-11",children:p("comments.addComment")}),(n.start>0||n.end>0)&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:p("comments.lineRange",{start:n.start,end:n.end})})]}),l&&(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:l})]}),i&&(0,r.jsx)("div",{className:"px-3 py-2 border-b border-border max-h-24 overflow-hidden",children:(0,r.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[C,j&&(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,r.jsxs)("div",{className:"p-2",children:[(0,r.jsx)("textarea",{ref:y,value:f,onChange:e=>g(e.target.value),placeholder:p("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:x,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),N()),"Escape"!==e.key||x||m()}}),(0,r.jsxs)("div",{className:"mt-1 flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:p(x?"comments.submitting":"comments.enterSubmit")}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("button",{className:"px-3 py-1 text-xs font-medium border border-amber-11 text-amber-11 rounded-md hover:bg-amber-9/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:N,disabled:x||!f.trim(),children:p("comments.submitComment")}),u&&(0,r.jsx)("button",{className:"px-3 py-1 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:()=>{!x&&!h&&u&&f.trim()&&(b(!0),u(f.trim()),m())},disabled:x||h||!f.trim(),title:h?p("comments.aiResponding"):void 0,children:p("comments.sendToAI")})]})]})]})]})}function l({x:e,y:t,range:n,filePath:a,lineSnapshot:i,container:d,onSubmit:c,onClose:u,isChatLoading:m}){let{t:h}=(0,o.Bd)(),[p,f]=(0,s.useState)(""),g=(0,s.useRef)(null),x=(0,s.useRef)(null),[b,v]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(g.current&&d){let n=d.getBoundingClientRect(),r=g.current.getBoundingClientRect(),s=e-n.left,o=t-n.top;s+r.width>n.width-16&&(s=n.width-r.width-16),s<16&&(s=16),o+r.height>n.height-16&&(o=o-r.height-8),o<16&&(o=16),queueMicrotask(()=>v({x:s,y:o}))}},[e,t,d]),(0,s.useEffect)(()=>{x.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&u()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]);let y=i?.split("\n").slice(0,5).join("\n"),w=!!i&&i.split("\n").length>5;return(0,r.jsxs)("div",{ref:g,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:b.x,top:b.y},children:[(0,r.jsxs)("div",{className:"px-3 py-2 bg-brand/10 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-brand",children:h("comments.askAI")}),(n.start>0||n.end>0)&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:h("comments.lineRange",{start:n.start,end:n.end})})]}),a&&(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:a})]}),i&&(0,r.jsx)("div",{className:"px-3 py-2 border-b border-border max-h-24 overflow-hidden",children:(0,r.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[y,w&&(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,r.jsxs)("div",{className:"p-2",children:[(0,r.jsx)("textarea",{ref:x,value:p,onChange:e=>f(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:m,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!m&&p.trim()&&(c(p.trim()),u())),"Escape"===e.key&&u()}}),(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:h(m?"comments.aiGenerating":"comments.enterSend")})]})]})}},7578:(e,t,n)=>{n.d(t,{S:()=>a,l:()=>l});var r=n(95155),s=n(68287),o=n(16147);function a(e){return"loading"===e||"unread"===e?e:"normal"}function l({projectNumber:e,sessionNumber:t,coordinate:n,status:a="normal",statusLabel:i,bot:d,className:c=""}){if(n){let[r,s]=n.split(".");e??=r,t??=s}if(null==e&&null==t&&"normal"!==a&&(t="\xb7"),null==e&&null==t)return null;let u=[e,t].filter(e=>null!=e).join(".");return(0,r.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[9px] font-medium leading-none tabular-nums flex-shrink-0 ${c}`,"aria-label":i?`${u} \xb7 ${i}`:u,children:[null!=e&&(0,r.jsx)("span",{className:`flex h-4 w-4 items-center justify-center border rounded-[4px] ${(0,s.ci)("normal",!1)}`,children:e}),null!=t&&(0,r.jsx)(o.w,{wash:(0,s.JQ)(a,!1),ring:(0,s.QV)(a),bot:d,title:i,children:t})]})}},8183:(e,t,n)=>{n.d(t,{EF:()=>m,OS:()=>c,V6:()=>i,X4:()=>u,Yn:()=>d,c4:()=>f,eh:()=>p,iM:()=>h,kz:()=>l});let r=new Map,s=new Set,o=new Map,a=new Map,l=(e,t)=>`${e}
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[98596],{1058:(e,t,n)=>{n.d(t,{_:()=>l});var r=n(12115),s=n(90717),o=n(86957),a=n(46456);function l({cwd:e,filePath:t}){let[n,i]=(0,r.useState)([]),[d,c]=(0,r.useState)(!1),[u,m]=(0,r.useState)(null),h=(0,r.useCallback)(async()=>{if(!e||!t)return;c(!0),m(null);let n=await o.t4.runPromiseExit((0,a.lb)(e,t));if("Success"===n._tag)i(n.value.comments??[]);else{let e="Fail"===n.cause._tag?n.cause.error:null,t=e?.cause;m(t instanceof Error?t.message:"Failed to load comments")}c(!1)},[e,t]);(0,r.useEffect)(()=>{h()},[h]),(0,r.useEffect)(()=>(0,s.zL)(()=>{h()}),[h]);let p=(0,r.useCallback)(async(n,r,l,d)=>{let c=await o.t4.runPromiseExit((0,a.BC)({cwd:e,filePath:t,startLine:n,endLine:r,content:l,...d?{selectedText:d}:{}}));if("Success"===c._tag&&c.value.comment){let e=c.value.comment;return i(t=>[...t,e]),(0,s.Cm)(),e}return"Failure"===c._tag&&console.error("Failed to add comment:",c.cause),null},[e,t]),f=(0,r.useCallback)(async(t,n)=>{let r=await o.t4.runPromiseExit((0,a.vv)(e,t,n));if("Success"===r._tag&&r.value.comment){let e=r.value.comment;return i(n=>n.map(n=>n.id===t?e:n)),!0}return"Failure"===r._tag&&console.error("Failed to update comment:",r.cause),!1},[e]),g=(0,r.useCallback)(async t=>{let n=await o.t4.runPromiseExit((0,a.Tu)(e,t));return"Success"===n._tag?(i(e=>e.filter(e=>e.id!==t)),(0,s.Cm)(),!0):(console.error("Failed to delete comment:",n.cause),!1)},[e]),x=(0,r.useCallback)(e=>n.filter(t=>e>=t.startLine&&e<=t.endLine),[n]);return{comments:n,isLoading:d,error:u,addComment:p,updateComment:f,deleteComment:g,refresh:h,getCommentsForLine:x}}},2111:(e,t,n)=>{n.d(t,{D:()=>i,h:()=>d});var r=n(12115),s=n(91281),o=n(36196);s.EV(o.YA(1),1.5).pipe(s.gP(s.ji(o.YA(10))),s.y$(s.t5(10))),s.EV(o.ne(200),2).pipe(s.gP(s.ji(o.YA(5))),s.y$(s.t5(5))),s.EV(o.YA(1),2).pipe(s.et,s.gP(s.ji(o.YA(30))),s.y$(s.t5(8))),s.ji(o.YA(30)),s.ji(o.YA(1)),s.ji(o.YA(30)),o.ne(50),s.BW;let a=new Map,l=new Set;function i(e){return l.add(e),()=>{l.delete(e)}}function d({url:e,onMessage:t,onOpen:n,enabled:s=!0}){let o=(0,r.useRef)(t),i=(0,r.useRef)(n);(0,r.useEffect)(()=>{o.current=t}),(0,r.useEffect)(()=>{i.current=n}),(0,r.useEffect)(()=>{if(!s)return;let t=e=>o.current(e),n=()=>i.current?.(),r=function(e){let t=a.get(e);if(t)return t;let n={ws:null,listeners:new Set,openListeners:new Set,retryCount:0,retryTimer:null,connect(){let t="https:"===window.location.protocol?"wss:":"ws:",r=new WebSocket(`${t}//${window.location.host}${e}`);r.onopen=()=>{let e=n.retryCount>0;n.retryCount=0,n.openListeners.forEach(e=>{try{e()}catch(e){console.error("[useWebSocket] open listener threw",e)}}),e&&l.forEach(e=>{try{e()}catch(e){console.error("[useWebSocket] reconnect listener threw",e)}})},r.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}t?.type!=="ping"&&n.listeners.forEach(e=>{try{e(t)}catch(e){console.error("[useWebSocket] listener threw; other listeners unaffected",e)}})},r.onclose=()=>{if(0===n.listeners.size)return;let e=Math.min(1e3*Math.pow(1.5,n.retryCount),1e4);n.retryCount++,n.retryTimer=setTimeout(()=>n.connect(),e)},r.onerror=()=>{},n.ws=r},destroy(){n.retryTimer&&clearTimeout(n.retryTimer),n.ws&&n.ws.close(),n.ws=null,a.delete(e)}};return a.set(e,n),n.connect(),n}(e);return r.listeners.add(t),r.openListeners.add(n),r.ws?.readyState===WebSocket.OPEN&&n(),()=>{r.listeners.delete(t),r.openListeners.delete(n),0===r.listeners.size&&r.destroy()}},[e,s])}},3238:(e,t,n)=>{n.d(t,{DP:()=>a,NP:()=>i,Ql:()=>l});var r=n(95155),s=n(12115);let o=(0,s.createContext)(null);function a(){let e=(0,s.useContext)(o);if(!e)throw Error("useTheme must be used within a ThemeProvider");return e}function l(){return(0,s.useContext)(o)}function i({children:e}){let[t,n]=(0,s.useState)("system"),[a,l]=(0,s.useState)("light"),d=(0,s.useCallback)(()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[]),c=(0,s.useCallback)(e=>{let t=document.documentElement;t.classList.remove("light","dark"),t.classList.add(e),l(e);let n=document.querySelector('meta[name="theme-color"]'),r="dark"===e?"#111113":"#f9f9fb";n&&n.setAttribute("content",r)},[]),u=(0,s.useCallback)(e=>{n(e),localStorage.setItem("theme",e),c("system"===e?d():e),document.querySelectorAll("iframe").forEach(t=>{t.contentWindow?.postMessage({type:"THEME_CHANGE",theme:e},"*")})},[d,c]);return(0,s.useEffect)(()=>{let e=localStorage.getItem("theme")||"dark";queueMicrotask(()=>{n(e),c("system"===e?d():e)})},[d,c]),(0,s.useEffect)(()=>{if("system"!==t)return;let e=window.matchMedia("(prefers-color-scheme: dark)"),n=e=>{c(e.matches?"dark":"light")};return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[t,c]),(0,s.useEffect)(()=>{let e=e=>{if(e.data?.type==="THEME_CHANGE"){let t=e.data.theme;n(t),localStorage.setItem("theme",t),c("system"===t?d():t)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[d,c]),(0,r.jsx)(o.Provider,{value:{theme:t,resolvedTheme:a,setTheme:u},children:e})}},3939:(e,t,n)=>{n.d(t,{iy:()=>s,ke:()=>l});let r="http://cockpit.invalid";function s(e,t){let n;if(!e)return null;let s=e.trim();try{if(s.startsWith("/")){if((n=new URL(s,r)).origin!==r)return null}else if(!t||(n=new URL(s)).origin!==t)return null}catch{return null}if("/project"!==n.pathname)return null;let o=n.searchParams.get("cwd"),a=n.searchParams.get("sessionId");return o&&a?{cwd:o,sessionId:a}:null}let o=/(?<![\w/.~%=&+@-])\/project\?[\w\-.~%!$&*+,;=:@/?#]+/g,a=/[.,;:!?]+$/;function l(e){let t=[],n=0;for(let r of e.matchAll(o)){let o=r[0].replace(a,""),l=s(o);if(!l)continue;let i=r.index;i>n&&t.push({kind:"text",text:e.slice(n,i)}),t.push({kind:"link",text:o,target:l}),n=i+o.length}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}},4055:(e,t,n)=>{n.d(t,{h:()=>s});let r=new Set(["Read","Grep","Glob","LS","WebSearch","WebFetch","NotebookRead","TodoRead","AskUserQuestion","ExitPlanMode","TodoWrite","Skill"]),s=e=>!r.has(e)},4768:(e,t,n)=>{n.d(t,{O:()=>r});function r(e){let t=e.replace(/[^a-zA-Z0-9]/g,"-");return t.length<=200?t:`${t.slice(0,200)}-${function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t).toString(36)}(e)}`}},5135:(e,t,n)=>{n.d(t,{M:()=>E});var r=n(95155),s=n(12115),o=n(79114),a=n(14341),l=n(47650),i=n(70188),d=n(34075),c=n(89109),u=n(7320),m=n(37614),h=n(1058),p=n(48347),f=n(90717),g=n(69809),x=n(6744),b=n(34582),v=n(97251),y=n(11890),w=n(47215),k=n(43595),C=n(88403),j=n(47176),N=n(27570),S=n(79237);let T=[v.W];function E({content:e,filePath:t,cwd:n,onClose:v,sourceFile:R,embedded:M=!1,onLocalFileLink:L,scrollToAnchor:I,tocDefaultCollapsed:A=!1}){let F=R||n&&(0,S.y)(n,t)||t,{t:P}=(0,o.Bd)(),$=(0,i.iN)(),D=(0,p.r)(),_=(0,k.U)(),O=(0,C.Q)(),{comments:B,addComment:H,updateComment:V,deleteComment:U,refresh:W}=(0,h._)({cwd:n,filePath:t}),[q,z]=(0,s.useState)(!1),[K,G]=(0,s.useState)(null),[Q,J]=(0,s.useState)(null),[Y,Z]=(0,s.useState)(null),X=(0,s.useMemo)(()=>e.split("\n"),[e]),ee=(0,s.useMemo)(()=>(0,b.J4)(t,n),[t,n]);(0,s.useEffect)(()=>{queueMicrotask(()=>z(!0))},[]);let[et,en]=(0,s.useState)(null),er=(0,s.useRef)(null);(0,s.useEffect)(()=>{er.current!==et&&en(er.current)});let es=(0,s.useRef)({onLocalFileLink:L,sourceFile:F});es.current={onLocalFileLink:L,sourceFile:F};let eo=(0,s.useRef)(e=>{let{onLocalFileLink:t,sourceFile:n}=es.current;if(!t||e.startsWith("//")||/^[a-z][a-z0-9+.-]*:/i.test(e))return!1;let r=e.indexOf("#"),s=r>=0?e.slice(0,r):e,o=r>=0?e.slice(r+1):null;if(!s)return!1;let a=s;try{a=decodeURIComponent(s)}catch{}return t((0,w.WU)(n,a),(0,w.e$)(a)?o:null),!0}).current;(0,s.useEffect)(()=>{if(!I)return;let e=setTimeout(()=>{(0,y.O)(er.current,I)},80);return()=>clearTimeout(e)},[I,e]);let{toolbarRef:ea,bumpRef:el,clearToolbar:ei}=(0,N.L)({enabled:!0,container:et,resolveLineRange:e=>{let t=function(e){let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;if(!t||!("closest"in t))return null;let n=t.closest("[data-source-start]");if(!n)return null;let r=n.getAttribute("data-source-start"),s=n.getAttribute("data-source-end");return r&&s?{start:parseInt(r,10),end:parseInt(s,10)}:null}(e);return t?{start:t.start,end:t.end}:null},buildLineSnapshot:({start:e,end:t})=>{let n=Math.max(0,e-1),r=Math.min(X.length,t);return X.slice(n,r).join("\n")}}),ed=(0,s.useCallback)(()=>{let e=ea.current;e&&(G({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),ei())},[ei,ea]),ec=(0,s.useCallback)(()=>{let e=ea.current;e&&(J({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),ei())},[ei,ea]),eu=(0,s.useCallback)(()=>{let e=ea.current;e&&D&&(ei(),(0,f.Ff)(D.sendMessage,{filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},g.A.t("explain.selectionMessage")))},[D,t,ei,ea]),em=(0,s.useCallback)(async e=>{K&&(await H(K.range.start,K.range.end,e,K.selectedText),G(null))},[K,H]),eh=(0,s.useCallback)(async(e,r)=>{if(D)try{let s=await (0,f.$3)(n),o=[];for(let e of s)o.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});o.push({filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot});let a=(0,f.Gw)(o,r);D.sendMessage(a),await (0,f.RP)(n),W()}catch(e){console.error("Failed to send to AI:",e)}},[D,t,n,W]),ep=(0,s.useCallback)(e=>{Q&&eh(Q,e)},[Q,eh]),ef=(0,s.useCallback)(e=>{K&&eh(K,e)},[K,eh]),eg=(0,s.useMemo)(()=>{if(0===B.length)return[];let e=new Map;for(let t of B){let n=`${t.startLine}-${t.endLine}`;e.has(n)||e.set(n,[]),e.get(n).push(t)}return Array.from(e.entries()).map(([e,t])=>({key:e,startLine:t[0].startLine,endLine:t[0].endLine,comments:t}))},[B]),[ex,eb]=(0,s.useState)([]);return(0,s.useEffect)(()=>{if(0===eg.length||!er.current)return void queueMicrotask(()=>eb([]));let e=setTimeout(()=>{let e=er.current;if(!e)return;let t=[],n=e.querySelectorAll("[data-source-start]");for(let r of eg){let s=null,o=1/0;for(let e of n){let t=parseInt(e.getAttribute("data-source-start"),10),n=parseInt(e.getAttribute("data-source-end"),10);if(t<=r.startLine&&n>=r.endLine){let r=n-t;r<o&&(o=r,s=e)}}if(s){let n=e.getBoundingClientRect(),o=s.getBoundingClientRect();t.push({key:r.key,top:o.top-n.top+e.scrollTop,comments:r.comments})}}eb(t)},100);return()=>clearTimeout(e)},[eg,e]),(0,s.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(Q){J(null),e.stopPropagation();return}if(K){G(null),e.stopPropagation();return}if(ea.current){ea.current=null,el.current(),e.stopPropagation();return}if(Y){Z(null),e.stopPropagation();return}v?.()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[Q,K,Y,v]),(0,r.jsxs)(r.Fragment,{children:[!M&&(0,r.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-brand transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":t,onClick:()=>{navigator.clipboard.writeText(t),(0,d.oR)(P("common.copiedPath"))},children:(0,r.jsx)("bdi",{dir:"ltr",children:t})}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[((0,w.C_)(t)||(0,w.OG)(t))&&(0,r.jsx)("button",{onClick:()=>{let e=t.startsWith("/")||!n?t:`${n.replace(/\/$/,"")}/${t}`;(0,w.OG)(t)?O(e):_(e)},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:P((0,w.OG)(t)?"bots.addTooltip":"skills.addTooltip"),children:(0,r.jsx)(a.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:v,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:P("common.close"),children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,r.jsx)(j.l,{content:e,containerRef:er,defaultCollapsed:A}),(0,r.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:er,children:[(0,r.jsx)("div",{className:"p-6",children:(0,r.jsx)(x.T,{content:e,basePath:ee,rehypePlugins:T,onLinkClick:eo})}),ex.map(({key:e,top:t,comments:n})=>(0,r.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:t},onClick:e=>{e.stopPropagation(),Z({comment:n[0],x:e.clientX,y:e.clientY})},children:(0,r.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-lv1 hover:bg-amber-500 transition-colors",children:n.length})},e))]})]}),q&&$&&(0,l.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c.fS,{floatingToolbarRef:ea,bumpRef:el,container:$,onAddComment:ed,onSendToAI:ec,onExplain:D?eu:void 0,isChatLoading:D?.isLoading}),K&&(0,r.jsx)(u.t,{x:K.x,y:K.y,range:K.range,filePath:t,lineSnapshot:K.lineSnapshot,container:$,onSubmit:em,onSendToAI:D?ef:void 0,onClose:()=>G(null),isChatLoading:D?.isLoading}),Q&&(0,r.jsx)(u.G,{x:Q.x,y:Q.y,range:Q.range,filePath:t,lineSnapshot:Q.lineSnapshot,container:$,onSubmit:ep,onClose:()=>J(null),isChatLoading:D?.isLoading}),Y&&(0,r.jsx)(m.t,{x:Y.x,y:Y.y,comment:Y.comment,container:$,onClose:()=>Z(null),onUpdateComment:V,onDeleteComment:U})]}),$)]})}},6744:(e,t,n)=>{n.d(t,{T:()=>O});var r=n(95155),s=n(46361),o=n(79204),a=n(98164),l=n(77815),i=n(97720),d=n(88374);n(84559),n(21227);var c=n(91334),u=n(38194),m=n(88522),h=n(12115),p=n(34582),f=n(3939),g=n(3238),x=n(11890),b=n(73620);function v(e){return{type:"tableCell",children:[{type:"text",value:e}]}}let y=[n(54152).A,function(){return e=>{let t=e.children;for(let e=0;e<t.length;e++){let n=t[e];if("yaml"!==n.type)continue;let r=null;try{let e=b.Ay.load(n.value??"");e&&"object"==typeof e&&!Array.isArray(e)&&(r=e)}catch{r=null}let s=r?Object.entries(r):[];if(0===s.length){t.splice(e,1),e--;continue}let o={type:"tableRow",children:[v("Field"),v("Value")]},a=s.map(([e,t])=>({type:"tableRow",children:[v(e),v(function(e){if(null==e)return"";if("string"==typeof e)return e.replace(/\s*\n\s*/g," ").trim();if("number"==typeof e||"boolean"==typeof e)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}(t))]}));t[e]={type:"table",align:["left","left"],children:[o,...a]}}}}];function w(e){return!(!e.trim()||/\n[ \t]*\n/.test(e)||e.includes("$"))}function k(e){if(!e.includes("\\(")&&!e.includes("\\["))return e;let t=[],n=e=>(t.push(e),`\u0000MATHMASK${t.length-1}\u0000`);return e.replace(/```[\s\S]*?```/g,n).replace(/~~~[\s\S]*?~~~/g,n).replace(/`[^`\n]+`/g,n).replace(/\\\[([^\u0000]*?)\\\]/g,(e,t)=>w(t)?`$$${t}$$`:e).replace(/\\\(([^\u0000]*?)\\\)/g,(e,t)=>w(t)?`$${t}$`:e).replace(/\u0000MATHMASK(\d+)\u0000/g,(e,n)=>t[+n])}var C=n(44902),j=n(70570);let N=[C.A,j.A];var S=n(48250),T=n(20768);let E="data-session-link";function R(){return e=>{(0,S.YR)(e,"text",(e,t,n)=>{if(!n||void 0===t||!e.value?.includes("/project?")||"link"===n.type||"linkReference"===n.type)return;let r=(0,f.ke)(e.value);if(!r.some(e=>"link"===e.kind))return;let s=r.map(e=>"text"===e.kind?{type:"text",value:e.text}:{type:"link",url:e.text,children:[{type:"text",value:e.text}],data:{hProperties:{[E]:""}}});return n.children.splice(t,1,...s),[T._Z,t+s.length]})}}var M=n(69924);let L=[...y,o.A,...N,a.A,function(){return(e,t)=>{let n=String(t?.value??"");n&&function e(t,n){let r=t.children;if(r)for(let s=0;s<r.length;s++)n(r[s],s,t),e(r[s],n)}(e,(e,t,r)=>{var s;if("inlineMath"!==e.type)return;let o=e.position?.start?.offset,a=e.position?.end?.offset;void 0!==o&&void 0!==a&&(s=e.value??"","$$"!==n.slice(o,o+2)&&(!s||/^\s|\s$/.test(s)||/\d/.test(n[o-1]??"")||/\d/.test(n[a]??"")||0)&&(r.children[t]={type:"text",value:n.slice(o,a),position:e.position}))})}},l.jb,R],I=[...y,o.A,...N,l.jb,R],A=[i.A,d.A],F=[i.A];function P(e){let t=[],n=e=>(t.push(e),` MASK${t.length-1} `);return e.replace(/```[\s\S]*?```/g,e=>n(e)).replace(/~~~[\s\S]*?~~~/g,e=>n(e)).replace(/^(\|.+\|)$/gm,e=>/^\|[\s:|-]+\|$/.test(e)?e:e.replace(/`([^`]*)`/g,(e,t)=>t.includes("|")?"`"+t.replace(/\|/g,"\\|")+"`":e)).replace(/ MASK(\d+) /g,(e,n)=>t[+n])}let $=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clippath","defs","ellipse","g","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","text","tspan","use"]);function D(e){let t=[],n=e=>(t.push(e),`\u0000MASK${t.length-1}\u0000`);return e.replace(/```[\s\S]*?```/g,e=>n(e)).replace(/~~~[\s\S]*?~~~/g,e=>n(e)).replace(/`[^`\n]+`/g,e=>n(e)).replace(/<\/?([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(e,t)=>{let n=t.toLowerCase();return $.has(n)||n.includes("-")?e:e.replace(/</g,"<").replace(/>/g,">")}).replace(/\u0000MASK(\d+)\u0000/g,(e,n)=>t[+n])}function _({code:e}){let[t,n]=(0,h.useState)(!1),s=(0,h.useRef)(null);return(0,h.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]),(0,r.jsx)("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{n(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>n(!1),1500)})},title:t?"Copied":"Copy","aria-label":"Copy code",className:"absolute top-2 right-2 p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-foreground/10 opacity-0 group-hover/code:opacity-100 focus-visible:opacity-100 transition-opacity",children:(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t?(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})})}let O=(0,h.memo)(function({content:e,isUser:t=!1,isStreaming:n=!1,enableMath:o=!0,isDark:a,rehypePlugins:l,onLinkClick:i,basePath:d}){let b=(0,g.Ql)(),v=a??b?.resolvedTheme==="dark",y=(0,h.useRef)(null),w=(0,h.useMemo)(()=>({code({className:e,children:t,node:n,...s}){let o=/language-(\w+)/.exec(e||"");if(!("string"==typeof t||"number"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e||"number"==typeof e)))return(0,r.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent font-mono",...s,children:t});let a=String(t);if(!o&&!e&&!a.includes("\n"))return(0,r.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent font-mono",...s,children:t});let l=a.replace(/\n$/,""),i=o?.[1]||"text",d=Number(s["data-source-start"])||0,h=d?d+1:0,p=0;return(0,r.jsxs)("div",{className:"group/code relative font-mono",style:{margin:"1.35em 0"},children:[(0,r.jsx)(c.A,{style:v?u.A:m.A,language:i,PreTag:"div",className:"md-figure",customStyle:{margin:0,borderRadius:"0.375rem",fontSize:"0.92em",fontFamily:"inherit"},codeTagProps:{className:`language-${i}`,style:{fontFamily:"inherit"}},wrapLines:!0,lineProps:()=>{let e=h+p;return p++,{"data-source-start":e,"data-source-end":e,style:{display:"block"}}},children:l}),(0,r.jsx)(_,{code:l})]})},p:({children:e,node:t,...n})=>(0,r.jsx)("p",{...n,children:e}),h1:({children:e,node:t,...n})=>(0,r.jsx)("h1",{...n,children:e}),h2:({children:e,node:t,...n})=>(0,r.jsx)("h2",{...n,children:e}),h3:({children:e,node:t,...n})=>(0,r.jsx)("h3",{...n,children:e}),ul:({children:e,node:t,...n})=>(0,r.jsx)("ul",{className:"list-disc",...n,children:e}),ol:({children:e,node:t,...n})=>(0,r.jsx)("ol",{className:"list-decimal",...n,children:e}),li:({children:e,node:t,...n})=>(0,r.jsx)("li",{...n,children:e}),blockquote:({children:e,node:t,...n})=>(0,r.jsx)("blockquote",{className:"border-l-2 border-border pl-4 text-muted-foreground",...n,children:e}),a:({href:e,children:t,node:n,...s})=>{let o=e&&E in s?(0,f.iy)(e):null;return o?(0,r.jsx)(M.B,{href:e,target:o,newTab:!0,onClick:t=>{i?.(e)&&t.preventDefault()}}):(0,r.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand hover:underline",...s,onClick:t=>{if(e){if(e.startsWith("#")){(0,x.O)(y.current,e.slice(1))&&t.preventDefault();return}i?.(e)&&t.preventDefault()}},children:t})},table:({children:e,node:t,...n})=>(0,r.jsx)("div",{className:"md-figure overflow-x-auto",...n,children:(0,r.jsx)("table",{className:"min-w-full border border-border",children:e})}),thead:({children:e,node:t,...n})=>(0,r.jsx)("thead",{className:"bg-accent",...n,children:e}),th:({children:e,node:t,...n})=>(0,r.jsx)("th",{className:"px-4 py-2 text-left font-semibold border-b border-border",...n,children:e}),td:({children:e,node:t,...n})=>(0,r.jsx)("td",{className:"px-4 py-2 border-b border-border",...n,children:e}),hr:({node:e,...t})=>(0,r.jsx)("hr",{className:"border-border",...t}),img:({src:e,alt:t,node:n,height:s,width:o,style:a,...l})=>{let i=d&&"string"==typeof e?(0,p.xh)(e,d):e;if(!(s||o||a))return(0,r.jsx)("img",{src:i,alt:t||"",className:"max-w-full h-auto rounded-lg my-3",...l});let c=e=>e?/^\d+$/.test(String(e))?`${e}px`:String(e):void 0,u={...a,height:c(s)??a?.height,width:c(o)??a?.width};return(0,r.jsx)("img",{src:i,alt:t||"",style:u,className:"inline-block align-middle",...l})},strong:({children:e,node:t,...n})=>(0,r.jsx)("strong",{className:"font-bold",...n,children:e}),em:({children:e,node:t,...n})=>(0,r.jsx)("em",{className:"italic",...n,children:e}),del:({children:e,node:t,...n})=>(0,r.jsx)("del",{className:"line-through",...n,children:e})}),[v,i,d]),C=o?L:I,j=o?A:F,N=(0,h.useMemo)(()=>{if(t||n)return D(e);let r=D(P(!function(e){if(/^\|[\s:|-]+\|$/m.test(e))return!1;if(/[┌┐└┘│─├┤┬┴┼╔╗╚╝║═╭╮╯╰▲▼◀▶△▽◁▷]/.test(e)||/\+[-=]{2,}\+/.test(e))return!0;let t=e.split("\n").filter(e=>/^\s*\||\|\s*$/.test(e));if(t.length>=3){let e=t.map(e=>(e.match(/\|/g)||[]).length);return!e.every(t=>t===e[0])||!(e[0]>=3)}return!1}(e)||/^```[\s\S]*```$/m.test(e.trim())?e:"```text\n"+e.trim()+"\n```"));return o?k(r):r},[e,t,n,o]),S=(0,h.useMemo)(()=>l?.length?[...j,...l]:j,[l,j]);if(t)return(0,r.jsx)("div",{className:"reading-measure whitespace-pre-wrap break-words",children:e});if(n){let t=e.lastIndexOf("\n");if(-1===t)return(0,r.jsx)("div",{className:"reading-measure whitespace-pre-wrap break-words",children:e});let n=e.slice(0,t+1),a=e.slice(t+1);return(0,r.jsxs)("div",{className:"markdown-body",ref:y,children:[(0,r.jsx)(s.oz,{remarkPlugins:C,rehypePlugins:j,components:w,children:o?k(D(P(n))):D(P(n))}),a&&(0,r.jsx)("span",{className:"md-tail whitespace-pre-wrap",children:a})]})}return(0,r.jsx)("div",{className:"markdown-body",ref:y,children:(0,r.jsx)(s.oz,{remarkPlugins:C,rehypePlugins:S,components:w,children:N})})})},7320:(e,t,n)=>{n.d(t,{G:()=>l,t:()=>a});var r=n(95155),s=n(12115),o=n(79114);function a({x:e,y:t,range:n,filePath:l,lineSnapshot:i,container:d,onSubmit:c,onSendToAI:u,onClose:m,isChatLoading:h}){let{t:p}=(0,o.Bd)(),[f,g]=(0,s.useState)(""),[x,b]=(0,s.useState)(!1),v=(0,s.useRef)(null),y=(0,s.useRef)(null),[w,k]=(0,s.useState)({x:0,y:0}),C=i?.split("\n").slice(0,5).join("\n"),j=!!i&&i.split("\n").length>5;(0,s.useEffect)(()=>{if(v.current&&d){let n=d.getBoundingClientRect(),r=v.current.getBoundingClientRect(),s=e-n.left,o=t-n.top;s+r.width>n.width-16&&(s=n.width-r.width-16),s<16&&(s=16),o+r.height>n.height-16&&(o=o-r.height-8),o<16&&(o=16),queueMicrotask(()=>k({x:s,y:o}))}},[e,t,d]),(0,s.useEffect)(()=>{y.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{x||!v.current||v.current.contains(e.target)||m()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[m,x]);let N=()=>{!x&&f.trim()&&(b(!0),c(f.trim()))};return(0,r.jsxs)("div",{ref:v,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:w.x,top:w.y},children:[(0,r.jsxs)("div",{className:"px-3 py-2 bg-amber-9/10 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-amber-11",children:p("comments.addComment")}),(n.start>0||n.end>0)&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:p("comments.lineRange",{start:n.start,end:n.end})})]}),l&&(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:l})]}),i&&(0,r.jsx)("div",{className:"px-3 py-2 border-b border-border max-h-24 overflow-hidden",children:(0,r.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[C,j&&(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,r.jsxs)("div",{className:"p-2",children:[(0,r.jsx)("textarea",{ref:y,value:f,onChange:e=>g(e.target.value),placeholder:p("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:x,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),N()),"Escape"!==e.key||x||m()}}),(0,r.jsxs)("div",{className:"mt-1 flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:p(x?"comments.submitting":"comments.enterSubmit")}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("button",{className:"px-3 py-1 text-xs font-medium border border-amber-11 text-amber-11 rounded-md hover:bg-amber-9/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:N,disabled:x||!f.trim(),children:p("comments.submitComment")}),u&&(0,r.jsx)("button",{className:"px-3 py-1 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:()=>{!x&&!h&&u&&f.trim()&&(b(!0),u(f.trim()),m())},disabled:x||h||!f.trim(),title:h?p("comments.aiResponding"):void 0,children:p("comments.sendToAI")})]})]})]})]})}function l({x:e,y:t,range:n,filePath:a,lineSnapshot:i,container:d,onSubmit:c,onClose:u,isChatLoading:m}){let{t:h}=(0,o.Bd)(),[p,f]=(0,s.useState)(""),g=(0,s.useRef)(null),x=(0,s.useRef)(null),[b,v]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(g.current&&d){let n=d.getBoundingClientRect(),r=g.current.getBoundingClientRect(),s=e-n.left,o=t-n.top;s+r.width>n.width-16&&(s=n.width-r.width-16),s<16&&(s=16),o+r.height>n.height-16&&(o=o-r.height-8),o<16&&(o=16),queueMicrotask(()=>v({x:s,y:o}))}},[e,t,d]),(0,s.useEffect)(()=>{x.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&u()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]);let y=i?.split("\n").slice(0,5).join("\n"),w=!!i&&i.split("\n").length>5;return(0,r.jsxs)("div",{ref:g,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:b.x,top:b.y},children:[(0,r.jsxs)("div",{className:"px-3 py-2 bg-brand/10 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-brand",children:h("comments.askAI")}),(n.start>0||n.end>0)&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:h("comments.lineRange",{start:n.start,end:n.end})})]}),a&&(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:a})]}),i&&(0,r.jsx)("div",{className:"px-3 py-2 border-b border-border max-h-24 overflow-hidden",children:(0,r.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[y,w&&(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,r.jsxs)("div",{className:"p-2",children:[(0,r.jsx)("textarea",{ref:x,value:p,onChange:e=>f(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:m,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!m&&p.trim()&&(c(p.trim()),u())),"Escape"===e.key&&u()}}),(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:h(m?"comments.aiGenerating":"comments.enterSend")})]})]})}},7578:(e,t,n)=>{n.d(t,{S:()=>a,l:()=>l});var r=n(95155),s=n(68287),o=n(16147);function a(e){return"loading"===e||"unread"===e?e:"normal"}function l({projectNumber:e,sessionNumber:t,coordinate:n,status:a="normal",statusLabel:i,bot:d,className:c=""}){if(n){let[r,s]=n.split(".");e??=r,t??=s}if(null==e&&null==t&&"normal"!==a&&(t="\xb7"),null==e&&null==t)return null;let u=[e,t].filter(e=>null!=e).join(".");return(0,r.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[9px] font-medium leading-none tabular-nums flex-shrink-0 ${c}`,"aria-label":i?`${u} \xb7 ${i}`:u,children:[null!=e&&(0,r.jsx)("span",{className:`flex h-4 w-4 items-center justify-center border rounded-[4px] ${(0,s.ci)("normal",!1)}`,children:e}),null!=t&&(0,r.jsx)(o.w,{wash:(0,s.JQ)(a,!1),ring:(0,s.QV)(a),bot:d,title:i,children:t})]})}},8183:(e,t,n)=>{n.d(t,{EF:()=>m,OS:()=>c,V6:()=>i,X4:()=>u,Yn:()=>d,c4:()=>f,eh:()=>p,iM:()=>h,kz:()=>l});let r=new Map,s=new Set,o=new Map,a=new Map,l=(e,t)=>`${e}
|
|
2
2
|
${t.match(/([0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})(?:\.jsonl)?$/i)?.[1]??t}`,i=()=>r,d=()=>a,c=e=>(s.add(e),()=>{s.delete(e)});function u(e){m([e])}function m(e,t){let n;for(let s of e){let e=l(s.cwd,s.sessionId),o=(n??r).get(e);o&&(o.titleRevision>s.titleRevision||JSON.stringify(o)===JSON.stringify(s)||t&&o!==t.get(e)&&o.titleRevision===s.titleRevision)||(n??=new Map(r)).set(e,s)}n&&(r=n,s.forEach(e=>e()))}function h(e,t,n,r,s=-1){let o=e.get(l(t,n));return!o||s>o.titleRevision?r:null!==o.customTitle?o.customTitle:s>=o.titleRevision?r:o.title}function p(e,t){let n=l(e,t),r=o.get(n)??{cwd:e,sessionId:t,count:0};return r.count++,o.set(n,r),()=>{0==--r.count&&o.delete(n)}}let f=()=>[...o.values()]},8601:(e,t,n)=>{n.d(t,{BV:()=>i,NR:()=>y,Yd:()=>C,kn:()=>d,oJ:()=>f,zC:()=>k});var r=n(95155),s=n(12115),o=n(64428),a=n(57125),l=n(53317);let i="claude-opus-5-5",d="gpt-6.2-sol",c=[{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra High"},{id:"max",label:"Max"},{id:"ultracode",label:"Ultracode"},{id:"ultrathink",label:"Ultrathink"}],u=[{id:"claude-sonnet-5-5",label:"Claude Sonnet 5.5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"medium"},{id:"claude-sonnet-5",label:"Claude Sonnet 5",effort:["low","medium","high","xhigh","max","ultrathink"],defaultEffort:"high"},{id:"claude-opus-5-5",label:"Claude Opus 5.5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"medium",fast:!0},{id:"claude-opus-5",label:"Claude Opus 5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",fast:!0},{id:"claude-fable-5-1",label:"Claude Fable 5.1",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high"},{id:"claude-haiku-5-5",label:"Claude Haiku 5.5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"medium"},{id:"claude-haiku-4-5",label:"Claude Haiku 4.5",thinking:!0}],m=[{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra High"},{id:"max",label:"Max"},{id:"ultra",label:"Ultra",description:"Max reasoning with parallel agents"}],h=[{id:"gpt-6.2-sol",label:"GPT-6.2 Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"high"},{id:"gpt-6.2-astra",label:"GPT-6.2 Astra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"high"},{id:"gpt-6.1-terra",label:"GPT-6.1 Terra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"medium"},{id:"gpt-6.1-sol",label:"GPT-6.1 Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"high"},{id:"gpt-6-astra",label:"GPT-6 Astra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"high"},{id:"gpt-6-sol",label:"GPT-6 Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"high"},{id:"gpt-6-luna",label:"GPT-6 Luna",reasoning:["low","medium","high","xhigh","max"],defaultReasoning:"medium"},{id:"gpt-5.6-sol",label:"GPT-5.6 Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"high"},{id:"gpt-5.6-terra",label:"GPT-5.6 Terra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"medium"},{id:"gpt-5.6-luna",label:"GPT-5.6 Luna",reasoning:["low","medium","high","xhigh","max"],defaultReasoning:"medium"}];function p(e){return h.find(t=>t.id===e)?.defaultReasoning??"medium"}function f(e,t){let n=h.find(t=>t.id===e)?.reasoning;return t&&(!n||n.includes(t))?t:p(e)}function g(e,t){return e.find(e=>e.id===t)?.label??t}function x(e){return u.find(t=>t.id===e)?.fast===!0}function b(e){return u.find(t=>t.id===e)?.thinking===!0}function v(e){let t=u.find(t=>t.id===e);return t?t.defaultEffort:"high"}function y(e,t){let n=u.find(t=>t.id===e),r=n?.effort;return t&&(!n||r?.includes(t))?t:v(e)}function w({value:e,selected:t,label:n,description:s,defaultValue:o,onSelect:l}){return(0,r.jsxs)("button",{type:"button",onClick:()=>l(e),className:`flex w-full items-start gap-2 px-3 py-2 text-left text-xs transition-colors ${t?a.yI:"text-muted-foreground hover:bg-hover hover:text-foreground"}`,children:[(0,r.jsx)("span",{className:"mt-0.5",children:(0,r.jsx)(a.hG,{selected:t})}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"block truncate",children:n}),s&&(0,r.jsx)("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:s})]}),(0,r.jsx)("span",{className:"shrink-0",children:o&&(0,r.jsx)("span",{className:"rounded bg-muted px-1.5 text-[10px] font-medium text-muted-foreground",children:"Default"})})]})}function k({title:e,selected:t,value:n,items:l,onSelect:i,icon:d,testId:c}){let u=(0,s.useRef)(null),m=(0,s.useRef)(null),[h,p]=(0,s.useState)(!1),[f,g]=(0,s.useState)({top:0,left:0}),x=(0,o.F2)(),b=l.find(e=>e.id===t)?.description;(0,a.r8)(m,h,f.left);let v=()=>{let e=u.current?.getBoundingClientRect();if(!e)return;let t=x?.getBoundingClientRect(),n=t?.left??0,r=t?.top??0;g({top:e.bottom+4-r,left:e.left-n})};return(0,s.useEffect)(()=>{if(!h)return;let e=e=>{let t=e.target;m.current?.contains(t)||u.current?.contains(t)||p(!1)},t=()=>v();return document.addEventListener("mousedown",e),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[h]),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(a.XY,{buttonRef:u,label:n,labelMaxWidth:"max-w-[180px]",title:`${e}: ${n}${b?`
|
|
3
3
|
${b}`:""}`,onClick:()=>{h||v(),p(e=>!e)},icon:d,testId:c}),h&&(0,r.jsx)(o.ZL,{children:(0,r.jsxs)("div",{ref:m,className:`${a.ys} min-w-[190px]`,style:{top:f.top,left:f.left},children:[(0,r.jsx)("div",{className:"px-3 pb-1 text-[11px] font-medium text-muted-foreground",children:e}),(0,r.jsx)("div",{className:"flex flex-col",children:l.map(e=>(0,r.jsx)(w,{value:e.id,selected:t===e.id,label:e.label,description:e.description,defaultValue:e.defaultValue,onSelect:e=>{i(e),p(!1)}},e.id))})]})})]})}function C(e){let t,n,s,o=e.engine??"claude",w=e.claudeModel??i,C=v(w),j=(t=u.find(e=>e.id===w)?.effort)?t.map(e=>c.find(t=>t.id===e)??{id:e,label:e}):[],N=y(w,e.claudeEffort),S=e.claudeFastMode??!1,T=e.claudeThinking??!1,E=e.codexModel??d,R=p(E),M=(n=h.find(e=>e.id===E)?.reasoning)?n.map(e=>m.find(t=>t.id===e)??{id:e,label:e}):m,L=f(E,e.codexReasoningEffort);return"claude"!==o?(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,r.jsx)(k,{title:"Model",selected:E,value:h.find(e=>e.id===E)?.label??(0,l.U)(E),items:h.map(e=>({id:e.id,label:e.label,defaultValue:e.id===d})),onSelect:t=>{e.onCodexModelChange?.(t),e.onCodexReasoningEffortChange?.(p(t))},icon:(0,r.jsx)(a.eV,{engine:"codex"}),testId:"codex-model-picker"}),(0,r.jsx)(k,{title:"Reasoning",selected:L,value:g(m,L),items:M.map(e=>({...e,defaultValue:e.id===R})),onSelect:t=>e.onCodexReasoningEffortChange?.(t),testId:"codex-reasoning-picker"})]}):(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,r.jsx)(k,{title:"Model",selected:w,value:(s=u.find(e=>e.id===w))?s.label:w.startsWith("claude-")?`Claude ${(0,l.J)(w)}`:w,items:u.map(e=>({id:e.id,label:e.label,defaultValue:e.id===i})),onSelect:t=>{e.onClaudeModelChange?.(t);let n=v(t);n&&e.onClaudeEffortChange?.(n),x(t)||e.onClaudeFastModeChange?.(!1),b(t)||e.onClaudeThinkingChange?.(!1)},icon:(0,r.jsx)(a.eV,{engine:"claude"}),testId:"claude-model-picker"}),N&&j.length>0&&(0,r.jsx)(k,{title:"Reasoning",selected:N,value:g(c,N),items:j.map(e=>({...e,defaultValue:e.id===C})),onSelect:t=>e.onClaudeEffortChange?.(t),testId:"claude-reasoning-picker"}),x(w)&&(0,r.jsx)(k,{title:"Fast Mode",selected:S?"on":"off",value:S?"Fast On":"Fast Off",items:[{id:"on",label:"On"},{id:"off",label:"Off",defaultValue:!0}],onSelect:t=>e.onClaudeFastModeChange?.("on"===t),testId:"claude-fast-mode-picker"}),b(w)&&(0,r.jsx)(k,{title:"Thinking",selected:T?"on":"off",value:T?"Thinking On":"Thinking Off",items:[{id:"on",label:"On"},{id:"off",label:"Off",defaultValue:!0}],onSelect:t=>e.onClaudeThinkingChange?.("on"===t),testId:"claude-thinking-picker"})]})}},9573:(e,t,n)=>{n.d(t,{Ew:()=>l,Tt:()=>d,se:()=>i,xK:()=>a});var r=n(49433),s=n(82680);let o=e=>r.$mh({try:async t=>{let n=await fetch(e,{signal:t});if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()},catch:t=>new s.uV({message:`GET ${e} failed`,cause:t})}),a=(e,t,n)=>o(`/api/snapshots?cwd=${encodeURIComponent(e)}&toolIds=${encodeURIComponent(t.join(","))}${n?`&sessionKey=${encodeURIComponent(n)}`:""}`).pipe(r.TjK(e=>e.commits??[])),l=(e,t,n)=>o(`/api/snapshots/diff?cwd=${encodeURIComponent(e)}&commit=${encodeURIComponent(t)}${void 0===n?"":`&file=${encodeURIComponent(n)}`}`),i=(e,t,n)=>a(e,t,n).pipe(r.qIB(t=>r.Q7R(t.map(t=>l(e,t.hash)),{concurrency:4}))),d=(e,t,n,r)=>o(`/api/snapshots/range-diff?cwd=${encodeURIComponent(e)}&head=${encodeURIComponent(n)}${t?`&base=${encodeURIComponent(t)}`:""}${void 0===r?"":`&file=${encodeURIComponent(r)}`}`)},11890:(e,t,n)=>{function r(e){return e.trim().toLowerCase().replace(/[\s]+/g,"-").replace(/[^\w一-鿿-ヿ가--]/g,"").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"")}function s(e,t){if(!e)return!1;let n=t;try{n=decodeURIComponent(t)}catch{}let s=r(n);if(!s)return!1;for(let t of e.querySelectorAll("h1, h2, h3, h4, h5, h6"))if(r(t.textContent||"")===s)return t.scrollIntoView({behavior:"smooth",block:"start"}),!0;return!1}n.d(t,{O:()=>s})},14575:(e,t,n)=>{n.d(t,{o:()=>a});var r=n(95155);n(12115);let s={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",lean:"#448aff",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"},o={"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 a({name:e,className:t="",size:n=16}){let l,i=o[l=e.toLowerCase()]?o[l]:s[e.split(".").pop()?.toLowerCase()||""]||s.default,d=e.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(d)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,r.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(d)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,r.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"===d||"tsx"===d&&e.includes("component")?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,r.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===d?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.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:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,r.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:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:i})]}):["md","mdx"].includes(d)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("path",{d:"M5 15V9l3 4 3-4v6M17 12l-2-3v6M17 12l2-3v6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["py","pyi","pyx"].includes(d)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.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,r.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,r.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,r.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===d?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:i}),(0,r.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,r.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,r.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,r.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===d?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:i,strokeWidth:"2",fill:"none"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:i}),(0,r.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:i,strokeWidth:"2",strokeLinecap:"round"})]}):"lean"===d?(0,r.jsx)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:(0,r.jsx)("path",{d:"M3.45 1.5 1.5 2.5 12 22.5 22.5 2.5 20.55 1.5 15.9 10.35H8.1ZM9 12h6l-3 6Z",fill:i,fillRule:"evenodd"})}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(d)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:i}),(0,r.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===d?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"html"===d?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,r.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(d)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,r.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(d)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(d)?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,r.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===d||".gitignore"===e.toLowerCase()?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:i}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,r.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===d||"dockerfile"===e.toLowerCase()||e.toLowerCase().startsWith("dockerfile")?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:i}),(0,r.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:i,strokeWidth:"1.5",fill:"none"})]}):"env"===d||e.startsWith(".env")?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:i}),(0,r.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===d?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"vue"===d?(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:i}),(0,r.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,r.jsxs)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,r.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("path",{d:"M14 3v5h5",stroke:i,strokeWidth:"1.5",fill:"none"})]})}},14594:(e,t,n)=>{function r(e,t,n){return t?e?n?`${e.replace(/\n+$/,"")}
|
|
4
4
|
|
|
5
|
-
${t}`:e+t:t:e}function s(e,t,n=!1){let r=e||[];if(!t)return r;let o=r[r.length-1];return n||o?.type!=="text"?[...r,{type:"text",text:t}]:[...r.slice(0,-1),{type:"text",text:o.text+t}]}function o(e){return null!=e.parent_tool_use_id}n.d(t,{FM:()=>u,Nn:()=>o,A7:()=>l,az:()=>i,Uy:()=>d,fD:()=>c});let a=["task_started","task_progress","task_notification"];function l(e){return"system"===e.type&&a.includes(e.subtype??"")}function i(e){return!o(e)&&!e._human&&(l(e)&&!!e.tool_use_id&&!e.ambient||"tool_progress"===e.type&&!!e.tool_call_id||"user"===e.type&&Array.isArray(e.message?.content)&&e.message.content.some(e=>!!e.tool_use_id))}function d(e,t){let n={status:"running",...e};return"task_notification"===t.subtype&&(n.status=t.status??"completed"),t.task_id&&(n.id=t.task_id),t.last_tool_name&&(n.lastToolName=t.last_tool_name),t.summary&&(n.summary=t.summary),"number"==typeof t.usage?.tool_uses&&(n.toolUses=t.usage.tool_uses),"number"==typeof t.usage?.duration_ms&&(n.durationMs=t.usage.duration_ms),n}function c(e){let t=!1,n=e.map(e=>e.toolCalls?.some(e=>e.task?.status==="running")?(t=!0,{...e,toolCalls:e.toolCalls.map(e=>e.task?.status==="running"?{...e,task:{...e.task,status:"unknown"}}:e)}):e);return t?n:e}function u(e,t,n){let{engine:a,assistantId:i}=n;if(o(t))return e;if("system"===t.type&&"input_started"===t.subtype&&t.inputId){let n=e.find(e=>"user"===e.role&&e.liveInputId===t.inputId);if(!n)return e;let r=e.filter(e=>e.id===i||"assistant"!==e.role||e.content||e.toolCalls?.length||e.streamError);if(r.some(e=>e.id===i))return r;let s=r.indexOf(n),o={id:i,role:"assistant",content:"",isStreaming:!0,liveInputId:t.inputId,liveRunId:n.liveRunId,sourceId:void 0,turnStartedAt:n.turnStartedAt,timestamp:n.timestamp,runKey:n.runKey};return[...r.slice(0,s+1),o,...r.slice(s+1)]}if("system"===t.type&&"input_binding"===t.subtype&&t.inputId&&t.sourceId)return e.map(e=>"user"===e.role&&e.liveInputId===t.inputId?{...e,sourceId:t.sourceId}:e);if(l(t)){let n=t.tool_use_id;if(!n||t.ambient)return e;let r=!1,s=e.map(e=>e.toolCalls?.some(e=>e.id===n)?(r=!0,{...e,toolCalls:e.toolCalls.map(e=>e.id===n?{...e,task:d(e.task,t)}:e)}):e);return r?s:e}if("stream_event"===t.type){let n=t.event;if(n?.type==="content_block_delta"&&n.delta?.type==="text_delta"&&n.delta.text){let t=n.delta.text;return e.map(e=>e.id===i?{...e,content:r(e.content||"",t,!!e.pendingTextBreak),parts:s(e.parts,t,!!e.pendingTextBreak),pendingTextBreak:!1}:e)}return e}if("assistant"===t.type){let n=t.message?.content;if(!Array.isArray(n))return e;let o=e,l=t.message?.model==="<synthetic>";if("codex"===a||"ollama"===a||l){let e=n.filter(e=>"text"===e.type&&e.text).map(e=>e.text).join("");e&&(o=o.map(t=>t.id===i?{...t,content:r(t.content||"",e,!!t.pendingTextBreak),parts:s(t.parts,e,!!t.pendingTextBreak),pendingTextBreak:!1}:t))}for(let e of n)if(e.name){let t={id:e.id||`tool-${i}-${e.name}`,name:e.name,input:e.input||{},isLoading:!0};o=o.map(e=>e.id!==i||e.toolCalls?.some(e=>e.id===t.id)?e:{...e,toolCalls:[...e.toolCalls||[],t],parts:function(e,t){let n=e||[];return n.some(e=>"tool"===e.type&&e.id===t)?n:[...n,{type:"tool",id:t}]}(e.parts,t.id),pendingTextBreak:!0})}return o}if("tool_progress"===t.type&&t.tool_call_id){let n=t.progress_text??"";return e.map(e=>e.toolCalls?.some(e=>e.id===t.tool_call_id&&e.isLoading)?{...e,toolCalls:e.toolCalls.map(e=>e.id===t.tool_call_id?{...e,result:n}:e)}:e)}if("user"===t.type){let n=t.message?.content;if(!Array.isArray(n))return e;let r=e;for(let e of n)if(e.tool_use_id){let t=e.tool_use_id,n="string"==typeof e.content?e.content:JSON.stringify(e.content),s={..."boolean"==typeof e.is_error?{isError:e.is_error}:{},..."number"==typeof e.exit_code?{exitCode:e.exit_code}:{}};r=r.map(e=>e.toolCalls?.some(e=>e.id===t)?{...e,toolCalls:e.toolCalls.map(e=>e.id===t?{...e,result:n,isLoading:!1,...s}:e)}:e)}return r}if("error"===t.type){let n=t.error||"An error occurred. Please try again.",o=`⚠️ ${n}`;if(t.undeliveredInputs?.length){let r=e;for(let[e,s]of t.undeliveredInputs.entries()){let t=`undelivered-${s.inputId??`${i}-${e}`}`;if(r.some(e=>e.id===t))continue;let l=r.find(e=>"user"===e.role&&s.inputId&&e.liveInputId===s.inputId);if(l||(r=[...r,l={id:`${t}-input`,role:"user",content:s.text??"",images:s.images,liveInputId:s.inputId}]),"codex"===a){let e={...l,turnId:t,sourceTaskId:void 0};r=r.map(t=>t===l?e:t),l=e}let d=r.indexOf(l),c=r.findIndex((e,t)=>t>d&&"user"===e.role),u=c<0?r.length:c,m={id:t,role:"assistant",content:o,streamError:n,turnId:"codex"===a?t:void 0,liveInputId:s.inputId,liveRunId:l.liveRunId,timestamp:l.timestamp,isStreaming:!1};r=[...r.slice(0,u),m,...r.slice(u)]}return r}return e.map(e=>e.id===i?{...e,content:r(e.content||"",o,!0),streamError:n,parts:s(e.parts,o,!0),isStreaming:!1}:e)}if("result"===t.type){let n="string"==typeof t.result?t.result.trim():"";return e.map(e=>e.id===i?{...e,content:!e.content&&n?n:e.content,parts:!e.content&&n?s(e.parts,n):e.parts,isStreaming:!1,toolCalls:e.toolCalls?.map(e=>({...e,isLoading:!1}))}:e)}return e}},16147:(e,t,n)=>{n.d(t,{w:()=>o});var r=n(95155);let s="font-mono text-[9px] font-medium leading-none tabular-nums transition-colors";function o({children:e,wash:t,ring:n="",bot:a,className:l="",tooltip:i,title:d,role:c,ariaLabel:u,ariaHidden:m}){let h={title:d,role:c,"aria-label":u,"aria-hidden":m?"true":void 0,"data-tooltip":i??(a?`@${a}`:void 0)};return a?(0,r.jsx)("span",{className:`relative -m-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center ${n} ${l}`,...h,children:(0,r.jsx)("span",{className:`session-number-bot flex h-full w-full items-center justify-center ${s} ${t}`,children:(0,r.jsx)("span",{className:"translate-y-[1.5px]",children:e})})}):(0,r.jsx)("span",{className:`flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border ${s} ${n} ${t} ${l}`,...h,children:e})}},17196:(e,t,n)=>{n.d(t,{Np:()=>c,ZD:()=>l,ZR:()=>i,b8:()=>d,kS:()=>o,sQ:()=>a});let r=null,s=["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","lean4"];function o(){return r||(r=Promise.all([n.e(49304),n.e(64523)]).then(n.bind(n,64523)).then(({createHighlighter:e})=>e({themes:["github-dark","github-light"],langs:[...s]}))),r}function a(e){let t=e.split("/").pop()?.toLowerCase()||"",n=t.split(".").pop()?.toLowerCase();if(".env"===t||t.startsWith(".env.")||"dockerfile"===t||t.startsWith("dockerfile.")||"makefile"===t)return"bash";let r={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",lean:"lean4",toml:"yaml",sass:"scss",less:"css",scala:"java",r:"python",vim:"bash",env:"bash"}[n||""]||"text";return s.includes(r)?r:"text"}function l(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}let i=2e3;function d(e){return e.length>i?l(e.map(e=>e.content).join("")):e.map(e=>e.color?`<span style="color:${e.color}">${l(e.content)}</span>`:l(e.content)).join("")}function c(e,t,n,r){if(!t)return[];let s=[],o=n?t:t.toLowerCase();for(let t=0;t<e.length;t++){let a=n?e[t]:e[t].toLowerCase(),l=0;for(;;){let e=a.indexOf(o,l);if(-1===e)break;let n=e+o.length;if(r){let r=e>0?a[e-1]:" ",o=n<a.length?a[n]:" ",l=!/\w/.test(r),i=!/\w/.test(o);l&&i&&s.push({lineIndex:t,startCol:e,endCol:n})}else s.push({lineIndex:t,startCol:e,endCol:n});l=e+1}}return s}},19095:(e,t,n)=>{n.d(t,{r:()=>r});function r(e){let t=0,n=0;for(let r of e)/[\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\u{20000}-\u{2a6df}\uac00-\ud7af]/u.test(r)?t+=1:n+=1;return Math.max(1,Math.ceil(t+n/4))}},19502:(e,t,n)=>{n.d(t,{YO:()=>s,aj:()=>r,pU:()=>o});let r=3,s=20;function o(e,t,n,a=[]){let l=e.length,i=n=>"unchanged"!==e[n].type||"unchanged"!==t[n].type,d=new Set;for(let e=0;e<l;e++){if(!i(e))continue;let t=Math.max(0,e-r),n=Math.min(l-1,e+r);for(let e=t;e<=n;e++)d.add(e)}let c=[];for(let e=0;e<l;e++){if(d.has(e))continue;let t=e;for(;e<l&&!d.has(e);)e++;c.push({id:c.length,startIdx:t,endIdx:e-1}),e--}for(let e of c){let t=n.get(e.id)??{topRevealed:0,bottomRevealed:0},r=e.endIdx-e.startIdx+1,s=Math.max(0,Math.min(t.topRevealed,r)),o=Math.max(0,Math.min(t.bottomRevealed,r-s));for(let t=e.startIdx;t<e.startIdx+s;t++)d.add(t);for(let t=e.endIdx-o+1;t<=e.endIdx;t++)d.add(t)}let u=[];for(let e=0;e<l;e++){let n;if(d.has(e)){u.push({kind:"diff",idx:e});continue}let r=e;for(;e<l&&!d.has(e);)e++;let o=e-1;e--;let i=c.find(e=>e.startIdx<=r&&o<=e.endIdx);if(!i)continue;let m=o-r+1,h=Math.min(s,m);if(a.length>0&&o+1<l)for(let e=o+1;e<l;e++){let r=t[e].lineNum;if(!(r<=0)){n=function(e,t){let n=null;for(let r of e)r.startLine<=t&&t<=r.endLine&&(!n||r.endLine-r.startLine<n.endLine-n.startLine)&&(n=r);return n}(a,r)??void 0;break}}u.push({kind:"gap-expand",gapId:i.id,direction:"up",revealCount:h}),u.push({kind:"gap-label",gapId:i.id,hiddenCount:m,enclosingFn:n}),u.push({kind:"gap-expand",gapId:i.id,direction:"down",revealCount:h})}return{rows:u,gaps:c}}},20073:(e,t,n)=>{n.d(t,{u:()=>o});var r=n(95155),s=n(8601);function o({options:e,level:t,onChange:n}){if(!e||!t||"none"===e.mode||!e.levels.some(e=>"off"!==e))return null;let a=t=>{let n=e.labels[t]??t;return n.charAt(0).toUpperCase()+n.slice(1)};return e.levels.length<=1?(0,r.jsx)("span",{className:"text-xs text-muted-foreground",title:"This model requires thinking","data-testid":"pi-thinking-required",children:a(t)}):(0,r.jsx)(s.zC,{title:"required"===e.mode?"Thinking (required)":"Thinking",selected:t,value:a(t),items:e.levels.map(t=>({id:t,label:a(t),defaultValue:t===e.defaultLevel})),onSelect:n,testId:"pi-thinking-picker"})}},20080:(e,t,n)=>{n.d(t,{K:()=>l});var r=n(95155),s=n(12115),o=n(79114);function a({label:e,labelClassName:t,src:n,node:l,alt:i}){let{t:d}=(0,o.Bd)(),[c,u]=(0,s.useState)(!1);return(0,r.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col items-center gap-2",children:[(0,r.jsx)("div",{className:`text-xs font-medium ${t}`,children:e}),(0,r.jsx)("div",{className:"w-full flex-1 flex items-center justify-center rounded border border-border bg-secondary p-3 min-h-[8rem]",children:l?(0,r.jsx)("div",{className:"w-full min-w-0",children:l}):c?(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:d("diffViewer.imageLoadFailed")}):(0,r.jsx)("img",{src:n,alt:i,onError:()=>u(!0),className:"max-w-full max-h-[60vh] object-contain"})})]})}function l({filePath:e,oldSrc:t,newSrc:n,oldNode:s,newNode:i}){let{t:d}=(0,o.Bd)(),c=!!s||!!t,u=!!i||!!n;return(0,r.jsxs)("div",{className:"h-full overflow-auto p-4",children:[(0,r.jsx)("div",{className:"text-xs font-mono text-muted-foreground mb-3 truncate",children:e}),c||u?(0,r.jsxs)("div",{className:"flex flex-wrap items-stretch gap-4",children:[c&&(0,r.jsx)(a,{label:d(u?"diffViewer.imageBefore":"diffViewer.imageDeleted"),labelClassName:"text-red-11",src:t,node:s,alt:`${e} (before)`}),u&&(0,r.jsx)(a,{label:d(c?"diffViewer.imageAfter":"diffViewer.imageAdded"),labelClassName:"text-green-11",src:n,node:i,alt:`${e} (after)`})]}):(0,r.jsx)("div",{className:"text-sm text-muted-foreground",children:d("diffViewer.imageUnavailable")})]})}},20235:(e,t,n)=>{n.d(t,{GI:()=>a,_9:()=>l,s1:()=>d,zl:()=>i});var r=n(95155),s=n(12115),o=n(23970);let a="inline-block rounded bg-brand/15 px-1.5 text-brand",l=`mr-1.5 text-[0.9em] ${a}`,i=(0,s.memo)(function({text:e,matchLine:t,variant:n}){let s=[];return e.split("\n").forEach((e,o)=>{o>0&&s.push("\n");let a=t(e);if(!a)return void s.push(e);let i=e.slice(a.start,a.end),d=e.slice(a.end);if("chip"===n)s.push(e.slice(0,a.start),(0,r.jsx)("span",{className:l,children:i},o),d.replace(/^\s+/,""));else{let t=(0,r.jsx)("span",{className:"inline-block rounded bg-brand/15 text-brand ring-2 ring-brand/15",children:(0,r.jsx)("span",{className:"inline-block scale-[0.9]",children:i})},o);s.push(e.slice(0,a.start),t,d)}}),(0,r.jsx)(r.Fragment,{children:s})});function d({value:e,textareaRef:t,matchLine:n,boxClassName:a,colorClassName:l,className:c="",wrapperClassName:u="",onScroll:m,onKeyDown:h,...p}){let f=(0,s.useMemo)(()=>e.split("\n").some(e=>null!==n(e)),[e,n]),g=(0,s.useRef)(null),x=(0,s.useCallback)(()=>{let e=t.current,n=g.current;e&&n&&(n.style.width=`${e.clientWidth+2*e.clientLeft}px`,n.scrollTop=e.scrollTop)},[t]);return(0,s.useLayoutEffect)(()=>{if(!f)return;x();let e=t.current;if(!e)return;let n=new ResizeObserver(x);return n.observe(e),()=>n.disconnect()},[f,x,t]),(0,s.useLayoutEffect)(()=>{f&&x()},[f,e,x]),(0,r.jsxs)("div",{className:`relative ${u}`,children:[f&&(0,r.jsxs)("div",{ref:g,"aria-hidden":!0,className:`pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap break-words ${a} ${l}`,children:[(0,r.jsx)(i,{text:e,matchLine:n,variant:"mark"}),""]}),(0,r.jsx)("textarea",{ref:t,value:e,onKeyDown:e=>{let t=e.currentTarget;if(("Backspace"===e.key||"Delete"===e.key)&&!e.nativeEvent.isComposing&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&t.selectionStart===t.selectionEnd){let r=(0,o.AM)(t.value,t.selectionStart,e.key,n);if(r){e.preventDefault(),t.setSelectionRange(r[0],r[1]),document.execCommand("delete")||(t.setRangeText("",r[0],r[1],"start"),t.dispatchEvent(new Event("input",{bubbles:!0})));return}}h?.(e)},onScroll:e=>{f&&x(),m?.(e)},className:`relative block w-full whitespace-pre-wrap break-words ${a} ${f?"bg-transparent text-transparent caret-foreground selection:text-transparent selection:bg-[Highlight]":l} ${c}`,...p})]})}},20832:(e,t,n)=>{n.d(t,{p:()=>c});var r=n(95155),s=n(12115),o=n(79114),a=n(86957),l=n(33199),i=n(97938),d=n(32456);function c({cwd:e,sessionId:t,subtitle:n,emptyText:u,onOpenSession:m}){let{t:h}=(0,o.Bd)(),[p,f]=(0,s.useState)(null),g=(0,s.useRef)(void 0);(0,s.useEffect)(()=>{let n=!1,r=async()=>{let r=await a.t4.runPromiseExit((0,i.z)({cwd:e,sessionId:t,limit:10,ifFingerprint:g.current}));if(n)return;if("Success"!==r._tag||!r.value)return void f(e=>e??[]);let s=r.value;s.fingerprint&&(g.current=s.fingerprint),!s.notModified&&s.messages&&f(s.messages)};r();let s=setInterval(r,5e3);return()=>{n=!0,clearInterval(s)}},[e,t]);let x=(0,s.useRef)(null),b=(0,s.useRef)(null),v=(0,s.useRef)(!0),[y,w]=(0,s.useState)(!0),k=(0,s.useCallback)(()=>{let e=x.current;if(!e)return;let t=e.scrollTop+e.clientHeight>=e.scrollHeight-40;v.current=t,w(t||e.scrollTop<=40)},[]);return(0,s.useLayoutEffect)(()=>{let e=x.current;e&&v.current&&(e.scrollTop=e.scrollHeight)},[p]),(0,s.useEffect)(()=>{let e=b.current;if(!e)return;let t=new ResizeObserver(k);return t.observe(e),()=>t.disconnect()},[k,p]),(0,r.jsxs)("div",{className:"flex-1 flex flex-col h-full min-w-0",children:[(0,r.jsx)("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border flex-shrink-0",children:(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-foreground truncate","data-tooltip":e,children:(0,d.Qr)(e)}),(0,r.jsx)("div",{className:"text-[11px] text-muted-foreground truncate","data-tooltip":n,children:n})]})}),(0,r.jsxs)("div",{className:"relative flex-1 min-h-0 flex",children:[(0,r.jsx)("div",{ref:x,onScroll:k,className:"flex-1 overflow-y-auto px-8 py-4",children:null===p||0===p.length?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-6",children:null===p?h("common.loading"):u}):(0,r.jsx)("div",{ref:b,className:"mx-auto w-full max-w-[var(--chat-column)] [&_a]:pointer-events-none",children:p.map(t=>(0,r.jsx)(l.s,{message:t,cwd:e,disableOverlays:!0},t.id))})}),(0,r.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center pb-4",children:(0,r.jsxs)("button",{onClick:m,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-brand text-white text-sm font-medium shadow-lv3 hover:bg-brand/90 transition-opacity ${y?"opacity-100 pointer-events-auto":"opacity-0"}`,title:h("scheduledTasks.openSession"),children:[(0,r.jsx)("span",{children:h("scheduledTasks.openSession")}),(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7-7 7M3 12h18"})})]})})]})]})}},20917:(e,t,n)=>{n.d(t,{R:()=>b,e:()=>w});var r=n(95272),s=n(12115),o=n(49433),a=n(86957),l=n(95595),i=n(83448),d=n(19095),c=n(14594),u=n(67958),m=n(98245),h=n(65153),p=n(69809),f=n(34075),g=n(2111),x=n(99356);let b=[];function v(){try{return crypto.randomUUID()}catch{return`run-${Date.now()}-${Math.floor(1e9*Math.random())}`}}function y({run:e,update:t,engine:n,onAccepted:r,onEnd:s,onDeleted:o,onSettled:a}){return(0,h.u)(e.runKey,t,!0,n,{onlyRunId:e.id,onSnapshotStart:e=>{r?.(e),t(e.id,[])},onRunEnd:(t,n,r)=>{s?.(t,n,r),t||a(e.id)},onRecoveryDeleted:o,onWriterIdle:()=>{s?.(!1,e.id),a(e.id)}}),null}function w(e,t,{sessionId:n,cwd:k,engine:C,planMode:j,noHistory:N,ollamaModel:S,engineModel:T,piThinkingLevel:E,claudeModel:R,claudeEffort:M,claudeFastMode:L,claudeThinking:I,codexModel:A,codexReasoningEffort:P,grokModel:F,grokReasoningEffort:$,onSessionId:D,onFetchTitle:_,onSendStart:B,onRunEnd:O,onRunAccepted:H,onSendFailure:V,onInputRejected:U,onRecoveryDeleted:W,taskStore:q}){let z=(0,s.useId)(),K=(0,s.useRef)(n),G=(0,s.useRef)({cwd:k,sessionId:n}),[Q,J]=(0,s.useState)([]);(0,s.useEffect)(()=>{let e=G.current;(e.cwd!==k||e.sessionId!==n&&K.current!==n)&&J([]),G.current={cwd:k,sessionId:n},K.current=n},[k,n]);let Y=(0,s.useCallback)(e=>J(t=>t.filter(t=>t.id!==e)),[]),X=(0,h.u)(null,t,!1,C,{onSnapshotStart:e=>{H?.(e),t(e.id,[])},onRunEnd:O,onRecoveryDeleted:W}),[Z,ee]=(0,s.useState)(!1),[et,en]=(0,s.useState)(null),[er,es]=(0,s.useState)(null),[eo,ea]=(0,s.useState)(null),[el,ei]=(0,s.useState)(null),[ed,ec]=(0,s.useState)(null),[eu,em]=(0,s.useState)(b),[eh,ep]=(0,s.useState)(null),ef=(0,s.useRef)(null),[eg,ex]=(0,s.useState)(null),eb=(0,s.useRef)(eg);eb.current=eg;let ev=(0,s.useRef)(!1),ey=(0,s.useRef)(!1),ew=(0,s.useRef)(O);ew.current=O;let ek=(0,s.useRef)(q);ek.current=q;let eC=(0,s.useRef)(!1),ej=(0,s.useRef)(null),eN=(0,s.useRef)(n);eN.current=n;let eS=(0,s.useRef)(null),eT=(0,s.useRef)(null),eE=(0,s.useRef)(null),eR=(0,s.useRef)(!1),eM=(0,s.useRef)(!1),eL=(0,s.useRef)(null),eI=(0,s.useRef)(0),eA=(0,s.useRef)((0,u.B)()),eP=(0,s.useRef)(null),eF=(0,s.useRef)([]),e$=(0,s.useRef)(!1),eD=(0,s.useRef)(!1),e_=(0,s.useCallback)(e=>{let n=eP.current;n&&t(n,e)},[t]),eB=(0,s.useCallback)(()=>{let e=eS.current;if(e&&e.text){let{messageId:t,text:n}=e;e_({event:{type:"stream_event",event:{type:"content_block_delta",delta:{type:"text_delta",text:n}}},engine:C,assistantId:t}),eS.current={messageId:t,text:""}}eT.current=null},[e_,C]),eO=(0,s.useCallback)((e=!1,t=!1)=>{eP.current&&ew.current?.(e,eP.current,t),eT.current&&(clearTimeout(eT.current),eT.current=null),ej.current&&(clearTimeout(ej.current),ej.current=null),eB(),e_(c.fD),ek.current?.settleRunning(),ee(!1),es(null),ea(null),em(b);let n=eb.current,r=eE.current;n&&e_(e=>e.map(e=>e.id===n.assistantId||e.id===r?{...e,isStreaming:!1}:e)),ev.current=e&&!!n,ev.current||(eb.current=null,ex(null))},[eB,e_]),eH=(0,s.useCallback)(async()=>{let e=eb.current,t=await a.t4.runPromiseExit((0,i.vc)({sessionId:eN.current,runId:e?.runKey}));"Failure"===t._tag?(0,f.oR)(p.A.t("chat.stopFailed",{defaultValue:"Could not stop the run. Try again."}),"error"):t.value.ok&&e&&eb.current===e&&eO(!0)},[eO]),eV=(0,s.useCallback)((e,t)=>{let n=e.type;if((0,c.Nn)(e))return;let r=e=>{if(ey.current||"string"!=typeof e||!e)return;let t=(0,d.r)(e);es(e=>({outputTokens:(e?.outputTokens||0)+t}))};if("system"===n&&"input_started"===e.subtype&&"string"==typeof e.inputId){eB(),eD.current=!0,e$.current=!1;let t=`input-asst-${e.inputId}`;eE.current=t,e_({event:e,engine:C,assistantId:t});return}if("system"===n&&"input_binding"===e.subtype)return void e_({event:e,engine:C,assistantId:""});if("system"===n&&"task_binding"===e.subtype&&"string"==typeof e.taskId)return void e_(t=>t.map(t=>t.liveRunId===eP.current?{...t,sourceTaskId:e.taskId}:t));if("system"===n&&"init"===e.subtype){let t=e.session_id,n=eR.current;if(K.current=t,D(t),eN.current=t,n||(ea(e=>e??Date.now()),es(null),ey.current=!1),ec(null),n){e$.current=!1;let e=`auto-asst-${eP.current}-${++eI.current}`;eE.current=e,e_(t=>[...t,{id:e,role:"assistant",content:"",toolCalls:[],isStreaming:!0,liveRunId:eP.current??void 0,turnId:"codex"===C?`live-task-${eP.current}`:void 0,runKey:eb.current?.runKey}])}eM.current=!0;return}if("user"===n&&e._human){let t="string"==typeof e._turnId?e._turnId:null;if(!t)return;if(t===eP.current){let n="number"==typeof e._ts?new Date(e._ts).toISOString():void 0,r=e.message?.content,s="string"==typeof r&&r?r:null;e_(e=>e.map(e=>e.liveRunId!==t?e:{...e,turnStartedAt:n,...s&&"user"===e.role?{content:s}:{}}));return}let n=e.message?.content,r=`auto-user-${t}`;e_(s=>s.some(e=>e.id===r)?s:[...s,{id:r,liveInputId:t,role:"user",content:"string"==typeof n?n:"",...Array.isArray(e._images)&&e._images.length?{images:e._images}:{},liveRunId:eP.current??void 0,turnId:"codex"===C?`live-task-${eP.current}`:void 0,runKey:eb.current?.runKey}]),eD.current||(e$.current=!0);return}if("system"===n&&"background_tasks_changed"===e.subtype){let t=(e.tasks??[]).filter(e=>!e.ambient).map(e=>({task_id:e.task_id,description:e.description}));em(t.length?t:b);return}if(!(0,c.A7)(e)||(ek.current?.applyEvent(e),eA.current.observe(e),e_({event:e,engine:C,assistantId:t}),"task_notification"===e.subtype)){if("system"===n&&"task_notification"===e.subtype){if(!eM.current&&eA.current.reportsToMain(e)){let t=e.status,n=e.summary||"",r=e.task_id,s=`<task-notification>
|
|
5
|
+
${t}`:e+t:t:e}function s(e,t,n=!1){let r=e||[];if(!t)return r;let o=r[r.length-1];return n||o?.type!=="text"?[...r,{type:"text",text:t}]:[...r.slice(0,-1),{type:"text",text:o.text+t}]}function o(e){return null!=e.parent_tool_use_id}n.d(t,{FM:()=>u,Nn:()=>o,A7:()=>l,az:()=>i,Uy:()=>d,fD:()=>c});let a=["task_started","task_progress","task_notification"];function l(e){return"system"===e.type&&a.includes(e.subtype??"")}function i(e){return!o(e)&&!e._human&&(l(e)&&!!e.tool_use_id&&!e.ambient||"tool_progress"===e.type&&!!e.tool_call_id||"user"===e.type&&Array.isArray(e.message?.content)&&e.message.content.some(e=>!!e.tool_use_id))}function d(e,t){let n={status:"running",...e};return"task_notification"===t.subtype&&(n.status=t.status??"completed"),t.task_id&&(n.id=t.task_id),t.last_tool_name&&(n.lastToolName=t.last_tool_name),t.summary&&(n.summary=t.summary),"number"==typeof t.usage?.tool_uses&&(n.toolUses=t.usage.tool_uses),"number"==typeof t.usage?.duration_ms&&(n.durationMs=t.usage.duration_ms),n}function c(e){let t=!1,n=e.map(e=>e.toolCalls?.some(e=>e.task?.status==="running")?(t=!0,{...e,toolCalls:e.toolCalls.map(e=>e.task?.status==="running"?{...e,task:{...e.task,status:"unknown"}}:e)}):e);return t?n:e}function u(e,t,n){let{engine:a,assistantId:i}=n;if(o(t))return e;if("system"===t.type&&"input_started"===t.subtype&&t.inputId){let n=e.find(e=>"user"===e.role&&e.liveInputId===t.inputId);if(!n)return e;let r=e.filter(e=>e.id===i||"assistant"!==e.role||e.content||e.toolCalls?.length||e.streamError);if(r.some(e=>e.id===i))return r;let s=r.indexOf(n),o={id:i,role:"assistant",content:"",isStreaming:!0,liveInputId:t.inputId,liveRunId:n.liveRunId,sourceId:void 0,turnStartedAt:n.turnStartedAt,timestamp:n.timestamp,runKey:n.runKey};return[...r.slice(0,s+1),o,...r.slice(s+1)]}if("system"===t.type&&"input_binding"===t.subtype&&t.inputId&&t.sourceId)return e.map(e=>"user"===e.role&&e.liveInputId===t.inputId?{...e,sourceId:t.sourceId}:e);if(l(t)){let n=t.tool_use_id;if(!n||t.ambient)return e;let r=!1,s=e.map(e=>e.toolCalls?.some(e=>e.id===n)?(r=!0,{...e,toolCalls:e.toolCalls.map(e=>e.id===n?{...e,task:d(e.task,t)}:e)}):e);return r?s:e}if("stream_event"===t.type){let n=t.event;if(n?.type==="content_block_delta"&&n.delta?.type==="text_delta"&&n.delta.text){let t=n.delta.text;return e.map(e=>e.id===i?{...e,content:r(e.content||"",t,!!e.pendingTextBreak),parts:s(e.parts,t,!!e.pendingTextBreak),pendingTextBreak:!1}:e)}return e}if("assistant"===t.type){let n=t.message?.content;if(!Array.isArray(n))return e;let o=e,l=t.message?.model==="<synthetic>";if("codex"===a||"ollama"===a||l){let e=n.filter(e=>"text"===e.type&&e.text).map(e=>e.text).join("");e&&(o=o.map(t=>t.id===i?{...t,content:r(t.content||"",e,!!t.pendingTextBreak),parts:s(t.parts,e,!!t.pendingTextBreak),pendingTextBreak:!1}:t))}for(let e of n)if(e.name){let t={id:e.id||`tool-${i}-${e.name}`,name:e.name,input:e.input||{},isLoading:!0};o=o.map(e=>e.id!==i||e.toolCalls?.some(e=>e.id===t.id)?e:{...e,toolCalls:[...e.toolCalls||[],t],parts:function(e,t){let n=e||[];return n.some(e=>"tool"===e.type&&e.id===t)?n:[...n,{type:"tool",id:t}]}(e.parts,t.id),pendingTextBreak:!0})}return o}if("tool_progress"===t.type&&t.tool_call_id){let n=t.progress_text??"";return e.map(e=>e.toolCalls?.some(e=>e.id===t.tool_call_id&&e.isLoading)?{...e,toolCalls:e.toolCalls.map(e=>e.id===t.tool_call_id?{...e,result:n}:e)}:e)}if("user"===t.type){let n=t.message?.content;if(!Array.isArray(n))return e;let r=e;for(let e of n)if(e.tool_use_id){let t=e.tool_use_id,n="string"==typeof e.content?e.content:JSON.stringify(e.content),s={..."boolean"==typeof e.is_error?{isError:e.is_error}:{},..."number"==typeof e.exit_code?{exitCode:e.exit_code}:{}};r=r.map(e=>e.toolCalls?.some(e=>e.id===t)?{...e,toolCalls:e.toolCalls.map(e=>e.id===t?{...e,result:n,isLoading:!1,...s}:e)}:e)}return r}if("error"===t.type){let n=t.error||"An error occurred. Please try again.",o=`⚠️ ${n}`;if(t.undeliveredInputs?.length){let r=e;for(let[e,s]of t.undeliveredInputs.entries()){let t=`undelivered-${s.inputId??`${i}-${e}`}`;if(r.some(e=>e.id===t))continue;let l=r.find(e=>"user"===e.role&&s.inputId&&e.liveInputId===s.inputId);if(l||(r=[...r,l={id:`${t}-input`,role:"user",content:s.text??"",images:s.images,liveInputId:s.inputId}]),"codex"===a){let e={...l,turnId:t,sourceTaskId:void 0};r=r.map(t=>t===l?e:t),l=e}let d=r.indexOf(l),c=r.findIndex((e,t)=>t>d&&"user"===e.role),u=c<0?r.length:c,m={id:t,role:"assistant",content:o,streamError:n,turnId:"codex"===a?t:void 0,liveInputId:s.inputId,liveRunId:l.liveRunId,timestamp:l.timestamp,isStreaming:!1};r=[...r.slice(0,u),m,...r.slice(u)]}return r}return e.map(e=>e.id===i?{...e,content:r(e.content||"",o,!0),streamError:n,parts:s(e.parts,o,!0),isStreaming:!1}:e)}if("result"===t.type){let n="string"==typeof t.result?t.result.trim():"";return e.map(e=>e.id===i?{...e,content:!e.content&&n?n:e.content,parts:!e.content&&n?s(e.parts,n):e.parts,isStreaming:!1,toolCalls:e.toolCalls?.map(e=>({...e,isLoading:!1}))}:e)}return e}},16147:(e,t,n)=>{n.d(t,{w:()=>o});var r=n(95155);let s="font-mono text-[9px] font-medium leading-none tabular-nums transition-colors";function o({children:e,wash:t,ring:n="",bot:a,className:l="",tooltip:i,title:d,role:c,ariaLabel:u,ariaHidden:m}){let h={title:d,role:c,"aria-label":u,"aria-hidden":m?"true":void 0,"data-tooltip":i??(a?`@${a}`:void 0)};return a?(0,r.jsx)("span",{className:`relative -m-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center ${n} ${l}`,...h,children:(0,r.jsx)("span",{className:`session-number-bot flex h-full w-full items-center justify-center ${s} ${t}`,children:(0,r.jsx)("span",{className:"translate-y-[1.5px]",children:e})})}):(0,r.jsx)("span",{className:`flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border ${s} ${n} ${t} ${l}`,...h,children:e})}},17196:(e,t,n)=>{n.d(t,{Np:()=>c,ZD:()=>l,ZR:()=>i,b8:()=>d,kS:()=>o,sQ:()=>a});let r=null,s=["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","lean4"];function o(){return r||(r=Promise.all([n.e(49304),n.e(64523)]).then(n.bind(n,64523)).then(({createHighlighter:e})=>e({themes:["github-dark","github-light"],langs:[...s]}))),r}function a(e){let t=e.split("/").pop()?.toLowerCase()||"",n=t.split(".").pop()?.toLowerCase();if(".env"===t||t.startsWith(".env.")||"dockerfile"===t||t.startsWith("dockerfile.")||"makefile"===t)return"bash";let r={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",lean:"lean4",toml:"yaml",sass:"scss",less:"css",scala:"java",r:"python",vim:"bash",env:"bash"}[n||""]||"text";return s.includes(r)?r:"text"}function l(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}let i=2e3;function d(e){return e.length>i?l(e.map(e=>e.content).join("")):e.map(e=>e.color?`<span style="color:${e.color}">${l(e.content)}</span>`:l(e.content)).join("")}function c(e,t,n,r){if(!t)return[];let s=[],o=n?t:t.toLowerCase();for(let t=0;t<e.length;t++){let a=n?e[t]:e[t].toLowerCase(),l=0;for(;;){let e=a.indexOf(o,l);if(-1===e)break;let n=e+o.length;if(r){let r=e>0?a[e-1]:" ",o=n<a.length?a[n]:" ",l=!/\w/.test(r),i=!/\w/.test(o);l&&i&&s.push({lineIndex:t,startCol:e,endCol:n})}else s.push({lineIndex:t,startCol:e,endCol:n});l=e+1}}return s}},19095:(e,t,n)=>{n.d(t,{r:()=>r});function r(e){let t=0,n=0;for(let r of e)/[\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\u{20000}-\u{2a6df}\uac00-\ud7af]/u.test(r)?t+=1:n+=1;return Math.max(1,Math.ceil(t+n/4))}},19502:(e,t,n)=>{n.d(t,{YO:()=>s,aj:()=>r,pU:()=>o});let r=3,s=20;function o(e,t,n,a=[]){let l=e.length,i=n=>"unchanged"!==e[n].type||"unchanged"!==t[n].type,d=new Set;for(let e=0;e<l;e++){if(!i(e))continue;let t=Math.max(0,e-r),n=Math.min(l-1,e+r);for(let e=t;e<=n;e++)d.add(e)}let c=[];for(let e=0;e<l;e++){if(d.has(e))continue;let t=e;for(;e<l&&!d.has(e);)e++;c.push({id:c.length,startIdx:t,endIdx:e-1}),e--}for(let e of c){let t=n.get(e.id)??{topRevealed:0,bottomRevealed:0},r=e.endIdx-e.startIdx+1,s=Math.max(0,Math.min(t.topRevealed,r)),o=Math.max(0,Math.min(t.bottomRevealed,r-s));for(let t=e.startIdx;t<e.startIdx+s;t++)d.add(t);for(let t=e.endIdx-o+1;t<=e.endIdx;t++)d.add(t)}let u=[];for(let e=0;e<l;e++){let n;if(d.has(e)){u.push({kind:"diff",idx:e});continue}let r=e;for(;e<l&&!d.has(e);)e++;let o=e-1;e--;let i=c.find(e=>e.startIdx<=r&&o<=e.endIdx);if(!i)continue;let m=o-r+1,h=Math.min(s,m);if(a.length>0&&o+1<l)for(let e=o+1;e<l;e++){let r=t[e].lineNum;if(!(r<=0)){n=function(e,t){let n=null;for(let r of e)r.startLine<=t&&t<=r.endLine&&(!n||r.endLine-r.startLine<n.endLine-n.startLine)&&(n=r);return n}(a,r)??void 0;break}}u.push({kind:"gap-expand",gapId:i.id,direction:"up",revealCount:h}),u.push({kind:"gap-label",gapId:i.id,hiddenCount:m,enclosingFn:n}),u.push({kind:"gap-expand",gapId:i.id,direction:"down",revealCount:h})}return{rows:u,gaps:c}}},20073:(e,t,n)=>{n.d(t,{u:()=>o});var r=n(95155),s=n(8601);function o({options:e,level:t,onChange:n}){if(!e||!t||"none"===e.mode||!e.levels.some(e=>"off"!==e))return null;let a=t=>{let n=e.labels[t]??t;return n.charAt(0).toUpperCase()+n.slice(1)};return e.levels.length<=1?(0,r.jsx)("span",{className:"text-xs text-muted-foreground",title:"This model requires thinking","data-testid":"pi-thinking-required",children:a(t)}):(0,r.jsx)(s.zC,{title:"required"===e.mode?"Thinking (required)":"Thinking",selected:t,value:a(t),items:e.levels.map(t=>({id:t,label:a(t),defaultValue:t===e.defaultLevel})),onSelect:n,testId:"pi-thinking-picker"})}},20080:(e,t,n)=>{n.d(t,{K:()=>l});var r=n(95155),s=n(12115),o=n(79114);function a({label:e,labelClassName:t,src:n,node:l,alt:i}){let{t:d}=(0,o.Bd)(),[c,u]=(0,s.useState)(!1);return(0,r.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col items-center gap-2",children:[(0,r.jsx)("div",{className:`text-xs font-medium ${t}`,children:e}),(0,r.jsx)("div",{className:"w-full flex-1 flex items-center justify-center rounded border border-border bg-secondary p-3 min-h-[8rem]",children:l?(0,r.jsx)("div",{className:"w-full min-w-0",children:l}):c?(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:d("diffViewer.imageLoadFailed")}):(0,r.jsx)("img",{src:n,alt:i,onError:()=>u(!0),className:"max-w-full max-h-[60vh] object-contain"})})]})}function l({filePath:e,oldSrc:t,newSrc:n,oldNode:s,newNode:i}){let{t:d}=(0,o.Bd)(),c=!!s||!!t,u=!!i||!!n;return(0,r.jsxs)("div",{className:"h-full overflow-auto p-4",children:[(0,r.jsx)("div",{className:"text-xs font-mono text-muted-foreground mb-3 truncate",children:e}),c||u?(0,r.jsxs)("div",{className:"flex flex-wrap items-stretch gap-4",children:[c&&(0,r.jsx)(a,{label:d(u?"diffViewer.imageBefore":"diffViewer.imageDeleted"),labelClassName:"text-red-11",src:t,node:s,alt:`${e} (before)`}),u&&(0,r.jsx)(a,{label:d(c?"diffViewer.imageAfter":"diffViewer.imageAdded"),labelClassName:"text-green-11",src:n,node:i,alt:`${e} (after)`})]}):(0,r.jsx)("div",{className:"text-sm text-muted-foreground",children:d("diffViewer.imageUnavailable")})]})}},20235:(e,t,n)=>{n.d(t,{GI:()=>a,_9:()=>l,s1:()=>d,zl:()=>i});var r=n(95155),s=n(12115),o=n(23970);let a="inline-block rounded bg-brand/15 px-1.5 text-brand",l=`mr-1.5 text-[0.9em] ${a}`,i=(0,s.memo)(function({text:e,matchLine:t,variant:n}){let s=[];return e.split("\n").forEach((e,o)=>{o>0&&s.push("\n");let a=t(e);if(!a)return void s.push(e);let i=e.slice(a.start,a.end),d=e.slice(a.end);if("chip"===n)s.push(e.slice(0,a.start),(0,r.jsx)("span",{className:l,children:i},o),d.replace(/^\s+/,""));else{let t=(0,r.jsx)("span",{className:"inline-block rounded bg-brand/15 text-brand ring-2 ring-brand/15",children:(0,r.jsx)("span",{className:"inline-block scale-[0.9]",children:i})},o);s.push(e.slice(0,a.start),t,d)}}),(0,r.jsx)(r.Fragment,{children:s})});function d({value:e,textareaRef:t,matchLine:n,boxClassName:a,colorClassName:l,className:c="",wrapperClassName:u="",onScroll:m,onKeyDown:h,...p}){let f=(0,s.useMemo)(()=>e.split("\n").some(e=>null!==n(e)),[e,n]),g=(0,s.useRef)(null),x=(0,s.useCallback)(()=>{let e=t.current,n=g.current;e&&n&&(n.style.width=`${e.clientWidth+2*e.clientLeft}px`,n.scrollTop=e.scrollTop)},[t]);return(0,s.useLayoutEffect)(()=>{if(!f)return;x();let e=t.current;if(!e)return;let n=new ResizeObserver(x);return n.observe(e),()=>n.disconnect()},[f,x,t]),(0,s.useLayoutEffect)(()=>{f&&x()},[f,e,x]),(0,r.jsxs)("div",{className:`relative ${u}`,children:[f&&(0,r.jsxs)("div",{ref:g,"aria-hidden":!0,className:`pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap break-words ${a} ${l}`,children:[(0,r.jsx)(i,{text:e,matchLine:n,variant:"mark"}),""]}),(0,r.jsx)("textarea",{ref:t,value:e,onKeyDown:e=>{let t=e.currentTarget;if(("Backspace"===e.key||"Delete"===e.key)&&!e.nativeEvent.isComposing&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&t.selectionStart===t.selectionEnd){let r=(0,o.AM)(t.value,t.selectionStart,e.key,n);if(r){e.preventDefault(),t.setSelectionRange(r[0],r[1]),document.execCommand("delete")||(t.setRangeText("",r[0],r[1],"start"),t.dispatchEvent(new Event("input",{bubbles:!0})));return}}h?.(e)},onScroll:e=>{f&&x(),m?.(e)},className:`relative block w-full whitespace-pre-wrap break-words ${a} ${f?"bg-transparent text-transparent caret-foreground selection:text-transparent selection:bg-[Highlight]":l} ${c}`,...p})]})}},20832:(e,t,n)=>{n.d(t,{p:()=>c});var r=n(95155),s=n(12115),o=n(79114),a=n(86957),l=n(33199),i=n(97938),d=n(32456);function c({cwd:e,sessionId:t,subtitle:n,emptyText:u,onOpenSession:m}){let{t:h}=(0,o.Bd)(),[p,f]=(0,s.useState)(null),g=(0,s.useRef)(void 0);(0,s.useEffect)(()=>{let n=!1,r=async()=>{let r=await a.t4.runPromiseExit((0,i.z)({cwd:e,sessionId:t,limit:10,ifFingerprint:g.current}));if(n)return;if("Success"!==r._tag||!r.value)return void f(e=>e??[]);let s=r.value;s.fingerprint&&(g.current=s.fingerprint),!s.notModified&&s.messages&&f(s.messages)};r();let s=setInterval(r,5e3);return()=>{n=!0,clearInterval(s)}},[e,t]);let x=(0,s.useRef)(null),b=(0,s.useRef)(null),v=(0,s.useRef)(!0),[y,w]=(0,s.useState)(!0),k=(0,s.useCallback)(()=>{let e=x.current;if(!e)return;let t=e.scrollTop+e.clientHeight>=e.scrollHeight-40;v.current=t,w(t||e.scrollTop<=40)},[]);return(0,s.useLayoutEffect)(()=>{let e=x.current;e&&v.current&&(e.scrollTop=e.scrollHeight)},[p]),(0,s.useEffect)(()=>{let e=b.current;if(!e)return;let t=new ResizeObserver(k);return t.observe(e),()=>t.disconnect()},[k,p]),(0,r.jsxs)("div",{className:"flex-1 flex flex-col h-full min-w-0",children:[(0,r.jsx)("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border flex-shrink-0",children:(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-foreground truncate","data-tooltip":e,children:(0,d.Qr)(e)}),(0,r.jsx)("div",{className:"text-[11px] text-muted-foreground truncate","data-tooltip":n,children:n})]})}),(0,r.jsxs)("div",{className:"relative flex-1 min-h-0 flex",children:[(0,r.jsx)("div",{ref:x,onScroll:k,className:"flex-1 overflow-y-auto px-8 py-4",children:null===p||0===p.length?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-6",children:null===p?h("common.loading"):u}):(0,r.jsx)("div",{ref:b,className:"mx-auto w-full max-w-[var(--chat-column)] [&_a]:pointer-events-none",children:p.map(t=>(0,r.jsx)(l.s,{message:t,cwd:e,disableOverlays:!0},t.id))})}),(0,r.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center pb-4",children:(0,r.jsxs)("button",{onClick:m,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-brand text-white text-sm font-medium shadow-lv3 hover:bg-brand/90 transition-opacity ${y?"opacity-100 pointer-events-auto":"opacity-0"}`,title:h("scheduledTasks.openSession"),children:[(0,r.jsx)("span",{children:h("scheduledTasks.openSession")}),(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7-7 7M3 12h18"})})]})})]})]})}},20917:(e,t,n)=>{n.d(t,{R:()=>b,e:()=>w});var r=n(95272),s=n(12115),o=n(49433),a=n(86957),l=n(95595),i=n(83448),d=n(19095),c=n(14594),u=n(67958),m=n(98245),h=n(65153),p=n(69809),f=n(34075),g=n(2111),x=n(99356);let b=[];function v(){try{return crypto.randomUUID()}catch{return`run-${Date.now()}-${Math.floor(1e9*Math.random())}`}}function y({run:e,update:t,engine:n,onAccepted:r,onEnd:s,onDeleted:o,onSettled:a}){return(0,h.u)(e.runKey,t,!0,n,{onlyRunId:e.id,onSnapshotStart:e=>{r?.(e),t(e.id,[])},onRunEnd:(t,n,r)=>{s?.(t,n,r),t||a(e.id)},onRecoveryDeleted:o,onWriterIdle:()=>{s?.(!1,e.id),a(e.id)}}),null}function w(e,t,{sessionId:n,cwd:k,engine:C,planMode:j,noHistory:N,ollamaModel:S,engineModel:T,piThinkingLevel:E,claudeModel:R,claudeEffort:M,claudeFastMode:L,claudeThinking:I,codexModel:A,codexReasoningEffort:F,grokModel:P,grokReasoningEffort:$,onSessionId:D,onFetchTitle:_,onSendStart:O,onRunEnd:B,onRunAccepted:H,onSendFailure:V,onInputRejected:U,onRecoveryDeleted:W,taskStore:q}){let z=(0,s.useId)(),K=(0,s.useRef)(n),G=(0,s.useRef)({cwd:k,sessionId:n}),[Q,J]=(0,s.useState)([]);(0,s.useEffect)(()=>{let e=G.current;(e.cwd!==k||e.sessionId!==n&&K.current!==n)&&J([]),G.current={cwd:k,sessionId:n},K.current=n},[k,n]);let Y=(0,s.useCallback)(e=>J(t=>t.filter(t=>t.id!==e)),[]),Z=(0,h.u)(null,t,!1,C,{onSnapshotStart:e=>{H?.(e),t(e.id,[])},onRunEnd:B,onRecoveryDeleted:W}),[X,ee]=(0,s.useState)(!1),[et,en]=(0,s.useState)(null),[er,es]=(0,s.useState)(null),[eo,ea]=(0,s.useState)(null),[el,ei]=(0,s.useState)(null),[ed,ec]=(0,s.useState)(null),[eu,em]=(0,s.useState)(b),[eh,ep]=(0,s.useState)(null),ef=(0,s.useRef)(null),[eg,ex]=(0,s.useState)(null),eb=(0,s.useRef)(eg);eb.current=eg;let ev=(0,s.useRef)(!1),ey=(0,s.useRef)(!1),ew=(0,s.useRef)(B);ew.current=B;let ek=(0,s.useRef)(q);ek.current=q;let eC=(0,s.useRef)(!1),ej=(0,s.useRef)(null),eN=(0,s.useRef)(n);eN.current=n;let eS=(0,s.useRef)(null),eT=(0,s.useRef)(null),eE=(0,s.useRef)(null),eR=(0,s.useRef)(!1),eM=(0,s.useRef)(!1),eL=(0,s.useRef)(null),eI=(0,s.useRef)(0),eA=(0,s.useRef)((0,u.B)()),eF=(0,s.useRef)(null),eP=(0,s.useRef)([]),e$=(0,s.useRef)(!1),eD=(0,s.useRef)(!1),e_=(0,s.useCallback)(e=>{let n=eF.current;n&&t(n,e)},[t]),eO=(0,s.useCallback)(()=>{let e=eS.current;if(e&&e.text){let{messageId:t,text:n}=e;e_({event:{type:"stream_event",event:{type:"content_block_delta",delta:{type:"text_delta",text:n}}},engine:C,assistantId:t}),eS.current={messageId:t,text:""}}eT.current=null},[e_,C]),eB=(0,s.useCallback)((e=!1,t=!1)=>{eF.current&&ew.current?.(e,eF.current,t),eT.current&&(clearTimeout(eT.current),eT.current=null),ej.current&&(clearTimeout(ej.current),ej.current=null),eO(),e_(c.fD),ek.current?.settleRunning(),ee(!1),es(null),ea(null),em(b);let n=eb.current,r=eE.current;n&&e_(e=>e.map(e=>e.id===n.assistantId||e.id===r?{...e,isStreaming:!1}:e)),ev.current=e&&!!n,ev.current||(eb.current=null,ex(null))},[eO,e_]),eH=(0,s.useCallback)(async()=>{let e=eb.current,t=await a.t4.runPromiseExit((0,i.vc)({sessionId:eN.current,runId:e?.runKey}));"Failure"===t._tag?(0,f.oR)(p.A.t("chat.stopFailed",{defaultValue:"Could not stop the run. Try again."}),"error"):t.value.ok&&e&&eb.current===e&&eB(!0)},[eB]),eV=(0,s.useCallback)((e,t)=>{let n=e.type;if((0,c.Nn)(e))return;let r=e=>{if(ey.current||"string"!=typeof e||!e)return;let t=(0,d.r)(e);es(e=>({outputTokens:(e?.outputTokens||0)+t}))};if("system"===n&&"input_started"===e.subtype&&"string"==typeof e.inputId){eO(),eD.current=!0,e$.current=!1;let t=`input-asst-${e.inputId}`;eE.current=t,e_({event:e,engine:C,assistantId:t});return}if("system"===n&&"input_binding"===e.subtype)return void e_({event:e,engine:C,assistantId:""});if("system"===n&&"task_binding"===e.subtype&&"string"==typeof e.taskId)return void e_(t=>t.map(t=>t.liveRunId===eF.current?{...t,sourceTaskId:e.taskId}:t));if("system"===n&&"init"===e.subtype){let t=e.session_id,n=eR.current;if(K.current=t,D(t),eN.current=t,n||(ea(e=>e??Date.now()),es(null),ey.current=!1),ec(null),n){e$.current=!1;let e=`auto-asst-${eF.current}-${++eI.current}`;eE.current=e,e_(t=>[...t,{id:e,role:"assistant",content:"",toolCalls:[],isStreaming:!0,liveRunId:eF.current??void 0,turnId:"codex"===C?`live-task-${eF.current}`:void 0,runKey:eb.current?.runKey}])}eM.current=!0;return}if("user"===n&&e._human){let t="string"==typeof e._turnId?e._turnId:null;if(!t)return;if(t===eF.current){let n="number"==typeof e._ts?new Date(e._ts).toISOString():void 0,r=e.message?.content,s="string"==typeof r&&r?r:null;e_(e=>e.map(e=>e.liveRunId!==t?e:{...e,turnStartedAt:n,...s&&"user"===e.role?{content:s}:{}}));return}let n=e.message?.content,r=`auto-user-${t}`;e_(s=>s.some(e=>e.id===r)?s:[...s,{id:r,liveInputId:t,role:"user",content:"string"==typeof n?n:"",...Array.isArray(e._images)&&e._images.length?{images:e._images}:{},liveRunId:eF.current??void 0,turnId:"codex"===C?`live-task-${eF.current}`:void 0,runKey:eb.current?.runKey}]),eD.current||(e$.current=!0);return}if("system"===n&&"background_tasks_changed"===e.subtype){let t=(e.tasks??[]).filter(e=>!e.ambient).map(e=>({task_id:e.task_id,description:e.description}));em(t.length?t:b);return}if(!(0,c.A7)(e)||(ek.current?.applyEvent(e),eA.current.observe(e),e_({event:e,engine:C,assistantId:t}),"task_notification"===e.subtype)){if("system"===n&&"task_notification"===e.subtype){if(!eM.current&&eA.current.reportsToMain(e)){let t=e.status,n=e.summary||"",r=e.task_id,s=`<task-notification>
|
|
6
6
|
`+(r?`<task-id>${r}</task-id>
|
|
7
7
|
`:"")+(e.tool_use_id?`<tool-use-id>${e.tool_use_id}</tool-use-id>
|
|
8
8
|
`:"")+(t?`<status>${t}</status>
|
|
9
9
|
`:"")+(n?`<summary>${n}</summary>
|
|
10
10
|
`:"")+(e.output_file?`<output-file>${e.output_file}</output-file>
|
|
11
|
-
`:"")+"</task-notification>",o=`auto-tasknotif-${r||++eI.current}`;e_(e=>[...e,{id:o,role:"system",content:n,systemEvent:{kind:"task-notification",...t?{status:t}:{},detail:s},liveRunId:eP.current??void 0,turnId:"codex"===C?`live-task-${eP.current}`:void 0,runKey:eb.current?.runKey}])}return}if("system"===n&&"notice"===e.subtype){let t=(0,m.C)(e,`auto-notice-${++eI.current}`);t&&e_(e=>[...e,{...t,liveRunId:eP.current??void 0,turnId:"codex"===C?`live-task-${eP.current}`:void 0,runKey:eb.current?.runKey}]);return}if("system"===n&&"api_retry"===e.subtype)return void ec({attempt:e.attempt??0,maxRetries:e.max_retries??0,delayMs:e.retry_delay_ms??0,errorStatus:e.error_status,error:e.error});if("rate_limit_event"===n){let t=e.rate_limit_info;t&&ei({status:t.status||"allowed",resetsAt:t.resetsAt,rateLimitType:t.rateLimitType,utilization:t.utilization,overageStatus:t.overageStatus,overageDisabledReason:t.overageDisabledReason,isUsingOverage:t.isUsingOverage,surpassedThreshold:t.surpassedThreshold});return}if("usage_update"===n){let t=e.output_tokens;if("number"==typeof t&&Number.isFinite(t)){ey.current=!0;let e=Math.max(0,Math.round(t));es(t=>({outputTokens:Math.max(t?.outputTokens||0,e)}))}return}if("error"===n){let n=e.error||p.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});ec(null),eT.current&&(clearTimeout(eT.current),eT.current=null),eB(),e_({event:{...e,type:"error",error:n},engine:C,assistantId:t});return}if("stream_event"===n){ec(e=>e?null:e);let n=e.event;if(e$.current&&n?.type==="message_start"){e$.current=!1,eT.current&&(clearTimeout(eT.current),eT.current=null),eB();let e=t,n=`auto-asst-${eP.current}-${++eI.current}`;eE.current=n,t=n,e_(t=>[...t.map(t=>t.id===e?{...t,isStreaming:!1}:t),{id:n,role:"assistant",content:"",toolCalls:[],isStreaming:!0,liveRunId:eP.current??void 0,turnId:"codex"===C?`live-task-${eP.current}`:void 0,runKey:eb.current?.runKey}])}if(n?.type==="content_block_delta"&&n.delta?.type==="text_delta"){let e=n.delta.text||"";r(e),eS.current&&eS.current.messageId===t?eS.current.text+=e:eS.current={messageId:t,text:e},eT.current||(eT.current=setTimeout(eB,50))}return}if("assistant"===n){ec(e=>e?null:e);let n=e.message?.usage;n&&(eL.current=n);let s=e.message?.content;if(Array.isArray(s))for(let e of s)e.text?r(e.text):e.name&&r(`${e.name} ${JSON.stringify(e.input??{})}`);e_({event:e,engine:C,assistantId:t})}if("tool_progress"===n)return void e_({event:e,engine:C,assistantId:t});if("user"===n){let n=e.message?.content;if(Array.isArray(n))for(let e of n)r("string"==typeof e.content?e.content:JSON.stringify(e.content??""));e_({event:e,engine:C,assistantId:t})}if("prompt_suggestion"===n){let t="string"==typeof e.suggestion?e.suggestion.trim():"",n=eN.current;ep(t&&n?{sessionId:n,text:t}:null)}if("result"===n){eM.current=!1,eR.current=!0,ec(null),eT.current&&(clearTimeout(eT.current),eT.current=null),eB();let n=eN.current;n&&k&&e_(e=>(2===e.length&&_(n),e));let r=eL.current??e.usage;eL.current=null;let s=e.total_cost_usd;r&&en({inputTokens:r.input_tokens||0,outputTokens:r.output_tokens||0,cacheCreationInputTokens:r.cache_creation_input_tokens||0,cacheReadInputTokens:r.cache_read_input_tokens||0,totalCostUsd:s||0}),e_({event:e,engine:C,assistantId:t})}}},[e_,eB,D,_,k,C]);(0,g.h)({url:eg?`/ws/session-stream?sessionId=${encodeURIComponent(eg.runKey)}&subscriber=${encodeURIComponent(z)}`:"/ws/session-stream",enabled:!!eg,onMessage:e=>{eC.current=!0,ej.current&&(clearTimeout(ej.current),ej.current=null);let t=eb.current;if(!t)return;for(let t of e.recoveries??[])t.runId&&t.runId!==eP.current&&X(t);let n=e.recoveries?.find(e=>e.runId===eP.current)??e;if("run-snapshot"===n.type&&Array.isArray(n.events)){if(n.runId&&n.runId!==eP.current)return void eO();"number"==typeof n.startedAt&&eP.current&&H?.({id:eP.current,startedAt:n.startedAt,recovery:n.recovery}),eT.current&&(clearTimeout(eT.current),eT.current=null),eS.current=null,eE.current=t.assistantId,eD.current=!1,eR.current=!1,eM.current=!1,e$.current=!1,ey.current=!1,es(null);let e="number"==typeof n.outputTokens&&Number.isFinite(n.outputTokens)?Math.max(0,Math.round(n.outputTokens)):null;null!==e&&(ey.current=!0,es({outputTokens:e}));let r="number"==typeof n.startedAt?new Date(n.startedAt).toISOString():void 0;for(let e of(e_(eF.current.map(e=>({...e,turnStartedAt:r??e.turnStartedAt}))),n.events))eV(e,eE.current??t.assistantId);for(let e of(n.status&&"running"!==n.status&&eO(!0===n.writerActive,"error"===n.status),n.recoveryDeletions??[]))W?.(e)}else if("run-event"===n.type&&n.message){if("recovery-deleted"===n.message.type)return void W?.(n.message.deletion);if("run-ended"===n.message.type||"run-settled"===n.message.type){if("string"==typeof n.message.runId&&n.message.runId!==eP.current)return;eO("run-ended"===n.message.type&&!0===n.message.writerActive,"error"===n.message.status);return}if(ev.current){(0,r.X)(n.message)&&eV(n.message,eE.current??t.assistantId);return}eV(n.message,eE.current??t.assistantId)}else if("run-idle"===n.type)for(let e of(eO(),n.recoveryDeletions??[]))W?.(e)}});let eU=(0,s.useRef)(Z);eU.current=Z;let eW=(0,s.useCallback)(e=>{if("prompt-suggestion"!==e.type||eU.current)return;let t=eN.current,n="string"==typeof e.data?.suggestion?e.data.suggestion.trim():"";t&&e.data?.sessionId===t&&n&&ep({sessionId:t,text:n})},[]),[eq]=(0,s.useState)(x.I7);(0,g.h)({url:eq,enabled:"codex"===C,onMessage:eW});let ez=(0,s.useCallback)(async(e,t,n)=>{let r=n&&"permissionMode"in n?"plan"===n.permissionMode:j,s=t?.map(e=>({type:"base64",media_type:e.media_type,data:e.data}));if(ev.current&&eb.current&&eP.current){let e={id:eP.current,runKey:eb.current.runKey};J(t=>[...t.filter(t=>t.id!==e.id),e])}eb.current=null,ex(null),ev.current=!1;let o=v();eP.current=o,B?.({id:o,startedAt:Date.now()});let a={id:`user-${o}`,liveInputId:o,liveRunId:o,turnId:"codex"===C?`live-task-${o}`:void 0,role:"user",content:e,images:s};e_(e=>[...e,a]),ep(null),ee(!0),es(null),ey.current=!1,ea(Date.now()),ec(null),em(b);let i=`assistant-${o}`,d={id:i,liveRunId:o,turnId:"codex"===C?`live-task-${o}`:void 0,role:"assistant",content:"",toolCalls:[],isStreaming:!0};eF.current=[a,d],e_(e=>[...e,d]),eD.current=!1,eE.current=i,eR.current=!1,eM.current=!1,e$.current=!1;let c=!C||"claude"===C,u="deepseek"===C||"kimi"===C||"glm"===C,m="ollama"===C||u||c||"codex"===C||"grok"===C;try{let t=C&&"claude"!==C?`/api/chat/${C}`:"/api/chat",n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,sessionId:eN.current,runId:o,images:s,cwd:k,language:p.A.language,..."ollama"===C&&S&&{model:S},...u&&T&&{model:T},...(u||"ollama"===C)&&void 0!==E&&{piThinkingLevel:E},...c&&R&&{model:R},...c&&M&&{claudeEffort:M},...c&&void 0!==L&&{claudeFastMode:L},...c&&void 0!==I&&{claudeThinking:I},..."codex"===C&&A&&{model:A},..."codex"===C&&P&&{codexReasoningEffort:P},..."codex"===C&&{promptSuggestions:!0},..."grok"===C&&{model:F&&"grok-build"!==F?F:l.yR},..."grok"===C&&{grokReasoningEffort:$||l.ZL},...r&&c&&{permissionMode:"plan"},...m&&N&&{noHistory:!0}})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||p.A.t("chat.requestFailed",{defaultValue:"Request failed"}))}let a=await n.json().catch(()=>({}));if(H?.({id:o,startedAt:a.startedAt??Date.now()}),"number"==typeof a.startedAt){let e=new Date(a.startedAt).toISOString();e_(t=>t.map(t=>t.liveRunId===o?{...t,turnStartedAt:e}:t))}ex({runKey:a.runKey||o,assistantId:i}),eC.current=!1,ej.current&&clearTimeout(ej.current),ej.current=setTimeout(()=>{eb.current&&!eC.current&&e_(e=>e.map(e=>e.id!==i||e.content?e:{...e,content:p.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."})}))},15e3)}catch(t){console.error("Chat error:",t);let e=t instanceof Error?t.message:p.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});e_(t=>t.map(t=>t.id===i?{...t,content:e,streamError:e,isStreaming:!1}:t)),V?.(o),ee(!1),ex(null)}},[k,C,j,N,S,T,E,R,M,L,I,A,P,F,$,e_,eO,B,H,V]),eK=(0,s.useCallback)(async(e,t,n)=>{ep(null);let r=v(),s=Date.now(),d=t?.map(e=>({type:"base64",media_type:e.media_type,data:e.data})),c="ollama"===C||"deepseek"===C||"kimi"===C||"glm"===C;await a.t4.runPromise((0,i.VA)(C,{prompt:e,sessionId:n,runId:r,images:d,cwd:k,language:p.A.language,inject:!0,...c?{model:"ollama"===C?S:T,piThinkingLevel:E,noHistory:N}:{},..."codex"===C?{model:A,codexReasoningEffort:P,noHistory:N}:{},..."grok"===C?{model:F&&"grok-build"!==F?F:l.yR,grokReasoningEffort:$||l.ZL,noHistory:N}:{}}).pipe(o.sFT(t=>o.OH5(()=>{U?.(n,{id:r,startedAt:s,messages:[{id:`user-${r}`,role:"user",content:e,images:d},{id:`error-${r}`,role:"assistant",content:t.message,streamError:t.message}]})}))))},[k,C,S,T,E,A,P,F,$,N,U]);return{drainingSubscriptions:Q.map(e=>(0,s.createElement)(y,{key:e.id,run:e,update:t,engine:C,onAccepted:H,onEnd:O,onDeleted:W,onSettled:Y})),isLoading:Z,tokenUsage:et,liveOutputTokens:er,runningStartedAt:eo,rateLimitInfo:el,apiRetryInfo:ed,backgroundTasks:eu,promptSuggestion:eh&&eh.sessionId===n?eh.text:null,handleSend:ez,handleStop:eH,injectMessage:eK,abortControllerRef:ef}}},22576:(e,t,n)=>{function r(e,t){let n=e.split("\n"),r=t.split("\n"),a=n.length,l=r.length,i=0;for(;i<a&&i<l&&n[i]===r[i];)i++;let d=a,c=l;for(;d>i&&c>i&&n[d-1]===r[c-1];)d--,c--;let u=[],m=(e,t)=>u.push({type:"unchanged",content:n[e],oldLineNum:e+1,newLineNum:t+1}),h=e=>u.push({type:"removed",content:n[e],oldLineNum:e+1}),p=e=>u.push({type:"added",content:r[e],newLineNum:e+1});for(let e=0;e<i;e++)m(e,e);let f=function(e,t,n,r,a,l){let i=n-t,d=l-a;if(0===i&&0===d)return new Uint8Array(0);if(0===i)return new Uint8Array(d).fill(2);if(0===d)return new Uint8Array(i).fill(o);let c=new Map,u=e=>{let t=c.get(e);return void 0===t&&(t=c.size,c.set(e,t)),t},m=new Int32Array(i),h=new Int32Array(d);for(let n=0;n<i;n++)m[n]=u(e[t+n]);for(let e=0;e<d;e++)h[e]=u(r[a+e]);let p=Math.min(i+d,2e3),f=p+1,g=new Int32Array(2*f+1),x=[],b=-1;for(let e=0;e<=p;e++){x.push(g.slice(f-e,f+e+1));for(let t=-e;t<=e;t+=2){let n=t===-e||t!==e&&g[f+t-1]<g[f+t+1]?g[f+t+1]:g[f+t-1]+1,r=n-t;for(;n<i&&r<d&&m[n]===h[r];)n++,r++;if(g[f+t]=n,n>=i&&r>=d){b=e;break}}if(b>=0)break}if(b<0)return null;let v=new Uint8Array(i+d),y=v.length,w=i,k=d;for(let e=b;e>0;e--){let t=x[e],n=w-k,r=n===-e||n!==e&&t[n-1+e]<t[n+1+e],a=r?n+1:n-1,l=t[a+e],i=l-a;for(;w>l&&k>i;)v[--y]=s,w--,k--;r?(v[--y]=2,k--):(v[--y]=o,w--)}for(;w>0&&k>0;)v[--y]=s,w--,k--;return v.subarray(y)}(n,i,d,r,i,c);if(f){let e=i,t=i;for(let n of f)n===s?m(e++,t++):n===o?h(e++):p(t++)}else{for(let e=i;e<d;e++)h(e);for(let e=i;e<c;e++)p(e)}for(let e=0;e<a-d;e++)m(d+e,c+e);return u}n.d(t,{X:()=>r});let s=0,o=1},23348:(e,t,n)=>{n.d(t,{Eo:()=>d,jm:()=>a,zB:()=>i});var r=n(49433),s=n(84230),o=n(37640);let a=()=>(0,s.F)("/api/bots",(0,o.zi)("/api/bots")),l=r.OH5(()=>(0,s.T)("/api/bots")),i=e=>(0,o.B2)("/api/bots",{path:e}).pipe(r.yeE(l)),d=e=>(0,o.zi)(`/api/bots/${encodeURIComponent(e)}`,{method:"DELETE"}).pipe(r.yeE(l))},23970:(e,t,n)=>{function r(e){return e.replace(/\s+/g," ").trim()}n.d(t,{AM:()=>l,fp:()=>a});let s=e=>r(e).toLowerCase(),o=/^\s*(\/@|\/|@)(\S+?)(?:\s+|$)/;function a(e,t){let n=e.match(o);if(!n)return null;let[,a,l]=n,i=e.indexOf(a);if("@"!==a)return t.isSkill(l)?{kind:"skill",start:i,end:i+a.length+l.length}:null;if(t.isBot(l))return{kind:"bot",start:i,end:i+1+l.length};let d=function(e,t){let n=e.toLowerCase(),o=null;for(let r of t){let t=s(r.title);if(!t||t.length<=(o?.length??0)||!n.startsWith(t))continue;let a=e.charAt(t.length);(!a||/\s/.test(a))&&(o=t)}if(null===o)return null;let a=t.filter(e=>s(e.title)===o),l=e.slice(0,o.length);return a.length>1?{kind:"ambiguous",title:l,candidates:a}:{kind:"match",session:a[0],title:r(a[0].title),rest:e.slice(o.length).trim()}}(e.slice(i+1),t.sessions);return d?.kind!=="match"||t.selfSessionId&&d.session.sessionId===t.selfSessionId?null:{kind:"session",start:i,end:i+1+d.title.length}}function l(e,t,n,r){let s=0===t?0:e.lastIndexOf("\n",t-1)+1,o=e.indexOf("\n",s),a=e.slice(s,-1===o?e.length:o),l=r(a);if(!l)return null;let i=t-s;if(!("Backspace"===n?i>l.start&&i<=l.end:i>=l.start&&i<l.end))return null;let d=" "===a[l.end]?l.end+1:l.end;return[s+l.start,s+d]}},24602:(e,t,n)=>{n.d(t,{N:()=>S});var r=n(95155),s=n(12115),o=n(79114),a=n(64428),l=n(34075),i=n(14341),d=n(42804),c=n(22164),u=n(34582),m=n(85269),h=n(86304),p=n(17243),f=n(28132),g=n(86957),x=n(38408),b=n(60938),v=n(51145),y=n(79237);let w=new Set(["png","jpg","jpeg","gif","webp","svg","ico","bmp","avif"]),k=new Set(["js","mjs","cjs","jsx","ts","tsx","css","json","html","htm","md","markdown","txt","yml","yaml","sh","bash","xml","csv"]),C=e=>{let t=e.replace(/\\/g,"/");return t.slice(t.lastIndexOf("/")+1)},j=e=>{let t,n,r=(n=(t=C(e).toLowerCase()).lastIndexOf("."))<0?"":t.slice(n+1);return w.has(r)?"image":k.has(r)?"text":null};function N({entryPath:e,entryContent:t}){let n=(0,s.useMemo)(()=>{let t,n;return(n=(t=e.replace(/\\/g,"/")).lastIndexOf("/"))<=0?"/":t.slice(0,n)},[e]),o=e=>(0,y.y)(n,e)||C(e),a=(0,s.useRef)(new Map),[l,i]=(0,s.useState)([]),[d,c]=(0,s.useState)(e),[u,m]=(0,s.useState)(!0);(0,s.useEffect)(()=>{a.current=new Map([[e,t]]);let r={abs:e,rel:C(e),kind:"text"};i([r]),c(e),m(!0);let s=!1;return(async()=>{let l=new Set([e]),d=[r],c=[t];for(;c.length&&d.length<40&&!s;)for(let e of function(e){let t,n=/(?<![.\w])\.\/([\w./-]+\.\w+)/g,r=new Set;for(;null!==(t=n.exec(e));)r.add(t[1]);return[...r]}(c.shift())){if(d.length>=40)break;let t=function(e,t){let n=e.replace(/\\/g,"/").replace(/\/+$/,""),r=[];for(let e of(n+"/"+t).split("/"))if(""!==e&&"."!==e){if(".."===e){if(!r.length)return null;r.pop();continue}r.push(e)}let s="/"+r.join("/");return s===n||s.startsWith(n+"/")?s:null}(n,e);if(!t||l.has(t))continue;l.add(t);let r=j(t);if(r)if("image"===r){let e=await g.t4.runPromise((0,b.r6)(n,t)).catch(()=>null);e?.ok&&e.data&&!s&&(d.push({abs:t,rel:o(t),kind:r}),i([...d]))}else{let e=await g.t4.runPromise((0,v.K)(n,t)).catch(()=>null);e?.ok&&e.data?.content!=null&&(a.current.set(t,e.data.content),c.push(e.data.content),s||(d.push({abs:t,rel:o(t),kind:r}),i([...d])))}}s||m(!1)})(),()=>{s=!0}},[e,t,n]);let h=l.find(e=>e.abs===d),w=l.length>1||u;return(0,r.jsxs)("div",{className:"flex h-full",children:[w&&(0,r.jsxs)("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto",children:[l.map(e=>(0,r.jsxs)("button",{onClick:()=>c(e.abs),"data-tooltip":e.rel,className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 min-w-0 transition-colors ${d===e.abs?"bg-accent text-foreground":"text-muted-foreground hover:bg-hover"}`,children:["image"===e.kind?(0,r.jsx)(p.A,{className:"w-3.5 h-3.5 flex-shrink-0"}):(0,r.jsx)(f.A,{className:"w-3.5 h-3.5 flex-shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:e.rel})]},e.abs)),u&&(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"…"})]}),(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:h?.kind==="image"?(0,r.jsx)("div",{className:"h-full flex items-center justify-center p-4 overflow-auto bg-background",children:(0,r.jsx)("img",{src:`/api/file?path=${encodeURIComponent(d)}&raw=true`,alt:C(d),className:"max-w-full max-h-full object-contain"})}):(0,r.jsx)(x.Cv,{content:a.current.get(d)??"",filePath:d,cwd:n},d)})]})}function S({filePath:e,content:t,cwd:n,onClose:p,onContentSearch:f}){let{t:g}=(0,o.Bd)(),x=(0,h.P)(),[b,v]=(0,s.useState)("preview");return(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:p,children:(0,r.jsxs)("div",{className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":e,onClick:()=>{navigator.clipboard.writeText(e),(0,l.oR)(g("common.copiedPath"))},children:(0,r.jsx)("bdi",{dir:"ltr",children:e})}),(0,r.jsx)("button",{onClick:()=>v(e=>"preview"===e?"source":"preview"),className:`px-1.5 py-0.5 text-xs rounded transition-colors flex-shrink-0 ${"preview"===b?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:"preview"===b?g("fileBrowser.exitPreview"):g("common.preview")}),(0,r.jsx)("button",{onClick:()=>x(e),title:g("htmlApps.addTooltip"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,r.jsx)(i.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:()=>{window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:e}})),p()},title:g("common.openInConsole"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,r.jsx)(d.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:()=>{let t=(0,u.Xe)(e,n);window.open((0,u.PB)(t,window.location.origin),"_blank")},title:g("browser.openInNewWindow"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,r.jsx)(c.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:p,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:"preview"===b?(0,r.jsx)(m.O,{content:t,filePath:e,cwd:n,onContentSearch:f?e=>{f(e),p()}:void 0}):(0,r.jsx)(N,{entryPath:e,entryContent:t,cwd:n})})]})})})}},27570:(e,t,n)=>{n.d(t,{L:()=>s});var r=n(12115);function s({enabled:e,container:t,resolveLineRange:n,buildLineSnapshot:o,dragThresholdPx:a=5}){let l=(0,r.useRef)(null),i=(0,r.useRef)(()=>{}),d=(0,r.useRef)(n),c=(0,r.useRef)(o),u=(0,r.useRef)(a);return d.current=n,c.current=o,u.current=a,(0,r.useEffect)(()=>{if(!e||!t)return;let n=!1,r=0,s=0,o=()=>{l.current&&(l.current=null,i.current())},a=e=>{n=!0,r=e.clientX,s=e.clientY;let t=e.target;t?.closest?.(".floating-toolbar")||o()},m=e=>{n=!1;let a=e.target;if(a?.closest?.(".floating-toolbar"))return;let m=u.current,h=Math.abs(e.clientX-r)>m||Math.abs(e.clientY-s)>m,p=window.getSelection();if(!p||p.isCollapsed||!p.toString().trim()||!h)return void o();let f=p.getRangeAt(0);if(!t.contains(f.commonAncestorContainer))return void o();let g=d.current(f.startContainer),x=d.current(f.endContainer);if(!g||!x)return void o();let b=Math.min(g.start,x.start),v=Math.max(g.end,x.end),y=p.toString(),w=c.current({start:b,end:v});l.current={x:e.clientX,y:e.clientY,range:{start:b,end:v},selectedText:y,lineSnapshot:w},i.current()},h=()=>{if(n||!l.current)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||o()};return t.addEventListener("mousedown",a),document.addEventListener("mouseup",m),document.addEventListener("selectionchange",h),()=>{t.removeEventListener("mousedown",a),document.removeEventListener("mouseup",m),document.removeEventListener("selectionchange",h)}},[e,t]),{toolbarRef:l,bumpRef:i,clearToolbar:()=>{l.current&&(l.current=null,i.current())}}}},30133:(e,t,n)=>{n.d(t,{y:()=>o});var r=n(95155),s=n(79114);function o({value:e,onChange:t,className:n}){let{t:a}=(0,s.Bd)();return(0,r.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${n??""}`,children:["compact","full"].map(n=>(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),t(n)},className:`px-2 py-0.5 text-xs transition-colors ${e===n?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:a("compact"===n?"diffViewer.compact":"diffViewer.full")},n))})}},30577:(e,t,n)=>{n.d(t,{m:()=>c});var r=n(95155),s=n(12115),o=n(64428),a=n(86957),l=n(57125),i=n(83448);function d(e){return"env"===e?"from env var":"default"===e?"default":null}function c({currentModel:e,onModelChange:t}){let[n,u]=(0,s.useState)(!1),[m,h]=(0,s.useState)([]),[p,f]=(0,s.useState)(!1),[g,x]=(0,s.useState)(null),[b,v]=(0,s.useState)(!1),[y,w]=(0,s.useState)(!1),[k,C]=(0,s.useState)(!1),[j,N]=(0,s.useState)(null),[S,T]=(0,s.useState)(""),[E,R]=(0,s.useState)("default"),[M,L]=(0,s.useState)(!1),[I,A]=(0,s.useState)(""),[P,F]=(0,s.useState)("default"),[$,D]=(0,s.useState)(""),[_,B]=(0,s.useState)(!1),O=(0,s.useRef)(null),H=(0,s.useRef)(null),V=(0,s.useRef)(null),[U,W]=(0,s.useState)({top:0,left:0});(0,l.r8)(H,n,U.left);let q=(0,o.F2)();(0,s.useEffect)(()=>{if(!n)return;let e=e=>{H.current&&!H.current.contains(e.target)&&O.current&&!O.current.contains(e.target)&&u(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]);let z=(0,s.useCallback)(async()=>{f(!0),x(null);let e=await a.t4.runPromiseExit((0,i.qD)(()=>v(!0)));if(v(!1),"Failure"===e._tag)x("Connection error");else{let t=e.value;switch(t._tag){case"ok":h(t.models);break;case"not-installed":case"error":x(t.message);break;case"not-running":x("Ollama is not running")}}f(!1)},[]),K=(0,s.useCallback)(e=>{T(e.baseUrl),R(e.baseUrlSource),L(e.hasKey),A(e.maskedKey),F(e.keySource),D(""),B(!1)},[]),G=(0,s.useCallback)(async()=>{w(!0),N(null);let e=await a.t4.runPromiseExit((0,i.F4)());"Failure"===e._tag?N("Failed to load config"):K(e.value),w(!1)},[K]),Q=async()=>{C(!0),N(null);let e=await a.t4.runPromiseExit((0,i.yS)({baseUrl:S}));"Failure"===e._tag?N("Save failed"):(K(e.value),await z()),C(!1)},J=async()=>{let e=$.trim();if(!e)return;C(!0),N(null);let t=await a.t4.runPromiseExit((0,i.yS)({apiKey:e}));"Failure"===t._tag?N("Save failed"):K(t.value),C(!1)},Y=async()=>{C(!0),N(null);let e=await a.t4.runPromiseExit((0,i.yS)({apiKey:""}));"Failure"===e._tag?N("Clear failed"):K(e.value),C(!1)},X=e?e.replace(/:latest$/,""):"Select model",Z=d(E),ee=d(P),et=n?(0,r.jsx)(o.ZL,{children:(0,r.jsxs)("div",{ref:H,className:`${l.ys} min-w-[300px]`,style:{top:U.top,left:U.left},children:[(0,r.jsxs)("div",{className:"px-3 py-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Server URL"}),Z&&!y&&(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:Z})]}),y?(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"text",value:S,onChange:e=>T(e.target.value),onKeyDown:e=>{"Enter"===e.key&&Q()},placeholder:"http://127.0.0.1:11434",spellCheck:!1,className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${l.Fx}`}),(0,r.jsx)("button",{onClick:Q,disabled:k,className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${l.$T}`,children:k?"...":"Save"})]})]}),(0,r.jsxs)("div",{className:"px-3 py-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"API Key"}),ee&&M&&!y&&(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:ee})]}),y?null:M&&!_?(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:I}),(0,r.jsx)("button",{onClick:()=>{B(!0),D(""),setTimeout(()=>V.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-hover text-foreground transition-colors",disabled:k,children:"Edit"}),(0,r.jsx)("button",{onClick:Y,className:"text-[11px] px-2 py-1 rounded text-red-11 hover:bg-red-500/10 transition-colors",disabled:k,children:"Clear"})]}):(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{ref:V,type:"password",value:$,onChange:e=>D(e.target.value),onKeyDown:e=>{"Enter"===e.key&&J()},placeholder:"optional — for authenticated servers",spellCheck:!1,className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${l.Fx}`}),(0,r.jsx)("button",{onClick:J,disabled:k||!$.trim(),className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${l.$T}`,children:k?"...":"Save"}),M&&(0,r.jsx)("button",{onClick:()=>{B(!1),D("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),j&&(0,r.jsx)("div",{className:"mt-1 text-[11px] text-red-11",children:j})]}),(0,r.jsx)("div",{className:"my-1 border-t border-border"}),(0,r.jsx)("div",{className:"px-3 pt-1 pb-0.5",children:(0,r.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Model"})}),(0,r.jsx)("div",{className:"max-h-[240px] overflow-y-auto",children:p||b?(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),b?"Starting Ollama...":"Loading models..."]}):g?(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-red-11",children:g}):0===m.length?(0,r.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models found. Run ",(0,r.jsx)("code",{className:"bg-secondary px-1 rounded",children:"ollama pull <model>"})]}):m.map(n=>{var s;let o=n.name===e;return(0,r.jsxs)("button",{onClick:()=>{t(n.name),u(!1)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors ${o?l.yI:"text-foreground hover:bg-hover"}`,children:[(0,r.jsx)(l.hG,{selected:o}),(0,r.jsx)("span",{className:"truncate",children:n.name.replace(/:latest$/,"")}),(0,r.jsx)("span",{className:"ml-auto pl-2 text-muted-foreground flex-shrink-0",children:n.parameter_size||((s=n.size)<1e9?`${(s/1e6).toFixed(0)}M`:`${(s/1e9).toFixed(1)}G`)})]},n.name)})})]})}):null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.XY,{buttonRef:O,label:X,title:"Configure Ollama",onClick:()=>{if(!n){if(O.current){let e=O.current.getBoundingClientRect(),t=q?.getBoundingClientRect(),n=t?.left??0,r=t?.top??0;W({top:e.bottom+4-r,left:e.left-n})}G(),z()}u(e=>!e)},icon:(0,r.jsx)(l.eV,{engine:"ollama"}),testId:"ollama-config-picker"}),et]})}},32041:(e,t,n)=>{n.d(t,{C0:()=>m});var r=n(95155),s=n(12115),o=n(61878),a=n(33210),l=n(9921),i=n(66088),d=n(79114);let c=/^-?[\d,]*\.?\d+%?$/;function u(e){return c.test(e)?parseFloat(e.replace(/,/g,"")):NaN}function m({content:e,filePath:t,className:n="",action:h}){let{t:p}=(0,d.Bd)(),[f,g]=(0,s.useState)(500),[x,b]=(0,s.useState)(""),[v,y]=(0,s.useState)(-1),[w,k]=(0,s.useState)(null),{header:C,body:j,columnCount:N}=(0,s.useMemo)(()=>{let n=(function(e,t){let n=[],r=[],s="",o=!1,a=!1,l=()=>{r.push(s),n.push(r),r=[],s="",a=!1};for(let n=0;n<e.length;n++){let i=e[n];if(o){if('"'!==i){s+=i;continue}'"'===e[n+1]?(s+='"',n++):o=!1;continue}if('"'===i&&""===s){o=!0,a=!0;continue}if(i===t){r.push(s),s="",a=!0;continue}if("\r"===i){"\n"===e[n+1]&&n++,l();continue}if("\n"===i){l();continue}s+=i,a=!0}return(a||""!==s||r.length>0)&&l(),n})(e,function(e,t){if(t&&/\.tsv$/i.test(t))return" ";let n=e.slice(0,65536),r={",":0,";":0," ":0,"|":0},s=!1,o=0;for(let e=0;e<n.length&&o<5;e++){let t=n[e];if('"'===t){s=!s;continue}if(!s){if("\n"===t){o++;continue}t in r&&r[t]++}}let a=Object.entries(r).sort((e,t)=>t[1]-e[1])[0];return a[1]>0?a[0]:","}(e,t)).filter(e=>e.length>1||""!==e[0]),r=n.reduce((e,t)=>Math.max(e,t.length),0),s=n.slice(1).map((e,t)=>({index:t,cells:e}));return{header:n[0]??[],body:s,columnCount:r}},[e,t]);(0,s.useEffect)(()=>{g(500),b(""),y(-1),k(null)},[e,t]);let S=(0,s.useMemo)(()=>{let e=x.trim().toLowerCase();return e?j.filter(t=>v>=0?(t.cells[v]??"").toLowerCase().includes(e):t.cells.some(t=>t.toLowerCase().includes(e))):j},[j,x,v]),T=(0,s.useMemo)(()=>{if(!w)return S;let e="asc"===w.dir?1:-1;return[...S].sort((t,n)=>(function(e,t,n){if(""===e||""===t)return e===t?0:""===e?1:-1;let r=u(e),s=u(t);return isNaN(r)||isNaN(s)?e.localeCompare(t,void 0,{numeric:!0})*n:(r-s)*n})(t.cells[w.col]??"",n.cells[w.col]??"",e))},[S,w]);(0,s.useEffect)(()=>{g(500)},[x,v]);let E=(0,s.useCallback)(e=>{k(t=>t&&t.col===e?"asc"===t.dir?{col:e,dir:"desc"}:null:{col:e,dir:"asc"})},[]);if(0===N)return(0,r.jsx)("div",{className:`flex items-center justify-center ${n}`,children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:p("csv.empty")})});let R=T.slice(0,f);return(0,r.jsxs)("div",{className:`flex flex-col min-h-0 ${n}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-1 min-w-0 px-1.5 py-0.5 rounded border border-border bg-card focus-within:border-brand transition-colors",children:[(0,r.jsx)(o.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0","aria-hidden":!0}),(0,r.jsx)("input",{value:x,onChange:e=>b(e.target.value),placeholder:p("csv.filterPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs text-foreground placeholder:text-muted-foreground outline-none"}),x&&(0,r.jsx)("button",{onClick:()=>b(""),className:"text-muted-foreground hover:text-foreground flex-shrink-0",title:p("csv.clearFilter"),children:(0,r.jsx)(a.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsxs)("select",{value:v,onChange:e=>y(Number(e.target.value)),className:"text-xs bg-card text-muted-foreground border border-border rounded px-1 py-1 max-w-[10rem] flex-shrink-0",title:p("csv.filterColumn"),children:[(0,r.jsx)("option",{value:-1,children:p("csv.allColumns")}),Array.from({length:N},(e,t)=>(0,r.jsx)("option",{value:t,children:C[t]||`#${t+1}`},t))]}),h&&(0,r.jsx)("button",{onClick:h.onClick,className:"text-xs px-2 py-1 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:h.label})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,r.jsxs)("table",{className:"text-xs border-collapse w-max min-w-full",children:[(0,r.jsx)("thead",{className:"sticky top-0 z-10",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"sticky left-0 z-20 bg-accent border-b border-r border-border px-2 py-1.5 text-right font-normal text-muted-foreground select-none",children:"#"}),Array.from({length:N},(e,t)=>(0,r.jsx)("th",{onClick:()=>E(t),className:"bg-accent border-b border-border px-2 py-1.5 text-left font-medium text-foreground whitespace-nowrap cursor-pointer select-none hover:bg-hover",title:p("csv.sortHint"),children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[C[t]??"",w?.col===t&&("asc"===w.dir?(0,r.jsx)(l.A,{className:"w-3 h-3 text-brand","aria-hidden":!0}):(0,r.jsx)(i.A,{className:"w-3 h-3 text-brand","aria-hidden":!0}))]})},t))]})}),(0,r.jsx)("tbody",{children:R.map(e=>(0,r.jsxs)("tr",{className:"hover:bg-hover",children:[(0,r.jsx)("td",{className:"sticky left-0 bg-card border-b border-r border-border px-2 py-1 text-right text-muted-foreground tabular-nums select-none",children:e.index+1}),Array.from({length:N},(t,n)=>{let s=e.cells[n]??"";return(0,r.jsx)("td",{title:s.length>60?s:void 0,className:`border-b border-border px-2 py-1 max-w-[28rem] truncate text-foreground ${c.test(s)?"text-right tabular-nums":""}`,children:s},n)})]},e.index))})]}),0===R.length&&(0,r.jsx)("div",{className:"p-4 text-xs text-muted-foreground",children:p("csv.noMatch")})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3 px-3 py-1.5 border-t border-border text-xs text-muted-foreground flex-shrink-0",children:[(0,r.jsx)("span",{children:S.length===j.length?p("csv.summary",{rows:j.length,cols:N}):p("csv.summaryFiltered",{rows:S.length,total:j.length,cols:N})}),R.length<T.length&&(0,r.jsx)("button",{onClick:()=>g(e=>e+500),className:"px-1.5 py-0.5 rounded hover:bg-hover hover:text-foreground transition-colors",children:p("csv.loadMore",{shown:R.length,total:T.length})})]})]})}},32456:(e,t,n)=>{n.d(t,{Mm:()=>l,Qr:()=>o,fw:()=>a,wG:()=>i,wX:()=>d});var r=n(95155),s=n(39872);let o=e=>e.split("/").pop()||e;function a(e,t){let n=Math.floor((Date.now()-t)/6e4);if(n<1)return e("common.justNow");if(n<60)return e("common.minutesAgo",{count:n});let r=Math.floor(n/60);return r<24?e("common.hoursAgo",{count:r}):e("common.daysAgo",{count:Math.floor(r/24)})}function l(e,t){return"loading"===t?e("sessions.running"):"unread"===t?e("sessions.done"):void 0}function i(e){let t=new Map;for(let n of e){let e=t.get(n.cwd);e?e.push(n):t.set(n.cwd,[n])}return[...t].map(([e,t])=>({cwd:e,items:t}))}function d({cwd:e,projectOrder:t,currentCwd:n,children:a}){let l=t.indexOf(e)+1;return(0,r.jsxs)("div",{className:"sticky top-0 z-10 px-3 py-1.5 bg-card rounded-t-lg border-b border-border/60 text-[11px] font-medium text-muted-foreground flex items-center gap-1.5",children:[l>0&&(0,r.jsx)(s.B,{number:l,isActive:e===n}),(0,r.jsx)("span",{className:"truncate","data-tooltip":e,children:o(e)}),a]})}},33199:(e,t,n)=>{n.d(t,{s:()=>eJ});var r=n(95155),s=n(12115),o=n(34075),a=n(64428),l=n(67635),i=n(46945),d=n(54731),c=n(9921),u=n(66088),m=n(12651),h=n(81165),p=n(16950),f=n(11019),g=n(12612),x=n(31025),b=n(74102),v=n(68459),y=n(18763),w=n(73172),k=n(79114),C=n(49433),j=n(91281),N=n(80286),S=n(86957),T=n(97938);function E({cwd:e,sessionId:t,toolCall:n,workflowRef:o,running:l,onClose:i}){let{t:d}=(0,k.Bd)(),[c,u]=(0,s.useState)(null),[m,h]=(0,s.useState)(null),[p,f]=(0,s.useState)(!1),[g,x]=(0,s.useState)([]),[b,v]=(0,s.useState)(),y=(0,s.useRef)(0),w=(0,s.useRef)(void 0),R=o?!!o.running:l??!n?.result,M=(0,s.useCallback)(async()=>{let r=++y.current,s=await S.t4.runPromiseExit((0,T.z)({cwd:e,sessionId:t,...o?{workflowId:o.runId,workflowAgentId:o.agentId}:{toolUseId:n?.id},childSessionId:b,ifFingerprint:w.current}));if(r!==y.current||(f(!0),"Success"!==s._tag||!s.value))return;let a=s.value;!b&&a.childSessionId&&v(a.childSessionId),a.children&&x(a.children),a.fingerprint&&(w.current=a.fingerprint),!a.notModified&&(a.messages&&u(a.messages),a.subagent&&h(a.subagent))},[e,t,n?.id,o?.runId,o?.agentId,b]);(0,s.useEffect)(()=>{let e=C.ivC(M),t=S.t4.runFork(R?e.pipe(C.uxO(j.ji(5e3))):e);return()=>{y.current++,S.t4.runFork(N.G(t))}},[R,M]);let L=(0,s.useRef)(null),I=(0,s.useRef)(!0);(0,s.useEffect)(()=>{let e=L.current;e&&I.current&&(e.scrollTop=e.scrollHeight)},[c]);let A="string"==typeof n?.input?.description?n.input.description:"",P=o?o.label||"":[m?.agentType,m?.description,A].filter(Boolean).join(" \xb7 ");return(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:e=>{e.stopPropagation(),i()},children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-base",children:"\uD83E\uDD16"}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:d("chat.subagent")}),P&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":P,children:P}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[R&&(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("button",{onClick:i,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:d("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),g.length>0&&(0,r.jsx)("div",{className:"flex gap-2 overflow-x-auto px-4 py-2 border-b border-border flex-shrink-0",children:g.map(e=>(0,r.jsxs)("button",{type:"button","aria-pressed":(b??g[0]?.id)===e.id,className:"text-xs rounded px-2 py-1 whitespace-nowrap aria-pressed:bg-hover text-foreground",title:`${e.model} \xb7 ${e.status}`,onClick:()=>{(b??g[0]?.id)!==e.id&&(y.current++,w.current=void 0,u(null),h(null),f(!1),v(e.id))},children:[e.name," \xb7 ",e.model," \xb7 ",d(`chat.piChildStatus.${e.status}`,{defaultValue:e.status})]},e.id))}),(0,r.jsx)("div",{ref:L,onScroll:()=>{let e=L.current;e&&(I.current=e.scrollTop+e.clientHeight>=e.scrollHeight-40)},className:"flex-1 overflow-y-auto px-4 py-3",children:null===c?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:p?d("chat.subagentEmpty"):d("common.loading")}):c.map(n=>(0,r.jsx)(eJ,{message:n,cwd:e,sessionId:t},n.id))})]})})})}function R(e){return e?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):"0"}function M(e){if(!e)return"–";let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return`${n}m${t%60}s`}let L={done:"text-green-9",running:"text-brand",queued:"text-muted-foreground",error:"text-red-9",failed:"text-red-9"};function I({cwd:e,sessionId:t,runId:n,isRunning:o,onClose:l}){let{t:i}=(0,k.Bd)(),[d,c]=(0,s.useState)(null),[u,m]=(0,s.useState)(!1),[h,p]=(0,s.useState)(null),f=(0,s.useRef)(void 0),g=o||null!=d&&"completed"!==d.status&&"failed"!==d.status,x=(0,s.useCallback)(async()=>{let r=await S.t4.runPromiseExit((0,T.z)({cwd:e,sessionId:t,workflowId:n,ifFingerprint:f.current}));if(m(!0),"Success"!==r._tag||!r.value)return;let s=r.value;s.fingerprint&&(f.current=s.fingerprint),!s.notModified&&s.workflow&&c(s.workflow)},[e,t,n]);(0,s.useEffect)(()=>{if(x(),!g)return;let e=setInterval(x,5e3);return()=>clearInterval(e)},[g,x]);let b=[];if(d?.agents){let e=new Map;for(let t of d.agents){let n=t.phaseTitle||i("chat.workflowUngrouped");e.has(n)||e.set(n,[]),e.get(n).push(t)}for(let[t,n]of e)b.push({title:t,agents:n})}let v=d?[d.workflowName,d.status,`${d.agentCount??d.agents?.length??0} ${i("chat.workflowAgents")}`,`${R(d.totalTokens)} tok`,M(d.durationMs)].filter(Boolean).join(" \xb7 "):"";return(0,r.jsxs)(a.ZL,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:l,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-base",children:"\uD83E\uDDE9"}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:i("chat.workflowRun")}),v&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":v,children:v}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[g&&(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("button",{onClick:l,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:i("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:null===d?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:i(u?"chat.workflowEmpty":"common.loading")}):(0,r.jsxs)(r.Fragment,{children:[d.summary&&(0,r.jsx)("div",{className:"mb-3 text-xs text-muted-foreground whitespace-pre-wrap",children:d.summary}),b.map(e=>(0,r.jsxs)(s.Fragment,{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-foreground/80 mt-3 mb-1 sticky top-0 bg-card py-1",children:e.title}),e.agents.map(e=>(0,r.jsx)(A,{agent:e,onOpen:()=>e.agentId&&p({runId:n,agentId:e.agentId,label:e.label,running:"done"!==e.state&&g})},`${e.index}-${e.agentId}`))]},e.title))]})})]})}),h&&(0,r.jsx)(E,{cwd:e,sessionId:t,workflowRef:h,onClose:()=>p(null)})]})}function A({agent:e,onOpen:t}){let{t:n}=(0,k.Bd)(),[o,a]=(0,s.useState)(!1),l=e.state&&L[e.state]||"text-muted-foreground",i=e.resultPreview||e.promptPreview||"";return(0,r.jsxs)("div",{className:"border border-border rounded-md mb-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,r.jsx)("button",{onClick:()=>a(e=>!e),className:"text-foreground-subtle text-xs flex-shrink-0",title:n(o?"chat.collapse":"chat.expand"),children:o?"▲":"▼"}),(0,r.jsx)("span",{className:"text-xs text-foreground truncate flex-1 min-w-0","data-tooltip":e.label||"",children:e.label||e.agentId}),(0,r.jsx)("span",{className:`text-[10px] flex-shrink-0 ${l}`,children:e.state}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[R(e.tokens)," tok \xb7 ",M(e.durationMs)]}),e.agentId&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:t,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&t()},className:"text-xs text-brand hover:text-teal-10 cursor-pointer flex-shrink-0",title:n("chat.subagentViewTitle"),children:n("chat.workflowViewAgent")})]}),o&&i&&(0,r.jsx)("pre",{className:"text-[11px] bg-secondary px-2 py-1.5 rounded-b overflow-x-auto max-h-32 overflow-y-auto text-muted-foreground whitespace-pre-wrap border-t border-border",children:i})]})}var P=n(74086),F=n(60938),$=n(45619),D=n(38408),_=n(6744),B=n(47176),O=n(97251),H=n(34582),V=n(56045),U=n(61043),W=n(50860),q=n(47215);function z({filePath:e}){let[t,n]=(0,s.useState)(null),[o,a]=(0,s.useState)(!0),[l,i]=(0,s.useState)(null),d=(0,s.useRef)(!1),c=(0,q.e$)(e),u=(0,q.u)(e);return((0,s.useEffect)(()=>{u?a(!1):d.current||(d.current=!0,(async()=>{a(!0),i(null);let t=await S.t4.runPromiseExit((0,F.nM)(e));if("Success"===t._tag)n(t.value.content??null);else{let e="Fail"===t.cause._tag?t.cause.error:null,n=e?.cause;i(n instanceof Error?n.message:"Failed to load file")}a(!1),d.current=!1})())},[e,u]),l)?(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("div",{className:"text-xs text-red-11",children:l})}):o?(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):(0,q.u)(e)?(0,r.jsx)(W.I,{absPath:e,className:"flex items-center justify-center h-full overflow-auto",imgClassName:"max-w-full max-h-full object-contain",alt:e.split("/").pop()||"image"}):t?c?(0,r.jsx)(G,{content:t,filePath:e}):(0,r.jsx)(D.Cv,{content:t,filePath:e,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}let K=[O.W];function G({content:e,filePath:t}){let n=(0,s.useRef)(null),o=(0,s.useMemo)(()=>(0,H.J4)(t),[t]);return(0,r.jsxs)("div",{className:"h-full flex",children:[(0,r.jsx)(B.l,{content:e,containerRef:n}),(0,r.jsx)("div",{ref:n,className:"flex-1 overflow-auto p-4",children:(0,r.jsx)(_.T,{content:e,basePath:o,rehypePlugins:K})})]})}function Q({title:e,content:t,toolName:n,result:l,sidebar:i,onClose:d}){let{t:c}=(0,k.Bd)(),u=(0,q.jU)(t),m=(0,q.zs)(t),h=(0,q.oK)(t),p=!!m,f=!!h,g=()=>("Read"===n||"Write"===n)&&f?"file":p?"diff-unified":u?"readable":"json",[x,b]=(0,s.useState)(g()),v=`${n??""}\0${t}`,[y,w]=(0,s.useState)(v);y!==v&&(w(v),b(g()));let C=(0,s.useRef)(null),j=(0,V.o)(C);(0,s.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&"readable"===x&&u){e.preventDefault(),j.open();return}if("Escape"===e.key){if(j.isVisible)return void j.close();document.activeElement instanceof HTMLElement&&document.activeElement.blur(),d()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[d,x,u,j]);let N=()=>"file"===x&&h?(0,r.jsx)(z,{filePath:h}):"diff-unified"===x&&m?(0,r.jsx)($.xU,{oldContent:m.old_string,newContent:m.new_string,filePath:m.file_path}):"diff-split"===x&&m?(0,r.jsx)($.xZ,{oldContent:m.old_string,newContent:m.new_string,filePath:m.file_path}):"readable"===x&&u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(V._,{search:j}),(0,r.jsx)("pre",{ref:C,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,q.xb)(t)})]}):(0,r.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:u?(0,q.C6)(t):t}),S=(0,s.useMemo)(()=>void 0===l?null:(0,q.jU)(l)?(0,q.C6)(l):l,[l]),T=(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:d,children:(0,r.jsxs)("div",{className:"bg-card shadow-lv3 w-full max-w-[90%] h-full md:h-[90vh] rounded-none md:rounded-lg flex flex-col transition-all",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground truncate",title:e,children:e}),h&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(h),(0,o.oR)(c("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:c("common.copyAbsPath"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsxs)("div",{className:"flex items-center gap-3 flex-shrink-0 whitespace-nowrap",children:[u&&(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[p&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:()=>b("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===x?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:c("diffViewer.sideBySide"),children:"Split"}),(0,r.jsx)("button",{onClick:()=>b("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===x?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:c("diffViewer.unified"),children:"Unified"})]}),f&&(0,r.jsx)("button",{onClick:()=>b("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===x?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:c("diffViewer.previewFile"),children:"File"}),(0,r.jsx)("button",{onClick:()=>b("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===x?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:c("common.readable")}),(0,r.jsx)("button",{onClick:()=>b("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===x?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,r.jsx)("button",{onClick:d,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[i&&(0,r.jsx)(U.q,{children:i}),(0,r.jsx)("div",{className:"flex-1 min-w-0 flex flex-col",children:null===S?(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-auto p-4",children:N()}):(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col",children:[(0,r.jsxs)("div",{className:`min-h-0 flex flex-col ${"diff-unified"===x||"diff-split"===x||"file"===x?"flex-1":"flex-shrink-0 max-h-[40%]"}`,children:[(0,r.jsx)("div",{className:"px-4 pt-3 pb-1 text-xs text-muted-foreground",children:c("toolCall.input")}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-auto px-4 pb-3",children:N()})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col border-t border-border",children:[(0,r.jsx)("div",{className:"px-4 pt-3 pb-1 text-xs text-muted-foreground",children:c("toolCall.result")}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-auto px-4 pb-3",children:(0,r.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:S})})]})]})})]})]})});return(0,r.jsx)(a.ZL,{children:T})}var J=n(79237);let Y=null,X=new Set;function Z(e){return X.add(e),()=>{X.delete(e)}}let ee={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",ApplyPatch:"\uD83E\uDDE9",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D",Workflow:"\uD83E\uDDE9",Skill:"\uD83D\uDEE0️"};function et(e){return"object"==typeof e&&null!==e}function en(e,t){let n=t?(0,J.y)(t,e):null;if(n)return n;let r=e.split("/");return r.length>2?".../"+r.slice(-2).join("/"):e}function er(e,t){let{name:n,input:r}=e,s="Agent"===n||"Task"===n,o="Workflow"===n,a="Skill"===n,l=(()=>{if("Bash"===n&&r.command&&"string"==typeof r.command)return r.command;if("ApplyPatch"===n&&Array.isArray(r.changes)){let e=r.changes.filter(et).flatMap(e=>{let n="string"==typeof e.path?e.path:"";if(!n)return[];let r="string"==typeof e.kind&&e.kind?e.kind:"update";return`${r} ${en(n,t)}`});if(e.length>0)return e.join(" \xb7 ")}if(s&&r.description&&"string"==typeof r.description)return r.description;if(o){let e=["string"==typeof r.name?r.name:"","string"==typeof r.args?r.args:"string"==typeof r.resumeFromRunId?r.resumeFromRunId:""].filter(Boolean).join(" \xb7 ");if(e)return e}if(a&&"string"==typeof r.skill){let e="string"==typeof r.args?r.args:"";return[r.skill,e].filter(Boolean).join(" \xb7 ")}return"Glob"===n&&r.pattern&&"string"==typeof r.pattern||"Grep"===n&&r.pattern&&"string"==typeof r.pattern?r.pattern:"ToolSearch"===n&&r.query&&"string"==typeof r.query?r.query:"TaskCreate"===n&&r.subject&&"string"==typeof r.subject?r.subject:r.file_path&&"string"==typeof r.file_path?r.file_path:r.path&&"string"==typeof r.path?r.path:null})(),i="Glob"===n||"Grep"===n||"Bash"===n||"ApplyPatch"===n||s||o||a,d=l?i?l:en(l,t):null;return{icon:ee[n]||"\uD83D\uDD27",displayInfo:l,displayPath:d}}function es({calls:e,initialIndex:t,cwd:n,onClose:o}){let[a,l]=(0,s.useState)(t),i=e[Math.min(a,e.length-1)];if(!i)return null;let{displayPath:d}=er(i,n),c=e.length>1?(0,r.jsx)("ul",{className:"py-1",children:e.map((e,t)=>{let s=er(e,n),o=e===i;return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{onClick:()=>l(t),className:`w-full px-3 py-1.5 flex items-center gap-2 text-left transition-colors ${o?"bg-accent":"hover:bg-hover"}`,title:s.displayInfo??e.name,children:[(0,r.jsx)("span",{className:"text-sm flex-shrink-0",children:s.icon}),(0,r.jsx)("span",{className:`text-sm text-foreground flex-shrink-0 ${o?"font-medium":""}`,children:e.name}),s.displayPath&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate min-w-0 flex-1",children:s.displayPath}),e.isLoading&&(0,r.jsx)("span",{className:"ml-auto inline-block w-3 h-3 border-2 border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"})]})},`${e.id}-${t}`)})}):void 0;return(0,r.jsx)(Q,{title:`${i.name}${d?` ${d}`:""}`,content:JSON.stringify(i.input,null,2),result:!i.isLoading&&i.result?"string"==typeof i.result?i.result:JSON.stringify(i.result,null,2):void 0,toolName:i.name,sidebar:c,onClose:o})}function eo({toolCall:e,cwd:t,sessionId:n,disableOverlays:a=!1,siblings:l,index:i=0}){var d;let{t:c}=(0,k.Bd)(),u=(0,s.useId)(),m=(0,s.useSyncExternalStore)(Z,()=>Y===u,()=>!1),[h,p]=(0,s.useState)(!1),[f,g]=(0,s.useState)(!1),[x,b]=(0,s.useState)(!1),v="Agent"===e.name||"Task"===e.name,y=(v||"subagent"===e.name)&&!!t&&!!n,w="Workflow"===e.name,C=w&&(d=e.result)?d.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,j=w&&!!C&&!!t&&!!n,N=(0,P.v2)(e.id)??e.task,S=N?.status==="running",T=!!e.isLoading||S,R="subagent"===e.name?!!e.isLoading:N?S||!!e.isLoading:!e.result,M=S?[N?.lastToolName,N?.toolUses?String(N.toolUses):null].filter(Boolean).join(" \xb7 "):"",L="Skill"===e.name,A="ApplyPatch"===e.name||v||w||L,{icon:F,displayInfo:$,displayPath:D}=er(e,t),_=(0,s.useCallback)(()=>p(!1),[]);return(0,r.jsxs)("div",{className:"border-b border-line-1 last:border-b-0",children:[(0,r.jsxs)("button",{onClick:()=>{Y=Y===u?null:u,X.forEach(e=>e())},className:"w-full px-3 py-1.5 flex items-center gap-2 text-left hover:bg-hover transition-colors",children:[(0,r.jsx)("span",{className:"text-sm",children:F}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:e.name}),D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":$||"","data-tooltip-mono":!0,children:D}),!A&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),$&&(navigator.clipboard.writeText($),(0,o.oR)(c("common.copiedPath")))},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),$&&(navigator.clipboard.writeText($),(0,o.oR)(c("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0 cursor-pointer",title:c("common.copyAbsPath"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[y&&!a&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),g(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),g(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:c("chat.subagentViewTitle"),children:c("chat.subagent")}),j&&!a&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),b(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),b(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:c("chat.workflowViewTitle"),children:c("chat.workflowRun")}),M&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate max-w-[16rem]",children:M}),m&&!a&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),p(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),p(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:c("toolCall.detailsTitle"),children:c("toolCall.details")})}),T?(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,r.jsx)("span",{className:"text-foreground-subtle text-xs",children:m?"▲":"▼"})]})]}),m&&(0,r.jsxs)("div",{className:"border-t border-line-1",children:[(0,r.jsx)("div",{className:"px-3 py-2",children:(0,r.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-60 overflow-y-auto text-foreground",children:e.result?"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2):JSON.stringify(e.input,null,2)})}),e.skillContent&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-line-1",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[c("toolCall.skillContent",{defaultValue:"Skill content"}),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-60 overflow-y-auto text-foreground whitespace-pre-wrap",children:e.skillContent})]})]}),h&&(0,r.jsx)(es,{calls:l&&l[i]===e?l:[e],initialIndex:l&&l[i]===e?i:0,cwd:t,onClose:_}),f&&t&&n&&(0,r.jsx)(E,{cwd:t,sessionId:n,toolCall:e,running:R,onClose:()=>g(!1)}),x&&t&&n&&C&&(0,r.jsx)(I,{cwd:t,sessionId:n,runId:C,isRunning:T,onClose:()=>b(!1)})]})}var ea=n(62111),el=n(56204),ei=n(33210),ed=n(58515),ec=n(36201),eu=n(55804),em=n(37618),eh=n(83897);function ep(e){let t=e.input?.questions||[],n=e.input?.answers||{},r={};if(e.result)try{let t=JSON.parse(e.result);t?.answers&&(r=t.answers)}catch{}return{questions:t,answers:{...n,...r}}}function ef(e,t){return`${e}-${t}`}function eg({toolCalls:e,onClose:t}){let{t:n}=(0,k.Bd)(),i=(0,eh.nH)(),[d,c]=(0,s.useState)({}),[u,m]=(0,s.useState)({}),[h,p]=(0,s.useState)({}),[f,g]=(0,s.useState)({});(0,s.useEffect)(()=>{let t={};e.forEach((e,n)=>{let{questions:r,answers:s}=ep(e);r.forEach((e,r)=>{let o=s[e.question];if(o){let s=ef(n,r);t[s]=o,e.options.some(e=>e.label===o)||(m(e=>({...e,[s]:!0})),p(e=>({...e,[s]:o})))}})}),queueMicrotask(()=>c(t))},[e]),(0,ea.E)(t);let x=e.reduce((e,t)=>{let{questions:n}=ep(t);return e+n.length},0),b=Object.values(f).filter(Boolean).length,v=(0,s.useCallback)((e,t)=>{c(n=>({...n,[e]:t})),m(t=>({...t,[e]:!1}))},[]),y=(0,s.useCallback)(e=>{m(t=>{let n=!t[e];if(n){let t=h[e]||"";t&&c(n=>({...n,[e]:t}))}return{...t,[e]:n}})},[h]),w=(0,s.useCallback)((e,t)=>{p(n=>({...n,[e]:t})),t&&c(n=>({...n,[e]:t}))},[]),C=(0,s.useCallback)(e=>{g(t=>({...t,[e]:!t[e]}))},[]),j=(0,s.useCallback)(()=>{let t=b>0,r=[];return e.forEach((e,s)=>{let{questions:o}=ep(e);o.forEach((e,o)=>{let a=ef(s,o);if(t&&!f[a])return;let l=d[a];r.push(`Q: ${e.question}`),r.push(`A: ${l||n("askQuestion.notSelected")}`),r.push("")})}),r.join("\n").trim()},[e,d,f,b,n]),N=(0,s.useCallback)(()=>{navigator.clipboard.writeText(j()),(0,o.oR)(b>0?n("toast.copiedQA",{count:b}):n("toast.copiedAllQA"))},[j,b,n]),S=(0,s.useCallback)(()=>{i?(i.sendMessage(j()),(0,o.oR)(n("toast.sentQA")),t()):(0,o.oR)(n("askQuestion.sendNoChat"))},[i,j,t,n]),T=(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:t,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:n("askQuestion.title")}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[n("askQuestion.nQuestions",{count:x}),b>0&&` \xb7 ${n("askQuestion.checkedN",{count:b})}`]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:S,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:b>0?n("askQuestion.sendChecked",{count:b}):n("askQuestion.sendAll"),children:(0,r.jsx)(el.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:N,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:b>0?n("askQuestion.copyChecked",{count:b}):n("askQuestion.copyAll"),children:(0,r.jsx)(l.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(ei.A,{className:"w-5 h-5"})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:e.map((t,s)=>{let{questions:o}=ep(t);return o.map((t,a)=>{let l=ef(s,a),i=d[l],c=u[l]||!1,m=f[l]||!1;return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("button",{onClick:()=>C(l),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-hover transition-colors",title:n("askQuestion.checkToCopy"),children:m?(0,r.jsx)(ed.A,{className:"w-4 h-4 text-brand"}):(0,r.jsx)(ec.A,{className:"w-4 h-4 text-muted-foreground"})}),t.header&&(0,r.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,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:t.question})]}),(0,r.jsxs)("div",{className:"space-y-1 ml-7",children:[t.options.map((e,t)=>{let n=i===e.label&&!c;return(0,r.jsxs)("button",{onClick:()=>v(l,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-hover ${n?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,r.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:n?(0,r.jsx)(eu.A,{className:"w-3.5 h-3.5 text-brand"}):(0,r.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:`text-sm ${n?"text-foreground font-medium":"text-foreground"}`,children:e.label}),e.description&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:e.description})]})]},t)}),(0,r.jsxs)("button",{onClick:()=>y(l),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-hover ${c?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,r.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:c?(0,r.jsx)(eu.A,{className:"w-3.5 h-3.5 text-brand"}):(0,r.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(em.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:n("askQuestion.custom")})]})]}),c&&(0,r.jsx)("div",{className:"ml-6 mt-1",children:(0,r.jsx)("input",{type:"text",autoFocus:!0,value:h[l]||"",onChange:e=>w(l,e.target.value),placeholder:n("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"})})]}),(s!==e.length-1||a!==o.length-1)&&(0,r.jsx)("div",{className:"border-b border-border/50 mt-3"})]},l)})})})]})});return(0,r.jsx)(a.ZL,{children:T})}var ex=n(54271),eb=n(9573),ev=n(4055),ey=n(24602),ew=n(32041);function ek({filePath:e,content:t,onClose:n,zClassName:l="z-50"}){let{t:i}=(0,k.Bd)(),[d,c]=(0,s.useState)("table");return(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:`fixed inset-0 ${l} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:n,children:(0,r.jsxs)("div",{className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":e,onClick:()=>{navigator.clipboard.writeText(e),(0,o.oR)(i("common.copiedPath"))},children:(0,r.jsx)("bdi",{dir:"ltr",children:e})}),(0,r.jsx)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5 flex-shrink-0",children:["table","raw"].map(e=>(0,r.jsx)("button",{onClick:()=>c(e),className:`px-2 py-0.5 text-xs rounded transition-colors ${d===e?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:i(`csv.${e}`)},e))}),(0,r.jsx)("button",{onClick:n,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:"table"===d?(0,r.jsx)(ew.C0,{content:t,filePath:e,className:"h-full"}):(0,r.jsx)(D.Cv,{content:t,filePath:e,showLineNumbers:!0,showSearch:!0,className:"h-full"})})]})})})}var eC=n(3939),ej=n(95045),eN=n(75346);let eS={isFramed:()=>window.parent!==window,publishOpenProject:e=>(0,ej.F)(eN.n.OpenProject,e),navigate:e=>window.location.assign(e)};function eT(e,t,n=eS){n.isFramed()?n.publishOpenProject({cwd:e.cwd,sessionId:e.sessionId,switchToAgent:!0}):n.navigate(t)}var eE=n(69924),eR=n(86359),eM=n(80905),eL=n(95686),eI=n(70188),eA=n(82680);function eP({filePath:e,content:t,onClose:n}){let{t:l}=(0,k.Bd)(),[i,d]=(0,s.useState)(null),c=(0,s.useCallback)(()=>{S.t4.runPromiseExit(C.$mh({try:()=>navigator.clipboard.writeText(e),catch:e=>new eA.uV({message:"Failed to copy text to clipboard",cause:e})})).then(e=>{let t="Success"===e._tag;(0,o.oR)(l(t?"common.copiedPath":"common.copyFailed"),t?"success":"error")})},[e,l]);return(0,s.useEffect)(()=>{let e=e=>{"Escape"!==e.key||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),n())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[n]),(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:n,children:(0,r.jsxs)("div",{ref:d,className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:c,"aria-label":l("common.copyAbsPath"),className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},title:e,children:(0,r.jsx)("bdi",{dir:"ltr",children:e})}),(0,r.jsx)("button",{onClick:n,"aria-label":l("common.close"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:(0,r.jsx)(eI.SU,{container:i,children:(0,r.jsx)(D.Cv,{content:t,filePath:e,className:"h-full"})})})]})})})}var eF=n(83448);function e$(e){let t=e.replace(/\/+$/,"");return t.startsWith("/private/")?t.slice(8):t}var eD=n(67183),e_=n(86511),eB=n(58453),eO=n(20235);async function eH(e,t){if(!navigator.clipboard?.write||"u"<typeof ClipboardItem)throw Error("Clipboard image write is unavailable");try{await navigator.clipboard.write([new ClipboardItem({[e.type]:e})]);return}catch(t){if("image/png"===e.type)throw t}let n=await new Promise((e,n)=>{let r=new Image;r.onload=()=>{let t=document.createElement("canvas");t.width=r.naturalWidth,t.height=r.naturalHeight;let s=t.getContext("2d");s?(s.drawImage(r,0,0),t.toBlob(t=>{t?e(t):n(Error("Could not encode image"))},"image/png")):n(Error("Canvas is unavailable"))},r.onerror=()=>n(Error("Could not load image")),r.src=t});await navigator.clipboard.write([new ClipboardItem({"image/png":n})])}function eV({image:e,onClose:t}){let{t:n}=(0,k.Bd)(),s=`data:${e.media_type};base64,${e.data}`,i=async t=>{t.stopPropagation();try{await eH(function(e,t){let n=atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new Blob([r],{type:t})}(e.data,e.media_type),s),(0,o.oR)(n("chat.copiedImage"),"success")}catch{(0,o.oR)(n("common.copyFailed"),"error")}},d=(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[(0,r.jsxs)("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:i,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:n("chat.copyImage"),children:(0,r.jsx)(l.A,{className:"w-5 h-5"})}),(0,r.jsx)("button",{type:"button",onClick:t,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:n("common.close"),children:(0,r.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("img",{src:s,alt:n("chat.imagePreview"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]});return(0,r.jsx)(a.ZL,{children:d})}function eU({filePath:e,cwd:t,sessionId:n,onClose:i}){let{t:d}=(0,k.Bd)(),[c,u]=(0,s.useState)("file"),[m,h]=(0,s.useState)(!1),[p,f]=(0,s.useState)(0),g=`/api/file?path=${encodeURIComponent(e)}&raw=true`,x=t&&n?`/api/session/image?${new URLSearchParams({cwd:t,sessionId:n,path:e})}`:null,b="session"===c&&x?x:g,v=async t=>{t.stopPropagation();try{let t,n=await fetch(b);if(!n.ok)throw Error("Could not read image");let r=await n.blob(),s=r.type?r:new Blob([r],{type:(t=e.slice(e.lastIndexOf(".")).toLowerCase(),".jpg"===t||".jpeg"===t?"image/jpeg":".png"===t?"image/png":".gif"===t?"image/gif":".webp"===t?"image/webp":".svg"===t?"image/svg+xml":".bmp"===t?"image/bmp":".ico"===t?"image/x-icon":".avif"===t?"image/avif":"image/png")});await eH(s,b),(0,o.oR)(d("chat.copiedImage"),"success")}catch{(0,o.oR)(d("common.copyFailed"),"error")}};return(0,r.jsx)(a.ZL,{children:(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:i,children:[(0,r.jsxs)("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:v,disabled:m,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:d("chat.copyImage"),children:(0,r.jsx)(l.A,{className:"w-5 h-5"})}),(0,r.jsx)("button",{type:"button",onClick:i,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:d("common.close"),children:(0,r.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),m?(0,r.jsxs)("div",{role:"alert",className:"flex flex-col items-center gap-3 text-white",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("p",{children:d("chat.imageLoadFailed")}),(0,r.jsx)("button",{type:"button",className:"rounded bg-white/15 px-4 py-2",onClick:()=>{u("file"),h(!1),f(e=>e+1)},children:d("common.retry")})]}):(0,r.jsx)("img",{src:b,alt:e.split("/").pop(),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation(),onError:()=>{"file"===c&&x?u("session"):h(!0)}},`${c}:${p}`)]})})}let eW=(0,s.memo)(function({text:e,isAside:t,isUser:n,isStreaming:a,onOpenFileLink:l,onPreviewFile:c,cwd:u}){let{t:m}=(0,k.Bd)(),h=(0,s.useMemo)(()=>{if(n||!l)return;let e=e=>{c?c(e):(0,o.oR)(m("toast.fileOutsideProject"),"error")};return t=>{let n=function(e,t){let n;if(!e||e.startsWith("#")||e.startsWith("//")||/^[a-z][a-z0-9+.-]*:/i.test(e)&&!e.startsWith("file:"))return null;let r=e;try{r=decodeURIComponent(e)}catch{}r.startsWith("file://")&&(r=r.slice(7));let s=r.indexOf("#"),o=s>=0?r.slice(s+1):"",a=s>=0?r.slice(0,s):r,l=a.indexOf("?"),i=l>=0?a.slice(l+1):"";a=l>=0?a.slice(0,l):a;let d=o.match(/^L?(\d+)(?:-L?\d+)?$/i)?.[1],c=i.match(/(?:^|[&;])(?:line|L)=(\d+)(?:$|[&;])/i)?.[1],u=a.match(/:(\d+)(?::\d+)?$/),m=d||c||u?.[1];if(m&&(n=Number(m),u&&(a=a.slice(0,-u[0].length))),!(a=a.trim()))return null;let h=n&&n>0?{lineNumber:n}:{},p=t?e$(t):"";if(a.startsWith("/")){let e=e$(a),t=p?(0,J.y)(p,e):null;return""===t?null:t?{rel:(0,q.WU)("",t),abs:null,...h}:{rel:(0,q.WU)("",e),abs:e,...h}}return{rel:(0,q.WU)("",a),abs:null,...h}}(t,u);return!!n&&(n.abs?u?S.t4.runPromise((0,F.r6)(u,n.rel)).then(t=>{t.ok&&t.data?.exists?l({path:n.rel,...n.lineNumber?{lineNumber:n.lineNumber}:{}}):e(n.abs)}).catch(()=>e(n.abs)):e(n.abs):l({path:n.rel,...n.lineNumber?{lineNumber:n.lineNumber}:{}}),!0)}},[u,n,l,c,m]),p=(0,s.useMemo)(()=>{if(!n)return e=>{let t=(0,eC.iy)(e,window.location.origin);return t?(eT(t,e),!0):!!h&&h(e)}},[n,h]),f=(0,s.useMemo)(()=>n?(0,e_.nl)(e):null,[n,e]),g=(0,s.useMemo)(()=>f?.link?(0,eC.iy)(f.link):null,[f]),x=f?f.body:e,b=(0,s.useMemo)(()=>n?(0,eB.n2)(x):null,[n,x]),v=(0,s.useMemo)(()=>{if(!n)return null;let e=(0,eC.ke)(x);return e.some(e=>"link"===e.kind)?e:null},[n,x]),y=f&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1 text-xs text-muted-foreground",children:[(0,r.jsx)(i.A,{className:"w-3 h-3 shrink-0","aria-hidden":!0}),(0,r.jsx)("span",{children:"sent"===f.kind?m("chat.originSent",{project:f.project??m("chat.originUnknown")}):m("chat.originDelegated",{project:f.project??m("chat.originUnknown")})}),f.link&&g&&(0,r.jsx)(eE.B,{href:f.link,target:g,onClick:e=>{e.preventDefault(),eT(g,f.link)}})]}),w=(0,r.jsxs)(r.Fragment,{children:[y,b?(0,r.jsx)(eq,{prompt:b}):v?(0,r.jsx)("div",{className:"reading-measure whitespace-pre-wrap break-words",children:v.map((e,t)=>"link"===e.kind?(0,r.jsx)(eE.B,{href:e.text,target:e.target,onClick:t=>{t.preventDefault(),eT(e.target,e.text)}},t):e.text)}):(0,r.jsx)(_.T,{content:x,isUser:n,isStreaming:a,onLinkClick:p}),a&&(0,r.jsx)("span",{className:"inline-block w-2 h-4 ml-1 bg-current animate-pulse"})]});return t?(0,r.jsxs)("div",{className:"flex gap-1.5 break-words opacity-65",children:[(0,r.jsx)(d.A,{className:"w-3 h-3 mt-[5px] shrink-0 text-muted-foreground","aria-hidden":!0}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:w})]}):(0,r.jsx)("div",{className:"break-words",children:w})}),eq=(0,s.memo)(function({prompt:e}){let{t}=(0,k.Bd)(),[n,o]=(0,s.useState)(!1),{lines:a,references:l,notes:i}=e;return(0,r.jsxs)("div",{className:"reading-measure break-words",children:[(0,r.jsx)("div",{className:"whitespace-pre-wrap",children:a.map((e,t)=>(0,r.jsxs)("div",{children:[e.command&&(0,r.jsx)("span",{className:eO._9,children:e.command}),e.text||(e.command?null:"\xa0")]},t))}),l.length>0&&(0,r.jsxs)("div",{className:"mt-1.5 text-xs text-muted-foreground",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),className:"inline-flex items-center gap-1 hover:text-foreground",children:[n?(0,r.jsx)(c.A,{className:"w-3 h-3"}):(0,r.jsx)(u.A,{className:"w-3 h-3"}),t("chat.commandRefs",{count:l.length})]}),n&&(0,r.jsx)("ul",{className:"mt-1 space-y-0.5 pl-4",children:l.map((e,n)=>(0,r.jsxs)("li",{className:"truncate","data-tooltip":e.detail||void 0,"data-tooltip-mono":!0,children:[(0,r.jsx)("span",{className:"mr-1.5",children:t(`chat.commandRef_${e.kind}`)}),(0,r.jsx)("span",{className:"text-foreground",children:e.name}),e.detail&&(0,r.jsx)("span",{className:"ml-1.5 font-mono",children:e.detail})]},n))})]}),i.length>0&&(0,r.jsx)("div",{className:"mt-1.5 rounded border border-amber-9/30 bg-amber-9/10 px-2 py-1 text-xs text-amber-11",children:i.map((e,t)=>(0,r.jsx)("div",{children:e},t))})]})}),ez="28em",eK=(0,s.memo)(function({children:e}){let{t}=(0,k.Bd)(),[n,o]=(0,s.useState)(!1),[a,l]=(0,s.useState)(!1),i=(0,s.useRef)(null),d=(0,s.useRef)(null),m=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(n)return;let e=d.current,t=m.current;if(!e||!t)return;let r=()=>l(e.scrollHeight>e.clientHeight+1);r();let s=new ResizeObserver(r);return s.observe(t),()=>s.disconnect()},[n]);let h=(0,s.useCallback)(()=>{if(!n)return void o(!0);let e=i.current?.closest("[data-message-id]")??i.current;o(!1),requestAnimationFrame(()=>{e&&e.getBoundingClientRect().top<0&&e.scrollIntoView({block:"start",behavior:"auto"})})},[n]);return(0,r.jsxs)("div",{ref:i,children:[(0,r.jsx)("div",{ref:d,className:n?void 0:"overflow-hidden",style:n?void 0:{maxHeight:ez},children:(0,r.jsx)("div",{ref:m,children:e})}),a&&(0,r.jsxs)(r.Fragment,{children:[!n&&(0,r.jsx)("div",{className:"text-muted-foreground leading-none pt-1 select-none",children:"…"}),(0,r.jsxs)("button",{type:"button",onClick:h,className:"mt-1 flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[t(n?"chat.showLess":"chat.showMore"),n?(0,r.jsx)(c.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(u.A,{className:"w-3.5 h-3.5"})]})]})]})});function eG({collapsible:e,children:t}){return e?(0,r.jsx)(eK,{children:t}):(0,r.jsx)(r.Fragment,{children:t})}let eQ=new Map,eJ=(0,s.memo)(function({message:e,cwd:t,sessionId:n,snapshotsEnabled:l=!0,onFork:i,onDeleteTurn:d,forkSupported:c=!0,onSendToPeer:T,peerSide:E,onApprovePlan:R,isLoading:M,onContentSearch:L,onShowFileDiff:I,onOpenFileLink:A,disableOverlays:P=!1}){let F,$,D,B,{t:O,i18n:H}=(0,k.Bd)(),[V,U]=(0,s.useState)(null),[W,z]=(0,s.useState)(()=>1===(e.toolCalls?.length||0)),[K,G]=(0,s.useState)(!1),[Q,J]=(0,s.useState)(!1),[Y,X]=(0,s.useState)(!1),[Z,ee]=(0,s.useState)(!1),[et,en]=(0,s.useState)(!1),er=(0,s.useRef)(null),es=(0,s.useRef)(null),ea="user"===e.role,el=e.images&&e.images.length>0,ei=e.toolCalls?.length||0,ed=!!n&&!!t&&!!i&&c,ec=!!n&&!!t&&!!d;(0,s.useEffect)(()=>{if(!Z)return;let e=e=>{er.current?.contains(e.target)||ee(!1)},t=e=>{"Escape"===e.key&&(ee(!1),es.current?.focus())};return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[Z]);let eu=(0,s.useMemo)(()=>e.toolCalls?.some(e=>(0,ev.h)(e.name))||!1,[e.toolCalls]),em=(0,s.useMemo)(()=>ea&&e.content?(0,eD.M)(e.content):null,[ea,e.content]),eh=(0,s.useMemo)(()=>{let t=e.parts,n=em?em.body:e.content;if(!t?.length)return n?[{text:n,isAside:!1}]:[];let r=-1;t.forEach((e,t)=>{"tool"===e.type&&(r=t)});let s=[];return t.forEach((e,t)=>{"text"===e.type&&s.push({text:e.text,isAside:t<r})}),s},[e.parts,e.content,em]),ep=(0,s.useMemo)(()=>(0,ex.vP)([],e.toolCalls??[],t).length>0,[e.toolCalls,t]),ef=function(e,t,n,r){let[o,a]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{if(!r||o||!e)return;let s=(n??[]).map(e=>e.id).filter(Boolean);if(!s.length)return;let l=n?.some(e=>(0,ev.h)(e.name))??!1,i=S.t4.runFork((0,eb.xK)(e,s,t??void 0).pipe(C.h9N(e=>C.FFw("Cannot check message snapshots",e).pipe(C.as([]))),C.Mim(e=>C.OH5(()=>{e.length>0&&a(!0)})),C.uxO({while:e=>0===e.length&&l,times:2,schedule:j.ji("2 seconds")})));return()=>{S.t4.runFork(N.G(i))}},[r,o,e,t,n]),o}(t,n,e.toolCalls,l&&eu&&!ep);(0,s.useEffect)(()=>{I&&e.toolCalls?.length&&I(e.id,e.toolCalls,t,n??void 0,!0)},[I,e.id,e.toolCalls,t,n]);let ew=(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]),eC=(0,s.useMemo)(()=>e.toolCalls?e.toolCalls.filter(e=>"AskUserQuestion"===e.name):[],[e.toolCalls]),ej=(0,s.useMemo)(()=>{if(!e.toolCalls)return null;for(let t=e.toolCalls.length-1;t>=0;t--)if("ExitPlanMode"===e.toolCalls[t].name){let n=e.toolCalls[t].input?.plan;return"string"==typeof n&&n?n:null}return null},[e.toolCalls]),eN=(0,s.useMemo)(()=>e.toolCalls?.filter(e=>"ExitPlanMode"!==e.name)??[],[e.toolCalls]),eS=(0,s.useMemo)(()=>{if(!e.toolCalls)return[];let t=new Set,n=[];for(let r of e.toolCalls)if("Read"===r.name||"Edit"===r.name||"Write"===r.name){let e=r.input.file_path;e&&!t.has(e)&&(t.add(e),n.push(e))}return n},[e.toolCalls]),eT=(0,s.useMemo)(()=>{if(!e.toolCalls)return[];let t=[];for(let n of e.toolCalls){let e=n.input?.thought;if(e&&"string"==typeof e){let r=e.match(/PREVIOUS:\s*(.*?)\s*→\s*THIS:\s*(.*?)\s*→\s*EXPECT:\s*(.*)/i);r?t.push({previous:r[1].trim(),current:r[2].trim(),expect:r[3].trim(),raw:e,toolName:n.name}):t.push({previous:"",current:e,expect:"",raw:e,toolName:n.name})}}return t},[e.toolCalls]),[eE,eI]=(0,s.useState)(null),eA=eE?.path??null,e$=eE?function({path:e,source:t}){return(0,q.u)(e)?"image":(0,q.aR)(e)&&"tool"===t?"html":(0,q.Zy)(e)?"csv":(0,q.e$)(e)?"markdown":"text"}(eE):null,[e_,eO]=(0,s.useState)(null),eH=e_?.path===eA?e_.content:null,eq=(0,s.useCallback)(e=>{eI({path:e,source:"link"})},[]),ez=(0,s.useCallback)(()=>eI(null),[]);(0,s.useEffect)(()=>{if(!eA||(0,q.u)(eA))return void queueMicrotask(()=>eO(null));let e=!1;return S.t4.runPromiseExit((0,eF.an)(eA)).then(t=>{if(!e)if("Success"===t._tag&&void 0!==t.value.content)eO({path:eA,content:t.value.content});else{let e="Failure"===t._tag?eR.od(t.cause):eM.dv(),n=eM.Ru(e)?e.value.message:"";(0,o.oR)(n?`${O("toast.readFileFailed")}: ${n}`:O("toast.readFileFailed"),"error"),eI(null)}}),()=>{e=!0}},[eA,O]);let eK=async()=>{if(ec&&!M&&!et&&await (0,o.lJ)((e.turnUserCount??0)>1?O("chat.deleteTaskConfirm",{count:e.turnUserCount}):O("chat.deleteTurnConfirm",{defaultValue:"Delete this question, answer, and its tool records? This cannot be undone."}),{title:O("chat.deleteTurn",{defaultValue:"Delete turn"}),confirmText:O("chat.deleteTurnConfirmAction",{defaultValue:"Delete turn"}),danger:!0})){en(!0);try{await d(e.id)}finally{en(!1)}}},eJ=!!E&&!!T&&!!e.content,eY=(0,s.useMemo)(()=>{var t;let n;if(!e.timestamp)return"";let r=new Date(e.timestamp);return isNaN(r.getTime())?"":(t=H.language,!(n=eQ.get(t))&&(n=new Intl.DateTimeFormat(t,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),eQ.set(t,n)),n).format(r)},[e.timestamp,H.language]);if("system"===e.role){let t=e.systemEvent,n=t?.kind==="task-notification"?"failed"===t.status?"⚠️":"stopped"===t.status?"⏹️":"\uD83D\uDD14":"ℹ️",s=t?.detail||e.content;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex justify-center my-2 px-2","data-role":"system",children:(0,r.jsxs)("button",{type:"button",onClick:()=>X(!0),className:"flex items-center gap-1.5 max-w-[85%] text-[11px] text-muted-foreground bg-secondary/40 border border-border/50 rounded-full px-3 py-1 hover:bg-secondary hover:text-foreground transition-colors cursor-pointer",title:O("chat.viewDetails",{defaultValue:"Click for details"}),children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:n}),(0,r.jsx)("span",{className:"truncate",children:e.content})]})}),Y&&(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:()=>X(!1),children:(0,r.jsxs)("div",{className:"bg-card shadow-lv3 w-full max-w-4xl max-h-[80vh] rounded-lg flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("span",{className:"text-sm text-foreground flex items-center gap-1.5",children:[(0,r.jsx)("span",{children:n}),t?.kind==="task-notification"?O("chat.taskNotification",{defaultValue:"Task notification"}):O("chat.systemNotice",{defaultValue:"Notice"})]}),(0,r.jsx)("button",{onClick:()=>X(!1),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors",children:"✕"})]}),(0,r.jsx)("pre",{className:"flex-1 overflow-auto px-4 py-3 text-xs text-foreground whitespace-pre-wrap break-words",children:s})]})})})]})}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:`flex flex-col ${ea?"items-end":"items-start"} mb-4 group`,"data-role":e.role,children:[(0,r.jsx)("div",{className:`relative flex items-start ${ea?"justify-end":"justify-start"} w-full`,children:(0,r.jsxs)("div",{className:`chat-turn px-4 py-2 text-foreground ${ea?"max-w-[80%] bg-muted rounded-2xl rounded-br-md border border-brand/40":"w-full"}`,children:[el&&(0,r.jsx)("div",{className:`flex flex-wrap gap-2 ${e.content?"mb-2":""}`,children:e.images.map((e,t)=>(0,r.jsx)("div",{className:`relative w-16 h-16 rounded-lg overflow-hidden border border-white/20 ${P?"":"cursor-pointer hover:opacity-90 transition-opacity"}`,onClick:P?void 0:()=>U(e),children:(0,r.jsx)("img",{src:`data:${e.media_type};base64,${e.data}`,alt:O("chat.imageN",{index:t+1}),className:"w-full h-full object-cover"})},t))}),em&&em.items.length>0&&(0,r.jsxs)("details",{className:"mb-2 text-xs text-muted-foreground","data-testid":"decision-context",children:[(0,r.jsx)("summary",{className:"cursor-pointer select-none",children:O("chat.decisionContextAttached",{defaultValue:"{{count}} related decisions attached",count:em.items.length})}),(0,r.jsx)("ul",{className:"mt-1 list-disc space-y-0.5 pl-4",children:em.items.map(e=>(0,r.jsx)("li",{children:e.text},e.key))})]}),eh.length>0&&(0,r.jsx)(eG,{collapsible:ea,children:(0,r.jsx)("div",{className:"space-y-3",children:eh.map((n,s)=>(0,r.jsx)(eW,{text:n.text,isAside:n.isAside,isUser:ea,isStreaming:!!e.isStreaming&&s===eh.length-1,onOpenFileLink:A,onPreviewFile:eq,cwd:t},s))})}),ew&&(D=($=Array.isArray(F=ew.input?.todos)?F:[]).filter(e=>"completed"===e.status).length,B=$.length,(0,r.jsx)("div",{className:`${e.content||el?"mt-2":""}`,children:(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden px-3 py-2 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,r.jsx)("div",{className:"flex-1 h-1 bg-secondary rounded-full overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-green-500 rounded-full transition-all duration-300",style:{width:`${B>0?D/B*100:0}%`}})}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[D,"/",B]})]}),$.map((e,t)=>(0,r.jsxs)("div",{className:`flex items-center gap-1.5 ${"completed"===e.status?"opacity-50":""}`,children:["completed"===e.status?(0,r.jsx)(m.A,{className:"w-3 h-3 text-green-11 flex-shrink-0"}):"in_progress"===e.status?(0,r.jsx)(h.A,{className:"w-3 h-3 text-brand flex-shrink-0 animate-spin"}):(0,r.jsx)(p.A,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),(0,r.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))]})})),ej&&(0,r.jsx)("div",{className:`${e.content||el||ew?"mt-2":""}`,children:(0,r.jsxs)("div",{className:"border border-brand/40 rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-border bg-brand/10",children:[(0,r.jsx)("span",{className:"text-sm",children:"\uD83D\uDCCB"}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:O("chat.planTitle",{defaultValue:"Plan (awaiting your review)"})})]}),(0,r.jsx)("div",{className:"px-3 py-2",children:(0,r.jsx)(_.T,{content:ej,isUser:!1})}),R&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:O("chat.planApproveHint",{defaultValue:"本环境无审批弹窗,点此退出 Plan 并执行"})}),(0,r.jsxs)("button",{onClick:()=>R(),disabled:M,className:"flex items-center gap-1.5 px-3 py-1 rounded-md bg-brand text-white text-xs font-medium hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex-shrink-0",children:[(0,r.jsx)("span",{children:"✓"}),(0,r.jsx)("span",{children:O("chat.approvePlan",{defaultValue:"批准并执行"})})]})]})]})}),eS.length>0&&(0,r.jsx)("div",{className:`${e.content||el||ew?"mt-2":""}`,children:(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden px-3 py-2 space-y-0.5",children:eS.map(e=>(0,r.jsxs)("button",{disabled:P,onClick:()=>eI({path:e,source:"tool"}),className:"flex items-center gap-1.5 w-full text-left rounded px-1 py-0.5 group/md transition-colors enabled:hover:bg-hover disabled:cursor-default",children:[(0,q.u)(e)?(0,r.jsxs)("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,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v14a1 1 0 01-1 1H5a1 1 0 01-1-1V5z"}),(0,r.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4-4 3 3 4-4 5 5"})]}):(0,q.Zy)(e)?(0,r.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,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm0 4h16M10 10v10"})}):(0,q.aR)(e)?(0,r.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,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}):(0,r.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,r.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,r.jsx)("span",{className:"text-xs text-muted-foreground group-hover/md:text-foreground truncate",children:e.split("/").pop()})]},e))})}),eT.length>0&&(0,r.jsx)("div",{className:`${e.content||el||ew||eS.length>0?"mt-2":""}`,children:(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,r.jsxs)("table",{className:"w-full text-xs",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border text-muted-foreground",children:[(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium w-[60px]",children:"Tool"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Previous"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Action"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Expect"})]})}),(0,r.jsx)("tbody",{children:eT.map((e,t)=>(0,r.jsxs)("tr",{className:t<eT.length-1?"border-b border-border/50":"",children:[(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground font-mono",children:e.toolName}),(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:e.previous||"—"}),(0,r.jsx)("td",{className:"px-2 py-1 text-foreground",children:e.current}),(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:e.expect||"—"})]},t))})]})})}),eN.length>0&&(0,r.jsx)("div",{className:`${e.content||el?"mt-3":""}`,children:ei>0?(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsxs)("button",{onClick:()=>z(!W),className:"flex-1 px-3 py-1.5 flex items-center gap-2 text-left hover:bg-hover transition-colors active:bg-muted",children:[(0,r.jsx)("span",{className:"text-sm",children:"\uD83D\uDD27"}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:O("chat.toolCalls",{count:eN.length})}),(0,r.jsx)("span",{className:"ml-auto text-muted-foreground text-sm",children:W?O("chat.collapse"):O("chat.expand")})]}),!P&&eC.length>0&&(0,r.jsx)("button",{onClick:()=>J(!0),className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover transition-colors border-l border-line-1",title:O("chat.viewQuestions"),children:(0,r.jsx)(f.A,{className:"w-4 h-4"})}),!P&&(ep||ef)&&(0,r.jsx)("button",{onClick:()=>{I&&e.toolCalls?I(e.id,e.toolCalls,t,n??void 0):G(!0)},className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover transition-colors border-l border-line-1",title:O("chat.viewAllFileChanges"),children:(0,r.jsx)(g.A,{className:"w-4 h-4"})})]}),W&&(0,r.jsx)("div",{className:"border-t border-line-1",children:eN.map((e,s)=>(0,r.jsx)(eo,{toolCall:e,cwd:t,sessionId:n,disableOverlays:P,siblings:eN,index:s},`${e.id}-${s}`))})]}):eN.map((e,s)=>(0,r.jsx)(eo,{toolCall:e,cwd:t,sessionId:n,disableOverlays:P,siblings:eN,index:s},`${e.id}-${s}`))})]})}),(eY||e.content||ed||ec)&&(0,r.jsxs)("div",{className:`flex items-center gap-1 mt-0.5 px-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity ${ea?"flex-row-reverse":""}`,children:[e.content&&(0,r.jsx)("button",{onClick:()=>{if(e.content){let t=em?em.body:e.content;navigator.clipboard.writeText(ea?(0,eB.Wn)(t):t),(0,o.oR)(O("toast.copiedMessage"))}},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:O("chat.copyMessage"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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"})})}),ed&&(0,r.jsxs)("div",{ref:er,className:"relative",children:[(0,r.jsxs)("button",{ref:es,type:"button",onClick:()=>ee(e=>!e),className:"flex items-center gap-1 rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-hover hover:text-foreground","aria-expanded":Z,title:O("chat.newSession"),children:[(0,r.jsx)(x.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:O("chat.newSession")}),(0,r.jsx)(u.A,{className:`h-3 w-3 transition-transform ${Z?"rotate-180":""}`})]}),Z&&(0,r.jsxs)("div",{role:"group","aria-label":O("chat.newSession"),className:`absolute bottom-full z-50 mb-1 w-56 overflow-hidden rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-lv2 ${ea?"right-0":"left-0"}`,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{ed&&(ee(!1),i(e.id,"prefix"))},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-hover focus-visible:bg-hover focus-visible:outline-none",children:[(0,r.jsx)(x.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block text-xs font-medium",children:O("chat.continueFromHere")}),(0,r.jsx)("span",{className:"mt-0.5 block text-[11px] leading-4 text-muted-foreground",children:O("chat.continueFromHereDesc")})]})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{ed&&(ee(!1),i(e.id,"single"))},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-hover focus-visible:bg-hover focus-visible:outline-none",children:[(0,r.jsx)(b.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block text-xs font-medium",children:O("chat.onlyThisTurn")}),(0,r.jsx)("span",{className:"mt-0.5 block text-[11px] leading-4 text-muted-foreground",children:(e.turnUserCount??0)>1?O("chat.onlyThisTaskDesc",{count:e.turnUserCount}):O("chat.onlyThisTurnDesc")})]})]})]})]}),ec&&(0,r.jsxs)("button",{type:"button",onClick:eK,disabled:M||et,className:"flex items-center gap-1 rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-red-3 hover:text-red-11 disabled:cursor-not-allowed disabled:opacity-40",title:M?O("chat.deleteTurnWhileRunning"):O("chat.deleteTurn"),children:[(0,r.jsx)(v.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:et?O("chat.deletingTurn"):O("chat.deleteTurn")})]}),eJ&&(0,r.jsx)("button",{onClick:()=>{eJ&&T(e.content)},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:O("chat.sendToPeerPane"),children:"right"===E?(0,r.jsx)(y.A,{className:"w-4 h-4"}):(0,r.jsx)(w.A,{className:"w-4 h-4"})}),eY&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground mx-1",children:eY})]})]}),V&&(0,r.jsx)(eV,{image:V,onClose:()=>U(null)}),K&&e.toolCalls&&(0,r.jsx)(ex.zB,{toolCalls:e.toolCalls,cwd:t,sessionId:n??void 0,onClose:()=>G(!1),onContentSearch:L}),Q&&eC.length>0&&(0,r.jsx)(eg,{toolCalls:eC,onClose:()=>J(!1)}),eA&&"image"===e$&&(0,r.jsx)(eU,{filePath:eA,cwd:t,sessionId:n,onClose:ez},`${t}:${n}:${eA}`),eA&&"image"!==e$&&null!==eH&&("html"===e$?(0,r.jsx)(ey.N,{filePath:eA,content:eH,cwd:t,onClose:ez,onContentSearch:L}):"csv"===e$?(0,r.jsx)(ek,{filePath:eA,content:eH,onClose:ez}):"markdown"===e$?(0,r.jsx)(eL.x,{filePath:eA,content:eH,cwd:t||"",onClose:ez}):(0,r.jsx)(eP,{filePath:eA,content:eH,onClose:ez}))]})})},33442:(e,t,n)=>{n.d(t,{_:()=>s,a:()=>o});let r=(0,n(93964).N)("cockpit-bots",["/api/bots","/api/session-bots"]),s=r.notify,o=r.subscribe},34075:(e,t,n)=>{n.d(t,{dj:()=>l,lJ:()=>u,oR:()=>h,tE:()=>i});var r=n(95155),s=n(12115),o=n(69809);let a=(0,s.createContext)(null);function l(){let e=(0,s.useContext)(a);if(!e)throw Error("useToast must be used within a ToastProvider");return e}function i({children:e}){let[t,n]=(0,s.useState)([]),o=(0,s.useCallback)((e,t="success")=>{let r=`toast-${Date.now()}`;n(n=>[...n,{id:r,message:e,type:t}])},[]),l=(0,s.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return(0,r.jsxs)(a.Provider,{value:{showToast:o},children:[e,(0,r.jsx)(d,{toasts:t,onRemove:l})]})}function d({toasts:e,onRemove:t}){return(0,r.jsx)("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-[100] flex flex-col items-center gap-2 max-w-[26rem]",children:e.map(e=>(0,r.jsx)(c,{toast:e,onRemove:t},e.id))})}function c({toast:e,onRemove:t}){(0,s.useEffect)(()=>{let n=setTimeout(()=>{t(e.id)},3e3);return()=>clearTimeout(n)},[e.id,t]);let n={success:"bg-green-9",error:"bg-red-9",info:"bg-brand"}[e.type],o={success:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),error:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),info:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}[e.type];return(0,r.jsxs)("div",{className:`${n} text-white px-4 py-3 rounded-lg shadow-lv2 flex items-center gap-3 min-w-[200px] animate-slide-in`,style:{animation:"slideIn 0.3s ease-out"},children:[o,(0,r.jsx)("span",{className:"text-sm",children:e.message}),(0,r.jsx)("button",{onClick:()=>t(e.id),className:"ml-auto p-1 hover:bg-white/20 rounded transition-colors",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}function u(e,t){let{title:n=o.A.t("confirm.title",{defaultValue:"Confirm"}),confirmText:r=o.A.t("confirm.ok",{defaultValue:"OK"}),cancelText:s=o.A.t("confirm.cancel",{defaultValue:"Cancel"}),danger:a=!1}=t||{};return new Promise(t=>{let o=document.createElement("div");o.className="fixed inset-0 z-[200] flex items-center justify-center",o.style.animation="confirmFadeIn 0.15s ease-out";let l=e=>{o.style.animation="confirmFadeOut 0.12s ease-in",o.addEventListener("animationend",()=>{document.body.removeChild(o),t(e)},{once:!0})};o.addEventListener("mousedown",e=>{e.target===o&&l(!1)});let i=e=>{"Escape"===e.key?(e.stopPropagation(),document.removeEventListener("keydown",i,!0),l(!1)):"Enter"===e.key&&(e.stopPropagation(),document.removeEventListener("keydown",i,!0),l(!0))};document.addEventListener("keydown",i,!0),o.innerHTML=`
|
|
11
|
+
`:"")+"</task-notification>",o=`auto-tasknotif-${r||++eI.current}`;e_(e=>[...e,{id:o,role:"system",content:n,systemEvent:{kind:"task-notification",...t?{status:t}:{},detail:s},liveRunId:eF.current??void 0,turnId:"codex"===C?`live-task-${eF.current}`:void 0,runKey:eb.current?.runKey}])}return}if("system"===n&&"notice"===e.subtype){let t=(0,m.C)(e,`auto-notice-${++eI.current}`);t&&e_(e=>[...e,{...t,liveRunId:eF.current??void 0,turnId:"codex"===C?`live-task-${eF.current}`:void 0,runKey:eb.current?.runKey}]);return}if("system"===n&&"api_retry"===e.subtype)return void ec({attempt:e.attempt??0,maxRetries:e.max_retries??0,delayMs:e.retry_delay_ms??0,errorStatus:e.error_status,error:e.error});if("rate_limit_event"===n){let t=e.rate_limit_info;t&&ei({status:t.status||"allowed",resetsAt:t.resetsAt,rateLimitType:t.rateLimitType,utilization:t.utilization,overageStatus:t.overageStatus,overageDisabledReason:t.overageDisabledReason,isUsingOverage:t.isUsingOverage,surpassedThreshold:t.surpassedThreshold});return}if("usage_update"===n){let t=e.output_tokens;if("number"==typeof t&&Number.isFinite(t)){ey.current=!0;let e=Math.max(0,Math.round(t));es(t=>({outputTokens:Math.max(t?.outputTokens||0,e)}))}return}if("error"===n){let n=e.error||p.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});ec(null),eT.current&&(clearTimeout(eT.current),eT.current=null),eO(),e_({event:{...e,type:"error",error:n},engine:C,assistantId:t});return}if("stream_event"===n){ec(e=>e?null:e);let n=e.event;if(e$.current&&n?.type==="message_start"){e$.current=!1,eT.current&&(clearTimeout(eT.current),eT.current=null),eO();let e=t,n=`auto-asst-${eF.current}-${++eI.current}`;eE.current=n,t=n,e_(t=>[...t.map(t=>t.id===e?{...t,isStreaming:!1}:t),{id:n,role:"assistant",content:"",toolCalls:[],isStreaming:!0,liveRunId:eF.current??void 0,turnId:"codex"===C?`live-task-${eF.current}`:void 0,runKey:eb.current?.runKey}])}if(n?.type==="content_block_delta"&&n.delta?.type==="text_delta"){let e=n.delta.text||"";r(e),eS.current&&eS.current.messageId===t?eS.current.text+=e:eS.current={messageId:t,text:e},eT.current||(eT.current=setTimeout(eO,50))}return}if("assistant"===n){ec(e=>e?null:e);let n=e.message?.usage;n&&(eL.current=n);let s=e.message?.content;if(Array.isArray(s))for(let e of s)e.text?r(e.text):e.name&&r(`${e.name} ${JSON.stringify(e.input??{})}`);e_({event:e,engine:C,assistantId:t})}if("tool_progress"===n)return void e_({event:e,engine:C,assistantId:t});if("user"===n){let n=e.message?.content;if(Array.isArray(n))for(let e of n)r("string"==typeof e.content?e.content:JSON.stringify(e.content??""));e_({event:e,engine:C,assistantId:t})}if("prompt_suggestion"===n){let t="string"==typeof e.suggestion?e.suggestion.trim():"",n=eN.current;ep(t&&n?{sessionId:n,text:t}:null)}if("result"===n){eM.current=!1,eR.current=!0,ec(null),eT.current&&(clearTimeout(eT.current),eT.current=null),eO();let n=eN.current;n&&k&&e_(e=>(2===e.length&&_(n),e));let r=eL.current??e.usage;eL.current=null;let s=e.total_cost_usd;r&&en({inputTokens:r.input_tokens||0,outputTokens:r.output_tokens||0,cacheCreationInputTokens:r.cache_creation_input_tokens||0,cacheReadInputTokens:r.cache_read_input_tokens||0,totalCostUsd:s||0}),e_({event:e,engine:C,assistantId:t})}}},[e_,eO,D,_,k,C]);(0,g.h)({url:eg?`/ws/session-stream?sessionId=${encodeURIComponent(eg.runKey)}&subscriber=${encodeURIComponent(z)}`:"/ws/session-stream",enabled:!!eg,onMessage:e=>{eC.current=!0,ej.current&&(clearTimeout(ej.current),ej.current=null);let t=eb.current;if(!t)return;for(let t of e.recoveries??[])t.runId&&t.runId!==eF.current&&Z(t);let n=e.recoveries?.find(e=>e.runId===eF.current)??e;if("run-snapshot"===n.type&&Array.isArray(n.events)){if(n.runId&&n.runId!==eF.current)return void eB();"number"==typeof n.startedAt&&eF.current&&H?.({id:eF.current,startedAt:n.startedAt,recovery:n.recovery}),eT.current&&(clearTimeout(eT.current),eT.current=null),eS.current=null,eE.current=t.assistantId,eD.current=!1,eR.current=!1,eM.current=!1,e$.current=!1,ey.current=!1,es(null);let e="number"==typeof n.outputTokens&&Number.isFinite(n.outputTokens)?Math.max(0,Math.round(n.outputTokens)):null;null!==e&&(ey.current=!0,es({outputTokens:e}));let r="number"==typeof n.startedAt?new Date(n.startedAt).toISOString():void 0;for(let e of(e_(eP.current.map(e=>({...e,turnStartedAt:r??e.turnStartedAt}))),n.events))eV(e,eE.current??t.assistantId);for(let e of(n.status&&"running"!==n.status&&eB(!0===n.writerActive,"error"===n.status),n.recoveryDeletions??[]))W?.(e)}else if("run-event"===n.type&&n.message){if("recovery-deleted"===n.message.type)return void W?.(n.message.deletion);if("run-ended"===n.message.type||"run-settled"===n.message.type){if("string"==typeof n.message.runId&&n.message.runId!==eF.current)return;eB("run-ended"===n.message.type&&!0===n.message.writerActive,"error"===n.message.status);return}if(ev.current){(0,r.X)(n.message)&&eV(n.message,eE.current??t.assistantId);return}eV(n.message,eE.current??t.assistantId)}else if("run-idle"===n.type)for(let e of(eB(),n.recoveryDeletions??[]))W?.(e)}});let eU=(0,s.useRef)(X);eU.current=X;let eW=(0,s.useCallback)(e=>{if("prompt-suggestion"!==e.type||eU.current)return;let t=eN.current,n="string"==typeof e.data?.suggestion?e.data.suggestion.trim():"";t&&e.data?.sessionId===t&&n&&ep({sessionId:t,text:n})},[]),[eq]=(0,s.useState)(x.I7);(0,g.h)({url:eq,enabled:"codex"===C,onMessage:eW});let ez=(0,s.useCallback)(async(e,t,n)=>{let r=n&&"permissionMode"in n?"plan"===n.permissionMode:j,s=t?.map(e=>({type:"base64",media_type:e.media_type,data:e.data}));if(ev.current&&eb.current&&eF.current){let e={id:eF.current,runKey:eb.current.runKey};J(t=>[...t.filter(t=>t.id!==e.id),e])}eb.current=null,ex(null),ev.current=!1;let o=v();eF.current=o,O?.({id:o,startedAt:Date.now()});let a={id:`user-${o}`,liveInputId:o,liveRunId:o,turnId:"codex"===C?`live-task-${o}`:void 0,role:"user",content:e,images:s};e_(e=>[...e,a]),ep(null),ee(!0),es(null),ey.current=!1,ea(Date.now()),ec(null),em(b);let i=`assistant-${o}`,d={id:i,liveRunId:o,turnId:"codex"===C?`live-task-${o}`:void 0,role:"assistant",content:"",toolCalls:[],isStreaming:!0};eP.current=[a,d],e_(e=>[...e,d]),eD.current=!1,eE.current=i,eR.current=!1,eM.current=!1,e$.current=!1;let c=!C||"claude"===C,u="deepseek"===C||"kimi"===C||"glm"===C,m="ollama"===C||u||c||"codex"===C||"grok"===C;try{let t=C&&"claude"!==C?`/api/chat/${C}`:"/api/chat",n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,sessionId:eN.current,runId:o,images:s,cwd:k,language:p.A.language,..."ollama"===C&&S&&{model:S},...u&&T&&{model:T},...(u||"ollama"===C)&&void 0!==E&&{piThinkingLevel:E},...c&&R&&{model:R},...c&&M&&{claudeEffort:M},...c&&void 0!==L&&{claudeFastMode:L},...c&&void 0!==I&&{claudeThinking:I},..."codex"===C&&A&&{model:A},..."codex"===C&&F&&{codexReasoningEffort:F},..."codex"===C&&{promptSuggestions:!0},..."grok"===C&&{model:P&&"grok-build"!==P?P:l.yR},..."grok"===C&&{grokReasoningEffort:$||l.ZL},...r&&c&&{permissionMode:"plan"},...m&&N&&{noHistory:!0}})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||p.A.t("chat.requestFailed",{defaultValue:"Request failed"}))}let a=await n.json().catch(()=>({}));if(H?.({id:o,startedAt:a.startedAt??Date.now()}),"number"==typeof a.startedAt){let e=new Date(a.startedAt).toISOString();e_(t=>t.map(t=>t.liveRunId===o?{...t,turnStartedAt:e}:t))}ex({runKey:a.runKey||o,assistantId:i}),eC.current=!1,ej.current&&clearTimeout(ej.current),ej.current=setTimeout(()=>{eb.current&&!eC.current&&e_(e=>e.map(e=>e.id!==i||e.content?e:{...e,content:p.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."})}))},15e3)}catch(t){console.error("Chat error:",t);let e=t instanceof Error?t.message:p.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});e_(t=>t.map(t=>t.id===i?{...t,content:e,streamError:e,isStreaming:!1}:t)),V?.(o),ee(!1),ex(null)}},[k,C,j,N,S,T,E,R,M,L,I,A,F,P,$,e_,eB,O,H,V]),eK=(0,s.useCallback)(async(e,t,n)=>{ep(null);let r=v(),s=Date.now(),d=t?.map(e=>({type:"base64",media_type:e.media_type,data:e.data})),c="ollama"===C||"deepseek"===C||"kimi"===C||"glm"===C;await a.t4.runPromise((0,i.VA)(C,{prompt:e,sessionId:n,runId:r,images:d,cwd:k,language:p.A.language,inject:!0,...c?{model:"ollama"===C?S:T,piThinkingLevel:E,noHistory:N}:{},..."codex"===C?{model:A,codexReasoningEffort:F,noHistory:N}:{},..."grok"===C?{model:P&&"grok-build"!==P?P:l.yR,grokReasoningEffort:$||l.ZL,noHistory:N}:{}}).pipe(o.sFT(t=>o.OH5(()=>{U?.(n,{id:r,startedAt:s,messages:[{id:`user-${r}`,role:"user",content:e,images:d},{id:`error-${r}`,role:"assistant",content:t.message,streamError:t.message}]})}))))},[k,C,S,T,E,A,F,P,$,N,U]);return{drainingSubscriptions:Q.map(e=>(0,s.createElement)(y,{key:e.id,run:e,update:t,engine:C,onAccepted:H,onEnd:B,onDeleted:W,onSettled:Y})),isLoading:X,tokenUsage:et,liveOutputTokens:er,runningStartedAt:eo,rateLimitInfo:el,apiRetryInfo:ed,backgroundTasks:eu,promptSuggestion:eh&&eh.sessionId===n?eh.text:null,handleSend:ez,handleStop:eH,injectMessage:eK,abortControllerRef:ef}}},22576:(e,t,n)=>{function r(e,t){let n=e.split("\n"),r=t.split("\n"),a=n.length,l=r.length,i=0;for(;i<a&&i<l&&n[i]===r[i];)i++;let d=a,c=l;for(;d>i&&c>i&&n[d-1]===r[c-1];)d--,c--;let u=[],m=(e,t)=>u.push({type:"unchanged",content:n[e],oldLineNum:e+1,newLineNum:t+1}),h=e=>u.push({type:"removed",content:n[e],oldLineNum:e+1}),p=e=>u.push({type:"added",content:r[e],newLineNum:e+1});for(let e=0;e<i;e++)m(e,e);let f=function(e,t,n,r,a,l){let i=n-t,d=l-a;if(0===i&&0===d)return new Uint8Array(0);if(0===i)return new Uint8Array(d).fill(2);if(0===d)return new Uint8Array(i).fill(o);let c=new Map,u=e=>{let t=c.get(e);return void 0===t&&(t=c.size,c.set(e,t)),t},m=new Int32Array(i),h=new Int32Array(d);for(let n=0;n<i;n++)m[n]=u(e[t+n]);for(let e=0;e<d;e++)h[e]=u(r[a+e]);let p=Math.min(i+d,2e3),f=p+1,g=new Int32Array(2*f+1),x=[],b=-1;for(let e=0;e<=p;e++){x.push(g.slice(f-e,f+e+1));for(let t=-e;t<=e;t+=2){let n=t===-e||t!==e&&g[f+t-1]<g[f+t+1]?g[f+t+1]:g[f+t-1]+1,r=n-t;for(;n<i&&r<d&&m[n]===h[r];)n++,r++;if(g[f+t]=n,n>=i&&r>=d){b=e;break}}if(b>=0)break}if(b<0)return null;let v=new Uint8Array(i+d),y=v.length,w=i,k=d;for(let e=b;e>0;e--){let t=x[e],n=w-k,r=n===-e||n!==e&&t[n-1+e]<t[n+1+e],a=r?n+1:n-1,l=t[a+e],i=l-a;for(;w>l&&k>i;)v[--y]=s,w--,k--;r?(v[--y]=2,k--):(v[--y]=o,w--)}for(;w>0&&k>0;)v[--y]=s,w--,k--;return v.subarray(y)}(n,i,d,r,i,c);if(f){let e=i,t=i;for(let n of f)n===s?m(e++,t++):n===o?h(e++):p(t++)}else{for(let e=i;e<d;e++)h(e);for(let e=i;e<c;e++)p(e)}for(let e=0;e<a-d;e++)m(d+e,c+e);return u}n.d(t,{X:()=>r});let s=0,o=1},23348:(e,t,n)=>{n.d(t,{Eo:()=>d,jm:()=>a,zB:()=>i});var r=n(49433),s=n(84230),o=n(37640);let a=()=>(0,s.F)("/api/bots",(0,o.zi)("/api/bots")),l=r.OH5(()=>(0,s.T)("/api/bots")),i=e=>(0,o.B2)("/api/bots",{path:e}).pipe(r.yeE(l)),d=e=>(0,o.zi)(`/api/bots/${encodeURIComponent(e)}`,{method:"DELETE"}).pipe(r.yeE(l))},23970:(e,t,n)=>{function r(e){return e.replace(/\s+/g," ").trim()}n.d(t,{AM:()=>l,fp:()=>a});let s=e=>r(e).toLowerCase(),o=/^\s*(\/@|\/|@)(\S+?)(?:\s+|$)/;function a(e,t){let n=e.match(o);if(!n)return null;let[,a,l]=n,i=e.indexOf(a);if("@"!==a)return t.isSkill(l)?{kind:"skill",start:i,end:i+a.length+l.length}:null;if(t.isBot(l))return{kind:"bot",start:i,end:i+1+l.length};let d=function(e,t){let n=e.toLowerCase(),o=null;for(let r of t){let t=s(r.title);if(!t||t.length<=(o?.length??0)||!n.startsWith(t))continue;let a=e.charAt(t.length);(!a||/\s/.test(a))&&(o=t)}if(null===o)return null;let a=t.filter(e=>s(e.title)===o),l=e.slice(0,o.length);return a.length>1?{kind:"ambiguous",title:l,candidates:a}:{kind:"match",session:a[0],title:r(a[0].title),rest:e.slice(o.length).trim()}}(e.slice(i+1),t.sessions);return d?.kind!=="match"||t.selfSessionId&&d.session.sessionId===t.selfSessionId?null:{kind:"session",start:i,end:i+1+d.title.length}}function l(e,t,n,r){let s=0===t?0:e.lastIndexOf("\n",t-1)+1,o=e.indexOf("\n",s),a=e.slice(s,-1===o?e.length:o),l=r(a);if(!l)return null;let i=t-s;if(!("Backspace"===n?i>l.start&&i<=l.end:i>=l.start&&i<l.end))return null;let d=" "===a[l.end]?l.end+1:l.end;return[s+l.start,s+d]}},24602:(e,t,n)=>{n.d(t,{N:()=>S});var r=n(95155),s=n(12115),o=n(79114),a=n(64428),l=n(34075),i=n(14341),d=n(42804),c=n(22164),u=n(34582),m=n(85269),h=n(86304),p=n(17243),f=n(28132),g=n(86957),x=n(38408),b=n(60938),v=n(51145),y=n(79237);let w=new Set(["png","jpg","jpeg","gif","webp","svg","ico","bmp","avif"]),k=new Set(["js","mjs","cjs","jsx","ts","tsx","css","json","html","htm","md","markdown","txt","yml","yaml","sh","bash","xml","csv"]),C=e=>{let t=e.replace(/\\/g,"/");return t.slice(t.lastIndexOf("/")+1)},j=e=>{let t,n,r=(n=(t=C(e).toLowerCase()).lastIndexOf("."))<0?"":t.slice(n+1);return w.has(r)?"image":k.has(r)?"text":null};function N({entryPath:e,entryContent:t}){let n=(0,s.useMemo)(()=>{let t,n;return(n=(t=e.replace(/\\/g,"/")).lastIndexOf("/"))<=0?"/":t.slice(0,n)},[e]),o=e=>(0,y.y)(n,e)||C(e),a=(0,s.useRef)(new Map),[l,i]=(0,s.useState)([]),[d,c]=(0,s.useState)(e),[u,m]=(0,s.useState)(!0);(0,s.useEffect)(()=>{a.current=new Map([[e,t]]);let r={abs:e,rel:C(e),kind:"text"};i([r]),c(e),m(!0);let s=!1;return(async()=>{let l=new Set([e]),d=[r],c=[t];for(;c.length&&d.length<40&&!s;)for(let e of function(e){let t,n=/(?<![.\w])\.\/([\w./-]+\.\w+)/g,r=new Set;for(;null!==(t=n.exec(e));)r.add(t[1]);return[...r]}(c.shift())){if(d.length>=40)break;let t=function(e,t){let n=e.replace(/\\/g,"/").replace(/\/+$/,""),r=[];for(let e of(n+"/"+t).split("/"))if(""!==e&&"."!==e){if(".."===e){if(!r.length)return null;r.pop();continue}r.push(e)}let s="/"+r.join("/");return s===n||s.startsWith(n+"/")?s:null}(n,e);if(!t||l.has(t))continue;l.add(t);let r=j(t);if(r)if("image"===r){let e=await g.t4.runPromise((0,b.r6)(n,t)).catch(()=>null);e?.ok&&e.data&&!s&&(d.push({abs:t,rel:o(t),kind:r}),i([...d]))}else{let e=await g.t4.runPromise((0,v.K)(n,t)).catch(()=>null);e?.ok&&e.data?.content!=null&&(a.current.set(t,e.data.content),c.push(e.data.content),s||(d.push({abs:t,rel:o(t),kind:r}),i([...d])))}}s||m(!1)})(),()=>{s=!0}},[e,t,n]);let h=l.find(e=>e.abs===d),w=l.length>1||u;return(0,r.jsxs)("div",{className:"flex h-full",children:[w&&(0,r.jsxs)("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto",children:[l.map(e=>(0,r.jsxs)("button",{onClick:()=>c(e.abs),"data-tooltip":e.rel,className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 min-w-0 transition-colors ${d===e.abs?"bg-accent text-foreground":"text-muted-foreground hover:bg-hover"}`,children:["image"===e.kind?(0,r.jsx)(p.A,{className:"w-3.5 h-3.5 flex-shrink-0"}):(0,r.jsx)(f.A,{className:"w-3.5 h-3.5 flex-shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:e.rel})]},e.abs)),u&&(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"…"})]}),(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:h?.kind==="image"?(0,r.jsx)("div",{className:"h-full flex items-center justify-center p-4 overflow-auto bg-background",children:(0,r.jsx)("img",{src:`/api/file?path=${encodeURIComponent(d)}&raw=true`,alt:C(d),className:"max-w-full max-h-full object-contain"})}):(0,r.jsx)(x.Cv,{content:a.current.get(d)??"",filePath:d,cwd:n},d)})]})}function S({filePath:e,content:t,cwd:n,onClose:p,onContentSearch:f}){let{t:g}=(0,o.Bd)(),x=(0,h.P)(),[b,v]=(0,s.useState)("preview");return(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:p,children:(0,r.jsxs)("div",{className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":e,onClick:()=>{navigator.clipboard.writeText(e),(0,l.oR)(g("common.copiedPath"))},children:(0,r.jsx)("bdi",{dir:"ltr",children:e})}),(0,r.jsx)("button",{onClick:()=>v(e=>"preview"===e?"source":"preview"),className:`px-1.5 py-0.5 text-xs rounded transition-colors flex-shrink-0 ${"preview"===b?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:"preview"===b?g("fileBrowser.exitPreview"):g("common.preview")}),(0,r.jsx)("button",{onClick:()=>x(e),title:g("htmlApps.addTooltip"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,r.jsx)(i.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:()=>{window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:e}})),p()},title:g("common.openInConsole"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,r.jsx)(d.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:()=>{let t=(0,u.Xe)(e,n);window.open((0,u.PB)(t,window.location.origin),"_blank")},title:g("browser.openInNewWindow"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,r.jsx)(c.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:p,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:"preview"===b?(0,r.jsx)(m.O,{content:t,filePath:e,cwd:n,onContentSearch:f?e=>{f(e),p()}:void 0}):(0,r.jsx)(N,{entryPath:e,entryContent:t,cwd:n})})]})})})}},27570:(e,t,n)=>{n.d(t,{L:()=>s});var r=n(12115);function s({enabled:e,container:t,resolveLineRange:n,buildLineSnapshot:o,dragThresholdPx:a=5}){let l=(0,r.useRef)(null),i=(0,r.useRef)(()=>{}),d=(0,r.useRef)(n),c=(0,r.useRef)(o),u=(0,r.useRef)(a);return d.current=n,c.current=o,u.current=a,(0,r.useEffect)(()=>{if(!e||!t)return;let n=!1,r=0,s=0,o=()=>{l.current&&(l.current=null,i.current())},a=e=>{n=!0,r=e.clientX,s=e.clientY;let t=e.target;t?.closest?.(".floating-toolbar")||o()},m=e=>{n=!1;let a=e.target;if(a?.closest?.(".floating-toolbar"))return;let m=u.current,h=Math.abs(e.clientX-r)>m||Math.abs(e.clientY-s)>m,p=window.getSelection();if(!p||p.isCollapsed||!p.toString().trim()||!h)return void o();let f=p.getRangeAt(0);if(!t.contains(f.commonAncestorContainer))return void o();let g=d.current(f.startContainer),x=d.current(f.endContainer);if(!g||!x)return void o();let b=Math.min(g.start,x.start),v=Math.max(g.end,x.end),y=p.toString(),w=c.current({start:b,end:v});l.current={x:e.clientX,y:e.clientY,range:{start:b,end:v},selectedText:y,lineSnapshot:w},i.current()},h=()=>{if(n||!l.current)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||o()};return t.addEventListener("mousedown",a),document.addEventListener("mouseup",m),document.addEventListener("selectionchange",h),()=>{t.removeEventListener("mousedown",a),document.removeEventListener("mouseup",m),document.removeEventListener("selectionchange",h)}},[e,t]),{toolbarRef:l,bumpRef:i,clearToolbar:()=>{l.current&&(l.current=null,i.current())}}}},30133:(e,t,n)=>{n.d(t,{y:()=>o});var r=n(95155),s=n(79114);function o({value:e,onChange:t,className:n}){let{t:a}=(0,s.Bd)();return(0,r.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${n??""}`,children:["compact","full"].map(n=>(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),t(n)},className:`px-2 py-0.5 text-xs transition-colors ${e===n?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:a("compact"===n?"diffViewer.compact":"diffViewer.full")},n))})}},30577:(e,t,n)=>{n.d(t,{m:()=>c});var r=n(95155),s=n(12115),o=n(64428),a=n(86957),l=n(57125),i=n(83448);function d(e){return"env"===e?"from env var":"default"===e?"default":null}function c({currentModel:e,onModelChange:t}){let[n,u]=(0,s.useState)(!1),[m,h]=(0,s.useState)([]),[p,f]=(0,s.useState)(!1),[g,x]=(0,s.useState)(null),[b,v]=(0,s.useState)(!1),[y,w]=(0,s.useState)(!1),[k,C]=(0,s.useState)(!1),[j,N]=(0,s.useState)(null),[S,T]=(0,s.useState)(""),[E,R]=(0,s.useState)("default"),[M,L]=(0,s.useState)(!1),[I,A]=(0,s.useState)(""),[F,P]=(0,s.useState)("default"),[$,D]=(0,s.useState)(""),[_,O]=(0,s.useState)(!1),B=(0,s.useRef)(null),H=(0,s.useRef)(null),V=(0,s.useRef)(null),[U,W]=(0,s.useState)({top:0,left:0});(0,l.r8)(H,n,U.left);let q=(0,o.F2)();(0,s.useEffect)(()=>{if(!n)return;let e=e=>{H.current&&!H.current.contains(e.target)&&B.current&&!B.current.contains(e.target)&&u(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]);let z=(0,s.useCallback)(async()=>{f(!0),x(null);let e=await a.t4.runPromiseExit((0,i.qD)(()=>v(!0)));if(v(!1),"Failure"===e._tag)x("Connection error");else{let t=e.value;switch(t._tag){case"ok":h(t.models);break;case"not-installed":case"error":x(t.message);break;case"not-running":x("Ollama is not running")}}f(!1)},[]),K=(0,s.useCallback)(e=>{T(e.baseUrl),R(e.baseUrlSource),L(e.hasKey),A(e.maskedKey),P(e.keySource),D(""),O(!1)},[]),G=(0,s.useCallback)(async()=>{w(!0),N(null);let e=await a.t4.runPromiseExit((0,i.F4)());"Failure"===e._tag?N("Failed to load config"):K(e.value),w(!1)},[K]),Q=async()=>{C(!0),N(null);let e=await a.t4.runPromiseExit((0,i.yS)({baseUrl:S}));"Failure"===e._tag?N("Save failed"):(K(e.value),await z()),C(!1)},J=async()=>{let e=$.trim();if(!e)return;C(!0),N(null);let t=await a.t4.runPromiseExit((0,i.yS)({apiKey:e}));"Failure"===t._tag?N("Save failed"):K(t.value),C(!1)},Y=async()=>{C(!0),N(null);let e=await a.t4.runPromiseExit((0,i.yS)({apiKey:""}));"Failure"===e._tag?N("Clear failed"):K(e.value),C(!1)},Z=e?e.replace(/:latest$/,""):"Select model",X=d(E),ee=d(F),et=n?(0,r.jsx)(o.ZL,{children:(0,r.jsxs)("div",{ref:H,className:`${l.ys} min-w-[300px]`,style:{top:U.top,left:U.left},children:[(0,r.jsxs)("div",{className:"px-3 py-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Server URL"}),X&&!y&&(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:X})]}),y?(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"text",value:S,onChange:e=>T(e.target.value),onKeyDown:e=>{"Enter"===e.key&&Q()},placeholder:"http://127.0.0.1:11434",spellCheck:!1,className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${l.Fx}`}),(0,r.jsx)("button",{onClick:Q,disabled:k,className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${l.$T}`,children:k?"...":"Save"})]})]}),(0,r.jsxs)("div",{className:"px-3 py-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"API Key"}),ee&&M&&!y&&(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:ee})]}),y?null:M&&!_?(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:I}),(0,r.jsx)("button",{onClick:()=>{O(!0),D(""),setTimeout(()=>V.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-hover text-foreground transition-colors",disabled:k,children:"Edit"}),(0,r.jsx)("button",{onClick:Y,className:"text-[11px] px-2 py-1 rounded text-red-11 hover:bg-red-500/10 transition-colors",disabled:k,children:"Clear"})]}):(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{ref:V,type:"password",value:$,onChange:e=>D(e.target.value),onKeyDown:e=>{"Enter"===e.key&&J()},placeholder:"optional — for authenticated servers",spellCheck:!1,className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${l.Fx}`}),(0,r.jsx)("button",{onClick:J,disabled:k||!$.trim(),className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${l.$T}`,children:k?"...":"Save"}),M&&(0,r.jsx)("button",{onClick:()=>{O(!1),D("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),j&&(0,r.jsx)("div",{className:"mt-1 text-[11px] text-red-11",children:j})]}),(0,r.jsx)("div",{className:"my-1 border-t border-border"}),(0,r.jsx)("div",{className:"px-3 pt-1 pb-0.5",children:(0,r.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Model"})}),(0,r.jsx)("div",{className:"max-h-[240px] overflow-y-auto",children:p||b?(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),b?"Starting Ollama...":"Loading models..."]}):g?(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-red-11",children:g}):0===m.length?(0,r.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models found. Run ",(0,r.jsx)("code",{className:"bg-secondary px-1 rounded",children:"ollama pull <model>"})]}):m.map(n=>{var s;let o=n.name===e;return(0,r.jsxs)("button",{onClick:()=>{t(n.name),u(!1)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors ${o?l.yI:"text-foreground hover:bg-hover"}`,children:[(0,r.jsx)(l.hG,{selected:o}),(0,r.jsx)("span",{className:"truncate",children:n.name.replace(/:latest$/,"")}),(0,r.jsx)("span",{className:"ml-auto pl-2 text-muted-foreground flex-shrink-0",children:n.parameter_size||((s=n.size)<1e9?`${(s/1e6).toFixed(0)}M`:`${(s/1e9).toFixed(1)}G`)})]},n.name)})})]})}):null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.XY,{buttonRef:B,label:Z,title:"Configure Ollama",onClick:()=>{if(!n){if(B.current){let e=B.current.getBoundingClientRect(),t=q?.getBoundingClientRect(),n=t?.left??0,r=t?.top??0;W({top:e.bottom+4-r,left:e.left-n})}G(),z()}u(e=>!e)},icon:(0,r.jsx)(l.eV,{engine:"ollama"}),testId:"ollama-config-picker"}),et]})}},31703:(e,t,n)=>{n.d(t,{zB:()=>Z,e$:()=>Y,vP:()=>q});var r=n(95155),s=n(12115),o=n(79114),a=n(49433),l=n(77725),i=n(62111),d=n(70188),c=n(72312),u=n(61043),m=n(64428),h=n(52839),p=n(79237),f=n(67889),g=n(33210),x=n(56058),b=n(32880),v=n(33024),y=n(12710),w=n(32967),k=n(88780),C=n(30133),j=n(48661),N=n(20080),S=n(45619),T=n(47215),E=n(5135),R=n(24602),M=n(9573),L=n(4055);let I=new Set(["sudo","command","exec","time","nice","env"]),A=new Set(["-C","-c","--git-dir","--work-tree","--namespace"]),F=e=>e.replace(/^(['"])(.*)\1$/,"$2");function P(e){let t=0;for(;t<e.length&&(/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[t])||I.has(e[t]));)t++;let n=e[t];if("gh"===n)return"pr"===e[t+1]&&"checkout"===e[t+2];if("git"!==n&&!n?.endsWith("/git"))return!1;for(t++;t<e.length&&e[t].startsWith("-");)A.has(e[t])&&t++,t++;let r=e[t];if(!r)return!1;var s=e.slice(t+1).map(F);switch(r){case"rebase":case"pull":case"merge":case"switch":case"cherry-pick":case"am":return!0;case"checkout":return!s.includes("--")&&!s.includes(".");case"reset":return s.some(e=>"--hard"===e||"--keep"===e||"--merge"===e);case"stash":return"pop"===s[0]||"apply"===s[0];default:return!1}}var $=n(86957),D=n(82680);let _="cockpit:diff-aggregate-default";function O(e,t){return{path:e.path,status:e.status,additions:e.additions,deletions:e.deletions,old_string:e.oldContent??"",new_string:e.newContent??"",unviewable:!e.isImage&&(e.binary||null===e.oldContent&&null===e.newContent),contentDeferred:e.contentDeferred,isImage:e.isImage,oldRev:e.oldRev,newRev:e.newRev,external:null!==t&&t.size>0&&!t.has(e.path)}}let B=(e,t,n)=>`/api/snapshots/blob?cwd=${encodeURIComponent(e)}&rev=${encodeURIComponent(t)}&file=${encodeURIComponent(n)}`;function H(e){return e.fullSubject||e.subject}function V(e,t,n){let r=H(e),s=r.split("\n"),o=s.length>n?s.slice(0,n).join("\n"):r,a=o.length>t?o.slice(0,t):o;return s.length>n||o.length>t?`${a.trimEnd()}…`:a}function U(e,t){return t&&(0,p.y)(t,e)||e}function W(e,t){let n=[];for(let r of e)if("Edit"===r.name){let e=r.input;if(e.file_path&&"string"==typeof e.old_string&&"string"==typeof e.new_string){let s=U(e.file_path,t);n.push({key:r.id,toolName:"Edit",subject:`[Edit] ${s}`,legacy:!0,changeClass:(0,h.q)(s),files:[{path:s,status:"modified",old_string:e.old_string,new_string:e.new_string}]})}}else if("Write"===r.name){let e=r.input;if(e.file_path&&"string"==typeof e.content){let s=U(e.file_path,t);n.push({key:r.id,toolName:"Write",subject:`[Write] ${s}`,legacy:!0,changeClass:(0,h.q)(s),files:[{path:s,status:"added",old_string:"",new_string:e.content}]})}}return n}function q(e,t,n){var r;let s,o=e.map(e=>{let t=new Set(e.commit.toolFiles);return{key:e.commit.toolId??e.commit.hash,shortHash:e.commit.hash.slice(0,7),hash:e.commit.hash,parent:e.commit.parent,declared:e.commit.toolFiles,toolName:e.commit.toolName??"tool",subject:e.commit.subject,timestamp:e.commit.timestamp,truncated:!0===e.truncated,changeClass:(0,h.S)(e.files.map(e=>e.path)),files:e.files.map(e=>O(e,t))}});return r=o.length>0?o:W(t,n),s=new Map(t.map(e=>[e.id,e])),r.map(e=>{let t,n=s.get(e.key),r=function(e){if(!e)return;let t=e.input;return"string"==typeof t.description&&t.description?t.description:"string"==typeof t.command&&t.command?t.command:"string"==typeof t.prompt&&t.prompt?t.prompt:"string"==typeof t.file_path&&t.file_path?t.file_path:"string"==typeof t.notebook_path&&t.notebook_path?t.notebook_path:void 0}(n),o="string"==typeof(t=n?.input.command)&&t?t:Array.isArray(t)&&t.every(e=>"string"==typeof e)?t.join(" "):void 0;return r||o?{...e,...r?{fullSubject:`[${e.toolName}] ${r}`}:{},...o?{command:o}:{}}:e})}function z(e){let t=!1,n=0,r=0;for(let s of e)(void 0!==s.additions||void 0!==s.deletions)&&(t=!0),n+=s.additions??0,r+=s.deletions??0;return t?{additions:n,deletions:r}:null}function K({additions:e,deletions:t}){return(0,r.jsxs)("span",{className:"flex items-center gap-1 font-mono",children:[(0,r.jsxs)("span",{className:"text-green-11",children:["+",e]}),(0,r.jsxs)("span",{className:"text-red-11",children:["-",t]})]})}function G(e){let t=new Date(1e3*e),n=new Date,r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),l=`${r}-${s} ${o}:${a}`;return t.getFullYear()===n.getFullYear()?l:`${t.getFullYear()}-${l}`}let Q=(e,t=!1)=>`p-1 rounded transition-colors ${t?"text-foreground-subtle opacity-60 cursor-not-allowed":e?"bg-hover text-foreground":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,J=e=>`ml-0.5 px-2 py-0.5 text-xs rounded border transition-colors ${e?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:text-foreground hover:bg-hover"}`;function Y({toolCalls:e,cwd:t,sessionId:n,onClose:m,onContentSearch:h,fullscreen:p,onToggleFullscreen:I,fullscreenByDefault:A,onToggleFullscreenByDefault:F}){let{t:U}=(0,o.Bd)(),Z=(0,s.useRef)(null),[X,ee]=(0,s.useState)(null);(0,s.useEffect)(()=>{ee(Z.current)},[]);let et=(0,s.useMemo)(()=>e.map(e=>e.id).filter(Boolean),[e]),en=et.join(","),[er,es]=(0,s.useState)(0);(0,s.useEffect)(()=>{es(0)},[en]);let eo=(0,l.Z)(t&&et.length>0?(0,M.se)(t,et,n):a.PyW([]),[t,n,en,er]),ea=(0,s.useMemo)(()=>e.filter(e=>(0,L.h)(e.name)).map(e=>e.id),[e]);(0,s.useEffect)(()=>{if("success"!==eo.status||er>=2)return;let e=new Set(eo.data.map(e=>e.commit.toolId));if(ea.some(t=>!e.has(t))){let e=setTimeout(()=>es(e=>e+1),2e3);return()=>clearTimeout(e)}},[eo,er,ea]);let el=(0,s.useRef)([]),ei="loading"===eo.status&&0===el.current.length,ed=(0,s.useMemo)(()=>{if("success"===eo.status){let n=q(eo.data,e,t);return n.length>0&&(el.current=n),n}return"loading"===eo.status&&el.current.length>0?el.current:"loading"===eo.status?[]:W(e,t)},[eo,e,t]),[ec,eu]=(0,s.useState)(!1),[em,eh]=(0,s.useState)(()=>$.t4.runSync(a.SvU({try:()=>"1"===window.localStorage.getItem(_),catch:e=>new D.uV({message:"load diff aggregate default failed",cause:e})}).pipe(a.h9N(()=>a.PyW(!1))))),[ep,ef]=(0,s.useState)(!1),eg=(0,s.useMemo)(()=>ed.filter(e=>e.hash),[ed]),ex=(0,s.useMemo)(()=>(function(e){let t=[];for(let r=0;r<e.length-1;r++){var n;void 0!==(n=e[r]).command&&(function(e){let t=[],n=[],r="",s=null,o=()=>{r&&n.push(r),r=""},a=()=>{o(),n.length&&t.push(n),n=[]};for(let t=0;t<e.length;t++){let n=e[t];if(s){n===s?s=null:r+=n;continue}if('"'===n||"'"===n){s=n;continue}if("\\"===n&&t+1<e.length){r+=e[++t];continue}if(" "===n||" "===n){o();continue}if("\n"===n||";"===n||"|"===n||"&"===n||"("===n||")"===n){a();continue}r+=n}return a(),t})(n.command).some(P)&&t.push(r)}return{skip:t.length>0?t[t.length-1]+1:0,shifts:t}})(eg),[eg]),eb=(0,s.useMemo)(()=>ep?eg:eg.slice(ex.skip),[eg,ep,ex]),ev=(0,s.useMemo)(()=>{if(ep||0===ex.shifts.length)return ed;let e=new Set(ex.shifts.map(e=>eg[e].key));return ed.filter(t=>!e.has(t.key))},[ed,eg,ep,ex]),ey=(0,s.useMemo)(()=>0===eb.length||eb.length<2&&0===ex.skip?null:{base:eb[0].parent??null,head:eb[eb.length-1].hash},[eb,ex]),ew=!!t&&ed.length>=2,ek=null===ey;(0,s.useEffect)(()=>{ec&&!ey&&eu(!1)},[ec,ey]);let eC=(0,s.useRef)(!1);(0,s.useEffect)(()=>{!eC.current&&ey&&(eC.current=!0,em&&eu(!0))},[ey,em]);let ej=(0,s.useCallback)(()=>{let e=!em;eh(e),ey&&eu(e),$.t4.runSync(a.SvU({try:()=>window.localStorage.setItem(_,e?"1":"0"),catch:e=>new D.uV({message:"save diff aggregate default failed",cause:e})}).pipe(a.h9N(()=>a.rIH)))},[em,ey]),eN=(0,l.Z)(ec&&t&&ey?(0,M.Tt)(t,ey.base,ey.head):a.PyW(null),[ec,t,ey?.base??"",ey?.head??""]),eS=(0,s.useMemo)(()=>0===eb.length||eb.some(e=>!e.declared||0===e.declared.length)?null:new Set(eb.flatMap(e=>e.declared)),[eb]),eT=(0,s.useMemo)(()=>"success"===eN.status&&eN.data?eN.data.files.map(e=>O(e,eS)):[],[eN,eS]),eE="success"===eN.status&&eN.data?.truncated===!0,eR=ec&&"loading"===eN.status,eM=ec&&"error"===eN.status,[eL,eI]=(0,s.useState)(null),[eA,eF]=(0,s.useState)(null),[eP,e$]=(0,s.useState)(new Set),[eD,e_]=(0,s.useState)(()=>window.innerWidth>=768),[eO,eB]=(0,s.useState)("compact"),[eH,eV]=(0,s.useState)("unified"),[eU,eW]=(0,s.useState)(!1),[eq,ez]=(0,s.useState)(!1),[eK,eG]=(0,s.useState)(null),eQ=(0,s.useMemo)(()=>ed.find(e=>e.key===eL)??null,[ed,eL]),eJ=(0,s.useRef)(null);(0,s.useEffect)(()=>{eQ&&(eJ.current=eQ)},[eQ]);let eY=eQ??eJ.current,eZ=(0,s.useMemo)(()=>ec?eT:eY?.files??[],[ec,eT,eY]),eX=(0,s.useMemo)(()=>(0,k.Do)(eZ),[eZ]),e0=(0,s.useMemo)(()=>eZ.find(e=>e.path===eA)??null,[eZ,eA]),e1=e0?.contentDeferred?e0.path:void 0,e2=ec?ey?.base??null:null,e5=ec?ey?.head:eY?.hash,e4=t&&e1&&e5?JSON.stringify([t,ec,e2,e5,e1]):null,e3=(0,l.Z)(e4&&t&&e1&&e5?a.JkU(function*(){let{files:e}=yield*ec?(0,M.Tt)(t,e2,e5,e1):(0,M.Ew)(t,e5,e1);return{key:e4,file:e[0]??null}}).pipe(a.DM4(()=>({key:e4,file:null}))):a.PyW(null),[e4]),e8="success"===e3.status&&e3.data?.key===e4?e3.data?.file:void 0,e6=(0,s.useMemo)(()=>e8&&e0?{...O(e8,null),external:e0.external}:e0,[e8,e0]),e9=(0,s.useMemo)(()=>z(eZ),[eZ]),e7=(0,s.useCallback)(e=>{eI(e.key),eF(e.files[0]?.path??null),e$(new Set((0,k.Sz)((0,k.Do)(e.files))))},[]);(0,s.useEffect)(()=>{ev.length>0&&null==eL&&e7(ev[0])},[ev,eL,e7]),(0,s.useEffect)(()=>{null==eL||0===ev.length||ev.some(e=>e.key===eL)||ed.some(e=>e.key===eL)&&e7(ev[0])},[ed,ev,eL,e7]),(0,s.useEffect)(()=>{0===eZ.length||eA&&eZ.some(e=>e.path===eA)||eF(eZ[0].path)},[eZ,eA]),(0,s.useEffect)(()=>{ec&&0!==eT.length&&e$(new Set((0,k.Sz)((0,k.Do)(eT))))},[ec,eT]),(0,s.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(eU)return void eW(!1);if(eq)return void ez(!1);if(eK)return void eG(null);(0,i.k)(),m()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[m,eU,eq,eK]);let te=(0,s.useMemo)(()=>ev.reduce((e,t)=>e+t.files.length,0),[ev]),tt=e=>(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:e});return(0,r.jsx)(d.SU,{container:X,children:(0,r.jsxs)("div",{ref:Z,className:"relative bg-card shadow-lv3 w-full h-full flex flex-col rounded-lg",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:`${f.o} px-3`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{onClick:m,"aria-label":U("common.close"),title:U("common.close"),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(g.A,{className:"w-4 h-4"})}),I&&(0,r.jsx)("button",{onClick:I,"aria-label":p?U("diffViewer.exitFull"):U("diffViewer.expandFull"),title:p?U("diffViewer.exitFull"):U("diffViewer.expandFull"),"aria-pressed":!0===p,className:Q(!0===p),children:p?(0,r.jsx)(x.A,{className:"w-4 h-4"}):(0,r.jsx)(b.A,{className:"w-4 h-4"})}),F&&(0,r.jsx)("button",{onClick:F,"aria-pressed":!0===A,title:A?U("diffViewer.openFullOn"):U("diffViewer.openFullOff"),className:J(!0===A),children:U("diffViewer.openFull")}),ew&&(0,r.jsx)("button",{onClick:()=>eu(e=>!e),disabled:ek,"aria-pressed":ec,"aria-label":U("diffViewer.aggregate"),title:ek?U("diffViewer.aggregateUnavailable"):ec?U("diffViewer.aggregateOff"):U("diffViewer.aggregateOn"),className:Q(ec,ek),children:(0,r.jsx)(v.A,{className:"w-4 h-4"})}),ew&&(0,r.jsx)("button",{onClick:ej,"aria-pressed":em,title:em?U("diffViewer.openAggregateOn"):U("diffViewer.openAggregateOff"),className:J(!0===em),children:U("diffViewer.openAggregate")})]}),(0,r.jsx)("div",{className:"w-px h-4 bg-border flex-shrink-0"}),(0,r.jsx)("button",{onClick:()=>e_(e=>!e),"aria-label":U("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors flex-shrink-0 ${eD?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:(0,r.jsx)(y.A,{className:"w-4 h-4"})}),(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground truncate",children:ec?U("diffViewer.fileChangesAggregate",{count:eZ.length}):U("diffViewer.fileChanges",{count:te})})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[eD&&!ec&&(0,r.jsxs)("div",{className:"w-60 flex-shrink-0 border-r border-border overflow-y-auto",children:[ex.shifts.length>0&&(0,r.jsx)("button",{onClick:()=>ef(e=>!e),"data-tooltip":U("diffViewer.aggregateSkippedHint"),className:"w-full px-3 py-1.5 border-b border-border text-left text-xs bg-amber-500/10 text-amber-600 dark:text-amber-400 hover:bg-amber-500/20 transition-colors",children:ep?U("diffViewer.callsBaselineShown",{count:ex.shifts.length}):U("diffViewer.callsBaselineHidden",{count:ex.shifts.length})}),ev.map(e=>{let t;return(0,r.jsxs)("div",{onClick:()=>e7(e),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${eL===e.key?"bg-brand/10":""}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.changeClass&&(0,r.jsx)(c.N,{cls:e.changeClass}),e.shortHash&&(0,r.jsx)("span",{className:"font-mono text-xs text-brand",children:e.shortHash}),void 0!==e.timestamp&&(0,r.jsx)("span",{className:"text-xs text-foreground-subtle",children:G(e.timestamp)})]}),(0,r.jsx)("div",{className:"text-sm text-foreground whitespace-pre-wrap break-words mt-0.5 line-clamp-3","data-tooltip":H(e),children:V(e,320,3)}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:U("commitDetail.nChanges",{count:e.files.length})}),(t=z(e.files))&&(t.additions>0||t.deletions>0)?(0,r.jsx)(K,{additions:t.additions,deletions:t.deletions}):null]})]},e.key)})]}),(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:ei?tt(U("diffViewer.loadingSnapshots")):0===ed.length?tt(U("diffViewer.noChanges")):ec||eY?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-border text-xs text-muted-foreground",children:[ec?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,r.jsx)(v.A,{className:"w-3.5 h-3.5"}),U("diffViewer.aggregateSummary",{count:eZ.length,calls:eb.length})]}),ex.skip>0&&(0,r.jsx)("button",{onClick:()=>ef(e=>!e),"data-tooltip":U("diffViewer.aggregateSkippedHint"),className:"px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors",children:ep?U("diffViewer.aggregateBaselineIncluded",{count:ex.skip}):U("diffViewer.aggregateBaselineSkipped",{count:ex.skip})}),e9&&(e9.additions>0||e9.deletions>0)&&(0,r.jsx)(K,{additions:e9.additions,deletions:e9.deletions}),eE&&(0,r.jsx)("span",{className:"text-amber-11",children:U("diffViewer.truncated")})]}):eY?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"flex items-center gap-1 text-foreground flex-shrink-0 whitespace-nowrap",children:[(0,r.jsx)(w.A,{className:"w-3.5 h-3.5"}),eY.toolName]}),eY.shortHash&&(0,r.jsx)("span",{className:"font-mono text-brand flex-shrink-0",children:eY.shortHash}),void 0!==eY.timestamp&&(0,r.jsx)("span",{className:"flex-shrink-0 whitespace-nowrap",children:G(eY.timestamp)}),(0,r.jsx)("span",{className:"flex-1 min-w-0 truncate","data-tooltip":H(eY),children:V(eY,640,6).replace(/\s*\n\s*/g," ")}),eY.truncated&&(0,r.jsx)("span",{className:"text-amber-11",children:U("diffViewer.truncated")}),eY.legacy&&(0,r.jsx)("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-400","data-tooltip":U("diffViewer.reconstructedHint"),children:U("diffViewer.reconstructed")})]}):null,(0,r.jsx)("div",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:!e6?.isImage&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(C.y,{value:eO,onChange:eB}),(0,r.jsx)(j.q,{value:eH,onChange:eV})]})})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[eD&&(0,r.jsx)(u.q,{children:eR?(0,r.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("diffViewer.aggregateLoading")}):(0,r.jsxs)(r.Fragment,{children:[eZ.length>0&&(0,r.jsx)(k.WY,{files:eZ}),(0,r.jsx)(k.VO,{files:eX,selectedPath:eA,expandedPaths:eP,onToggle:e=>e$(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{!e.isDirectory&&e.file&&(eF(e.file.path),window.innerWidth<768&&e_(!1))},cwd:t||"",showChanges:!0,showChangeClass:!0,renderActions:e=>{if(e.isDirectory)return null;let t=e.file;return t?(0,r.jsx)(r.Fragment,{children:t.external&&(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0","data-tooltip":U("diffViewer.externalChange")})}):null}})]})}),(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:e6?e6.isImage?(0,r.jsx)(N.K,{filePath:e6.path,oldSrc:t&&e6.oldRev?B(t,e6.oldRev,e6.path):null,newSrc:t&&e6.newRev?B(t,e6.newRev,e6.path):null}):e6.unviewable?(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:e4&&void 0===e8?U("diffViewer.loadingFile"):e4&&null===e8?U("diffViewer.fileLoadFailed"):U("diffViewer.notViewable")}):"unified"===eH?(0,r.jsx)(S.xU,{oldContent:e6.old_string,newContent:e6.new_string,filePath:e6.path,highlight:!e1,cwd:t,enableComments:!0,onContentSearch:h,compact:"compact"===eO,onPreview:"deleted"===e6.status?void 0:(0,T.e$)(e6.path)?()=>eW(!0):(0,T.aR)(e6.path)?()=>ez(!0):e6.path.endsWith(".json")?()=>eG({content:e6.new_string,filePath:e6.path}):void 0,previewLabel:e6.path.endsWith(".json")?U("common.readable"):U("common.preview")}):(0,r.jsx)(S.xZ,{oldContent:e6.old_string,newContent:e6.new_string,filePath:e6.path,highlight:!e1,isNew:"added"===e6.status,isDeleted:"deleted"===e6.status,cwd:t,enableComments:!0,onContentSearch:h,compact:"compact"===eO,onPreview:"deleted"===e6.status?void 0:(0,T.e$)(e6.path)?()=>eW(!0):(0,T.aR)(e6.path)?()=>ez(!0):e6.path.endsWith(".json")?()=>eG({content:e6.new_string,filePath:e6.path}):void 0,previewLabel:e6.path.endsWith(".json")?U("common.readable"):U("common.preview")}):(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:eR?U("diffViewer.aggregateLoading"):eM?U("diffViewer.aggregateFailed"):ec&&0===eZ.length?U("diffViewer.aggregateEmpty"):U("diffViewer.selectFileToView")})})]})]}):tt(U("diffViewer.selectFileToView"))})]}),eU&&e6&&(0,r.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>eW(!1),children:(0,r.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[95%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(E.M,{content:e6.new_string,filePath:e6.path,cwd:t||"",onClose:()=>eW(!1)})})}),eq&&e6&&(0,r.jsx)(R.N,{filePath:e6.path,content:e6.new_string,cwd:t,onClose:()=>ez(!1),onContentSearch:h}),eK&&(0,r.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>eG(null),children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[95%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:eK.filePath}),(0,r.jsx)("button",{onClick:()=>eG(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(g.A,{className:"w-4 h-4"})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,T.xb)(eK.content)})})]})})]})})}function Z({toolCalls:e,cwd:t,sessionId:n,onClose:s,onContentSearch:o}){return(0,r.jsx)(m.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:s,children:(0,r.jsx)(Y,{toolCalls:e,cwd:t,sessionId:n,onClose:s,onContentSearch:o?e=>{s(),o(e)}:void 0})})})}},32041:(e,t,n)=>{n.d(t,{C0:()=>m});var r=n(95155),s=n(12115),o=n(61878),a=n(33210),l=n(9921),i=n(66088),d=n(79114);let c=/^-?[\d,]*\.?\d+%?$/;function u(e){return c.test(e)?parseFloat(e.replace(/,/g,"")):NaN}function m({content:e,filePath:t,className:n="",action:h}){let{t:p}=(0,d.Bd)(),[f,g]=(0,s.useState)(500),[x,b]=(0,s.useState)(""),[v,y]=(0,s.useState)(-1),[w,k]=(0,s.useState)(null),{header:C,body:j,columnCount:N}=(0,s.useMemo)(()=>{let n=(function(e,t){let n=[],r=[],s="",o=!1,a=!1,l=()=>{r.push(s),n.push(r),r=[],s="",a=!1};for(let n=0;n<e.length;n++){let i=e[n];if(o){if('"'!==i){s+=i;continue}'"'===e[n+1]?(s+='"',n++):o=!1;continue}if('"'===i&&""===s){o=!0,a=!0;continue}if(i===t){r.push(s),s="",a=!0;continue}if("\r"===i){"\n"===e[n+1]&&n++,l();continue}if("\n"===i){l();continue}s+=i,a=!0}return(a||""!==s||r.length>0)&&l(),n})(e,function(e,t){if(t&&/\.tsv$/i.test(t))return" ";let n=e.slice(0,65536),r={",":0,";":0," ":0,"|":0},s=!1,o=0;for(let e=0;e<n.length&&o<5;e++){let t=n[e];if('"'===t){s=!s;continue}if(!s){if("\n"===t){o++;continue}t in r&&r[t]++}}let a=Object.entries(r).sort((e,t)=>t[1]-e[1])[0];return a[1]>0?a[0]:","}(e,t)).filter(e=>e.length>1||""!==e[0]),r=n.reduce((e,t)=>Math.max(e,t.length),0),s=n.slice(1).map((e,t)=>({index:t,cells:e}));return{header:n[0]??[],body:s,columnCount:r}},[e,t]);(0,s.useEffect)(()=>{g(500),b(""),y(-1),k(null)},[e,t]);let S=(0,s.useMemo)(()=>{let e=x.trim().toLowerCase();return e?j.filter(t=>v>=0?(t.cells[v]??"").toLowerCase().includes(e):t.cells.some(t=>t.toLowerCase().includes(e))):j},[j,x,v]),T=(0,s.useMemo)(()=>{if(!w)return S;let e="asc"===w.dir?1:-1;return[...S].sort((t,n)=>(function(e,t,n){if(""===e||""===t)return e===t?0:""===e?1:-1;let r=u(e),s=u(t);return isNaN(r)||isNaN(s)?e.localeCompare(t,void 0,{numeric:!0})*n:(r-s)*n})(t.cells[w.col]??"",n.cells[w.col]??"",e))},[S,w]);(0,s.useEffect)(()=>{g(500)},[x,v]);let E=(0,s.useCallback)(e=>{k(t=>t&&t.col===e?"asc"===t.dir?{col:e,dir:"desc"}:null:{col:e,dir:"asc"})},[]);if(0===N)return(0,r.jsx)("div",{className:`flex items-center justify-center ${n}`,children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:p("csv.empty")})});let R=T.slice(0,f);return(0,r.jsxs)("div",{className:`flex flex-col min-h-0 ${n}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-1 min-w-0 px-1.5 py-0.5 rounded border border-border bg-card focus-within:border-brand transition-colors",children:[(0,r.jsx)(o.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0","aria-hidden":!0}),(0,r.jsx)("input",{value:x,onChange:e=>b(e.target.value),placeholder:p("csv.filterPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs text-foreground placeholder:text-muted-foreground outline-none"}),x&&(0,r.jsx)("button",{onClick:()=>b(""),className:"text-muted-foreground hover:text-foreground flex-shrink-0",title:p("csv.clearFilter"),children:(0,r.jsx)(a.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsxs)("select",{value:v,onChange:e=>y(Number(e.target.value)),className:"text-xs bg-card text-muted-foreground border border-border rounded px-1 py-1 max-w-[10rem] flex-shrink-0",title:p("csv.filterColumn"),children:[(0,r.jsx)("option",{value:-1,children:p("csv.allColumns")}),Array.from({length:N},(e,t)=>(0,r.jsx)("option",{value:t,children:C[t]||`#${t+1}`},t))]}),h&&(0,r.jsx)("button",{onClick:h.onClick,className:"text-xs px-2 py-1 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:h.label})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,r.jsxs)("table",{className:"text-xs border-collapse w-max min-w-full",children:[(0,r.jsx)("thead",{className:"sticky top-0 z-10",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"sticky left-0 z-20 bg-accent border-b border-r border-border px-2 py-1.5 text-right font-normal text-muted-foreground select-none",children:"#"}),Array.from({length:N},(e,t)=>(0,r.jsx)("th",{onClick:()=>E(t),className:"bg-accent border-b border-border px-2 py-1.5 text-left font-medium text-foreground whitespace-nowrap cursor-pointer select-none hover:bg-hover",title:p("csv.sortHint"),children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[C[t]??"",w?.col===t&&("asc"===w.dir?(0,r.jsx)(l.A,{className:"w-3 h-3 text-brand","aria-hidden":!0}):(0,r.jsx)(i.A,{className:"w-3 h-3 text-brand","aria-hidden":!0}))]})},t))]})}),(0,r.jsx)("tbody",{children:R.map(e=>(0,r.jsxs)("tr",{className:"hover:bg-hover",children:[(0,r.jsx)("td",{className:"sticky left-0 bg-card border-b border-r border-border px-2 py-1 text-right text-muted-foreground tabular-nums select-none",children:e.index+1}),Array.from({length:N},(t,n)=>{let s=e.cells[n]??"";return(0,r.jsx)("td",{title:s.length>60?s:void 0,className:`border-b border-border px-2 py-1 max-w-[28rem] truncate text-foreground ${c.test(s)?"text-right tabular-nums":""}`,children:s},n)})]},e.index))})]}),0===R.length&&(0,r.jsx)("div",{className:"p-4 text-xs text-muted-foreground",children:p("csv.noMatch")})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3 px-3 py-1.5 border-t border-border text-xs text-muted-foreground flex-shrink-0",children:[(0,r.jsx)("span",{children:S.length===j.length?p("csv.summary",{rows:j.length,cols:N}):p("csv.summaryFiltered",{rows:S.length,total:j.length,cols:N})}),R.length<T.length&&(0,r.jsx)("button",{onClick:()=>g(e=>e+500),className:"px-1.5 py-0.5 rounded hover:bg-hover hover:text-foreground transition-colors",children:p("csv.loadMore",{shown:R.length,total:T.length})})]})]})}},32456:(e,t,n)=>{n.d(t,{Mm:()=>l,Qr:()=>o,fw:()=>a,wG:()=>i,wX:()=>d});var r=n(95155),s=n(39872);let o=e=>e.split("/").pop()||e;function a(e,t){let n=Math.floor((Date.now()-t)/6e4);if(n<1)return e("common.justNow");if(n<60)return e("common.minutesAgo",{count:n});let r=Math.floor(n/60);return r<24?e("common.hoursAgo",{count:r}):e("common.daysAgo",{count:Math.floor(r/24)})}function l(e,t){return"loading"===t?e("sessions.running"):"unread"===t?e("sessions.done"):void 0}function i(e){let t=new Map;for(let n of e){let e=t.get(n.cwd);e?e.push(n):t.set(n.cwd,[n])}return[...t].map(([e,t])=>({cwd:e,items:t}))}function d({cwd:e,projectOrder:t,currentCwd:n,children:a}){let l=t.indexOf(e)+1;return(0,r.jsxs)("div",{className:"sticky top-0 z-10 px-3 py-1.5 bg-card rounded-t-lg border-b border-border/60 text-[11px] font-medium text-muted-foreground flex items-center gap-1.5",children:[l>0&&(0,r.jsx)(s.B,{number:l,isActive:e===n}),(0,r.jsx)("span",{className:"truncate","data-tooltip":e,children:o(e)}),a]})}},33199:(e,t,n)=>{n.d(t,{s:()=>eJ});var r=n(95155),s=n(12115),o=n(34075),a=n(64428),l=n(67635),i=n(46945),d=n(54731),c=n(9921),u=n(66088),m=n(12651),h=n(81165),p=n(16950),f=n(11019),g=n(12612),x=n(31025),b=n(74102),v=n(68459),y=n(18763),w=n(73172),k=n(79114),C=n(49433),j=n(91281),N=n(80286),S=n(86957),T=n(97938);function E({cwd:e,sessionId:t,toolCall:n,workflowRef:o,running:l,onClose:i}){let{t:d}=(0,k.Bd)(),[c,u]=(0,s.useState)(null),[m,h]=(0,s.useState)(null),[p,f]=(0,s.useState)(!1),[g,x]=(0,s.useState)([]),[b,v]=(0,s.useState)(),y=(0,s.useRef)(0),w=(0,s.useRef)(void 0),R=o?!!o.running:l??!n?.result,M=(0,s.useCallback)(async()=>{let r=++y.current,s=await S.t4.runPromiseExit((0,T.z)({cwd:e,sessionId:t,...o?{workflowId:o.runId,workflowAgentId:o.agentId}:{toolUseId:n?.id},childSessionId:b,ifFingerprint:w.current}));if(r!==y.current||(f(!0),"Success"!==s._tag||!s.value))return;let a=s.value;!b&&a.childSessionId&&v(a.childSessionId),a.children&&x(a.children),a.fingerprint&&(w.current=a.fingerprint),!a.notModified&&(a.messages&&u(a.messages),a.subagent&&h(a.subagent))},[e,t,n?.id,o?.runId,o?.agentId,b]);(0,s.useEffect)(()=>{let e=C.ivC(M),t=S.t4.runFork(R?e.pipe(C.uxO(j.ji(5e3))):e);return()=>{y.current++,S.t4.runFork(N.G(t))}},[R,M]);let L=(0,s.useRef)(null),I=(0,s.useRef)(!0);(0,s.useEffect)(()=>{let e=L.current;e&&I.current&&(e.scrollTop=e.scrollHeight)},[c]);let A="string"==typeof n?.input?.description?n.input.description:"",F=o?o.label||"":[m?.agentType,m?.description,A].filter(Boolean).join(" \xb7 ");return(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:e=>{e.stopPropagation(),i()},children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-base",children:"\uD83E\uDD16"}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:d("chat.subagent")}),F&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":F,children:F}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[R&&(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("button",{onClick:i,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:d("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),g.length>0&&(0,r.jsx)("div",{className:"flex gap-2 overflow-x-auto px-4 py-2 border-b border-border flex-shrink-0",children:g.map(e=>(0,r.jsxs)("button",{type:"button","aria-pressed":(b??g[0]?.id)===e.id,className:"text-xs rounded px-2 py-1 whitespace-nowrap aria-pressed:bg-hover text-foreground",title:`${e.model} \xb7 ${e.status}`,onClick:()=>{(b??g[0]?.id)!==e.id&&(y.current++,w.current=void 0,u(null),h(null),f(!1),v(e.id))},children:[e.name," \xb7 ",e.model," \xb7 ",d(`chat.piChildStatus.${e.status}`,{defaultValue:e.status})]},e.id))}),(0,r.jsx)("div",{ref:L,onScroll:()=>{let e=L.current;e&&(I.current=e.scrollTop+e.clientHeight>=e.scrollHeight-40)},className:"flex-1 overflow-y-auto px-4 py-3",children:null===c?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:p?d("chat.subagentEmpty"):d("common.loading")}):c.map(n=>(0,r.jsx)(eJ,{message:n,cwd:e,sessionId:t},n.id))})]})})})}function R(e){return e?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):"0"}function M(e){if(!e)return"–";let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return`${n}m${t%60}s`}let L={done:"text-green-9",running:"text-brand",queued:"text-muted-foreground",error:"text-red-9",failed:"text-red-9"};function I({cwd:e,sessionId:t,runId:n,isRunning:o,onClose:l}){let{t:i}=(0,k.Bd)(),[d,c]=(0,s.useState)(null),[u,m]=(0,s.useState)(!1),[h,p]=(0,s.useState)(null),f=(0,s.useRef)(void 0),g=o||null!=d&&"completed"!==d.status&&"failed"!==d.status,x=(0,s.useCallback)(async()=>{let r=await S.t4.runPromiseExit((0,T.z)({cwd:e,sessionId:t,workflowId:n,ifFingerprint:f.current}));if(m(!0),"Success"!==r._tag||!r.value)return;let s=r.value;s.fingerprint&&(f.current=s.fingerprint),!s.notModified&&s.workflow&&c(s.workflow)},[e,t,n]);(0,s.useEffect)(()=>{if(x(),!g)return;let e=setInterval(x,5e3);return()=>clearInterval(e)},[g,x]);let b=[];if(d?.agents){let e=new Map;for(let t of d.agents){let n=t.phaseTitle||i("chat.workflowUngrouped");e.has(n)||e.set(n,[]),e.get(n).push(t)}for(let[t,n]of e)b.push({title:t,agents:n})}let v=d?[d.workflowName,d.status,`${d.agentCount??d.agents?.length??0} ${i("chat.workflowAgents")}`,`${R(d.totalTokens)} tok`,M(d.durationMs)].filter(Boolean).join(" \xb7 "):"";return(0,r.jsxs)(a.ZL,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:l,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-base",children:"\uD83E\uDDE9"}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:i("chat.workflowRun")}),v&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":v,children:v}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[g&&(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("button",{onClick:l,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:i("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:null===d?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:i(u?"chat.workflowEmpty":"common.loading")}):(0,r.jsxs)(r.Fragment,{children:[d.summary&&(0,r.jsx)("div",{className:"mb-3 text-xs text-muted-foreground whitespace-pre-wrap",children:d.summary}),b.map(e=>(0,r.jsxs)(s.Fragment,{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-foreground/80 mt-3 mb-1 sticky top-0 bg-card py-1",children:e.title}),e.agents.map(e=>(0,r.jsx)(A,{agent:e,onOpen:()=>e.agentId&&p({runId:n,agentId:e.agentId,label:e.label,running:"done"!==e.state&&g})},`${e.index}-${e.agentId}`))]},e.title))]})})]})}),h&&(0,r.jsx)(E,{cwd:e,sessionId:t,workflowRef:h,onClose:()=>p(null)})]})}function A({agent:e,onOpen:t}){let{t:n}=(0,k.Bd)(),[o,a]=(0,s.useState)(!1),l=e.state&&L[e.state]||"text-muted-foreground",i=e.resultPreview||e.promptPreview||"";return(0,r.jsxs)("div",{className:"border border-border rounded-md mb-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,r.jsx)("button",{onClick:()=>a(e=>!e),className:"text-foreground-subtle text-xs flex-shrink-0",title:n(o?"chat.collapse":"chat.expand"),children:o?"▲":"▼"}),(0,r.jsx)("span",{className:"text-xs text-foreground truncate flex-1 min-w-0","data-tooltip":e.label||"",children:e.label||e.agentId}),(0,r.jsx)("span",{className:`text-[10px] flex-shrink-0 ${l}`,children:e.state}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[R(e.tokens)," tok \xb7 ",M(e.durationMs)]}),e.agentId&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:t,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&t()},className:"text-xs text-brand hover:text-teal-10 cursor-pointer flex-shrink-0",title:n("chat.subagentViewTitle"),children:n("chat.workflowViewAgent")})]}),o&&i&&(0,r.jsx)("pre",{className:"text-[11px] bg-secondary px-2 py-1.5 rounded-b overflow-x-auto max-h-32 overflow-y-auto text-muted-foreground whitespace-pre-wrap border-t border-border",children:i})]})}var F=n(74086),P=n(60938),$=n(45619),D=n(38408),_=n(6744),O=n(47176),B=n(97251),H=n(34582),V=n(56045),U=n(61043),W=n(50860),q=n(47215);function z({filePath:e}){let[t,n]=(0,s.useState)(null),[o,a]=(0,s.useState)(!0),[l,i]=(0,s.useState)(null),d=(0,s.useRef)(!1),c=(0,q.e$)(e),u=(0,q.u)(e);return((0,s.useEffect)(()=>{u?a(!1):d.current||(d.current=!0,(async()=>{a(!0),i(null);let t=await S.t4.runPromiseExit((0,P.nM)(e));if("Success"===t._tag)n(t.value.content??null);else{let e="Fail"===t.cause._tag?t.cause.error:null,n=e?.cause;i(n instanceof Error?n.message:"Failed to load file")}a(!1),d.current=!1})())},[e,u]),l)?(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("div",{className:"text-xs text-red-11",children:l})}):o?(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):(0,q.u)(e)?(0,r.jsx)(W.I,{absPath:e,className:"flex items-center justify-center h-full overflow-auto",imgClassName:"max-w-full max-h-full object-contain",alt:e.split("/").pop()||"image"}):t?c?(0,r.jsx)(G,{content:t,filePath:e}):(0,r.jsx)(D.Cv,{content:t,filePath:e,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}let K=[B.W];function G({content:e,filePath:t}){let n=(0,s.useRef)(null),o=(0,s.useMemo)(()=>(0,H.J4)(t),[t]);return(0,r.jsxs)("div",{className:"h-full flex",children:[(0,r.jsx)(O.l,{content:e,containerRef:n}),(0,r.jsx)("div",{ref:n,className:"flex-1 overflow-auto p-4",children:(0,r.jsx)(_.T,{content:e,basePath:o,rehypePlugins:K})})]})}function Q({title:e,content:t,toolName:n,result:l,sidebar:i,onClose:d}){let{t:c}=(0,k.Bd)(),u=(0,q.jU)(t),m=(0,q.zs)(t),h=(0,q.oK)(t),p=!!m,f=!!h,g=()=>("Read"===n||"Write"===n)&&f?"file":p?"diff-unified":u?"readable":"json",[x,b]=(0,s.useState)(g()),v=`${n??""}\0${t}`,[y,w]=(0,s.useState)(v);y!==v&&(w(v),b(g()));let C=(0,s.useRef)(null),j=(0,V.o)(C);(0,s.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&"readable"===x&&u){e.preventDefault(),j.open();return}if("Escape"===e.key){if(j.isVisible)return void j.close();document.activeElement instanceof HTMLElement&&document.activeElement.blur(),d()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[d,x,u,j]);let N=()=>"file"===x&&h?(0,r.jsx)(z,{filePath:h}):"diff-unified"===x&&m?(0,r.jsx)($.xU,{oldContent:m.old_string,newContent:m.new_string,filePath:m.file_path}):"diff-split"===x&&m?(0,r.jsx)($.xZ,{oldContent:m.old_string,newContent:m.new_string,filePath:m.file_path}):"readable"===x&&u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(V._,{search:j}),(0,r.jsx)("pre",{ref:C,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,q.xb)(t)})]}):(0,r.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:u?(0,q.C6)(t):t}),S=(0,s.useMemo)(()=>void 0===l?null:(0,q.jU)(l)?(0,q.C6)(l):l,[l]),T=(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:d,children:(0,r.jsxs)("div",{className:"bg-card shadow-lv3 w-full max-w-[90%] h-full md:h-[90vh] rounded-none md:rounded-lg flex flex-col transition-all",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground truncate",title:e,children:e}),h&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(h),(0,o.oR)(c("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:c("common.copyAbsPath"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsxs)("div",{className:"flex items-center gap-3 flex-shrink-0 whitespace-nowrap",children:[u&&(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[p&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:()=>b("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===x?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:c("diffViewer.sideBySide"),children:"Split"}),(0,r.jsx)("button",{onClick:()=>b("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===x?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:c("diffViewer.unified"),children:"Unified"})]}),f&&(0,r.jsx)("button",{onClick:()=>b("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===x?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:c("diffViewer.previewFile"),children:"File"}),(0,r.jsx)("button",{onClick:()=>b("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===x?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:c("common.readable")}),(0,r.jsx)("button",{onClick:()=>b("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===x?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,r.jsx)("button",{onClick:d,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[i&&(0,r.jsx)(U.q,{children:i}),(0,r.jsx)("div",{className:"flex-1 min-w-0 flex flex-col",children:null===S?(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-auto p-4",children:N()}):(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col",children:[(0,r.jsxs)("div",{className:`min-h-0 flex flex-col ${"diff-unified"===x||"diff-split"===x||"file"===x?"flex-1":"flex-shrink-0 max-h-[40%]"}`,children:[(0,r.jsx)("div",{className:"px-4 pt-3 pb-1 text-xs text-muted-foreground",children:c("toolCall.input")}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-auto px-4 pb-3",children:N()})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col border-t border-border",children:[(0,r.jsx)("div",{className:"px-4 pt-3 pb-1 text-xs text-muted-foreground",children:c("toolCall.result")}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-auto px-4 pb-3",children:(0,r.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:S})})]})]})})]})]})});return(0,r.jsx)(a.ZL,{children:T})}var J=n(79237);let Y=null,Z=new Set;function X(e){return Z.add(e),()=>{Z.delete(e)}}let ee={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",ApplyPatch:"\uD83E\uDDE9",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D",Workflow:"\uD83E\uDDE9",Skill:"\uD83D\uDEE0️"};function et(e){return"object"==typeof e&&null!==e}function en(e,t){let n=t?(0,J.y)(t,e):null;if(n)return n;let r=e.split("/");return r.length>2?".../"+r.slice(-2).join("/"):e}function er(e,t){let{name:n,input:r}=e,s="Agent"===n||"Task"===n,o="Workflow"===n,a="Skill"===n,l=(()=>{if("Bash"===n&&r.command&&"string"==typeof r.command)return r.command;if("ApplyPatch"===n&&Array.isArray(r.changes)){let e=r.changes.filter(et).flatMap(e=>{let n="string"==typeof e.path?e.path:"";if(!n)return[];let r="string"==typeof e.kind&&e.kind?e.kind:"update";return`${r} ${en(n,t)}`});if(e.length>0)return e.join(" \xb7 ")}if(s&&r.description&&"string"==typeof r.description)return r.description;if(o){let e=["string"==typeof r.name?r.name:"","string"==typeof r.args?r.args:"string"==typeof r.resumeFromRunId?r.resumeFromRunId:""].filter(Boolean).join(" \xb7 ");if(e)return e}if(a&&"string"==typeof r.skill){let e="string"==typeof r.args?r.args:"";return[r.skill,e].filter(Boolean).join(" \xb7 ")}return"Glob"===n&&r.pattern&&"string"==typeof r.pattern||"Grep"===n&&r.pattern&&"string"==typeof r.pattern?r.pattern:"ToolSearch"===n&&r.query&&"string"==typeof r.query?r.query:"TaskCreate"===n&&r.subject&&"string"==typeof r.subject?r.subject:r.file_path&&"string"==typeof r.file_path?r.file_path:r.path&&"string"==typeof r.path?r.path:null})(),i="Glob"===n||"Grep"===n||"Bash"===n||"ApplyPatch"===n||s||o||a,d=l?i?l:en(l,t):null;return{icon:ee[n]||"\uD83D\uDD27",displayInfo:l,displayPath:d}}function es({calls:e,initialIndex:t,cwd:n,onClose:o}){let[a,l]=(0,s.useState)(t),i=e[Math.min(a,e.length-1)];if(!i)return null;let{displayPath:d}=er(i,n),c=e.length>1?(0,r.jsx)("ul",{className:"py-1",children:e.map((e,t)=>{let s=er(e,n),o=e===i;return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{onClick:()=>l(t),className:`w-full px-3 py-1.5 flex items-center gap-2 text-left transition-colors ${o?"bg-accent":"hover:bg-hover"}`,title:s.displayInfo??e.name,children:[(0,r.jsx)("span",{className:"text-sm flex-shrink-0",children:s.icon}),(0,r.jsx)("span",{className:`text-sm text-foreground flex-shrink-0 ${o?"font-medium":""}`,children:e.name}),s.displayPath&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate min-w-0 flex-1",children:s.displayPath}),e.isLoading&&(0,r.jsx)("span",{className:"ml-auto inline-block w-3 h-3 border-2 border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"})]})},`${e.id}-${t}`)})}):void 0;return(0,r.jsx)(Q,{title:`${i.name}${d?` ${d}`:""}`,content:JSON.stringify(i.input,null,2),result:!i.isLoading&&i.result?"string"==typeof i.result?i.result:JSON.stringify(i.result,null,2):void 0,toolName:i.name,sidebar:c,onClose:o})}function eo({toolCall:e,cwd:t,sessionId:n,disableOverlays:a=!1,siblings:l,index:i=0}){var d;let{t:c}=(0,k.Bd)(),u=(0,s.useId)(),m=(0,s.useSyncExternalStore)(X,()=>Y===u,()=>!1),[h,p]=(0,s.useState)(!1),[f,g]=(0,s.useState)(!1),[x,b]=(0,s.useState)(!1),v="Agent"===e.name||"Task"===e.name,y=(v||"subagent"===e.name)&&!!t&&!!n,w="Workflow"===e.name,C=w&&(d=e.result)?d.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,j=w&&!!C&&!!t&&!!n,N=(0,F.v2)(e.id)??e.task,S=N?.status==="running",T=!!e.isLoading||S,R="subagent"===e.name?!!e.isLoading:N?S||!!e.isLoading:!e.result,M=S?[N?.lastToolName,N?.toolUses?String(N.toolUses):null].filter(Boolean).join(" \xb7 "):"",L="Skill"===e.name,A="ApplyPatch"===e.name||v||w||L,{icon:P,displayInfo:$,displayPath:D}=er(e,t),_=(0,s.useCallback)(()=>p(!1),[]);return(0,r.jsxs)("div",{className:"border-b border-line-1 last:border-b-0",children:[(0,r.jsxs)("button",{onClick:()=>{Y=Y===u?null:u,Z.forEach(e=>e())},className:"w-full px-3 py-1.5 flex items-center gap-2 text-left hover:bg-hover transition-colors",children:[(0,r.jsx)("span",{className:"text-sm",children:P}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:e.name}),D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":$||"","data-tooltip-mono":!0,children:D}),!A&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),$&&(navigator.clipboard.writeText($),(0,o.oR)(c("common.copiedPath")))},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),$&&(navigator.clipboard.writeText($),(0,o.oR)(c("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0 cursor-pointer",title:c("common.copyAbsPath"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[y&&!a&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),g(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),g(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:c("chat.subagentViewTitle"),children:c("chat.subagent")}),j&&!a&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),b(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),b(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:c("chat.workflowViewTitle"),children:c("chat.workflowRun")}),M&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate max-w-[16rem]",children:M}),m&&!a&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),p(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),p(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:c("toolCall.detailsTitle"),children:c("toolCall.details")})}),T?(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,r.jsx)("span",{className:"text-foreground-subtle text-xs",children:m?"▲":"▼"})]})]}),m&&(0,r.jsxs)("div",{className:"border-t border-line-1",children:[(0,r.jsx)("div",{className:"px-3 py-2",children:(0,r.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-60 overflow-y-auto text-foreground",children:e.result?"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2):JSON.stringify(e.input,null,2)})}),e.skillContent&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-line-1",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[c("toolCall.skillContent",{defaultValue:"Skill content"}),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-60 overflow-y-auto text-foreground whitespace-pre-wrap",children:e.skillContent})]})]}),h&&(0,r.jsx)(es,{calls:l&&l[i]===e?l:[e],initialIndex:l&&l[i]===e?i:0,cwd:t,onClose:_}),f&&t&&n&&(0,r.jsx)(E,{cwd:t,sessionId:n,toolCall:e,running:R,onClose:()=>g(!1)}),x&&t&&n&&C&&(0,r.jsx)(I,{cwd:t,sessionId:n,runId:C,isRunning:T,onClose:()=>b(!1)})]})}var ea=n(62111),el=n(56204),ei=n(33210),ed=n(58515),ec=n(36201),eu=n(55804),em=n(37618),eh=n(83897);function ep(e){let t=e.input?.questions||[],n=e.input?.answers||{},r={};if(e.result)try{let t=JSON.parse(e.result);t?.answers&&(r=t.answers)}catch{}return{questions:t,answers:{...n,...r}}}function ef(e,t){return`${e}-${t}`}function eg({toolCalls:e,onClose:t}){let{t:n}=(0,k.Bd)(),i=(0,eh.nH)(),[d,c]=(0,s.useState)({}),[u,m]=(0,s.useState)({}),[h,p]=(0,s.useState)({}),[f,g]=(0,s.useState)({});(0,s.useEffect)(()=>{let t={};e.forEach((e,n)=>{let{questions:r,answers:s}=ep(e);r.forEach((e,r)=>{let o=s[e.question];if(o){let s=ef(n,r);t[s]=o,e.options.some(e=>e.label===o)||(m(e=>({...e,[s]:!0})),p(e=>({...e,[s]:o})))}})}),queueMicrotask(()=>c(t))},[e]),(0,ea.E)(t);let x=e.reduce((e,t)=>{let{questions:n}=ep(t);return e+n.length},0),b=Object.values(f).filter(Boolean).length,v=(0,s.useCallback)((e,t)=>{c(n=>({...n,[e]:t})),m(t=>({...t,[e]:!1}))},[]),y=(0,s.useCallback)(e=>{m(t=>{let n=!t[e];if(n){let t=h[e]||"";t&&c(n=>({...n,[e]:t}))}return{...t,[e]:n}})},[h]),w=(0,s.useCallback)((e,t)=>{p(n=>({...n,[e]:t})),t&&c(n=>({...n,[e]:t}))},[]),C=(0,s.useCallback)(e=>{g(t=>({...t,[e]:!t[e]}))},[]),j=(0,s.useCallback)(()=>{let t=b>0,r=[];return e.forEach((e,s)=>{let{questions:o}=ep(e);o.forEach((e,o)=>{let a=ef(s,o);if(t&&!f[a])return;let l=d[a];r.push(`Q: ${e.question}`),r.push(`A: ${l||n("askQuestion.notSelected")}`),r.push("")})}),r.join("\n").trim()},[e,d,f,b,n]),N=(0,s.useCallback)(()=>{navigator.clipboard.writeText(j()),(0,o.oR)(b>0?n("toast.copiedQA",{count:b}):n("toast.copiedAllQA"))},[j,b,n]),S=(0,s.useCallback)(()=>{i?(i.sendMessage(j()),(0,o.oR)(n("toast.sentQA")),t()):(0,o.oR)(n("askQuestion.sendNoChat"))},[i,j,t,n]),T=(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:t,children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:n("askQuestion.title")}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[n("askQuestion.nQuestions",{count:x}),b>0&&` \xb7 ${n("askQuestion.checkedN",{count:b})}`]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:S,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:b>0?n("askQuestion.sendChecked",{count:b}):n("askQuestion.sendAll"),children:(0,r.jsx)(el.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:N,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:b>0?n("askQuestion.copyChecked",{count:b}):n("askQuestion.copyAll"),children:(0,r.jsx)(l.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(ei.A,{className:"w-5 h-5"})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:e.map((t,s)=>{let{questions:o}=ep(t);return o.map((t,a)=>{let l=ef(s,a),i=d[l],c=u[l]||!1,m=f[l]||!1;return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("button",{onClick:()=>C(l),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-hover transition-colors",title:n("askQuestion.checkToCopy"),children:m?(0,r.jsx)(ed.A,{className:"w-4 h-4 text-brand"}):(0,r.jsx)(ec.A,{className:"w-4 h-4 text-muted-foreground"})}),t.header&&(0,r.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,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:t.question})]}),(0,r.jsxs)("div",{className:"space-y-1 ml-7",children:[t.options.map((e,t)=>{let n=i===e.label&&!c;return(0,r.jsxs)("button",{onClick:()=>v(l,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-hover ${n?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,r.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:n?(0,r.jsx)(eu.A,{className:"w-3.5 h-3.5 text-brand"}):(0,r.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:`text-sm ${n?"text-foreground font-medium":"text-foreground"}`,children:e.label}),e.description&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:e.description})]})]},t)}),(0,r.jsxs)("button",{onClick:()=>y(l),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-hover ${c?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,r.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:c?(0,r.jsx)(eu.A,{className:"w-3.5 h-3.5 text-brand"}):(0,r.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(em.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:n("askQuestion.custom")})]})]}),c&&(0,r.jsx)("div",{className:"ml-6 mt-1",children:(0,r.jsx)("input",{type:"text",autoFocus:!0,value:h[l]||"",onChange:e=>w(l,e.target.value),placeholder:n("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"})})]}),(s!==e.length-1||a!==o.length-1)&&(0,r.jsx)("div",{className:"border-b border-border/50 mt-3"})]},l)})})})]})});return(0,r.jsx)(a.ZL,{children:T})}var ex=n(31703),eb=n(9573),ev=n(4055),ey=n(24602),ew=n(32041);function ek({filePath:e,content:t,onClose:n,zClassName:l="z-50"}){let{t:i}=(0,k.Bd)(),[d,c]=(0,s.useState)("table");return(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:`fixed inset-0 ${l} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:n,children:(0,r.jsxs)("div",{className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":e,onClick:()=>{navigator.clipboard.writeText(e),(0,o.oR)(i("common.copiedPath"))},children:(0,r.jsx)("bdi",{dir:"ltr",children:e})}),(0,r.jsx)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5 flex-shrink-0",children:["table","raw"].map(e=>(0,r.jsx)("button",{onClick:()=>c(e),className:`px-2 py-0.5 text-xs rounded transition-colors ${d===e?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:i(`csv.${e}`)},e))}),(0,r.jsx)("button",{onClick:n,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:"table"===d?(0,r.jsx)(ew.C0,{content:t,filePath:e,className:"h-full"}):(0,r.jsx)(D.Cv,{content:t,filePath:e,showLineNumbers:!0,showSearch:!0,className:"h-full"})})]})})})}var eC=n(3939),ej=n(95045),eN=n(75346);let eS={isFramed:()=>window.parent!==window,publishOpenProject:e=>(0,ej.F)(eN.n.OpenProject,e),navigate:e=>window.location.assign(e)};function eT(e,t,n=eS){n.isFramed()?n.publishOpenProject({cwd:e.cwd,sessionId:e.sessionId,switchToAgent:!0}):n.navigate(t)}var eE=n(69924),eR=n(86359),eM=n(80905),eL=n(95686),eI=n(70188),eA=n(82680);function eF({filePath:e,content:t,onClose:n}){let{t:l}=(0,k.Bd)(),[i,d]=(0,s.useState)(null),c=(0,s.useCallback)(()=>{S.t4.runPromiseExit(C.$mh({try:()=>navigator.clipboard.writeText(e),catch:e=>new eA.uV({message:"Failed to copy text to clipboard",cause:e})})).then(e=>{let t="Success"===e._tag;(0,o.oR)(l(t?"common.copiedPath":"common.copyFailed"),t?"success":"error")})},[e,l]);return(0,s.useEffect)(()=>{let e=e=>{"Escape"!==e.key||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),n())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[n]),(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:n,children:(0,r.jsxs)("div",{ref:d,className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:c,"aria-label":l("common.copyAbsPath"),className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},title:e,children:(0,r.jsx)("bdi",{dir:"ltr",children:e})}),(0,r.jsx)("button",{onClick:n,"aria-label":l("common.close"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:(0,r.jsx)(eI.SU,{container:i,children:(0,r.jsx)(D.Cv,{content:t,filePath:e,className:"h-full"})})})]})})})}var eP=n(83448);function e$(e){let t=e.replace(/\/+$/,"");return t.startsWith("/private/")?t.slice(8):t}var eD=n(67183),e_=n(86511),eO=n(58453),eB=n(20235);async function eH(e,t){if(!navigator.clipboard?.write||"u"<typeof ClipboardItem)throw Error("Clipboard image write is unavailable");try{await navigator.clipboard.write([new ClipboardItem({[e.type]:e})]);return}catch(t){if("image/png"===e.type)throw t}let n=await new Promise((e,n)=>{let r=new Image;r.onload=()=>{let t=document.createElement("canvas");t.width=r.naturalWidth,t.height=r.naturalHeight;let s=t.getContext("2d");s?(s.drawImage(r,0,0),t.toBlob(t=>{t?e(t):n(Error("Could not encode image"))},"image/png")):n(Error("Canvas is unavailable"))},r.onerror=()=>n(Error("Could not load image")),r.src=t});await navigator.clipboard.write([new ClipboardItem({"image/png":n})])}function eV({image:e,onClose:t}){let{t:n}=(0,k.Bd)(),s=`data:${e.media_type};base64,${e.data}`,i=async t=>{t.stopPropagation();try{await eH(function(e,t){let n=atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new Blob([r],{type:t})}(e.data,e.media_type),s),(0,o.oR)(n("chat.copiedImage"),"success")}catch{(0,o.oR)(n("common.copyFailed"),"error")}},d=(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[(0,r.jsxs)("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:i,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:n("chat.copyImage"),children:(0,r.jsx)(l.A,{className:"w-5 h-5"})}),(0,r.jsx)("button",{type:"button",onClick:t,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:n("common.close"),children:(0,r.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("img",{src:s,alt:n("chat.imagePreview"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]});return(0,r.jsx)(a.ZL,{children:d})}function eU({filePath:e,cwd:t,sessionId:n,onClose:i}){let{t:d}=(0,k.Bd)(),[c,u]=(0,s.useState)("file"),[m,h]=(0,s.useState)(!1),[p,f]=(0,s.useState)(0),g=`/api/file?path=${encodeURIComponent(e)}&raw=true`,x=t&&n?`/api/session/image?${new URLSearchParams({cwd:t,sessionId:n,path:e})}`:null,b="session"===c&&x?x:g,v=async t=>{t.stopPropagation();try{let t,n=await fetch(b);if(!n.ok)throw Error("Could not read image");let r=await n.blob(),s=r.type?r:new Blob([r],{type:(t=e.slice(e.lastIndexOf(".")).toLowerCase(),".jpg"===t||".jpeg"===t?"image/jpeg":".png"===t?"image/png":".gif"===t?"image/gif":".webp"===t?"image/webp":".svg"===t?"image/svg+xml":".bmp"===t?"image/bmp":".ico"===t?"image/x-icon":".avif"===t?"image/avif":"image/png")});await eH(s,b),(0,o.oR)(d("chat.copiedImage"),"success")}catch{(0,o.oR)(d("common.copyFailed"),"error")}};return(0,r.jsx)(a.ZL,{children:(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:i,children:[(0,r.jsxs)("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:v,disabled:m,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:d("chat.copyImage"),children:(0,r.jsx)(l.A,{className:"w-5 h-5"})}),(0,r.jsx)("button",{type:"button",onClick:i,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:d("common.close"),children:(0,r.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),m?(0,r.jsxs)("div",{role:"alert",className:"flex flex-col items-center gap-3 text-white",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("p",{children:d("chat.imageLoadFailed")}),(0,r.jsx)("button",{type:"button",className:"rounded bg-white/15 px-4 py-2",onClick:()=>{u("file"),h(!1),f(e=>e+1)},children:d("common.retry")})]}):(0,r.jsx)("img",{src:b,alt:e.split("/").pop(),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation(),onError:()=>{"file"===c&&x?u("session"):h(!0)}},`${c}:${p}`)]})})}let eW=(0,s.memo)(function({text:e,isAside:t,isUser:n,isStreaming:a,onOpenFileLink:l,onPreviewFile:c,cwd:u}){let{t:m}=(0,k.Bd)(),h=(0,s.useMemo)(()=>{if(n||!l)return;let e=e=>{c?c(e):(0,o.oR)(m("toast.fileOutsideProject"),"error")};return t=>{let n=function(e,t){let n;if(!e||e.startsWith("#")||e.startsWith("//")||/^[a-z][a-z0-9+.-]*:/i.test(e)&&!e.startsWith("file:"))return null;let r=e;try{r=decodeURIComponent(e)}catch{}r.startsWith("file://")&&(r=r.slice(7));let s=r.indexOf("#"),o=s>=0?r.slice(s+1):"",a=s>=0?r.slice(0,s):r,l=a.indexOf("?"),i=l>=0?a.slice(l+1):"";a=l>=0?a.slice(0,l):a;let d=o.match(/^L?(\d+)(?:-L?\d+)?$/i)?.[1],c=i.match(/(?:^|[&;])(?:line|L)=(\d+)(?:$|[&;])/i)?.[1],u=a.match(/:(\d+)(?::\d+)?$/),m=d||c||u?.[1];if(m&&(n=Number(m),u&&(a=a.slice(0,-u[0].length))),!(a=a.trim()))return null;let h=n&&n>0?{lineNumber:n}:{},p=t?e$(t):"";if(a.startsWith("/")){let e=e$(a),t=p?(0,J.y)(p,e):null;return""===t?null:t?{rel:(0,q.WU)("",t),abs:null,...h}:{rel:(0,q.WU)("",e),abs:e,...h}}return{rel:(0,q.WU)("",a),abs:null,...h}}(t,u);return!!n&&(n.abs?u?S.t4.runPromise((0,P.r6)(u,n.rel)).then(t=>{t.ok&&t.data?.exists?l({path:n.rel,...n.lineNumber?{lineNumber:n.lineNumber}:{}}):e(n.abs)}).catch(()=>e(n.abs)):e(n.abs):l({path:n.rel,...n.lineNumber?{lineNumber:n.lineNumber}:{}}),!0)}},[u,n,l,c,m]),p=(0,s.useMemo)(()=>{if(!n)return e=>{let t=(0,eC.iy)(e,window.location.origin);return t?(eT(t,e),!0):!!h&&h(e)}},[n,h]),f=(0,s.useMemo)(()=>n?(0,e_.nl)(e):null,[n,e]),g=(0,s.useMemo)(()=>f?.link?(0,eC.iy)(f.link):null,[f]),x=f?f.body:e,b=(0,s.useMemo)(()=>n?(0,eO.n2)(x):null,[n,x]),v=(0,s.useMemo)(()=>{if(!n)return null;let e=(0,eC.ke)(x);return e.some(e=>"link"===e.kind)?e:null},[n,x]),y=f&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1 text-xs text-muted-foreground",children:[(0,r.jsx)(i.A,{className:"w-3 h-3 shrink-0","aria-hidden":!0}),(0,r.jsx)("span",{children:"sent"===f.kind?m("chat.originSent",{project:f.project??m("chat.originUnknown")}):m("chat.originDelegated",{project:f.project??m("chat.originUnknown")})}),f.link&&g&&(0,r.jsx)(eE.B,{href:f.link,target:g,onClick:e=>{e.preventDefault(),eT(g,f.link)}})]}),w=(0,r.jsxs)(r.Fragment,{children:[y,b?(0,r.jsx)(eq,{prompt:b}):v?(0,r.jsx)("div",{className:"reading-measure whitespace-pre-wrap break-words",children:v.map((e,t)=>"link"===e.kind?(0,r.jsx)(eE.B,{href:e.text,target:e.target,onClick:t=>{t.preventDefault(),eT(e.target,e.text)}},t):e.text)}):(0,r.jsx)(_.T,{content:x,isUser:n,isStreaming:a,onLinkClick:p}),a&&(0,r.jsx)("span",{className:"inline-block w-2 h-4 ml-1 bg-current animate-pulse"})]});return t?(0,r.jsxs)("div",{className:"flex gap-1.5 break-words opacity-65",children:[(0,r.jsx)(d.A,{className:"w-3 h-3 mt-[5px] shrink-0 text-muted-foreground","aria-hidden":!0}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:w})]}):(0,r.jsx)("div",{className:"break-words",children:w})}),eq=(0,s.memo)(function({prompt:e}){let{t}=(0,k.Bd)(),[n,o]=(0,s.useState)(!1),{lines:a,references:l,notes:i}=e;return(0,r.jsxs)("div",{className:"reading-measure break-words",children:[(0,r.jsx)("div",{className:"whitespace-pre-wrap",children:a.map((e,t)=>(0,r.jsxs)("div",{children:[e.command&&(0,r.jsx)("span",{className:eB._9,children:e.command}),e.text||(e.command?null:"\xa0")]},t))}),l.length>0&&(0,r.jsxs)("div",{className:"mt-1.5 text-xs text-muted-foreground",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),className:"inline-flex items-center gap-1 hover:text-foreground",children:[n?(0,r.jsx)(c.A,{className:"w-3 h-3"}):(0,r.jsx)(u.A,{className:"w-3 h-3"}),t("chat.commandRefs",{count:l.length})]}),n&&(0,r.jsx)("ul",{className:"mt-1 space-y-0.5 pl-4",children:l.map((e,n)=>(0,r.jsxs)("li",{className:"truncate","data-tooltip":e.detail||void 0,"data-tooltip-mono":!0,children:[(0,r.jsx)("span",{className:"mr-1.5",children:t(`chat.commandRef_${e.kind}`)}),(0,r.jsx)("span",{className:"text-foreground",children:e.name}),e.detail&&(0,r.jsx)("span",{className:"ml-1.5 font-mono",children:e.detail})]},n))})]}),i.length>0&&(0,r.jsx)("div",{className:"mt-1.5 rounded border border-amber-9/30 bg-amber-9/10 px-2 py-1 text-xs text-amber-11",children:i.map((e,t)=>(0,r.jsx)("div",{children:e},t))})]})}),ez="28em",eK=(0,s.memo)(function({children:e}){let{t}=(0,k.Bd)(),[n,o]=(0,s.useState)(!1),[a,l]=(0,s.useState)(!1),i=(0,s.useRef)(null),d=(0,s.useRef)(null),m=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(n)return;let e=d.current,t=m.current;if(!e||!t)return;let r=()=>l(e.scrollHeight>e.clientHeight+1);r();let s=new ResizeObserver(r);return s.observe(t),()=>s.disconnect()},[n]);let h=(0,s.useCallback)(()=>{if(!n)return void o(!0);let e=i.current?.closest("[data-message-id]")??i.current;o(!1),requestAnimationFrame(()=>{e&&e.getBoundingClientRect().top<0&&e.scrollIntoView({block:"start",behavior:"auto"})})},[n]);return(0,r.jsxs)("div",{ref:i,children:[(0,r.jsx)("div",{ref:d,className:n?void 0:"overflow-hidden",style:n?void 0:{maxHeight:ez},children:(0,r.jsx)("div",{ref:m,children:e})}),a&&(0,r.jsxs)(r.Fragment,{children:[!n&&(0,r.jsx)("div",{className:"text-muted-foreground leading-none pt-1 select-none",children:"…"}),(0,r.jsxs)("button",{type:"button",onClick:h,className:"mt-1 flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[t(n?"chat.showLess":"chat.showMore"),n?(0,r.jsx)(c.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(u.A,{className:"w-3.5 h-3.5"})]})]})]})});function eG({collapsible:e,children:t}){return e?(0,r.jsx)(eK,{children:t}):(0,r.jsx)(r.Fragment,{children:t})}let eQ=new Map,eJ=(0,s.memo)(function({message:e,cwd:t,sessionId:n,snapshotsEnabled:l=!0,onFork:i,onDeleteTurn:d,forkSupported:c=!0,onSendToPeer:T,peerSide:E,onApprovePlan:R,isLoading:M,onContentSearch:L,onShowFileDiff:I,onOpenFileLink:A,disableOverlays:F=!1}){let P,$,D,O,{t:B,i18n:H}=(0,k.Bd)(),[V,U]=(0,s.useState)(null),[W,z]=(0,s.useState)(()=>1===(e.toolCalls?.length||0)),[K,G]=(0,s.useState)(!1),[Q,J]=(0,s.useState)(!1),[Y,Z]=(0,s.useState)(!1),[X,ee]=(0,s.useState)(!1),[et,en]=(0,s.useState)(!1),er=(0,s.useRef)(null),es=(0,s.useRef)(null),ea="user"===e.role,el=e.images&&e.images.length>0,ei=e.toolCalls?.length||0,ed=!!n&&!!t&&!!i&&c,ec=!!n&&!!t&&!!d;(0,s.useEffect)(()=>{if(!X)return;let e=e=>{er.current?.contains(e.target)||ee(!1)},t=e=>{"Escape"===e.key&&(ee(!1),es.current?.focus())};return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[X]);let eu=(0,s.useMemo)(()=>e.toolCalls?.some(e=>(0,ev.h)(e.name))||!1,[e.toolCalls]),em=(0,s.useMemo)(()=>ea&&e.content?(0,eD.M)(e.content):null,[ea,e.content]),eh=(0,s.useMemo)(()=>{let t=e.parts,n=em?em.body:e.content;if(!t?.length)return n?[{text:n,isAside:!1}]:[];let r=-1;t.forEach((e,t)=>{"tool"===e.type&&(r=t)});let s=[];return t.forEach((e,t)=>{"text"===e.type&&s.push({text:e.text,isAside:t<r})}),s},[e.parts,e.content,em]),ep=(0,s.useMemo)(()=>(0,ex.vP)([],e.toolCalls??[],t).length>0,[e.toolCalls,t]),ef=function(e,t,n,r){let[o,a]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{if(!r||o||!e)return;let s=(n??[]).map(e=>e.id).filter(Boolean);if(!s.length)return;let l=n?.some(e=>(0,ev.h)(e.name))??!1,i=S.t4.runFork((0,eb.xK)(e,s,t??void 0).pipe(C.h9N(e=>C.FFw("Cannot check message snapshots",e).pipe(C.as([]))),C.Mim(e=>C.OH5(()=>{e.length>0&&a(!0)})),C.uxO({while:e=>0===e.length&&l,times:2,schedule:j.ji("2 seconds")})));return()=>{S.t4.runFork(N.G(i))}},[r,o,e,t,n]),o}(t,n,e.toolCalls,l&&eu&&!ep);(0,s.useEffect)(()=>{I&&e.toolCalls?.length&&I(e.id,e.toolCalls,t,n??void 0,!0)},[I,e.id,e.toolCalls,t,n]);let ew=(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]),eC=(0,s.useMemo)(()=>e.toolCalls?e.toolCalls.filter(e=>"AskUserQuestion"===e.name):[],[e.toolCalls]),ej=(0,s.useMemo)(()=>{if(!e.toolCalls)return null;for(let t=e.toolCalls.length-1;t>=0;t--)if("ExitPlanMode"===e.toolCalls[t].name){let n=e.toolCalls[t].input?.plan;return"string"==typeof n&&n?n:null}return null},[e.toolCalls]),eN=(0,s.useMemo)(()=>e.toolCalls?.filter(e=>"ExitPlanMode"!==e.name)??[],[e.toolCalls]),eS=(0,s.useMemo)(()=>{if(!e.toolCalls)return[];let t=new Set,n=[];for(let r of e.toolCalls)if("Read"===r.name||"Edit"===r.name||"Write"===r.name){let e=r.input.file_path;e&&!t.has(e)&&(t.add(e),n.push(e))}return n},[e.toolCalls]),eT=(0,s.useMemo)(()=>{if(!e.toolCalls)return[];let t=[];for(let n of e.toolCalls){let e=n.input?.thought;if(e&&"string"==typeof e){let r=e.match(/PREVIOUS:\s*(.*?)\s*→\s*THIS:\s*(.*?)\s*→\s*EXPECT:\s*(.*)/i);r?t.push({previous:r[1].trim(),current:r[2].trim(),expect:r[3].trim(),raw:e,toolName:n.name}):t.push({previous:"",current:e,expect:"",raw:e,toolName:n.name})}}return t},[e.toolCalls]),[eE,eI]=(0,s.useState)(null),eA=eE?.path??null,e$=eE?function({path:e,source:t}){return(0,q.u)(e)?"image":(0,q.aR)(e)&&"tool"===t?"html":(0,q.Zy)(e)?"csv":(0,q.e$)(e)?"markdown":"text"}(eE):null,[e_,eB]=(0,s.useState)(null),eH=e_?.path===eA?e_.content:null,eq=(0,s.useCallback)(e=>{eI({path:e,source:"link"})},[]),ez=(0,s.useCallback)(()=>eI(null),[]);(0,s.useEffect)(()=>{if(!eA||(0,q.u)(eA))return void queueMicrotask(()=>eB(null));let e=!1;return S.t4.runPromiseExit((0,eP.an)(eA)).then(t=>{if(!e)if("Success"===t._tag&&void 0!==t.value.content)eB({path:eA,content:t.value.content});else{let e="Failure"===t._tag?eR.od(t.cause):eM.dv(),n=eM.Ru(e)?e.value.message:"";(0,o.oR)(n?`${B("toast.readFileFailed")}: ${n}`:B("toast.readFileFailed"),"error"),eI(null)}}),()=>{e=!0}},[eA,B]);let eK=async()=>{if(ec&&!M&&!et&&await (0,o.lJ)((e.turnUserCount??0)>1?B("chat.deleteTaskConfirm",{count:e.turnUserCount}):B("chat.deleteTurnConfirm",{defaultValue:"Delete this question, answer, and its tool records? This cannot be undone."}),{title:B("chat.deleteTurn",{defaultValue:"Delete turn"}),confirmText:B("chat.deleteTurnConfirmAction",{defaultValue:"Delete turn"}),danger:!0})){en(!0);try{await d(e.id)}finally{en(!1)}}},eJ=!!E&&!!T&&!!e.content,eY=(0,s.useMemo)(()=>{var t;let n;if(!e.timestamp)return"";let r=new Date(e.timestamp);return isNaN(r.getTime())?"":(t=H.language,!(n=eQ.get(t))&&(n=new Intl.DateTimeFormat(t,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),eQ.set(t,n)),n).format(r)},[e.timestamp,H.language]);if("system"===e.role){let t=e.systemEvent,n=t?.kind==="task-notification"?"failed"===t.status?"⚠️":"stopped"===t.status?"⏹️":"\uD83D\uDD14":"ℹ️",s=t?.detail||e.content;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex justify-center my-2 px-2","data-role":"system",children:(0,r.jsxs)("button",{type:"button",onClick:()=>Z(!0),className:"flex items-center gap-1.5 max-w-[85%] text-[11px] text-muted-foreground bg-secondary/40 border border-border/50 rounded-full px-3 py-1 hover:bg-secondary hover:text-foreground transition-colors cursor-pointer",title:B("chat.viewDetails",{defaultValue:"Click for details"}),children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:n}),(0,r.jsx)("span",{className:"truncate",children:e.content})]})}),Y&&(0,r.jsx)(a.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:()=>Z(!1),children:(0,r.jsxs)("div",{className:"bg-card shadow-lv3 w-full max-w-4xl max-h-[80vh] rounded-lg flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)("span",{className:"text-sm text-foreground flex items-center gap-1.5",children:[(0,r.jsx)("span",{children:n}),t?.kind==="task-notification"?B("chat.taskNotification",{defaultValue:"Task notification"}):B("chat.systemNotice",{defaultValue:"Notice"})]}),(0,r.jsx)("button",{onClick:()=>Z(!1),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors",children:"✕"})]}),(0,r.jsx)("pre",{className:"flex-1 overflow-auto px-4 py-3 text-xs text-foreground whitespace-pre-wrap break-words",children:s})]})})})]})}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:`flex flex-col ${ea?"items-end":"items-start"} mb-4 group`,"data-role":e.role,children:[(0,r.jsx)("div",{className:`relative flex items-start ${ea?"justify-end":"justify-start"} w-full`,children:(0,r.jsxs)("div",{className:`chat-turn px-4 py-2 text-foreground ${ea?"max-w-[80%] bg-muted rounded-2xl rounded-br-md border border-brand/40":"w-full"}`,children:[el&&(0,r.jsx)("div",{className:`flex flex-wrap gap-2 ${e.content?"mb-2":""}`,children:e.images.map((e,t)=>(0,r.jsx)("div",{className:`relative w-16 h-16 rounded-lg overflow-hidden border border-white/20 ${F?"":"cursor-pointer hover:opacity-90 transition-opacity"}`,onClick:F?void 0:()=>U(e),children:(0,r.jsx)("img",{src:`data:${e.media_type};base64,${e.data}`,alt:B("chat.imageN",{index:t+1}),className:"w-full h-full object-cover"})},t))}),em&&em.items.length>0&&(0,r.jsxs)("details",{className:"mb-2 text-xs text-muted-foreground","data-testid":"decision-context",children:[(0,r.jsx)("summary",{className:"cursor-pointer select-none",children:B("chat.decisionContextAttached",{defaultValue:"{{count}} related decisions attached",count:em.items.length})}),(0,r.jsx)("ul",{className:"mt-1 list-disc space-y-0.5 pl-4",children:em.items.map(e=>(0,r.jsx)("li",{children:e.text},e.key))})]}),eh.length>0&&(0,r.jsx)(eG,{collapsible:ea,children:(0,r.jsx)("div",{className:"space-y-3",children:eh.map((n,s)=>(0,r.jsx)(eW,{text:n.text,isAside:n.isAside,isUser:ea,isStreaming:!!e.isStreaming&&s===eh.length-1,onOpenFileLink:A,onPreviewFile:eq,cwd:t},s))})}),ew&&(D=($=Array.isArray(P=ew.input?.todos)?P:[]).filter(e=>"completed"===e.status).length,O=$.length,(0,r.jsx)("div",{className:`${e.content||el?"mt-2":""}`,children:(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden px-3 py-2 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,r.jsx)("div",{className:"flex-1 h-1 bg-secondary rounded-full overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-green-500 rounded-full transition-all duration-300",style:{width:`${O>0?D/O*100:0}%`}})}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[D,"/",O]})]}),$.map((e,t)=>(0,r.jsxs)("div",{className:`flex items-center gap-1.5 ${"completed"===e.status?"opacity-50":""}`,children:["completed"===e.status?(0,r.jsx)(m.A,{className:"w-3 h-3 text-green-11 flex-shrink-0"}):"in_progress"===e.status?(0,r.jsx)(h.A,{className:"w-3 h-3 text-brand flex-shrink-0 animate-spin"}):(0,r.jsx)(p.A,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),(0,r.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))]})})),ej&&(0,r.jsx)("div",{className:`${e.content||el||ew?"mt-2":""}`,children:(0,r.jsxs)("div",{className:"border border-brand/40 rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-border bg-brand/10",children:[(0,r.jsx)("span",{className:"text-sm",children:"\uD83D\uDCCB"}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:B("chat.planTitle",{defaultValue:"Plan (awaiting your review)"})})]}),(0,r.jsx)("div",{className:"px-3 py-2",children:(0,r.jsx)(_.T,{content:ej,isUser:!1})}),R&&(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:B("chat.planApproveHint",{defaultValue:"本环境无审批弹窗,点此退出 Plan 并执行"})}),(0,r.jsxs)("button",{onClick:()=>R(),disabled:M,className:"flex items-center gap-1.5 px-3 py-1 rounded-md bg-brand text-white text-xs font-medium hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex-shrink-0",children:[(0,r.jsx)("span",{children:"✓"}),(0,r.jsx)("span",{children:B("chat.approvePlan",{defaultValue:"批准并执行"})})]})]})]})}),eS.length>0&&(0,r.jsx)("div",{className:`${e.content||el||ew?"mt-2":""}`,children:(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden px-3 py-2 space-y-0.5",children:eS.map(e=>(0,r.jsxs)("button",{disabled:F,onClick:()=>eI({path:e,source:"tool"}),className:"flex items-center gap-1.5 w-full text-left rounded px-1 py-0.5 group/md transition-colors enabled:hover:bg-hover disabled:cursor-default",children:[(0,q.u)(e)?(0,r.jsxs)("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,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v14a1 1 0 01-1 1H5a1 1 0 01-1-1V5z"}),(0,r.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4-4 3 3 4-4 5 5"})]}):(0,q.Zy)(e)?(0,r.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,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm0 4h16M10 10v10"})}):(0,q.aR)(e)?(0,r.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,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}):(0,r.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,r.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,r.jsx)("span",{className:"text-xs text-muted-foreground group-hover/md:text-foreground truncate",children:e.split("/").pop()})]},e))})}),eT.length>0&&(0,r.jsx)("div",{className:`${e.content||el||ew||eS.length>0?"mt-2":""}`,children:(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,r.jsxs)("table",{className:"w-full text-xs",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border text-muted-foreground",children:[(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium w-[60px]",children:"Tool"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Previous"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Action"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Expect"})]})}),(0,r.jsx)("tbody",{children:eT.map((e,t)=>(0,r.jsxs)("tr",{className:t<eT.length-1?"border-b border-border/50":"",children:[(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground font-mono",children:e.toolName}),(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:e.previous||"—"}),(0,r.jsx)("td",{className:"px-2 py-1 text-foreground",children:e.current}),(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:e.expect||"—"})]},t))})]})})}),eN.length>0&&(0,r.jsx)("div",{className:`${e.content||el?"mt-3":""}`,children:ei>0?(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsxs)("button",{onClick:()=>z(!W),className:"flex-1 px-3 py-1.5 flex items-center gap-2 text-left hover:bg-hover transition-colors active:bg-muted",children:[(0,r.jsx)("span",{className:"text-sm",children:"\uD83D\uDD27"}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:B("chat.toolCalls",{count:eN.length})}),(0,r.jsx)("span",{className:"ml-auto text-muted-foreground text-sm",children:W?B("chat.collapse"):B("chat.expand")})]}),!F&&eC.length>0&&(0,r.jsx)("button",{onClick:()=>J(!0),className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover transition-colors border-l border-line-1",title:B("chat.viewQuestions"),children:(0,r.jsx)(f.A,{className:"w-4 h-4"})}),!F&&(ep||ef)&&(0,r.jsx)("button",{onClick:()=>{I&&e.toolCalls?I(e.id,e.toolCalls,t,n??void 0):G(!0)},className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover transition-colors border-l border-line-1",title:B("chat.viewAllFileChanges"),children:(0,r.jsx)(g.A,{className:"w-4 h-4"})})]}),W&&(0,r.jsx)("div",{className:"border-t border-line-1",children:eN.map((e,s)=>(0,r.jsx)(eo,{toolCall:e,cwd:t,sessionId:n,disableOverlays:F,siblings:eN,index:s},`${e.id}-${s}`))})]}):eN.map((e,s)=>(0,r.jsx)(eo,{toolCall:e,cwd:t,sessionId:n,disableOverlays:F,siblings:eN,index:s},`${e.id}-${s}`))})]})}),(eY||e.content||ed||ec)&&(0,r.jsxs)("div",{className:`flex items-center gap-1 mt-0.5 px-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity ${ea?"flex-row-reverse":""}`,children:[e.content&&(0,r.jsx)("button",{onClick:()=>{if(e.content){let t=em?em.body:e.content;navigator.clipboard.writeText(ea?(0,eO.Wn)(t):t),(0,o.oR)(B("toast.copiedMessage"))}},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:B("chat.copyMessage"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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"})})}),ed&&(0,r.jsxs)("div",{ref:er,className:"relative",children:[(0,r.jsxs)("button",{ref:es,type:"button",onClick:()=>ee(e=>!e),className:"flex items-center gap-1 rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-hover hover:text-foreground","aria-expanded":X,title:B("chat.newSession"),children:[(0,r.jsx)(x.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:B("chat.newSession")}),(0,r.jsx)(u.A,{className:`h-3 w-3 transition-transform ${X?"rotate-180":""}`})]}),X&&(0,r.jsxs)("div",{role:"group","aria-label":B("chat.newSession"),className:`absolute bottom-full z-50 mb-1 w-56 overflow-hidden rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-lv2 ${ea?"right-0":"left-0"}`,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{ed&&(ee(!1),i(e.id,"prefix"))},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-hover focus-visible:bg-hover focus-visible:outline-none",children:[(0,r.jsx)(x.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block text-xs font-medium",children:B("chat.continueFromHere")}),(0,r.jsx)("span",{className:"mt-0.5 block text-[11px] leading-4 text-muted-foreground",children:B("chat.continueFromHereDesc")})]})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{ed&&(ee(!1),i(e.id,"single"))},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-hover focus-visible:bg-hover focus-visible:outline-none",children:[(0,r.jsx)(b.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block text-xs font-medium",children:B("chat.onlyThisTurn")}),(0,r.jsx)("span",{className:"mt-0.5 block text-[11px] leading-4 text-muted-foreground",children:(e.turnUserCount??0)>1?B("chat.onlyThisTaskDesc",{count:e.turnUserCount}):B("chat.onlyThisTurnDesc")})]})]})]})]}),ec&&(0,r.jsxs)("button",{type:"button",onClick:eK,disabled:M||et,className:"flex items-center gap-1 rounded px-1.5 py-1 text-[11px] text-muted-foreground hover:bg-red-3 hover:text-red-11 disabled:cursor-not-allowed disabled:opacity-40",title:M?B("chat.deleteTurnWhileRunning"):B("chat.deleteTurn"),children:[(0,r.jsx)(v.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:et?B("chat.deletingTurn"):B("chat.deleteTurn")})]}),eJ&&(0,r.jsx)("button",{onClick:()=>{eJ&&T(e.content)},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:B("chat.sendToPeerPane"),children:"right"===E?(0,r.jsx)(y.A,{className:"w-4 h-4"}):(0,r.jsx)(w.A,{className:"w-4 h-4"})}),eY&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground mx-1",children:eY})]})]}),V&&(0,r.jsx)(eV,{image:V,onClose:()=>U(null)}),K&&e.toolCalls&&(0,r.jsx)(ex.zB,{toolCalls:e.toolCalls,cwd:t,sessionId:n??void 0,onClose:()=>G(!1),onContentSearch:L}),Q&&eC.length>0&&(0,r.jsx)(eg,{toolCalls:eC,onClose:()=>J(!1)}),eA&&"image"===e$&&(0,r.jsx)(eU,{filePath:eA,cwd:t,sessionId:n,onClose:ez},`${t}:${n}:${eA}`),eA&&"image"!==e$&&null!==eH&&("html"===e$?(0,r.jsx)(ey.N,{filePath:eA,content:eH,cwd:t,onClose:ez,onContentSearch:L}):"csv"===e$?(0,r.jsx)(ek,{filePath:eA,content:eH,onClose:ez}):"markdown"===e$?(0,r.jsx)(eL.x,{filePath:eA,content:eH,cwd:t||"",onClose:ez}):(0,r.jsx)(eF,{filePath:eA,content:eH,onClose:ez}))]})})},33442:(e,t,n)=>{n.d(t,{_:()=>s,a:()=>o});let r=(0,n(93964).N)("cockpit-bots",["/api/bots","/api/session-bots"]),s=r.notify,o=r.subscribe},34075:(e,t,n)=>{n.d(t,{dj:()=>l,lJ:()=>u,oR:()=>h,tE:()=>i});var r=n(95155),s=n(12115),o=n(69809);let a=(0,s.createContext)(null);function l(){let e=(0,s.useContext)(a);if(!e)throw Error("useToast must be used within a ToastProvider");return e}function i({children:e}){let[t,n]=(0,s.useState)([]),o=(0,s.useCallback)((e,t="success")=>{let r=`toast-${Date.now()}`;n(n=>[...n,{id:r,message:e,type:t}])},[]),l=(0,s.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return(0,r.jsxs)(a.Provider,{value:{showToast:o},children:[e,(0,r.jsx)(d,{toasts:t,onRemove:l})]})}function d({toasts:e,onRemove:t}){return(0,r.jsx)("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-[100] flex flex-col items-center gap-2 max-w-[26rem]",children:e.map(e=>(0,r.jsx)(c,{toast:e,onRemove:t},e.id))})}function c({toast:e,onRemove:t}){(0,s.useEffect)(()=>{let n=setTimeout(()=>{t(e.id)},3e3);return()=>clearTimeout(n)},[e.id,t]);let n={success:"bg-green-9",error:"bg-red-9",info:"bg-brand"}[e.type],o={success:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),error:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),info:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}[e.type];return(0,r.jsxs)("div",{className:`${n} text-white px-4 py-3 rounded-lg shadow-lv2 flex items-center gap-3 min-w-[200px] animate-slide-in`,style:{animation:"slideIn 0.3s ease-out"},children:[o,(0,r.jsx)("span",{className:"text-sm",children:e.message}),(0,r.jsx)("button",{onClick:()=>t(e.id),className:"ml-auto p-1 hover:bg-white/20 rounded transition-colors",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}function u(e,t){let{title:n=o.A.t("confirm.title",{defaultValue:"Confirm"}),confirmText:r=o.A.t("confirm.ok",{defaultValue:"OK"}),cancelText:s=o.A.t("confirm.cancel",{defaultValue:"Cancel"}),danger:a=!1}=t||{};return new Promise(t=>{let o=document.createElement("div");o.className="fixed inset-0 z-[200] flex items-center justify-center",o.style.animation="confirmFadeIn 0.15s ease-out";let l=e=>{o.style.animation="confirmFadeOut 0.12s ease-in",o.addEventListener("animationend",()=>{document.body.removeChild(o),t(e)},{once:!0})};o.addEventListener("mousedown",e=>{e.target===o&&l(!1)});let i=e=>{"Escape"===e.key?(e.stopPropagation(),document.removeEventListener("keydown",i,!0),l(!1)):"Enter"===e.key&&(e.stopPropagation(),document.removeEventListener("keydown",i,!0),l(!0))};document.addEventListener("keydown",i,!0),o.innerHTML=`
|
|
12
12
|
<div class="fixed inset-0 bg-scrim"></div>
|
|
13
13
|
<div class="relative bg-card border border-border rounded-xl shadow-lv3 p-6 max-w-sm w-full mx-4" style="animation: confirmScaleIn 0.15s ease-out">
|
|
14
14
|
<div class="text-base font-medium text-foreground mb-2">${n}</div>
|
|
@@ -723,11 +723,11 @@ ${t}`:e+t:t:e}function s(e,t,n=!1){let r=e||[];if(!t)return r;let o=r[r.length-1
|
|
|
723
723
|
try { if (ws) ws.close(); } catch (e) {}
|
|
724
724
|
});
|
|
725
725
|
})();
|
|
726
|
-
`;function o(e){return/^([/\\]|[A-Za-z]:)/.test(e)}function a(e){return o(e)||(0,r.P)(e)}function l(e,t){let n=e.replace(/[/\\]+$/,"");return t?`${n}/${t}`:n}function i(e,t){let n,r=(n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")))<0?"":0===n?"/":e.slice(0,n);return a(e)?r:t?l(t,r):r}function d(e,t){return a(e)||!!t}let c="/apps/local/",u="/apps/builtin/";function m(e){return e.trim().replace(/^\u200e+/,"").trim()}function h(e,t){let n=m(e);return c+p(a(n)?n:l(t??"",n)).replace(/\\/g,"/").split("/").map(encodeURIComponent).join("/").replace(/^\//,"")}function p(e){let t=/^[A-Za-z]:/.exec(e)?.[0]??"",n=t?e.slice(t.length):e,r=/^[/\\]/.test(n),s=[];for(let e of n.split(/[/\\]/))if(e&&"."!==e){if(".."===e){s.length&&".."!==s[s.length-1]?s.pop():r||t||s.push("..");continue}s.push(e)}return t+(r||t?"/":"")+s.join("/")}let f=/^([a-z][a-z0-9+.-]*:|\/\/|\/)/i;function g(e,t,n){let r=e.trim();if(!r||f.test(r)||!d(t,n))return e;let s=o(t)?t:l(n,t),a=r.search(/[?#]/),i=a<0?r:r.slice(0,a),c=a<0?"":r.slice(a);if(!i)return e;let u=i;try{u=decodeURIComponent(i)}catch{}return h(p(l(s,u)))+c}let x=[{chip:"*.md",exts:["md"]},{chip:"*.txt",exts:["txt"]},{chip:"*.png/jpg/gif/webp/svg",exts:["png","jpg","jpeg","gif","webp","svg"]},{chip:"*.pdf",exts:["pdf"]},{chip:"*.json",exts:["json"]},{chip:"*.csv",exts:["csv"]},{chip:"*.tsv",exts:["tsv"]}],b=RegExp(`\\.(${x.flatMap(e=>e.exts).join("|")})$`,"i"),v=x.map(e=>e.chip);function y(e){return b.test(e.trim())}function w(e,t){let n;return/\.html?$/i.test(m(e))?h(e,t):u+"file-viewer/index.html?file="+encodeURIComponent(p(a(n=m(e))?n:l(t??"",n)).replace(/\\/g,"/"))}function k(e,t){try{let n=new URL(e,t);if(!n.pathname.startsWith(u)&&!n.pathname.startsWith(c))return e;return"localhost"===n.hostname&&(n.hostname="127.0.0.1"),n.toString()}catch{return e}}function C(e,t){let n=e=>JSON.stringify(e).replace(/</g,"\\u003c"),r="<script>"+s.replaceAll("__CWD__",n(t.cwd)).replaceAll("__WS_URL__",n(t.wsUrl??""))+"<\/script>",o=e.match(/<head[^>]*>/i);if(o&&void 0!==o.index){let t=o.index+o[0].length;return e.slice(0,t)+r+e.slice(t)}let a=e.match(/<html[^>]*>/i);if(a&&void 0!==a.index){let t=a.index+a[0].length;return e.slice(0,t)+r+e.slice(t)}return r+e}},37614:(e,t,n)=>{n.d(t,{t:()=>a});var r=n(95155),s=n(12115),o=n(79114);function a({x:e,y:t,comment:n,container:l,onClose:i,onUpdateComment:d,onDeleteComment:c}){let{t:u}=(0,o.Bd)(),[m,h]=(0,s.useState)(!1),[p,f]=(0,s.useState)(n.content),g=(0,s.useRef)(null),[x,b]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(g.current&&l){let n=l.getBoundingClientRect(),r=g.current.getBoundingClientRect(),s=e-n.left,o=t-n.top;s+r.width>n.width-16&&(s=n.width-r.width-16),s<16&&(s=16),o+r.height>n.height-16&&(o=o-r.height-8),o<16&&(o=16),queueMicrotask(()=>b({x:s,y:o}))}},[e,t,l]),(0,s.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&i()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let v=async()=>{p.trim()&&(await d(n.id,p.trim()),h(!1))},y=async()=>{await c(n.id),i()};return(0,r.jsx)("div",{ref:g,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:x.x,top:x.y},children:(0,r.jsx)("div",{className:"p-3",children:m?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("textarea",{value:p,onChange:e=>f(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(),v()),"Escape"===e.key&&(h(!1),f(n.content))}}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{onClick:()=>{h(!1),f(n.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:u("common.cancel")}),(0,r.jsx)("button",{onClick:v,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:u("common.save")})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.content}),(0,r.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:u("comments.lineRange",{start:n.startLine,end:n.endLine})}),(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)("button",{onClick:()=>h(!0),className:"p-1 rounded hover:bg-hover text-muted-foreground",title:u("common.edit"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)("button",{onClick:y,className:"p-1 rounded hover:bg-hover text-muted-foreground hover:text-red-9",title:u("common.delete"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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"})})})]})]})]})})})}},37640:(e,t,n)=>{n.d(t,{B2:()=>a,oh:()=>l,zi:()=>o});var r=n(49433),s=n(82680);let o=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e,t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`HTTP ${n.status}`)}return await n.json()},catch:n=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),a=(e,t)=>o(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=(e,t)=>{if(e&&"object"==typeof e&&"_tag"in e&&"Fail"===e._tag&&"error"in e){let t=e.error?.cause;if(t instanceof Error)return t.message}return t}},38408:(e,t,n)=>{n.d(t,{Cv:()=>F,XO:()=>$});var r=n(95155),s=n(12115),o=n(79114),a=n(47650),l=n(86957),i=n(60938),d=n(51145),c=n(70188),u=n(7320),m=n(56978),h=n(17196),p=n(89109),f=n(37614),g=n(69809),x=n(64428),b=n(96497);function v({blame:e,onClick:t}){let{t:n}=(0,o.Bd)(),a=(0,s.useRef)(null),l=(0,s.useRef)(null),i=(0,x.F2)(),d=(0,s.useRef)(!1),c=(0,s.useRef)(!1),u=(0,s.useRef)(null),m=(0,s.useRef)(null),h=(0,s.useRef)(null),p=(0,s.useRef)(e);(0,s.useEffect)(()=>{p.current=e},[e]);let f=(0,s.useRef)(t);(0,s.useEffect)(()=>{f.current=t},[t]);let b=(0,s.useCallback)(()=>{let e,t=l.current,n=a.current;if(!t||!n)return;let r=n.getBoundingClientRect(),s=t.getBoundingClientRect(),o=i?.getBoundingClientRect(),d=o?.left??0,c=o?.top??0,u=o?.width??window.innerWidth,m=o?.height??window.innerHeight,h=r.left-d;h+s.width>u-8&&(h=u-s.width-8),h<8&&(h=8);let p=r.top-c,f=r.bottom-c;(e=p-s.height-4<0?f+4:p-s.height-4)+s.height>m-8&&(e=m-s.height-8),t.style.left=`${h}px`,t.style.top=`${e}px`},[i]),y=(0,s.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),m.current&&(clearTimeout(m.current),m.current=null),d.current=!1,c.current=!1,l.current&&(l.current.style.display="none"),h.current&&(document.removeEventListener("mousedown",h.current.down),document.removeEventListener("mouseup",h.current.up),h.current=null)},[]),w=(0,s.useCallback)(()=>{let e=l.current;if(!e||d.current)return;d.current=!0,e.style.left="-9999px",e.style.top="-9999px",e.style.display="block",requestAnimationFrame(()=>requestAnimationFrame(b));let t=0,n=0,r=e=>{t=e.clientX,n=e.clientY},s=e=>{if(!(Math.abs(e.clientX-t)>5||Math.abs(e.clientY-n)>5)){let t;t=e.target,l.current?.contains(t)||a.current?.contains(t)||y()}};document.addEventListener("mousedown",r),document.addEventListener("mouseup",s),h.current={down:r,up:s}},[b,y]),k=(0,s.useCallback)(()=>{if(u.current&&clearTimeout(u.current),m.current&&(clearTimeout(m.current),m.current=null),d.current)return;let e=window.getSelection();(!e||e.isCollapsed)&&(u.current=setTimeout(w,500))},[w]),C=(0,s.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),d.current&&(m.current=setTimeout(()=>{c.current||y()},200))},[y]),j=(0,s.useCallback)(()=>{c.current=!0,m.current&&(clearTimeout(m.current),m.current=null)},[]),N=(0,s.useCallback)(()=>{c.current=!1,y()},[y]),S=(0,s.useCallback)(e=>{e.stopPropagation();let t=window.getSelection();t&&t.toString().length>0&&l.current?.contains(t.anchorNode)||(f.current?.(p.current),y())},[y]);(0,s.useEffect)(()=>()=>y(),[y]);let T=e.message.split("\n")[0]||"",E=e.message.split("\n").slice(1).join("\n").trim();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{ref:a,className:"select-none text-xs text-muted-foreground/50 ml-6 cursor-default hover:text-muted-foreground/80",onMouseEnter:k,onMouseLeave:C,children:[e.author.split(" ")[0],", ",function(e){let t=g.A.t,n=Math.floor((Date.now()-1e3*e)/1e3);if(n<60)return t("common.justNow");let r=Math.floor(n/60);if(r<60)return t("common.minutesAgo",{count:r});let s=Math.floor(r/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 a=Math.floor(o/30);return a<12?t("common.monthsAgo",{count:a}):t("common.yearsAgo",{count:Math.floor(a/12)})}(e.time)," \xb7 ",T]}),(0,r.jsx)(x.ZL,{children:(0,r.jsxs)("div",{ref:l,className:"fixed z-[9999] bg-card border border-border rounded-lg shadow-lv3 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:j,onMouseLeave:N,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,r.jsx)("span",{className:"font-mono text-brand",children:e.hash}),(0,r.jsx)("span",{className:"text-muted-foreground",children:e.author}),(0,r.jsx)("span",{className:"text-muted-foreground/60",children:new Date(1e3*e.time).toLocaleString()})]}),(0,r.jsx)("div",{className:"font-medium",children:T}),E&&(0,r.jsx)("div",{className:"mt-1 text-muted-foreground",children:E}),(0,r.jsx)("div",{className:"mt-2 text-[11px] text-brand border-t border-border pt-2 cursor-pointer hover:underline",onClick:S,children:n("codeViewer.clickToViewDetails")})]})})]})}let y=[{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)"}],w=(0,s.memo)(function({virtualKey:e,lineNum:t,highlightedHtml:n,hasComments:a,firstComment:l,lineCommentsCount:i,isInRange:d,showLineNumbers:c,lineNumChars:u,commentsEnabled:m,virtualItemSize:h,virtualItemStart:p,onCommentBubbleClick:f,onCmdClick:g,onTokenHover:x,onTokenHoverLeave:y,flashLine:w,blameLine:k,showBlameInfo:C,blameAuthorColor:j,isBlameHovered:N,onBlameClick:S,onBlameMouseEnter:T,onBlameMouseLeave:E,inlineBlameData:R,onInlineBlameClick:M,isCursorLine:L,cursorCol:I}){let{t:A}=(0,o.Bd)(),P=(0,s.useMemo)(()=>L&&null!=I?function(e,t){let n=0,r=0;for(;r<e.length;){if("<"===e[r]){let t=e.indexOf(">",r);if(-1!==t){r=t+1;continue}}if(n===t){let t;if("&"===e[r]){let n=e.indexOf(";",r);t=-1!==n&&n-r<10?n+1:r+1}else t=r+1;let n=e.substring(r,t);return e.substring(0,r)+'<span class="vi-char-cursor">'+n+"</span>"+e.substring(t)}if("&"===e[r]){let t=e.indexOf(";",r);r=-1!==t&&t-r<10?t+1:r+1}else r++;n++}return e+'<span class="vi-char-cursor"> </span>'}(n,I):n,[n,L,I]),F=(0,s.useCallback)(e=>{if(!e.metaKey||!g)return;e.preventDefault(),e.stopPropagation();let n=e.currentTarget,r=(0,b.j)(e,n);window.getSelection()?.removeAllRanges(),g(t,r)},[t,g]),$=(0,s.useCallback)(e=>{if(!x)return;let n=(0,b.A)(e,e.currentTarget);n&&x(t,n.column,n.rect)},[t,x]),D=(0,s.useCallback)(()=>{k&&S&&S(k)},[k,S]),_=(0,s.useCallback)(e=>{k&&T&&T(k,e)},[k,T]);return(0,r.jsxs)("div",{"data-line":t,style:{position:"absolute",top:0,left:0,width:"100%",height:`${h}px`,transform:`translateY(${p}px)`,backgroundColor:N&&j?j.bg:void 0},className:`flex ${w===t?"flash-line":""} ${L?"vi-cursor-line":""} ${d?"bg-blue-9/20":a?"bg-amber-9/10":"hover:bg-hover"}`,children:[(0,r.jsxs)("div",{className:"flex shrink-0 sticky left-0 z-[2] bg-card",style:{backgroundImage:N&&j?`linear-gradient(${j.bg}, ${j.bg})`:void 0},children:[k&&j&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-1 flex-shrink-0",style:{backgroundColor:j.border}}),(0,r.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-hover",onMouseEnter:_,onMouseLeave:E,onClick:D,title:A("codeViewer.clickToViewCommit"),children:C?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"font-medium",style:{color:j.border},children:k.hash}),(0,r.jsx)("span",{className:"truncate flex-1",children:k.author.split(" ")[0]})]}):null})]}),c&&(0,r.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 ${d?"bg-blue-9/30 text-blue-11":"bg-card/50 text-foreground-subtle"}`,children:[m&&a&&l&&(0,r.jsx)("button",{onClick:e=>f(l,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:A("codeViewer.nComments",{count:i}),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.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"})})}),m&&!a&&(0,r.jsx)("span",{className:"w-4"}),(0,r.jsx)("span",{className:"text-right",style:{minWidth:`${u}ch`},children:t})]})]}),(0,r.jsxs)("span",{className:"flex-1 px-3 whitespace-pre select-text",onClick:F,onMouseOver:$,onMouseLeave:y,"data-code-content":!0,children:[(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:P}}),R&&(0,r.jsx)(v,{blame:R,onClick:M})]})]},e)});var k=n(64702),C=n(1058),j=n(90717),N=n(48347),S=n(27570);function T(e,t,n){let r,s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=0;for(;(r=s.nextNode())&&r!==t;)o+=r.textContent.length;return o+n}function E(e,t){let n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=t,o=null;for(;n=r.nextNode();){o=n;let e=n.textContent.length;if(s<=e)return{node:n,offset:s};s-=e}return o?{node:o,offset:o.textContent.length}:null}var R=n(82292),M=n(34075);let L="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function I(e){let t=window.getSelection();if(!t?.rangeCount)return null;let n=t.getRangeAt(0),r=n.startContainer;for(;r&&r.parentElement!==e;)r=r.parentElement;if(!r)return null;let s=Array.from(e.children).indexOf(r);if(s<0)return null;let o=document.createRange();return o.selectNodeContents(r),o.setEnd(n.startContainer,n.startOffset),{line:s,offset:o.toString().length}}function A(e,t){let n,r=e.children[t.line];if(!r)return;let s=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=t.offset;for(;n=s.nextNode();){let e=n.textContent?.length||0;if(o<=e){let e=window.getSelection(),t=document.createRange();t.setStart(n,o),t.collapse(!0),e?.removeAllRanges(),e?.addRange(t);return}o-=e}let a=window.getSelection(),l=document.createRange();l.selectNodeContents(r),l.collapse(!1),a?.removeAllRanges(),a?.addRange(l)}function P(e){return e.map(e=>`<div style="${L}">${e}</div>`).join("")}let F=(0,s.forwardRef)(function({content:e,filePath:t,showLineNumbers:n=!0,showSearch:x=!0,className:b="",cwd:v,enableComments:F=!1,scrollToLine:$=null,scrollToLineAlign:D="center",onScrollToLineComplete:_,highlightKeyword:B=null,visibleLineRef:O,onCmdClick:H,onTokenHover:V,onTokenHoverLeave:U,onTokenHoverCancel:W,blameLines:q,inlineBlameLines:z,onSelectCommit:K,editable:G=!1,initialMtime:Q,onEditorClose:J,onSaved:Y,onEditorStateChange:X,viMode:Z=!1,onContentMutate:ee,onEnterInsertMode:et,onViSave:en,viStateRef:er,initialCursorLine:es,initialCursorCol:eo,onInitialCursorSet:ea,onContentSearch:el},ei){let{t:ed}=(0,o.Bd)(),ec=(0,s.useRef)(e),eu=(0,s.useRef)(!1),[em,eh]=(0,s.useState)(!1),[ep,ef]=(0,s.useState)(!1),[eg,ex]=(0,s.useState)(()=>e.split("\n").length),eb=(0,s.useRef)(e.split("\n").length),[ev,ey]=(0,s.useState)({show:!1}),ew=(0,s.useRef)(null),ek=(0,s.useRef)(null),eC=(0,s.useRef)(Q),ej=(0,s.useRef)(null),eN=(0,s.useRef)(!1),eS=(0,s.useRef)(!1),{parentRef:eT,containerRef:eE,searchInputRef:eR,floatingToolbarRef:eM,suppressHoverRef:eL,bumpToolbarRef:eI,savedSelectionRef:eA,highlightedLines:eP,isMounted:eF,cmdHeld:e$,flashLine:eD,isSearchVisible:e_,searchQuery:eB,caseSensitive:eO,wholeWord:eH,currentMatchIndex:eV,viewingComment:eU,addCommentInput:eW,sendToAIInput:eq,aiBridge:ez,commentsEnabled:eK,updateComment:eG,deleteComment:eQ,lines:eJ,matches:eY,rowData:eX,virtualizer:eZ,commentsByEndLine:e0,linesWithComments:e1,setIsSearchVisible:e2,setSearchQuery:e5,setCaseSensitive:e4,setWholeWord:e3,setViewingComment:e8,setAddCommentInput:e6,setSendToAIInput:e9,goToNextMatch:e7,goToPrevMatch:te,handleSearchKeyDown:tt,handleCommentBubbleClick:tn,handleToolbarAddComment:tr,handleToolbarSendToAI:ts,handleToolbarExplain:to,handleToolbarSearch:ta,handleCommentSubmit:tl,handleSendToAISubmit:ti,handleCommentSendToAI:td,getHighlightedLineHtml:tc,suppressMatchScrollRef:tu,inlineBlameLineRef:tm,inlineBlameVersion:th}=function({content:e,filePath:t,showSearch:n=!0,cwd:r,enableComments:o=!1,scrollToLine:a=null,scrollToLineAlign:l="center",onScrollToLineComplete:i,visibleLineRef:d,onContentSearch:c}){let[u,p]=(0,s.useState)(!1),f=(0,s.useRef)(null),x=(0,s.useRef)(null),b=(0,s.useRef)(null),v=(0,N.r)();(0,s.useEffect)(()=>{p(!0)},[]);let[y,w]=(0,s.useState)(!1),[E,R]=(0,s.useState)(null),M=(0,s.useRef)(null),[L,I]=(0,s.useState)(!1),[A,P]=(0,s.useState)(""),[F,$]=(0,s.useState)(!1),[D,_]=(0,s.useState)(!1),[B,O]=(0,s.useState)(0),[H,V]=(0,s.useState)(0),U=(0,s.useRef)(!1),[W,q]=(0,s.useState)(null),z=(0,s.useRef)(!1),K=(0,s.useRef)(null),[G,Q]=(0,s.useState)(null),[J,Y]=(0,s.useState)(null),X=(0,s.useMemo)(()=>e.split("\n"),[e]),[Z,ee]=(0,s.useState)(null);(0,s.useEffect)(()=>{f.current!==Z&&ee(f.current)});let et=o&&!!r,{toolbarRef:en,bumpRef:er,clearToolbar:es}=(0,S.L)({enabled:et,container:Z,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,n=t?.closest("[data-line]");if(!n)return null;let r=parseInt(n.getAttribute("data-line")||"0",10);return!Number.isFinite(r)||r<=0?null:{start:r,end:r}},buildLineSnapshot:({start:e,end:t})=>X.slice(e-1,t).join("\n")}),eo=(0,s.useRef)(null),[ea,el]=(0,s.useState)(0),{comments:ei,addComment:ed,updateComment:ec,deleteComment:eu,refresh:em}=(0,C._)({cwd:r||"",filePath:t}),eh=(0,m.C)(X,t),ep=(0,s.useMemo)(()=>{let e=new Map;for(let t of ei){let n=t.endLine;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[ei]),ef=(0,s.useMemo)(()=>{let e=new Set;for(let t of ei)for(let n=t.startLine;n<=t.endLine;n++)e.add(n);return e},[ei]),eg=(0,s.useMemo)(()=>(0,h.Np)(X,A,F,D),[X,A,F,D]);(0,s.useEffect)(()=>{eg.length>0&&O(0)},[eg.length,A,F,D]);let ex=(0,s.useMemo)(()=>{let e=[];for(let t=0;t<X.length;t++)e.push({type:"code",lineIndex:t});return e},[X.length]),eb=(0,k.Te)({count:ex.length,getScrollElement:()=>f.current,estimateSize:()=>20,overscan:10});(0,s.useEffect)(()=>{if(!d)return;let e=f.current;if(!e)return;let t=()=>{if(!eb.range)return;let t=e.scrollTop;for(let e of eb.getVirtualItems())if(e.start>=t){let t=ex[e.index];t?.type==="code"&&(d.current=t.lineIndex+1);return}};return e.addEventListener("scroll",t,{passive:!0}),t(),()=>e.removeEventListener("scroll",t)},[d,ex]),(0,s.useEffect)(()=>{let e=e=>{"Meta"===e.key&&w(!0)},t=e=>{"Meta"===e.key&&w(!1)},n=()=>w(!1);return window.addEventListener("keydown",e),window.addEventListener("keyup",t),window.addEventListener("blur",n),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t),window.removeEventListener("blur",n)}},[]),(0,s.useEffect)(()=>{if(!n)return;let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),I(!0),setTimeout(()=>b.current?.focus(),0)),"Escape"===e.key&&!e.defaultPrevented){if(L)I(!1),P("");else if(J)Y(null);else if(G)Q(null);else if(en.current)es();else{if(!W)return;q(null)}e.preventDefault(),e.stopPropagation()}},t=x.current;if(t)return t.addEventListener("keydown",e),()=>t.removeEventListener("keydown",e)},[n,L,J,G,W]),(0,s.useEffect)(()=>{if(U.current){U.current=!1;return}if(eg.length>0&&B>=0&&B<eg.length){let e=eg[B],t=ex.findIndex(t=>"code"===t.type&&t.lineIndex===e.lineIndex);t>=0&&eb.scrollToIndex(t,{align:"center"})}},[B,eg,eb,ex,H]);let ev=(0,s.useCallback)(()=>{0!==eg.length&&(O(e=>(e+1)%eg.length),V(e=>e+1))},[eg.length]),ey=(0,s.useCallback)(()=>{0!==eg.length&&(O(e=>(e-1+eg.length)%eg.length),V(e=>e+1))},[eg.length]),ew=(0,s.useRef)(a);ew.current=a,(0,s.useEffect)(()=>{if(null!==ew.current&&ew.current>0&&ex.length>0){let e=ew.current,t=e-1,n=ex.findIndex(e=>"code"===e.type&&e.lineIndex===t);if(n>=0){let t=()=>{eb.scrollToIndex(n,{align:l}),"center"===l&&(M.current&&clearTimeout(M.current),R(null),requestAnimationFrame(()=>R(e)),M.current=setTimeout(()=>R(null),1600)),i?.()};"start"===l?requestAnimationFrame(t):setTimeout(t,150)}}},[a,l,ex.length,eb,i]);let ek=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?ey():ev()),"Escape"===e.key&&(I(!1),P(""))},[ev,ey]),eC=(0,s.useCallback)((e,t)=>{et&&(t.stopPropagation(),q({comment:e,x:t.clientX,y:t.clientY}),es(),Q(null),Y(null))},[et,es]);(0,s.useEffect)(()=>{if(!et)return;let e=f.current,t=!1,n=()=>{t=!0,K.current=null,z.current=!0},r=()=>{t=!1;let e=window.getSelection();if(!e||e.isCollapsed||!e.toString().trim()){z.current=!1;return}let n=e.getRangeAt(0),r=f.current;if(!r||!r.contains(n.commonAncestorContainer))return;let s=n.startContainer,o=n.endContainer,a=(s.nodeType===Node.TEXT_NODE?s.parentElement:s)?.closest("[data-line]"),l=(o.nodeType===Node.TEXT_NODE?o.parentElement:o)?.closest("[data-line]");if(!a||!l)return;let i=parseInt(a.getAttribute("data-line")||"0",10),d=parseInt(l.getAttribute("data-line")||"0",10);i&&d&&(z.current=!0,K.current={startLine:i,startOffset:T(a,n.startContainer,n.startOffset),endLine:d,endOffset:T(l,n.endContainer,n.endOffset)})},s=()=>{if(t)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||(K.current=null,z.current=!1)};return e?.addEventListener("mousedown",n),document.addEventListener("mouseup",r),document.addEventListener("selectionchange",s),()=>{e?.removeEventListener("mousedown",n),document.removeEventListener("mouseup",r),document.removeEventListener("selectionchange",s)}},[et]),(0,s.useEffect)(()=>{let e=f.current;if(!e)return;let t=t=>{let n,r;if(!e.contains(t.target)){if(t.target.closest?.("[data-inline-blame-tip]"))return;null!==eo.current&&(eo.current=null,el(e=>e+1));return}let s=window.getSelection();if(s&&!s.isCollapsed&&s.toString().trim())return;let o=(n=t.target,(r=n.closest?.("[data-line]"))?parseInt(r.getAttribute("data-line")||"0",10):null);o!==eo.current&&(eo.current=o,requestAnimationFrame(()=>el(e=>e+1)))};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]);let ej=(0,s.useCallback)(()=>{let e=en.current;e&&(Q({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),es())},[es,en]),eN=(0,s.useCallback)(()=>{let e=en.current;e&&(Y({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),es())},[es,en]),eS=(0,s.useCallback)(()=>{let e=en.current;e&&v&&(es(),(0,j.Ff)(v.sendMessage,{filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},g.A.t("explain.selectionMessage")))},[v,t,es,en]),eT=(0,s.useCallback)(()=>{let e=en.current;if(!e||!c)return;let t=e.selectedText.trim();es(),t&&c(t)},[c,es,en]),eE=(0,s.useCallback)(async e=>{G&&(await ed(G.range.start,G.range.end,e,G.selectedText),Q(null))},[G,ed]),eR=(0,s.useCallback)(async(e,n)=>{if(v&&r)try{let s=await (0,j.$3)(r),o=[];for(let e of s)o.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});o.push({filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot});let a=(0,j.Gw)(o,n);v.sendMessage(a),await (0,j.RP)(r),em()}catch(e){console.error("Failed to send to AI:",e)}},[v,t,r,em]),eM=(0,s.useCallback)(e=>{J&&eR(J,e)},[J,eR]),eL=(0,s.useCallback)(e=>{G&&eR(G,e)},[G,eR]),eI=(0,s.useCallback)((e,t,n)=>{let r=X[e];if(!r)return t;let s=[];if(A&&eg.length>0)for(let t of eg.filter(t=>t.lineIndex===e)){let n=eg[B]?.lineIndex===e&&eg[B]?.startCol===t.startCol;s.push({start:t.startCol,end:t.endCol,cls:n?"hl-cur":"hl-m"})}if(n&&!A&&n.length>=1){let e=n.toLowerCase(),t=r.toLowerCase(),o=0;for(;-1!==(o=t.indexOf(e,o));)s.push({start:o,end:o+n.length,cls:"hl-kw"}),o+=1}if(0===s.length)return t;if(s.sort((e,t)=>e.start-t.start||e.end-t.end),s.length>h.ZR){let e=s.findIndex(e=>"hl-cur"===e.cls),t=s.slice(0,h.ZR);e>=h.ZR&&(t[t.length-1]=s[e]),s=t}let o=[],a=0;for(let e of s){if(e.start<a)continue;e.start>a&&o.push((0,h.ZD)(r.substring(a,e.start)));let t=(0,h.ZD)(r.substring(e.start,e.end));o.push(`<span class="${e.cls}">${t}</span>`),a=e.end}if(a<r.length&&o.push((0,h.ZD)(r.substring(a))),t!==(0,h.ZD)(r)){let e=t;for(let t of s){let n=r.substring(t.start,t.end),s=(0,h.ZD)(n),o=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=RegExp(`(?<=>)([^<]*?)(${o})`,""),l=`$1<span class="${t.cls}">${s}</span>`,i=e.replace(a,l);i.length>e.length+200||(e=i)}return e}return o.join("")},[A,eg,B,X]);return{parentRef:f,containerRef:x,searchInputRef:b,floatingToolbarRef:en,suppressHoverRef:z,savedSelectionRef:K,highlightedLines:eh,isMounted:u,cmdHeld:y,flashLine:E,isSearchVisible:L,searchQuery:A,caseSensitive:F,wholeWord:D,currentMatchIndex:B,viewingComment:W,bumpToolbarRef:er,addCommentInput:G,sendToAIInput:J,aiBridge:v,commentsEnabled:et,comments:ei,updateComment:ec,deleteComment:eu,lines:X,matches:eg,rowData:ex,virtualizer:eb,commentsByEndLine:ep,linesWithComments:ef,setIsSearchVisible:I,setSearchQuery:P,suppressMatchScrollRef:U,setCaseSensitive:$,setWholeWord:_,setViewingComment:q,setAddCommentInput:Q,setSendToAIInput:Y,goToNextMatch:ev,goToPrevMatch:ey,handleSearchKeyDown:ek,handleCommentBubbleClick:eC,handleToolbarAddComment:ej,handleToolbarSendToAI:eN,handleToolbarExplain:eS,handleToolbarSearch:eT,handleCommentSubmit:eE,handleSendToAISubmit:eM,handleCommentSendToAI:eL,getHighlightedLineHtml:eI,inlineBlameLineRef:eo,inlineBlameVersion:ea}}({content:e,filePath:t,showSearch:x,cwd:v,enableComments:!G&&F,scrollToLine:G?null:$,scrollToLineAlign:G?"center":D,onScrollToLineComplete:G?void 0:_,visibleLineRef:G?void 0:O,onContentSearch:el}),tp=(0,c.iN)(),tf=(0,s.useRef)(null),tg=(0,s.useRef)(null),tx=(0,s.useRef)({line:0,col:0}),tb=(0,s.useRef)({line:0,col:0}),tv=function({lines:e,enabled:t,onContentChange:n,onEnterInsert:r,onSave:o,getVisibleLineCount:a,scrollToLine:l,onSearchExecute:i,onSearchNext:d,onSearchPrev:c,onSearchClear:u}){let[m,h]=(0,s.useState)("normal"),[p,f]=(0,s.useState)(-1),[g,x]=(0,s.useState)(0),[b,v]=(0,s.useState)(!1),[y,w]=(0,s.useState)(""),[k,C]=(0,s.useState)(""),[j,N]=(0,s.useState)(""),[S,T]=(0,s.useState)(""),E=(0,s.useRef)([]),R=(0,s.useRef)([]),M=(0,s.useRef)([]),L=(0,s.useRef)(null),I=(0,s.useRef)(e);(0,s.useEffect)(()=>{I.current=e}),(0,s.useEffect)(()=>{0!==e.length&&queueMicrotask(()=>f(t=>Math.min(t,e.length-1)))},[e.length]);let A=(0,s.useCallback)((e,t)=>Math.max(0,Math.min(t,Math.max(0,(I.current[e]??"").length-1))),[]),P=(0,s.useRef)(e.length);(0,s.useEffect)(()=>{let t=Math.abs(e.length-P.current);P.current=e.length,t>10&&(queueMicrotask(()=>{f(-1),x(0),v(!1)}),E.current=[],R.current=[],M.current=[])},[e]);let F=(0,s.useCallback)(()=>{L.current&&(clearTimeout(L.current),L.current=null),w("")},[]),$=(0,s.useCallback)(()=>{L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{w(""),L.current=null},500)},[]),D=(0,s.useCallback)((e,t)=>{E.current.push(t),R.current=[],v(!0),n(e.join("\n"))},[n]),_=(0,s.useCallback)((e,t)=>{let n=Math.max(0,Math.min(e,I.current.length-1));f(n),x(A(n,t??0)),l(n,"auto")},[l,A]),B=(0,s.useCallback)(e=>{f(t=>{let n=Math.max(0,Math.min(t+e,I.current.length-1));return l(n,"auto"),x(e=>Math.max(0,Math.min(e,Math.max(0,(I.current[n]??"").length-1)))),n})},[l]),O=(0,s.useCallback)(()=>{let e=I.current,t=Math.min(p,e.length-1);if(0===e.length)return;let n=e[t];M.current=[n];let r=[...e];r.splice(t,1),0===r.length&&r.push("");let s=Math.min(t,r.length-1);D(r,{lineIndex:t,oldLines:[n],newLines:[],cursorLine:t}),f(s),x(0)},[p,D]),H=(0,s.useCallback)(()=>{let e=I.current,t=Math.min(p,e.length-1);e.length>0&&(M.current=[e[t]])},[p]),V=(0,s.useCallback)(()=>{let e=M.current;if(0===e.length)return;let t=I.current,n=Math.min(p,t.length-1)+1,r=[...t];r.splice(n,0,...e),D(r,{lineIndex:n,oldLines:[],newLines:[...e],cursorLine:p}),f(n),x(0),l(n,"auto")},[p,D,l]),U=(0,s.useCallback)(()=>{let e=I.current,t=Math.min(p,e.length-1),n=e[t];if(!n||0===n.length)return;let r=n.substring(1),s=[...e];s[t]=r,D(s,{lineIndex:t,oldLines:[n],newLines:[r],cursorLine:p})},[p,D]),W=(0,s.useCallback)(()=>{let e=E.current;if(0===e.length)return;let t=e.pop(),r=[...I.current];0===t.newLines.length&&t.oldLines.length>0?r.splice(t.lineIndex,0,...t.oldLines):0===t.oldLines.length&&t.newLines.length>0?(r.splice(t.lineIndex,t.newLines.length),0===r.length&&r.push("")):r.splice(t.lineIndex,t.newLines.length,...t.oldLines),R.current.push(t),n(r.join("\n")),f(Math.min(t.cursorLine,r.length-1)),l(Math.min(t.cursorLine,r.length-1),"auto"),0===e.length&&v(!1)},[n,l]),q=(0,s.useCallback)(()=>{let e=R.current;if(0===e.length)return;let t=e.pop(),r=[...I.current];0===t.newLines.length&&t.oldLines.length>0?(r.splice(t.lineIndex,t.oldLines.length),0===r.length&&r.push("")):0===t.oldLines.length&&t.newLines.length>0?r.splice(t.lineIndex,0,...t.newLines):r.splice(t.lineIndex,t.oldLines.length,...t.newLines),E.current.push(t),v(!0),n(r.join("\n"));let s=t.lineIndex+Math.max(0,t.newLines.length-1);f(Math.min(s,r.length-1)),l(Math.min(s,r.length-1),"auto")},[n,l]),z=(0,s.useCallback)(e=>{let t=I.current,n=Math.min(p,t.length-1);if("o"===e||"O"===e){let r="o"===e?n+1:n,s=[...t];s.splice(r,0,""),D(s,{lineIndex:r,oldLines:[],newLines:[""],cursorLine:p}),n=r,f(r)}h("insert"),r(n,g,e)},[p,g,D,r]),K=(0,s.useCallback)(()=>{h("normal"),F()},[F]),G=(0,s.useCallback)(()=>{h("command"),C("")},[]),Q=(0,s.useCallback)(()=>{h("normal"),C("")},[]),J=(0,s.useCallback)(()=>{h("search"),N("")},[]),Y=(0,s.useCallback)(()=>{h("normal"),N("")},[]),X=(0,s.useCallback)(e=>{let t=e.trim();if("w"===t){o?.(),h("normal"),C("");return}if("q"===t){h("normal"),C("");return}if("wq"===t){o?.(),h("normal"),C("");return}if("noh"===t||"nohlsearch"===t){u?.(),h("normal"),C("");return}let n=parseInt(t,10);if(!isNaN(n)&&n>0){let e=Math.min(n-1,I.current.length-1);f(e),l(e,"center"),h("normal"),C("");return}h("normal"),C("")},[o,u,l]),Z=(0,s.useCallback)(e=>{if(!e){h("normal"),N("");return}T(e),i?.(e),h("normal"),N("")},[i]),ee=(0,s.useCallback)(e=>{if(!t)return!1;let n=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;if("insert"===m)return("Escape"===e.key||!!n)&&(K(),!0);if("command"===m)return!e.isComposing&&("Escape"===e.key||n?Q():"Enter"===e.key?X(k):"Backspace"===e.key?0===k.length?Q():C(e=>e.slice(0,-1)):1!==e.key.length||e.metaKey||e.ctrlKey||C(t=>t+e.key),!0);if("search"===m)return!e.isComposing&&("Escape"===e.key||n?Y():"Enter"===e.key?Z(j):"Backspace"===e.key?0===j.length?Y():N(e=>e.slice(0,-1)):1!==e.key.length||e.metaKey||e.ctrlKey||N(t=>t+e.key),!0);if(p<0&&(f(0),x(0)),e.metaKey)return!1;if(e.ctrlKey)return"d"===e.key?(B(Math.max(1,Math.floor(a()/2))),F(),!0):"u"===e.key?(B(-Math.max(1,Math.floor(a()/2))),F(),!0):"r"===e.key&&(q(),F(),!0);let r=e.key,s=y+r;if("g"===s)return w("g"),$(),!0;if("gg"===s)return _(0),F(),!0;if("d"===s)return w("d"),$(),!0;if("dd"===s)return O(),F(),!0;if("y"===s)return w("y"),$(),!0;if("yy"===s)return H(),F(),!0;if(y&&s!==r&&F(),"j"===r||"ArrowDown"===r)return B(1),!0;if("k"===r||"ArrowUp"===r)return B(-1),!0;if("h"===r||"ArrowLeft"===r)return x(e=>Math.max(0,e-1)),!0;if("l"===r||"ArrowRight"===r){let e=Math.max(0,(I.current[p]??"").length-1);return x(t=>Math.min(e,t+1)),!0}if("0"===r)return x(0),!0;if("$"===r)return x(Math.max(0,(I.current[p]??"").length-1)),!0;if("^"===r){let e=(I.current[p]??"").search(/\S/);return x(e>=0?e:0),!0}return"G"===r?(_(I.current.length-1),!0):"x"===r?(U(),!0):"p"===r?(V(),!0):"u"===r?(W(),!0):"i"===r||"a"===r||"I"===r||"A"===r||"o"===r||"O"===r?(z(r),!0):"/"===r?(J(),!0):"n"===r?(d?.(),!0):"N"===r?(c?.(),!0):":"===r?(G(),!0):"Escape"!==r&&1===r.length},[t,m,y,k,j,p,K,z,G,Q,J,Y,X,Z,B,_,a,O,H,V,U,W,q,F,$,d,c]);return{state:{mode:m,cursorLine:p,cursorCol:g,isDirty:b,keyBuffer:y,commandInput:k,searchInput:j,lastSearch:S},handleKeyDown:ee,enterNormal:K,enterInsert:z,setCursorLine:f,setCursorCol:x,setCommandInput:C,setSearchInput:N,setIsDirty:v,clearUndoHistory:(0,s.useCallback)(()=>{E.current=[],R.current=[]},[])}}({lines:eJ,enabled:Z&&!G,onContentChange:e=>{tx.current={line:tb.current.line,col:tb.current.col},ee?.(e)},onEnterInsert:(e,t,n)=>{let r=t;if("a"===n)r=t+1;else if("A"===n)r=(eJ[e]??"").length;else if("I"===n){let t=(eJ[e]??"").search(/\S/);r=t>=0?t:0}else("o"===n||"O"===n)&&(r=0);tx.current={line:e,col:r},et?.(e)},onSave:en,getVisibleLineCount:()=>{let e=eT.current;return e?Math.floor(e.clientHeight/20):20},scrollToLine:(e,t)=>{let n=eX.findIndex(t=>"code"===t.type&&t.lineIndex===e);n>=0&&eZ.scrollToIndex(n,{align:t||"auto"})},onSearchExecute:e=>{e5(e),e2(!1)},onSearchNext:e7,onSearchPrev:te,onSearchClear:()=>{e5("")}});(0,s.useEffect)(()=>{er&&(er.current={cursorLine:tv.state.cursorLine,cursorCol:tv.state.cursorCol}),tb.current={line:tv.state.cursorLine,col:tv.state.cursorCol}},[er,tv.state.cursorLine,tv.state.cursorCol]);let ty=(0,s.useRef)(null);(0,s.useEffect)(()=>{Z&&!G&&null!=es&&t&&ty.current!==t&&(ty.current=t,tv.setCursorLine(es-1),null!=eo&&tv.setCursorCol(eo-1),ea?.())},[Z,G,es,eo,t]),(0,s.useEffect)(()=>{if(!Z||G)return;let e=eE.current;if(!e)return;let t=e=>{let t=e.target;"TEXTAREA"===t.tagName||"INPUT"===t.tagName||t.isContentEditable||tv.handleKeyDown(e)&&(e.preventDefault(),e.stopPropagation())};return e.addEventListener("keydown",t,!0),()=>e.removeEventListener("keydown",t,!0)},[Z,G,tv.handleKeyDown]),(0,s.useEffect)(()=>{if(!Z||G)return;let e=eE.current;e&&"normal"===tv.state.mode&&requestAnimationFrame(()=>{let t=document.activeElement;t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName||t.isContentEditable)||e.focus()})},[Z,G,tv.state.mode,e]);let tw=(0,s.useCallback)(e=>{if(!Z||G)return;let t=e.target.closest("[data-line]");if(t){let n=parseInt(t.getAttribute("data-line"),10);if(!isNaN(n)){tv.setCursorLine(n-1);let r=t.querySelector("[data-code-content]");if(r){let t=document.caretRangeFromPoint(e.clientX,e.clientY);if(t&&r.contains(t.startContainer)){let e,s=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=0;for(;e=s.nextNode();){if(e===t.startContainer){o+=t.startOffset;break}o+=e.textContent?.length||0}let a=eJ[n-1]??"";tv.setCursorCol(Math.max(0,Math.min(o,Math.max(0,a.length-1))))}}}}let n=e.target;if("TEXTAREA"===n.tagName||"INPUT"===n.tagName||n.isContentEditable)return;let r=eE.current;r&&r.focus()},[Z,G,tv.setCursorLine,tv.setCursorCol,eJ]),tk=(0,s.useCallback)(e=>{Z&&!G&&requestAnimationFrame(()=>{let e=window.getSelection(),t=e?.toString().trim();t&&/^\S+$/.test(t)&&(tu.current=!0,e5(t))})},[Z,G,e5,tu]);(0,s.useEffect)(()=>{"command"===tv.state.mode?setTimeout(()=>tf.current?.focus(),0):"search"===tv.state.mode&&setTimeout(()=>tg.current?.focus(),0)},[tv.state.mode]),(0,s.useEffect)(()=>{let e=eT.current;if(!e)return;let t=()=>{(W??U)?.()};return e.addEventListener("mousedown",t),()=>e.removeEventListener("mousedown",t)},[W,U]),(0,s.useEffect)(()=>{eW||eq?(eL.current=!0,U?.()):eM.current||(eL.current=!1)},[eW,eq,U]),(0,s.useLayoutEffect)(()=>{let e=eA.current;if(!e)return;let t=window.getSelection();if(t&&!t.isCollapsed)return;let n=eT.current;if(!n)return;let r=n.querySelector(`[data-line="${e.startLine}"]`),s=n.querySelector(`[data-line="${e.endLine}"]`);if(!r||!s)return;let o=E(r,e.startOffset),a=E(s,e.endOffset);if(o&&a)try{let e=document.createRange();e.setStart(o.node,o.offset),e.setEnd(a.node,a.offset),t?.removeAllRanges(),t?.addRange(e)}catch{}});let tC=(0,s.useCallback)((e,t,n)=>{eL.current||V?.(e,t,n)},[V]),tj=(0,s.useCallback)((e,t)=>{eL.current||H?.(e,t)},[H]),tN=Math.max(4,String(G?eg:eJ.length).length),tS=(0,s.useMemo)(()=>{let e=0;for(let t of eJ){let n=0;for(let e=0;e<t.length;e++)" "===t[e]?n+=2-n%2:n+=1;n>e&&(e=n)}return e},[eJ]);(0,s.useEffect)(()=>{if(G){ec.current=e;let t=e.split("\n").length;eb.current=t,ex(t),eu.current=!1,eh(!1),ey({show:!1}),eC.current=Q}},[G,e,Q]),(0,s.useEffect)(()=>{if(!G)return;let t=ew.current;if(!t)return;let n=e.split("\n");t.innerHTML=P(n.map((e,t)=>eP[t]||(0,h.ZD)(e||" "))),requestAnimationFrame(()=>{let e,r;Z?(e=Math.max(0,Math.min(tx.current.line,n.length-1)),r=tx.current.col):(e=Math.max(0,Math.min((O?.current??1)-1,n.length-1)),r=0),t.focus(),A(t,{line:e,offset:r});let s=O?.current??1;ek.current&&(ek.current.scrollTop=(s-1)*20)})},[G]),(0,s.useEffect)(()=>{G&&X?.({isDirty:em,isSaving:ep})},[G,em,ep,X]);let tT=(0,s.useCallback)(()=>{let e=ew.current;if(!e)return ec.current;let t=[];for(let n of e.childNodes){let e=n.textContent||"";t.push(" "===e?"":e)}return t.join("\n")},[]),tE=(0,s.useCallback)(()=>{ej.current&&clearTimeout(ej.current),ej.current=setTimeout(async()=>{let e=ew.current;if(e&&!eS.current){ec.current=tT();try{let n=await (0,h.kS)(),r=(0,h.sQ)(t),s=document.documentElement.classList.contains("dark"),o=ec.current.split("\n"),a=n.codeToTokens(o.join("\n"),{lang:r,theme:s?"github-dark":"github-light"}).tokens.map(e=>(0,h.b8)(e)),l=I(e);eN.current=!0,e.innerHTML=P(a),eN.current=!1,l&&A(e,l)}catch{}}},300)},[t,tT]);(0,s.useEffect)(()=>{if(G)return()=>{ej.current&&clearTimeout(ej.current)}},[G]);let tR=(0,s.useCallback)(()=>{let e=ew.current;if(!e)return;eu.current||(eu.current=!0,eh(!0));let t=e.children.length;t!==eb.current&&(eb.current=t,ex(t))},[]),tM=(0,s.useCallback)(()=>{eN.current||eS.current||(tR(),tE())},[tR,tE]),tL=(0,s.useCallback)(e=>{if(!e.nativeEvent.isComposing&&("Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," ")),"Enter"===e.key)){e.preventDefault();let t=ew.current;if(!t)return;let n=window.getSelection();if(!n?.rangeCount)return;let r=n.getRangeAt(0);r.deleteContents();let s=r.startContainer;for(;s&&s.parentElement!==t;)s=s.parentElement;if(!s||!(s instanceof HTMLElement))return;let o=I(t),a=Array.from(t.children).indexOf(s),l=s.textContent||"",i=o?.offset??l.length,d=l.substring(0,i),c=l.substring(i);s.innerHTML=(0,h.ZD)(d||" ");let u=document.createElement("div");u.setAttribute("style",L),u.innerHTML=(0,h.ZD)(c||" "),s.after(u),A(t,{line:a+1,offset:0}),tR(),tE()}},[tR,tE]),tI=(0,s.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)},[]),tA=(0,s.useCallback)(async(e=!1)=>{if(!v)return;ec.current=tT(),ef(!0);let n=await l.t4.runPromiseExit((0,i.OJ)({cwd:v,path:t,content:ec.current,expectedMtime:e?void 0:eC.current}));if("Failure"===n._tag){console.error("Error saving file:",n.cause),(0,M.oR)(ed("toast.saveFailed"),"error"),ef(!1);return}let r=n.value,s=r.data;if(409===r.status&&s?.conflict){let e=await l.t4.runPromiseExit((0,d.K)(v,t));"Success"===e._tag&&e.value.ok&&"string"==typeof e.value.data?.content?ey({show:!0,diskContent:e.value.data.content}):ey({show:!0}),ef(!1);return}if(!r.ok){console.error("Error saving file: status",r.status),(0,M.oR)(ed("toast.saveFailed"),"error"),ef(!1);return}let o=s?.mtime;o&&(eC.current=o),eu.current=!1,eh(!1),ey({show:!1}),(0,M.oR)(ed("toast.savedSuccess"),"success"),Y?.(),ef(!1)},[v,t,tT,Y,ed]),tP=(0,s.useCallback)(async()=>{em&&!ep&&await tA(!1)},[em,ep,tA]),tF=(0,s.useCallback)(async()=>{ey({show:!1}),await tA(!0)},[tA]),t$=(0,s.useCallback)(()=>{if(void 0!==ev.diskContent){ec.current=ev.diskContent;let t=ev.diskContent.split("\n").length;eb.current=t,ex(t);let n=ev.diskContent!==e;eu.current=n,eh(n);let r=ew.current;r&&(r.innerHTML=P(ev.diskContent.split("\n").map(e=>(0,h.ZD)(e||" "))),tE())}ey({show:!1}),Y?.()},[ev.diskContent,e,Y,tE]),tD=(0,s.useCallback)(()=>{let e=ek.current;return e?Math.floor(e.scrollTop/20)+1:O?.current??1},[O]),t_=(0,s.useCallback)(async()=>{(!em||await (0,M.lJ)(ed("codeViewer.unsavedConfirm"),{danger:!0,confirmText:ed("codeViewer.discardChanges"),cancelText:ed("codeViewer.continueEditing")}))&&J?.(tD())},[em,J,tD]);(0,s.useEffect)(()=>{if(!G)return;let e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&(e.preventDefault(),tP())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[G,tP]);let tB=(0,s.useCallback)(()=>{let e=tT();ee?.(e);let t=ew.current,n=t?I(t):null,r=tD();if(tv.enterNormal(),n){tv.setCursorLine(n.line);let t=e.split("\n")[n.line]??"";tv.setCursorCol(Math.max(0,Math.min(n.offset,Math.max(0,t.length-1))))}else tv.setCursorLine(Math.max(0,r-1));J?.(r)},[tT,ee,tD,J,tv]);(0,s.useEffect)(()=>{if(!G)return;let e=e=>{let t="Escape"===e.key,n=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;(t||Z&&n)&&(e.preventDefault(),e.stopPropagation(),Z?eu.current?(0,M.lJ)(ed("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:ed("codeViewer.discardChanges"),cancelText:ed("codeViewer.continueEditing")}).then(e=>{e&&tB()}):tB():t_())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[G,Z,t_,tB]);let tO=(0,s.useCallback)(()=>{eu.current||(eu.current=!0,eh(!0))},[]);(0,s.useImperativeHandle)(ei,()=>({save:tP,close:t_,markDirty:tO,get isDirty(){return eu.current},get isSaving(){return ep}}),[tP,t_,tO,ep]);let tH=!!(q&&q.length>0),tV=(0,s.useMemo)(()=>{if(!q)return new Map;let e=[...new Set(q.map(e=>e.author))],t=new Map;return e.forEach((e,n)=>{t.set(e,y[n%y.length])}),t},[q]),[tU,tW]=(0,s.useState)(null),[tq,tz]=(0,s.useState)(null);(0,s.useEffect)(()=>{tW(null),tz(null)},[q]);let tK=(0,s.useCallback)((e,t)=>{tW(e.author);let n=t.currentTarget.getBoundingClientRect();tz({line:e,x:n.right+8,y:n.top})},[]),tG=(0,s.useCallback)(()=>{tW(null),tz(null)},[]),tQ=(0,s.useCallback)(e=>{K&&(K({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}),tz(null))},[K]),tJ=`${tN+2}ch`;return(0,r.jsxs)("div",{ref:eE,className:`h-full flex flex-col outline-none ${b}`,tabIndex:0,onClick:tw,onDoubleClick:tk,children:[G&&ev.show&&(0,r.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,r.jsx)("svg",{className:"w-5 h-5 text-amber-11 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)("span",{className:"text-sm text-foreground flex-1",children:ed("codeViewer.fileModifiedExternally")}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:t$,className:"px-3 py-1 text-sm rounded border border-border hover:bg-hover transition-colors",children:ed("codeViewer.useDiskVersion")}),(0,r.jsx)("button",{onClick:tF,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:ed("codeViewer.forceOverwrite")})]})]}),!G&&x&&e_&&(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,r.jsx)("input",{ref:eR,type:"text",value:eB,onChange:e=>e5(e.target.value),onKeyDown:tt,placeholder:ed("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,r.jsx)("button",{onClick:()=>e4(!eO),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${eO?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-hover"}`,title:ed("codeViewer.caseSensitive"),children:"Aa"}),(0,r.jsx)("button",{onClick:()=>e3(!eH),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${eH?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-hover"}`,title:ed("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:eY.length>0?`${eV+1}/${eY.length}`:ed("common.noMatch")}),(0,r.jsx)("button",{onClick:te,disabled:0===eY.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ed("common.previous"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,r.jsx)("button",{onClick:e7,disabled:0===eY.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ed("common.next"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("button",{onClick:()=>{e2(!1),e5("")},className:"p-1 rounded hover:bg-hover",title:ed("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),G?(0,r.jsx)("div",{ref:ek,className:"flex-1 overflow-auto bg-card",children:(0,r.jsxs)("div",{className:"flex",style:{minHeight:"100%"},children:[(0,r.jsx)("div",{className:"flex-shrink-0 font-mono text-sm select-none sticky left-0 z-[2] bg-card",style:{width:tJ},children:Array.from({length:eg},(e,t)=>(0,r.jsx)("div",{className:"text-right text-muted-foreground/50 pr-3",style:{height:20,lineHeight:"20px"},children:t+1},t))}),(0,r.jsx)("div",{ref:ew,contentEditable:!0,suppressContentEditableWarning:!0,onInput:tM,onKeyDown:tL,onPaste:tI,onCompositionStart:()=>{eS.current=!0},onCompositionEnd:()=>{eS.current=!1,tM()},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",className:"flex-1 font-mono text-sm outline-none",style:{caretColor:"var(--foreground)",tabSize:2}})]})}):(0,r.jsx)("div",{ref:eT,className:`flex-1 overflow-auto font-mono text-sm bg-card${e$?" cmd-held-container":""}`,children:(0,r.jsx)("div",{style:{height:`${eZ.getTotalSize()}px`,minWidth:"100%",width:tH?`calc(${tN+tS+10}ch + 13rem)`:`${tN+tS+10}ch`,position:"relative"},children:eZ.getVirtualItems().map(e=>{let t=eX[e.index];if("code"!==t.type)return null;let s=t.lineIndex,o=s+1,a=eP[s]||(0,h.ZD)(eJ[s]||""),l=tc(s,a,B),i=e1.has(o),d=e0.get(o),c=d?.[0],u=!!(eW&&o>=eW.range.start&&o<=eW.range.end),m=th>=0?tm.current:null,p=!G&&z&&m===o?z[s]??null:null,f=tH?q[s]:void 0,g=tH&&s>0?q[s-1]:void 0,x=!!f&&(!g||g.hash!==f.hash),b=f?tV.get(f.author):void 0;return(0,r.jsx)(w,{virtualKey:e.key,lineNum:o,highlightedHtml:l,hasComments:i,firstComment:c,lineCommentsCount:d?.length,isInRange:u,showLineNumbers:n,lineNumChars:tN,commentsEnabled:eK,virtualItemSize:e.size,virtualItemStart:e.start,onCommentBubbleClick:tn,onCmdClick:tj,onTokenHover:tC,onTokenHoverLeave:U,flashLine:eD,blameLine:f,showBlameInfo:x,blameAuthorColor:b,isBlameHovered:!!(f&&tU===f.author),onBlameClick:tQ,onBlameMouseEnter:tK,onBlameMouseLeave:tG,inlineBlameData:p,onInlineBlameClick:tQ,isCursorLine:Z&&!G&&tv.state.cursorLine===s,cursorCol:Z&&!G&&tv.state.cursorLine===s?tv.state.cursorCol:void 0},e.key)})})}),Z&&(0,r.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"===tv.state.mode&&(0,r.jsx)("span",{className:"text-green-11 font-medium",children:"NORMAL"}),"insert"===tv.state.mode&&(0,r.jsx)("span",{className:"text-blue-11 font-medium",children:"INSERT"}),"command"===tv.state.mode&&(0,r.jsxs)("div",{className:"flex items-center flex-1",children:[(0,r.jsx)("span",{className:"text-foreground",children:":"}),(0,r.jsx)("input",{ref:tf,value:tv.state.commandInput,onChange:e=>tv.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(),tv.handleKeyDown(e.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),"search"===tv.state.mode&&(0,r.jsxs)("div",{className:"flex items-center flex-1",children:[(0,r.jsx)("span",{className:"text-foreground",children:"/"}),(0,r.jsx)("input",{ref:tg,value:tv.state.searchInput,onChange:e=>tv.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(),tv.handleKeyDown(e.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),tv.state.keyBuffer&&"normal"===tv.state.mode&&(0,r.jsx)("span",{className:"ml-2 text-muted-foreground",children:tv.state.keyBuffer}),tv.state.isDirty&&("normal"===tv.state.mode||"command"===tv.state.mode)&&(0,r.jsx)("span",{className:"ml-2 text-amber-11",children:"[+]"}),(0,r.jsxs)("span",{className:"ml-auto text-muted-foreground",children:[tv.state.cursorLine+1,":",tv.state.cursorCol+1]})]}),eF&&tp&&(0,a.createPortal)((0,r.jsxs)(r.Fragment,{children:[!G&&(0,r.jsx)(p.fS,{floatingToolbarRef:eM,bumpRef:eI,container:tp,onAddComment:tr,onSendToAI:ts,onSearch:el?ta:void 0,onExplain:ez?to:void 0,isChatLoading:ez?.isLoading}),!G&&eW&&(0,r.jsx)(u.t,{x:eW.x,y:eW.y,range:eW.range,filePath:t,lineSnapshot:eW.lineSnapshot,container:tp,onSubmit:tl,onSendToAI:ez?td:void 0,onClose:()=>e6(null),isChatLoading:ez?.isLoading}),!G&&eq&&(0,r.jsx)(u.G,{x:eq.x,y:eq.y,range:eq.range,filePath:t,lineSnapshot:eq.lineSnapshot,container:tp,onSubmit:ti,onClose:()=>e9(null),isChatLoading:ez?.isLoading}),!G&&eU&&(0,r.jsx)(f.t,{x:eU.x,y:eU.y,comment:eU.comment,container:tp,onClose:()=>e8(null),onUpdateComment:eG,onDeleteComment:eQ}),tq&&(0,r.jsxs)("div",{className:"fixed z-50 bg-card border border-border rounded-lg shadow-lv2 p-3 max-w-lg",style:{left:Math.min(tq.x,window.innerWidth-450),top:Math.max(8,Math.min(tq.y,window.innerHeight-200))},children:[(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"px-2 py-0.5 rounded text-xs font-mono font-medium text-white flex-shrink-0",style:{backgroundColor:tV.get(tq.line.author)?.border||"#666"},children:tq.line.hash}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:tq.line.author}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:tq.line.authorEmail})]})]}),(0,r.jsx)("div",{className:"mt-2 text-sm text-foreground whitespace-pre-wrap max-h-48 overflow-y-auto",children:tq.line.message}),(0,r.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground border-t border-border pt-2",children:[(0,R.fw)(tq.line.time)," \xb7 ",new Date(1e3*tq.line.time).toLocaleString(),(0,r.jsx)("span",{className:"ml-2 text-brand",children:ed("codeViewer.clickToViewDetails")})]})]})]}),tp)]})});function $({content:e,filePath:t,className:n=""}){let o=(0,s.useMemo)(()=>e.split("\n"),[e]),a=(0,m.C)(o,t),l=Math.max(4,String(o.length).length);return(0,r.jsx)("pre",{className:`overflow-auto text-sm font-mono bg-muted p-2 ${n}`,children:o.map((e,t)=>(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"text-foreground-subtle select-none pr-4 text-right",style:{minWidth:`${l+2}ch`},children:t+1}),(0,r.jsx)("span",{className:"flex-1",dangerouslySetInnerHTML:{__html:a[t]||(0,h.ZD)(e||" ")}})]},t))})}},38719:(e,t,n)=>{n.d(t,{M:()=>L});var r=n(95155),s=n(12115),o=n(83897),a=n(57125),l=n(49619);function i({bot:e}){return e?(0,r.jsx)("span",{className:"shrink-0 inline-flex items-center text-brand","data-tooltip":`@${e}`,"aria-label":`Bot session: @${e}`,role:"img",children:(0,r.jsx)(l.A,{className:"h-3.5 w-3.5"})}):null}var d=n(33199),c=n(79114);let u=(0,s.memo)(function({copy:e,onDismiss:t}){let{t:n}=(0,c.Bd)(),o=(0,s.useMemo)(()=>e.messages.map(e=>[`[${e.role}]`,e.content,e.systemEvent?.detail!==e.content?e.systemEvent?.detail:void 0,e.streamError&&!e.content.includes(e.streamError)?e.streamError:void 0,...(e.toolCalls??[]).map(e=>JSON.stringify(e,null,2))].filter(Boolean).join("\n")).join("\n\n"),[e.messages]),a=(0,s.useCallback)(()=>t?.(e.id),[t,e.id]);return(0,r.jsxs)("div",{className:"flex items-start gap-1 text-xs",children:[(0,r.jsxs)("details",{className:"min-w-0 flex-1","data-recovery-id":e.id,children:[(0,r.jsxs)("summary",{className:"cursor-pointer select-none text-muted-foreground hover:text-foreground",children:[n("chat.recoveryCopy")," \xb7 ",new Date(e.startedAt).toLocaleTimeString()]}),(0,r.jsx)("p",{className:"my-2 text-muted-foreground",children:n("chat.recoveryCopyHint")}),(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-words select-text",children:o}),e.messages.flatMap(e=>(e.images??[]).map((t,s)=>(0,r.jsx)("img",{src:`data:${t.media_type};base64,${t.data}`,alt:n("chat.recoveryAttachment"),className:"mt-2 max-h-40 max-w-full object-contain"},`${e.id}-${s}`)))]}),t&&(0,r.jsx)("button",{type:"button",onClick:a,"aria-label":n("common.close"),title:n("common.close"),className:"shrink-0 rounded px-1 leading-4 text-muted-foreground hover:bg-accent hover:text-foreground",children:"\xd7"})]})}),m=(0,s.memo)(function({copies:e,onDismiss:t}){let{t:n}=(0,c.Bd)();return e.length?(0,r.jsx)("aside",{"aria-label":n("chat.recoveryCopiesLabel"),className:"max-h-64 shrink-0 overflow-y-auto space-y-1 px-4 py-1 border-b border-border",children:e.map(e=>(0,r.jsx)(u,{copy:e,onDismiss:t},e.id))}):null});var h=n(1058),p=n(90717),f=n(89109),g=n(7320),x=n(86957),b=n(83448),v=n(62111),y=n(64428);let w=/[,,]/;function k({initialRows:e,lang:t,isCustomized:n,onSave:o,onRestoreDefault:a,onClose:l}){let{t:i}=(0,c.Bd)(),[d,u]=(0,s.useState)(()=>e.map(e=>e.join("zh"===t?",":", ")).join("\n"));(0,v.E)(l);let m=(0,s.useCallback)(()=>{o(d.split("\n").map(e=>e.split(w).map(e=>e.trim().slice(0,200)).filter(Boolean).slice(0,8)).filter(e=>e.length>0).slice(0,12)),l()},[d,o,l]),h=(0,s.useCallback)(()=>{a(),l()},[a,l]);return(0,r.jsx)(y.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim p-4",onClick:l,children:(0,r.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-lv3 w-full max-w-md flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-foreground",children:i("quickReply.editTitle")}),(0,r.jsx)("button",{onClick:l,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors","aria-label":i("quickReply.cancel"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsxs)("div",{className:"px-4 py-3 flex flex-col gap-2",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:i("quickReply.editHint")}),(0,r.jsx)("textarea",{autoFocus:!0,value:d,onChange:e=>u(e.target.value),placeholder:i("quickReply.editPlaceholder"),rows:6,spellCheck:!1,className:"w-full px-2 py-1.5 text-xs bg-background border border-border rounded text-foreground focus:outline-none focus:border-brand resize-y"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:i("quickReply.customizedFor",{lang:i("zh"===t?"quickReply.langZh":"quickReply.langEn")})})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-border",children:[(0,r.jsx)("button",{onClick:h,disabled:!n,className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:i("quickReply.restoreDefault")}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:l,className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-hover transition-colors",children:i("quickReply.cancel")}),(0,r.jsx)("button",{onClick:m,className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",children:i("quickReply.save")})]})]})]})})})}let C={mode:"follow",pinTop:null},j={mode:"free",pinTop:null};function N(e){return Math.max(0,e.scrollHeight-e.spacer)}function S(e){return Math.max(0,N(e)-e.clientHeight)}function T(e,t){return e<=0?0:Math.max(0,e+t.clientHeight-N(t))}function E(e){return N(e)-e.scrollTop-e.clientHeight<50}function R(e,t="auto"){return{owner:C,spacer:0,scrollTo:S(e),behavior:t}}function M({value:e}){let[t,n]=(0,s.useState)(e),o=(0,s.useRef)(e),a=(0,s.useRef)(null);return(0,s.useEffect)(()=>{null!==a.current&&(cancelAnimationFrame(a.current),a.current=null);let t=o.current;if(e<=t){o.current=e,n(e);return}let r=performance.now(),s=l=>{let i=Math.min(1,Math.ceil(12*Math.min(1,(l-r)/400))/12),d=Math.round(t+(e-t)*i);o.current=d,n(d),i<1?a.current=requestAnimationFrame(s):a.current=null};return a.current=requestAnimationFrame(s),()=>{null!==a.current&&cancelAnimationFrame(a.current),a.current=null}},[e]),(0,r.jsx)("span",{className:"tabular-nums",children:t})}let L=(0,s.forwardRef)(function({messages:e,recoveryCopies:t,onDismissRecoveryCopy:n,isLoading:l,cwd:u,sessionId:v,engine:y,botName:w,apiRetryInfo:N,backgroundTasks:L,liveOutputTokens:I,runningStartedAt:A,hasMoreHistory:P,isLoadingMore:F,onLoadMore:$,onFork:D,onDeleteTurn:_,onSendToPeer:B,peerSide:O,isActive:H=!0,snapshotsEnabled:V=H,onContentSearch:U,onShowFileDiff:W,onOpenFileLink:q,onApprovePlan:z,onShowUserMessages:K},G){let Q,{t:J,i18n:Y}=(0,c.Bd)(),X=(0,s.useRef)(null),Z=(0,s.useRef)(null),ee=(0,s.useRef)(null),et=(0,s.useRef)(null),en=(0,s.useRef)(null),er=(0,s.useRef)(null),[es,eo]=(0,s.useState)(null),ea=(0,s.useRef)({mode:"follow",pinTop:null}),el=(0,s.useRef)(null),ei=(0,s.useRef)(!1),ed=(0,s.useRef)(H),ec=(0,s.useCallback)(()=>{let e=ee.current;return e?{clientHeight:e.clientHeight,scrollHeight:e.scrollHeight,scrollTop:e.scrollTop,spacer:el.current?.offsetHeight??0}:null},[]),eu=(0,s.useRef)(null),em=(0,s.useCallback)(e=>{let t=ec();if(!t)return!1;let n=function(e,t,n){if(!(n.clientHeight>0))return null;switch(t.type){case"reset":return{owner:C,spacer:0,scrollTo:null,behavior:"auto"};case"toEnd":return R(n,"smooth");case"readFrom":{let e=t.top;return{owner:{mode:"reading",pinTop:e},spacer:T(e,n),scrollTo:e,behavior:"auto"}}case"settle":{if("reading"===e.mode){let t=e.pinTop??n.scrollTop;return{owner:e,spacer:T(t,n),scrollTo:null,behavior:"auto"}}if(n.spacer<=0)return null;let t=Math.min(n.scrollTop,S(n));return{owner:t>=S(n)?C:j,spacer:0,scrollTo:t,behavior:"smooth",deferSpacer:!0}}case"pin":{let e=T(t.top,n);if(e<=0)return R(n);return{owner:{mode:"pinned",pinTop:t.top},spacer:e,scrollTo:t.top,behavior:"smooth"}}case"jump":return{owner:j,spacer:T(n.scrollTop,n),scrollTo:null,behavior:"auto"};case"release":if("pinned"!==e.mode&&"reading"!==e.mode)return null;return{owner:j,spacer:T(n.scrollTop,n),scrollTo:null,behavior:"auto"};case"content":case"viewport":if("follow"===e.mode)return R(n);if("pinned"===e.mode){let r=e.pinTop??n.scrollTop,s=T(r,n);if(s<=0)return R(n);return{owner:e,spacer:s,scrollTo:"viewport"===t.type?r:null,behavior:"auto"}}if("reading"===e.mode){let r=e.pinTop??n.scrollTop;return{owner:e,spacer:T(r,n),scrollTo:"viewport"===t.type?r:null,behavior:"auto"}}return{owner:e,spacer:T(n.scrollTop,n),scrollTo:null,behavior:"auto"}}}(ea.current,e,t);if(!n)return!1;eu.current?.(),ea.current=n.owner;let r=()=>{el.current&&(el.current.style.height=`${n.spacer}px`)};n.deferSpacer||r();let s=ee.current;if(null!==n.scrollTo&&s?.scrollTo({top:n.scrollTo,behavior:n.behavior}),n.deferSpacer&&s){let e=()=>{n(),r()},t=setTimeout(e,700),n=()=>{clearTimeout(t),s.removeEventListener("scrollend",e),eu.current=null};s.addEventListener("scrollend",e,{once:!0}),eu.current=n}return!0},[ec]);(0,s.useEffect)(()=>()=>eu.current?.(),[]);let[eh,ep]=(0,s.useState)(!1),[ef,eg]=(0,s.useState)(!1),[ex,eb]=(0,s.useState)(null),[ev,ey]=(0,s.useState)(0);(0,s.useEffect)(()=>{eo(er.current)},[]),(0,s.useEffect)(()=>{if(!l||!A)return void ey(0);let e=()=>ey(Math.max(0,Math.floor((Date.now()-A)/1e3)));e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[l,A]);let ew=(0,s.useMemo)(()=>(0,a.ch)(y)?a.H[y]:a.H.claude,[y]),ek=(0,a.ch)(y)?y:"claude",eC=(0,s.useMemo)(()=>{let e=Math.floor(ev/60),t=ev%60;return e>0?`${e}m${t}s`:`${t}s`},[ev]),{isSearchVisible:ej,searchQuery:eN,setSearchQuery:eS,matches:eT,currentMatchIndex:eE,goToNextMatch:eR,goToPrevMatch:eM,closeSearch:eL,searchInputRef:eI,handleSearchKeyDown:eA}=function(e){let[t,n]=(0,s.useState)(!1),[r,o]=(0,s.useState)(""),[a,l]=(0,s.useState)([]),[i,d]=(0,s.useState)(0),c=(0,s.useRef)(null),u=(0,s.useRef)([]),m=(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]),h=(0,s.useCallback)(t=>{if(m(),!t||!e.current){l([]),d(0);return}let n=[],r=[],s=t.toLowerCase();e.current.querySelectorAll("[data-message-id]").forEach(e=>{let o,a=e.getAttribute("data-message-id")||"",l=0,i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),d=[];for(;o=i.nextNode();)d.push(o);for(let e of d){let o=(e.textContent||"").toLowerCase(),i=0,d=[];for(;;){let e=o.indexOf(s,i);if(-1===e)break;d.push({start:e,end:e+t.length}),i=e+1}if(0!==d.length)for(let t=d.length-1;t>=0;t--){let s=d[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),n.push({messageId:a,markIndex:l}),r.push(i),l++}}}),n.reverse(),r.reverse(),u.current=r,l(n),d(n.length>0?0:-1)},[e,m]);(0,s.useEffect)(()=>{queueMicrotask(()=>h(r))},[r,h]),(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,a]);let p=(0,s.useCallback)(()=>{0!==a.length&&d(e=>(e+1)%a.length)},[a.length]),f=(0,s.useCallback)(()=>{0!==a.length&&d(e=>(e-1+a.length)%a.length)},[a.length]),g=(0,s.useCallback)(()=>{n(!0),setTimeout(()=>c.current?.focus(),0)},[]),x=(0,s.useCallback)(()=>{n(!1),o(""),m(),l([]),d(0)},[m]),b=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?f():p()),"Escape"===e.key&&x()},[p,f,x]);return(0,s.useEffect)(()=>{let t=e.current;if(!t)return;let n=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),e.stopPropagation(),g())};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)},[e,g]),{isSearchVisible:t,searchQuery:r,setSearchQuery:o,matches:a,currentMatchIndex:i,goToNextMatch:p,goToPrevMatch:f,openSearch:g,closeSearch:x,searchInputRef:c,handleSearchKeyDown:b}}(er),eP=(0,o.nH)(),eF=(0,s.useRef)(null),e$=(0,s.useRef)(()=>{}),{addComment:eD,refresh:e_}=(0,h._)({cwd:u||"",filePath:p.Un}),[eB,eO]=(0,s.useState)(null),[eH,eV]=(0,s.useState)(null),eU=(0,s.useCallback)(e=>{if(eB||eH)return;let t=window.getSelection();if(!t||t.isCollapsed||!t.rangeCount){eF.current=null,e$.current();return}let n=t.toString().trim();if(!n){eF.current=null,e$.current();return}let r=t.anchorNode instanceof HTMLElement?t.anchorNode:t.anchorNode?.parentElement;if(r?.closest('[data-role="user"]')){eF.current=null,e$.current();return}eF.current={x:e.clientX,y:e.clientY,range:{start:0,end:0},selectedText:n,lineSnapshot:n},e$.current()},[eB,eH]),eW=(0,s.useCallback)(e=>{let t=e.target;!(t.closest(".floating-toolbar")||t.closest('[class*="z-[200]"]'))&&eF.current&&(eF.current=null,e$.current())},[]),eq=(0,s.useCallback)(()=>{let e=eF.current;e&&(eO({x:e.x,y:e.y,text:e.selectedText}),eF.current=null,e$.current(),window.getSelection()?.removeAllRanges())},[]),ez=(0,s.useCallback)(()=>{let e=eF.current;e&&(eV({x:e.x,y:e.y,text:e.selectedText}),eF.current=null,e$.current(),window.getSelection()?.removeAllRanges())},[]),eK=(0,s.useCallback)(()=>{let e=eF.current;e&&eP&&(eF.current=null,e$.current(),window.getSelection()?.removeAllRanges(),(0,p.Ff)(eP.sendMessage,{filePath:p.Un,startLine:0,endLine:0,codeContent:e.selectedText},J("explain.selectionMessage")))},[eP,J]),eG=(0,s.useCallback)(()=>{let e=eF.current;if(!e||!U)return;let t=e.selectedText.trim();eF.current=null,e$.current(),window.getSelection()?.removeAllRanges(),t&&U(t)},[U]),eQ=(0,s.useCallback)(async e=>{eB&&(await eD(0,0,e,eB.text),eO(null))},[eB,eD]),eJ=(0,s.useCallback)(async(e,t)=>{if(eP&&u)try{let n=(await (0,p.$3)(u)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));n.push({filePath:p.Un,startLine:0,endLine:0,codeContent:e});let r=(0,p.Gw)(n,t);eP.sendMessage(r),await (0,p.RP)(u),e_()}catch(e){console.error("Failed to send to AI:",e)}},[eP,u,e_]),eY=(0,s.useCallback)((e,t)=>{let n=eF.current;if(!n)return;let r=n.selectedText;eF.current=null,e$.current(),window.getSelection()?.removeAllRanges(),"comment"===e?eD(0,0,t,r):eJ(r,t)},[eD,eJ]),eX=(Q=Y.language,Q?.toLowerCase().startsWith("zh")?"zh":"en"),[eZ,e0]=(0,s.useState)(null),[e1,e2]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=!1;return x.t4.runPromiseExit((0,b.td)()).then(t=>{e||e0("Success"===t._tag?((e,t)=>{if(!e||"object"!=typeof e)return null;let n=e.quickReplies;return n&&"object"==typeof n?(e=>{if(!Array.isArray(e))return null;let t=[];for(let n of e.slice(0,12)){if(!Array.isArray(n))continue;let e=[];for(let t of n.slice(0,8)){if("string"!=typeof t)continue;let n=t.trim().slice(0,200);n&&e.push(n)}e.length&&t.push(e)}return t.length?t:null})(n[t]):null})(t.value,eX):null)}),()=>{e=!0}},[eX]);let e5=(0,s.useCallback)(e=>{x.t4.runPromiseExit((0,b.td)()).then(t=>{let n={..."Success"===t._tag?t.value.quickReplies??{}:{}};return e?n[eX]=e:delete n[eX],x.t4.runPromiseExit((0,b.em)({quickReplies:n})).then(t=>{"Success"===t._tag?e0(e):console.error("Failed to save quick replies:",t.cause)})})},[eX]),e4=(0,s.useCallback)(()=>{eF.current=null,e$.current(),window.getSelection()?.removeAllRanges(),e2(!0)},[]),e3=(0,s.useMemo)(()=>eZ??f.SZ.map(e=>e.map(e=>J(e))),[eZ,J]),e8=(0,s.useCallback)(e=>{eH&&eJ(eH.text,e)},[eH,eJ]),e6=(0,s.useCallback)(e=>{eB&&eJ(eB.text,e)},[eB,eJ]),e9=(0,s.useMemo)(()=>{let t=new Set;return e.filter(e=>!t.has(e.id)&&(t.add(e.id),"assistant"!==e.role||!!e.isStreaming||!!e.content||!!e.images?.length||!!e.toolCalls?.length||!!e.parts?.length))},[e]),e7=(0,s.useMemo)(()=>e9.filter(e=>"user"===e.role),[e9]),te=(0,s.useMemo)(()=>e7.slice(-10),[e7]),tt=P||e7.length>10,tn=(0,s.useRef)(0),tr=(0,s.useRef)(!1),ts=(0,s.useCallback)(()=>{let e=ee.current;return!e||e.scrollTop<50},[]),to=(0,s.useCallback)((e=!1)=>{let t=ee.current;if(!t)return;if(e&&te.length>0)return void eb(te[te.length-1].id);let n=t.getBoundingClientRect(),r=null,s=null;for(let e of te){let o=t.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);if(!o)continue;let a=o.getBoundingClientRect().top;!s&&a<n.bottom&&(s=e.id),a<=n.top+12&&(r=e.id)}eb(r??s)},[te]),ta=(0,s.useCallback)(()=>{let e=ec(),t=!e||E(e),n=ts();if(e&&(ea.current=function(e,t){return"pinned"===e.mode||"reading"===e.mode?e:50>Math.abs(t.scrollTop-S(t))?C:j}(ea.current,e)),ep(!n),eg(!t),to(t),n&&P&&!F&&$){let e=ee.current;e&&(tn.current=e.scrollHeight,tr.current=!0),$()}},[ts,ec,to,P,F,$]),tl=(0,s.useCallback)(()=>{em({type:"release"}),Z.current?.scrollIntoView({behavior:"smooth"})},[em]),ti=(0,s.useCallback)(()=>{em({type:"toEnd"})},[em]),td=(0,s.useCallback)(e=>{let t=ee.current;if(!t)return!1;let n=t.querySelector(`[data-message-id="${e}"]`);if(!n)return!1;let r=n.getBoundingClientRect().top-t.getBoundingClientRect().top;return t.scrollTo({top:t.scrollTop+r-8,behavior:"auto"}),em({type:"jump"}),et.current&&clearTimeout(et.current),en.current?.classList.remove("flash-turn"),n.classList.remove("flash-turn"),n.offsetWidth,n.classList.add("flash-turn"),en.current=n,et.current=setTimeout(()=>{n.classList.remove("flash-turn"),en.current=null,et.current=null},2e3),!0},[em]),tc=(0,s.useRef)(!1),tu=(0,s.useCallback)(()=>{tc.current=!0},[]);(0,s.useImperativeHandle)(G,()=>({scrollToMessage:td,pinNextUserMessage:tu}),[td,tu]),(0,s.useLayoutEffect)(()=>{let e;if(!tc.current)return;let t=ee.current;if(!t)return;for(let t=e9.length-1;t>=0;t-=1)if("user"===e9[t].role){e=e9[t];break}if(!e)return;let n=t.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);n&&(tc.current=!1,em({type:"pin",top:Math.max(0,n.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop-8)}))},[e9,em]),(0,s.useLayoutEffect)(()=>{let e=ed.current;ed.current=H,e&&!H&&l&&(ei.current=!0)},[H,l]),(0,s.useLayoutEffect)(()=>{tr.current||em({type:"content"})},[e,l,em]),(0,s.useEffect)(()=>{let e=ee.current;if(!e)return;let t=new ResizeObserver(()=>em({type:"viewport"}));return t.observe(e),()=>t.disconnect()},[em]),(0,s.useEffect)(()=>{let e=ee.current;if(!e)return;let t=()=>em({type:"release"});return e.addEventListener("wheel",t,{passive:!0}),e.addEventListener("touchmove",t,{passive:!0}),e.addEventListener("keydown",t),()=>{e.removeEventListener("wheel",t),e.removeEventListener("touchmove",t),e.removeEventListener("keydown",t)}},[em]);let tm=(0,s.useRef)(v);(0,s.useEffect)(()=>{let e=tm.current;tm.current=v,e&&e!==v&&(tc.current=!1,ei.current=!1,em({type:"reset"}))},[v,em]),(0,s.useLayoutEffect)(()=>{if(tr.current&&!F){let e=ee.current;if(e){let t=e.scrollHeight-tn.current;e.scrollTop=t,tr.current=!1}}},[e,F]);let th=(0,s.useRef)(l),tp=(0,s.useRef)(!1);return(0,s.useEffect)(()=>{let e=th.current;th.current=l,e&&!l&&(tp.current=!em({type:"settle"}))},[l,em]),(0,s.useLayoutEffect)(()=>{if(H){if(ei.current){let e=ee.current,t=e?.querySelectorAll('[data-role="user"]'),n=t?.item((t?.length??0)-1);if(e&&n&&em({type:"readFrom",top:Math.max(0,n.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop-8)})){ei.current=!1,tp.current=!1;return}}em({type:"viewport"}),tp.current&&(tp.current=!1,em({type:"settle"}))}},[H,em]),(0,s.useEffect)(()=>{if(!H)return;let e=ec();to(!!e&&E(e))},[e,H,ec,to]),(0,r.jsxs)("div",{ref:er,className:"relative flex-1 min-h-0 overflow-hidden flex flex-col outline-none",tabIndex:-1,onMouseUp:eU,onMouseDown:eW,children:[t&&(0,r.jsx)(m,{copies:t,onDismiss:n}),ej&&(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,r.jsx)("input",{ref:eI,type:"text",value:eN,onChange:e=>eS(e.target.value),onKeyDown:eA,placeholder:J("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,r.jsx)("span",{className:"text-xs text-muted-foreground",children:eT.length>0?`${eE+1}/${eT.length}`:J("common.noMatch")}),(0,r.jsx)("button",{onClick:eM,disabled:0===eT.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:J("codeViewer.prevShiftEnter"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,r.jsx)("button",{onClick:eR,disabled:0===eT.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:J("codeViewer.nextEnter"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("button",{onClick:eL,className:"p-1 rounded hover:bg-hover",title:J("codeViewer.closeEsc"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{ref:ee,onScroll:ta,className:"relative flex-1 min-h-0 overflow-y-auto px-8 py-4 [mask-image:linear-gradient(to_bottom,transparent,black_24px,black_calc(100%-24px),transparent)]",children:0!==e.length||l?(0,r.jsxs)("div",{className:"mx-auto w-full max-w-[var(--chat-column)]",children:[(0,r.jsx)("div",{ref:Z}),P&&(0,r.jsx)("div",{className:"flex justify-center py-3",children:F?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("span",{children:J("chat.loadMoreHistory")})]}):(0,r.jsx)("button",{onClick:$,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:J("chat.scrollUpForMore")})}),e9.map(e=>(0,r.jsx)("div",{"data-message-id":e.id,"data-role":e.role,children:(0,r.jsx)(d.s,{message:e,cwd:u,sessionId:v,snapshotsEnabled:V,onFork:D,onDeleteTurn:_,forkSupported:!0,onSendToPeer:B,peerSide:O,onApprovePlan:z,isLoading:l,onContentSearch:U,onShowFileDiff:W,onOpenFileLink:q})},e.id)),l&&(0,r.jsx)("div",{className:"flex justify-start mb-4",children:(0,r.jsxs)("div",{className:"px-1 py-1 max-w-[90%]",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[(0,r.jsx)(i,{bot:w}),(0,r.jsx)("span",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center","aria-hidden":"true",children:(0,r.jsx)(a.eV,{engine:ek,className:"h-4 w-4"})}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground/80 text-shimmer",children:[ew," running ",eC," \xb7 processing"," ",(0,r.jsx)(M,{value:I?.outputTokens??0})]})]}),L&&L.length>0&&(0,r.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-muted-foreground border-t border-border/50 pt-2",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{children:["Waiting on ",L.length," background task",L.length>1?"s":""]}),L.map(e=>(0,r.jsx)("div",{className:"text-muted-foreground/80 break-words",children:e.description},e.task_id))]})]}),N&&(0,r.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-amber-11 border-t border-border/50 pt-2",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{children:["Retrying API call (attempt ",N.attempt,N.maxRetries>0?`/${N.maxRetries}`:"",N.delayMs>0?`, delay ${(N.delayMs/1e3).toFixed(1)}s`:"",")"]}),(N.errorStatus||N.error)&&(0,r.jsxs)("div",{className:"text-muted-foreground/80 break-words",children:[N.errorStatus?`${N.errorStatus}`:"",N.errorStatus&&N.error?" \xb7 ":"",N.error||""]})]})]})]})}),(0,r.jsx)("div",{ref:el,"aria-hidden":!0}),(0,r.jsx)("div",{ref:X})]}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full text-foreground-subtle",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-4xl mb-4",children:"\uD83D\uDCAC"}),(0,r.jsx)("div",{children:J("chat.startConversation")})]})})}),(te.length>0||eh||ef)&&(0,r.jsxs)("nav",{className:"absolute top-1/2 z-10 flex -translate-y-1/2 flex-col items-center gap-2",style:{right:"max(0.5rem, calc(50% - var(--chat-column) / 2 - 2.25rem))"},"aria-label":J("chat.recentUserMessages"),children:[eh&&e.length>0&&(0,r.jsx)("button",{onClick:tl,className:"mb-1 flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition-all hover:bg-hover hover:text-foreground active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:J("chat.jumpToStart"),"aria-label":J("chat.jumpToStart"),children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 5h14M12 19V9m-5 5l5-5 5 5"})})}),tt&&K&&(0,r.jsx)("button",{onClick:K,className:"mb-1 flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:J("chat.moreUserMessages"),"aria-label":J("chat.moreUserMessages"),children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),te.map((e,t)=>{let n=ex===e.id,s=e.content.replace(/\s+/g," ").trim()||(e.images?.length?J("chat.imageMessage"):J("chat.userMessage"));return(0,r.jsxs)("div",{className:"group relative flex h-3 items-center",children:[(0,r.jsx)("button",{onClick:t=>{td(e.id),t.detail>0&&t.currentTarget.blur()},className:"flex h-3 w-7 items-center justify-center rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-current":n?"true":void 0,"aria-label":J("chat.recentUserMessageNumber",{index:t+1,total:te.length}),children:(0,r.jsx)("span",{"aria-hidden":!0,className:`h-0.5 rounded-full transition-all ${n?"w-4 bg-foreground":"w-3 bg-foreground/20 group-hover:w-4 group-hover:bg-foreground/45"}`})}),(0,r.jsx)("div",{className:"pointer-events-none absolute right-8 top-1/2 hidden w-72 -translate-y-1/2 rounded-xl border border-border bg-card px-3 py-2.5 text-left shadow-lv2 group-hover:block group-focus-within:block",children:(0,r.jsx)("div",{className:"line-clamp-4 text-sm leading-5 text-foreground",children:s})})]},e.id)}),ef&&e.length>0&&(0,r.jsx)("button",{onClick:ti,className:"mt-1 flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition-all hover:bg-hover hover:text-foreground active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:J("chat.jumpToLatest"),"aria-label":J("chat.jumpToLatest"),children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 19H5m7-14v10m5-5l-5 5-5-5"})})})]}),es&&(0,r.jsx)(f.fS,{floatingToolbarRef:eF,bumpRef:e$,container:es,onAddComment:eq,onSendToAI:ez,onSearch:U?eG:void 0,onExplain:eP?eK:void 0,onQuickReply:eY,quickReplyRows:e3,onEditQuickReplies:e4,isChatLoading:eP?.isLoading}),e1&&(0,r.jsx)(k,{initialRows:e3,lang:eX,isCustomized:null!==eZ,onSave:e=>e5(e.length?e:null),onRestoreDefault:()=>e5(null),onClose:()=>e2(!1)}),eB&&es&&(0,r.jsx)(g.t,{x:eB.x,y:eB.y,range:{start:0,end:0},lineSnapshot:eB.text,container:es,onSubmit:eQ,onSendToAI:eP?e6:void 0,onClose:()=>eO(null),isChatLoading:eP?.isLoading}),eH&&es&&(0,r.jsx)(g.G,{x:eH.x,y:eH.y,range:{start:0,end:0},lineSnapshot:eH.text,container:es,onSubmit:e8,onClose:()=>eV(null),isChatLoading:eP?.isLoading})]})})},39872:(e,t,n)=>{n.d(t,{B:()=>o});var r=n(95155),s=n(68287);function o({number:e,status:t="normal",isActive:n=!1}){return(0,r.jsx)("span",{className:`flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center rounded-[4px] border font-mono text-[10px] font-medium leading-none tabular-nums transition-colors ${(0,s.ci)(t,n)}`,"aria-hidden":"true",children:e})}},41066:(e,t,n)=>{n.d(t,{X:()=>i});var r=n(12115),s=n(49433);let o=["ollama","deepseek","kimi","glm"];var a=n(77725),l=n(83448);function i(e,t,n,i,d){let[c,u]=(0,r.useState)(0),[m,h]=(0,r.useState)(),p=JSON.stringify([e,t,n,i,d,c]),f=(0,a.Z)((0,r.useMemo)(()=>o.some(t=>t===e)&&t&&("ollama"===e||d)?(0,l.sy)(e,t,n,i).pipe(s.TjK(e=>({key:p,options:e}))):s.PyW(void 0),[e,t,n,i,d,p]),[p]),g="success"===f.status&&f.data?.key===p?f.data.options:void 0,x=m&&m.engine===e&&m.cwd===n&&(m.sessionId===i||null===m.sessionId)?m.level:void 0,b=g?x&&g.levels.includes(x)?x:g.selectedLevel:void 0;return{options:g,level:b,onChange:(0,r.useCallback)(t=>{e&&h({engine:e,cwd:n,sessionId:i,level:t})},[e,n,i]),retry:(0,r.useCallback)(()=>u(e=>e+1),[]),error:"error"===f.status?f.error:void 0}}},41948:(e,t,n)=>{function r(e){let t,n,r=[],s=[],o=!1;for(let a of e)(void 0!==a.turnId?a.turnId!==t:"user"===a.role?o||n!==a.id:void 0!==a.turnUserId&&(o||n!==a.turnUserId))&&(s.length>0&&r.push(s),s=[],n=void 0,o=!1),s.push(a),t=a.turnId,"user"===a.role?o=!0:void 0!==a.turnUserId&&(n=a.turnUserId);return s.length>0&&r.push(s),r}function s(e,t){let n=r(e),s=n.findIndex(e=>e.some(e=>e.id===t));return s<0?e:n.filter((e,t)=>t!==s).flat()}n.d(t,{T:()=>s,l:()=>r})},43595:(e,t,n)=>{n.d(t,{U:()=>l});var r=n(48764),s=n(58250),o=n(51536);let a={add:r.L5,notify:s.k,namespace:"skills",failureKey:"skills.addFailed"},l=()=>(0,o.X)(a)},45619:(e,t,n)=>{n.d(t,{xU:()=>E,xZ:()=>T});var r=n(95155),s=n(12115),o=n(79114),a=n(64702),l=n(22576),i=n(19502),d=n(34075),c=n(56978),u=n(17196);function m({lines:e,containerRef:t}){let n=(0,s.useRef)(null),[o,a]=(0,s.useState)({top:0,height:0});if((0,s.useEffect)(()=>{let e=t.current;if(!e)return;let r=()=>{let{scrollTop:t,scrollHeight:r,clientHeight:s}=e,o=n.current?.clientHeight||0;if(r<=s)a({top:0,height:o});else{let e=o/r;a({top:t*e,height:s*e})}};return r(),e.addEventListener("scroll",r),window.addEventListener("resize",r),()=>{e.removeEventListener("scroll",r),window.removeEventListener("resize",r)}},[t]),0===e.length)return null;let l=100/e.length;return(0,r.jsxs)("div",{ref:n,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:e=>{let r=t.current,s=n.current;if(!r||!s)return;let o=s.getBoundingClientRect(),a=(e.clientY-o.top)/o.height*r.scrollHeight-r.clientHeight/2;r.scrollTo({top:Math.max(0,a),behavior:"smooth"})},children:[e.map((e,t)=>"unchanged"!==e.type&&(0,r.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===e.type?"bg-red-9":"bg-green-9"}`,style:{top:`${t*l}%`,height:`${Math.max(l,.5)}%`,minHeight:"2px"}},t)),(0,r.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`}})]})}var h=n(47650),p=n(1058),f=n(90717),g=n(69809),x=n(70188),b=n(48347),v=n(89109),y=n(7320),w=n(37614),k=n(27570);function C({cwd:e,enableComments:t=!1,filePath:n,diffLines:o,containerEl:a,onContentSearch:l}){let i=(0,x.iN)(),d=(0,b.r)(),c=t&&!!e,{comments:u,addComment:m,updateComment:j,deleteComment:N,refresh:S}=(0,p._)({cwd:e||"",filePath:n}),[T,E]=(0,s.useState)(null),{toolbarRef:R,bumpRef:M,clearToolbar:L}=(0,k.L)({enabled:c,container:a,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,n=t?.closest("[data-new-line]");if(!n)return null;let r=parseInt(n.getAttribute("data-new-line")||"0",10);return!Number.isFinite(r)||r<=0?null:{start:r,end:r}},buildLineSnapshot:({start:e,end:t})=>{let n=[],r=0;for(let s of o)("unchanged"===s.type||"added"===s.type)&&++r>=e&&r<=t&&n.push(s.content);return n.join("\n")}}),[I,A]=(0,s.useState)(null),[P,F]=(0,s.useState)(null),[$,D]=(0,s.useState)(!1);(0,s.useEffect)(()=>{D(!0)},[]);let _=(0,s.useMemo)(()=>{let e=new Set;for(let t of u)for(let n=t.startLine;n<=t.endLine;n++)e.add(n);return e},[u]),B=(0,s.useMemo)(()=>{let e=new Map;for(let t of u){let n=t.endLine;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[u]),O=(0,s.useCallback)((e,t)=>{t.stopPropagation(),E({comment:e,x:t.clientX,y:t.clientY}),L(),A(null),F(null)},[L]),H=(0,s.useCallback)(()=>{let e=R.current;e&&(A({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),L())},[L,R]),V=(0,s.useCallback)(()=>{let e=R.current;e&&(F({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),L())},[L,R]),U=(0,s.useCallback)(()=>{let e=R.current;e&&d&&(L(),(0,f.Ff)(d.sendMessage,{filePath:n,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},g.A.t("explain.selectionMessage")))},[d,n,L,R]),W=(0,s.useCallback)(()=>{let e=R.current;if(!e||!l)return;let t=e.selectedText.trim();L(),t&&l(t)},[l,L,R]),q=(0,s.useCallback)(async(t,r)=>{if(d&&e)try{let s=await (0,f.$3)(e),o=[];for(let e of s)o.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});o.push({filePath:n,startLine:t.range.start,endLine:t.range.end,codeContent:t.lineSnapshot});let a=(0,f.Gw)(o,r);d.sendMessage(a),await (0,f.RP)(e),S()}catch(e){console.error("Failed to send to AI:",e)}},[d,n,e,S]),z=(0,s.useCallback)(e=>{P&&q(P,e)},[P,q]),K=(0,s.useCallback)(e=>{I&&q(I,e)},[I,q]),G=(0,s.useCallback)(async e=>{I&&(await m(I.range.start,I.range.end,e,I.selectedText),A(null))},[I,m]),Q=$&&i?(0,h.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.fS,{floatingToolbarRef:R,bumpRef:M,container:i,onAddComment:H,onSendToAI:V,onSearch:l?W:void 0,onExplain:d?U:void 0,isChatLoading:d?.isLoading??!1}),I&&(0,r.jsx)(y.t,{x:I.x,y:I.y,range:I.range,filePath:n,lineSnapshot:I.lineSnapshot,container:i,onSubmit:G,onSendToAI:d?K:void 0,onClose:()=>A(null),isChatLoading:d?.isLoading}),P&&(0,r.jsx)(y.G,{x:P.x,y:P.y,range:P.range,filePath:n,lineSnapshot:P.lineSnapshot,container:i,onSubmit:z,onClose:()=>F(null),isChatLoading:d?.isLoading}),T&&(0,r.jsx)(w.t,{x:T.x,y:T.y,comment:T.comment,container:i,onClose:()=>E(null),onUpdateComment:j,onDeleteComment:N})]}),i):null;return{commentsEnabled:c,linesWithComments:_,commentsByEndLine:B,handleCommentBubbleClick:O,addCommentRange:I?.range??null,sendToAIRange:P?.range??null,commentPortal:Q}}var j=n(96497);function N(e){return(0,s.useCallback)((t,n)=>{if(!e||n<=0)return;let r=(0,j.A)(t,t.currentTarget);r&&e(n,r.column,r.rect)},[e])}function S(e){return e.params?`${e.name}(${e.params.join(", ")})`:e.name}function T({oldContent:e,newContent:t,filePath:n,isNew:h=!1,isDeleted:p=!1,cwd:f,enableComments:g=!1,onPreview:x,previewLabel:b,headerLeading:v,onContentSearch:y,targetLine:w,compact:k=!1,highlight:j=!0,symbols:E,onTokenHover:R,onTokenHoverLeave:M,onTokenHoverCancel:L}){let{t:I}=(0,o.Bd)(),A=N(R),P=b??I("common.preview"),F=(0,s.useMemo)(()=>(0,l.X)(e,t),[e,t]),$=(0,s.useRef)(null),D=(0,s.useRef)(null),_=(0,s.useRef)(null),B=(0,s.useRef)(!1),[O,H]=(0,s.useState)(null);(0,s.useEffect)(()=>{_.current!==O&&H(_.current)});let{commentsEnabled:V,linesWithComments:U,commentsByEndLine:W,handleCommentBubbleClick:q,addCommentRange:z,sendToAIRange:K,commentPortal:G}=C({cwd:f,enableComments:g,filePath:n,diffLines:F,containerEl:O,onContentSearch:y});(0,s.useEffect)(()=>{let e=D.current,t=_.current;if(!e||!t)return;let n=(e,t)=>{B.current||(B.current=!0,t.scrollLeft=e.scrollLeft,requestAnimationFrame(()=>{B.current=!1}))},r=()=>n(e,t),s=()=>n(t,e);return e.addEventListener("scroll",r),t.addEventListener("scroll",s),()=>{e.removeEventListener("scroll",r),t.removeEventListener("scroll",s)}},[]);let{leftLines:Q,rightLines:J}=(0,s.useMemo)(()=>{let e=[],t=[],n=0,r=0;for(let s=0;s<F.length;s++){let o=F[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});n++,r++,e.push({lineNum:n,content:o.content,type:"unchanged",originalIdx:s}),t.push({lineNum:r,content:o.content,type:"unchanged",originalIdx:s})}else"removed"===o.type?(n++,e.push({lineNum:n,content:o.content,type:"removed",originalIdx:s})):"added"===o.type&&(r++,t.push({lineNum:r,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}},[F]),Y=(0,s.useMemo)(()=>F.map(e=>e.content),[F]),X=(0,c.C)(Y,n,j),[Z,ee]=(0,s.useState)(()=>new Map);(0,s.useLayoutEffect)(()=>{ee(new Map),ei.measure()},[Q,J]);let et=(0,s.useMemo)(()=>E??[],[E]),{rows:en,gaps:er}=(0,s.useMemo)(()=>k?(0,i.pU)(Q,J,Z,et):{rows:Q.map((e,t)=>({kind:"diff",idx:t})),gaps:[]},[k,Q,Q,J,Z,et]),es=(0,s.useCallback)((e,t)=>{let n=er.find(t=>t.id===e);n&&ee(r=>{let s=r.get(e)??{topRevealed:0,bottomRevealed:0},o=n.endIdx-n.startIdx+1-s.topRevealed-s.bottomRevealed;if(o<=0)return r;let a=Math.min(i.YO,o),l="up"===t?{...s,topRevealed:s.topRevealed+a}:{...s,bottomRevealed:s.bottomRevealed+a};return new Map(r).set(e,l)})},[er]),eo=(0,s.useCallback)(e=>{for(let t of er)if(e>=t.startIdx&&e<=t.endIdx)return t.id;return null},[er]),ea=(0,s.useCallback)(e=>en[e]?.kind==="gap-label"?28:20,[en]),el=(0,s.useCallback)(e=>{let t=en[e];if(!t)return e;if("gap-label"===t.kind)return`gl:${t.gapId}`;if("gap-expand"===t.kind)return`ge:${t.gapId}:${t.direction}`;let n=Q[t.idx],r=J[t.idx];return`d:${n?.lineNum??"x"}:${n?.type??"x"}:${r?.lineNum??"x"}:${r?.type??"x"}`},[en,Q,J]),ei=(0,a.Te)({count:en.length,getScrollElement:()=>$.current,estimateSize:ea,getItemKey:el,overscan:20}),ed=h?"w-1/4":p?"w-3/4":"w-1/2",ec=h?"w-3/4":p?"w-1/4":"w-1/2",eu=(0,s.useMemo)(()=>en.map(e=>{if("diff"!==e.kind)return{type:"unchanged"};let t=Q[e.idx],n=J[e.idx];return"removed"===t.type?{type:"removed"}:n?.type==="added"?{type:"added"}:{type:"unchanged"}}),[en,Q,J]),em=ei.getTotalSize(),eh=ei.getVirtualItems();return(0,s.useEffect)(()=>{if(!w)return;let e=("after"===w.side?J:Q).findIndex(e=>e.lineNum===w.line);if(-1===e)return;let t=en.findIndex(t=>"diff"===t.kind&&t.idx===e);if(-1===t){let t=eo(e);if(null!==t){let e=er.find(e=>e.id===t);if(!e)return;let n=e.endIdx-e.startIdx+1;ee(e=>{let r=e.get(t)??{topRevealed:0,bottomRevealed:0};if(r.topRevealed+r.bottomRevealed>=n)return e;let s=new Map(e);return s.set(t,{topRevealed:n,bottomRevealed:0}),s})}return}let n=requestAnimationFrame(()=>{ei.scrollToIndex(t,{align:"start"})});return()=>cancelAnimationFrame(n)},[w,Q,J,en]),(0,r.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[v&&(0,r.jsx)("div",{className:"flex-shrink-0 px-2 py-1 border-b border-border bg-accent",children:v}),(0,r.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,r.jsx)("div",{className:`${ed} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:h?"(New File)":p?"Deleted":"Old"}),(0,r.jsxs)("div",{className:`${ec} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,r.jsx)("span",{className:"block text-center",children:p?"(Deleted)":"New"}),(0,r.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[x&&(0,r.jsx)("button",{onClick:x,className:"text-muted-foreground hover:text-foreground transition-colors",children:P}),!p&&t&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,d.oR)(I("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:I("common.copy")})]})]}),(0,r.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,r.jsx)("div",{ref:$,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,r.jsxs)("div",{className:"flex",style:{height:`${em}px`},children:[(0,r.jsx)("div",{ref:D,className:`${ed} overflow-x-auto border-r border-border`,children:(0,r.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eh.map(e=>{let t=en[e.index];if("gap-expand"===t.kind||"gap-label"===t.kind){let n="gap-label"===t.kind;return(0,r.jsx)("div",{ref:ei.measureElement,"data-index":e.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,ea(e.index))}px`,transform:`translateY(${e.start}px)`},className:n?"bg-accent border-y border-border":""},e.key)}let n=Q[t.idx];return(0,r.jsxs)("div",{ref:ei.measureElement,"data-index":e.index,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,ea(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${"removed"===n.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:n.lineNum||""}),(0,r.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:n.originalIdx>=0&&X[n.originalIdx]||(0,u.ZD)(n.content||" ")}})]},e.key)})})}),(0,r.jsx)("div",{ref:_,className:`${ec} overflow-x-auto`,children:(0,r.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eh.map(e=>{let t=en[e.index];if("gap-expand"===t.kind)return(0,r.jsx)("button",{ref:ei.measureElement,"data-index":e.index,type:"button",onClick:()=>es(t.gapId,t.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,ea(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center text-[11px] text-foreground/50 hover:bg-hover hover:text-brand active:bg-brand/15 transition-colors duration-100 cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-brand/60",title:I("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),"aria-label":I("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),children:(0,r.jsx)("span",{className:"select-none",children:I("diffViewer.gap.more",{count:t.revealCount})})},e.key);if("gap-label"===t.kind)return(0,r.jsxs)("div",{ref:ei.measureElement,"data-index":e.index,"data-gap-id":t.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,ea(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center gap-2 px-3 text-[11px] text-foreground/80 bg-accent border-y border-border min-w-0 select-none",children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:I("diffViewer.gap.hidden",{count:t.hiddenCount})}),t.enclosingFn&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"opacity-50 flex-shrink-0",children:"\xb7"}),(0,r.jsx)("span",{className:"truncate min-w-0 font-medium","data-tooltip":S(t.enclosingFn),"data-tooltip-mono":!0,children:S(t.enclosingFn)})]})]},e.key);let n=J[t.idx],s=n?.lineNum||0,o=s>0&&U.has(s),a=W.get(s),l=a?.[0],i=z&&s>=z.start&&s<=z.end,d=K&&s>=K.start&&s<=K.end,c=i||d;return(0,r.jsxs)("div",{ref:ei.measureElement,"data-index":e.index,"data-new-line":s||void 0,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,ea(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${c?"bg-blue-9/20":o?"bg-amber-9/10":n?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,r.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-foreground-subtle select-none border-r border-border ${c?"bg-blue-9/30":""}`,style:{width:V?"52px":"40px"},children:[V&&s>0&&o&&l&&(0,r.jsx)("button",{onClick:e=>q(l,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:I("codeViewer.nComments",{count:a?.length}),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.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"})})}),V&&s>0&&!o&&(0,r.jsx)("span",{className:"w-4"}),(0,r.jsx)("span",{className:"flex-1 text-right pr-1",children:s||""})]}),(0,r.jsx)("span",{className:"whitespace-pre pl-2",onMouseOver:R?e=>A(e,s):void 0,onMouseLeave:R?M:void 0,onMouseDown:R?L:void 0,dangerouslySetInnerHTML:{__html:n?.originalIdx>=0&&X[n.originalIdx]||(0,u.ZD)(n?.content||" ")}})]},e.key)})})})]})}),(0,r.jsx)(m,{lines:eu,containerRef:$})]}),G]})}function E({oldContent:e,newContent:t,filePath:n,cwd:h,enableComments:p=!1,onPreview:f,previewLabel:g,headerLeading:x,onContentSearch:b,compact:v=!1,highlight:y=!0,onTokenHover:w,onTokenHoverLeave:k,onTokenHoverCancel:j}){let{t:S}=(0,o.Bd)(),T=N(w),R=g??S("common.preview"),M=(0,s.useMemo)(()=>(0,l.X)(e,t),[e,t]),L=(0,s.useRef)(null),I=(0,s.useMemo)(()=>M.map(e=>e.content),[M]),A=(0,c.C)(I,n,y),[P,F]=(0,s.useState)(null);(0,s.useEffect)(()=>{L.current!==P&&F(L.current)});let{commentsEnabled:$,linesWithComments:D,commentsByEndLine:_,handleCommentBubbleClick:B,addCommentRange:O,sendToAIRange:H,commentPortal:V}=C({cwd:h,enableComments:p,filePath:n,diffLines:M,containerEl:P,onContentSearch:b}),[U,W]=(0,s.useState)(()=>new Set);(0,s.useEffect)(()=>{W(new Set)},[e,t,n]);let q=(0,s.useMemo)(()=>v?function(e,t){let n=e.length,r=Array(n).fill(!1);for(let t=0;t<n;t++){if("unchanged"===e[t].type)continue;let s=Math.max(0,t-i.aj),o=Math.min(n-1,t+i.aj);for(let e=s;e<=o;e++)r[e]=!0}let s=[],o=0,a=0;for(;a<n;){if(r[a]){s.push({kind:"line",line:e[a],index:a}),a++;continue}let l=a;for(;l<n&&!r[l];)l++;let i=o++;if(t.has(i))for(let t=a;t<l;t++)s.push({kind:"line",line:e[t],index:t});else s.push({kind:"gap",id:i,count:l-a});a=l}return s}(M,U):M.map((e,t)=>({kind:"line",line:e,index:t})),[v,M,U]),z=(0,s.useCallback)(e=>{let t=q[e];if(!t)return e;if("gap"===t.kind)return`gap:${t.id}`;let n=t.line;return`${n.type}:${n.oldLineNum??"x"}:${n.newLineNum??"x"}`},[q]),K=(0,a.Te)({count:q.length,getScrollElement:()=>L.current,estimateSize:()=>20,getItemKey:z,overscan:20}),G=(0,s.useMemo)(()=>q.map(e=>"gap"===e.kind?{type:"unchanged"}:{type:e.line.type}),[q]);return(0,r.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(x||f||t)&&(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-end gap-2 px-2 py-1 border-b border-border bg-accent text-xs",children:[x&&(0,r.jsx)("div",{className:"mr-auto min-w-0",children:x}),f&&(0,r.jsx)("button",{onClick:f,className:"text-muted-foreground hover:text-foreground transition-colors",children:R}),t&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,d.oR)(S("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:S("common.copy")}),(0,r.jsx)("div",{className:"w-4 flex-shrink-0"})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,r.jsx)("div",{ref:L,className:"flex-1 min-w-0 overflow-auto",children:(0,r.jsx)("div",{style:{height:`${K.getTotalSize()}px`,position:"relative"},children:K.getVirtualItems().map(e=>{let t=q[e.index];if(!t)return null;let n={position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${e.size}px`,transform:`translateY(${e.start}px)`};if("gap"===t.kind){let s=S("diffViewer.gap.hidden",{count:t.count});return(0,r.jsx)("div",{style:n,onClick:()=>W(e=>new Set(e).add(t.id)),className:"flex items-center cursor-pointer bg-slate-2 hover:bg-hover border-y border-border text-xs text-foreground-subtle select-none","data-tooltip":s,children:(0,r.jsx)("span",{className:"w-full text-center",children:s})},e.key)}let s=t.line,o="removed"!==s.type?s.newLineNum??0:0,a=o>0&&D.has(o),l=_.get(o),i=l?.[0],d=O&&o>=O.start&&o<=O.end,c=H&&o>=H.start&&o<=H.end;return(0,r.jsxs)("div",{style:n,"data-new-line":o||void 0,className:`flex ${d||c?"bg-blue-9/20":a?"bg-amber-9/10":"removed"===s.type?"bg-red-9/15 dark:bg-red-9/25":"added"===s.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[$&&(0,r.jsx)("span",{className:"w-5 flex-shrink-0 flex items-center justify-center select-none",children:o>0&&a&&i&&(0,r.jsx)("button",{onClick:e=>B(i,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:S("codeViewer.nComments",{count:l?.length}),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.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"})})})}),(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:"added"!==s.type?s.oldLineNum:""}),(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:"removed"!==s.type?s.newLineNum:""}),(0,r.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===s.type?"text-red-11":"added"===s.type?"text-green-11":"text-foreground-subtle"}`,children:"removed"===s.type?"-":"added"===s.type?"+":" "}),(0,r.jsx)("span",{className:"flex-1 whitespace-pre pl-1",onMouseOver:w?e=>T(e,o):void 0,onMouseLeave:w?k:void 0,onMouseDown:w?j:void 0,dangerouslySetInnerHTML:{__html:A[t.index]||(0,u.ZD)(s.content||" ")}})]},e.key)})})}),(0,r.jsx)(m,{lines:G,containerRef:L})]}),V]})}},46456:(e,t,n)=>{n.d(t,{$:()=>c,BC:()=>u,Tu:()=>h,lb:()=>i,tj:()=>p,vv:()=>m});var r=n(49433),s=n(82680),o=n(84230);let a=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()},catch:n=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),l=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`)},catch:n=>new s.uV({message:`${t.method} ${e} failed`,cause:n})}),i=(e,t)=>{let n=`/api/comments?cwd=${encodeURIComponent(e)}${t?`&filePath=${encodeURIComponent(t)}`:""}`;return(0,o.F)(n,a(n))},d=r.OH5(()=>(0,o.T)("/api/comments")),c=e=>a(`/api/comments?cwd=${encodeURIComponent(e)}&all=true`),u=e=>a("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).pipe(r.yeE(d)),m=(e,t,n)=>a("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,id:t,content:n})}).pipe(r.yeE(d)),h=(e,t)=>l(`/api/comments?cwd=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`,{method:"DELETE"}).pipe(r.yeE(d)),p=e=>l(`/api/comments?cwd=${encodeURIComponent(e)}&all=true`,{method:"DELETE"}).pipe(r.yeE(d))},47176:(e,t,n)=>{n.d(t,{l:()=>i});var r=n(95155),s=n(12115),o=n(79114),a=n(94287);let l=e=>`h1[data-source-start="${e}"], h2[data-source-start="${e}"], h3[data-source-start="${e}"], h4[data-source-start="${e}"], h5[data-source-start="${e}"], h6[data-source-start="${e}"]`;function i({content:e,containerRef:t,width:n="w-80",defaultCollapsed:d=!1}){let{t:c}=(0,o.Bd)(),u=(0,s.useMemo)(()=>(function(e){let t=[],n=e.split("\n"),r=!1;for(let e=0;e<n.length;e++){let s=n[e];if(s.trimStart().startsWith("```")){r=!r;continue}if(r)continue;let o=/^(#{1,6})\s+(.+)$/.exec(s);o&&t.push({level:o[1].length,text:o[2].replace(/\s*#+\s*$/,"").replace(/\\([!-\/:-@[-`{-~])/g,"$1"),sourceLine:e+1})}return t})(e),[e]),[m,h]=(0,s.useState)(d),[p,f]=(0,s.useState)(null),g=(0,s.useCallback)(e=>{let n=t.current;if(!n)return;let r=n.querySelector(l(e));r&&r.scrollIntoView({behavior:"smooth",block:"start"})},[t]);return((0,s.useEffect)(()=>{let e=t.current;if(!e||0===u.length)return;let n=()=>{let t=[];for(let n of u){let r=e.querySelector(l(n.sourceLine));if(r){let s=r.getBoundingClientRect().top-e.getBoundingClientRect().top;t.push({line:n.sourceLine,top:s})}}let n=null;for(let e of t)e.top<=60&&(n=e.line);null===n&&t.length>0&&(n=t[0].line),f(n)},r=setTimeout(n,150);return e.addEventListener("scroll",n,{passive:!0}),()=>{clearTimeout(r),e.removeEventListener("scroll",n)}},[u,e,t]),0===u.length)?null:(0,r.jsxs)("div",{className:`border-r border-border flex-shrink-0 flex flex-col transition-[width] duration-200 ${m?"w-8":n}`,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-border flex-shrink-0",children:[!m&&(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:c("editor.toc")}),(0,r.jsx)("button",{onClick:()=>h(e=>!e),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:c(m?"editor.expandToc":"editor.collapseToc"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:m?(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"}):(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),!m&&(0,r.jsx)("nav",{className:"flex-1 overflow-y-auto py-1",children:u.map((e,t)=>(0,r.jsx)(a.m,{content:e.text,delay:400,children:(0,r.jsx)("button",{onClick:()=>g(e.sourceLine),className:`block w-full text-left text-sm py-1 px-2 truncate transition-colors hover:bg-hover ${p===e.sourceLine?"text-brand font-medium bg-brand/5":"text-muted-foreground"}`,style:{paddingLeft:`${(e.level-1)*12+8}px`},children:e.text})},t))})]})}},47215:(e,t,n)=>{n.d(t,{C6:()=>a,C_:()=>y,Hz:()=>v,OG:()=>w,WU:()=>k,Zy:()=>b,aR:()=>x,cG:()=>l,d9:()=>i,e$:()=>g,jU:()=>o,oK:()=>C,u:()=>f,xb:()=>d,zs:()=>h});var r=n(12115),s=n(69809);function o(e){try{return JSON.parse(e),!0}catch{return!1}}function a(e){try{let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}let l={key:"hsl(var(--blue-11))",str:"hsl(var(--green-11))",num:"hsl(var(--violet-11))",bool:"hsl(var(--red-11))",punct:"hsl(var(--slate-11))",fold:"hsl(var(--slate-11))"},i=r.createContext({version:0,collapsed:!1});function d(e,t=l){try{let n=JSON.parse(e);return m(n,0,t)}catch{return e}}let c=(e,t)=>r.createElement("span",{style:{color:e}},t);function u({label:e,labelColor:t,value:n,indent:o,colors:a}){let l=r.useContext(i),[d,h]=r.useState(null),p=d&&d.version===l.version?d.collapsed:l.collapsed,[f,g]=r.useState({x:0,y:0}),x="string"==typeof n&&n.replace(/\\n/g,"\n").split("\n").length>3,b={onMouseDown:e=>{g({x:e.clientX,y:e.clientY})},onClick:e=>{let t=e.clientX-f.x,n=e.clientY-f.y;t*t+n*n>25||(e.stopPropagation(),h({version:l.version,collapsed:!p}))},style:{cursor:"pointer"}};if(x&&p&&"string"==typeof n){let o=n.replace(/\\n/g,"\n").split("\n")[0],l=n.replace(/\\n/g,"\n").split("\n").length;return r.createElement("span",b,c(t,e),c(a.punct,": "),c(a.str,o),c(a.fold,` ${s.A.t("toolCall.foldedLines",{count:l})}`))}let v=r.createElement(r.Fragment,null,c(t,e),c(a.punct,": "),m(n,o,a));return x?r.createElement("span",b,v):v}function m(e,t,n){let s=" ".repeat(t);if(null===e)return c(n.bool,"null");if(void 0===e)return c(n.bool,"undefined");if("string"==typeof e){let t=e.replace(/\\n/g,"\n").replace(/\n/g,"\n"+s);return c(n.str,t)}if("number"==typeof e)return c(n.num,String(e));if("boolean"==typeof e)return c(n.bool,String(e));if(Array.isArray(e))return 0===e.length?c(n.punct,"[]"):r.createElement(r.Fragment,null,c(n.punct,"["),"\n",...e.map((o,a)=>r.createElement("span",{key:a},s+" ",r.createElement(u,{label:`[${a}]`,labelColor:n.key,value:o,indent:t+1,colors:n}),a<e.length-1?r.createElement(r.Fragment,null,c(n.punct,","),"\n"):"\n")),s,c(n.punct,"]"));if("object"==typeof e){let o=Object.entries(e);return 0===o.length?c(n.punct,"{}"):r.createElement(r.Fragment,null,c(n.punct,"{"),"\n",...o.map(([e,a],l)=>r.createElement("span",{key:e},s+" ",r.createElement(u,{label:e,labelColor:n.key,value:a,indent:t+1,colors:n}),l<o.length-1?r.createElement(r.Fragment,null,c(n.punct,","),"\n"):"\n")),s,c(n.punct,"}"))}return String(e)}function h(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}let p=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function f(e){let t=e.slice(e.lastIndexOf(".")).toLowerCase();return p.has(t)}function g(e){return e.toLowerCase().endsWith(".md")}function x(e){let t=e.toLowerCase();return t.endsWith(".html")||t.endsWith(".htm")}function b(e){let t=e.toLowerCase();return t.endsWith(".csv")||t.endsWith(".tsv")}function v(e){return e.toLowerCase().endsWith(".json")}function y(e){return"skill.md"===e.slice(e.lastIndexOf("/")+1).toLowerCase()}function w(e){return"bot.md"===e.slice(e.lastIndexOf("/")+1).toLowerCase()}function k(e,t){let n=t.startsWith("/")?[]:e.split("/").slice(0,-1);for(let e of t.replace(/^\//,"").split("/"))""!==e&&"."!==e&&(".."===e?n.pop():n.push(e));return n.join("/")}function C(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}},48050:(e,t,n)=>{n.d(t,{F9:()=>i,S6:()=>l,iS:()=>a});var r=n(49433),s=n(82680),o=n(8183);let a=(e,t,n)=>r.$mh({try:async()=>{let r=await fetch("/api/session-title",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,sessionId:t,...n})});if(!r.ok)throw Error(`Cannot ${void 0===n?"read":"save"} session title (HTTP ${r.status})`);return await r.json()},catch:e=>new s.uV({message:"Session title request failed",cause:e})}),l=(e,t)=>r.DYE(()=>{let n=(0,o.V6)();return r.$mh({try:async n=>{let r=await fetch("/api/session-title",{method:"POST",headers:{"Content-Type":"application/json"},signal:n,body:JSON.stringify({cwd:e,sessionIds:t})});if(!r.ok)throw Error(`Cannot read session titles (HTTP ${r.status})`);return await r.json()},catch:e=>new s.uV({message:"Session title batch failed",cause:e})}).pipe(r.Mim(({titles:e})=>r.OH5(()=>(0,o.EF)(e,n))),r.TjK(({titles:e})=>e.map(e=>({...(0,o.V6)().get((0,o.kz)(e.cwd,e.sessionId)),sessionId:e.sessionId}))))}),i=(e,t)=>r.$mh({try:async n=>{let r=await fetch("/api/session-title/suggest",{method:"POST",headers:{"Content-Type":"application/json"},signal:n,body:JSON.stringify({cwd:e,sessionId:t})}),s=await r.json().catch(()=>null);if(!r.ok||"string"!=typeof s?.title)throw Error(s?.error??`HTTP ${r.status}`);return s.title},catch:e=>new s.uV({message:e instanceof Error?e.message:"Title suggestion failed",cause:e})})},48347:(e,t,n)=>{n.d(t,{H:()=>a,r:()=>l});var r=n(95155),s=n(12115);let o=(0,s.createContext)(null);function a({value:e,children:t}){return(0,r.jsx)(o.Provider,{value:e,children:t})}function l(){return(0,s.useContext)(o)}},48661:(e,t,n)=>{n.d(t,{q:()=>o});var r=n(95155),s=n(79114);function o({value:e,onChange:t,className:n}){let{t:a}=(0,s.Bd)();return(0,r.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${n??""}`,children:["split","unified"].map(n=>(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),t(n)},className:`px-2 py-0.5 text-xs transition-colors ${e===n?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:a("split"===n?"diffViewer.viewSplit":"diffViewer.viewUnified")},n))})}},48764:(e,t,n)=>{n.d(t,{Bz:()=>u,De:()=>m,Ek:()=>h,Hy:()=>a,L5:()=>d,Wd:()=>i,hp:()=>c});var r=n(49433),s=n(84230),o=n(37640);let a=()=>(0,s.F)("/api/skills",(0,o.zi)("/api/skills")),l=r.OH5(()=>(0,s.T)("/api/skills")),i=()=>(0,o.zi)("/api/skills/builtin"),d=e=>(0,o.zi)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}).pipe(r.yeE(l)),c=e=>(0,o.zi)(`/api/skills/${encodeURIComponent(e)}`,{method:"DELETE"}).pipe(r.yeE(l)),u=e=>(0,o.zi)(`/api/skills/content?id=${encodeURIComponent(e)}`),m=(e,t)=>(0,o.zi)(`${e}?id=${encodeURIComponent(t)}`),h=(e,t,n)=>(0,o.zi)(`${e}?id=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`)},50605:(e,t,n)=>{function r(e){return/^~(?=$|[/\\])/.test(e.trim())}function s(e,t){return t&&r(e)?t.replace(/[/\\]+$/,"")+e.trim().slice(1):e}n.d(t,{D:()=>s,P:()=>r})},50860:(e,t,n)=>{n.d(t,{I:()=>l});var r=n(95155),s=n(12115),o=n(86957),a=n(60938);function l(e){let{refreshKey:t,className:n="h-full flex items-center justify-center p-4 bg-secondary",imgClassName:l="max-w-full max-h-full object-contain",alt:i}=e,d="absPath"in e&&"string"==typeof e.absPath,c=d?void 0:e.cwd,u=d?void 0:e.path,m=d?e.absPath:void 0,[h,p]=(0,s.useState)({kind:"loading"}),f=(0,s.useRef)(0);if((0,s.useEffect)(()=>{let e=++f.current;return p({kind:"loading"}),(async()=>{if(d){if(e!==f.current)return;p({kind:"ready",etag:null,size:0});return}let t=await o.t4.runPromiseExit((0,a.r6)(c,u));if(e!==f.current)return;if("Failure"===t._tag){let e="Fail"===t.cause._tag?t.cause.error:null,n=e?.cause;p({kind:"error",message:n instanceof Error?n.message:"Unknown error"});return}let n=t.value;if(!n.ok)return p({kind:"error",message:`stat failed (${n.status})`});let r=n.data;r&&r.exists?"too-large"===r.category?p({kind:"too-large",size:r.size??0}):"image"!==r.category?p({kind:"error",message:`Not an image (${r.category})`}):p({kind:"ready",etag:r.etag||`t-${r.mtimeMs??Date.now()}`,size:r.size??0}):p({kind:"missing"})})(),()=>{f.current++}},[d,c,u,m,t]),"loading"===h.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})});if("missing"===h.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("div",{className:"text-sm text-muted-foreground",children:"File not found"})});if("too-large"===h.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsxs)("div",{className:"text-sm text-muted-foreground",children:["Image too large to preview (",Math.round(h.size/1024/1024)," MB)"]})});if("error"===h.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("div",{className:"text-sm text-red-11",children:h.message})});let g=d?`/api/file?path=${encodeURIComponent(m)}&raw=true`:`/api/files/read?cwd=${encodeURIComponent(c)}&path=${encodeURIComponent(u)}&v=${encodeURIComponent(h.etag)}`;return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("img",{src:g,alt:i??(u||m),className:l})})}},51145:(e,t,n)=>{n.d(t,{K:()=>o});var r=n(49433),s=n(82680);let o=(e,t)=>{let n,o;return n=`/api/files/text?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,o={cache:"no-store"},r.$mh({try:async()=>{let e=await fetch(n,o),t=null;try{t=await e.json()}catch{}return{status:e.status,ok:e.ok,data:t}},catch:e=>new s.uV({message:`GET ${n} failed`,cause:e})})}},51536:(e,t,n)=>{n.d(t,{X:()=>i});var r=n(12115),s=n(79114),o=n(34075),a=n(37640),l=n(86957);function i({add:e,notify:t,namespace:n,failureKey:d}){let{t:c}=(0,s.Bd)();return(0,r.useCallback)(async r=>{let s=await l.t4.runPromiseExit(e(r));"Success"===s._tag?s.value.alreadyExists?(0,o.oR)(c(`${n}.alreadyAdded`),"info"):((0,o.oR)(c(`${n}.added`),"success"),t()):(0,o.oR)((0,a.oh)(s.cause,c(d)),"error")},[e,t,n,d,c])}},52839:(e,t,n)=>{n.d(t,{S:()=>a,q:()=>o});let r=[/(^|\/)__tests__\//,/(^|\/)tests?\//,/\.(test|spec)\.[^/]+$/],s=[/\.(md|mdx)$/i,/(^|\/)docs\//,/(^|\/)README[^/]*$/i,/(^|\/)LICENSE[^/]*$/i,/(^|\/)CHANGELOG[^/]*$/i];function o(e){return r.some(t=>t.test(e))?"test":s.some(t=>t.test(e))?"docs":null}function a(e){if(0===e.length)return null;let t=o(e[0]);return null===t?null:e.every(e=>o(e)===t)?t:null}},53317:(e,t,n)=>{function r(e){return e.replace(/^claude-/,"").replace(/-\d{8}$/,"").replace(/(\d)-(?=\d)/g,"$1.").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function s(e){return e.split("-").map((e,t)=>0===t?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)).join("-")}n.d(t,{J:()=>r,U:()=>s})},54271:(e,t,n)=>{n.d(t,{zB:()=>U,e$:()=>V,vP:()=>_});var r=n(95155),s=n(12115),o=n(79114),a=n(49433),l=n(77725),i=n(62111),d=n(70188),c=n(72312),u=n(61043),m=n(64428),h=n(52839),p=n(79237),f=n(67889),g=n(33210),x=n(56058),b=n(32880),v=n(12710),y=n(33024),w=n(32967),k=n(88780),C=n(30133),j=n(48661),N=n(20080),S=n(45619),T=n(47215),E=n(5135),R=n(24602),M=n(9573),L=n(4055);function I(e,t){return{path:e.path,status:e.status,additions:e.additions,deletions:e.deletions,old_string:e.oldContent??"",new_string:e.newContent??"",unviewable:!e.isImage&&(e.binary||null===e.oldContent&&null===e.newContent),contentDeferred:e.contentDeferred,isImage:e.isImage,oldRev:e.oldRev,newRev:e.newRev,external:null!==t&&t.size>0&&!t.has(e.path)}}let A=(e,t,n)=>`/api/snapshots/blob?cwd=${encodeURIComponent(e)}&rev=${encodeURIComponent(t)}&file=${encodeURIComponent(n)}`;function P(e){return e.fullSubject||e.subject}function F(e,t,n){let r=P(e),s=r.split("\n"),o=s.length>n?s.slice(0,n).join("\n"):r,a=o.length>t?o.slice(0,t):o;return s.length>n||o.length>t?`${a.trimEnd()}…`:a}function $(e,t){return t&&(0,p.y)(t,e)||e}function D(e,t){let n=[];for(let r of e)if("Edit"===r.name){let e=r.input;if(e.file_path&&"string"==typeof e.old_string&&"string"==typeof e.new_string){let s=$(e.file_path,t);n.push({key:r.id,toolName:"Edit",subject:`[Edit] ${s}`,legacy:!0,changeClass:(0,h.q)(s),files:[{path:s,status:"modified",old_string:e.old_string,new_string:e.new_string}]})}}else if("Write"===r.name){let e=r.input;if(e.file_path&&"string"==typeof e.content){let s=$(e.file_path,t);n.push({key:r.id,toolName:"Write",subject:`[Write] ${s}`,legacy:!0,changeClass:(0,h.q)(s),files:[{path:s,status:"added",old_string:"",new_string:e.content}]})}}return n}function _(e,t,n){var r;let s,o=e.map(e=>{let t=new Set(e.commit.toolFiles);return{key:e.commit.toolId??e.commit.hash,shortHash:e.commit.hash.slice(0,7),hash:e.commit.hash,parent:e.commit.parent,declared:e.commit.toolFiles,toolName:e.commit.toolName??"tool",subject:e.commit.subject,timestamp:e.commit.timestamp,truncated:!0===e.truncated,changeClass:(0,h.S)(e.files.map(e=>e.path)),files:e.files.map(e=>I(e,t))}});return r=o.length>0?o:D(t,n),s=new Map(t.map(e=>[e.id,e])),r.map(e=>{let t=function(e){if(!e)return;let t=e.input;return"string"==typeof t.description&&t.description?t.description:"string"==typeof t.command&&t.command?t.command:"string"==typeof t.prompt&&t.prompt?t.prompt:"string"==typeof t.file_path&&t.file_path?t.file_path:"string"==typeof t.notebook_path&&t.notebook_path?t.notebook_path:void 0}(s.get(e.key));return t?{...e,fullSubject:`[${e.toolName}] ${t}`}:e})}function B(e){let t=!1,n=0,r=0;for(let s of e)(void 0!==s.additions||void 0!==s.deletions)&&(t=!0),n+=s.additions??0,r+=s.deletions??0;return t?{additions:n,deletions:r}:null}function O({additions:e,deletions:t}){return(0,r.jsxs)("span",{className:"flex items-center gap-1 font-mono",children:[(0,r.jsxs)("span",{className:"text-green-11",children:["+",e]}),(0,r.jsxs)("span",{className:"text-red-11",children:["-",t]})]})}function H(e){let t=new Date(1e3*e),n=new Date,r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),l=`${r}-${s} ${o}:${a}`;return t.getFullYear()===n.getFullYear()?l:`${t.getFullYear()}-${l}`}function V({toolCalls:e,cwd:t,sessionId:n,onClose:m,onContentSearch:h,fullscreen:p,onToggleFullscreen:$}){let{t:U}=(0,o.Bd)(),W=(0,s.useRef)(null),[q,z]=(0,s.useState)(null);(0,s.useEffect)(()=>{z(W.current)},[]);let K=(0,s.useMemo)(()=>e.map(e=>e.id).filter(Boolean),[e]),G=K.join(","),[Q,J]=(0,s.useState)(0);(0,s.useEffect)(()=>{J(0)},[G]);let Y=(0,l.Z)(t&&K.length>0?(0,M.se)(t,K,n):a.PyW([]),[t,n,G,Q]),X=(0,s.useMemo)(()=>e.filter(e=>(0,L.h)(e.name)).map(e=>e.id),[e]);(0,s.useEffect)(()=>{if("success"!==Y.status||Q>=2)return;let e=new Set(Y.data.map(e=>e.commit.toolId));if(X.some(t=>!e.has(t))){let e=setTimeout(()=>J(e=>e+1),2e3);return()=>clearTimeout(e)}},[Y,Q,X]);let Z=(0,s.useRef)([]),ee="loading"===Y.status&&0===Z.current.length,et=(0,s.useMemo)(()=>{if("success"===Y.status){let n=_(Y.data,e,t);return n.length>0&&(Z.current=n),n}return"loading"===Y.status&&Z.current.length>0?Z.current:"loading"===Y.status?[]:D(e,t)},[Y,e,t]),[en,er]=(0,s.useState)(!1),[es,eo]=(0,s.useState)(!1),ea=(0,s.useMemo)(()=>et.filter(e=>e.hash),[et]),el=(0,s.useMemo)(()=>(function(e){var t;let n=0;for(;n<e.length-1&&(!0===(t=e[n]).truncated||t.files.length>=50);)n++;return n})(ea),[ea]),ei=(0,s.useMemo)(()=>es?ea:ea.slice(el),[ea,es,el]),ed=(0,s.useMemo)(()=>{if(es||0===el)return et;let e=new Set(ea.slice(0,el).map(e=>e.key));return et.filter(t=>!e.has(t.key))},[et,ea,es,el]),ec=(0,s.useMemo)(()=>0===ei.length||ei.length<2&&0===el?null:{base:ei[0].parent??null,head:ei[ei.length-1].hash},[ei,el]),eu=!!t&&et.length>=2,em=null===ec;(0,s.useEffect)(()=>{en&&!ec&&er(!1)},[en,ec]);let eh=(0,l.Z)(en&&t&&ec?(0,M.Tt)(t,ec.base,ec.head):a.PyW(null),[en,t,ec?.base??"",ec?.head??""]),ep=(0,s.useMemo)(()=>0===ei.length||ei.some(e=>!e.declared||0===e.declared.length)?null:new Set(ei.flatMap(e=>e.declared)),[ei]),ef=(0,s.useMemo)(()=>"success"===eh.status&&eh.data?eh.data.files.map(e=>I(e,ep)):[],[eh,ep]),eg="success"===eh.status&&eh.data?.truncated===!0,ex=en&&"loading"===eh.status,eb=en&&"error"===eh.status,[ev,ey]=(0,s.useState)(null),[ew,ek]=(0,s.useState)(null),[eC,ej]=(0,s.useState)(new Set),[eN,eS]=(0,s.useState)(()=>window.innerWidth>=768),[eT,eE]=(0,s.useState)("compact"),[eR,eM]=(0,s.useState)("unified"),[eL,eI]=(0,s.useState)(!1),[eA,eP]=(0,s.useState)(!1),[eF,e$]=(0,s.useState)(null),eD=(0,s.useMemo)(()=>et.find(e=>e.key===ev)??null,[et,ev]),e_=(0,s.useRef)(null);(0,s.useEffect)(()=>{eD&&(e_.current=eD)},[eD]);let eB=eD??e_.current,eO=(0,s.useMemo)(()=>en?ef:eB?.files??[],[en,ef,eB]),eH=(0,s.useMemo)(()=>(0,k.Do)(eO),[eO]),eV=(0,s.useMemo)(()=>eO.find(e=>e.path===ew)??null,[eO,ew]),eU=eV?.contentDeferred?eV.path:void 0,eW=en?ec?.base??null:null,eq=en?ec?.head:eB?.hash,ez=t&&eU&&eq?JSON.stringify([t,en,eW,eq,eU]):null,eK=(0,l.Z)(ez&&t&&eU&&eq?a.JkU(function*(){let{files:e}=yield*en?(0,M.Tt)(t,eW,eq,eU):(0,M.Ew)(t,eq,eU);return{key:ez,file:e[0]??null}}).pipe(a.DM4(()=>({key:ez,file:null}))):a.PyW(null),[ez]),eG="success"===eK.status&&eK.data?.key===ez?eK.data?.file:void 0,eQ=(0,s.useMemo)(()=>eG&&eV?{...I(eG,null),external:eV.external}:eV,[eG,eV]),eJ=(0,s.useMemo)(()=>B(eO),[eO]),eY=(0,s.useCallback)(e=>{ey(e.key),ek(e.files[0]?.path??null),ej(new Set((0,k.Sz)((0,k.Do)(e.files))))},[]);(0,s.useEffect)(()=>{ed.length>0&&null==ev&&eY(ed[0])},[ed,ev,eY]),(0,s.useEffect)(()=>{null==ev||0===ed.length||ed.some(e=>e.key===ev)||et.some(e=>e.key===ev)&&eY(ed[0])},[et,ed,ev,eY]),(0,s.useEffect)(()=>{0===eO.length||ew&&eO.some(e=>e.path===ew)||ek(eO[0].path)},[eO,ew]),(0,s.useEffect)(()=>{en&&0!==ef.length&&ej(new Set((0,k.Sz)((0,k.Do)(ef))))},[en,ef]),(0,s.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(eL)return void eI(!1);if(eA)return void eP(!1);if(eF)return void e$(null);(0,i.k)(),m()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[m,eL,eA,eF]);let eX=(0,s.useMemo)(()=>ed.reduce((e,t)=>e+t.files.length,0),[ed]),eZ=e=>(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:e});return(0,r.jsx)(d.SU,{container:q,children:(0,r.jsxs)("div",{ref:W,className:"relative bg-card shadow-lv3 w-full h-full flex flex-col rounded-lg",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:`${f.o} px-3`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{onClick:m,"aria-label":U("common.close"),title:U("common.close"),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(g.A,{className:"w-4 h-4"})}),$&&(0,r.jsx)("button",{onClick:$,"aria-label":p?U("diffViewer.exitFull"):U("diffViewer.expandFull"),title:p?U("diffViewer.exitFull"):U("diffViewer.expandFull"),"aria-pressed":!0===p,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:p?(0,r.jsx)(x.A,{className:"w-4 h-4"}):(0,r.jsx)(b.A,{className:"w-4 h-4"})}),eu&&(0,r.jsx)("button",{onClick:()=>er(e=>!e),disabled:em,"aria-pressed":en,title:em?U("diffViewer.aggregateUnavailable"):en?U("diffViewer.aggregateOff"):U("diffViewer.aggregateOn"),className:`ml-0.5 px-2 py-0.5 text-xs rounded border transition-colors ${em?"border-border text-foreground-subtle opacity-60 cursor-not-allowed":en?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:U("diffViewer.aggregate")})]}),(0,r.jsx)("div",{className:"w-px h-4 bg-border flex-shrink-0"}),(0,r.jsx)("button",{onClick:()=>eS(e=>!e),"aria-label":U("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors flex-shrink-0 ${eN?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:(0,r.jsx)(v.A,{className:"w-4 h-4"})}),(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground truncate",children:en?U("diffViewer.fileChangesAggregate",{count:eO.length}):U("diffViewer.fileChanges",{count:eX})})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[eN&&!en&&(0,r.jsxs)("div",{className:"w-60 flex-shrink-0 border-r border-border overflow-y-auto",children:[el>0&&(0,r.jsx)("button",{onClick:()=>eo(e=>!e),"data-tooltip":U("diffViewer.aggregateSkippedHint",{threshold:50}),className:"w-full px-3 py-1.5 border-b border-border text-left text-xs bg-amber-500/10 text-amber-600 dark:text-amber-400 hover:bg-amber-500/20 transition-colors",children:es?U("diffViewer.callsBaselineShown",{count:el}):U("diffViewer.callsBaselineHidden",{count:el})}),ed.map(e=>{let t;return(0,r.jsxs)("div",{onClick:()=>eY(e),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${ev===e.key?"bg-brand/10":""}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.changeClass&&(0,r.jsx)(c.N,{cls:e.changeClass}),e.shortHash&&(0,r.jsx)("span",{className:"font-mono text-xs text-brand",children:e.shortHash}),void 0!==e.timestamp&&(0,r.jsx)("span",{className:"text-xs text-foreground-subtle",children:H(e.timestamp)})]}),(0,r.jsx)("div",{className:"text-sm text-foreground whitespace-pre-wrap break-words mt-0.5 line-clamp-3","data-tooltip":P(e),children:F(e,320,3)}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:U("commitDetail.nChanges",{count:e.files.length})}),(t=B(e.files))&&(t.additions>0||t.deletions>0)?(0,r.jsx)(O,{additions:t.additions,deletions:t.deletions}):null]})]},e.key)})]}),(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:ee?eZ(U("diffViewer.loadingSnapshots")):0===et.length?eZ(U("diffViewer.noChanges")):en||eB?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-border text-xs text-muted-foreground",children:[en?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,r.jsx)(y.A,{className:"w-3.5 h-3.5"}),U("diffViewer.aggregateSummary",{count:eO.length,calls:ei.length})]}),el>0&&(0,r.jsx)("button",{onClick:()=>eo(e=>!e),"data-tooltip":U("diffViewer.aggregateSkippedHint",{threshold:50}),className:"px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors",children:es?U("diffViewer.aggregateBaselineIncluded",{count:el}):U("diffViewer.aggregateBaselineSkipped",{count:el})}),eJ&&(eJ.additions>0||eJ.deletions>0)&&(0,r.jsx)(O,{additions:eJ.additions,deletions:eJ.deletions}),eg&&(0,r.jsx)("span",{className:"text-amber-11",children:U("diffViewer.truncated")})]}):eB?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"flex items-center gap-1 text-foreground flex-shrink-0 whitespace-nowrap",children:[(0,r.jsx)(w.A,{className:"w-3.5 h-3.5"}),eB.toolName]}),eB.shortHash&&(0,r.jsx)("span",{className:"font-mono text-brand flex-shrink-0",children:eB.shortHash}),void 0!==eB.timestamp&&(0,r.jsx)("span",{className:"flex-shrink-0 whitespace-nowrap",children:H(eB.timestamp)}),(0,r.jsx)("span",{className:"flex-1 min-w-0 truncate","data-tooltip":P(eB),children:F(eB,640,6).replace(/\s*\n\s*/g," ")}),eB.truncated&&(0,r.jsx)("span",{className:"text-amber-11",children:U("diffViewer.truncated")}),eB.legacy&&(0,r.jsx)("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-400","data-tooltip":U("diffViewer.reconstructedHint"),children:U("diffViewer.reconstructed")})]}):null,(0,r.jsx)("div",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:!eQ?.isImage&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(C.y,{value:eT,onChange:eE}),(0,r.jsx)(j.q,{value:eR,onChange:eM})]})})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[eN&&(0,r.jsx)(u.q,{children:ex?(0,r.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("diffViewer.aggregateLoading")}):(0,r.jsxs)(r.Fragment,{children:[eO.length>0&&(0,r.jsx)(k.WY,{files:eO}),(0,r.jsx)(k.VO,{files:eH,selectedPath:ew,expandedPaths:eC,onToggle:e=>ej(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{!e.isDirectory&&e.file&&(ek(e.file.path),window.innerWidth<768&&eS(!1))},cwd:t||"",showChanges:!0,showChangeClass:!0,renderActions:e=>{if(e.isDirectory)return null;let t=e.file;return t?(0,r.jsx)(r.Fragment,{children:t.external&&(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0","data-tooltip":U("diffViewer.externalChange")})}):null}})]})}),(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:eQ?eQ.isImage?(0,r.jsx)(N.K,{filePath:eQ.path,oldSrc:t&&eQ.oldRev?A(t,eQ.oldRev,eQ.path):null,newSrc:t&&eQ.newRev?A(t,eQ.newRev,eQ.path):null}):eQ.unviewable?(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:ez&&void 0===eG?U("diffViewer.loadingFile"):ez&&null===eG?U("diffViewer.fileLoadFailed"):U("diffViewer.notViewable")}):"unified"===eR?(0,r.jsx)(S.xU,{oldContent:eQ.old_string,newContent:eQ.new_string,filePath:eQ.path,highlight:!eU,cwd:t,enableComments:!0,onContentSearch:h,compact:"compact"===eT,onPreview:"deleted"===eQ.status?void 0:(0,T.e$)(eQ.path)?()=>eI(!0):(0,T.aR)(eQ.path)?()=>eP(!0):eQ.path.endsWith(".json")?()=>e$({content:eQ.new_string,filePath:eQ.path}):void 0,previewLabel:eQ.path.endsWith(".json")?U("common.readable"):U("common.preview")}):(0,r.jsx)(S.xZ,{oldContent:eQ.old_string,newContent:eQ.new_string,filePath:eQ.path,highlight:!eU,isNew:"added"===eQ.status,isDeleted:"deleted"===eQ.status,cwd:t,enableComments:!0,onContentSearch:h,compact:"compact"===eT,onPreview:"deleted"===eQ.status?void 0:(0,T.e$)(eQ.path)?()=>eI(!0):(0,T.aR)(eQ.path)?()=>eP(!0):eQ.path.endsWith(".json")?()=>e$({content:eQ.new_string,filePath:eQ.path}):void 0,previewLabel:eQ.path.endsWith(".json")?U("common.readable"):U("common.preview")}):(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:ex?U("diffViewer.aggregateLoading"):eb?U("diffViewer.aggregateFailed"):en&&0===eO.length?U("diffViewer.aggregateEmpty"):U("diffViewer.selectFileToView")})})]})]}):eZ(U("diffViewer.selectFileToView"))})]}),eL&&eQ&&(0,r.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>eI(!1),children:(0,r.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[95%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(E.M,{content:eQ.new_string,filePath:eQ.path,cwd:t||"",onClose:()=>eI(!1)})})}),eA&&eQ&&(0,r.jsx)(R.N,{filePath:eQ.path,content:eQ.new_string,cwd:t,onClose:()=>eP(!1),onContentSearch:h}),eF&&(0,r.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>e$(null),children:(0,r.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[95%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:eF.filePath}),(0,r.jsx)("button",{onClick:()=>e$(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(g.A,{className:"w-4 h-4"})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,T.xb)(eF.content)})})]})})]})})}function U({toolCalls:e,cwd:t,sessionId:n,onClose:s,onContentSearch:o}){return(0,r.jsx)(m.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:s,children:(0,r.jsx)(V,{toolCalls:e,cwd:t,sessionId:n,onClose:s,onContentSearch:o?e=>{s(),o(e)}:void 0})})})}},56045:(e,t,n)=>{n.d(t,{_:()=>l,o:()=>a});var r=n(12115),s=n(69809);let o="json-search-highlight-style";function a(e){let[t,n]=(0,r.useState)(!1),[s,a]=(0,r.useState)(""),[l,i]=(0,r.useState)(!1),[d,c]=(0,r.useState)(0),[u,m]=(0,r.useState)(0),h=(0,r.useRef)(null),p=(0,r.useRef)([]),f=(0,r.useCallback)(()=>{let t;CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),p.current=[];let n=e.current;if(!n||!s){c(0),m(0);return}!function(){if(document.getElementById(o))return;let e=document.createElement("style");e.id=o,e.textContent="::highlight(json-search){background:var(--highlight)}::highlight(json-search-current){background:var(--highlight-current)}",document.head.appendChild(e)}();let r=n.textContent||"",a=l?s:s.toLowerCase(),i=l?r:r.toLowerCase(),d=[],u=0;for(;u<i.length;){let e=i.indexOf(a,u);if(-1===e)break;d.push([e,e+a.length]),u=e+1}if(0===d.length){c(0),m(0);return}let h=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),f=0,g=0,x=[],b=null,v=0;for(;(t=h.nextNode())&&g<d.length;){let e=t.textContent?.length||0,n=f,r=f+e;for(;g<d.length;){let[e,s]=d[g];if(e>=r)break;if(!b)if(e>=n)(b=document.createRange()).setStart(t,e-n),v=s;else break;if(v<=r)b.setEnd(t,v-n),x.push(b),b=null,g++;else break}f=r}p.current=x,c(x.length),m(e=>x.length>0?Math.min(e,x.length-1):0),CSS.highlights&&x.length>0&&CSS.highlights.set("json-search",new Highlight(...x))},[e,s,l]),g=(0,r.useCallback)((e,t)=>{let n=e.getBoundingClientRect();(t.top<n.top||t.bottom>n.bottom)&&(e.scrollTop+=t.top-n.top-n.height/2+t.height/2)},[]),x=(0,r.useCallback)(t=>{CSS.highlights?.delete("json-search-current");let n=p.current[t];if(!n||!CSS.highlights)return;CSS.highlights.set("json-search-current",new Highlight(n));let r=n.getBoundingClientRect(),s=e.current?.parentElement;s&&g(s,r)},[e,g]);(0,r.useEffect)(()=>{queueMicrotask(()=>f())},[f]),(0,r.useEffect)(()=>{x(u)},[u,d,x]),(0,r.useEffect)(()=>{let t=e.current;if(!t||!s)return;let n=new MutationObserver(()=>f());return n.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>n.disconnect()},[e,s,f]),(0,r.useEffect)(()=>{t||(CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),p.current=[])},[t]),(0,r.useEffect)(()=>()=>{CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current")},[]);let b=(0,r.useCallback)(()=>{0!==d&&m(e=>(e+1)%d)},[d]),v=(0,r.useCallback)(()=>{0!==d&&m(e=>(e-1+d)%d)},[d]),y=(0,r.useCallback)(()=>{n(!0),setTimeout(()=>h.current?.focus(),0)},[]),w=(0,r.useCallback)(()=>{n(!1),a(""),m(0)},[]),k=(0,r.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?v():b()),"Escape"===e.key&&(e.preventDefault(),w())},[b,v,w]);return{isVisible:t,query:s,setQuery:a,caseSensitive:l,setCaseSensitive:i,matchCount:d,currentIndex:u,searchInputRef:h,open:y,close:w,goToNext:b,goToPrev:v,handleKeyDown:k}}function l({search:e}){return e.isVisible?r.createElement("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border"},r.createElement("input",{ref:e.searchInputRef,type:"text",value:e.query,onChange:t=>e.setQuery(t.target.value),onKeyDown:e.handleKeyDown,placeholder:s.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"}),r.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:s.A.t("codeViewer.caseSensitive")},"Aa"),r.createElement("span",{className:"text-xs text-muted-foreground"},e.matchCount>0?`${e.currentIndex+1}/${e.matchCount}`:s.A.t("common.noMatch")),r.createElement("button",{onClick:e.goToPrev,disabled:0===e.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:s.A.t("common.previous")},r.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}))),r.createElement("button",{onClick:e.goToNext,disabled:0===e.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:s.A.t("common.next")},r.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),r.createElement("button",{onClick:e.close,className:"p-1 rounded hover:bg-accent",title:s.A.t("common.close")},r.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))):null}},56978:(e,t,n)=>{n.d(t,{C:()=>o});var r=n(12115),s=n(17196);function o(e,t,n=!0){let[a,l]=(0,r.useState)(null),[i,d]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(!n)return;let e=()=>{d(document.documentElement.classList.contains("dark"))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[n]);let c=(0,r.useMemo)(()=>n?e.join("\n"):"",[e,n]),u=`${c}:${t}:${i}`,m=(0,r.useMemo)(()=>n&&a&&a.key===u?a.html:e.map(e=>(0,s.ZD)(e||" ")),[e,u,a,n]);return(0,r.useEffect)(()=>{if(!n||0===e.length)return;let r=!1;return(async()=>{try{let e=await (0,s.kS)();if(r)return;let n=(0,s.sQ)(t),o=e.codeToTokens(c,{lang:n,theme:i?"github-dark":"github-light"}),a=[];for(let e=0;e<o.tokens.length;e++)if(a[e]=(0,s.b8)(o.tokens[e]),e%500==0&&e>0&&(await new Promise(e=>setTimeout(e,0)),r))return;l({key:u,html:a})}catch(e){console.error("Line highlight error:",e)}})(),()=>{r=!0}},[c,t,i,n]),m}},57125:(e,t,n)=>{n.d(t,{$T:()=>p,Aw:()=>f,CX:()=>c,Fx:()=>h,H:()=>l,XY:()=>y,ch:()=>i,eV:()=>b,hG:()=>v,pe:()=>u,r8:()=>x,yI:()=>m,ys:()=>g});var r=n(95155),s=n(12115),o=n(94514),a=n(66088);let l={claude:"Claude",codex:"Codex",grok:"Grok",deepseek:"DeepSeek",kimi:"Kimi",glm:"GLM",ollama:"Ollama"};function i(e){return!!e&&e in l}let d={claude:0,codex:1,deepseek:2,glm:3,kimi:4,ollama:5,grok:3.5},c=Object.keys(d).sort((e,t)=>d[e]-d[t]),u={claude:"text-[#c6532d] dark:text-[#D97757]",codex:"text-emerald-600 dark:text-emerald-400",grok:"text-foreground",deepseek:"text-sky-600 dark:text-sky-400",kimi:"text-purple-600 dark:text-purple-400",glm:"text-amber-600 dark:text-amber-400",ollama:"text-violet-600 dark:text-violet-400"},m="bg-accent font-medium text-foreground",h="focus:border-brand",p="bg-brand text-white hover:bg-brand/90",f="text-rose-600 dark:text-rose-400",g="fixed z-[9999] max-h-[70vh] overflow-y-auto rounded-lg border border-border bg-popover py-2 shadow-lv2";function x(e,t,n){(0,s.useLayoutEffect)(()=>{let n=e.current;if(!t||!n)return;n.style.transform="";let r=n.getBoundingClientRect(),s=r.right-(window.innerWidth-8);s>0&&(n.style.transform=`translateX(-${Math.min(s,Math.max(0,r.left-8))}px)`)},[e,t,n])}function b({engine:e,className:t="h-3.5 w-3.5"}){return(0,r.jsx)("img",{alt:"","aria-hidden":"true",src:`/agent-icons/${e}.svg`,className:`${t} flex-shrink-0`})}function v({selected:e}){return(0,r.jsx)("span",{className:"flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center text-foreground",children:e&&(0,r.jsx)(o.A,{className:"h-3.5 w-3.5"})})}function y({label:e,title:t,onClick:n,buttonRef:s,icon:o,labelClassName:l,labelMaxWidth:i="max-w-[160px]",testId:d,...c}){return(0,r.jsxs)("button",{...c,ref:s,type:"button",onClick:n,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed",title:t,"data-testid":d,children:[o,(0,r.jsx)("span",{className:`truncate ${i} ${l??""}`,children:e}),(0,r.jsx)(a.A,{className:"h-3 w-3 flex-shrink-0"})]})}},58250:(e,t,n)=>{n.d(t,{U:()=>o,k:()=>s});let r=(0,n(93964).N)("cockpit-skills","/api/skills"),s=r.notify,o=r.subscribe},58453:(e,t,n)=>{n.d(t,{Wn:()=>c,e9:()=>u,n2:()=>d});var r=n(86511);let s=new Map(Object.entries({read:{zh:"请先读取以下 skill 文件,再据此执行:",en:"Read these skill files first, then act accordingly:"},handoff:{zh:"以下文件交给你派发的子会话去读,你只转交路径,不要自己打开:",en:"These files are for the session you delegate to. Pass the paths along; do not open them yourself:"},handoffMixed:{zh:"以下路径原样转交给你派发的子会话;除上面读取列表已列出的以外,不要自己打开:",en:"Pass these paths verbatim to the session you delegate to; do not open any that the read list above does not already list:"},targets:{zh:"以上 [session\xb7@…] 行指向的会话(cwd 与 sessionId 原样使用):",en:"Sessions the [session\xb7@…] lines above address (use cwd and sessionId verbatim):"},unresolved:{zh:"以下 @ 开头的行没有被识别,已按普通文本处理,请告知用户:",en:"These @ lines were not recognised and were left as plain text. Tell the user:"}}).flatMap(([e,t])=>[[t.zh,e],[t.en,e]])),o=/^---\nname:\s*([^\n]+)/,a=/^\[(?:(main|subagent|session)·)?(.+?)\](?: (.*))?$/,l=e=>{let[t,...n]=e.split("\n");return s.has(t)&&n.length>0&&n.every(e=>e.startsWith("- "))},i=(e,t)=>{let n="targets"===t?e.match(/^- (.+)(?::|: )(\{.*\})$/):e.match(/^- (.+?)(?::|: )(.*)$/);return n?{name:n[1],detail:n[2]}:null};function d(e){let t=function(e){let t=e.split("\n\n"),n=t.length-1,r=!1;for(;n>=0;){if(l(t[n])){r=!0,n--;continue}let e=n;for(;e>0&&!o.test(t[e]);)e--;if(e>0&&o.test(t[e])&&l(t[e-1])){r=!0,n=e-1;continue}break}if(!r)return -1;let s=0;for(let e=0;e<=n;e++)s+=t[e].length+2;return n<0?0:s-2}(e);if(-1===t)return null;let n=e.slice(0,t),r=e.slice(t).replace(/^\n+/,""),d=[],c=[],u=null;for(let e of r.split(/\n\n(?=\S)/)){let[t,...n]=e.split("\n"),r=s.get(t),a=null!==u?e.match(o):null;if(r)u=r;else if(a){d.push({kind:"inline",name:a[1].trim().replace(/^["']|["']$/g,""),detail:""}),u="inline";continue}else if("inline"===u)continue;for(let e of r?n:[t,...n]){if("unresolved"===u){e.startsWith("- ")&&c.push(e.slice(2));continue}let t=u?i(e,u):null;t&&u&&d.push({kind:u,...t})}}let m=new Set(d.map(e=>e.name)),h=d.filter(e=>"targets"===e.kind).map(e=>e.name).sort((e,t)=>t.length-e.length),p=(n?n.split("\n"):[]).map(e=>{if(e.startsWith("[session\xb7"))for(let t of h){let n=`[session\xb7${t}]`;if(e.startsWith(n)&&(e.length===n.length||" "===e[n.length]))return{command:t,text:e.slice(n.length+1)}}let t=e.match(a);if(!t)return{command:null,text:e};let[,n,r,s=""]=t;return n||m.has(r)?{command:r.startsWith("@")?r:"subagent"===n?`/@${r}`:`/${r}`,text:s}:{command:null,text:e}});if(!(0===d.length&&c.length>0)&&!p.some(e=>e.command))return null;for(;p.length&&null===p[p.length-1].command&&!p[p.length-1].text.trim();)p.pop();return{lines:p,references:d,notes:c}}function c(e){let t=d(e);return t?t.lines.map(e=>e.command?e.text?`${e.command} ${e.text}`:e.command:e.text).join("\n"):e}function u(e){let t=(0,r.nl)(e);return c(t?t.body:e)}},59461:(e,t,n)=>{n.d(t,{Q:()=>w,j:()=>v});var r=n(95155),s=n(75347),o=n(8183),a=n(12115),l=n(79114),i=n(66109),d=n(95045),c=n(75346),u=n(86957),m=n(4768),h=n(83448),p=n(92689),f=n(7578),g=n(20832),x=n(32456);let b=[{key:"today",labelKey:"sessions.dateToday"},{key:"yesterday",labelKey:"sessions.dateYesterday"},{key:"last7Days",labelKey:"sessions.dateLast7Days"},{key:"earlier",labelKey:"sessions.dateEarlier"}];function v(e,t=Date.now()){let n=new Date(t);n.setHours(0,0,0,0);let r=n.getTime();return e>=r?"today":e>=r-864e5?"yesterday":e>=r-5184e5?"last7Days":"earlier"}let y=e=>e.sessionId||(e.path.split("/").pop()||"").replace(".jsonl","");function w({isOpen:e,onClose:t,cwd:n,onSelectSession:k,projectNumber:C,openSessionIds:j=[]}){let{t:N}=(0,l.Bd)(),S=(0,s.bc)(),[T,E]=(0,a.useState)([]),[R,M]=(0,a.useState)(0),[L,I]=(0,a.useState)(!1),[A,P]=(0,a.useState)(null),[F,$]=(0,a.useState)(""),D=(0,a.useRef)(null),[_,B]=(0,a.useState)(null),O=(0,a.useCallback)(async()=>{if(!n)return;I(!0),P(null);let e=(0,m.O)(n),t=await u.t4.runPromiseExit((0,h.QW)(e));"Success"===t._tag?(E(t.value),M(Date.now())):P("Failed to load sessions"),I(!1)},[n]);(0,a.useEffect)(()=>{e?(O(),setTimeout(()=>{D.current?.focus(),D.current?.select()},100)):B(null)},[e,O]),(0,a.useEffect)(()=>{let n=n=>{"Escape"===n.key&&e&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t]);let H=e=>{let r=y(e);k?(k(r,(0,o.iM)(S,n,r,e.title,e.titleRevision)),t()):(0,d.F)(c.n.OpenProject,{cwd:n,sessionId:r})},V=(0,a.useMemo)(()=>{let e=[...T].sort((e,t)=>Date.parse(t.modifiedAt)-Date.parse(e.modifiedAt));if(!F)return e;let t=F.toLowerCase();return e.filter(e=>!!(0,o.iM)(S,n,y(e),e.title,e.titleRevision).toLowerCase().includes(t)||(void 0!==e.searchText?e.searchText.includes(t):(0,o.iM)(S,n,y(e),e.title,e.titleRevision).toLowerCase().includes(t)||e.firstMessages.some(e=>e.toLowerCase().includes(t))||e.lastMessages.some(e=>e.toLowerCase().includes(t))))},[T,S,n,F]),U=(0,a.useMemo)(()=>{let e={today:[],yesterday:[],last7Days:[],earlier:[]};for(let t of V)e[v(Date.parse(t.modifiedAt),R)].push(t);return e},[V,R]),W=_?T.find(e=>y(e)===_)??null:null;if((0,a.useEffect)(()=>{if(!e||W)return;let t=V[0];B(t?y(t):null)},[e,W,V]),!e)return null;let q=e=>{let t=y(e),o=j.indexOf(t),a=t===_,l=e.lastMessages[e.lastMessages.length-1]??e.firstMessages[0];return(0,r.jsxs)("div",{onClick:()=>B(t),onDoubleClick:()=>H(e),className:`group/session-title rounded-md px-3 py-2 cursor-pointer transition-colors ${a?"bg-brand/10":"hover:bg-hover"}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(p.S,{engine:e.engine}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground flex items-center gap-1 flex-1 min-w-0",children:(0,r.jsx)(s.dh,{cwd:n,sessionId:t,title:e.title,titleRevision:e.titleRevision})}),(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:(0,x.fw)(N,Date.parse(e.modifiedAt))}),C&&o>=0&&(0,r.jsx)(f.l,{projectNumber:C,sessionNumber:o+1,bot:e.bot})]}),l&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground truncate mt-0.5 pl-[22px]",children:l})]},e.path)};return(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:t}),(0,r.jsxs)("div",{className:i.iG,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-foreground",children:N("sessions.sessionList")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground truncate","data-tooltip":n,children:n})]}),(0,r.jsx)("button",{onClick:t,className:"p-1 ml-4 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,r.jsxs)("div",{className:"w-full md:w-[360px] min-h-0 flex-shrink-0 md:border-r border-border flex flex-col",children:[(0,r.jsx)("div",{className:"p-3 flex-shrink-0 border-b border-border",children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{ref:D,type:"text",placeholder:N("sessions.searchSessions"),value:F,onChange:e=>$(e.target.value),className:"w-full px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),F&&(0,r.jsx)("button",{onClick:()=>{$(""),D.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:N("fileBrowser.clear"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:(0,r.jsx)("div",{className:"p-3 space-y-3",children:0===T.length&&L?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-6",children:N("sessions.loadingSessions")}):0===T.length&&A?(0,r.jsx)("div",{className:"text-xs text-red-11 text-center py-6",children:A}):0===V.length?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-6",children:F?N("sessions.noMatchingSessions"):N("sessions.noSessionsYet")}):b.map(({key:e,labelKey:t})=>{let n=U[e];return 0===n.length?null:(0,r.jsxs)("div",{className:"rounded-lg border border-border",children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 px-3 py-1.5 bg-card rounded-t-lg border-b border-border/60 text-[11px] font-medium text-muted-foreground flex items-center gap-1.5",children:[(0,r.jsx)("span",{children:N(t)}),(0,r.jsx)("span",{className:"ml-auto tabular-nums text-foreground-subtle",children:n.length})]}),(0,r.jsx)("div",{className:"p-1 space-y-0.5",children:n.map(q)})]},e)})})})]}),(0,r.jsx)("div",{className:"hidden md:flex flex-1 min-w-0",children:W?(0,r.jsx)(g.p,{cwd:n,sessionId:y(W),subtitle:(0,o.iM)(S,n,y(W),W.title,W.titleRevision),emptyText:N("sessions.noSessionMessages"),onOpenSession:()=>H(W)},y(W)):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-xs text-muted-foreground",children:N("sessions.selectSessionHint")})})]})]})]})}},60938:(e,t,n)=>{n.d(t,{DZ:()=>i,Ft:()=>m,Nn:()=>v,OJ:()=>g,VK:()=>y,YW:()=>u,__:()=>b,dt:()=>x,eA:()=>f,eE:()=>h,gZ:()=>d,mP:()=>l,nM:()=>w,r6:()=>p,r9:()=>c});var r=n(49433),s=n(82680);let o=(e,t={})=>r.$mh({try:async()=>{let n=await fetch(e,t.init);if(t.passThroughStatuses&&t.passThroughStatuses.includes(n.status))return await n.json().catch(()=>({}));if(!n.ok){let e;try{e=(await n.json()).error}catch{}throw Error(e||`HTTP ${n.status}`)}return await n.json()},catch:t=>new s.uV({message:`GET ${e} failed`,cause:t})}),a=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw Error(`HTTP ${n.status}`)},catch:t=>new s.uV({message:`POST ${e} failed`,cause:t})}),l=e=>o(`/api/files/init?cwd=${encodeURIComponent(e)}`),i=e=>o(`/api/files/index?cwd=${encodeURIComponent(e)}`),d=(e,t)=>o(`/api/files/readdir?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`),c=e=>o(`/api/files/recent?cwd=${encodeURIComponent(e)}`),u=(e,t,n)=>a("/api/files/recent",{cwd:e,file:t,...n??{}}),m=(e,t)=>a("/api/files/expanded",{cwd:e,paths:t}),h=(e,t)=>o(`/api/files/blame?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`).pipe(r.h9N(e=>r.PyW({error:e.message}))),p=(e,t)=>{let n,o;return n=`/api/files/stat?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,o={cache:"no-store"},r.$mh({try:async()=>{let e=await fetch(n,o),t=null;try{t=await e.json()}catch{}return{status:e.status,ok:e.ok,data:t}},catch:e=>new s.uV({message:`GET ${n} failed`,cause:e})})},f=e=>o(`/api/files/text?${e.toString()}`),g=e=>r.$mh({try:async()=>{let t=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=null;try{n=await t.json()}catch{}return{status:t.status,ok:t.ok,data:n}},catch:e=>new s.uV({message:"POST /api/files/save failed",cause:e})}),x=()=>o("/api/files/clipboard"),b=e=>r.$mh({try:async()=>{let t=await fetch("/api/files/clipboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(`HTTP ${t.status}`)},catch:e=>new s.uV({message:"POST /api/files/clipboard failed",cause:e})}),v=e=>r.$mh({try:async()=>{let t=await fetch("/api/files/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`HTTP ${t.status}`);return n},catch:e=>new s.uV({message:"POST /api/files/paste failed",cause:e})}),y=e=>r.$mh({try:async()=>{let t=await fetch("/api/files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`HTTP ${t.status}`);return n},catch:e=>new s.uV({message:"POST /api/files/delete failed",cause:e})}),w=e=>o(`/api/file?path=${encodeURIComponent(e)}`)},61043:(e,t,n)=>{n.d(t,{q:()=>o});var r=n(95155),s=n(12115);function o({children:e,defaultWidth:t=288}){let[n,a]=(0,s.useState)(t),l=(0,s.useRef)(null),i=(0,s.useCallback)(e=>{if("mouse"!==e.pointerType||0!==e.button)return;let n=e.currentTarget.previousElementSibling,r=e.currentTarget.parentElement;n&&r&&(e.preventDefault(),l.current={pointerId:e.pointerId,startX:e.clientX,startWidth:n.getBoundingClientRect().width,maxWidth:Math.min(1.5*t,r.getBoundingClientRect().width/2)},e.currentTarget.setPointerCapture(e.pointerId))},[t]),d=(0,s.useCallback)(e=>{let n=l.current;if(!n||n.pointerId!==e.pointerId)return;let r=n.startWidth+e.clientX-n.startX;a(Math.min(n.maxWidth,Math.max(t,r)))},[t]),c=(0,s.useCallback)(e=>{l.current?.pointerId===e.pointerId&&(l.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex-shrink-0 overflow-y-auto overflow-x-hidden",style:{width:n,maxWidth:"50%"},children:e}),(0,r.jsx)("div",{onPointerDown:i,onPointerMove:d,onPointerUp:c,onPointerCancel:c,onLostPointerCapture:c,className:"w-[5px] flex-shrink-0 relative cursor-col-resize group",children:(0,r.jsx)("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border group-hover:bg-brand transition-colors"})})]})}},62111:(e,t,n)=>{n.d(t,{E:()=>o,k:()=>s});var r=n(12115);function s(){"u">typeof document&&document.activeElement instanceof HTMLElement&&document.activeElement.blur()}function o(e,t=!0){(0,r.useEffect)(()=>{if(!t)return;let n=t=>{"Escape"===t.key&&(s(),e())};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,t])}},63040:(e,t,n)=>{n.d(t,{m3:()=>a,mi:()=>s,ot:()=>o});var r=n(37640);let s=()=>(0,r.zi)("/api/html-apps"),o=e=>(0,r.zi)("/api/html-apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),a=e=>(0,r.zi)(`/api/html-apps/${encodeURIComponent(e)}`,{method:"DELETE"})},63563:(e,t,n)=>{n.d(t,{N:()=>r});function r(){let e="u"<typeof BroadcastChannel?null:new BroadcastChannel("cockpit-html-apps");if(e)try{e.postMessage({type:"changed"})}finally{e.close()}}},64428:(e,t,n)=>{n.d(t,{F2:()=>m,ZL:()=>c,a9:()=>u});var r=n(95155),s=n(12115),o=n(47650);let a=()=>()=>{},l=()=>document.body,i=()=>null,d=(0,s.createContext)(null);function c({children:e}){let t=(0,s.useContext)(d),n=(0,s.useSyncExternalStore)(a,l,i),r=t??n;return r?(0,o.createPortal)(e,r):null}function u({children:e}){let[t,n]=(0,s.useState)(null);return(0,r.jsxs)("div",{className:"relative w-full h-full",style:{transform:"translateZ(0)"},children:[(0,r.jsx)(d.Provider,{value:t,children:e}),(0,r.jsx)("div",{ref:n,className:"absolute inset-0 pointer-events-none [&>*]:pointer-events-auto"})]})}function m(){return(0,s.useContext)(d)}},65153:(e,t,n)=>{n.d(t,{u:()=>c});var r=n(95272),s=n(12115),o=n(2111),a=n(19095),l=n(14594),i=n(98245),d=n(67958);function c(e,t,n,c,u){let m=(0,s.useId)(),h=(0,s.useRef)(null),p=(0,s.useRef)(0),f=(0,s.useRef)(null),g=(0,s.useCallback)(e=>{f.current&&t(f.current.id,e)},[t]),x=(0,s.useRef)(!1),b=(0,s.useRef)(0),v=(0,s.useRef)(0),y=(0,s.useRef)(!1),w=(0,s.useRef)(void 0),k=()=>({liveRunId:f.current?.id,sourceTaskId:w.current,turnStartedAt:new Date(v.current||f.current?.startedAt||Date.now()).toISOString(),..."codex"===c?{turnId:`live-task-${f.current?.id}-${b.current}`}:{}}),C=(0,s.useRef)(0),j=(0,s.useRef)(!1),N=(0,s.useRef)(!1),S=(0,s.useRef)(!1),T=(0,s.useRef)((0,d.B)()),E=(0,s.useRef)(!1),R=(0,s.useRef)(!1),M=e=>{f.current={...e,active:!0},x.current=!1,w.current=void 0,b.current=0,v.current=e.startedAt,y.current=!1,h.current=null,p.current=0,C.current=0,j.current=!1,N.current=!1,S.current=!1,E.current=!1,R.current=!1,u?.onSnapshotStart?.(e),u?.onLiveOutputTokens?.(null),u?.onRunStartedAt?.(e.startedAt),u?.onBackgroundTasks?.([])},L=()=>{let e=`live-asst-${f.current?.id}-${++p.current}`;h.current=e;let t=k();return g(n=>[...n,{id:e,role:"assistant",content:"",isStreaming:!0,timestamp:t.turnStartedAt,...t}]),e},I=e=>{if((0,l.Nn)(e))return;let t=e=>{u?.onLiveOutputTokens?.({outputTokens:Math.max(0,Math.round(e))})},n=e=>{!j.current&&"string"==typeof e&&e&&(C.current+=(0,a.r)(e),t(C.current))};if("system"===e.type&&"init"===e.subtype){let t=N.current;"codex"===c&&t&&!y.current&&b.current++,"number"==typeof e._ts&&Number.isFinite(e._ts)&&(v.current=e._ts),y.current=!1,S.current=!0,t||(C.current=0,j.current=!1,u?.onLiveOutputTokens?.(null),u?.onRunStartedAt?.(Date.now())),E.current=!1,L();return}if("usage_update"===e.type){"number"==typeof e.output_tokens&&Number.isFinite(e.output_tokens)&&(j.current=!0,C.current=Math.max(C.current,Math.round(e.output_tokens)),t(C.current));return}if("stream_event"===e.type){let t=e.event;if(E.current&&t?.type==="message_start"){E.current=!1;let e=h.current;e&&g(t=>t.map(t=>t.id===e?{...t,isStreaming:!1}:t)),L()}t?.type==="content_block_delta"&&t.delta?.type==="text_delta"&&n(t.delta.text)}if("system"===e.type&&"input_started"===e.subtype&&e.inputId){R.current=!0,E.current=!1;let t=`input-asst-${e.inputId}`;h.current=t,g({event:e,engine:c,assistantId:t});return}if("system"===e.type&&"input_binding"===e.subtype)return void g({event:e,engine:c,assistantId:""});if("system"===e.type&&"task_binding"===e.subtype&&"string"==typeof e.taskId){w.current=e.taskId,g(e=>e.map(e=>e.liveRunId===f.current?.id?{...e,sourceTaskId:w.current}:e));return}if("system"===e.type&&"background_tasks_changed"===e.subtype){let t=e.tasks??[];u?.onBackgroundTasks?.(t.filter(e=>!e.ambient).map(e=>({task_id:e.task_id,description:e.description})));return}if(!(0,l.A7)(e)||(u?.taskStore?.applyEvent(e),T.current.observe(e),g({event:e,engine:c,assistantId:h.current??""}),"task_notification"===e.subtype)){if("system"===e.type&&"task_notification"===e.subtype){if(!S.current&&T.current.reportsToMain(e)){let t=`live-tasknotif-${e.task_id||++p.current}`,n=`<task-notification>
|
|
726
|
+
`;function o(e){return/^([/\\]|[A-Za-z]:)/.test(e)}function a(e){return o(e)||(0,r.P)(e)}function l(e,t){let n=e.replace(/[/\\]+$/,"");return t?`${n}/${t}`:n}function i(e,t){let n,r=(n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")))<0?"":0===n?"/":e.slice(0,n);return a(e)?r:t?l(t,r):r}function d(e,t){return a(e)||!!t}let c="/apps/local/",u="/apps/builtin/";function m(e){return e.trim().replace(/^\u200e+/,"").trim()}function h(e,t){let n=m(e);return c+p(a(n)?n:l(t??"",n)).replace(/\\/g,"/").split("/").map(encodeURIComponent).join("/").replace(/^\//,"")}function p(e){let t=/^[A-Za-z]:/.exec(e)?.[0]??"",n=t?e.slice(t.length):e,r=/^[/\\]/.test(n),s=[];for(let e of n.split(/[/\\]/))if(e&&"."!==e){if(".."===e){s.length&&".."!==s[s.length-1]?s.pop():r||t||s.push("..");continue}s.push(e)}return t+(r||t?"/":"")+s.join("/")}let f=/^([a-z][a-z0-9+.-]*:|\/\/|\/)/i;function g(e,t,n){let r=e.trim();if(!r||f.test(r)||!d(t,n))return e;let s=o(t)?t:l(n,t),a=r.search(/[?#]/),i=a<0?r:r.slice(0,a),c=a<0?"":r.slice(a);if(!i)return e;let u=i;try{u=decodeURIComponent(i)}catch{}return h(p(l(s,u)))+c}let x=[{chip:"*.md",exts:["md"]},{chip:"*.txt",exts:["txt"]},{chip:"*.png/jpg/gif/webp/svg",exts:["png","jpg","jpeg","gif","webp","svg"]},{chip:"*.pdf",exts:["pdf"]},{chip:"*.json",exts:["json"]},{chip:"*.csv",exts:["csv"]},{chip:"*.tsv",exts:["tsv"]}],b=RegExp(`\\.(${x.flatMap(e=>e.exts).join("|")})$`,"i"),v=x.map(e=>e.chip);function y(e){return b.test(e.trim())}function w(e,t){let n;return/\.html?$/i.test(m(e))?h(e,t):u+"file-viewer/index.html?file="+encodeURIComponent(p(a(n=m(e))?n:l(t??"",n)).replace(/\\/g,"/"))}function k(e,t){try{let n=new URL(e,t);if(!n.pathname.startsWith(u)&&!n.pathname.startsWith(c))return e;return"localhost"===n.hostname&&(n.hostname="127.0.0.1"),n.toString()}catch{return e}}function C(e,t){let n=e=>JSON.stringify(e).replace(/</g,"\\u003c"),r="<script>"+s.replaceAll("__CWD__",n(t.cwd)).replaceAll("__WS_URL__",n(t.wsUrl??""))+"<\/script>",o=e.match(/<head[^>]*>/i);if(o&&void 0!==o.index){let t=o.index+o[0].length;return e.slice(0,t)+r+e.slice(t)}let a=e.match(/<html[^>]*>/i);if(a&&void 0!==a.index){let t=a.index+a[0].length;return e.slice(0,t)+r+e.slice(t)}return r+e}},37614:(e,t,n)=>{n.d(t,{t:()=>a});var r=n(95155),s=n(12115),o=n(79114);function a({x:e,y:t,comment:n,container:l,onClose:i,onUpdateComment:d,onDeleteComment:c}){let{t:u}=(0,o.Bd)(),[m,h]=(0,s.useState)(!1),[p,f]=(0,s.useState)(n.content),g=(0,s.useRef)(null),[x,b]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(g.current&&l){let n=l.getBoundingClientRect(),r=g.current.getBoundingClientRect(),s=e-n.left,o=t-n.top;s+r.width>n.width-16&&(s=n.width-r.width-16),s<16&&(s=16),o+r.height>n.height-16&&(o=o-r.height-8),o<16&&(o=16),queueMicrotask(()=>b({x:s,y:o}))}},[e,t,l]),(0,s.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&i()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let v=async()=>{p.trim()&&(await d(n.id,p.trim()),h(!1))},y=async()=>{await c(n.id),i()};return(0,r.jsx)("div",{ref:g,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:x.x,top:x.y},children:(0,r.jsx)("div",{className:"p-3",children:m?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("textarea",{value:p,onChange:e=>f(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(),v()),"Escape"===e.key&&(h(!1),f(n.content))}}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{onClick:()=>{h(!1),f(n.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:u("common.cancel")}),(0,r.jsx)("button",{onClick:v,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:u("common.save")})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.content}),(0,r.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:u("comments.lineRange",{start:n.startLine,end:n.endLine})}),(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)("button",{onClick:()=>h(!0),className:"p-1 rounded hover:bg-hover text-muted-foreground",title:u("common.edit"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)("button",{onClick:y,className:"p-1 rounded hover:bg-hover text-muted-foreground hover:text-red-9",title:u("common.delete"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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"})})})]})]})]})})})}},37640:(e,t,n)=>{n.d(t,{B2:()=>a,oh:()=>l,zi:()=>o});var r=n(49433),s=n(82680);let o=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e,t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`HTTP ${n.status}`)}return await n.json()},catch:n=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),a=(e,t)=>o(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=(e,t)=>{if(e&&"object"==typeof e&&"_tag"in e&&"Fail"===e._tag&&"error"in e){let t=e.error?.cause;if(t instanceof Error)return t.message}return t}},38408:(e,t,n)=>{n.d(t,{Cv:()=>P,XO:()=>$});var r=n(95155),s=n(12115),o=n(79114),a=n(47650),l=n(86957),i=n(60938),d=n(51145),c=n(70188),u=n(7320),m=n(56978),h=n(17196),p=n(89109),f=n(37614),g=n(69809),x=n(64428),b=n(96497);function v({blame:e,onClick:t}){let{t:n}=(0,o.Bd)(),a=(0,s.useRef)(null),l=(0,s.useRef)(null),i=(0,x.F2)(),d=(0,s.useRef)(!1),c=(0,s.useRef)(!1),u=(0,s.useRef)(null),m=(0,s.useRef)(null),h=(0,s.useRef)(null),p=(0,s.useRef)(e);(0,s.useEffect)(()=>{p.current=e},[e]);let f=(0,s.useRef)(t);(0,s.useEffect)(()=>{f.current=t},[t]);let b=(0,s.useCallback)(()=>{let e,t=l.current,n=a.current;if(!t||!n)return;let r=n.getBoundingClientRect(),s=t.getBoundingClientRect(),o=i?.getBoundingClientRect(),d=o?.left??0,c=o?.top??0,u=o?.width??window.innerWidth,m=o?.height??window.innerHeight,h=r.left-d;h+s.width>u-8&&(h=u-s.width-8),h<8&&(h=8);let p=r.top-c,f=r.bottom-c;(e=p-s.height-4<0?f+4:p-s.height-4)+s.height>m-8&&(e=m-s.height-8),t.style.left=`${h}px`,t.style.top=`${e}px`},[i]),y=(0,s.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),m.current&&(clearTimeout(m.current),m.current=null),d.current=!1,c.current=!1,l.current&&(l.current.style.display="none"),h.current&&(document.removeEventListener("mousedown",h.current.down),document.removeEventListener("mouseup",h.current.up),h.current=null)},[]),w=(0,s.useCallback)(()=>{let e=l.current;if(!e||d.current)return;d.current=!0,e.style.left="-9999px",e.style.top="-9999px",e.style.display="block",requestAnimationFrame(()=>requestAnimationFrame(b));let t=0,n=0,r=e=>{t=e.clientX,n=e.clientY},s=e=>{if(!(Math.abs(e.clientX-t)>5||Math.abs(e.clientY-n)>5)){let t;t=e.target,l.current?.contains(t)||a.current?.contains(t)||y()}};document.addEventListener("mousedown",r),document.addEventListener("mouseup",s),h.current={down:r,up:s}},[b,y]),k=(0,s.useCallback)(()=>{if(u.current&&clearTimeout(u.current),m.current&&(clearTimeout(m.current),m.current=null),d.current)return;let e=window.getSelection();(!e||e.isCollapsed)&&(u.current=setTimeout(w,500))},[w]),C=(0,s.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),d.current&&(m.current=setTimeout(()=>{c.current||y()},200))},[y]),j=(0,s.useCallback)(()=>{c.current=!0,m.current&&(clearTimeout(m.current),m.current=null)},[]),N=(0,s.useCallback)(()=>{c.current=!1,y()},[y]),S=(0,s.useCallback)(e=>{e.stopPropagation();let t=window.getSelection();t&&t.toString().length>0&&l.current?.contains(t.anchorNode)||(f.current?.(p.current),y())},[y]);(0,s.useEffect)(()=>()=>y(),[y]);let T=e.message.split("\n")[0]||"",E=e.message.split("\n").slice(1).join("\n").trim();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{ref:a,className:"select-none text-xs text-muted-foreground/50 ml-6 cursor-default hover:text-muted-foreground/80",onMouseEnter:k,onMouseLeave:C,children:[e.author.split(" ")[0],", ",function(e){let t=g.A.t,n=Math.floor((Date.now()-1e3*e)/1e3);if(n<60)return t("common.justNow");let r=Math.floor(n/60);if(r<60)return t("common.minutesAgo",{count:r});let s=Math.floor(r/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 a=Math.floor(o/30);return a<12?t("common.monthsAgo",{count:a}):t("common.yearsAgo",{count:Math.floor(a/12)})}(e.time)," \xb7 ",T]}),(0,r.jsx)(x.ZL,{children:(0,r.jsxs)("div",{ref:l,className:"fixed z-[9999] bg-card border border-border rounded-lg shadow-lv3 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:j,onMouseLeave:N,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,r.jsx)("span",{className:"font-mono text-brand",children:e.hash}),(0,r.jsx)("span",{className:"text-muted-foreground",children:e.author}),(0,r.jsx)("span",{className:"text-muted-foreground/60",children:new Date(1e3*e.time).toLocaleString()})]}),(0,r.jsx)("div",{className:"font-medium",children:T}),E&&(0,r.jsx)("div",{className:"mt-1 text-muted-foreground",children:E}),(0,r.jsx)("div",{className:"mt-2 text-[11px] text-brand border-t border-border pt-2 cursor-pointer hover:underline",onClick:S,children:n("codeViewer.clickToViewDetails")})]})})]})}let y=[{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)"}],w=(0,s.memo)(function({virtualKey:e,lineNum:t,highlightedHtml:n,hasComments:a,firstComment:l,lineCommentsCount:i,isInRange:d,showLineNumbers:c,lineNumChars:u,commentsEnabled:m,virtualItemSize:h,virtualItemStart:p,onCommentBubbleClick:f,onCmdClick:g,onTokenHover:x,onTokenHoverLeave:y,flashLine:w,blameLine:k,showBlameInfo:C,blameAuthorColor:j,isBlameHovered:N,onBlameClick:S,onBlameMouseEnter:T,onBlameMouseLeave:E,inlineBlameData:R,onInlineBlameClick:M,isCursorLine:L,cursorCol:I}){let{t:A}=(0,o.Bd)(),F=(0,s.useMemo)(()=>L&&null!=I?function(e,t){let n=0,r=0;for(;r<e.length;){if("<"===e[r]){let t=e.indexOf(">",r);if(-1!==t){r=t+1;continue}}if(n===t){let t;if("&"===e[r]){let n=e.indexOf(";",r);t=-1!==n&&n-r<10?n+1:r+1}else t=r+1;let n=e.substring(r,t);return e.substring(0,r)+'<span class="vi-char-cursor">'+n+"</span>"+e.substring(t)}if("&"===e[r]){let t=e.indexOf(";",r);r=-1!==t&&t-r<10?t+1:r+1}else r++;n++}return e+'<span class="vi-char-cursor"> </span>'}(n,I):n,[n,L,I]),P=(0,s.useCallback)(e=>{if(!e.metaKey||!g)return;e.preventDefault(),e.stopPropagation();let n=e.currentTarget,r=(0,b.j)(e,n);window.getSelection()?.removeAllRanges(),g(t,r)},[t,g]),$=(0,s.useCallback)(e=>{if(!x)return;let n=(0,b.A)(e,e.currentTarget);n&&x(t,n.column,n.rect)},[t,x]),D=(0,s.useCallback)(()=>{k&&S&&S(k)},[k,S]),_=(0,s.useCallback)(e=>{k&&T&&T(k,e)},[k,T]);return(0,r.jsxs)("div",{"data-line":t,style:{position:"absolute",top:0,left:0,width:"100%",height:`${h}px`,transform:`translateY(${p}px)`,backgroundColor:N&&j?j.bg:void 0},className:`flex ${w===t?"flash-line":""} ${L?"vi-cursor-line":""} ${d?"bg-blue-9/20":a?"bg-amber-9/10":"hover:bg-hover"}`,children:[(0,r.jsxs)("div",{className:"flex shrink-0 sticky left-0 z-[2] bg-card",style:{backgroundImage:N&&j?`linear-gradient(${j.bg}, ${j.bg})`:void 0},children:[k&&j&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-1 flex-shrink-0",style:{backgroundColor:j.border}}),(0,r.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-hover",onMouseEnter:_,onMouseLeave:E,onClick:D,title:A("codeViewer.clickToViewCommit"),children:C?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"font-medium",style:{color:j.border},children:k.hash}),(0,r.jsx)("span",{className:"truncate flex-1",children:k.author.split(" ")[0]})]}):null})]}),c&&(0,r.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 ${d?"bg-blue-9/30 text-blue-11":"bg-card/50 text-foreground-subtle"}`,children:[m&&a&&l&&(0,r.jsx)("button",{onClick:e=>f(l,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:A("codeViewer.nComments",{count:i}),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.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"})})}),m&&!a&&(0,r.jsx)("span",{className:"w-4"}),(0,r.jsx)("span",{className:"text-right",style:{minWidth:`${u}ch`},children:t})]})]}),(0,r.jsxs)("span",{className:"flex-1 px-3 whitespace-pre select-text",onClick:P,onMouseOver:$,onMouseLeave:y,"data-code-content":!0,children:[(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:F}}),R&&(0,r.jsx)(v,{blame:R,onClick:M})]})]},e)});var k=n(64702),C=n(1058),j=n(90717),N=n(48347),S=n(27570);function T(e,t,n){let r,s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=0;for(;(r=s.nextNode())&&r!==t;)o+=r.textContent.length;return o+n}function E(e,t){let n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=t,o=null;for(;n=r.nextNode();){o=n;let e=n.textContent.length;if(s<=e)return{node:n,offset:s};s-=e}return o?{node:o,offset:o.textContent.length}:null}var R=n(82292),M=n(34075);let L="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function I(e){let t=window.getSelection();if(!t?.rangeCount)return null;let n=t.getRangeAt(0),r=n.startContainer;for(;r&&r.parentElement!==e;)r=r.parentElement;if(!r)return null;let s=Array.from(e.children).indexOf(r);if(s<0)return null;let o=document.createRange();return o.selectNodeContents(r),o.setEnd(n.startContainer,n.startOffset),{line:s,offset:o.toString().length}}function A(e,t){let n,r=e.children[t.line];if(!r)return;let s=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=t.offset;for(;n=s.nextNode();){let e=n.textContent?.length||0;if(o<=e){let e=window.getSelection(),t=document.createRange();t.setStart(n,o),t.collapse(!0),e?.removeAllRanges(),e?.addRange(t);return}o-=e}let a=window.getSelection(),l=document.createRange();l.selectNodeContents(r),l.collapse(!1),a?.removeAllRanges(),a?.addRange(l)}function F(e){return e.map(e=>`<div style="${L}">${e}</div>`).join("")}let P=(0,s.forwardRef)(function({content:e,filePath:t,showLineNumbers:n=!0,showSearch:x=!0,className:b="",cwd:v,enableComments:P=!1,scrollToLine:$=null,scrollToLineAlign:D="center",onScrollToLineComplete:_,highlightKeyword:O=null,visibleLineRef:B,onCmdClick:H,onTokenHover:V,onTokenHoverLeave:U,onTokenHoverCancel:W,blameLines:q,inlineBlameLines:z,onSelectCommit:K,editable:G=!1,initialMtime:Q,onEditorClose:J,onSaved:Y,onEditorStateChange:Z,viMode:X=!1,onContentMutate:ee,onEnterInsertMode:et,onViSave:en,viStateRef:er,initialCursorLine:es,initialCursorCol:eo,onInitialCursorSet:ea,onContentSearch:el},ei){let{t:ed}=(0,o.Bd)(),ec=(0,s.useRef)(e),eu=(0,s.useRef)(!1),[em,eh]=(0,s.useState)(!1),[ep,ef]=(0,s.useState)(!1),[eg,ex]=(0,s.useState)(()=>e.split("\n").length),eb=(0,s.useRef)(e.split("\n").length),[ev,ey]=(0,s.useState)({show:!1}),ew=(0,s.useRef)(null),ek=(0,s.useRef)(null),eC=(0,s.useRef)(Q),ej=(0,s.useRef)(null),eN=(0,s.useRef)(!1),eS=(0,s.useRef)(!1),{parentRef:eT,containerRef:eE,searchInputRef:eR,floatingToolbarRef:eM,suppressHoverRef:eL,bumpToolbarRef:eI,savedSelectionRef:eA,highlightedLines:eF,isMounted:eP,cmdHeld:e$,flashLine:eD,isSearchVisible:e_,searchQuery:eO,caseSensitive:eB,wholeWord:eH,currentMatchIndex:eV,viewingComment:eU,addCommentInput:eW,sendToAIInput:eq,aiBridge:ez,commentsEnabled:eK,updateComment:eG,deleteComment:eQ,lines:eJ,matches:eY,rowData:eZ,virtualizer:eX,commentsByEndLine:e0,linesWithComments:e1,setIsSearchVisible:e2,setSearchQuery:e5,setCaseSensitive:e4,setWholeWord:e3,setViewingComment:e8,setAddCommentInput:e6,setSendToAIInput:e9,goToNextMatch:e7,goToPrevMatch:te,handleSearchKeyDown:tt,handleCommentBubbleClick:tn,handleToolbarAddComment:tr,handleToolbarSendToAI:ts,handleToolbarExplain:to,handleToolbarSearch:ta,handleCommentSubmit:tl,handleSendToAISubmit:ti,handleCommentSendToAI:td,getHighlightedLineHtml:tc,suppressMatchScrollRef:tu,inlineBlameLineRef:tm,inlineBlameVersion:th}=function({content:e,filePath:t,showSearch:n=!0,cwd:r,enableComments:o=!1,scrollToLine:a=null,scrollToLineAlign:l="center",onScrollToLineComplete:i,visibleLineRef:d,onContentSearch:c}){let[u,p]=(0,s.useState)(!1),f=(0,s.useRef)(null),x=(0,s.useRef)(null),b=(0,s.useRef)(null),v=(0,N.r)();(0,s.useEffect)(()=>{p(!0)},[]);let[y,w]=(0,s.useState)(!1),[E,R]=(0,s.useState)(null),M=(0,s.useRef)(null),[L,I]=(0,s.useState)(!1),[A,F]=(0,s.useState)(""),[P,$]=(0,s.useState)(!1),[D,_]=(0,s.useState)(!1),[O,B]=(0,s.useState)(0),[H,V]=(0,s.useState)(0),U=(0,s.useRef)(!1),[W,q]=(0,s.useState)(null),z=(0,s.useRef)(!1),K=(0,s.useRef)(null),[G,Q]=(0,s.useState)(null),[J,Y]=(0,s.useState)(null),Z=(0,s.useMemo)(()=>e.split("\n"),[e]),[X,ee]=(0,s.useState)(null);(0,s.useEffect)(()=>{f.current!==X&&ee(f.current)});let et=o&&!!r,{toolbarRef:en,bumpRef:er,clearToolbar:es}=(0,S.L)({enabled:et,container:X,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,n=t?.closest("[data-line]");if(!n)return null;let r=parseInt(n.getAttribute("data-line")||"0",10);return!Number.isFinite(r)||r<=0?null:{start:r,end:r}},buildLineSnapshot:({start:e,end:t})=>Z.slice(e-1,t).join("\n")}),eo=(0,s.useRef)(null),[ea,el]=(0,s.useState)(0),{comments:ei,addComment:ed,updateComment:ec,deleteComment:eu,refresh:em}=(0,C._)({cwd:r||"",filePath:t}),eh=(0,m.C)(Z,t),ep=(0,s.useMemo)(()=>{let e=new Map;for(let t of ei){let n=t.endLine;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[ei]),ef=(0,s.useMemo)(()=>{let e=new Set;for(let t of ei)for(let n=t.startLine;n<=t.endLine;n++)e.add(n);return e},[ei]),eg=(0,s.useMemo)(()=>(0,h.Np)(Z,A,P,D),[Z,A,P,D]);(0,s.useEffect)(()=>{eg.length>0&&B(0)},[eg.length,A,P,D]);let ex=(0,s.useMemo)(()=>{let e=[];for(let t=0;t<Z.length;t++)e.push({type:"code",lineIndex:t});return e},[Z.length]),eb=(0,k.Te)({count:ex.length,getScrollElement:()=>f.current,estimateSize:()=>20,overscan:10});(0,s.useEffect)(()=>{if(!d)return;let e=f.current;if(!e)return;let t=()=>{if(!eb.range)return;let t=e.scrollTop;for(let e of eb.getVirtualItems())if(e.start>=t){let t=ex[e.index];t?.type==="code"&&(d.current=t.lineIndex+1);return}};return e.addEventListener("scroll",t,{passive:!0}),t(),()=>e.removeEventListener("scroll",t)},[d,ex]),(0,s.useEffect)(()=>{let e=e=>{"Meta"===e.key&&w(!0)},t=e=>{"Meta"===e.key&&w(!1)},n=()=>w(!1);return window.addEventListener("keydown",e),window.addEventListener("keyup",t),window.addEventListener("blur",n),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t),window.removeEventListener("blur",n)}},[]),(0,s.useEffect)(()=>{if(!n)return;let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),I(!0),setTimeout(()=>b.current?.focus(),0)),"Escape"===e.key&&!e.defaultPrevented){if(L)I(!1),F("");else if(J)Y(null);else if(G)Q(null);else if(en.current)es();else{if(!W)return;q(null)}e.preventDefault(),e.stopPropagation()}},t=x.current;if(t)return t.addEventListener("keydown",e),()=>t.removeEventListener("keydown",e)},[n,L,J,G,W]),(0,s.useEffect)(()=>{if(U.current){U.current=!1;return}if(eg.length>0&&O>=0&&O<eg.length){let e=eg[O],t=ex.findIndex(t=>"code"===t.type&&t.lineIndex===e.lineIndex);t>=0&&eb.scrollToIndex(t,{align:"center"})}},[O,eg,eb,ex,H]);let ev=(0,s.useCallback)(()=>{0!==eg.length&&(B(e=>(e+1)%eg.length),V(e=>e+1))},[eg.length]),ey=(0,s.useCallback)(()=>{0!==eg.length&&(B(e=>(e-1+eg.length)%eg.length),V(e=>e+1))},[eg.length]),ew=(0,s.useRef)(a);ew.current=a,(0,s.useEffect)(()=>{if(null!==ew.current&&ew.current>0&&ex.length>0){let e=ew.current,t=e-1,n=ex.findIndex(e=>"code"===e.type&&e.lineIndex===t);if(n>=0){let t=()=>{eb.scrollToIndex(n,{align:l}),"center"===l&&(M.current&&clearTimeout(M.current),R(null),requestAnimationFrame(()=>R(e)),M.current=setTimeout(()=>R(null),1600)),i?.()};"start"===l?requestAnimationFrame(t):setTimeout(t,150)}}},[a,l,ex.length,eb,i]);let ek=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?ey():ev()),"Escape"===e.key&&(I(!1),F(""))},[ev,ey]),eC=(0,s.useCallback)((e,t)=>{et&&(t.stopPropagation(),q({comment:e,x:t.clientX,y:t.clientY}),es(),Q(null),Y(null))},[et,es]);(0,s.useEffect)(()=>{if(!et)return;let e=f.current,t=!1,n=()=>{t=!0,K.current=null,z.current=!0},r=()=>{t=!1;let e=window.getSelection();if(!e||e.isCollapsed||!e.toString().trim()){z.current=!1;return}let n=e.getRangeAt(0),r=f.current;if(!r||!r.contains(n.commonAncestorContainer))return;let s=n.startContainer,o=n.endContainer,a=(s.nodeType===Node.TEXT_NODE?s.parentElement:s)?.closest("[data-line]"),l=(o.nodeType===Node.TEXT_NODE?o.parentElement:o)?.closest("[data-line]");if(!a||!l)return;let i=parseInt(a.getAttribute("data-line")||"0",10),d=parseInt(l.getAttribute("data-line")||"0",10);i&&d&&(z.current=!0,K.current={startLine:i,startOffset:T(a,n.startContainer,n.startOffset),endLine:d,endOffset:T(l,n.endContainer,n.endOffset)})},s=()=>{if(t)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||(K.current=null,z.current=!1)};return e?.addEventListener("mousedown",n),document.addEventListener("mouseup",r),document.addEventListener("selectionchange",s),()=>{e?.removeEventListener("mousedown",n),document.removeEventListener("mouseup",r),document.removeEventListener("selectionchange",s)}},[et]),(0,s.useEffect)(()=>{let e=f.current;if(!e)return;let t=t=>{let n,r;if(!e.contains(t.target)){if(t.target.closest?.("[data-inline-blame-tip]"))return;null!==eo.current&&(eo.current=null,el(e=>e+1));return}let s=window.getSelection();if(s&&!s.isCollapsed&&s.toString().trim())return;let o=(n=t.target,(r=n.closest?.("[data-line]"))?parseInt(r.getAttribute("data-line")||"0",10):null);o!==eo.current&&(eo.current=o,requestAnimationFrame(()=>el(e=>e+1)))};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]);let ej=(0,s.useCallback)(()=>{let e=en.current;e&&(Q({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),es())},[es,en]),eN=(0,s.useCallback)(()=>{let e=en.current;e&&(Y({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),es())},[es,en]),eS=(0,s.useCallback)(()=>{let e=en.current;e&&v&&(es(),(0,j.Ff)(v.sendMessage,{filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},g.A.t("explain.selectionMessage")))},[v,t,es,en]),eT=(0,s.useCallback)(()=>{let e=en.current;if(!e||!c)return;let t=e.selectedText.trim();es(),t&&c(t)},[c,es,en]),eE=(0,s.useCallback)(async e=>{G&&(await ed(G.range.start,G.range.end,e,G.selectedText),Q(null))},[G,ed]),eR=(0,s.useCallback)(async(e,n)=>{if(v&&r)try{let s=await (0,j.$3)(r),o=[];for(let e of s)o.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});o.push({filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot});let a=(0,j.Gw)(o,n);v.sendMessage(a),await (0,j.RP)(r),em()}catch(e){console.error("Failed to send to AI:",e)}},[v,t,r,em]),eM=(0,s.useCallback)(e=>{J&&eR(J,e)},[J,eR]),eL=(0,s.useCallback)(e=>{G&&eR(G,e)},[G,eR]),eI=(0,s.useCallback)((e,t,n)=>{let r=Z[e];if(!r)return t;let s=[];if(A&&eg.length>0)for(let t of eg.filter(t=>t.lineIndex===e)){let n=eg[O]?.lineIndex===e&&eg[O]?.startCol===t.startCol;s.push({start:t.startCol,end:t.endCol,cls:n?"hl-cur":"hl-m"})}if(n&&!A&&n.length>=1){let e=n.toLowerCase(),t=r.toLowerCase(),o=0;for(;-1!==(o=t.indexOf(e,o));)s.push({start:o,end:o+n.length,cls:"hl-kw"}),o+=1}if(0===s.length)return t;if(s.sort((e,t)=>e.start-t.start||e.end-t.end),s.length>h.ZR){let e=s.findIndex(e=>"hl-cur"===e.cls),t=s.slice(0,h.ZR);e>=h.ZR&&(t[t.length-1]=s[e]),s=t}let o=[],a=0;for(let e of s){if(e.start<a)continue;e.start>a&&o.push((0,h.ZD)(r.substring(a,e.start)));let t=(0,h.ZD)(r.substring(e.start,e.end));o.push(`<span class="${e.cls}">${t}</span>`),a=e.end}if(a<r.length&&o.push((0,h.ZD)(r.substring(a))),t!==(0,h.ZD)(r)){let e=t;for(let t of s){let n=r.substring(t.start,t.end),s=(0,h.ZD)(n),o=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=RegExp(`(?<=>)([^<]*?)(${o})`,""),l=`$1<span class="${t.cls}">${s}</span>`,i=e.replace(a,l);i.length>e.length+200||(e=i)}return e}return o.join("")},[A,eg,O,Z]);return{parentRef:f,containerRef:x,searchInputRef:b,floatingToolbarRef:en,suppressHoverRef:z,savedSelectionRef:K,highlightedLines:eh,isMounted:u,cmdHeld:y,flashLine:E,isSearchVisible:L,searchQuery:A,caseSensitive:P,wholeWord:D,currentMatchIndex:O,viewingComment:W,bumpToolbarRef:er,addCommentInput:G,sendToAIInput:J,aiBridge:v,commentsEnabled:et,comments:ei,updateComment:ec,deleteComment:eu,lines:Z,matches:eg,rowData:ex,virtualizer:eb,commentsByEndLine:ep,linesWithComments:ef,setIsSearchVisible:I,setSearchQuery:F,suppressMatchScrollRef:U,setCaseSensitive:$,setWholeWord:_,setViewingComment:q,setAddCommentInput:Q,setSendToAIInput:Y,goToNextMatch:ev,goToPrevMatch:ey,handleSearchKeyDown:ek,handleCommentBubbleClick:eC,handleToolbarAddComment:ej,handleToolbarSendToAI:eN,handleToolbarExplain:eS,handleToolbarSearch:eT,handleCommentSubmit:eE,handleSendToAISubmit:eM,handleCommentSendToAI:eL,getHighlightedLineHtml:eI,inlineBlameLineRef:eo,inlineBlameVersion:ea}}({content:e,filePath:t,showSearch:x,cwd:v,enableComments:!G&&P,scrollToLine:G?null:$,scrollToLineAlign:G?"center":D,onScrollToLineComplete:G?void 0:_,visibleLineRef:G?void 0:B,onContentSearch:el}),tp=(0,c.iN)(),tf=(0,s.useRef)(null),tg=(0,s.useRef)(null),tx=(0,s.useRef)({line:0,col:0}),tb=(0,s.useRef)({line:0,col:0}),tv=function({lines:e,enabled:t,onContentChange:n,onEnterInsert:r,onSave:o,getVisibleLineCount:a,scrollToLine:l,onSearchExecute:i,onSearchNext:d,onSearchPrev:c,onSearchClear:u}){let[m,h]=(0,s.useState)("normal"),[p,f]=(0,s.useState)(-1),[g,x]=(0,s.useState)(0),[b,v]=(0,s.useState)(!1),[y,w]=(0,s.useState)(""),[k,C]=(0,s.useState)(""),[j,N]=(0,s.useState)(""),[S,T]=(0,s.useState)(""),E=(0,s.useRef)([]),R=(0,s.useRef)([]),M=(0,s.useRef)([]),L=(0,s.useRef)(null),I=(0,s.useRef)(e);(0,s.useEffect)(()=>{I.current=e}),(0,s.useEffect)(()=>{0!==e.length&&queueMicrotask(()=>f(t=>Math.min(t,e.length-1)))},[e.length]);let A=(0,s.useCallback)((e,t)=>Math.max(0,Math.min(t,Math.max(0,(I.current[e]??"").length-1))),[]),F=(0,s.useRef)(e.length);(0,s.useEffect)(()=>{let t=Math.abs(e.length-F.current);F.current=e.length,t>10&&(queueMicrotask(()=>{f(-1),x(0),v(!1)}),E.current=[],R.current=[],M.current=[])},[e]);let P=(0,s.useCallback)(()=>{L.current&&(clearTimeout(L.current),L.current=null),w("")},[]),$=(0,s.useCallback)(()=>{L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{w(""),L.current=null},500)},[]),D=(0,s.useCallback)((e,t)=>{E.current.push(t),R.current=[],v(!0),n(e.join("\n"))},[n]),_=(0,s.useCallback)((e,t)=>{let n=Math.max(0,Math.min(e,I.current.length-1));f(n),x(A(n,t??0)),l(n,"auto")},[l,A]),O=(0,s.useCallback)(e=>{f(t=>{let n=Math.max(0,Math.min(t+e,I.current.length-1));return l(n,"auto"),x(e=>Math.max(0,Math.min(e,Math.max(0,(I.current[n]??"").length-1)))),n})},[l]),B=(0,s.useCallback)(()=>{let e=I.current,t=Math.min(p,e.length-1);if(0===e.length)return;let n=e[t];M.current=[n];let r=[...e];r.splice(t,1),0===r.length&&r.push("");let s=Math.min(t,r.length-1);D(r,{lineIndex:t,oldLines:[n],newLines:[],cursorLine:t}),f(s),x(0)},[p,D]),H=(0,s.useCallback)(()=>{let e=I.current,t=Math.min(p,e.length-1);e.length>0&&(M.current=[e[t]])},[p]),V=(0,s.useCallback)(()=>{let e=M.current;if(0===e.length)return;let t=I.current,n=Math.min(p,t.length-1)+1,r=[...t];r.splice(n,0,...e),D(r,{lineIndex:n,oldLines:[],newLines:[...e],cursorLine:p}),f(n),x(0),l(n,"auto")},[p,D,l]),U=(0,s.useCallback)(()=>{let e=I.current,t=Math.min(p,e.length-1),n=e[t];if(!n||0===n.length)return;let r=n.substring(1),s=[...e];s[t]=r,D(s,{lineIndex:t,oldLines:[n],newLines:[r],cursorLine:p})},[p,D]),W=(0,s.useCallback)(()=>{let e=E.current;if(0===e.length)return;let t=e.pop(),r=[...I.current];0===t.newLines.length&&t.oldLines.length>0?r.splice(t.lineIndex,0,...t.oldLines):0===t.oldLines.length&&t.newLines.length>0?(r.splice(t.lineIndex,t.newLines.length),0===r.length&&r.push("")):r.splice(t.lineIndex,t.newLines.length,...t.oldLines),R.current.push(t),n(r.join("\n")),f(Math.min(t.cursorLine,r.length-1)),l(Math.min(t.cursorLine,r.length-1),"auto"),0===e.length&&v(!1)},[n,l]),q=(0,s.useCallback)(()=>{let e=R.current;if(0===e.length)return;let t=e.pop(),r=[...I.current];0===t.newLines.length&&t.oldLines.length>0?(r.splice(t.lineIndex,t.oldLines.length),0===r.length&&r.push("")):0===t.oldLines.length&&t.newLines.length>0?r.splice(t.lineIndex,0,...t.newLines):r.splice(t.lineIndex,t.oldLines.length,...t.newLines),E.current.push(t),v(!0),n(r.join("\n"));let s=t.lineIndex+Math.max(0,t.newLines.length-1);f(Math.min(s,r.length-1)),l(Math.min(s,r.length-1),"auto")},[n,l]),z=(0,s.useCallback)(e=>{let t=I.current,n=Math.min(p,t.length-1);if("o"===e||"O"===e){let r="o"===e?n+1:n,s=[...t];s.splice(r,0,""),D(s,{lineIndex:r,oldLines:[],newLines:[""],cursorLine:p}),n=r,f(r)}h("insert"),r(n,g,e)},[p,g,D,r]),K=(0,s.useCallback)(()=>{h("normal"),P()},[P]),G=(0,s.useCallback)(()=>{h("command"),C("")},[]),Q=(0,s.useCallback)(()=>{h("normal"),C("")},[]),J=(0,s.useCallback)(()=>{h("search"),N("")},[]),Y=(0,s.useCallback)(()=>{h("normal"),N("")},[]),Z=(0,s.useCallback)(e=>{let t=e.trim();if("w"===t){o?.(),h("normal"),C("");return}if("q"===t){h("normal"),C("");return}if("wq"===t){o?.(),h("normal"),C("");return}if("noh"===t||"nohlsearch"===t){u?.(),h("normal"),C("");return}let n=parseInt(t,10);if(!isNaN(n)&&n>0){let e=Math.min(n-1,I.current.length-1);f(e),l(e,"center"),h("normal"),C("");return}h("normal"),C("")},[o,u,l]),X=(0,s.useCallback)(e=>{if(!e){h("normal"),N("");return}T(e),i?.(e),h("normal"),N("")},[i]),ee=(0,s.useCallback)(e=>{if(!t)return!1;let n=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;if("insert"===m)return("Escape"===e.key||!!n)&&(K(),!0);if("command"===m)return!e.isComposing&&("Escape"===e.key||n?Q():"Enter"===e.key?Z(k):"Backspace"===e.key?0===k.length?Q():C(e=>e.slice(0,-1)):1!==e.key.length||e.metaKey||e.ctrlKey||C(t=>t+e.key),!0);if("search"===m)return!e.isComposing&&("Escape"===e.key||n?Y():"Enter"===e.key?X(j):"Backspace"===e.key?0===j.length?Y():N(e=>e.slice(0,-1)):1!==e.key.length||e.metaKey||e.ctrlKey||N(t=>t+e.key),!0);if(p<0&&(f(0),x(0)),e.metaKey)return!1;if(e.ctrlKey)return"d"===e.key?(O(Math.max(1,Math.floor(a()/2))),P(),!0):"u"===e.key?(O(-Math.max(1,Math.floor(a()/2))),P(),!0):"r"===e.key&&(q(),P(),!0);let r=e.key,s=y+r;if("g"===s)return w("g"),$(),!0;if("gg"===s)return _(0),P(),!0;if("d"===s)return w("d"),$(),!0;if("dd"===s)return B(),P(),!0;if("y"===s)return w("y"),$(),!0;if("yy"===s)return H(),P(),!0;if(y&&s!==r&&P(),"j"===r||"ArrowDown"===r)return O(1),!0;if("k"===r||"ArrowUp"===r)return O(-1),!0;if("h"===r||"ArrowLeft"===r)return x(e=>Math.max(0,e-1)),!0;if("l"===r||"ArrowRight"===r){let e=Math.max(0,(I.current[p]??"").length-1);return x(t=>Math.min(e,t+1)),!0}if("0"===r)return x(0),!0;if("$"===r)return x(Math.max(0,(I.current[p]??"").length-1)),!0;if("^"===r){let e=(I.current[p]??"").search(/\S/);return x(e>=0?e:0),!0}return"G"===r?(_(I.current.length-1),!0):"x"===r?(U(),!0):"p"===r?(V(),!0):"u"===r?(W(),!0):"i"===r||"a"===r||"I"===r||"A"===r||"o"===r||"O"===r?(z(r),!0):"/"===r?(J(),!0):"n"===r?(d?.(),!0):"N"===r?(c?.(),!0):":"===r?(G(),!0):"Escape"!==r&&1===r.length},[t,m,y,k,j,p,K,z,G,Q,J,Y,Z,X,O,_,a,B,H,V,U,W,q,P,$,d,c]);return{state:{mode:m,cursorLine:p,cursorCol:g,isDirty:b,keyBuffer:y,commandInput:k,searchInput:j,lastSearch:S},handleKeyDown:ee,enterNormal:K,enterInsert:z,setCursorLine:f,setCursorCol:x,setCommandInput:C,setSearchInput:N,setIsDirty:v,clearUndoHistory:(0,s.useCallback)(()=>{E.current=[],R.current=[]},[])}}({lines:eJ,enabled:X&&!G,onContentChange:e=>{tx.current={line:tb.current.line,col:tb.current.col},ee?.(e)},onEnterInsert:(e,t,n)=>{let r=t;if("a"===n)r=t+1;else if("A"===n)r=(eJ[e]??"").length;else if("I"===n){let t=(eJ[e]??"").search(/\S/);r=t>=0?t:0}else("o"===n||"O"===n)&&(r=0);tx.current={line:e,col:r},et?.(e)},onSave:en,getVisibleLineCount:()=>{let e=eT.current;return e?Math.floor(e.clientHeight/20):20},scrollToLine:(e,t)=>{let n=eZ.findIndex(t=>"code"===t.type&&t.lineIndex===e);n>=0&&eX.scrollToIndex(n,{align:t||"auto"})},onSearchExecute:e=>{e5(e),e2(!1)},onSearchNext:e7,onSearchPrev:te,onSearchClear:()=>{e5("")}});(0,s.useEffect)(()=>{er&&(er.current={cursorLine:tv.state.cursorLine,cursorCol:tv.state.cursorCol}),tb.current={line:tv.state.cursorLine,col:tv.state.cursorCol}},[er,tv.state.cursorLine,tv.state.cursorCol]);let ty=(0,s.useRef)(null);(0,s.useEffect)(()=>{X&&!G&&null!=es&&t&&ty.current!==t&&(ty.current=t,tv.setCursorLine(es-1),null!=eo&&tv.setCursorCol(eo-1),ea?.())},[X,G,es,eo,t]),(0,s.useEffect)(()=>{if(!X||G)return;let e=eE.current;if(!e)return;let t=e=>{let t=e.target;"TEXTAREA"===t.tagName||"INPUT"===t.tagName||t.isContentEditable||tv.handleKeyDown(e)&&(e.preventDefault(),e.stopPropagation())};return e.addEventListener("keydown",t,!0),()=>e.removeEventListener("keydown",t,!0)},[X,G,tv.handleKeyDown]),(0,s.useEffect)(()=>{if(!X||G)return;let e=eE.current;e&&"normal"===tv.state.mode&&requestAnimationFrame(()=>{let t=document.activeElement;t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName||t.isContentEditable)||e.focus()})},[X,G,tv.state.mode,e]);let tw=(0,s.useCallback)(e=>{if(!X||G)return;let t=e.target.closest("[data-line]");if(t){let n=parseInt(t.getAttribute("data-line"),10);if(!isNaN(n)){tv.setCursorLine(n-1);let r=t.querySelector("[data-code-content]");if(r){let t=document.caretRangeFromPoint(e.clientX,e.clientY);if(t&&r.contains(t.startContainer)){let e,s=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=0;for(;e=s.nextNode();){if(e===t.startContainer){o+=t.startOffset;break}o+=e.textContent?.length||0}let a=eJ[n-1]??"";tv.setCursorCol(Math.max(0,Math.min(o,Math.max(0,a.length-1))))}}}}let n=e.target;if("TEXTAREA"===n.tagName||"INPUT"===n.tagName||n.isContentEditable)return;let r=eE.current;r&&r.focus()},[X,G,tv.setCursorLine,tv.setCursorCol,eJ]),tk=(0,s.useCallback)(e=>{X&&!G&&requestAnimationFrame(()=>{let e=window.getSelection(),t=e?.toString().trim();t&&/^\S+$/.test(t)&&(tu.current=!0,e5(t))})},[X,G,e5,tu]);(0,s.useEffect)(()=>{"command"===tv.state.mode?setTimeout(()=>tf.current?.focus(),0):"search"===tv.state.mode&&setTimeout(()=>tg.current?.focus(),0)},[tv.state.mode]),(0,s.useEffect)(()=>{let e=eT.current;if(!e)return;let t=()=>{(W??U)?.()};return e.addEventListener("mousedown",t),()=>e.removeEventListener("mousedown",t)},[W,U]),(0,s.useEffect)(()=>{eW||eq?(eL.current=!0,U?.()):eM.current||(eL.current=!1)},[eW,eq,U]),(0,s.useLayoutEffect)(()=>{let e=eA.current;if(!e)return;let t=window.getSelection();if(t&&!t.isCollapsed)return;let n=eT.current;if(!n)return;let r=n.querySelector(`[data-line="${e.startLine}"]`),s=n.querySelector(`[data-line="${e.endLine}"]`);if(!r||!s)return;let o=E(r,e.startOffset),a=E(s,e.endOffset);if(o&&a)try{let e=document.createRange();e.setStart(o.node,o.offset),e.setEnd(a.node,a.offset),t?.removeAllRanges(),t?.addRange(e)}catch{}});let tC=(0,s.useCallback)((e,t,n)=>{eL.current||V?.(e,t,n)},[V]),tj=(0,s.useCallback)((e,t)=>{eL.current||H?.(e,t)},[H]),tN=Math.max(4,String(G?eg:eJ.length).length),tS=(0,s.useMemo)(()=>{let e=0;for(let t of eJ){let n=0;for(let e=0;e<t.length;e++)" "===t[e]?n+=2-n%2:n+=1;n>e&&(e=n)}return e},[eJ]);(0,s.useEffect)(()=>{if(G){ec.current=e;let t=e.split("\n").length;eb.current=t,ex(t),eu.current=!1,eh(!1),ey({show:!1}),eC.current=Q}},[G,e,Q]),(0,s.useEffect)(()=>{if(!G)return;let t=ew.current;if(!t)return;let n=e.split("\n");t.innerHTML=F(n.map((e,t)=>eF[t]||(0,h.ZD)(e||" "))),requestAnimationFrame(()=>{let e,r;X?(e=Math.max(0,Math.min(tx.current.line,n.length-1)),r=tx.current.col):(e=Math.max(0,Math.min((B?.current??1)-1,n.length-1)),r=0),t.focus(),A(t,{line:e,offset:r});let s=B?.current??1;ek.current&&(ek.current.scrollTop=(s-1)*20)})},[G]),(0,s.useEffect)(()=>{G&&Z?.({isDirty:em,isSaving:ep})},[G,em,ep,Z]);let tT=(0,s.useCallback)(()=>{let e=ew.current;if(!e)return ec.current;let t=[];for(let n of e.childNodes){let e=n.textContent||"";t.push(" "===e?"":e)}return t.join("\n")},[]),tE=(0,s.useCallback)(()=>{ej.current&&clearTimeout(ej.current),ej.current=setTimeout(async()=>{let e=ew.current;if(e&&!eS.current){ec.current=tT();try{let n=await (0,h.kS)(),r=(0,h.sQ)(t),s=document.documentElement.classList.contains("dark"),o=ec.current.split("\n"),a=n.codeToTokens(o.join("\n"),{lang:r,theme:s?"github-dark":"github-light"}).tokens.map(e=>(0,h.b8)(e)),l=I(e);eN.current=!0,e.innerHTML=F(a),eN.current=!1,l&&A(e,l)}catch{}}},300)},[t,tT]);(0,s.useEffect)(()=>{if(G)return()=>{ej.current&&clearTimeout(ej.current)}},[G]);let tR=(0,s.useCallback)(()=>{let e=ew.current;if(!e)return;eu.current||(eu.current=!0,eh(!0));let t=e.children.length;t!==eb.current&&(eb.current=t,ex(t))},[]),tM=(0,s.useCallback)(()=>{eN.current||eS.current||(tR(),tE())},[tR,tE]),tL=(0,s.useCallback)(e=>{if(!e.nativeEvent.isComposing&&("Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," ")),"Enter"===e.key)){e.preventDefault();let t=ew.current;if(!t)return;let n=window.getSelection();if(!n?.rangeCount)return;let r=n.getRangeAt(0);r.deleteContents();let s=r.startContainer;for(;s&&s.parentElement!==t;)s=s.parentElement;if(!s||!(s instanceof HTMLElement))return;let o=I(t),a=Array.from(t.children).indexOf(s),l=s.textContent||"",i=o?.offset??l.length,d=l.substring(0,i),c=l.substring(i);s.innerHTML=(0,h.ZD)(d||" ");let u=document.createElement("div");u.setAttribute("style",L),u.innerHTML=(0,h.ZD)(c||" "),s.after(u),A(t,{line:a+1,offset:0}),tR(),tE()}},[tR,tE]),tI=(0,s.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)},[]),tA=(0,s.useCallback)(async(e=!1)=>{if(!v)return;ec.current=tT(),ef(!0);let n=await l.t4.runPromiseExit((0,i.OJ)({cwd:v,path:t,content:ec.current,expectedMtime:e?void 0:eC.current}));if("Failure"===n._tag){console.error("Error saving file:",n.cause),(0,M.oR)(ed("toast.saveFailed"),"error"),ef(!1);return}let r=n.value,s=r.data;if(409===r.status&&s?.conflict){let e=await l.t4.runPromiseExit((0,d.K)(v,t));"Success"===e._tag&&e.value.ok&&"string"==typeof e.value.data?.content?ey({show:!0,diskContent:e.value.data.content}):ey({show:!0}),ef(!1);return}if(!r.ok){console.error("Error saving file: status",r.status),(0,M.oR)(ed("toast.saveFailed"),"error"),ef(!1);return}let o=s?.mtime;o&&(eC.current=o),eu.current=!1,eh(!1),ey({show:!1}),(0,M.oR)(ed("toast.savedSuccess"),"success"),Y?.(),ef(!1)},[v,t,tT,Y,ed]),tF=(0,s.useCallback)(async()=>{em&&!ep&&await tA(!1)},[em,ep,tA]),tP=(0,s.useCallback)(async()=>{ey({show:!1}),await tA(!0)},[tA]),t$=(0,s.useCallback)(()=>{if(void 0!==ev.diskContent){ec.current=ev.diskContent;let t=ev.diskContent.split("\n").length;eb.current=t,ex(t);let n=ev.diskContent!==e;eu.current=n,eh(n);let r=ew.current;r&&(r.innerHTML=F(ev.diskContent.split("\n").map(e=>(0,h.ZD)(e||" "))),tE())}ey({show:!1}),Y?.()},[ev.diskContent,e,Y,tE]),tD=(0,s.useCallback)(()=>{let e=ek.current;return e?Math.floor(e.scrollTop/20)+1:B?.current??1},[B]),t_=(0,s.useCallback)(async()=>{(!em||await (0,M.lJ)(ed("codeViewer.unsavedConfirm"),{danger:!0,confirmText:ed("codeViewer.discardChanges"),cancelText:ed("codeViewer.continueEditing")}))&&J?.(tD())},[em,J,tD]);(0,s.useEffect)(()=>{if(!G)return;let e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&(e.preventDefault(),tF())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[G,tF]);let tO=(0,s.useCallback)(()=>{let e=tT();ee?.(e);let t=ew.current,n=t?I(t):null,r=tD();if(tv.enterNormal(),n){tv.setCursorLine(n.line);let t=e.split("\n")[n.line]??"";tv.setCursorCol(Math.max(0,Math.min(n.offset,Math.max(0,t.length-1))))}else tv.setCursorLine(Math.max(0,r-1));J?.(r)},[tT,ee,tD,J,tv]);(0,s.useEffect)(()=>{if(!G)return;let e=e=>{let t="Escape"===e.key,n=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;(t||X&&n)&&(e.preventDefault(),e.stopPropagation(),X?eu.current?(0,M.lJ)(ed("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:ed("codeViewer.discardChanges"),cancelText:ed("codeViewer.continueEditing")}).then(e=>{e&&tO()}):tO():t_())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[G,X,t_,tO]);let tB=(0,s.useCallback)(()=>{eu.current||(eu.current=!0,eh(!0))},[]);(0,s.useImperativeHandle)(ei,()=>({save:tF,close:t_,markDirty:tB,get isDirty(){return eu.current},get isSaving(){return ep}}),[tF,t_,tB,ep]);let tH=!!(q&&q.length>0),tV=(0,s.useMemo)(()=>{if(!q)return new Map;let e=[...new Set(q.map(e=>e.author))],t=new Map;return e.forEach((e,n)=>{t.set(e,y[n%y.length])}),t},[q]),[tU,tW]=(0,s.useState)(null),[tq,tz]=(0,s.useState)(null);(0,s.useEffect)(()=>{tW(null),tz(null)},[q]);let tK=(0,s.useCallback)((e,t)=>{tW(e.author);let n=t.currentTarget.getBoundingClientRect();tz({line:e,x:n.right+8,y:n.top})},[]),tG=(0,s.useCallback)(()=>{tW(null),tz(null)},[]),tQ=(0,s.useCallback)(e=>{K&&(K({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}),tz(null))},[K]),tJ=`${tN+2}ch`;return(0,r.jsxs)("div",{ref:eE,className:`h-full flex flex-col outline-none ${b}`,tabIndex:0,onClick:tw,onDoubleClick:tk,children:[G&&ev.show&&(0,r.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,r.jsx)("svg",{className:"w-5 h-5 text-amber-11 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)("span",{className:"text-sm text-foreground flex-1",children:ed("codeViewer.fileModifiedExternally")}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:t$,className:"px-3 py-1 text-sm rounded border border-border hover:bg-hover transition-colors",children:ed("codeViewer.useDiskVersion")}),(0,r.jsx)("button",{onClick:tP,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:ed("codeViewer.forceOverwrite")})]})]}),!G&&x&&e_&&(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,r.jsx)("input",{ref:eR,type:"text",value:eO,onChange:e=>e5(e.target.value),onKeyDown:tt,placeholder:ed("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,r.jsx)("button",{onClick:()=>e4(!eB),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${eB?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-hover"}`,title:ed("codeViewer.caseSensitive"),children:"Aa"}),(0,r.jsx)("button",{onClick:()=>e3(!eH),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${eH?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-hover"}`,title:ed("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:eY.length>0?`${eV+1}/${eY.length}`:ed("common.noMatch")}),(0,r.jsx)("button",{onClick:te,disabled:0===eY.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ed("common.previous"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,r.jsx)("button",{onClick:e7,disabled:0===eY.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ed("common.next"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("button",{onClick:()=>{e2(!1),e5("")},className:"p-1 rounded hover:bg-hover",title:ed("common.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),G?(0,r.jsx)("div",{ref:ek,className:"flex-1 overflow-auto bg-card",children:(0,r.jsxs)("div",{className:"flex",style:{minHeight:"100%"},children:[(0,r.jsx)("div",{className:"flex-shrink-0 font-mono text-sm select-none sticky left-0 z-[2] bg-card",style:{width:tJ},children:Array.from({length:eg},(e,t)=>(0,r.jsx)("div",{className:"text-right text-muted-foreground/50 pr-3",style:{height:20,lineHeight:"20px"},children:t+1},t))}),(0,r.jsx)("div",{ref:ew,contentEditable:!0,suppressContentEditableWarning:!0,onInput:tM,onKeyDown:tL,onPaste:tI,onCompositionStart:()=>{eS.current=!0},onCompositionEnd:()=>{eS.current=!1,tM()},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",className:"flex-1 font-mono text-sm outline-none",style:{caretColor:"var(--foreground)",tabSize:2}})]})}):(0,r.jsx)("div",{ref:eT,className:`flex-1 overflow-auto font-mono text-sm bg-card${e$?" cmd-held-container":""}`,children:(0,r.jsx)("div",{style:{height:`${eX.getTotalSize()}px`,minWidth:"100%",width:tH?`calc(${tN+tS+10}ch + 13rem)`:`${tN+tS+10}ch`,position:"relative"},children:eX.getVirtualItems().map(e=>{let t=eZ[e.index];if("code"!==t.type)return null;let s=t.lineIndex,o=s+1,a=eF[s]||(0,h.ZD)(eJ[s]||""),l=tc(s,a,O),i=e1.has(o),d=e0.get(o),c=d?.[0],u=!!(eW&&o>=eW.range.start&&o<=eW.range.end),m=th>=0?tm.current:null,p=!G&&z&&m===o?z[s]??null:null,f=tH?q[s]:void 0,g=tH&&s>0?q[s-1]:void 0,x=!!f&&(!g||g.hash!==f.hash),b=f?tV.get(f.author):void 0;return(0,r.jsx)(w,{virtualKey:e.key,lineNum:o,highlightedHtml:l,hasComments:i,firstComment:c,lineCommentsCount:d?.length,isInRange:u,showLineNumbers:n,lineNumChars:tN,commentsEnabled:eK,virtualItemSize:e.size,virtualItemStart:e.start,onCommentBubbleClick:tn,onCmdClick:tj,onTokenHover:tC,onTokenHoverLeave:U,flashLine:eD,blameLine:f,showBlameInfo:x,blameAuthorColor:b,isBlameHovered:!!(f&&tU===f.author),onBlameClick:tQ,onBlameMouseEnter:tK,onBlameMouseLeave:tG,inlineBlameData:p,onInlineBlameClick:tQ,isCursorLine:X&&!G&&tv.state.cursorLine===s,cursorCol:X&&!G&&tv.state.cursorLine===s?tv.state.cursorCol:void 0},e.key)})})}),X&&(0,r.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"===tv.state.mode&&(0,r.jsx)("span",{className:"text-green-11 font-medium",children:"NORMAL"}),"insert"===tv.state.mode&&(0,r.jsx)("span",{className:"text-blue-11 font-medium",children:"INSERT"}),"command"===tv.state.mode&&(0,r.jsxs)("div",{className:"flex items-center flex-1",children:[(0,r.jsx)("span",{className:"text-foreground",children:":"}),(0,r.jsx)("input",{ref:tf,value:tv.state.commandInput,onChange:e=>tv.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(),tv.handleKeyDown(e.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),"search"===tv.state.mode&&(0,r.jsxs)("div",{className:"flex items-center flex-1",children:[(0,r.jsx)("span",{className:"text-foreground",children:"/"}),(0,r.jsx)("input",{ref:tg,value:tv.state.searchInput,onChange:e=>tv.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(),tv.handleKeyDown(e.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),tv.state.keyBuffer&&"normal"===tv.state.mode&&(0,r.jsx)("span",{className:"ml-2 text-muted-foreground",children:tv.state.keyBuffer}),tv.state.isDirty&&("normal"===tv.state.mode||"command"===tv.state.mode)&&(0,r.jsx)("span",{className:"ml-2 text-amber-11",children:"[+]"}),(0,r.jsxs)("span",{className:"ml-auto text-muted-foreground",children:[tv.state.cursorLine+1,":",tv.state.cursorCol+1]})]}),eP&&tp&&(0,a.createPortal)((0,r.jsxs)(r.Fragment,{children:[!G&&(0,r.jsx)(p.fS,{floatingToolbarRef:eM,bumpRef:eI,container:tp,onAddComment:tr,onSendToAI:ts,onSearch:el?ta:void 0,onExplain:ez?to:void 0,isChatLoading:ez?.isLoading}),!G&&eW&&(0,r.jsx)(u.t,{x:eW.x,y:eW.y,range:eW.range,filePath:t,lineSnapshot:eW.lineSnapshot,container:tp,onSubmit:tl,onSendToAI:ez?td:void 0,onClose:()=>e6(null),isChatLoading:ez?.isLoading}),!G&&eq&&(0,r.jsx)(u.G,{x:eq.x,y:eq.y,range:eq.range,filePath:t,lineSnapshot:eq.lineSnapshot,container:tp,onSubmit:ti,onClose:()=>e9(null),isChatLoading:ez?.isLoading}),!G&&eU&&(0,r.jsx)(f.t,{x:eU.x,y:eU.y,comment:eU.comment,container:tp,onClose:()=>e8(null),onUpdateComment:eG,onDeleteComment:eQ}),tq&&(0,r.jsxs)("div",{className:"fixed z-50 bg-card border border-border rounded-lg shadow-lv2 p-3 max-w-lg",style:{left:Math.min(tq.x,window.innerWidth-450),top:Math.max(8,Math.min(tq.y,window.innerHeight-200))},children:[(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"px-2 py-0.5 rounded text-xs font-mono font-medium text-white flex-shrink-0",style:{backgroundColor:tV.get(tq.line.author)?.border||"#666"},children:tq.line.hash}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:tq.line.author}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:tq.line.authorEmail})]})]}),(0,r.jsx)("div",{className:"mt-2 text-sm text-foreground whitespace-pre-wrap max-h-48 overflow-y-auto",children:tq.line.message}),(0,r.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground border-t border-border pt-2",children:[(0,R.fw)(tq.line.time)," \xb7 ",new Date(1e3*tq.line.time).toLocaleString(),(0,r.jsx)("span",{className:"ml-2 text-brand",children:ed("codeViewer.clickToViewDetails")})]})]})]}),tp)]})});function $({content:e,filePath:t,className:n=""}){let o=(0,s.useMemo)(()=>e.split("\n"),[e]),a=(0,m.C)(o,t),l=Math.max(4,String(o.length).length);return(0,r.jsx)("pre",{className:`overflow-auto text-sm font-mono bg-muted p-2 ${n}`,children:o.map((e,t)=>(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{className:"text-foreground-subtle select-none pr-4 text-right",style:{minWidth:`${l+2}ch`},children:t+1}),(0,r.jsx)("span",{className:"flex-1",dangerouslySetInnerHTML:{__html:a[t]||(0,h.ZD)(e||" ")}})]},t))})}},38719:(e,t,n)=>{n.d(t,{M:()=>L});var r=n(95155),s=n(12115),o=n(83897),a=n(57125),l=n(49619);function i({bot:e}){return e?(0,r.jsx)("span",{className:"shrink-0 inline-flex items-center text-brand","data-tooltip":`@${e}`,"aria-label":`Bot session: @${e}`,role:"img",children:(0,r.jsx)(l.A,{className:"h-3.5 w-3.5"})}):null}var d=n(33199),c=n(79114);let u=(0,s.memo)(function({copy:e,onDismiss:t}){let{t:n}=(0,c.Bd)(),o=(0,s.useMemo)(()=>e.messages.map(e=>[`[${e.role}]`,e.content,e.systemEvent?.detail!==e.content?e.systemEvent?.detail:void 0,e.streamError&&!e.content.includes(e.streamError)?e.streamError:void 0,...(e.toolCalls??[]).map(e=>JSON.stringify(e,null,2))].filter(Boolean).join("\n")).join("\n\n"),[e.messages]),a=(0,s.useCallback)(()=>t?.(e.id),[t,e.id]);return(0,r.jsxs)("div",{className:"flex items-start gap-1 text-xs",children:[(0,r.jsxs)("details",{className:"min-w-0 flex-1","data-recovery-id":e.id,children:[(0,r.jsxs)("summary",{className:"cursor-pointer select-none text-muted-foreground hover:text-foreground",children:[n("chat.recoveryCopy")," \xb7 ",new Date(e.startedAt).toLocaleTimeString()]}),(0,r.jsx)("p",{className:"my-2 text-muted-foreground",children:n("chat.recoveryCopyHint")}),(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-words select-text",children:o}),e.messages.flatMap(e=>(e.images??[]).map((t,s)=>(0,r.jsx)("img",{src:`data:${t.media_type};base64,${t.data}`,alt:n("chat.recoveryAttachment"),className:"mt-2 max-h-40 max-w-full object-contain"},`${e.id}-${s}`)))]}),t&&(0,r.jsx)("button",{type:"button",onClick:a,"aria-label":n("common.close"),title:n("common.close"),className:"shrink-0 rounded px-1 leading-4 text-muted-foreground hover:bg-accent hover:text-foreground",children:"\xd7"})]})}),m=(0,s.memo)(function({copies:e,onDismiss:t}){let{t:n}=(0,c.Bd)();return e.length?(0,r.jsx)("aside",{"aria-label":n("chat.recoveryCopiesLabel"),className:"max-h-64 shrink-0 overflow-y-auto space-y-1 px-4 py-1 border-b border-border",children:e.map(e=>(0,r.jsx)(u,{copy:e,onDismiss:t},e.id))}):null});var h=n(1058),p=n(90717),f=n(89109),g=n(7320),x=n(86957),b=n(83448),v=n(62111),y=n(64428);let w=/[,,]/;function k({initialRows:e,lang:t,isCustomized:n,onSave:o,onRestoreDefault:a,onClose:l}){let{t:i}=(0,c.Bd)(),[d,u]=(0,s.useState)(()=>e.map(e=>e.join("zh"===t?",":", ")).join("\n"));(0,v.E)(l);let m=(0,s.useCallback)(()=>{o(d.split("\n").map(e=>e.split(w).map(e=>e.trim().slice(0,200)).filter(Boolean).slice(0,8)).filter(e=>e.length>0).slice(0,12)),l()},[d,o,l]),h=(0,s.useCallback)(()=>{a(),l()},[a,l]);return(0,r.jsx)(y.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim p-4",onClick:l,children:(0,r.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-lv3 w-full max-w-md flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-foreground",children:i("quickReply.editTitle")}),(0,r.jsx)("button",{onClick:l,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors","aria-label":i("quickReply.cancel"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsxs)("div",{className:"px-4 py-3 flex flex-col gap-2",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:i("quickReply.editHint")}),(0,r.jsx)("textarea",{autoFocus:!0,value:d,onChange:e=>u(e.target.value),placeholder:i("quickReply.editPlaceholder"),rows:6,spellCheck:!1,className:"w-full px-2 py-1.5 text-xs bg-background border border-border rounded text-foreground focus:outline-none focus:border-brand resize-y"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:i("quickReply.customizedFor",{lang:i("zh"===t?"quickReply.langZh":"quickReply.langEn")})})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-border",children:[(0,r.jsx)("button",{onClick:h,disabled:!n,className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:i("quickReply.restoreDefault")}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:l,className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-hover transition-colors",children:i("quickReply.cancel")}),(0,r.jsx)("button",{onClick:m,className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",children:i("quickReply.save")})]})]})]})})})}let C={mode:"follow",pinTop:null},j={mode:"free",pinTop:null};function N(e){return Math.max(0,e.scrollHeight-e.spacer)}function S(e){return Math.max(0,N(e)-e.clientHeight)}function T(e,t){return e<=0?0:Math.max(0,e+t.clientHeight-N(t))}function E(e){return N(e)-e.scrollTop-e.clientHeight<50}function R(e,t="auto"){return{owner:C,spacer:0,scrollTo:S(e),behavior:t}}function M({value:e}){let[t,n]=(0,s.useState)(e),o=(0,s.useRef)(e),a=(0,s.useRef)(null);return(0,s.useEffect)(()=>{null!==a.current&&(cancelAnimationFrame(a.current),a.current=null);let t=o.current;if(e<=t){o.current=e,n(e);return}let r=performance.now(),s=l=>{let i=Math.min(1,Math.ceil(12*Math.min(1,(l-r)/400))/12),d=Math.round(t+(e-t)*i);o.current=d,n(d),i<1?a.current=requestAnimationFrame(s):a.current=null};return a.current=requestAnimationFrame(s),()=>{null!==a.current&&cancelAnimationFrame(a.current),a.current=null}},[e]),(0,r.jsx)("span",{className:"tabular-nums",children:t})}let L=(0,s.forwardRef)(function({messages:e,recoveryCopies:t,onDismissRecoveryCopy:n,isLoading:l,cwd:u,sessionId:v,engine:y,botName:w,apiRetryInfo:N,backgroundTasks:L,liveOutputTokens:I,runningStartedAt:A,hasMoreHistory:F,isLoadingMore:P,onLoadMore:$,onFork:D,onDeleteTurn:_,onSendToPeer:O,peerSide:B,isActive:H=!0,snapshotsEnabled:V=H,onContentSearch:U,onShowFileDiff:W,onOpenFileLink:q,onApprovePlan:z,onShowUserMessages:K},G){let Q,{t:J,i18n:Y}=(0,c.Bd)(),Z=(0,s.useRef)(null),X=(0,s.useRef)(null),ee=(0,s.useRef)(null),et=(0,s.useRef)(null),en=(0,s.useRef)(null),er=(0,s.useRef)(null),[es,eo]=(0,s.useState)(null),ea=(0,s.useRef)({mode:"follow",pinTop:null}),el=(0,s.useRef)(null),ei=(0,s.useRef)(!1),ed=(0,s.useRef)(H),ec=(0,s.useCallback)(()=>{let e=ee.current;return e?{clientHeight:e.clientHeight,scrollHeight:e.scrollHeight,scrollTop:e.scrollTop,spacer:el.current?.offsetHeight??0}:null},[]),eu=(0,s.useRef)(null),em=(0,s.useCallback)(e=>{let t=ec();if(!t)return!1;let n=function(e,t,n){if(!(n.clientHeight>0))return null;switch(t.type){case"reset":return{owner:C,spacer:0,scrollTo:null,behavior:"auto"};case"toEnd":return R(n,"smooth");case"readFrom":{let e=t.top;return{owner:{mode:"reading",pinTop:e},spacer:T(e,n),scrollTo:e,behavior:"auto"}}case"settle":{if("reading"===e.mode){let t=e.pinTop??n.scrollTop;return{owner:e,spacer:T(t,n),scrollTo:null,behavior:"auto"}}if(n.spacer<=0)return null;let t=Math.min(n.scrollTop,S(n));return{owner:t>=S(n)?C:j,spacer:0,scrollTo:t,behavior:"smooth",deferSpacer:!0}}case"pin":{let e=T(t.top,n);if(e<=0)return R(n);return{owner:{mode:"pinned",pinTop:t.top},spacer:e,scrollTo:t.top,behavior:"smooth"}}case"jump":return{owner:j,spacer:T(n.scrollTop,n),scrollTo:null,behavior:"auto"};case"release":if("pinned"!==e.mode&&"reading"!==e.mode)return null;return{owner:j,spacer:T(n.scrollTop,n),scrollTo:null,behavior:"auto"};case"content":case"viewport":if("follow"===e.mode)return R(n);if("pinned"===e.mode){let r=e.pinTop??n.scrollTop,s=T(r,n);if(s<=0)return R(n);return{owner:e,spacer:s,scrollTo:"viewport"===t.type?r:null,behavior:"auto"}}if("reading"===e.mode){let r=e.pinTop??n.scrollTop;return{owner:e,spacer:T(r,n),scrollTo:"viewport"===t.type?r:null,behavior:"auto"}}return{owner:e,spacer:T(n.scrollTop,n),scrollTo:null,behavior:"auto"}}}(ea.current,e,t);if(!n)return!1;eu.current?.(),ea.current=n.owner;let r=()=>{el.current&&(el.current.style.height=`${n.spacer}px`)};n.deferSpacer||r();let s=ee.current;if(null!==n.scrollTo&&s?.scrollTo({top:n.scrollTo,behavior:n.behavior}),n.deferSpacer&&s){let e=()=>{n(),r()},t=setTimeout(e,700),n=()=>{clearTimeout(t),s.removeEventListener("scrollend",e),eu.current=null};s.addEventListener("scrollend",e,{once:!0}),eu.current=n}return!0},[ec]);(0,s.useEffect)(()=>()=>eu.current?.(),[]);let[eh,ep]=(0,s.useState)(!1),[ef,eg]=(0,s.useState)(!1),[ex,eb]=(0,s.useState)(null),[ev,ey]=(0,s.useState)(0);(0,s.useEffect)(()=>{eo(er.current)},[]),(0,s.useEffect)(()=>{if(!l||!A)return void ey(0);let e=()=>ey(Math.max(0,Math.floor((Date.now()-A)/1e3)));e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[l,A]);let ew=(0,s.useMemo)(()=>(0,a.ch)(y)?a.H[y]:a.H.claude,[y]),ek=(0,a.ch)(y)?y:"claude",eC=(0,s.useMemo)(()=>{let e=Math.floor(ev/60),t=ev%60;return e>0?`${e}m${t}s`:`${t}s`},[ev]),{isSearchVisible:ej,searchQuery:eN,setSearchQuery:eS,matches:eT,currentMatchIndex:eE,goToNextMatch:eR,goToPrevMatch:eM,closeSearch:eL,searchInputRef:eI,handleSearchKeyDown:eA}=function(e){let[t,n]=(0,s.useState)(!1),[r,o]=(0,s.useState)(""),[a,l]=(0,s.useState)([]),[i,d]=(0,s.useState)(0),c=(0,s.useRef)(null),u=(0,s.useRef)([]),m=(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]),h=(0,s.useCallback)(t=>{if(m(),!t||!e.current){l([]),d(0);return}let n=[],r=[],s=t.toLowerCase();e.current.querySelectorAll("[data-message-id]").forEach(e=>{let o,a=e.getAttribute("data-message-id")||"",l=0,i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),d=[];for(;o=i.nextNode();)d.push(o);for(let e of d){let o=(e.textContent||"").toLowerCase(),i=0,d=[];for(;;){let e=o.indexOf(s,i);if(-1===e)break;d.push({start:e,end:e+t.length}),i=e+1}if(0!==d.length)for(let t=d.length-1;t>=0;t--){let s=d[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),n.push({messageId:a,markIndex:l}),r.push(i),l++}}}),n.reverse(),r.reverse(),u.current=r,l(n),d(n.length>0?0:-1)},[e,m]);(0,s.useEffect)(()=>{queueMicrotask(()=>h(r))},[r,h]),(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,a]);let p=(0,s.useCallback)(()=>{0!==a.length&&d(e=>(e+1)%a.length)},[a.length]),f=(0,s.useCallback)(()=>{0!==a.length&&d(e=>(e-1+a.length)%a.length)},[a.length]),g=(0,s.useCallback)(()=>{n(!0),setTimeout(()=>c.current?.focus(),0)},[]),x=(0,s.useCallback)(()=>{n(!1),o(""),m(),l([]),d(0)},[m]),b=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?f():p()),"Escape"===e.key&&x()},[p,f,x]);return(0,s.useEffect)(()=>{let t=e.current;if(!t)return;let n=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),e.stopPropagation(),g())};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)},[e,g]),{isSearchVisible:t,searchQuery:r,setSearchQuery:o,matches:a,currentMatchIndex:i,goToNextMatch:p,goToPrevMatch:f,openSearch:g,closeSearch:x,searchInputRef:c,handleSearchKeyDown:b}}(er),eF=(0,o.nH)(),eP=(0,s.useRef)(null),e$=(0,s.useRef)(()=>{}),{addComment:eD,refresh:e_}=(0,h._)({cwd:u||"",filePath:p.Un}),[eO,eB]=(0,s.useState)(null),[eH,eV]=(0,s.useState)(null),eU=(0,s.useCallback)(e=>{if(eO||eH)return;let t=window.getSelection();if(!t||t.isCollapsed||!t.rangeCount){eP.current=null,e$.current();return}let n=t.toString().trim();if(!n){eP.current=null,e$.current();return}let r=t.anchorNode instanceof HTMLElement?t.anchorNode:t.anchorNode?.parentElement;if(r?.closest('[data-role="user"]')){eP.current=null,e$.current();return}eP.current={x:e.clientX,y:e.clientY,range:{start:0,end:0},selectedText:n,lineSnapshot:n},e$.current()},[eO,eH]),eW=(0,s.useCallback)(e=>{let t=e.target;!(t.closest(".floating-toolbar")||t.closest('[class*="z-[200]"]'))&&eP.current&&(eP.current=null,e$.current())},[]),eq=(0,s.useCallback)(()=>{let e=eP.current;e&&(eB({x:e.x,y:e.y,text:e.selectedText}),eP.current=null,e$.current(),window.getSelection()?.removeAllRanges())},[]),ez=(0,s.useCallback)(()=>{let e=eP.current;e&&(eV({x:e.x,y:e.y,text:e.selectedText}),eP.current=null,e$.current(),window.getSelection()?.removeAllRanges())},[]),eK=(0,s.useCallback)(()=>{let e=eP.current;e&&eF&&(eP.current=null,e$.current(),window.getSelection()?.removeAllRanges(),(0,p.Ff)(eF.sendMessage,{filePath:p.Un,startLine:0,endLine:0,codeContent:e.selectedText},J("explain.selectionMessage")))},[eF,J]),eG=(0,s.useCallback)(()=>{let e=eP.current;if(!e||!U)return;let t=e.selectedText.trim();eP.current=null,e$.current(),window.getSelection()?.removeAllRanges(),t&&U(t)},[U]),eQ=(0,s.useCallback)(async e=>{eO&&(await eD(0,0,e,eO.text),eB(null))},[eO,eD]),eJ=(0,s.useCallback)(async(e,t)=>{if(eF&&u)try{let n=(await (0,p.$3)(u)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));n.push({filePath:p.Un,startLine:0,endLine:0,codeContent:e});let r=(0,p.Gw)(n,t);eF.sendMessage(r),await (0,p.RP)(u),e_()}catch(e){console.error("Failed to send to AI:",e)}},[eF,u,e_]),eY=(0,s.useCallback)((e,t)=>{let n=eP.current;if(!n)return;let r=n.selectedText;eP.current=null,e$.current(),window.getSelection()?.removeAllRanges(),"comment"===e?eD(0,0,t,r):eJ(r,t)},[eD,eJ]),eZ=(Q=Y.language,Q?.toLowerCase().startsWith("zh")?"zh":"en"),[eX,e0]=(0,s.useState)(null),[e1,e2]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=!1;return x.t4.runPromiseExit((0,b.td)()).then(t=>{e||e0("Success"===t._tag?((e,t)=>{if(!e||"object"!=typeof e)return null;let n=e.quickReplies;return n&&"object"==typeof n?(e=>{if(!Array.isArray(e))return null;let t=[];for(let n of e.slice(0,12)){if(!Array.isArray(n))continue;let e=[];for(let t of n.slice(0,8)){if("string"!=typeof t)continue;let n=t.trim().slice(0,200);n&&e.push(n)}e.length&&t.push(e)}return t.length?t:null})(n[t]):null})(t.value,eZ):null)}),()=>{e=!0}},[eZ]);let e5=(0,s.useCallback)(e=>{x.t4.runPromiseExit((0,b.td)()).then(t=>{let n={..."Success"===t._tag?t.value.quickReplies??{}:{}};return e?n[eZ]=e:delete n[eZ],x.t4.runPromiseExit((0,b.em)({quickReplies:n})).then(t=>{"Success"===t._tag?e0(e):console.error("Failed to save quick replies:",t.cause)})})},[eZ]),e4=(0,s.useCallback)(()=>{eP.current=null,e$.current(),window.getSelection()?.removeAllRanges(),e2(!0)},[]),e3=(0,s.useMemo)(()=>eX??f.SZ.map(e=>e.map(e=>J(e))),[eX,J]),e8=(0,s.useCallback)(e=>{eH&&eJ(eH.text,e)},[eH,eJ]),e6=(0,s.useCallback)(e=>{eO&&eJ(eO.text,e)},[eO,eJ]),e9=(0,s.useMemo)(()=>{let t=new Set;return e.filter(e=>!t.has(e.id)&&(t.add(e.id),"assistant"!==e.role||!!e.isStreaming||!!e.content||!!e.images?.length||!!e.toolCalls?.length||!!e.parts?.length))},[e]),e7=(0,s.useMemo)(()=>e9.filter(e=>"user"===e.role),[e9]),te=(0,s.useMemo)(()=>e7.slice(-10),[e7]),tt=F||e7.length>10,tn=(0,s.useRef)(0),tr=(0,s.useRef)(!1),ts=(0,s.useCallback)(()=>{let e=ee.current;return!e||e.scrollTop<50},[]),to=(0,s.useCallback)((e=!1)=>{let t=ee.current;if(!t)return;if(e&&te.length>0)return void eb(te[te.length-1].id);let n=t.getBoundingClientRect(),r=null,s=null;for(let e of te){let o=t.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);if(!o)continue;let a=o.getBoundingClientRect().top;!s&&a<n.bottom&&(s=e.id),a<=n.top+12&&(r=e.id)}eb(r??s)},[te]),ta=(0,s.useCallback)(()=>{let e=ec(),t=!e||E(e),n=ts();if(e&&(ea.current=function(e,t){return"pinned"===e.mode||"reading"===e.mode?e:50>Math.abs(t.scrollTop-S(t))?C:j}(ea.current,e)),ep(!n),eg(!t),to(t),n&&F&&!P&&$){let e=ee.current;e&&(tn.current=e.scrollHeight,tr.current=!0),$()}},[ts,ec,to,F,P,$]),tl=(0,s.useCallback)(()=>{em({type:"release"}),X.current?.scrollIntoView({behavior:"smooth"})},[em]),ti=(0,s.useCallback)(()=>{em({type:"toEnd"})},[em]),td=(0,s.useCallback)(e=>{let t=ee.current;if(!t)return!1;let n=t.querySelector(`[data-message-id="${e}"]`);if(!n)return!1;let r=n.getBoundingClientRect().top-t.getBoundingClientRect().top;return t.scrollTo({top:t.scrollTop+r-8,behavior:"auto"}),em({type:"jump"}),et.current&&clearTimeout(et.current),en.current?.classList.remove("flash-turn"),n.classList.remove("flash-turn"),n.offsetWidth,n.classList.add("flash-turn"),en.current=n,et.current=setTimeout(()=>{n.classList.remove("flash-turn"),en.current=null,et.current=null},2e3),!0},[em]),tc=(0,s.useRef)(!1),tu=(0,s.useCallback)(()=>{tc.current=!0},[]);(0,s.useImperativeHandle)(G,()=>({scrollToMessage:td,pinNextUserMessage:tu}),[td,tu]),(0,s.useLayoutEffect)(()=>{let e;if(!tc.current)return;let t=ee.current;if(!t)return;for(let t=e9.length-1;t>=0;t-=1)if("user"===e9[t].role){e=e9[t];break}if(!e)return;let n=t.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);n&&(tc.current=!1,em({type:"pin",top:Math.max(0,n.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop-8)}))},[e9,em]),(0,s.useLayoutEffect)(()=>{let e=ed.current;ed.current=H,e&&!H&&l&&(ei.current=!0)},[H,l]),(0,s.useLayoutEffect)(()=>{tr.current||em({type:"content"})},[e,l,em]),(0,s.useEffect)(()=>{let e=ee.current;if(!e)return;let t=new ResizeObserver(()=>em({type:"viewport"}));return t.observe(e),()=>t.disconnect()},[em]),(0,s.useEffect)(()=>{let e=ee.current;if(!e)return;let t=()=>em({type:"release"});return e.addEventListener("wheel",t,{passive:!0}),e.addEventListener("touchmove",t,{passive:!0}),e.addEventListener("keydown",t),()=>{e.removeEventListener("wheel",t),e.removeEventListener("touchmove",t),e.removeEventListener("keydown",t)}},[em]);let tm=(0,s.useRef)(v);(0,s.useEffect)(()=>{let e=tm.current;tm.current=v,e&&e!==v&&(tc.current=!1,ei.current=!1,em({type:"reset"}))},[v,em]),(0,s.useLayoutEffect)(()=>{if(tr.current&&!P){let e=ee.current;if(e){let t=e.scrollHeight-tn.current;e.scrollTop=t,tr.current=!1}}},[e,P]);let th=(0,s.useRef)(l),tp=(0,s.useRef)(!1);return(0,s.useEffect)(()=>{let e=th.current;th.current=l,e&&!l&&(tp.current=!em({type:"settle"}))},[l,em]),(0,s.useLayoutEffect)(()=>{if(H){if(ei.current){let e=ee.current,t=e?.querySelectorAll('[data-role="user"]'),n=t?.item((t?.length??0)-1);if(e&&n&&em({type:"readFrom",top:Math.max(0,n.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop-8)})){ei.current=!1,tp.current=!1;return}}em({type:"viewport"}),tp.current&&(tp.current=!1,em({type:"settle"}))}},[H,em]),(0,s.useEffect)(()=>{if(!H)return;let e=ec();to(!!e&&E(e))},[e,H,ec,to]),(0,r.jsxs)("div",{ref:er,className:"relative flex-1 min-h-0 overflow-hidden flex flex-col outline-none",tabIndex:-1,onMouseUp:eU,onMouseDown:eW,children:[t&&(0,r.jsx)(m,{copies:t,onDismiss:n}),ej&&(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,r.jsx)("input",{ref:eI,type:"text",value:eN,onChange:e=>eS(e.target.value),onKeyDown:eA,placeholder:J("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,r.jsx)("span",{className:"text-xs text-muted-foreground",children:eT.length>0?`${eE+1}/${eT.length}`:J("common.noMatch")}),(0,r.jsx)("button",{onClick:eM,disabled:0===eT.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:J("codeViewer.prevShiftEnter"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,r.jsx)("button",{onClick:eR,disabled:0===eT.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:J("codeViewer.nextEnter"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("button",{onClick:eL,className:"p-1 rounded hover:bg-hover",title:J("codeViewer.closeEsc"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{ref:ee,onScroll:ta,className:"relative flex-1 min-h-0 overflow-y-auto px-8 py-4 [mask-image:linear-gradient(to_bottom,transparent,black_24px,black_calc(100%-24px),transparent)]",children:0!==e.length||l?(0,r.jsxs)("div",{className:"mx-auto w-full max-w-[var(--chat-column)]",children:[(0,r.jsx)("div",{ref:X}),F&&(0,r.jsx)("div",{className:"flex justify-center py-3",children:P?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,r.jsx)("span",{children:J("chat.loadMoreHistory")})]}):(0,r.jsx)("button",{onClick:$,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:J("chat.scrollUpForMore")})}),e9.map(e=>(0,r.jsx)("div",{"data-message-id":e.id,"data-role":e.role,children:(0,r.jsx)(d.s,{message:e,cwd:u,sessionId:v,snapshotsEnabled:V,onFork:D,onDeleteTurn:_,forkSupported:!0,onSendToPeer:O,peerSide:B,onApprovePlan:z,isLoading:l,onContentSearch:U,onShowFileDiff:W,onOpenFileLink:q})},e.id)),l&&(0,r.jsx)("div",{className:"flex justify-start mb-4",children:(0,r.jsxs)("div",{className:"px-1 py-1 max-w-[90%]",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[(0,r.jsx)(i,{bot:w}),(0,r.jsx)("span",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center","aria-hidden":"true",children:(0,r.jsx)(a.eV,{engine:ek,className:"h-4 w-4"})}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground/80 text-shimmer",children:[ew," running ",eC," \xb7 processing"," ",(0,r.jsx)(M,{value:I?.outputTokens??0})]})]}),L&&L.length>0&&(0,r.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-muted-foreground border-t border-border/50 pt-2",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{children:["Waiting on ",L.length," background task",L.length>1?"s":""]}),L.map(e=>(0,r.jsx)("div",{className:"text-muted-foreground/80 break-words",children:e.description},e.task_id))]})]}),N&&(0,r.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-amber-11 border-t border-border/50 pt-2",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{children:["Retrying API call (attempt ",N.attempt,N.maxRetries>0?`/${N.maxRetries}`:"",N.delayMs>0?`, delay ${(N.delayMs/1e3).toFixed(1)}s`:"",")"]}),(N.errorStatus||N.error)&&(0,r.jsxs)("div",{className:"text-muted-foreground/80 break-words",children:[N.errorStatus?`${N.errorStatus}`:"",N.errorStatus&&N.error?" \xb7 ":"",N.error||""]})]})]})]})}),(0,r.jsx)("div",{ref:el,"aria-hidden":!0}),(0,r.jsx)("div",{ref:Z})]}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full text-foreground-subtle",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-4xl mb-4",children:"\uD83D\uDCAC"}),(0,r.jsx)("div",{children:J("chat.startConversation")})]})})}),(te.length>0||eh||ef)&&(0,r.jsxs)("nav",{className:"absolute top-1/2 z-10 flex -translate-y-1/2 flex-col items-center gap-2",style:{right:"max(0.5rem, calc(50% - var(--chat-column) / 2 - 2.25rem))"},"aria-label":J("chat.recentUserMessages"),children:[eh&&e.length>0&&(0,r.jsx)("button",{onClick:tl,className:"mb-1 flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition-all hover:bg-hover hover:text-foreground active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:J("chat.jumpToStart"),"aria-label":J("chat.jumpToStart"),children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 5h14M12 19V9m-5 5l5-5 5 5"})})}),tt&&K&&(0,r.jsx)("button",{onClick:K,className:"mb-1 flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:J("chat.moreUserMessages"),"aria-label":J("chat.moreUserMessages"),children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),te.map((e,t)=>{let n=ex===e.id,s=e.content.replace(/\s+/g," ").trim()||(e.images?.length?J("chat.imageMessage"):J("chat.userMessage"));return(0,r.jsxs)("div",{className:"group relative flex h-3 items-center",children:[(0,r.jsx)("button",{onClick:t=>{td(e.id),t.detail>0&&t.currentTarget.blur()},className:"flex h-3 w-7 items-center justify-center rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-current":n?"true":void 0,"aria-label":J("chat.recentUserMessageNumber",{index:t+1,total:te.length}),children:(0,r.jsx)("span",{"aria-hidden":!0,className:`h-0.5 rounded-full transition-all ${n?"w-4 bg-foreground":"w-3 bg-foreground/20 group-hover:w-4 group-hover:bg-foreground/45"}`})}),(0,r.jsx)("div",{className:"pointer-events-none absolute right-8 top-1/2 hidden w-72 -translate-y-1/2 rounded-xl border border-border bg-card px-3 py-2.5 text-left shadow-lv2 group-hover:block group-focus-within:block",children:(0,r.jsx)("div",{className:"line-clamp-4 text-sm leading-5 text-foreground",children:s})})]},e.id)}),ef&&e.length>0&&(0,r.jsx)("button",{onClick:ti,className:"mt-1 flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition-all hover:bg-hover hover:text-foreground active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:J("chat.jumpToLatest"),"aria-label":J("chat.jumpToLatest"),children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 19H5m7-14v10m5-5l-5 5-5-5"})})})]}),es&&(0,r.jsx)(f.fS,{floatingToolbarRef:eP,bumpRef:e$,container:es,onAddComment:eq,onSendToAI:ez,onSearch:U?eG:void 0,onExplain:eF?eK:void 0,onQuickReply:eY,quickReplyRows:e3,onEditQuickReplies:e4,isChatLoading:eF?.isLoading}),e1&&(0,r.jsx)(k,{initialRows:e3,lang:eZ,isCustomized:null!==eX,onSave:e=>e5(e.length?e:null),onRestoreDefault:()=>e5(null),onClose:()=>e2(!1)}),eO&&es&&(0,r.jsx)(g.t,{x:eO.x,y:eO.y,range:{start:0,end:0},lineSnapshot:eO.text,container:es,onSubmit:eQ,onSendToAI:eF?e6:void 0,onClose:()=>eB(null),isChatLoading:eF?.isLoading}),eH&&es&&(0,r.jsx)(g.G,{x:eH.x,y:eH.y,range:{start:0,end:0},lineSnapshot:eH.text,container:es,onSubmit:e8,onClose:()=>eV(null),isChatLoading:eF?.isLoading})]})})},39872:(e,t,n)=>{n.d(t,{B:()=>o});var r=n(95155),s=n(68287);function o({number:e,status:t="normal",isActive:n=!1}){return(0,r.jsx)("span",{className:`flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center rounded-[4px] border font-mono text-[10px] font-medium leading-none tabular-nums transition-colors ${(0,s.ci)(t,n)}`,"aria-hidden":"true",children:e})}},41066:(e,t,n)=>{n.d(t,{X:()=>i});var r=n(12115),s=n(49433);let o=["ollama","deepseek","kimi","glm"];var a=n(77725),l=n(83448);function i(e,t,n,i,d){let[c,u]=(0,r.useState)(0),[m,h]=(0,r.useState)(),p=JSON.stringify([e,t,n,i,d,c]),f=(0,a.Z)((0,r.useMemo)(()=>o.some(t=>t===e)&&t&&("ollama"===e||d)?(0,l.sy)(e,t,n,i).pipe(s.TjK(e=>({key:p,options:e}))):s.PyW(void 0),[e,t,n,i,d,p]),[p]),g="success"===f.status&&f.data?.key===p?f.data.options:void 0,x=m&&m.engine===e&&m.cwd===n&&(m.sessionId===i||null===m.sessionId)?m.level:void 0,b=g?x&&g.levels.includes(x)?x:g.selectedLevel:void 0;return{options:g,level:b,onChange:(0,r.useCallback)(t=>{e&&h({engine:e,cwd:n,sessionId:i,level:t})},[e,n,i]),retry:(0,r.useCallback)(()=>u(e=>e+1),[]),error:"error"===f.status?f.error:void 0}}},41948:(e,t,n)=>{function r(e){let t,n,r=[],s=[],o=!1;for(let a of e)(void 0!==a.turnId?a.turnId!==t:"user"===a.role?o||n!==a.id:void 0!==a.turnUserId&&(o||n!==a.turnUserId))&&(s.length>0&&r.push(s),s=[],n=void 0,o=!1),s.push(a),t=a.turnId,"user"===a.role?o=!0:void 0!==a.turnUserId&&(n=a.turnUserId);return s.length>0&&r.push(s),r}function s(e,t){let n=r(e),s=n.findIndex(e=>e.some(e=>e.id===t));return s<0?e:n.filter((e,t)=>t!==s).flat()}n.d(t,{T:()=>s,l:()=>r})},43595:(e,t,n)=>{n.d(t,{U:()=>l});var r=n(48764),s=n(58250),o=n(51536);let a={add:r.L5,notify:s.k,namespace:"skills",failureKey:"skills.addFailed"},l=()=>(0,o.X)(a)},45619:(e,t,n)=>{n.d(t,{xU:()=>E,xZ:()=>T});var r=n(95155),s=n(12115),o=n(79114),a=n(64702),l=n(22576),i=n(19502),d=n(34075),c=n(56978),u=n(17196);function m({lines:e,containerRef:t}){let n=(0,s.useRef)(null),[o,a]=(0,s.useState)({top:0,height:0});if((0,s.useEffect)(()=>{let e=t.current;if(!e)return;let r=()=>{let{scrollTop:t,scrollHeight:r,clientHeight:s}=e,o=n.current?.clientHeight||0;if(r<=s)a({top:0,height:o});else{let e=o/r;a({top:t*e,height:s*e})}};return r(),e.addEventListener("scroll",r),window.addEventListener("resize",r),()=>{e.removeEventListener("scroll",r),window.removeEventListener("resize",r)}},[t]),0===e.length)return null;let l=100/e.length;return(0,r.jsxs)("div",{ref:n,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:e=>{let r=t.current,s=n.current;if(!r||!s)return;let o=s.getBoundingClientRect(),a=(e.clientY-o.top)/o.height*r.scrollHeight-r.clientHeight/2;r.scrollTo({top:Math.max(0,a),behavior:"smooth"})},children:[e.map((e,t)=>"unchanged"!==e.type&&(0,r.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===e.type?"bg-red-9":"bg-green-9"}`,style:{top:`${t*l}%`,height:`${Math.max(l,.5)}%`,minHeight:"2px"}},t)),(0,r.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`}})]})}var h=n(47650),p=n(1058),f=n(90717),g=n(69809),x=n(70188),b=n(48347),v=n(89109),y=n(7320),w=n(37614),k=n(27570);function C({cwd:e,enableComments:t=!1,filePath:n,diffLines:o,containerEl:a,onContentSearch:l}){let i=(0,x.iN)(),d=(0,b.r)(),c=t&&!!e,{comments:u,addComment:m,updateComment:j,deleteComment:N,refresh:S}=(0,p._)({cwd:e||"",filePath:n}),[T,E]=(0,s.useState)(null),{toolbarRef:R,bumpRef:M,clearToolbar:L}=(0,k.L)({enabled:c,container:a,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,n=t?.closest("[data-new-line]");if(!n)return null;let r=parseInt(n.getAttribute("data-new-line")||"0",10);return!Number.isFinite(r)||r<=0?null:{start:r,end:r}},buildLineSnapshot:({start:e,end:t})=>{let n=[],r=0;for(let s of o)("unchanged"===s.type||"added"===s.type)&&++r>=e&&r<=t&&n.push(s.content);return n.join("\n")}}),[I,A]=(0,s.useState)(null),[F,P]=(0,s.useState)(null),[$,D]=(0,s.useState)(!1);(0,s.useEffect)(()=>{D(!0)},[]);let _=(0,s.useMemo)(()=>{let e=new Set;for(let t of u)for(let n=t.startLine;n<=t.endLine;n++)e.add(n);return e},[u]),O=(0,s.useMemo)(()=>{let e=new Map;for(let t of u){let n=t.endLine;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[u]),B=(0,s.useCallback)((e,t)=>{t.stopPropagation(),E({comment:e,x:t.clientX,y:t.clientY}),L(),A(null),P(null)},[L]),H=(0,s.useCallback)(()=>{let e=R.current;e&&(A({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),L())},[L,R]),V=(0,s.useCallback)(()=>{let e=R.current;e&&(P({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),L())},[L,R]),U=(0,s.useCallback)(()=>{let e=R.current;e&&d&&(L(),(0,f.Ff)(d.sendMessage,{filePath:n,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},g.A.t("explain.selectionMessage")))},[d,n,L,R]),W=(0,s.useCallback)(()=>{let e=R.current;if(!e||!l)return;let t=e.selectedText.trim();L(),t&&l(t)},[l,L,R]),q=(0,s.useCallback)(async(t,r)=>{if(d&&e)try{let s=await (0,f.$3)(e),o=[];for(let e of s)o.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});o.push({filePath:n,startLine:t.range.start,endLine:t.range.end,codeContent:t.lineSnapshot});let a=(0,f.Gw)(o,r);d.sendMessage(a),await (0,f.RP)(e),S()}catch(e){console.error("Failed to send to AI:",e)}},[d,n,e,S]),z=(0,s.useCallback)(e=>{F&&q(F,e)},[F,q]),K=(0,s.useCallback)(e=>{I&&q(I,e)},[I,q]),G=(0,s.useCallback)(async e=>{I&&(await m(I.range.start,I.range.end,e,I.selectedText),A(null))},[I,m]),Q=$&&i?(0,h.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.fS,{floatingToolbarRef:R,bumpRef:M,container:i,onAddComment:H,onSendToAI:V,onSearch:l?W:void 0,onExplain:d?U:void 0,isChatLoading:d?.isLoading??!1}),I&&(0,r.jsx)(y.t,{x:I.x,y:I.y,range:I.range,filePath:n,lineSnapshot:I.lineSnapshot,container:i,onSubmit:G,onSendToAI:d?K:void 0,onClose:()=>A(null),isChatLoading:d?.isLoading}),F&&(0,r.jsx)(y.G,{x:F.x,y:F.y,range:F.range,filePath:n,lineSnapshot:F.lineSnapshot,container:i,onSubmit:z,onClose:()=>P(null),isChatLoading:d?.isLoading}),T&&(0,r.jsx)(w.t,{x:T.x,y:T.y,comment:T.comment,container:i,onClose:()=>E(null),onUpdateComment:j,onDeleteComment:N})]}),i):null;return{commentsEnabled:c,linesWithComments:_,commentsByEndLine:O,handleCommentBubbleClick:B,addCommentRange:I?.range??null,sendToAIRange:F?.range??null,commentPortal:Q}}var j=n(96497);function N(e){return(0,s.useCallback)((t,n)=>{if(!e||n<=0)return;let r=(0,j.A)(t,t.currentTarget);r&&e(n,r.column,r.rect)},[e])}function S(e){return e.params?`${e.name}(${e.params.join(", ")})`:e.name}function T({oldContent:e,newContent:t,filePath:n,isNew:h=!1,isDeleted:p=!1,cwd:f,enableComments:g=!1,onPreview:x,previewLabel:b,headerLeading:v,onContentSearch:y,targetLine:w,compact:k=!1,highlight:j=!0,symbols:E,onTokenHover:R,onTokenHoverLeave:M,onTokenHoverCancel:L}){let{t:I}=(0,o.Bd)(),A=N(R),F=b??I("common.preview"),P=(0,s.useMemo)(()=>(0,l.X)(e,t),[e,t]),$=(0,s.useRef)(null),D=(0,s.useRef)(null),_=(0,s.useRef)(null),O=(0,s.useRef)(!1),[B,H]=(0,s.useState)(null);(0,s.useEffect)(()=>{_.current!==B&&H(_.current)});let{commentsEnabled:V,linesWithComments:U,commentsByEndLine:W,handleCommentBubbleClick:q,addCommentRange:z,sendToAIRange:K,commentPortal:G}=C({cwd:f,enableComments:g,filePath:n,diffLines:P,containerEl:B,onContentSearch:y});(0,s.useEffect)(()=>{let e=D.current,t=_.current;if(!e||!t)return;let n=(e,t)=>{O.current||(O.current=!0,t.scrollLeft=e.scrollLeft,requestAnimationFrame(()=>{O.current=!1}))},r=()=>n(e,t),s=()=>n(t,e);return e.addEventListener("scroll",r),t.addEventListener("scroll",s),()=>{e.removeEventListener("scroll",r),t.removeEventListener("scroll",s)}},[]);let{leftLines:Q,rightLines:J}=(0,s.useMemo)(()=>{let e=[],t=[],n=0,r=0;for(let s=0;s<P.length;s++){let o=P[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});n++,r++,e.push({lineNum:n,content:o.content,type:"unchanged",originalIdx:s}),t.push({lineNum:r,content:o.content,type:"unchanged",originalIdx:s})}else"removed"===o.type?(n++,e.push({lineNum:n,content:o.content,type:"removed",originalIdx:s})):"added"===o.type&&(r++,t.push({lineNum:r,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}},[P]),Y=(0,s.useMemo)(()=>P.map(e=>e.content),[P]),Z=(0,c.C)(Y,n,j),[X,ee]=(0,s.useState)(()=>new Map);(0,s.useLayoutEffect)(()=>{ee(new Map),ei.measure()},[Q,J]);let et=(0,s.useMemo)(()=>E??[],[E]),{rows:en,gaps:er}=(0,s.useMemo)(()=>k?(0,i.pU)(Q,J,X,et):{rows:Q.map((e,t)=>({kind:"diff",idx:t})),gaps:[]},[k,Q,Q,J,X,et]),es=(0,s.useCallback)((e,t)=>{let n=er.find(t=>t.id===e);n&&ee(r=>{let s=r.get(e)??{topRevealed:0,bottomRevealed:0},o=n.endIdx-n.startIdx+1-s.topRevealed-s.bottomRevealed;if(o<=0)return r;let a=Math.min(i.YO,o),l="up"===t?{...s,topRevealed:s.topRevealed+a}:{...s,bottomRevealed:s.bottomRevealed+a};return new Map(r).set(e,l)})},[er]),eo=(0,s.useCallback)(e=>{for(let t of er)if(e>=t.startIdx&&e<=t.endIdx)return t.id;return null},[er]),ea=(0,s.useCallback)(e=>en[e]?.kind==="gap-label"?28:20,[en]),el=(0,s.useCallback)(e=>{let t=en[e];if(!t)return e;if("gap-label"===t.kind)return`gl:${t.gapId}`;if("gap-expand"===t.kind)return`ge:${t.gapId}:${t.direction}`;let n=Q[t.idx],r=J[t.idx];return`d:${n?.lineNum??"x"}:${n?.type??"x"}:${r?.lineNum??"x"}:${r?.type??"x"}`},[en,Q,J]),ei=(0,a.Te)({count:en.length,getScrollElement:()=>$.current,estimateSize:ea,getItemKey:el,overscan:20}),ed=h?"w-1/4":p?"w-3/4":"w-1/2",ec=h?"w-3/4":p?"w-1/4":"w-1/2",eu=(0,s.useMemo)(()=>en.map(e=>{if("diff"!==e.kind)return{type:"unchanged"};let t=Q[e.idx],n=J[e.idx];return"removed"===t.type?{type:"removed"}:n?.type==="added"?{type:"added"}:{type:"unchanged"}}),[en,Q,J]),em=ei.getTotalSize(),eh=ei.getVirtualItems();return(0,s.useEffect)(()=>{if(!w)return;let e=("after"===w.side?J:Q).findIndex(e=>e.lineNum===w.line);if(-1===e)return;let t=en.findIndex(t=>"diff"===t.kind&&t.idx===e);if(-1===t){let t=eo(e);if(null!==t){let e=er.find(e=>e.id===t);if(!e)return;let n=e.endIdx-e.startIdx+1;ee(e=>{let r=e.get(t)??{topRevealed:0,bottomRevealed:0};if(r.topRevealed+r.bottomRevealed>=n)return e;let s=new Map(e);return s.set(t,{topRevealed:n,bottomRevealed:0}),s})}return}let n=requestAnimationFrame(()=>{ei.scrollToIndex(t,{align:"start"})});return()=>cancelAnimationFrame(n)},[w,Q,J,en]),(0,r.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[v&&(0,r.jsx)("div",{className:"flex-shrink-0 px-2 py-1 border-b border-border bg-accent",children:v}),(0,r.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,r.jsx)("div",{className:`${ed} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:h?"(New File)":p?"Deleted":"Old"}),(0,r.jsxs)("div",{className:`${ec} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,r.jsx)("span",{className:"block text-center",children:p?"(Deleted)":"New"}),(0,r.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[x&&(0,r.jsx)("button",{onClick:x,className:"text-muted-foreground hover:text-foreground transition-colors",children:F}),!p&&t&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,d.oR)(I("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:I("common.copy")})]})]}),(0,r.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,r.jsx)("div",{ref:$,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,r.jsxs)("div",{className:"flex",style:{height:`${em}px`},children:[(0,r.jsx)("div",{ref:D,className:`${ed} overflow-x-auto border-r border-border`,children:(0,r.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eh.map(e=>{let t=en[e.index];if("gap-expand"===t.kind||"gap-label"===t.kind){let n="gap-label"===t.kind;return(0,r.jsx)("div",{ref:ei.measureElement,"data-index":e.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,ea(e.index))}px`,transform:`translateY(${e.start}px)`},className:n?"bg-accent border-y border-border":""},e.key)}let n=Q[t.idx];return(0,r.jsxs)("div",{ref:ei.measureElement,"data-index":e.index,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,ea(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${"removed"===n.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:n.lineNum||""}),(0,r.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:n.originalIdx>=0&&Z[n.originalIdx]||(0,u.ZD)(n.content||" ")}})]},e.key)})})}),(0,r.jsx)("div",{ref:_,className:`${ec} overflow-x-auto`,children:(0,r.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eh.map(e=>{let t=en[e.index];if("gap-expand"===t.kind)return(0,r.jsx)("button",{ref:ei.measureElement,"data-index":e.index,type:"button",onClick:()=>es(t.gapId,t.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,ea(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center text-[11px] text-foreground/50 hover:bg-hover hover:text-brand active:bg-brand/15 transition-colors duration-100 cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-brand/60",title:I("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),"aria-label":I("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),children:(0,r.jsx)("span",{className:"select-none",children:I("diffViewer.gap.more",{count:t.revealCount})})},e.key);if("gap-label"===t.kind)return(0,r.jsxs)("div",{ref:ei.measureElement,"data-index":e.index,"data-gap-id":t.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,ea(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center gap-2 px-3 text-[11px] text-foreground/80 bg-accent border-y border-border min-w-0 select-none",children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:I("diffViewer.gap.hidden",{count:t.hiddenCount})}),t.enclosingFn&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"opacity-50 flex-shrink-0",children:"\xb7"}),(0,r.jsx)("span",{className:"truncate min-w-0 font-medium","data-tooltip":S(t.enclosingFn),"data-tooltip-mono":!0,children:S(t.enclosingFn)})]})]},e.key);let n=J[t.idx],s=n?.lineNum||0,o=s>0&&U.has(s),a=W.get(s),l=a?.[0],i=z&&s>=z.start&&s<=z.end,d=K&&s>=K.start&&s<=K.end,c=i||d;return(0,r.jsxs)("div",{ref:ei.measureElement,"data-index":e.index,"data-new-line":s||void 0,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,ea(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${c?"bg-blue-9/20":o?"bg-amber-9/10":n?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,r.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-foreground-subtle select-none border-r border-border ${c?"bg-blue-9/30":""}`,style:{width:V?"52px":"40px"},children:[V&&s>0&&o&&l&&(0,r.jsx)("button",{onClick:e=>q(l,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:I("codeViewer.nComments",{count:a?.length}),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.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"})})}),V&&s>0&&!o&&(0,r.jsx)("span",{className:"w-4"}),(0,r.jsx)("span",{className:"flex-1 text-right pr-1",children:s||""})]}),(0,r.jsx)("span",{className:"whitespace-pre pl-2",onMouseOver:R?e=>A(e,s):void 0,onMouseLeave:R?M:void 0,onMouseDown:R?L:void 0,dangerouslySetInnerHTML:{__html:n?.originalIdx>=0&&Z[n.originalIdx]||(0,u.ZD)(n?.content||" ")}})]},e.key)})})})]})}),(0,r.jsx)(m,{lines:eu,containerRef:$})]}),G]})}function E({oldContent:e,newContent:t,filePath:n,cwd:h,enableComments:p=!1,onPreview:f,previewLabel:g,headerLeading:x,onContentSearch:b,compact:v=!1,highlight:y=!0,onTokenHover:w,onTokenHoverLeave:k,onTokenHoverCancel:j}){let{t:S}=(0,o.Bd)(),T=N(w),R=g??S("common.preview"),M=(0,s.useMemo)(()=>(0,l.X)(e,t),[e,t]),L=(0,s.useRef)(null),I=(0,s.useMemo)(()=>M.map(e=>e.content),[M]),A=(0,c.C)(I,n,y),[F,P]=(0,s.useState)(null);(0,s.useEffect)(()=>{L.current!==F&&P(L.current)});let{commentsEnabled:$,linesWithComments:D,commentsByEndLine:_,handleCommentBubbleClick:O,addCommentRange:B,sendToAIRange:H,commentPortal:V}=C({cwd:h,enableComments:p,filePath:n,diffLines:M,containerEl:F,onContentSearch:b}),[U,W]=(0,s.useState)(()=>new Set);(0,s.useEffect)(()=>{W(new Set)},[e,t,n]);let q=(0,s.useMemo)(()=>v?function(e,t){let n=e.length,r=Array(n).fill(!1);for(let t=0;t<n;t++){if("unchanged"===e[t].type)continue;let s=Math.max(0,t-i.aj),o=Math.min(n-1,t+i.aj);for(let e=s;e<=o;e++)r[e]=!0}let s=[],o=0,a=0;for(;a<n;){if(r[a]){s.push({kind:"line",line:e[a],index:a}),a++;continue}let l=a;for(;l<n&&!r[l];)l++;let i=o++;if(t.has(i))for(let t=a;t<l;t++)s.push({kind:"line",line:e[t],index:t});else s.push({kind:"gap",id:i,count:l-a});a=l}return s}(M,U):M.map((e,t)=>({kind:"line",line:e,index:t})),[v,M,U]),z=(0,s.useCallback)(e=>{let t=q[e];if(!t)return e;if("gap"===t.kind)return`gap:${t.id}`;let n=t.line;return`${n.type}:${n.oldLineNum??"x"}:${n.newLineNum??"x"}`},[q]),K=(0,a.Te)({count:q.length,getScrollElement:()=>L.current,estimateSize:()=>20,getItemKey:z,overscan:20}),G=(0,s.useMemo)(()=>q.map(e=>"gap"===e.kind?{type:"unchanged"}:{type:e.line.type}),[q]);return(0,r.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(x||f||t)&&(0,r.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-end gap-2 px-2 py-1 border-b border-border bg-accent text-xs",children:[x&&(0,r.jsx)("div",{className:"mr-auto min-w-0",children:x}),f&&(0,r.jsx)("button",{onClick:f,className:"text-muted-foreground hover:text-foreground transition-colors",children:R}),t&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,d.oR)(S("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:S("common.copy")}),(0,r.jsx)("div",{className:"w-4 flex-shrink-0"})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,r.jsx)("div",{ref:L,className:"flex-1 min-w-0 overflow-auto",children:(0,r.jsx)("div",{style:{height:`${K.getTotalSize()}px`,position:"relative"},children:K.getVirtualItems().map(e=>{let t=q[e.index];if(!t)return null;let n={position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${e.size}px`,transform:`translateY(${e.start}px)`};if("gap"===t.kind){let s=S("diffViewer.gap.hidden",{count:t.count});return(0,r.jsx)("div",{style:n,onClick:()=>W(e=>new Set(e).add(t.id)),className:"flex items-center cursor-pointer bg-slate-2 hover:bg-hover border-y border-border text-xs text-foreground-subtle select-none","data-tooltip":s,children:(0,r.jsx)("span",{className:"w-full text-center",children:s})},e.key)}let s=t.line,o="removed"!==s.type?s.newLineNum??0:0,a=o>0&&D.has(o),l=_.get(o),i=l?.[0],d=B&&o>=B.start&&o<=B.end,c=H&&o>=H.start&&o<=H.end;return(0,r.jsxs)("div",{style:n,"data-new-line":o||void 0,className:`flex ${d||c?"bg-blue-9/20":a?"bg-amber-9/10":"removed"===s.type?"bg-red-9/15 dark:bg-red-9/25":"added"===s.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[$&&(0,r.jsx)("span",{className:"w-5 flex-shrink-0 flex items-center justify-center select-none",children:o>0&&a&&i&&(0,r.jsx)("button",{onClick:e=>O(i,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:S("codeViewer.nComments",{count:l?.length}),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.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"})})})}),(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:"added"!==s.type?s.oldLineNum:""}),(0,r.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:"removed"!==s.type?s.newLineNum:""}),(0,r.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===s.type?"text-red-11":"added"===s.type?"text-green-11":"text-foreground-subtle"}`,children:"removed"===s.type?"-":"added"===s.type?"+":" "}),(0,r.jsx)("span",{className:"flex-1 whitespace-pre pl-1",onMouseOver:w?e=>T(e,o):void 0,onMouseLeave:w?k:void 0,onMouseDown:w?j:void 0,dangerouslySetInnerHTML:{__html:A[t.index]||(0,u.ZD)(s.content||" ")}})]},e.key)})})}),(0,r.jsx)(m,{lines:G,containerRef:L})]}),V]})}},46456:(e,t,n)=>{n.d(t,{$:()=>c,BC:()=>u,Tu:()=>h,lb:()=>i,tj:()=>p,vv:()=>m});var r=n(49433),s=n(82680),o=n(84230);let a=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()},catch:n=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),l=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`)},catch:n=>new s.uV({message:`${t.method} ${e} failed`,cause:n})}),i=(e,t)=>{let n=`/api/comments?cwd=${encodeURIComponent(e)}${t?`&filePath=${encodeURIComponent(t)}`:""}`;return(0,o.F)(n,a(n))},d=r.OH5(()=>(0,o.T)("/api/comments")),c=e=>a(`/api/comments?cwd=${encodeURIComponent(e)}&all=true`),u=e=>a("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).pipe(r.yeE(d)),m=(e,t,n)=>a("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,id:t,content:n})}).pipe(r.yeE(d)),h=(e,t)=>l(`/api/comments?cwd=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`,{method:"DELETE"}).pipe(r.yeE(d)),p=e=>l(`/api/comments?cwd=${encodeURIComponent(e)}&all=true`,{method:"DELETE"}).pipe(r.yeE(d))},47176:(e,t,n)=>{n.d(t,{l:()=>i});var r=n(95155),s=n(12115),o=n(79114),a=n(94287);let l=e=>`h1[data-source-start="${e}"], h2[data-source-start="${e}"], h3[data-source-start="${e}"], h4[data-source-start="${e}"], h5[data-source-start="${e}"], h6[data-source-start="${e}"]`;function i({content:e,containerRef:t,width:n="w-80",defaultCollapsed:d=!1}){let{t:c}=(0,o.Bd)(),u=(0,s.useMemo)(()=>(function(e){let t=[],n=e.split("\n"),r=!1;for(let e=0;e<n.length;e++){let s=n[e];if(s.trimStart().startsWith("```")){r=!r;continue}if(r)continue;let o=/^(#{1,6})\s+(.+)$/.exec(s);o&&t.push({level:o[1].length,text:o[2].replace(/\s*#+\s*$/,"").replace(/\\([!-\/:-@[-`{-~])/g,"$1"),sourceLine:e+1})}return t})(e),[e]),[m,h]=(0,s.useState)(d),[p,f]=(0,s.useState)(null),g=(0,s.useCallback)(e=>{let n=t.current;if(!n)return;let r=n.querySelector(l(e));r&&r.scrollIntoView({behavior:"smooth",block:"start"})},[t]);return((0,s.useEffect)(()=>{let e=t.current;if(!e||0===u.length)return;let n=()=>{let t=[];for(let n of u){let r=e.querySelector(l(n.sourceLine));if(r){let s=r.getBoundingClientRect().top-e.getBoundingClientRect().top;t.push({line:n.sourceLine,top:s})}}let n=null;for(let e of t)e.top<=60&&(n=e.line);null===n&&t.length>0&&(n=t[0].line),f(n)},r=setTimeout(n,150);return e.addEventListener("scroll",n,{passive:!0}),()=>{clearTimeout(r),e.removeEventListener("scroll",n)}},[u,e,t]),0===u.length)?null:(0,r.jsxs)("div",{className:`border-r border-border flex-shrink-0 flex flex-col transition-[width] duration-200 ${m?"w-8":n}`,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-border flex-shrink-0",children:[!m&&(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:c("editor.toc")}),(0,r.jsx)("button",{onClick:()=>h(e=>!e),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:c(m?"editor.expandToc":"editor.collapseToc"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:m?(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"}):(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),!m&&(0,r.jsx)("nav",{className:"flex-1 overflow-y-auto py-1",children:u.map((e,t)=>(0,r.jsx)(a.m,{content:e.text,delay:400,children:(0,r.jsx)("button",{onClick:()=>g(e.sourceLine),className:`block w-full text-left text-sm py-1 px-2 truncate transition-colors hover:bg-hover ${p===e.sourceLine?"text-brand font-medium bg-brand/5":"text-muted-foreground"}`,style:{paddingLeft:`${(e.level-1)*12+8}px`},children:e.text})},t))})]})}},47215:(e,t,n)=>{n.d(t,{C6:()=>a,C_:()=>y,Hz:()=>v,OG:()=>w,WU:()=>k,Zy:()=>b,aR:()=>x,cG:()=>l,d9:()=>i,e$:()=>g,jU:()=>o,oK:()=>C,u:()=>f,xb:()=>d,zs:()=>h});var r=n(12115),s=n(69809);function o(e){try{return JSON.parse(e),!0}catch{return!1}}function a(e){try{let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}let l={key:"hsl(var(--blue-11))",str:"hsl(var(--green-11))",num:"hsl(var(--violet-11))",bool:"hsl(var(--red-11))",punct:"hsl(var(--slate-11))",fold:"hsl(var(--slate-11))"},i=r.createContext({version:0,collapsed:!1});function d(e,t=l){try{let n=JSON.parse(e);return m(n,0,t)}catch{return e}}let c=(e,t)=>r.createElement("span",{style:{color:e}},t);function u({label:e,labelColor:t,value:n,indent:o,colors:a}){let l=r.useContext(i),[d,h]=r.useState(null),p=d&&d.version===l.version?d.collapsed:l.collapsed,[f,g]=r.useState({x:0,y:0}),x="string"==typeof n&&n.replace(/\\n/g,"\n").split("\n").length>3,b={onMouseDown:e=>{g({x:e.clientX,y:e.clientY})},onClick:e=>{let t=e.clientX-f.x,n=e.clientY-f.y;t*t+n*n>25||(e.stopPropagation(),h({version:l.version,collapsed:!p}))},style:{cursor:"pointer"}};if(x&&p&&"string"==typeof n){let o=n.replace(/\\n/g,"\n").split("\n")[0],l=n.replace(/\\n/g,"\n").split("\n").length;return r.createElement("span",b,c(t,e),c(a.punct,": "),c(a.str,o),c(a.fold,` ${s.A.t("toolCall.foldedLines",{count:l})}`))}let v=r.createElement(r.Fragment,null,c(t,e),c(a.punct,": "),m(n,o,a));return x?r.createElement("span",b,v):v}function m(e,t,n){let s=" ".repeat(t);if(null===e)return c(n.bool,"null");if(void 0===e)return c(n.bool,"undefined");if("string"==typeof e){let t=e.replace(/\\n/g,"\n").replace(/\n/g,"\n"+s);return c(n.str,t)}if("number"==typeof e)return c(n.num,String(e));if("boolean"==typeof e)return c(n.bool,String(e));if(Array.isArray(e))return 0===e.length?c(n.punct,"[]"):r.createElement(r.Fragment,null,c(n.punct,"["),"\n",...e.map((o,a)=>r.createElement("span",{key:a},s+" ",r.createElement(u,{label:`[${a}]`,labelColor:n.key,value:o,indent:t+1,colors:n}),a<e.length-1?r.createElement(r.Fragment,null,c(n.punct,","),"\n"):"\n")),s,c(n.punct,"]"));if("object"==typeof e){let o=Object.entries(e);return 0===o.length?c(n.punct,"{}"):r.createElement(r.Fragment,null,c(n.punct,"{"),"\n",...o.map(([e,a],l)=>r.createElement("span",{key:e},s+" ",r.createElement(u,{label:e,labelColor:n.key,value:a,indent:t+1,colors:n}),l<o.length-1?r.createElement(r.Fragment,null,c(n.punct,","),"\n"):"\n")),s,c(n.punct,"}"))}return String(e)}function h(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}let p=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function f(e){let t=e.slice(e.lastIndexOf(".")).toLowerCase();return p.has(t)}function g(e){return e.toLowerCase().endsWith(".md")}function x(e){let t=e.toLowerCase();return t.endsWith(".html")||t.endsWith(".htm")}function b(e){let t=e.toLowerCase();return t.endsWith(".csv")||t.endsWith(".tsv")}function v(e){return e.toLowerCase().endsWith(".json")}function y(e){return"skill.md"===e.slice(e.lastIndexOf("/")+1).toLowerCase()}function w(e){return"bot.md"===e.slice(e.lastIndexOf("/")+1).toLowerCase()}function k(e,t){let n=t.startsWith("/")?[]:e.split("/").slice(0,-1);for(let e of t.replace(/^\//,"").split("/"))""!==e&&"."!==e&&(".."===e?n.pop():n.push(e));return n.join("/")}function C(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}},48050:(e,t,n)=>{n.d(t,{F9:()=>i,S6:()=>l,iS:()=>a});var r=n(49433),s=n(82680),o=n(8183);let a=(e,t,n)=>r.$mh({try:async()=>{let r=await fetch("/api/session-title",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,sessionId:t,...n})});if(!r.ok)throw Error(`Cannot ${void 0===n?"read":"save"} session title (HTTP ${r.status})`);return await r.json()},catch:e=>new s.uV({message:"Session title request failed",cause:e})}),l=(e,t)=>r.DYE(()=>{let n=(0,o.V6)();return r.$mh({try:async n=>{let r=await fetch("/api/session-title",{method:"POST",headers:{"Content-Type":"application/json"},signal:n,body:JSON.stringify({cwd:e,sessionIds:t})});if(!r.ok)throw Error(`Cannot read session titles (HTTP ${r.status})`);return await r.json()},catch:e=>new s.uV({message:"Session title batch failed",cause:e})}).pipe(r.Mim(({titles:e})=>r.OH5(()=>(0,o.EF)(e,n))),r.TjK(({titles:e})=>e.map(e=>({...(0,o.V6)().get((0,o.kz)(e.cwd,e.sessionId)),sessionId:e.sessionId}))))}),i=(e,t)=>r.$mh({try:async n=>{let r=await fetch("/api/session-title/suggest",{method:"POST",headers:{"Content-Type":"application/json"},signal:n,body:JSON.stringify({cwd:e,sessionId:t})}),s=await r.json().catch(()=>null);if(!r.ok||"string"!=typeof s?.title)throw Error(s?.error??`HTTP ${r.status}`);return s.title},catch:e=>new s.uV({message:e instanceof Error?e.message:"Title suggestion failed",cause:e})})},48347:(e,t,n)=>{n.d(t,{H:()=>a,r:()=>l});var r=n(95155),s=n(12115);let o=(0,s.createContext)(null);function a({value:e,children:t}){return(0,r.jsx)(o.Provider,{value:e,children:t})}function l(){return(0,s.useContext)(o)}},48661:(e,t,n)=>{n.d(t,{q:()=>o});var r=n(95155),s=n(79114);function o({value:e,onChange:t,className:n}){let{t:a}=(0,s.Bd)();return(0,r.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${n??""}`,children:["split","unified"].map(n=>(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),t(n)},className:`px-2 py-0.5 text-xs transition-colors ${e===n?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:a("split"===n?"diffViewer.viewSplit":"diffViewer.viewUnified")},n))})}},48764:(e,t,n)=>{n.d(t,{Bz:()=>u,De:()=>m,Ek:()=>h,Hy:()=>a,L5:()=>d,Wd:()=>i,hp:()=>c});var r=n(49433),s=n(84230),o=n(37640);let a=()=>(0,s.F)("/api/skills",(0,o.zi)("/api/skills")),l=r.OH5(()=>(0,s.T)("/api/skills")),i=()=>(0,o.zi)("/api/skills/builtin"),d=e=>(0,o.zi)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}).pipe(r.yeE(l)),c=e=>(0,o.zi)(`/api/skills/${encodeURIComponent(e)}`,{method:"DELETE"}).pipe(r.yeE(l)),u=e=>(0,o.zi)(`/api/skills/content?id=${encodeURIComponent(e)}`),m=(e,t)=>(0,o.zi)(`${e}?id=${encodeURIComponent(t)}`),h=(e,t,n)=>(0,o.zi)(`${e}?id=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`)},50605:(e,t,n)=>{function r(e){return/^~(?=$|[/\\])/.test(e.trim())}function s(e,t){return t&&r(e)?t.replace(/[/\\]+$/,"")+e.trim().slice(1):e}n.d(t,{D:()=>s,P:()=>r})},50860:(e,t,n)=>{n.d(t,{I:()=>l});var r=n(95155),s=n(12115),o=n(86957),a=n(60938);function l(e){let{refreshKey:t,className:n="h-full flex items-center justify-center p-4 bg-secondary",imgClassName:l="max-w-full max-h-full object-contain",alt:i}=e,d="absPath"in e&&"string"==typeof e.absPath,c=d?void 0:e.cwd,u=d?void 0:e.path,m=d?e.absPath:void 0,[h,p]=(0,s.useState)({kind:"loading"}),f=(0,s.useRef)(0);if((0,s.useEffect)(()=>{let e=++f.current;return p({kind:"loading"}),(async()=>{if(d){if(e!==f.current)return;p({kind:"ready",etag:null,size:0});return}let t=await o.t4.runPromiseExit((0,a.r6)(c,u));if(e!==f.current)return;if("Failure"===t._tag){let e="Fail"===t.cause._tag?t.cause.error:null,n=e?.cause;p({kind:"error",message:n instanceof Error?n.message:"Unknown error"});return}let n=t.value;if(!n.ok)return p({kind:"error",message:`stat failed (${n.status})`});let r=n.data;r&&r.exists?"too-large"===r.category?p({kind:"too-large",size:r.size??0}):"image"!==r.category?p({kind:"error",message:`Not an image (${r.category})`}):p({kind:"ready",etag:r.etag||`t-${r.mtimeMs??Date.now()}`,size:r.size??0}):p({kind:"missing"})})(),()=>{f.current++}},[d,c,u,m,t]),"loading"===h.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})});if("missing"===h.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("div",{className:"text-sm text-muted-foreground",children:"File not found"})});if("too-large"===h.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsxs)("div",{className:"text-sm text-muted-foreground",children:["Image too large to preview (",Math.round(h.size/1024/1024)," MB)"]})});if("error"===h.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("div",{className:"text-sm text-red-11",children:h.message})});let g=d?`/api/file?path=${encodeURIComponent(m)}&raw=true`:`/api/files/read?cwd=${encodeURIComponent(c)}&path=${encodeURIComponent(u)}&v=${encodeURIComponent(h.etag)}`;return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("img",{src:g,alt:i??(u||m),className:l})})}},51145:(e,t,n)=>{n.d(t,{K:()=>o});var r=n(49433),s=n(82680);let o=(e,t)=>{let n,o;return n=`/api/files/text?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,o={cache:"no-store"},r.$mh({try:async()=>{let e=await fetch(n,o),t=null;try{t=await e.json()}catch{}return{status:e.status,ok:e.ok,data:t}},catch:e=>new s.uV({message:`GET ${n} failed`,cause:e})})}},51536:(e,t,n)=>{n.d(t,{X:()=>i});var r=n(12115),s=n(79114),o=n(34075),a=n(37640),l=n(86957);function i({add:e,notify:t,namespace:n,failureKey:d}){let{t:c}=(0,s.Bd)();return(0,r.useCallback)(async r=>{let s=await l.t4.runPromiseExit(e(r));"Success"===s._tag?s.value.alreadyExists?(0,o.oR)(c(`${n}.alreadyAdded`),"info"):((0,o.oR)(c(`${n}.added`),"success"),t()):(0,o.oR)((0,a.oh)(s.cause,c(d)),"error")},[e,t,n,d,c])}},52839:(e,t,n)=>{n.d(t,{S:()=>a,q:()=>o});let r=[/(^|\/)__tests__\//,/(^|\/)tests?\//,/\.(test|spec)\.[^/]+$/],s=[/\.(md|mdx)$/i,/(^|\/)docs\//,/(^|\/)README[^/]*$/i,/(^|\/)LICENSE[^/]*$/i,/(^|\/)CHANGELOG[^/]*$/i];function o(e){return r.some(t=>t.test(e))?"test":s.some(t=>t.test(e))?"docs":null}function a(e){if(0===e.length)return null;let t=o(e[0]);return null===t?null:e.every(e=>o(e)===t)?t:null}},53317:(e,t,n)=>{function r(e){return e.replace(/^claude-/,"").replace(/-\d{8}$/,"").replace(/(\d)-(?=\d)/g,"$1.").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function s(e){return e.split("-").map((e,t)=>0===t?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)).join("-")}n.d(t,{J:()=>r,U:()=>s})},56045:(e,t,n)=>{n.d(t,{_:()=>l,o:()=>a});var r=n(12115),s=n(69809);let o="json-search-highlight-style";function a(e){let[t,n]=(0,r.useState)(!1),[s,a]=(0,r.useState)(""),[l,i]=(0,r.useState)(!1),[d,c]=(0,r.useState)(0),[u,m]=(0,r.useState)(0),h=(0,r.useRef)(null),p=(0,r.useRef)([]),f=(0,r.useCallback)(()=>{let t;CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),p.current=[];let n=e.current;if(!n||!s){c(0),m(0);return}!function(){if(document.getElementById(o))return;let e=document.createElement("style");e.id=o,e.textContent="::highlight(json-search){background:var(--highlight)}::highlight(json-search-current){background:var(--highlight-current)}",document.head.appendChild(e)}();let r=n.textContent||"",a=l?s:s.toLowerCase(),i=l?r:r.toLowerCase(),d=[],u=0;for(;u<i.length;){let e=i.indexOf(a,u);if(-1===e)break;d.push([e,e+a.length]),u=e+1}if(0===d.length){c(0),m(0);return}let h=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),f=0,g=0,x=[],b=null,v=0;for(;(t=h.nextNode())&&g<d.length;){let e=t.textContent?.length||0,n=f,r=f+e;for(;g<d.length;){let[e,s]=d[g];if(e>=r)break;if(!b)if(e>=n)(b=document.createRange()).setStart(t,e-n),v=s;else break;if(v<=r)b.setEnd(t,v-n),x.push(b),b=null,g++;else break}f=r}p.current=x,c(x.length),m(e=>x.length>0?Math.min(e,x.length-1):0),CSS.highlights&&x.length>0&&CSS.highlights.set("json-search",new Highlight(...x))},[e,s,l]),g=(0,r.useCallback)((e,t)=>{let n=e.getBoundingClientRect();(t.top<n.top||t.bottom>n.bottom)&&(e.scrollTop+=t.top-n.top-n.height/2+t.height/2)},[]),x=(0,r.useCallback)(t=>{CSS.highlights?.delete("json-search-current");let n=p.current[t];if(!n||!CSS.highlights)return;CSS.highlights.set("json-search-current",new Highlight(n));let r=n.getBoundingClientRect(),s=e.current?.parentElement;s&&g(s,r)},[e,g]);(0,r.useEffect)(()=>{queueMicrotask(()=>f())},[f]),(0,r.useEffect)(()=>{x(u)},[u,d,x]),(0,r.useEffect)(()=>{let t=e.current;if(!t||!s)return;let n=new MutationObserver(()=>f());return n.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>n.disconnect()},[e,s,f]),(0,r.useEffect)(()=>{t||(CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),p.current=[])},[t]),(0,r.useEffect)(()=>()=>{CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current")},[]);let b=(0,r.useCallback)(()=>{0!==d&&m(e=>(e+1)%d)},[d]),v=(0,r.useCallback)(()=>{0!==d&&m(e=>(e-1+d)%d)},[d]),y=(0,r.useCallback)(()=>{n(!0),setTimeout(()=>h.current?.focus(),0)},[]),w=(0,r.useCallback)(()=>{n(!1),a(""),m(0)},[]),k=(0,r.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?v():b()),"Escape"===e.key&&(e.preventDefault(),w())},[b,v,w]);return{isVisible:t,query:s,setQuery:a,caseSensitive:l,setCaseSensitive:i,matchCount:d,currentIndex:u,searchInputRef:h,open:y,close:w,goToNext:b,goToPrev:v,handleKeyDown:k}}function l({search:e}){return e.isVisible?r.createElement("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border"},r.createElement("input",{ref:e.searchInputRef,type:"text",value:e.query,onChange:t=>e.setQuery(t.target.value),onKeyDown:e.handleKeyDown,placeholder:s.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"}),r.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:s.A.t("codeViewer.caseSensitive")},"Aa"),r.createElement("span",{className:"text-xs text-muted-foreground"},e.matchCount>0?`${e.currentIndex+1}/${e.matchCount}`:s.A.t("common.noMatch")),r.createElement("button",{onClick:e.goToPrev,disabled:0===e.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:s.A.t("common.previous")},r.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}))),r.createElement("button",{onClick:e.goToNext,disabled:0===e.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:s.A.t("common.next")},r.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),r.createElement("button",{onClick:e.close,className:"p-1 rounded hover:bg-accent",title:s.A.t("common.close")},r.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))):null}},56978:(e,t,n)=>{n.d(t,{C:()=>o});var r=n(12115),s=n(17196);function o(e,t,n=!0){let[a,l]=(0,r.useState)(null),[i,d]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(!n)return;let e=()=>{d(document.documentElement.classList.contains("dark"))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[n]);let c=(0,r.useMemo)(()=>n?e.join("\n"):"",[e,n]),u=`${c}:${t}:${i}`,m=(0,r.useMemo)(()=>n&&a&&a.key===u?a.html:e.map(e=>(0,s.ZD)(e||" ")),[e,u,a,n]);return(0,r.useEffect)(()=>{if(!n||0===e.length)return;let r=!1;return(async()=>{try{let e=await (0,s.kS)();if(r)return;let n=(0,s.sQ)(t),o=e.codeToTokens(c,{lang:n,theme:i?"github-dark":"github-light"}),a=[];for(let e=0;e<o.tokens.length;e++)if(a[e]=(0,s.b8)(o.tokens[e]),e%500==0&&e>0&&(await new Promise(e=>setTimeout(e,0)),r))return;l({key:u,html:a})}catch(e){console.error("Line highlight error:",e)}})(),()=>{r=!0}},[c,t,i,n]),m}},57125:(e,t,n)=>{n.d(t,{$T:()=>p,Aw:()=>f,CX:()=>c,Fx:()=>h,H:()=>l,XY:()=>y,ch:()=>i,eV:()=>b,hG:()=>v,pe:()=>u,r8:()=>x,yI:()=>m,ys:()=>g});var r=n(95155),s=n(12115),o=n(94514),a=n(66088);let l={claude:"Claude",codex:"Codex",grok:"Grok",deepseek:"DeepSeek",kimi:"Kimi",glm:"GLM",ollama:"Ollama"};function i(e){return!!e&&e in l}let d={claude:0,codex:1,deepseek:2,glm:3,kimi:4,ollama:5,grok:3.5},c=Object.keys(d).sort((e,t)=>d[e]-d[t]),u={claude:"text-[#c6532d] dark:text-[#D97757]",codex:"text-emerald-600 dark:text-emerald-400",grok:"text-foreground",deepseek:"text-sky-600 dark:text-sky-400",kimi:"text-purple-600 dark:text-purple-400",glm:"text-amber-600 dark:text-amber-400",ollama:"text-violet-600 dark:text-violet-400"},m="bg-accent font-medium text-foreground",h="focus:border-brand",p="bg-brand text-white hover:bg-brand/90",f="text-rose-600 dark:text-rose-400",g="fixed z-[9999] max-h-[70vh] overflow-y-auto rounded-lg border border-border bg-popover py-2 shadow-lv2";function x(e,t,n){(0,s.useLayoutEffect)(()=>{let n=e.current;if(!t||!n)return;n.style.transform="";let r=n.getBoundingClientRect(),s=r.right-(window.innerWidth-8);s>0&&(n.style.transform=`translateX(-${Math.min(s,Math.max(0,r.left-8))}px)`)},[e,t,n])}function b({engine:e,className:t="h-3.5 w-3.5"}){return(0,r.jsx)("img",{alt:"","aria-hidden":"true",src:`/agent-icons/${e}.svg`,className:`${t} flex-shrink-0`})}function v({selected:e}){return(0,r.jsx)("span",{className:"flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center text-foreground",children:e&&(0,r.jsx)(o.A,{className:"h-3.5 w-3.5"})})}function y({label:e,title:t,onClick:n,buttonRef:s,icon:o,labelClassName:l,labelMaxWidth:i="max-w-[160px]",testId:d,...c}){return(0,r.jsxs)("button",{...c,ref:s,type:"button",onClick:n,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed",title:t,"data-testid":d,children:[o,(0,r.jsx)("span",{className:`truncate ${i} ${l??""}`,children:e}),(0,r.jsx)(a.A,{className:"h-3 w-3 flex-shrink-0"})]})}},58250:(e,t,n)=>{n.d(t,{U:()=>o,k:()=>s});let r=(0,n(93964).N)("cockpit-skills","/api/skills"),s=r.notify,o=r.subscribe},58453:(e,t,n)=>{n.d(t,{Wn:()=>c,e9:()=>u,n2:()=>d});var r=n(86511);let s=new Map(Object.entries({read:{zh:"请先读取以下 skill 文件,再据此执行:",en:"Read these skill files first, then act accordingly:"},handoff:{zh:"以下文件交给你派发的子会话去读,你只转交路径,不要自己打开:",en:"These files are for the session you delegate to. Pass the paths along; do not open them yourself:"},handoffMixed:{zh:"以下路径原样转交给你派发的子会话;除上面读取列表已列出的以外,不要自己打开:",en:"Pass these paths verbatim to the session you delegate to; do not open any that the read list above does not already list:"},targets:{zh:"以上 [session\xb7@…] 行指向的会话(cwd 与 sessionId 原样使用):",en:"Sessions the [session\xb7@…] lines above address (use cwd and sessionId verbatim):"},unresolved:{zh:"以下 @ 开头的行没有被识别,已按普通文本处理,请告知用户:",en:"These @ lines were not recognised and were left as plain text. Tell the user:"}}).flatMap(([e,t])=>[[t.zh,e],[t.en,e]])),o=/^---\nname:\s*([^\n]+)/,a=/^\[(?:(main|subagent|session)·)?(.+?)\](?: (.*))?$/,l=e=>{let[t,...n]=e.split("\n");return s.has(t)&&n.length>0&&n.every(e=>e.startsWith("- "))},i=(e,t)=>{let n="targets"===t?e.match(/^- (.+)(?::|: )(\{.*\})$/):e.match(/^- (.+?)(?::|: )(.*)$/);return n?{name:n[1],detail:n[2]}:null};function d(e){let t=function(e){let t=e.split("\n\n"),n=t.length-1,r=!1;for(;n>=0;){if(l(t[n])){r=!0,n--;continue}let e=n;for(;e>0&&!o.test(t[e]);)e--;if(e>0&&o.test(t[e])&&l(t[e-1])){r=!0,n=e-1;continue}break}if(!r)return -1;let s=0;for(let e=0;e<=n;e++)s+=t[e].length+2;return n<0?0:s-2}(e);if(-1===t)return null;let n=e.slice(0,t),r=e.slice(t).replace(/^\n+/,""),d=[],c=[],u=null;for(let e of r.split(/\n\n(?=\S)/)){let[t,...n]=e.split("\n"),r=s.get(t),a=null!==u?e.match(o):null;if(r)u=r;else if(a){d.push({kind:"inline",name:a[1].trim().replace(/^["']|["']$/g,""),detail:""}),u="inline";continue}else if("inline"===u)continue;for(let e of r?n:[t,...n]){if("unresolved"===u){e.startsWith("- ")&&c.push(e.slice(2));continue}let t=u?i(e,u):null;t&&u&&d.push({kind:u,...t})}}let m=new Set(d.map(e=>e.name)),h=d.filter(e=>"targets"===e.kind).map(e=>e.name).sort((e,t)=>t.length-e.length),p=(n?n.split("\n"):[]).map(e=>{if(e.startsWith("[session\xb7"))for(let t of h){let n=`[session\xb7${t}]`;if(e.startsWith(n)&&(e.length===n.length||" "===e[n.length]))return{command:t,text:e.slice(n.length+1)}}let t=e.match(a);if(!t)return{command:null,text:e};let[,n,r,s=""]=t;return n||m.has(r)?{command:r.startsWith("@")?r:"subagent"===n?`/@${r}`:`/${r}`,text:s}:{command:null,text:e}});if(!(0===d.length&&c.length>0)&&!p.some(e=>e.command))return null;for(;p.length&&null===p[p.length-1].command&&!p[p.length-1].text.trim();)p.pop();return{lines:p,references:d,notes:c}}function c(e){let t=d(e);return t?t.lines.map(e=>e.command?e.text?`${e.command} ${e.text}`:e.command:e.text).join("\n"):e}function u(e){let t=(0,r.nl)(e);return c(t?t.body:e)}},59461:(e,t,n)=>{n.d(t,{Q:()=>w,j:()=>v});var r=n(95155),s=n(75347),o=n(8183),a=n(12115),l=n(79114),i=n(66109),d=n(95045),c=n(75346),u=n(86957),m=n(4768),h=n(83448),p=n(92689),f=n(7578),g=n(20832),x=n(32456);let b=[{key:"today",labelKey:"sessions.dateToday"},{key:"yesterday",labelKey:"sessions.dateYesterday"},{key:"last7Days",labelKey:"sessions.dateLast7Days"},{key:"earlier",labelKey:"sessions.dateEarlier"}];function v(e,t=Date.now()){let n=new Date(t);n.setHours(0,0,0,0);let r=n.getTime();return e>=r?"today":e>=r-864e5?"yesterday":e>=r-5184e5?"last7Days":"earlier"}let y=e=>e.sessionId||(e.path.split("/").pop()||"").replace(".jsonl","");function w({isOpen:e,onClose:t,cwd:n,onSelectSession:k,projectNumber:C,openSessionIds:j=[]}){let{t:N}=(0,l.Bd)(),S=(0,s.bc)(),[T,E]=(0,a.useState)([]),[R,M]=(0,a.useState)(0),[L,I]=(0,a.useState)(!1),[A,F]=(0,a.useState)(null),[P,$]=(0,a.useState)(""),D=(0,a.useRef)(null),[_,O]=(0,a.useState)(null),B=(0,a.useCallback)(async()=>{if(!n)return;I(!0),F(null);let e=(0,m.O)(n),t=await u.t4.runPromiseExit((0,h.QW)(e));"Success"===t._tag?(E(t.value),M(Date.now())):F("Failed to load sessions"),I(!1)},[n]);(0,a.useEffect)(()=>{e?(B(),setTimeout(()=>{D.current?.focus(),D.current?.select()},100)):O(null)},[e,B]),(0,a.useEffect)(()=>{let n=n=>{"Escape"===n.key&&e&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t]);let H=e=>{let r=y(e);k?(k(r,(0,o.iM)(S,n,r,e.title,e.titleRevision)),t()):(0,d.F)(c.n.OpenProject,{cwd:n,sessionId:r})},V=(0,a.useMemo)(()=>{let e=[...T].sort((e,t)=>Date.parse(t.modifiedAt)-Date.parse(e.modifiedAt));if(!P)return e;let t=P.toLowerCase();return e.filter(e=>!!(0,o.iM)(S,n,y(e),e.title,e.titleRevision).toLowerCase().includes(t)||(void 0!==e.searchText?e.searchText.includes(t):(0,o.iM)(S,n,y(e),e.title,e.titleRevision).toLowerCase().includes(t)||e.firstMessages.some(e=>e.toLowerCase().includes(t))||e.lastMessages.some(e=>e.toLowerCase().includes(t))))},[T,S,n,P]),U=(0,a.useMemo)(()=>{let e={today:[],yesterday:[],last7Days:[],earlier:[]};for(let t of V)e[v(Date.parse(t.modifiedAt),R)].push(t);return e},[V,R]),W=_?T.find(e=>y(e)===_)??null:null;if((0,a.useEffect)(()=>{if(!e||W)return;let t=V[0];O(t?y(t):null)},[e,W,V]),!e)return null;let q=e=>{let t=y(e),o=j.indexOf(t),a=t===_,l=e.lastMessages[e.lastMessages.length-1]??e.firstMessages[0];return(0,r.jsxs)("div",{onClick:()=>O(t),onDoubleClick:()=>H(e),className:`group/session-title rounded-md px-3 py-2 cursor-pointer transition-colors ${a?"bg-brand/10":"hover:bg-hover"}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(p.S,{engine:e.engine}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground flex items-center gap-1 flex-1 min-w-0",children:(0,r.jsx)(s.dh,{cwd:n,sessionId:t,title:e.title,titleRevision:e.titleRevision})}),(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:(0,x.fw)(N,Date.parse(e.modifiedAt))}),C&&o>=0&&(0,r.jsx)(f.l,{projectNumber:C,sessionNumber:o+1,bot:e.bot})]}),l&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground truncate mt-0.5 pl-[22px]",children:l})]},e.path)};return(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:t}),(0,r.jsxs)("div",{className:i.iG,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-foreground",children:N("sessions.sessionList")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground truncate","data-tooltip":n,children:n})]}),(0,r.jsx)("button",{onClick:t,className:"p-1 ml-4 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,r.jsxs)("div",{className:"w-full md:w-[360px] min-h-0 flex-shrink-0 md:border-r border-border flex flex-col",children:[(0,r.jsx)("div",{className:"p-3 flex-shrink-0 border-b border-border",children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{ref:D,type:"text",placeholder:N("sessions.searchSessions"),value:P,onChange:e=>$(e.target.value),className:"w-full px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),P&&(0,r.jsx)("button",{onClick:()=>{$(""),D.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:N("fileBrowser.clear"),children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:(0,r.jsx)("div",{className:"p-3 space-y-3",children:0===T.length&&L?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-6",children:N("sessions.loadingSessions")}):0===T.length&&A?(0,r.jsx)("div",{className:"text-xs text-red-11 text-center py-6",children:A}):0===V.length?(0,r.jsx)("div",{className:"text-xs text-muted-foreground text-center py-6",children:P?N("sessions.noMatchingSessions"):N("sessions.noSessionsYet")}):b.map(({key:e,labelKey:t})=>{let n=U[e];return 0===n.length?null:(0,r.jsxs)("div",{className:"rounded-lg border border-border",children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 px-3 py-1.5 bg-card rounded-t-lg border-b border-border/60 text-[11px] font-medium text-muted-foreground flex items-center gap-1.5",children:[(0,r.jsx)("span",{children:N(t)}),(0,r.jsx)("span",{className:"ml-auto tabular-nums text-foreground-subtle",children:n.length})]}),(0,r.jsx)("div",{className:"p-1 space-y-0.5",children:n.map(q)})]},e)})})})]}),(0,r.jsx)("div",{className:"hidden md:flex flex-1 min-w-0",children:W?(0,r.jsx)(g.p,{cwd:n,sessionId:y(W),subtitle:(0,o.iM)(S,n,y(W),W.title,W.titleRevision),emptyText:N("sessions.noSessionMessages"),onOpenSession:()=>H(W)},y(W)):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-xs text-muted-foreground",children:N("sessions.selectSessionHint")})})]})]})]})}},60938:(e,t,n)=>{n.d(t,{DZ:()=>i,Ft:()=>m,Nn:()=>v,OJ:()=>g,VK:()=>y,YW:()=>u,__:()=>b,dt:()=>x,eA:()=>f,eE:()=>h,gZ:()=>d,mP:()=>l,nM:()=>w,r6:()=>p,r9:()=>c});var r=n(49433),s=n(82680);let o=(e,t={})=>r.$mh({try:async()=>{let n=await fetch(e,t.init);if(t.passThroughStatuses&&t.passThroughStatuses.includes(n.status))return await n.json().catch(()=>({}));if(!n.ok){let e;try{e=(await n.json()).error}catch{}throw Error(e||`HTTP ${n.status}`)}return await n.json()},catch:t=>new s.uV({message:`GET ${e} failed`,cause:t})}),a=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw Error(`HTTP ${n.status}`)},catch:t=>new s.uV({message:`POST ${e} failed`,cause:t})}),l=e=>o(`/api/files/init?cwd=${encodeURIComponent(e)}`),i=e=>o(`/api/files/index?cwd=${encodeURIComponent(e)}`),d=(e,t)=>o(`/api/files/readdir?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`),c=e=>o(`/api/files/recent?cwd=${encodeURIComponent(e)}`),u=(e,t,n)=>a("/api/files/recent",{cwd:e,file:t,...n??{}}),m=(e,t)=>a("/api/files/expanded",{cwd:e,paths:t}),h=(e,t)=>o(`/api/files/blame?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`).pipe(r.h9N(e=>r.PyW({error:e.message}))),p=(e,t)=>{let n,o;return n=`/api/files/stat?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,o={cache:"no-store"},r.$mh({try:async()=>{let e=await fetch(n,o),t=null;try{t=await e.json()}catch{}return{status:e.status,ok:e.ok,data:t}},catch:e=>new s.uV({message:`GET ${n} failed`,cause:e})})},f=e=>o(`/api/files/text?${e.toString()}`),g=e=>r.$mh({try:async()=>{let t=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=null;try{n=await t.json()}catch{}return{status:t.status,ok:t.ok,data:n}},catch:e=>new s.uV({message:"POST /api/files/save failed",cause:e})}),x=()=>o("/api/files/clipboard"),b=e=>r.$mh({try:async()=>{let t=await fetch("/api/files/clipboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(`HTTP ${t.status}`)},catch:e=>new s.uV({message:"POST /api/files/clipboard failed",cause:e})}),v=e=>r.$mh({try:async()=>{let t=await fetch("/api/files/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`HTTP ${t.status}`);return n},catch:e=>new s.uV({message:"POST /api/files/paste failed",cause:e})}),y=e=>r.$mh({try:async()=>{let t=await fetch("/api/files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`HTTP ${t.status}`);return n},catch:e=>new s.uV({message:"POST /api/files/delete failed",cause:e})}),w=e=>o(`/api/file?path=${encodeURIComponent(e)}`)},61043:(e,t,n)=>{n.d(t,{q:()=>o});var r=n(95155),s=n(12115);function o({children:e,defaultWidth:t=288}){let[n,a]=(0,s.useState)(t),l=(0,s.useRef)(null),i=(0,s.useCallback)(e=>{if("mouse"!==e.pointerType||0!==e.button)return;let n=e.currentTarget.previousElementSibling,r=e.currentTarget.parentElement;n&&r&&(e.preventDefault(),l.current={pointerId:e.pointerId,startX:e.clientX,startWidth:n.getBoundingClientRect().width,maxWidth:Math.min(1.5*t,r.getBoundingClientRect().width/2)},e.currentTarget.setPointerCapture(e.pointerId))},[t]),d=(0,s.useCallback)(e=>{let n=l.current;if(!n||n.pointerId!==e.pointerId)return;let r=n.startWidth+e.clientX-n.startX;a(Math.min(n.maxWidth,Math.max(t,r)))},[t]),c=(0,s.useCallback)(e=>{l.current?.pointerId===e.pointerId&&(l.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex-shrink-0 overflow-y-auto overflow-x-hidden",style:{width:n,maxWidth:"50%"},children:e}),(0,r.jsx)("div",{onPointerDown:i,onPointerMove:d,onPointerUp:c,onPointerCancel:c,onLostPointerCapture:c,className:"w-[5px] flex-shrink-0 relative cursor-col-resize group",children:(0,r.jsx)("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border group-hover:bg-brand transition-colors"})})]})}},62111:(e,t,n)=>{n.d(t,{E:()=>o,k:()=>s});var r=n(12115);function s(){"u">typeof document&&document.activeElement instanceof HTMLElement&&document.activeElement.blur()}function o(e,t=!0){(0,r.useEffect)(()=>{if(!t)return;let n=t=>{"Escape"===t.key&&(s(),e())};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,t])}},63040:(e,t,n)=>{n.d(t,{m3:()=>a,mi:()=>s,ot:()=>o});var r=n(37640);let s=()=>(0,r.zi)("/api/html-apps"),o=e=>(0,r.zi)("/api/html-apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),a=e=>(0,r.zi)(`/api/html-apps/${encodeURIComponent(e)}`,{method:"DELETE"})},63563:(e,t,n)=>{n.d(t,{N:()=>r});function r(){let e="u"<typeof BroadcastChannel?null:new BroadcastChannel("cockpit-html-apps");if(e)try{e.postMessage({type:"changed"})}finally{e.close()}}},64428:(e,t,n)=>{n.d(t,{F2:()=>m,ZL:()=>c,a9:()=>u});var r=n(95155),s=n(12115),o=n(47650);let a=()=>()=>{},l=()=>document.body,i=()=>null,d=(0,s.createContext)(null);function c({children:e}){let t=(0,s.useContext)(d),n=(0,s.useSyncExternalStore)(a,l,i),r=t??n;return r?(0,o.createPortal)(e,r):null}function u({children:e}){let[t,n]=(0,s.useState)(null);return(0,r.jsxs)("div",{className:"relative w-full h-full",style:{transform:"translateZ(0)"},children:[(0,r.jsx)(d.Provider,{value:t,children:e}),(0,r.jsx)("div",{ref:n,className:"absolute inset-0 pointer-events-none [&>*]:pointer-events-auto"})]})}function m(){return(0,s.useContext)(d)}},65153:(e,t,n)=>{n.d(t,{u:()=>c});var r=n(95272),s=n(12115),o=n(2111),a=n(19095),l=n(14594),i=n(98245),d=n(67958);function c(e,t,n,c,u){let m=(0,s.useId)(),h=(0,s.useRef)(null),p=(0,s.useRef)(0),f=(0,s.useRef)(null),g=(0,s.useCallback)(e=>{f.current&&t(f.current.id,e)},[t]),x=(0,s.useRef)(!1),b=(0,s.useRef)(0),v=(0,s.useRef)(0),y=(0,s.useRef)(!1),w=(0,s.useRef)(void 0),k=()=>({liveRunId:f.current?.id,sourceTaskId:w.current,turnStartedAt:new Date(v.current||f.current?.startedAt||Date.now()).toISOString(),..."codex"===c?{turnId:`live-task-${f.current?.id}-${b.current}`}:{}}),C=(0,s.useRef)(0),j=(0,s.useRef)(!1),N=(0,s.useRef)(!1),S=(0,s.useRef)(!1),T=(0,s.useRef)((0,d.B)()),E=(0,s.useRef)(!1),R=(0,s.useRef)(!1),M=e=>{f.current={...e,active:!0},x.current=!1,w.current=void 0,b.current=0,v.current=e.startedAt,y.current=!1,h.current=null,p.current=0,C.current=0,j.current=!1,N.current=!1,S.current=!1,E.current=!1,R.current=!1,u?.onSnapshotStart?.(e),u?.onLiveOutputTokens?.(null),u?.onRunStartedAt?.(e.startedAt),u?.onBackgroundTasks?.([])},L=()=>{let e=`live-asst-${f.current?.id}-${++p.current}`;h.current=e;let t=k();return g(n=>[...n,{id:e,role:"assistant",content:"",isStreaming:!0,timestamp:t.turnStartedAt,...t}]),e},I=e=>{if((0,l.Nn)(e))return;let t=e=>{u?.onLiveOutputTokens?.({outputTokens:Math.max(0,Math.round(e))})},n=e=>{!j.current&&"string"==typeof e&&e&&(C.current+=(0,a.r)(e),t(C.current))};if("system"===e.type&&"init"===e.subtype){let t=N.current;"codex"===c&&t&&!y.current&&b.current++,"number"==typeof e._ts&&Number.isFinite(e._ts)&&(v.current=e._ts),y.current=!1,S.current=!0,t||(C.current=0,j.current=!1,u?.onLiveOutputTokens?.(null),u?.onRunStartedAt?.(Date.now())),E.current=!1,L();return}if("usage_update"===e.type){"number"==typeof e.output_tokens&&Number.isFinite(e.output_tokens)&&(j.current=!0,C.current=Math.max(C.current,Math.round(e.output_tokens)),t(C.current));return}if("stream_event"===e.type){let t=e.event;if(E.current&&t?.type==="message_start"){E.current=!1;let e=h.current;e&&g(t=>t.map(t=>t.id===e?{...t,isStreaming:!1}:t)),L()}t?.type==="content_block_delta"&&t.delta?.type==="text_delta"&&n(t.delta.text)}if("system"===e.type&&"input_started"===e.subtype&&e.inputId){R.current=!0,E.current=!1;let t=`input-asst-${e.inputId}`;h.current=t,g({event:e,engine:c,assistantId:t});return}if("system"===e.type&&"input_binding"===e.subtype)return void g({event:e,engine:c,assistantId:""});if("system"===e.type&&"task_binding"===e.subtype&&"string"==typeof e.taskId){w.current=e.taskId,g(e=>e.map(e=>e.liveRunId===f.current?.id?{...e,sourceTaskId:w.current}:e));return}if("system"===e.type&&"background_tasks_changed"===e.subtype){let t=e.tasks??[];u?.onBackgroundTasks?.(t.filter(e=>!e.ambient).map(e=>({task_id:e.task_id,description:e.description})));return}if(!(0,l.A7)(e)||(u?.taskStore?.applyEvent(e),T.current.observe(e),g({event:e,engine:c,assistantId:h.current??""}),"task_notification"===e.subtype)){if("system"===e.type&&"task_notification"===e.subtype){if(!S.current&&T.current.reportsToMain(e)){let t=`live-tasknotif-${e.task_id||++p.current}`,n=`<task-notification>
|
|
727
727
|
`+(e.task_id?`<task-id>${e.task_id}</task-id>
|
|
728
728
|
`:"")+(e.tool_use_id?`<tool-use-id>${e.tool_use_id}</tool-use-id>
|
|
729
729
|
`:"")+(e.status?`<status>${e.status}</status>
|
|
730
730
|
`:"")+(e.summary?`<summary>${e.summary}</summary>
|
|
731
731
|
`:"")+(e.output_file?`<output-file>${e.output_file}</output-file>
|
|
732
|
-
`:"")+"</task-notification>",r=k();g(s=>[...s,{...r,id:t,role:"system",content:e.summary||"",systemEvent:{kind:"task-notification",...e.status?{status:e.status}:{},detail:n}}])}return}if("system"===e.type&&"notice"===e.subtype){let t=(0,i.C)(e,`live-notice-${++p.current}`),n=k();t&&g(e=>[...e,{...t,...n}]);return}if("user"===e.type&&e._human){let t=e.message?.content,n="string"==typeof t?t:Array.isArray(t)?t.map(e=>e?.text||"").join(""):"",r="string"==typeof e._turnId?e._turnId:null;!R.current&&(S.current||N.current)&&(E.current=!0);let s="number"==typeof e._ts&&Number.isFinite(e._ts)?e._ts:null;"codex"===c&&!S.current&&N.current&&b.current++,"codex"===c&&S.current||(v.current=s??f.current?.startedAt??Date.now()),y.current=!0;let o=k(),a=r?`live-user-${r}`:`live-user-${f.current?.id}-${++p.current}`;g(t=>r&&t.some(e=>e.id===a||e.liveInputId===r)?t:[...t,{id:a,role:"user",content:n,...o,liveInputId:r??void 0,...null!==s?{timestamp:new Date(s).toISOString()}:{},...e._images?.length?{images:e._images}:{}}]);return}if("result"===e.type&&(S.current=!1,N.current=!0),"assistant"===e.type&&Array.isArray(e.message?.content))for(let t of e.message.content)t.text?n(t.text):t.name&&n(`${t.name} ${JSON.stringify(t.input??{})}`);if("user"===e.type&&Array.isArray(e.message?.content))for(let t of e.message.content)n("string"==typeof t.content?t.content:JSON.stringify(t.content??""));g({event:e,engine:c,assistantId:h.current??L()})}},A=(0,s.useRef)(!1),P=t=>{if(!u?.onlyRunId||!A.current){if(u?.onlyRunId&&"run-snapshot"===t.type&&t.runId!==u.onlyRunId){if(t.recovery)return;A.current=!0,u.onRunEnd?.(!1,u.onlyRunId);return}if("run-snapshot"===t.type&&Array.isArray(t.events)){!t.recovery&&f.current&&t.runId&&t.runId!==f.current.id&&u?.onRunEnd?.(!1,f.current.id);let n="running"!==t.status&&!0===t.writerActive&&t.events.length>0,r="error"===t.status;if("running"!==t.status&&!n&&!(r&&t.events.length)){x.current=!0===t.writerActive,f.current&&(f.current.active=!1);let n="string"==typeof t.runId?t.runId:f.current?.id;for(let s of(n&&u?.onRunEnd?.(x.current,n,r),!x.current&&e&&u?.onWriterIdle?.(e),u?.onRunningChange?.(!1),u?.onLiveOutputTokens?.(null),u?.onRunStartedAt?.(null),u?.onBackgroundTasks?.([]),g(l.fD),u?.taskStore?.settleRunning(),C.current=0,j.current=!1,N.current=!1,t.recoveryDeletions??[]))u?.onRecoveryDeleted?.(s);return}let s="number"==typeof t.startedAt?t.startedAt:null,o={id:t.runId||`${e}:${s}`,startedAt:s??Date.now(),recovery:t.recovery};M(o);let a="number"==typeof t.outputTokens&&Number.isFinite(t.outputTokens)?Math.max(0,Math.round(t.outputTokens)):null;for(let e of(null!==a&&(C.current=a,j.current=!0,u?.onLiveOutputTokens?.({outputTokens:a})),t.events))I(e);for(let e of((n||r)&&(x.current=!0===t.writerActive,f.current.active=!1,u?.onRunEnd?.(x.current,o.id,r),g(l.fD)),t.recoveryDeletions??[]))u?.onRecoveryDeleted?.(e);u?.onRunningChange?.(!n&&!r),u?.onRunStartedAt?.(r?null:"number"==typeof t.startedAt?t.startedAt:Date.now())}else if("run-event"===t.type&&t.message){if("recovery-deleted"===t.message.type)return void u?.onRecoveryDeleted?.(t.message.deletion);if("run-ended"===t.message.type||"run-settled"===t.message.type){if("string"==typeof t.message.runId&&f.current&&t.message.runId!==f.current.id)return;x.current="run-ended"===t.message.type&&!0===t.message.writerActive,f.current&&(f.current.active=!1);let e="string"==typeof t.message.runId?t.message.runId:f.current?.id;e&&u?.onRunEnd?.(x.current,e,"error"===t.message.status),u?.onRunningChange?.(!1),u?.onLiveOutputTokens?.(null),u?.onRunStartedAt?.(null),u?.onBackgroundTasks?.([]),g(l.fD),u?.taskStore?.settleRunning(),C.current=0,j.current=!1,N.current=!1;return}if(x.current){(0,r.X)(t.message)&&I(t.message);return}let n=t.message;f.current?.active||M({id:"string"==typeof n._turnId?n._turnId:`${e}:${n._ts??Date.now()}`,startedAt:n._ts??Date.now()}),I(n),u?.onRunningChange?.(!0)}else if("run-idle"===t.type){for(let e of t.recoveryDeletions??[])u?.onRecoveryDeleted?.(e);e&&u?.onWriterIdle?.(e),x.current=!1,f.current&&(f.current.active=!1),f.current&&u?.onRunEnd?.(!1,f.current.id),u?.onRunningChange?.(!1),u?.onLiveOutputTokens?.(null),u?.onRunStartedAt?.(null),u?.onBackgroundTasks?.([]),g(l.fD),u?.taskStore?.settleRunning(),C.current=0,j.current=!1,N.current=!1}}};return(0,o.h)({url:e?`/ws/session-stream?sessionId=${encodeURIComponent(e)}&subscriber=${encodeURIComponent(m)}`:"/ws/session-stream",enabled:n&&!!e,onMessage:e=>{for(let t of e.recoveries??[])P(t);P(e),!u?.onlyRunId||f.current?.id!==u.onlyRunId||x.current||f.current.active||(A.current=!0)}}),e=>P({...e,recovery:!0})}},66109:(e,t,n)=>{n.d(t,{aO:()=>r,iG:()=>s,jL:()=>o});let r="relative w-full max-w-[calc((100vw_-_28rem)*0.9)] h-[90vh] mx-4 bg-card rounded-lg shadow-lv3 flex flex-col overflow-hidden",s="relative w-full max-w-[calc((100vw_-_14rem)*0.9)] h-[90vh] mx-4 bg-card rounded-lg shadow-lv3 flex flex-col overflow-hidden",o="grid grid-cols-[repeat(auto-fill,minmax(320px,1fr))] gap-3"},67183:(e,t,n)=>{n.d(t,{M:()=>o,a:()=>a});let r=/^\s*<cockpit-decisions>\n?([\s\S]*?)<\/cockpit-decisions>\s*/,s=/^- \[(dec-[a-z0-9]+-[a-z0-9]+) r(\d+)\] (.*)$/gm;function o(e){let t=r.exec(e);if(!t)return{items:[],body:e};let n=[];for(let e of t[1].matchAll(s))n.push({key:`${e[1]}@${e[2]}`,text:e[3]});return{items:n,body:e.slice(t[0].length)}}let a=e=>o(e).body},67415:(e,t,n)=>{n.d(t,{VU:()=>a,gG:()=>l,i2:()=>i});var r=n(49433),s=n(84230),o=n(37640);let a=()=>(0,s.F)("/api/session-bots",(0,o.zi)("/api/session-bots")),l=r.OH5(()=>(0,s.T)("/api/session-bots")),i=(e,t)=>(0,o.zi)("/api/session-bots",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,sessionId:t})}).pipe(r.yeE(l))},67889:(e,t,n)=>{n.d(t,{o:()=>r});let r="flex items-center gap-2 h-9 flex-shrink-0 border-b border-border"},67958:(e,t,n)=>{n.d(t,{B:()=>r});function r(){let e=new Map,t=new Set,n=new Set;return{observe(r){"system"===r.type&&r.task_id&&("task_started"===r.subtype?(t.add(r.task_id),r.parent_task_id&&e.set(r.task_id,r.parent_task_id)):"task_notification"===r.subtype&&n.add(r.task_id))},reportsToMain(r){let s=r.task_id?e.get(r.task_id):void 0;return!(s&&t.has(s))||n.has(s)}}}},68287:(e,t,n)=>{function r(e){return"loading"===e?"relative session-number-running":""}function s(e,t){return"loading"===e||"unread"===e?"border-transparent bg-orange-11/15 text-orange-11":t?"border-transparent bg-brand/15 text-brand":"border-transparent bg-muted-foreground/15 text-muted-foreground"}function o(e,t){return[r(e),s(e,t)].filter(Boolean).join(" ")}n.d(t,{JQ:()=>s,QV:()=>r,ci:()=>o})},69809:(e,t,n)=>{n.d(t,{A:()=>a});var r=n(50931);let s=JSON.parse('{"common":{"openAsProject":"Open as project","save":"Save","cancel":"Cancel","delete":"Delete","close":"Close","minimize":"Minimize","copy":"Copy","edit":"Edit","file":"File","codeMap":"Code Map","diff":"Diff","confirm":"Confirm","loading":"Loading...","search":"Search","refresh":"Refresh","retry":"Retry","submit":"Submit","copied":"Copied","saved":"Saved","failed":"Failed","noMatch":"No matches","noData":"No data","done":"Done","justNow":"just now","minutesAgo":"{{count}}m ago","hoursAgo":"{{count}}h ago","daysAgo":"{{count}}d ago","monthsAgo":"{{count}}mo ago","yearsAgo":"{{count}}y ago","saveFailed":"Save failed","copyFailed":"Copy failed","deleteFailed":"Delete failed","operationFailed":"Operation failed","copiedPath":"Path copied","copyPath":"Copy path","openInConsole":"Open in Console bubble","copyAbsPath":"Copy absolute path","loadMore":"Load more","noResult":"No results","selected":"Selected","selectAll":"Select all","hint":"Notice","confirmBtn":"OK","cancelBtn":"Cancel","preview":"Preview","readable":"Readable","previous":"Previous","next":"Next","all":"All","input":"Input","result":"Result","line":"Line","lines":"lines","running":"Running","connecting":"Connecting","connected":"Connected","connectionFailed":"Connection failed","builtin":"Built-in","global":"Global","project":"Project","current":"Current","code":"Code"},"htmlApps":{"tabFiles":"Files","tabRun":"Run","mine":"Mine","selectHint":"Select an app on the left to see its files and source; it only runs when you click Run (apps get full shell access).","openFull":"Open full screen (minimisable to the sidebar)","title":"HTML Apps","addTooltip":"Add to HTML panel","added":"Added to HTML panel","alreadyAdded":"Already added","addFailed":"Failed to add","add":"Add","adding":"Adding...","addHtmlApp":"Add HTML app","searchPlaceholder":"Search HTML apps...","pathLabel":"Absolute path to the .html file","invalid":"Invalid","builtin":"Built-in","noDescription":"No description","emptyNoApps":"No custom HTML apps yet.","emptyCreatePrefix":"Use","emptyCreateSuffix":"in chat to create a new app.","addExisting":"add an existing HTML file","viewDocs":"view docs","emptyNoMatch":"No HTML apps match your search."},"skills":{"addTooltip":"Add to Skills panel","added":"Added to Skills panel","alreadyAdded":"Already added","addFailed":"Failed to add","title":"Skills","searchPlaceholder":"Search skills...","clearSearch":"Clear","addSkill":"Add Skill","emptyNoSkills":"No skills yet.","emptyIntroPrefix":"Use","emptyIntroSuffix":"in chat to distil a reusable workflow into a SKILL.md file.","emptyNoMatch":"No skills match your search.","viewDocs":"view docs","pathLabel":"Absolute path to SKILL.md","pathPlaceholder":"/Users/you/.../skills/foo/SKILL.md","add":"Add","adding":"Adding...","invalid":"Invalid","builtinGroup":"Builtin","builtinReadOnly":"Builtin \xb7 read-only","selectHint":"Select a skill on the left to view its SKILL.md","fileTooLarge":"File is over 1 MB — not previewed","fileNotPreviewable":"This file cannot be previewed (binary)","copyPath":"Copy path","noDescription":"No description","previewTitle":"Skill Preview","source":"Source","cannotRead":"File cannot be read."},"toast":{"savedSuccess":"Saved","saveFailed":"Save failed","copiedName":"Copied: {{name}}","copyFailed":"Copy failed","deleteFailed":"Delete failed","operationFailed":"Operation failed","staged":"Staged","stageFailed":"Stage failed","unstaged":"Unstaged","unstageFailed":"Unstage failed","stagedNFiles":"Staged {{count}} files","unstagedNFiles":"Unstaged {{count}} files","discardFailed":"Discard failed","discardedNFiles":"Discarded changes in {{count}} files","deletedFile":"File deleted","discardedChanges":"Changes discarded","pastedFile":"Pasted: {{name}}","pasteFailed":"Paste failed","noFileToPaste":"No file to paste","createdFile":"Created: {{name}}","createFailed":"Create failed","movedToTrash":"Moved to trash: {{name}}","copiedPageUrl":"Page URL copied","copiedDirPath":"Directory path copied","switchedToBranch":"Switched to {{branch}}","switchBranchFailed":"Branch switch failed","loadBranchFailed":"Failed to load branches","copiedCommand":"Copied: {{command}}","copiedMessage":"Message copied","sentToPeer":"Sent to the other pane","sendToPeerFailed":"Failed to send to the other pane","forkFailed":"Failed to fork session","excerptFailed":"Failed to excerpt this turn","turnDeleted":"Turn deleted","deleteTurnFailed":"Failed to delete this turn","copiedUrl":"URL copied","copiedOutput":"Output copied","copiedCmd":"Command copied","copiedComment":"Comment copied","copiedAllComments":"All comments copied","copiedFileContent":"File content copied","copiedQA":"Copied {{count}} Q&A","copiedAllQA":"All Q&A copied","sentQA":"Sent to AI","readFileFailed":"Failed to read file","fileOutsideProject":"File preview is unavailable here","reviewCreated":"Review created, link copied","reviewUpdated":"Review updated, link copied","reviewCreateFailed":"Failed to create review","sharingClosed":"Sharing disabled","sharingCloseFailed":"Failed to disable sharing","linkCopied":"Link copied","addCommentFailed":"Failed to add comment","deleteCommentFailed":"Failed to delete comment","editCommentFailed":"Failed to edit comment","addReplyFailed":"Failed to add reply","deleteReplyFailed":"Failed to delete reply","editReplyFailed":"Failed to edit reply","disconnected":"Disconnected: {{id}}","pluginReloading":"Reloading extension...","worktreeCreateSuccess":"Worktree created: {{name}}","worktreeCreateFailed":"Failed to create worktree","worktreeLoadFailed":"Failed to load worktree list","worktreeDeleted":"Worktree deleted","worktreeDeleteFailed":"Failed to delete worktree","worktreeLocked":"Locked","worktreeUnlocked":"Unlocked"},"workspace":{"selectProject":"Select a project to start","searchProjectPath":"Search project path...","loadingProjects":"Loading projects...","projectNotFound":"No projects found","sessions":"{{count}} sessions","loadingSessions":"Loading sessions...","noSessions":"No sessions","loadingText":"Loading...","openProject":"Open Project","expandSidebar":"Expand sidebar","collapseSidebar":"Collapse sidebar","notes":"Notes","skills":"Skills","apps":"Apps","settings":"Settings","help":"Help","updateAvailable":"v{{version}} available","copyUpgradeCommand":"Copy cockpit update","updateNow":"Update now","updating":"Updating…","updateComplete":"Update complete","updateFailed":"Update failed","updateCardPreparing":"Preparing update…","updateCardInstalling":"Downloading and installing","updateCardRepairing":"Repairing native dependency","updateCardUpToDate":"Already on the latest version, v{{version}}","updateCardCopyFix":"Copy fix command","updateCardFixCopied":"Fix command copied","updateCardRollingBack":"Install failed, rolling back","updateCardRestarting":"Restarting Cockpit…","updateCardDone":"Updated to v{{version}}","updateCardElapsed":"{{seconds}}s elapsed","updateCardBaseline":"last time ~{{seconds}}s","updateCardNoLiveStatus":"Live status unavailable; the update is still running","updateCardRolledBack":"Rolled back to the previous version; Cockpit is usable.","updateCardManualHint":"You can retry from a terminal:","updateCardLogHint":"Log: {{path}}","updateRestartNote":"Cockpit will restart in the background.","viewChangelog":"View changelog","serverRestarted":"Cockpit was updated in the background.","serverReloadAfterRestart":"Cockpit restarted. Reload this page.","reloadNow":"Reload","upgradeCommandCopied":"Copied `cockpit update`","projectNotes":"Project Notes","closeProject":"Close project","unsentDraft":"Unsent draft","bots":"Bots"},"mobile":{"useDesktop":"Desktop","messagePlaceholder":"Message…","send":"Send","stop":"Stop","enableNotifications":"Enable notifications","disableNotifications":"Disable notifications","notifyError":"Could not enable notifications","useMobile":"Mobile","newChat":"New chat","voiceInput":"Voice input","voiceStop":"Stop voice input","voiceListening":"Listening…","voiceDenied":"Microphone access was denied — allow it in the browser settings","voiceFailed":"Voice input failed: {{reason}}","voiceUnsupported":"Voice input is not available in this browser — use the microphone on your keyboard","quickInstructionsHint":"Tap to fill the input"},"sessions":{"recentSessions":"Recent Sessions","favorites":"Favorite Sessions","titleSingleLine":"The title must be a single line, with no line breaks or \\\\n","titleNoAt":"The title must not contain @","titleNotMentionable":"This title cannot be used with @: {{reason}}. Rename it first","mentionable":"Can be @-mentioned","mentionableHint":"Adds this session to the Bots list; any session can then hand it a task with \\"@title task\\"","suggestTitle":"Suggest a title with AI","titleSuggestFailed":"Could not suggest a title: {{reason}}","noFavorites":"No favorite sessions yet. Click the star in the tab bar to add.","addFavorite":"Add to favorites","removeFavorite":"Remove from favorites","selectFavoriteHint":"Select a favorite on the left to preview its messages","noSessionMessages":"No messages in this session, or its transcript is gone","selectSessionHint":"Select a session on the left to preview its messages","dateToday":"Today","dateYesterday":"Yesterday","dateLast7Days":"Last 7 days","dateEarlier":"Earlier","runningCount":"{{count}} running","unreadCount":"{{count}} unread","noSessions":"No sessions yet","running":"Running","done":"Done","dragToReorder":"Drag to reorder within this project","restoreTitle":"Restore default title","titleEmpty":"Title cannot be empty.","titleLoadFailed":"Could not load the title. Close and try again.","titleSaveFailed":"Could not save the title. Please try again.","editTitle":"Edit title","projectSessions":"Project Sessions","browseAllSessions":"Browse all sessions","sessionList":"Session List","search":"Search","searchSessions":"Search sessions...","searchRecentSessions":"Search recent sessions","loadSessionsFailed":"Failed to load sessions","loadingSessions":"Loading sessions...","noMatchingSessions":"No matching sessions","noSessionsYet":"No sessions yet","projectList":"Project List","openFolder":"Open Folder","loadingHistory":"Loading history...","sessionsTab":"Sessions","pullRequestsTab":"PRs","searchPullRequests":"Search number / URL / title","allRepos":"All repos","allEngines":"All engines","noPullRequests":"No recent session has opened a PR yet","noPullRequestsHint":"PRs appear here once a session runs gh pr create","noMatchingPullRequests":"No matching PRs","selectPullRequestHint":"Select a PR on the left to view its session","pullRequestSessions":"{{count}} sessions","openPullRequest":"Open PR","copyResumeCommand":"Copy resume","resumeCommandCopied":"Copied: {{command}}","copyFailed":"Copy failed"},"scheduledTasks":{"title":"Scheduled Tasks","aboutToTrigger":"About to trigger","secondsLater":"in {{count}}s","minutesLater":"in {{count}}m","hoursMinutesLater":"in {{h}}h {{m}}m","hoursLater":"in {{h}}h","onceType":"Once (in {{duration}})","everyDuration":"Every {{duration}}","completed":"Completed","paused":"Paused","activeCount":"{{running}} active","pausedCount":"{{paused}} paused","noScheduledTasks":"No scheduled tasks. Click the clock button in the chat input to create one.","lastResult":"Last","runNow":"Run now","deleteFailed":"Failed to delete the task","resume":"Resume","pause":"Pause","completedCount":"Completed ({{count}})","pendingCount":"{{count}} to review","openSession":"Open session","selectTaskHint":"Select a task on the left to preview its session messages","noTaskMessages":"No messages in this task\'s session yet","success":"Success","failure":"Failed","inFlight":"Running now","interrupted":"Interrupted","createTask":"Create Scheduled Task","editTask":"Edit Scheduled Task","sendMessage":"Message","messagePlaceholder":"Enter message to send...","taskFile":"Task File","taskFilePlaceholder":"/Users/you/project/tasks/daily-report.md","taskFileHint":"Absolute path. On each fire the agent reads this file first and acts on what it describes — edits take effect on the next run.","taskFilePromptHeader":"Read this task file first, then act accordingly:","type":"Type","once":"Once","interval":"Interval","quickSelect":"Quick Select","customCron":"Custom Cron Expression","customDuration":"Custom duration","cronPlaceholder":"e.g. 0 9 * * 1-5 (weekdays at 9am)","cronFormat":"Format: min hour day month weekday (e.g. 0 9 * * 1-5)","amountPlaceholder":"Amount","limitTimeRange":"Limit execution time range","startAt":"Start at (optional)","startAtHint":"Empty = start now. When set, runs stay on start + N \xd7 interval and never drift with run time","clear":"Clear","fromTime":"from {{time}}","to":"to","saveBtn":"Save ({{modKey}}↩)","createBtn":"Create ({{modKey}}↩)","5minLater":"In 5 minutes","15minLater":"In 15 minutes","30minLater":"In 30 minutes","1hourLater":"In 1 hour","3hoursLater":"In 3 hours","6hoursLater":"In 6 hours","1dayLater":"In 1 day","3daysLater":"In 3 days","every15min":"Every 15 min","every30min":"Every 30 min","every1hour":"Every 1 hour","every2hours":"Every 2 hours","every6hours":"Every 6 hours","every12hours":"Every 12 hours","everyDay":"Every day","daily9am":"Daily 09:00","daily6pm":"Daily 18:00","weeklyMon9am":"Mon 09:00","monthly1st9am":"1st of month 09:00","unit":{"minute":"min","hour":"hours","day":"days"},"duration":{"minute_one":"{{count}} min","minute_other":"{{count}} min","hour_one":"{{count}} hour","hour_other":"{{count}} hours","day_one":"{{count}} day","day_other":"{{count}} days"}},"runningTerminals":{"title":"Terminals","status":"{{count}} terminal(s) \xb7 {{projects}} project(s)","keys":"↑↓ select \xb7 Enter / double-click open \xb7 Del stop \xb7 Esc close","empty":"No terminals running","currentProject":"current project","stop":"Stop","confirmStop":"Stop this process?","stopping":"Stopping…","stopFailed":"Failed to stop the terminal","openTerminal":"Open terminal","typeHint":"Click the terminal to type","modePty":"PTY \xb7 interactive terminal","modePipe":"Pipe \xb7 output only","ended":"Ended","selectHint":"Select a terminal on the left to preview its output","notFound":"Couldn\'t find this terminal\'s bubble"},"cron":{"everyNMinutes":"Every {{n}} minutes","everyNHours":"Every {{n}} hours","everyMinute":"Every minute","everyHourAtMin":"Every hour at minute {{m}}","hourlyEveryMin":"{{h}}:xx every minute","daily":"Daily at {{time}}","weekdays":"Weekdays","weekends":"Weekends","dowSun":"Sun","dowMon":"Mon","dowTue":"Tue","dowWed":"Wed","dowThu":"Thu","dowFri":"Fri","dowSat":"Sat","monthPrefix":"","dayOfMonth":"","dayRange":"{{a}}th to {{b}}th","weekdayPrefix":"","weekdayRange":"{{a}} to {{b}}"},"blockViewer":{"empty":{"body":"Select a file in the left tree to see its code map.","hint":"or press ⌘K to search."},"fileMode":{"loading":"Loading…","notFound":"This file is not indexed (unsupported language or beyond the file cap)."},"buildProgress":{"listing":"Listing files…","contexts":"Reading project config…","parsing":"Parsing files","resolving":"Resolving imports…","edges":"Building call graph…","done":"Finishing up…"},"search":{"tooltip":"Search (⌘K)","hint":"Start typing to search","noResults":"No matches","files":"Files","symbols":"Symbols"},"viewerToggle":{"toBlock":"Show code map","toCode":"Back to code view"},"tabs":{"toc":"Functions","history":"Trail"},"toc":{"title":"this file","empty":"No functions detected.","notIndexed":"File not in project graph (unsupported language / not in git tracked set / file cap reached)."},"history":{"title":"recent","empty":"Click an input or output pin to begin tracing.","clear":"Clear history"},"refresh":"Rebuild project graph","relationsStale":"Project relations need a refresh","retry":"Retry"},"blockDiffViewer":{"loading":"Building code map…","unsupported":"Code map diff is not available for this file type.","unsupportedHint":"Switch back to the regular diff view to read it.","error":"Code map diff failed: {{message}}","noBlockChanges":"No code-map changes (formatting / whitespace only).","noBefore":"(new)","noAfter":"(removed)","kind":{"added":"added","deleted":"deleted","modified":"modified"}},"fileBrowser":{"directoryTree":"Tree","searchTab":"Search","recentTab":"Recent","changesTab":"Status","historyTab":"History","searchFiles":"Search files...","clear":"Clear","exactMatchOn":"Exact match (on)","exactMatchOff":"Exact match (off)","refreshTree":"Refresh directory tree","collapseAll":"Collapse all directories","searchFileContent":"Search file contents...","caseSensitive":"Case sensitive","wholeWord":"Whole word","regex":"Regex","fileTypes":"File types (ts,tsx)","compareMode":"Compare","compareModeOff":"Close branch comparison","compareModeOn":"Compare with selected branch","compareScopeHead":"HEAD","compareScopeWorktree":"Worktree","compareScopeHeadHint":"Compare committed work only","compareScopeWorktreeHint":"Include uncommitted changes (staged / unstaged / untracked)","createFile":"New File","createFileIn":"New File (in {{path}}/)","fileName":"File name...","noRecentFiles":"No recent files","stagingArea":"Staged ({{count}})","changesSummary_one":"{{count}} change","changesSummary_other":"{{count}} changes","noChanges":"No changes in working tree","refreshChanges":"Refresh changes","unstageAll":"Unstage all","noStagedFiles":"No staged files","unstageNFiles":"Unstage {{count}} files","unstageFile":"Unstage","workspace":"Workspace ({{count}})","discardAll":"Discard all","stageAll":"Stage all","noUnstagedChanges":"No unstaged changes","discardNFiles":"Discard changes in {{count}} files","stageNFiles":"Stage {{count}} files","discardChanges":"Discard changes","stageFile":"Stage file","loadingDiff":"Loading diff...","noDiffFiles":"No diff files","nFilesChangedPlain":"{{count}} files changed","nFilesChanged":"{{count}} files changed (vs {{branch}})","nFilesChangedWorktree":"{{count}} files changed (vs {{branch}}, incl. uncommitted)","noDiffFilesHeadHint":"Nothing committed on this branch yet — switch to Worktree to see uncommitted changes","loadingCommits":"Loading commits...","noCommits":"No commits","allLoaded":"All {{count}} records loaded","locateInTree":"Locate in directory tree","unsaved":"Unsaved","saveBeforeSwitch":"Current file has unsaved changes. Save before switching?","saveAndSwitch":"Save and switch","closeEdit":"Close edit (ESC)","closeBtn":"Close","copyFileContent":"Copy file content","toggleJsonReadable":"Toggle JSON readable mode","previewMarkdown":"Preview Markdown","exitPreview":"Exit Preview","collapseAllJson":"Fold","expandAllJson":"Full","viewBlame":"View line-by-line change history","viewDiff":"View changes against HEAD","exitDiff":"Exit Diff","diffLoadFailed":"Failed to load diff","editFile":"Edit file","backToPreview":"Back to preview","cannotPreview":"Cannot preview this file","selectFileToPreview":"Select a file to preview","staged":"Staged","unstaged":"Unstaged","selectFileToViewDiff":"Select a file to view diff","loadingDiffContent":"Loading diff...","clickCompareToLoad":"Click \\"Compare\\" to load branch diff","selectCommitToView":"Select a commit to view details","confirmDelete":"Confirm Delete","confirmDeleteMessage":"Move <file>{{name}}</file> to trash?","nFilesNMatches":"{{files}} files, {{matches}} matches","resultsTruncated":"Results truncated","noContentSearchResults":"No results","enterKeywordToSearch":"Enter keyword to search file contents","searchMinChars":"Search requires at least 2 characters"},"csv":{"table":"Table","raw":"Raw","empty":"Empty table","summary":"{{rows}} rows \xb7 {{cols}} columns","summaryFiltered":"{{rows}} / {{total}} rows matched \xb7 {{cols}} columns","loadMore":"Load more ({{shown}} / {{total}} shown)","filterPlaceholder":"Filter rows…","filterColumn":"Filter column","clearFilter":"Clear filter","allColumns":"All columns","noMatch":"No matching rows","sortHint":"Click to sort (asc / desc / off)"},"codeViewer":{"fileModifiedExternally":"File was modified externally. Saving will overwrite external changes.","useDiskVersion":"Use disk version","forceOverwrite":"Force overwrite","searchPlaceholder":"Search...","caseSensitive":"Case sensitive","wholeWordMatch":"Whole word match","unsavedConfirm":"You have unsaved changes. Close anyway?","discardChanges":"Discard changes","continueEditing":"Continue editing","unsavedExitConfirm":"You have unsaved changes. Exit edit mode?","clickToViewDetails":"Click to view details","clickToViewCommit":"Click to view commit details","nComments":"{{count}} comments","searchChat":"Search chat...","prevShiftEnter":"Previous (Shift+Enter)","nextEnter":"Next (Enter)","closeEsc":"Close (Esc)"},"chat":{"commandRefs_one":"{{count}} reference attached","commandRefs_other":"{{count}} references attached","commandRef_read":"read","commandRef_handoff":"hand on","commandRef_handoffMixed":"hand on","commandRef_targets":"target","commandRef_inline":"inlined","originSent":"@-mention from {{project}}","originDelegated":"Delegated from {{project}}","originUnknown":"another session","decisionContextAttached":"{{count}} related decisions attached","codexInput":{"queued":"Additional message waiting to send","accepted":"Codex accepted the additional message","failed":"Additional message delivery failed or is unconfirmed — open for details","images":"Images: {{count}}"},"recoveryCopy":"Failed run recovery copy","recoveryCopyHint":"Temporary copy of observed content. It may repeat saved history and is not sent to the model. Kept while this conversation remains open.","recoveryCopiesLabel":"Failed run recovery copies","recoveryAttachment":"Recovery attachment","startConversation":"Start a conversation","loadMoreHistory":"Load more...","scrollUpForMore":"↑ Scroll up to load more history","jumpToStart":"Jump to start","jumpToLatest":"Jump to latest","jumpToPrevUserMessage":"Previous user message","jumpToNextUserMessage":"Next user message","recentUserMessages":"Recent user messages","moreUserMessages":"More","userMessage":"User message","recentUserMessageNumber":"Recent user message {{index}} of {{total}}","imageMessage":"Image message","copyMessage":"Copy message","copyImage":"Copy image","copiedImage":"Image copied","forkSession":"Fork session from here","excerptTurn":"Excerpt this turn to a new session","newSession":"New session","continueFromHere":"Continue from here","continueFromHereDesc":"Keep all context through this turn","onlyThisTurn":"Only this turn","onlyThisTurnDesc":"Keep only this question and answer","onlyThisTaskDesc":"Keep this entire task, including all {{count}} inputs and replies","deleteTurn":"Delete turn","deletingTurn":"Deleting…","deleteTurnConfirm":"Delete this question, answer, and its tool records? This cannot be undone.","deleteTaskConfirm":"This task contains {{count}} user inputs, including additional steering. Delete the entire task with all its inputs, replies, and tool records? This cannot be undone.","deleteTurnConfirmAction":"Delete turn","deleteTurnWhileRunning":"A turn cannot be deleted while the session is running","sendToPeerPane":"Send this message to the other pane","imageN":"Image {{index}}","imagePreview":"Image preview","imageLoadFailed":"Could not load this image","toolCalls":"{{count}} tool calls","collapse":"▲ Collapse","expand":"▼ Expand","showMore":"Show more","showLess":"Show less","subagent":"Subagent","piChildStatus":{"interrupted":"Interrupted snapshot","truncated":"Truncated","running":"Running","done":"Done","failed":"Failed","cancelled":"Cancelled"},"subagentEmpty":"No subagent transcript found","subagentViewTitle":"View subagent transcript","workflowRun":"Run details","workflowViewTitle":"View workflow run details","workflowEmpty":"No workflow run journal found","workflowAgents":"agents","workflowViewAgent":"View","workflowUngrouped":"Ungrouped","viewQuestions":"View questions","viewAllFileChanges":"View all file changes","requestFailed":"Request failed","cannotReadStream":"Cannot read response stream","errorRetry":"An error occurred, please retry","codexResumeFailed":"Previous session is in use by another Codex client — started a new session; history was not carried over","codexResumeFailedPrevious":"Previous session","codexResumeFailedNew":"New session","codexContextCompacting":"Codex is compacting the context…","placeholder":"Type a message, / for skills, @ for bots","placeholderDisabled":"Generating... you can keep typing (ESC to cancel; if stuck, cancel and resend \'continue\')","placeholderRunning":"Generating... Enter sends now: it joins the current reply at its next step (ESC to stop)","imageSizeLimit":"Image size exceeds limit (max 5MB), current: {{size}}MB","viewGitChanges":"View Git changes","viewAllComments":"View all comments","userMessages":"User messages","projectNotes":"Project Notes","scheduledTasks":"Scheduled Tasks","quickInstructions":"Quick Instructions","globalInstructions":"Global Instructions","projectInstructions":"Project Instructions","noQuickInstructions":"No quick instructions yet","addQuickInstruction":"Add quick instruction","quickInstructionPlaceholder":"One-line instruction — Enter to save, Esc to cancel","insertQuickInstruction":"Insert into input (without sending)","addInstructionGroup":"New group","instructionGroupNamePlaceholder":"Group name — Enter to save, Esc to cancel","instructionGroupLabel":"Group","instructionGroupNone":"No group","deleteInstructionGroupConfirm":"Deleting \\"{{name}}\\" also deletes the {{count}} instruction(s) inside it. Continue?","editGlobalInstructions":"Edit global instructions","editProjectInstructions":"Edit project instructions","quickInstructionsMarkdownHint":"One top-level entry per line. Add lines beginning with “- ” after a group name for its instructions. Write \\\\n for a line break inside one instruction.","quickInstructionsMarkdownPlaceholder":"Continue\\nDraw with text\\n- Draw a login flow\\n- Draw a system architecture","quickInstructionsMarkdownError":"Invalid format on line {{line}}.","savingQuickInstructions":"Saving...","saveQuickInstructionsFailed":"Could not save. Your edits are still here; please try again.","context":"Context","output":"Output","copiedCommandTooltip":"Copied!","copyCommandTooltip":"Copy command: {{command}}","executedCommand":"Executed `{{command}}`{{exitInfo}}, output:\\n```\\n{{output}}\\n```","executedCommandFailed":"Failed to execute `{{command}}`: {{error}}","executionMode":"Execution Mode","checkBalance":"Check balance","balanceFailed":"Query failed — check the API key","balanceNeedsKey":"Set a DeepSeek API key first","balanceUnavailable":"Account is not available for requests","balanceEmpty":"No balance returned","openUsagePage":"Open DeepSeek usage console","checkQuota":"Check quota","quotaFailed":"Quota unavailable — check the API key","quotaNeedsKey":"Set an API key first","quotaEmpty":"No quota returned","quotaResetAt":"Resets {{time}}","openProviderConsole":"Open the provider console","planMode":"Plan mode","planModeDesc":"read-only, plans first without edits","planModeOn":"Plan mode on — read-only; send a task to get a plan","planModeOff":"Plan mode off","planModeHint":"Plan mode: read-only exploration that produces a plan without editing. Uncheck and resend to implement.","noHistory":"No history context","noHistoryDesc":"each prompt is independent","noHistoryHint":"No history context: each message is sent to the model on its own, with no prior conversation. The transcript above still records everything.","planTitle":"Plan (awaiting your review)","approvePlan":"Approve & run","planApproveHint":"No approval dialog here — click to exit plan mode and execute","approvePlanPrompt":"Approved — proceed with the plan above.","maximizePane":"Maximize this pane","restorePane":"Restore both panes","closePane":"Close this pane","singlePane":"Single pane","splitPane":"Split into two panes"},"console":{"enterCommandOrUrl":"Enter a command or URL to start","emptyIntro":"Type any of the following in the input bar to create a bubble:","bubbleCommand":"Command","bubbleInteractive":"Interactive","bubbleBrowser":"Browser","bubbleBrowserNoteIframe":"Some sites block iframe embedding — install Cockpit Bridge under Settings → Browser Extension before opening.","bubbleBrowserNoteCookie":"If a logged-in site first shows as signed out, refresh a few times to restore it.","bubbleDatabase":"Database","bubbleFilePreview":"File preview","loadingMore":"Loading...","loadMoreHistory":"Load more history","quickCommands":"Quick Commands","singleColumn":"Single column","dualColumn":"Dual column","envVars":"Environment Variables","launchShell":"Launch interactive shell","htmlApps":"HTML apps","inputPlaceholder":"Enter command or URL and press Enter... (↑↓ history, Tab complete)","scopeProject":"Project","scopeGlobal":"Global","tabSwitchEscClose":"Tab to switch \xb7 Esc to close","copyOutput":"Copy output","copyCommand":"Copy command","rerun":"Re-run","deleteRecord":"Delete record","searchPlaceholder":"Search...","searchMode":"Search","filterMode":"Filter","prevShiftEnter":"Previous (Shift+Enter)","nextEnter":"Next (Enter)","loadingTerminal":"Loading terminal...","clickToInput":"Click terminal area to type","stdinPlaceholder":"stdin input...","runningText":"Running...","exitCode":"Exit code: {{code}}","totalLines":"{{count}} lines total","globalCommands":"Global Commands","projectCommands":"Project Commands","noCustomCommands":"No custom commands yet","editGlobalCommands":"Edit global commands","editProjectCommands":"Edit project commands","quickCommandsTextHint":"One per line as \\"name: command\\". Names may only contain letters, digits, - and _; everything after the first colon is the command.","quickCommandsTextPlaceholder":"pg: psql -h localhost -U postgres\\ngitpull: git pull --rebase","quickCommandsTextError":"Line {{line}} is invalid; expected \\"name: command\\".","savingQuickCommands":"Saving...","saveQuickCommandsFailed":"Save failed. Your edits are kept; please retry.","restoreTooltip":"Restore ({{modKey}}M / ESC)","screenshotting":"Screenshotting...","outputFileDeleted":"[Output file deleted]"},"browser":{"blankPage":"Blank page","copyUrl":"Copy URL","openInNewWindow":"Open in new window","exitMaximize":"Exit maximize ({{modKey}}M)","maximize":"Maximize ({{modKey}}M)","pageLoadFailed":"Page load failed","openInTabFallback":"OpenCockpit Bridge is not connected — opened a plain new tab instead","movedToChrome":"Web pages now open in Chrome tabs, not in the console.","openInChrome":"Open in Chrome","openedInChrome":"Opened in Chrome — {{command}}","clickToWake":"Click to wake","sleeping":"Sleeping","loadingPage":"Loading...","loadFailed":"Load failed"},"database":{"connectionFailed":"Connection failed","connected":"Connected","connecting":"Connecting...","refreshTableList":"Refresh table list","filterTable":"T Tables","filterView":"V Views","noTables":"No tables","tabStructure":"Structure","tabData":"Data","tabSql":"SQL","filterActive":"Filter: {{count}} cols","clearAllFilters":"Clear all filters","deleteNRows":"Delete {{count}} rows","confirmDeleteRows":"Confirm delete?","copyCsvSelected":"Copy selected rows as CSV","copyCsvAll":"Export all as CSV","copyJsonSelected":"Copy selected rows as JSON","copyJsonAll":"Export all as JSON","copyCSV":"Copy CSV","CSV":"CSV","copyJSON":"Copy JSON","JSON":"JSON","selectTable":"Select a table","selectTableToView":"Select a table to view structure","selectTableForData":"Select a table to view data","columns":"Columns","colName":"Name","colType":"Type","colNullable":"Nullable","colDefault":"Default","primaryKey":"Primary Key","foreignKeys":"Foreign Keys","indexes":"Indexes","enable":"Enable","commaValues":"Comma-separated values","likePattern":"%pattern%","valuePlaceholder":"Value","apply":"Apply","clearFilter":"Clear","addRow":"+ Add Row","totalRows":"{{count}} rows","rowsAffected":"{{command}} — {{count}} rows affected ({{duration}}ms)","queryRows":"{{count}} rows ({{duration}}ms)","resultTruncated":"[Results truncated to 1000 rows]","sqlPlaceholder":"Enter SQL... ({{modKey}}Enter to execute)","executing":"Executing...","execute":"▶ Execute","deleteRowsFailed":"{{count}} rows failed to delete","inputParams":"Input Parameters","resultLabel":"Result"},"mysql":{"connectionFailed":"Connection failed","connected":"Connected","connecting":"Connecting...","refreshTableList":"Refresh table list","filterTable":"T Tables","filterView":"V Views","noTables":"No tables","tabStructure":"Structure","tabData":"Data","tabSql":"SQL","filterActive":"Filter: {{count}} cols","clearAllFilters":"Clear all filters","deleteNRows":"Delete {{count}} rows","confirmDeleteRows":"Confirm delete?","copyCsvSelected":"Copy selected rows as CSV","copyCsvAll":"Export all as CSV","copyJsonSelected":"Copy selected rows as JSON","copyJsonAll":"Export all as JSON","copyCSV":"Copy CSV","CSV":"CSV","copyJSON":"Copy JSON","JSON":"JSON","selectTable":"Select a table","selectTableToView":"Select a table to view structure","selectTableForData":"Select a table to view data","columns":"Columns","colName":"Name","colType":"Type","colNullable":"Nullable","colDefault":"Default","primaryKey":"Primary Key","foreignKeys":"Foreign Keys","indexes":"Indexes","enable":"Enable","commaValues":"Comma-separated values","likePattern":"%pattern%","valuePlaceholder":"Value","apply":"Apply","clearFilter":"Clear","addRow":"+ Add Row","totalRows":"{{count}} rows","rowsAffected":"{{command}} — {{count}} rows affected ({{duration}}ms)","queryRows":"{{count}} rows ({{duration}}ms)","resultTruncated":"[Results truncated to 1000 rows]","sqlPlaceholder":"Enter SQL... ({{modKey}}Enter to execute)","executing":"Executing...","execute":"▶ Execute","deleteRowsFailed":"{{count}} rows failed to delete"},"redis":{"neverExpires":"Never expires","expired":"Expired","loadFailed":"Load failed","deleteFailed":"Delete failed","saveFailed":"Save failed","scanPlaceholder":"SCAN pattern...","scanSearch":"Search (SCAN)","noKeys":"No keys","loadMore":"Load more...","tabData":"Data","tabInfo":"Info","tabCli":"CLI","selectKey":"Select a key","keyNotExist":"Key does not exist","unsupportedType":"Unsupported type: {{type}}","nItems":"{{total}} items","showingN":"showing {{count}}","nMembers":"{{total}} members","nEntries":"{{total}} entries","cliHint":"Enter Redis commands, e.g. PING, GET key, KEYS *","cliPlaceholder":"Enter command..."},"git":{"switchBranch":"Switch branch","searchBranch":"Search branches...","noBranches":"No branches available","noMatchingBranches":"No matching branches","localBranches":"Local Branches","remoteBranches":"Remote Branches","branchNotFound":"Branch not found","selectBranch":"Select branch...","currentBranch":"Current","notGitRepo":"Current directory is not a Git repository","cannotGetBranches":"Cannot get branch info","getBranchesFailed":"Failed to get branch info","discardAllConfirm":"Discard changes in {{count}} workspace files? This cannot be undone.","worktree":{"title":"Git Worktree","count":"{{count}} worktrees","selectBranch":"Select branch","addWorktree":"+ Add Worktree","confirmDelete":"Confirm Delete","confirmDeleteMsg":"Delete this worktree?","path":"Path:","branch":"Branch:","locked":"Locked","unlock":"Unlock","lock":"Lock","searchBranch":"Search branches...","noBranches":"No available branches"}},"comments":{"addComment":"Add Comment","lineRange":"Line {{start}}-{{end}}","inputPlaceholder":"Enter comment...","newComment":"New comment {{range}}","commentPlaceholder":"Enter comment... ({{modKey}}Enter to submit, Esc to cancel)","nComments":"{{count}} comments","allComments":"All Comments","copyAllComments":"Copy all comments","noComments":"No comments yet","clearAll":"Clear all","totalComments":"{{count}} comments total","aiReply":"AI Reply","noContent":"(no content)","linesCount":"({{count}} lines)","codeRef":"Here are my annotated comments and references:","note":"Note: {{content}}","submitting":"Submitting...","enterSubmit":"Enter to submit \xb7 Shift+Enter for new line","submitComment":"Submit Comment","askAI":"Ask AI","inputQuestion":"Enter your question...","aiGenerating":"Generating, please wait...","enterSend":"Enter to send \xb7 Shift+Enter for new line","sendToAI":"Send to AI","aiResponding":"AI is responding..."},"fileContextMenu":{"createFile":"New File","copyFile":"Copy File","copyFolder":"Copy Folder","pasteHere":"Paste Here","deleteFile":"Delete File","deleteFolder":"Delete Folder","copyRelativePath":"Copy Relative Path","copyAbsolutePath":"Copy Absolute Path","copyRelativeDirPath":"Copy Relative Dir Path","copyAbsoluteDirPath":"Copy Absolute Dir Path","copyFileName":"Copy File Name","copyFolderName":"Copy Folder Name"},"settings":{"title":"Settings","theme":"Theme","themeLight":"Light","themeDark":"Dark","themeSystem":"System","browserExtension":"Browser Extension","extensionInstalled":"OpenCockpit Bridge connected","extensionNotInstalled":"OpenCockpit Bridge not connected","extensionDescription":"Lets `cockpit browser` drive your Chrome tabs and Console browser bubbles. Every tab gets an id (in the extension\'s popup and icon tooltip); Cockpit asks before acting on a tab you haven\'t allowed — permission is per tab.","installSteps":"Installation steps:","step1":"1. Open Chrome and navigate to","step2":"2. Enable \\"Developer mode\\" in the top-right corner","step3":"3. Click \\"Load unpacked\\"","step4mac":"4. Press <kbd>Cmd+Shift+G</kbd> → paste the path below → Enter","copyExtensionPath":"Copy extension directory path","reloadExtension":"Reload extension","about":"About","language":"Language","languageAuto":"System","switchDark":"Switch to dark","switchLight":"Switch to light","agentsBundled":"bundled","codexSection":"Codex","codexSuggestions":"Suggest next prompt","codexSuggestionsDescription":"After each reply, ask Codex to predict your next message and show it in the input box (Tab to accept). Costs one small extra request per turn."},"editor":{"placeholder":"Write something... Type / for commands","noteTitle":"{{name}} - Notes","noteUntitled":"Notes","globalNote":"Global note","emptyNote":"Empty note","searchNotes":"Search notes...","saving":"Saving...","conflictReloaded":"This note was changed elsewhere. Loaded the latest version; your recent unsaved edits were discarded.","linkPlaceholder":"Enter URL...","confirmLink":"Confirm","removeLink":"Remove link","heading1":"Heading 1","heading2":"Heading 2","heading3":"Heading 3","bold":"Bold","italic":"Italic","strikethrough":"Strikethrough","inlineCode":"Inline code","link":"Link","bulletList":"Bullet list","orderedList":"Ordered list","taskList":"Task list","blockquote":"Blockquote","codeBlock":"Code block","table":"Table","horizontalRule":"Horizontal rule","insertRowAbove":"Insert row above","insertRowBelow":"Insert row below","insertColumnLeft":"Insert column left","insertColumnRight":"Insert column right","deleteRow":"Delete row","deleteColumn":"Delete column","deleteTable":"Delete table","deleteCodeBlock":"Delete code block","toc":"TOC","expandToc":"Expand TOC","collapseToc":"Collapse TOC"},"slashCommands":{"heading1":"Heading 1","heading1Desc":"Large heading","heading2":"Heading 2","heading2Desc":"Medium heading","heading3":"Heading 3","heading3Desc":"Small heading","bulletList":"Bullet List","bulletListDesc":"Bulleted list","orderedList":"Ordered List","orderedListDesc":"Numbered list","taskList":"Task List","taskListDesc":"Checkable task list","blockquote":"Blockquote","blockquoteDesc":"Quote block","codeBlock":"Code Block","codeBlockDesc":"Code snippet","table":"Table","tableDesc":"Insert 3\xd73 table","horizontalRule":"Divider","horizontalRuleDesc":"Horizontal divider","link":"Link","linkDesc":"Insert hyperlink"},"commands":{"plan":"Enable plan mode \xb7 /plan <task> to plan it \xb7 /plan off to disable"},"markdown":{"copied":"✓ Copied","copy":"Copy"},"imagePreview":{"previewImage":"Preview image","deleteImage":"Delete image","copyImage":"Copy image","copiedImage":"Image copied"},"tokenStats":{"title":"Claude Code Token Stats","activeHours":"Active Hours Distribution","hourSessions":"{{h}}:00 — {{count}} sessions","messages":"Messages","toolCalls":"Tool Calls","activityTrend":"Activity Trend","byModel":"By Model","tokenUsage":"Token Usage","equivalentCost":"Equivalent Cost","modelCostDetail":"Model Cost Details","model":"Model","share":"Share","total":"Total","totalSessions":"Total Sessions","totalMessages":"Total Messages","equivalentApiCost":"Equivalent API Cost","longestSession":"Longest Session","firstUse":"First Use","notFound":"~/.claude/stats-cache.json not found","day":"Day","week":"Week","month":"Month"},"toolCall":{"inputParams":"Input Parameters","resultLabel":"Result","inputParamsTitle":"View input parameters","resultTitle":"View result","input":"Input","result":"Result","details":"Details","detailsTitle":"View input and result","foldedLines":"... ({{count}} lines)"},"fileEditor":{"unsavedConfirm":"You have unsaved changes. Close anyway?","discardChanges":"Discard changes","continueEditing":"Continue editing","externallyModified":"File was modified externally. Saving will overwrite external changes.","useDiskVersion":"Use disk version","forceOverwrite":"Force overwrite"},"quickFileOpen":{"placeholder":"Type file name to open...","noMatch":"No matching files","recent":"Recent","selectHint":"Select","openHint":"Open","closeHint":"Close"},"envManager":{"title":"Environment Variables","tabScope":"Current Tab Only","globalScope":"Global Environment Variables","varNamePlaceholder":"Variable name (e.g. NODE_ENV)","varValuePlaceholder":"Value (e.g. production)","valuePlaceholder":"Value","noVars":"No environment variables yet. Add one to get started."},"aliasManager":{"title":"Command Aliases","description":"Set shortcut aliases for common commands (global)","aliasPlaceholder":"Alias (e.g. ll)","commandPlaceholder":"Full command (e.g. ls -la)","fullCommandPlaceholder":"Full command","usage":"Usage tip:","usageDesc":"Type an alias to execute the corresponding full command","noAliases":"No command aliases yet. Add one to get started."},"diffViewer":{"fileChanges":"File Changes ({{count}})","expandFull":"Expand to full width","exitFull":"Back to column","toggleFileTree":"Toggle file tree","selectFileToView":"Select a file to view changes","sideBySide":"Side by side","unified":"Unified","viewSplit":"Split","viewUnified":"Unified","previewFile":"Preview file","copiedAll":"Full text copied","compact":"Compact","full":"Full","gap":{"hidden":"{{count}} lines hidden","more":"\xb7\xb7\xb7 more +{{count}} \xb7\xb7\xb7","expandUp":"Expand {{count}} lines up","expandDown":"Expand {{count}} lines down","expandAll":"Click to expand {{count}} lines"},"loadingSnapshots":"Loading snapshots…","loadingFile":"Loading file diff…","fileLoadFailed":"Could not load the file diff","noChanges":"No file changes detected in this turn","notViewable":"Binary or oversized file — diff not viewable","externalChange":"Concurrent change from another session/process","reconstructed":"reconstructed","reconstructedHint":"Rebuilt from tool-call parameters — not a disk snapshot","truncated":"Too many files — list truncated","aggregate":"Aggregate","aggregateOn":"View the net change across all calls","aggregateOff":"Back to per-call view","fileChangesAggregate":"File Changes ({{count}}) \xb7 Aggregate","aggregateSummary":"{{count}} files changed (across {{calls}} calls)","aggregateLoading":"Aggregating changes…","aggregateEmpty":"No net change after aggregation","aggregateUnavailable":"No snapshots — cannot aggregate","aggregateFailed":"Aggregation failed","aggregateBaselineSkipped":"Skipped {{count}} baseline-scale call(s)","aggregateBaselineIncluded":"Including {{count}} baseline-scale call(s)","callsBaselineHidden":"Hid {{count}} baseline-scale call(s)","callsBaselineShown":"Showing {{count}} baseline-scale call(s)","aggregateSkippedHint":"These calls touched more than {{threshold}} files — usually a branch switch or rebase rather than authored work. Click to toggle.","imageBefore":"Before","imageAfter":"After","imageAdded":"Added","imageDeleted":"Deleted","imageLoadFailed":"Failed to load image","imageUnavailable":"Image not present in either revision"},"commitDetail":{"title":"Commit Details","hash":"Hash:","author":"Author:","date":"Date:","files":"Files:","nChanges":"{{count}} changes","loadingFiles":"Loading files...","noFileChanges":"No file changes","loadingDiff":"Loading diff...","selectFileToView":"Select a file to view diff"},"askQuestion":{"title":"Questions","nQuestions":"{{count}} questions","checkedN":"{{count}} checked","copyChecked":"Copy {{count}} checked Q&A","copyAll":"Copy all Q&A","sendChecked":"Send {{count}} checked Q&A to AI","sendAll":"Send all Q&A to AI","sendNoChat":"No active chat session","checkToCopy":"Check to copy","custom":"Custom","customPlaceholder":"Enter custom answer...","notSelected":"(not selected)"},"tabBar":{"closeTab":"Close session","closeAll":"Close all sessions","newTab":"New session"},"tabManagerTopBar":{"copyPageUrl":"Copy page URL","copyDirPath":"Copy directory path","refreshProject":"Refresh project","openInVSCode":"Open in VS Code","openInCursor":"Open in Cursor","aliasesGlobal":"Command Aliases (Global)","tokenStats":"Token Stats","openSurething":"Open Surething","openOnPhone":"Open on phone","phoneQrHint":"Scan with your phone to open Cockpit","phoneQrSessionHint":"Scan with your phone to open this session","phoneQrTokenWarning":"This code contains your access token. Don\'t share it.","phoneQrFailed":"Could not generate the QR code"},"hoverTooltip":{"findReferences":"Find References","search":"Search"},"todoViewer":{"title":"Task List","progress":"{{completed}} / {{total}} done"},"userMessages":{"title":"User Messages","noMessages":"No user messages","searchPlaceholder":"Search user messages…","noResults":"No matching messages","loadFailed":"Failed to load","count":"{{shown}} / {{total}}","jumping":"Loading the turns around this message…"},"shortIdBadge":{"clickToDisconnect":"Click to disconnect","clickToRegister":"Click to register and copy CLI command","setTitle":"Name this bubble (so /cc can find it later)","setTitlePlaceholder":"set title","editTitle":"Edit title","titleSet":"Title: {{title}}","dialogTitle":"Name this bubble","dialogPlaceholder":"e.g. alloydb proxy, staging admin"},"api":{"pathForbidden":"Operation not allowed on this path","deleteForbidden":"Delete not allowed on this path","notAFolder":"Target is not a folder","imageTooLarge":"Image too large to preview","cannotPreviewBinary":"Cannot preview binary file","fileTooLarge":"File too large to preview (over 10MB)","fileModifiedExternally":"File was modified externally"},"folderPicker":{"title":"Open Folder","placeholder":"Type or paste a path, e.g. ~/Work/my-app","open":"Open","showHidden":"Show hidden","hint":"↑↓ select \xb7 Tab/Enter go in \xb7 ⌘/Ctrl+Enter open","empty":"No subfolders","noMatch":"No matching folders","notFound":"Folder not found","notDirectory":"Not a folder","denied":"Permission denied. On macOS, grant access in System Settings › Privacy & Security."},"confirm":{"title":"Notice","ok":"OK","cancel":"Cancel"},"floatingToolbar":{"addComment":"Add Comment","sendToAI":"Send to AI","search":"Search"},"quickReply":{"optionA":"A","optionB":"B","optionC":"C","optionD":"D","allRecommended":"Rest recommended","thisOne":"This one","notThis":"Not this","why":"Why?","elaborate":"Say more","example":"Give an example","start":"Do it","continue":"Continue","ok":"OK","done":"Done","edit":"Edit quick replies","editTitle":"Edit quick replies","editHint":"One line per row; separate phrases with commas. Each phrase is sent to the chat exactly as written.","editPlaceholder":"This one, Not this\\nWhy?, Say more","restoreDefault":"Restore defaults","save":"Save","cancel":"Cancel","customizedFor":"Customizing the {{lang}} phrases — the other language is unaffected.","langEn":"English","langZh":"Chinese","saveFailed":"Failed to save quick replies"},"searchResults":{"title":"Search Results","nMatches":"({{count}} matches)","searching":"Searching...","noResults":"No matches","scopeSelected":"Selected","scopeAll":"All"},"references":{"title":"References","searching":"Searching...","notFound":"No references found"},"gitFileTree":{"noFiles":"No files"},"deps":{"action":"Dependencies","none":"none","symbolMessage":"Analyse the dependencies of {{name}} ({{path}}:{{lines}}).\\n\\nCallers: {{callers}}\\nCalls: {{callees}}\\nExternal: {{externals}}\\n\\nExplain which modules it is coupled to, and which of those dependencies could be narrowed."},"explain":{"action":"Explain","fileMessage":"Explain {{path}}","symbolMessage":"Explain {{name}} ({{path}}:{{lines}})","selectionMessage":"Explain","commitFileMessage":"Explain what git commit {{hash}} changed in {{path}}","compareFileMessage":"Explain the git changes to {{path}} in {{base}}...HEAD","compareFileWorktreeMessage":"Explain the changes to {{path}} relative to {{base}}, including uncommitted work","stagedFileMessage":"Explain the git staged changes to {{path}}","unstagedFileMessage":"Explain the git working tree changes to {{path}}"},"bots":{"sessionBadge":"Session","sessionGroup":"Session Bots","sessionGroupHint":"Sessions ticked \\"Can be @-mentioned\\" in their title dialog; @-mentioning one sends the task into that session","sessionGone":"The session no longer exists","sessionNameInvalid":"Its title cannot be a name (multi-line or contains @); rename it to @-mention it","sessionUsage":"Write \\"@{{name}} <task>\\" in any session to send the task into this one","removeSession":"Remove from Bots","title":"Bots","search":"Search bots","addExisting":"Add bot","addTooltip":"Add as Bot","emptyNoMatch":"No bots match your search.","emptyNoBots":"No bots of your own yet.","emptyCreatePrefix":"Use","emptyCreateSuffix":"in chat to create one.","emptyAddExisting":"add an existing Bot directory","invalid":"Invalid","builtin":"Built-in","mine":"Mine","tabFiles":"Files","tabSessions":"Sessions","noSessions":"No recent sessions for this Bot","sessionsScope":"Every session run in its folder, plus sessions it recently dispatched elsewhere","selectHint":"Select a Bot on the left to see its files and sessions","remove":"Remove registration","open":"Open as project","pathPlaceholder":"Absolute path to a Bot directory or its BOT.md","addHint":"The directory must contain a BOT.md. Its files are not changed.","added":"Bot added","alreadyAdded":"Already added","removed":"Bot removed; its files were kept.","loadFailed":"Failed to load bots","saveFailed":"Failed to add bot","removeFailed":"Failed to remove bot"},"contextInspector":{"title":"Session context","open":"View context contents","used":"Used","window":"Window","free":"Free","unknownWindow":"Window size unknown","capturedAt":"Recorded {{time}}","refresh":"Refresh","loadFailed":"Failed to read context","noSession":"The session has not started yet; there is no context","empty":"No context items to show","selectItem":"Select an item on the left to see its content","noContent":"The engine does not expose the text of this item, only its name and token count","truncated":"Content is long; showing the first {{count}} characters","estimated":"≈ marks character-based estimates","items":"{{count}} items","copy":"Copy","copied":"Copied","groups":{"prompt":"Prompt","memory":"Memory files","tools":"Tools","skills":"Skills & agents","messages":"Messages","tool_io":"Tool calls","reasoning":"Reasoning","other":"Other"},"categories":{"system":"System prompt","instructions":"Extra instructions","memory":"Memory files","tools":"Tool definitions","mcp":"MCP tools","skills":"Skills","agents":"Custom agents","environment":"Environment","messages":"Messages","tool_io":"Tool calls & results","reasoning":"Reasoning","summary":"Compaction summary","other":"Other"},"notes":{"system_prompt_hidden":"The engine assembles its system prompt internally and does not expose the text; only section names and token counts are listed.","tool_schemas_hidden":"Built-in tools expose names and token counts only, not their schemas.","skills_listing_only":"Skills occupy only their name and description in context; the full body loads when a skill is used.","snapshot_from_last_turn":"The breakdown was recorded at the end of the last turn, not live.","no_snapshot_yet":"No breakdown has been recorded for this session yet; exact numbers appear after the next turn. Showing estimates from the transcript.","reasoning_encrypted":"Some reasoning or compaction content is encrypted: its text cannot be shown and its size cannot be estimated.","after_compaction":"The session has been compacted; only content after the latest compaction is included.","estimated_breakdown":"Per-category token counts are estimates; the total at the top is the engine\'s own number.","usage_unknown":"The engine reported no context size for this session."}}}'),o=JSON.parse('{"common":{"openAsProject":"作为项目打开","save":"保存","cancel":"取消","delete":"删除","close":"关闭","minimize":"最小化","copy":"复制","edit":"编辑","file":"文件","codeMap":"代码地图","diff":"Diff","confirm":"确认","loading":"加载中...","search":"搜索","refresh":"刷新","retry":"重试","submit":"提交","copied":"已复制","saved":"已保存","failed":"失败","noMatch":"无匹配","noData":"无数据","done":"完成","justNow":"刚刚","minutesAgo":"{{count}}分钟前","hoursAgo":"{{count}}小时前","daysAgo":"{{count}}天前","monthsAgo":"{{count}}个月前","yearsAgo":"{{count}}年前","saveFailed":"保存失败","copyFailed":"复制失败","deleteFailed":"删除失败","operationFailed":"操作失败","copiedPath":"已复制路径","copyPath":"复制路径","openInConsole":"在 Console 气泡打开","copyAbsPath":"复制绝对路径","loadMore":"加载更多","noResult":"无匹配结果","selected":"已选择","selectAll":"全选","hint":"提示","confirmBtn":"确定","cancelBtn":"取消","preview":"预览","readable":"可读","previous":"上一个","next":"下一个","all":"全部","input":"输入","result":"结果","line":"行","lines":"行","running":"运行中","connecting":"连接中","connected":"已连接","connectionFailed":"连接失败","builtin":"内置","global":"全局","project":"项目","current":"当前","code":"代码"},"htmlApps":{"tabFiles":"文件","tabRun":"运行","mine":"我的","selectHint":"选择左侧应用,查看它的文件和源码;点「运行」才会运行它(应用拥有完整的命令行权限)。","openFull":"全屏打开(可最小化到侧边栏)","title":"HTML 应用","addTooltip":"添加到 HTML 面板","added":"已添加到 HTML 面板","alreadyAdded":"已添加过","addFailed":"添加失败","add":"添加","adding":"添加中...","addHtmlApp":"添加 HTML 应用","searchPlaceholder":"搜索 HTML 应用...","pathLabel":".html 文件的绝对路径","invalid":"无效","builtin":"内置","noDescription":"无描述","emptyNoApps":"还没有自定义 HTML 应用。","emptyCreatePrefix":"在聊天里使用","emptyCreateSuffix":"创建新应用。","addExisting":"添加已有 HTML 文件","viewDocs":"查看文档","emptyNoMatch":"没有匹配的 HTML 应用。"},"skills":{"addTooltip":"添加到 Skills 面板","added":"已添加到 Skills 面板","alreadyAdded":"已添加过","addFailed":"添加失败","title":"Skills","searchPlaceholder":"搜索 skills...","clearSearch":"清除","addSkill":"添加 Skill","emptyNoSkills":"还没有 skill。","emptyIntroPrefix":"在聊天里使用","emptyIntroSuffix":"把可复用经验整理成 SKILL.md。","emptyNoMatch":"没有匹配的 skill。","viewDocs":"查看文档","pathLabel":"SKILL.md 的绝对路径","pathPlaceholder":"/Users/you/.../skills/foo/SKILL.md","add":"添加","adding":"添加中...","invalid":"无效","builtinGroup":"内置","builtinReadOnly":"内置技能,只读","selectHint":"选择左侧技能,查看它的 SKILL.md","fileTooLarge":"文件超过 1 MB,不预览","fileNotPreviewable":"该文件无法预览(二进制)","copyPath":"复制路径","noDescription":"无描述","previewTitle":"Skill 预览","source":"源码","cannotRead":"无法读取文件。"},"toast":{"savedSuccess":"已保存","saveFailed":"保存失败","copiedName":"已复制: {{name}}","copyFailed":"复制失败","deleteFailed":"删除失败","operationFailed":"操作失败","staged":"已暂存","stageFailed":"暂存失败","unstaged":"已取消暂存","unstageFailed":"取消暂存失败","stagedNFiles":"已暂存 {{count}} 个文件","unstagedNFiles":"已取消暂存 {{count}} 个文件","discardFailed":"放弃变更失败","discardedNFiles":"已放弃 {{count}} 个文件的变更","deletedFile":"已删除文件","discardedChanges":"已放弃变更","pastedFile":"已粘贴: {{name}}","pasteFailed":"粘贴失败","noFileToPaste":"没有可粘贴的文件","createdFile":"已创建文件: {{name}}","createFailed":"创建失败","movedToTrash":"已移动到回收站: {{name}}","copiedPageUrl":"已复制页面地址","copiedDirPath":"已复制目录路径","switchedToBranch":"已切换到 {{branch}}","switchBranchFailed":"切换分支失败","loadBranchFailed":"加载分支列表失败","copiedCommand":"已复制: {{command}}","copiedMessage":"已复制消息","sentToPeer":"已发送到另一栏","sendToPeerFailed":"发送到另一栏失败","forkFailed":"分叉会话失败","excerptFailed":"摘录本轮失败","turnDeleted":"已删除本轮","deleteTurnFailed":"删除本轮失败","copiedUrl":"已复制网址","copiedOutput":"已复制输出","copiedCmd":"已复制命令","copiedComment":"已复制评论","copiedAllComments":"已复制全部评论","copiedFileContent":"已复制文件内容","copiedQA":"已复制 {{count}} 个问答","copiedAllQA":"已复制所有问答","sentQA":"已发送给 AI","readFileFailed":"读取文件失败","fileOutsideProject":"此处无法打开文件预览","reviewCreated":"评审已创建,链接已复制","reviewUpdated":"评审已更新,链接已复制","reviewCreateFailed":"创建评审失败","sharingClosed":"已关闭分享","sharingCloseFailed":"关闭分享失败","linkCopied":"链接已复制","addCommentFailed":"添加评论失败","deleteCommentFailed":"删除评论失败","editCommentFailed":"编辑评论失败","addReplyFailed":"添加回复失败","deleteReplyFailed":"删除回复失败","editReplyFailed":"编辑回复失败","disconnected":"已断开: {{id}}","pluginReloading":"插件重载中...","worktreeCreateSuccess":"Worktree 创建成功: {{name}}","worktreeCreateFailed":"创建 worktree 失败","worktreeLoadFailed":"加载 worktree 列表失败","worktreeDeleted":"Worktree 已删除","worktreeDeleteFailed":"删除 worktree 失败","worktreeLocked":"已锁定","worktreeUnlocked":"已解锁"},"workspace":{"selectProject":"选择一个项目开始","searchProjectPath":"搜索项目路径...","loadingProjects":"加载项目中...","projectNotFound":"未找到项目","sessions":"{{count}} 会话","loadingSessions":"加载会话...","noSessions":"无会话记录","loadingText":"加载中...","openProject":"打开项目","expandSidebar":"展开侧边栏","collapseSidebar":"折叠侧边栏","notes":"笔记","skills":"技能","apps":"应用","settings":"设置","help":"帮助","updateAvailable":"新版本 v{{version}} 可用","copyUpgradeCommand":"复制 cockpit update","updateNow":"立即更新","updating":"正在更新…","updateComplete":"更新完成","updateFailed":"更新失败","updateCardPreparing":"正在准备更新…","updateCardInstalling":"正在下载并安装","updateCardRepairing":"正在修复原生依赖","updateCardUpToDate":"已是最新版本 v{{version}}","updateCardCopyFix":"复制修复命令","updateCardFixCopied":"已复制修复命令","updateCardRollingBack":"安装失败,正在回滚","updateCardRestarting":"正在重启 Cockpit…","updateCardDone":"已更新到 v{{version}}","updateCardElapsed":"已用 {{seconds}} 秒","updateCardBaseline":"上次约 {{seconds}} 秒","updateCardNoLiveStatus":"暂时读不到实时状态,更新仍在进行","updateCardRolledBack":"已回滚到原版本,Cockpit 可正常使用。","updateCardManualHint":"可在终端手动重试:","updateCardLogHint":"日志:{{path}}","updateRestartNote":"Cockpit 将在后台重启。","viewChangelog":"查看变更日志","serverRestarted":"Cockpit 已在后台更新。","serverReloadAfterRestart":"Cockpit 已重启,请重新加载页面。","reloadNow":"刷新","upgradeCommandCopied":"已复制 `cockpit update`","projectNotes":"项目笔记","closeProject":"关闭项目","unsentDraft":"有未发送的输入","bots":"机器人"},"mobile":{"useDesktop":"桌面版","messagePlaceholder":"发消息…","send":"发送","stop":"停止","enableNotifications":"开启通知","disableNotifications":"关闭通知","notifyError":"无法开启通知","useMobile":"手机版","newChat":"新会话","voiceInput":"语音输入","voiceStop":"停止语音输入","voiceListening":"正在听…","voiceDenied":"麦克风权限被拒绝,请在浏览器设置里允许","voiceFailed":"语音输入失败:{{reason}}","voiceUnsupported":"此浏览器无法语音识别,请用键盘上的麦克风听写","quickInstructionsHint":"点一下填入输入框"},"sessions":{"recentSessions":"最近会话","favorites":"收藏会话","titleSingleLine":"标题只能有一行,不能包含换行或 \\\\n","titleNoAt":"标题不能包含 @","titleNotMentionable":"当前标题不能用来 @:{{reason}}。请改个名字","mentionable":"可被 @ 调用","mentionableHint":"勾选后加入 Bots 列表,可在任意会话里用「@标题 任务」把任务派给它","suggestTitle":"让 AI 起个标题","titleSuggestFailed":"生成标题失败:{{reason}}","noFavorites":"暂无收藏会话,在 Tab 栏点击星标可添加","addFavorite":"收藏此会话","removeFavorite":"取消收藏","selectFavoriteHint":"选择左侧收藏,查看它的会话消息","noSessionMessages":"该会话暂无消息,或记录已不存在","selectSessionHint":"选择左侧会话,查看它的消息","dateToday":"今天","dateYesterday":"昨天","dateLast7Days":"最近 7 天","dateEarlier":"更早","runningCount":"{{count}} 运行中","unreadCount":"{{count}} 未读","noSessions":"暂无会话记录","running":"运行中","done":"完成","dragToReorder":"拖动以调整本项目内的顺序","restoreTitle":"恢复默认标题","titleEmpty":"标题不能为空。","titleLoadFailed":"无法读取标题,请关闭后重试。","titleSaveFailed":"保存标题失败,请重试。","editTitle":"编辑标题","projectSessions":"项目会话","browseAllSessions":"浏览所有会话","sessionList":"会话列表","search":"搜索","searchSessions":"搜索会话...","searchRecentSessions":"搜索最近会话","loadSessionsFailed":"加载会话失败","loadingSessions":"加载会话中...","noMatchingSessions":"未找到匹配的会话","noSessionsYet":"暂无会话","projectList":"项目列表","openFolder":"打开文件夹","loadingHistory":"加载历史消息...","sessionsTab":"会话","pullRequestsTab":"PR","searchPullRequests":"搜索 编号 / 链接 / 标题","allRepos":"全部仓库","allEngines":"全部引擎","noPullRequests":"最近会话里还没有开过 PR","noPullRequestsHint":"会话里运行 gh pr create 后,会自动出现在这里","noMatchingPullRequests":"未找到匹配的 PR","selectPullRequestHint":"选择左侧 PR,查看它的会话","pullRequestSessions":"共 {{count}} 个会话","openPullRequest":"打开 PR","copyResumeCommand":"复制 resume","resumeCommandCopied":"已复制:{{command}}","copyFailed":"复制失败"},"scheduledTasks":{"title":"定时任务","aboutToTrigger":"即将触发","secondsLater":"{{count}}秒后","minutesLater":"{{count}}分钟后","hoursMinutesLater":"{{h}}小时{{m}}分后","hoursLater":"{{h}}小时后","onceType":"一次性({{duration}}后)","everyDuration":"每{{duration}}","completed":"已完成","paused":"已暂停","activeCount":"{{running}} 个活跃","pausedCount":"{{paused}} 个暂停","noScheduledTasks":"暂无定时任务,在聊天输入栏点击时钟按钮创建","lastResult":"上次","runNow":"立即运行","deleteFailed":"删除任务失败","resume":"恢复","pause":"暂停","completedCount":"已完成 ({{count}})","pendingCount":"{{count}} 个待查看","openSession":"打开会话","selectTaskHint":"选择左侧任务,查看它的会话消息","noTaskMessages":"该任务的会话暂无消息","success":"成功","failure":"失败","inFlight":"正在运行","interrupted":"已中断","createTask":"创建定时任务","editTask":"编辑定时任务","sendMessage":"发送消息","messagePlaceholder":"输入要发送的消息...","taskFile":"任务文件","taskFilePlaceholder":"/Users/you/project/tasks/daily-report.md","taskFileHint":"填写绝对路径。触发时会让 agent 先读取该文件,再按其中描述执行——文件内容改动下次触发即生效。","taskFilePromptHeader":"请先读取以下任务文件,再据此执行:","type":"类型","once":"一次性","interval":"周期","quickSelect":"快捷选择","customCron":"自定义 Cron 表达式","customDuration":"自定义时长","cronPlaceholder":"例: 0 9 * * 1-5 (工作日9点)","cronFormat":"格式:分 时 日 月 星期(如 0 9 * * 1-5)","amountPlaceholder":"数值","limitTimeRange":"限制执行时段","startAt":"起始时间(可选)","startAtHint":"留空则从现在开始;设置后固定在「起始时间 + N \xd7 间隔」执行,不随运行时长漂移","clear":"清除","fromTime":"自 {{time}} 起","to":"至","saveBtn":"保存 ({{modKey}}↩)","createBtn":"创建 ({{modKey}}↩)","5minLater":"5 分钟后","15minLater":"15 分钟后","30minLater":"30 分钟后","1hourLater":"1 小时后","3hoursLater":"3 小时后","6hoursLater":"6 小时后","1dayLater":"1 天后","3daysLater":"3 天后","every15min":"每 15 分钟","every30min":"每 30 分钟","every1hour":"每 1 小时","every2hours":"每 2 小时","every6hours":"每 6 小时","every12hours":"每 12 小时","everyDay":"每 1 天","daily9am":"每天 09:00","daily6pm":"每天 18:00","weeklyMon9am":"每周一 09:00","monthly1st9am":"每月 1 号 09:00","unit":{"minute":"分钟","hour":"小时","day":"天"},"duration":{"minute":"{{count}}分钟","hour":"{{count}}小时","day":"{{count}}天"}},"runningTerminals":{"title":"终端","status":"{{count}} 个终端 \xb7 {{projects}} 个项目","keys":"↑↓ 选择 \xb7 Enter / 双击 打开 \xb7 Del 停止 \xb7 Esc 关闭","empty":"没有正在运行的终端","currentProject":"当前项目","stop":"停止","confirmStop":"停止这个进程?","stopping":"停止中…","stopFailed":"停止终端失败","openTerminal":"打开终端","typeHint":"点击终端即可输入","modePty":"PTY \xb7 交互式终端","modePipe":"管道 \xb7 仅输出","ended":"已结束","selectHint":"选择左侧终端,查看它的输出","notFound":"没找到这个终端的气泡"},"cron":{"everyNMinutes":"每 {{n}} 分钟","everyNHours":"每 {{n}} 小时整点","everyMinute":"每分钟","everyHourAtMin":"每小时第 {{m}} 分","hourlyEveryMin":"{{h}} 点每分钟","daily":"每天 {{time}}","weekdays":"工作日","weekends":"周末","dowSun":"日","dowMon":"一","dowTue":"二","dowWed":"三","dowThu":"四","dowFri":"五","dowSat":"六","monthPrefix":"月","dayOfMonth":"号","dayRange":"{{a}}号到{{b}}号","weekdayPrefix":"周","weekdayRange":"周{{a}}到周{{b}}"},"blockViewer":{"empty":{"body":"在左侧文件树选择一个文件,查看它的代码地图。","hint":"或按 ⌘K 搜索。"},"fileMode":{"loading":"加载中…","notFound":"该文件未索引(不支持的语言或超出文件上限)。"},"buildProgress":{"listing":"正在扫描文件…","contexts":"正在读取项目配置…","parsing":"正在解析文件","resolving":"正在解析引用关系…","edges":"正在构建调用图…","done":"即将完成…"},"search":{"tooltip":"搜索 (⌘K)","hint":"开始输入以搜索","noResults":"未找到匹配","files":"文件","symbols":"符号"},"viewerToggle":{"toBlock":"显示代码地图","toCode":"返回代码视图"},"tabs":{"toc":"函数列表","history":"跳转记录"},"toc":{"title":"本文件","empty":"未检测到函数。","notIndexed":"该文件未被项目图收录(扩展未支持 / 不在 git 跟踪集 / 超出文件上限)。"},"history":{"title":"最近","empty":"点击左右两侧的 pin 开始追踪调用链。","clear":"清空历史"},"refresh":"重新构建项目图","relationsStale":"项目关联关系需要刷新","retry":"重试"},"blockDiffViewer":{"loading":"正在生成代码地图…","unsupported":"该文件类型暂不支持代码地图 diff","unsupportedHint":"切回常规 diff 视图查看。","error":"代码地图 diff 失败:{{message}}","noBlockChanges":"代码地图无变化(仅格式或空白)。","noBefore":"(新增)","noAfter":"(已删除)","kind":{"added":"新增","deleted":"删除","modified":"修改"}},"fileBrowser":{"directoryTree":"目录树","searchTab":"搜索","recentTab":"最近","changesTab":"变更","historyTab":"历史","searchFiles":"搜索文件...","clear":"清除","exactMatchOn":"全词匹配(已开启)","exactMatchOff":"全词匹配(已关闭)","refreshTree":"刷新目录树","collapseAll":"折叠所有目录","searchFileContent":"搜索文件内容...","caseSensitive":"区分大小写","wholeWord":"完整词","regex":"正则","fileTypes":"文件类型 (ts,tsx)","compareMode":"对比","compareModeOff":"关闭分支对比","compareModeOn":"与选定分支对比","compareScopeHead":"HEAD","compareScopeWorktree":"工作区","compareScopeHeadHint":"仅对比已提交的改动","compareScopeWorktreeHint":"对比包含未提交的改动(已暂存 / 未暂存 / 未跟踪)","createFile":"新建文件","createFileIn":"新建文件 (在 {{path}}/)","fileName":"文件名...","noRecentFiles":"暂无最近浏览的文件","stagingArea":"暂存区 ({{count}})","changesSummary_one":"{{count}} 个变更","changesSummary_other":"{{count}} 个变更","noChanges":"工作区无变更","refreshChanges":"刷新变更列表","unstageAll":"全部取消","noStagedFiles":"无暂存的文件","unstageNFiles":"取消暂存 {{count}} 个文件","unstageFile":"取消暂存","workspace":"工作区 ({{count}})","discardAll":"放弃所有","stageAll":"全部暂存","noUnstagedChanges":"无未暂存的变更","discardNFiles":"放弃 {{count}} 个文件的变更","stageNFiles":"暂存 {{count}} 个文件","discardChanges":"放弃变更","stageFile":"暂存文件","loadingDiff":"加载对比文件中...","noDiffFiles":"无差异文件","nFilesChangedPlain":"{{count}} 个文件变更","nFilesChanged":"{{count}} 个文件变更(vs {{branch}})","nFilesChangedWorktree":"{{count}} 个文件变更(vs {{branch}},含未提交)","noDiffFilesHeadHint":"本分支尚无已提交的改动,切到「工作区」可看到未提交的部分","loadingCommits":"加载提交记录中...","noCommits":"无提交记录","allLoaded":"已加载全部 {{count}} 条记录","locateInTree":"在目录树中定位","unsaved":"未保存","saveBeforeSwitch":"当前文件有未保存的修改,是否保存后切换?","saveAndSwitch":"保存并切换","closeEdit":"关闭编辑 (ESC)","closeBtn":"关闭","copyFileContent":"复制文件内容","toggleJsonReadable":"切换 JSON 可读模式","previewMarkdown":"预览 Markdown 渲染效果","exitPreview":"退出预览","collapseAllJson":"折叠","expandAllJson":"展开","viewBlame":"查看每行代码的修改记录","viewDiff":"查看相对 HEAD 的改动","exitDiff":"退出 Diff","diffLoadFailed":"加载差异失败","editFile":"编辑文件","backToPreview":"返回预览","cannotPreview":"无法预览此文件","selectFileToPreview":"选择文件以预览","staged":"已暂存","unstaged":"未暂存","selectFileToViewDiff":"选择文件查看差异","loadingDiffContent":"加载差异中...","clickCompareToLoad":"点击「对比」加载分支差异","selectCommitToView":"选择提交查看详情","confirmDelete":"确认删除","confirmDeleteMessage":"确定要将 <file>{{name}}</file> 移动到回收站吗?","nFilesNMatches":"{{files}} 个文件,{{matches}} 处匹配","resultsTruncated":"结果已截断","noContentSearchResults":"无匹配结果","enterKeywordToSearch":"输入关键词搜索文件内容","searchMinChars":"搜索内容至少需要 2 个字符"},"csv":{"table":"表格","raw":"原始内容","empty":"空表格","summary":"{{rows}} 行 \xb7 {{cols}} 列","summaryFiltered":"匹配 {{rows}} / {{total}} 行 \xb7 {{cols}} 列","loadMore":"加载更多(已显示 {{shown}} / {{total}})","filterPlaceholder":"筛选内容…","filterColumn":"筛选列","clearFilter":"清除筛选","allColumns":"全部列","noMatch":"没有匹配的行","sortHint":"点击排序(升序 / 降序 / 取消)"},"codeViewer":{"fileModifiedExternally":"文件已被外部修改,保存将覆盖外部更改","useDiskVersion":"使用磁盘版本","forceOverwrite":"强制覆盖","searchPlaceholder":"搜索...","caseSensitive":"区分大小写","wholeWordMatch":"全字匹配","unsavedConfirm":"有未保存的修改,确定关闭?","discardChanges":"放弃修改","continueEditing":"继续编辑","unsavedExitConfirm":"有未保存的修改,确定退出编辑模式?","clickToViewDetails":"点击查看详情","clickToViewCommit":"点击查看 commit 详情","nComments":"{{count}} 条评论","searchChat":"搜索聊天内容...","prevShiftEnter":"上一个 (Shift+Enter)","nextEnter":"下一个 (Enter)","closeEsc":"关闭 (Esc)"},"chat":{"commandRefs":"附带 {{count}} 个引用","commandRef_read":"读取","commandRef_handoff":"转交","commandRef_handoffMixed":"转交","commandRef_targets":"目标","commandRef_inline":"内嵌","originSent":"来自 {{project}} 的 @ 消息","originDelegated":"由 {{project}} 委派","originUnknown":"另一个会话","decisionContextAttached":"附带了 {{count}} 条相关决策","codexInput":{"queued":"追加消息等待发送","accepted":"Codex 已接受追加消息","failed":"追加消息发送失败或未确认,请打开详情查看","images":"图片:{{count}} 张"},"recoveryCopy":"失败运行的恢复副本","recoveryCopyHint":"这是运行期间观察到的内容的临时副本,可能与已保存的历史重复,不会发送给模型。仅在本对话保持打开期间保留。","recoveryCopiesLabel":"失败运行的恢复副本","recoveryAttachment":"恢复副本附件","startConversation":"开始对话吧","loadMoreHistory":"加载更多...","scrollUpForMore":"↑ 向上滚动加载更多历史","jumpToStart":"跳转到开始","jumpToLatest":"跳转到最新","jumpToPrevUserMessage":"上一条用户消息","jumpToNextUserMessage":"下一条用户消息","recentUserMessages":"最近的用户消息","moreUserMessages":"更多","userMessage":"用户消息","recentUserMessageNumber":"最近用户消息 {{index}}/{{total}}","imageMessage":"图片消息","copyMessage":"复制消息","copyImage":"复制图片","copiedImage":"已复制图片","forkSession":"从此处分叉会话","excerptTurn":"摘录本轮到新会话","newSession":"新建会话","continueFromHere":"延续到此处","continueFromHereDesc":"保留截至本轮的全部上下文","onlyThisTurn":"仅提取本轮","onlyThisTurnDesc":"只带这一轮问答","onlyThisTaskDesc":"保留整个任务,包含全部 {{count}} 条输入及回答","deleteTurn":"删除本轮","deletingTurn":"正在删除…","deleteTurnConfirm":"确定删除这一轮的问题、回答及工具记录吗?此操作无法撤销。","deleteTaskConfirm":"本任务包含 {{count}} 条用户输入(含追加输入)。确定删除整个任务的全部输入、回答及工具记录吗?此操作无法撤销。","deleteTurnConfirmAction":"删除本轮","deleteTurnWhileRunning":"会话运行期间不能删除","sendToPeerPane":"发送本条消息到另一栏","imageN":"图片 {{index}}","imagePreview":"图片预览","imageLoadFailed":"无法加载此图片","toolCalls":"{{count}} 个工具调用","collapse":"▲ 收起","expand":"▼ 展开","showMore":"显示更多","showLess":"收起","subagent":"子代理","piChildStatus":{"interrupted":"中断快照","truncated":"已截断","running":"运行中","done":"已完成","failed":"失败","cancelled":"已取消"},"subagentEmpty":"未找到子代理消息记录","subagentViewTitle":"查看子代理执行过程","workflowRun":"运行详情","workflowViewTitle":"查看工作流运行详情","workflowEmpty":"未找到工作流运行记录","workflowAgents":"个代理","workflowViewAgent":"查看","workflowUngrouped":"未分组","viewQuestions":"查看提问","viewAllFileChanges":"查看所有文件变更","requestFailed":"请求失败","cannotReadStream":"无法读取响应流","errorRetry":"发生错误,请重试","codexResumeFailed":"原会话被其他 Codex 客户端占用,已新建会话,历史未继承","codexResumeFailedPrevious":"原会话","codexResumeFailedNew":"新会话","codexContextCompacting":"Codex 正在压缩上下文…","placeholder":"输入消息,/ 调用 skill,@ 调用机器人","placeholderDisabled":"生成中... 可继续输入 (ESC 取消;卡住太久可取消后重发「继续」)","placeholderRunning":"生成中... 回车即发送,会在当前回复的下一步插入(ESC 停止)","imageSizeLimit":"图片大小超过限制(最大 5MB),当前大小: {{size}}MB","viewGitChanges":"查看 Git 变更","viewAllComments":"查看所有评论","userMessages":"用户消息列表","projectNotes":"项目笔记","scheduledTasks":"定时任务","quickInstructions":"快捷指令","globalInstructions":"全局指令","projectInstructions":"项目指令","noQuickInstructions":"暂无快捷指令","addQuickInstruction":"新增快捷指令","quickInstructionPlaceholder":"输入一句话指令,Enter 保存,Esc 取消","insertQuickInstruction":"填入输入框(不发送)","addInstructionGroup":"新增分组","instructionGroupNamePlaceholder":"输入分组名,Enter 保存,Esc 取消","instructionGroupLabel":"所属分组","instructionGroupNone":"不分组","deleteInstructionGroupConfirm":"删除分组「{{name}}」会同时删除组内 {{count}} 条指令,确定继续?","editGlobalInstructions":"编辑全局指令","editProjectInstructions":"编辑项目指令","quickInstructionsMarkdownHint":"一级内容每行一条;分组名称后的「- 」开头行是该分组的子命令;单条指令内的换行用 \\\\n 表示。","quickInstructionsMarkdownPlaceholder":"按推荐实施\\n用文本画图\\n- 画一个登录流程\\n- 画一个系统架构","quickInstructionsMarkdownError":"第 {{line}} 行格式不正确。","savingQuickInstructions":"保存中...","saveQuickInstructionsFailed":"保存失败,修改仍然保留,请重试。","context":"上下文","output":"输出","copiedCommandTooltip":"已复制!","copyCommandTooltip":"复制命令: {{command}}","executedCommand":"执行了 `{{command}}`{{exitInfo}},输出:\\n```\\n{{output}}\\n```","executedCommandFailed":"执行 `{{command}}` 失败:{{error}}","executionMode":"执行模式","checkBalance":"查询余额","balanceFailed":"查询失败,请检查 API Key","balanceNeedsKey":"请先配置 DeepSeek API Key","balanceUnavailable":"账户当前不可用","balanceEmpty":"接口未返回余额","openUsagePage":"打开 DeepSeek 用量控制台","checkQuota":"查询额度","quotaFailed":"额度查询失败,请检查 API Key","quotaNeedsKey":"请先设置 API Key","quotaEmpty":"未返回额度信息","quotaResetAt":"{{time}} 重置","openProviderConsole":"打开服务商控制台","planMode":"计划模式","planModeDesc":"只读,先出计划不改代码","planModeOn":"已开启计划模式——只读;发一个任务即可拿到计划","planModeOff":"已关闭计划模式","planModeHint":"计划模式:只读探索、产出计划但不改文件。取消勾选后重发才会实现。","noHistory":"不带历史上下文","noHistoryDesc":"每次提问均独立","noHistoryHint":"不带历史上下文:每条消息单独发给模型,不带之前的对话。上方的会话记录照常保留。","planTitle":"计划(待你确认)","approvePlan":"批准并执行","planApproveHint":"本环境无审批弹窗,点此退出计划模式并执行","approvePlanPrompt":"已批准,按上述计划开始执行。","maximizePane":"放大本栏","restorePane":"还原双栏","closePane":"关闭本栏","singlePane":"切回单栏","splitPane":"并排双栏"},"console":{"enterCommandOrUrl":"输入命令或网址开始使用","emptyIntro":"在下方输入框输入以下内容,即可创建对应气泡:","bubbleCommand":"命令","bubbleInteractive":"交互终端","bubbleBrowser":"浏览器","bubbleBrowserNoteIframe":"部分网站会拦截 iframe 嵌入,请在「设置 → 浏览器插件」安装 Cockpit Bridge 后再打开。","bubbleBrowserNoteCookie":"已登录的网站若首次显示未登录,多刷新几次即可恢复。","bubbleDatabase":"数据库","bubbleFilePreview":"文件预览","loadingMore":"加载中...","loadMoreHistory":"加载更多历史","quickCommands":"快捷命令","singleColumn":"单列布局","dualColumn":"双列布局","envVars":"环境变量","launchShell":"启动交互终端","htmlApps":"HTML 应用","inputPlaceholder":"输入命令或网址并按 Enter... (↑↓ 历史, Tab 补全)","scopeProject":"项目","scopeGlobal":"全局","tabSwitchEscClose":"Tab 切换 \xb7 Esc 关闭","copyOutput":"复制输出","copyCommand":"复制命令","rerun":"重新运行","deleteRecord":"删除记录","searchPlaceholder":"搜索...","searchMode":"搜索","filterMode":"过滤","prevShiftEnter":"上一个 (Shift+Enter)","nextEnter":"下一个 (Enter)","loadingTerminal":"加载终端...","clickToInput":"点击终端区域输入","stdinPlaceholder":"stdin 输入...","runningText":"运行中...","exitCode":"退出代码: {{code}}","totalLines":"共 {{count}} 行","globalCommands":"全局命令","projectCommands":"项目命令","noCustomCommands":"暂无自定义命令","editGlobalCommands":"编辑全局命令","editProjectCommands":"编辑项目命令","quickCommandsTextHint":"每行一条,格式为「名称: 命令」;名称只能包含字母、数字、- 和 _,第一个冒号之后都是命令。","quickCommandsTextPlaceholder":"pg: psql -h localhost -U postgres\\ngitpull: git pull --rebase","quickCommandsTextError":"第 {{line}} 行格式不正确,应为「名称: 命令」。","savingQuickCommands":"保存中...","saveQuickCommandsFailed":"保存失败,修改仍然保留,请重试。","restoreTooltip":"还原 ({{modKey}}M / ESC)","screenshotting":"截图中...","outputFileDeleted":"[输出文件已删除]"},"browser":{"blankPage":"空白页","copyUrl":"复制网址","openInNewWindow":"在新窗口打开","exitMaximize":"退出最大化 ({{modKey}}M)","maximize":"最大化 ({{modKey}}M)","pageLoadFailed":"页面加载失败","openInTabFallback":"OpenCockpit Bridge 未连接,已改用普通新标签页打开","movedToChrome":"网页现在在 Chrome 标签页中打开,不再放在 Console 里。","openInChrome":"在 Chrome 中打开","openedInChrome":"已在 Chrome 中打开 —— {{command}}","clickToWake":"点击唤醒","sleeping":"已休眠","loadingPage":"加载中...","loadFailed":"加载失败"},"database":{"connectionFailed":"连接失败","connected":"已连接","connecting":"连接中...","refreshTableList":"刷新表列表","filterTable":"T 表","filterView":"V 视图","noTables":"无表","tabStructure":"结构","tabData":"数据","tabSql":"SQL","filterActive":"筛选: {{count}}列","clearAllFilters":"清除所有筛选","deleteNRows":"删除 {{count}} 行","confirmDeleteRows":"确认删除?","copyCsvSelected":"复制选中行为 CSV","copyCsvAll":"导出全表 CSV","copyJsonSelected":"复制选中行为 JSON","copyJsonAll":"导出全表 JSON","copyCSV":"复制 CSV","CSV":"CSV","copyJSON":"复制 JSON","JSON":"JSON","selectTable":"选择左侧表格","selectTableToView":"选择表以查看结构","selectTableForData":"选择表以查看数据","columns":"列","colName":"名称","colType":"类型","colNullable":"可空","colDefault":"默认值","primaryKey":"主键","foreignKeys":"外键","indexes":"索引","enable":"启用","commaValues":"逗号分隔多值","likePattern":"%pattern%","valuePlaceholder":"值","apply":"应用","clearFilter":"清除","addRow":"+ 新增行","totalRows":"{{count}} 行","rowsAffected":"{{command}} — {{count}} 行受影响 ({{duration}}ms)","queryRows":"{{count}} 行 ({{duration}}ms)","resultTruncated":"[结果已截断至1000行]","sqlPlaceholder":"输入 SQL... ({{modKey}}Enter 执行)","executing":"执行中...","execute":"▶ 执行","deleteRowsFailed":"{{count}} 行删除失败","inputParams":"输入参数","resultLabel":"结果"},"mysql":{"connectionFailed":"连接失败","connected":"已连接","connecting":"连接中...","refreshTableList":"刷新表列表","filterTable":"T 表","filterView":"V 视图","noTables":"无表","tabStructure":"结构","tabData":"数据","tabSql":"SQL","filterActive":"筛选: {{count}}列","clearAllFilters":"清除所有筛选","deleteNRows":"删除 {{count}} 行","confirmDeleteRows":"确认删除?","copyCsvSelected":"复制选中行为 CSV","copyCsvAll":"导出全表 CSV","copyJsonSelected":"复制选中行为 JSON","copyJsonAll":"导出全表 JSON","copyCSV":"复制 CSV","CSV":"CSV","copyJSON":"复制 JSON","JSON":"JSON","selectTable":"选择左侧表格","selectTableToView":"选择表以查看结构","selectTableForData":"选择表以查看数据","columns":"列","colName":"名称","colType":"类型","colNullable":"可空","colDefault":"默认值","primaryKey":"主键","foreignKeys":"外键","indexes":"索引","enable":"启用","commaValues":"逗号分隔多值","likePattern":"%pattern%","valuePlaceholder":"值","apply":"应用","clearFilter":"清除","addRow":"+ 新增行","totalRows":"{{count}} 行","rowsAffected":"{{command}} — {{count}} 行受影响 ({{duration}}ms)","queryRows":"{{count}} 行 ({{duration}}ms)","resultTruncated":"[结果已截断至1000行]","sqlPlaceholder":"输入 SQL... ({{modKey}}Enter 执行)","executing":"执行中...","execute":"▶ 执行","deleteRowsFailed":"{{count}} 行删除失败"},"redis":{"neverExpires":"永不过期","expired":"已过期","loadFailed":"加载失败","deleteFailed":"删除失败","saveFailed":"保存失败","scanPlaceholder":"SCAN 模式...","scanSearch":"搜索 (SCAN)","noKeys":"无 key","loadMore":"加载更多...","tabData":"数据","tabInfo":"信息","tabCli":"CLI","selectKey":"选择左侧 Key","keyNotExist":"Key 不存在","unsupportedType":"不支持的类型: {{type}}","nItems":"{{total}} items","showingN":"显示 {{count}}","nMembers":"{{total}} members","nEntries":"{{total}} entries","cliHint":"输入 Redis 命令,如 PING, GET key, KEYS *","cliPlaceholder":"输入命令..."},"git":{"switchBranch":"切换分支","searchBranch":"搜索分支...","noBranches":"无可切换分支","noMatchingBranches":"无匹配分支","localBranches":"本地分支","remoteBranches":"远程分支","branchNotFound":"未找到分支","selectBranch":"选择分支...","currentBranch":"当前","notGitRepo":"当前目录不是 Git 仓库","cannotGetBranches":"无法获取分支信息","getBranchesFailed":"获取分支信息失败","discardAllConfirm":"确定要放弃工作区的 {{count}} 个文件的变更吗?此操作不可恢复。","worktree":{"title":"Git Worktree","count":"{{count}} 个 worktree","selectBranch":"选择分支","addWorktree":"+ 添加 Worktree","confirmDelete":"确认删除","confirmDeleteMsg":"确定要删除 worktree 吗?","path":"路径:","branch":"分支:","locked":"已锁定","unlock":"解锁","lock":"锁定","searchBranch":"搜索分支...","noBranches":"无可用分支"}},"comments":{"addComment":"添加评论","lineRange":"行 {{start}}-{{end}}","inputPlaceholder":"输入评论...","newComment":"新评论 {{range}}","commentPlaceholder":"输入评论... ({{modKey}}Enter 提交, Esc 取消)","nComments":"{{count}} 条评论","allComments":"所有评论","copyAllComments":"复制全部评论","noComments":"暂无评论","clearAll":"清空所有","totalComments":"共 {{count}} 条评论","aiReply":"AI 回复","noContent":"(无内容)","linesCount":"({{count}} 行)","codeRef":"以下是我标注的评论和引用:","note":"备注: {{content}}","submitting":"提交中...","enterSubmit":"Enter 提交 \xb7 Shift+Enter 换行","submitComment":"提交评论","askAI":"提问 AI","inputQuestion":"输入你的问题...","aiGenerating":"正在生成中,请稍候...","enterSend":"Enter 发送 \xb7 Shift+Enter 换行","sendToAI":"发送 AI","aiResponding":"AI 正在响应中..."},"fileContextMenu":{"createFile":"新建文件","copyFile":"复制文件","copyFolder":"复制文件夹","pasteHere":"粘贴到此处","deleteFile":"删除文件","deleteFolder":"删除文件夹","copyRelativePath":"复制相对路径","copyAbsolutePath":"复制绝对路径","copyRelativeDirPath":"复制相对文件夹路径","copyAbsoluteDirPath":"复制绝对文件夹路径","copyFileName":"复制文件名","copyFolderName":"复制文件夹名"},"settings":{"title":"设置","theme":"主题","themeLight":"浅色","themeDark":"深色","themeSystem":"跟随系统","browserExtension":"浏览器插件","extensionInstalled":"OpenCockpit Bridge 已连接","extensionNotInstalled":"OpenCockpit Bridge 未连接","extensionDescription":"让 `cockpit browser` 能操作你的 Chrome 标签页和 Console 里的浏览器气泡。每个标签页都有 id(在插件小面板和图标的悬停提示里);Cockpit 操作一个你还没允许的标签页前会先问你,按标签页逐个授权。","installSteps":"安装步骤:","step1":"1. 打开 Chrome 地址栏输入","step2":"2. 开启右上角「开发者模式」","step3":"3. 点击「加载已解压的扩展程序」","step4mac":"4. 按 <kbd>Cmd+Shift+G</kbd> → 粘贴下方路径 → 回车","copyExtensionPath":"复制插件目录路径","reloadExtension":"重载插件","about":"关于","language":"语言","languageAuto":"跟随系统","switchDark":"切换暗色","switchLight":"切换亮色","agentsBundled":"内置","codexSection":"Codex","codexSuggestions":"预测下一句","codexSuggestionsDescription":"每轮回复后让 Codex 猜你下一句要说什么,显示在输入框里(按 Tab 采用)。每轮会多一次小请求。"},"editor":{"placeholder":"写点什么... 输入 / 打开快捷命令","noteTitle":"{{name}} - 笔记","noteUntitled":"笔记","globalNote":"全局笔记","emptyNote":"空笔记","searchNotes":"搜索笔记...","saving":"保存中...","conflictReloaded":"笔记已被其他地方修改,已加载最新版本,刚才未保存的编辑已丢弃","linkPlaceholder":"输入链接地址...","confirmLink":"确认","removeLink":"移除链接","heading1":"标题 1","heading2":"标题 2","heading3":"标题 3","bold":"粗体","italic":"斜体","strikethrough":"删除线","inlineCode":"行内代码","link":"链接","bulletList":"无序列表","orderedList":"有序列表","taskList":"待办列表","blockquote":"引用","codeBlock":"代码块","table":"表格","horizontalRule":"分割线","insertRowAbove":"在上方插入行","insertRowBelow":"在下方插入行","insertColumnLeft":"在左侧插入列","insertColumnRight":"在右侧插入列","deleteRow":"删除当前行","deleteColumn":"删除当前列","deleteTable":"删除表格","deleteCodeBlock":"删除代码块","toc":"目录","expandToc":"展开目录","collapseToc":"收起目录"},"slashCommands":{"heading1":"标题 1","heading1Desc":"大标题","heading2":"标题 2","heading2Desc":"中标题","heading3":"标题 3","heading3Desc":"小标题","bulletList":"无序列表","bulletListDesc":"项目符号列表","orderedList":"有序列表","orderedListDesc":"编号列表","taskList":"待办列表","taskListDesc":"可勾选的任务列表","blockquote":"引用","blockquoteDesc":"引用块","codeBlock":"代码块","codeBlockDesc":"代码片段","table":"表格","tableDesc":"插入 3\xd73 表格","horizontalRule":"分割线","horizontalRuleDesc":"水平分割线","link":"链接","linkDesc":"插入超链接"},"commands":{"plan":"开启计划模式 \xb7 /plan <任务> 直接规划该任务 \xb7 /plan off 关闭"},"markdown":{"copied":"✓ 已复制","copy":"复制"},"imagePreview":{"previewImage":"预览图片","deleteImage":"删除图片","copyImage":"复制图片","copiedImage":"已复制图片"},"tokenStats":{"title":"Claude Code Token 统计","activeHours":"活跃时段分布","hourSessions":"{{h}}:00 — {{count}} 次会话","messages":"消息","toolCalls":"工具调用","activityTrend":"活动趋势","byModel":"按模型","tokenUsage":"Token 用量","equivalentCost":"等效费用","modelCostDetail":"模型费用明细","model":"模型","share":"占比","total":"合计","totalSessions":"总会话","totalMessages":"总消息","equivalentApiCost":"等效 API 费用","longestSession":"最长会话","firstUse":"首次使用","notFound":"未找到 ~/.claude/stats-cache.json","day":"日","week":"周","month":"月"},"toolCall":{"inputParams":"输入参数","resultLabel":"结果","inputParamsTitle":"查看输入参数","resultTitle":"查看结果","input":"输入","result":"结果","details":"详细","detailsTitle":"查看输入与结果","foldedLines":"... ({{count}} 行)"},"fileEditor":{"unsavedConfirm":"有未保存的修改,确定关闭?","discardChanges":"放弃修改","continueEditing":"继续编辑","externallyModified":"文件已被外部修改,保存将覆盖外部更改","useDiskVersion":"使用磁盘版本","forceOverwrite":"强制覆盖"},"quickFileOpen":{"placeholder":"输入文件名快速打开...","noMatch":"没有匹配的文件","recent":"最近","selectHint":"选择","openHint":"打开","closeHint":"关闭"},"envManager":{"title":"环境变量管理","tabScope":"当前 Tab 专用","globalScope":"全局环境变量","varNamePlaceholder":"变量名(如 NODE_ENV)","varValuePlaceholder":"值(如 production)","valuePlaceholder":"值","noVars":"还没有环境变量,添加一个试试"},"aliasManager":{"title":"命令别名管理","description":"为常用命令设置快捷别名(全局生效)","aliasPlaceholder":"别名(如 ll)","commandPlaceholder":"完整命令(如 ls -la)","fullCommandPlaceholder":"完整命令","usage":"使用提示:","usageDesc":"输入别名即可执行对应的完整命令","noAliases":"还没有命令别名,添加一个试试"},"diffViewer":{"fileChanges":"文件变更 ({{count}})","expandFull":"扩展到全屏","exitFull":"回到分栏","toggleFileTree":"切换文件目录","selectFileToView":"选择左侧文件查看变更","sideBySide":"并列对比","unified":"统一对比","viewSplit":"双栏","viewUnified":"单栏","previewFile":"预览文件","copiedAll":"已复制全文","compact":"精简","full":"全文","gap":{"hidden":"已隐藏 {{count}} 行","more":"\xb7\xb7\xb7 更多 +{{count}} \xb7\xb7\xb7","expandUp":"向上展开 {{count}} 行","expandDown":"向下展开 {{count}} 行","expandAll":"点击展开 {{count}} 行"},"loadingSnapshots":"正在加载快照…","loadingFile":"正在加载文件差异…","fileLoadFailed":"无法加载文件差异","noChanges":"本轮未检测到文件变更","notViewable":"二进制或超大文件,无法展示 diff","externalChange":"同期其他会话/外部进程的变更","reconstructed":"参数重建","reconstructedHint":"由工具调用参数重建,非磁盘快照","truncated":"文件过多,仅显示部分","aggregate":"汇总","aggregateOn":"查看全部调用的累计变更","aggregateOff":"返回逐次调用","fileChangesAggregate":"文件变更 ({{count}}) \xb7 汇总","aggregateSummary":"{{count}} 个文件变更({{calls}} 次调用累计)","aggregateLoading":"正在汇总变更…","aggregateEmpty":"累计后无净变更","aggregateUnavailable":"无快照,无法汇总","aggregateFailed":"汇总失败","aggregateBaselineSkipped":"已跳过 {{count}} 次基线级调用","aggregateBaselineIncluded":"已计入 {{count}} 次基线级调用","callsBaselineHidden":"已隐藏 {{count}} 次基线级调用","callsBaselineShown":"已显示 {{count}} 次基线级调用","aggregateSkippedHint":"这些调用改动的文件数超过 {{threshold}},通常是切换分支 / rebase 而非编写代码。点击切换是否计入","imageBefore":"变更前","imageAfter":"变更后","imageAdded":"新增","imageDeleted":"已删除","imageLoadFailed":"图片加载失败","imageUnavailable":"该版本无此图片"},"commitDetail":{"title":"提交详情","hash":"哈希:","author":"作者:","date":"日期:","files":"文件:","nChanges":"{{count}} 个变更","loadingFiles":"加载文件中...","noFileChanges":"无文件变更","loadingDiff":"加载差异中...","selectFileToView":"选择文件查看差异"},"askQuestion":{"title":"提问","nQuestions":"{{count}} 个问题","checkedN":"已勾选 {{count}}","copyChecked":"复制勾选的 {{count}} 个问答","copyAll":"复制所有问答","sendChecked":"发送勾选的 {{count}} 个问答给 AI","sendAll":"发送所有问答给 AI","sendNoChat":"没有可用的聊天会话","checkToCopy":"勾选以复制","custom":"自定义","customPlaceholder":"输入自定义回答...","notSelected":"(未选择)"},"tabBar":{"closeTab":"关闭会话","closeAll":"关闭所有会话","newTab":"新会话"},"tabManagerTopBar":{"copyPageUrl":"复制页面地址","copyDirPath":"复制目录路径","refreshProject":"刷新当前项目","openInVSCode":"在 VS Code 中打开","openInCursor":"在 Cursor 中打开","aliasesGlobal":"命令别名(全局)","tokenStats":"Token 统计","openSurething":"打开 Surething","openOnPhone":"在手机上打开","phoneQrHint":"用手机扫码打开 Cockpit","phoneQrSessionHint":"用手机扫码打开当前会话","phoneQrTokenWarning":"二维码包含访问令牌,请勿外传","phoneQrFailed":"二维码生成失败"},"hoverTooltip":{"findReferences":"查找引用","search":"搜索"},"todoViewer":{"title":"任务列表","progress":"{{completed}} / {{total}} 完成"},"userMessages":{"title":"用户消息列表","noMessages":"暂无用户消息","searchPlaceholder":"搜索用户消息…","noResults":"没有匹配的消息","loadFailed":"加载失败","count":"{{shown}} / {{total}} 条","jumping":"正在加载该消息所在的对话…"},"shortIdBadge":{"clickToDisconnect":"点击断开连接","clickToRegister":"点击注册并复制 CLI 命令","setTitle":"给这个气泡命名(便于 /cc 通过 connection list 找到它)","setTitlePlaceholder":"设置标题","editTitle":"编辑标题","titleSet":"标题:{{title}}","dialogTitle":"给气泡命名","dialogPlaceholder":"例如:alloydb 代理、预发管理后台"},"api":{"pathForbidden":"不允许操作此路径","deleteForbidden":"不允许删除此路径","notAFolder":"目标不是文件夹","imageTooLarge":"图片文件过大,无法预览","cannotPreviewBinary":"无法预览二进制文件","fileTooLarge":"文件过大,无法预览(超过 10MB)","fileModifiedExternally":"文件已被外部修改"},"folderPicker":{"title":"打开文件夹","placeholder":"输入或粘贴路径,如 ~/Work/my-app","open":"打开","showHidden":"显示隐藏目录","hint":"↑↓ 选择 \xb7 Tab/回车 进入 \xb7 ⌘/Ctrl+回车 打开","empty":"没有子文件夹","noMatch":"没有匹配的文件夹","notFound":"文件夹不存在","notDirectory":"不是文件夹","denied":"没有访问权限。macOS 上请在 系统设置 › 隐私与安全性 中授权。"},"confirm":{"title":"提示","ok":"确定","cancel":"取消"},"floatingToolbar":{"addComment":"添加评论","sendToAI":"发送 AI","search":"搜索"},"quickReply":{"optionA":"A","optionB":"B","optionC":"C","optionD":"D","allRecommended":"其他按推荐","thisOne":"就这个","notThis":"不要这样","why":"为什么","elaborate":"展开说","example":"举个例子","start":"开始做","continue":"继续","ok":"OK","done":"做完了","edit":"编辑快捷短语","editTitle":"编辑快捷短语","editHint":"一行对应面板的一行,行内用逗号分隔。每个短语会原样发送到对话。","editPlaceholder":"就这个,不要这样\\n为什么,展开说","restoreDefault":"恢复默认","save":"保存","cancel":"取消","customizedFor":"当前编辑的是{{lang}}短语,另一种语言不受影响。","langEn":"英文","langZh":"中文","saveFailed":"保存快捷短语失败"},"searchResults":{"title":"搜索结果","nMatches":"({{count}} 处匹配)","searching":"搜索中...","noResults":"无匹配结果","scopeSelected":"选中","scopeAll":"全部"},"references":{"title":"引用","searching":"搜索中...","notFound":"未找到引用"},"gitFileTree":{"noFiles":"无文件"},"deps":{"action":"依赖关系","none":"无","symbolMessage":"分析 {{name}} ({{path}}:{{lines}}) 的依赖关系。\\n\\n调用者:{{callers}}\\n调用了:{{callees}}\\n外部依赖:{{externals}}\\n\\n请说明它耦合在哪些模块上,以及哪些依赖是可以收敛掉的。"},"explain":{"action":"解释一下","fileMessage":"解释一下 {{path}}","symbolMessage":"解释一下 {{name}} ({{path}}:{{lines}})","selectionMessage":"解释一下","commitFileMessage":"解释一下 git commit {{hash}} 对 {{path}} 的改动","compareFileMessage":"解释一下 git {{base}}...HEAD 中 {{path}} 的改动","compareFileWorktreeMessage":"解释一下 {{path}} 相对 {{base}} 的改动(含未提交的部分)","stagedFileMessage":"解释一下 git 暂存区中 {{path}} 的改动","unstagedFileMessage":"解释一下 git 工作区中 {{path}} 的改动"},"bots":{"sessionBadge":"会话","sessionGroup":"会话 Bot","sessionGroupHint":"在会话的改名框里勾选「可被 @ 调用」的会话;@ 它会把任务发进这个会话","sessionGone":"会话已不存在","sessionNameInvalid":"标题不能用作名字(多行或含 @),改个名字才能 @","sessionUsage":"在任意会话里写「@{{name}} 任务」把任务发进这个会话","removeSession":"移出 Bots","title":"机器人","search":"搜索机器人","addExisting":"添加机器人","addTooltip":"添加为机器人","emptyNoMatch":"没有匹配的机器人。","emptyNoBots":"还没有你自己的机器人。","emptyCreatePrefix":"在聊天里使用","emptyCreateSuffix":"创建一个。","emptyAddExisting":"添加已有的机器人目录","invalid":"无效","builtin":"内置","mine":"我的","tabFiles":"文件","tabSessions":"会话","noSessions":"最近没有这个机器人的会话","sessionsScope":"在它目录里运行的全部会话,以及它最近派发出去的会话","selectHint":"选择左侧机器人,查看它的文件和会话","remove":"移除注册","open":"作为项目打开","pathPlaceholder":"机器人目录或其 BOT.md 的绝对路径","addHint":"目录中必须包含 BOT.md,不会改动其中的文件。","added":"机器人已添加","alreadyAdded":"已添加过","removed":"已移除机器人注册,目录文件仍保留。","loadFailed":"加载机器人失败","saveFailed":"添加机器人失败","removeFailed":"移除机器人失败"},"contextInspector":{"title":"会话上下文","open":"查看上下文内容","used":"已用","window":"窗口","free":"剩余","unknownWindow":"窗口大小未知","capturedAt":"统计于 {{time}}","refresh":"刷新","loadFailed":"读取上下文失败","noSession":"会话还没有开始,暂无上下文","empty":"没有可展示的上下文条目","selectItem":"点左侧条目查看具体内容","noContent":"该引擎没有暴露这一项的原文,只有名称和 token 数","truncated":"内容过长,只显示前 {{count}} 个字符","estimated":"≈ 为按字符估算","items":"{{count}} 项","copy":"复制","copied":"已复制","groups":{"prompt":"提示词","memory":"记忆文件","tools":"工具","skills":"Skills 与 Agents","messages":"消息","tool_io":"工具调用","reasoning":"推理","other":"其他"},"categories":{"system":"System prompt","instructions":"附加指令","memory":"记忆文件","tools":"工具定义","mcp":"MCP 工具","skills":"Skills","agents":"自定义 Agents","environment":"环境信息","messages":"对话消息","tool_io":"工具调用与结果","reasoning":"推理内容","summary":"压缩摘要","other":"其他"},"notes":{"system_prompt_hidden":"System prompt 由引擎内部拼接,不对外提供原文,这里只列出各段名称和 token 数。","tool_schemas_hidden":"内置工具只提供名称和 token 数,不提供 schema 原文。","skills_listing_only":"Skills 在上下文里只占名称和描述;完整内容要等调用时才加载。","snapshot_from_last_turn":"分类数据是上一轮结束时记录的,不是实时数据。","no_snapshot_yet":"这个会话还没有记录过分类快照,下一轮对话结束后会有精确的分类数据;当前显示的是从记录中估算的结果。","reasoning_encrypted":"部分推理或压缩内容是加密的,看不到原文,也无法估算大小。","after_compaction":"会话已压缩过,这里只包含最近一次压缩之后的内容。","estimated_breakdown":"各分类的 token 数是估算值,顶部的总数以引擎上报为准。","usage_unknown":"引擎没有上报这个会话的上下文大小。"}}}');r.Ay.isInitialized||r.Ay.init({resources:{en:{translation:s},zh:{translation:o}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});let a=r.Ay},69895:(e,t,n)=>{n.d(t,{P:()=>c});var r=n(12115),s=n(49433),o=n(86957),a=n(82680),l=n(88292),i=n(75346);let d=s.$mh({try:async()=>{let e=await fetch("/api/pinned-sessions");if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()},catch:e=>new a.uV({message:"Cannot load favorites",cause:e})});function c(){let[e,t]=(0,r.useState)([]),n=(0,r.useRef)(0),c=(0,r.useRef)(0),u=(0,r.useRef)(0),m=(0,r.useMemo)(()=>s.RIP(1),[]),h=(0,r.useCallback)(()=>{if(c.current>0)return;let e=n.current,r=++u.current;o.t4.runPromise(d.pipe(s.YWq({onSuccess:s=>{r===u.current&&e===n.current&&0===c.current&&t(s.sessions||[])},onFailure:()=>{}})))},[]);(0,r.useEffect)(()=>{h()},[h]),(0,r.useEffect)(()=>{let e=e=>{e.data?.type==="PINNED_SESSIONS_CHANGED"&&h()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[h]);let p=(0,r.useCallback)(e=>{n.current++,c.current++,t(e),o.t4.runFork(m.withPermits(1)(s.$mh({try:async()=>{let t=await fetch("/api/pinned-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessions:e})});if(!t.ok)throw Error(`HTTP ${t.status}`)},catch:e=>new a.uV({message:"Cannot save favorites",cause:e})}).pipe(s.Mim(()=>s.qIB(l.d,e=>e.publish(i.n.PinnedSessionsChanged,{}))))).pipe(s.yeE(s.OH5(()=>{c.current--})),s.h9N(e=>s.FFw("Cannot save favorites",e).pipe(s.Mim(()=>s.OH5(h))))))},[h,m]),f=(0,r.useCallback)(t=>e.some(e=>e.sessionId===t),[e]),g=(0,r.useCallback)((t,n,r)=>{e.some(e=>e.sessionId===t)||p([...e,{sessionId:t,cwd:n,title:r}])},[e,p]),x=(0,r.useCallback)(t=>{p(e.filter(e=>e.sessionId!==t))},[e,p]);return{pinnedSessions:e,isPinned:f,pinSession:g,unpinSession:x,reorder:(0,r.useCallback)(e=>{p(e)},[p]),reload:h}}},69924:(e,t,n)=>{n.d(t,{B:()=>s});var r=n(95155);function s({href:e,target:t,onClick:n,newTab:o=!1}){return(0,r.jsxs)("a",{href:e,title:`${t.cwd}
|
|
733
|
-
${t.sessionId}`,className:"inline-flex items-center gap-1 px-1.5 rounded bg-brand/10 hover:bg-brand/20 text-brand text-[0.9em] align-baseline whitespace-nowrap no-underline",onClick:n,...o?{target:"_blank",rel:"noopener noreferrer"}:{},children:[(0,r.jsx)("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:(0,r.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),t.sessionId.slice(0,8)]})}},70188:(e,t,n)=>{n.d(t,{Ee:()=>m,SU:()=>d,ft:()=>u,iN:()=>c});var r=n(95155),s=n(12115),o=n(79114),a=n(47650),l=n(34075);let i=(0,s.createContext)(null);function d({container:e,children:t}){return(0,r.jsx)(i.Provider,{value:e,children:t})}function c(){return(0,s.useContext)(i)}function u({x:e,y:t,path:n,cwd:d,isDirectory:c,onClose:m,onCreateFile:h,onDelete:p,onRefresh:f,onCopyFile:g,onPaste:x,onExplain:b,explainDisabled:v}){let{t:y}=(0,o.Bd)(),w=(0,s.useRef)(null),k=(0,s.useContext)(i),C=n.split("/").pop()||n,j=`${d}/${n}`,N=n.includes("/")?n.substring(0,n.lastIndexOf("/")):"",S=N?`${d}/${N}`:d,T=c?n:N,E=c?j:S;(0,s.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&m()},t=e=>{"Escape"===e.key&&m()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[m]);let[R,M]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(w.current&&k){let n=k.getBoundingClientRect(),r=w.current.getBoundingClientRect(),s=e-n.left,o=t-n.top;s=Math.min(s,n.width-r.width-8),o=Math.min(o,n.height-r.height-8),M({x:s=Math.max(8,s),y:o=Math.max(8,o)})}else if(w.current){let n=w.current.getBoundingClientRect();M({x:Math.max(8,Math.min(e,window.innerWidth-n.width-8)),y:Math.max(8,Math.min(t,window.innerHeight-n.height-8))})}},[e,t,k]);let L=(0,s.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(e),(0,l.oR)(y("toast.copiedName",{name:t}),"success")}catch{(0,l.oR)(y("toast.copyFailed"),"error")}m()},[m,y]),I=c?n:N,A=!!b&&!c,P=[{label:y("fileContextMenu.copyRelativePath"),value:n},{label:y("fileContextMenu.copyAbsolutePath"),value:j},{label:y("fileContextMenu.copyRelativeDirPath"),value:T||"."},{label:y("fileContextMenu.copyAbsoluteDirPath"),value:E},{label:c?y("fileContextMenu.copyFolderName"):y("fileContextMenu.copyFileName"),value:C}],F=(0,r.jsxs)("div",{ref:w,className:"absolute z-[200] bg-card border border-border rounded-lg shadow-lv2 py-1 w-fit whitespace-nowrap",style:{left:R.x,top:R.y},children:[A&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",disabled:v,title:v?y("comments.aiResponding"):void 0,onClick:()=>{m(),b(n)},children:y("explain.action")}),A&&(0,r.jsx)("div",{className:"my-1 border-t border-border"}),h&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>{m(),h(I)},children:y("fileContextMenu.createFile")}),g&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>{m(),g(n)},children:c?y("fileContextMenu.copyFolder"):y("fileContextMenu.copyFile")}),x&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>{m(),x(I)},children:y("fileContextMenu.pasteHere")}),p&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-destructive hover:bg-hover transition-colors",onClick:()=>{m(),p(n,c,C)},children:c?y("fileContextMenu.deleteFolder"):y("fileContextMenu.deleteFile")}),!!(h||g||x||p)&&(0,r.jsx)("div",{className:"my-1 border-t border-border"}),P.map((e,t)=>(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>L(e.value,e.label),children:e.label},t))]});return k?(0,a.createPortal)(F,k):F}function m(){let[e,t]=(0,s.useState)(null);return{contextMenu:e,showContextMenu:(0,s.useCallback)((e,n,r)=>{e.preventDefault(),e.stopPropagation(),t({x:e.clientX,y:e.clientY,path:n,isDirectory:r})},[]),hideContextMenu:(0,s.useCallback)(()=>{t(null)},[])}}},72312:(e,t,n)=>{n.d(t,{N:()=>s});var r=n(95155);function s({cls:e}){return(0,r.jsx)("span",{className:`text-[10px] px-1 py-px rounded flex-shrink-0 ${"test"===e?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400/80":"bg-sky-500/15 text-sky-600 dark:text-sky-400/80"}`,children:e})}},73103:(e,t,n)=>{n.d(t,{k:()=>i});var r=n(95155),s=n(8601),o=n(57125),a=n(53317),l=n(95595);function i(e){let t=l.M7,n=e.model&&"grok-build"!==e.model?e.model:l.yR,i=t.models.find(e=>e.id===n),d=t.models.map(e=>({id:e.id,label:e.label,defaultValue:e.id===t.defaultModel}));d.some(e=>e.id===n)||d.unshift({id:n,label:(0,a.J)(n),defaultValue:!1});let c=i?.reasoning??t.models[0].reasoning,u=c.some(t=>t.id===e.reasoningEffort)?e.reasoningEffort:i?.defaultReasoning??l.ZL;return(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,r.jsx)(s.zC,{title:"Model",selected:n,value:i?.label??d.find(e=>e.id===n).label,items:d,onSelect:n=>{e.onModelChange?.(n),e.onReasoningEffortChange?.(t.models.find(e=>e.id===n)?.defaultReasoning??l.ZL)},icon:(0,r.jsx)(o.eV,{engine:"grok"}),testId:"grok-model-picker"}),(0,r.jsx)(s.zC,{title:"Reasoning",selected:u,value:c.find(e=>e.id===u)?.label??u,items:c.map(e=>({...e,defaultValue:e.id===(i?.defaultReasoning??l.ZL)})),onSelect:t=>e.onReasoningEffortChange?.(t),testId:"grok-reasoning-picker"})]})}},74086:(e,t,n)=>{n.d(t,{I$:()=>a,hC:()=>o,v2:()=>l});var r=n(12115),s=n(14594);function o(){let e=new Map,t=new Set,n=()=>t.forEach(e=>e());return{applyEvent(t){let r=t.tool_use_id;if(!r||t.ambient)return;let o=(0,s.Uy)(e.get(r),t);e.set(r,o),n()},getTask:t=>e.get(t),settleRunning(){let t=!1;for(let[n,r]of e)"running"===r.status&&(e.set(n,{...r,status:"unknown"}),t=!0);t&&n()},subscribe:e=>(t.add(e),()=>t.delete(e))}}let a=(0,r.createContext)({applyEvent:()=>{},getTask:()=>void 0,settleRunning:()=>{},subscribe:()=>()=>{}});function l(e){let t=(0,r.useContext)(a),n=(0,r.useCallback)(()=>e?t.getTask(e):void 0,[t,e]);return(0,r.useSyncExternalStore)(t.subscribe,n,n)}},75346:(e,t,n)=>{n.d(t,{n:()=>s});var r=n(88292);let s={SessionChange:(0,r.R)("session-change"),ViewChange:(0,r.R)("view-change"),OpenNote:(0,r.R)("open-note"),LangChange:(0,r.R)("lang-change"),TabAdd:(0,r.R)("tab-add"),TabClose:(0,r.R)("tab-close"),SwitchSession:(0,r.R)("switch-session"),ProjectChange:(0,r.R)("project-change"),OpenProject:(0,r.R)("open-project"),SessionComplete:(0,r.R)("session-complete"),OpenTokenStats:(0,r.R)("open-token-stats"),PinnedSessionsChanged:(0,r.R)("pinned-sessions-changed"),ScheduledTasksChanged:(0,r.R)("scheduled-tasks-changed"),ScreenshotPrepare:(0,r.R)("screenshot-prepare"),ScreenshotDone:(0,r.R)("screenshot-done")}},75347:(e,t,n)=>{n.d(t,{dh:()=>y,hc:()=>v,bc:()=>b});var r=n(95155),s=n(12115),o=n(47650),a=n(79114),l=n(49387),i=n(86901),d=n(49433),c=n(86957),u=n(67415),m=n(33442),h=n(2111),p=n(68287),f=n(48050),g=n(8183),x=n(99356);let b=()=>(0,s.useSyncExternalStore)(g.OS,g.V6,g.Yn);function v(){let e=(0,s.useCallback)(e=>{if("session-title-changed"===e.type&&e.data&&(0,g.X4)(e.data),"global-state"===e.type&&e.data?.sessions)for(let t of e.data.sessions)"number"==typeof t.titleRevision&&void 0!==t.defaultTitle&&void 0!==t.customTitle&&(0,g.X4)(t)},[]),[t]=(0,s.useState)(x.I7);return(0,h.h)({url:t,onMessage:e}),(0,s.useEffect)(()=>(0,h.D)(()=>{for(let{cwd:e,sessionId:t}of(0,g.c4)())c.t4.runFork((0,f.iS)(e,t).pipe(d.Mim(e=>d.OH5(()=>(0,g.X4)(e))),d.h9N(e=>d.FFw("Cannot refresh session title",e))))}),[]),null}function y({cwd:e,sessionId:t,title:n,titleRevision:h,initialTitleReady:x=!1,editable:v=!0}){let{t:w}=(0,a.Bd)(),k=b(),C=(0,g.iM)(k,e,t,n,h),[j,N]=(0,s.useState)(!1),[S,T]=(0,s.useState)(""),[E,R]=(0,s.useState)(!1),[M,L]=(0,s.useState)(!1),[I,A]=(0,s.useState)(!1),[P,F]=(0,s.useState)(!1),[$,D]=(0,s.useState)(!1),[_,B]=(0,s.useState)(""),[O,H]=(0,s.useState)(!1),V=(0,s.useRef)(null),U=(0,s.useCallback)(()=>{V.current?.abort(),V.current=null,H(!1),N(!1)},[]);(0,s.useEffect)(()=>()=>V.current?.abort(),[]);let W=`ai-title-${(0,s.useId)().replace(/[^a-zA-Z0-9_-]/g,"")}`,[q,z]=(0,s.useState)(""),K=(0,s.useRef)(null),G=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(!e||!t)return;let n=(0,g.eh)(e,t),r=!0;return x||c.t4.runFork((0,f.iS)(e,t).pipe(d.Mim(e=>d.OH5(()=>{r&&(0,g.X4)(e)})),d.h9N(e=>d.FFw("Cannot read session title",e)))),()=>{r=!1,n()}},[e,t,x]),(0,s.useEffect)(()=>{if(!j)return;let n=!0;return L(!1),z(""),c.t4.runFork((0,f.iS)(e,t).pipe(d.YWq({onSuccess:e=>{n&&((0,g.X4)(e),T(e.title),B(e.title),A(null!==e.customTitle),F(!0===e.mentionable),D(!0===e.mentionable),L(!0),K.current?.focus(),K.current?.select())},onFailure:()=>{n&&z(w("sessions.titleLoadFailed"))}}))),()=>{n=!1}},[j,e,t,w]),(0,s.useEffect)(()=>{if(!j)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopImmediatePropagation(),G.current||U())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[j]);let Q=async()=>{if(O||E)return;H(!0),z("");let n=new AbortController;V.current=n;let r=await c.t4.runPromiseExit((0,f.F9)(e,t),{signal:n.signal});V.current===n&&(V.current=null,H(!1),"Success"===r._tag?(T(r.value),K.current?.focus()):z(w("sessions.titleSuggestFailed",{reason:"Fail"===r.cause._tag?r.cause.error.message:""})))},J=e=>w("empty"===e?"sessions.titleEmpty":"multiline"===e?"sessions.titleSingleLine":"sessions.titleNoAt"),Y=async n=>{if(G.current||!M)return;let r=null===n||I||n!==_;if(null!==n){let e=/[\r\n]|\\[nr]/.test(n)?"multiline":n.replace(/[\r\n]+/g," ").trim()?n.includes("@")?"at":null:"empty";if(e&&r)return void z(J(e));if(e&&P)return void z(w("sessions.titleNotMentionable",{reason:J(e)}))}G.current=!0,R(!0),z("");let s=await c.t4.runPromiseExit((0,f.iS)(e,t,{...r&&{customTitle:n},mentionable:P}));G.current=!1,R(!1),"Success"===s._tag?((0,g.X4)(s.value),U(),(P||$)&&(c.t4.runSync(u.gG),(0,m._)())):z(w("sessions.titleSaveFailed"))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"truncate min-w-0","data-tooltip":C,children:C}),v&&e&&t&&(0,r.jsx)("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 pointer-events-none group-hover/session-title:opacity-100 group-hover/session-title:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto hover:text-foreground hover:bg-hover transition-opacity","aria-label":w("sessions.editTitle"),onClick:e=>{e.stopPropagation(),T(C),N(!0)},onDoubleClick:e=>e.stopPropagation(),children:(0,r.jsx)(l.A,{className:"w-3 h-3"})}),j&&(0,o.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-black/40 p-4",onClick:e=>{e.stopPropagation(),e.target!==e.currentTarget||G.current||U()},onDoubleClick:e=>e.stopPropagation(),children:(0,r.jsxs)("form",{role:"dialog","aria-modal":"true","aria-label":w("sessions.editTitle"),className:"w-full max-w-sm rounded-xl border border-border bg-card p-4 shadow-xl space-y-3",onSubmit:e=>{e.preventDefault(),Y(S)},children:[(0,r.jsx)("h2",{className:"text-sm font-medium",children:w("sessions.editTitle")}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{ref:K,autoFocus:!0,"aria-label":w("sessions.editTitle"),value:S,disabled:E||O,onKeyDown:e=>{"Enter"===e.key&&e.nativeEvent.isComposing&&e.preventDefault()},onChange:e=>T(e.target.value),className:"w-full rounded border border-border bg-background py-1 pl-2 pr-8 text-sm focus:outline-none focus:ring-1 focus:ring-ring"}),(0,r.jsxs)("button",{type:"button","aria-label":w("sessions.suggestTitle"),"data-tooltip":w("sessions.suggestTitle"),disabled:E||O||!M,onClick:()=>void Q(),className:`absolute right-1 top-1/2 -translate-y-1/2 rounded-full p-0.5 ${O?"":"hover:bg-hover disabled:opacity-50"}`,children:[(0,r.jsx)("svg",{width:"0",height:"0",className:"absolute","aria-hidden":"true",children:(0,r.jsx)("defs",{children:(0,r.jsxs)("linearGradient",{id:W,x1:"0",y1:"0",x2:"1",y2:"1",children:[(0,r.jsx)("stop",{offset:"0%",stopColor:"var(--color-blue-9)"}),(0,r.jsx)("stop",{offset:"55%",stopColor:"var(--color-brand)"}),(0,r.jsx)("stop",{offset:"100%",stopColor:"var(--color-amber-9)"})]})})}),(0,r.jsx)("span",{className:`flex items-center justify-center w-6 h-6 rounded-full ${O?(0,p.ci)("loading",!1):""}`,children:(0,r.jsx)(i.A,{stroke:`url(#${W})`,className:"w-3.5 h-3.5"})})]})]}),(0,r.jsxs)("label",{className:"flex items-start gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:P,disabled:E||!M,onChange:e=>F(e.target.checked)}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"text-foreground",children:w("sessions.mentionable")}),(0,r.jsx)("br",{}),w("sessions.mentionableHint")]})]}),q&&(0,r.jsx)("p",{role:"alert",className:"text-xs text-destructive",children:q}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 text-xs",children:[I&&(0,r.jsx)("button",{type:"button",disabled:E||!M,className:"mr-auto text-muted-foreground disabled:opacity-50",onClick:()=>void Y(null),children:w("sessions.restoreTitle")}),(0,r.jsx)("button",{type:"button",disabled:E,onClick:U,children:w("common.cancel")}),(0,r.jsx)("button",{type:"submit",disabled:E||O||!M,className:"rounded bg-brand px-3 py-1 text-white disabled:opacity-50",children:E?w("common.loading"):w("common.save")})]})]})}),document.body)]})}},77725:(e,t,n)=>{n.d(t,{Z:()=>c});var r=n(12115),s=n(10592),o=n(86359),a=n(80905),l=n(49433),i=n(80286),d=n(86957);function c(e,t){let[n,c]=(0,r.useState)({status:"loading"});return(0,r.useEffect)(()=>{c({status:"loading"});let t=d.t4.runFork(e);return t.addObserver(e=>{s.YW(e,{onSuccess:e=>c({status:"success",data:e}),onFailure:e=>{if(o.t9(e))return;let t=o.od(e);c({status:"error",error:a.Ru(t)?t.value:e})}})}),()=>{l.MY7(i.G(t))}},t),n}},79237:(e,t,n)=>{n.d(t,{y:()=>s});let r=e=>"/"===e||"\\"===e;function s(e,t){let n;if(!e)return null;let s=""===(n=e.replace(/[/\\]+$/,""))||/^[A-Za-z]:$/.test(n)?e:n;return t===s?"":t.startsWith(s)?r(s[s.length-1])?t.slice(s.length):r(t[s.length])?t.slice(s.length+1):null:null}},82292:(e,t,n)=>{function r(e,t){for(let n of e){if(n.path===t)return n;if(n.children){let e=r(n.children,t);if(e)return e}}return null}function s(e,t){if(!e)return"";let n=r(t,e);if(n?.isDirectory)return e;let s=e.split("/");return s.pop(),s.join("/")}function o(e){let t=[];for(let n of e){let e=n.split("/"),r=t;for(let t=0;t<e.length;t++){let n=e[t],s=t===e.length-1,o=e.slice(0,t+1).join("/"),a=r.find(e=>e.name===n);a||(a={name:n,path:o,isDirectory:!s,children:s?void 0:[]},r.push(a)),!s&&a.children&&(r=a.children)}}let n=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&&n(e.children)})};return n(t),t}function a(e){let t=[],n=e=>{for(let r of e)r.isDirectory&&(t.push(r.path),r.children&&n(r.children))};return n(e),t}n.d(t,{B_:()=>p,HR:()=>function e(t,n){if(0===n.length)return t;let r=new Map(n.map(e=>[e.path,e]));return t.map(t=>{let n=r.get(t.path);return n&&t.isDirectory?void 0===t.children&&void 0!==n.children?{...t,children:n.children}:void 0!==t.children&&void 0!==n.children?{...t,children:e(t.children,n.children)}:t:t})},KH:()=>c,MB:()=>r,S7:()=>s,fw:()=>u,q3:()=>d,r6:()=>m,tE:()=>h,tW:()=>a,u:()=>i,v3:()=>o});let l=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp","avif"]);function i(e){let t=e.split(".").pop()?.toLowerCase();return l.has(t||"")}function d(e,t,n=!1){let r=new Set;if(!t)return r;let s=t.toLowerCase(),o=e=>{if(r.add(e.path),e.children)for(let t of e.children)o(t)},a=(e,t)=>{let l=e.name.toLowerCase(),i=n?l===s:l.includes(s);if(i&&e.children)return o(e),t.forEach(e=>r.add(e)),!0;let d=!1;if(e.children)for(let n of e.children)a(n,[...t,e.path])&&(d=!0);return(!!i||!!d)&&(r.add(e.path),t.forEach(e=>r.add(e)),!0)};for(let t of e)a(t,[]);return r}function c(e,t,n=!1){let r=new Set;if(!t)return r;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(n?o===s:o.includes(s)){for(let t=0;t<=e.length-1;t++)r.add(e.slice(0,t+1).join("/"));break}}}return r}function u(e){let t=Math.floor(Math.floor((Date.now()-1e3*e)/1e3)/60),n=Math.floor(t/60),r=Math.floor(n/24),s=Math.floor(r/30),o=Math.floor(r/365);return o>0?`${o}y ago`:s>0?`${s}mo ago`:r>0?`${r}d ago`:n>0?`${n}h ago`:t>0?`${t}m ago`:"just now"}function m(e){let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return r?`${s}-${o} ${a}:${l}`:`${t.getFullYear()}-${s}-${o} ${a}:${l}`}let h=()=>{},p=50},82680:(e,t,n)=>{n.d(t,{m_:()=>o,uV:()=>s});var r=n(50584);class s extends r.rN("AppError"){}r.rN("DBError"),r.rN("WSError"),r.rN("FSError"),r.rN("AgentError"),r.rN("ValidationError");class o extends r.rN("NotFoundError"){}r.rN("PermissionError")},83448:(e,t,n)=>{n.d(t,{$N:()=>R,$x:()=>H,Ay:()=>D,Cr:()=>_,F4:()=>C,Fi:()=>v,Hw:()=>g,J5:()=>m,JC:()=>T,K9:()=>u,M5:()=>N,Ny:()=>x,QW:()=>M,VA:()=>a,Vm:()=>A,ZQ:()=>O,Zr:()=>E,_9:()=>B,_l:()=>$,an:()=>F,dM:()=>k,dQ:()=>b,em:()=>f,hZ:()=>V,he:()=>w,l1:()=>S,nM:()=>h,qD:()=>P,sy:()=>y,td:()=>p,vc:()=>d,yS:()=>j,z2:()=>L});var r=n(49433),s=n(82680),o=n(84230);let a=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e&&"claude"!==e?`/api/chat/${e}`:"/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw Error((await n.json()).error??`HTTP ${n.status}`)},catch:e=>new s.uV({message:e instanceof Error?e.message:"Cannot deliver chat input",cause:e})}),l=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()},catch:n=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),i=(e,t)=>l(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),d=e=>i("/api/chat/stop",e),c=(e,t)=>l(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),u=e=>l(`/api/project-state?cwd=${encodeURIComponent(e)}`),m=(e,t)=>i("/api/project-state",{cwd:e,sessions:[],...t}),h=(e,t)=>i("/api/session/user-messages",{cwd:e,sessionId:t}),p=()=>(0,o.F)("/api/settings",l("/api/settings")),f=e=>c("/api/settings",e).pipe(r.yeE(r.OH5(()=>(0,o.T)("/api/settings")))),g=e=>l(`/api/${e}/credentials`),x=e=>l(`/api/${e}/credentials?reveal=1`),b=(e,t)=>c(`/api/${e}/credentials`,{apiKey:t}),v=e=>l(`/api/${e}/models`),y=(e,t,n,r)=>{let s=new URLSearchParams({engine:e,model:t,...n?{cwd:n}:{},...r?{sessionId:r}:{}});return l(`/api/pi/thinking?${s}`)},w=()=>l("/api/deepseek/balance"),k=e=>l(`/api/${e}/usage`),C=()=>l("/api/ollama/config"),j=e=>c("/api/ollama/config",e),N=()=>(0,o.F)("/api/commands",l("/api/commands")),S=()=>(0,o.F)("/api/skills",l("/api/skills")),T=e=>i("/api/bash",e),E=(e,t)=>i(`/api/session/${encodeURIComponent(e)}/fork`,t),R=(e,t)=>l(`/api/session/${encodeURIComponent(e)}/turn`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),M=e=>l(`/api/sessions/projects/${encodeURIComponent(e)}`),L=()=>l("/api/global-state").pipe(r.TjK(e=>e.sessions??[])),I=()=>r.$mh({try:async()=>{let e=await fetch("/api/ollama/models"),t=await e.json().catch(()=>({}));return 503===e.status?{_tag:"not-running",...t.error&&{reason:t.error}}:e.ok?{_tag:"ok",models:t.models??[]}:{_tag:"error",message:t.error||"Failed to fetch models"}},catch:e=>new s.uV({message:"fetch ollama models failed",cause:e})}),A=()=>r.ivC(async()=>{let e=await fetch("/api/ollama/default-model");if(e.ok)return(await e.json()).model||void 0}).pipe(r.DM4(()=>void 0)),P=e=>r.JkU(function*(){let t=yield*I();if("not-running"!==t._tag)return t;e&&(yield*r.OH5(e));let n=yield*r.$mh({try:async()=>{let e=await fetch("/api/ollama/start",{method:"POST"}),t=await e.json().catch(()=>({}));return 404===e.status?{_tag:"not-installed",message:t.message||"Ollama is not installed"}:e.ok?{_tag:"started"}:{_tag:"error",message:"Failed to start Ollama"}},catch:e=>new s.uV({message:"start ollama failed",cause:e})});if("not-installed"===n._tag)return{_tag:"not-installed",message:n.message};if("error"===n._tag)return{_tag:"error",message:n.message};let o=yield*I();return"not-running"===o._tag?{_tag:"error",message:o.reason??t.reason??"Ollama started but cannot fetch models"}:o}),F=e=>r.$mh({try:async()=>{let t=await fetch(`/api/file?path=${encodeURIComponent(e)}`),n=await t.json();if(!t.ok)throw Error(n.error||`HTTP ${t.status}`);return n},catch:e=>new s.uV({message:e instanceof Error?e.message:"Failed to read file",cause:e})}),$=(e,t)=>i("/api/session-context",{cwd:e,sessionId:t}),D=(e,t)=>i("/api/session-context",{cwd:e,sessionId:t,summary:!0}),_=()=>l("/api/claude-stats"),B=e=>Array.isArray(e.items),O=()=>l("/api/instructions/config?scope=global"),H=e=>l(`/api/instructions/config?cwd=${encodeURIComponent(e)}`),V=e=>i("/api/instructions/config",e)},83897:(e,t,n)=>{n.d(t,{k_:()=>l,nH:()=>i});var r=n(95155),s=n(12115),o=n(48347);let a=(0,s.createContext)(null);function l({children:e}){let t=(0,s.useRef)(new Map),n=(0,s.useRef)(null),[i,d]=(0,s.useState)(()=>new Set),c=i.size>0,u=(0,s.useCallback)((e,t)=>{d(n=>{if(t===n.has(e))return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),m=(0,s.useCallback)((e,n)=>{t.current.set(n,e)},[]),h=(0,s.useCallback)(e=>{t.current.delete(e),d(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),p=(0,s.useCallback)(e=>{n.current=e},[]),f=(0,s.useCallback)(e=>{let r=n.current;if(!r)return void console.warn("No active tab to send message");let s=t.current.get(r);s?s(e):console.warn(`No chat sender registered for tab ${r}`)},[]),g=(0,s.useCallback)((e,n)=>{let r=t.current.get(e);return r?(r(n),!0):(console.warn(`No chat sender registered for tab ${e}`),!1)},[]),x=(0,s.useMemo)(()=>({sendMessage:f,sendToTab:g,isLoading:c,registerChat:m,unregisterChat:h,setActiveTab:p,setChatLoading:u}),[f,g,c,m,h,p,u]),b=(0,s.useMemo)(()=>({sendMessage:f,isLoading:c}),[f,c]);return(0,r.jsx)(a.Provider,{value:x,children:(0,r.jsx)(o.H,{value:b,children:e})})}function i(){return(0,s.useContext)(a)}},84230:(e,t,n)=>{n.d(t,{F:()=>l,T:()=>i});var r=n(49433),s=n(33440);let o=new Map,a=e=>r.qIB(r.ivC(()=>e.done),e=>e),l=(e,t)=>r.DYE(()=>{let n=o.get(e);return n?r.TjK(a(n),e=>structuredClone(e)):r.qIB(r.fA(),n=>{let r={startedAt:Date.now(),done:s.Np(n)(t)};return o.set(e,r),r.done.then(()=>{o.get(e)===r&&o.delete(e)}),a(r)})}),i=(e,t=1/0)=>{for(let[n,r]of o)n.startsWith(e)&&r.startedAt<t&&o.delete(n)}},84444:(e,t,n)=>{n.d(t,{H:()=>s});let r=e=>"unread"===e?0:"loading"===e?1:2;function s(e){return[...e].sort((e,t)=>r(e.status)-r(t.status)||t.lastActive-e.lastActive)}},85269:(e,t,n)=>{n.d(t,{O:()=>m});var r=n(95155),s=n(12115),o=n(48347),a=n(89109),l=n(7320),i=n(34582),d=n(1058),c=n(90717),u=n(69809);function m({content:e,filePath:t,cwd:n,onContentSearch:h,reloadKey:p=0}){let f=(0,o.r)(),g=!!n,x=(0,s.useMemo)(()=>{if((0,i.qF)(t,n))return{mode:"url",url:(0,i.Xe)(t,n)};let r=e??"",s=(0,i.J4)(t,n),o="https:"===window.location.protocol?"wss:":"ws:",a=`${o}//${window.location.host}/ws/bash?cwd=${encodeURIComponent(s)}`;return{mode:"srcdoc",html:(0,i.OP)(r,{cwd:s,wsUrl:a})}},[e,t,n]),{addComment:b,refresh:v}=(0,d._)({cwd:n||"",filePath:t}),[y,w]=(0,s.useState)(null),k=(0,s.useRef)(null),C=(0,s.useRef)(null),j=(0,s.useRef)(()=>{}),[N,S]=(0,s.useState)(null),[T,E]=(0,s.useState)(null),R=(0,s.useRef)(!1);(0,s.useEffect)(()=>{R.current=!!(N||T)},[N,T]);let M=(0,s.useCallback)(()=>{C.current&&(C.current=null,j.current())},[]),L=(0,s.useCallback)(()=>{let e=k.current,t=e?.contentWindow;if(t){let e=document.documentElement.classList.contains("dark");t.postMessage({type:"THEME_CHANGE",theme:e?"dark":"light"},"*"),t.postMessage({type:"cockpit:language-change",lang:u.A.language},"*")}if(!g)return;let n=e?.contentDocument;e&&n&&(n.addEventListener("mouseup",t=>{if(R.current)return;let n=e.contentWindow?.getSelection(),r=n&&!n.isCollapsed?n.toString().trim():"";if(!r)return void M();let s=e.getBoundingClientRect();C.current={x:s.left+t.clientX,y:s.top+t.clientY,range:{start:0,end:0},selectedText:r,lineSnapshot:r},j.current()}),n.addEventListener("mousedown",()=>{M(),S(null),E(null)}),n.addEventListener("scroll",()=>M(),{capture:!0,passive:!0}))},[g,M]),I=(0,s.useCallback)(()=>{let e=C.current;e&&(S({x:e.x,y:e.y,text:e.selectedText}),M(),k.current?.contentWindow?.getSelection()?.removeAllRanges())},[M]),A=(0,s.useCallback)(()=>{let e=C.current;e&&(E({x:e.x,y:e.y,text:e.selectedText}),M(),k.current?.contentWindow?.getSelection()?.removeAllRanges())},[M]),P=(0,s.useCallback)(()=>{let e=C.current;e&&f&&(M(),k.current?.contentWindow?.getSelection()?.removeAllRanges(),(0,c.Ff)(f.sendMessage,{filePath:t,startLine:0,endLine:0,codeContent:e.selectedText},u.A.t("explain.selectionMessage")))},[f,t,M]),F=(0,s.useCallback)(()=>{let e=C.current;if(!e||!h)return;let t=e.selectedText.trim();M(),k.current?.contentWindow?.getSelection()?.removeAllRanges(),t&&h(t)},[h,M]),$=(0,s.useCallback)(async e=>{N&&(await b(0,0,e,N.text),S(null))},[N,b]),D=(0,s.useCallback)(async(e,r)=>{if(f&&n)try{let s=(await (0,c.$3)(n)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));s.push({filePath:t,startLine:0,endLine:0,codeContent:e});let o=(0,c.Gw)(s,r);f.sendMessage(o),await (0,c.RP)(n),v()}catch(e){console.error("[HtmlAppFrame] send to AI failed:",e)}},[f,n,t,v]),_=(0,s.useCallback)(e=>{T&&D(T.text,e)},[T,D]),B=(0,s.useCallback)(e=>{N&&D(N.text,e)},[N,D]);return(0,r.jsxs)("div",{ref:w,className:"relative h-full w-full bg-white",children:[(0,r.jsx)("iframe",{ref:k,..."url"===x.mode?{src:x.url}:{srcDoc:x.html},title:t,className:"h-full w-full border-0",onLoad:L},`${t}:${p}`),g&&y&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.fS,{floatingToolbarRef:C,bumpRef:j,container:y,onAddComment:I,onSendToAI:A,onSearch:h?F:void 0,onExplain:f?P:void 0,isChatLoading:f?.isLoading}),N&&(0,r.jsx)(l.t,{x:N.x,y:N.y,range:{start:0,end:0},filePath:t,lineSnapshot:N.text,container:y,onSubmit:$,onSendToAI:f?B:void 0,onClose:()=>S(null),isChatLoading:f?.isLoading}),T&&(0,r.jsx)(l.G,{x:T.x,y:T.y,range:{start:0,end:0},filePath:t,lineSnapshot:T.text,container:y,onSubmit:_,onClose:()=>E(null),isChatLoading:f?.isLoading})]})]})}},86304:(e,t,n)=>{n.d(t,{P:()=>d});var r=n(12115),s=n(79114),o=n(34075),a=n(86957),l=n(63040),i=n(63563);function d(){let{t:e}=(0,s.Bd)();return(0,r.useCallback)(async t=>{let n=await a.t4.runPromiseExit((0,l.ot)(t));if("Success"===n._tag)n.value.alreadyExists?(0,o.oR)(e("htmlApps.alreadyAdded"),"info"):((0,o.oR)(e("htmlApps.added"),"success"),(0,i.N)());else{let t="Fail"===n.cause._tag?n.cause.error:null,r=t?.cause,s=r instanceof Error?r.message:e("htmlApps.addFailed");(0,o.oR)(s,"error")}},[e])}},86511:(e,t,n)=>{n.d(t,{nl:()=>a});let r=/^\[Sent from Cockpit session (\/project\?\S+) \((.*)\) via @mention(?: · input ([\w-]+))?\]$/,s=/^\[Sent via @mention from another Cockpit session(?: · input ([\w-]+))?\]$/,o=/^\[Delegated from Cockpit session (\/project\?\S+) \((.*)\)\]$/;function a(e){let t=e.split("\n"),n=t[0]??"",a=n.match(r),l=a?null:n.match(s);if(a||l){let e=a?.[3]??l?.[1];return{kind:"sent",link:a?.[1]??null,project:a?.[2]??null,body:t.slice(1).join("\n").replace(/^\n+/,""),...e&&{inputId:e}}}let i=t.findIndex((e,t)=>t<=1&&o.test(e));if(-1===i)return null;let d=t[i].match(o);return{kind:"delegated",link:d[1],project:d[2],body:[...t.slice(0,i),...t.slice(i+1)].join("\n").replace(/^\n+/,"")}}},86957:(e,t,n)=>{n.d(t,{t4:()=>_});var r=n(59257),s=n(74565),o=n(49433),a=n(93404),l=n(22484),i=n(41463);let d=r.Um(l.j9,l.dl((e=>{switch((e??"").toLowerCase()){case"all":return a.u8;case"trace":return a.Cn;case"debug":return a.y;case"info":default:return a.R2;case"warning":case"warn":return a.N5;case"error":return a.$D;case"fatal":return a.Lj;case"none":return a.NV}})(i.env.COCKPIT_LOG_LEVEL)));var c=n(80905),u=n(98953);let m=globalThis,h=m.__cockpitSpanRing??={buffer:[],index:new Map},p=e=>{let t="abcdef0123456789",n="";for(let r=0;r<e;r++)n+=t.charAt(Math.floor(Math.random()*t.length));return n};class f{constructor(e,t,n,r,s,o){this.name=e,this.parent=t,this.context=n,this.startTime=s,this.kind=o,this._tag="Span",this.sampled=!0,this.attributes=new Map,this.events=[],this.traceId=c.Ru(t)?t.value.traceId:p(32),this.spanId=p(16),this.status={_tag:"Started",startTime:s},this.links=Array.from(r),function(e){if(h.buffer.push(e),h.index.set(e.spanId,h.buffer.length-1),h.buffer.length>500){h.buffer.shift(),h.index.clear();for(let e=0;e<h.buffer.length;e++)h.index.set(h.buffer[e].spanId,e)}}(function(e,t,n,r,s,o){return{traceId:t,spanId:e,parentSpanId:n,name:r,kind:s,startTimeNs:o.toString(),endTimeNs:null,durationMs:null,attributes:{},events:[],status:"started"}}(this.spanId,this.traceId,function(e){return c.Ru(e)?e.value.spanId:null}(t),e,o,s))}end(e,t){this.status={_tag:"Ended",endTime:e,exit:t,startTime:this.status.startTime},function(e,t,n){let r=h.index.get(e);if(void 0===r)return;let s=h.buffer[r];if(!s)return;let o=Number(t-BigInt(s.startTimeNs))/1e6;h.buffer[r]={...s,endTimeNs:t.toString(),durationMs:Math.round(100*o)/100,status:"Success"===n._tag?"ok":"error",errorMessage:"Failure"===n._tag?function(e){if(e instanceof Error)return e.message;if("string"==typeof e)return e;try{return JSON.stringify(e)}catch{return String(e)}}(n.cause):void 0}}(this.spanId,e,"Success"===t._tag?{_tag:"Success"}:{_tag:"Failure",cause:t.cause})}attribute(e,t){this.attributes.set(e,t),function(e,t,n){let r=h.index.get(e);if(void 0===r)return;let s=h.buffer[r];s&&(h.buffer[r]={...s,attributes:{...s.attributes,[t]:n}})}(this.spanId,e,t)}event(e,t,n){this.events.push([e,t,n??{}]),function(e,t,n,r){let s=h.index.get(e);if(void 0===s)return;let o=h.buffer[s];o&&(h.buffer[s]={...o,events:[...o.events,{name:t,timeNs:n.toString(),attributes:r}]})}(this.spanId,e,t,n)}addLinks(e){this.links.push(...e)}}let g=u.L8({span:(e,t,n,r,s,o)=>new f(e,t,n,r,s,o),context:e=>e()}),x=r.Py(u.sh,g);r.Ie;var b=n(63400),v=n(41463);let y=b.eu("dev","prod")("COCKPIT_ENV").pipe(b.IQ("prod")),w=b.Yj("COCKPIT_HOST").pipe(b.IQ("127.0.0.1")),k=b.nd("COCKPIT_PORT").pipe(b.NW(()=>b.nd("PORT")),b.IQ(3457)),C=b.uK(b.Yj("COCKPIT_OPEN_PROJECT")).pipe(b.Tj(e=>"Some"===e._tag?e.value:void 0)),j=b.zM("COCKPIT_NO_OPEN").pipe(b.IQ(!1)),N=b.Yj("COCKPIT_LOG_LEVEL").pipe(b.IQ("info")),S=b.nd("COCKPIT_SNAPSHOT_KEEP_DAYS").pipe(b.IQ(7)),T=b.nd("COCKPIT_SNAPSHOT_REPO_TTL_DAYS").pipe(b.IQ(30)),E=b.nd("COCKPIT_SNAPSHOT_MAX_FILE_KB").pipe(b.IQ(2048)),R=b.nd("COCKPIT_SESSION_KEEP_DAYS").pipe(b.IQ(30)),M=b.nd("COCKPIT_DELEGATE_MAX").pipe(b.tf({message:"COCKPIT_DELEGATE_MAX must be >= 1",validation:e=>e>=1}),b.IQ(10));o.JkU(function*(){let e=yield*y,t=yield*w,n=yield*k,r=yield*C,s=yield*j,a=yield*N,l=yield*S,i=yield*T,d=yield*E,c=yield*R,u=yield*M,m=yield*o.OH5(()=>{let e=void 0!==v?v.env:void 0,t=e?.HOME||e?.USERPROFILE||".",n=e?.COCKPIT_HOME;return n?n.replace(/^~(?=$|\/)/,t):t+"/.cockpit"});return{env:e,host:t,port:3457===n&&"dev"===e?3456:n,cockpitDir:m,openProject:r,openBrowser:!s,logLevel:a,logFile:m+"/logs/cockpit.log",snapshotKeepDays:l,snapshotRepoTtlDays:i,snapshotMaxFileKb:d,sessionKeepDays:c,delegateMaxConcurrent:u}}).pipe(o.QgK);let L=r.Ie;var I=n(38147),A=n(23363),P=n(88292);let F=r.P1(P.d,o.JkU(function*(){let e=yield*I.dT();return yield*o.Q56(o.OH5(()=>{let t=t=>{o.MY7(I.mk(e,t))};return window.addEventListener("message",t),t}),e=>o.OH5(()=>{window.removeEventListener("message",e)})),P.d.of({publish:(e,t)=>o.OH5(()=>{let n={type:e.legacyType,topic:e.id,msg:t,..."object"==typeof t&&null!==t?t:{}};window.parent.postMessage(n,"*")}),subscribe:t=>A.qdp(e).pipe(A.pbD(e=>{var n;return n=e.data,!!n&&"object"==typeof n&&(n.topic===t.id||n.type===t.legacyType)}),A.TjK(e=>((e,t)=>{if(e.topic===t.id)return e.msg;let{type:n,...r}=e;return r})(e.data,t)))})})),$=r.Um(d,x,L),D=r.Um($,F),_=s.L8(D);o.rIH},88292:(e,t,n)=>{n.d(t,{R:()=>s,d:()=>o});var r=n(50995);let s=(e,t)=>({id:e,legacyType:t??e.replace(/-/g,"_").toUpperCase()}),o=r.Io("@cockpit/IframeBus")},88403:(e,t,n)=>{n.d(t,{Q:()=>l});var r=n(23348),s=n(33442),o=n(51536);let a={add:r.zB,notify:s._,namespace:"bots",failureKey:"bots.saveFailed"},l=()=>(0,o.X)(a)},88780:(e,t,n)=>{n.d(t,{Do:()=>h,Sz:()=>p,VO:()=>m,WY:()=>x,ab:()=>g,wI:()=>f});var r=n(95155),s=n(12115),o=n(79114),a=n(14575),l=n(72312),i=n(70188),d=n(52839);function c({status:e}){let{label:t,className:n}={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,r.jsx)("span",{className:`text-xs font-bold ${n}`,children:t})}let u=s.memo(function e({node:t,level:n,selectedPath:o,expandedPaths:i,onSelect:u,onToggle:m,onContextMenu:h,showChanges:p=!1,showChangeClass:f=!1,hideIndicatorsOnHover:g=!1,renderActions:x}){let b,v=o===t.path,y=i.has(t.path),w=(0,s.useCallback)(()=>{t.isDirectory?m(t.path):u(t)},[t,u,m]),k=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),h(e,t.path,t.isDirectory)},[t.path,t.isDirectory,h]);return t.isDirectory?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-hover cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*n+8}px`},onClick:w,onContextMenu:k,children:[(0,r.jsx)("span",{className:"text-foreground-subtle text-xs",children:y?"▼":"▶"}),(0,r.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":t.path,children:t.name}),x&&x(t)]}),y&&t.children.map(t=>(0,r.jsx)(e,{node:t,level:n+1,selectedPath:o,expandedPaths:i,onSelect:u,onToggle:m,onContextMenu:h,showChanges:p,showChangeClass:f,hideIndicatorsOnHover:g,renderActions:x},t.path))]}):(0,r.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${v?"bg-brand/10":"hover:bg-hover"}`,style:{paddingLeft:`${12*n+8}px`},onClick:w,onContextMenu:k,children:[(0,r.jsx)(a.o,{name:t.name,size:16,className:"flex-shrink-0"}),(0,r.jsx)("span",{className:`text-sm flex-1 truncate ${v?"text-brand":"text-foreground"}`,"data-tooltip":t.path,children:t.name}),f&&((b=(0,d.q)(t.path))?(0,r.jsx)("span",{className:g?"group-hover:hidden":void 0,children:(0,r.jsx)(l.N,{cls:b})}):null),x&&x(t),t.status&&(0,r.jsx)("span",{className:g?"group-hover:hidden":void 0,children:(0,r.jsx)(c,{status:t.status})}),p&&void 0!==t.additions&&void 0!==t.deletions&&(0,r.jsxs)("span",{className:`contents ${g?"group-hover:hidden":""}`,children:[(0,r.jsxs)("span",{className:"text-xs text-green-11",children:["+",t.additions]}),(0,r.jsxs)("span",{className:"text-xs text-red-11",children:["-",t.deletions]})]})]})});function m({files:e,selectedPath:t,expandedPaths:n,onSelect:s,onToggle:a,cwd:l,showChanges:d=!1,showChangeClass:c=!1,hideIndicatorsOnHover:h=!1,renderActions:p,emptyMessage:f,className:g,onExplain:x,explainDisabled:b}){let{t:v}=(0,o.Bd)(),y=f??v("gitFileTree.noFiles"),{contextMenu:w,showContextMenu:k,hideContextMenu:C}=(0,i.Ee)();return 0===e.length?(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-foreground-subtle",children:y}):(0,r.jsxs)("div",{className:g||"py-1",children:[e.map(e=>(0,r.jsx)(u,{node:e,level:0,selectedPath:t,expandedPaths:n,onSelect:s,onToggle:a,onContextMenu:k,showChanges:d,showChangeClass:c,hideIndicatorsOnHover:h,renderActions:p},e.path)),w&&(0,r.jsx)(i.ft,{x:w.x,y:w.y,path:w.path,cwd:l,isDirectory:w.isDirectory,onClose:C,onExplain:x,explainDisabled:b})]})}function h(e){let t=[];for(let n of e){let e=n.path.split("/"),r=t;for(let t=0;t<e.length;t++){let s=e[t],o=t===e.length-1,a=e.slice(0,t+1).join("/"),l=r.find(e=>e.name===s);l||(l={name:s,path:a,isDirectory:!o,children:[],...o&&{status:n.status,additions:n.additions,deletions:n.deletions,oldPath:n.oldPath,file:n}},r.push(l)),o||(r=l.children)}}let n=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>n(e.children))};return n(t),t}function p(e){let t=[],n=e=>{for(let r of e)r.isDirectory&&(t.push(r.path),n(r.children))};return n(e),t}function f(e){let t=[],n=e=>{if(e.isDirectory)for(let t of e.children)n(t);else t.push(e)};return n(e),t}let g=s.memo(function({files:e,className:t=""}){let{additions:n,deletions:o}=(0,s.useMemo)(()=>(function(e){let t=0,n=0;for(let r of e)t+=r.additions??0,n+=r.deletions??0;return{additions:t,deletions:n}})(e),[e]);return(0,r.jsxs)("span",{className:`flex flex-shrink-0 items-center gap-1.5 text-xs tabular-nums ${t}`,children:[(0,r.jsxs)("span",{className:"text-green-11",children:["+",n]}),(0,r.jsxs)("span",{className:"text-red-11",children:["-",o]})]})}),x=s.memo(function({files:e,label:t}){let{t:n}=(0,o.Bd)();return(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:t??n("fileBrowser.nFilesChangedPlain",{count:e.length})}),(0,r.jsx)(g,{files:e})]})})},89109:(e,t,n)=>{n.d(t,{SZ:()=>a,fS:()=>d});var r=n(95155),s=n(12115),o=n(79114);let a=[["quickReply.optionA","quickReply.optionB","quickReply.optionC","quickReply.optionD"],["quickReply.allRecommended","quickReply.thisOne","quickReply.notThis"],["quickReply.why","quickReply.elaborate","quickReply.example"],["quickReply.start","quickReply.continue","quickReply.ok","quickReply.done"]];function l({rows:e,placeAbove:t,onHeight:n,onPick:a,onEdit:i,onMouseEnter:d,onMouseLeave:c}){let{t:u}=(0,o.Bd)(),m=(0,s.useRef)(null);return(0,s.useEffect)(()=>{m.current&&n(m.current.getBoundingClientRect().height)},[n,e]),(0,r.jsxs)("div",{ref:m,className:`absolute ${t?"bottom-full mb-1":"top-full mt-1"} left-0 z-[201] flex flex-col gap-1 bg-card border border-border rounded-lg shadow-lv3 p-1.5`,onMouseEnter:d,onMouseLeave:c,children:[i&&(0,r.jsx)("button",{className:"absolute top-0.5 right-0.5 p-1 text-muted-foreground hover:text-brand transition-colors",onClick:i,title:u("quickReply.edit"),"aria-label":u("quickReply.edit"),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),e.map((e,t)=>(0,r.jsx)("div",{className:`flex items-center gap-1${i&&0===t?" pr-5":""}`,children:e.map((e,n)=>(0,r.jsx)("button",{className:"px-2 py-1 text-xs whitespace-nowrap border border-border text-foreground rounded hover:border-brand hover:bg-hover transition-colors",onClick:()=>a(e),children:e},`${t}:${n}:${e}`))},t))]})}function i({x:e,y:t,visible:n,container:d,onAddComment:c,onSendToAI:u,onSearch:m,onExplain:h,onQuickReply:p,quickReplyRows:f,onEditQuickReplies:g,isChatLoading:x}){let{t:b}=(0,o.Bd)(),v=(0,s.useRef)(null),[y,w]=(0,s.useState)({w:0,h:0}),[k,C]=(0,s.useState)(0),[j,N]=(0,s.useState)(null),S=(0,s.useRef)(null);(0,s.useLayoutEffect)(()=>{let e=v.current;if(!e)return;let{width:t,height:n}=e.getBoundingClientRect();w(e=>e.w===t&&e.h===n?e:{w:t,h:n})});let T=(0,s.useCallback)(e=>{C(t=>t===e?t:e)},[]);(0,s.useEffect)(()=>{n||N(null)},[n]);let E=(0,s.useCallback)(()=>{S.current&&(clearTimeout(S.current),S.current=null)},[]),R=(0,s.useCallback)(e=>{E(),N(e)},[E]),M=(0,s.useCallback)(()=>{E(),S.current=setTimeout(()=>N(null),150)},[E]);(0,s.useEffect)(()=>E,[E]);let L=d.getBoundingClientRect(),I=e-L.left,A=Math.max(0,t-L.top-40),P=Math.max(0,Math.min(I+8,L.width-y.w-8)),F=k>0&&A+y.h+8+k>L.height,$=(0,s.useMemo)(()=>f??a.map(e=>e.map(e=>b(e))),[f,b]),D=e=>p&&j===e?(0,r.jsx)(l,{rows:$,onEdit:g,placeAbove:F,onHeight:T,onPick:t=>{N(null),p(e,t)},onMouseEnter:E,onMouseLeave:M}):null;return(0,r.jsxs)("div",{ref:v,className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-lv3 p-1.5",style:{left:P,top:A,visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none"},children:[(0,r.jsxs)("div",{className:"relative",onMouseEnter:()=>R("comment"),onMouseLeave:M,children:[(0,r.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:c,children:b("floatingToolbar.addComment")}),D("comment")]}),(0,r.jsxs)("div",{className:"relative",onMouseEnter:()=>{x||R("ai")},onMouseLeave:M,children:[(0,r.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:u,disabled:x,title:x?b("comments.aiResponding"):void 0,children:b("floatingToolbar.sendToAI")}),D("ai")]}),h&&(0,r.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:h,disabled:x,title:x?b("comments.aiResponding"):void 0,children:b("explain.action")}),m&&(0,r.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:m,children:b("floatingToolbar.search")})]})}let d=(0,s.memo)(function({floatingToolbarRef:e,bumpRef:t,container:n,onAddComment:o,onSendToAI:a,onSearch:l,onExplain:d,onQuickReply:c,quickReplyRows:u,onEditQuickReplies:m,isChatLoading:h}){let[p,f]=(0,s.useState)(0);(0,s.useEffect)(()=>{t.current=()=>f(e=>e+1)},[t]);let g=(0,s.useMemo)(()=>e.current,[p]);return(0,r.jsx)(i,{x:g?.x??0,y:g?.y??0,visible:!!g,container:n,onAddComment:o,onSendToAI:a,onSearch:l,onExplain:d,onQuickReply:c,quickReplyRows:u,onEditQuickReplies:m,isChatLoading:h})})},90717:(e,t,n)=>{n.d(t,{$3:()=>u,Cm:()=>c,Ff:()=>f,Gw:()=>p,RP:()=>m,Un:()=>h,zL:()=>d});var r=n(69809),s=n(49433),o=n(86957),a=n(82680),l=n(46456);let i=new Set;function d(e){return i.add(e),()=>i.delete(e)}function c(){i.forEach(e=>e())}async function u(e){let t=await o.t4.runPromiseExit((0,l.lb)(e));if("Success"!==t._tag)throw Error("Failed to fetch comments");let n=t.value.comments??[];if(0===n.length)return[];let r=new Map;for(let e of n)e.selectedText||(r.has(e.filePath)||r.set(e.filePath,[]),r.get(e.filePath).push(e));let i=new Map;await Promise.all(Array.from(r.keys()).map(async t=>{let n=await o.t4.runPromiseExit(s.$mh({try:async()=>{let n=await fetch(`/api/files/text?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`);return n.ok?await n.json():null},catch:e=>new a.uV({message:`read file text ${t} failed`,cause:e})}));"Success"===n._tag&&n.value&&"string"==typeof n.value.content?i.set(t,n.value.content.split("\n")):"Failure"===n._tag&&console.error(`Failed to read file ${t}:`,n.cause)}));let d=[];for(let e of n){if(e.selectedText){d.push({...e,codeContent:e.selectedText});continue}let t=i.get(e.filePath),n="";if(t){let r=Math.max(0,e.startLine-1),s=Math.min(t.length,e.endLine);n=t.slice(r,s).join("\n")}d.push({...e,codeContent:n})}return d}async function m(e){let t=await o.t4.runPromiseExit((0,l.tj)(e));return"Success"===t._tag?(c(),!0):(console.error("Failed to clear comments:",t.cause),!1)}let h="__chat__";function p(e,t){let n=e.filter(e=>e.filePath===h),s=e.filter(e=>e.filePath!==h),o=[];for(let e of(s.length>0&&(o.push(`${r.A.t("comments.codeRef")}`,""),s.forEach((e,t)=>{let n=e.startLine>0||e.endLine>0?`:${e.startLine}-${e.endLine}`:"";o.push(`[${t+1}] ${e.filePath}${n}`),o.push("```"),o.push(e.codeContent),o.push("```"),e.note&&o.push(r.A.t("comments.note",{content:e.note})),o.push("")})),n)){let t=e.codeContent.split("\n").map(e=>`> ${e}`).join("\n");o.push(t),e.note&&o.push(e.note),o.push("")}if(t.trim()){for(;o.length>0&&""===o[o.length-1];)o.pop();o.push(t.trim())}return o.join("\n").trim()}function f(e,t,n){e(p([t],n))}},92689:(e,t,n)=>{n.d(t,{S:()=>o});var r=n(95155),s=n(57125);function o({engine:e,tooltip:t,size:n="md"}){let a=e||"claude";return(0,s.ch)(a)?(0,r.jsx)("span",{className:"shrink-0 inline-flex items-center","data-tooltip":t??s.H[a],children:(0,r.jsx)(s.eV,{engine:a,className:"sm"===n?"h-3 w-3":"h-3.5 w-3.5"})}):(0,r.jsx)("span",{className:"shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded bg-muted text-muted-foreground","data-tooltip":t??a,children:a})}},93964:(e,t,n)=>{n.d(t,{N:()=>o});var r=n(84230);let s=e=>"u"<typeof BroadcastChannel?null:new BroadcastChannel(e),o=(e,t)=>({notify:()=>{let t=s(e);if(t)try{t.postMessage({type:"changed",at:Date.now()})}finally{t.close()}},subscribe:n=>{let o=s(e);if(!o)return()=>void 0;let a=e=>{if(e.data?.type==="changed"){if(t){let n="number"==typeof e.data.at?e.data.at:Date.now();for(let e of"string"==typeof t?[t]:t)(0,r.T)(e,n)}n()}};return o.addEventListener("message",a),()=>{o.removeEventListener("message",a),o.close()}}})},94287:(e,t,n)=>{n.d(t,{m:()=>o});var r=n(95155),s=n(12115);function o({content:e,children:t,className:n}){if(n)return(0,r.jsx)("div",{"data-tooltip":e,className:n,children:t});let a=s.Children.toArray(t);if(1===a.length&&(0,s.isValidElement)(a[0])){let t=a[0];return(0,s.cloneElement)(t,{"data-tooltip":e})}return(0,r.jsx)("div",{"data-tooltip":e,style:{display:"contents"},children:t})}},95045:(e,t,n)=>{n.d(t,{F:()=>a});var r=n(49433),s=n(88292),o=n(86957);let a=(e,t)=>{o.t4.runFork(r.qIB(s.d,n=>n.publish(e,t)))}},95272:(e,t,n)=>{n.d(t,{Q:()=>s,X:()=>o});var r=n(41948);function s(e,t){return(0,r.l)(e).filter(e=>!e.some(e=>e.sourceId&&t.sourceIds.includes(e.sourceId)||e.sourceTaskId&&t.taskIds.includes(e.sourceTaskId))).flat().map(e=>{let n=e.sourceId&&t.sourceRemap?.[e.sourceId];return n?{...e,sourceId:n}:e})}function o(e){return e?.type==="error"&&Array.isArray(e.undeliveredInputs)&&e.undeliveredInputs.length>0||e?.type==="system"&&"input_binding"===e.subtype&&"string"==typeof e.inputId&&"string"==typeof e.sourceId}},95595:(e,t,n)=>{n.d(t,{M7:()=>a,ZL:()=>s,yR:()=>r});let r="grok-4.7",s="high",o=[{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra High"}],a={defaultModel:r,models:[{id:"grok-4.7",label:"Grok 4.7"},{id:"grok-4.6",label:"Grok 4.6"},{id:"grok-4.5",label:"Grok 4.5"}].map(e=>({...e,reasoning:o,defaultReasoning:s}))}},95686:(e,t,n)=>{n.d(t,{x:()=>i});var r=n(95155),s=n(12115),o=n(64428),a=n(70188),l=n(5135);function i({filePath:e,content:t,cwd:n,onClose:d,zClassName:c="z-50"}){let[u,m]=(0,s.useState)(null);return(0,r.jsx)(o.ZL,{children:(0,r.jsx)("div",{className:`fixed inset-0 ${c} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:d,children:(0,r.jsx)("div",{ref:m,className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(a.SU,{container:u,children:(0,r.jsx)(l.M,{content:t,filePath:e,cwd:n,onClose:d})})})})})}},96497:(e,t,n)=>{function r(e,t){let n,r=document.caretRangeFromPoint(e.clientX,e.clientY);if(!r||!t.contains(r.startContainer))return 1;let s=r.startContainer,o=r.startOffset,a=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),l=1;for(;n=a.nextNode();){if(n===s){l+=o;break}l+=n.textContent?.length||0}return l}function s(e,t){if(0!==e.buttons)return null;let n=window.getSelection();if(n&&!n.isCollapsed)return null;let s=e.target;if("SPAN"!==s.tagName||!s.style.color)return null;let o=s.getBoundingClientRect();return{column:r(e,t),rect:{x:o.left,y:o.bottom+4}}}n.d(t,{A:()=>s,j:()=>r})},97251:(e,t,n)=>{n.d(t,{W:()=>o});var r=n(48250);let s=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","table","tr","hr","div","ul","ol"]);function o(){return e=>{(0,r.YR)(e,"element",e=>{if(s.has(e.tagName)&&e.position&&(e.properties||(e.properties={}),e.properties["data-source-start"]=e.position.start.line,e.properties["data-source-end"]=e.position.end.line,"pre"===e.tagName)){let t=e.children?.find(e=>"element"===e.type&&"code"===e.tagName);t&&(t.properties||(t.properties={}),t.properties["data-source-start"]=e.position.start.line,t.properties["data-source-end"]=e.position.end.line)}})}}},97488:(e,t,n)=>{n.d(t,{Z:()=>c});var r=n(95155),s=n(12115),o=n(64428),a=n(57125),l=n(86957),i=n(83448);let d={deepseek:{label:"DeepSeek",apiKeysUrl:"https://platform.deepseek.com/api_keys",modelsEndpoint:"/v1/models"},kimi:{label:"Kimi",apiKeysUrl:"https://www.kimi.com/code/console",modelsEndpoint:"/coding/v1/models"},glm:{label:"GLM",apiKeysUrl:"https://bigmodel.cn/apikey/platform",modelsEndpoint:"/coding/paas/v4/models",regions:[{id:"cn",label:"中国大陆",hint:"open.bigmodel.cn"},{id:"global",label:"International",hint:"api.z.ai"}]}};function c({engine:e,currentModel:t,onModelChange:n,onHasKeyChange:u}){let m=d[e],[h,p]=(0,s.useState)(!1),[f,g]=(0,s.useState)(!1),[x,b]=(0,s.useState)(""),[v,y]=(0,s.useState)(""),[w,k]=(0,s.useState)(!1),[C,j]=(0,s.useState)(!1),[N,S]=(0,s.useState)(!1),[T,E]=(0,s.useState)(null),[R,M]=(0,s.useState)(!1),[L,I]=(0,s.useState)([]),[A,P]=(0,s.useState)(null),[F,$]=(0,s.useState)(null),D=(0,s.useRef)(null),_=(0,s.useRef)(null),B=(0,s.useRef)(null),O=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{O.current&&clearTimeout(O.current)},[]);let H=(0,s.useRef)(t),V=(0,s.useRef)(n),U=(0,s.useRef)(u);(0,s.useEffect)(()=>{H.current=t,V.current=n,U.current=u}),(0,s.useEffect)(()=>{U.current?.(f)},[f]);let[W,q]=(0,s.useState)({top:0,left:0});(0,a.r8)(_,h,W.left);let z=(0,o.F2)();(0,s.useEffect)(()=>{let t=!1;return(async()=>{let[n,r]=await Promise.all([l.t4.runPromiseExit((0,i.Hw)(e)),l.t4.runPromiseExit((0,i.td)())]);if(t||"Failure"===n._tag)return;g(n.value.hasKey),b(n.value.maskedKey);let s="Success"===r._tag?r.value?.engines?.[e]:void 0,o=s?.builtinModel;!H.current&&o&&V.current(o)})(),()=>{t=!0}},[e]),(0,s.useEffect)(()=>{if(!h)return;let e=e=>{_.current&&!_.current.contains(e.target)&&D.current&&!D.current.contains(e.target)&&p(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[h]);let K=(0,s.useCallback)(async()=>{j(!0),E(null),P(null);let[r,s]=await Promise.all([l.t4.runPromiseExit((0,i.Hw)(e)),l.t4.runPromiseExit((0,i.td)())]);if("Failure"===r._tag){E("Failed to load settings"),j(!1);return}g(r.value.hasKey),b(r.value.maskedKey),y(""),k(!1);let o="Success"===s._tag?s.value:void 0,a=o?.engines?.[e],d=a?.builtinModel;m.regions&&$(a?.region??("en"===o?.language?"global":"cn"));let c=[];if(r.value.hasKey){let t=await l.t4.runPromiseExit((0,i.Fi)(e));"Success"===t._tag?c=t.value.models:P("Failed to load models — check the API key")}I(c);let u=c.map(e=>e.id),h=d&&u.includes(d)?d:u[0];!h||t&&u.includes(t)||n(h),j(!1)},[e,t,n,m.regions]),G=(0,s.useCallback)(async t=>{let n=await l.t4.runPromiseExit((0,i.td)()),r=("Success"===n._tag?n.value:{}).engines||{},s={...r,[e]:{...r[e]||{},builtinModel:t}};if("Failure"===(await l.t4.runPromiseExit((0,i.em)({engines:s})))._tag)throw Error("Failed to save settings")},[e]),Q=(0,s.useCallback)(async t=>{$(t);let n=await l.t4.runPromiseExit((0,i.td)()),r=("Success"===n._tag?n.value:{}).engines||{};"Failure"===(await l.t4.runPromiseExit((0,i.em)({engines:{...r,[e]:{...r[e]||{},region:t}}})))._tag?E("Failed to save region"):K()},[e,K]),J=async()=>{let t=v.trim();if(!t)return;S(!0),E(null);let n=await l.t4.runPromiseExit((0,i.dQ)(e,t));"Failure"===n._tag?E("Save failed"):(g(n.value.hasKey),b(n.value.maskedKey),y(""),k(!1),K()),S(!1)},Y=async()=>{S(!0),E(null);let t=await l.t4.runPromiseExit((0,i.dQ)(e,""));"Failure"===t._tag?E("Clear failed"):(g(t.value.hasKey),b(t.value.maskedKey),y(""),k(!1),I([])),S(!1)},X=async()=>{let t=await l.t4.runPromiseExit((0,i.Ny)(e));if("Failure"===t._tag||!t.value.apiKey)return void E("Copy failed");try{await navigator.clipboard.writeText(t.value.apiKey)}catch{E("Clipboard unavailable");return}E(null),M(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>M(!1),1500)},Z=async e=>{n(e);try{await G(e)}catch{}},ee=f?t||"Select model":"Set API key",et=f?void 0:a.Aw,en=t||"",er=h?(0,r.jsx)(o.ZL,{children:(0,r.jsx)("div",{ref:_,className:`${a.ys} min-w-[280px]`,style:{top:W.top,left:W.left},children:C?(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"px-3 py-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"API Key"}),(0,r.jsx)("a",{href:m.apiKeysUrl,target:"_blank",rel:"noopener","data-testid":`${e}-api-keys-link`,title:`Open ${m.label} API keys page`,"aria-label":`Open ${m.label} API keys page`,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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"})})})]}),f&&!w?(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:x}),(0,r.jsx)("button",{onClick:X,"data-testid":`${e}-copy-api-key`,title:R?"Copied":"Copy API key","aria-label":"Copy API key",className:`p-1 rounded transition-colors ${R?"text-green-11":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,disabled:N,children:R?(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)("button",{onClick:()=>{k(!0),y(""),setTimeout(()=>B.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-hover text-foreground transition-colors",disabled:N,children:"Edit"}),(0,r.jsx)("button",{onClick:Y,className:"text-[11px] px-2 py-1 rounded text-red-11 hover:bg-red-500/10 transition-colors",disabled:N,children:"Clear"})]}):(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{ref:B,type:"password",value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{"Enter"===e.key&&J()},placeholder:"sk-...",className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${a.Fx}`,autoFocus:!0}),(0,r.jsx)("button",{onClick:J,disabled:N||!v.trim(),className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${a.$T}`,children:N?"Saving...":"Save"}),f&&(0,r.jsx)("button",{onClick:()=>{k(!1),y("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),T&&(0,r.jsx)("div",{className:"mt-1 text-[11px] text-red-11",children:T})]}),(0,r.jsx)("div",{className:"my-1 border-t border-border"}),m.regions&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"px-3 py-1.5",children:[(0,r.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Region"}),(0,r.jsx)("div",{className:"inline-flex rounded-md border border-border overflow-hidden text-xs",role:"group","data-testid":`${e}-region-toggle`,children:m.regions.map(t=>(0,r.jsx)("button",{type:"button","data-testid":`${e}-region-${t.id}`,onClick:()=>Q(t.id),title:t.hint,className:`px-2 py-0.5 ${F===t.id?"bg-brand text-white":"bg-transparent text-muted-foreground hover:bg-hover"}`,children:t.label},t.id))})]}),(0,r.jsx)("div",{className:"my-1 border-t border-border"})]}),(0,r.jsxs)("div",{className:"px-3 py-1.5",children:[(0,r.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Model"}),A&&(0,r.jsx)("div",{className:"mb-1 text-[11px] text-red-11",children:A}),!A&&0===L.length&&(0,r.jsx)("div",{className:"mb-1 text-[11px] text-muted-foreground",children:f?`No models returned by ${m.modelsEndpoint}`:"Save an API key to list models"}),(0,r.jsx)("div",{className:"flex flex-col gap-0.5",children:L.map(e=>{var t;let n=en===e.id,s=(t=e.contextTokens)&&!(t<=0)?t>=1048576?`${Math.round(t/1048576)}M`:`${Math.round(t/1024)}K`:null;return(0,r.jsxs)("button",{onClick:()=>Z(e.id),className:`flex items-center gap-2 px-2 py-1 text-xs rounded transition-colors ${n?a.yI:"text-foreground hover:bg-hover"}`,children:[(0,r.jsx)(a.hG,{selected:n}),(0,r.jsx)("span",{className:"truncate",children:e.id}),e.label&&e.label!==e.id&&(0,r.jsx)("span",{className:"truncate text-[10px] text-muted-foreground",children:e.label}),s&&(0,r.jsx)("span",{className:"ml-auto pl-2 text-[10px] text-muted-foreground flex-shrink-0",children:s})]},e.id)})})]})]})})}):null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.XY,{buttonRef:D,label:ee,labelClassName:et,title:`Configure ${m.label}`,onClick:()=>{if(!h){if(D.current){let e=D.current.getBoundingClientRect(),t=z?.getBoundingClientRect(),n=t?.left??0,r=t?.top??0;q({top:e.bottom+4-r,left:e.left-n})}K()}p(e=>!e)},icon:(0,r.jsx)(a.eV,{engine:e}),testId:`${e}-config-picker`}),er]})}},97938:(e,t,n)=>{n.d(t,{z:()=>b,m:()=>w});var r=n(14594),s=n(8183),o=n(12115),a=n(41948),l=n(95272);function i(e,t){let n=new Map(e.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.id);return t&&function e(t,n){if(Object.is(t,n))return!0;if(!t||!n||"object"!=typeof t||"object"!=typeof n)return!1;if(Array.isArray(t)||Array.isArray(n))return Array.isArray(t)&&Array.isArray(n)&&t.length===n.length&&t.every((t,r)=>e(t,n[r]));let r=Object.keys(t);return r.length===Object.keys(n).length&&r.every(r=>Object.hasOwn(n,r)&&e(t[r],n[r]))}(t,e)?t:e});return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r}let d={messages:[],diskTurns:[],runs:[],failures:[],dismissedFailures:[],sessionId:null,totalTurns:0,hasMore:!1,needsStableRead:!1,writerIdle:!1,writerIdleRevision:0};function c(e){let t=e[0],n=t?.turnStartedAt??e.find(e=>"user"===e.role)?.timestamp??t?.timestamp;return n?Date.parse(n):NaN}function u(e,t){if("pending"===e.phase)return;let n=(0,a.l)(e.messages);for(let e of t){let t=n.findIndex(t=>t.some(t=>e.messages.some(e=>t.id===e.id||!!t.sourceId&&t.sourceId===(e.sourceId??e.id)||!!t.sourceTaskId&&t.sourceTaskId===e.sourceTaskId)));if(t>=0)return Math.max(0,e.index-t)}if(e.anchor){let r=e.anchor,s=n.findIndex(e=>e.some(e=>e.id===r.liveId&&(!e.sourceId||e.sourceId===(r.source.sourceId??r.source.id)))),o=t.find(e=>e.messages.some(e=>{var t;return t=r.source,t.sourceId?(e.sourceId??e.id)===t.sourceId:e.id===t.id&&(!t.prefix||e.sourceRef?.prefix===t.prefix)}));if(o&&s>=0)return Math.max(0,o.index-s)}for(let e of t){let t=n.findIndex(t=>t.some(t=>t.toolCalls?.some(t=>e.messages.some(e=>e.toolCalls?.some(e=>e.id===t.id)))));if(t>=0)return Math.max(0,e.index-t)}if(e.messages.some(e=>e.sourceId||e.sourceTaskId)||!Number.isFinite(c(n[0]??[])))return;let r=t.find(t=>c(t.messages)>=e.startedAt);if(!r)return;let s=t.find(e=>e.index===r.index-1);if(0===r.index||s&&c(s.messages)<e.startedAt)return r.index;let o=new Set;for(let r of t.filter(t=>c(t.messages)>=e.startedAt)){let e=r.messages.filter(e=>"user"===e.role);n.forEach((t,n)=>{let s=t.filter(e=>"user"===e.role);e.length&&s.length&&s[0].content===e[0].content&&JSON.stringify(s[0].images)===JSON.stringify(e[0].images)&&o.add(r.index-n)})}return 1===o.size?Math.max(0,[...o][0]):void 0}function m(e,t){return[...e.filter(e=>e.id!==t.id),...t.messages.length?[{id:t.id,startedAt:t.startedAt,messages:t.messages.map(e=>({...e,isStreaming:!1,toolCalls:e.toolCalls?.map(e=>({...e,isLoading:!1}))}))}]:[]]}function h(e){return!(e.terminalError&&"released"===e.phase)}function p(e,t=!1){let n=new Map(e.diskTurns.map(e=>[e.index,e.messages])),r=e.totalTurns,s=e.runs.map((n,s)=>{let o=u(n,e.diskTurns),l=e.runs.slice(0,s).some(e=>!h(e)),i=o??(t||n.anchor||l&&n.start>r?r:n.start),d={...n,start:i,anchor:void 0===o?n.anchor:function(e,t,n){for(let[r,s]of(0,a.l)(e.messages).entries()){let e=s.find(e=>"user"===e.role),o=t.find(e=>e.index===n+r)?.messages.find(e=>"user"===e.role);if(e&&o)return{liveId:e.id,source:o.sourceRef??{id:o.id,sourceId:o.sourceId,prefix:""}}}return e.anchor}(n,e.diskTurns,i)};return h(n)&&(r=Math.max(r,i+(0,a.l)(n.messages).length)),d});for(let e=0;e<s.length;e++){let t=s[e];if(!t.messages.length||!h(t))continue;let r=s.slice(e+1).find(e=>h(e))?.start??1/0;for(let e of n.keys())e>=t.start&&e<r&&n.delete(e);(0,a.l)(t.messages).forEach((e,s)=>{t.start+s<r&&n.set(t.start+s,e)})}let o=[...n.keys()].sort((e,t)=>e-t);if(!o.length)return{...e,runs:s,messages:i(e.messages,[]),startTurnIndex:0,hasMore:!1};let l=o.length-1;for(;l>0&&o[l-1]===o[l]-1;)l--;let d=o[l];return{...e,runs:s,startTurnIndex:d,hasMore:d>0,messages:i(e.messages,o.slice(l).flatMap(e=>n.get(e)))}}var f=n(49433),g=n(86957),x=n(82680);let b=e=>f.$mh({try:async t=>{let n=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:t});return n.ok?await n.json():null},catch:e=>new x.uV({message:"session-by-path failed",cause:e})}),v=new Map;function y(e){let t=e.runs.filter(e=>"released"===e.phase).map(e=>e.id),n=e.needsStableRead&&e.writerIdle&&!e.runs.some(e=>"pending"===e.phase||"active"===e.phase||"draining"===e.phase);return t.length||n?JSON.stringify([t,e.writerIdleRevision]):null}function w(e,{cwd:t,initialSessionId:n,onSessionId:c,onTitleChange:k,onTokenUsage:C,reconcileLimit:j=10,enabled:N=!0,liveRunning:S=!1}){let[T,E]=(0,o.useState)(!1),[R,M]=(0,o.useState)(!1),[L,I]=(0,o.useState)(d),A=(0,o.useRef)(L),P=(0,o.useRef)(new Set),F=(0,o.useRef)(null),$=(0,o.useRef)(null),D=(0,o.useCallback)(e=>{if("run-messages"===e.type){let{runId:t,update:n}=e,s=A.current.runs.find(e=>e.id===t);s&&!s.recovery&&$.current&&"object"==typeof n&&!Array.isArray(n)&&(0,r.az)(n.event)&&$.current.toolUpdates.push(n)}"page"!==e.type||e.fromCache||(e={...e,toolUpdates:$.current?.toolUpdates});let t=function(e,t){if("recovery-dismissed"===t.type)return{...e,dismissedFailures:[...e.dismissedFailures,t.id],failures:e.failures.filter(e=>e.id!==t.id)};let n=function(e,t){if("sender-start"===t.type||"replay-start"===t.type||"run-accepted"===t.type){let n="sender-start"!==t.type&&!t.run.recovery,r=e.runs.find(e=>e.id===t.run.id),s=r?e.runs.indexOf(r):e.runs.length,o=e.runs.map((e,t)=>n&&t<s&&"pending"!==e.phase?{...e,phase:"released"}:e),l=e.failures;for(let t of o)t.terminalError&&"released"===t.phase&&e.runs.find(e=>e.id===t.id)?.phase!=="released"&&(l=m(l,t));let i={...t.run,phase:t.run.recovery?"released":r&&("draining"===r.phase||"released"===r.phase)?r.phase:n?"active":"pending",terminalError:t.run.recovery||r?.terminalError,messages:"replay-start"===t.type?[]:r?.messages??[],start:r?.start??Math.max(e.totalTurns,...o.filter(h).map(e=>e.start+(0,a.l)(e.messages).length)),anchor:r?.anchor};return o=r?o.map(e=>e.id===i.id?i:e):[...o,i],p({...e,runs:o,failures:l,writerIdle:!1})}if("input-rejected"===t.type)return null!==e.sessionId&&e.sessionId!==t.sessionId?e:{...e,failures:m(e.failures,t.copy)};if("validated"===t.type)return null!==e.sessionId&&e.sessionId!==t.sessionId?e:{...e,sessionId:t.sessionId,needsStableRead:!t.stable};if("writer-idle"===t.type)return null!==e.sessionId&&e.sessionId!==t.sessionId?e:{...e,sessionId:t.sessionId,writerIdle:!0,writerIdleRevision:e.writerIdleRevision+1};if("run-end"===t.type){let n=e.runs.some(e=>e.id===t.runId),r=e.runs.map(e=>e.id===t.runId?{...e,...t.failed?{terminalError:!0}:{},phase:t.writerActive&&"released"!==e.phase?"draining":"released"}:e),s=r.find(e=>e.id===t.runId&&e.terminalError&&"released"===e.phase),o=s?m(e.failures,s):e.failures,a=r.some(e=>"pending"===e.phase||"active"===e.phase||"draining"===e.phase);return p({...e,runs:r,failures:o,writerIdle:!a&&(n||e.writerIdle||!t.writerActive)})}if("send-failed"===t.type){let n=e.runs.find(e=>e.id===t.runId);return n?p({...e,runs:e.runs.filter(e=>e!==n),failures:m(e.failures,n)}):e}if("recovery-deleted"===t.type){let{clearsBefore:n}=t.deletion,r=e=>void 0!==n&&e.startedAt<=n;return p({...e,failures:e.failures.filter(e=>!r(e)).map(e=>({...e,messages:(0,l.Q)(e.messages,t.deletion)})).filter(e=>e.messages.length),runs:e.runs.map(e=>e.terminalError?{...e,messages:r(e)?[]:(0,l.Q)(e.messages,t.deletion)}:e)})}if("run-messages"===t.type){let n=e.runs.find(e=>e.id===t.runId);if(!n)return e;let s=t.update,o="object"!=typeof s||Array.isArray(s)?void 0:s,a=e=>"function"==typeof s?s(e):Array.isArray(s)?s:(0,r.FM)(e,s.event,s),l=!!o&&!n.recovery&&(0,r.az)(o.event),i=e.runs.map(e=>e===n||l&&!e.terminalError?{...e,messages:a(e.messages)}:e),d=l?e.diskTurns.map(e=>({...e,messages:a(e.messages)})):e.diskTurns,c=i.find(e=>e.id===t.runId&&e.terminalError&&"released"===e.phase);return p({...e,diskTurns:d,runs:i,failures:c?m(e.failures,c):e.failures})}if("messages"===t.type){let n=new Map(("function"==typeof t.update?t.update(e.messages):t.update).map(e=>[e.id,e])),r=e=>e.flatMap(e=>n.get(e.id)??[]);return p({...e,diskTurns:e.diskTurns.map(e=>({...e,messages:r(e.messages)})),runs:e.runs.map(e=>e.terminalError&&"released"===e.phase?e:{...e,messages:r(e.messages)})})}let{page:n,mode:s,sessionId:o}=t;if("prepend"===s&&(e.sessionId!==o||t.endTurnIndex!==e.diskCursor?.index))return e;let c=null===e.sessionId||e.sessionId===o,f="prepend"!==s||!0===n.replacesWindow,g=t.fromCache||!f&&!1!==n.stable?c&&e.needsStableRead:!1===n.stable;if(!n.messages.length&&!1===n.stable)return{...c?e:d,sessionId:o,needsStableRead:g};let x=n.totalTurns??e.totalTurns,b=t.endTurnIndex??x,v=n.startTurnIndex??Math.max(0,b-(0,a.l)(n.messages).length),y=c&&!n.replacesWindow&&"replace"!==s&&"jump"!==s,w=new Map((y?e.diskTurns:[]).map(e=>[e.index,e]));if("prepend"!==s)for(let e of w.keys())e>=v&&w.delete(e);let k=n.messages,C=new Set(k.map(e=>e.id));for(let e of t.toolUpdates??[])k=(0,r.FM)(k,e.event,e).filter(e=>C.has(e.id));(0,a.l)(k).forEach((e,t)=>{let n=v+t;w.set(n,{index:n,messages:i(w.get(n)?.messages??[],e)})});let j=[...w.values()].filter(e=>e.index<x).sort((e,t)=>e.index-t.index),N=c?e.runs.filter(e=>f&&!t.fromCache&&t.reconciles?.includes(e.id)&&"released"===e.phase&&(!e.terminalError||!1!==n.stable)&&(v<=(u(e,j)??e.start)||n.replacesWindow)):[],S=c?e.runs.filter(e=>!N.includes(e)):[],T=c?e.failures:[];return p({...e,sessionId:o,diskTurns:j,runs:S,failures:T,totalTurns:x,needsStableRead:g,writerIdle:c&&e.writerIdle,diskCursor:y&&e.diskCursor&&!(v<=e.diskCursor.index)?e.diskCursor:{index:v,proof:n.beforeProof}},"prepend"!==s)}(e,t);if(n===e||!n.dismissedFailures.length)return n;let s=n.failures.filter(e=>!n.dismissedFailures.includes(e.id));return s.length===n.failures.length?n:{...n,failures:s}}(A.current,e);for(let e of(y(t)!==y(A.current)&&(F.current=null),A.current=t,I(t),P.current))e()},[]),{messages:_,hasMore:B}=L,O=(0,o.useRef)(0),H=(0,o.useRef)(void 0),[V,U]=(0,o.useState)(0),W=(0,o.useCallback)(e=>{$.current?.requestId===e&&($.current=null,M(!1),E(!1),U(O.current))},[]),q=(0,o.useRef)(0),z=(0,o.useCallback)(()=>{let e=q.current++,t=$.current;for(let n of(t?.navigation===e&&(O.current===t.requestId&&++O.current,W(t.requestId)),P.current))n()},[W]),K=(0,o.useCallback)(()=>{z(),++O.current,$.current&&W($.current.requestId),H.current=void 0},[z,W]),G=(0,o.useCallback)(e=>{D({type:"messages",update:e})},[D]),Q=(0,o.useCallback)((e,t)=>{D({type:"run-messages",runId:e,update:t})},[D]),[J,Y]=(0,o.useState)(null),[X,Z]=(0,o.useState)(null),[ee,et]=(0,o.useState)(null),[en,er]=(0,o.useState)(null),es=(0,o.useRef)(null);es.current=J;let eo=(0,o.useRef)(null),ea=J??e??n,el=(0,o.useRef)(ea);el.current=ea;let ei=(0,o.useRef)({cwd:t,sessionId:n??e}),ed=(0,o.useRef)(!1),ec=(0,o.useRef)(!1);(0,o.useEffect)(()=>()=>{ed.current=!1,ec.current=!1,K()},[t,K]);let eu=(0,o.useRef)(k);eu.current=k;let em=(0,o.useRef)(C);em.current=C;let eh=(0,o.useRef)(void 0),ep=(0,o.useCallback)(e=>{++O.current,$.current&&W($.current.requestId),eh.current=void 0,D({type:"sender-start",run:e})},[D,W]),ef=(0,o.useCallback)(e=>{eh.current=void 0,D({type:"run-accepted",run:e})},[D]),eg=(0,o.useCallback)(e=>D({type:"send-failed",runId:e}),[D]),ex=(0,o.useCallback)((e,t)=>{el.current===e&&(null===ei.current.sessionId||ei.current.sessionId===e)&&D({type:"input-rejected",sessionId:e,copy:t})},[D]),eb=(0,o.useCallback)(e=>{eh.current=void 0,D({type:"replay-start",run:e})},[D]),ev=(0,o.useCallback)((e,t,n=!1)=>{eh.current=void 0,D({type:"run-end",runId:t,writerActive:e,failed:n})},[D]),ey=(0,o.useCallback)(e=>D({type:"recovery-deleted",deletion:e}),[D]),ew=(0,o.useCallback)(e=>D({type:"recovery-dismissed",id:e}),[D]),ek=(0,o.useCallback)(e=>D({type:"writer-idle",sessionId:e}),[D]),eC=(0,o.useRef)(0),ej=(0,o.useCallback)(async(e,t,n=!1,r,o,a=!1)=>{if((ei.current.cwd!==e||ei.current.sessionId!==t)&&((ei.current.cwd!==e||null!==ei.current.sessionId)&&K(),ei.current={cwd:e,sessionId:t},eh.current=void 0,eC.current=0),n){let e=Date.now();if(!a&&e-eC.current<5e3)return;eC.current=e}let l=++O.current,i=A.current.runs.filter(e=>"released"===e.phase).map(e=>e.id);$.current={requestId:l,toolUpdates:[]},n||(H.current=void 0);let d=H.current,u=(n,r,a=!1)=>{n.replacesWindow&&(H.current=void 0),eh.current=a&&0===A.current.runs.length&&!1!==n.stable?n.fingerprint:void 0,n.messages&&(D({type:"page",sessionId:t,page:{...n,messages:n.messages},mode:r?"incremental":"replace",endTurnIndex:o,reconciles:a?i:void 0,fromCache:!a}),Y(t),es.current=t),n.sessionId&&c(n.sessionId),n.engine&&(et(n.engine),Z(n.model??null)),er(n.bot??null),n.title&&("number"==typeof n.titleRevision&&void 0!==n.defaultTitle&&void 0!==n.customTitle&&(0,s.X4)({cwd:e,sessionId:t,title:n.title,defaultTitle:n.defaultTitle,customTitle:n.customTitle,titleRevision:n.titleRevision}),eu.current?.((0,s.iM)((0,s.V6)(),e,t,n.title,n.titleRevision))),n.usage&&em.current?.({inputTokens:n.usage.input_tokens||0,outputTokens:n.usage.output_tokens||0,cacheCreationInputTokens:n.usage.cache_creation_input_tokens||0,cacheReadInputTokens:n.usage.cache_read_input_tokens||0,totalCostUsd:0})},m=`${e}::${t}`;a&&v.delete(m);let h=!n&&void 0===o,p=h?v.get(m):void 0;n||(p&&0===A.current.runs.length?u(p.data,!1):E(!0));try{let s={cwd:e,sessionId:t,limit:r,beforeTurnIndex:o};if(n&&void 0!==r&&void 0===o){let e=[A.current.diskCursor?.index,d?.start,...A.current.runs.filter(e=>i.includes(e.id)).map(e=>e.start)].filter(e=>void 0!==e);e.length>0&&(s.fromTurnIndex=Math.min(...e)),s.fromTurnIndex===A.current.diskCursor?.index&&(s.expectedStartProof=A.current.diskCursor?.proof)}let a=A.current.startTurnIndex,c=void 0!==o||(void 0===r?0!==a:"number"==typeof s.fromTurnIndex&&(void 0===a||s.fromTurnIndex<a));n&&!c&&eh.current&&0===A.current.runs.length?s.ifFingerprint=eh.current:p&&0===A.current.runs.length&&(s.ifFingerprint=p.fingerprint);let f=await g.t4.runPromiseExit(b(s));if(l!==O.current)return;if("Success"===f._tag&&f.value){let r=f.value;if((r.messages||r.notModified)&&(eo.current=JSON.stringify([e,t])),r.notModified){"boolean"==typeof r.stable&&(eh.current=r.stable?r.fingerprint:void 0,D({type:"validated",sessionId:t,stable:r.stable}));return}if(u(r,n,!0),H.current===d&&(H.current=void 0),h&&r.fingerprint&&r.messages&&!1!==r.stable&&(v.delete(m),v.set(m,{data:r,fingerprint:r.fingerprint}),v.size>20)){let e=v.keys().next().value;void 0!==e&&v.delete(e)}}}catch(e){console.error("Failed to load history by cwd and sessionId:",e)}finally{W(l)}},[c,K,W]),eN=y(L),eS=L.runs.some(e=>"pending"===e.phase);(0,o.useEffect)(()=>{let e=N&&!ed.current;if(ed.current=N,!N){ec.current=!1;return}if(!e&&!ec.current)return;e&&(F.current=null);let r=es.current??n;if(!t||!r)return;if($.current){ec.current=!0;return}if(ec.current=!1,eN)return;let s=A.current.runs,o=eo.current===JSON.stringify([t,r]);o&&(S||s.some(e=>"released"!==e.phase))||ej(t,r,o,o?j??void 0:10)},[N,V,t,n,S,eN,j,ej]),(0,o.useEffect)(()=>{if(!N||!eN||$.current||!t||!ea||ei.current.cwd!==t||ei.current.sessionId&&ei.current.sessionId!==ea)return;let e=JSON.stringify([t,ea,eN]),n=F.current;n?.demand===e&&(eS||n.requestId===O.current)||(ej(t,ea,!0,j??void 0,void 0,!0),F.current={demand:e,requestId:O.current})},[N,eN,eS,V,t,ea,j,ej]);let eT=(0,o.useCallback)(async()=>{let n=A.current;if(!t||!e||$.current||!n.hasMore||!n.diskCursor?.index)return;let r=n.diskCursor.index,s=n.runs.filter(e=>"released"===e.phase).map(e=>e.id),o=++O.current;$.current={requestId:o,toolUpdates:[]},H.current={requestId:o,start:Math.max(0,r-10)},M(!0);try{let a=await g.t4.runPromiseExit(b({cwd:t,sessionId:e,limit:10,beforeTurnIndex:r,expectedBeforeProof:n.diskCursor.proof}));if(o!==O.current)return;if("Success"===a._tag&&a.value){let o=a.value;if(o.messages){if(!o.beforeProof&&void 0!==o.totalTurns&&o.totalTurns<n.totalTurns)return void await ej(t,e,!1,10,void 0,!0);o.replacesWindow&&(H.current=void 0),D({type:"page",sessionId:e,page:{...o,messages:o.messages},mode:"prepend",endTurnIndex:r,reconciles:s}),Y(e),!o.replacesWindow&&void 0!==o.totalTurns&&o.totalTurns>n.totalTurns&&await ej(t,e,!0,10,void 0,!0)}}else"Failure"===a._tag&&console.error("Failed to load more history:",a.cause)}finally{H.current?.requestId===o&&(H.current=void 0),W(o)}},[t,e,ej,W]),eE=(0,o.useCallback)(async function n(r,s,o){z();let l=q.current,i=es.current??e;if(!t||!i||r<0||ei.current.sessionId&&ei.current.sessionId!==i)return{status:"cancelled"};ei.current={cwd:t,sessionId:i};let d=A.current.runs.findLast(e=>{if(o)return e.id===o;let t=u(e,A.current.diskTurns);return void 0!==t&&r>=t});if(d&&"released"!==d.phase&&("Failure"===(await g.t4.runPromiseExit(f.bIC(e=>{let t=()=>{let n=l!==q.current,r=!A.current.runs.some(e=>e.id===d.id&&"released"!==e.phase);(n||r)&&(P.current.delete(t),e(n?f.fJG(new x.uV({message:"History navigation cancelled"})):f.rIH))};return P.current.add(t),t(),f.OH5(()=>{P.current.delete(t)})})))._tag||l!==q.current))return{status:"cancelled"};let c=++O.current,m=A.current.runs.filter(e=>"released"===e.phase).map(e=>e.id);$.current={requestId:c,navigation:l,toolUpdates:[]},M(!0);try{let e=await g.t4.runPromiseExit(b({cwd:t,sessionId:i,fromTurnIndex:Math.min(r,...A.current.runs.filter(e=>m.includes(e.id)).map(e=>e.start)),target:s}).pipe(f.KT6(f.bIC(e=>{let t=()=>{l!==q.current&&e(f.fJG(new x.uV({message:"History navigation cancelled"})))};return P.current.add(t),t(),f.OH5(()=>{P.current.delete(t)})}))));if(l!==q.current)return{status:"cancelled"};if(c!==O.current)return n(r,s);if("Failure"===e._tag)return console.error("Failed to load turns for jump:",e.cause),{status:"failed"};if(!e.value)return{status:"failed"};if(es.current&&es.current!==i)return{status:"cancelled"};let o=e.value;if("missing"===o.targetStatus||"stale"===o.targetStatus)return{status:o.targetStatus};if(o.messages&&(D({type:"page",sessionId:i,page:{...o,messages:o.messages,startTurnIndex:o.startTurnIndex??r},mode:"jump",reconciles:m}),Y(i)),s&&o.resolvedMessageId&&!A.current.messages.some(e=>e.id===o.resolvedMessageId)){let e=(0,a.l)(o.messages??[]).findIndex(e=>e.some(e=>e.id===o.resolvedMessageId)),t=(o.startTurnIndex??r)+Math.max(0,e),l=A.current.runs.findLast(e=>e.start<=t);if(l&&"released"!==l.phase)return n(r,s,l.id);return{status:"failed"}}return eh.current=A.current.runs.length?void 0:o.fingerprint,o.messages?{status:"ready",messageId:o.resolvedMessageId}:{status:"failed"}}finally{W(c)}},[t,e,z,W]);return{messages:_,recoveryCopies:L.failures,onRecoveryDeleted:ey,onRecoveryDismissed:ew,setMessages:G,onLiveSnapshotStart:eb,setRunMessages:Q,onRunAccepted:ef,onSendFailure:eg,onInputRejected:ex,onLiveRunEnd:ev,onSenderStart:ep,onWriterIdle:ek,isLoadingHistory:T,isLoadingMore:R,hasMoreHistory:B,loadMoreHistory:eT,ensureTurnLoaded:eE,cancelTurnLoad:z,loadHistoryByCwdAndSessionId:ej,loadedSessionId:J,loadedEngine:ee,loadedModel:X,loadedBot:en}}},98245:(e,t,n)=>{n.d(t,{C:()=>s});var r=n(69809);function s(e,t){if("codex_input_queued"===e.notice||"codex_input_accepted"===e.notice||"codex_input_failed"===e.notice){let n=e.notice.slice(12),s=r.A.t(`chat.codexInput.${n}`),o=[s,e.input_text,e.input_images?r.A.t("chat.codexInput.images",{count:e.input_images}):"",e.error].filter(Boolean).join("\n\n");return{id:t,role:"system",content:s,systemEvent:{kind:"meta",detail:o}}}if("codex_context_compacting"===e.notice){let e=r.A.t("chat.codexContextCompacting",{defaultValue:"Codex is compacting the context…"});return{id:t,role:"system",content:e,systemEvent:{kind:"meta",detail:e}}}if("codex_resume_failed"!==e.notice)return null;let n=e.previous_session_id||"",s=r.A.t("chat.codexResumeFailed",{defaultValue:"Previous session is in use by another Codex client — started a new session; history was not carried over"}),o=[...n?[`${r.A.t("chat.codexResumeFailedPrevious",{defaultValue:"Previous session"})}: ${n}`]:[],...e.session_id?[`${r.A.t("chat.codexResumeFailedNew",{defaultValue:"New session"})}: ${e.session_id}`]:[]],a=[s,...o.length?["",...o]:[],...e.error?["",e.error]:[]].join("\n");return{id:t,role:"system",content:s,systemEvent:{kind:"meta",detail:a}}}},99356:(e,t,n)=>{n.d(t,{I7:()=>s,WM:()=>r});let r="/ws/global-state?limit=100";function s(){let e=window.location.pathname;return"/m"===e||e.startsWith("/m/")?r:"/ws/global-state"}}}]);
|
|
732
|
+
`:"")+"</task-notification>",r=k();g(s=>[...s,{...r,id:t,role:"system",content:e.summary||"",systemEvent:{kind:"task-notification",...e.status?{status:e.status}:{},detail:n}}])}return}if("system"===e.type&&"notice"===e.subtype){let t=(0,i.C)(e,`live-notice-${++p.current}`),n=k();t&&g(e=>[...e,{...t,...n}]);return}if("user"===e.type&&e._human){let t=e.message?.content,n="string"==typeof t?t:Array.isArray(t)?t.map(e=>e?.text||"").join(""):"",r="string"==typeof e._turnId?e._turnId:null;!R.current&&(S.current||N.current)&&(E.current=!0);let s="number"==typeof e._ts&&Number.isFinite(e._ts)?e._ts:null;"codex"===c&&!S.current&&N.current&&b.current++,"codex"===c&&S.current||(v.current=s??f.current?.startedAt??Date.now()),y.current=!0;let o=k(),a=r?`live-user-${r}`:`live-user-${f.current?.id}-${++p.current}`;g(t=>r&&t.some(e=>e.id===a||e.liveInputId===r)?t:[...t,{id:a,role:"user",content:n,...o,liveInputId:r??void 0,...null!==s?{timestamp:new Date(s).toISOString()}:{},...e._images?.length?{images:e._images}:{}}]);return}if("result"===e.type&&(S.current=!1,N.current=!0),"assistant"===e.type&&Array.isArray(e.message?.content))for(let t of e.message.content)t.text?n(t.text):t.name&&n(`${t.name} ${JSON.stringify(t.input??{})}`);if("user"===e.type&&Array.isArray(e.message?.content))for(let t of e.message.content)n("string"==typeof t.content?t.content:JSON.stringify(t.content??""));g({event:e,engine:c,assistantId:h.current??L()})}},A=(0,s.useRef)(!1),F=t=>{if(!u?.onlyRunId||!A.current){if(u?.onlyRunId&&"run-snapshot"===t.type&&t.runId!==u.onlyRunId){if(t.recovery)return;A.current=!0,u.onRunEnd?.(!1,u.onlyRunId);return}if("run-snapshot"===t.type&&Array.isArray(t.events)){!t.recovery&&f.current&&t.runId&&t.runId!==f.current.id&&u?.onRunEnd?.(!1,f.current.id);let n="running"!==t.status&&!0===t.writerActive&&t.events.length>0,r="error"===t.status;if("running"!==t.status&&!n&&!(r&&t.events.length)){x.current=!0===t.writerActive,f.current&&(f.current.active=!1);let n="string"==typeof t.runId?t.runId:f.current?.id;for(let s of(n&&u?.onRunEnd?.(x.current,n,r),!x.current&&e&&u?.onWriterIdle?.(e),u?.onRunningChange?.(!1),u?.onLiveOutputTokens?.(null),u?.onRunStartedAt?.(null),u?.onBackgroundTasks?.([]),g(l.fD),u?.taskStore?.settleRunning(),C.current=0,j.current=!1,N.current=!1,t.recoveryDeletions??[]))u?.onRecoveryDeleted?.(s);return}let s="number"==typeof t.startedAt?t.startedAt:null,o={id:t.runId||`${e}:${s}`,startedAt:s??Date.now(),recovery:t.recovery};M(o);let a="number"==typeof t.outputTokens&&Number.isFinite(t.outputTokens)?Math.max(0,Math.round(t.outputTokens)):null;for(let e of(null!==a&&(C.current=a,j.current=!0,u?.onLiveOutputTokens?.({outputTokens:a})),t.events))I(e);for(let e of((n||r)&&(x.current=!0===t.writerActive,f.current.active=!1,u?.onRunEnd?.(x.current,o.id,r),g(l.fD)),t.recoveryDeletions??[]))u?.onRecoveryDeleted?.(e);u?.onRunningChange?.(!n&&!r),u?.onRunStartedAt?.(r?null:"number"==typeof t.startedAt?t.startedAt:Date.now())}else if("run-event"===t.type&&t.message){if("recovery-deleted"===t.message.type)return void u?.onRecoveryDeleted?.(t.message.deletion);if("run-ended"===t.message.type||"run-settled"===t.message.type){if("string"==typeof t.message.runId&&f.current&&t.message.runId!==f.current.id)return;x.current="run-ended"===t.message.type&&!0===t.message.writerActive,f.current&&(f.current.active=!1);let e="string"==typeof t.message.runId?t.message.runId:f.current?.id;e&&u?.onRunEnd?.(x.current,e,"error"===t.message.status),u?.onRunningChange?.(!1),u?.onLiveOutputTokens?.(null),u?.onRunStartedAt?.(null),u?.onBackgroundTasks?.([]),g(l.fD),u?.taskStore?.settleRunning(),C.current=0,j.current=!1,N.current=!1;return}if(x.current){(0,r.X)(t.message)&&I(t.message);return}let n=t.message;f.current?.active||M({id:"string"==typeof n._turnId?n._turnId:`${e}:${n._ts??Date.now()}`,startedAt:n._ts??Date.now()}),I(n),u?.onRunningChange?.(!0)}else if("run-idle"===t.type){for(let e of t.recoveryDeletions??[])u?.onRecoveryDeleted?.(e);e&&u?.onWriterIdle?.(e),x.current=!1,f.current&&(f.current.active=!1),f.current&&u?.onRunEnd?.(!1,f.current.id),u?.onRunningChange?.(!1),u?.onLiveOutputTokens?.(null),u?.onRunStartedAt?.(null),u?.onBackgroundTasks?.([]),g(l.fD),u?.taskStore?.settleRunning(),C.current=0,j.current=!1,N.current=!1}}};return(0,o.h)({url:e?`/ws/session-stream?sessionId=${encodeURIComponent(e)}&subscriber=${encodeURIComponent(m)}`:"/ws/session-stream",enabled:n&&!!e,onMessage:e=>{for(let t of e.recoveries??[])F(t);F(e),!u?.onlyRunId||f.current?.id!==u.onlyRunId||x.current||f.current.active||(A.current=!0)}}),e=>F({...e,recovery:!0})}},66109:(e,t,n)=>{n.d(t,{aO:()=>r,iG:()=>s,jL:()=>o});let r="relative w-full max-w-[calc((100vw_-_28rem)*0.9)] h-[90vh] mx-4 bg-card rounded-lg shadow-lv3 flex flex-col overflow-hidden",s="relative w-full max-w-[calc((100vw_-_14rem)*0.9)] h-[90vh] mx-4 bg-card rounded-lg shadow-lv3 flex flex-col overflow-hidden",o="grid grid-cols-[repeat(auto-fill,minmax(320px,1fr))] gap-3"},67183:(e,t,n)=>{n.d(t,{M:()=>o,a:()=>a});let r=/^\s*<cockpit-decisions>\n?([\s\S]*?)<\/cockpit-decisions>\s*/,s=/^- \[(dec-[a-z0-9]+-[a-z0-9]+) r(\d+)\] (.*)$/gm;function o(e){let t=r.exec(e);if(!t)return{items:[],body:e};let n=[];for(let e of t[1].matchAll(s))n.push({key:`${e[1]}@${e[2]}`,text:e[3]});return{items:n,body:e.slice(t[0].length)}}let a=e=>o(e).body},67415:(e,t,n)=>{n.d(t,{VU:()=>a,gG:()=>l,i2:()=>i});var r=n(49433),s=n(84230),o=n(37640);let a=()=>(0,s.F)("/api/session-bots",(0,o.zi)("/api/session-bots")),l=r.OH5(()=>(0,s.T)("/api/session-bots")),i=(e,t)=>(0,o.zi)("/api/session-bots",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,sessionId:t})}).pipe(r.yeE(l))},67889:(e,t,n)=>{n.d(t,{o:()=>r});let r="flex items-center gap-2 h-9 flex-shrink-0 border-b border-border"},67958:(e,t,n)=>{n.d(t,{B:()=>r});function r(){let e=new Map,t=new Set,n=new Set;return{observe(r){"system"===r.type&&r.task_id&&("task_started"===r.subtype?(t.add(r.task_id),r.parent_task_id&&e.set(r.task_id,r.parent_task_id)):"task_notification"===r.subtype&&n.add(r.task_id))},reportsToMain(r){let s=r.task_id?e.get(r.task_id):void 0;return!(s&&t.has(s))||n.has(s)}}}},68287:(e,t,n)=>{function r(e){return"loading"===e?"relative session-number-running":""}function s(e,t){return"loading"===e||"unread"===e?"border-transparent bg-orange-11/15 text-orange-11":t?"border-transparent bg-brand/15 text-brand":"border-transparent bg-muted-foreground/15 text-muted-foreground"}function o(e,t){return[r(e),s(e,t)].filter(Boolean).join(" ")}n.d(t,{JQ:()=>s,QV:()=>r,ci:()=>o})},69809:(e,t,n)=>{n.d(t,{A:()=>a});var r=n(50931);let s=JSON.parse('{"common":{"openAsProject":"Open as project","save":"Save","cancel":"Cancel","delete":"Delete","close":"Close","minimize":"Minimize","copy":"Copy","edit":"Edit","file":"File","codeMap":"Code Map","diff":"Diff","confirm":"Confirm","loading":"Loading...","search":"Search","refresh":"Refresh","retry":"Retry","submit":"Submit","copied":"Copied","saved":"Saved","failed":"Failed","noMatch":"No matches","noData":"No data","done":"Done","justNow":"just now","minutesAgo":"{{count}}m ago","hoursAgo":"{{count}}h ago","daysAgo":"{{count}}d ago","monthsAgo":"{{count}}mo ago","yearsAgo":"{{count}}y ago","saveFailed":"Save failed","copyFailed":"Copy failed","deleteFailed":"Delete failed","operationFailed":"Operation failed","copiedPath":"Path copied","copyPath":"Copy path","openInConsole":"Open in Console bubble","copyAbsPath":"Copy absolute path","loadMore":"Load more","noResult":"No results","selected":"Selected","selectAll":"Select all","hint":"Notice","confirmBtn":"OK","cancelBtn":"Cancel","preview":"Preview","readable":"Readable","previous":"Previous","next":"Next","all":"All","input":"Input","result":"Result","line":"Line","lines":"lines","running":"Running","connecting":"Connecting","connected":"Connected","connectionFailed":"Connection failed","builtin":"Built-in","global":"Global","project":"Project","current":"Current","code":"Code"},"htmlApps":{"tabFiles":"Files","tabRun":"Run","mine":"Mine","selectHint":"Select an app on the left to see its files and source; it only runs when you click Run (apps get full shell access).","openFull":"Open full screen (minimisable to the sidebar)","title":"HTML Apps","addTooltip":"Add to HTML panel","added":"Added to HTML panel","alreadyAdded":"Already added","addFailed":"Failed to add","add":"Add","adding":"Adding...","addHtmlApp":"Add HTML app","searchPlaceholder":"Search HTML apps...","pathLabel":"Absolute path to the .html file","invalid":"Invalid","builtin":"Built-in","noDescription":"No description","emptyNoApps":"No custom HTML apps yet.","emptyCreatePrefix":"Use","emptyCreateSuffix":"in chat to create a new app.","addExisting":"add an existing HTML file","viewDocs":"view docs","emptyNoMatch":"No HTML apps match your search."},"skills":{"addTooltip":"Add to Skills panel","added":"Added to Skills panel","alreadyAdded":"Already added","addFailed":"Failed to add","title":"Skills","searchPlaceholder":"Search skills...","clearSearch":"Clear","addSkill":"Add Skill","emptyNoSkills":"No skills yet.","emptyIntroPrefix":"Use","emptyIntroSuffix":"in chat to distil a reusable workflow into a SKILL.md file.","emptyNoMatch":"No skills match your search.","viewDocs":"view docs","pathLabel":"Absolute path to SKILL.md","pathPlaceholder":"/Users/you/.../skills/foo/SKILL.md","add":"Add","adding":"Adding...","invalid":"Invalid","builtinGroup":"Builtin","builtinReadOnly":"Builtin \xb7 read-only","selectHint":"Select a skill on the left to view its SKILL.md","fileTooLarge":"File is over 1 MB — not previewed","fileNotPreviewable":"This file cannot be previewed (binary)","copyPath":"Copy path","noDescription":"No description","previewTitle":"Skill Preview","source":"Source","cannotRead":"File cannot be read."},"toast":{"savedSuccess":"Saved","saveFailed":"Save failed","copiedName":"Copied: {{name}}","copyFailed":"Copy failed","deleteFailed":"Delete failed","operationFailed":"Operation failed","staged":"Staged","stageFailed":"Stage failed","unstaged":"Unstaged","unstageFailed":"Unstage failed","stagedNFiles":"Staged {{count}} files","unstagedNFiles":"Unstaged {{count}} files","discardFailed":"Discard failed","discardedNFiles":"Discarded changes in {{count}} files","deletedFile":"File deleted","discardedChanges":"Changes discarded","pastedFile":"Pasted: {{name}}","pasteFailed":"Paste failed","noFileToPaste":"No file to paste","createdFile":"Created: {{name}}","createFailed":"Create failed","movedToTrash":"Moved to trash: {{name}}","copiedPageUrl":"Page URL copied","copiedDirPath":"Directory path copied","switchedToBranch":"Switched to {{branch}}","switchBranchFailed":"Branch switch failed","loadBranchFailed":"Failed to load branches","copiedCommand":"Copied: {{command}}","copiedMessage":"Message copied","sentToPeer":"Sent to the other pane","sendToPeerFailed":"Failed to send to the other pane","forkFailed":"Failed to fork session","excerptFailed":"Failed to excerpt this turn","turnDeleted":"Turn deleted","deleteTurnFailed":"Failed to delete this turn","copiedUrl":"URL copied","copiedOutput":"Output copied","copiedCmd":"Command copied","copiedComment":"Comment copied","copiedAllComments":"All comments copied","copiedFileContent":"File content copied","copiedQA":"Copied {{count}} Q&A","copiedAllQA":"All Q&A copied","sentQA":"Sent to AI","readFileFailed":"Failed to read file","fileOutsideProject":"File preview is unavailable here","reviewCreated":"Review created, link copied","reviewUpdated":"Review updated, link copied","reviewCreateFailed":"Failed to create review","sharingClosed":"Sharing disabled","sharingCloseFailed":"Failed to disable sharing","linkCopied":"Link copied","addCommentFailed":"Failed to add comment","deleteCommentFailed":"Failed to delete comment","editCommentFailed":"Failed to edit comment","addReplyFailed":"Failed to add reply","deleteReplyFailed":"Failed to delete reply","editReplyFailed":"Failed to edit reply","disconnected":"Disconnected: {{id}}","pluginReloading":"Reloading extension...","worktreeCreateSuccess":"Worktree created: {{name}}","worktreeCreateFailed":"Failed to create worktree","worktreeLoadFailed":"Failed to load worktree list","worktreeDeleted":"Worktree deleted","worktreeDeleteFailed":"Failed to delete worktree","worktreeLocked":"Locked","worktreeUnlocked":"Unlocked"},"workspace":{"selectProject":"Select a project to start","searchProjectPath":"Search project path...","loadingProjects":"Loading projects...","projectNotFound":"No projects found","sessions":"{{count}} sessions","loadingSessions":"Loading sessions...","noSessions":"No sessions","loadingText":"Loading...","openProject":"Open Project","expandSidebar":"Expand sidebar","collapseSidebar":"Collapse sidebar","notes":"Notes","skills":"Skills","apps":"Apps","settings":"Settings","help":"Help","updateAvailable":"v{{version}} available","copyUpgradeCommand":"Copy cockpit update","updateNow":"Update now","updating":"Updating…","updateComplete":"Update complete","updateFailed":"Update failed","updateCardPreparing":"Preparing update…","updateCardInstalling":"Downloading and installing","updateCardRepairing":"Repairing native dependency","updateCardUpToDate":"Already on the latest version, v{{version}}","updateCardCopyFix":"Copy fix command","updateCardFixCopied":"Fix command copied","updateCardRollingBack":"Install failed, rolling back","updateCardRestarting":"Restarting Cockpit…","updateCardDone":"Updated to v{{version}}","updateCardElapsed":"{{seconds}}s elapsed","updateCardBaseline":"last time ~{{seconds}}s","updateCardNoLiveStatus":"Live status unavailable; the update is still running","updateCardRolledBack":"Rolled back to the previous version; Cockpit is usable.","updateCardManualHint":"You can retry from a terminal:","updateCardLogHint":"Log: {{path}}","updateRestartNote":"Cockpit will restart in the background.","viewChangelog":"View changelog","serverRestarted":"Cockpit was updated in the background.","serverReloadAfterRestart":"Cockpit restarted. Reload this page.","reloadNow":"Reload","upgradeCommandCopied":"Copied `cockpit update`","projectNotes":"Project Notes","closeProject":"Close project","unsentDraft":"Unsent draft","bots":"Bots"},"mobile":{"useDesktop":"Desktop","messagePlaceholder":"Message…","send":"Send","stop":"Stop","enableNotifications":"Enable notifications","disableNotifications":"Disable notifications","notifyError":"Could not enable notifications","useMobile":"Mobile","newChat":"New chat","voiceInput":"Voice input","voiceStop":"Stop voice input","voiceListening":"Listening…","voiceDenied":"Microphone access was denied — allow it in the browser settings","voiceFailed":"Voice input failed: {{reason}}","voiceUnsupported":"Voice input is not available in this browser — use the microphone on your keyboard","quickInstructionsHint":"Tap to fill the input"},"sessions":{"recentSessions":"Recent Sessions","favorites":"Favorite Sessions","titleSingleLine":"The title must be a single line, with no line breaks or \\\\n","titleNoAt":"The title must not contain @","titleNotMentionable":"This title cannot be used with @: {{reason}}. Rename it first","mentionable":"Can be @-mentioned","mentionableHint":"Adds this session to the Bots list; any session can then hand it a task with \\"@title task\\"","suggestTitle":"Suggest a title with AI","titleSuggestFailed":"Could not suggest a title: {{reason}}","noFavorites":"No favorite sessions yet. Click the star in the tab bar to add.","addFavorite":"Add to favorites","removeFavorite":"Remove from favorites","selectFavoriteHint":"Select a favorite on the left to preview its messages","noSessionMessages":"No messages in this session, or its transcript is gone","selectSessionHint":"Select a session on the left to preview its messages","dateToday":"Today","dateYesterday":"Yesterday","dateLast7Days":"Last 7 days","dateEarlier":"Earlier","runningCount":"{{count}} running","unreadCount":"{{count}} unread","noSessions":"No sessions yet","running":"Running","done":"Done","dragToReorder":"Drag to reorder within this project","restoreTitle":"Restore default title","titleEmpty":"Title cannot be empty.","titleLoadFailed":"Could not load the title. Close and try again.","titleSaveFailed":"Could not save the title. Please try again.","editTitle":"Edit title","projectSessions":"Project Sessions","browseAllSessions":"Browse all sessions","sessionList":"Session List","search":"Search","searchSessions":"Search sessions...","searchRecentSessions":"Search recent sessions","loadSessionsFailed":"Failed to load sessions","loadingSessions":"Loading sessions...","noMatchingSessions":"No matching sessions","noSessionsYet":"No sessions yet","projectList":"Project List","openFolder":"Open Folder","loadingHistory":"Loading history...","sessionsTab":"Sessions","pullRequestsTab":"PRs","searchPullRequests":"Search number / URL / title","allRepos":"All repos","allEngines":"All engines","noPullRequests":"No recent session has opened a PR yet","noPullRequestsHint":"PRs appear here once a session runs gh pr create","noMatchingPullRequests":"No matching PRs","selectPullRequestHint":"Select a PR on the left to view its session","pullRequestSessions":"{{count}} sessions","openPullRequest":"Open PR","copyResumeCommand":"Copy resume","resumeCommandCopied":"Copied: {{command}}","copyFailed":"Copy failed"},"scheduledTasks":{"title":"Scheduled Tasks","aboutToTrigger":"About to trigger","secondsLater":"in {{count}}s","minutesLater":"in {{count}}m","hoursMinutesLater":"in {{h}}h {{m}}m","hoursLater":"in {{h}}h","onceType":"Once (in {{duration}})","everyDuration":"Every {{duration}}","completed":"Completed","paused":"Paused","activeCount":"{{running}} active","pausedCount":"{{paused}} paused","noScheduledTasks":"No scheduled tasks. Click the clock button in the chat input to create one.","lastResult":"Last","runNow":"Run now","deleteFailed":"Failed to delete the task","resume":"Resume","pause":"Pause","completedCount":"Completed ({{count}})","pendingCount":"{{count}} to review","openSession":"Open session","selectTaskHint":"Select a task on the left to preview its session messages","noTaskMessages":"No messages in this task\'s session yet","success":"Success","failure":"Failed","inFlight":"Running now","interrupted":"Interrupted","createTask":"Create Scheduled Task","editTask":"Edit Scheduled Task","sendMessage":"Message","messagePlaceholder":"Enter message to send...","taskFile":"Task File","taskFilePlaceholder":"/Users/you/project/tasks/daily-report.md","taskFileHint":"Absolute path. On each fire the agent reads this file first and acts on what it describes — edits take effect on the next run.","taskFilePromptHeader":"Read this task file first, then act accordingly:","type":"Type","once":"Once","interval":"Interval","quickSelect":"Quick Select","customCron":"Custom Cron Expression","customDuration":"Custom duration","cronPlaceholder":"e.g. 0 9 * * 1-5 (weekdays at 9am)","cronFormat":"Format: min hour day month weekday (e.g. 0 9 * * 1-5)","amountPlaceholder":"Amount","limitTimeRange":"Limit execution time range","startAt":"Start at (optional)","startAtHint":"Empty = start now. When set, runs stay on start + N \xd7 interval and never drift with run time","clear":"Clear","fromTime":"from {{time}}","to":"to","saveBtn":"Save ({{modKey}}↩)","createBtn":"Create ({{modKey}}↩)","5minLater":"In 5 minutes","15minLater":"In 15 minutes","30minLater":"In 30 minutes","1hourLater":"In 1 hour","3hoursLater":"In 3 hours","6hoursLater":"In 6 hours","1dayLater":"In 1 day","3daysLater":"In 3 days","every15min":"Every 15 min","every30min":"Every 30 min","every1hour":"Every 1 hour","every2hours":"Every 2 hours","every6hours":"Every 6 hours","every12hours":"Every 12 hours","everyDay":"Every day","daily9am":"Daily 09:00","daily6pm":"Daily 18:00","weeklyMon9am":"Mon 09:00","monthly1st9am":"1st of month 09:00","unit":{"minute":"min","hour":"hours","day":"days"},"duration":{"minute_one":"{{count}} min","minute_other":"{{count}} min","hour_one":"{{count}} hour","hour_other":"{{count}} hours","day_one":"{{count}} day","day_other":"{{count}} days"}},"runningTerminals":{"title":"Terminals","status":"{{count}} terminal(s) \xb7 {{projects}} project(s)","keys":"↑↓ select \xb7 Enter / double-click open \xb7 Del stop \xb7 Esc close","empty":"No terminals running","currentProject":"current project","stop":"Stop","confirmStop":"Stop this process?","stopping":"Stopping…","stopFailed":"Failed to stop the terminal","openTerminal":"Open terminal","typeHint":"Click the terminal to type","modePty":"PTY \xb7 interactive terminal","modePipe":"Pipe \xb7 output only","ended":"Ended","selectHint":"Select a terminal on the left to preview its output","notFound":"Couldn\'t find this terminal\'s bubble"},"cron":{"everyNMinutes":"Every {{n}} minutes","everyNHours":"Every {{n}} hours","everyMinute":"Every minute","everyHourAtMin":"Every hour at minute {{m}}","hourlyEveryMin":"{{h}}:xx every minute","daily":"Daily at {{time}}","weekdays":"Weekdays","weekends":"Weekends","dowSun":"Sun","dowMon":"Mon","dowTue":"Tue","dowWed":"Wed","dowThu":"Thu","dowFri":"Fri","dowSat":"Sat","monthPrefix":"","dayOfMonth":"","dayRange":"{{a}}th to {{b}}th","weekdayPrefix":"","weekdayRange":"{{a}} to {{b}}"},"blockViewer":{"empty":{"body":"Select a file in the left tree to see its code map.","hint":"or press ⌘K to search."},"fileMode":{"loading":"Loading…","notFound":"This file is not indexed (unsupported language or beyond the file cap)."},"buildProgress":{"listing":"Listing files…","contexts":"Reading project config…","parsing":"Parsing files","resolving":"Resolving imports…","edges":"Building call graph…","done":"Finishing up…"},"search":{"tooltip":"Search (⌘K)","hint":"Start typing to search","noResults":"No matches","files":"Files","symbols":"Symbols"},"viewerToggle":{"toBlock":"Show code map","toCode":"Back to code view"},"tabs":{"toc":"Functions","history":"Trail"},"toc":{"title":"this file","empty":"No functions detected.","notIndexed":"File not in project graph (unsupported language / not in git tracked set / file cap reached)."},"history":{"title":"recent","empty":"Click an input or output pin to begin tracing.","clear":"Clear history"},"refresh":"Rebuild project graph","relationsStale":"Project relations need a refresh","retry":"Retry"},"blockDiffViewer":{"loading":"Building code map…","unsupported":"Code map diff is not available for this file type.","unsupportedHint":"Switch back to the regular diff view to read it.","error":"Code map diff failed: {{message}}","noBlockChanges":"No code-map changes (formatting / whitespace only).","noBefore":"(new)","noAfter":"(removed)","kind":{"added":"added","deleted":"deleted","modified":"modified"}},"fileBrowser":{"directoryTree":"Tree","searchTab":"Search","recentTab":"Recent","changesTab":"Status","historyTab":"History","searchFiles":"Search files...","clear":"Clear","exactMatchOn":"Exact match (on)","exactMatchOff":"Exact match (off)","refreshTree":"Refresh directory tree","collapseAll":"Collapse all directories","searchFileContent":"Search file contents...","caseSensitive":"Case sensitive","wholeWord":"Whole word","regex":"Regex","fileTypes":"File types (ts,tsx)","compareMode":"Compare","compareModeOff":"Close branch comparison","compareModeOn":"Compare with selected branch","compareScopeHead":"HEAD","compareScopeWorktree":"Worktree","compareScopeHeadHint":"Compare committed work only","compareScopeWorktreeHint":"Include uncommitted changes (staged / unstaged / untracked)","createFile":"New File","createFileIn":"New File (in {{path}}/)","fileName":"File name...","noRecentFiles":"No recent files","stagingArea":"Staged ({{count}})","changesSummary_one":"{{count}} change","changesSummary_other":"{{count}} changes","noChanges":"No changes in working tree","refreshChanges":"Refresh changes","unstageAll":"Unstage all","noStagedFiles":"No staged files","unstageNFiles":"Unstage {{count}} files","unstageFile":"Unstage","workspace":"Workspace ({{count}})","discardAll":"Discard all","stageAll":"Stage all","noUnstagedChanges":"No unstaged changes","discardNFiles":"Discard changes in {{count}} files","stageNFiles":"Stage {{count}} files","discardChanges":"Discard changes","stageFile":"Stage file","loadingDiff":"Loading diff...","noDiffFiles":"No diff files","nFilesChangedPlain":"{{count}} files changed","nFilesChanged":"{{count}} files changed (vs {{branch}})","nFilesChangedWorktree":"{{count}} files changed (vs {{branch}}, incl. uncommitted)","noDiffFilesHeadHint":"Nothing committed on this branch yet — switch to Worktree to see uncommitted changes","loadingCommits":"Loading commits...","noCommits":"No commits","allLoaded":"All {{count}} records loaded","locateInTree":"Locate in directory tree","unsaved":"Unsaved","saveBeforeSwitch":"Current file has unsaved changes. Save before switching?","saveAndSwitch":"Save and switch","closeEdit":"Close edit (ESC)","closeBtn":"Close","copyFileContent":"Copy file content","toggleJsonReadable":"Toggle JSON readable mode","previewMarkdown":"Preview Markdown","exitPreview":"Exit Preview","collapseAllJson":"Fold","expandAllJson":"Full","viewBlame":"View line-by-line change history","viewDiff":"View changes against HEAD","exitDiff":"Exit Diff","diffLoadFailed":"Failed to load diff","editFile":"Edit file","backToPreview":"Back to preview","cannotPreview":"Cannot preview this file","selectFileToPreview":"Select a file to preview","staged":"Staged","unstaged":"Unstaged","selectFileToViewDiff":"Select a file to view diff","loadingDiffContent":"Loading diff...","clickCompareToLoad":"Click \\"Compare\\" to load branch diff","selectCommitToView":"Select a commit to view details","confirmDelete":"Confirm Delete","confirmDeleteMessage":"Move <file>{{name}}</file> to trash?","nFilesNMatches":"{{files}} files, {{matches}} matches","resultsTruncated":"Results truncated","noContentSearchResults":"No results","enterKeywordToSearch":"Enter keyword to search file contents","searchMinChars":"Search requires at least 2 characters"},"csv":{"table":"Table","raw":"Raw","empty":"Empty table","summary":"{{rows}} rows \xb7 {{cols}} columns","summaryFiltered":"{{rows}} / {{total}} rows matched \xb7 {{cols}} columns","loadMore":"Load more ({{shown}} / {{total}} shown)","filterPlaceholder":"Filter rows…","filterColumn":"Filter column","clearFilter":"Clear filter","allColumns":"All columns","noMatch":"No matching rows","sortHint":"Click to sort (asc / desc / off)"},"codeViewer":{"fileModifiedExternally":"File was modified externally. Saving will overwrite external changes.","useDiskVersion":"Use disk version","forceOverwrite":"Force overwrite","searchPlaceholder":"Search...","caseSensitive":"Case sensitive","wholeWordMatch":"Whole word match","unsavedConfirm":"You have unsaved changes. Close anyway?","discardChanges":"Discard changes","continueEditing":"Continue editing","unsavedExitConfirm":"You have unsaved changes. Exit edit mode?","clickToViewDetails":"Click to view details","clickToViewCommit":"Click to view commit details","nComments":"{{count}} comments","searchChat":"Search chat...","prevShiftEnter":"Previous (Shift+Enter)","nextEnter":"Next (Enter)","closeEsc":"Close (Esc)"},"chat":{"commandRefs_one":"{{count}} reference attached","commandRefs_other":"{{count}} references attached","commandRef_read":"read","commandRef_handoff":"hand on","commandRef_handoffMixed":"hand on","commandRef_targets":"target","commandRef_inline":"inlined","originSent":"@-mention from {{project}}","originDelegated":"Delegated from {{project}}","originUnknown":"another session","decisionContextAttached":"{{count}} related decisions attached","codexInput":{"queued":"Additional message waiting to send","accepted":"Codex accepted the additional message","failed":"Additional message delivery failed or is unconfirmed — open for details","images":"Images: {{count}}"},"recoveryCopy":"Failed run recovery copy","recoveryCopyHint":"Temporary copy of observed content. It may repeat saved history and is not sent to the model. Kept while this conversation remains open.","recoveryCopiesLabel":"Failed run recovery copies","recoveryAttachment":"Recovery attachment","startConversation":"Start a conversation","loadMoreHistory":"Load more...","scrollUpForMore":"↑ Scroll up to load more history","jumpToStart":"Jump to start","jumpToLatest":"Jump to latest","jumpToPrevUserMessage":"Previous user message","jumpToNextUserMessage":"Next user message","recentUserMessages":"Recent user messages","moreUserMessages":"More","userMessage":"User message","recentUserMessageNumber":"Recent user message {{index}} of {{total}}","imageMessage":"Image message","copyMessage":"Copy message","copyImage":"Copy image","copiedImage":"Image copied","forkSession":"Fork session from here","excerptTurn":"Excerpt this turn to a new session","newSession":"New session","continueFromHere":"Continue from here","continueFromHereDesc":"Keep all context through this turn","onlyThisTurn":"Only this turn","onlyThisTurnDesc":"Keep only this question and answer","onlyThisTaskDesc":"Keep this entire task, including all {{count}} inputs and replies","deleteTurn":"Delete turn","deletingTurn":"Deleting…","deleteTurnConfirm":"Delete this question, answer, and its tool records? This cannot be undone.","deleteTaskConfirm":"This task contains {{count}} user inputs, including additional steering. Delete the entire task with all its inputs, replies, and tool records? This cannot be undone.","deleteTurnConfirmAction":"Delete turn","deleteTurnWhileRunning":"A turn cannot be deleted while the session is running","sendToPeerPane":"Send this message to the other pane","imageN":"Image {{index}}","imagePreview":"Image preview","imageLoadFailed":"Could not load this image","toolCalls":"{{count}} tool calls","collapse":"▲ Collapse","expand":"▼ Expand","showMore":"Show more","showLess":"Show less","subagent":"Subagent","piChildStatus":{"interrupted":"Interrupted snapshot","truncated":"Truncated","running":"Running","done":"Done","failed":"Failed","cancelled":"Cancelled"},"subagentEmpty":"No subagent transcript found","subagentViewTitle":"View subagent transcript","workflowRun":"Run details","workflowViewTitle":"View workflow run details","workflowEmpty":"No workflow run journal found","workflowAgents":"agents","workflowViewAgent":"View","workflowUngrouped":"Ungrouped","viewQuestions":"View questions","viewAllFileChanges":"View all file changes","requestFailed":"Request failed","cannotReadStream":"Cannot read response stream","errorRetry":"An error occurred, please retry","codexResumeFailed":"Previous session is in use by another Codex client — started a new session; history was not carried over","codexResumeFailedPrevious":"Previous session","codexResumeFailedNew":"New session","codexContextCompacting":"Codex is compacting the context…","placeholder":"Type a message, / for skills, @ for bots","placeholderDisabled":"Generating... you can keep typing (ESC to cancel; if stuck, cancel and resend \'continue\')","placeholderRunning":"Generating... Enter sends now: it joins the current reply at its next step (ESC to stop)","imageSizeLimit":"Image size exceeds limit (max 5MB), current: {{size}}MB","viewGitChanges":"View Git changes","viewAllComments":"View all comments","userMessages":"User messages","projectNotes":"Project Notes","scheduledTasks":"Scheduled Tasks","quickInstructions":"Quick Instructions","globalInstructions":"Global Instructions","projectInstructions":"Project Instructions","noQuickInstructions":"No quick instructions yet","addQuickInstruction":"Add quick instruction","quickInstructionPlaceholder":"One-line instruction — Enter to save, Esc to cancel","insertQuickInstruction":"Insert into input (without sending)","addInstructionGroup":"New group","instructionGroupNamePlaceholder":"Group name — Enter to save, Esc to cancel","instructionGroupLabel":"Group","instructionGroupNone":"No group","deleteInstructionGroupConfirm":"Deleting \\"{{name}}\\" also deletes the {{count}} instruction(s) inside it. Continue?","editGlobalInstructions":"Edit global instructions","editProjectInstructions":"Edit project instructions","quickInstructionsMarkdownHint":"One top-level entry per line. Add lines beginning with “- ” after a group name for its instructions. Write \\\\n for a line break inside one instruction.","quickInstructionsMarkdownPlaceholder":"Continue\\nDraw with text\\n- Draw a login flow\\n- Draw a system architecture","quickInstructionsMarkdownError":"Invalid format on line {{line}}.","savingQuickInstructions":"Saving...","saveQuickInstructionsFailed":"Could not save. Your edits are still here; please try again.","context":"Context","output":"Output","copiedCommandTooltip":"Copied!","copyCommandTooltip":"Copy command: {{command}}","executedCommand":"Executed `{{command}}`{{exitInfo}}, output:\\n```\\n{{output}}\\n```","executedCommandFailed":"Failed to execute `{{command}}`: {{error}}","executionMode":"Execution Mode","checkBalance":"Check balance","balanceFailed":"Query failed — check the API key","balanceNeedsKey":"Set a DeepSeek API key first","balanceUnavailable":"Account is not available for requests","balanceEmpty":"No balance returned","openUsagePage":"Open DeepSeek usage console","checkQuota":"Check quota","quotaFailed":"Quota unavailable — check the API key","quotaNeedsKey":"Set an API key first","quotaEmpty":"No quota returned","quotaResetAt":"Resets {{time}}","openProviderConsole":"Open the provider console","planMode":"Plan mode","planModeDesc":"read-only, plans first without edits","planModeOn":"Plan mode on — read-only; send a task to get a plan","planModeOff":"Plan mode off","planModeHint":"Plan mode: read-only exploration that produces a plan without editing. Uncheck and resend to implement.","noHistory":"No history context","noHistoryDesc":"each prompt is independent","noHistoryHint":"No history context: each message is sent to the model on its own, with no prior conversation. The transcript above still records everything.","planTitle":"Plan (awaiting your review)","approvePlan":"Approve & run","planApproveHint":"No approval dialog here — click to exit plan mode and execute","approvePlanPrompt":"Approved — proceed with the plan above.","maximizePane":"Maximize this pane","restorePane":"Restore both panes","closePane":"Close this pane","singlePane":"Single pane","splitPane":"Split into two panes"},"console":{"enterCommandOrUrl":"Enter a command or URL to start","emptyIntro":"Type any of the following in the input bar to create a bubble:","bubbleCommand":"Command","bubbleInteractive":"Interactive","bubbleBrowser":"Browser","bubbleBrowserNoteIframe":"Some sites block iframe embedding — install Cockpit Bridge under Settings → Browser Extension before opening.","bubbleBrowserNoteCookie":"If a logged-in site first shows as signed out, refresh a few times to restore it.","bubbleDatabase":"Database","bubbleFilePreview":"File preview","loadingMore":"Loading...","loadMoreHistory":"Load more history","quickCommands":"Quick Commands","singleColumn":"Single column","dualColumn":"Dual column","envVars":"Environment Variables","launchShell":"Launch interactive shell","htmlApps":"HTML apps","inputPlaceholder":"Enter command or URL and press Enter... (↑↓ history, Tab complete)","scopeProject":"Project","scopeGlobal":"Global","tabSwitchEscClose":"Tab to switch \xb7 Esc to close","copyOutput":"Copy output","copyCommand":"Copy command","rerun":"Re-run","deleteRecord":"Delete record","searchPlaceholder":"Search...","searchMode":"Search","filterMode":"Filter","prevShiftEnter":"Previous (Shift+Enter)","nextEnter":"Next (Enter)","loadingTerminal":"Loading terminal...","clickToInput":"Click terminal area to type","stdinPlaceholder":"stdin input...","runningText":"Running...","exitCode":"Exit code: {{code}}","totalLines":"{{count}} lines total","globalCommands":"Global Commands","projectCommands":"Project Commands","noCustomCommands":"No custom commands yet","editGlobalCommands":"Edit global commands","editProjectCommands":"Edit project commands","quickCommandsTextHint":"One per line as \\"name: command\\". Names may only contain letters, digits, - and _; everything after the first colon is the command.","quickCommandsTextPlaceholder":"pg: psql -h localhost -U postgres\\ngitpull: git pull --rebase","quickCommandsTextError":"Line {{line}} is invalid; expected \\"name: command\\".","savingQuickCommands":"Saving...","saveQuickCommandsFailed":"Save failed. Your edits are kept; please retry.","restoreTooltip":"Restore ({{modKey}}M / ESC)","screenshotting":"Screenshotting...","outputFileDeleted":"[Output file deleted]"},"browser":{"blankPage":"Blank page","copyUrl":"Copy URL","openInNewWindow":"Open in new window","exitMaximize":"Exit maximize ({{modKey}}M)","maximize":"Maximize ({{modKey}}M)","pageLoadFailed":"Page load failed","openInTabFallback":"OpenCockpit Bridge is not connected — opened a plain new tab instead","movedToChrome":"Web pages now open in Chrome tabs, not in the console.","openInChrome":"Open in Chrome","openedInChrome":"Opened in Chrome — {{command}}","clickToWake":"Click to wake","sleeping":"Sleeping","loadingPage":"Loading...","loadFailed":"Load failed"},"database":{"connectionFailed":"Connection failed","connected":"Connected","connecting":"Connecting...","refreshTableList":"Refresh table list","filterTable":"T Tables","filterView":"V Views","noTables":"No tables","tabStructure":"Structure","tabData":"Data","tabSql":"SQL","filterActive":"Filter: {{count}} cols","clearAllFilters":"Clear all filters","deleteNRows":"Delete {{count}} rows","confirmDeleteRows":"Confirm delete?","copyCsvSelected":"Copy selected rows as CSV","copyCsvAll":"Export all as CSV","copyJsonSelected":"Copy selected rows as JSON","copyJsonAll":"Export all as JSON","copyCSV":"Copy CSV","CSV":"CSV","copyJSON":"Copy JSON","JSON":"JSON","selectTable":"Select a table","selectTableToView":"Select a table to view structure","selectTableForData":"Select a table to view data","columns":"Columns","colName":"Name","colType":"Type","colNullable":"Nullable","colDefault":"Default","primaryKey":"Primary Key","foreignKeys":"Foreign Keys","indexes":"Indexes","enable":"Enable","commaValues":"Comma-separated values","likePattern":"%pattern%","valuePlaceholder":"Value","apply":"Apply","clearFilter":"Clear","addRow":"+ Add Row","totalRows":"{{count}} rows","rowsAffected":"{{command}} — {{count}} rows affected ({{duration}}ms)","queryRows":"{{count}} rows ({{duration}}ms)","resultTruncated":"[Results truncated to 1000 rows]","sqlPlaceholder":"Enter SQL... ({{modKey}}Enter to execute)","executing":"Executing...","execute":"▶ Execute","deleteRowsFailed":"{{count}} rows failed to delete","inputParams":"Input Parameters","resultLabel":"Result"},"mysql":{"connectionFailed":"Connection failed","connected":"Connected","connecting":"Connecting...","refreshTableList":"Refresh table list","filterTable":"T Tables","filterView":"V Views","noTables":"No tables","tabStructure":"Structure","tabData":"Data","tabSql":"SQL","filterActive":"Filter: {{count}} cols","clearAllFilters":"Clear all filters","deleteNRows":"Delete {{count}} rows","confirmDeleteRows":"Confirm delete?","copyCsvSelected":"Copy selected rows as CSV","copyCsvAll":"Export all as CSV","copyJsonSelected":"Copy selected rows as JSON","copyJsonAll":"Export all as JSON","copyCSV":"Copy CSV","CSV":"CSV","copyJSON":"Copy JSON","JSON":"JSON","selectTable":"Select a table","selectTableToView":"Select a table to view structure","selectTableForData":"Select a table to view data","columns":"Columns","colName":"Name","colType":"Type","colNullable":"Nullable","colDefault":"Default","primaryKey":"Primary Key","foreignKeys":"Foreign Keys","indexes":"Indexes","enable":"Enable","commaValues":"Comma-separated values","likePattern":"%pattern%","valuePlaceholder":"Value","apply":"Apply","clearFilter":"Clear","addRow":"+ Add Row","totalRows":"{{count}} rows","rowsAffected":"{{command}} — {{count}} rows affected ({{duration}}ms)","queryRows":"{{count}} rows ({{duration}}ms)","resultTruncated":"[Results truncated to 1000 rows]","sqlPlaceholder":"Enter SQL... ({{modKey}}Enter to execute)","executing":"Executing...","execute":"▶ Execute","deleteRowsFailed":"{{count}} rows failed to delete"},"redis":{"neverExpires":"Never expires","expired":"Expired","loadFailed":"Load failed","deleteFailed":"Delete failed","saveFailed":"Save failed","scanPlaceholder":"SCAN pattern...","scanSearch":"Search (SCAN)","noKeys":"No keys","loadMore":"Load more...","tabData":"Data","tabInfo":"Info","tabCli":"CLI","selectKey":"Select a key","keyNotExist":"Key does not exist","unsupportedType":"Unsupported type: {{type}}","nItems":"{{total}} items","showingN":"showing {{count}}","nMembers":"{{total}} members","nEntries":"{{total}} entries","cliHint":"Enter Redis commands, e.g. PING, GET key, KEYS *","cliPlaceholder":"Enter command..."},"git":{"switchBranch":"Switch branch","searchBranch":"Search branches...","noBranches":"No branches available","noMatchingBranches":"No matching branches","localBranches":"Local Branches","remoteBranches":"Remote Branches","branchNotFound":"Branch not found","selectBranch":"Select branch...","currentBranch":"Current","notGitRepo":"Current directory is not a Git repository","cannotGetBranches":"Cannot get branch info","getBranchesFailed":"Failed to get branch info","discardAllConfirm":"Discard changes in {{count}} workspace files? This cannot be undone.","worktree":{"title":"Git Worktree","count":"{{count}} worktrees","selectBranch":"Select branch","addWorktree":"+ Add Worktree","confirmDelete":"Confirm Delete","confirmDeleteMsg":"Delete this worktree?","path":"Path:","branch":"Branch:","locked":"Locked","unlock":"Unlock","lock":"Lock","searchBranch":"Search branches...","noBranches":"No available branches"}},"comments":{"addComment":"Add Comment","lineRange":"Line {{start}}-{{end}}","inputPlaceholder":"Enter comment...","newComment":"New comment {{range}}","commentPlaceholder":"Enter comment... ({{modKey}}Enter to submit, Esc to cancel)","nComments":"{{count}} comments","allComments":"All Comments","copyAllComments":"Copy all comments","noComments":"No comments yet","clearAll":"Clear all","totalComments":"{{count}} comments total","aiReply":"AI Reply","noContent":"(no content)","linesCount":"({{count}} lines)","codeRef":"Here are my annotated comments and references:","note":"Note: {{content}}","submitting":"Submitting...","enterSubmit":"Enter to submit \xb7 Shift+Enter for new line","submitComment":"Submit Comment","askAI":"Ask AI","inputQuestion":"Enter your question...","aiGenerating":"Generating, please wait...","enterSend":"Enter to send \xb7 Shift+Enter for new line","sendToAI":"Send to AI","aiResponding":"AI is responding..."},"fileContextMenu":{"createFile":"New File","copyFile":"Copy File","copyFolder":"Copy Folder","pasteHere":"Paste Here","deleteFile":"Delete File","deleteFolder":"Delete Folder","copyRelativePath":"Copy Relative Path","copyAbsolutePath":"Copy Absolute Path","copyRelativeDirPath":"Copy Relative Dir Path","copyAbsoluteDirPath":"Copy Absolute Dir Path","copyFileName":"Copy File Name","copyFolderName":"Copy Folder Name"},"settings":{"title":"Settings","theme":"Theme","themeLight":"Light","themeDark":"Dark","themeSystem":"System","browserExtension":"Browser Extension","extensionInstalled":"OpenCockpit Bridge connected","extensionNotInstalled":"OpenCockpit Bridge not connected","extensionDescription":"Lets `cockpit browser` drive your Chrome tabs and Console browser bubbles. Every tab gets an id (in the extension\'s popup and icon tooltip); Cockpit asks before acting on a tab you haven\'t allowed — permission is per tab.","installSteps":"Installation steps:","step1":"1. Open Chrome and navigate to","step2":"2. Enable \\"Developer mode\\" in the top-right corner","step3":"3. Click \\"Load unpacked\\"","step4mac":"4. Press <kbd>Cmd+Shift+G</kbd> → paste the path below → Enter","copyExtensionPath":"Copy extension directory path","reloadExtension":"Reload extension","about":"About","language":"Language","languageAuto":"System","switchDark":"Switch to dark","switchLight":"Switch to light","agentsBundled":"bundled","codexSection":"Codex","codexSuggestions":"Suggest next prompt","codexSuggestionsDescription":"After each reply, ask Codex to predict your next message and show it in the input box (Tab to accept). Costs one small extra request per turn."},"editor":{"placeholder":"Write something... Type / for commands","noteTitle":"{{name}} - Notes","noteUntitled":"Notes","globalNote":"Global note","emptyNote":"Empty note","searchNotes":"Search notes...","saving":"Saving...","conflictReloaded":"This note was changed elsewhere. Loaded the latest version; your recent unsaved edits were discarded.","linkPlaceholder":"Enter URL...","confirmLink":"Confirm","removeLink":"Remove link","heading1":"Heading 1","heading2":"Heading 2","heading3":"Heading 3","bold":"Bold","italic":"Italic","strikethrough":"Strikethrough","inlineCode":"Inline code","link":"Link","bulletList":"Bullet list","orderedList":"Ordered list","taskList":"Task list","blockquote":"Blockquote","codeBlock":"Code block","table":"Table","horizontalRule":"Horizontal rule","insertRowAbove":"Insert row above","insertRowBelow":"Insert row below","insertColumnLeft":"Insert column left","insertColumnRight":"Insert column right","deleteRow":"Delete row","deleteColumn":"Delete column","deleteTable":"Delete table","deleteCodeBlock":"Delete code block","toc":"TOC","expandToc":"Expand TOC","collapseToc":"Collapse TOC"},"slashCommands":{"heading1":"Heading 1","heading1Desc":"Large heading","heading2":"Heading 2","heading2Desc":"Medium heading","heading3":"Heading 3","heading3Desc":"Small heading","bulletList":"Bullet List","bulletListDesc":"Bulleted list","orderedList":"Ordered List","orderedListDesc":"Numbered list","taskList":"Task List","taskListDesc":"Checkable task list","blockquote":"Blockquote","blockquoteDesc":"Quote block","codeBlock":"Code Block","codeBlockDesc":"Code snippet","table":"Table","tableDesc":"Insert 3\xd73 table","horizontalRule":"Divider","horizontalRuleDesc":"Horizontal divider","link":"Link","linkDesc":"Insert hyperlink"},"commands":{"plan":"Enable plan mode \xb7 /plan <task> to plan it \xb7 /plan off to disable"},"markdown":{"copied":"✓ Copied","copy":"Copy"},"imagePreview":{"previewImage":"Preview image","deleteImage":"Delete image","copyImage":"Copy image","copiedImage":"Image copied"},"tokenStats":{"title":"Claude Code Token Stats","activeHours":"Active Hours Distribution","hourSessions":"{{h}}:00 — {{count}} sessions","messages":"Messages","toolCalls":"Tool Calls","activityTrend":"Activity Trend","byModel":"By Model","tokenUsage":"Token Usage","equivalentCost":"Equivalent Cost","modelCostDetail":"Model Cost Details","model":"Model","share":"Share","total":"Total","totalSessions":"Total Sessions","totalMessages":"Total Messages","equivalentApiCost":"Equivalent API Cost","longestSession":"Longest Session","firstUse":"First Use","notFound":"~/.claude/stats-cache.json not found","day":"Day","week":"Week","month":"Month"},"toolCall":{"inputParams":"Input Parameters","resultLabel":"Result","inputParamsTitle":"View input parameters","resultTitle":"View result","input":"Input","result":"Result","details":"Details","detailsTitle":"View input and result","foldedLines":"... ({{count}} lines)"},"fileEditor":{"unsavedConfirm":"You have unsaved changes. Close anyway?","discardChanges":"Discard changes","continueEditing":"Continue editing","externallyModified":"File was modified externally. Saving will overwrite external changes.","useDiskVersion":"Use disk version","forceOverwrite":"Force overwrite"},"quickFileOpen":{"placeholder":"Type file name to open...","noMatch":"No matching files","recent":"Recent","selectHint":"Select","openHint":"Open","closeHint":"Close"},"envManager":{"title":"Environment Variables","tabScope":"Current Tab Only","globalScope":"Global Environment Variables","varNamePlaceholder":"Variable name (e.g. NODE_ENV)","varValuePlaceholder":"Value (e.g. production)","valuePlaceholder":"Value","noVars":"No environment variables yet. Add one to get started."},"aliasManager":{"title":"Command Aliases","description":"Set shortcut aliases for common commands (global)","aliasPlaceholder":"Alias (e.g. ll)","commandPlaceholder":"Full command (e.g. ls -la)","fullCommandPlaceholder":"Full command","usage":"Usage tip:","usageDesc":"Type an alias to execute the corresponding full command","noAliases":"No command aliases yet. Add one to get started."},"diffViewer":{"fileChanges":"File Changes ({{count}})","expandFull":"Expand to full width","exitFull":"Back to column","openFull":"Open full","openFullOn":"On: diffs open full width (click to open in column)","openFullOff":"Off: diffs open in column (click to open full width)","toggleFileTree":"Toggle file tree","selectFileToView":"Select a file to view changes","sideBySide":"Side by side","unified":"Unified","viewSplit":"Split","viewUnified":"Unified","previewFile":"Preview file","copiedAll":"Full text copied","compact":"Compact","full":"Full","gap":{"hidden":"{{count}} lines hidden","more":"\xb7\xb7\xb7 more +{{count}} \xb7\xb7\xb7","expandUp":"Expand {{count}} lines up","expandDown":"Expand {{count}} lines down","expandAll":"Click to expand {{count}} lines"},"loadingSnapshots":"Loading snapshots…","loadingFile":"Loading file diff…","fileLoadFailed":"Could not load the file diff","noChanges":"No file changes detected in this turn","notViewable":"Binary or oversized file — diff not viewable","externalChange":"Concurrent change from another session/process","reconstructed":"reconstructed","reconstructedHint":"Rebuilt from tool-call parameters — not a disk snapshot","truncated":"Too many files — list truncated","aggregate":"Aggregate","openAggregate":"Open aggregate","openAggregateOn":"On: diffs open on the aggregate (click to open per call)","openAggregateOff":"Off: diffs open per call (click to open on the aggregate)","aggregateOn":"View the net change across all calls","aggregateOff":"Back to per-call view","fileChangesAggregate":"File Changes ({{count}}) \xb7 Aggregate","aggregateSummary":"{{count}} files changed (across {{calls}} calls)","aggregateLoading":"Aggregating changes…","aggregateEmpty":"No net change after aggregation","aggregateUnavailable":"No snapshots — cannot aggregate","aggregateFailed":"Aggregation failed","aggregateBaselineSkipped":"Skipped {{count}} call(s) up to the last baseline change","aggregateBaselineIncluded":"Including {{count}} call(s) up to the last baseline change","callsBaselineHidden":"Hid {{count}} baseline-change call(s)","callsBaselineShown":"Showing {{count}} baseline-change call(s)","aggregateSkippedHint":"Calls that ran git rebase / pull / checkout and similar count as baseline changes (switching or pulling code rather than writing it); the aggregate starts after the last one. Click to toggle.","imageBefore":"Before","imageAfter":"After","imageAdded":"Added","imageDeleted":"Deleted","imageLoadFailed":"Failed to load image","imageUnavailable":"Image not present in either revision"},"commitDetail":{"title":"Commit Details","hash":"Hash:","author":"Author:","date":"Date:","files":"Files:","nChanges":"{{count}} changes","loadingFiles":"Loading files...","noFileChanges":"No file changes","loadingDiff":"Loading diff...","selectFileToView":"Select a file to view diff"},"askQuestion":{"title":"Questions","nQuestions":"{{count}} questions","checkedN":"{{count}} checked","copyChecked":"Copy {{count}} checked Q&A","copyAll":"Copy all Q&A","sendChecked":"Send {{count}} checked Q&A to AI","sendAll":"Send all Q&A to AI","sendNoChat":"No active chat session","checkToCopy":"Check to copy","custom":"Custom","customPlaceholder":"Enter custom answer...","notSelected":"(not selected)"},"tabBar":{"closeTab":"Close session","closeAll":"Close all sessions","newTab":"New session"},"tabManagerTopBar":{"copyPageUrl":"Copy page URL","copyDirPath":"Copy directory path","refreshProject":"Refresh project","openInVSCode":"Open in VS Code","openInCursor":"Open in Cursor","aliasesGlobal":"Command Aliases (Global)","tokenStats":"Token Stats","openSurething":"Open Surething","openOnPhone":"Open on phone","phoneQrHint":"Scan with your phone to open Cockpit","phoneQrSessionHint":"Scan with your phone to open this session","phoneQrTokenWarning":"This code contains your access token. Don\'t share it.","phoneQrFailed":"Could not generate the QR code"},"hoverTooltip":{"findReferences":"Find References","search":"Search"},"todoViewer":{"title":"Task List","progress":"{{completed}} / {{total}} done"},"userMessages":{"title":"User Messages","noMessages":"No user messages","searchPlaceholder":"Search user messages…","noResults":"No matching messages","loadFailed":"Failed to load","count":"{{shown}} / {{total}}","jumping":"Loading the turns around this message…"},"shortIdBadge":{"clickToDisconnect":"Click to disconnect","clickToRegister":"Click to register and copy CLI command","setTitle":"Name this bubble (so /cc can find it later)","setTitlePlaceholder":"set title","editTitle":"Edit title","titleSet":"Title: {{title}}","dialogTitle":"Name this bubble","dialogPlaceholder":"e.g. alloydb proxy, staging admin"},"api":{"pathForbidden":"Operation not allowed on this path","deleteForbidden":"Delete not allowed on this path","notAFolder":"Target is not a folder","imageTooLarge":"Image too large to preview","cannotPreviewBinary":"Cannot preview binary file","fileTooLarge":"File too large to preview (over 10MB)","fileModifiedExternally":"File was modified externally"},"folderPicker":{"title":"Open Folder","placeholder":"Type or paste a path, e.g. ~/Work/my-app","open":"Open","showHidden":"Show hidden","hint":"↑↓ select \xb7 Tab/Enter go in \xb7 ⌘/Ctrl+Enter open","empty":"No subfolders","noMatch":"No matching folders","notFound":"Folder not found","notDirectory":"Not a folder","denied":"Permission denied. On macOS, grant access in System Settings › Privacy & Security."},"confirm":{"title":"Notice","ok":"OK","cancel":"Cancel"},"floatingToolbar":{"addComment":"Add Comment","sendToAI":"Send to AI","search":"Search"},"quickReply":{"optionA":"A","optionB":"B","optionC":"C","optionD":"D","allRecommended":"Rest recommended","thisOne":"This one","notThis":"Not this","why":"Why?","elaborate":"Say more","example":"Give an example","start":"Do it","continue":"Continue","ok":"OK","done":"Done","edit":"Edit quick replies","editTitle":"Edit quick replies","editHint":"One line per row; separate phrases with commas. Each phrase is sent to the chat exactly as written.","editPlaceholder":"This one, Not this\\nWhy?, Say more","restoreDefault":"Restore defaults","save":"Save","cancel":"Cancel","customizedFor":"Customizing the {{lang}} phrases — the other language is unaffected.","langEn":"English","langZh":"Chinese","saveFailed":"Failed to save quick replies"},"searchResults":{"title":"Search Results","nMatches":"({{count}} matches)","searching":"Searching...","noResults":"No matches","scopeSelected":"Selected","scopeAll":"All"},"references":{"title":"References","searching":"Searching...","notFound":"No references found"},"gitFileTree":{"noFiles":"No files"},"deps":{"action":"Dependencies","none":"none","symbolMessage":"Analyse the dependencies of {{name}} ({{path}}:{{lines}}).\\n\\nCallers: {{callers}}\\nCalls: {{callees}}\\nExternal: {{externals}}\\n\\nExplain which modules it is coupled to, and which of those dependencies could be narrowed."},"explain":{"action":"Explain","fileMessage":"Explain {{path}}","symbolMessage":"Explain {{name}} ({{path}}:{{lines}})","selectionMessage":"Explain","commitFileMessage":"Explain what git commit {{hash}} changed in {{path}}","compareFileMessage":"Explain the git changes to {{path}} in {{base}}...HEAD","compareFileWorktreeMessage":"Explain the changes to {{path}} relative to {{base}}, including uncommitted work","stagedFileMessage":"Explain the git staged changes to {{path}}","unstagedFileMessage":"Explain the git working tree changes to {{path}}"},"bots":{"sessionBadge":"Session","sessionGroup":"Session Bots","sessionGroupHint":"Sessions ticked \\"Can be @-mentioned\\" in their title dialog; @-mentioning one sends the task into that session","sessionGone":"The session no longer exists","sessionNameInvalid":"Its title cannot be a name (multi-line or contains @); rename it to @-mention it","sessionUsage":"Write \\"@{{name}} <task>\\" in any session to send the task into this one","removeSession":"Remove from Bots","title":"Bots","search":"Search bots","addExisting":"Add bot","addTooltip":"Add as Bot","emptyNoMatch":"No bots match your search.","emptyNoBots":"No bots of your own yet.","emptyCreatePrefix":"Use","emptyCreateSuffix":"in chat to create one.","emptyAddExisting":"add an existing Bot directory","invalid":"Invalid","builtin":"Built-in","mine":"Mine","tabFiles":"Files","tabSessions":"Sessions","noSessions":"No recent sessions for this Bot","sessionsScope":"Every session run in its folder, plus sessions it recently dispatched elsewhere","selectHint":"Select a Bot on the left to see its files and sessions","remove":"Remove registration","open":"Open as project","pathPlaceholder":"Absolute path to a Bot directory or its BOT.md","addHint":"The directory must contain a BOT.md. Its files are not changed.","added":"Bot added","alreadyAdded":"Already added","removed":"Bot removed; its files were kept.","loadFailed":"Failed to load bots","saveFailed":"Failed to add bot","removeFailed":"Failed to remove bot"},"contextInspector":{"title":"Session context","open":"View context contents","used":"Used","window":"Window","free":"Free","unknownWindow":"Window size unknown","capturedAt":"Recorded {{time}}","refresh":"Refresh","loadFailed":"Failed to read context","noSession":"The session has not started yet; there is no context","empty":"No context items to show","selectItem":"Select an item on the left to see its content","noContent":"The engine does not expose the text of this item, only its name and token count","truncated":"Content is long; showing the first {{count}} characters","estimated":"≈ marks character-based estimates","items":"{{count}} items","copy":"Copy","copied":"Copied","groups":{"prompt":"Prompt","memory":"Memory files","tools":"Tools","skills":"Skills & agents","messages":"Messages","tool_io":"Tool calls","reasoning":"Reasoning","other":"Other"},"categories":{"system":"System prompt","instructions":"Extra instructions","memory":"Memory files","tools":"Tool definitions","mcp":"MCP tools","skills":"Skills","agents":"Custom agents","environment":"Environment","messages":"Messages","tool_io":"Tool calls & results","reasoning":"Reasoning","summary":"Compaction summary","other":"Other"},"notes":{"system_prompt_hidden":"The engine assembles its system prompt internally and does not expose the text; only section names and token counts are listed.","tool_schemas_hidden":"Built-in tools expose names and token counts only, not their schemas.","skills_listing_only":"Skills occupy only their name and description in context; the full body loads when a skill is used.","snapshot_from_last_turn":"The breakdown was recorded at the end of the last turn, not live.","no_snapshot_yet":"No breakdown has been recorded for this session yet; exact numbers appear after the next turn. Showing estimates from the transcript.","reasoning_encrypted":"Some reasoning or compaction content is encrypted: its text cannot be shown and its size cannot be estimated.","after_compaction":"The session has been compacted; only content after the latest compaction is included.","estimated_breakdown":"Per-category token counts are estimates; the total at the top is the engine\'s own number.","usage_unknown":"The engine reported no context size for this session."}}}'),o=JSON.parse('{"common":{"openAsProject":"作为项目打开","save":"保存","cancel":"取消","delete":"删除","close":"关闭","minimize":"最小化","copy":"复制","edit":"编辑","file":"文件","codeMap":"代码地图","diff":"Diff","confirm":"确认","loading":"加载中...","search":"搜索","refresh":"刷新","retry":"重试","submit":"提交","copied":"已复制","saved":"已保存","failed":"失败","noMatch":"无匹配","noData":"无数据","done":"完成","justNow":"刚刚","minutesAgo":"{{count}}分钟前","hoursAgo":"{{count}}小时前","daysAgo":"{{count}}天前","monthsAgo":"{{count}}个月前","yearsAgo":"{{count}}年前","saveFailed":"保存失败","copyFailed":"复制失败","deleteFailed":"删除失败","operationFailed":"操作失败","copiedPath":"已复制路径","copyPath":"复制路径","openInConsole":"在 Console 气泡打开","copyAbsPath":"复制绝对路径","loadMore":"加载更多","noResult":"无匹配结果","selected":"已选择","selectAll":"全选","hint":"提示","confirmBtn":"确定","cancelBtn":"取消","preview":"预览","readable":"可读","previous":"上一个","next":"下一个","all":"全部","input":"输入","result":"结果","line":"行","lines":"行","running":"运行中","connecting":"连接中","connected":"已连接","connectionFailed":"连接失败","builtin":"内置","global":"全局","project":"项目","current":"当前","code":"代码"},"htmlApps":{"tabFiles":"文件","tabRun":"运行","mine":"我的","selectHint":"选择左侧应用,查看它的文件和源码;点「运行」才会运行它(应用拥有完整的命令行权限)。","openFull":"全屏打开(可最小化到侧边栏)","title":"HTML 应用","addTooltip":"添加到 HTML 面板","added":"已添加到 HTML 面板","alreadyAdded":"已添加过","addFailed":"添加失败","add":"添加","adding":"添加中...","addHtmlApp":"添加 HTML 应用","searchPlaceholder":"搜索 HTML 应用...","pathLabel":".html 文件的绝对路径","invalid":"无效","builtin":"内置","noDescription":"无描述","emptyNoApps":"还没有自定义 HTML 应用。","emptyCreatePrefix":"在聊天里使用","emptyCreateSuffix":"创建新应用。","addExisting":"添加已有 HTML 文件","viewDocs":"查看文档","emptyNoMatch":"没有匹配的 HTML 应用。"},"skills":{"addTooltip":"添加到 Skills 面板","added":"已添加到 Skills 面板","alreadyAdded":"已添加过","addFailed":"添加失败","title":"Skills","searchPlaceholder":"搜索 skills...","clearSearch":"清除","addSkill":"添加 Skill","emptyNoSkills":"还没有 skill。","emptyIntroPrefix":"在聊天里使用","emptyIntroSuffix":"把可复用经验整理成 SKILL.md。","emptyNoMatch":"没有匹配的 skill。","viewDocs":"查看文档","pathLabel":"SKILL.md 的绝对路径","pathPlaceholder":"/Users/you/.../skills/foo/SKILL.md","add":"添加","adding":"添加中...","invalid":"无效","builtinGroup":"内置","builtinReadOnly":"内置技能,只读","selectHint":"选择左侧技能,查看它的 SKILL.md","fileTooLarge":"文件超过 1 MB,不预览","fileNotPreviewable":"该文件无法预览(二进制)","copyPath":"复制路径","noDescription":"无描述","previewTitle":"Skill 预览","source":"源码","cannotRead":"无法读取文件。"},"toast":{"savedSuccess":"已保存","saveFailed":"保存失败","copiedName":"已复制: {{name}}","copyFailed":"复制失败","deleteFailed":"删除失败","operationFailed":"操作失败","staged":"已暂存","stageFailed":"暂存失败","unstaged":"已取消暂存","unstageFailed":"取消暂存失败","stagedNFiles":"已暂存 {{count}} 个文件","unstagedNFiles":"已取消暂存 {{count}} 个文件","discardFailed":"放弃变更失败","discardedNFiles":"已放弃 {{count}} 个文件的变更","deletedFile":"已删除文件","discardedChanges":"已放弃变更","pastedFile":"已粘贴: {{name}}","pasteFailed":"粘贴失败","noFileToPaste":"没有可粘贴的文件","createdFile":"已创建文件: {{name}}","createFailed":"创建失败","movedToTrash":"已移动到回收站: {{name}}","copiedPageUrl":"已复制页面地址","copiedDirPath":"已复制目录路径","switchedToBranch":"已切换到 {{branch}}","switchBranchFailed":"切换分支失败","loadBranchFailed":"加载分支列表失败","copiedCommand":"已复制: {{command}}","copiedMessage":"已复制消息","sentToPeer":"已发送到另一栏","sendToPeerFailed":"发送到另一栏失败","forkFailed":"分叉会话失败","excerptFailed":"摘录本轮失败","turnDeleted":"已删除本轮","deleteTurnFailed":"删除本轮失败","copiedUrl":"已复制网址","copiedOutput":"已复制输出","copiedCmd":"已复制命令","copiedComment":"已复制评论","copiedAllComments":"已复制全部评论","copiedFileContent":"已复制文件内容","copiedQA":"已复制 {{count}} 个问答","copiedAllQA":"已复制所有问答","sentQA":"已发送给 AI","readFileFailed":"读取文件失败","fileOutsideProject":"此处无法打开文件预览","reviewCreated":"评审已创建,链接已复制","reviewUpdated":"评审已更新,链接已复制","reviewCreateFailed":"创建评审失败","sharingClosed":"已关闭分享","sharingCloseFailed":"关闭分享失败","linkCopied":"链接已复制","addCommentFailed":"添加评论失败","deleteCommentFailed":"删除评论失败","editCommentFailed":"编辑评论失败","addReplyFailed":"添加回复失败","deleteReplyFailed":"删除回复失败","editReplyFailed":"编辑回复失败","disconnected":"已断开: {{id}}","pluginReloading":"插件重载中...","worktreeCreateSuccess":"Worktree 创建成功: {{name}}","worktreeCreateFailed":"创建 worktree 失败","worktreeLoadFailed":"加载 worktree 列表失败","worktreeDeleted":"Worktree 已删除","worktreeDeleteFailed":"删除 worktree 失败","worktreeLocked":"已锁定","worktreeUnlocked":"已解锁"},"workspace":{"selectProject":"选择一个项目开始","searchProjectPath":"搜索项目路径...","loadingProjects":"加载项目中...","projectNotFound":"未找到项目","sessions":"{{count}} 会话","loadingSessions":"加载会话...","noSessions":"无会话记录","loadingText":"加载中...","openProject":"打开项目","expandSidebar":"展开侧边栏","collapseSidebar":"折叠侧边栏","notes":"笔记","skills":"技能","apps":"应用","settings":"设置","help":"帮助","updateAvailable":"新版本 v{{version}} 可用","copyUpgradeCommand":"复制 cockpit update","updateNow":"立即更新","updating":"正在更新…","updateComplete":"更新完成","updateFailed":"更新失败","updateCardPreparing":"正在准备更新…","updateCardInstalling":"正在下载并安装","updateCardRepairing":"正在修复原生依赖","updateCardUpToDate":"已是最新版本 v{{version}}","updateCardCopyFix":"复制修复命令","updateCardFixCopied":"已复制修复命令","updateCardRollingBack":"安装失败,正在回滚","updateCardRestarting":"正在重启 Cockpit…","updateCardDone":"已更新到 v{{version}}","updateCardElapsed":"已用 {{seconds}} 秒","updateCardBaseline":"上次约 {{seconds}} 秒","updateCardNoLiveStatus":"暂时读不到实时状态,更新仍在进行","updateCardRolledBack":"已回滚到原版本,Cockpit 可正常使用。","updateCardManualHint":"可在终端手动重试:","updateCardLogHint":"日志:{{path}}","updateRestartNote":"Cockpit 将在后台重启。","viewChangelog":"查看变更日志","serverRestarted":"Cockpit 已在后台更新。","serverReloadAfterRestart":"Cockpit 已重启,请重新加载页面。","reloadNow":"刷新","upgradeCommandCopied":"已复制 `cockpit update`","projectNotes":"项目笔记","closeProject":"关闭项目","unsentDraft":"有未发送的输入","bots":"机器人"},"mobile":{"useDesktop":"桌面版","messagePlaceholder":"发消息…","send":"发送","stop":"停止","enableNotifications":"开启通知","disableNotifications":"关闭通知","notifyError":"无法开启通知","useMobile":"手机版","newChat":"新会话","voiceInput":"语音输入","voiceStop":"停止语音输入","voiceListening":"正在听…","voiceDenied":"麦克风权限被拒绝,请在浏览器设置里允许","voiceFailed":"语音输入失败:{{reason}}","voiceUnsupported":"此浏览器无法语音识别,请用键盘上的麦克风听写","quickInstructionsHint":"点一下填入输入框"},"sessions":{"recentSessions":"最近会话","favorites":"收藏会话","titleSingleLine":"标题只能有一行,不能包含换行或 \\\\n","titleNoAt":"标题不能包含 @","titleNotMentionable":"当前标题不能用来 @:{{reason}}。请改个名字","mentionable":"可被 @ 调用","mentionableHint":"勾选后加入 Bots 列表,可在任意会话里用「@标题 任务」把任务派给它","suggestTitle":"让 AI 起个标题","titleSuggestFailed":"生成标题失败:{{reason}}","noFavorites":"暂无收藏会话,在 Tab 栏点击星标可添加","addFavorite":"收藏此会话","removeFavorite":"取消收藏","selectFavoriteHint":"选择左侧收藏,查看它的会话消息","noSessionMessages":"该会话暂无消息,或记录已不存在","selectSessionHint":"选择左侧会话,查看它的消息","dateToday":"今天","dateYesterday":"昨天","dateLast7Days":"最近 7 天","dateEarlier":"更早","runningCount":"{{count}} 运行中","unreadCount":"{{count}} 未读","noSessions":"暂无会话记录","running":"运行中","done":"完成","dragToReorder":"拖动以调整本项目内的顺序","restoreTitle":"恢复默认标题","titleEmpty":"标题不能为空。","titleLoadFailed":"无法读取标题,请关闭后重试。","titleSaveFailed":"保存标题失败,请重试。","editTitle":"编辑标题","projectSessions":"项目会话","browseAllSessions":"浏览所有会话","sessionList":"会话列表","search":"搜索","searchSessions":"搜索会话...","searchRecentSessions":"搜索最近会话","loadSessionsFailed":"加载会话失败","loadingSessions":"加载会话中...","noMatchingSessions":"未找到匹配的会话","noSessionsYet":"暂无会话","projectList":"项目列表","openFolder":"打开文件夹","loadingHistory":"加载历史消息...","sessionsTab":"会话","pullRequestsTab":"PR","searchPullRequests":"搜索 编号 / 链接 / 标题","allRepos":"全部仓库","allEngines":"全部引擎","noPullRequests":"最近会话里还没有开过 PR","noPullRequestsHint":"会话里运行 gh pr create 后,会自动出现在这里","noMatchingPullRequests":"未找到匹配的 PR","selectPullRequestHint":"选择左侧 PR,查看它的会话","pullRequestSessions":"共 {{count}} 个会话","openPullRequest":"打开 PR","copyResumeCommand":"复制 resume","resumeCommandCopied":"已复制:{{command}}","copyFailed":"复制失败"},"scheduledTasks":{"title":"定时任务","aboutToTrigger":"即将触发","secondsLater":"{{count}}秒后","minutesLater":"{{count}}分钟后","hoursMinutesLater":"{{h}}小时{{m}}分后","hoursLater":"{{h}}小时后","onceType":"一次性({{duration}}后)","everyDuration":"每{{duration}}","completed":"已完成","paused":"已暂停","activeCount":"{{running}} 个活跃","pausedCount":"{{paused}} 个暂停","noScheduledTasks":"暂无定时任务,在聊天输入栏点击时钟按钮创建","lastResult":"上次","runNow":"立即运行","deleteFailed":"删除任务失败","resume":"恢复","pause":"暂停","completedCount":"已完成 ({{count}})","pendingCount":"{{count}} 个待查看","openSession":"打开会话","selectTaskHint":"选择左侧任务,查看它的会话消息","noTaskMessages":"该任务的会话暂无消息","success":"成功","failure":"失败","inFlight":"正在运行","interrupted":"已中断","createTask":"创建定时任务","editTask":"编辑定时任务","sendMessage":"发送消息","messagePlaceholder":"输入要发送的消息...","taskFile":"任务文件","taskFilePlaceholder":"/Users/you/project/tasks/daily-report.md","taskFileHint":"填写绝对路径。触发时会让 agent 先读取该文件,再按其中描述执行——文件内容改动下次触发即生效。","taskFilePromptHeader":"请先读取以下任务文件,再据此执行:","type":"类型","once":"一次性","interval":"周期","quickSelect":"快捷选择","customCron":"自定义 Cron 表达式","customDuration":"自定义时长","cronPlaceholder":"例: 0 9 * * 1-5 (工作日9点)","cronFormat":"格式:分 时 日 月 星期(如 0 9 * * 1-5)","amountPlaceholder":"数值","limitTimeRange":"限制执行时段","startAt":"起始时间(可选)","startAtHint":"留空则从现在开始;设置后固定在「起始时间 + N \xd7 间隔」执行,不随运行时长漂移","clear":"清除","fromTime":"自 {{time}} 起","to":"至","saveBtn":"保存 ({{modKey}}↩)","createBtn":"创建 ({{modKey}}↩)","5minLater":"5 分钟后","15minLater":"15 分钟后","30minLater":"30 分钟后","1hourLater":"1 小时后","3hoursLater":"3 小时后","6hoursLater":"6 小时后","1dayLater":"1 天后","3daysLater":"3 天后","every15min":"每 15 分钟","every30min":"每 30 分钟","every1hour":"每 1 小时","every2hours":"每 2 小时","every6hours":"每 6 小时","every12hours":"每 12 小时","everyDay":"每 1 天","daily9am":"每天 09:00","daily6pm":"每天 18:00","weeklyMon9am":"每周一 09:00","monthly1st9am":"每月 1 号 09:00","unit":{"minute":"分钟","hour":"小时","day":"天"},"duration":{"minute":"{{count}}分钟","hour":"{{count}}小时","day":"{{count}}天"}},"runningTerminals":{"title":"终端","status":"{{count}} 个终端 \xb7 {{projects}} 个项目","keys":"↑↓ 选择 \xb7 Enter / 双击 打开 \xb7 Del 停止 \xb7 Esc 关闭","empty":"没有正在运行的终端","currentProject":"当前项目","stop":"停止","confirmStop":"停止这个进程?","stopping":"停止中…","stopFailed":"停止终端失败","openTerminal":"打开终端","typeHint":"点击终端即可输入","modePty":"PTY \xb7 交互式终端","modePipe":"管道 \xb7 仅输出","ended":"已结束","selectHint":"选择左侧终端,查看它的输出","notFound":"没找到这个终端的气泡"},"cron":{"everyNMinutes":"每 {{n}} 分钟","everyNHours":"每 {{n}} 小时整点","everyMinute":"每分钟","everyHourAtMin":"每小时第 {{m}} 分","hourlyEveryMin":"{{h}} 点每分钟","daily":"每天 {{time}}","weekdays":"工作日","weekends":"周末","dowSun":"日","dowMon":"一","dowTue":"二","dowWed":"三","dowThu":"四","dowFri":"五","dowSat":"六","monthPrefix":"月","dayOfMonth":"号","dayRange":"{{a}}号到{{b}}号","weekdayPrefix":"周","weekdayRange":"周{{a}}到周{{b}}"},"blockViewer":{"empty":{"body":"在左侧文件树选择一个文件,查看它的代码地图。","hint":"或按 ⌘K 搜索。"},"fileMode":{"loading":"加载中…","notFound":"该文件未索引(不支持的语言或超出文件上限)。"},"buildProgress":{"listing":"正在扫描文件…","contexts":"正在读取项目配置…","parsing":"正在解析文件","resolving":"正在解析引用关系…","edges":"正在构建调用图…","done":"即将完成…"},"search":{"tooltip":"搜索 (⌘K)","hint":"开始输入以搜索","noResults":"未找到匹配","files":"文件","symbols":"符号"},"viewerToggle":{"toBlock":"显示代码地图","toCode":"返回代码视图"},"tabs":{"toc":"函数列表","history":"跳转记录"},"toc":{"title":"本文件","empty":"未检测到函数。","notIndexed":"该文件未被项目图收录(扩展未支持 / 不在 git 跟踪集 / 超出文件上限)。"},"history":{"title":"最近","empty":"点击左右两侧的 pin 开始追踪调用链。","clear":"清空历史"},"refresh":"重新构建项目图","relationsStale":"项目关联关系需要刷新","retry":"重试"},"blockDiffViewer":{"loading":"正在生成代码地图…","unsupported":"该文件类型暂不支持代码地图 diff","unsupportedHint":"切回常规 diff 视图查看。","error":"代码地图 diff 失败:{{message}}","noBlockChanges":"代码地图无变化(仅格式或空白)。","noBefore":"(新增)","noAfter":"(已删除)","kind":{"added":"新增","deleted":"删除","modified":"修改"}},"fileBrowser":{"directoryTree":"目录树","searchTab":"搜索","recentTab":"最近","changesTab":"变更","historyTab":"历史","searchFiles":"搜索文件...","clear":"清除","exactMatchOn":"全词匹配(已开启)","exactMatchOff":"全词匹配(已关闭)","refreshTree":"刷新目录树","collapseAll":"折叠所有目录","searchFileContent":"搜索文件内容...","caseSensitive":"区分大小写","wholeWord":"完整词","regex":"正则","fileTypes":"文件类型 (ts,tsx)","compareMode":"对比","compareModeOff":"关闭分支对比","compareModeOn":"与选定分支对比","compareScopeHead":"HEAD","compareScopeWorktree":"工作区","compareScopeHeadHint":"仅对比已提交的改动","compareScopeWorktreeHint":"对比包含未提交的改动(已暂存 / 未暂存 / 未跟踪)","createFile":"新建文件","createFileIn":"新建文件 (在 {{path}}/)","fileName":"文件名...","noRecentFiles":"暂无最近浏览的文件","stagingArea":"暂存区 ({{count}})","changesSummary_one":"{{count}} 个变更","changesSummary_other":"{{count}} 个变更","noChanges":"工作区无变更","refreshChanges":"刷新变更列表","unstageAll":"全部取消","noStagedFiles":"无暂存的文件","unstageNFiles":"取消暂存 {{count}} 个文件","unstageFile":"取消暂存","workspace":"工作区 ({{count}})","discardAll":"放弃所有","stageAll":"全部暂存","noUnstagedChanges":"无未暂存的变更","discardNFiles":"放弃 {{count}} 个文件的变更","stageNFiles":"暂存 {{count}} 个文件","discardChanges":"放弃变更","stageFile":"暂存文件","loadingDiff":"加载对比文件中...","noDiffFiles":"无差异文件","nFilesChangedPlain":"{{count}} 个文件变更","nFilesChanged":"{{count}} 个文件变更(vs {{branch}})","nFilesChangedWorktree":"{{count}} 个文件变更(vs {{branch}},含未提交)","noDiffFilesHeadHint":"本分支尚无已提交的改动,切到「工作区」可看到未提交的部分","loadingCommits":"加载提交记录中...","noCommits":"无提交记录","allLoaded":"已加载全部 {{count}} 条记录","locateInTree":"在目录树中定位","unsaved":"未保存","saveBeforeSwitch":"当前文件有未保存的修改,是否保存后切换?","saveAndSwitch":"保存并切换","closeEdit":"关闭编辑 (ESC)","closeBtn":"关闭","copyFileContent":"复制文件内容","toggleJsonReadable":"切换 JSON 可读模式","previewMarkdown":"预览 Markdown 渲染效果","exitPreview":"退出预览","collapseAllJson":"折叠","expandAllJson":"展开","viewBlame":"查看每行代码的修改记录","viewDiff":"查看相对 HEAD 的改动","exitDiff":"退出 Diff","diffLoadFailed":"加载差异失败","editFile":"编辑文件","backToPreview":"返回预览","cannotPreview":"无法预览此文件","selectFileToPreview":"选择文件以预览","staged":"已暂存","unstaged":"未暂存","selectFileToViewDiff":"选择文件查看差异","loadingDiffContent":"加载差异中...","clickCompareToLoad":"点击「对比」加载分支差异","selectCommitToView":"选择提交查看详情","confirmDelete":"确认删除","confirmDeleteMessage":"确定要将 <file>{{name}}</file> 移动到回收站吗?","nFilesNMatches":"{{files}} 个文件,{{matches}} 处匹配","resultsTruncated":"结果已截断","noContentSearchResults":"无匹配结果","enterKeywordToSearch":"输入关键词搜索文件内容","searchMinChars":"搜索内容至少需要 2 个字符"},"csv":{"table":"表格","raw":"原始内容","empty":"空表格","summary":"{{rows}} 行 \xb7 {{cols}} 列","summaryFiltered":"匹配 {{rows}} / {{total}} 行 \xb7 {{cols}} 列","loadMore":"加载更多(已显示 {{shown}} / {{total}})","filterPlaceholder":"筛选内容…","filterColumn":"筛选列","clearFilter":"清除筛选","allColumns":"全部列","noMatch":"没有匹配的行","sortHint":"点击排序(升序 / 降序 / 取消)"},"codeViewer":{"fileModifiedExternally":"文件已被外部修改,保存将覆盖外部更改","useDiskVersion":"使用磁盘版本","forceOverwrite":"强制覆盖","searchPlaceholder":"搜索...","caseSensitive":"区分大小写","wholeWordMatch":"全字匹配","unsavedConfirm":"有未保存的修改,确定关闭?","discardChanges":"放弃修改","continueEditing":"继续编辑","unsavedExitConfirm":"有未保存的修改,确定退出编辑模式?","clickToViewDetails":"点击查看详情","clickToViewCommit":"点击查看 commit 详情","nComments":"{{count}} 条评论","searchChat":"搜索聊天内容...","prevShiftEnter":"上一个 (Shift+Enter)","nextEnter":"下一个 (Enter)","closeEsc":"关闭 (Esc)"},"chat":{"commandRefs":"附带 {{count}} 个引用","commandRef_read":"读取","commandRef_handoff":"转交","commandRef_handoffMixed":"转交","commandRef_targets":"目标","commandRef_inline":"内嵌","originSent":"来自 {{project}} 的 @ 消息","originDelegated":"由 {{project}} 委派","originUnknown":"另一个会话","decisionContextAttached":"附带了 {{count}} 条相关决策","codexInput":{"queued":"追加消息等待发送","accepted":"Codex 已接受追加消息","failed":"追加消息发送失败或未确认,请打开详情查看","images":"图片:{{count}} 张"},"recoveryCopy":"失败运行的恢复副本","recoveryCopyHint":"这是运行期间观察到的内容的临时副本,可能与已保存的历史重复,不会发送给模型。仅在本对话保持打开期间保留。","recoveryCopiesLabel":"失败运行的恢复副本","recoveryAttachment":"恢复副本附件","startConversation":"开始对话吧","loadMoreHistory":"加载更多...","scrollUpForMore":"↑ 向上滚动加载更多历史","jumpToStart":"跳转到开始","jumpToLatest":"跳转到最新","jumpToPrevUserMessage":"上一条用户消息","jumpToNextUserMessage":"下一条用户消息","recentUserMessages":"最近的用户消息","moreUserMessages":"更多","userMessage":"用户消息","recentUserMessageNumber":"最近用户消息 {{index}}/{{total}}","imageMessage":"图片消息","copyMessage":"复制消息","copyImage":"复制图片","copiedImage":"已复制图片","forkSession":"从此处分叉会话","excerptTurn":"摘录本轮到新会话","newSession":"新建会话","continueFromHere":"延续到此处","continueFromHereDesc":"保留截至本轮的全部上下文","onlyThisTurn":"仅提取本轮","onlyThisTurnDesc":"只带这一轮问答","onlyThisTaskDesc":"保留整个任务,包含全部 {{count}} 条输入及回答","deleteTurn":"删除本轮","deletingTurn":"正在删除…","deleteTurnConfirm":"确定删除这一轮的问题、回答及工具记录吗?此操作无法撤销。","deleteTaskConfirm":"本任务包含 {{count}} 条用户输入(含追加输入)。确定删除整个任务的全部输入、回答及工具记录吗?此操作无法撤销。","deleteTurnConfirmAction":"删除本轮","deleteTurnWhileRunning":"会话运行期间不能删除","sendToPeerPane":"发送本条消息到另一栏","imageN":"图片 {{index}}","imagePreview":"图片预览","imageLoadFailed":"无法加载此图片","toolCalls":"{{count}} 个工具调用","collapse":"▲ 收起","expand":"▼ 展开","showMore":"显示更多","showLess":"收起","subagent":"子代理","piChildStatus":{"interrupted":"中断快照","truncated":"已截断","running":"运行中","done":"已完成","failed":"失败","cancelled":"已取消"},"subagentEmpty":"未找到子代理消息记录","subagentViewTitle":"查看子代理执行过程","workflowRun":"运行详情","workflowViewTitle":"查看工作流运行详情","workflowEmpty":"未找到工作流运行记录","workflowAgents":"个代理","workflowViewAgent":"查看","workflowUngrouped":"未分组","viewQuestions":"查看提问","viewAllFileChanges":"查看所有文件变更","requestFailed":"请求失败","cannotReadStream":"无法读取响应流","errorRetry":"发生错误,请重试","codexResumeFailed":"原会话被其他 Codex 客户端占用,已新建会话,历史未继承","codexResumeFailedPrevious":"原会话","codexResumeFailedNew":"新会话","codexContextCompacting":"Codex 正在压缩上下文…","placeholder":"输入消息,/ 调用 skill,@ 调用机器人","placeholderDisabled":"生成中... 可继续输入 (ESC 取消;卡住太久可取消后重发「继续」)","placeholderRunning":"生成中... 回车即发送,会在当前回复的下一步插入(ESC 停止)","imageSizeLimit":"图片大小超过限制(最大 5MB),当前大小: {{size}}MB","viewGitChanges":"查看 Git 变更","viewAllComments":"查看所有评论","userMessages":"用户消息列表","projectNotes":"项目笔记","scheduledTasks":"定时任务","quickInstructions":"快捷指令","globalInstructions":"全局指令","projectInstructions":"项目指令","noQuickInstructions":"暂无快捷指令","addQuickInstruction":"新增快捷指令","quickInstructionPlaceholder":"输入一句话指令,Enter 保存,Esc 取消","insertQuickInstruction":"填入输入框(不发送)","addInstructionGroup":"新增分组","instructionGroupNamePlaceholder":"输入分组名,Enter 保存,Esc 取消","instructionGroupLabel":"所属分组","instructionGroupNone":"不分组","deleteInstructionGroupConfirm":"删除分组「{{name}}」会同时删除组内 {{count}} 条指令,确定继续?","editGlobalInstructions":"编辑全局指令","editProjectInstructions":"编辑项目指令","quickInstructionsMarkdownHint":"一级内容每行一条;分组名称后的「- 」开头行是该分组的子命令;单条指令内的换行用 \\\\n 表示。","quickInstructionsMarkdownPlaceholder":"按推荐实施\\n用文本画图\\n- 画一个登录流程\\n- 画一个系统架构","quickInstructionsMarkdownError":"第 {{line}} 行格式不正确。","savingQuickInstructions":"保存中...","saveQuickInstructionsFailed":"保存失败,修改仍然保留,请重试。","context":"上下文","output":"输出","copiedCommandTooltip":"已复制!","copyCommandTooltip":"复制命令: {{command}}","executedCommand":"执行了 `{{command}}`{{exitInfo}},输出:\\n```\\n{{output}}\\n```","executedCommandFailed":"执行 `{{command}}` 失败:{{error}}","executionMode":"执行模式","checkBalance":"查询余额","balanceFailed":"查询失败,请检查 API Key","balanceNeedsKey":"请先配置 DeepSeek API Key","balanceUnavailable":"账户当前不可用","balanceEmpty":"接口未返回余额","openUsagePage":"打开 DeepSeek 用量控制台","checkQuota":"查询额度","quotaFailed":"额度查询失败,请检查 API Key","quotaNeedsKey":"请先设置 API Key","quotaEmpty":"未返回额度信息","quotaResetAt":"{{time}} 重置","openProviderConsole":"打开服务商控制台","planMode":"计划模式","planModeDesc":"只读,先出计划不改代码","planModeOn":"已开启计划模式——只读;发一个任务即可拿到计划","planModeOff":"已关闭计划模式","planModeHint":"计划模式:只读探索、产出计划但不改文件。取消勾选后重发才会实现。","noHistory":"不带历史上下文","noHistoryDesc":"每次提问均独立","noHistoryHint":"不带历史上下文:每条消息单独发给模型,不带之前的对话。上方的会话记录照常保留。","planTitle":"计划(待你确认)","approvePlan":"批准并执行","planApproveHint":"本环境无审批弹窗,点此退出计划模式并执行","approvePlanPrompt":"已批准,按上述计划开始执行。","maximizePane":"放大本栏","restorePane":"还原双栏","closePane":"关闭本栏","singlePane":"切回单栏","splitPane":"并排双栏"},"console":{"enterCommandOrUrl":"输入命令或网址开始使用","emptyIntro":"在下方输入框输入以下内容,即可创建对应气泡:","bubbleCommand":"命令","bubbleInteractive":"交互终端","bubbleBrowser":"浏览器","bubbleBrowserNoteIframe":"部分网站会拦截 iframe 嵌入,请在「设置 → 浏览器插件」安装 Cockpit Bridge 后再打开。","bubbleBrowserNoteCookie":"已登录的网站若首次显示未登录,多刷新几次即可恢复。","bubbleDatabase":"数据库","bubbleFilePreview":"文件预览","loadingMore":"加载中...","loadMoreHistory":"加载更多历史","quickCommands":"快捷命令","singleColumn":"单列布局","dualColumn":"双列布局","envVars":"环境变量","launchShell":"启动交互终端","htmlApps":"HTML 应用","inputPlaceholder":"输入命令或网址并按 Enter... (↑↓ 历史, Tab 补全)","scopeProject":"项目","scopeGlobal":"全局","tabSwitchEscClose":"Tab 切换 \xb7 Esc 关闭","copyOutput":"复制输出","copyCommand":"复制命令","rerun":"重新运行","deleteRecord":"删除记录","searchPlaceholder":"搜索...","searchMode":"搜索","filterMode":"过滤","prevShiftEnter":"上一个 (Shift+Enter)","nextEnter":"下一个 (Enter)","loadingTerminal":"加载终端...","clickToInput":"点击终端区域输入","stdinPlaceholder":"stdin 输入...","runningText":"运行中...","exitCode":"退出代码: {{code}}","totalLines":"共 {{count}} 行","globalCommands":"全局命令","projectCommands":"项目命令","noCustomCommands":"暂无自定义命令","editGlobalCommands":"编辑全局命令","editProjectCommands":"编辑项目命令","quickCommandsTextHint":"每行一条,格式为「名称: 命令」;名称只能包含字母、数字、- 和 _,第一个冒号之后都是命令。","quickCommandsTextPlaceholder":"pg: psql -h localhost -U postgres\\ngitpull: git pull --rebase","quickCommandsTextError":"第 {{line}} 行格式不正确,应为「名称: 命令」。","savingQuickCommands":"保存中...","saveQuickCommandsFailed":"保存失败,修改仍然保留,请重试。","restoreTooltip":"还原 ({{modKey}}M / ESC)","screenshotting":"截图中...","outputFileDeleted":"[输出文件已删除]"},"browser":{"blankPage":"空白页","copyUrl":"复制网址","openInNewWindow":"在新窗口打开","exitMaximize":"退出最大化 ({{modKey}}M)","maximize":"最大化 ({{modKey}}M)","pageLoadFailed":"页面加载失败","openInTabFallback":"OpenCockpit Bridge 未连接,已改用普通新标签页打开","movedToChrome":"网页现在在 Chrome 标签页中打开,不再放在 Console 里。","openInChrome":"在 Chrome 中打开","openedInChrome":"已在 Chrome 中打开 —— {{command}}","clickToWake":"点击唤醒","sleeping":"已休眠","loadingPage":"加载中...","loadFailed":"加载失败"},"database":{"connectionFailed":"连接失败","connected":"已连接","connecting":"连接中...","refreshTableList":"刷新表列表","filterTable":"T 表","filterView":"V 视图","noTables":"无表","tabStructure":"结构","tabData":"数据","tabSql":"SQL","filterActive":"筛选: {{count}}列","clearAllFilters":"清除所有筛选","deleteNRows":"删除 {{count}} 行","confirmDeleteRows":"确认删除?","copyCsvSelected":"复制选中行为 CSV","copyCsvAll":"导出全表 CSV","copyJsonSelected":"复制选中行为 JSON","copyJsonAll":"导出全表 JSON","copyCSV":"复制 CSV","CSV":"CSV","copyJSON":"复制 JSON","JSON":"JSON","selectTable":"选择左侧表格","selectTableToView":"选择表以查看结构","selectTableForData":"选择表以查看数据","columns":"列","colName":"名称","colType":"类型","colNullable":"可空","colDefault":"默认值","primaryKey":"主键","foreignKeys":"外键","indexes":"索引","enable":"启用","commaValues":"逗号分隔多值","likePattern":"%pattern%","valuePlaceholder":"值","apply":"应用","clearFilter":"清除","addRow":"+ 新增行","totalRows":"{{count}} 行","rowsAffected":"{{command}} — {{count}} 行受影响 ({{duration}}ms)","queryRows":"{{count}} 行 ({{duration}}ms)","resultTruncated":"[结果已截断至1000行]","sqlPlaceholder":"输入 SQL... ({{modKey}}Enter 执行)","executing":"执行中...","execute":"▶ 执行","deleteRowsFailed":"{{count}} 行删除失败","inputParams":"输入参数","resultLabel":"结果"},"mysql":{"connectionFailed":"连接失败","connected":"已连接","connecting":"连接中...","refreshTableList":"刷新表列表","filterTable":"T 表","filterView":"V 视图","noTables":"无表","tabStructure":"结构","tabData":"数据","tabSql":"SQL","filterActive":"筛选: {{count}}列","clearAllFilters":"清除所有筛选","deleteNRows":"删除 {{count}} 行","confirmDeleteRows":"确认删除?","copyCsvSelected":"复制选中行为 CSV","copyCsvAll":"导出全表 CSV","copyJsonSelected":"复制选中行为 JSON","copyJsonAll":"导出全表 JSON","copyCSV":"复制 CSV","CSV":"CSV","copyJSON":"复制 JSON","JSON":"JSON","selectTable":"选择左侧表格","selectTableToView":"选择表以查看结构","selectTableForData":"选择表以查看数据","columns":"列","colName":"名称","colType":"类型","colNullable":"可空","colDefault":"默认值","primaryKey":"主键","foreignKeys":"外键","indexes":"索引","enable":"启用","commaValues":"逗号分隔多值","likePattern":"%pattern%","valuePlaceholder":"值","apply":"应用","clearFilter":"清除","addRow":"+ 新增行","totalRows":"{{count}} 行","rowsAffected":"{{command}} — {{count}} 行受影响 ({{duration}}ms)","queryRows":"{{count}} 行 ({{duration}}ms)","resultTruncated":"[结果已截断至1000行]","sqlPlaceholder":"输入 SQL... ({{modKey}}Enter 执行)","executing":"执行中...","execute":"▶ 执行","deleteRowsFailed":"{{count}} 行删除失败"},"redis":{"neverExpires":"永不过期","expired":"已过期","loadFailed":"加载失败","deleteFailed":"删除失败","saveFailed":"保存失败","scanPlaceholder":"SCAN 模式...","scanSearch":"搜索 (SCAN)","noKeys":"无 key","loadMore":"加载更多...","tabData":"数据","tabInfo":"信息","tabCli":"CLI","selectKey":"选择左侧 Key","keyNotExist":"Key 不存在","unsupportedType":"不支持的类型: {{type}}","nItems":"{{total}} items","showingN":"显示 {{count}}","nMembers":"{{total}} members","nEntries":"{{total}} entries","cliHint":"输入 Redis 命令,如 PING, GET key, KEYS *","cliPlaceholder":"输入命令..."},"git":{"switchBranch":"切换分支","searchBranch":"搜索分支...","noBranches":"无可切换分支","noMatchingBranches":"无匹配分支","localBranches":"本地分支","remoteBranches":"远程分支","branchNotFound":"未找到分支","selectBranch":"选择分支...","currentBranch":"当前","notGitRepo":"当前目录不是 Git 仓库","cannotGetBranches":"无法获取分支信息","getBranchesFailed":"获取分支信息失败","discardAllConfirm":"确定要放弃工作区的 {{count}} 个文件的变更吗?此操作不可恢复。","worktree":{"title":"Git Worktree","count":"{{count}} 个 worktree","selectBranch":"选择分支","addWorktree":"+ 添加 Worktree","confirmDelete":"确认删除","confirmDeleteMsg":"确定要删除 worktree 吗?","path":"路径:","branch":"分支:","locked":"已锁定","unlock":"解锁","lock":"锁定","searchBranch":"搜索分支...","noBranches":"无可用分支"}},"comments":{"addComment":"添加评论","lineRange":"行 {{start}}-{{end}}","inputPlaceholder":"输入评论...","newComment":"新评论 {{range}}","commentPlaceholder":"输入评论... ({{modKey}}Enter 提交, Esc 取消)","nComments":"{{count}} 条评论","allComments":"所有评论","copyAllComments":"复制全部评论","noComments":"暂无评论","clearAll":"清空所有","totalComments":"共 {{count}} 条评论","aiReply":"AI 回复","noContent":"(无内容)","linesCount":"({{count}} 行)","codeRef":"以下是我标注的评论和引用:","note":"备注: {{content}}","submitting":"提交中...","enterSubmit":"Enter 提交 \xb7 Shift+Enter 换行","submitComment":"提交评论","askAI":"提问 AI","inputQuestion":"输入你的问题...","aiGenerating":"正在生成中,请稍候...","enterSend":"Enter 发送 \xb7 Shift+Enter 换行","sendToAI":"发送 AI","aiResponding":"AI 正在响应中..."},"fileContextMenu":{"createFile":"新建文件","copyFile":"复制文件","copyFolder":"复制文件夹","pasteHere":"粘贴到此处","deleteFile":"删除文件","deleteFolder":"删除文件夹","copyRelativePath":"复制相对路径","copyAbsolutePath":"复制绝对路径","copyRelativeDirPath":"复制相对文件夹路径","copyAbsoluteDirPath":"复制绝对文件夹路径","copyFileName":"复制文件名","copyFolderName":"复制文件夹名"},"settings":{"title":"设置","theme":"主题","themeLight":"浅色","themeDark":"深色","themeSystem":"跟随系统","browserExtension":"浏览器插件","extensionInstalled":"OpenCockpit Bridge 已连接","extensionNotInstalled":"OpenCockpit Bridge 未连接","extensionDescription":"让 `cockpit browser` 能操作你的 Chrome 标签页和 Console 里的浏览器气泡。每个标签页都有 id(在插件小面板和图标的悬停提示里);Cockpit 操作一个你还没允许的标签页前会先问你,按标签页逐个授权。","installSteps":"安装步骤:","step1":"1. 打开 Chrome 地址栏输入","step2":"2. 开启右上角「开发者模式」","step3":"3. 点击「加载已解压的扩展程序」","step4mac":"4. 按 <kbd>Cmd+Shift+G</kbd> → 粘贴下方路径 → 回车","copyExtensionPath":"复制插件目录路径","reloadExtension":"重载插件","about":"关于","language":"语言","languageAuto":"跟随系统","switchDark":"切换暗色","switchLight":"切换亮色","agentsBundled":"内置","codexSection":"Codex","codexSuggestions":"预测下一句","codexSuggestionsDescription":"每轮回复后让 Codex 猜你下一句要说什么,显示在输入框里(按 Tab 采用)。每轮会多一次小请求。"},"editor":{"placeholder":"写点什么... 输入 / 打开快捷命令","noteTitle":"{{name}} - 笔记","noteUntitled":"笔记","globalNote":"全局笔记","emptyNote":"空笔记","searchNotes":"搜索笔记...","saving":"保存中...","conflictReloaded":"笔记已被其他地方修改,已加载最新版本,刚才未保存的编辑已丢弃","linkPlaceholder":"输入链接地址...","confirmLink":"确认","removeLink":"移除链接","heading1":"标题 1","heading2":"标题 2","heading3":"标题 3","bold":"粗体","italic":"斜体","strikethrough":"删除线","inlineCode":"行内代码","link":"链接","bulletList":"无序列表","orderedList":"有序列表","taskList":"待办列表","blockquote":"引用","codeBlock":"代码块","table":"表格","horizontalRule":"分割线","insertRowAbove":"在上方插入行","insertRowBelow":"在下方插入行","insertColumnLeft":"在左侧插入列","insertColumnRight":"在右侧插入列","deleteRow":"删除当前行","deleteColumn":"删除当前列","deleteTable":"删除表格","deleteCodeBlock":"删除代码块","toc":"目录","expandToc":"展开目录","collapseToc":"收起目录"},"slashCommands":{"heading1":"标题 1","heading1Desc":"大标题","heading2":"标题 2","heading2Desc":"中标题","heading3":"标题 3","heading3Desc":"小标题","bulletList":"无序列表","bulletListDesc":"项目符号列表","orderedList":"有序列表","orderedListDesc":"编号列表","taskList":"待办列表","taskListDesc":"可勾选的任务列表","blockquote":"引用","blockquoteDesc":"引用块","codeBlock":"代码块","codeBlockDesc":"代码片段","table":"表格","tableDesc":"插入 3\xd73 表格","horizontalRule":"分割线","horizontalRuleDesc":"水平分割线","link":"链接","linkDesc":"插入超链接"},"commands":{"plan":"开启计划模式 \xb7 /plan <任务> 直接规划该任务 \xb7 /plan off 关闭"},"markdown":{"copied":"✓ 已复制","copy":"复制"},"imagePreview":{"previewImage":"预览图片","deleteImage":"删除图片","copyImage":"复制图片","copiedImage":"已复制图片"},"tokenStats":{"title":"Claude Code Token 统计","activeHours":"活跃时段分布","hourSessions":"{{h}}:00 — {{count}} 次会话","messages":"消息","toolCalls":"工具调用","activityTrend":"活动趋势","byModel":"按模型","tokenUsage":"Token 用量","equivalentCost":"等效费用","modelCostDetail":"模型费用明细","model":"模型","share":"占比","total":"合计","totalSessions":"总会话","totalMessages":"总消息","equivalentApiCost":"等效 API 费用","longestSession":"最长会话","firstUse":"首次使用","notFound":"未找到 ~/.claude/stats-cache.json","day":"日","week":"周","month":"月"},"toolCall":{"inputParams":"输入参数","resultLabel":"结果","inputParamsTitle":"查看输入参数","resultTitle":"查看结果","input":"输入","result":"结果","details":"详细","detailsTitle":"查看输入与结果","foldedLines":"... ({{count}} 行)"},"fileEditor":{"unsavedConfirm":"有未保存的修改,确定关闭?","discardChanges":"放弃修改","continueEditing":"继续编辑","externallyModified":"文件已被外部修改,保存将覆盖外部更改","useDiskVersion":"使用磁盘版本","forceOverwrite":"强制覆盖"},"quickFileOpen":{"placeholder":"输入文件名快速打开...","noMatch":"没有匹配的文件","recent":"最近","selectHint":"选择","openHint":"打开","closeHint":"关闭"},"envManager":{"title":"环境变量管理","tabScope":"当前 Tab 专用","globalScope":"全局环境变量","varNamePlaceholder":"变量名(如 NODE_ENV)","varValuePlaceholder":"值(如 production)","valuePlaceholder":"值","noVars":"还没有环境变量,添加一个试试"},"aliasManager":{"title":"命令别名管理","description":"为常用命令设置快捷别名(全局生效)","aliasPlaceholder":"别名(如 ll)","commandPlaceholder":"完整命令(如 ls -la)","fullCommandPlaceholder":"完整命令","usage":"使用提示:","usageDesc":"输入别名即可执行对应的完整命令","noAliases":"还没有命令别名,添加一个试试"},"diffViewer":{"fileChanges":"文件变更 ({{count}})","expandFull":"扩展到全屏","exitFull":"回到分栏","openFull":"默认全屏","openFullOn":"已开启:文件变更默认全屏打开(点击改为默认半屏)","openFullOff":"已关闭:文件变更默认半屏打开(点击改为默认全屏)","toggleFileTree":"切换文件目录","selectFileToView":"选择左侧文件查看变更","sideBySide":"并列对比","unified":"统一对比","viewSplit":"双栏","viewUnified":"单栏","previewFile":"预览文件","copiedAll":"已复制全文","compact":"精简","full":"全文","gap":{"hidden":"已隐藏 {{count}} 行","more":"\xb7\xb7\xb7 更多 +{{count}} \xb7\xb7\xb7","expandUp":"向上展开 {{count}} 行","expandDown":"向下展开 {{count}} 行","expandAll":"点击展开 {{count}} 行"},"loadingSnapshots":"正在加载快照…","loadingFile":"正在加载文件差异…","fileLoadFailed":"无法加载文件差异","noChanges":"本轮未检测到文件变更","notViewable":"二进制或超大文件,无法展示 diff","externalChange":"同期其他会话/外部进程的变更","reconstructed":"参数重建","reconstructedHint":"由工具调用参数重建,非磁盘快照","truncated":"文件过多,仅显示部分","aggregate":"汇总","openAggregate":"默认汇总","openAggregateOn":"已开启:文件变更默认打开汇总(点击改为默认逐次调用)","openAggregateOff":"已关闭:文件变更默认逐次调用(点击改为默认汇总)","aggregateOn":"查看全部调用的累计变更","aggregateOff":"返回逐次调用","fileChangesAggregate":"文件变更 ({{count}}) \xb7 汇总","aggregateSummary":"{{count}} 个文件变更({{calls}} 次调用累计)","aggregateLoading":"正在汇总变更…","aggregateEmpty":"累计后无净变更","aggregateUnavailable":"无快照,无法汇总","aggregateFailed":"汇总失败","aggregateBaselineSkipped":"已跳过基线变化及之前的 {{count}} 次调用","aggregateBaselineIncluded":"已计入基线变化及之前的 {{count}} 次调用","callsBaselineHidden":"已隐藏 {{count}} 次基线变化调用","callsBaselineShown":"已显示 {{count}} 次基线变化调用","aggregateSkippedHint":"执行了 git rebase / pull / checkout 等切换基线命令的调用视为基线变化(换分支、拉代码,而非编写代码);汇总从最后一次基线变化之后开始。点击切换是否计入","imageBefore":"变更前","imageAfter":"变更后","imageAdded":"新增","imageDeleted":"已删除","imageLoadFailed":"图片加载失败","imageUnavailable":"该版本无此图片"},"commitDetail":{"title":"提交详情","hash":"哈希:","author":"作者:","date":"日期:","files":"文件:","nChanges":"{{count}} 个变更","loadingFiles":"加载文件中...","noFileChanges":"无文件变更","loadingDiff":"加载差异中...","selectFileToView":"选择文件查看差异"},"askQuestion":{"title":"提问","nQuestions":"{{count}} 个问题","checkedN":"已勾选 {{count}}","copyChecked":"复制勾选的 {{count}} 个问答","copyAll":"复制所有问答","sendChecked":"发送勾选的 {{count}} 个问答给 AI","sendAll":"发送所有问答给 AI","sendNoChat":"没有可用的聊天会话","checkToCopy":"勾选以复制","custom":"自定义","customPlaceholder":"输入自定义回答...","notSelected":"(未选择)"},"tabBar":{"closeTab":"关闭会话","closeAll":"关闭所有会话","newTab":"新会话"},"tabManagerTopBar":{"copyPageUrl":"复制页面地址","copyDirPath":"复制目录路径","refreshProject":"刷新当前项目","openInVSCode":"在 VS Code 中打开","openInCursor":"在 Cursor 中打开","aliasesGlobal":"命令别名(全局)","tokenStats":"Token 统计","openSurething":"打开 Surething","openOnPhone":"在手机上打开","phoneQrHint":"用手机扫码打开 Cockpit","phoneQrSessionHint":"用手机扫码打开当前会话","phoneQrTokenWarning":"二维码包含访问令牌,请勿外传","phoneQrFailed":"二维码生成失败"},"hoverTooltip":{"findReferences":"查找引用","search":"搜索"},"todoViewer":{"title":"任务列表","progress":"{{completed}} / {{total}} 完成"},"userMessages":{"title":"用户消息列表","noMessages":"暂无用户消息","searchPlaceholder":"搜索用户消息…","noResults":"没有匹配的消息","loadFailed":"加载失败","count":"{{shown}} / {{total}} 条","jumping":"正在加载该消息所在的对话…"},"shortIdBadge":{"clickToDisconnect":"点击断开连接","clickToRegister":"点击注册并复制 CLI 命令","setTitle":"给这个气泡命名(便于 /cc 通过 connection list 找到它)","setTitlePlaceholder":"设置标题","editTitle":"编辑标题","titleSet":"标题:{{title}}","dialogTitle":"给气泡命名","dialogPlaceholder":"例如:alloydb 代理、预发管理后台"},"api":{"pathForbidden":"不允许操作此路径","deleteForbidden":"不允许删除此路径","notAFolder":"目标不是文件夹","imageTooLarge":"图片文件过大,无法预览","cannotPreviewBinary":"无法预览二进制文件","fileTooLarge":"文件过大,无法预览(超过 10MB)","fileModifiedExternally":"文件已被外部修改"},"folderPicker":{"title":"打开文件夹","placeholder":"输入或粘贴路径,如 ~/Work/my-app","open":"打开","showHidden":"显示隐藏目录","hint":"↑↓ 选择 \xb7 Tab/回车 进入 \xb7 ⌘/Ctrl+回车 打开","empty":"没有子文件夹","noMatch":"没有匹配的文件夹","notFound":"文件夹不存在","notDirectory":"不是文件夹","denied":"没有访问权限。macOS 上请在 系统设置 › 隐私与安全性 中授权。"},"confirm":{"title":"提示","ok":"确定","cancel":"取消"},"floatingToolbar":{"addComment":"添加评论","sendToAI":"发送 AI","search":"搜索"},"quickReply":{"optionA":"A","optionB":"B","optionC":"C","optionD":"D","allRecommended":"其他按推荐","thisOne":"就这个","notThis":"不要这样","why":"为什么","elaborate":"展开说","example":"举个例子","start":"开始做","continue":"继续","ok":"OK","done":"做完了","edit":"编辑快捷短语","editTitle":"编辑快捷短语","editHint":"一行对应面板的一行,行内用逗号分隔。每个短语会原样发送到对话。","editPlaceholder":"就这个,不要这样\\n为什么,展开说","restoreDefault":"恢复默认","save":"保存","cancel":"取消","customizedFor":"当前编辑的是{{lang}}短语,另一种语言不受影响。","langEn":"英文","langZh":"中文","saveFailed":"保存快捷短语失败"},"searchResults":{"title":"搜索结果","nMatches":"({{count}} 处匹配)","searching":"搜索中...","noResults":"无匹配结果","scopeSelected":"选中","scopeAll":"全部"},"references":{"title":"引用","searching":"搜索中...","notFound":"未找到引用"},"gitFileTree":{"noFiles":"无文件"},"deps":{"action":"依赖关系","none":"无","symbolMessage":"分析 {{name}} ({{path}}:{{lines}}) 的依赖关系。\\n\\n调用者:{{callers}}\\n调用了:{{callees}}\\n外部依赖:{{externals}}\\n\\n请说明它耦合在哪些模块上,以及哪些依赖是可以收敛掉的。"},"explain":{"action":"解释一下","fileMessage":"解释一下 {{path}}","symbolMessage":"解释一下 {{name}} ({{path}}:{{lines}})","selectionMessage":"解释一下","commitFileMessage":"解释一下 git commit {{hash}} 对 {{path}} 的改动","compareFileMessage":"解释一下 git {{base}}...HEAD 中 {{path}} 的改动","compareFileWorktreeMessage":"解释一下 {{path}} 相对 {{base}} 的改动(含未提交的部分)","stagedFileMessage":"解释一下 git 暂存区中 {{path}} 的改动","unstagedFileMessage":"解释一下 git 工作区中 {{path}} 的改动"},"bots":{"sessionBadge":"会话","sessionGroup":"会话 Bot","sessionGroupHint":"在会话的改名框里勾选「可被 @ 调用」的会话;@ 它会把任务发进这个会话","sessionGone":"会话已不存在","sessionNameInvalid":"标题不能用作名字(多行或含 @),改个名字才能 @","sessionUsage":"在任意会话里写「@{{name}} 任务」把任务发进这个会话","removeSession":"移出 Bots","title":"机器人","search":"搜索机器人","addExisting":"添加机器人","addTooltip":"添加为机器人","emptyNoMatch":"没有匹配的机器人。","emptyNoBots":"还没有你自己的机器人。","emptyCreatePrefix":"在聊天里使用","emptyCreateSuffix":"创建一个。","emptyAddExisting":"添加已有的机器人目录","invalid":"无效","builtin":"内置","mine":"我的","tabFiles":"文件","tabSessions":"会话","noSessions":"最近没有这个机器人的会话","sessionsScope":"在它目录里运行的全部会话,以及它最近派发出去的会话","selectHint":"选择左侧机器人,查看它的文件和会话","remove":"移除注册","open":"作为项目打开","pathPlaceholder":"机器人目录或其 BOT.md 的绝对路径","addHint":"目录中必须包含 BOT.md,不会改动其中的文件。","added":"机器人已添加","alreadyAdded":"已添加过","removed":"已移除机器人注册,目录文件仍保留。","loadFailed":"加载机器人失败","saveFailed":"添加机器人失败","removeFailed":"移除机器人失败"},"contextInspector":{"title":"会话上下文","open":"查看上下文内容","used":"已用","window":"窗口","free":"剩余","unknownWindow":"窗口大小未知","capturedAt":"统计于 {{time}}","refresh":"刷新","loadFailed":"读取上下文失败","noSession":"会话还没有开始,暂无上下文","empty":"没有可展示的上下文条目","selectItem":"点左侧条目查看具体内容","noContent":"该引擎没有暴露这一项的原文,只有名称和 token 数","truncated":"内容过长,只显示前 {{count}} 个字符","estimated":"≈ 为按字符估算","items":"{{count}} 项","copy":"复制","copied":"已复制","groups":{"prompt":"提示词","memory":"记忆文件","tools":"工具","skills":"Skills 与 Agents","messages":"消息","tool_io":"工具调用","reasoning":"推理","other":"其他"},"categories":{"system":"System prompt","instructions":"附加指令","memory":"记忆文件","tools":"工具定义","mcp":"MCP 工具","skills":"Skills","agents":"自定义 Agents","environment":"环境信息","messages":"对话消息","tool_io":"工具调用与结果","reasoning":"推理内容","summary":"压缩摘要","other":"其他"},"notes":{"system_prompt_hidden":"System prompt 由引擎内部拼接,不对外提供原文,这里只列出各段名称和 token 数。","tool_schemas_hidden":"内置工具只提供名称和 token 数,不提供 schema 原文。","skills_listing_only":"Skills 在上下文里只占名称和描述;完整内容要等调用时才加载。","snapshot_from_last_turn":"分类数据是上一轮结束时记录的,不是实时数据。","no_snapshot_yet":"这个会话还没有记录过分类快照,下一轮对话结束后会有精确的分类数据;当前显示的是从记录中估算的结果。","reasoning_encrypted":"部分推理或压缩内容是加密的,看不到原文,也无法估算大小。","after_compaction":"会话已压缩过,这里只包含最近一次压缩之后的内容。","estimated_breakdown":"各分类的 token 数是估算值,顶部的总数以引擎上报为准。","usage_unknown":"引擎没有上报这个会话的上下文大小。"}}}');r.Ay.isInitialized||r.Ay.init({resources:{en:{translation:s},zh:{translation:o}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});let a=r.Ay},69895:(e,t,n)=>{n.d(t,{P:()=>c});var r=n(12115),s=n(49433),o=n(86957),a=n(82680),l=n(88292),i=n(75346);let d=s.$mh({try:async()=>{let e=await fetch("/api/pinned-sessions");if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()},catch:e=>new a.uV({message:"Cannot load favorites",cause:e})});function c(){let[e,t]=(0,r.useState)([]),n=(0,r.useRef)(0),c=(0,r.useRef)(0),u=(0,r.useRef)(0),m=(0,r.useMemo)(()=>s.RIP(1),[]),h=(0,r.useCallback)(()=>{if(c.current>0)return;let e=n.current,r=++u.current;o.t4.runPromise(d.pipe(s.YWq({onSuccess:s=>{r===u.current&&e===n.current&&0===c.current&&t(s.sessions||[])},onFailure:()=>{}})))},[]);(0,r.useEffect)(()=>{h()},[h]),(0,r.useEffect)(()=>{let e=e=>{e.data?.type==="PINNED_SESSIONS_CHANGED"&&h()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[h]);let p=(0,r.useCallback)(e=>{n.current++,c.current++,t(e),o.t4.runFork(m.withPermits(1)(s.$mh({try:async()=>{let t=await fetch("/api/pinned-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessions:e})});if(!t.ok)throw Error(`HTTP ${t.status}`)},catch:e=>new a.uV({message:"Cannot save favorites",cause:e})}).pipe(s.Mim(()=>s.qIB(l.d,e=>e.publish(i.n.PinnedSessionsChanged,{}))))).pipe(s.yeE(s.OH5(()=>{c.current--})),s.h9N(e=>s.FFw("Cannot save favorites",e).pipe(s.Mim(()=>s.OH5(h))))))},[h,m]),f=(0,r.useCallback)(t=>e.some(e=>e.sessionId===t),[e]),g=(0,r.useCallback)((t,n,r)=>{e.some(e=>e.sessionId===t)||p([...e,{sessionId:t,cwd:n,title:r}])},[e,p]),x=(0,r.useCallback)(t=>{p(e.filter(e=>e.sessionId!==t))},[e,p]);return{pinnedSessions:e,isPinned:f,pinSession:g,unpinSession:x,reorder:(0,r.useCallback)(e=>{p(e)},[p]),reload:h}}},69924:(e,t,n)=>{n.d(t,{B:()=>s});var r=n(95155);function s({href:e,target:t,onClick:n,newTab:o=!1}){return(0,r.jsxs)("a",{href:e,title:`${t.cwd}
|
|
733
|
+
${t.sessionId}`,className:"inline-flex items-center gap-1 px-1.5 rounded bg-brand/10 hover:bg-brand/20 text-brand text-[0.9em] align-baseline whitespace-nowrap no-underline",onClick:n,...o?{target:"_blank",rel:"noopener noreferrer"}:{},children:[(0,r.jsx)("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:(0,r.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),t.sessionId.slice(0,8)]})}},70188:(e,t,n)=>{n.d(t,{Ee:()=>m,SU:()=>d,ft:()=>u,iN:()=>c});var r=n(95155),s=n(12115),o=n(79114),a=n(47650),l=n(34075);let i=(0,s.createContext)(null);function d({container:e,children:t}){return(0,r.jsx)(i.Provider,{value:e,children:t})}function c(){return(0,s.useContext)(i)}function u({x:e,y:t,path:n,cwd:d,isDirectory:c,onClose:m,onCreateFile:h,onDelete:p,onRefresh:f,onCopyFile:g,onPaste:x,onExplain:b,explainDisabled:v}){let{t:y}=(0,o.Bd)(),w=(0,s.useRef)(null),k=(0,s.useContext)(i),C=n.split("/").pop()||n,j=`${d}/${n}`,N=n.includes("/")?n.substring(0,n.lastIndexOf("/")):"",S=N?`${d}/${N}`:d,T=c?n:N,E=c?j:S;(0,s.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&m()},t=e=>{"Escape"===e.key&&m()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[m]);let[R,M]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(w.current&&k){let n=k.getBoundingClientRect(),r=w.current.getBoundingClientRect(),s=e-n.left,o=t-n.top;s=Math.min(s,n.width-r.width-8),o=Math.min(o,n.height-r.height-8),M({x:s=Math.max(8,s),y:o=Math.max(8,o)})}else if(w.current){let n=w.current.getBoundingClientRect();M({x:Math.max(8,Math.min(e,window.innerWidth-n.width-8)),y:Math.max(8,Math.min(t,window.innerHeight-n.height-8))})}},[e,t,k]);let L=(0,s.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(e),(0,l.oR)(y("toast.copiedName",{name:t}),"success")}catch{(0,l.oR)(y("toast.copyFailed"),"error")}m()},[m,y]),I=c?n:N,A=!!b&&!c,F=[{label:y("fileContextMenu.copyRelativePath"),value:n},{label:y("fileContextMenu.copyAbsolutePath"),value:j},{label:y("fileContextMenu.copyRelativeDirPath"),value:T||"."},{label:y("fileContextMenu.copyAbsoluteDirPath"),value:E},{label:c?y("fileContextMenu.copyFolderName"):y("fileContextMenu.copyFileName"),value:C}],P=(0,r.jsxs)("div",{ref:w,className:"absolute z-[200] bg-card border border-border rounded-lg shadow-lv2 py-1 w-fit whitespace-nowrap",style:{left:R.x,top:R.y},children:[A&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",disabled:v,title:v?y("comments.aiResponding"):void 0,onClick:()=>{m(),b(n)},children:y("explain.action")}),A&&(0,r.jsx)("div",{className:"my-1 border-t border-border"}),h&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>{m(),h(I)},children:y("fileContextMenu.createFile")}),g&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>{m(),g(n)},children:c?y("fileContextMenu.copyFolder"):y("fileContextMenu.copyFile")}),x&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>{m(),x(I)},children:y("fileContextMenu.pasteHere")}),p&&(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-destructive hover:bg-hover transition-colors",onClick:()=>{m(),p(n,c,C)},children:c?y("fileContextMenu.deleteFolder"):y("fileContextMenu.deleteFile")}),!!(h||g||x||p)&&(0,r.jsx)("div",{className:"my-1 border-t border-border"}),F.map((e,t)=>(0,r.jsx)("button",{className:"block w-full px-3 py-1.5 text-left text-sm text-foreground hover:bg-hover transition-colors",onClick:()=>L(e.value,e.label),children:e.label},t))]});return k?(0,a.createPortal)(P,k):P}function m(){let[e,t]=(0,s.useState)(null);return{contextMenu:e,showContextMenu:(0,s.useCallback)((e,n,r)=>{e.preventDefault(),e.stopPropagation(),t({x:e.clientX,y:e.clientY,path:n,isDirectory:r})},[]),hideContextMenu:(0,s.useCallback)(()=>{t(null)},[])}}},72312:(e,t,n)=>{n.d(t,{N:()=>s});var r=n(95155);function s({cls:e}){return(0,r.jsx)("span",{className:`text-[10px] px-1 py-px rounded flex-shrink-0 ${"test"===e?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400/80":"bg-sky-500/15 text-sky-600 dark:text-sky-400/80"}`,children:e})}},73103:(e,t,n)=>{n.d(t,{k:()=>i});var r=n(95155),s=n(8601),o=n(57125),a=n(53317),l=n(95595);function i(e){let t=l.M7,n=e.model&&"grok-build"!==e.model?e.model:l.yR,i=t.models.find(e=>e.id===n),d=t.models.map(e=>({id:e.id,label:e.label,defaultValue:e.id===t.defaultModel}));d.some(e=>e.id===n)||d.unshift({id:n,label:(0,a.J)(n),defaultValue:!1});let c=i?.reasoning??t.models[0].reasoning,u=c.some(t=>t.id===e.reasoningEffort)?e.reasoningEffort:i?.defaultReasoning??l.ZL;return(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,r.jsx)(s.zC,{title:"Model",selected:n,value:i?.label??d.find(e=>e.id===n).label,items:d,onSelect:n=>{e.onModelChange?.(n),e.onReasoningEffortChange?.(t.models.find(e=>e.id===n)?.defaultReasoning??l.ZL)},icon:(0,r.jsx)(o.eV,{engine:"grok"}),testId:"grok-model-picker"}),(0,r.jsx)(s.zC,{title:"Reasoning",selected:u,value:c.find(e=>e.id===u)?.label??u,items:c.map(e=>({...e,defaultValue:e.id===(i?.defaultReasoning??l.ZL)})),onSelect:t=>e.onReasoningEffortChange?.(t),testId:"grok-reasoning-picker"})]})}},74086:(e,t,n)=>{n.d(t,{I$:()=>a,hC:()=>o,v2:()=>l});var r=n(12115),s=n(14594);function o(){let e=new Map,t=new Set,n=()=>t.forEach(e=>e());return{applyEvent(t){let r=t.tool_use_id;if(!r||t.ambient)return;let o=(0,s.Uy)(e.get(r),t);e.set(r,o),n()},getTask:t=>e.get(t),settleRunning(){let t=!1;for(let[n,r]of e)"running"===r.status&&(e.set(n,{...r,status:"unknown"}),t=!0);t&&n()},subscribe:e=>(t.add(e),()=>t.delete(e))}}let a=(0,r.createContext)({applyEvent:()=>{},getTask:()=>void 0,settleRunning:()=>{},subscribe:()=>()=>{}});function l(e){let t=(0,r.useContext)(a),n=(0,r.useCallback)(()=>e?t.getTask(e):void 0,[t,e]);return(0,r.useSyncExternalStore)(t.subscribe,n,n)}},75346:(e,t,n)=>{n.d(t,{n:()=>s});var r=n(88292);let s={SessionChange:(0,r.R)("session-change"),ViewChange:(0,r.R)("view-change"),OpenNote:(0,r.R)("open-note"),LangChange:(0,r.R)("lang-change"),TabAdd:(0,r.R)("tab-add"),TabClose:(0,r.R)("tab-close"),SwitchSession:(0,r.R)("switch-session"),ProjectChange:(0,r.R)("project-change"),OpenProject:(0,r.R)("open-project"),SessionComplete:(0,r.R)("session-complete"),OpenTokenStats:(0,r.R)("open-token-stats"),PinnedSessionsChanged:(0,r.R)("pinned-sessions-changed"),ScheduledTasksChanged:(0,r.R)("scheduled-tasks-changed"),ScreenshotPrepare:(0,r.R)("screenshot-prepare"),ScreenshotDone:(0,r.R)("screenshot-done")}},75347:(e,t,n)=>{n.d(t,{dh:()=>y,hc:()=>v,bc:()=>b});var r=n(95155),s=n(12115),o=n(47650),a=n(79114),l=n(49387),i=n(86901),d=n(49433),c=n(86957),u=n(67415),m=n(33442),h=n(2111),p=n(68287),f=n(48050),g=n(8183),x=n(99356);let b=()=>(0,s.useSyncExternalStore)(g.OS,g.V6,g.Yn);function v(){let e=(0,s.useCallback)(e=>{if("session-title-changed"===e.type&&e.data&&(0,g.X4)(e.data),"global-state"===e.type&&e.data?.sessions)for(let t of e.data.sessions)"number"==typeof t.titleRevision&&void 0!==t.defaultTitle&&void 0!==t.customTitle&&(0,g.X4)(t)},[]),[t]=(0,s.useState)(x.I7);return(0,h.h)({url:t,onMessage:e}),(0,s.useEffect)(()=>(0,h.D)(()=>{for(let{cwd:e,sessionId:t}of(0,g.c4)())c.t4.runFork((0,f.iS)(e,t).pipe(d.Mim(e=>d.OH5(()=>(0,g.X4)(e))),d.h9N(e=>d.FFw("Cannot refresh session title",e))))}),[]),null}function y({cwd:e,sessionId:t,title:n,titleRevision:h,initialTitleReady:x=!1,editable:v=!0}){let{t:w}=(0,a.Bd)(),k=b(),C=(0,g.iM)(k,e,t,n,h),[j,N]=(0,s.useState)(!1),[S,T]=(0,s.useState)(""),[E,R]=(0,s.useState)(!1),[M,L]=(0,s.useState)(!1),[I,A]=(0,s.useState)(!1),[F,P]=(0,s.useState)(!1),[$,D]=(0,s.useState)(!1),[_,O]=(0,s.useState)(""),[B,H]=(0,s.useState)(!1),V=(0,s.useRef)(null),U=(0,s.useCallback)(()=>{V.current?.abort(),V.current=null,H(!1),N(!1)},[]);(0,s.useEffect)(()=>()=>V.current?.abort(),[]);let W=`ai-title-${(0,s.useId)().replace(/[^a-zA-Z0-9_-]/g,"")}`,[q,z]=(0,s.useState)(""),K=(0,s.useRef)(null),G=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(!e||!t)return;let n=(0,g.eh)(e,t),r=!0;return x||c.t4.runFork((0,f.iS)(e,t).pipe(d.Mim(e=>d.OH5(()=>{r&&(0,g.X4)(e)})),d.h9N(e=>d.FFw("Cannot read session title",e)))),()=>{r=!1,n()}},[e,t,x]),(0,s.useEffect)(()=>{if(!j)return;let n=!0;return L(!1),z(""),c.t4.runFork((0,f.iS)(e,t).pipe(d.YWq({onSuccess:e=>{n&&((0,g.X4)(e),T(e.title),O(e.title),A(null!==e.customTitle),P(!0===e.mentionable),D(!0===e.mentionable),L(!0),K.current?.focus(),K.current?.select())},onFailure:()=>{n&&z(w("sessions.titleLoadFailed"))}}))),()=>{n=!1}},[j,e,t,w]),(0,s.useEffect)(()=>{if(!j)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopImmediatePropagation(),G.current||U())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[j]);let Q=async()=>{if(B||E)return;H(!0),z("");let n=new AbortController;V.current=n;let r=await c.t4.runPromiseExit((0,f.F9)(e,t),{signal:n.signal});V.current===n&&(V.current=null,H(!1),"Success"===r._tag?(T(r.value),K.current?.focus()):z(w("sessions.titleSuggestFailed",{reason:"Fail"===r.cause._tag?r.cause.error.message:""})))},J=e=>w("empty"===e?"sessions.titleEmpty":"multiline"===e?"sessions.titleSingleLine":"sessions.titleNoAt"),Y=async n=>{if(G.current||!M)return;let r=null===n||I||n!==_;if(null!==n){let e=/[\r\n]|\\[nr]/.test(n)?"multiline":n.replace(/[\r\n]+/g," ").trim()?n.includes("@")?"at":null:"empty";if(e&&r)return void z(J(e));if(e&&F)return void z(w("sessions.titleNotMentionable",{reason:J(e)}))}G.current=!0,R(!0),z("");let s=await c.t4.runPromiseExit((0,f.iS)(e,t,{...r&&{customTitle:n},mentionable:F}));G.current=!1,R(!1),"Success"===s._tag?((0,g.X4)(s.value),U(),(F||$)&&(c.t4.runSync(u.gG),(0,m._)())):z(w("sessions.titleSaveFailed"))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"truncate min-w-0","data-tooltip":C,children:C}),v&&e&&t&&(0,r.jsx)("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 pointer-events-none group-hover/session-title:opacity-100 group-hover/session-title:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto hover:text-foreground hover:bg-hover transition-opacity","aria-label":w("sessions.editTitle"),onClick:e=>{e.stopPropagation(),T(C),N(!0)},onDoubleClick:e=>e.stopPropagation(),children:(0,r.jsx)(l.A,{className:"w-3 h-3"})}),j&&(0,o.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-black/40 p-4",onClick:e=>{e.stopPropagation(),e.target!==e.currentTarget||G.current||U()},onDoubleClick:e=>e.stopPropagation(),children:(0,r.jsxs)("form",{role:"dialog","aria-modal":"true","aria-label":w("sessions.editTitle"),className:"w-full max-w-sm rounded-xl border border-border bg-card p-4 shadow-xl space-y-3",onSubmit:e=>{e.preventDefault(),Y(S)},children:[(0,r.jsx)("h2",{className:"text-sm font-medium",children:w("sessions.editTitle")}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{ref:K,autoFocus:!0,"aria-label":w("sessions.editTitle"),value:S,disabled:E||B,onKeyDown:e=>{"Enter"===e.key&&e.nativeEvent.isComposing&&e.preventDefault()},onChange:e=>T(e.target.value),className:"w-full rounded border border-border bg-background py-1 pl-2 pr-8 text-sm focus:outline-none focus:ring-1 focus:ring-ring"}),(0,r.jsxs)("button",{type:"button","aria-label":w("sessions.suggestTitle"),"data-tooltip":w("sessions.suggestTitle"),disabled:E||B||!M,onClick:()=>void Q(),className:`absolute right-1 top-1/2 -translate-y-1/2 rounded-full p-0.5 ${B?"":"hover:bg-hover disabled:opacity-50"}`,children:[(0,r.jsx)("svg",{width:"0",height:"0",className:"absolute","aria-hidden":"true",children:(0,r.jsx)("defs",{children:(0,r.jsxs)("linearGradient",{id:W,x1:"0",y1:"0",x2:"1",y2:"1",children:[(0,r.jsx)("stop",{offset:"0%",stopColor:"var(--color-blue-9)"}),(0,r.jsx)("stop",{offset:"55%",stopColor:"var(--color-brand)"}),(0,r.jsx)("stop",{offset:"100%",stopColor:"var(--color-amber-9)"})]})})}),(0,r.jsx)("span",{className:`flex items-center justify-center w-6 h-6 rounded-full ${B?(0,p.ci)("loading",!1):""}`,children:(0,r.jsx)(i.A,{stroke:`url(#${W})`,className:"w-3.5 h-3.5"})})]})]}),(0,r.jsxs)("label",{className:"flex items-start gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:F,disabled:E||!M,onChange:e=>P(e.target.checked)}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"text-foreground",children:w("sessions.mentionable")}),(0,r.jsx)("br",{}),w("sessions.mentionableHint")]})]}),q&&(0,r.jsx)("p",{role:"alert",className:"text-xs text-destructive",children:q}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 text-xs",children:[I&&(0,r.jsx)("button",{type:"button",disabled:E||!M,className:"mr-auto text-muted-foreground disabled:opacity-50",onClick:()=>void Y(null),children:w("sessions.restoreTitle")}),(0,r.jsx)("button",{type:"button",disabled:E,onClick:U,children:w("common.cancel")}),(0,r.jsx)("button",{type:"submit",disabled:E||B||!M,className:"rounded bg-brand px-3 py-1 text-white disabled:opacity-50",children:E?w("common.loading"):w("common.save")})]})]})}),document.body)]})}},77725:(e,t,n)=>{n.d(t,{Z:()=>c});var r=n(12115),s=n(10592),o=n(86359),a=n(80905),l=n(49433),i=n(80286),d=n(86957);function c(e,t){let[n,c]=(0,r.useState)({status:"loading"});return(0,r.useEffect)(()=>{c({status:"loading"});let t=d.t4.runFork(e);return t.addObserver(e=>{s.YW(e,{onSuccess:e=>c({status:"success",data:e}),onFailure:e=>{if(o.t9(e))return;let t=o.od(e);c({status:"error",error:a.Ru(t)?t.value:e})}})}),()=>{l.MY7(i.G(t))}},t),n}},79237:(e,t,n)=>{n.d(t,{y:()=>s});let r=e=>"/"===e||"\\"===e;function s(e,t){let n;if(!e)return null;let s=""===(n=e.replace(/[/\\]+$/,""))||/^[A-Za-z]:$/.test(n)?e:n;return t===s?"":t.startsWith(s)?r(s[s.length-1])?t.slice(s.length):r(t[s.length])?t.slice(s.length+1):null:null}},82292:(e,t,n)=>{function r(e,t){for(let n of e){if(n.path===t)return n;if(n.children){let e=r(n.children,t);if(e)return e}}return null}function s(e,t){if(!e)return"";let n=r(t,e);if(n?.isDirectory)return e;let s=e.split("/");return s.pop(),s.join("/")}function o(e){let t=[];for(let n of e){let e=n.split("/"),r=t;for(let t=0;t<e.length;t++){let n=e[t],s=t===e.length-1,o=e.slice(0,t+1).join("/"),a=r.find(e=>e.name===n);a||(a={name:n,path:o,isDirectory:!s,children:s?void 0:[]},r.push(a)),!s&&a.children&&(r=a.children)}}let n=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&&n(e.children)})};return n(t),t}function a(e){let t=[],n=e=>{for(let r of e)r.isDirectory&&(t.push(r.path),r.children&&n(r.children))};return n(e),t}n.d(t,{B_:()=>p,HR:()=>function e(t,n){if(0===n.length)return t;let r=new Map(n.map(e=>[e.path,e]));return t.map(t=>{let n=r.get(t.path);return n&&t.isDirectory?void 0===t.children&&void 0!==n.children?{...t,children:n.children}:void 0!==t.children&&void 0!==n.children?{...t,children:e(t.children,n.children)}:t:t})},KH:()=>c,MB:()=>r,S7:()=>s,fw:()=>u,q3:()=>d,r6:()=>m,tE:()=>h,tW:()=>a,u:()=>i,v3:()=>o});let l=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp","avif"]);function i(e){let t=e.split(".").pop()?.toLowerCase();return l.has(t||"")}function d(e,t,n=!1){let r=new Set;if(!t)return r;let s=t.toLowerCase(),o=e=>{if(r.add(e.path),e.children)for(let t of e.children)o(t)},a=(e,t)=>{let l=e.name.toLowerCase(),i=n?l===s:l.includes(s);if(i&&e.children)return o(e),t.forEach(e=>r.add(e)),!0;let d=!1;if(e.children)for(let n of e.children)a(n,[...t,e.path])&&(d=!0);return(!!i||!!d)&&(r.add(e.path),t.forEach(e=>r.add(e)),!0)};for(let t of e)a(t,[]);return r}function c(e,t,n=!1){let r=new Set;if(!t)return r;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(n?o===s:o.includes(s)){for(let t=0;t<=e.length-1;t++)r.add(e.slice(0,t+1).join("/"));break}}}return r}function u(e){let t=Math.floor(Math.floor((Date.now()-1e3*e)/1e3)/60),n=Math.floor(t/60),r=Math.floor(n/24),s=Math.floor(r/30),o=Math.floor(r/365);return o>0?`${o}y ago`:s>0?`${s}mo ago`:r>0?`${r}d ago`:n>0?`${n}h ago`:t>0?`${t}m ago`:"just now"}function m(e){let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return r?`${s}-${o} ${a}:${l}`:`${t.getFullYear()}-${s}-${o} ${a}:${l}`}let h=()=>{},p=50},82680:(e,t,n)=>{n.d(t,{m_:()=>o,uV:()=>s});var r=n(50584);class s extends r.rN("AppError"){}r.rN("DBError"),r.rN("WSError"),r.rN("FSError"),r.rN("AgentError"),r.rN("ValidationError");class o extends r.rN("NotFoundError"){}r.rN("PermissionError")},83448:(e,t,n)=>{n.d(t,{$N:()=>R,$x:()=>H,Ay:()=>D,Cr:()=>_,F4:()=>C,Fi:()=>v,Hw:()=>g,J5:()=>m,JC:()=>T,K9:()=>u,M5:()=>N,Ny:()=>x,QW:()=>M,VA:()=>a,Vm:()=>A,ZQ:()=>B,Zr:()=>E,_9:()=>O,_l:()=>$,an:()=>P,dM:()=>k,dQ:()=>b,em:()=>f,hZ:()=>V,he:()=>w,l1:()=>S,nM:()=>h,qD:()=>F,sy:()=>y,td:()=>p,vc:()=>d,yS:()=>j,z2:()=>L});var r=n(49433),s=n(82680),o=n(84230);let a=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e&&"claude"!==e?`/api/chat/${e}`:"/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw Error((await n.json()).error??`HTTP ${n.status}`)},catch:e=>new s.uV({message:e instanceof Error?e.message:"Cannot deliver chat input",cause:e})}),l=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()},catch:n=>new s.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),i=(e,t)=>l(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),d=e=>i("/api/chat/stop",e),c=(e,t)=>l(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),u=e=>l(`/api/project-state?cwd=${encodeURIComponent(e)}`),m=(e,t)=>i("/api/project-state",{cwd:e,sessions:[],...t}),h=(e,t)=>i("/api/session/user-messages",{cwd:e,sessionId:t}),p=()=>(0,o.F)("/api/settings",l("/api/settings")),f=e=>c("/api/settings",e).pipe(r.yeE(r.OH5(()=>(0,o.T)("/api/settings")))),g=e=>l(`/api/${e}/credentials`),x=e=>l(`/api/${e}/credentials?reveal=1`),b=(e,t)=>c(`/api/${e}/credentials`,{apiKey:t}),v=e=>l(`/api/${e}/models`),y=(e,t,n,r)=>{let s=new URLSearchParams({engine:e,model:t,...n?{cwd:n}:{},...r?{sessionId:r}:{}});return l(`/api/pi/thinking?${s}`)},w=()=>l("/api/deepseek/balance"),k=e=>l(`/api/${e}/usage`),C=()=>l("/api/ollama/config"),j=e=>c("/api/ollama/config",e),N=()=>(0,o.F)("/api/commands",l("/api/commands")),S=()=>(0,o.F)("/api/skills",l("/api/skills")),T=e=>i("/api/bash",e),E=(e,t)=>i(`/api/session/${encodeURIComponent(e)}/fork`,t),R=(e,t)=>l(`/api/session/${encodeURIComponent(e)}/turn`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),M=e=>l(`/api/sessions/projects/${encodeURIComponent(e)}`),L=()=>l("/api/global-state").pipe(r.TjK(e=>e.sessions??[])),I=()=>r.$mh({try:async()=>{let e=await fetch("/api/ollama/models"),t=await e.json().catch(()=>({}));return 503===e.status?{_tag:"not-running",...t.error&&{reason:t.error}}:e.ok?{_tag:"ok",models:t.models??[]}:{_tag:"error",message:t.error||"Failed to fetch models"}},catch:e=>new s.uV({message:"fetch ollama models failed",cause:e})}),A=()=>r.ivC(async()=>{let e=await fetch("/api/ollama/default-model");if(e.ok)return(await e.json()).model||void 0}).pipe(r.DM4(()=>void 0)),F=e=>r.JkU(function*(){let t=yield*I();if("not-running"!==t._tag)return t;e&&(yield*r.OH5(e));let n=yield*r.$mh({try:async()=>{let e=await fetch("/api/ollama/start",{method:"POST"}),t=await e.json().catch(()=>({}));return 404===e.status?{_tag:"not-installed",message:t.message||"Ollama is not installed"}:e.ok?{_tag:"started"}:{_tag:"error",message:"Failed to start Ollama"}},catch:e=>new s.uV({message:"start ollama failed",cause:e})});if("not-installed"===n._tag)return{_tag:"not-installed",message:n.message};if("error"===n._tag)return{_tag:"error",message:n.message};let o=yield*I();return"not-running"===o._tag?{_tag:"error",message:o.reason??t.reason??"Ollama started but cannot fetch models"}:o}),P=e=>r.$mh({try:async()=>{let t=await fetch(`/api/file?path=${encodeURIComponent(e)}`),n=await t.json();if(!t.ok)throw Error(n.error||`HTTP ${t.status}`);return n},catch:e=>new s.uV({message:e instanceof Error?e.message:"Failed to read file",cause:e})}),$=(e,t)=>i("/api/session-context",{cwd:e,sessionId:t}),D=(e,t)=>i("/api/session-context",{cwd:e,sessionId:t,summary:!0}),_=()=>l("/api/claude-stats"),O=e=>Array.isArray(e.items),B=()=>l("/api/instructions/config?scope=global"),H=e=>l(`/api/instructions/config?cwd=${encodeURIComponent(e)}`),V=e=>i("/api/instructions/config",e)},83897:(e,t,n)=>{n.d(t,{k_:()=>l,nH:()=>i});var r=n(95155),s=n(12115),o=n(48347);let a=(0,s.createContext)(null);function l({children:e}){let t=(0,s.useRef)(new Map),n=(0,s.useRef)(null),[i,d]=(0,s.useState)(()=>new Set),c=i.size>0,u=(0,s.useCallback)((e,t)=>{d(n=>{if(t===n.has(e))return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),m=(0,s.useCallback)((e,n)=>{t.current.set(n,e)},[]),h=(0,s.useCallback)(e=>{t.current.delete(e),d(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),p=(0,s.useCallback)(e=>{n.current=e},[]),f=(0,s.useCallback)(e=>{let r=n.current;if(!r)return void console.warn("No active tab to send message");let s=t.current.get(r);s?s(e):console.warn(`No chat sender registered for tab ${r}`)},[]),g=(0,s.useCallback)((e,n)=>{let r=t.current.get(e);return r?(r(n),!0):(console.warn(`No chat sender registered for tab ${e}`),!1)},[]),x=(0,s.useMemo)(()=>({sendMessage:f,sendToTab:g,isLoading:c,registerChat:m,unregisterChat:h,setActiveTab:p,setChatLoading:u}),[f,g,c,m,h,p,u]),b=(0,s.useMemo)(()=>({sendMessage:f,isLoading:c}),[f,c]);return(0,r.jsx)(a.Provider,{value:x,children:(0,r.jsx)(o.H,{value:b,children:e})})}function i(){return(0,s.useContext)(a)}},84230:(e,t,n)=>{n.d(t,{F:()=>l,T:()=>i});var r=n(49433),s=n(33440);let o=new Map,a=e=>r.qIB(r.ivC(()=>e.done),e=>e),l=(e,t)=>r.DYE(()=>{let n=o.get(e);return n?r.TjK(a(n),e=>structuredClone(e)):r.qIB(r.fA(),n=>{let r={startedAt:Date.now(),done:s.Np(n)(t)};return o.set(e,r),r.done.then(()=>{o.get(e)===r&&o.delete(e)}),a(r)})}),i=(e,t=1/0)=>{for(let[n,r]of o)n.startsWith(e)&&r.startedAt<t&&o.delete(n)}},84444:(e,t,n)=>{n.d(t,{H:()=>s});let r=e=>"unread"===e?0:"loading"===e?1:2;function s(e){return[...e].sort((e,t)=>r(e.status)-r(t.status)||t.lastActive-e.lastActive)}},85269:(e,t,n)=>{n.d(t,{O:()=>m});var r=n(95155),s=n(12115),o=n(48347),a=n(89109),l=n(7320),i=n(34582),d=n(1058),c=n(90717),u=n(69809);function m({content:e,filePath:t,cwd:n,onContentSearch:h,reloadKey:p=0}){let f=(0,o.r)(),g=!!n,x=(0,s.useMemo)(()=>{if((0,i.qF)(t,n))return{mode:"url",url:(0,i.Xe)(t,n)};let r=e??"",s=(0,i.J4)(t,n),o="https:"===window.location.protocol?"wss:":"ws:",a=`${o}//${window.location.host}/ws/bash?cwd=${encodeURIComponent(s)}`;return{mode:"srcdoc",html:(0,i.OP)(r,{cwd:s,wsUrl:a})}},[e,t,n]),{addComment:b,refresh:v}=(0,d._)({cwd:n||"",filePath:t}),[y,w]=(0,s.useState)(null),k=(0,s.useRef)(null),C=(0,s.useRef)(null),j=(0,s.useRef)(()=>{}),[N,S]=(0,s.useState)(null),[T,E]=(0,s.useState)(null),R=(0,s.useRef)(!1);(0,s.useEffect)(()=>{R.current=!!(N||T)},[N,T]);let M=(0,s.useCallback)(()=>{C.current&&(C.current=null,j.current())},[]),L=(0,s.useCallback)(()=>{let e=k.current,t=e?.contentWindow;if(t){let e=document.documentElement.classList.contains("dark");t.postMessage({type:"THEME_CHANGE",theme:e?"dark":"light"},"*"),t.postMessage({type:"cockpit:language-change",lang:u.A.language},"*")}if(!g)return;let n=e?.contentDocument;e&&n&&(n.addEventListener("mouseup",t=>{if(R.current)return;let n=e.contentWindow?.getSelection(),r=n&&!n.isCollapsed?n.toString().trim():"";if(!r)return void M();let s=e.getBoundingClientRect();C.current={x:s.left+t.clientX,y:s.top+t.clientY,range:{start:0,end:0},selectedText:r,lineSnapshot:r},j.current()}),n.addEventListener("mousedown",()=>{M(),S(null),E(null)}),n.addEventListener("scroll",()=>M(),{capture:!0,passive:!0}))},[g,M]),I=(0,s.useCallback)(()=>{let e=C.current;e&&(S({x:e.x,y:e.y,text:e.selectedText}),M(),k.current?.contentWindow?.getSelection()?.removeAllRanges())},[M]),A=(0,s.useCallback)(()=>{let e=C.current;e&&(E({x:e.x,y:e.y,text:e.selectedText}),M(),k.current?.contentWindow?.getSelection()?.removeAllRanges())},[M]),F=(0,s.useCallback)(()=>{let e=C.current;e&&f&&(M(),k.current?.contentWindow?.getSelection()?.removeAllRanges(),(0,c.Ff)(f.sendMessage,{filePath:t,startLine:0,endLine:0,codeContent:e.selectedText},u.A.t("explain.selectionMessage")))},[f,t,M]),P=(0,s.useCallback)(()=>{let e=C.current;if(!e||!h)return;let t=e.selectedText.trim();M(),k.current?.contentWindow?.getSelection()?.removeAllRanges(),t&&h(t)},[h,M]),$=(0,s.useCallback)(async e=>{N&&(await b(0,0,e,N.text),S(null))},[N,b]),D=(0,s.useCallback)(async(e,r)=>{if(f&&n)try{let s=(await (0,c.$3)(n)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));s.push({filePath:t,startLine:0,endLine:0,codeContent:e});let o=(0,c.Gw)(s,r);f.sendMessage(o),await (0,c.RP)(n),v()}catch(e){console.error("[HtmlAppFrame] send to AI failed:",e)}},[f,n,t,v]),_=(0,s.useCallback)(e=>{T&&D(T.text,e)},[T,D]),O=(0,s.useCallback)(e=>{N&&D(N.text,e)},[N,D]);return(0,r.jsxs)("div",{ref:w,className:"relative h-full w-full bg-white",children:[(0,r.jsx)("iframe",{ref:k,..."url"===x.mode?{src:x.url}:{srcDoc:x.html},title:t,className:"h-full w-full border-0",onLoad:L},`${t}:${p}`),g&&y&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.fS,{floatingToolbarRef:C,bumpRef:j,container:y,onAddComment:I,onSendToAI:A,onSearch:h?P:void 0,onExplain:f?F:void 0,isChatLoading:f?.isLoading}),N&&(0,r.jsx)(l.t,{x:N.x,y:N.y,range:{start:0,end:0},filePath:t,lineSnapshot:N.text,container:y,onSubmit:$,onSendToAI:f?O:void 0,onClose:()=>S(null),isChatLoading:f?.isLoading}),T&&(0,r.jsx)(l.G,{x:T.x,y:T.y,range:{start:0,end:0},filePath:t,lineSnapshot:T.text,container:y,onSubmit:_,onClose:()=>E(null),isChatLoading:f?.isLoading})]})]})}},86304:(e,t,n)=>{n.d(t,{P:()=>d});var r=n(12115),s=n(79114),o=n(34075),a=n(86957),l=n(63040),i=n(63563);function d(){let{t:e}=(0,s.Bd)();return(0,r.useCallback)(async t=>{let n=await a.t4.runPromiseExit((0,l.ot)(t));if("Success"===n._tag)n.value.alreadyExists?(0,o.oR)(e("htmlApps.alreadyAdded"),"info"):((0,o.oR)(e("htmlApps.added"),"success"),(0,i.N)());else{let t="Fail"===n.cause._tag?n.cause.error:null,r=t?.cause,s=r instanceof Error?r.message:e("htmlApps.addFailed");(0,o.oR)(s,"error")}},[e])}},86511:(e,t,n)=>{n.d(t,{nl:()=>a});let r=/^\[Sent from Cockpit session (\/project\?\S+) \((.*)\) via @mention(?: · input ([\w-]+))?\]$/,s=/^\[Sent via @mention from another Cockpit session(?: · input ([\w-]+))?\]$/,o=/^\[Delegated from Cockpit session (\/project\?\S+) \((.*)\)\]$/;function a(e){let t=e.split("\n"),n=t[0]??"",a=n.match(r),l=a?null:n.match(s);if(a||l){let e=a?.[3]??l?.[1];return{kind:"sent",link:a?.[1]??null,project:a?.[2]??null,body:t.slice(1).join("\n").replace(/^\n+/,""),...e&&{inputId:e}}}let i=t.findIndex((e,t)=>t<=1&&o.test(e));if(-1===i)return null;let d=t[i].match(o);return{kind:"delegated",link:d[1],project:d[2],body:[...t.slice(0,i),...t.slice(i+1)].join("\n").replace(/^\n+/,"")}}},86957:(e,t,n)=>{n.d(t,{t4:()=>_});var r=n(59257),s=n(74565),o=n(49433),a=n(93404),l=n(22484),i=n(41463);let d=r.Um(l.j9,l.dl((e=>{switch((e??"").toLowerCase()){case"all":return a.u8;case"trace":return a.Cn;case"debug":return a.y;case"info":default:return a.R2;case"warning":case"warn":return a.N5;case"error":return a.$D;case"fatal":return a.Lj;case"none":return a.NV}})(i.env.COCKPIT_LOG_LEVEL)));var c=n(80905),u=n(98953);let m=globalThis,h=m.__cockpitSpanRing??={buffer:[],index:new Map},p=e=>{let t="abcdef0123456789",n="";for(let r=0;r<e;r++)n+=t.charAt(Math.floor(Math.random()*t.length));return n};class f{constructor(e,t,n,r,s,o){this.name=e,this.parent=t,this.context=n,this.startTime=s,this.kind=o,this._tag="Span",this.sampled=!0,this.attributes=new Map,this.events=[],this.traceId=c.Ru(t)?t.value.traceId:p(32),this.spanId=p(16),this.status={_tag:"Started",startTime:s},this.links=Array.from(r),function(e){if(h.buffer.push(e),h.index.set(e.spanId,h.buffer.length-1),h.buffer.length>500){h.buffer.shift(),h.index.clear();for(let e=0;e<h.buffer.length;e++)h.index.set(h.buffer[e].spanId,e)}}(function(e,t,n,r,s,o){return{traceId:t,spanId:e,parentSpanId:n,name:r,kind:s,startTimeNs:o.toString(),endTimeNs:null,durationMs:null,attributes:{},events:[],status:"started"}}(this.spanId,this.traceId,function(e){return c.Ru(e)?e.value.spanId:null}(t),e,o,s))}end(e,t){this.status={_tag:"Ended",endTime:e,exit:t,startTime:this.status.startTime},function(e,t,n){let r=h.index.get(e);if(void 0===r)return;let s=h.buffer[r];if(!s)return;let o=Number(t-BigInt(s.startTimeNs))/1e6;h.buffer[r]={...s,endTimeNs:t.toString(),durationMs:Math.round(100*o)/100,status:"Success"===n._tag?"ok":"error",errorMessage:"Failure"===n._tag?function(e){if(e instanceof Error)return e.message;if("string"==typeof e)return e;try{return JSON.stringify(e)}catch{return String(e)}}(n.cause):void 0}}(this.spanId,e,"Success"===t._tag?{_tag:"Success"}:{_tag:"Failure",cause:t.cause})}attribute(e,t){this.attributes.set(e,t),function(e,t,n){let r=h.index.get(e);if(void 0===r)return;let s=h.buffer[r];s&&(h.buffer[r]={...s,attributes:{...s.attributes,[t]:n}})}(this.spanId,e,t)}event(e,t,n){this.events.push([e,t,n??{}]),function(e,t,n,r){let s=h.index.get(e);if(void 0===s)return;let o=h.buffer[s];o&&(h.buffer[s]={...o,events:[...o.events,{name:t,timeNs:n.toString(),attributes:r}]})}(this.spanId,e,t,n)}addLinks(e){this.links.push(...e)}}let g=u.L8({span:(e,t,n,r,s,o)=>new f(e,t,n,r,s,o),context:e=>e()}),x=r.Py(u.sh,g);r.Ie;var b=n(63400),v=n(41463);let y=b.eu("dev","prod")("COCKPIT_ENV").pipe(b.IQ("prod")),w=b.Yj("COCKPIT_HOST").pipe(b.IQ("127.0.0.1")),k=b.nd("COCKPIT_PORT").pipe(b.NW(()=>b.nd("PORT")),b.IQ(3457)),C=b.uK(b.Yj("COCKPIT_OPEN_PROJECT")).pipe(b.Tj(e=>"Some"===e._tag?e.value:void 0)),j=b.zM("COCKPIT_NO_OPEN").pipe(b.IQ(!1)),N=b.Yj("COCKPIT_LOG_LEVEL").pipe(b.IQ("info")),S=b.nd("COCKPIT_SNAPSHOT_KEEP_DAYS").pipe(b.IQ(7)),T=b.nd("COCKPIT_SNAPSHOT_REPO_TTL_DAYS").pipe(b.IQ(30)),E=b.nd("COCKPIT_SNAPSHOT_MAX_FILE_KB").pipe(b.IQ(2048)),R=b.nd("COCKPIT_SESSION_KEEP_DAYS").pipe(b.IQ(30)),M=b.nd("COCKPIT_DELEGATE_MAX").pipe(b.tf({message:"COCKPIT_DELEGATE_MAX must be >= 1",validation:e=>e>=1}),b.IQ(10));o.JkU(function*(){let e=yield*y,t=yield*w,n=yield*k,r=yield*C,s=yield*j,a=yield*N,l=yield*S,i=yield*T,d=yield*E,c=yield*R,u=yield*M,m=yield*o.OH5(()=>{let e=void 0!==v?v.env:void 0,t=e?.HOME||e?.USERPROFILE||".",n=e?.COCKPIT_HOME;return n?n.replace(/^~(?=$|\/)/,t):t+"/.cockpit"});return{env:e,host:t,port:3457===n&&"dev"===e?3456:n,cockpitDir:m,openProject:r,openBrowser:!s,logLevel:a,logFile:m+"/logs/cockpit.log",snapshotKeepDays:l,snapshotRepoTtlDays:i,snapshotMaxFileKb:d,sessionKeepDays:c,delegateMaxConcurrent:u}}).pipe(o.QgK);let L=r.Ie;var I=n(38147),A=n(23363),F=n(88292);let P=r.P1(F.d,o.JkU(function*(){let e=yield*I.dT();return yield*o.Q56(o.OH5(()=>{let t=t=>{o.MY7(I.mk(e,t))};return window.addEventListener("message",t),t}),e=>o.OH5(()=>{window.removeEventListener("message",e)})),F.d.of({publish:(e,t)=>o.OH5(()=>{let n={type:e.legacyType,topic:e.id,msg:t,..."object"==typeof t&&null!==t?t:{}};window.parent.postMessage(n,"*")}),subscribe:t=>A.qdp(e).pipe(A.pbD(e=>{var n;return n=e.data,!!n&&"object"==typeof n&&(n.topic===t.id||n.type===t.legacyType)}),A.TjK(e=>((e,t)=>{if(e.topic===t.id)return e.msg;let{type:n,...r}=e;return r})(e.data,t)))})})),$=r.Um(d,x,L),D=r.Um($,P),_=s.L8(D);o.rIH},88292:(e,t,n)=>{n.d(t,{R:()=>s,d:()=>o});var r=n(50995);let s=(e,t)=>({id:e,legacyType:t??e.replace(/-/g,"_").toUpperCase()}),o=r.Io("@cockpit/IframeBus")},88403:(e,t,n)=>{n.d(t,{Q:()=>l});var r=n(23348),s=n(33442),o=n(51536);let a={add:r.zB,notify:s._,namespace:"bots",failureKey:"bots.saveFailed"},l=()=>(0,o.X)(a)},88780:(e,t,n)=>{n.d(t,{Do:()=>h,Sz:()=>p,VO:()=>m,WY:()=>x,ab:()=>g,wI:()=>f});var r=n(95155),s=n(12115),o=n(79114),a=n(14575),l=n(72312),i=n(70188),d=n(52839);function c({status:e}){let{label:t,className:n}={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,r.jsx)("span",{className:`text-xs font-bold ${n}`,children:t})}let u=s.memo(function e({node:t,level:n,selectedPath:o,expandedPaths:i,onSelect:u,onToggle:m,onContextMenu:h,showChanges:p=!1,showChangeClass:f=!1,hideIndicatorsOnHover:g=!1,renderActions:x}){let b,v=o===t.path,y=i.has(t.path),w=(0,s.useCallback)(()=>{t.isDirectory?m(t.path):u(t)},[t,u,m]),k=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),h(e,t.path,t.isDirectory)},[t.path,t.isDirectory,h]);return t.isDirectory?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-hover cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*n+8}px`},onClick:w,onContextMenu:k,children:[(0,r.jsx)("span",{className:"text-foreground-subtle text-xs",children:y?"▼":"▶"}),(0,r.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":t.path,children:t.name}),x&&x(t)]}),y&&t.children.map(t=>(0,r.jsx)(e,{node:t,level:n+1,selectedPath:o,expandedPaths:i,onSelect:u,onToggle:m,onContextMenu:h,showChanges:p,showChangeClass:f,hideIndicatorsOnHover:g,renderActions:x},t.path))]}):(0,r.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${v?"bg-brand/10":"hover:bg-hover"}`,style:{paddingLeft:`${12*n+8}px`},onClick:w,onContextMenu:k,children:[(0,r.jsx)(a.o,{name:t.name,size:16,className:"flex-shrink-0"}),(0,r.jsx)("span",{className:`text-sm flex-1 truncate ${v?"text-brand":"text-foreground"}`,"data-tooltip":t.path,children:t.name}),f&&((b=(0,d.q)(t.path))?(0,r.jsx)("span",{className:g?"group-hover:hidden":void 0,children:(0,r.jsx)(l.N,{cls:b})}):null),x&&x(t),t.status&&(0,r.jsx)("span",{className:g?"group-hover:hidden":void 0,children:(0,r.jsx)(c,{status:t.status})}),p&&void 0!==t.additions&&void 0!==t.deletions&&(0,r.jsxs)("span",{className:`contents ${g?"group-hover:hidden":""}`,children:[(0,r.jsxs)("span",{className:"text-xs text-green-11",children:["+",t.additions]}),(0,r.jsxs)("span",{className:"text-xs text-red-11",children:["-",t.deletions]})]})]})});function m({files:e,selectedPath:t,expandedPaths:n,onSelect:s,onToggle:a,cwd:l,showChanges:d=!1,showChangeClass:c=!1,hideIndicatorsOnHover:h=!1,renderActions:p,emptyMessage:f,className:g,onExplain:x,explainDisabled:b}){let{t:v}=(0,o.Bd)(),y=f??v("gitFileTree.noFiles"),{contextMenu:w,showContextMenu:k,hideContextMenu:C}=(0,i.Ee)();return 0===e.length?(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-foreground-subtle",children:y}):(0,r.jsxs)("div",{className:g||"py-1",children:[e.map(e=>(0,r.jsx)(u,{node:e,level:0,selectedPath:t,expandedPaths:n,onSelect:s,onToggle:a,onContextMenu:k,showChanges:d,showChangeClass:c,hideIndicatorsOnHover:h,renderActions:p},e.path)),w&&(0,r.jsx)(i.ft,{x:w.x,y:w.y,path:w.path,cwd:l,isDirectory:w.isDirectory,onClose:C,onExplain:x,explainDisabled:b})]})}function h(e){let t=[];for(let n of e){let e=n.path.split("/"),r=t;for(let t=0;t<e.length;t++){let s=e[t],o=t===e.length-1,a=e.slice(0,t+1).join("/"),l=r.find(e=>e.name===s);l||(l={name:s,path:a,isDirectory:!o,children:[],...o&&{status:n.status,additions:n.additions,deletions:n.deletions,oldPath:n.oldPath,file:n}},r.push(l)),o||(r=l.children)}}let n=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>n(e.children))};return n(t),t}function p(e){let t=[],n=e=>{for(let r of e)r.isDirectory&&(t.push(r.path),n(r.children))};return n(e),t}function f(e){let t=[],n=e=>{if(e.isDirectory)for(let t of e.children)n(t);else t.push(e)};return n(e),t}let g=s.memo(function({files:e,className:t=""}){let{additions:n,deletions:o}=(0,s.useMemo)(()=>(function(e){let t=0,n=0;for(let r of e)t+=r.additions??0,n+=r.deletions??0;return{additions:t,deletions:n}})(e),[e]);return(0,r.jsxs)("span",{className:`flex flex-shrink-0 items-center gap-1.5 text-xs tabular-nums ${t}`,children:[(0,r.jsxs)("span",{className:"text-green-11",children:["+",n]}),(0,r.jsxs)("span",{className:"text-red-11",children:["-",o]})]})}),x=s.memo(function({files:e,label:t}){let{t:n}=(0,o.Bd)();return(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:t??n("fileBrowser.nFilesChangedPlain",{count:e.length})}),(0,r.jsx)(g,{files:e})]})})},89109:(e,t,n)=>{n.d(t,{SZ:()=>a,fS:()=>d});var r=n(95155),s=n(12115),o=n(79114);let a=[["quickReply.optionA","quickReply.optionB","quickReply.optionC","quickReply.optionD"],["quickReply.allRecommended","quickReply.thisOne","quickReply.notThis"],["quickReply.why","quickReply.elaborate","quickReply.example"],["quickReply.start","quickReply.continue","quickReply.ok","quickReply.done"]];function l({rows:e,placeAbove:t,onHeight:n,onPick:a,onEdit:i,onMouseEnter:d,onMouseLeave:c}){let{t:u}=(0,o.Bd)(),m=(0,s.useRef)(null);return(0,s.useEffect)(()=>{m.current&&n(m.current.getBoundingClientRect().height)},[n,e]),(0,r.jsxs)("div",{ref:m,className:`absolute ${t?"bottom-full mb-1":"top-full mt-1"} left-0 z-[201] flex flex-col gap-1 bg-card border border-border rounded-lg shadow-lv3 p-1.5`,onMouseEnter:d,onMouseLeave:c,children:[i&&(0,r.jsx)("button",{className:"absolute top-0.5 right-0.5 p-1 text-muted-foreground hover:text-brand transition-colors",onClick:i,title:u("quickReply.edit"),"aria-label":u("quickReply.edit"),children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),e.map((e,t)=>(0,r.jsx)("div",{className:`flex items-center gap-1${i&&0===t?" pr-5":""}`,children:e.map((e,n)=>(0,r.jsx)("button",{className:"px-2 py-1 text-xs whitespace-nowrap border border-border text-foreground rounded hover:border-brand hover:bg-hover transition-colors",onClick:()=>a(e),children:e},`${t}:${n}:${e}`))},t))]})}function i({x:e,y:t,visible:n,container:d,onAddComment:c,onSendToAI:u,onSearch:m,onExplain:h,onQuickReply:p,quickReplyRows:f,onEditQuickReplies:g,isChatLoading:x}){let{t:b}=(0,o.Bd)(),v=(0,s.useRef)(null),[y,w]=(0,s.useState)({w:0,h:0}),[k,C]=(0,s.useState)(0),[j,N]=(0,s.useState)(null),S=(0,s.useRef)(null);(0,s.useLayoutEffect)(()=>{let e=v.current;if(!e)return;let{width:t,height:n}=e.getBoundingClientRect();w(e=>e.w===t&&e.h===n?e:{w:t,h:n})});let T=(0,s.useCallback)(e=>{C(t=>t===e?t:e)},[]);(0,s.useEffect)(()=>{n||N(null)},[n]);let E=(0,s.useCallback)(()=>{S.current&&(clearTimeout(S.current),S.current=null)},[]),R=(0,s.useCallback)(e=>{E(),N(e)},[E]),M=(0,s.useCallback)(()=>{E(),S.current=setTimeout(()=>N(null),150)},[E]);(0,s.useEffect)(()=>E,[E]);let L=d.getBoundingClientRect(),I=e-L.left,A=Math.max(0,t-L.top-40),F=Math.max(0,Math.min(I+8,L.width-y.w-8)),P=k>0&&A+y.h+8+k>L.height,$=(0,s.useMemo)(()=>f??a.map(e=>e.map(e=>b(e))),[f,b]),D=e=>p&&j===e?(0,r.jsx)(l,{rows:$,onEdit:g,placeAbove:P,onHeight:T,onPick:t=>{N(null),p(e,t)},onMouseEnter:E,onMouseLeave:M}):null;return(0,r.jsxs)("div",{ref:v,className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-lv3 p-1.5",style:{left:F,top:A,visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none"},children:[(0,r.jsxs)("div",{className:"relative",onMouseEnter:()=>R("comment"),onMouseLeave:M,children:[(0,r.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:c,children:b("floatingToolbar.addComment")}),D("comment")]}),(0,r.jsxs)("div",{className:"relative",onMouseEnter:()=>{x||R("ai")},onMouseLeave:M,children:[(0,r.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:u,disabled:x,title:x?b("comments.aiResponding"):void 0,children:b("floatingToolbar.sendToAI")}),D("ai")]}),h&&(0,r.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:h,disabled:x,title:x?b("comments.aiResponding"):void 0,children:b("explain.action")}),m&&(0,r.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:m,children:b("floatingToolbar.search")})]})}let d=(0,s.memo)(function({floatingToolbarRef:e,bumpRef:t,container:n,onAddComment:o,onSendToAI:a,onSearch:l,onExplain:d,onQuickReply:c,quickReplyRows:u,onEditQuickReplies:m,isChatLoading:h}){let[p,f]=(0,s.useState)(0);(0,s.useEffect)(()=>{t.current=()=>f(e=>e+1)},[t]);let g=(0,s.useMemo)(()=>e.current,[p]);return(0,r.jsx)(i,{x:g?.x??0,y:g?.y??0,visible:!!g,container:n,onAddComment:o,onSendToAI:a,onSearch:l,onExplain:d,onQuickReply:c,quickReplyRows:u,onEditQuickReplies:m,isChatLoading:h})})},90717:(e,t,n)=>{n.d(t,{$3:()=>u,Cm:()=>c,Ff:()=>f,Gw:()=>p,RP:()=>m,Un:()=>h,zL:()=>d});var r=n(69809),s=n(49433),o=n(86957),a=n(82680),l=n(46456);let i=new Set;function d(e){return i.add(e),()=>i.delete(e)}function c(){i.forEach(e=>e())}async function u(e){let t=await o.t4.runPromiseExit((0,l.lb)(e));if("Success"!==t._tag)throw Error("Failed to fetch comments");let n=t.value.comments??[];if(0===n.length)return[];let r=new Map;for(let e of n)e.selectedText||(r.has(e.filePath)||r.set(e.filePath,[]),r.get(e.filePath).push(e));let i=new Map;await Promise.all(Array.from(r.keys()).map(async t=>{let n=await o.t4.runPromiseExit(s.$mh({try:async()=>{let n=await fetch(`/api/files/text?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`);return n.ok?await n.json():null},catch:e=>new a.uV({message:`read file text ${t} failed`,cause:e})}));"Success"===n._tag&&n.value&&"string"==typeof n.value.content?i.set(t,n.value.content.split("\n")):"Failure"===n._tag&&console.error(`Failed to read file ${t}:`,n.cause)}));let d=[];for(let e of n){if(e.selectedText){d.push({...e,codeContent:e.selectedText});continue}let t=i.get(e.filePath),n="";if(t){let r=Math.max(0,e.startLine-1),s=Math.min(t.length,e.endLine);n=t.slice(r,s).join("\n")}d.push({...e,codeContent:n})}return d}async function m(e){let t=await o.t4.runPromiseExit((0,l.tj)(e));return"Success"===t._tag?(c(),!0):(console.error("Failed to clear comments:",t.cause),!1)}let h="__chat__";function p(e,t){let n=e.filter(e=>e.filePath===h),s=e.filter(e=>e.filePath!==h),o=[];for(let e of(s.length>0&&(o.push(`${r.A.t("comments.codeRef")}`,""),s.forEach((e,t)=>{let n=e.startLine>0||e.endLine>0?`:${e.startLine}-${e.endLine}`:"";o.push(`[${t+1}] ${e.filePath}${n}`),o.push("```"),o.push(e.codeContent),o.push("```"),e.note&&o.push(r.A.t("comments.note",{content:e.note})),o.push("")})),n)){let t=e.codeContent.split("\n").map(e=>`> ${e}`).join("\n");o.push(t),e.note&&o.push(e.note),o.push("")}if(t.trim()){for(;o.length>0&&""===o[o.length-1];)o.pop();o.push(t.trim())}return o.join("\n").trim()}function f(e,t,n){e(p([t],n))}},92689:(e,t,n)=>{n.d(t,{S:()=>o});var r=n(95155),s=n(57125);function o({engine:e,tooltip:t,size:n="md"}){let a=e||"claude";return(0,s.ch)(a)?(0,r.jsx)("span",{className:"shrink-0 inline-flex items-center","data-tooltip":t??s.H[a],children:(0,r.jsx)(s.eV,{engine:a,className:"sm"===n?"h-3 w-3":"h-3.5 w-3.5"})}):(0,r.jsx)("span",{className:"shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded bg-muted text-muted-foreground","data-tooltip":t??a,children:a})}},93964:(e,t,n)=>{n.d(t,{N:()=>o});var r=n(84230);let s=e=>"u"<typeof BroadcastChannel?null:new BroadcastChannel(e),o=(e,t)=>({notify:()=>{let t=s(e);if(t)try{t.postMessage({type:"changed",at:Date.now()})}finally{t.close()}},subscribe:n=>{let o=s(e);if(!o)return()=>void 0;let a=e=>{if(e.data?.type==="changed"){if(t){let n="number"==typeof e.data.at?e.data.at:Date.now();for(let e of"string"==typeof t?[t]:t)(0,r.T)(e,n)}n()}};return o.addEventListener("message",a),()=>{o.removeEventListener("message",a),o.close()}}})},94287:(e,t,n)=>{n.d(t,{m:()=>o});var r=n(95155),s=n(12115);function o({content:e,children:t,className:n}){if(n)return(0,r.jsx)("div",{"data-tooltip":e,className:n,children:t});let a=s.Children.toArray(t);if(1===a.length&&(0,s.isValidElement)(a[0])){let t=a[0];return(0,s.cloneElement)(t,{"data-tooltip":e})}return(0,r.jsx)("div",{"data-tooltip":e,style:{display:"contents"},children:t})}},95045:(e,t,n)=>{n.d(t,{F:()=>a});var r=n(49433),s=n(88292),o=n(86957);let a=(e,t)=>{o.t4.runFork(r.qIB(s.d,n=>n.publish(e,t)))}},95272:(e,t,n)=>{n.d(t,{Q:()=>s,X:()=>o});var r=n(41948);function s(e,t){return(0,r.l)(e).filter(e=>!e.some(e=>e.sourceId&&t.sourceIds.includes(e.sourceId)||e.sourceTaskId&&t.taskIds.includes(e.sourceTaskId))).flat().map(e=>{let n=e.sourceId&&t.sourceRemap?.[e.sourceId];return n?{...e,sourceId:n}:e})}function o(e){return e?.type==="error"&&Array.isArray(e.undeliveredInputs)&&e.undeliveredInputs.length>0||e?.type==="system"&&"input_binding"===e.subtype&&"string"==typeof e.inputId&&"string"==typeof e.sourceId}},95595:(e,t,n)=>{n.d(t,{M7:()=>a,ZL:()=>s,yR:()=>r});let r="grok-4.7",s="high",o=[{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra High"}],a={defaultModel:r,models:[{id:"grok-4.7",label:"Grok 4.7"},{id:"grok-4.6",label:"Grok 4.6"},{id:"grok-4.5",label:"Grok 4.5"}].map(e=>({...e,reasoning:o,defaultReasoning:s}))}},95686:(e,t,n)=>{n.d(t,{x:()=>i});var r=n(95155),s=n(12115),o=n(64428),a=n(70188),l=n(5135);function i({filePath:e,content:t,cwd:n,onClose:d,zClassName:c="z-50"}){let[u,m]=(0,s.useState)(null);return(0,r.jsx)(o.ZL,{children:(0,r.jsx)("div",{className:`fixed inset-0 ${c} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:d,children:(0,r.jsx)("div",{ref:m,className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(a.SU,{container:u,children:(0,r.jsx)(l.M,{content:t,filePath:e,cwd:n,onClose:d})})})})})}},96497:(e,t,n)=>{function r(e,t){let n,r=document.caretRangeFromPoint(e.clientX,e.clientY);if(!r||!t.contains(r.startContainer))return 1;let s=r.startContainer,o=r.startOffset,a=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),l=1;for(;n=a.nextNode();){if(n===s){l+=o;break}l+=n.textContent?.length||0}return l}function s(e,t){if(0!==e.buttons)return null;let n=window.getSelection();if(n&&!n.isCollapsed)return null;let s=e.target;if("SPAN"!==s.tagName||!s.style.color)return null;let o=s.getBoundingClientRect();return{column:r(e,t),rect:{x:o.left,y:o.bottom+4}}}n.d(t,{A:()=>s,j:()=>r})},97251:(e,t,n)=>{n.d(t,{W:()=>o});var r=n(48250);let s=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","table","tr","hr","div","ul","ol"]);function o(){return e=>{(0,r.YR)(e,"element",e=>{if(s.has(e.tagName)&&e.position&&(e.properties||(e.properties={}),e.properties["data-source-start"]=e.position.start.line,e.properties["data-source-end"]=e.position.end.line,"pre"===e.tagName)){let t=e.children?.find(e=>"element"===e.type&&"code"===e.tagName);t&&(t.properties||(t.properties={}),t.properties["data-source-start"]=e.position.start.line,t.properties["data-source-end"]=e.position.end.line)}})}}},97488:(e,t,n)=>{n.d(t,{Z:()=>c});var r=n(95155),s=n(12115),o=n(64428),a=n(57125),l=n(86957),i=n(83448);let d={deepseek:{label:"DeepSeek",apiKeysUrl:"https://platform.deepseek.com/api_keys",modelsEndpoint:"/v1/models"},kimi:{label:"Kimi",apiKeysUrl:"https://www.kimi.com/code/console",modelsEndpoint:"/coding/v1/models"},glm:{label:"GLM",apiKeysUrl:"https://bigmodel.cn/apikey/platform",modelsEndpoint:"/coding/paas/v4/models",regions:[{id:"cn",label:"中国大陆",hint:"open.bigmodel.cn"},{id:"global",label:"International",hint:"api.z.ai"}]}};function c({engine:e,currentModel:t,onModelChange:n,onHasKeyChange:u}){let m=d[e],[h,p]=(0,s.useState)(!1),[f,g]=(0,s.useState)(!1),[x,b]=(0,s.useState)(""),[v,y]=(0,s.useState)(""),[w,k]=(0,s.useState)(!1),[C,j]=(0,s.useState)(!1),[N,S]=(0,s.useState)(!1),[T,E]=(0,s.useState)(null),[R,M]=(0,s.useState)(!1),[L,I]=(0,s.useState)([]),[A,F]=(0,s.useState)(null),[P,$]=(0,s.useState)(null),D=(0,s.useRef)(null),_=(0,s.useRef)(null),O=(0,s.useRef)(null),B=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{B.current&&clearTimeout(B.current)},[]);let H=(0,s.useRef)(t),V=(0,s.useRef)(n),U=(0,s.useRef)(u);(0,s.useEffect)(()=>{H.current=t,V.current=n,U.current=u}),(0,s.useEffect)(()=>{U.current?.(f)},[f]);let[W,q]=(0,s.useState)({top:0,left:0});(0,a.r8)(_,h,W.left);let z=(0,o.F2)();(0,s.useEffect)(()=>{let t=!1;return(async()=>{let[n,r]=await Promise.all([l.t4.runPromiseExit((0,i.Hw)(e)),l.t4.runPromiseExit((0,i.td)())]);if(t||"Failure"===n._tag)return;g(n.value.hasKey),b(n.value.maskedKey);let s="Success"===r._tag?r.value?.engines?.[e]:void 0,o=s?.builtinModel;!H.current&&o&&V.current(o)})(),()=>{t=!0}},[e]),(0,s.useEffect)(()=>{if(!h)return;let e=e=>{_.current&&!_.current.contains(e.target)&&D.current&&!D.current.contains(e.target)&&p(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[h]);let K=(0,s.useCallback)(async()=>{j(!0),E(null),F(null);let[r,s]=await Promise.all([l.t4.runPromiseExit((0,i.Hw)(e)),l.t4.runPromiseExit((0,i.td)())]);if("Failure"===r._tag){E("Failed to load settings"),j(!1);return}g(r.value.hasKey),b(r.value.maskedKey),y(""),k(!1);let o="Success"===s._tag?s.value:void 0,a=o?.engines?.[e],d=a?.builtinModel;m.regions&&$(a?.region??("en"===o?.language?"global":"cn"));let c=[];if(r.value.hasKey){let t=await l.t4.runPromiseExit((0,i.Fi)(e));"Success"===t._tag?c=t.value.models:F("Failed to load models — check the API key")}I(c);let u=c.map(e=>e.id),h=d&&u.includes(d)?d:u[0];!h||t&&u.includes(t)||n(h),j(!1)},[e,t,n,m.regions]),G=(0,s.useCallback)(async t=>{let n=await l.t4.runPromiseExit((0,i.td)()),r=("Success"===n._tag?n.value:{}).engines||{},s={...r,[e]:{...r[e]||{},builtinModel:t}};if("Failure"===(await l.t4.runPromiseExit((0,i.em)({engines:s})))._tag)throw Error("Failed to save settings")},[e]),Q=(0,s.useCallback)(async t=>{$(t);let n=await l.t4.runPromiseExit((0,i.td)()),r=("Success"===n._tag?n.value:{}).engines||{};"Failure"===(await l.t4.runPromiseExit((0,i.em)({engines:{...r,[e]:{...r[e]||{},region:t}}})))._tag?E("Failed to save region"):K()},[e,K]),J=async()=>{let t=v.trim();if(!t)return;S(!0),E(null);let n=await l.t4.runPromiseExit((0,i.dQ)(e,t));"Failure"===n._tag?E("Save failed"):(g(n.value.hasKey),b(n.value.maskedKey),y(""),k(!1),K()),S(!1)},Y=async()=>{S(!0),E(null);let t=await l.t4.runPromiseExit((0,i.dQ)(e,""));"Failure"===t._tag?E("Clear failed"):(g(t.value.hasKey),b(t.value.maskedKey),y(""),k(!1),I([])),S(!1)},Z=async()=>{let t=await l.t4.runPromiseExit((0,i.Ny)(e));if("Failure"===t._tag||!t.value.apiKey)return void E("Copy failed");try{await navigator.clipboard.writeText(t.value.apiKey)}catch{E("Clipboard unavailable");return}E(null),M(!0),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>M(!1),1500)},X=async e=>{n(e);try{await G(e)}catch{}},ee=f?t||"Select model":"Set API key",et=f?void 0:a.Aw,en=t||"",er=h?(0,r.jsx)(o.ZL,{children:(0,r.jsx)("div",{ref:_,className:`${a.ys} min-w-[280px]`,style:{top:W.top,left:W.left},children:C?(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"px-3 py-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"API Key"}),(0,r.jsx)("a",{href:m.apiKeysUrl,target:"_blank",rel:"noopener","data-testid":`${e}-api-keys-link`,title:`Open ${m.label} API keys page`,"aria-label":`Open ${m.label} API keys page`,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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"})})})]}),f&&!w?(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:x}),(0,r.jsx)("button",{onClick:Z,"data-testid":`${e}-copy-api-key`,title:R?"Copied":"Copy API key","aria-label":"Copy API key",className:`p-1 rounded transition-colors ${R?"text-green-11":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,disabled:N,children:R?(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)("button",{onClick:()=>{k(!0),y(""),setTimeout(()=>O.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-hover text-foreground transition-colors",disabled:N,children:"Edit"}),(0,r.jsx)("button",{onClick:Y,className:"text-[11px] px-2 py-1 rounded text-red-11 hover:bg-red-500/10 transition-colors",disabled:N,children:"Clear"})]}):(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{ref:O,type:"password",value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{"Enter"===e.key&&J()},placeholder:"sk-...",className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${a.Fx}`,autoFocus:!0}),(0,r.jsx)("button",{onClick:J,disabled:N||!v.trim(),className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${a.$T}`,children:N?"Saving...":"Save"}),f&&(0,r.jsx)("button",{onClick:()=>{k(!1),y("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),T&&(0,r.jsx)("div",{className:"mt-1 text-[11px] text-red-11",children:T})]}),(0,r.jsx)("div",{className:"my-1 border-t border-border"}),m.regions&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"px-3 py-1.5",children:[(0,r.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Region"}),(0,r.jsx)("div",{className:"inline-flex rounded-md border border-border overflow-hidden text-xs",role:"group","data-testid":`${e}-region-toggle`,children:m.regions.map(t=>(0,r.jsx)("button",{type:"button","data-testid":`${e}-region-${t.id}`,onClick:()=>Q(t.id),title:t.hint,className:`px-2 py-0.5 ${P===t.id?"bg-brand text-white":"bg-transparent text-muted-foreground hover:bg-hover"}`,children:t.label},t.id))})]}),(0,r.jsx)("div",{className:"my-1 border-t border-border"})]}),(0,r.jsxs)("div",{className:"px-3 py-1.5",children:[(0,r.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Model"}),A&&(0,r.jsx)("div",{className:"mb-1 text-[11px] text-red-11",children:A}),!A&&0===L.length&&(0,r.jsx)("div",{className:"mb-1 text-[11px] text-muted-foreground",children:f?`No models returned by ${m.modelsEndpoint}`:"Save an API key to list models"}),(0,r.jsx)("div",{className:"flex flex-col gap-0.5",children:L.map(e=>{var t;let n=en===e.id,s=(t=e.contextTokens)&&!(t<=0)?t>=1048576?`${Math.round(t/1048576)}M`:`${Math.round(t/1024)}K`:null;return(0,r.jsxs)("button",{onClick:()=>X(e.id),className:`flex items-center gap-2 px-2 py-1 text-xs rounded transition-colors ${n?a.yI:"text-foreground hover:bg-hover"}`,children:[(0,r.jsx)(a.hG,{selected:n}),(0,r.jsx)("span",{className:"truncate",children:e.id}),e.label&&e.label!==e.id&&(0,r.jsx)("span",{className:"truncate text-[10px] text-muted-foreground",children:e.label}),s&&(0,r.jsx)("span",{className:"ml-auto pl-2 text-[10px] text-muted-foreground flex-shrink-0",children:s})]},e.id)})})]})]})})}):null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.XY,{buttonRef:D,label:ee,labelClassName:et,title:`Configure ${m.label}`,onClick:()=>{if(!h){if(D.current){let e=D.current.getBoundingClientRect(),t=z?.getBoundingClientRect(),n=t?.left??0,r=t?.top??0;q({top:e.bottom+4-r,left:e.left-n})}K()}p(e=>!e)},icon:(0,r.jsx)(a.eV,{engine:e}),testId:`${e}-config-picker`}),er]})}},97938:(e,t,n)=>{n.d(t,{z:()=>b,m:()=>w});var r=n(14594),s=n(8183),o=n(12115),a=n(41948),l=n(95272);function i(e,t){let n=new Map(e.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.id);return t&&function e(t,n){if(Object.is(t,n))return!0;if(!t||!n||"object"!=typeof t||"object"!=typeof n)return!1;if(Array.isArray(t)||Array.isArray(n))return Array.isArray(t)&&Array.isArray(n)&&t.length===n.length&&t.every((t,r)=>e(t,n[r]));let r=Object.keys(t);return r.length===Object.keys(n).length&&r.every(r=>Object.hasOwn(n,r)&&e(t[r],n[r]))}(t,e)?t:e});return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r}let d={messages:[],diskTurns:[],runs:[],failures:[],dismissedFailures:[],sessionId:null,totalTurns:0,hasMore:!1,needsStableRead:!1,writerIdle:!1,writerIdleRevision:0};function c(e){let t=e[0],n=t?.turnStartedAt??e.find(e=>"user"===e.role)?.timestamp??t?.timestamp;return n?Date.parse(n):NaN}function u(e,t){if("pending"===e.phase)return;let n=(0,a.l)(e.messages);for(let e of t){let t=n.findIndex(t=>t.some(t=>e.messages.some(e=>t.id===e.id||!!t.sourceId&&t.sourceId===(e.sourceId??e.id)||!!t.sourceTaskId&&t.sourceTaskId===e.sourceTaskId)));if(t>=0)return Math.max(0,e.index-t)}if(e.anchor){let r=e.anchor,s=n.findIndex(e=>e.some(e=>e.id===r.liveId&&(!e.sourceId||e.sourceId===(r.source.sourceId??r.source.id)))),o=t.find(e=>e.messages.some(e=>{var t;return t=r.source,t.sourceId?(e.sourceId??e.id)===t.sourceId:e.id===t.id&&(!t.prefix||e.sourceRef?.prefix===t.prefix)}));if(o&&s>=0)return Math.max(0,o.index-s)}for(let e of t){let t=n.findIndex(t=>t.some(t=>t.toolCalls?.some(t=>e.messages.some(e=>e.toolCalls?.some(e=>e.id===t.id)))));if(t>=0)return Math.max(0,e.index-t)}if(e.messages.some(e=>e.sourceId||e.sourceTaskId)||!Number.isFinite(c(n[0]??[])))return;let r=t.find(t=>c(t.messages)>=e.startedAt);if(!r)return;let s=t.find(e=>e.index===r.index-1);if(0===r.index||s&&c(s.messages)<e.startedAt)return r.index;let o=new Set;for(let r of t.filter(t=>c(t.messages)>=e.startedAt)){let e=r.messages.filter(e=>"user"===e.role);n.forEach((t,n)=>{let s=t.filter(e=>"user"===e.role);e.length&&s.length&&s[0].content===e[0].content&&JSON.stringify(s[0].images)===JSON.stringify(e[0].images)&&o.add(r.index-n)})}return 1===o.size?Math.max(0,[...o][0]):void 0}function m(e,t){return[...e.filter(e=>e.id!==t.id),...t.messages.length?[{id:t.id,startedAt:t.startedAt,messages:t.messages.map(e=>({...e,isStreaming:!1,toolCalls:e.toolCalls?.map(e=>({...e,isLoading:!1}))}))}]:[]]}function h(e){return!(e.terminalError&&"released"===e.phase)}function p(e,t=!1){let n=new Map(e.diskTurns.map(e=>[e.index,e.messages])),r=e.totalTurns,s=e.runs.map((n,s)=>{let o=u(n,e.diskTurns),l=e.runs.slice(0,s).some(e=>!h(e)),i=o??(t||n.anchor||l&&n.start>r?r:n.start),d={...n,start:i,anchor:void 0===o?n.anchor:function(e,t,n){for(let[r,s]of(0,a.l)(e.messages).entries()){let e=s.find(e=>"user"===e.role),o=t.find(e=>e.index===n+r)?.messages.find(e=>"user"===e.role);if(e&&o)return{liveId:e.id,source:o.sourceRef??{id:o.id,sourceId:o.sourceId,prefix:""}}}return e.anchor}(n,e.diskTurns,i)};return h(n)&&(r=Math.max(r,i+(0,a.l)(n.messages).length)),d});for(let e=0;e<s.length;e++){let t=s[e];if(!t.messages.length||!h(t))continue;let r=s.slice(e+1).find(e=>h(e))?.start??1/0;for(let e of n.keys())e>=t.start&&e<r&&n.delete(e);(0,a.l)(t.messages).forEach((e,s)=>{t.start+s<r&&n.set(t.start+s,e)})}let o=[...n.keys()].sort((e,t)=>e-t);if(!o.length)return{...e,runs:s,messages:i(e.messages,[]),startTurnIndex:0,hasMore:!1};let l=o.length-1;for(;l>0&&o[l-1]===o[l]-1;)l--;let d=o[l];return{...e,runs:s,startTurnIndex:d,hasMore:d>0,messages:i(e.messages,o.slice(l).flatMap(e=>n.get(e)))}}var f=n(49433),g=n(86957),x=n(82680);let b=e=>f.$mh({try:async t=>{let n=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:t});return n.ok?await n.json():null},catch:e=>new x.uV({message:"session-by-path failed",cause:e})}),v=new Map;function y(e){let t=e.runs.filter(e=>"released"===e.phase).map(e=>e.id),n=e.needsStableRead&&e.writerIdle&&!e.runs.some(e=>"pending"===e.phase||"active"===e.phase||"draining"===e.phase);return t.length||n?JSON.stringify([t,e.writerIdleRevision]):null}function w(e,{cwd:t,initialSessionId:n,onSessionId:c,onTitleChange:k,onTokenUsage:C,reconcileLimit:j=10,enabled:N=!0,liveRunning:S=!1}){let[T,E]=(0,o.useState)(!1),[R,M]=(0,o.useState)(!1),[L,I]=(0,o.useState)(d),A=(0,o.useRef)(L),F=(0,o.useRef)(new Set),P=(0,o.useRef)(null),$=(0,o.useRef)(null),D=(0,o.useCallback)(e=>{if("run-messages"===e.type){let{runId:t,update:n}=e,s=A.current.runs.find(e=>e.id===t);s&&!s.recovery&&$.current&&"object"==typeof n&&!Array.isArray(n)&&(0,r.az)(n.event)&&$.current.toolUpdates.push(n)}"page"!==e.type||e.fromCache||(e={...e,toolUpdates:$.current?.toolUpdates});let t=function(e,t){if("recovery-dismissed"===t.type)return{...e,dismissedFailures:[...e.dismissedFailures,t.id],failures:e.failures.filter(e=>e.id!==t.id)};let n=function(e,t){if("sender-start"===t.type||"replay-start"===t.type||"run-accepted"===t.type){let n="sender-start"!==t.type&&!t.run.recovery,r=e.runs.find(e=>e.id===t.run.id),s=r?e.runs.indexOf(r):e.runs.length,o=e.runs.map((e,t)=>n&&t<s&&"pending"!==e.phase?{...e,phase:"released"}:e),l=e.failures;for(let t of o)t.terminalError&&"released"===t.phase&&e.runs.find(e=>e.id===t.id)?.phase!=="released"&&(l=m(l,t));let i={...t.run,phase:t.run.recovery?"released":r&&("draining"===r.phase||"released"===r.phase)?r.phase:n?"active":"pending",terminalError:t.run.recovery||r?.terminalError,messages:"replay-start"===t.type?[]:r?.messages??[],start:r?.start??Math.max(e.totalTurns,...o.filter(h).map(e=>e.start+(0,a.l)(e.messages).length)),anchor:r?.anchor};return o=r?o.map(e=>e.id===i.id?i:e):[...o,i],p({...e,runs:o,failures:l,writerIdle:!1})}if("input-rejected"===t.type)return null!==e.sessionId&&e.sessionId!==t.sessionId?e:{...e,failures:m(e.failures,t.copy)};if("validated"===t.type)return null!==e.sessionId&&e.sessionId!==t.sessionId?e:{...e,sessionId:t.sessionId,needsStableRead:!t.stable};if("writer-idle"===t.type)return null!==e.sessionId&&e.sessionId!==t.sessionId?e:{...e,sessionId:t.sessionId,writerIdle:!0,writerIdleRevision:e.writerIdleRevision+1};if("run-end"===t.type){let n=e.runs.some(e=>e.id===t.runId),r=e.runs.map(e=>e.id===t.runId?{...e,...t.failed?{terminalError:!0}:{},phase:t.writerActive&&"released"!==e.phase?"draining":"released"}:e),s=r.find(e=>e.id===t.runId&&e.terminalError&&"released"===e.phase),o=s?m(e.failures,s):e.failures,a=r.some(e=>"pending"===e.phase||"active"===e.phase||"draining"===e.phase);return p({...e,runs:r,failures:o,writerIdle:!a&&(n||e.writerIdle||!t.writerActive)})}if("send-failed"===t.type){let n=e.runs.find(e=>e.id===t.runId);return n?p({...e,runs:e.runs.filter(e=>e!==n),failures:m(e.failures,n)}):e}if("recovery-deleted"===t.type){let{clearsBefore:n}=t.deletion,r=e=>void 0!==n&&e.startedAt<=n;return p({...e,failures:e.failures.filter(e=>!r(e)).map(e=>({...e,messages:(0,l.Q)(e.messages,t.deletion)})).filter(e=>e.messages.length),runs:e.runs.map(e=>e.terminalError?{...e,messages:r(e)?[]:(0,l.Q)(e.messages,t.deletion)}:e)})}if("run-messages"===t.type){let n=e.runs.find(e=>e.id===t.runId);if(!n)return e;let s=t.update,o="object"!=typeof s||Array.isArray(s)?void 0:s,a=e=>"function"==typeof s?s(e):Array.isArray(s)?s:(0,r.FM)(e,s.event,s),l=!!o&&!n.recovery&&(0,r.az)(o.event),i=e.runs.map(e=>e===n||l&&!e.terminalError?{...e,messages:a(e.messages)}:e),d=l?e.diskTurns.map(e=>({...e,messages:a(e.messages)})):e.diskTurns,c=i.find(e=>e.id===t.runId&&e.terminalError&&"released"===e.phase);return p({...e,diskTurns:d,runs:i,failures:c?m(e.failures,c):e.failures})}if("messages"===t.type){let n=new Map(("function"==typeof t.update?t.update(e.messages):t.update).map(e=>[e.id,e])),r=e=>e.flatMap(e=>n.get(e.id)??[]);return p({...e,diskTurns:e.diskTurns.map(e=>({...e,messages:r(e.messages)})),runs:e.runs.map(e=>e.terminalError&&"released"===e.phase?e:{...e,messages:r(e.messages)})})}let{page:n,mode:s,sessionId:o}=t;if("prepend"===s&&(e.sessionId!==o||t.endTurnIndex!==e.diskCursor?.index))return e;let c=null===e.sessionId||e.sessionId===o,f="prepend"!==s||!0===n.replacesWindow,g=t.fromCache||!f&&!1!==n.stable?c&&e.needsStableRead:!1===n.stable;if(!n.messages.length&&!1===n.stable)return{...c?e:d,sessionId:o,needsStableRead:g};let x=n.totalTurns??e.totalTurns,b=t.endTurnIndex??x,v=n.startTurnIndex??Math.max(0,b-(0,a.l)(n.messages).length),y=c&&!n.replacesWindow&&"replace"!==s&&"jump"!==s,w=new Map((y?e.diskTurns:[]).map(e=>[e.index,e]));if("prepend"!==s)for(let e of w.keys())e>=v&&w.delete(e);let k=n.messages,C=new Set(k.map(e=>e.id));for(let e of t.toolUpdates??[])k=(0,r.FM)(k,e.event,e).filter(e=>C.has(e.id));(0,a.l)(k).forEach((e,t)=>{let n=v+t;w.set(n,{index:n,messages:i(w.get(n)?.messages??[],e)})});let j=[...w.values()].filter(e=>e.index<x).sort((e,t)=>e.index-t.index),N=c?e.runs.filter(e=>f&&!t.fromCache&&t.reconciles?.includes(e.id)&&"released"===e.phase&&(!e.terminalError||!1!==n.stable)&&(v<=(u(e,j)??e.start)||n.replacesWindow)):[],S=c?e.runs.filter(e=>!N.includes(e)):[],T=c?e.failures:[];return p({...e,sessionId:o,diskTurns:j,runs:S,failures:T,totalTurns:x,needsStableRead:g,writerIdle:c&&e.writerIdle,diskCursor:y&&e.diskCursor&&!(v<=e.diskCursor.index)?e.diskCursor:{index:v,proof:n.beforeProof}},"prepend"!==s)}(e,t);if(n===e||!n.dismissedFailures.length)return n;let s=n.failures.filter(e=>!n.dismissedFailures.includes(e.id));return s.length===n.failures.length?n:{...n,failures:s}}(A.current,e);for(let e of(y(t)!==y(A.current)&&(P.current=null),A.current=t,I(t),F.current))e()},[]),{messages:_,hasMore:O}=L,B=(0,o.useRef)(0),H=(0,o.useRef)(void 0),[V,U]=(0,o.useState)(0),W=(0,o.useCallback)(e=>{$.current?.requestId===e&&($.current=null,M(!1),E(!1),U(B.current))},[]),q=(0,o.useRef)(0),z=(0,o.useCallback)(()=>{let e=q.current++,t=$.current;for(let n of(t?.navigation===e&&(B.current===t.requestId&&++B.current,W(t.requestId)),F.current))n()},[W]),K=(0,o.useCallback)(()=>{z(),++B.current,$.current&&W($.current.requestId),H.current=void 0},[z,W]),G=(0,o.useCallback)(e=>{D({type:"messages",update:e})},[D]),Q=(0,o.useCallback)((e,t)=>{D({type:"run-messages",runId:e,update:t})},[D]),[J,Y]=(0,o.useState)(null),[Z,X]=(0,o.useState)(null),[ee,et]=(0,o.useState)(null),[en,er]=(0,o.useState)(null),es=(0,o.useRef)(null);es.current=J;let eo=(0,o.useRef)(null),ea=J??e??n,el=(0,o.useRef)(ea);el.current=ea;let ei=(0,o.useRef)({cwd:t,sessionId:n??e}),ed=(0,o.useRef)(!1),ec=(0,o.useRef)(!1);(0,o.useEffect)(()=>()=>{ed.current=!1,ec.current=!1,K()},[t,K]);let eu=(0,o.useRef)(k);eu.current=k;let em=(0,o.useRef)(C);em.current=C;let eh=(0,o.useRef)(void 0),ep=(0,o.useCallback)(e=>{++B.current,$.current&&W($.current.requestId),eh.current=void 0,D({type:"sender-start",run:e})},[D,W]),ef=(0,o.useCallback)(e=>{eh.current=void 0,D({type:"run-accepted",run:e})},[D]),eg=(0,o.useCallback)(e=>D({type:"send-failed",runId:e}),[D]),ex=(0,o.useCallback)((e,t)=>{el.current===e&&(null===ei.current.sessionId||ei.current.sessionId===e)&&D({type:"input-rejected",sessionId:e,copy:t})},[D]),eb=(0,o.useCallback)(e=>{eh.current=void 0,D({type:"replay-start",run:e})},[D]),ev=(0,o.useCallback)((e,t,n=!1)=>{eh.current=void 0,D({type:"run-end",runId:t,writerActive:e,failed:n})},[D]),ey=(0,o.useCallback)(e=>D({type:"recovery-deleted",deletion:e}),[D]),ew=(0,o.useCallback)(e=>D({type:"recovery-dismissed",id:e}),[D]),ek=(0,o.useCallback)(e=>D({type:"writer-idle",sessionId:e}),[D]),eC=(0,o.useRef)(0),ej=(0,o.useCallback)(async(e,t,n=!1,r,o,a=!1)=>{if((ei.current.cwd!==e||ei.current.sessionId!==t)&&((ei.current.cwd!==e||null!==ei.current.sessionId)&&K(),ei.current={cwd:e,sessionId:t},eh.current=void 0,eC.current=0),n){let e=Date.now();if(!a&&e-eC.current<5e3)return;eC.current=e}let l=++B.current,i=A.current.runs.filter(e=>"released"===e.phase).map(e=>e.id);$.current={requestId:l,toolUpdates:[]},n||(H.current=void 0);let d=H.current,u=(n,r,a=!1)=>{n.replacesWindow&&(H.current=void 0),eh.current=a&&0===A.current.runs.length&&!1!==n.stable?n.fingerprint:void 0,n.messages&&(D({type:"page",sessionId:t,page:{...n,messages:n.messages},mode:r?"incremental":"replace",endTurnIndex:o,reconciles:a?i:void 0,fromCache:!a}),Y(t),es.current=t),n.sessionId&&c(n.sessionId),n.engine&&(et(n.engine),X(n.model??null)),er(n.bot??null),n.title&&("number"==typeof n.titleRevision&&void 0!==n.defaultTitle&&void 0!==n.customTitle&&(0,s.X4)({cwd:e,sessionId:t,title:n.title,defaultTitle:n.defaultTitle,customTitle:n.customTitle,titleRevision:n.titleRevision}),eu.current?.((0,s.iM)((0,s.V6)(),e,t,n.title,n.titleRevision))),n.usage&&em.current?.({inputTokens:n.usage.input_tokens||0,outputTokens:n.usage.output_tokens||0,cacheCreationInputTokens:n.usage.cache_creation_input_tokens||0,cacheReadInputTokens:n.usage.cache_read_input_tokens||0,totalCostUsd:0})},m=`${e}::${t}`;a&&v.delete(m);let h=!n&&void 0===o,p=h?v.get(m):void 0;n||(p&&0===A.current.runs.length?u(p.data,!1):E(!0));try{let s={cwd:e,sessionId:t,limit:r,beforeTurnIndex:o};if(n&&void 0!==r&&void 0===o){let e=[A.current.diskCursor?.index,d?.start,...A.current.runs.filter(e=>i.includes(e.id)).map(e=>e.start)].filter(e=>void 0!==e);e.length>0&&(s.fromTurnIndex=Math.min(...e)),s.fromTurnIndex===A.current.diskCursor?.index&&(s.expectedStartProof=A.current.diskCursor?.proof)}let a=A.current.startTurnIndex,c=void 0!==o||(void 0===r?0!==a:"number"==typeof s.fromTurnIndex&&(void 0===a||s.fromTurnIndex<a));n&&!c&&eh.current&&0===A.current.runs.length?s.ifFingerprint=eh.current:p&&0===A.current.runs.length&&(s.ifFingerprint=p.fingerprint);let f=await g.t4.runPromiseExit(b(s));if(l!==B.current)return;if("Success"===f._tag&&f.value){let r=f.value;if((r.messages||r.notModified)&&(eo.current=JSON.stringify([e,t])),r.notModified){"boolean"==typeof r.stable&&(eh.current=r.stable?r.fingerprint:void 0,D({type:"validated",sessionId:t,stable:r.stable}));return}if(u(r,n,!0),H.current===d&&(H.current=void 0),h&&r.fingerprint&&r.messages&&!1!==r.stable&&(v.delete(m),v.set(m,{data:r,fingerprint:r.fingerprint}),v.size>20)){let e=v.keys().next().value;void 0!==e&&v.delete(e)}}}catch(e){console.error("Failed to load history by cwd and sessionId:",e)}finally{W(l)}},[c,K,W]),eN=y(L),eS=L.runs.some(e=>"pending"===e.phase);(0,o.useEffect)(()=>{let e=N&&!ed.current;if(ed.current=N,!N){ec.current=!1;return}if(!e&&!ec.current)return;e&&(P.current=null);let r=es.current??n;if(!t||!r)return;if($.current){ec.current=!0;return}if(ec.current=!1,eN)return;let s=A.current.runs,o=eo.current===JSON.stringify([t,r]);o&&(S||s.some(e=>"released"!==e.phase))||ej(t,r,o,o?j??void 0:10)},[N,V,t,n,S,eN,j,ej]),(0,o.useEffect)(()=>{if(!N||!eN||$.current||!t||!ea||ei.current.cwd!==t||ei.current.sessionId&&ei.current.sessionId!==ea)return;let e=JSON.stringify([t,ea,eN]),n=P.current;n?.demand===e&&(eS||n.requestId===B.current)||(ej(t,ea,!0,j??void 0,void 0,!0),P.current={demand:e,requestId:B.current})},[N,eN,eS,V,t,ea,j,ej]);let eT=(0,o.useCallback)(async()=>{let n=A.current;if(!t||!e||$.current||!n.hasMore||!n.diskCursor?.index)return;let r=n.diskCursor.index,s=n.runs.filter(e=>"released"===e.phase).map(e=>e.id),o=++B.current;$.current={requestId:o,toolUpdates:[]},H.current={requestId:o,start:Math.max(0,r-10)},M(!0);try{let a=await g.t4.runPromiseExit(b({cwd:t,sessionId:e,limit:10,beforeTurnIndex:r,expectedBeforeProof:n.diskCursor.proof}));if(o!==B.current)return;if("Success"===a._tag&&a.value){let o=a.value;if(o.messages){if(!o.beforeProof&&void 0!==o.totalTurns&&o.totalTurns<n.totalTurns)return void await ej(t,e,!1,10,void 0,!0);o.replacesWindow&&(H.current=void 0),D({type:"page",sessionId:e,page:{...o,messages:o.messages},mode:"prepend",endTurnIndex:r,reconciles:s}),Y(e),!o.replacesWindow&&void 0!==o.totalTurns&&o.totalTurns>n.totalTurns&&await ej(t,e,!0,10,void 0,!0)}}else"Failure"===a._tag&&console.error("Failed to load more history:",a.cause)}finally{H.current?.requestId===o&&(H.current=void 0),W(o)}},[t,e,ej,W]),eE=(0,o.useCallback)(async function n(r,s,o){z();let l=q.current,i=es.current??e;if(!t||!i||r<0||ei.current.sessionId&&ei.current.sessionId!==i)return{status:"cancelled"};ei.current={cwd:t,sessionId:i};let d=A.current.runs.findLast(e=>{if(o)return e.id===o;let t=u(e,A.current.diskTurns);return void 0!==t&&r>=t});if(d&&"released"!==d.phase&&("Failure"===(await g.t4.runPromiseExit(f.bIC(e=>{let t=()=>{let n=l!==q.current,r=!A.current.runs.some(e=>e.id===d.id&&"released"!==e.phase);(n||r)&&(F.current.delete(t),e(n?f.fJG(new x.uV({message:"History navigation cancelled"})):f.rIH))};return F.current.add(t),t(),f.OH5(()=>{F.current.delete(t)})})))._tag||l!==q.current))return{status:"cancelled"};let c=++B.current,m=A.current.runs.filter(e=>"released"===e.phase).map(e=>e.id);$.current={requestId:c,navigation:l,toolUpdates:[]},M(!0);try{let e=await g.t4.runPromiseExit(b({cwd:t,sessionId:i,fromTurnIndex:Math.min(r,...A.current.runs.filter(e=>m.includes(e.id)).map(e=>e.start)),target:s}).pipe(f.KT6(f.bIC(e=>{let t=()=>{l!==q.current&&e(f.fJG(new x.uV({message:"History navigation cancelled"})))};return F.current.add(t),t(),f.OH5(()=>{F.current.delete(t)})}))));if(l!==q.current)return{status:"cancelled"};if(c!==B.current)return n(r,s);if("Failure"===e._tag)return console.error("Failed to load turns for jump:",e.cause),{status:"failed"};if(!e.value)return{status:"failed"};if(es.current&&es.current!==i)return{status:"cancelled"};let o=e.value;if("missing"===o.targetStatus||"stale"===o.targetStatus)return{status:o.targetStatus};if(o.messages&&(D({type:"page",sessionId:i,page:{...o,messages:o.messages,startTurnIndex:o.startTurnIndex??r},mode:"jump",reconciles:m}),Y(i)),s&&o.resolvedMessageId&&!A.current.messages.some(e=>e.id===o.resolvedMessageId)){let e=(0,a.l)(o.messages??[]).findIndex(e=>e.some(e=>e.id===o.resolvedMessageId)),t=(o.startTurnIndex??r)+Math.max(0,e),l=A.current.runs.findLast(e=>e.start<=t);if(l&&"released"!==l.phase)return n(r,s,l.id);return{status:"failed"}}return eh.current=A.current.runs.length?void 0:o.fingerprint,o.messages?{status:"ready",messageId:o.resolvedMessageId}:{status:"failed"}}finally{W(c)}},[t,e,z,W]);return{messages:_,recoveryCopies:L.failures,onRecoveryDeleted:ey,onRecoveryDismissed:ew,setMessages:G,onLiveSnapshotStart:eb,setRunMessages:Q,onRunAccepted:ef,onSendFailure:eg,onInputRejected:ex,onLiveRunEnd:ev,onSenderStart:ep,onWriterIdle:ek,isLoadingHistory:T,isLoadingMore:R,hasMoreHistory:O,loadMoreHistory:eT,ensureTurnLoaded:eE,cancelTurnLoad:z,loadHistoryByCwdAndSessionId:ej,loadedSessionId:J,loadedEngine:ee,loadedModel:Z,loadedBot:en}}},98245:(e,t,n)=>{n.d(t,{C:()=>s});var r=n(69809);function s(e,t){if("codex_input_queued"===e.notice||"codex_input_accepted"===e.notice||"codex_input_failed"===e.notice){let n=e.notice.slice(12),s=r.A.t(`chat.codexInput.${n}`),o=[s,e.input_text,e.input_images?r.A.t("chat.codexInput.images",{count:e.input_images}):"",e.error].filter(Boolean).join("\n\n");return{id:t,role:"system",content:s,systemEvent:{kind:"meta",detail:o}}}if("codex_context_compacting"===e.notice){let e=r.A.t("chat.codexContextCompacting",{defaultValue:"Codex is compacting the context…"});return{id:t,role:"system",content:e,systemEvent:{kind:"meta",detail:e}}}if("codex_resume_failed"!==e.notice)return null;let n=e.previous_session_id||"",s=r.A.t("chat.codexResumeFailed",{defaultValue:"Previous session is in use by another Codex client — started a new session; history was not carried over"}),o=[...n?[`${r.A.t("chat.codexResumeFailedPrevious",{defaultValue:"Previous session"})}: ${n}`]:[],...e.session_id?[`${r.A.t("chat.codexResumeFailedNew",{defaultValue:"New session"})}: ${e.session_id}`]:[]],a=[s,...o.length?["",...o]:[],...e.error?["",e.error]:[]].join("\n");return{id:t,role:"system",content:s,systemEvent:{kind:"meta",detail:a}}}},99356:(e,t,n)=>{n.d(t,{I7:()=>s,WM:()=>r});let r="/ws/global-state?limit=100";function s(){let e=window.location.pathname;return"/m"===e||e.startsWith("/m/")?r:"/ws/global-state"}}}]);
|