@surething/cockpit 1.0.284 → 1.0.286
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 +2 -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/server/app/_global-error/page.js.nft.json +1 -1
- package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/_global-error.html +1 -1
- package/.next-prod/server/app/_global-error.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found/page.js +1 -1
- package/.next-prod/server/app/_not-found/page.js.nft.json +1 -1
- package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/_not-found.html +2 -2
- package/.next-prod/server/app/_not-found.rsc +2 -2
- package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next-prod/server/app/api/agent/test/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/bash/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/bots/[id]/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/bots/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/codex/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/deepseek/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/glm/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/kimi/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/ollama/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/route.js +1 -1
- package/.next-prod/server/app/api/chat/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/stop/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/claude-stats/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/commands/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/comments/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/columns/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/connect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/disconnect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/export/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/query/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/db/schemas/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/deepseek/balance/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/deepseek/credentials/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/deepseek/models/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/dev/spans/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/extension/version/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/file/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/blame/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/clipboard/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/copy/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/delete/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/expanded/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/index/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/init/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/paste/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/read/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/readdir/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/recent/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/save/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/search/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/stat/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/files/text/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/fs/dirs/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/blob/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/branch-diff/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/branches/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/commit-diff/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/commits/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/current-branch/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/diff/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/discard/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/stage/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/status/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/unstage/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/git/worktree/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/glm/credentials/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/glm/models/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/glm/usage/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/global-state/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/health/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/html-apps/[id]/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/html-apps/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/instructions/config/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/kimi/credentials/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/kimi/models/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/kimi/usage/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/definition/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/hover/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/references/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/status/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/lsp/warmup/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/columns/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/connect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/disconnect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/export/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/query/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/mysql/schemas/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/neo4j/connect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/neo4j/disconnect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/neo4j/query/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/neo4j/schema/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/note/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/ollama/config/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/ollama/default-model/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/ollama/models/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/ollama/start/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/open-cursor/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/open-vscode/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/output-styles/config/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/pinned-sessions/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/project-settings/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/project-state/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/affected/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/callees/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/callers/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/coedit/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/context/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/file/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/file-functions/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/impact/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/related/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/risk/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projectGraph/search/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/projects/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/push/public-key/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/push/subscribe/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/push/unsubscribe/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/command/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/connect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/delete/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/disconnect/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/get/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/keys/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/redis/set/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/restart/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/scheduled-tasks/route.js +2 -2
- package/.next-prod/server/app/api/scheduled-tasks/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/services/config/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/services/scripts/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/fork/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/history/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/turn/route.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/turn/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/session/user-messages/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/session-by-path/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/sessions/delegate/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/sessions/projects/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/sessions/search/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/sessions/status/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/settings/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/shutdown/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/skills/[id]/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/skills/content/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/skills/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/snapshots/blob/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/snapshots/diff/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/snapshots/range-diff/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/snapshots/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/aliases/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/autocomplete/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/bubble-order/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/env/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/history/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/terminal/running/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/update/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/update-state/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/version/route.js.nft.json +1 -1
- package/.next-prod/server/app/apps/[...path]/route.js.nft.json +1 -1
- package/.next-prod/server/app/favicon.ico/route.js.nft.json +1 -1
- package/.next-prod/server/app/m/page.js +1 -1
- package/.next-prod/server/app/m/page.js.nft.json +1 -1
- package/.next-prod/server/app/m/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/manifest.webmanifest/route.js.nft.json +1 -1
- package/.next-prod/server/app/page.js +1 -1
- package/.next-prod/server/app/page.js.nft.json +1 -1
- package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/project/page.js +1 -1
- package/.next-prod/server/app/project/page.js.nft.json +1 -1
- package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app-paths-manifest.json +2 -2
- package/.next-prod/server/chunks/2493.js +4 -4
- package/.next-prod/server/chunks/7438.js +14 -14
- package/.next-prod/server/chunks/{5591.js → 8647.js} +7 -7
- package/.next-prod/server/chunks/9830.js +1 -1
- package/.next-prod/server/middleware-build-manifest.js +1 -1
- package/.next-prod/server/pages/404.html +2 -2
- package/.next-prod/server/pages/500.html +1 -1
- package/.next-prod/server/server-reference-manifest.json +1 -1
- package/.next-prod/static/chunks/{2550-eb5beeffe90c8632.js → 2550-d42d8fc88c0cec98.js} +21 -21
- package/.next-prod/static/chunks/{3919-aceb512341847e1c.js → 4731-3b3290b5ec84f6bd.js} +11 -11
- package/.next-prod/static/chunks/{5313-da9f9a2ce9c5ba34.js → 5313-d734a6541498a6db.js} +7 -7
- package/.next-prod/static/chunks/app/{layout-64ed9873820de627.js → layout-26d284da8922060a.js} +1 -1
- package/.next-prod/static/chunks/app/m/{page-a60ec971bab91969.js → page-6a86aa4f5ebeebfd.js} +1 -1
- package/.next-prod/static/chunks/app/{page-acbb0b783e63d133.js → page-88b01c311b11942a.js} +1 -1
- package/.next-prod/static/chunks/app/project/{page-acbb0b783e63d133.js → page-88b01c311b11942a.js} +1 -1
- package/.next-prod/trace +14 -14
- package/.next-prod/trace-build +1 -1
- package/dist/{chunk-2KRJ7JEJ.mjs → chunk-2UCBL4S6.mjs} +1 -1
- package/dist/{chunk-FP25USWW.mjs → chunk-G6BCSLZX.mjs} +148 -38
- package/dist/httpApi.mjs +2 -2
- package/dist/scheduledTasks.mjs +65 -12
- package/dist/wsServer.mjs +4 -4
- package/package.json +5 -3
- package/public/html-lib/markdown.js +85 -85
- /package/.next-prod/static/{qXlYDVAyeD8v5tCOCGbXD → cwGvPiCgQI4epB2d3stR2}/_buildManifest.js +0 -0
- /package/.next-prod/static/{qXlYDVAyeD8v5tCOCGbXD → cwGvPiCgQI4epB2d3stR2}/_ssgManifest.js +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5313],{201:(e,t,n)=>{n.d(t,{M:()=>L});var r=n(95155),o=n(12115),s=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 c=n(23883),d=n(1058),u=n(90717),h=n(89109),m=n(7320),p=n(79114),f=n(86957),g=n(83448),x=n(62111),b=n(64428);let v=/[,,]/;function y({initialRows:e,lang:t,isCustomized:n,onSave:s,onRestoreDefault:a,onClose:l}){let{t:i}=(0,p.Bd)(),[c,d]=(0,o.useState)(()=>e.map(e=>e.join("zh"===t?",":", ")).join("\n"));(0,x.E)(l);let u=(0,o.useCallback)(()=>{s(c.split("\n").map(e=>e.split(v).map(e=>e.trim().slice(0,200)).filter(Boolean).slice(0,8)).filter(e=>e.length>0).slice(0,12)),l()},[c,s,l]),h=(0,o.useCallback)(()=>{a(),l()},[a,l]);return(0,r.jsx)(b.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:c,onChange:e=>d(e.target.value),placeholder:i("quickReply.editPlaceholder"),rows:6,spellCheck:!1,className:"w-full px-2 py-1.5 text-xs font-mono 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:u,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 w={mode:"follow",pinTop:null},k={mode:"free",pinTop:null};function C(e){return Math.max(0,e.scrollHeight-e.spacer)}function j(e){return Math.max(0,C(e)-e.clientHeight)}function N(e,t){return e<=0?0:Math.max(0,e+t.clientHeight-C(t))}function S(e){return C(e)-e.scrollTop-e.clientHeight<50}function T(e,t="auto"){return{owner:w,spacer:0,scrollTo:j(e),behavior:t}}function E({value:e}){let[t,n]=(0,o.useState)(e),s=(0,o.useRef)(e),a=(0,o.useRef)(null);return(0,o.useEffect)(()=>{null!==a.current&&(cancelAnimationFrame(a.current),a.current=null);let t=s.current;if(e<=t){s.current=e,n(e);return}let r=performance.now(),o=l=>{let i=Math.min(1,Math.ceil(12*Math.min(1,(l-r)/400))/12),c=Math.round(t+(e-t)*i);s.current=c,n(c),i<1?a.current=requestAnimationFrame(o):a.current=null};return a.current=requestAnimationFrame(o),()=>{null!==a.current&&cancelAnimationFrame(a.current),a.current=null}},[e]),(0,r.jsx)("span",{className:"tabular-nums",children:t})}let L=(0,o.forwardRef)(function({messages:e,isLoading:t,cwd:n,sessionId:l,engine:x,botName:b,apiRetryInfo:v,backgroundTasks:C,liveOutputTokens:L,runningStartedAt:M,hasMoreHistory:R,isLoadingMore:A,onLoadMore:P,onFork:F,onDeleteTurn:I,onSendToPeer:$,peerSide:D,isActive:B=!0,onContentSearch:O,onShowFileDiff:_,onOpenFileLink:H,onApprovePlan:V,onShowUserMessages:U},W){let q,{t:z,i18n:K}=(0,p.Bd)(),G=(0,o.useRef)(null),J=(0,o.useRef)(null),Q=(0,o.useRef)(null),Y=(0,o.useRef)(null),Z=(0,o.useRef)(null),X=(0,o.useRef)(null),[ee,et]=(0,o.useState)(null),en=(0,o.useRef)({mode:"follow",pinTop:null}),er=(0,o.useRef)(null),eo=(0,o.useRef)(!1),es=(0,o.useRef)(B),ea=(0,o.useCallback)(()=>{let e=Q.current;return e?{clientHeight:e.clientHeight,scrollHeight:e.scrollHeight,scrollTop:e.scrollTop,spacer:er.current?.offsetHeight??0}:null},[]),el=(0,o.useRef)(null),ei=(0,o.useCallback)(e=>{let t=ea();if(!t)return!1;let n=function(e,t,n){if(!(n.clientHeight>0))return null;switch(t.type){case"reset":return{owner:w,spacer:0,scrollTo:null,behavior:"auto"};case"toEnd":return T(n,"smooth");case"readFrom":{let e=t.top;return{owner:{mode:"reading",pinTop:e},spacer:N(e,n),scrollTo:e,behavior:"auto"}}case"settle":{if("reading"===e.mode){let t=e.pinTop??n.scrollTop;return{owner:e,spacer:N(t,n),scrollTo:null,behavior:"auto"}}if(n.spacer<=0)return null;let t=Math.min(n.scrollTop,j(n));return{owner:t>=j(n)?w:k,spacer:0,scrollTo:t,behavior:"smooth",deferSpacer:!0}}case"pin":{let e=N(t.top,n);if(e<=0)return T(n);return{owner:{mode:"pinned",pinTop:t.top},spacer:e,scrollTo:t.top,behavior:"smooth"}}case"release":if("pinned"!==e.mode&&"reading"!==e.mode)return null;return{owner:k,spacer:N(n.scrollTop,n),scrollTo:null,behavior:"auto"};case"content":case"viewport":if("follow"===e.mode)return T(n);if("pinned"===e.mode){let r=e.pinTop??n.scrollTop,o=N(r,n);if(o<=0)return T(n);return{owner:e,spacer:o,scrollTo:"viewport"===t.type?r:null,behavior:"auto"}}if("reading"===e.mode){let r=e.pinTop??n.scrollTop;return{owner:e,spacer:N(r,n),scrollTo:"viewport"===t.type?r:null,behavior:"auto"}}return{owner:e,spacer:N(n.scrollTop,n),scrollTo:null,behavior:"auto"}}}(en.current,e,t);if(!n)return!1;el.current?.(),en.current=n.owner;let r=()=>{er.current&&(er.current.style.height=`${n.spacer}px`)};n.deferSpacer||r();let o=Q.current;if(null!==n.scrollTo&&o?.scrollTo({top:n.scrollTo,behavior:n.behavior}),n.deferSpacer&&o){let e=()=>{n(),r()},t=setTimeout(e,700),n=()=>{clearTimeout(t),o.removeEventListener("scrollend",e),el.current=null};o.addEventListener("scrollend",e,{once:!0}),el.current=n}return!0},[ea]);(0,o.useEffect)(()=>()=>el.current?.(),[]);let[ec,ed]=(0,o.useState)(!1),[eu,eh]=(0,o.useState)(!1),[em,ep]=(0,o.useState)(null),[ef,eg]=(0,o.useState)(0);(0,o.useEffect)(()=>{et(X.current)},[]),(0,o.useEffect)(()=>{if(!t||!M)return void eg(0);let e=()=>eg(Math.max(0,Math.floor((Date.now()-M)/1e3)));e();let n=setInterval(e,1e3);return()=>clearInterval(n)},[t,M]);let ex=(0,o.useMemo)(()=>(0,a.ch)(x)?a.H[x]:a.H.claude,[x]),eb=(0,a.ch)(x)?x:"claude",ev=(0,o.useMemo)(()=>{let e=Math.floor(ef/60),t=ef%60;return e>0?`${e}m${t}s`:`${t}s`},[ef]),{isSearchVisible:ey,searchQuery:ew,setSearchQuery:ek,matches:eC,currentMatchIndex:ej,goToNextMatch:eN,goToPrevMatch:eS,closeSearch:eT,searchInputRef:eE,handleSearchKeyDown:eL}=function(e){let[t,n]=(0,o.useState)(!1),[r,s]=(0,o.useState)(""),[a,l]=(0,o.useState)([]),[i,c]=(0,o.useState)(0),d=(0,o.useRef)(null),u=(0,o.useRef)([]),h=(0,o.useCallback)(()=>{let t=e.current;t&&(t.querySelectorAll("mark.chat-search-match, mark.chat-search-current").forEach(e=>{let t=e.parentNode;t&&(t.replaceChild(document.createTextNode(e.textContent||""),e),t.normalize())}),u.current=[])},[e]),m=(0,o.useCallback)(t=>{if(h(),!t||!e.current){l([]),c(0);return}let n=[],r=[],o=t.toLowerCase();e.current.querySelectorAll("[data-message-id]").forEach(e=>{let s,a=e.getAttribute("data-message-id")||"",l=0,i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),c=[];for(;s=i.nextNode();)c.push(s);for(let e of c){let s=(e.textContent||"").toLowerCase(),i=0,c=[];for(;;){let e=s.indexOf(o,i);if(-1===e)break;c.push({start:e,end:e+t.length}),i=e+1}if(0!==c.length)for(let t=c.length-1;t>=0;t--){let o=c[t];e.splitText(o.end);let s=e.splitText(o.start),i=document.createElement("mark");i.className="chat-search-match",i.textContent=s.textContent,s.parentNode.replaceChild(i,s),n.push({messageId:a,markIndex:l}),r.push(i),l++}}}),n.reverse(),r.reverse(),u.current=r,l(n),c(n.length>0?0:-1)},[e,h]);(0,o.useEffect)(()=>{queueMicrotask(()=>m(r))},[r,m]),(0,o.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,o.useCallback)(()=>{0!==a.length&&c(e=>(e+1)%a.length)},[a.length]),f=(0,o.useCallback)(()=>{0!==a.length&&c(e=>(e-1+a.length)%a.length)},[a.length]),g=(0,o.useCallback)(()=>{n(!0),setTimeout(()=>d.current?.focus(),0)},[]),x=(0,o.useCallback)(()=>{n(!1),s(""),h(),l([]),c(0)},[h]),b=(0,o.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?f():p()),"Escape"===e.key&&x()},[p,f,x]);return(0,o.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:s,matches:a,currentMatchIndex:i,goToNextMatch:p,goToPrevMatch:f,openSearch:g,closeSearch:x,searchInputRef:d,handleSearchKeyDown:b}}(X),eM=(0,s.nH)(),eR=(0,o.useRef)(null),eA=(0,o.useRef)(()=>{}),{addComment:eP,refresh:eF}=(0,d._)({cwd:n||"",filePath:u.Un}),[eI,e$]=(0,o.useState)(null),[eD,eB]=(0,o.useState)(null),eO=(0,o.useCallback)(e=>{if(eI||eD)return;let t=window.getSelection();if(!t||t.isCollapsed||!t.rangeCount){eR.current=null,eA.current();return}let n=t.toString().trim();if(!n){eR.current=null,eA.current();return}let r=t.anchorNode instanceof HTMLElement?t.anchorNode:t.anchorNode?.parentElement;if(r?.closest('[data-role="user"]')){eR.current=null,eA.current();return}eR.current={x:e.clientX,y:e.clientY,range:{start:0,end:0},selectedText:n,lineSnapshot:n},eA.current()},[eI,eD]),e_=(0,o.useCallback)(e=>{let t=e.target;!(t.closest(".floating-toolbar")||t.closest('[class*="z-[200]"]'))&&eR.current&&(eR.current=null,eA.current())},[]),eH=(0,o.useCallback)(()=>{let e=eR.current;e&&(e$({x:e.x,y:e.y,text:e.selectedText}),eR.current=null,eA.current(),window.getSelection()?.removeAllRanges())},[]),eV=(0,o.useCallback)(()=>{let e=eR.current;e&&(eB({x:e.x,y:e.y,text:e.selectedText}),eR.current=null,eA.current(),window.getSelection()?.removeAllRanges())},[]),eU=(0,o.useCallback)(()=>{let e=eR.current;e&&eM&&(eR.current=null,eA.current(),window.getSelection()?.removeAllRanges(),(0,u.Ff)(eM.sendMessage,{filePath:u.Un,startLine:0,endLine:0,codeContent:e.selectedText},z("explain.selectionMessage")))},[eM,z]),eW=(0,o.useCallback)(()=>{let e=eR.current;if(!e||!O)return;let t=e.selectedText.trim();eR.current=null,eA.current(),window.getSelection()?.removeAllRanges(),t&&O(t)},[O]),eq=(0,o.useCallback)(async e=>{eI&&(await eP(0,0,e,eI.text),e$(null))},[eI,eP]),ez=(0,o.useCallback)(async(e,t)=>{if(eM&&n)try{let r=(await (0,u.$3)(n)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));r.push({filePath:u.Un,startLine:0,endLine:0,codeContent:e});let o=(0,u.Gw)(r,t);eM.sendMessage(o),await (0,u.RP)(n),eF()}catch(e){console.error("Failed to send to AI:",e)}},[eM,n,eF]),eK=(0,o.useCallback)((e,t)=>{let n=eR.current;if(!n)return;let r=n.selectedText;eR.current=null,eA.current(),window.getSelection()?.removeAllRanges(),"comment"===e?eP(0,0,t,r):ez(r,t)},[eP,ez]),eG=(q=K.language,q?.toLowerCase().startsWith("zh")?"zh":"en"),[eJ,eQ]=(0,o.useState)(null),[eY,eZ]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=!1;return f.t4.runPromiseExit((0,g.td)()).then(t=>{e||eQ("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,eG):null)}),()=>{e=!0}},[eG]);let eX=(0,o.useCallback)(e=>{f.t4.runPromiseExit((0,g.td)()).then(t=>{let n={..."Success"===t._tag?t.value.quickReplies??{}:{}};return e?n[eG]=e:delete n[eG],f.t4.runPromiseExit((0,g.em)({quickReplies:n})).then(t=>{"Success"===t._tag?eQ(e):console.error("Failed to save quick replies:",t.cause)})})},[eG]),e0=(0,o.useCallback)(()=>{eR.current=null,eA.current(),window.getSelection()?.removeAllRanges(),eZ(!0)},[]),e1=(0,o.useMemo)(()=>eJ??h.SZ.map(e=>e.map(e=>z(e))),[eJ,z]),e2=(0,o.useCallback)(e=>{eD&&ez(eD.text,e)},[eD,ez]),e5=(0,o.useCallback)(e=>{eI&&ez(eI.text,e)},[eI,ez]),e4=(0,o.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]),e3=(0,o.useMemo)(()=>e4.filter(e=>"user"===e.role),[e4]),e8=(0,o.useMemo)(()=>e3.slice(-10),[e3]),e6=R||e3.length>10,e9=(0,o.useRef)(0),e7=(0,o.useRef)(!1),te=(0,o.useCallback)(()=>{let e=Q.current;return!e||e.scrollTop<50},[]),tt=(0,o.useCallback)((e=!1)=>{let t=Q.current;if(!t)return;if(e&&e8.length>0)return void ep(e8[e8.length-1].id);let n=t.getBoundingClientRect(),r=null,o=null;for(let e of e8){let s=t.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);if(!s)continue;let a=s.getBoundingClientRect().top;!o&&a<n.bottom&&(o=e.id),a<=n.top+12&&(r=e.id)}ep(r??o)},[e8]),tn=(0,o.useCallback)(()=>{let e=ea(),t=!e||S(e),n=te();if(e&&(en.current=function(e,t){return"pinned"===e.mode||"reading"===e.mode?e:50>Math.abs(t.scrollTop-j(t))?w:k}(en.current,e)),ed(!n),eh(!t),tt(t),n&&R&&!A&&P){let e=Q.current;e&&(e9.current=e.scrollHeight,e7.current=!0),P()}},[te,ea,tt,R,A,P]),tr=(0,o.useCallback)(()=>{ei({type:"release"}),J.current?.scrollIntoView({behavior:"smooth"})},[ei]),to=(0,o.useCallback)(()=>{ei({type:"toEnd"})},[ei]),ts=(0,o.useCallback)(e=>{let t=Q.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"}),ei({type:"release"}),Y.current&&clearTimeout(Y.current),Z.current?.classList.remove("flash-turn"),n.classList.remove("flash-turn"),n.offsetWidth,n.classList.add("flash-turn"),Z.current=n,Y.current=setTimeout(()=>{n.classList.remove("flash-turn"),Z.current=null,Y.current=null},2e3),!0},[ei]),ta=(0,o.useRef)(!1),tl=(0,o.useCallback)(()=>{ta.current=!0},[]);(0,o.useImperativeHandle)(W,()=>({scrollToMessage:ts,pinNextUserMessage:tl}),[ts,tl]),(0,o.useLayoutEffect)(()=>{let e;if(!ta.current)return;let t=Q.current;if(!t)return;for(let t=e4.length-1;t>=0;t-=1)if("user"===e4[t].role){e=e4[t];break}if(!e)return;let n=t.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);n&&(ta.current=!1,ei({type:"pin",top:Math.max(0,n.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop-8)}))},[e4,ei]),(0,o.useLayoutEffect)(()=>{let e=es.current;es.current=B,e&&!B&&t&&(eo.current=!0)},[B,t]),(0,o.useLayoutEffect)(()=>{e7.current||ei({type:"content"})},[e,t,ei]),(0,o.useEffect)(()=>{let e=Q.current;if(!e)return;let t=new ResizeObserver(()=>ei({type:"viewport"}));return t.observe(e),()=>t.disconnect()},[ei]),(0,o.useEffect)(()=>{let e=Q.current;if(!e)return;let t=()=>ei({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)}},[ei]);let ti=(0,o.useRef)(l);(0,o.useEffect)(()=>{let e=ti.current;ti.current=l,e&&e!==l&&(ta.current=!1,eo.current=!1,ei({type:"reset"}))},[l,ei]),(0,o.useLayoutEffect)(()=>{if(e7.current&&!A){let e=Q.current;if(e){let t=e.scrollHeight-e9.current;e.scrollTop=t,e7.current=!1}}},[e,A]);let tc=(0,o.useRef)(t),td=(0,o.useRef)(!1);return(0,o.useEffect)(()=>{let e=tc.current;tc.current=t,e&&!t&&(td.current=!ei({type:"settle"}))},[t,ei]),(0,o.useLayoutEffect)(()=>{if(B){if(eo.current){let e=Q.current,t=e?.querySelectorAll('[data-role="user"]'),n=t?.item((t?.length??0)-1);if(e&&n&&ei({type:"readFrom",top:Math.max(0,n.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop-8)})){eo.current=!1,td.current=!1;return}}ei({type:"viewport"}),td.current&&(td.current=!1,ei({type:"settle"}))}},[B,ei]),(0,o.useEffect)(()=>{if(!B)return;let e=ea();tt(!!e&&S(e))},[e,B,ea,tt]),(0,r.jsxs)("div",{ref:X,className:"relative flex-1 min-h-0 overflow-hidden flex flex-col outline-none",tabIndex:-1,onMouseUp:eO,onMouseDown:e_,children:[ey&&(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:eE,type:"text",value:ew,onChange:e=>ek(e.target.value),onKeyDown:eL,placeholder:z("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:eC.length>0?`${ej+1}/${eC.length}`:z("common.noMatch")}),(0,r.jsx)("button",{onClick:eS,disabled:0===eC.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:z("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:eN,disabled:0===eC.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:z("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:eT,className:"p-1 rounded hover:bg-hover",title:z("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:Q,onScroll:tn,className:"relative flex-1 min-h-0 overflow-y-auto px-8 py-4",children:0!==e.length||t?(0,r.jsxs)("div",{className:"mx-auto w-full max-w-[var(--chat-column)]",children:[(0,r.jsx)("div",{ref:J}),R&&(0,r.jsx)("div",{className:"flex justify-center py-3",children:A?(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:z("chat.loadMoreHistory")})]}):(0,r.jsx)("button",{onClick:P,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:z("chat.scrollUpForMore")})}),e4.map(e=>(0,r.jsx)("div",{"data-message-id":e.id,"data-role":e.role,children:(0,r.jsx)(c.s,{message:e,cwd:n,sessionId:l,onFork:F,onDeleteTurn:I,forkSupported:!0,onSendToPeer:$,peerSide:D,onApprovePlan:V,isLoading:t,onContentSearch:O,onShowFileDiff:_,onOpenFileLink:H})},e.id)),t&&(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:b}),(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:eb,className:"h-4 w-4"})}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground/80 text-shimmer",children:[ex," running ",ev," \xb7 processing"," ",(0,r.jsx)(E,{value:L?.outputTokens??0})]})]}),C&&C.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 ",C.length," background task",C.length>1?"s":""]}),C.map(e=>(0,r.jsx)("div",{className:"text-muted-foreground/80 break-words",children:e.description},e.task_id))]})]}),v&&(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 ",v.attempt,v.maxRetries>0?`/${v.maxRetries}`:"",v.delayMs>0?`, delay ${(v.delayMs/1e3).toFixed(1)}s`:"",")"]}),(v.errorStatus||v.error)&&(0,r.jsxs)("div",{className:"text-muted-foreground/80 break-words",children:[v.errorStatus?`${v.errorStatus}`:"",v.errorStatus&&v.error?" \xb7 ":"",v.error||""]})]})]})]})}),(0,r.jsx)("div",{ref:er,"aria-hidden":!0}),(0,r.jsx)("div",{ref:G})]}):(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:z("chat.startConversation")})]})})}),(e8.length>0||ec||eu)&&(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":z("chat.recentUserMessages"),children:[ec&&e.length>0&&(0,r.jsx)("button",{onClick:tr,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:z("chat.jumpToStart"),"aria-label":z("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"})})}),e6&&U&&(0,r.jsx)("button",{onClick:U,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:z("chat.moreUserMessages"),"aria-label":z("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"})})}),e8.map((e,t)=>{let n=em===e.id,o=e.content.replace(/\s+/g," ").trim()||(e.images?.length?z("chat.imageMessage"):z("chat.userMessage"));return(0,r.jsxs)("div",{className:"group relative flex h-3 items-center",children:[(0,r.jsx)("button",{onClick:t=>{ts(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":z("chat.recentUserMessageNumber",{index:t+1,total:e8.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:o})})]},e.id)}),eu&&e.length>0&&(0,r.jsx)("button",{onClick:to,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:z("chat.jumpToLatest"),"aria-label":z("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"})})})]}),ee&&(0,r.jsx)(h.fS,{floatingToolbarRef:eR,bumpRef:eA,container:ee,onAddComment:eH,onSendToAI:eV,onSearch:O?eW:void 0,onExplain:eM?eU:void 0,onQuickReply:eK,quickReplyRows:e1,onEditQuickReplies:e0,isChatLoading:eM?.isLoading}),eY&&(0,r.jsx)(y,{initialRows:e1,lang:eG,isCustomized:null!==eJ,onSave:e=>eX(e.length?e:null),onRestoreDefault:()=>eX(null),onClose:()=>eZ(!1)}),eI&&ee&&(0,r.jsx)(m.t,{x:eI.x,y:eI.y,range:{start:0,end:0},lineSnapshot:eI.text,container:ee,onSubmit:eq,onSendToAI:eM?e5:void 0,onClose:()=>e$(null),isChatLoading:eM?.isLoading}),eD&&ee&&(0,r.jsx)(m.G,{x:eD.x,y:eD.y,range:{start:0,end:0},lineSnapshot:eD.text,container:ee,onSubmit:e2,onClose:()=>eB(null),isChatLoading:eM?.isLoading})]})})},1058:(e,t,n)=>{n.d(t,{_:()=>l});var r=n(12115),o=n(90717),s=n(86957),a=n(46456);function l({cwd:e,filePath:t}){let[n,i]=(0,r.useState)([]),[c,d]=(0,r.useState)(!1),[u,h]=(0,r.useState)(null),m=(0,r.useCallback)(async()=>{if(!e||!t)return;d(!0),h(null);let n=await s.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;h(t instanceof Error?t.message:"Failed to load comments")}d(!1)},[e,t]);(0,r.useEffect)(()=>{m()},[m]),(0,r.useEffect)(()=>(0,o.zL)(()=>{m()}),[m]);let p=(0,r.useCallback)(async(n,r,l,c)=>{let d=await s.t4.runPromiseExit((0,a.BC)({cwd:e,filePath:t,startLine:n,endLine:r,content:l,...c?{selectedText:c}:{}}));if("Success"===d._tag&&d.value.comment){let e=d.value.comment;return i(t=>[...t,e]),(0,o.Cm)(),e}return"Failure"===d._tag&&console.error("Failed to add comment:",d.cause),null},[e,t]),f=(0,r.useCallback)(async(t,n)=>{let r=await s.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 s.t4.runPromiseExit((0,a.Tu)(e,t));return"Success"===n._tag?(i(e=>e.filter(e=>e.id!==t)),(0,o.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:c,error:u,addComment:p,updateComment:f,deleteComment:g,refresh:m,getCommentsForLine:x}}},2111:(e,t,n)=>{n.d(t,{D:()=>i,h:()=>c});var r=n(12115),o=n(91281),s=n(36196);o.EV(s.YA(1),1.5).pipe(o.gP(o.ji(s.YA(10))),o.y$(o.t5(10))),o.EV(s.ne(200),2).pipe(o.gP(o.ji(s.YA(5))),o.y$(o.t5(5))),o.EV(s.YA(1),2).pipe(o.et,o.gP(o.ji(s.YA(30))),o.y$(o.t5(8))),o.ji(s.YA(30)),o.ji(s.YA(1)),o.ji(s.YA(30)),s.ne(50),o.BW;let a=new Map,l=new Set;function i(e){return l.add(e),()=>{l.delete(e)}}function c({url:e,onMessage:t,enabled:n=!0}){let o=(0,r.useRef)(t);(0,r.useEffect)(()=>{o.current=t}),(0,r.useEffect)(()=>{if(!n)return;let t=e=>o.current(e),r=function(e){let t=a.get(e);if(t)return t;let n={ws:null,listeners: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,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.listeners.delete(t),0===r.listeners.size&&r.destroy()}},[e,n])}},3238:(e,t,n)=>{n.d(t,{DP:()=>a,NP:()=>i,Ql:()=>l});var r=n(95155),o=n(12115);let s=(0,o.createContext)(null);function a(){let e=(0,o.useContext)(s);if(!e)throw Error("useTheme must be used within a ThemeProvider");return e}function l(){return(0,o.useContext)(s)}function i({children:e}){let[t,n]=(0,o.useState)("system"),[a,l]=(0,o.useState)("light"),c=(0,o.useCallback)(()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[]),d=(0,o.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,o.useCallback)(e=>{n(e),localStorage.setItem("theme",e),d("system"===e?c():e),document.querySelectorAll("iframe").forEach(t=>{t.contentWindow?.postMessage({type:"THEME_CHANGE",theme:e},"*")})},[c,d]);return(0,o.useEffect)(()=>{let e=localStorage.getItem("theme")||"dark";queueMicrotask(()=>{n(e),d("system"===e?c():e)})},[c,d]),(0,o.useEffect)(()=>{if("system"!==t)return;let e=window.matchMedia("(prefers-color-scheme: dark)"),n=e=>{d(e.matches?"dark":"light")};return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[t,d]),(0,o.useEffect)(()=>{let e=e=>{if(e.data?.type==="THEME_CHANGE"){let t=e.data.theme;n(t),localStorage.setItem("theme",t),d("system"===t?c():t)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[c,d]),(0,r.jsx)(s.Provider,{value:{theme:t,resolvedTheme:a,setTheme:u},children:e})}},3292:(e,t,n)=>{n.d(t,{P:()=>c});var r=n(12115),o=n(95045),s=n(75346),a=n(49433),l=n(86957),i=n(82680);function c(){let[e,t]=(0,r.useState)([]),n=(0,r.useCallback)(()=>{let e=a.$mh({try:async()=>{let e=await fetch("/api/pinned-sessions");return await e.json()},catch:e=>new i.uV({message:"loadPinnedSessions failed",cause:e})});l.t4.runPromise(e.pipe(a.YWq({onSuccess:e=>t(e.sessions||[]),onFailure:()=>{}})))},[]);(0,r.useEffect)(()=>{n()},[n]),(0,r.useEffect)(()=>{let e=e=>{e.data?.type==="PINNED_SESSIONS_CHANGED"&&n()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[n]);let c=(0,r.useCallback)(e=>{t(e);let n=a.$mh({try:async()=>{await fetch("/api/pinned-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessions:e})})},catch:e=>new i.uV({message:"savePinnedSessions failed",cause:e})});l.t4.runFork(n.pipe(a.NWQ(()=>a.rIH))),(0,o.F)(s.n.PinnedSessionsChanged,{})},[]),d=(0,r.useCallback)(t=>e.some(e=>e.sessionId===t),[e]),u=(0,r.useCallback)((t,n,r)=>{e.some(e=>e.sessionId===t)||c([...e,{sessionId:t,cwd:n,customTitle:r}])},[e,c]),h=(0,r.useCallback)(t=>{c(e.filter(e=>e.sessionId!==t))},[e,c]),m=(0,r.useCallback)((t,n)=>{c(e.map(e=>e.sessionId===t?{...e,customTitle:n}:e))},[e,c]);return{pinnedSessions:e,isPinned:d,pinSession:u,unpinSession:h,updateTitle:m,reorder:(0,r.useCallback)(e=>{c(e)},[c]),reload:n}}},4055:(e,t,n)=>{n.d(t,{h:()=>o});let r=new Set(["Read","Grep","Glob","LS","WebSearch","WebFetch","NotebookRead","TodoRead","AskUserQuestion","ExitPlanMode","TodoWrite","Skill"]),o=e=>!r.has(e)},5135:(e,t,n)=>{n.d(t,{M:()=>E});var r=n(95155),o=n(12115),s=n(79114),a=n(14341),l=n(47650),i=n(70188),c=n(34075),d=n(89109),u=n(7320),h=n(37614),m=n(1058),p=n(48347),f=n(90717),g=n(69809),x=n(95927),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:L,embedded:M=!1,onLocalMdLink:R,scrollToAnchor:A}){let P=L||n&&(0,S.y)(n,t)||t,{t:F}=(0,s.Bd)(),I=(0,i.iN)(),$=(0,p.r)(),D=(0,k.U)(),B=(0,C.Q)(),{comments:O,addComment:_,updateComment:H,deleteComment:V,refresh:U}=(0,m._)({cwd:n,filePath:t}),[W,q]=(0,o.useState)(!1),[z,K]=(0,o.useState)(null),[G,J]=(0,o.useState)(null),[Q,Y]=(0,o.useState)(null),Z=(0,o.useMemo)(()=>e.split("\n"),[e]),X=(0,o.useMemo)(()=>(0,b.J4)(t,n),[t,n]);(0,o.useEffect)(()=>{queueMicrotask(()=>q(!0))},[]);let[ee,et]=(0,o.useState)(null),en=(0,o.useRef)(null);(0,o.useEffect)(()=>{en.current!==ee&&et(en.current)});let er=(0,o.useRef)({onLocalMdLink:R,sourceFile:P});er.current={onLocalMdLink:R,sourceFile:P};let eo=(0,o.useRef)(e=>{let{onLocalMdLink:t,sourceFile:n}=er.current;if(!t||/^[a-z][a-z0-9+.-]*:/i.test(e))return!1;let r=e.indexOf("#"),o=r>=0?e.slice(0,r):e,s=r>=0?e.slice(r+1):null;if(!o)return!1;let a=o;try{a=decodeURIComponent(o)}catch{}return!!(0,w.e$)(a)&&(t((0,w.WU)(n,a),s),!0)}).current;(0,o.useEffect)(()=>{if(!A)return;let e=setTimeout(()=>{(0,y.O)(en.current,A)},80);return()=>clearTimeout(e)},[A,e]);let{toolbarRef:es,bumpRef:ea,clearToolbar:el}=(0,N.L)({enabled:!0,container:ee,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"),o=n.getAttribute("data-source-end");return r&&o?{start:parseInt(r,10),end:parseInt(o,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")}}),ei=(0,o.useCallback)(()=>{let e=es.current;e&&(K({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),el())},[el,es]),ec=(0,o.useCallback)(()=>{let e=es.current;e&&(J({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),el())},[el,es]),ed=(0,o.useCallback)(()=>{let e=es.current;e&&$&&(el(),(0,f.Ff)($.sendMessage,{filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},g.A.t("explain.selectionMessage")))},[$,t,el,es]),eu=(0,o.useCallback)(async e=>{z&&(await _(z.range.start,z.range.end,e,z.selectedText),K(null))},[z,_]),eh=(0,o.useCallback)(async(e,r)=>{if($)try{let o=await (0,f.$3)(n),s=[];for(let e of o)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});s.push({filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot});let a=(0,f.Gw)(s,r);$.sendMessage(a),await (0,f.RP)(n),U()}catch(e){console.error("Failed to send to AI:",e)}},[$,t,n,U]),em=(0,o.useCallback)(e=>{G&&eh(G,e)},[G,eh]),ep=(0,o.useCallback)(e=>{z&&eh(z,e)},[z,eh]),ef=(0,o.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]),[eg,ex]=(0,o.useState)([]);return(0,o.useEffect)(()=>{if(0===ef.length||!en.current)return void queueMicrotask(()=>ex([]));let e=setTimeout(()=>{let e=en.current;if(!e)return;let t=[],n=e.querySelectorAll("[data-source-start]");for(let r of ef){let o=null,s=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<s&&(s=r,o=e)}}if(o){let n=e.getBoundingClientRect(),s=o.getBoundingClientRect();t.push({key:r.key,top:s.top-n.top+e.scrollTop,comments:r.comments})}}ex(t)},100);return()=>clearTimeout(e)},[ef,e]),(0,o.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(G){J(null),e.stopPropagation();return}if(z){K(null),e.stopPropagation();return}if(es.current){es.current=null,ea.current(),e.stopPropagation();return}if(Q){Y(null),e.stopPropagation();return}v?.()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[G,z,Q,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.jsxs)("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,c.oR)(F("common.copiedPath"))},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):D(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:en}),(0,r.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:en,children:[(0,r.jsx)("div",{className:"p-6",children:(0,r.jsx)(x.T,{content:e,basePath:X,rehypePlugins:T,onLinkClick:eo})}),eg.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(),Y({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))]})]}),W&&I&&(0,l.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.fS,{floatingToolbarRef:es,bumpRef:ea,container:I,onAddComment:ei,onSendToAI:ec,onExplain:$?ed:void 0,isChatLoading:$?.isLoading}),z&&(0,r.jsx)(u.t,{x:z.x,y:z.y,range:z.range,filePath:t,lineSnapshot:z.lineSnapshot,container:I,onSubmit:eu,onSendToAI:$?ep:void 0,onClose:()=>K(null),isChatLoading:$?.isLoading}),G&&(0,r.jsx)(u.G,{x:G.x,y:G.y,range:G.range,filePath:t,lineSnapshot:G.lineSnapshot,container:I,onSubmit:em,onClose:()=>J(null),isChatLoading:$?.isLoading}),Q&&(0,r.jsx)(h.t,{x:Q.x,y:Q.y,comment:Q.comment,container:I,onClose:()=>Y(null),onUpdateComment:H,onDeleteComment:V})]}),I)]})}},7320:(e,t,n)=>{n.d(t,{G:()=>l,t:()=>a});var r=n(95155),o=n(12115),s=n(79114);function a({x:e,y:t,range:n,filePath:l,lineSnapshot:i,container:c,onSubmit:d,onSendToAI:u,onClose:h,isChatLoading:m}){let{t:p}=(0,s.Bd)(),[f,g]=(0,o.useState)(""),[x,b]=(0,o.useState)(!1),v=(0,o.useRef)(null),y=(0,o.useRef)(null),[w,k]=(0,o.useState)({x:0,y:0}),C=i?.split("\n").slice(0,5).join("\n"),j=!!i&&i.split("\n").length>5;(0,o.useEffect)(()=>{if(v.current&&c){let n=c.getBoundingClientRect(),r=v.current.getBoundingClientRect(),o=e-n.left,s=t-n.top;o+r.width>n.width-16&&(o=n.width-r.width-16),o<16&&(o=16),s+r.height>n.height-16&&(s=s-r.height-8),s<16&&(s=16),queueMicrotask(()=>k({x:o,y:s}))}},[e,t,c]),(0,o.useEffect)(()=>{y.current?.focus()},[]),(0,o.useEffect)(()=>{let e=e=>{x||!v.current||v.current.contains(e.target)||h()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[h,x]);let N=()=>{!x&&f.trim()&&(b(!0),d(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||h()}}),(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&&!m&&u&&f.trim()&&(b(!0),u(f.trim()),h())},disabled:x||m||!f.trim(),title:m?p("comments.aiResponding"):void 0,children:p("comments.sendToAI")})]})]})]})]})}function l({x:e,y:t,range:n,filePath:a,lineSnapshot:i,container:c,onSubmit:d,onClose:u,isChatLoading:h}){let{t:m}=(0,s.Bd)(),[p,f]=(0,o.useState)(""),g=(0,o.useRef)(null),x=(0,o.useRef)(null),[b,v]=(0,o.useState)({x:0,y:0});(0,o.useEffect)(()=>{if(g.current&&c){let n=c.getBoundingClientRect(),r=g.current.getBoundingClientRect(),o=e-n.left,s=t-n.top;o+r.width>n.width-16&&(o=n.width-r.width-16),o<16&&(o=16),s+r.height>n.height-16&&(s=s-r.height-8),s<16&&(s=16),queueMicrotask(()=>v({x:o,y:s}))}},[e,t,c]),(0,o.useEffect)(()=>{x.current?.focus()},[]),(0,o.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:m("comments.askAI")}),(n.start>0||n.end>0)&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:m("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:m("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:h,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!h&&p.trim()&&(d(p.trim()),u())),"Escape"===e.key&&u()}}),(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:m(h?"comments.aiGenerating":"comments.enterSend")})]})]})}},9573:(e,t,n)=>{n.d(t,{Tt:()=>i,se:()=>l,xK:()=>a});var r=n(49433),o=n(82680);let s=e=>r.$mh({try:async()=>{let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status}`);return await t.json()},catch:t=>new o.uV({message:`GET ${e} failed`,cause:t})}),a=(e,t,n)=>s(`/api/snapshots?cwd=${encodeURIComponent(e)}&toolIds=${encodeURIComponent(t.join(","))}${n?`&sessionKey=${encodeURIComponent(n)}`:""}`).pipe(r.TjK(e=>e.commits??[])),l=(e,t,n)=>a(e,t,n).pipe(r.qIB(t=>r.Q7R(t.map(t=>{let n;return n=t.hash,s(`/api/snapshots/diff?cwd=${encodeURIComponent(e)}&commit=${encodeURIComponent(n)}`)}),{concurrency:4}))),i=(e,t,n)=>s(`/api/snapshots/range-diff?cwd=${encodeURIComponent(e)}&head=${encodeURIComponent(n)}${t?`&base=${encodeURIComponent(t)}`:""}`)},11890:(e,t,n)=>{function r(e){return e.trim().toLowerCase().replace(/[\s]+/g,"-").replace(/[^\w一-鿿-ヿ가--]/g,"").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"")}function o(e,t){if(!e)return!1;let n=t;try{n=decodeURIComponent(t)}catch{}let o=r(n);if(!o)return!1;for(let t of e.querySelectorAll("h1, h2, h3, h4, h5, h6"))if(r(t.textContent||"")===o)return t.scrollIntoView({behavior:"smooth",block:"start"}),!0;return!1}n.d(t,{O:()=>o})},14575:(e,t,n)=>{n.d(t,{o:()=>a});var r=n(95155);n(12115);let o={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"},s={"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=s[l=e.toLowerCase()]?s[l]:o[e.split(".").pop()?.toLowerCase()||""]||o.default,c=e.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(c)?(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(c)?(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"===c||"tsx"===c&&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"===c?(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(c)?(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(c)?(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"===c?(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"===c?(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"===c?(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(c)?(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"===c?(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"===c?(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(c)?(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(c)?(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(c)?(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"===c||".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"===c||"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"===c||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"===c?(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"===c?(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+$/,"")}
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5313],{201:(e,t,n)=>{n.d(t,{M:()=>L});var r=n(95155),o=n(12115),s=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 c=n(23883),d=n(1058),u=n(90717),h=n(89109),m=n(7320),p=n(79114),f=n(86957),g=n(83448),x=n(62111),b=n(64428);let v=/[,,]/;function y({initialRows:e,lang:t,isCustomized:n,onSave:s,onRestoreDefault:a,onClose:l}){let{t:i}=(0,p.Bd)(),[c,d]=(0,o.useState)(()=>e.map(e=>e.join("zh"===t?",":", ")).join("\n"));(0,x.E)(l);let u=(0,o.useCallback)(()=>{s(c.split("\n").map(e=>e.split(v).map(e=>e.trim().slice(0,200)).filter(Boolean).slice(0,8)).filter(e=>e.length>0).slice(0,12)),l()},[c,s,l]),h=(0,o.useCallback)(()=>{a(),l()},[a,l]);return(0,r.jsx)(b.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:c,onChange:e=>d(e.target.value),placeholder:i("quickReply.editPlaceholder"),rows:6,spellCheck:!1,className:"w-full px-2 py-1.5 text-xs font-mono 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:u,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 w={mode:"follow",pinTop:null},k={mode:"free",pinTop:null};function C(e){return Math.max(0,e.scrollHeight-e.spacer)}function j(e){return Math.max(0,C(e)-e.clientHeight)}function N(e,t){return e<=0?0:Math.max(0,e+t.clientHeight-C(t))}function S(e){return C(e)-e.scrollTop-e.clientHeight<50}function T(e,t="auto"){return{owner:w,spacer:0,scrollTo:j(e),behavior:t}}function E({value:e}){let[t,n]=(0,o.useState)(e),s=(0,o.useRef)(e),a=(0,o.useRef)(null);return(0,o.useEffect)(()=>{null!==a.current&&(cancelAnimationFrame(a.current),a.current=null);let t=s.current;if(e<=t){s.current=e,n(e);return}let r=performance.now(),o=l=>{let i=Math.min(1,Math.ceil(12*Math.min(1,(l-r)/400))/12),c=Math.round(t+(e-t)*i);s.current=c,n(c),i<1?a.current=requestAnimationFrame(o):a.current=null};return a.current=requestAnimationFrame(o),()=>{null!==a.current&&cancelAnimationFrame(a.current),a.current=null}},[e]),(0,r.jsx)("span",{className:"tabular-nums",children:t})}let L=(0,o.forwardRef)(function({messages:e,isLoading:t,cwd:n,sessionId:l,engine:x,botName:b,apiRetryInfo:v,backgroundTasks:C,liveOutputTokens:L,runningStartedAt:M,hasMoreHistory:R,isLoadingMore:A,onLoadMore:P,onFork:F,onDeleteTurn:I,onSendToPeer:D,peerSide:$,isActive:B=!0,onContentSearch:_,onShowFileDiff:O,onOpenFileLink:H,onApprovePlan:V,onShowUserMessages:U},W){let q,{t:z,i18n:K}=(0,p.Bd)(),G=(0,o.useRef)(null),J=(0,o.useRef)(null),Q=(0,o.useRef)(null),Y=(0,o.useRef)(null),Z=(0,o.useRef)(null),X=(0,o.useRef)(null),[ee,et]=(0,o.useState)(null),en=(0,o.useRef)({mode:"follow",pinTop:null}),er=(0,o.useRef)(null),eo=(0,o.useRef)(!1),es=(0,o.useRef)(B),ea=(0,o.useCallback)(()=>{let e=Q.current;return e?{clientHeight:e.clientHeight,scrollHeight:e.scrollHeight,scrollTop:e.scrollTop,spacer:er.current?.offsetHeight??0}:null},[]),el=(0,o.useRef)(null),ei=(0,o.useCallback)(e=>{let t=ea();if(!t)return!1;let n=function(e,t,n){if(!(n.clientHeight>0))return null;switch(t.type){case"reset":return{owner:w,spacer:0,scrollTo:null,behavior:"auto"};case"toEnd":return T(n,"smooth");case"readFrom":{let e=t.top;return{owner:{mode:"reading",pinTop:e},spacer:N(e,n),scrollTo:e,behavior:"auto"}}case"settle":{if("reading"===e.mode){let t=e.pinTop??n.scrollTop;return{owner:e,spacer:N(t,n),scrollTo:null,behavior:"auto"}}if(n.spacer<=0)return null;let t=Math.min(n.scrollTop,j(n));return{owner:t>=j(n)?w:k,spacer:0,scrollTo:t,behavior:"smooth",deferSpacer:!0}}case"pin":{let e=N(t.top,n);if(e<=0)return T(n);return{owner:{mode:"pinned",pinTop:t.top},spacer:e,scrollTo:t.top,behavior:"smooth"}}case"release":if("pinned"!==e.mode&&"reading"!==e.mode)return null;return{owner:k,spacer:N(n.scrollTop,n),scrollTo:null,behavior:"auto"};case"content":case"viewport":if("follow"===e.mode)return T(n);if("pinned"===e.mode){let r=e.pinTop??n.scrollTop,o=N(r,n);if(o<=0)return T(n);return{owner:e,spacer:o,scrollTo:"viewport"===t.type?r:null,behavior:"auto"}}if("reading"===e.mode){let r=e.pinTop??n.scrollTop;return{owner:e,spacer:N(r,n),scrollTo:"viewport"===t.type?r:null,behavior:"auto"}}return{owner:e,spacer:N(n.scrollTop,n),scrollTo:null,behavior:"auto"}}}(en.current,e,t);if(!n)return!1;el.current?.(),en.current=n.owner;let r=()=>{er.current&&(er.current.style.height=`${n.spacer}px`)};n.deferSpacer||r();let o=Q.current;if(null!==n.scrollTo&&o?.scrollTo({top:n.scrollTo,behavior:n.behavior}),n.deferSpacer&&o){let e=()=>{n(),r()},t=setTimeout(e,700),n=()=>{clearTimeout(t),o.removeEventListener("scrollend",e),el.current=null};o.addEventListener("scrollend",e,{once:!0}),el.current=n}return!0},[ea]);(0,o.useEffect)(()=>()=>el.current?.(),[]);let[ec,ed]=(0,o.useState)(!1),[eu,eh]=(0,o.useState)(!1),[em,ep]=(0,o.useState)(null),[ef,eg]=(0,o.useState)(0);(0,o.useEffect)(()=>{et(X.current)},[]),(0,o.useEffect)(()=>{if(!t||!M)return void eg(0);let e=()=>eg(Math.max(0,Math.floor((Date.now()-M)/1e3)));e();let n=setInterval(e,1e3);return()=>clearInterval(n)},[t,M]);let ex=(0,o.useMemo)(()=>(0,a.ch)(x)?a.H[x]:a.H.claude,[x]),eb=(0,a.ch)(x)?x:"claude",ev=(0,o.useMemo)(()=>{let e=Math.floor(ef/60),t=ef%60;return e>0?`${e}m${t}s`:`${t}s`},[ef]),{isSearchVisible:ey,searchQuery:ew,setSearchQuery:ek,matches:eC,currentMatchIndex:ej,goToNextMatch:eN,goToPrevMatch:eS,closeSearch:eT,searchInputRef:eE,handleSearchKeyDown:eL}=function(e){let[t,n]=(0,o.useState)(!1),[r,s]=(0,o.useState)(""),[a,l]=(0,o.useState)([]),[i,c]=(0,o.useState)(0),d=(0,o.useRef)(null),u=(0,o.useRef)([]),h=(0,o.useCallback)(()=>{let t=e.current;t&&(t.querySelectorAll("mark.chat-search-match, mark.chat-search-current").forEach(e=>{let t=e.parentNode;t&&(t.replaceChild(document.createTextNode(e.textContent||""),e),t.normalize())}),u.current=[])},[e]),m=(0,o.useCallback)(t=>{if(h(),!t||!e.current){l([]),c(0);return}let n=[],r=[],o=t.toLowerCase();e.current.querySelectorAll("[data-message-id]").forEach(e=>{let s,a=e.getAttribute("data-message-id")||"",l=0,i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),c=[];for(;s=i.nextNode();)c.push(s);for(let e of c){let s=(e.textContent||"").toLowerCase(),i=0,c=[];for(;;){let e=s.indexOf(o,i);if(-1===e)break;c.push({start:e,end:e+t.length}),i=e+1}if(0!==c.length)for(let t=c.length-1;t>=0;t--){let o=c[t];e.splitText(o.end);let s=e.splitText(o.start),i=document.createElement("mark");i.className="chat-search-match",i.textContent=s.textContent,s.parentNode.replaceChild(i,s),n.push({messageId:a,markIndex:l}),r.push(i),l++}}}),n.reverse(),r.reverse(),u.current=r,l(n),c(n.length>0?0:-1)},[e,h]);(0,o.useEffect)(()=>{queueMicrotask(()=>m(r))},[r,m]),(0,o.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,o.useCallback)(()=>{0!==a.length&&c(e=>(e+1)%a.length)},[a.length]),f=(0,o.useCallback)(()=>{0!==a.length&&c(e=>(e-1+a.length)%a.length)},[a.length]),g=(0,o.useCallback)(()=>{n(!0),setTimeout(()=>d.current?.focus(),0)},[]),x=(0,o.useCallback)(()=>{n(!1),s(""),h(),l([]),c(0)},[h]),b=(0,o.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?f():p()),"Escape"===e.key&&x()},[p,f,x]);return(0,o.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:s,matches:a,currentMatchIndex:i,goToNextMatch:p,goToPrevMatch:f,openSearch:g,closeSearch:x,searchInputRef:d,handleSearchKeyDown:b}}(X),eM=(0,s.nH)(),eR=(0,o.useRef)(null),eA=(0,o.useRef)(()=>{}),{addComment:eP,refresh:eF}=(0,d._)({cwd:n||"",filePath:u.Un}),[eI,eD]=(0,o.useState)(null),[e$,eB]=(0,o.useState)(null),e_=(0,o.useCallback)(e=>{if(eI||e$)return;let t=window.getSelection();if(!t||t.isCollapsed||!t.rangeCount){eR.current=null,eA.current();return}let n=t.toString().trim();if(!n){eR.current=null,eA.current();return}let r=t.anchorNode instanceof HTMLElement?t.anchorNode:t.anchorNode?.parentElement;if(r?.closest('[data-role="user"]')){eR.current=null,eA.current();return}eR.current={x:e.clientX,y:e.clientY,range:{start:0,end:0},selectedText:n,lineSnapshot:n},eA.current()},[eI,e$]),eO=(0,o.useCallback)(e=>{let t=e.target;!(t.closest(".floating-toolbar")||t.closest('[class*="z-[200]"]'))&&eR.current&&(eR.current=null,eA.current())},[]),eH=(0,o.useCallback)(()=>{let e=eR.current;e&&(eD({x:e.x,y:e.y,text:e.selectedText}),eR.current=null,eA.current(),window.getSelection()?.removeAllRanges())},[]),eV=(0,o.useCallback)(()=>{let e=eR.current;e&&(eB({x:e.x,y:e.y,text:e.selectedText}),eR.current=null,eA.current(),window.getSelection()?.removeAllRanges())},[]),eU=(0,o.useCallback)(()=>{let e=eR.current;e&&eM&&(eR.current=null,eA.current(),window.getSelection()?.removeAllRanges(),(0,u.Ff)(eM.sendMessage,{filePath:u.Un,startLine:0,endLine:0,codeContent:e.selectedText},z("explain.selectionMessage")))},[eM,z]),eW=(0,o.useCallback)(()=>{let e=eR.current;if(!e||!_)return;let t=e.selectedText.trim();eR.current=null,eA.current(),window.getSelection()?.removeAllRanges(),t&&_(t)},[_]),eq=(0,o.useCallback)(async e=>{eI&&(await eP(0,0,e,eI.text),eD(null))},[eI,eP]),ez=(0,o.useCallback)(async(e,t)=>{if(eM&&n)try{let r=(await (0,u.$3)(n)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));r.push({filePath:u.Un,startLine:0,endLine:0,codeContent:e});let o=(0,u.Gw)(r,t);eM.sendMessage(o),await (0,u.RP)(n),eF()}catch(e){console.error("Failed to send to AI:",e)}},[eM,n,eF]),eK=(0,o.useCallback)((e,t)=>{let n=eR.current;if(!n)return;let r=n.selectedText;eR.current=null,eA.current(),window.getSelection()?.removeAllRanges(),"comment"===e?eP(0,0,t,r):ez(r,t)},[eP,ez]),eG=(q=K.language,q?.toLowerCase().startsWith("zh")?"zh":"en"),[eJ,eQ]=(0,o.useState)(null),[eY,eZ]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=!1;return f.t4.runPromiseExit((0,g.td)()).then(t=>{e||eQ("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,eG):null)}),()=>{e=!0}},[eG]);let eX=(0,o.useCallback)(e=>{f.t4.runPromiseExit((0,g.td)()).then(t=>{let n={..."Success"===t._tag?t.value.quickReplies??{}:{}};return e?n[eG]=e:delete n[eG],f.t4.runPromiseExit((0,g.em)({quickReplies:n})).then(t=>{"Success"===t._tag?eQ(e):console.error("Failed to save quick replies:",t.cause)})})},[eG]),e0=(0,o.useCallback)(()=>{eR.current=null,eA.current(),window.getSelection()?.removeAllRanges(),eZ(!0)},[]),e1=(0,o.useMemo)(()=>eJ??h.SZ.map(e=>e.map(e=>z(e))),[eJ,z]),e2=(0,o.useCallback)(e=>{e$&&ez(e$.text,e)},[e$,ez]),e5=(0,o.useCallback)(e=>{eI&&ez(eI.text,e)},[eI,ez]),e4=(0,o.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]),e3=(0,o.useMemo)(()=>e4.filter(e=>"user"===e.role),[e4]),e8=(0,o.useMemo)(()=>e3.slice(-10),[e3]),e6=R||e3.length>10,e9=(0,o.useRef)(0),e7=(0,o.useRef)(!1),te=(0,o.useCallback)(()=>{let e=Q.current;return!e||e.scrollTop<50},[]),tt=(0,o.useCallback)((e=!1)=>{let t=Q.current;if(!t)return;if(e&&e8.length>0)return void ep(e8[e8.length-1].id);let n=t.getBoundingClientRect(),r=null,o=null;for(let e of e8){let s=t.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);if(!s)continue;let a=s.getBoundingClientRect().top;!o&&a<n.bottom&&(o=e.id),a<=n.top+12&&(r=e.id)}ep(r??o)},[e8]),tn=(0,o.useCallback)(()=>{let e=ea(),t=!e||S(e),n=te();if(e&&(en.current=function(e,t){return"pinned"===e.mode||"reading"===e.mode?e:50>Math.abs(t.scrollTop-j(t))?w:k}(en.current,e)),ed(!n),eh(!t),tt(t),n&&R&&!A&&P){let e=Q.current;e&&(e9.current=e.scrollHeight,e7.current=!0),P()}},[te,ea,tt,R,A,P]),tr=(0,o.useCallback)(()=>{ei({type:"release"}),J.current?.scrollIntoView({behavior:"smooth"})},[ei]),to=(0,o.useCallback)(()=>{ei({type:"toEnd"})},[ei]),ts=(0,o.useCallback)(e=>{let t=Q.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"}),ei({type:"release"}),Y.current&&clearTimeout(Y.current),Z.current?.classList.remove("flash-turn"),n.classList.remove("flash-turn"),n.offsetWidth,n.classList.add("flash-turn"),Z.current=n,Y.current=setTimeout(()=>{n.classList.remove("flash-turn"),Z.current=null,Y.current=null},2e3),!0},[ei]),ta=(0,o.useRef)(!1),tl=(0,o.useCallback)(()=>{ta.current=!0},[]);(0,o.useImperativeHandle)(W,()=>({scrollToMessage:ts,pinNextUserMessage:tl}),[ts,tl]),(0,o.useLayoutEffect)(()=>{let e;if(!ta.current)return;let t=Q.current;if(!t)return;for(let t=e4.length-1;t>=0;t-=1)if("user"===e4[t].role){e=e4[t];break}if(!e)return;let n=t.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);n&&(ta.current=!1,ei({type:"pin",top:Math.max(0,n.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop-8)}))},[e4,ei]),(0,o.useLayoutEffect)(()=>{let e=es.current;es.current=B,e&&!B&&t&&(eo.current=!0)},[B,t]),(0,o.useLayoutEffect)(()=>{e7.current||ei({type:"content"})},[e,t,ei]),(0,o.useEffect)(()=>{let e=Q.current;if(!e)return;let t=new ResizeObserver(()=>ei({type:"viewport"}));return t.observe(e),()=>t.disconnect()},[ei]),(0,o.useEffect)(()=>{let e=Q.current;if(!e)return;let t=()=>ei({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)}},[ei]);let ti=(0,o.useRef)(l);(0,o.useEffect)(()=>{let e=ti.current;ti.current=l,e&&e!==l&&(ta.current=!1,eo.current=!1,ei({type:"reset"}))},[l,ei]),(0,o.useLayoutEffect)(()=>{if(e7.current&&!A){let e=Q.current;if(e){let t=e.scrollHeight-e9.current;e.scrollTop=t,e7.current=!1}}},[e,A]);let tc=(0,o.useRef)(t),td=(0,o.useRef)(!1);return(0,o.useEffect)(()=>{let e=tc.current;tc.current=t,e&&!t&&(td.current=!ei({type:"settle"}))},[t,ei]),(0,o.useLayoutEffect)(()=>{if(B){if(eo.current){let e=Q.current,t=e?.querySelectorAll('[data-role="user"]'),n=t?.item((t?.length??0)-1);if(e&&n&&ei({type:"readFrom",top:Math.max(0,n.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop-8)})){eo.current=!1,td.current=!1;return}}ei({type:"viewport"}),td.current&&(td.current=!1,ei({type:"settle"}))}},[B,ei]),(0,o.useEffect)(()=>{if(!B)return;let e=ea();tt(!!e&&S(e))},[e,B,ea,tt]),(0,r.jsxs)("div",{ref:X,className:"relative flex-1 min-h-0 overflow-hidden flex flex-col outline-none",tabIndex:-1,onMouseUp:e_,onMouseDown:eO,children:[ey&&(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:eE,type:"text",value:ew,onChange:e=>ek(e.target.value),onKeyDown:eL,placeholder:z("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:eC.length>0?`${ej+1}/${eC.length}`:z("common.noMatch")}),(0,r.jsx)("button",{onClick:eS,disabled:0===eC.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:z("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:eN,disabled:0===eC.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:z("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:eT,className:"p-1 rounded hover:bg-hover",title:z("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:Q,onScroll:tn,className:"relative flex-1 min-h-0 overflow-y-auto px-8 py-4",children:0!==e.length||t?(0,r.jsxs)("div",{className:"mx-auto w-full max-w-[var(--chat-column)]",children:[(0,r.jsx)("div",{ref:J}),R&&(0,r.jsx)("div",{className:"flex justify-center py-3",children:A?(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:z("chat.loadMoreHistory")})]}):(0,r.jsx)("button",{onClick:P,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:z("chat.scrollUpForMore")})}),e4.map(e=>(0,r.jsx)("div",{"data-message-id":e.id,"data-role":e.role,children:(0,r.jsx)(c.s,{message:e,cwd:n,sessionId:l,onFork:F,onDeleteTurn:I,forkSupported:!0,onSendToPeer:D,peerSide:$,onApprovePlan:V,isLoading:t,onContentSearch:_,onShowFileDiff:O,onOpenFileLink:H})},e.id)),t&&(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:b}),(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:eb,className:"h-4 w-4"})}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground/80 text-shimmer",children:[ex," running ",ev," \xb7 processing"," ",(0,r.jsx)(E,{value:L?.outputTokens??0})]})]}),C&&C.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 ",C.length," background task",C.length>1?"s":""]}),C.map(e=>(0,r.jsx)("div",{className:"text-muted-foreground/80 break-words",children:e.description},e.task_id))]})]}),v&&(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 ",v.attempt,v.maxRetries>0?`/${v.maxRetries}`:"",v.delayMs>0?`, delay ${(v.delayMs/1e3).toFixed(1)}s`:"",")"]}),(v.errorStatus||v.error)&&(0,r.jsxs)("div",{className:"text-muted-foreground/80 break-words",children:[v.errorStatus?`${v.errorStatus}`:"",v.errorStatus&&v.error?" \xb7 ":"",v.error||""]})]})]})]})}),(0,r.jsx)("div",{ref:er,"aria-hidden":!0}),(0,r.jsx)("div",{ref:G})]}):(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:z("chat.startConversation")})]})})}),(e8.length>0||ec||eu)&&(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":z("chat.recentUserMessages"),children:[ec&&e.length>0&&(0,r.jsx)("button",{onClick:tr,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:z("chat.jumpToStart"),"aria-label":z("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"})})}),e6&&U&&(0,r.jsx)("button",{onClick:U,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:z("chat.moreUserMessages"),"aria-label":z("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"})})}),e8.map((e,t)=>{let n=em===e.id,o=e.content.replace(/\s+/g," ").trim()||(e.images?.length?z("chat.imageMessage"):z("chat.userMessage"));return(0,r.jsxs)("div",{className:"group relative flex h-3 items-center",children:[(0,r.jsx)("button",{onClick:t=>{ts(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":z("chat.recentUserMessageNumber",{index:t+1,total:e8.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:o})})]},e.id)}),eu&&e.length>0&&(0,r.jsx)("button",{onClick:to,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:z("chat.jumpToLatest"),"aria-label":z("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"})})})]}),ee&&(0,r.jsx)(h.fS,{floatingToolbarRef:eR,bumpRef:eA,container:ee,onAddComment:eH,onSendToAI:eV,onSearch:_?eW:void 0,onExplain:eM?eU:void 0,onQuickReply:eK,quickReplyRows:e1,onEditQuickReplies:e0,isChatLoading:eM?.isLoading}),eY&&(0,r.jsx)(y,{initialRows:e1,lang:eG,isCustomized:null!==eJ,onSave:e=>eX(e.length?e:null),onRestoreDefault:()=>eX(null),onClose:()=>eZ(!1)}),eI&&ee&&(0,r.jsx)(m.t,{x:eI.x,y:eI.y,range:{start:0,end:0},lineSnapshot:eI.text,container:ee,onSubmit:eq,onSendToAI:eM?e5:void 0,onClose:()=>eD(null),isChatLoading:eM?.isLoading}),e$&&ee&&(0,r.jsx)(m.G,{x:e$.x,y:e$.y,range:{start:0,end:0},lineSnapshot:e$.text,container:ee,onSubmit:e2,onClose:()=>eB(null),isChatLoading:eM?.isLoading})]})})},1058:(e,t,n)=>{n.d(t,{_:()=>l});var r=n(12115),o=n(90717),s=n(86957),a=n(46456);function l({cwd:e,filePath:t}){let[n,i]=(0,r.useState)([]),[c,d]=(0,r.useState)(!1),[u,h]=(0,r.useState)(null),m=(0,r.useCallback)(async()=>{if(!e||!t)return;d(!0),h(null);let n=await s.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;h(t instanceof Error?t.message:"Failed to load comments")}d(!1)},[e,t]);(0,r.useEffect)(()=>{m()},[m]),(0,r.useEffect)(()=>(0,o.zL)(()=>{m()}),[m]);let p=(0,r.useCallback)(async(n,r,l,c)=>{let d=await s.t4.runPromiseExit((0,a.BC)({cwd:e,filePath:t,startLine:n,endLine:r,content:l,...c?{selectedText:c}:{}}));if("Success"===d._tag&&d.value.comment){let e=d.value.comment;return i(t=>[...t,e]),(0,o.Cm)(),e}return"Failure"===d._tag&&console.error("Failed to add comment:",d.cause),null},[e,t]),f=(0,r.useCallback)(async(t,n)=>{let r=await s.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 s.t4.runPromiseExit((0,a.Tu)(e,t));return"Success"===n._tag?(i(e=>e.filter(e=>e.id!==t)),(0,o.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:c,error:u,addComment:p,updateComment:f,deleteComment:g,refresh:m,getCommentsForLine:x}}},2111:(e,t,n)=>{n.d(t,{D:()=>i,h:()=>c});var r=n(12115),o=n(91281),s=n(36196);o.EV(s.YA(1),1.5).pipe(o.gP(o.ji(s.YA(10))),o.y$(o.t5(10))),o.EV(s.ne(200),2).pipe(o.gP(o.ji(s.YA(5))),o.y$(o.t5(5))),o.EV(s.YA(1),2).pipe(o.et,o.gP(o.ji(s.YA(30))),o.y$(o.t5(8))),o.ji(s.YA(30)),o.ji(s.YA(1)),o.ji(s.YA(30)),s.ne(50),o.BW;let a=new Map,l=new Set;function i(e){return l.add(e),()=>{l.delete(e)}}function c({url:e,onMessage:t,enabled:n=!0}){let o=(0,r.useRef)(t);(0,r.useEffect)(()=>{o.current=t}),(0,r.useEffect)(()=>{if(!n)return;let t=e=>o.current(e),r=function(e){let t=a.get(e);if(t)return t;let n={ws:null,listeners: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,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.listeners.delete(t),0===r.listeners.size&&r.destroy()}},[e,n])}},3238:(e,t,n)=>{n.d(t,{DP:()=>a,NP:()=>i,Ql:()=>l});var r=n(95155),o=n(12115);let s=(0,o.createContext)(null);function a(){let e=(0,o.useContext)(s);if(!e)throw Error("useTheme must be used within a ThemeProvider");return e}function l(){return(0,o.useContext)(s)}function i({children:e}){let[t,n]=(0,o.useState)("system"),[a,l]=(0,o.useState)("light"),c=(0,o.useCallback)(()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[]),d=(0,o.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,o.useCallback)(e=>{n(e),localStorage.setItem("theme",e),d("system"===e?c():e),document.querySelectorAll("iframe").forEach(t=>{t.contentWindow?.postMessage({type:"THEME_CHANGE",theme:e},"*")})},[c,d]);return(0,o.useEffect)(()=>{let e=localStorage.getItem("theme")||"dark";queueMicrotask(()=>{n(e),d("system"===e?c():e)})},[c,d]),(0,o.useEffect)(()=>{if("system"!==t)return;let e=window.matchMedia("(prefers-color-scheme: dark)"),n=e=>{d(e.matches?"dark":"light")};return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[t,d]),(0,o.useEffect)(()=>{let e=e=>{if(e.data?.type==="THEME_CHANGE"){let t=e.data.theme;n(t),localStorage.setItem("theme",t),d("system"===t?c():t)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[c,d]),(0,r.jsx)(s.Provider,{value:{theme:t,resolvedTheme:a,setTheme:u},children:e})}},3292:(e,t,n)=>{n.d(t,{P:()=>c});var r=n(12115),o=n(95045),s=n(75346),a=n(49433),l=n(86957),i=n(82680);function c(){let[e,t]=(0,r.useState)([]),n=(0,r.useCallback)(()=>{let e=a.$mh({try:async()=>{let e=await fetch("/api/pinned-sessions");return await e.json()},catch:e=>new i.uV({message:"loadPinnedSessions failed",cause:e})});l.t4.runPromise(e.pipe(a.YWq({onSuccess:e=>t(e.sessions||[]),onFailure:()=>{}})))},[]);(0,r.useEffect)(()=>{n()},[n]),(0,r.useEffect)(()=>{let e=e=>{e.data?.type==="PINNED_SESSIONS_CHANGED"&&n()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[n]);let c=(0,r.useCallback)(e=>{t(e);let n=a.$mh({try:async()=>{await fetch("/api/pinned-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessions:e})})},catch:e=>new i.uV({message:"savePinnedSessions failed",cause:e})});l.t4.runFork(n.pipe(a.NWQ(()=>a.rIH))),(0,o.F)(s.n.PinnedSessionsChanged,{})},[]),d=(0,r.useCallback)(t=>e.some(e=>e.sessionId===t),[e]),u=(0,r.useCallback)((t,n,r)=>{e.some(e=>e.sessionId===t)||c([...e,{sessionId:t,cwd:n,customTitle:r}])},[e,c]),h=(0,r.useCallback)(t=>{c(e.filter(e=>e.sessionId!==t))},[e,c]),m=(0,r.useCallback)((t,n)=>{c(e.map(e=>e.sessionId===t?{...e,customTitle:n}:e))},[e,c]);return{pinnedSessions:e,isPinned:d,pinSession:u,unpinSession:h,updateTitle:m,reorder:(0,r.useCallback)(e=>{c(e)},[c]),reload:n}}},4055:(e,t,n)=>{n.d(t,{h:()=>o});let r=new Set(["Read","Grep","Glob","LS","WebSearch","WebFetch","NotebookRead","TodoRead","AskUserQuestion","ExitPlanMode","TodoWrite","Skill"]),o=e=>!r.has(e)},5135:(e,t,n)=>{n.d(t,{M:()=>E});var r=n(95155),o=n(12115),s=n(79114),a=n(14341),l=n(47650),i=n(70188),c=n(34075),d=n(89109),u=n(7320),h=n(37614),m=n(1058),p=n(48347),f=n(90717),g=n(69809),x=n(85958),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:L,embedded:M=!1,onLocalMdLink:R,scrollToAnchor:A}){let P=L||n&&(0,S.y)(n,t)||t,{t:F}=(0,s.Bd)(),I=(0,i.iN)(),D=(0,p.r)(),$=(0,k.U)(),B=(0,C.Q)(),{comments:_,addComment:O,updateComment:H,deleteComment:V,refresh:U}=(0,m._)({cwd:n,filePath:t}),[W,q]=(0,o.useState)(!1),[z,K]=(0,o.useState)(null),[G,J]=(0,o.useState)(null),[Q,Y]=(0,o.useState)(null),Z=(0,o.useMemo)(()=>e.split("\n"),[e]),X=(0,o.useMemo)(()=>(0,b.J4)(t,n),[t,n]);(0,o.useEffect)(()=>{queueMicrotask(()=>q(!0))},[]);let[ee,et]=(0,o.useState)(null),en=(0,o.useRef)(null);(0,o.useEffect)(()=>{en.current!==ee&&et(en.current)});let er=(0,o.useRef)({onLocalMdLink:R,sourceFile:P});er.current={onLocalMdLink:R,sourceFile:P};let eo=(0,o.useRef)(e=>{let{onLocalMdLink:t,sourceFile:n}=er.current;if(!t||/^[a-z][a-z0-9+.-]*:/i.test(e))return!1;let r=e.indexOf("#"),o=r>=0?e.slice(0,r):e,s=r>=0?e.slice(r+1):null;if(!o)return!1;let a=o;try{a=decodeURIComponent(o)}catch{}return!!(0,w.e$)(a)&&(t((0,w.WU)(n,a),s),!0)}).current;(0,o.useEffect)(()=>{if(!A)return;let e=setTimeout(()=>{(0,y.O)(en.current,A)},80);return()=>clearTimeout(e)},[A,e]);let{toolbarRef:es,bumpRef:ea,clearToolbar:el}=(0,N.L)({enabled:!0,container:ee,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"),o=n.getAttribute("data-source-end");return r&&o?{start:parseInt(r,10),end:parseInt(o,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")}}),ei=(0,o.useCallback)(()=>{let e=es.current;e&&(K({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),el())},[el,es]),ec=(0,o.useCallback)(()=>{let e=es.current;e&&(J({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),el())},[el,es]),ed=(0,o.useCallback)(()=>{let e=es.current;e&&D&&(el(),(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,el,es]),eu=(0,o.useCallback)(async e=>{z&&(await O(z.range.start,z.range.end,e,z.selectedText),K(null))},[z,O]),eh=(0,o.useCallback)(async(e,r)=>{if(D)try{let o=await (0,f.$3)(n),s=[];for(let e of o)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});s.push({filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot});let a=(0,f.Gw)(s,r);D.sendMessage(a),await (0,f.RP)(n),U()}catch(e){console.error("Failed to send to AI:",e)}},[D,t,n,U]),em=(0,o.useCallback)(e=>{G&&eh(G,e)},[G,eh]),ep=(0,o.useCallback)(e=>{z&&eh(z,e)},[z,eh]),ef=(0,o.useMemo)(()=>{if(0===_.length)return[];let e=new Map;for(let t of _){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}))},[_]),[eg,ex]=(0,o.useState)([]);return(0,o.useEffect)(()=>{if(0===ef.length||!en.current)return void queueMicrotask(()=>ex([]));let e=setTimeout(()=>{let e=en.current;if(!e)return;let t=[],n=e.querySelectorAll("[data-source-start]");for(let r of ef){let o=null,s=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<s&&(s=r,o=e)}}if(o){let n=e.getBoundingClientRect(),s=o.getBoundingClientRect();t.push({key:r.key,top:s.top-n.top+e.scrollTop,comments:r.comments})}}ex(t)},100);return()=>clearTimeout(e)},[ef,e]),(0,o.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(G){J(null),e.stopPropagation();return}if(z){K(null),e.stopPropagation();return}if(es.current){es.current=null,ea.current(),e.stopPropagation();return}if(Q){Y(null),e.stopPropagation();return}v?.()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[G,z,Q,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.jsxs)("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,c.oR)(F("common.copiedPath"))},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:en}),(0,r.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:en,children:[(0,r.jsx)("div",{className:"p-6",children:(0,r.jsx)(x.T,{content:e,basePath:X,rehypePlugins:T,onLinkClick:eo})}),eg.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(),Y({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))]})]}),W&&I&&(0,l.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.fS,{floatingToolbarRef:es,bumpRef:ea,container:I,onAddComment:ei,onSendToAI:ec,onExplain:D?ed:void 0,isChatLoading:D?.isLoading}),z&&(0,r.jsx)(u.t,{x:z.x,y:z.y,range:z.range,filePath:t,lineSnapshot:z.lineSnapshot,container:I,onSubmit:eu,onSendToAI:D?ep:void 0,onClose:()=>K(null),isChatLoading:D?.isLoading}),G&&(0,r.jsx)(u.G,{x:G.x,y:G.y,range:G.range,filePath:t,lineSnapshot:G.lineSnapshot,container:I,onSubmit:em,onClose:()=>J(null),isChatLoading:D?.isLoading}),Q&&(0,r.jsx)(h.t,{x:Q.x,y:Q.y,comment:Q.comment,container:I,onClose:()=>Y(null),onUpdateComment:H,onDeleteComment:V})]}),I)]})}},7320:(e,t,n)=>{n.d(t,{G:()=>l,t:()=>a});var r=n(95155),o=n(12115),s=n(79114);function a({x:e,y:t,range:n,filePath:l,lineSnapshot:i,container:c,onSubmit:d,onSendToAI:u,onClose:h,isChatLoading:m}){let{t:p}=(0,s.Bd)(),[f,g]=(0,o.useState)(""),[x,b]=(0,o.useState)(!1),v=(0,o.useRef)(null),y=(0,o.useRef)(null),[w,k]=(0,o.useState)({x:0,y:0}),C=i?.split("\n").slice(0,5).join("\n"),j=!!i&&i.split("\n").length>5;(0,o.useEffect)(()=>{if(v.current&&c){let n=c.getBoundingClientRect(),r=v.current.getBoundingClientRect(),o=e-n.left,s=t-n.top;o+r.width>n.width-16&&(o=n.width-r.width-16),o<16&&(o=16),s+r.height>n.height-16&&(s=s-r.height-8),s<16&&(s=16),queueMicrotask(()=>k({x:o,y:s}))}},[e,t,c]),(0,o.useEffect)(()=>{y.current?.focus()},[]),(0,o.useEffect)(()=>{let e=e=>{x||!v.current||v.current.contains(e.target)||h()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[h,x]);let N=()=>{!x&&f.trim()&&(b(!0),d(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||h()}}),(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&&!m&&u&&f.trim()&&(b(!0),u(f.trim()),h())},disabled:x||m||!f.trim(),title:m?p("comments.aiResponding"):void 0,children:p("comments.sendToAI")})]})]})]})]})}function l({x:e,y:t,range:n,filePath:a,lineSnapshot:i,container:c,onSubmit:d,onClose:u,isChatLoading:h}){let{t:m}=(0,s.Bd)(),[p,f]=(0,o.useState)(""),g=(0,o.useRef)(null),x=(0,o.useRef)(null),[b,v]=(0,o.useState)({x:0,y:0});(0,o.useEffect)(()=>{if(g.current&&c){let n=c.getBoundingClientRect(),r=g.current.getBoundingClientRect(),o=e-n.left,s=t-n.top;o+r.width>n.width-16&&(o=n.width-r.width-16),o<16&&(o=16),s+r.height>n.height-16&&(s=s-r.height-8),s<16&&(s=16),queueMicrotask(()=>v({x:o,y:s}))}},[e,t,c]),(0,o.useEffect)(()=>{x.current?.focus()},[]),(0,o.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:m("comments.askAI")}),(n.start>0||n.end>0)&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:m("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:m("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:h,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!h&&p.trim()&&(d(p.trim()),u())),"Escape"===e.key&&u()}}),(0,r.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:m(h?"comments.aiGenerating":"comments.enterSend")})]})]})}},9573:(e,t,n)=>{n.d(t,{Tt:()=>i,se:()=>l,xK:()=>a});var r=n(49433),o=n(82680);let s=e=>r.$mh({try:async()=>{let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status}`);return await t.json()},catch:t=>new o.uV({message:`GET ${e} failed`,cause:t})}),a=(e,t,n)=>s(`/api/snapshots?cwd=${encodeURIComponent(e)}&toolIds=${encodeURIComponent(t.join(","))}${n?`&sessionKey=${encodeURIComponent(n)}`:""}`).pipe(r.TjK(e=>e.commits??[])),l=(e,t,n)=>a(e,t,n).pipe(r.qIB(t=>r.Q7R(t.map(t=>{let n;return n=t.hash,s(`/api/snapshots/diff?cwd=${encodeURIComponent(e)}&commit=${encodeURIComponent(n)}`)}),{concurrency:4}))),i=(e,t,n)=>s(`/api/snapshots/range-diff?cwd=${encodeURIComponent(e)}&head=${encodeURIComponent(n)}${t?`&base=${encodeURIComponent(t)}`:""}`)},11890:(e,t,n)=>{function r(e){return e.trim().toLowerCase().replace(/[\s]+/g,"-").replace(/[^\w一-鿿-ヿ가--]/g,"").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"")}function o(e,t){if(!e)return!1;let n=t;try{n=decodeURIComponent(t)}catch{}let o=r(n);if(!o)return!1;for(let t of e.querySelectorAll("h1, h2, h3, h4, h5, h6"))if(r(t.textContent||"")===o)return t.scrollIntoView({behavior:"smooth",block:"start"}),!0;return!1}n.d(t,{O:()=>o})},14575:(e,t,n)=>{n.d(t,{o:()=>a});var r=n(95155);n(12115);let o={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"},s={"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=s[l=e.toLowerCase()]?s[l]:o[e.split(".").pop()?.toLowerCase()||""]||o.default,c=e.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(c)?(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(c)?(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"===c||"tsx"===c&&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"===c?(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(c)?(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(c)?(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"===c?(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"===c?(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"===c?(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(c)?(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"===c?(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"===c?(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(c)?(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(c)?(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(c)?(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"===c||".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"===c||"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"===c||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"===c?(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"===c?(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+$/,"")}
|
|
2
2
|
|
|
3
|
-
${t}`:e+t:t:e}function o(e,t,n=!1){let r=e||[];if(!t)return r;let s=r[r.length-1];return n||s?.type!=="text"?[...r,{type:"text",text:t}]:[...r.slice(0,-1),{type:"text",text:s.text+t}]}function s(e){return null!=e.parent_tool_use_id}n.d(t,{FM:()=>d,Nn:()=>s,A7:()=>l,Uy:()=>i,fD:()=>c});let a=["task_started","task_progress","task_notification"];function l(e){return"system"===e.type&&a.includes(e.subtype??"")}function i(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 d(e,t,n){let{engine:a,assistantId:c}=n;if(s(t))return e;if(l(t)){let n=t.tool_use_id;if(!n||t.ambient)return e;let r=!1,o=e.map(e=>e.toolCalls?.some(e=>e.id===n)?(r=!0,{...e,toolCalls:e.toolCalls.map(e=>e.id===n?{...e,task:i(e.task,t)}:e)}):e);return r?o: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===c?{...e,content:r(e.content||"",t,!!e.pendingTextBreak),parts:o(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 s=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&&(s=s.map(t=>t.id===c?{...t,content:r(t.content||"",e,!!t.pendingTextBreak),parts:o(t.parts,e,!!t.pendingTextBreak),pendingTextBreak:!1}:t))}for(let e of n)if(e.name){let t={id:e.id||`tool-${c}-${e.name}`,name:e.name,input:e.input||{},isLoading:!0};s=s.map(e=>e.id!==c||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 s}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);r=r.map(e=>e.id===c?{...e,toolCalls:e.toolCalls?.map(e=>e.id===t?{...e,result:n,isLoading:!1}:e)}:e)}return r}if("error"===t.type){let n=t.error||"An error occurred. Please try again.",s=`⚠️ ${n}`;return e.map(e=>e.id===c?{...e,content:r(e.content||"",s,!0),parts:o(e.parts,s,!0),isStreaming:!1}:e)}if("result"===t.type){let n="string"==typeof t.result?t.result.trim():"";return e.map(e=>e.id===c?{...e,content:!e.content&&n?n:e.content,parts:!e.content&&n?o(e.parts,n):e.parts,isStreaming:!1,toolCalls:e.toolCalls?.map(e=>({...e,isLoading:!1}))}:e)}return e}},17196:(e,t,n)=>{n.d(t,{Np:()=>d,ZD:()=>l,ZR:()=>i,b8:()=>c,kS:()=>s,sQ:()=>a});let r=null,o=["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 s(){return r||(r=Promise.all([n.e(9304),n.e(4523)]).then(n.bind(n,64523)).then(({createHighlighter:e})=>e({themes:["github-dark","github-light"],langs:[...o]}))),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 o.includes(r)?r:"text"}function l(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}let i=2e3;function c(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 d(e,t,n,r){if(!t)return[];let o=[],s=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(s,l);if(-1===e)break;let n=e+s.length;if(r){let r=e>0?a[e-1]:" ",s=n<a.length?a[n]:" ",l=!/\w/.test(r),i=!/\w/.test(s);l&&i&&o.push({lineIndex:t,startCol:e,endCol:n})}else o.push({lineIndex:t,startCol:e,endCol:n});l=e+1}}return o}},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:()=>o,aj:()=>r,pU:()=>s});let r=3,o=20;function s(e,t,n,a=[]){let l=e.length,i=n=>"unchanged"!==e[n].type||"unchanged"!==t[n].type,c=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++)c.add(e)}let d=[];for(let e=0;e<l;e++){if(c.has(e))continue;let t=e;for(;e<l&&!c.has(e);)e++;d.push({id:d.length,startIdx:t,endIdx:e-1}),e--}for(let e of d){let t=n.get(e.id)??{topRevealed:0,bottomRevealed:0},r=e.endIdx-e.startIdx+1,o=Math.max(0,Math.min(t.topRevealed,r)),s=Math.max(0,Math.min(t.bottomRevealed,r-o));for(let t=e.startIdx;t<e.startIdx+o;t++)c.add(t);for(let t=e.endIdx-s+1;t<=e.endIdx;t++)c.add(t)}let u=[];for(let e=0;e<l;e++){let n;if(c.has(e)){u.push({kind:"diff",idx:e});continue}let r=e;for(;e<l&&!c.has(e);)e++;let s=e-1;e--;let i=d.find(e=>e.startIdx<=r&&s<=e.endIdx);if(!i)continue;let h=s-r+1,m=Math.min(o,h);if(a.length>0&&s+1<l)for(let e=s+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:m}),u.push({kind:"gap-label",gapId:i.id,hiddenCount:h,enclosingFn:n}),u.push({kind:"gap-expand",gapId:i.id,direction:"down",revealCount:m})}return{rows:u,gaps:d}}},20080:(e,t,n)=>{n.d(t,{K:()=>l});var r=n(95155),o=n(12115),s=n(79114);function a({label:e,labelClassName:t,src:n,node:l,alt:i}){let{t:c}=(0,s.Bd)(),[d,u]=(0,o.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}):d?(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:c("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:o,newNode:i}){let{t:c}=(0,s.Bd)(),d=!!o||!!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}),d||u?(0,r.jsxs)("div",{className:"flex flex-wrap items-stretch gap-4",children:[d&&(0,r.jsx)(a,{label:c(u?"diffViewer.imageBefore":"diffViewer.imageDeleted"),labelClassName:"text-red-11",src:t,node:o,alt:`${e} (before)`}),u&&(0,r.jsx)(a,{label:c(d?"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:c("diffViewer.imageUnavailable")})]})}},20917:(e,t,n)=>{n.d(t,{R:()=>c,e:()=>d});var r=n(12115),o=n(19095),s=n(14594),a=n(98245),l=n(69809),i=n(2111);let c=[];function d(e,t,{sessionId:n,cwd:u,engine:h,planMode:m,noHistory:p,outputStyleId:f,ollamaModel:g,engineModel:x,claudeModel:b,claudeEffort:v,claudeFastMode:y,claudeThinking:w,codexModel:k,codexReasoningEffort:C,onSessionId:j,onFetchTitle:N,onRunComplete:S,taskStore:T}){let[E,L]=(0,r.useState)(!1),[M,R]=(0,r.useState)(null),[A,P]=(0,r.useState)(null),[F,I]=(0,r.useState)(null),[$,D]=(0,r.useState)(null),[B,O]=(0,r.useState)(null),[_,H]=(0,r.useState)(c),V=(0,r.useRef)(null),[U,W]=(0,r.useState)(null),q=(0,r.useRef)(U);q.current=U;let z=(0,r.useRef)(!1),K=(0,r.useRef)(S);K.current=S;let G=(0,r.useRef)(T);G.current=T;let J=(0,r.useRef)(!1),Q=(0,r.useRef)(null),Y=(0,r.useRef)(n);Y.current=n;let Z=(0,r.useRef)(null),X=(0,r.useRef)(null),ee=(0,r.useRef)(null),et=(0,r.useRef)(!1),en=(0,r.useRef)(!1),er=(0,r.useRef)(0),eo=(0,r.useCallback)(()=>{let e=Z.current;if(e&&e.text){let{messageId:n,text:r}=e;t(e=>(0,s.FM)(e,{type:"stream_event",event:{type:"content_block_delta",delta:{type:"text_delta",text:r}}},{engine:h,assistantId:n})),Z.current={messageId:n,text:""}}X.current=null},[t,h]),es=(0,r.useCallback)(()=>{X.current&&(clearTimeout(X.current),X.current=null),Q.current&&(clearTimeout(Q.current),Q.current=null),eo(),t(s.fD),G.current?.settleRunning(),L(!1),P(null),I(null),H(c);let e=q.current,n=ee.current;e&&t(t=>t.map(t=>t.id===e.assistantId||t.id===n?{...t,isStreaming:!1}:t)),W(null),K.current?.()},[eo,t]),ea=(0,r.useCallback)(()=>{let e=q.current;fetch("/api/chat/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Y.current,runId:e?.runKey})}).catch(()=>{}),es()},[es]),el=(0,r.useCallback)((e,n)=>{let r=e.type;if((0,s.Nn)(e))return;let i=e=>{if(z.current||"string"!=typeof e||!e)return;let t=(0,o.r)(e);P(e=>({outputTokens:(e?.outputTokens||0)+t}))};if("system"===r&&"init"===e.subtype){let n=e.session_id,r=et.current;if(j(n),Y.current=n,r||(I(e=>e??Date.now()),P(null),z.current=!1),O(null),r){let e=`auto-asst-${++er.current}`;ee.current=e,t(t=>[...t,{id:e,role:"assistant",content:"",toolCalls:[],isStreaming:!0,runKey:q.current?.runKey}])}en.current=!0;return}if("system"===r&&"background_tasks_changed"===e.subtype){let t=(e.tasks??[]).filter(e=>!e.ambient).map(e=>({task_id:e.task_id,description:e.description}));H(t.length?t:c);return}if(!(0,s.A7)(e)||(G.current?.applyEvent(e),t(t=>(0,s.FM)(t,e,{engine:h,assistantId:n})),"task_notification"===e.subtype)){if("system"===r&&"task_notification"===e.subtype){if(!en.current){let n=e.status,r=e.summary||"",o=e.task_id,s=`<task-notification>
|
|
3
|
+
${t}`:e+t:t:e}function o(e,t,n=!1){let r=e||[];if(!t)return r;let s=r[r.length-1];return n||s?.type!=="text"?[...r,{type:"text",text:t}]:[...r.slice(0,-1),{type:"text",text:s.text+t}]}function s(e){return null!=e.parent_tool_use_id}n.d(t,{FM:()=>d,Nn:()=>s,A7:()=>l,Uy:()=>i,fD:()=>c});let a=["task_started","task_progress","task_notification"];function l(e){return"system"===e.type&&a.includes(e.subtype??"")}function i(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 d(e,t,n){let{engine:a,assistantId:c}=n;if(s(t))return e;if(l(t)){let n=t.tool_use_id;if(!n||t.ambient)return e;let r=!1,o=e.map(e=>e.toolCalls?.some(e=>e.id===n)?(r=!0,{...e,toolCalls:e.toolCalls.map(e=>e.id===n?{...e,task:i(e.task,t)}:e)}):e);return r?o: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===c?{...e,content:r(e.content||"",t,!!e.pendingTextBreak),parts:o(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 s=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&&(s=s.map(t=>t.id===c?{...t,content:r(t.content||"",e,!!t.pendingTextBreak),parts:o(t.parts,e,!!t.pendingTextBreak),pendingTextBreak:!1}:t))}for(let e of n)if(e.name){let t={id:e.id||`tool-${c}-${e.name}`,name:e.name,input:e.input||{},isLoading:!0};s=s.map(e=>e.id!==c||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 s}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);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}:e)}:e)}return r}if("error"===t.type){let n=t.error||"An error occurred. Please try again.",s=`⚠️ ${n}`;return e.map(e=>e.id===c?{...e,content:r(e.content||"",s,!0),parts:o(e.parts,s,!0),isStreaming:!1}:e)}if("result"===t.type){let n="string"==typeof t.result?t.result.trim():"";return e.map(e=>e.id===c?{...e,content:!e.content&&n?n:e.content,parts:!e.content&&n?o(e.parts,n):e.parts,isStreaming:!1,toolCalls:e.toolCalls?.map(e=>({...e,isLoading:!1}))}:e)}return e}},17196:(e,t,n)=>{n.d(t,{Np:()=>d,ZD:()=>l,ZR:()=>i,b8:()=>c,kS:()=>s,sQ:()=>a});let r=null,o=["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 s(){return r||(r=Promise.all([n.e(9304),n.e(4523)]).then(n.bind(n,64523)).then(({createHighlighter:e})=>e({themes:["github-dark","github-light"],langs:[...o]}))),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 o.includes(r)?r:"text"}function l(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}let i=2e3;function c(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 d(e,t,n,r){if(!t)return[];let o=[],s=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(s,l);if(-1===e)break;let n=e+s.length;if(r){let r=e>0?a[e-1]:" ",s=n<a.length?a[n]:" ",l=!/\w/.test(r),i=!/\w/.test(s);l&&i&&o.push({lineIndex:t,startCol:e,endCol:n})}else o.push({lineIndex:t,startCol:e,endCol:n});l=e+1}}return o}},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:()=>o,aj:()=>r,pU:()=>s});let r=3,o=20;function s(e,t,n,a=[]){let l=e.length,i=n=>"unchanged"!==e[n].type||"unchanged"!==t[n].type,c=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++)c.add(e)}let d=[];for(let e=0;e<l;e++){if(c.has(e))continue;let t=e;for(;e<l&&!c.has(e);)e++;d.push({id:d.length,startIdx:t,endIdx:e-1}),e--}for(let e of d){let t=n.get(e.id)??{topRevealed:0,bottomRevealed:0},r=e.endIdx-e.startIdx+1,o=Math.max(0,Math.min(t.topRevealed,r)),s=Math.max(0,Math.min(t.bottomRevealed,r-o));for(let t=e.startIdx;t<e.startIdx+o;t++)c.add(t);for(let t=e.endIdx-s+1;t<=e.endIdx;t++)c.add(t)}let u=[];for(let e=0;e<l;e++){let n;if(c.has(e)){u.push({kind:"diff",idx:e});continue}let r=e;for(;e<l&&!c.has(e);)e++;let s=e-1;e--;let i=d.find(e=>e.startIdx<=r&&s<=e.endIdx);if(!i)continue;let h=s-r+1,m=Math.min(o,h);if(a.length>0&&s+1<l)for(let e=s+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:m}),u.push({kind:"gap-label",gapId:i.id,hiddenCount:h,enclosingFn:n}),u.push({kind:"gap-expand",gapId:i.id,direction:"down",revealCount:m})}return{rows:u,gaps:d}}},20080:(e,t,n)=>{n.d(t,{K:()=>l});var r=n(95155),o=n(12115),s=n(79114);function a({label:e,labelClassName:t,src:n,node:l,alt:i}){let{t:c}=(0,s.Bd)(),[d,u]=(0,o.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}):d?(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:c("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:o,newNode:i}){let{t:c}=(0,s.Bd)(),d=!!o||!!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}),d||u?(0,r.jsxs)("div",{className:"flex flex-wrap items-stretch gap-4",children:[d&&(0,r.jsx)(a,{label:c(u?"diffViewer.imageBefore":"diffViewer.imageDeleted"),labelClassName:"text-red-11",src:t,node:o,alt:`${e} (before)`}),u&&(0,r.jsx)(a,{label:c(d?"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:c("diffViewer.imageUnavailable")})]})}},20917:(e,t,n)=>{n.d(t,{R:()=>c,e:()=>u});var r=n(12115),o=n(19095),s=n(14594),a=n(98245),l=n(69809),i=n(2111);let c=[];function d(){try{return crypto.randomUUID()}catch{return`run-${Date.now()}-${Math.floor(1e9*Math.random())}`}}function u(e,t,{sessionId:n,cwd:h,engine:m,planMode:p,noHistory:f,outputStyleId:g,ollamaModel:x,engineModel:b,claudeModel:v,claudeEffort:y,claudeFastMode:w,claudeThinking:k,codexModel:C,codexReasoningEffort:j,onSessionId:N,onFetchTitle:S,onRunComplete:T,taskStore:E}){let[L,M]=(0,r.useState)(!1),[R,A]=(0,r.useState)(null),[P,F]=(0,r.useState)(null),[I,D]=(0,r.useState)(null),[$,B]=(0,r.useState)(null),[_,O]=(0,r.useState)(null),[H,V]=(0,r.useState)(c),[U,W]=(0,r.useState)(null),q=(0,r.useRef)(null),[z,K]=(0,r.useState)(null),G=(0,r.useRef)(z);G.current=z;let J=(0,r.useRef)(!1),Q=(0,r.useRef)(T);Q.current=T;let Y=(0,r.useRef)(E);Y.current=E;let Z=(0,r.useRef)(!1),X=(0,r.useRef)(null),ee=(0,r.useRef)(n);ee.current=n;let et=(0,r.useRef)(null),en=(0,r.useRef)(null),er=(0,r.useRef)(null),eo=(0,r.useRef)(!1),es=(0,r.useRef)(!1),ea=(0,r.useRef)(0),el=(0,r.useRef)(null),ei=(0,r.useRef)(!1),ec=(0,r.useCallback)(()=>{let e=et.current;if(e&&e.text){let{messageId:n,text:r}=e;t(e=>(0,s.FM)(e,{type:"stream_event",event:{type:"content_block_delta",delta:{type:"text_delta",text:r}}},{engine:m,assistantId:n})),et.current={messageId:n,text:""}}en.current=null},[t,m]),ed=(0,r.useCallback)(()=>{en.current&&(clearTimeout(en.current),en.current=null),X.current&&(clearTimeout(X.current),X.current=null),ec(),t(s.fD),Y.current?.settleRunning(),M(!1),F(null),D(null),V(c);let e=G.current,n=er.current;e&&t(t=>t.map(t=>t.id===e.assistantId||t.id===n?{...t,isStreaming:!1}:t)),K(null),Q.current?.()},[ec,t]),eu=(0,r.useCallback)(()=>{let e=G.current;fetch("/api/chat/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:ee.current,runId:e?.runKey})}).catch(()=>{}),ed()},[ed]),eh=(0,r.useCallback)((e,n)=>{let r=e.type;if((0,s.Nn)(e))return;let i=e=>{if(J.current||"string"!=typeof e||!e)return;let t=(0,o.r)(e);F(e=>({outputTokens:(e?.outputTokens||0)+t}))};if("system"===r&&"init"===e.subtype){let n=e.session_id,r=eo.current;if(N(n),ee.current=n,r||(D(e=>e??Date.now()),F(null),J.current=!1),O(null),r){ei.current=!1;let e=`auto-asst-${++ea.current}`;er.current=e,t(t=>[...t,{id:e,role:"assistant",content:"",toolCalls:[],isStreaming:!0,runKey:G.current?.runKey}])}es.current=!0;return}if("user"===r&&e._human){let n="string"==typeof e._turnId?e._turnId:null;if(!n||n===el.current)return;let r=e.message?.content,o=`auto-user-${n}`;t(t=>t.some(e=>e.id===o)?t:[...t,{id:o,role:"user",content:"string"==typeof r?r:"",...Array.isArray(e._images)&&e._images.length?{images:e._images}:{},runKey:G.current?.runKey}]),ei.current=!0;return}if("system"===r&&"background_tasks_changed"===e.subtype){let t=(e.tasks??[]).filter(e=>!e.ambient).map(e=>({task_id:e.task_id,description:e.description}));V(t.length?t:c);return}if(!(0,s.A7)(e)||(Y.current?.applyEvent(e),t(t=>(0,s.FM)(t,e,{engine:m,assistantId:n})),"task_notification"===e.subtype)){if("system"===r&&"task_notification"===e.subtype){if(!es.current){let n=e.status,r=e.summary||"",o=e.task_id,s=`<task-notification>
|
|
4
4
|
`+(o?`<task-id>${o}</task-id>
|
|
5
5
|
`:"")+(e.tool_use_id?`<tool-use-id>${e.tool_use_id}</tool-use-id>
|
|
6
6
|
`:"")+(n?`<status>${n}</status>
|
|
7
7
|
`:"")+(r?`<summary>${r}</summary>
|
|
8
8
|
`:"")+(e.output_file?`<output-file>${e.output_file}</output-file>
|
|
9
|
-
`:"")+"</task-notification>",a=`auto-tasknotif-${o||++
|
|
9
|
+
`:"")+"</task-notification>",a=`auto-tasknotif-${o||++ea.current}`;t(e=>[...e,{id:a,role:"system",content:r,systemEvent:{kind:"task-notification",...n?{status:n}:{},detail:s},runKey:G.current?.runKey}])}return}if("system"===r&&"notice"===e.subtype){let n=(0,a.C)(e,`auto-notice-${++ea.current}`);n&&t(e=>[...e,{...n,runKey:G.current?.runKey}]);return}if("system"===r&&"api_retry"===e.subtype)return void O({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"===r){let t=e.rate_limit_info;t&&B({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"===r){let t=e.output_tokens;if("number"==typeof t&&Number.isFinite(t)){J.current=!0;let e=Math.max(0,Math.round(t));F(t=>({outputTokens:Math.max(t?.outputTokens||0,e)}))}return}if("error"===r){let r=e.error||l.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});O(null),en.current&&(clearTimeout(en.current),en.current=null),ec(),t(e=>e.map(e=>e.id===n?{...e,content:e.content?`${e.content}
|
|
10
10
|
|
|
11
|
-
⚠️ ${r}`:`⚠️ ${r}`,isStreaming:!1}:e));return}if("stream_event"===r){O(e=>e?null:e);let t=e.event;if(t?.type==="content_block_delta"&&t.delta?.type==="text_delta"){let e=t.delta.text||"";i(e),Z.current&&Z.current.messageId===n?Z.current.text+=e:Z.current={messageId:n,text:e},X.current||(X.current=setTimeout(eo,50))}return}if("assistant"===r){let r=e.message?.content;if(Array.isArray(r))for(let e of r)e.text?i(e.text):e.name&&i(`${e.name} ${JSON.stringify(e.input??{})}`);t(t=>(0,s.FM)(t,e,{engine:h,assistantId:n}))}if("user"===r){let r=e.message?.content;if(Array.isArray(r))for(let e of r)i("string"==typeof e.content?e.content:JSON.stringify(e.content??""));t(t=>(0,s.FM)(t,e,{engine:h,assistantId:n}))}if("result"===r){en.current=!1,et.current=!0,O(null),X.current&&(clearTimeout(X.current),X.current=null),eo();let r=Y.current;r&&u&&t(e=>(2===e.length&&N(r),e));let o=e.usage,a=e.total_cost_usd;o&&R({inputTokens:o.input_tokens||0,outputTokens:o.output_tokens||0,cacheCreationInputTokens:o.cache_creation_input_tokens||0,cacheReadInputTokens:o.cache_read_input_tokens||0,totalCostUsd:a||0}),t(t=>(0,s.FM)(t,e,{engine:h,assistantId:n}))}}},[t,eo,j,N,u,h]);return(0,i.h)({url:U?`/ws/session-stream?sessionId=${encodeURIComponent(U.runKey)}`:"/ws/session-stream",enabled:!!U,onMessage:e=>{J.current=!0,Q.current&&(clearTimeout(Q.current),Q.current=null);let n=q.current;if(n)if("run-snapshot"===e.type&&Array.isArray(e.events)){X.current&&(clearTimeout(X.current),X.current=null),Z.current=null,ee.current=n.assistantId,et.current=!1,en.current=!1,z.current=!1,P(null);let r="number"==typeof e.outputTokens&&Number.isFinite(e.outputTokens)?Math.max(0,Math.round(e.outputTokens)):null;for(let o of(null!==r&&(z.current=!0,P({outputTokens:r})),t(e=>e.filter(e=>!("string"==typeof e.id&&e.id.startsWith("auto-")&&e.runKey===n.runKey)).map(e=>e.id===n.assistantId?{...e,content:"",toolCalls:[]}:e)),e.events))el(o,ee.current??n.assistantId);e.status&&"running"!==e.status&&es()}else if("run-event"===e.type&&e.message){if("run-ended"===e.message.type)return void es();el(e.message,ee.current??n.assistantId)}else"run-idle"===e.type&&es()}}),{isLoading:E,tokenUsage:M,liveOutputTokens:A,runningStartedAt:F,rateLimitInfo:$,apiRetryInfo:B,backgroundTasks:_,handleSend:(0,r.useCallback)(async(e,n,r)=>{let o=r&&"permissionMode"in r?"plan"===r.permissionMode:m,s=n?.map(e=>({type:"base64",media_type:e.media_type,data:e.data})),a={id:`user-${Date.now()}`,role:"user",content:e,images:s};t(e=>[...e,a]),L(!0),P(null),z.current=!1,I(Date.now()),O(null),H(c);let i=function(){try{return crypto.randomUUID()}catch{return`run-${Date.now()}-${Math.floor(1e9*Math.random())}`}}(),d=`assistant-${Date.now()}`,j={id:d,role:"assistant",content:"",toolCalls:[],isStreaming:!0};t(e=>[...e,j]),ee.current=d,et.current=!1,en.current=!1;let N=!h||"claude"===h,S="deepseek"===h||"kimi"===h||"glm"===h,T="ollama"===h||S||N||"codex"===h;try{let n="codex"===h?"/api/chat/codex":"kimi"===h?"/api/chat/kimi":"ollama"===h?"/api/chat/ollama":"deepseek"===h?"/api/chat/deepseek":"glm"===h?"/api/chat/glm":"/api/chat",r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,sessionId:Y.current,runId:i,images:s,cwd:u,language:l.A.language,..."ollama"===h&&g&&{model:g},...S&&x&&{model:x},...N&&b&&{model:b},...N&&v&&{claudeEffort:v},...N&&void 0!==y&&{claudeFastMode:y},...N&&void 0!==w&&{claudeThinking:w},..."codex"===h&&k&&{model:k},..."codex"===h&&C&&{codexReasoningEffort:C},...o&&N&&{permissionMode:"plan"},...T&&p&&{noHistory:!0},...f&&{outputStyleId:f}})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error||l.A.t("chat.requestFailed",{defaultValue:"Request failed"}))}let a=await r.json().catch(()=>({}));W({runKey:a.runKey||i,assistantId:d}),J.current=!1,Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>{q.current&&!J.current&&(t(e=>e.map(e=>e.id!==d||e.content?e:{...e,content:l.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."})})),es())},15e3)}catch(n){console.error("Chat error:",n);let e=n instanceof Error?n.message:l.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});t(t=>t.map(t=>t.id===d?{...t,content:e,isStreaming:!1}:t)),L(!1),W(null)}},[u,h,m,p,f,g,x,b,v,y,w,k,C,t,es]),handleStop:ea,abortControllerRef:V}}},22576:(e,t,n)=>{n.d(t,{X:()=>r});function r(e,t){let n=e.split("\n"),r=t.split("\n"),o=[],s=n.length,a=r.length,l=Array(s+1).fill(null).map(()=>Array(a+1).fill(0));for(let e=1;e<=s;e++)for(let t=1;t<=a;t++)n[e-1]===r[t-1]?l[e][t]=l[e-1][t-1]+1:l[e][t]=Math.max(l[e-1][t],l[e][t-1]);let i=s,c=a,d=[];for(;i>0||c>0;)i>0&&c>0&&n[i-1]===r[c-1]?(d.push({type:"unchanged",content:n[i-1],oldLineNum:i,newLineNum:c}),i--,c--):c>0&&(0===i||l[i][c-1]>=l[i-1][c])?(d.push({type:"added",content:r[c-1],newLineNum:c}),c--):(d.push({type:"removed",content:n[i-1],oldLineNum:i}),i--);for(;d.length>0;)o.push(d.pop());return o}},23348:(e,t,n)=>{n.d(t,{Eo:()=>a,jm:()=>o,zB:()=>s});var r=n(37640);let o=()=>(0,r.zi)("/api/bots"),s=e=>(0,r.B2)("/api/bots",{path:e}),a=e=>(0,r.zi)(`/api/bots/${encodeURIComponent(e)}`,{method:"DELETE"})},23883:(e,t,n)=>{n.d(t,{s:()=>eR});var r=n(95155),o=n(12115),s=n(34075),a=n(64428),l=n(67635),i=n(96035),c=n(54731),d=n(9921),u=n(66088),h=n(12651),m=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(86957),j=n(67589);function N({cwd:e,sessionId:t,toolCall:n,workflowRef:s,running:l,onClose:i}){let{t:c}=(0,k.Bd)(),[d,u]=(0,o.useState)(null),[h,m]=(0,o.useState)(null),[p,f]=(0,o.useState)(!1),g=(0,o.useRef)(void 0),x=s?!!s.running:l??!n?.result,b=(0,o.useCallback)(async()=>{let r=await C.t4.runPromiseExit((0,j.z)({cwd:e,sessionId:t,...s?{workflowId:s.runId,workflowAgentId:s.agentId}:{toolUseId:n?.id},ifFingerprint:g.current}));if(f(!0),"Success"!==r._tag||!r.value)return;let o=r.value;o.fingerprint&&(g.current=o.fingerprint),!o.notModified&&(o.messages&&u(o.messages),o.subagent&&m(o.subagent))},[e,t,n?.id,s?.runId,s?.agentId]);(0,o.useEffect)(()=>{if(b(),!x)return;let e=setInterval(b,5e3);return()=>clearInterval(e)},[x,b]);let v=(0,o.useRef)(null),y=(0,o.useRef)(!0);(0,o.useEffect)(()=>{let e=v.current;e&&y.current&&(e.scrollTop=e.scrollHeight)},[d]);let w="string"==typeof n?.input?.description?n.input.description:"",S=s?s.label||"":[h?.agentType,w].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:c("chat.subagent")}),S&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":S,children:S}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[x&&(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:c("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",{ref:v,onScroll:()=>{let e=v.current;e&&(y.current=e.scrollTop+e.clientHeight>=e.scrollHeight-40)},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:c(p?"chat.subagentEmpty":"common.loading")}):d.map(n=>(0,r.jsx)(eR,{message:n,cwd:e,sessionId:t},n.id))})]})})})}function S(e){return e?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):"0"}function T(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 E={done:"text-green-9",running:"text-brand",queued:"text-muted-foreground",error:"text-red-9",failed:"text-red-9"};function L({cwd:e,sessionId:t,runId:n,isRunning:s,onClose:l}){let{t:i}=(0,k.Bd)(),[c,d]=(0,o.useState)(null),[u,h]=(0,o.useState)(!1),[m,p]=(0,o.useState)(null),f=(0,o.useRef)(void 0),g=s||null!=c&&"completed"!==c.status&&"failed"!==c.status,x=(0,o.useCallback)(async()=>{let r=await C.t4.runPromiseExit((0,j.z)({cwd:e,sessionId:t,workflowId:n,ifFingerprint:f.current}));if(h(!0),"Success"!==r._tag||!r.value)return;let o=r.value;o.fingerprint&&(f.current=o.fingerprint),!o.notModified&&o.workflow&&d(o.workflow)},[e,t,n]);(0,o.useEffect)(()=>{if(x(),!g)return;let e=setInterval(x,5e3);return()=>clearInterval(e)},[g,x]);let b=[];if(c?.agents){let e=new Map;for(let t of c.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=c?[c.workflowName,c.status,`${c.agentCount??c.agents?.length??0} ${i("chat.workflowAgents")}`,`${S(c.totalTokens)} tok`,T(c.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===c?(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:[c.summary&&(0,r.jsx)("div",{className:"mb-3 text-xs text-muted-foreground whitespace-pre-wrap",children:c.summary}),b.map(e=>(0,r.jsxs)(o.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)(M,{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))]})})]})}),m&&(0,r.jsx)(N,{cwd:e,sessionId:t,workflowRef:m,onClose:()=>p(null)})]})}function M({agent:e,onOpen:t}){let{t:n}=(0,k.Bd)(),[s,a]=(0,o.useState)(!1),l=e.state&&E[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(s?"chat.collapse":"chat.expand"),children:s?"▲":"▼"}),(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:[S(e.tokens)," tok \xb7 ",T(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")})]}),s&&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 R=n(74086),A=n(60938),P=n(45619),F=n(38408),I=n(95927),$=n(47176),D=n(97251),B=n(34582),O=n(56045),_=n(50860),H=n(47215);function V({filePath:e}){let[t,n]=(0,o.useState)(null),[s,a]=(0,o.useState)(!0),[l,i]=(0,o.useState)(null),c=(0,o.useRef)(!1),d=(0,H.e$)(e),u=(0,H.u)(e);return((0,o.useEffect)(()=>{u?a(!1):c.current||(c.current=!0,(async()=>{a(!0),i(null);let t=await C.t4.runPromiseExit((0,A.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),c.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})}):s?(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,H.u)(e)?(0,r.jsx)(_.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?d?(0,r.jsx)(W,{content:t,filePath:e}):(0,r.jsx)(F.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 U=[D.W];function W({content:e,filePath:t}){let n=(0,o.useRef)(null),s=(0,o.useMemo)(()=>(0,B.J4)(t),[t]);return(0,r.jsxs)("div",{className:"h-full flex",children:[(0,r.jsx)($.l,{content:e,containerRef:n}),(0,r.jsx)("div",{ref:n,className:"flex-1 overflow-auto p-4",children:(0,r.jsx)(I.T,{content:e,basePath:s,rehypePlugins:U})})]})}function q({title:e,content:t,toolName:n,onClose:l}){let{t:i}=(0,k.Bd)(),c=(0,H.jU)(t),d=(0,H.zs)(t),u=(0,H.oK)(t),h=!!d,m=!!u,[p,f]=(0,o.useState)(("Read"===n||"Write"===n)&&m?"file":h?"diff-unified":c?"readable":"json"),g=(0,o.useRef)(null),x=(0,O.o)(g);(0,o.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&"readable"===p&&c){e.preventDefault(),x.open();return}if("Escape"===e.key){if(x.isVisible)return void x.close();document.activeElement instanceof HTMLElement&&document.activeElement.blur(),l()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[l,p,c,x]);let b=(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:l,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 px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:e}),u&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(u),(0,s.oR)(i("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:i("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",children:[c&&(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:()=>f("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===p?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.sideBySide"),children:"Split"}),(0,r.jsx)("button",{onClick:()=>f("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===p?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.unified"),children:"Unified"})]}),m&&(0,r.jsx)("button",{onClick:()=>f("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===p?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.previewFile"),children:"File"}),(0,r.jsx)("button",{onClick:()=>f("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===p?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:i("common.readable")}),(0,r.jsx)("button",{onClick:()=>f("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===p?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,r.jsx)("button",{onClick:l,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.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===p&&u?(0,r.jsx)(V,{filePath:u}):"diff-unified"===p&&d?(0,r.jsx)(P.xU,{oldContent:d.old_string,newContent:d.new_string,filePath:d.file_path}):"diff-split"===p&&d?(0,r.jsx)(P.xZ,{oldContent:d.old_string,newContent:d.new_string,filePath:d.file_path}):"readable"===p&&c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O._,{search:x}),(0,r.jsx)("pre",{ref:g,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,H.xb)(t)})]}):(0,r.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:c?(0,H.C6)(t):t})})]})});return(0,r.jsx)(a.ZL,{children:b})}var z=n(79237);let K={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 G(e){return"object"==typeof e&&null!==e}function J({toolCall:e,cwd:t,sessionId:n,disableOverlays:a=!1}){var l;let{t:i}=(0,k.Bd)(),[c,d]=(0,o.useState)(!1),[u,h]=(0,o.useState)(null),[m,p]=(0,o.useState)(!1),[f,g]=(0,o.useState)(!1),x=K[e.name]||"\uD83D\uDD27",b="Agent"===e.name||"Task"===e.name,v=b&&!!t&&!!n,y="Workflow"===e.name,w=y&&(l=e.result)?l.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,C=y&&!!w&&!!t&&!!n,j=(0,R.v2)(e.id)??e.task,S=j?.status==="running",T=!!e.isLoading||S,E=j?S||!!e.isLoading:!e.result,M=S?[j?.lastToolName,j?.toolUses?String(j.toolUses):null].filter(Boolean).join(" \xb7 "):"",A="Skill"===e.name,P="ApplyPatch"===e.name||b||y||A,F=e=>{let n=t?(0,z.y)(t,e):null;if(n)return n;let r=e.split("/");return r.length>2?".../"+r.slice(-2).join("/"):e},I=(()=>{let t=e.input;if("Bash"===e.name&&t.command&&"string"==typeof t.command)return t.command;if("ApplyPatch"===e.name&&Array.isArray(t.changes)){let e=t.changes.filter(G).flatMap(e=>{let t="string"==typeof e.path?e.path:"";if(!t)return[];let n="string"==typeof e.kind&&e.kind?e.kind:"update";return`${n} ${F(t)}`});if(e.length>0)return e.join(" \xb7 ")}if(b&&t.description&&"string"==typeof t.description)return t.description;if(y){let e=["string"==typeof t.name?t.name:"","string"==typeof t.args?t.args:"string"==typeof t.resumeFromRunId?t.resumeFromRunId:""].filter(Boolean).join(" \xb7 ");if(e)return e}if(A&&"string"==typeof t.skill){let e="string"==typeof t.args?t.args:"";return[t.skill,e].filter(Boolean).join(" \xb7 ")}return"Glob"===e.name&&t.pattern&&"string"==typeof t.pattern||"Grep"===e.name&&t.pattern&&"string"==typeof t.pattern?t.pattern:"ToolSearch"===e.name&&t.query&&"string"==typeof t.query?t.query:"TaskCreate"===e.name&&t.subject&&"string"==typeof t.subject?t.subject:t.file_path&&"string"==typeof t.file_path?t.file_path:t.path&&"string"==typeof t.path?t.path:null})(),$="Glob"===e.name||"Grep"===e.name||"Bash"===e.name||"ApplyPatch"===e.name||b||y||A,D=I?$?I:F(I):null,B=t=>{let n="input"===t?i("toolCall.inputParams"):i("toolCall.resultLabel"),r="input"===t?JSON.stringify(e.input,null,2):"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2);h({title:`${e.name}${D?` ${D}`:""} - ${n}`,content:r,toolName:e.name})};return(0,r.jsxs)("div",{className:"border-b border-line-1 last:border-b-0",children:[(0,r.jsxs)("button",{onClick:()=>d(!c),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:x}),(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":I||"",children:D}),!P&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),I&&(navigator.clipboard.writeText(I),(0,s.oR)(i("common.copiedPath")))},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),I&&(navigator.clipboard.writeText(I),(0,s.oR)(i("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0 cursor-pointer",title:i("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:[v&&!a&&(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:i("chat.subagentViewTitle"),children:i("chat.subagent")}),C&&!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:i("chat.workflowViewTitle"),children:i("chat.workflowRun")}),M&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate max-w-[16rem]",children:M}),c&&!e.isLoading&&!a&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),B("input")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),B("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:i("toolCall.inputParamsTitle"),children:i("toolCall.input")}),e.result&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),B("result")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),B("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:i("toolCall.resultTitle"),children:i("toolCall.result")})]}),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:c?"▲":"▼"})]})]}),c&&(0,r.jsxs)("div",{className:"border-t border-line-1",children:[(0,r.jsxs)("div",{className:"px-3 py-2",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[i("toolCall.inputParams"),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(e.input,null,2)})]}),e.result&&(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:[i("toolCall.resultLabel"),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2)})]}),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:[i("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})]})]}),u&&(0,r.jsx)(q,{title:u.title,content:u.content,toolName:u.toolName,onClose:()=>h(null)}),m&&t&&n&&(0,r.jsx)(N,{cwd:t,sessionId:n,toolCall:e,running:E,onClose:()=>p(!1)}),f&&t&&n&&w&&(0,r.jsx)(L,{cwd:t,sessionId:n,runId:w,isRunning:T,onClose:()=>g(!1)})]})}var Q=n(62111),Y=n(56204),Z=n(33210),X=n(58515),ee=n(36201),et=n(55804),en=n(37618),er=n(83897);function eo(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 es(e,t){return`${e}-${t}`}function ea({toolCalls:e,onClose:t}){let{t:n}=(0,k.Bd)(),i=(0,er.nH)(),[c,d]=(0,o.useState)({}),[u,h]=(0,o.useState)({}),[m,p]=(0,o.useState)({}),[f,g]=(0,o.useState)({});(0,o.useEffect)(()=>{let t={};e.forEach((e,n)=>{let{questions:r,answers:o}=eo(e);r.forEach((e,r)=>{let s=o[e.question];if(s){let o=es(n,r);t[o]=s,e.options.some(e=>e.label===s)||(h(e=>({...e,[o]:!0})),p(e=>({...e,[o]:s})))}})}),queueMicrotask(()=>d(t))},[e]),(0,Q.E)(t);let x=e.reduce((e,t)=>{let{questions:n}=eo(t);return e+n.length},0),b=Object.values(f).filter(Boolean).length,v=(0,o.useCallback)((e,t)=>{d(n=>({...n,[e]:t})),h(t=>({...t,[e]:!1}))},[]),y=(0,o.useCallback)(e=>{h(t=>{let n=!t[e];if(n){let t=m[e]||"";t&&d(n=>({...n,[e]:t}))}return{...t,[e]:n}})},[m]),w=(0,o.useCallback)((e,t)=>{p(n=>({...n,[e]:t})),t&&d(n=>({...n,[e]:t}))},[]),C=(0,o.useCallback)(e=>{g(t=>({...t,[e]:!t[e]}))},[]),j=(0,o.useCallback)(()=>{let t=b>0,r=[];return e.forEach((e,o)=>{let{questions:s}=eo(e);s.forEach((e,s)=>{let a=es(o,s);if(t&&!f[a])return;let l=c[a];r.push(`Q: ${e.question}`),r.push(`A: ${l||n("askQuestion.notSelected")}`),r.push("")})}),r.join("\n").trim()},[e,c,f,b,n]),N=(0,o.useCallback)(()=>{navigator.clipboard.writeText(j()),(0,s.oR)(b>0?n("toast.copiedQA",{count:b}):n("toast.copiedAllQA"))},[j,b,n]),S=(0,o.useCallback)(()=>{i?(i.sendMessage(j()),(0,s.oR)(n("toast.sentQA")),t()):(0,s.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)(Y.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)(Z.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,o)=>{let{questions:s}=eo(t);return s.map((t,a)=>{let l=es(o,a),i=c[l],d=u[l]||!1,h=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:h?(0,r.jsx)(X.A,{className:"w-4 h-4 text-brand"}):(0,r.jsx)(ee.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&&!d;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)(et.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 ${d?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,r.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:d?(0,r.jsx)(et.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)(en.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")})]})]}),d&&(0,r.jsx)("div",{className:"ml-6 mt-1",children:(0,r.jsx)("input",{type:"text",autoFocus:!0,value:m[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"})})]}),(o!==e.length-1||a!==s.length-1)&&(0,r.jsx)("div",{className:"border-b border-border/50 mt-3"})]},l)})})})]})});return(0,r.jsx)(a.ZL,{children:T})}var el=n(54271),ei=n(9573),ec=n(4055),ed=n(24602),eu=n(32041);function eh({filePath:e,content:t,onClose:n,zClassName:l="z-50"}){let{t:i}=(0,k.Bd)(),[c,d]=(0,o.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.jsxs)("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,s.oR)(i("common.copiedPath"))},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:()=>d(e),className:`px-2 py-0.5 text-xs rounded transition-colors ${c===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"===c?(0,r.jsx)(eu.C0,{content:t,filePath:e,className:"h-full"}):(0,r.jsx)(F.Cv,{content:t,filePath:e,showLineNumbers:!0,showSearch:!0,className:"h-full"})})]})})})}let em="http://cockpit.invalid";function ep(e,t){let n;if(!e)return null;let r=e.trim();try{if(r.startsWith("/")){if((n=new URL(r,em)).origin!==em)return null}else if(!t||(n=new URL(r)).origin!==t)return null}catch{return null}if("/project"!==n.pathname)return null;let o=n.searchParams.get("cwd"),s=n.searchParams.get("sessionId");return o&&s?{cwd:o,sessionId:s}:null}let ef=/(^|[\s([])(\/project\?[^\s)\]]+)/g;var eg=n(95045),ex=n(75346);let eb={isFramed:()=>window.parent!==window,publishOpenProject:e=>(0,eg.F)(ex.n.OpenProject,e),navigate:e=>window.location.assign(e)};function ev(e,t,n=eb){n.isFramed()?n.publishOpenProject({cwd:e.cwd,sessionId:e.sessionId,switchToAgent:!0}):n.navigate(t)}var ey=n(95686),ew=n(83448);async function ek(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 o=t.getContext("2d");o?(o.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 eC({image:e,onClose:t}){let{t:n}=(0,k.Bd)(),o=`data:${e.media_type};base64,${e.data}`,i=async t=>{t.stopPropagation();try{await ek(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),o),(0,s.oR)(n("chat.copiedImage"),"success")}catch{(0,s.oR)(n("common.copyFailed"),"error")}},c=(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:o,alt:n("chat.imagePreview"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]});return(0,r.jsx)(a.ZL,{children:c})}function ej({filePath:e,onClose:t}){let{t:n}=(0,k.Bd)(),o=`/api/file?path=${encodeURIComponent(e)}&raw=true`,i=async t=>{t.stopPropagation();try{let t,r=await fetch(o);if(!r.ok)throw Error("Could not read image");let a=await r.blob(),l=a.type?a:new Blob([a],{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 ek(l,o),(0,s.oR)(n("chat.copiedImage"),"success")}catch{(0,s.oR)(n("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: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:o,alt:e.split("/").pop(),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]})})}function eN(e){let t=e.replace(/\/+$/,"");return t.startsWith("/private/")?t.slice(8):t}let eS=(0,o.memo)(function({text:e,isAside:t,isUser:n,isStreaming:a,onOpenFileLink:l,onPreviewFile:d,cwd:u}){let{t:h}=(0,k.Bd)(),m=(0,o.useMemo)(()=>{if(n||!l)return;let e=e=>{d&&((0,H.e$)(e)||(0,H.u)(e)||(0,H.Zy)(e))?d(e):(0,s.oR)(h("toast.fileOutsideProject"),"error")};return t=>{let n=function(e,t){let n;if(!e||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 o=r.indexOf("#"),s=o>=0?r.slice(o+1):"",a=o>=0?r.slice(0,o):r,l=a.indexOf("?"),i=l>=0?a.slice(l+1):"";a=l>=0?a.slice(0,l):a;let c=s.match(/^L?(\d+)(?:-L?\d+)?$/i)?.[1],d=i.match(/(?:^|[&;])(?:line|L)=(\d+)(?:$|[&;])/i)?.[1],u=a.match(/:(\d+)(?::\d+)?$/),h=c||d||u?.[1];if(h&&(n=Number(h),u&&(a=a.slice(0,-u[0].length))),!(a=a.trim()))return null;let m=n&&n>0?{lineNumber:n}:{},p=t?eN(t):"";if(a.startsWith("/")){let e=eN(a),t=p?(0,z.y)(p,e):null;return""===t?null:t?{rel:(0,H.WU)("",t),abs:null,...m}:{rel:(0,H.WU)("",e),abs:e,...m}}return a.startsWith("./")||a.startsWith("../")||a.includes("/")||/\.[A-Za-z0-9][A-Za-z0-9_-]*$/.test(a)?{rel:(0,H.WU)("",a),abs:null,...m}:null}(t,u);return!!n&&(n.abs?u?C.t4.runPromise((0,A.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,d,h]),p=(0,o.useMemo)(()=>{if(!n)return e=>{let t=ep(e,window.location.origin);return t?(ev(t,e),!0):!!m&&m(e)}},[n,m]),f=(0,o.useMemo)(()=>{if(!n)return null;let t=function(e){let t=[],n=0;for(let r of e.matchAll(ef)){let o=r[2],s=ep(o);if(!s)continue;let a=r.index+r[1].length;a>n&&t.push({kind:"text",text:e.slice(n,a)}),t.push({kind:"link",text:o,target:s}),n=a+o.length}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}(e);return t.some(e=>"link"===e.kind)?t:null},[n,e]),g=(0,r.jsxs)(r.Fragment,{children:[f?(0,r.jsx)("div",{className:"reading-measure whitespace-pre-wrap break-words",children:f.map((e,t)=>"link"===e.kind?(0,r.jsxs)("a",{href:e.text,title:`${e.target.cwd}
|
|
12
|
-
${e.target.sessionId}`,className:"inline-flex items-center gap-1 px-1.5 rounded bg-brand/10 hover:bg-brand/20 text-brand font-mono text-[0.9em] align-baseline whitespace-nowrap no-underline",onClick:t=>{t.preventDefault(),ev(e.target,e.text)},children:[(0,r.jsx)(i.A,{className:"w-3 h-3 shrink-0","aria-hidden":!0}),e.target.sessionId.slice(0,8)]},t):e.text)}):(0,r.jsx)(I.T,{content:e,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)(c.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:g})]}):(0,r.jsx)("div",{className:"break-words",children:g})}),eT="28em",eE=(0,o.memo)(function({children:e}){let{t}=(0,k.Bd)(),[n,s]=(0,o.useState)(!1),[a,l]=(0,o.useState)(!1),i=(0,o.useRef)(null),c=(0,o.useRef)(null),h=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(n)return;let e=c.current,t=h.current;if(!e||!t)return;let r=()=>l(e.scrollHeight>e.clientHeight+1);r();let o=new ResizeObserver(r);return o.observe(t),()=>o.disconnect()},[n]);let m=(0,o.useCallback)(()=>{if(!n)return void s(!0);let e=i.current?.closest("[data-message-id]")??i.current;s(!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:c,className:n?void 0:"overflow-hidden",style:n?void 0:{maxHeight:eT},children:(0,r.jsx)("div",{ref:h,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:m,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)(d.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(u.A,{className:"w-3.5 h-3.5"})]})]})]})});function eL({collapsible:e,children:t}){return e?(0,r.jsx)(eE,{children:t}):(0,r.jsx)(r.Fragment,{children:t})}let eM=new Map,eR=(0,o.memo)(function({message:e,cwd:t,sessionId:n,onFork:l,onDeleteTurn:i,forkSupported:c=!0,onSendToPeer:d,peerSide:j,onApprovePlan:N,isLoading:S,onContentSearch:T,onShowFileDiff:E,onOpenFileLink:L,disableOverlays:M=!1}){let R,A,P,F,{t:$,i18n:D}=(0,k.Bd)(),[B,O]=(0,o.useState)(null),[_,V]=(0,o.useState)(()=>1===(e.toolCalls?.length||0)),[U,W]=(0,o.useState)(!1),[q,z]=(0,o.useState)(!1),[K,G]=(0,o.useState)(!1),[Q,Y]=(0,o.useState)(!1),[Z,X]=(0,o.useState)(!1),ee=(0,o.useRef)(null),et=(0,o.useRef)(null),en="user"===e.role,er=e.images&&e.images.length>0,eo=e.toolCalls?.length||0,es=!!n&&!!t&&!!l&&c,eu=!!n&&!!t&&!!i;(0,o.useEffect)(()=>{if(!Q)return;let e=e=>{ee.current?.contains(e.target)||Y(!1)},t=e=>{"Escape"===e.key&&(Y(!1),et.current?.focus())};return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[Q]);let em=(0,o.useMemo)(()=>e.toolCalls?.some(e=>(0,ec.h)(e.name))||!1,[e.toolCalls]),ep=(0,o.useMemo)(()=>{let t=e.parts;if(!t?.length)return e.content?[{text:e.content,isAside:!1}]:[];let n=-1;t.forEach((e,t)=>{"tool"===e.type&&(n=t)});let r=[];return t.forEach((e,t)=>{"text"===e.type&&r.push({text:e.text,isAside:t<n})}),r},[e.parts,e.content]),ef=(0,o.useMemo)(()=>(0,el.vP)([],e.toolCalls??[],t).length>0,[e.toolCalls,t]),[eg,ex]=(0,o.useState)(!1),eb=ef||eg;(0,o.useEffect)(()=>{E&&e.toolCalls?.length&&E(e.id,e.toolCalls,t,n??void 0,!0)},[E,e.id,e.toolCalls,t,n]),(0,o.useEffect)(()=>{if(!em||ef||!t)return;let r=(e.toolCalls??[]).map(e=>e.id).filter(Boolean);if(0===r.length)return;let o=(e.toolCalls??[]).filter(e=>(0,ec.h)(e.name)).map(e=>e.id),s=!1,a=null,l=0,i=()=>{C.t4.runPromiseExit((0,ei.xK)(t,r,n??void 0)).then(e=>{if(s)return;let t="Success"===e._tag?e.value:[];if(t.length>0)return void ex(!0);let n=new Set(t.map(e=>e.toolId));o.some(e=>!n.has(e))&&l<2&&(l+=1,a=setTimeout(i,2e3))})};return i(),()=>{s=!0,a&&clearTimeout(a)}},[em,ef,t,n,e.toolCalls]);let ev=(0,o.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]),ek=(0,o.useMemo)(()=>e.toolCalls?e.toolCalls.filter(e=>"AskUserQuestion"===e.name):[],[e.toolCalls]),eN=(0,o.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]),eT=(0,o.useMemo)(()=>e.toolCalls?.filter(e=>"ExitPlanMode"!==e.name)??[],[e.toolCalls]),eE=(0,o.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&&((0,H.e$)(e)||(0,H.aR)(e)||(0,H.u)(e)||(0,H.Zy)(e))&&!t.has(e)&&(t.add(e),n.push(e))}return n},[e.toolCalls]),eR=(0,o.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]),[eA,eP]=(0,o.useState)(null),[eF,eI]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!eA||(0,H.u)(eA))return void queueMicrotask(()=>eI(null));let e=!1;return C.t4.runPromiseExit((0,ew.an)(eA)).then(t=>{e||("Success"===t._tag&&void 0!==t.value.content?eI(t.value.content):((0,s.oR)($("toast.readFileFailed"),"error"),eP(null)))}),()=>{e=!0}},[eA,$]);let e$=async()=>{if(eu&&!S&&!Z&&await (0,s.lJ)($("chat.deleteTurnConfirm",{defaultValue:"Delete this question, answer, and its tool records? This cannot be undone."}),{title:$("chat.deleteTurn",{defaultValue:"Delete turn"}),confirmText:$("chat.deleteTurnConfirmAction",{defaultValue:"Delete turn"}),danger:!0})){X(!0);try{await i(e.id)}finally{X(!1)}}},eD=!!j&&!!d&&!!e.content,eB=(0,o.useMemo)(()=>{var t;let n;if(!e.timestamp)return"";let r=new Date(e.timestamp);return isNaN(r.getTime())?"":(t=D.language,!(n=eM.get(t))&&(n=new Intl.DateTimeFormat(t,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),eM.set(t,n)),n).format(r)},[e.timestamp,D.language]);if("system"===e.role){let t=e.systemEvent,n=t?.kind==="task-notification"?"failed"===t.status?"⚠️":"stopped"===t.status?"⏹️":"\uD83D\uDD14":"ℹ️",o=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:()=>G(!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:$("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})]})}),K&&(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:()=>G(!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"?$("chat.taskNotification",{defaultValue:"Task notification"}):$("chat.systemNotice",{defaultValue:"Notice"})]}),(0,r.jsx)("button",{onClick:()=>G(!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:o})]})})})]})}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:`flex flex-col ${en?"items-end":"items-start"} mb-4 group`,"data-role":e.role,children:[(0,r.jsx)("div",{className:`relative flex items-start ${en?"justify-end":"justify-start"} w-full`,children:(0,r.jsxs)("div",{className:`chat-turn px-4 py-2 text-foreground ${en?"max-w-[80%] bg-muted rounded-2xl rounded-br-md border border-brand/40":"w-full"}`,children:[er&&(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 ${M?"":"cursor-pointer hover:opacity-90 transition-opacity"}`,onClick:M?void 0:()=>O(e),children:(0,r.jsx)("img",{src:`data:${e.media_type};base64,${e.data}`,alt:$("chat.imageN",{index:t+1}),className:"w-full h-full object-cover"})},t))}),ep.length>0&&(0,r.jsx)(eL,{collapsible:en,children:(0,r.jsx)("div",{className:"space-y-3",children:ep.map((n,o)=>(0,r.jsx)(eS,{text:n.text,isAside:n.isAside,isUser:en,isStreaming:!!e.isStreaming&&o===ep.length-1,onOpenFileLink:L,onPreviewFile:eP,cwd:t},o))})}),ev&&(P=(A=Array.isArray(R=ev.input?.todos)?R:[]).filter(e=>"completed"===e.status).length,F=A.length,(0,r.jsx)("div",{className:`${e.content||er?"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:`${F>0?P/F*100:0}%`}})}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[P,"/",F]})]}),A.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)(h.A,{className:"w-3 h-3 text-green-11 flex-shrink-0"}):"in_progress"===e.status?(0,r.jsx)(m.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))]})})),eN&&(0,r.jsx)("div",{className:`${e.content||er||ev?"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:$("chat.planTitle",{defaultValue:"Plan (awaiting your review)"})})]}),(0,r.jsx)("div",{className:"px-3 py-2",children:(0,r.jsx)(I.T,{content:eN,isUser:!1})}),N&&(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:$("chat.planApproveHint",{defaultValue:"本环境无审批弹窗,点此退出 Plan 并执行"})}),(0,r.jsxs)("button",{onClick:()=>N(),disabled:S,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:$("chat.approvePlan",{defaultValue:"批准并执行"})})]})]})]})}),eE.length>0&&(0,r.jsx)("div",{className:`${e.content||er||ev?"mt-2":""}`,children:(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden px-3 py-2 space-y-0.5",children:eE.map(e=>(0,r.jsxs)("button",{disabled:M,onClick:()=>eP(e),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,H.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,H.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,H.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))})}),eR.length>0&&(0,r.jsx)("div",{className:`${e.content||er||ev||eE.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:eR.map((e,t)=>(0,r.jsxs)("tr",{className:t<eR.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))})]})})}),eT.length>0&&(0,r.jsx)("div",{className:`${e.content||er?"mt-3":""}`,children:eo>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:()=>V(!_),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:$("chat.toolCalls",{count:eT.length})}),(0,r.jsx)("span",{className:"ml-auto text-muted-foreground text-sm",children:_?$("chat.collapse"):$("chat.expand")})]}),!M&&ek.length>0&&(0,r.jsx)("button",{onClick:()=>z(!0),className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover transition-colors border-l border-line-1",title:$("chat.viewQuestions"),children:(0,r.jsx)(f.A,{className:"w-4 h-4"})}),!M&&eb&&(0,r.jsx)("button",{onClick:()=>{E&&e.toolCalls?E(e.id,e.toolCalls,t,n??void 0):W(!0)},className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover transition-colors border-l border-line-1",title:$("chat.viewAllFileChanges"),children:(0,r.jsx)(g.A,{className:"w-4 h-4"})})]}),_&&(0,r.jsx)("div",{className:"border-t border-line-1",children:eT.map((e,o)=>(0,r.jsx)(J,{toolCall:e,cwd:t,sessionId:n,disableOverlays:M},`${e.id}-${o}`))})]}):eT.map((e,o)=>(0,r.jsx)(J,{toolCall:e,cwd:t,sessionId:n,disableOverlays:M},`${e.id}-${o}`))})]})}),(eB||e.content||es||eu)&&(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 ${en?"flex-row-reverse":""}`,children:[e.content&&(0,r.jsx)("button",{onClick:()=>{e.content&&(navigator.clipboard.writeText(e.content),(0,s.oR)($("toast.copiedMessage")))},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:$("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"})})}),es&&(0,r.jsxs)("div",{ref:ee,className:"relative",children:[(0,r.jsxs)("button",{ref:et,type:"button",onClick:()=>Y(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":Q,title:$("chat.newSession"),children:[(0,r.jsx)(x.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:$("chat.newSession")}),(0,r.jsx)(u.A,{className:`h-3 w-3 transition-transform ${Q?"rotate-180":""}`})]}),Q&&(0,r.jsxs)("div",{role:"group","aria-label":$("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 ${en?"right-0":"left-0"}`,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{es&&(Y(!1),l(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:$("chat.continueFromHere")}),(0,r.jsx)("span",{className:"mt-0.5 block text-[11px] leading-4 text-muted-foreground",children:$("chat.continueFromHereDesc")})]})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{es&&(Y(!1),l(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:$("chat.onlyThisTurn")}),(0,r.jsx)("span",{className:"mt-0.5 block text-[11px] leading-4 text-muted-foreground",children:$("chat.onlyThisTurnDesc")})]})]})]})]}),eu&&(0,r.jsxs)("button",{type:"button",onClick:e$,disabled:S||Z,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:S?$("chat.deleteTurnWhileRunning"):$("chat.deleteTurn"),children:[(0,r.jsx)(v.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:Z?$("chat.deletingTurn"):$("chat.deleteTurn")})]}),eD&&(0,r.jsx)("button",{onClick:()=>{eD&&d(e.content)},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:$("chat.sendToPeerPane"),children:"right"===j?(0,r.jsx)(y.A,{className:"w-4 h-4"}):(0,r.jsx)(w.A,{className:"w-4 h-4"})}),eB&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground mx-1",children:eB})]})]}),B&&(0,r.jsx)(eC,{image:B,onClose:()=>O(null)}),U&&e.toolCalls&&(0,r.jsx)(el.zB,{toolCalls:e.toolCalls,cwd:t,sessionId:n??void 0,onClose:()=>W(!1),onContentSearch:T}),q&&ek.length>0&&(0,r.jsx)(ea,{toolCalls:ek,onClose:()=>z(!1)}),eA&&(0,H.u)(eA)&&(0,r.jsx)(ej,{filePath:eA,onClose:()=>eP(null)}),eA&&!(0,H.u)(eA)&&null!==eF&&((0,H.aR)(eA)?(0,r.jsx)(ed.N,{filePath:eA,content:eF,cwd:t,onClose:()=>eP(null),onContentSearch:T}):(0,H.Zy)(eA)?(0,r.jsx)(eh,{filePath:eA,content:eF,onClose:()=>eP(null)}):(0,r.jsx)(ey.x,{filePath:eA,content:eF,cwd:t||"",onClose:()=>eP(null)}))]})})},24602:(e,t,n)=>{n.d(t,{N:()=>S});var r=n(95155),o=n(12115),s=n(79114),a=n(64428),l=n(34075),i=n(14341),c=n(42804),d=n(22164),u=n(34582),h=n(85269),m=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,o.useMemo)(()=>{let t,n;return(n=(t=e.replace(/\\/g,"/")).lastIndexOf("/"))<=0?"/":t.slice(0,n)},[e]),s=e=>(0,y.y)(n,e)||C(e),a=(0,o.useRef)(new Map),[l,i]=(0,o.useState)([]),[c,d]=(0,o.useState)(e),[u,h]=(0,o.useState)(!0);(0,o.useEffect)(()=>{a.current=new Map([[e,t]]);let r={abs:e,rel:C(e),kind:"text"};i([r]),d(e),h(!0);let o=!1;return(async()=>{let l=new Set([e]),c=[r],d=[t];for(;d.length&&c.length<40&&!o;)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]}(d.shift())){if(c.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 o="/"+r.join("/");return o===n||o.startsWith(n+"/")?o: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&&!o&&(c.push({abs:t,rel:s(t),kind:r}),i([...c]))}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),d.push(e.data.content),o||(c.push({abs:t,rel:s(t),kind:r}),i([...c])))}}o||h(!1)})(),()=>{o=!0}},[e,t,n]);let m=l.find(e=>e.abs===c),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:()=>d(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 ${c===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:m?.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(c)}&raw=true`,alt:C(c),className:"max-w-full max-h-full object-contain"})}):(0,r.jsx)(x.Cv,{content:a.current.get(c)??"",filePath:c,cwd:n},c)})]})}function S({filePath:e,content:t,cwd:n,onClose:p,onContentSearch:f}){let{t:g}=(0,s.Bd)(),x=(0,m.P)(),[b,v]=(0,o.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.jsxs)("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:["",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)(c.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)(d.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)(h.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:()=>o});var r=n(12115);function o({enabled:e,container:t,resolveLineRange:n,buildLineSnapshot:s,dragThresholdPx:a=5}){let l=(0,r.useRef)(null),i=(0,r.useRef)(()=>{}),c=(0,r.useRef)(n),d=(0,r.useRef)(s),u=(0,r.useRef)(a);return c.current=n,d.current=s,u.current=a,(0,r.useEffect)(()=>{if(!e||!t)return;let n=!1,r=0,o=0,s=()=>{l.current&&(l.current=null,i.current())},a=e=>{n=!0,r=e.clientX,o=e.clientY;let t=e.target;t?.closest?.(".floating-toolbar")||s()},h=e=>{n=!1;let a=e.target;if(a?.closest?.(".floating-toolbar"))return;let h=u.current,m=Math.abs(e.clientX-r)>h||Math.abs(e.clientY-o)>h,p=window.getSelection();if(!p||p.isCollapsed||!p.toString().trim()||!m)return void s();let f=p.getRangeAt(0);if(!t.contains(f.commonAncestorContainer))return void s();let g=c.current(f.startContainer),x=c.current(f.endContainer);if(!g||!x)return void s();let b=Math.min(g.start,x.start),v=Math.max(g.end,x.end),y=p.toString(),w=d.current({start:b,end:v});l.current={x:e.clientX,y:e.clientY,range:{start:b,end:v},selectedText:y,lineSnapshot:w},i.current()},m=()=>{if(n||!l.current)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||s()};return t.addEventListener("mousedown",a),document.addEventListener("mouseup",h),document.addEventListener("selectionchange",m),()=>{t.removeEventListener("mousedown",a),document.removeEventListener("mouseup",h),document.removeEventListener("selectionchange",m)}},[e,t]),{toolbarRef:l,bumpRef:i,clearToolbar:()=>{l.current&&(l.current=null,i.current())}}}},30133:(e,t,n)=>{n.d(t,{y:()=>s});var r=n(95155),o=n(79114);function s({value:e,onChange:t,className:n}){let{t:a}=(0,o.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))})}},32041:(e,t,n)=>{n.d(t,{C0:()=>h});var r=n(95155),o=n(12115),s=n(61878),a=n(33210),l=n(9921),i=n(66088),c=n(79114);let d=/^-?[\d,]*\.?\d+%?$/;function u(e){return d.test(e)?parseFloat(e.replace(/,/g,"")):NaN}function h({content:e,filePath:t,className:n="",action:m}){let{t:p}=(0,c.Bd)(),[f,g]=(0,o.useState)(500),[x,b]=(0,o.useState)(""),[v,y]=(0,o.useState)(-1),[w,k]=(0,o.useState)(null),{header:C,body:j,columnCount:N}=(0,o.useMemo)(()=>{let n=(function(e,t){let n=[],r=[],o="",s=!1,a=!1,l=()=>{r.push(o),n.push(r),r=[],o="",a=!1};for(let n=0;n<e.length;n++){let i=e[n];if(s){if('"'!==i){o+=i;continue}'"'===e[n+1]?(o+='"',n++):s=!1;continue}if('"'===i&&""===o){s=!0,a=!0;continue}if(i===t){r.push(o),o="",a=!0;continue}if("\r"===i){"\n"===e[n+1]&&n++,l();continue}if("\n"===i){l();continue}o+=i,a=!0}return(a||""!==o||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},o=!1,s=0;for(let e=0;e<n.length&&s<5;e++){let t=n[e];if('"'===t){o=!o;continue}if(!o){if("\n"===t){s++;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),o=n.slice(1).map((e,t)=>({index:t,cells:e}));return{header:n[0]??[],body:o,columnCount:r}},[e,t]);(0,o.useEffect)(()=>{g(500),b(""),y(-1),k(null)},[e,t]);let S=(0,o.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,o.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),o=u(t);return isNaN(r)||isNaN(o)?e.localeCompare(t,void 0,{numeric:!0})*n:(r-o)*n})(t.cells[w.col]??"",n.cells[w.col]??"",e))},[S,w]);(0,o.useEffect)(()=>{g(500)},[x,v]);let E=(0,o.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 L=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)(s.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))]}),m&&(0,r.jsx)("button",{onClick:m.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:m.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:L.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 o=e.cells[n]??"";return(0,r.jsx)("td",{title:o.length>60?o:void 0,className:`border-b border-border px-2 py-1 max-w-[28rem] truncate text-foreground ${d.test(o)?"text-right tabular-nums":""}`,children:o},n)})]},e.index))})]}),0===L.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})}),L.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:L.length,total:T.length})})]})]})}},33442:(e,t,n)=>{n.d(t,{_:()=>o,a:()=>s});let r=(0,n(93964).N)("cockpit-bots"),o=r.notify,s=r.subscribe},34075:(e,t,n)=>{n.d(t,{dj:()=>l,lJ:()=>u,oR:()=>m,tE:()=>i});var r=n(95155),o=n(12115),s=n(69809);let a=(0,o.createContext)(null);function l(){let e=(0,o.useContext)(a);if(!e)throw Error("useToast must be used within a ToastProvider");return e}function i({children:e}){let[t,n]=(0,o.useState)([]),s=(0,o.useCallback)((e,t="success")=>{let r=`toast-${Date.now()}`;n(n=>[...n,{id:r,message:e,type:t}])},[]),l=(0,o.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return(0,r.jsxs)(a.Provider,{value:{showToast:s},children:[e,(0,r.jsx)(c,{toasts:t,onRemove:l})]})}function c({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)(d,{toast:e,onRemove:t},e.id))})}function d({toast:e,onRemove:t}){(0,o.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],s={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:[s,(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=s.A.t("confirm.title",{defaultValue:"Confirm"}),confirmText:r=s.A.t("confirm.ok",{defaultValue:"OK"}),cancelText:o=s.A.t("confirm.cancel",{defaultValue:"Cancel"}),danger:a=!1}=t||{};return new Promise(t=>{let s=document.createElement("div");s.className="fixed inset-0 z-[200] flex items-center justify-center",s.style.animation="confirmFadeIn 0.15s ease-out";let l=e=>{s.style.animation="confirmFadeOut 0.12s ease-in",s.addEventListener("animationend",()=>{document.body.removeChild(s),t(e)},{once:!0})};s.addEventListener("mousedown",e=>{e.target===s&&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),s.innerHTML=`
|
|
11
|
+
⚠️ ${r}`:`⚠️ ${r}`,isStreaming:!1}:e));return}if("stream_event"===r){O(e=>e?null:e);let r=e.event;if(ei.current&&r?.type==="message_start"){ei.current=!1,en.current&&(clearTimeout(en.current),en.current=null),ec();let e=n,r=`auto-asst-${++ea.current}`;er.current=r,n=r,t(t=>[...t.map(t=>t.id===e?{...t,isStreaming:!1}:t),{id:r,role:"assistant",content:"",toolCalls:[],isStreaming:!0,runKey:G.current?.runKey}])}if(r?.type==="content_block_delta"&&r.delta?.type==="text_delta"){let e=r.delta.text||"";i(e),et.current&&et.current.messageId===n?et.current.text+=e:et.current={messageId:n,text:e},en.current||(en.current=setTimeout(ec,50))}return}if("assistant"===r){let r=e.message?.content;if(Array.isArray(r))for(let e of r)e.text?i(e.text):e.name&&i(`${e.name} ${JSON.stringify(e.input??{})}`);t(t=>(0,s.FM)(t,e,{engine:m,assistantId:n}))}if("user"===r){let r=e.message?.content;if(Array.isArray(r))for(let e of r)i("string"==typeof e.content?e.content:JSON.stringify(e.content??""));t(t=>(0,s.FM)(t,e,{engine:m,assistantId:n}))}if("prompt_suggestion"===r){let t="string"==typeof e.suggestion?e.suggestion.trim():"",n=ee.current;W(t&&n?{sessionId:n,text:t}:null)}if("result"===r){es.current=!1,eo.current=!0,O(null),en.current&&(clearTimeout(en.current),en.current=null),ec();let r=ee.current;r&&h&&t(e=>(2===e.length&&S(r),e));let o=e.usage,a=e.total_cost_usd;o&&A({inputTokens:o.input_tokens||0,outputTokens:o.output_tokens||0,cacheCreationInputTokens:o.cache_creation_input_tokens||0,cacheReadInputTokens:o.cache_read_input_tokens||0,totalCostUsd:a||0}),t(t=>(0,s.FM)(t,e,{engine:m,assistantId:n}))}}},[t,ec,N,S,h,m]);(0,i.h)({url:z?`/ws/session-stream?sessionId=${encodeURIComponent(z.runKey)}`:"/ws/session-stream",enabled:!!z,onMessage:e=>{Z.current=!0,X.current&&(clearTimeout(X.current),X.current=null);let n=G.current;if(n)if("run-snapshot"===e.type&&Array.isArray(e.events)){en.current&&(clearTimeout(en.current),en.current=null),et.current=null,er.current=n.assistantId,eo.current=!1,es.current=!1,ei.current=!1,J.current=!1,F(null);let r="number"==typeof e.outputTokens&&Number.isFinite(e.outputTokens)?Math.max(0,Math.round(e.outputTokens)):null;for(let o of(null!==r&&(J.current=!0,F({outputTokens:r})),t(e=>e.filter(e=>!("string"==typeof e.id&&e.id.startsWith("auto-")&&e.runKey===n.runKey)).map(e=>e.id===n.assistantId?{...e,content:"",toolCalls:[]}:e)),e.events))eh(o,er.current??n.assistantId);e.status&&"running"!==e.status&&ed()}else if("run-event"===e.type&&e.message){if("run-ended"===e.message.type)return void ed();eh(e.message,er.current??n.assistantId)}else"run-idle"===e.type&&ed()}});let em=(0,r.useCallback)(async(e,n,r)=>{let o=r&&"permissionMode"in r?"plan"===r.permissionMode:p,s=n?.map(e=>({type:"base64",media_type:e.media_type,data:e.data})),a={id:`user-${Date.now()}`,role:"user",content:e,images:s};t(e=>[...e,a]),W(null),M(!0),F(null),J.current=!1,D(Date.now()),O(null),V(c);let i=d();el.current=i;let u=`assistant-${Date.now()}`,N={id:u,role:"assistant",content:"",toolCalls:[],isStreaming:!0};t(e=>[...e,N]),er.current=u,eo.current=!1,es.current=!1,ei.current=!1;let S=!m||"claude"===m,T="deepseek"===m||"kimi"===m||"glm"===m,E="ollama"===m||T||S||"codex"===m;try{let n="codex"===m?"/api/chat/codex":"kimi"===m?"/api/chat/kimi":"ollama"===m?"/api/chat/ollama":"deepseek"===m?"/api/chat/deepseek":"glm"===m?"/api/chat/glm":"/api/chat",r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,sessionId:ee.current,runId:i,images:s,cwd:h,language:l.A.language,..."ollama"===m&&x&&{model:x},...T&&b&&{model:b},...S&&v&&{model:v},...S&&y&&{claudeEffort:y},...S&&void 0!==w&&{claudeFastMode:w},...S&&void 0!==k&&{claudeThinking:k},..."codex"===m&&C&&{model:C},..."codex"===m&&j&&{codexReasoningEffort:j},...o&&S&&{permissionMode:"plan"},...E&&f&&{noHistory:!0},...g&&{outputStyleId:g}})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error||l.A.t("chat.requestFailed",{defaultValue:"Request failed"}))}let a=await r.json().catch(()=>({}));K({runKey:a.runKey||i,assistantId:u}),Z.current=!1,X.current&&clearTimeout(X.current),X.current=setTimeout(()=>{G.current&&!Z.current&&(t(e=>e.map(e=>e.id!==u||e.content?e:{...e,content:l.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."})})),ed())},15e3)}catch(n){console.error("Chat error:",n);let e=n instanceof Error?n.message:l.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});t(t=>t.map(t=>t.id===u?{...t,content:e,isStreaming:!1}:t)),M(!1),K(null)}},[h,m,p,f,g,x,b,v,y,w,k,C,j,t,ed]),ep=(0,r.useCallback)(async(e,t,n)=>{W(null);let r=await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,sessionId:n,runId:d(),images:t?.map(e=>({type:"base64",media_type:e.media_type,data:e.data})),cwd:h,language:l.A.language,inject:!0})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error||l.A.t("chat.requestFailed",{defaultValue:"Request failed"}))}},[h]);return{isLoading:L,tokenUsage:R,liveOutputTokens:P,runningStartedAt:I,rateLimitInfo:$,apiRetryInfo:_,backgroundTasks:H,promptSuggestion:U&&U.sessionId===n?U.text:null,handleSend:em,handleStop:eu,injectMessage:ep,abortControllerRef:q}}},22576:(e,t,n)=>{n.d(t,{X:()=>r});function r(e,t){let n=e.split("\n"),r=t.split("\n"),o=[],s=n.length,a=r.length,l=Array(s+1).fill(null).map(()=>Array(a+1).fill(0));for(let e=1;e<=s;e++)for(let t=1;t<=a;t++)n[e-1]===r[t-1]?l[e][t]=l[e-1][t-1]+1:l[e][t]=Math.max(l[e-1][t],l[e][t-1]);let i=s,c=a,d=[];for(;i>0||c>0;)i>0&&c>0&&n[i-1]===r[c-1]?(d.push({type:"unchanged",content:n[i-1],oldLineNum:i,newLineNum:c}),i--,c--):c>0&&(0===i||l[i][c-1]>=l[i-1][c])?(d.push({type:"added",content:r[c-1],newLineNum:c}),c--):(d.push({type:"removed",content:n[i-1],oldLineNum:i}),i--);for(;d.length>0;)o.push(d.pop());return o}},23348:(e,t,n)=>{n.d(t,{Eo:()=>a,jm:()=>o,zB:()=>s});var r=n(37640);let o=()=>(0,r.zi)("/api/bots"),s=e=>(0,r.B2)("/api/bots",{path:e}),a=e=>(0,r.zi)(`/api/bots/${encodeURIComponent(e)}`,{method:"DELETE"})},23883:(e,t,n)=>{n.d(t,{s:()=>eR});var r=n(95155),o=n(12115),s=n(34075),a=n(64428),l=n(67635),i=n(96035),c=n(54731),d=n(9921),u=n(66088),h=n(12651),m=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(86957),j=n(67589);function N({cwd:e,sessionId:t,toolCall:n,workflowRef:s,running:l,onClose:i}){let{t:c}=(0,k.Bd)(),[d,u]=(0,o.useState)(null),[h,m]=(0,o.useState)(null),[p,f]=(0,o.useState)(!1),g=(0,o.useRef)(void 0),x=s?!!s.running:l??!n?.result,b=(0,o.useCallback)(async()=>{let r=await C.t4.runPromiseExit((0,j.z)({cwd:e,sessionId:t,...s?{workflowId:s.runId,workflowAgentId:s.agentId}:{toolUseId:n?.id},ifFingerprint:g.current}));if(f(!0),"Success"!==r._tag||!r.value)return;let o=r.value;o.fingerprint&&(g.current=o.fingerprint),!o.notModified&&(o.messages&&u(o.messages),o.subagent&&m(o.subagent))},[e,t,n?.id,s?.runId,s?.agentId]);(0,o.useEffect)(()=>{if(b(),!x)return;let e=setInterval(b,5e3);return()=>clearInterval(e)},[x,b]);let v=(0,o.useRef)(null),y=(0,o.useRef)(!0);(0,o.useEffect)(()=>{let e=v.current;e&&y.current&&(e.scrollTop=e.scrollHeight)},[d]);let w="string"==typeof n?.input?.description?n.input.description:"",S=s?s.label||"":[h?.agentType,w].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:c("chat.subagent")}),S&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":S,children:S}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[x&&(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:c("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",{ref:v,onScroll:()=>{let e=v.current;e&&(y.current=e.scrollTop+e.clientHeight>=e.scrollHeight-40)},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:c(p?"chat.subagentEmpty":"common.loading")}):d.map(n=>(0,r.jsx)(eR,{message:n,cwd:e,sessionId:t},n.id))})]})})})}function S(e){return e?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):"0"}function T(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 E={done:"text-green-9",running:"text-brand",queued:"text-muted-foreground",error:"text-red-9",failed:"text-red-9"};function L({cwd:e,sessionId:t,runId:n,isRunning:s,onClose:l}){let{t:i}=(0,k.Bd)(),[c,d]=(0,o.useState)(null),[u,h]=(0,o.useState)(!1),[m,p]=(0,o.useState)(null),f=(0,o.useRef)(void 0),g=s||null!=c&&"completed"!==c.status&&"failed"!==c.status,x=(0,o.useCallback)(async()=>{let r=await C.t4.runPromiseExit((0,j.z)({cwd:e,sessionId:t,workflowId:n,ifFingerprint:f.current}));if(h(!0),"Success"!==r._tag||!r.value)return;let o=r.value;o.fingerprint&&(f.current=o.fingerprint),!o.notModified&&o.workflow&&d(o.workflow)},[e,t,n]);(0,o.useEffect)(()=>{if(x(),!g)return;let e=setInterval(x,5e3);return()=>clearInterval(e)},[g,x]);let b=[];if(c?.agents){let e=new Map;for(let t of c.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=c?[c.workflowName,c.status,`${c.agentCount??c.agents?.length??0} ${i("chat.workflowAgents")}`,`${S(c.totalTokens)} tok`,T(c.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===c?(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:[c.summary&&(0,r.jsx)("div",{className:"mb-3 text-xs text-muted-foreground whitespace-pre-wrap",children:c.summary}),b.map(e=>(0,r.jsxs)(o.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)(M,{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))]})})]})}),m&&(0,r.jsx)(N,{cwd:e,sessionId:t,workflowRef:m,onClose:()=>p(null)})]})}function M({agent:e,onOpen:t}){let{t:n}=(0,k.Bd)(),[s,a]=(0,o.useState)(!1),l=e.state&&E[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(s?"chat.collapse":"chat.expand"),children:s?"▲":"▼"}),(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:[S(e.tokens)," tok \xb7 ",T(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")})]}),s&&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 R=n(74086),A=n(60938),P=n(45619),F=n(38408),I=n(85958),D=n(47176),$=n(97251),B=n(34582),_=n(56045),O=n(50860),H=n(47215);function V({filePath:e}){let[t,n]=(0,o.useState)(null),[s,a]=(0,o.useState)(!0),[l,i]=(0,o.useState)(null),c=(0,o.useRef)(!1),d=(0,H.e$)(e),u=(0,H.u)(e);return((0,o.useEffect)(()=>{u?a(!1):c.current||(c.current=!0,(async()=>{a(!0),i(null);let t=await C.t4.runPromiseExit((0,A.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),c.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})}):s?(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,H.u)(e)?(0,r.jsx)(O.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?d?(0,r.jsx)(W,{content:t,filePath:e}):(0,r.jsx)(F.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 U=[$.W];function W({content:e,filePath:t}){let n=(0,o.useRef)(null),s=(0,o.useMemo)(()=>(0,B.J4)(t),[t]);return(0,r.jsxs)("div",{className:"h-full flex",children:[(0,r.jsx)(D.l,{content:e,containerRef:n}),(0,r.jsx)("div",{ref:n,className:"flex-1 overflow-auto p-4",children:(0,r.jsx)(I.T,{content:e,basePath:s,rehypePlugins:U})})]})}function q({title:e,content:t,toolName:n,onClose:l}){let{t:i}=(0,k.Bd)(),c=(0,H.jU)(t),d=(0,H.zs)(t),u=(0,H.oK)(t),h=!!d,m=!!u,[p,f]=(0,o.useState)(("Read"===n||"Write"===n)&&m?"file":h?"diff-unified":c?"readable":"json"),g=(0,o.useRef)(null),x=(0,_.o)(g);(0,o.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&"readable"===p&&c){e.preventDefault(),x.open();return}if("Escape"===e.key){if(x.isVisible)return void x.close();document.activeElement instanceof HTMLElement&&document.activeElement.blur(),l()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[l,p,c,x]);let b=(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:l,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 px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:e}),u&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(u),(0,s.oR)(i("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:i("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",children:[c&&(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:()=>f("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===p?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.sideBySide"),children:"Split"}),(0,r.jsx)("button",{onClick:()=>f("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===p?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.unified"),children:"Unified"})]}),m&&(0,r.jsx)("button",{onClick:()=>f("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===p?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:i("diffViewer.previewFile"),children:"File"}),(0,r.jsx)("button",{onClick:()=>f("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===p?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:i("common.readable")}),(0,r.jsx)("button",{onClick:()=>f("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===p?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,r.jsx)("button",{onClick:l,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.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===p&&u?(0,r.jsx)(V,{filePath:u}):"diff-unified"===p&&d?(0,r.jsx)(P.xU,{oldContent:d.old_string,newContent:d.new_string,filePath:d.file_path}):"diff-split"===p&&d?(0,r.jsx)(P.xZ,{oldContent:d.old_string,newContent:d.new_string,filePath:d.file_path}):"readable"===p&&c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(_._,{search:x}),(0,r.jsx)("pre",{ref:g,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,H.xb)(t)})]}):(0,r.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:c?(0,H.C6)(t):t})})]})});return(0,r.jsx)(a.ZL,{children:b})}var z=n(79237);let K={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 G(e){return"object"==typeof e&&null!==e}function J({toolCall:e,cwd:t,sessionId:n,disableOverlays:a=!1}){var l;let{t:i}=(0,k.Bd)(),[c,d]=(0,o.useState)(!1),[u,h]=(0,o.useState)(null),[m,p]=(0,o.useState)(!1),[f,g]=(0,o.useState)(!1),x=K[e.name]||"\uD83D\uDD27",b="Agent"===e.name||"Task"===e.name,v=b&&!!t&&!!n,y="Workflow"===e.name,w=y&&(l=e.result)?l.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,C=y&&!!w&&!!t&&!!n,j=(0,R.v2)(e.id)??e.task,S=j?.status==="running",T=!!e.isLoading||S,E=j?S||!!e.isLoading:!e.result,M=S?[j?.lastToolName,j?.toolUses?String(j.toolUses):null].filter(Boolean).join(" \xb7 "):"",A="Skill"===e.name,P="ApplyPatch"===e.name||b||y||A,F=e=>{let n=t?(0,z.y)(t,e):null;if(n)return n;let r=e.split("/");return r.length>2?".../"+r.slice(-2).join("/"):e},I=(()=>{let t=e.input;if("Bash"===e.name&&t.command&&"string"==typeof t.command)return t.command;if("ApplyPatch"===e.name&&Array.isArray(t.changes)){let e=t.changes.filter(G).flatMap(e=>{let t="string"==typeof e.path?e.path:"";if(!t)return[];let n="string"==typeof e.kind&&e.kind?e.kind:"update";return`${n} ${F(t)}`});if(e.length>0)return e.join(" \xb7 ")}if(b&&t.description&&"string"==typeof t.description)return t.description;if(y){let e=["string"==typeof t.name?t.name:"","string"==typeof t.args?t.args:"string"==typeof t.resumeFromRunId?t.resumeFromRunId:""].filter(Boolean).join(" \xb7 ");if(e)return e}if(A&&"string"==typeof t.skill){let e="string"==typeof t.args?t.args:"";return[t.skill,e].filter(Boolean).join(" \xb7 ")}return"Glob"===e.name&&t.pattern&&"string"==typeof t.pattern||"Grep"===e.name&&t.pattern&&"string"==typeof t.pattern?t.pattern:"ToolSearch"===e.name&&t.query&&"string"==typeof t.query?t.query:"TaskCreate"===e.name&&t.subject&&"string"==typeof t.subject?t.subject:t.file_path&&"string"==typeof t.file_path?t.file_path:t.path&&"string"==typeof t.path?t.path:null})(),D="Glob"===e.name||"Grep"===e.name||"Bash"===e.name||"ApplyPatch"===e.name||b||y||A,$=I?D?I:F(I):null,B=t=>{let n="input"===t?i("toolCall.inputParams"):i("toolCall.resultLabel"),r="input"===t?JSON.stringify(e.input,null,2):"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2);h({title:`${e.name}${$?` ${$}`:""} - ${n}`,content:r,toolName:e.name})};return(0,r.jsxs)("div",{className:"border-b border-line-1 last:border-b-0",children:[(0,r.jsxs)("button",{onClick:()=>d(!c),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:x}),(0,r.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:e.name}),$&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":I||"",children:$}),!P&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),I&&(navigator.clipboard.writeText(I),(0,s.oR)(i("common.copiedPath")))},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),I&&(navigator.clipboard.writeText(I),(0,s.oR)(i("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0 cursor-pointer",title:i("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:[v&&!a&&(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:i("chat.subagentViewTitle"),children:i("chat.subagent")}),C&&!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:i("chat.workflowViewTitle"),children:i("chat.workflowRun")}),M&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate max-w-[16rem]",children:M}),c&&!e.isLoading&&!a&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),B("input")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),B("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:i("toolCall.inputParamsTitle"),children:i("toolCall.input")}),e.result&&(0,r.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),B("result")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),B("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:i("toolCall.resultTitle"),children:i("toolCall.result")})]}),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:c?"▲":"▼"})]})]}),c&&(0,r.jsxs)("div",{className:"border-t border-line-1",children:[(0,r.jsxs)("div",{className:"px-3 py-2",children:[(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[i("toolCall.inputParams"),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(e.input,null,2)})]}),e.result&&(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:[i("toolCall.resultLabel"),":"]})}),(0,r.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof e.result?e.result:JSON.stringify(e.result,null,2)})]}),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:[i("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})]})]}),u&&(0,r.jsx)(q,{title:u.title,content:u.content,toolName:u.toolName,onClose:()=>h(null)}),m&&t&&n&&(0,r.jsx)(N,{cwd:t,sessionId:n,toolCall:e,running:E,onClose:()=>p(!1)}),f&&t&&n&&w&&(0,r.jsx)(L,{cwd:t,sessionId:n,runId:w,isRunning:T,onClose:()=>g(!1)})]})}var Q=n(62111),Y=n(56204),Z=n(33210),X=n(58515),ee=n(36201),et=n(55804),en=n(37618),er=n(83897);function eo(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 es(e,t){return`${e}-${t}`}function ea({toolCalls:e,onClose:t}){let{t:n}=(0,k.Bd)(),i=(0,er.nH)(),[c,d]=(0,o.useState)({}),[u,h]=(0,o.useState)({}),[m,p]=(0,o.useState)({}),[f,g]=(0,o.useState)({});(0,o.useEffect)(()=>{let t={};e.forEach((e,n)=>{let{questions:r,answers:o}=eo(e);r.forEach((e,r)=>{let s=o[e.question];if(s){let o=es(n,r);t[o]=s,e.options.some(e=>e.label===s)||(h(e=>({...e,[o]:!0})),p(e=>({...e,[o]:s})))}})}),queueMicrotask(()=>d(t))},[e]),(0,Q.E)(t);let x=e.reduce((e,t)=>{let{questions:n}=eo(t);return e+n.length},0),b=Object.values(f).filter(Boolean).length,v=(0,o.useCallback)((e,t)=>{d(n=>({...n,[e]:t})),h(t=>({...t,[e]:!1}))},[]),y=(0,o.useCallback)(e=>{h(t=>{let n=!t[e];if(n){let t=m[e]||"";t&&d(n=>({...n,[e]:t}))}return{...t,[e]:n}})},[m]),w=(0,o.useCallback)((e,t)=>{p(n=>({...n,[e]:t})),t&&d(n=>({...n,[e]:t}))},[]),C=(0,o.useCallback)(e=>{g(t=>({...t,[e]:!t[e]}))},[]),j=(0,o.useCallback)(()=>{let t=b>0,r=[];return e.forEach((e,o)=>{let{questions:s}=eo(e);s.forEach((e,s)=>{let a=es(o,s);if(t&&!f[a])return;let l=c[a];r.push(`Q: ${e.question}`),r.push(`A: ${l||n("askQuestion.notSelected")}`),r.push("")})}),r.join("\n").trim()},[e,c,f,b,n]),N=(0,o.useCallback)(()=>{navigator.clipboard.writeText(j()),(0,s.oR)(b>0?n("toast.copiedQA",{count:b}):n("toast.copiedAllQA"))},[j,b,n]),S=(0,o.useCallback)(()=>{i?(i.sendMessage(j()),(0,s.oR)(n("toast.sentQA")),t()):(0,s.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)(Y.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)(Z.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,o)=>{let{questions:s}=eo(t);return s.map((t,a)=>{let l=es(o,a),i=c[l],d=u[l]||!1,h=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:h?(0,r.jsx)(X.A,{className:"w-4 h-4 text-brand"}):(0,r.jsx)(ee.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&&!d;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)(et.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 ${d?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,r.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:d?(0,r.jsx)(et.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)(en.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")})]})]}),d&&(0,r.jsx)("div",{className:"ml-6 mt-1",children:(0,r.jsx)("input",{type:"text",autoFocus:!0,value:m[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"})})]}),(o!==e.length-1||a!==s.length-1)&&(0,r.jsx)("div",{className:"border-b border-border/50 mt-3"})]},l)})})})]})});return(0,r.jsx)(a.ZL,{children:T})}var el=n(54271),ei=n(9573),ec=n(4055),ed=n(24602),eu=n(32041);function eh({filePath:e,content:t,onClose:n,zClassName:l="z-50"}){let{t:i}=(0,k.Bd)(),[c,d]=(0,o.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.jsxs)("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,s.oR)(i("common.copiedPath"))},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:()=>d(e),className:`px-2 py-0.5 text-xs rounded transition-colors ${c===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"===c?(0,r.jsx)(eu.C0,{content:t,filePath:e,className:"h-full"}):(0,r.jsx)(F.Cv,{content:t,filePath:e,showLineNumbers:!0,showSearch:!0,className:"h-full"})})]})})})}let em="http://cockpit.invalid";function ep(e,t){let n;if(!e)return null;let r=e.trim();try{if(r.startsWith("/")){if((n=new URL(r,em)).origin!==em)return null}else if(!t||(n=new URL(r)).origin!==t)return null}catch{return null}if("/project"!==n.pathname)return null;let o=n.searchParams.get("cwd"),s=n.searchParams.get("sessionId");return o&&s?{cwd:o,sessionId:s}:null}let ef=/(^|[\s([])(\/project\?[^\s)\]]+)/g;var eg=n(95045),ex=n(75346);let eb={isFramed:()=>window.parent!==window,publishOpenProject:e=>(0,eg.F)(ex.n.OpenProject,e),navigate:e=>window.location.assign(e)};function ev(e,t,n=eb){n.isFramed()?n.publishOpenProject({cwd:e.cwd,sessionId:e.sessionId,switchToAgent:!0}):n.navigate(t)}var ey=n(95686),ew=n(83448);async function ek(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 o=t.getContext("2d");o?(o.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 eC({image:e,onClose:t}){let{t:n}=(0,k.Bd)(),o=`data:${e.media_type};base64,${e.data}`,i=async t=>{t.stopPropagation();try{await ek(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),o),(0,s.oR)(n("chat.copiedImage"),"success")}catch{(0,s.oR)(n("common.copyFailed"),"error")}},c=(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:o,alt:n("chat.imagePreview"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]});return(0,r.jsx)(a.ZL,{children:c})}function ej({filePath:e,onClose:t}){let{t:n}=(0,k.Bd)(),o=`/api/file?path=${encodeURIComponent(e)}&raw=true`,i=async t=>{t.stopPropagation();try{let t,r=await fetch(o);if(!r.ok)throw Error("Could not read image");let a=await r.blob(),l=a.type?a:new Blob([a],{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 ek(l,o),(0,s.oR)(n("chat.copiedImage"),"success")}catch{(0,s.oR)(n("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: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:o,alt:e.split("/").pop(),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:e=>e.stopPropagation()})]})})}function eN(e){let t=e.replace(/\/+$/,"");return t.startsWith("/private/")?t.slice(8):t}let eS=(0,o.memo)(function({text:e,isAside:t,isUser:n,isStreaming:a,onOpenFileLink:l,onPreviewFile:d,cwd:u}){let{t:h}=(0,k.Bd)(),m=(0,o.useMemo)(()=>{if(n||!l)return;let e=e=>{d&&((0,H.e$)(e)||(0,H.u)(e)||(0,H.Zy)(e))?d(e):(0,s.oR)(h("toast.fileOutsideProject"),"error")};return t=>{let n=function(e,t){let n;if(!e||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 o=r.indexOf("#"),s=o>=0?r.slice(o+1):"",a=o>=0?r.slice(0,o):r,l=a.indexOf("?"),i=l>=0?a.slice(l+1):"";a=l>=0?a.slice(0,l):a;let c=s.match(/^L?(\d+)(?:-L?\d+)?$/i)?.[1],d=i.match(/(?:^|[&;])(?:line|L)=(\d+)(?:$|[&;])/i)?.[1],u=a.match(/:(\d+)(?::\d+)?$/),h=c||d||u?.[1];if(h&&(n=Number(h),u&&(a=a.slice(0,-u[0].length))),!(a=a.trim()))return null;let m=n&&n>0?{lineNumber:n}:{},p=t?eN(t):"";if(a.startsWith("/")){let e=eN(a),t=p?(0,z.y)(p,e):null;return""===t?null:t?{rel:(0,H.WU)("",t),abs:null,...m}:{rel:(0,H.WU)("",e),abs:e,...m}}return a.startsWith("./")||a.startsWith("../")||a.includes("/")||/\.[A-Za-z0-9][A-Za-z0-9_-]*$/.test(a)?{rel:(0,H.WU)("",a),abs:null,...m}:null}(t,u);return!!n&&(n.abs?u?C.t4.runPromise((0,A.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,d,h]),p=(0,o.useMemo)(()=>{if(!n)return e=>{let t=ep(e,window.location.origin);return t?(ev(t,e),!0):!!m&&m(e)}},[n,m]),f=(0,o.useMemo)(()=>{if(!n)return null;let t=function(e){let t=[],n=0;for(let r of e.matchAll(ef)){let o=r[2],s=ep(o);if(!s)continue;let a=r.index+r[1].length;a>n&&t.push({kind:"text",text:e.slice(n,a)}),t.push({kind:"link",text:o,target:s}),n=a+o.length}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}(e);return t.some(e=>"link"===e.kind)?t:null},[n,e]),g=(0,r.jsxs)(r.Fragment,{children:[f?(0,r.jsx)("div",{className:"reading-measure whitespace-pre-wrap break-words",children:f.map((e,t)=>"link"===e.kind?(0,r.jsxs)("a",{href:e.text,title:`${e.target.cwd}
|
|
12
|
+
${e.target.sessionId}`,className:"inline-flex items-center gap-1 px-1.5 rounded bg-brand/10 hover:bg-brand/20 text-brand font-mono text-[0.9em] align-baseline whitespace-nowrap no-underline",onClick:t=>{t.preventDefault(),ev(e.target,e.text)},children:[(0,r.jsx)(i.A,{className:"w-3 h-3 shrink-0","aria-hidden":!0}),e.target.sessionId.slice(0,8)]},t):e.text)}):(0,r.jsx)(I.T,{content:e,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)(c.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:g})]}):(0,r.jsx)("div",{className:"break-words",children:g})}),eT="28em",eE=(0,o.memo)(function({children:e}){let{t}=(0,k.Bd)(),[n,s]=(0,o.useState)(!1),[a,l]=(0,o.useState)(!1),i=(0,o.useRef)(null),c=(0,o.useRef)(null),h=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(n)return;let e=c.current,t=h.current;if(!e||!t)return;let r=()=>l(e.scrollHeight>e.clientHeight+1);r();let o=new ResizeObserver(r);return o.observe(t),()=>o.disconnect()},[n]);let m=(0,o.useCallback)(()=>{if(!n)return void s(!0);let e=i.current?.closest("[data-message-id]")??i.current;s(!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:c,className:n?void 0:"overflow-hidden",style:n?void 0:{maxHeight:eT},children:(0,r.jsx)("div",{ref:h,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:m,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)(d.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(u.A,{className:"w-3.5 h-3.5"})]})]})]})});function eL({collapsible:e,children:t}){return e?(0,r.jsx)(eE,{children:t}):(0,r.jsx)(r.Fragment,{children:t})}let eM=new Map,eR=(0,o.memo)(function({message:e,cwd:t,sessionId:n,onFork:l,onDeleteTurn:i,forkSupported:c=!0,onSendToPeer:d,peerSide:j,onApprovePlan:N,isLoading:S,onContentSearch:T,onShowFileDiff:E,onOpenFileLink:L,disableOverlays:M=!1}){let R,A,P,F,{t:D,i18n:$}=(0,k.Bd)(),[B,_]=(0,o.useState)(null),[O,V]=(0,o.useState)(()=>1===(e.toolCalls?.length||0)),[U,W]=(0,o.useState)(!1),[q,z]=(0,o.useState)(!1),[K,G]=(0,o.useState)(!1),[Q,Y]=(0,o.useState)(!1),[Z,X]=(0,o.useState)(!1),ee=(0,o.useRef)(null),et=(0,o.useRef)(null),en="user"===e.role,er=e.images&&e.images.length>0,eo=e.toolCalls?.length||0,es=!!n&&!!t&&!!l&&c,eu=!!n&&!!t&&!!i;(0,o.useEffect)(()=>{if(!Q)return;let e=e=>{ee.current?.contains(e.target)||Y(!1)},t=e=>{"Escape"===e.key&&(Y(!1),et.current?.focus())};return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[Q]);let em=(0,o.useMemo)(()=>e.toolCalls?.some(e=>(0,ec.h)(e.name))||!1,[e.toolCalls]),ep=(0,o.useMemo)(()=>{let t=e.parts;if(!t?.length)return e.content?[{text:e.content,isAside:!1}]:[];let n=-1;t.forEach((e,t)=>{"tool"===e.type&&(n=t)});let r=[];return t.forEach((e,t)=>{"text"===e.type&&r.push({text:e.text,isAside:t<n})}),r},[e.parts,e.content]),ef=(0,o.useMemo)(()=>(0,el.vP)([],e.toolCalls??[],t).length>0,[e.toolCalls,t]),[eg,ex]=(0,o.useState)(!1),eb=ef||eg;(0,o.useEffect)(()=>{E&&e.toolCalls?.length&&E(e.id,e.toolCalls,t,n??void 0,!0)},[E,e.id,e.toolCalls,t,n]),(0,o.useEffect)(()=>{if(!em||ef||!t)return;let r=(e.toolCalls??[]).map(e=>e.id).filter(Boolean);if(0===r.length)return;let o=(e.toolCalls??[]).filter(e=>(0,ec.h)(e.name)).map(e=>e.id),s=!1,a=null,l=0,i=()=>{C.t4.runPromiseExit((0,ei.xK)(t,r,n??void 0)).then(e=>{if(s)return;let t="Success"===e._tag?e.value:[];if(t.length>0)return void ex(!0);let n=new Set(t.map(e=>e.toolId));o.some(e=>!n.has(e))&&l<2&&(l+=1,a=setTimeout(i,2e3))})};return i(),()=>{s=!0,a&&clearTimeout(a)}},[em,ef,t,n,e.toolCalls]);let ev=(0,o.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]),ek=(0,o.useMemo)(()=>e.toolCalls?e.toolCalls.filter(e=>"AskUserQuestion"===e.name):[],[e.toolCalls]),eN=(0,o.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]),eT=(0,o.useMemo)(()=>e.toolCalls?.filter(e=>"ExitPlanMode"!==e.name)??[],[e.toolCalls]),eE=(0,o.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&&((0,H.e$)(e)||(0,H.aR)(e)||(0,H.u)(e)||(0,H.Zy)(e))&&!t.has(e)&&(t.add(e),n.push(e))}return n},[e.toolCalls]),eR=(0,o.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]),[eA,eP]=(0,o.useState)(null),[eF,eI]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!eA||(0,H.u)(eA))return void queueMicrotask(()=>eI(null));let e=!1;return C.t4.runPromiseExit((0,ew.an)(eA)).then(t=>{e||("Success"===t._tag&&void 0!==t.value.content?eI(t.value.content):((0,s.oR)(D("toast.readFileFailed"),"error"),eP(null)))}),()=>{e=!0}},[eA,D]);let eD=async()=>{if(eu&&!S&&!Z&&await (0,s.lJ)(D("chat.deleteTurnConfirm",{defaultValue:"Delete this question, answer, and its tool records? This cannot be undone."}),{title:D("chat.deleteTurn",{defaultValue:"Delete turn"}),confirmText:D("chat.deleteTurnConfirmAction",{defaultValue:"Delete turn"}),danger:!0})){X(!0);try{await i(e.id)}finally{X(!1)}}},e$=!!j&&!!d&&!!e.content,eB=(0,o.useMemo)(()=>{var t;let n;if(!e.timestamp)return"";let r=new Date(e.timestamp);return isNaN(r.getTime())?"":(t=$.language,!(n=eM.get(t))&&(n=new Intl.DateTimeFormat(t,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),eM.set(t,n)),n).format(r)},[e.timestamp,$.language]);if("system"===e.role){let t=e.systemEvent,n=t?.kind==="task-notification"?"failed"===t.status?"⚠️":"stopped"===t.status?"⏹️":"\uD83D\uDD14":"ℹ️",o=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:()=>G(!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:D("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})]})}),K&&(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:()=>G(!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"?D("chat.taskNotification",{defaultValue:"Task notification"}):D("chat.systemNotice",{defaultValue:"Notice"})]}),(0,r.jsx)("button",{onClick:()=>G(!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:o})]})})})]})}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:`flex flex-col ${en?"items-end":"items-start"} mb-4 group`,"data-role":e.role,children:[(0,r.jsx)("div",{className:`relative flex items-start ${en?"justify-end":"justify-start"} w-full`,children:(0,r.jsxs)("div",{className:`chat-turn px-4 py-2 text-foreground ${en?"max-w-[80%] bg-muted rounded-2xl rounded-br-md border border-brand/40":"w-full"}`,children:[er&&(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 ${M?"":"cursor-pointer hover:opacity-90 transition-opacity"}`,onClick:M?void 0:()=>_(e),children:(0,r.jsx)("img",{src:`data:${e.media_type};base64,${e.data}`,alt:D("chat.imageN",{index:t+1}),className:"w-full h-full object-cover"})},t))}),ep.length>0&&(0,r.jsx)(eL,{collapsible:en,children:(0,r.jsx)("div",{className:"space-y-3",children:ep.map((n,o)=>(0,r.jsx)(eS,{text:n.text,isAside:n.isAside,isUser:en,isStreaming:!!e.isStreaming&&o===ep.length-1,onOpenFileLink:L,onPreviewFile:eP,cwd:t},o))})}),ev&&(P=(A=Array.isArray(R=ev.input?.todos)?R:[]).filter(e=>"completed"===e.status).length,F=A.length,(0,r.jsx)("div",{className:`${e.content||er?"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:`${F>0?P/F*100:0}%`}})}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[P,"/",F]})]}),A.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)(h.A,{className:"w-3 h-3 text-green-11 flex-shrink-0"}):"in_progress"===e.status?(0,r.jsx)(m.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))]})})),eN&&(0,r.jsx)("div",{className:`${e.content||er||ev?"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:D("chat.planTitle",{defaultValue:"Plan (awaiting your review)"})})]}),(0,r.jsx)("div",{className:"px-3 py-2",children:(0,r.jsx)(I.T,{content:eN,isUser:!1})}),N&&(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:D("chat.planApproveHint",{defaultValue:"本环境无审批弹窗,点此退出 Plan 并执行"})}),(0,r.jsxs)("button",{onClick:()=>N(),disabled:S,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:D("chat.approvePlan",{defaultValue:"批准并执行"})})]})]})]})}),eE.length>0&&(0,r.jsx)("div",{className:`${e.content||er||ev?"mt-2":""}`,children:(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden px-3 py-2 space-y-0.5",children:eE.map(e=>(0,r.jsxs)("button",{disabled:M,onClick:()=>eP(e),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,H.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,H.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,H.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))})}),eR.length>0&&(0,r.jsx)("div",{className:`${e.content||er||ev||eE.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:eR.map((e,t)=>(0,r.jsxs)("tr",{className:t<eR.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))})]})})}),eT.length>0&&(0,r.jsx)("div",{className:`${e.content||er?"mt-3":""}`,children:eo>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:()=>V(!O),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:D("chat.toolCalls",{count:eT.length})}),(0,r.jsx)("span",{className:"ml-auto text-muted-foreground text-sm",children:O?D("chat.collapse"):D("chat.expand")})]}),!M&&ek.length>0&&(0,r.jsx)("button",{onClick:()=>z(!0),className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover transition-colors border-l border-line-1",title:D("chat.viewQuestions"),children:(0,r.jsx)(f.A,{className:"w-4 h-4"})}),!M&&eb&&(0,r.jsx)("button",{onClick:()=>{E&&e.toolCalls?E(e.id,e.toolCalls,t,n??void 0):W(!0)},className:"px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover transition-colors border-l border-line-1",title:D("chat.viewAllFileChanges"),children:(0,r.jsx)(g.A,{className:"w-4 h-4"})})]}),O&&(0,r.jsx)("div",{className:"border-t border-line-1",children:eT.map((e,o)=>(0,r.jsx)(J,{toolCall:e,cwd:t,sessionId:n,disableOverlays:M},`${e.id}-${o}`))})]}):eT.map((e,o)=>(0,r.jsx)(J,{toolCall:e,cwd:t,sessionId:n,disableOverlays:M},`${e.id}-${o}`))})]})}),(eB||e.content||es||eu)&&(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 ${en?"flex-row-reverse":""}`,children:[e.content&&(0,r.jsx)("button",{onClick:()=>{e.content&&(navigator.clipboard.writeText(e.content),(0,s.oR)(D("toast.copiedMessage")))},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:D("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"})})}),es&&(0,r.jsxs)("div",{ref:ee,className:"relative",children:[(0,r.jsxs)("button",{ref:et,type:"button",onClick:()=>Y(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":Q,title:D("chat.newSession"),children:[(0,r.jsx)(x.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:D("chat.newSession")}),(0,r.jsx)(u.A,{className:`h-3 w-3 transition-transform ${Q?"rotate-180":""}`})]}),Q&&(0,r.jsxs)("div",{role:"group","aria-label":D("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 ${en?"right-0":"left-0"}`,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{es&&(Y(!1),l(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:D("chat.continueFromHere")}),(0,r.jsx)("span",{className:"mt-0.5 block text-[11px] leading-4 text-muted-foreground",children:D("chat.continueFromHereDesc")})]})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{es&&(Y(!1),l(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:D("chat.onlyThisTurn")}),(0,r.jsx)("span",{className:"mt-0.5 block text-[11px] leading-4 text-muted-foreground",children:D("chat.onlyThisTurnDesc")})]})]})]})]}),eu&&(0,r.jsxs)("button",{type:"button",onClick:eD,disabled:S||Z,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:S?D("chat.deleteTurnWhileRunning"):D("chat.deleteTurn"),children:[(0,r.jsx)(v.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:Z?D("chat.deletingTurn"):D("chat.deleteTurn")})]}),e$&&(0,r.jsx)("button",{onClick:()=>{e$&&d(e.content)},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover",title:D("chat.sendToPeerPane"),children:"right"===j?(0,r.jsx)(y.A,{className:"w-4 h-4"}):(0,r.jsx)(w.A,{className:"w-4 h-4"})}),eB&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground mx-1",children:eB})]})]}),B&&(0,r.jsx)(eC,{image:B,onClose:()=>_(null)}),U&&e.toolCalls&&(0,r.jsx)(el.zB,{toolCalls:e.toolCalls,cwd:t,sessionId:n??void 0,onClose:()=>W(!1),onContentSearch:T}),q&&ek.length>0&&(0,r.jsx)(ea,{toolCalls:ek,onClose:()=>z(!1)}),eA&&(0,H.u)(eA)&&(0,r.jsx)(ej,{filePath:eA,onClose:()=>eP(null)}),eA&&!(0,H.u)(eA)&&null!==eF&&((0,H.aR)(eA)?(0,r.jsx)(ed.N,{filePath:eA,content:eF,cwd:t,onClose:()=>eP(null),onContentSearch:T}):(0,H.Zy)(eA)?(0,r.jsx)(eh,{filePath:eA,content:eF,onClose:()=>eP(null)}):(0,r.jsx)(ey.x,{filePath:eA,content:eF,cwd:t||"",onClose:()=>eP(null)}))]})})},24602:(e,t,n)=>{n.d(t,{N:()=>S});var r=n(95155),o=n(12115),s=n(79114),a=n(64428),l=n(34075),i=n(14341),c=n(42804),d=n(22164),u=n(34582),h=n(85269),m=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,o.useMemo)(()=>{let t,n;return(n=(t=e.replace(/\\/g,"/")).lastIndexOf("/"))<=0?"/":t.slice(0,n)},[e]),s=e=>(0,y.y)(n,e)||C(e),a=(0,o.useRef)(new Map),[l,i]=(0,o.useState)([]),[c,d]=(0,o.useState)(e),[u,h]=(0,o.useState)(!0);(0,o.useEffect)(()=>{a.current=new Map([[e,t]]);let r={abs:e,rel:C(e),kind:"text"};i([r]),d(e),h(!0);let o=!1;return(async()=>{let l=new Set([e]),c=[r],d=[t];for(;d.length&&c.length<40&&!o;)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]}(d.shift())){if(c.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 o="/"+r.join("/");return o===n||o.startsWith(n+"/")?o: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&&!o&&(c.push({abs:t,rel:s(t),kind:r}),i([...c]))}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),d.push(e.data.content),o||(c.push({abs:t,rel:s(t),kind:r}),i([...c])))}}o||h(!1)})(),()=>{o=!0}},[e,t,n]);let m=l.find(e=>e.abs===c),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:()=>d(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 ${c===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:m?.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(c)}&raw=true`,alt:C(c),className:"max-w-full max-h-full object-contain"})}):(0,r.jsx)(x.Cv,{content:a.current.get(c)??"",filePath:c,cwd:n},c)})]})}function S({filePath:e,content:t,cwd:n,onClose:p,onContentSearch:f}){let{t:g}=(0,s.Bd)(),x=(0,m.P)(),[b,v]=(0,o.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.jsxs)("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:["",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)(c.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)(d.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)(h.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:()=>o});var r=n(12115);function o({enabled:e,container:t,resolveLineRange:n,buildLineSnapshot:s,dragThresholdPx:a=5}){let l=(0,r.useRef)(null),i=(0,r.useRef)(()=>{}),c=(0,r.useRef)(n),d=(0,r.useRef)(s),u=(0,r.useRef)(a);return c.current=n,d.current=s,u.current=a,(0,r.useEffect)(()=>{if(!e||!t)return;let n=!1,r=0,o=0,s=()=>{l.current&&(l.current=null,i.current())},a=e=>{n=!0,r=e.clientX,o=e.clientY;let t=e.target;t?.closest?.(".floating-toolbar")||s()},h=e=>{n=!1;let a=e.target;if(a?.closest?.(".floating-toolbar"))return;let h=u.current,m=Math.abs(e.clientX-r)>h||Math.abs(e.clientY-o)>h,p=window.getSelection();if(!p||p.isCollapsed||!p.toString().trim()||!m)return void s();let f=p.getRangeAt(0);if(!t.contains(f.commonAncestorContainer))return void s();let g=c.current(f.startContainer),x=c.current(f.endContainer);if(!g||!x)return void s();let b=Math.min(g.start,x.start),v=Math.max(g.end,x.end),y=p.toString(),w=d.current({start:b,end:v});l.current={x:e.clientX,y:e.clientY,range:{start:b,end:v},selectedText:y,lineSnapshot:w},i.current()},m=()=>{if(n||!l.current)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||s()};return t.addEventListener("mousedown",a),document.addEventListener("mouseup",h),document.addEventListener("selectionchange",m),()=>{t.removeEventListener("mousedown",a),document.removeEventListener("mouseup",h),document.removeEventListener("selectionchange",m)}},[e,t]),{toolbarRef:l,bumpRef:i,clearToolbar:()=>{l.current&&(l.current=null,i.current())}}}},30133:(e,t,n)=>{n.d(t,{y:()=>s});var r=n(95155),o=n(79114);function s({value:e,onChange:t,className:n}){let{t:a}=(0,o.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))})}},32041:(e,t,n)=>{n.d(t,{C0:()=>h});var r=n(95155),o=n(12115),s=n(61878),a=n(33210),l=n(9921),i=n(66088),c=n(79114);let d=/^-?[\d,]*\.?\d+%?$/;function u(e){return d.test(e)?parseFloat(e.replace(/,/g,"")):NaN}function h({content:e,filePath:t,className:n="",action:m}){let{t:p}=(0,c.Bd)(),[f,g]=(0,o.useState)(500),[x,b]=(0,o.useState)(""),[v,y]=(0,o.useState)(-1),[w,k]=(0,o.useState)(null),{header:C,body:j,columnCount:N}=(0,o.useMemo)(()=>{let n=(function(e,t){let n=[],r=[],o="",s=!1,a=!1,l=()=>{r.push(o),n.push(r),r=[],o="",a=!1};for(let n=0;n<e.length;n++){let i=e[n];if(s){if('"'!==i){o+=i;continue}'"'===e[n+1]?(o+='"',n++):s=!1;continue}if('"'===i&&""===o){s=!0,a=!0;continue}if(i===t){r.push(o),o="",a=!0;continue}if("\r"===i){"\n"===e[n+1]&&n++,l();continue}if("\n"===i){l();continue}o+=i,a=!0}return(a||""!==o||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},o=!1,s=0;for(let e=0;e<n.length&&s<5;e++){let t=n[e];if('"'===t){o=!o;continue}if(!o){if("\n"===t){s++;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),o=n.slice(1).map((e,t)=>({index:t,cells:e}));return{header:n[0]??[],body:o,columnCount:r}},[e,t]);(0,o.useEffect)(()=>{g(500),b(""),y(-1),k(null)},[e,t]);let S=(0,o.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,o.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),o=u(t);return isNaN(r)||isNaN(o)?e.localeCompare(t,void 0,{numeric:!0})*n:(r-o)*n})(t.cells[w.col]??"",n.cells[w.col]??"",e))},[S,w]);(0,o.useEffect)(()=>{g(500)},[x,v]);let E=(0,o.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 L=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)(s.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))]}),m&&(0,r.jsx)("button",{onClick:m.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:m.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:L.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 o=e.cells[n]??"";return(0,r.jsx)("td",{title:o.length>60?o:void 0,className:`border-b border-border px-2 py-1 max-w-[28rem] truncate text-foreground ${d.test(o)?"text-right tabular-nums":""}`,children:o},n)})]},e.index))})]}),0===L.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})}),L.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:L.length,total:T.length})})]})]})}},33442:(e,t,n)=>{n.d(t,{_:()=>o,a:()=>s});let r=(0,n(93964).N)("cockpit-bots"),o=r.notify,s=r.subscribe},34075:(e,t,n)=>{n.d(t,{dj:()=>l,lJ:()=>u,oR:()=>m,tE:()=>i});var r=n(95155),o=n(12115),s=n(69809);let a=(0,o.createContext)(null);function l(){let e=(0,o.useContext)(a);if(!e)throw Error("useToast must be used within a ToastProvider");return e}function i({children:e}){let[t,n]=(0,o.useState)([]),s=(0,o.useCallback)((e,t="success")=>{let r=`toast-${Date.now()}`;n(n=>[...n,{id:r,message:e,type:t}])},[]),l=(0,o.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return(0,r.jsxs)(a.Provider,{value:{showToast:s},children:[e,(0,r.jsx)(c,{toasts:t,onRemove:l})]})}function c({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)(d,{toast:e,onRemove:t},e.id))})}function d({toast:e,onRemove:t}){(0,o.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],s={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:[s,(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=s.A.t("confirm.title",{defaultValue:"Confirm"}),confirmText:r=s.A.t("confirm.ok",{defaultValue:"OK"}),cancelText:o=s.A.t("confirm.cancel",{defaultValue:"Cancel"}),danger:a=!1}=t||{};return new Promise(t=>{let s=document.createElement("div");s.className="fixed inset-0 z-[200] flex items-center justify-center",s.style.animation="confirmFadeIn 0.15s ease-out";let l=e=>{s.style.animation="confirmFadeOut 0.12s ease-in",s.addEventListener("animationend",()=>{document.body.removeChild(s),t(e)},{once:!0})};s.addEventListener("mousedown",e=>{e.target===s&&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),s.innerHTML=`
|
|
13
13
|
<div class="fixed inset-0 bg-scrim"></div>
|
|
14
14
|
<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">
|
|
15
15
|
<div class="text-base font-medium text-foreground mb-2">${n}</div>
|
|
@@ -724,10 +724,10 @@ ${e.target.sessionId}`,className:"inline-flex items-center gap-1 px-1.5 rounded
|
|
|
724
724
|
try { if (ws) ws.close(); } catch (e) {}
|
|
725
725
|
});
|
|
726
726
|
})();
|
|
727
|
-
`;function s(e){return/^([/\\]|[A-Za-z]:)/.test(e)}function a(e){return s(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 c(e,t){return a(e)||!!t}let d="/apps/local/",u="/apps/builtin/";function h(e,t){let n=e.trim();return d+m(a(n)?n:l(t??"",n)).replace(/\\/g,"/").split("/").map(encodeURIComponent).join("/").replace(/^\//,"")}function m(e){let t=/^[A-Za-z]:/.exec(e)?.[0]??"",n=t?e.slice(t.length):e,r=/^[/\\]/.test(n),o=[];for(let e of n.split(/[/\\]/))if(e&&"."!==e){if(".."===e){o.length&&".."!==o[o.length-1]?o.pop():r||t||o.push("..");continue}o.push(e)}return t+(r||t?"/":"")+o.join("/")}let p=/^([a-z][a-z0-9+.-]*:|\/\/|\/)/i;function f(e,t,n){let r=e.trim();if(!r||p.test(r)||!c(t,n))return e;let o=s(t)?t:l(n,t),a=r.search(/[?#]/),i=a<0?r:r.slice(0,a),d=a<0?"":r.slice(a);if(!i)return e;let u=i;try{u=decodeURIComponent(i)}catch{}return h(m(l(o,u)))+d}let g=[{chip:"*.md",exts:["md"]},{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"]}],x=RegExp(`\\.(${g.flatMap(e=>e.exts).join("|")})$`,"i"),b=g.map(e=>e.chip);function v(e){return x.test(e.trim())}function y(e,t){let n=e.trim();return u+"file-viewer/index.html?file="+encodeURIComponent(m(a(n)?n:l(t??"",n)).replace(/\\/g,"/"))}function w(e,t){try{let n=new URL(e,t);if(!n.pathname.startsWith(u)&&!n.pathname.startsWith(d))return e;return"localhost"===n.hostname&&(n.hostname="127.0.0.1"),n.toString()}catch{return e}}function k(e,t){let n=e=>JSON.stringify(e).replace(/</g,"\\u003c"),r="<script>"+o.replaceAll("__CWD__",n(t.cwd)).replaceAll("__WS_URL__",n(t.wsUrl??""))+"<\/script>",s=e.match(/<head[^>]*>/i);if(s&&void 0!==s.index){let t=s.index+s[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),o=n(12115),s=n(79114);function a({x:e,y:t,comment:n,container:l,onClose:i,onUpdateComment:c,onDeleteComment:d}){let{t:u}=(0,s.Bd)(),[h,m]=(0,o.useState)(!1),[p,f]=(0,o.useState)(n.content),g=(0,o.useRef)(null),[x,b]=(0,o.useState)({x:0,y:0});(0,o.useEffect)(()=>{if(g.current&&l){let n=l.getBoundingClientRect(),r=g.current.getBoundingClientRect(),o=e-n.left,s=t-n.top;o+r.width>n.width-16&&(o=n.width-r.width-16),o<16&&(o=16),s+r.height>n.height-16&&(s=s-r.height-8),s<16&&(s=16),queueMicrotask(()=>b({x:o,y:s}))}},[e,t,l]),(0,o.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 c(n.id,p.trim()),m(!1))},y=async()=>{await d(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:h?(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&&(m(!1),f(n.content))}}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{onClick:()=>{m(!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:()=>m(!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:()=>s});var r=n(49433),o=n(82680);let s=(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 o.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),a=(e,t)=>s(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:()=>I,XO:()=>$});var r=n(95155),o=n(12115),s=n(79114),a=n(47650),l=n(86957),i=n(60938),c=n(51145),d=n(70188),u=n(7320),h=n(56978),m=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,s.Bd)(),a=(0,o.useRef)(null),l=(0,o.useRef)(null),i=(0,x.F2)(),c=(0,o.useRef)(!1),d=(0,o.useRef)(!1),u=(0,o.useRef)(null),h=(0,o.useRef)(null),m=(0,o.useRef)(null),p=(0,o.useRef)(e);(0,o.useEffect)(()=>{p.current=e},[e]);let f=(0,o.useRef)(t);(0,o.useEffect)(()=>{f.current=t},[t]);let b=(0,o.useCallback)(()=>{let e,t=l.current,n=a.current;if(!t||!n)return;let r=n.getBoundingClientRect(),o=t.getBoundingClientRect(),s=i?.getBoundingClientRect(),c=s?.left??0,d=s?.top??0,u=s?.width??window.innerWidth,h=s?.height??window.innerHeight,m=r.left-c;m+o.width>u-8&&(m=u-o.width-8),m<8&&(m=8);let p=r.top-d,f=r.bottom-d;(e=p-o.height-4<0?f+4:p-o.height-4)+o.height>h-8&&(e=h-o.height-8),t.style.left=`${m}px`,t.style.top=`${e}px`},[i]),y=(0,o.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),h.current&&(clearTimeout(h.current),h.current=null),c.current=!1,d.current=!1,l.current&&(l.current.style.display="none"),m.current&&(document.removeEventListener("mousedown",m.current.down),document.removeEventListener("mouseup",m.current.up),m.current=null)},[]),w=(0,o.useCallback)(()=>{let e=l.current;if(!e||c.current)return;c.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},o=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",o),m.current={down:r,up:o}},[b,y]),k=(0,o.useCallback)(()=>{if(u.current&&clearTimeout(u.current),h.current&&(clearTimeout(h.current),h.current=null),c.current)return;let e=window.getSelection();(!e||e.isCollapsed)&&(u.current=setTimeout(w,500))},[w]),C=(0,o.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),c.current&&(h.current=setTimeout(()=>{d.current||y()},200))},[y]),j=(0,o.useCallback)(()=>{d.current=!0,h.current&&(clearTimeout(h.current),h.current=null)},[]),N=(0,o.useCallback)(()=>{d.current=!1,y()},[y]),S=(0,o.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,o.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 o=Math.floor(r/60);if(o<24)return t("common.hoursAgo",{count:o});let s=Math.floor(o/24);if(s<30)return t("common.daysAgo",{count:s});let a=Math.floor(s/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,o.memo)(function({virtualKey:e,lineNum:t,highlightedHtml:n,hasComments:a,firstComment:l,lineCommentsCount:i,isInRange:c,showLineNumbers:d,lineNumChars:u,commentsEnabled:h,virtualItemSize:m,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:L,onInlineBlameClick:M,isCursorLine:R,cursorCol:A}){let{t:P}=(0,s.Bd)(),F=(0,o.useMemo)(()=>R&&null!=A?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,A):n,[n,R,A]),I=(0,o.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,o.useCallback)(e=>{if(!x)return;let n=(0,b.A)(e,e.currentTarget);n&&x(t,n.column,n.rect)},[t,x]),D=(0,o.useCallback)(()=>{k&&S&&S(k)},[k,S]),B=(0,o.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:`${m}px`,transform:`translateY(${p}px)`,backgroundColor:N&&j?j.bg:void 0},className:`flex ${w===t?"flash-line":""} ${R?"vi-cursor-line":""} ${c?"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:B,onMouseLeave:E,onClick:D,title:P("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})]}),d&&(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 ${c?"bg-blue-9/30 text-blue-11":"bg-card/50 text-foreground-subtle"}`,children:[h&&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:P("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"})})}),h&&!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:I,onMouseOver:$,onMouseLeave:y,"data-code-content":!0,children:[(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:F}}),L&&(0,r.jsx)(v,{blame:L,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,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=0;for(;(r=o.nextNode())&&r!==t;)s+=r.textContent.length;return s+n}function E(e,t){let n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=t,s=null;for(;n=r.nextNode();){s=n;let e=n.textContent.length;if(o<=e)return{node:n,offset:o};o-=e}return s?{node:s,offset:s.textContent.length}:null}var L=n(82292),M=n(34075);let R="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function A(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 o=Array.from(e.children).indexOf(r);if(o<0)return null;let s=document.createRange();return s.selectNodeContents(r),s.setEnd(n.startContainer,n.startOffset),{line:o,offset:s.toString().length}}function P(e,t){let n,r=e.children[t.line];if(!r)return;let o=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),s=t.offset;for(;n=o.nextNode();){let e=n.textContent?.length||0;if(s<=e){let e=window.getSelection(),t=document.createRange();t.setStart(n,s),t.collapse(!0),e?.removeAllRanges(),e?.addRange(t);return}s-=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="${R}">${e}</div>`).join("")}let I=(0,o.forwardRef)(function({content:e,filePath:t,showLineNumbers:n=!0,showSearch:x=!0,className:b="",cwd:v,enableComments:I=!1,scrollToLine:$=null,scrollToLineAlign:D="center",onScrollToLineComplete:B,highlightKeyword:O=null,visibleLineRef:_,onCmdClick:H,onTokenHover:V,onTokenHoverLeave:U,onTokenHoverCancel:W,blameLines:q,inlineBlameLines:z,onSelectCommit:K,editable:G=!1,initialMtime:J,onEditorClose:Q,onSaved:Y,onEditorStateChange:Z,viMode:X=!1,onContentMutate:ee,onEnterInsertMode:et,onViSave:en,viStateRef:er,initialCursorLine:eo,initialCursorCol:es,onInitialCursorSet:ea,onContentSearch:el},ei){let{t:ec}=(0,s.Bd)(),ed=(0,o.useRef)(e),eu=(0,o.useRef)(!1),[eh,em]=(0,o.useState)(!1),[ep,ef]=(0,o.useState)(!1),[eg,ex]=(0,o.useState)(()=>e.split("\n").length),eb=(0,o.useRef)(e.split("\n").length),[ev,ey]=(0,o.useState)({show:!1}),ew=(0,o.useRef)(null),ek=(0,o.useRef)(null),eC=(0,o.useRef)(J),ej=(0,o.useRef)(null),eN=(0,o.useRef)(!1),eS=(0,o.useRef)(!1),{parentRef:eT,containerRef:eE,searchInputRef:eL,floatingToolbarRef:eM,suppressHoverRef:eR,bumpToolbarRef:eA,savedSelectionRef:eP,highlightedLines:eF,isMounted:eI,cmdHeld:e$,flashLine:eD,isSearchVisible:eB,searchQuery:eO,caseSensitive:e_,wholeWord:eH,currentMatchIndex:eV,viewingComment:eU,addCommentInput:eW,sendToAIInput:eq,aiBridge:ez,commentsEnabled:eK,updateComment:eG,deleteComment:eJ,lines:eQ,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:to,handleToolbarExplain:ts,handleToolbarSearch:ta,handleCommentSubmit:tl,handleSendToAISubmit:ti,handleCommentSendToAI:tc,getHighlightedLineHtml:td,suppressMatchScrollRef:tu,inlineBlameLineRef:th,inlineBlameVersion:tm}=function({content:e,filePath:t,showSearch:n=!0,cwd:r,enableComments:s=!1,scrollToLine:a=null,scrollToLineAlign:l="center",onScrollToLineComplete:i,visibleLineRef:c,onContentSearch:d}){let[u,p]=(0,o.useState)(!1),f=(0,o.useRef)(null),x=(0,o.useRef)(null),b=(0,o.useRef)(null),v=(0,N.r)();(0,o.useEffect)(()=>{p(!0)},[]);let[y,w]=(0,o.useState)(!1),[E,L]=(0,o.useState)(null),M=(0,o.useRef)(null),[R,A]=(0,o.useState)(!1),[P,F]=(0,o.useState)(""),[I,$]=(0,o.useState)(!1),[D,B]=(0,o.useState)(!1),[O,_]=(0,o.useState)(0),[H,V]=(0,o.useState)(0),U=(0,o.useRef)(!1),[W,q]=(0,o.useState)(null),z=(0,o.useRef)(!1),K=(0,o.useRef)(null),[G,J]=(0,o.useState)(null),[Q,Y]=(0,o.useState)(null),Z=(0,o.useMemo)(()=>e.split("\n"),[e]),[X,ee]=(0,o.useState)(null);(0,o.useEffect)(()=>{f.current!==X&&ee(f.current)});let et=s&&!!r,{toolbarRef:en,bumpRef:er,clearToolbar:eo}=(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")}),es=(0,o.useRef)(null),[ea,el]=(0,o.useState)(0),{comments:ei,addComment:ec,updateComment:ed,deleteComment:eu,refresh:eh}=(0,C._)({cwd:r||"",filePath:t}),em=(0,h.C)(Z,t),ep=(0,o.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,o.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,o.useMemo)(()=>(0,m.Np)(Z,P,I,D),[Z,P,I,D]);(0,o.useEffect)(()=>{eg.length>0&&_(0)},[eg.length,P,I,D]);let ex=(0,o.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,o.useEffect)(()=>{if(!c)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"&&(c.current=t.lineIndex+1);return}};return e.addEventListener("scroll",t,{passive:!0}),t(),()=>e.removeEventListener("scroll",t)},[c,ex]),(0,o.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,o.useEffect)(()=>{if(!n)return;let e=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),A(!0),setTimeout(()=>b.current?.focus(),0)),"Escape"===e.key&&(R?(A(!1),F("")):Q?Y(null):G?J(null):en.current?eo():W&&q(null))},t=x.current;if(t)return t.addEventListener("keydown",e),()=>t.removeEventListener("keydown",e)},[n,R,Q,G,W]),(0,o.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,o.useCallback)(()=>{0!==eg.length&&(_(e=>(e+1)%eg.length),V(e=>e+1))},[eg.length]),ey=(0,o.useCallback)(()=>{0!==eg.length&&(_(e=>(e-1+eg.length)%eg.length),V(e=>e+1))},[eg.length]),ew=(0,o.useRef)(a);ew.current=a,(0,o.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),L(null),requestAnimationFrame(()=>L(e)),M.current=setTimeout(()=>L(null),1600)),i?.()};"start"===l?requestAnimationFrame(t):setTimeout(t,150)}}},[a,l,ex.length,eb,i]);let ek=(0,o.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?ey():ev()),"Escape"===e.key&&(A(!1),F(""))},[ev,ey]),eC=(0,o.useCallback)((e,t)=>{et&&(t.stopPropagation(),q({comment:e,x:t.clientX,y:t.clientY}),eo(),J(null),Y(null))},[et,eo]);(0,o.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 o=n.startContainer,s=n.endContainer,a=(o.nodeType===Node.TEXT_NODE?o.parentElement:o)?.closest("[data-line]"),l=(s.nodeType===Node.TEXT_NODE?s.parentElement:s)?.closest("[data-line]");if(!a||!l)return;let i=parseInt(a.getAttribute("data-line")||"0",10),c=parseInt(l.getAttribute("data-line")||"0",10);i&&c&&(z.current=!0,K.current={startLine:i,startOffset:T(a,n.startContainer,n.startOffset),endLine:c,endOffset:T(l,n.endContainer,n.endOffset)})},o=()=>{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",o),()=>{e?.removeEventListener("mousedown",n),document.removeEventListener("mouseup",r),document.removeEventListener("selectionchange",o)}},[et]),(0,o.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!==es.current&&(es.current=null,el(e=>e+1));return}let o=window.getSelection();if(o&&!o.isCollapsed&&o.toString().trim())return;let s=(n=t.target,(r=n.closest?.("[data-line]"))?parseInt(r.getAttribute("data-line")||"0",10):null);s!==es.current&&(es.current=s,requestAnimationFrame(()=>el(e=>e+1)))};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]);let ej=(0,o.useCallback)(()=>{let e=en.current;e&&(J({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),eo())},[eo,en]),eN=(0,o.useCallback)(()=>{let e=en.current;e&&(Y({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),eo())},[eo,en]),eS=(0,o.useCallback)(()=>{let e=en.current;e&&v&&(eo(),(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,eo,en]),eT=(0,o.useCallback)(()=>{let e=en.current;if(!e||!d)return;let t=e.selectedText.trim();eo(),t&&d(t)},[d,eo,en]),eE=(0,o.useCallback)(async e=>{G&&(await ec(G.range.start,G.range.end,e,G.selectedText),J(null))},[G,ec]),eL=(0,o.useCallback)(async(e,n)=>{if(v&&r)try{let o=await (0,j.$3)(r),s=[];for(let e of o)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});s.push({filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot});let a=(0,j.Gw)(s,n);v.sendMessage(a),await (0,j.RP)(r),eh()}catch(e){console.error("Failed to send to AI:",e)}},[v,t,r,eh]),eM=(0,o.useCallback)(e=>{Q&&eL(Q,e)},[Q,eL]),eR=(0,o.useCallback)(e=>{G&&eL(G,e)},[G,eL]),eA=(0,o.useCallback)((e,t,n)=>{let r=Z[e];if(!r)return t;let o=[];if(P&&eg.length>0)for(let t of eg.filter(t=>t.lineIndex===e)){let n=eg[O]?.lineIndex===e&&eg[O]?.startCol===t.startCol;o.push({start:t.startCol,end:t.endCol,cls:n?"hl-cur":"hl-m"})}if(n&&!P&&n.length>=1){let e=n.toLowerCase(),t=r.toLowerCase(),s=0;for(;-1!==(s=t.indexOf(e,s));)o.push({start:s,end:s+n.length,cls:"hl-kw"}),s+=1}if(0===o.length)return t;if(o.sort((e,t)=>e.start-t.start||e.end-t.end),o.length>m.ZR){let e=o.findIndex(e=>"hl-cur"===e.cls),t=o.slice(0,m.ZR);e>=m.ZR&&(t[t.length-1]=o[e]),o=t}let s=[],a=0;for(let e of o){if(e.start<a)continue;e.start>a&&s.push((0,m.ZD)(r.substring(a,e.start)));let t=(0,m.ZD)(r.substring(e.start,e.end));s.push(`<span class="${e.cls}">${t}</span>`),a=e.end}if(a<r.length&&s.push((0,m.ZD)(r.substring(a))),t!==(0,m.ZD)(r)){let e=t;for(let t of o){let n=r.substring(t.start,t.end),o=(0,m.ZD)(n),s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=RegExp(`(?<=>)([^<]*?)(${s})`,""),l=`$1<span class="${t.cls}">${o}</span>`,i=e.replace(a,l);i.length>e.length+200||(e=i)}return e}return s.join("")},[P,eg,O,Z]);return{parentRef:f,containerRef:x,searchInputRef:b,floatingToolbarRef:en,suppressHoverRef:z,savedSelectionRef:K,highlightedLines:em,isMounted:u,cmdHeld:y,flashLine:E,isSearchVisible:R,searchQuery:P,caseSensitive:I,wholeWord:D,currentMatchIndex:O,viewingComment:W,bumpToolbarRef:er,addCommentInput:G,sendToAIInput:Q,aiBridge:v,commentsEnabled:et,comments:ei,updateComment:ed,deleteComment:eu,lines:Z,matches:eg,rowData:ex,virtualizer:eb,commentsByEndLine:ep,linesWithComments:ef,setIsSearchVisible:A,setSearchQuery:F,suppressMatchScrollRef:U,setCaseSensitive:$,setWholeWord:B,setViewingComment:q,setAddCommentInput:J,setSendToAIInput:Y,goToNextMatch:ev,goToPrevMatch:ey,handleSearchKeyDown:ek,handleCommentBubbleClick:eC,handleToolbarAddComment:ej,handleToolbarSendToAI:eN,handleToolbarExplain:eS,handleToolbarSearch:eT,handleCommentSubmit:eE,handleSendToAISubmit:eM,handleCommentSendToAI:eR,getHighlightedLineHtml:eA,inlineBlameLineRef:es,inlineBlameVersion:ea}}({content:e,filePath:t,showSearch:x,cwd:v,enableComments:!G&&I,scrollToLine:G?null:$,scrollToLineAlign:G?"center":D,onScrollToLineComplete:G?void 0:B,visibleLineRef:G?void 0:_,onContentSearch:el}),tp=(0,d.iN)(),tf=(0,o.useRef)(null),tg=(0,o.useRef)(null),tx=(0,o.useRef)({line:0,col:0}),tb=(0,o.useRef)({line:0,col:0}),tv=function({lines:e,enabled:t,onContentChange:n,onEnterInsert:r,onSave:s,getVisibleLineCount:a,scrollToLine:l,onSearchExecute:i,onSearchNext:c,onSearchPrev:d,onSearchClear:u}){let[h,m]=(0,o.useState)("normal"),[p,f]=(0,o.useState)(-1),[g,x]=(0,o.useState)(0),[b,v]=(0,o.useState)(!1),[y,w]=(0,o.useState)(""),[k,C]=(0,o.useState)(""),[j,N]=(0,o.useState)(""),[S,T]=(0,o.useState)(""),E=(0,o.useRef)([]),L=(0,o.useRef)([]),M=(0,o.useRef)([]),R=(0,o.useRef)(null),A=(0,o.useRef)(e);(0,o.useEffect)(()=>{A.current=e}),(0,o.useEffect)(()=>{0!==e.length&&queueMicrotask(()=>f(t=>Math.min(t,e.length-1)))},[e.length]);let P=(0,o.useCallback)((e,t)=>Math.max(0,Math.min(t,Math.max(0,(A.current[e]??"").length-1))),[]),F=(0,o.useRef)(e.length);(0,o.useEffect)(()=>{let t=Math.abs(e.length-F.current);F.current=e.length,t>10&&(queueMicrotask(()=>{f(-1),x(0),v(!1)}),E.current=[],L.current=[],M.current=[])},[e]);let I=(0,o.useCallback)(()=>{R.current&&(clearTimeout(R.current),R.current=null),w("")},[]),$=(0,o.useCallback)(()=>{R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{w(""),R.current=null},500)},[]),D=(0,o.useCallback)((e,t)=>{E.current.push(t),L.current=[],v(!0),n(e.join("\n"))},[n]),B=(0,o.useCallback)((e,t)=>{let n=Math.max(0,Math.min(e,A.current.length-1));f(n),x(P(n,t??0)),l(n,"auto")},[l,P]),O=(0,o.useCallback)(e=>{f(t=>{let n=Math.max(0,Math.min(t+e,A.current.length-1));return l(n,"auto"),x(e=>Math.max(0,Math.min(e,Math.max(0,(A.current[n]??"").length-1)))),n})},[l]),_=(0,o.useCallback)(()=>{let e=A.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 o=Math.min(t,r.length-1);D(r,{lineIndex:t,oldLines:[n],newLines:[],cursorLine:t}),f(o),x(0)},[p,D]),H=(0,o.useCallback)(()=>{let e=A.current,t=Math.min(p,e.length-1);e.length>0&&(M.current=[e[t]])},[p]),V=(0,o.useCallback)(()=>{let e=M.current;if(0===e.length)return;let t=A.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,o.useCallback)(()=>{let e=A.current,t=Math.min(p,e.length-1),n=e[t];if(!n||0===n.length)return;let r=n.substring(1),o=[...e];o[t]=r,D(o,{lineIndex:t,oldLines:[n],newLines:[r],cursorLine:p})},[p,D]),W=(0,o.useCallback)(()=>{let e=E.current;if(0===e.length)return;let t=e.pop(),r=[...A.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),L.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,o.useCallback)(()=>{let e=L.current;if(0===e.length)return;let t=e.pop(),r=[...A.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 o=t.lineIndex+Math.max(0,t.newLines.length-1);f(Math.min(o,r.length-1)),l(Math.min(o,r.length-1),"auto")},[n,l]),z=(0,o.useCallback)(e=>{let t=A.current,n=Math.min(p,t.length-1);if("o"===e||"O"===e){let r="o"===e?n+1:n,o=[...t];o.splice(r,0,""),D(o,{lineIndex:r,oldLines:[],newLines:[""],cursorLine:p}),n=r,f(r)}m("insert"),r(n,g,e)},[p,g,D,r]),K=(0,o.useCallback)(()=>{m("normal"),I()},[I]),G=(0,o.useCallback)(()=>{m("command"),C("")},[]),J=(0,o.useCallback)(()=>{m("normal"),C("")},[]),Q=(0,o.useCallback)(()=>{m("search"),N("")},[]),Y=(0,o.useCallback)(()=>{m("normal"),N("")},[]),Z=(0,o.useCallback)(e=>{let t=e.trim();if("w"===t){s?.(),m("normal"),C("");return}if("q"===t){m("normal"),C("");return}if("wq"===t){s?.(),m("normal"),C("");return}if("noh"===t||"nohlsearch"===t){u?.(),m("normal"),C("");return}let n=parseInt(t,10);if(!isNaN(n)&&n>0){let e=Math.min(n-1,A.current.length-1);f(e),l(e,"center"),m("normal"),C("");return}m("normal"),C("")},[s,u,l]),X=(0,o.useCallback)(e=>{if(!e){m("normal"),N("");return}T(e),i?.(e),m("normal"),N("")},[i]),ee=(0,o.useCallback)(e=>{if(!t)return!1;let n=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;if("insert"===h)return("Escape"===e.key||!!n)&&(K(),!0);if("command"===h)return!e.isComposing&&("Escape"===e.key||n?J():"Enter"===e.key?Z(k):"Backspace"===e.key?0===k.length?J():C(e=>e.slice(0,-1)):1!==e.key.length||e.metaKey||e.ctrlKey||C(t=>t+e.key),!0);if("search"===h)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))),I(),!0):"u"===e.key?(O(-Math.max(1,Math.floor(a()/2))),I(),!0):"r"===e.key&&(q(),I(),!0);let r=e.key,o=y+r;if("g"===o)return w("g"),$(),!0;if("gg"===o)return B(0),I(),!0;if("d"===o)return w("d"),$(),!0;if("dd"===o)return _(),I(),!0;if("y"===o)return w("y"),$(),!0;if("yy"===o)return H(),I(),!0;if(y&&o!==r&&I(),"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,(A.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,(A.current[p]??"").length-1)),!0;if("^"===r){let e=(A.current[p]??"").search(/\S/);return x(e>=0?e:0),!0}return"G"===r?(B(A.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?(Q(),!0):"n"===r?(c?.(),!0):"N"===r?(d?.(),!0):":"===r?(G(),!0):"Escape"!==r&&1===r.length},[t,h,y,k,j,p,K,z,G,J,Q,Y,Z,X,O,B,a,_,H,V,U,W,q,I,$,c,d]);return{state:{mode:h,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,o.useCallback)(()=>{E.current=[],L.current=[]},[])}}({lines:eQ,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=(eQ[e]??"").length;else if("I"===n){let t=(eQ[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,o.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,o.useRef)(null);(0,o.useEffect)(()=>{X&&!G&&null!=eo&&t&&ty.current!==t&&(ty.current=t,tv.setCursorLine(eo-1),null!=es&&tv.setCursorCol(es-1),ea?.())},[X,G,eo,es,t]),(0,o.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,o.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,o.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,o=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),s=0;for(;e=o.nextNode();){if(e===t.startContainer){s+=t.startOffset;break}s+=e.textContent?.length||0}let a=eQ[n-1]??"";tv.setCursorCol(Math.max(0,Math.min(s,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,eQ]),tk=(0,o.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,o.useEffect)(()=>{"command"===tv.state.mode?setTimeout(()=>tf.current?.focus(),0):"search"===tv.state.mode&&setTimeout(()=>tg.current?.focus(),0)},[tv.state.mode]),(0,o.useEffect)(()=>{let e=eT.current;if(!e)return;let t=()=>{(W??U)?.()};return e.addEventListener("mousedown",t),()=>e.removeEventListener("mousedown",t)},[W,U]),(0,o.useEffect)(()=>{eW||eq?(eR.current=!0,U?.()):eM.current||(eR.current=!1)},[eW,eq,U]),(0,o.useLayoutEffect)(()=>{let e=eP.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}"]`),o=n.querySelector(`[data-line="${e.endLine}"]`);if(!r||!o)return;let s=E(r,e.startOffset),a=E(o,e.endOffset);if(s&&a)try{let e=document.createRange();e.setStart(s.node,s.offset),e.setEnd(a.node,a.offset),t?.removeAllRanges(),t?.addRange(e)}catch{}});let tC=(0,o.useCallback)((e,t,n)=>{eR.current||V?.(e,t,n)},[V]),tj=(0,o.useCallback)((e,t)=>{eR.current||H?.(e,t)},[H]),tN=Math.max(4,String(G?eg:eQ.length).length),tS=(0,o.useMemo)(()=>{let e=0;for(let t of eQ){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},[eQ]);(0,o.useEffect)(()=>{if(G){ed.current=e;let t=e.split("\n").length;eb.current=t,ex(t),eu.current=!1,em(!1),ey({show:!1}),eC.current=J}},[G,e,J]),(0,o.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,m.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((_?.current??1)-1,n.length-1)),r=0),t.focus(),P(t,{line:e,offset:r});let o=_?.current??1;ek.current&&(ek.current.scrollTop=(o-1)*20)})},[G]),(0,o.useEffect)(()=>{G&&Z?.({isDirty:eh,isSaving:ep})},[G,eh,ep,Z]);let tT=(0,o.useCallback)(()=>{let e=ew.current;if(!e)return ed.current;let t=[];for(let n of e.childNodes){let e=n.textContent||"";t.push(" "===e?"":e)}return t.join("\n")},[]),tE=(0,o.useCallback)(()=>{ej.current&&clearTimeout(ej.current),ej.current=setTimeout(async()=>{let e=ew.current;if(e&&!eS.current){ed.current=tT();try{let n=await (0,m.kS)(),r=(0,m.sQ)(t),o=document.documentElement.classList.contains("dark"),s=ed.current.split("\n"),a=n.codeToTokens(s.join("\n"),{lang:r,theme:o?"github-dark":"github-light"}).tokens.map(e=>(0,m.b8)(e)),l=A(e);eN.current=!0,e.innerHTML=F(a),eN.current=!1,l&&P(e,l)}catch{}}},300)},[t,tT]);(0,o.useEffect)(()=>{if(G)return()=>{ej.current&&clearTimeout(ej.current)}},[G]);let tL=(0,o.useCallback)(()=>{let e=ew.current;if(!e)return;eu.current||(eu.current=!0,em(!0));let t=e.children.length;t!==eb.current&&(eb.current=t,ex(t))},[]),tM=(0,o.useCallback)(()=>{eN.current||eS.current||(tL(),tE())},[tL,tE]),tR=(0,o.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 o=r.startContainer;for(;o&&o.parentElement!==t;)o=o.parentElement;if(!o||!(o instanceof HTMLElement))return;let s=A(t),a=Array.from(t.children).indexOf(o),l=o.textContent||"",i=s?.offset??l.length,c=l.substring(0,i),d=l.substring(i);o.innerHTML=(0,m.ZD)(c||" ");let u=document.createElement("div");u.setAttribute("style",R),u.innerHTML=(0,m.ZD)(d||" "),o.after(u),P(t,{line:a+1,offset:0}),tL(),tE()}},[tL,tE]),tA=(0,o.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)},[]),tP=(0,o.useCallback)(async(e=!1)=>{if(!v)return;ed.current=tT(),ef(!0);let n=await l.t4.runPromiseExit((0,i.OJ)({cwd:v,path:t,content:ed.current,expectedMtime:e?void 0:eC.current}));if("Failure"===n._tag){console.error("Error saving file:",n.cause),(0,M.oR)(ec("toast.saveFailed"),"error"),ef(!1);return}let r=n.value,o=r.data;if(409===r.status&&o?.conflict){let e=await l.t4.runPromiseExit((0,c.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)(ec("toast.saveFailed"),"error"),ef(!1);return}let s=o?.mtime;s&&(eC.current=s),eu.current=!1,em(!1),ey({show:!1}),(0,M.oR)(ec("toast.savedSuccess"),"success"),Y?.(),ef(!1)},[v,t,tT,Y,ec]),tF=(0,o.useCallback)(async()=>{eh&&!ep&&await tP(!1)},[eh,ep,tP]),tI=(0,o.useCallback)(async()=>{ey({show:!1}),await tP(!0)},[tP]),t$=(0,o.useCallback)(()=>{if(void 0!==ev.diskContent){ed.current=ev.diskContent;let t=ev.diskContent.split("\n").length;eb.current=t,ex(t);let n=ev.diskContent!==e;eu.current=n,em(n);let r=ew.current;r&&(r.innerHTML=F(ev.diskContent.split("\n").map(e=>(0,m.ZD)(e||" "))),tE())}ey({show:!1}),Y?.()},[ev.diskContent,e,Y,tE]),tD=(0,o.useCallback)(()=>{let e=ek.current;return e?Math.floor(e.scrollTop/20)+1:_?.current??1},[_]),tB=(0,o.useCallback)(async()=>{(!eh||await (0,M.lJ)(ec("codeViewer.unsavedConfirm"),{danger:!0,confirmText:ec("codeViewer.discardChanges"),cancelText:ec("codeViewer.continueEditing")}))&&Q?.(tD())},[eh,Q,tD]);(0,o.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,o.useCallback)(()=>{let e=tT();ee?.(e);let t=ew.current,n=t?A(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));Q?.(r)},[tT,ee,tD,Q,tv]);(0,o.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)(ec("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:ec("codeViewer.discardChanges"),cancelText:ec("codeViewer.continueEditing")}).then(e=>{e&&tO()}):tO():tB())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[G,X,tB,tO]);let t_=(0,o.useCallback)(()=>{eu.current||(eu.current=!0,em(!0))},[]);(0,o.useImperativeHandle)(ei,()=>({save:tF,close:tB,markDirty:t_,get isDirty(){return eu.current},get isSaving(){return ep}}),[tF,tB,t_,ep]);let tH=!!(q&&q.length>0),tV=(0,o.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,o.useState)(null),[tq,tz]=(0,o.useState)(null);(0,o.useEffect)(()=>{tW(null),tz(null)},[q]);let tK=(0,o.useCallback)((e,t)=>{tW(e.author);let n=t.currentTarget.getBoundingClientRect();tz({line:e,x:n.right+8,y:n.top})},[]),tG=(0,o.useCallback)(()=>{tW(null),tz(null)},[]),tJ=(0,o.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]),tQ=`${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:ec("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:ec("codeViewer.useDiskVersion")}),(0,r.jsx)("button",{onClick:tI,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:ec("codeViewer.forceOverwrite")})]})]}),!G&&x&&eB&&(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:eL,type:"text",value:eO,onChange:e=>e5(e.target.value),onKeyDown:tt,placeholder:ec("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(!e_),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${e_?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-hover"}`,title:ec("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:ec("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:eY.length>0?`${eV+1}/${eY.length}`:ec("common.noMatch")}),(0,r.jsx)("button",{onClick:te,disabled:0===eY.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ec("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:ec("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:ec("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:tQ},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:tR,onPaste:tA,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 o=t.lineIndex,s=o+1,a=eF[o]||(0,m.ZD)(eQ[o]||""),l=td(o,a,O),i=e1.has(s),c=e0.get(s),d=c?.[0],u=!!(eW&&s>=eW.range.start&&s<=eW.range.end),h=tm>=0?th.current:null,p=!G&&z&&h===s?z[o]??null:null,f=tH?q[o]:void 0,g=tH&&o>0?q[o-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:s,highlightedHtml:l,hasComments:i,firstComment:d,lineCommentsCount:c?.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:tJ,onBlameMouseEnter:tK,onBlameMouseLeave:tG,inlineBlameData:p,onInlineBlameClick:tJ,isCursorLine:X&&!G&&tv.state.cursorLine===o,cursorCol:X&&!G&&tv.state.cursorLine===o?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]})]}),eI&&tp&&(0,a.createPortal)((0,r.jsxs)(r.Fragment,{children:[!G&&(0,r.jsx)(p.fS,{floatingToolbarRef:eM,bumpRef:eA,container:tp,onAddComment:tr,onSendToAI:to,onSearch:el?ta:void 0,onExplain:ez?ts: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?tc: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:eJ}),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,L.fw)(tq.line.time)," \xb7 ",new Date(1e3*tq.line.time).toLocaleString(),(0,r.jsx)("span",{className:"ml-2 text-brand",children:ec("codeViewer.clickToViewDetails")})]})]})]}),tp)]})});function $({content:e,filePath:t,className:n=""}){let s=(0,o.useMemo)(()=>e.split("\n"),[e]),a=(0,h.C)(s,t),l=Math.max(4,String(s.length).length);return(0,r.jsx)("pre",{className:`overflow-auto text-sm font-mono bg-muted p-2 ${n}`,children:s.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,m.ZD)(e||" ")}})]},t))})}},43595:(e,t,n)=>{n.d(t,{U:()=>l});var r=n(48764),o=n(58250),s=n(51536);let a={add:r.L5,notify:o.k,namespace:"skills",failureKey:"skills.addFailed"},l=()=>(0,s.X)(a)},45619:(e,t,n)=>{n.d(t,{xU:()=>E,xZ:()=>T});var r=n(95155),o=n(12115),s=n(79114),a=n(64702),l=n(22576),i=n(19502),c=n(34075),d=n(56978),u=n(17196);function h({lines:e,containerRef:t}){let n=(0,o.useRef)(null),[s,a]=(0,o.useState)({top:0,height:0});if((0,o.useEffect)(()=>{let e=t.current;if(!e)return;let r=()=>{let{scrollTop:t,scrollHeight:r,clientHeight:o}=e,s=n.current?.clientHeight||0;if(r<=o)a({top:0,height:s});else{let e=s/r;a({top:t*e,height:o*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,o=n.current;if(!r||!o)return;let s=o.getBoundingClientRect(),a=(e.clientY-s.top)/s.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:`${s.top}px`,height:`${Math.max(s.height,10)}px`}})]})}var m=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:s,containerEl:a,onContentSearch:l}){let i=(0,x.iN)(),c=(0,b.r)(),d=t&&!!e,{comments:u,addComment:h,updateComment:j,deleteComment:N,refresh:S}=(0,p._)({cwd:e||"",filePath:n}),[T,E]=(0,o.useState)(null),{toolbarRef:L,bumpRef:M,clearToolbar:R}=(0,k.L)({enabled:d,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 o of s)("unchanged"===o.type||"added"===o.type)&&++r>=e&&r<=t&&n.push(o.content);return n.join("\n")}}),[A,P]=(0,o.useState)(null),[F,I]=(0,o.useState)(null),[$,D]=(0,o.useState)(!1);(0,o.useEffect)(()=>{D(!0)},[]);let B=(0,o.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,o.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]),_=(0,o.useCallback)((e,t)=>{t.stopPropagation(),E({comment:e,x:t.clientX,y:t.clientY}),R(),P(null),I(null)},[R]),H=(0,o.useCallback)(()=>{let e=L.current;e&&(P({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),R())},[R,L]),V=(0,o.useCallback)(()=>{let e=L.current;e&&(I({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),R())},[R,L]),U=(0,o.useCallback)(()=>{let e=L.current;e&&c&&(R(),(0,f.Ff)(c.sendMessage,{filePath:n,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},g.A.t("explain.selectionMessage")))},[c,n,R,L]),W=(0,o.useCallback)(()=>{let e=L.current;if(!e||!l)return;let t=e.selectedText.trim();R(),t&&l(t)},[l,R,L]),q=(0,o.useCallback)(async(t,r)=>{if(c&&e)try{let o=await (0,f.$3)(e),s=[];for(let e of o)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});s.push({filePath:n,startLine:t.range.start,endLine:t.range.end,codeContent:t.lineSnapshot});let a=(0,f.Gw)(s,r);c.sendMessage(a),await (0,f.RP)(e),S()}catch(e){console.error("Failed to send to AI:",e)}},[c,n,e,S]),z=(0,o.useCallback)(e=>{F&&q(F,e)},[F,q]),K=(0,o.useCallback)(e=>{A&&q(A,e)},[A,q]),G=(0,o.useCallback)(async e=>{A&&(await h(A.range.start,A.range.end,e,A.selectedText),P(null))},[A,h]),J=$&&i?(0,m.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.fS,{floatingToolbarRef:L,bumpRef:M,container:i,onAddComment:H,onSendToAI:V,onSearch:l?W:void 0,onExplain:c?U:void 0,isChatLoading:c?.isLoading??!1}),A&&(0,r.jsx)(y.t,{x:A.x,y:A.y,range:A.range,filePath:n,lineSnapshot:A.lineSnapshot,container:i,onSubmit:G,onSendToAI:c?K:void 0,onClose:()=>P(null),isChatLoading:c?.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:()=>I(null),isChatLoading:c?.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:d,linesWithComments:B,commentsByEndLine:O,handleCommentBubbleClick:_,addCommentRange:A?.range??null,sendToAIRange:F?.range??null,commentPortal:J}}var j=n(96497);function N(e){return(0,o.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:m=!1,isDeleted:p=!1,cwd:f,enableComments:g=!1,onPreview:x,previewLabel:b,headerLeading:v,onContentSearch:y,targetLine:w,compact:k=!1,symbols:j,onTokenHover:E,onTokenHoverLeave:L,onTokenHoverCancel:M}){let{t:R}=(0,s.Bd)(),A=N(E),P=b??R("common.preview"),F=(0,o.useMemo)(()=>(0,l.X)(e,t),[e,t]),I=(0,o.useRef)(null),$=(0,o.useRef)(null),D=(0,o.useRef)(null),B=(0,o.useRef)(!1),[O,_]=(0,o.useState)(null);(0,o.useEffect)(()=>{D.current!==O&&_(D.current)});let{commentsEnabled:H,linesWithComments:V,commentsByEndLine:U,handleCommentBubbleClick:W,addCommentRange:q,sendToAIRange:z,commentPortal:K}=C({cwd:f,enableComments:g,filePath:n,diffLines:F,containerEl:O,onContentSearch:y});(0,o.useEffect)(()=>{let e=$.current,t=D.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),o=()=>n(t,e);return e.addEventListener("scroll",r),t.addEventListener("scroll",o),()=>{e.removeEventListener("scroll",r),t.removeEventListener("scroll",o)}},[]);let{leftLines:G,rightLines:J}=(0,o.useMemo)(()=>{let e=[],t=[],n=0,r=0;for(let o=0;o<F.length;o++){let s=F[o];if("unchanged"===s.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:s.content,type:"unchanged",originalIdx:o}),t.push({lineNum:r,content:s.content,type:"unchanged",originalIdx:o})}else"removed"===s.type?(n++,e.push({lineNum:n,content:s.content,type:"removed",originalIdx:o})):"added"===s.type&&(r++,t.push({lineNum:r,content:s.content,type:"added",originalIdx:o}))}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]),Q=(0,o.useMemo)(()=>F.map(e=>e.content),[F]),Y=(0,d.C)(Q,n),[Z,X]=(0,o.useState)(()=>new Map);(0,o.useLayoutEffect)(()=>{X(new Map),el.measure()},[G,J]);let ee=(0,o.useMemo)(()=>j??[],[j]),{rows:et,gaps:en}=(0,o.useMemo)(()=>k?(0,i.pU)(G,J,Z,ee):{rows:G.map((e,t)=>({kind:"diff",idx:t})),gaps:[]},[k,G,G,J,Z,ee]),er=(0,o.useCallback)((e,t)=>{let n=en.find(t=>t.id===e);n&&X(r=>{let o=r.get(e)??{topRevealed:0,bottomRevealed:0},s=n.endIdx-n.startIdx+1-o.topRevealed-o.bottomRevealed;if(s<=0)return r;let a=Math.min(i.YO,s),l="up"===t?{...o,topRevealed:o.topRevealed+a}:{...o,bottomRevealed:o.bottomRevealed+a};return new Map(r).set(e,l)})},[en]),eo=(0,o.useCallback)(e=>{for(let t of en)if(e>=t.startIdx&&e<=t.endIdx)return t.id;return null},[en]),es=(0,o.useCallback)(e=>et[e]?.kind==="gap-label"?28:20,[et]),ea=(0,o.useCallback)(e=>{let t=et[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=G[t.idx],r=J[t.idx];return`d:${n?.lineNum??"x"}:${n?.type??"x"}:${r?.lineNum??"x"}:${r?.type??"x"}`},[et,G,J]),el=(0,a.Te)({count:et.length,getScrollElement:()=>I.current,estimateSize:es,getItemKey:ea,overscan:20}),ei=m?"w-1/4":p?"w-3/4":"w-1/2",ec=m?"w-3/4":p?"w-1/4":"w-1/2",ed=(0,o.useMemo)(()=>et.map(e=>{if("diff"!==e.kind)return{type:"unchanged"};let t=G[e.idx],n=J[e.idx];return"removed"===t.type?{type:"removed"}:n?.type==="added"?{type:"added"}:{type:"unchanged"}}),[et,G,J]),eu=el.getTotalSize(),eh=el.getVirtualItems();return(0,o.useEffect)(()=>{if(!w)return;let e=("after"===w.side?J:G).findIndex(e=>e.lineNum===w.line);if(-1===e)return;let t=et.findIndex(t=>"diff"===t.kind&&t.idx===e);if(-1===t){let t=eo(e);if(null!==t){let e=en.find(e=>e.id===t);if(!e)return;let n=e.endIdx-e.startIdx+1;X(e=>{let r=e.get(t)??{topRevealed:0,bottomRevealed:0};if(r.topRevealed+r.bottomRevealed>=n)return e;let o=new Map(e);return o.set(t,{topRevealed:n,bottomRevealed:0}),o})}return}let n=requestAnimationFrame(()=>{el.scrollToIndex(t,{align:"start"})});return()=>cancelAnimationFrame(n)},[w,G,J,et]),(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:`${ei} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:m?"(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,c.oR)(R("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:R("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:I,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,r.jsxs)("div",{className:"flex",style:{height:`${eu}px`},children:[(0,r.jsx)("div",{ref:$,className:`${ei} 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=et[e.index];if("gap-expand"===t.kind||"gap-label"===t.kind){let n="gap-label"===t.kind;return(0,r.jsx)("div",{ref:el.measureElement,"data-index":e.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,es(e.index))}px`,transform:`translateY(${e.start}px)`},className:n?"bg-accent border-y border-border":""},e.key)}let n=G[t.idx];return(0,r.jsxs)("div",{ref:el.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,es(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&&Y[n.originalIdx]||(0,u.ZD)(n.content||" ")}})]},e.key)})})}),(0,r.jsx)("div",{ref:D,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=et[e.index];if("gap-expand"===t.kind)return(0,r.jsx)("button",{ref:el.measureElement,"data-index":e.index,type:"button",onClick:()=>er(t.gapId,t.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,es(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:R("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),"aria-label":R("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),children:(0,r.jsx)("span",{className:"select-none",children:R("diffViewer.gap.more",{count:t.revealCount})})},e.key);if("gap-label"===t.kind)return(0,r.jsxs)("div",{ref:el.measureElement,"data-index":e.index,"data-gap-id":t.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,es(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:R("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),children:S(t.enclosingFn)})]})]},e.key);let n=J[t.idx],o=n?.lineNum||0,s=o>0&&V.has(o),a=U.get(o),l=a?.[0],i=q&&o>=q.start&&o<=q.end,c=z&&o>=z.start&&o<=z.end,d=i||c;return(0,r.jsxs)("div",{ref:el.measureElement,"data-index":e.index,"data-new-line":o||void 0,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,es(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${d?"bg-blue-9/20":s?"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 ${d?"bg-blue-9/30":""}`,style:{width:H?"52px":"40px"},children:[H&&o>0&&s&&l&&(0,r.jsx)("button",{onClick:e=>W(l,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:R("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"})})}),H&&o>0&&!s&&(0,r.jsx)("span",{className:"w-4"}),(0,r.jsx)("span",{className:"flex-1 text-right pr-1",children:o||""})]}),(0,r.jsx)("span",{className:"whitespace-pre pl-2",onMouseOver:E?e=>A(e,o):void 0,onMouseLeave:E?L:void 0,onMouseDown:E?M:void 0,dangerouslySetInnerHTML:{__html:n?.originalIdx>=0&&Y[n.originalIdx]||(0,u.ZD)(n?.content||" ")}})]},e.key)})})})]})}),(0,r.jsx)(h,{lines:ed,containerRef:I})]}),K]})}function E({oldContent:e,newContent:t,filePath:n,cwd:m,enableComments:p=!1,onPreview:f,previewLabel:g,headerLeading:x,onContentSearch:b,compact:v=!1,onTokenHover:y,onTokenHoverLeave:w,onTokenHoverCancel:k}){let{t:j}=(0,s.Bd)(),S=N(y),T=g??j("common.preview"),L=(0,o.useMemo)(()=>(0,l.X)(e,t),[e,t]),M=(0,o.useRef)(null),R=(0,o.useMemo)(()=>L.map(e=>e.content),[L]),A=(0,d.C)(R,n),[P,F]=(0,o.useState)(null);(0,o.useEffect)(()=>{M.current!==P&&F(M.current)});let{commentsEnabled:I,linesWithComments:$,commentsByEndLine:D,handleCommentBubbleClick:B,addCommentRange:O,sendToAIRange:_,commentPortal:H}=C({cwd:m,enableComments:p,filePath:n,diffLines:L,containerEl:P,onContentSearch:b}),[V,U]=(0,o.useState)(()=>new Set);(0,o.useEffect)(()=>{U(new Set)},[e,t,n]);let W=(0,o.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 o=Math.max(0,t-i.aj),s=Math.min(n-1,t+i.aj);for(let e=o;e<=s;e++)r[e]=!0}let o=[],s=0,a=0;for(;a<n;){if(r[a]){o.push({kind:"line",line:e[a],index:a}),a++;continue}let l=a;for(;l<n&&!r[l];)l++;let i=s++;if(t.has(i))for(let t=a;t<l;t++)o.push({kind:"line",line:e[t],index:t});else o.push({kind:"gap",id:i,count:l-a});a=l}return o}(L,V):L.map((e,t)=>({kind:"line",line:e,index:t})),[v,L,V]),q=(0,o.useCallback)(e=>{let t=W[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"}`},[W]),z=(0,a.Te)({count:W.length,getScrollElement:()=>M.current,estimateSize:()=>20,getItemKey:q,overscan:20}),K=(0,o.useMemo)(()=>W.map(e=>"gap"===e.kind?{type:"unchanged"}:{type:e.line.type}),[W]);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:T}),t&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,c.oR)(j("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:j("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:M,className:"flex-1 min-w-0 overflow-auto",children:(0,r.jsx)("div",{style:{height:`${z.getTotalSize()}px`,position:"relative"},children:z.getVirtualItems().map(e=>{let t=W[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 o=j("diffViewer.gap.hidden",{count:t.count});return(0,r.jsx)("div",{style:n,onClick:()=>U(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":o,children:(0,r.jsx)("span",{className:"w-full text-center",children:o})},e.key)}let o=t.line,s="removed"!==o.type?o.newLineNum??0:0,a=s>0&&$.has(s),l=D.get(s),i=l?.[0],c=O&&s>=O.start&&s<=O.end,d=_&&s>=_.start&&s<=_.end;return(0,r.jsxs)("div",{style:n,"data-new-line":s||void 0,className:`flex ${c||d?"bg-blue-9/20":a?"bg-amber-9/10":"removed"===o.type?"bg-red-9/15 dark:bg-red-9/25":"added"===o.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[I&&(0,r.jsx)("span",{className:"w-5 flex-shrink-0 flex items-center justify-center select-none",children:s>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:j("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"!==o.type?o.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"!==o.type?o.newLineNum:""}),(0,r.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===o.type?"text-red-11":"added"===o.type?"text-green-11":"text-foreground-subtle"}`,children:"removed"===o.type?"-":"added"===o.type?"+":" "}),(0,r.jsx)("span",{className:"flex-1 whitespace-pre pl-1",onMouseOver:y?e=>S(e,s):void 0,onMouseLeave:y?w:void 0,onMouseDown:y?k:void 0,dangerouslySetInnerHTML:{__html:A[t.index]||(0,u.ZD)(o.content||" ")}})]},e.key)})})}),(0,r.jsx)(h,{lines:K,containerRef:M})]}),H]})}},46456:(e,t,n)=>{n.d(t,{$:()=>i,BC:()=>c,Tu:()=>u,lb:()=>l,tj:()=>h,vv:()=>d});var r=n(49433),o=n(82680);let s=(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 o.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),a=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`)},catch:n=>new o.uV({message:`${t.method} ${e} failed`,cause:n})}),l=(e,t)=>s(`/api/comments?cwd=${encodeURIComponent(e)}${t?`&filePath=${encodeURIComponent(t)}`:""}`),i=e=>s(`/api/comments?cwd=${encodeURIComponent(e)}&all=true`),c=e=>s("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),d=(e,t,n)=>s("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,id:t,content:n})}),u=(e,t)=>a(`/api/comments?cwd=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`,{method:"DELETE"}),h=e=>a(`/api/comments?cwd=${encodeURIComponent(e)}&all=true`,{method:"DELETE"})},47176:(e,t,n)=>{n.d(t,{l:()=>i});var r=n(95155),o=n(12115),s=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"}){let{t:c}=(0,s.Bd)(),d=(0,o.useMemo)(()=>(function(e){let t=[],n=e.split("\n"),r=!1;for(let e=0;e<n.length;e++){let o=n[e];if(o.trimStart().startsWith("```")){r=!r;continue}if(r)continue;let s=/^(#{1,6})\s+(.+)$/.exec(o);s&&t.push({level:s[1].length,text:s[2].replace(/\s*#+\s*$/,"").replace(/\\([!-\/:-@[-`{-~])/g,"$1"),sourceLine:e+1})}return t})(e),[e]),[u,h]=(0,o.useState)(!1),[m,p]=(0,o.useState)(null),f=(0,o.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,o.useEffect)(()=>{let e=t.current;if(!e||0===d.length)return;let n=()=>{let t=[];for(let n of d){let r=e.querySelector(l(n.sourceLine));if(r){let o=r.getBoundingClientRect().top-e.getBoundingClientRect().top;t.push({line:n.sourceLine,top:o})}}let n=null;for(let e of t)e.top<=60&&(n=e.line);null===n&&t.length>0&&(n=t[0].line),p(n)},r=setTimeout(n,150);return e.addEventListener("scroll",n,{passive:!0}),()=>{clearTimeout(r),e.removeEventListener("scroll",n)}},[d,e,t]),0===d.length)?null:(0,r.jsxs)("div",{className:`border-r border-border flex-shrink-0 flex flex-col transition-[width] duration-200 ${u?"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:[!u&&(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(u?"editor.expandToc":"editor.collapseToc"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u?(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"})})})]}),!u&&(0,r.jsx)("nav",{className:"flex-1 overflow-y-auto py-1",children:d.map((e,t)=>(0,r.jsx)(a.m,{content:e.text,delay:400,children:(0,r.jsx)("button",{onClick:()=>f(e.sourceLine),className:`block w-full text-left text-sm py-1 px-2 truncate transition-colors hover:bg-hover ${m===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:()=>s,oK:()=>C,u:()=>f,xb:()=>c,zs:()=>m});var r=n(12115),o=n(69809);function s(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 c(e,t=l){try{let n=JSON.parse(e);return h(n,0,t)}catch{return e}}let d=(e,t)=>r.createElement("span",{style:{color:e}},t);function u({label:e,labelColor:t,value:n,indent:s,colors:a}){let l=r.useContext(i),[c,m]=r.useState(null),p=c&&c.version===l.version?c.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(),m({version:l.version,collapsed:!p}))},style:{cursor:"pointer"}};if(x&&p&&"string"==typeof n){let s=n.replace(/\\n/g,"\n").split("\n")[0],l=n.replace(/\\n/g,"\n").split("\n").length;return r.createElement("span",b,d(t,e),d(a.punct,": "),d(a.str,s),d(a.fold,` ${o.A.t("toolCall.foldedLines",{count:l})}`))}let v=r.createElement(r.Fragment,null,d(t,e),d(a.punct,": "),h(n,s,a));return x?r.createElement("span",b,v):v}function h(e,t,n){let o=" ".repeat(t);if(null===e)return d(n.bool,"null");if(void 0===e)return d(n.bool,"undefined");if("string"==typeof e){let t=e.replace(/\\n/g,"\n").replace(/\n/g,"\n"+o);return d(n.str,t)}if("number"==typeof e)return d(n.num,String(e));if("boolean"==typeof e)return d(n.bool,String(e));if(Array.isArray(e))return 0===e.length?d(n.punct,"[]"):r.createElement(r.Fragment,null,d(n.punct,"["),"\n",...e.map((s,a)=>r.createElement("span",{key:a},o+" ",r.createElement(u,{label:`[${a}]`,labelColor:n.key,value:s,indent:t+1,colors:n}),a<e.length-1?r.createElement(r.Fragment,null,d(n.punct,","),"\n"):"\n")),o,d(n.punct,"]"));if("object"==typeof e){let s=Object.entries(e);return 0===s.length?d(n.punct,"{}"):r.createElement(r.Fragment,null,d(n.punct,"{"),"\n",...s.map(([e,a],l)=>r.createElement("span",{key:e},o+" ",r.createElement(u,{label:e,labelColor:n.key,value:a,indent:t+1,colors:n}),l<s.length-1?r.createElement(r.Fragment,null,d(n.punct,","),"\n"):"\n")),o,d(n.punct,"}"))}return String(e)}function m(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}},48347:(e,t,n)=>{n.d(t,{H:()=>a,r:()=>l});var r=n(95155),o=n(12115);let s=(0,o.createContext)(null);function a({value:e,children:t}){return(0,r.jsx)(s.Provider,{value:e,children:t})}function l(){return(0,o.useContext)(s)}},48661:(e,t,n)=>{n.d(t,{q:()=>s});var r=n(95155),o=n(79114);function s({value:e,onChange:t,className:n}){let{t:a}=(0,o.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:()=>l,Hy:()=>o,L5:()=>s,hp:()=>a});var r=n(37640);let o=()=>(0,r.zi)("/api/skills"),s=e=>(0,r.zi)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),a=e=>(0,r.zi)(`/api/skills/${encodeURIComponent(e)}`,{method:"DELETE"}),l=e=>(0,r.zi)(`/api/skills/content?id=${encodeURIComponent(e)}`)},50605:(e,t,n)=>{function r(e){return/^~(?=$|[/\\])/.test(e.trim())}function o(e,t){return t&&r(e)?t.replace(/[/\\]+$/,"")+e.trim().slice(1):e}n.d(t,{D:()=>o,P:()=>r})},50860:(e,t,n)=>{n.d(t,{I:()=>l});var r=n(95155),o=n(12115),s=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,c="absPath"in e&&"string"==typeof e.absPath,d=c?void 0:e.cwd,u=c?void 0:e.path,h=c?e.absPath:void 0,[m,p]=(0,o.useState)({kind:"loading"}),f=(0,o.useRef)(0);if((0,o.useEffect)(()=>{let e=++f.current;return p({kind:"loading"}),(async()=>{if(c){if(e!==f.current)return;p({kind:"ready",etag:null,size:0});return}let t=await s.t4.runPromiseExit((0,a.r6)(d,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++}},[c,d,u,h,t]),"loading"===m.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"===m.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"===m.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(m.size/1024/1024)," MB)"]})});if("error"===m.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("div",{className:"text-sm text-red-11",children:m.message})});let g=c?`/api/file?path=${encodeURIComponent(h)}&raw=true`:`/api/files/read?cwd=${encodeURIComponent(d)}&path=${encodeURIComponent(u)}&v=${encodeURIComponent(m.etag)}`;return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("img",{src:g,alt:i??(u||h),className:l})})}},51145:(e,t,n)=>{n.d(t,{K:()=>s});var r=n(49433),o=n(82680);let s=(e,t)=>{let n,s;return n=`/api/files/text?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,s={cache:"no-store"},r.$mh({try:async()=>{let e=await fetch(n,s),t=null;try{t=await e.json()}catch{}return{status:e.status,ok:e.ok,data:t}},catch:e=>new o.uV({message:`GET ${n} failed`,cause:e})})}},51536:(e,t,n)=>{n.d(t,{X:()=>i});var r=n(12115),o=n(79114),s=n(34075),a=n(37640),l=n(86957);function i({add:e,notify:t,namespace:n,failureKey:c}){let{t:d}=(0,o.Bd)();return(0,r.useCallback)(async r=>{let o=await l.t4.runPromiseExit(e(r));"Success"===o._tag?o.value.alreadyExists?(0,s.oR)(d(`${n}.alreadyAdded`),"info"):((0,s.oR)(d(`${n}.added`),"success"),t()):(0,s.oR)((0,a.oh)(o.cause,d(c)),"error")},[e,t,n,c,d])}},52839:(e,t,n)=>{n.d(t,{S:()=>a,q:()=>s});let r=[/(^|\/)__tests__\//,/(^|\/)tests?\//,/\.(test|spec)\.[^/]+$/],o=[/\.(md|mdx)$/i,/(^|\/)docs\//,/(^|\/)README[^/]*$/i,/(^|\/)LICENSE[^/]*$/i,/(^|\/)CHANGELOG[^/]*$/i];function s(e){return r.some(t=>t.test(e))?"test":o.some(t=>t.test(e))?"docs":null}function a(e){if(0===e.length)return null;let t=s(e[0]);return null===t?null:e.every(e=>s(e)===t)?t:null}},54271:(e,t,n)=>{n.d(t,{zB:()=>V,e$:()=>H,vP:()=>D});var r=n(95155),o=n(12115),s=n(79114),a=n(49433),l=n(77725),i=n(62111),c=n(70188),d=n(72312),u=n(64428),h=n(52839),m=n(79237),p=n(67889),f=n(33210),g=n(56058),x=n(32880),b=n(12710),v=n(33024),y=n(32967),w=n(88780),k=n(30133),C=n(48661),j=n(20080),N=n(45619),S=n(47215),T=n(5135),E=n(24602),L=n(9573),M=n(4055);function R(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),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),o=r.split("\n"),s=o.length>n?o.slice(0,n).join("\n"):r,a=s.length>t?s.slice(0,t):s;return o.length>n||s.length>t?`${a.trimEnd()}…`:a}function I(e,t){return t&&(0,m.y)(t,e)||e}function $(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 o=I(e.file_path,t);n.push({key:r.id,toolName:"Edit",subject:`[Edit] ${o}`,legacy:!0,changeClass:(0,h.q)(o),files:[{path:o,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 o=I(e.file_path,t);n.push({key:r.id,toolName:"Write",subject:`[Write] ${o}`,legacy:!0,changeClass:(0,h.q)(o),files:[{path:o,status:"added",old_string:"",new_string:e.content}]})}}return n}function D(e,t,n){var r;let o,s=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=>R(e,t))}});return r=s.length>0?s:$(t,n),o=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}(o.get(e.key));return t?{...e,fullSubject:`[${e.toolName}] ${t}`}:e})}function B(e){let t=!1,n=0,r=0;for(let o of e)(void 0!==o.additions||void 0!==o.deletions)&&(t=!0),n+=o.additions??0,r+=o.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 _(e){let t=new Date(1e3*e),n=new Date,r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),l=`${r}-${o} ${s}:${a}`;return t.getFullYear()===n.getFullYear()?l:`${t.getFullYear()}-${l}`}function H({toolCalls:e,cwd:t,sessionId:n,onClose:u,onContentSearch:h,fullscreen:m,onToggleFullscreen:I}){let{t:V}=(0,s.Bd)(),U=(0,o.useRef)(null),[W,q]=(0,o.useState)(null);(0,o.useEffect)(()=>{q(U.current)},[]);let z=(0,o.useMemo)(()=>e.map(e=>e.id).filter(Boolean),[e]),K=z.join(","),[G,J]=(0,o.useState)(0);(0,o.useEffect)(()=>{J(0)},[K]);let Q=(0,l.Z)(t&&z.length>0?(0,L.se)(t,z,n):a.PyW([]),[t,n,K,G]),Y=(0,o.useMemo)(()=>e.filter(e=>(0,M.h)(e.name)).map(e=>e.id),[e]);(0,o.useEffect)(()=>{if("success"!==Q.status||G>=2)return;let e=new Set(Q.data.map(e=>e.commit.toolId));if(Y.some(t=>!e.has(t))){let e=setTimeout(()=>J(e=>e+1),2e3);return()=>clearTimeout(e)}},[Q,G,Y]);let Z=(0,o.useRef)([]),X="loading"===Q.status&&0===Z.current.length,ee=(0,o.useMemo)(()=>{if("success"===Q.status){let n=D(Q.data,e,t);return n.length>0&&(Z.current=n),n}return"loading"===Q.status&&Z.current.length>0?Z.current:"loading"===Q.status?[]:$(e,t)},[Q,e,t]),[et,en]=(0,o.useState)(!1),[er,eo]=(0,o.useState)(!1),es=(0,o.useMemo)(()=>ee.filter(e=>e.hash),[ee]),ea=(0,o.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})(es),[es]),el=(0,o.useMemo)(()=>er?es:es.slice(ea),[es,er,ea]),ei=(0,o.useMemo)(()=>{if(er||0===ea)return ee;let e=new Set(es.slice(0,ea).map(e=>e.key));return ee.filter(t=>!e.has(t.key))},[ee,es,er,ea]),ec=(0,o.useMemo)(()=>0===el.length||el.length<2&&0===ea?null:{base:el[0].parent??null,head:el[el.length-1].hash},[el,ea]),ed=!!t&&ee.length>=2,eu=null===ec;(0,o.useEffect)(()=>{et&&!ec&&en(!1)},[et,ec]);let eh=(0,l.Z)(et&&t&&ec?(0,L.Tt)(t,ec.base,ec.head):a.PyW(null),[et,t,ec?.base??"",ec?.head??""]),em=(0,o.useMemo)(()=>0===el.length||el.some(e=>!e.declared||0===e.declared.length)?null:new Set(el.flatMap(e=>e.declared)),[el]),ep=(0,o.useMemo)(()=>"success"===eh.status&&eh.data?eh.data.files.map(e=>R(e,em)):[],[eh,em]),ef="success"===eh.status&&eh.data?.truncated===!0,eg=et&&"loading"===eh.status,ex=et&&"error"===eh.status,[eb,ev]=(0,o.useState)(null),[ey,ew]=(0,o.useState)(null),[ek,eC]=(0,o.useState)(new Set),[ej,eN]=(0,o.useState)(()=>window.innerWidth>=768),[eS,eT]=(0,o.useState)("compact"),[eE,eL]=(0,o.useState)("unified"),[eM,eR]=(0,o.useState)(!1),[eA,eP]=(0,o.useState)(!1),[eF,eI]=(0,o.useState)(null),e$=(0,o.useMemo)(()=>ee.find(e=>e.key===eb)??null,[ee,eb]),eD=(0,o.useRef)(null);(0,o.useEffect)(()=>{e$&&(eD.current=e$)},[e$]);let eB=e$??eD.current,eO=(0,o.useMemo)(()=>et?ep:eB?.files??[],[et,ep,eB]),e_=(0,o.useMemo)(()=>(0,w.Do)(eO),[eO]),eH=(0,o.useMemo)(()=>eO.find(e=>e.path===ey)??null,[eO,ey]),eV=(0,o.useMemo)(()=>B(eO),[eO]),eU=(0,o.useCallback)(e=>{ev(e.key),ew(e.files[0]?.path??null),eC(new Set((0,w.Sz)((0,w.Do)(e.files))))},[]);(0,o.useEffect)(()=>{ei.length>0&&null==eb&&eU(ei[0])},[ei,eb,eU]),(0,o.useEffect)(()=>{null==eb||0===ei.length||ei.some(e=>e.key===eb)||ee.some(e=>e.key===eb)&&eU(ei[0])},[ee,ei,eb,eU]),(0,o.useEffect)(()=>{0===eO.length||ey&&eO.some(e=>e.path===ey)||ew(eO[0].path)},[eO,ey]),(0,o.useEffect)(()=>{et&&0!==ep.length&&eC(new Set((0,w.Sz)((0,w.Do)(ep))))},[et,ep]),(0,o.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(eM)return void eR(!1);if(eA)return void eP(!1);if(eF)return void eI(null);(0,i.k)(),u()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u,eM,eA,eF]);let eW=(0,o.useMemo)(()=>ei.reduce((e,t)=>e+t.files.length,0),[ei]),eq=e=>(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:e});return(0,r.jsx)(c.SU,{container:W,children:(0,r.jsxs)("div",{ref:U,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:`${p.o} px-3`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{onClick:u,"aria-label":V("common.close"),title:V("common.close"),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(f.A,{className:"w-4 h-4"})}),I&&(0,r.jsx)("button",{onClick:I,"aria-label":m?V("diffViewer.exitFull"):V("diffViewer.expandFull"),title:m?V("diffViewer.exitFull"):V("diffViewer.expandFull"),"aria-pressed":!0===m,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:m?(0,r.jsx)(g.A,{className:"w-4 h-4"}):(0,r.jsx)(x.A,{className:"w-4 h-4"})}),ed&&(0,r.jsx)("button",{onClick:()=>en(e=>!e),disabled:eu,"aria-pressed":et,title:eu?V("diffViewer.aggregateUnavailable"):et?V("diffViewer.aggregateOff"):V("diffViewer.aggregateOn"),className:`ml-0.5 px-2 py-0.5 text-xs rounded border transition-colors ${eu?"border-border text-foreground-subtle opacity-60 cursor-not-allowed":et?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:V("diffViewer.aggregate")})]}),(0,r.jsx)("div",{className:"w-px h-4 bg-border flex-shrink-0"}),(0,r.jsx)("button",{onClick:()=>eN(e=>!e),"aria-label":V("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors flex-shrink-0 ${ej?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:(0,r.jsx)(b.A,{className:"w-4 h-4"})}),(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground truncate",children:et?V("diffViewer.fileChangesAggregate",{count:eO.length}):V("diffViewer.fileChanges",{count:eW})})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[ej&&!et&&(0,r.jsxs)("div",{className:"w-60 flex-shrink-0 border-r border-border overflow-y-auto",children:[ea>0&&(0,r.jsx)("button",{onClick:()=>eo(e=>!e),"data-tooltip":V("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:er?V("diffViewer.callsBaselineShown",{count:ea}):V("diffViewer.callsBaselineHidden",{count:ea})}),ei.map(e=>{let t;return(0,r.jsxs)("div",{onClick:()=>eU(e),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${eb===e.key?"bg-brand/10":""}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.changeClass&&(0,r.jsx)(d.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:_(e.timestamp)})]}),(0,r.jsx)("div",{className:"text-sm text-foreground whitespace-pre-wrap break-words mt-0.5","data-tooltip":P(e),children:F(e,320,10)}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:V("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:X?eq(V("diffViewer.loadingSnapshots")):0===ee.length?eq(V("diffViewer.noChanges")):et||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:[et?(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"}),V("diffViewer.aggregateSummary",{count:eO.length,calls:el.length})]}),ea>0&&(0,r.jsx)("button",{onClick:()=>eo(e=>!e),"data-tooltip":V("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:er?V("diffViewer.aggregateBaselineIncluded",{count:ea}):V("diffViewer.aggregateBaselineSkipped",{count:ea})}),eV&&(eV.additions>0||eV.deletions>0)&&(0,r.jsx)(O,{additions:eV.additions,deletions:eV.deletions}),ef&&(0,r.jsx)("span",{className:"text-amber-11",children:V("diffViewer.truncated")})]}):eB?(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"}),eB.toolName]}),eB.shortHash&&(0,r.jsx)("span",{className:"font-mono text-brand",children:eB.shortHash}),void 0!==eB.timestamp&&(0,r.jsx)("span",{children:_(eB.timestamp)}),(0,r.jsx)("span",{className:"flex-1 min-w-0 whitespace-pre-wrap break-words","data-tooltip":P(eB),children:F(eB,640,6)}),eB.truncated&&(0,r.jsx)("span",{className:"text-amber-11",children:V("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":V("diffViewer.reconstructedHint"),children:V("diffViewer.reconstructed")})]}):null,(0,r.jsx)("div",{className:"ml-auto flex items-center gap-2",children:!eH?.isImage&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.y,{value:eS,onChange:eT}),(0,r.jsx)(C.q,{value:eE,onChange:eL})]})})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[ej&&(0,r.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:eg?(0,r.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:V("diffViewer.aggregateLoading")}):(0,r.jsx)(w.VO,{files:e_,selectedPath:ey,expandedPaths:ek,onToggle:e=>eC(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{!e.isDirectory&&e.file&&(ew(e.file.path),window.innerWidth<768&&eN(!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":V("diffViewer.externalChange")})}):null}})}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:eH?eH.isImage?(0,r.jsx)(j.K,{filePath:eH.path,oldSrc:t&&eH.oldRev?A(t,eH.oldRev,eH.path):null,newSrc:t&&eH.newRev?A(t,eH.newRev,eH.path):null}):eH.unviewable?(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:V("diffViewer.notViewable")}):"unified"===eE?(0,r.jsx)(N.xU,{oldContent:eH.old_string,newContent:eH.new_string,filePath:eH.path,cwd:t,enableComments:!0,onContentSearch:h,compact:"compact"===eS,onPreview:"deleted"===eH.status?void 0:(0,S.e$)(eH.path)?()=>eR(!0):(0,S.aR)(eH.path)?()=>eP(!0):eH.path.endsWith(".json")?()=>eI({content:eH.new_string,filePath:eH.path}):void 0,previewLabel:eH.path.endsWith(".json")?V("common.readable"):V("common.preview")}):(0,r.jsx)(N.xZ,{oldContent:eH.old_string,newContent:eH.new_string,filePath:eH.path,isNew:"added"===eH.status,isDeleted:"deleted"===eH.status,cwd:t,enableComments:!0,onContentSearch:h,compact:"compact"===eS,onPreview:"deleted"===eH.status?void 0:(0,S.e$)(eH.path)?()=>eR(!0):(0,S.aR)(eH.path)?()=>eP(!0):eH.path.endsWith(".json")?()=>eI({content:eH.new_string,filePath:eH.path}):void 0,previewLabel:eH.path.endsWith(".json")?V("common.readable"):V("common.preview")}):(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:eg?V("diffViewer.aggregateLoading"):ex?V("diffViewer.aggregateFailed"):et&&0===eO.length?V("diffViewer.aggregateEmpty"):V("diffViewer.selectFileToView")})})]})]}):eq(V("diffViewer.selectFileToView"))})]}),eM&&eH&&(0,r.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>eR(!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)(T.M,{content:eH.new_string,filePath:eH.path,cwd:t||"",onClose:()=>eR(!1)})})}),eA&&eH&&(0,r.jsx)(E.N,{filePath:eH.path,content:eH.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:()=>eI(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:()=>eI(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(f.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,S.xb)(eF.content)})})]})})]})})}function V({toolCalls:e,cwd:t,sessionId:n,onClose:o,onContentSearch:s}){return(0,r.jsx)(u.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:o,children:(0,r.jsx)(H,{toolCalls:e,cwd:t,sessionId:n,onClose:o,onContentSearch:s?e=>{o(),s(e)}:void 0})})})}},56045:(e,t,n)=>{n.d(t,{_:()=>l,o:()=>a});var r=n(12115),o=n(69809);let s="json-search-highlight-style";function a(e){let[t,n]=(0,r.useState)(!1),[o,a]=(0,r.useState)(""),[l,i]=(0,r.useState)(!1),[c,d]=(0,r.useState)(0),[u,h]=(0,r.useState)(0),m=(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||!o){d(0),h(0);return}!function(){if(document.getElementById(s))return;let e=document.createElement("style");e.id=s,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?o:o.toLowerCase(),i=l?r:r.toLowerCase(),c=[],u=0;for(;u<i.length;){let e=i.indexOf(a,u);if(-1===e)break;c.push([e,e+a.length]),u=e+1}if(0===c.length){d(0),h(0);return}let m=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),f=0,g=0,x=[],b=null,v=0;for(;(t=m.nextNode())&&g<c.length;){let e=t.textContent?.length||0,n=f,r=f+e;for(;g<c.length;){let[e,o]=c[g];if(e>=r)break;if(!b)if(e>=n)(b=document.createRange()).setStart(t,e-n),v=o;else break;if(v<=r)b.setEnd(t,v-n),x.push(b),b=null,g++;else break}f=r}p.current=x,d(x.length),h(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,o,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(),o=e.current?.parentElement;o&&g(o,r)},[e,g]);(0,r.useEffect)(()=>{queueMicrotask(()=>f())},[f]),(0,r.useEffect)(()=>{x(u)},[u,c,x]),(0,r.useEffect)(()=>{let t=e.current;if(!t||!o)return;let n=new MutationObserver(()=>f());return n.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>n.disconnect()},[e,o,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!==c&&h(e=>(e+1)%c)},[c]),v=(0,r.useCallback)(()=>{0!==c&&h(e=>(e-1+c)%c)},[c]),y=(0,r.useCallback)(()=>{n(!0),setTimeout(()=>m.current?.focus(),0)},[]),w=(0,r.useCallback)(()=>{n(!1),a(""),h(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:o,setQuery:a,caseSensitive:l,setCaseSensitive:i,matchCount:c,currentIndex:u,searchInputRef:m,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:o.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:o.A.t("codeViewer.caseSensitive")},"Aa"),r.createElement("span",{className:"text-xs text-muted-foreground"},e.matchCount>0?`${e.currentIndex+1}/${e.matchCount}`:o.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:o.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:o.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:o.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:()=>s});var r=n(12115),o=n(17196);function s(e,t){let[n,s]=(0,r.useState)(null),[a,l]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=()=>{l(document.documentElement.classList.contains("dark"))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);let i=(0,r.useMemo)(()=>e.join("\n"),[e]),c=`${i}:${t}:${a}`,d=(0,r.useMemo)(()=>n&&n.key===c?n.html:e.map(e=>(0,o.ZD)(e||" ")),[e,c,n]);return(0,r.useEffect)(()=>{if(0===e.length)return;let n=!1;return(async()=>{try{let r=await (0,o.kS)();if(n)return;let l=(0,o.sQ)(t),i=e.join("\n"),d=r.codeToTokens(i,{lang:l,theme:a?"github-dark":"github-light"}),u=[];for(let e=0;e<d.tokens.length;e++)if(u[e]=(0,o.b8)(d.tokens[e]),e%500==0&&e>0&&(await new Promise(e=>setTimeout(e,0)),n))return;s({key:c,html:u})}catch(e){console.error("Line highlight error:",e)}})(),()=>{n=!0}},[i,t,a]),d}},57125:(e,t,n)=>{n.d(t,{$T:()=>m,Aw:()=>p,CX:()=>c,Fx:()=>h,H:()=>a,XY:()=>b,ch:()=>l,eV:()=>g,hG:()=>x,pe:()=>d,yI:()=>u,ys:()=>f});var r=n(95155);n(12115);var o=n(94514),s=n(66088);let a={claude:"Claude",codex:"Codex",deepseek:"DeepSeek",kimi:"Kimi",glm:"GLM",ollama:"Ollama"};function l(e){return!!e&&e in a}let i={claude:0,codex:1,deepseek:2,glm:3,kimi:4,ollama:5},c=Object.keys(i).sort((e,t)=>i[e]-i[t]),d={claude:"text-[#c6532d] dark:text-[#D97757]",codex:"text-emerald-600 dark:text-emerald-400",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"},u="bg-accent font-medium text-foreground",h="focus:border-brand",m="bg-brand text-white hover:bg-brand/90",p="text-rose-600 dark:text-rose-400",f="fixed z-[9999] max-h-[70vh] overflow-y-auto rounded-lg border border-border bg-popover py-2 shadow-lv2";function g({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 x({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 b({label:e,title:t,onClick:n,buttonRef:o,icon:a,labelClassName:l,labelMaxWidth:i="max-w-[160px]",testId:c}){return(0,r.jsxs)("button",{ref:o,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",title:t,"data-testid":c,children:[a,(0,r.jsx)("span",{className:`truncate ${i} ${l??""}`,children:e}),(0,r.jsx)(s.A,{className:"h-3 w-3 flex-shrink-0"})]})}},58250:(e,t,n)=>{n.d(t,{U:()=>s,k:()=>o});let r=(0,n(93964).N)("cockpit-skills"),o=r.notify,s=r.subscribe},60938:(e,t,n)=>{n.d(t,{DZ:()=>i,Ft:()=>h,Nn:()=>v,OJ:()=>g,VK:()=>y,YW:()=>u,__:()=>b,dt:()=>x,eA:()=>f,eE:()=>m,gZ:()=>c,mP:()=>l,nM:()=>w,r6:()=>p,r9:()=>d});var r=n(49433),o=n(82680);let s=(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 o.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 o.uV({message:`POST ${e} failed`,cause:t})}),l=e=>s(`/api/files/init?cwd=${encodeURIComponent(e)}`),i=e=>s(`/api/files/index?cwd=${encodeURIComponent(e)}`),c=(e,t)=>s(`/api/files/readdir?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`),d=e=>s(`/api/files/recent?cwd=${encodeURIComponent(e)}`),u=(e,t,n)=>a("/api/files/recent",{cwd:e,file:t,...n??{}}),h=(e,t)=>a("/api/files/expanded",{cwd:e,paths:t}),m=(e,t)=>s(`/api/files/blame?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`).pipe(r.h9N(e=>r.PyW({error:e.message}))),p=(e,t)=>{let n,s;return n=`/api/files/stat?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,s={cache:"no-store"},r.$mh({try:async()=>{let e=await fetch(n,s),t=null;try{t=await e.json()}catch{}return{status:e.status,ok:e.ok,data:t}},catch:e=>new o.uV({message:`GET ${n} failed`,cause:e})})},f=e=>s(`/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 o.uV({message:"POST /api/files/save failed",cause:e})}),x=()=>s("/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 o.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 o.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 o.uV({message:"POST /api/files/delete failed",cause:e})}),w=e=>s(`/api/file?path=${encodeURIComponent(e)}`)},62111:(e,t,n)=>{n.d(t,{E:()=>s,k:()=>o});var r=n(12115);function o(){"u">typeof document&&document.activeElement instanceof HTMLElement&&document.activeElement.blur()}function s(e,t=!0){(0,r.useEffect)(()=>{if(!t)return;let n=t=>{"Escape"===t.key&&(o(),e())};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,t])}},63040:(e,t,n)=>{n.d(t,{m3:()=>a,mi:()=>o,ot:()=>s});var r=n(37640);let o=()=>(0,r.zi)("/api/html-apps"),s=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:()=>h,ZL:()=>d,a9:()=>u});var r=n(95155),o=n(12115),s=n(47650);let a=()=>()=>{},l=()=>document.body,i=()=>null,c=(0,o.createContext)(null);function d({children:e}){let t=(0,o.useContext)(c),n=(0,o.useSyncExternalStore)(a,l,i),r=t??n;return r?(0,s.createPortal)(e,r):null}function u({children:e}){let[t,n]=(0,o.useState)(null);return(0,r.jsxs)("div",{className:"relative w-full h-full",style:{transform:"translateZ(0)"},children:[(0,r.jsx)(c.Provider,{value:t,children:e}),(0,r.jsx)("div",{ref:n,className:"absolute inset-0 pointer-events-none [&>*]:pointer-events-auto"})]})}function h(){return(0,o.useContext)(c)}},65153:(e,t,n)=>{n.d(t,{u:()=>i});var r=n(12115),o=n(2111),s=n(19095),a=n(14594),l=n(98245);function i(e,t,n,i,c){let d=(0,r.useRef)(null),u=(0,r.useRef)(0),h=(0,r.useRef)(0),m=(0,r.useRef)(!1),p=(0,r.useRef)(!1),f=(0,r.useRef)(!1),g=(0,r.useRef)(void 0),x=()=>{let e=`live-asst-${++u.current}`;return d.current=e,t(t=>[...t,{id:e,role:"assistant",content:"",isStreaming:!0}]),e},b=e=>{if((0,a.Nn)(e))return;let n=e=>{c?.onLiveOutputTokens?.({outputTokens:Math.max(0,Math.round(e))})},r=e=>{!m.current&&"string"==typeof e&&e&&(h.current+=(0,s.r)(e),n(h.current))};if("system"===e.type&&"init"===e.subtype){let e=p.current;f.current=!0,e||(h.current=0,m.current=!1,c?.onLiveOutputTokens?.(null),c?.onRunStartedAt?.(Date.now())),x();return}if("usage_update"===e.type){"number"==typeof e.output_tokens&&Number.isFinite(e.output_tokens)&&(m.current=!0,h.current=Math.max(h.current,Math.round(e.output_tokens)),n(h.current));return}if("stream_event"===e.type){let t=e.event;t?.type==="content_block_delta"&&t.delta?.type==="text_delta"&&r(t.delta.text)}if("system"===e.type&&"background_tasks_changed"===e.subtype){let t=e.tasks??[];c?.onBackgroundTasks?.(t.filter(e=>!e.ambient).map(e=>({task_id:e.task_id,description:e.description})));return}if((0,a.A7)(e)&&(c?.taskStore?.applyEvent(e),t(t=>(0,a.FM)(t,e,{engine:i,assistantId:d.current??""})),"task_notification"!==e.subtype))return;if("system"===e.type&&"task_notification"===e.subtype){if(!f.current){let n=`live-tasknotif-${e.task_id||++u.current}`,r=`<task-notification>
|
|
727
|
+
`;function s(e){return/^([/\\]|[A-Za-z]:)/.test(e)}function a(e){return s(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 c(e,t){return a(e)||!!t}let d="/apps/local/",u="/apps/builtin/";function h(e,t){let n=e.trim();return d+m(a(n)?n:l(t??"",n)).replace(/\\/g,"/").split("/").map(encodeURIComponent).join("/").replace(/^\//,"")}function m(e){let t=/^[A-Za-z]:/.exec(e)?.[0]??"",n=t?e.slice(t.length):e,r=/^[/\\]/.test(n),o=[];for(let e of n.split(/[/\\]/))if(e&&"."!==e){if(".."===e){o.length&&".."!==o[o.length-1]?o.pop():r||t||o.push("..");continue}o.push(e)}return t+(r||t?"/":"")+o.join("/")}let p=/^([a-z][a-z0-9+.-]*:|\/\/|\/)/i;function f(e,t,n){let r=e.trim();if(!r||p.test(r)||!c(t,n))return e;let o=s(t)?t:l(n,t),a=r.search(/[?#]/),i=a<0?r:r.slice(0,a),d=a<0?"":r.slice(a);if(!i)return e;let u=i;try{u=decodeURIComponent(i)}catch{}return h(m(l(o,u)))+d}let g=[{chip:"*.md",exts:["md"]},{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"]}],x=RegExp(`\\.(${g.flatMap(e=>e.exts).join("|")})$`,"i"),b=g.map(e=>e.chip);function v(e){return x.test(e.trim())}function y(e,t){let n=e.trim();return u+"file-viewer/index.html?file="+encodeURIComponent(m(a(n)?n:l(t??"",n)).replace(/\\/g,"/"))}function w(e,t){try{let n=new URL(e,t);if(!n.pathname.startsWith(u)&&!n.pathname.startsWith(d))return e;return"localhost"===n.hostname&&(n.hostname="127.0.0.1"),n.toString()}catch{return e}}function k(e,t){let n=e=>JSON.stringify(e).replace(/</g,"\\u003c"),r="<script>"+o.replaceAll("__CWD__",n(t.cwd)).replaceAll("__WS_URL__",n(t.wsUrl??""))+"<\/script>",s=e.match(/<head[^>]*>/i);if(s&&void 0!==s.index){let t=s.index+s[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),o=n(12115),s=n(79114);function a({x:e,y:t,comment:n,container:l,onClose:i,onUpdateComment:c,onDeleteComment:d}){let{t:u}=(0,s.Bd)(),[h,m]=(0,o.useState)(!1),[p,f]=(0,o.useState)(n.content),g=(0,o.useRef)(null),[x,b]=(0,o.useState)({x:0,y:0});(0,o.useEffect)(()=>{if(g.current&&l){let n=l.getBoundingClientRect(),r=g.current.getBoundingClientRect(),o=e-n.left,s=t-n.top;o+r.width>n.width-16&&(o=n.width-r.width-16),o<16&&(o=16),s+r.height>n.height-16&&(s=s-r.height-8),s<16&&(s=16),queueMicrotask(()=>b({x:o,y:s}))}},[e,t,l]),(0,o.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 c(n.id,p.trim()),m(!1))},y=async()=>{await d(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:h?(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&&(m(!1),f(n.content))}}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{onClick:()=>{m(!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:()=>m(!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:()=>s});var r=n(49433),o=n(82680);let s=(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 o.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),a=(e,t)=>s(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:()=>I,XO:()=>D});var r=n(95155),o=n(12115),s=n(79114),a=n(47650),l=n(86957),i=n(60938),c=n(51145),d=n(70188),u=n(7320),h=n(56978),m=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,s.Bd)(),a=(0,o.useRef)(null),l=(0,o.useRef)(null),i=(0,x.F2)(),c=(0,o.useRef)(!1),d=(0,o.useRef)(!1),u=(0,o.useRef)(null),h=(0,o.useRef)(null),m=(0,o.useRef)(null),p=(0,o.useRef)(e);(0,o.useEffect)(()=>{p.current=e},[e]);let f=(0,o.useRef)(t);(0,o.useEffect)(()=>{f.current=t},[t]);let b=(0,o.useCallback)(()=>{let e,t=l.current,n=a.current;if(!t||!n)return;let r=n.getBoundingClientRect(),o=t.getBoundingClientRect(),s=i?.getBoundingClientRect(),c=s?.left??0,d=s?.top??0,u=s?.width??window.innerWidth,h=s?.height??window.innerHeight,m=r.left-c;m+o.width>u-8&&(m=u-o.width-8),m<8&&(m=8);let p=r.top-d,f=r.bottom-d;(e=p-o.height-4<0?f+4:p-o.height-4)+o.height>h-8&&(e=h-o.height-8),t.style.left=`${m}px`,t.style.top=`${e}px`},[i]),y=(0,o.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),h.current&&(clearTimeout(h.current),h.current=null),c.current=!1,d.current=!1,l.current&&(l.current.style.display="none"),m.current&&(document.removeEventListener("mousedown",m.current.down),document.removeEventListener("mouseup",m.current.up),m.current=null)},[]),w=(0,o.useCallback)(()=>{let e=l.current;if(!e||c.current)return;c.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},o=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",o),m.current={down:r,up:o}},[b,y]),k=(0,o.useCallback)(()=>{if(u.current&&clearTimeout(u.current),h.current&&(clearTimeout(h.current),h.current=null),c.current)return;let e=window.getSelection();(!e||e.isCollapsed)&&(u.current=setTimeout(w,500))},[w]),C=(0,o.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),c.current&&(h.current=setTimeout(()=>{d.current||y()},200))},[y]),j=(0,o.useCallback)(()=>{d.current=!0,h.current&&(clearTimeout(h.current),h.current=null)},[]),N=(0,o.useCallback)(()=>{d.current=!1,y()},[y]),S=(0,o.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,o.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 o=Math.floor(r/60);if(o<24)return t("common.hoursAgo",{count:o});let s=Math.floor(o/24);if(s<30)return t("common.daysAgo",{count:s});let a=Math.floor(s/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,o.memo)(function({virtualKey:e,lineNum:t,highlightedHtml:n,hasComments:a,firstComment:l,lineCommentsCount:i,isInRange:c,showLineNumbers:d,lineNumChars:u,commentsEnabled:h,virtualItemSize:m,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:L,onInlineBlameClick:M,isCursorLine:R,cursorCol:A}){let{t:P}=(0,s.Bd)(),F=(0,o.useMemo)(()=>R&&null!=A?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,A):n,[n,R,A]),I=(0,o.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]),D=(0,o.useCallback)(e=>{if(!x)return;let n=(0,b.A)(e,e.currentTarget);n&&x(t,n.column,n.rect)},[t,x]),$=(0,o.useCallback)(()=>{k&&S&&S(k)},[k,S]),B=(0,o.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:`${m}px`,transform:`translateY(${p}px)`,backgroundColor:N&&j?j.bg:void 0},className:`flex ${w===t?"flash-line":""} ${R?"vi-cursor-line":""} ${c?"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:B,onMouseLeave:E,onClick:$,title:P("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})]}),d&&(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 ${c?"bg-blue-9/30 text-blue-11":"bg-card/50 text-foreground-subtle"}`,children:[h&&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:P("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"})})}),h&&!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:I,onMouseOver:D,onMouseLeave:y,"data-code-content":!0,children:[(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:F}}),L&&(0,r.jsx)(v,{blame:L,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,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=0;for(;(r=o.nextNode())&&r!==t;)s+=r.textContent.length;return s+n}function E(e,t){let n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=t,s=null;for(;n=r.nextNode();){s=n;let e=n.textContent.length;if(o<=e)return{node:n,offset:o};o-=e}return s?{node:s,offset:s.textContent.length}:null}var L=n(82292),M=n(34075);let R="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function A(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 o=Array.from(e.children).indexOf(r);if(o<0)return null;let s=document.createRange();return s.selectNodeContents(r),s.setEnd(n.startContainer,n.startOffset),{line:o,offset:s.toString().length}}function P(e,t){let n,r=e.children[t.line];if(!r)return;let o=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),s=t.offset;for(;n=o.nextNode();){let e=n.textContent?.length||0;if(s<=e){let e=window.getSelection(),t=document.createRange();t.setStart(n,s),t.collapse(!0),e?.removeAllRanges(),e?.addRange(t);return}s-=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="${R}">${e}</div>`).join("")}let I=(0,o.forwardRef)(function({content:e,filePath:t,showLineNumbers:n=!0,showSearch:x=!0,className:b="",cwd:v,enableComments:I=!1,scrollToLine:D=null,scrollToLineAlign:$="center",onScrollToLineComplete:B,highlightKeyword:_=null,visibleLineRef:O,onCmdClick:H,onTokenHover:V,onTokenHoverLeave:U,onTokenHoverCancel:W,blameLines:q,inlineBlameLines:z,onSelectCommit:K,editable:G=!1,initialMtime:J,onEditorClose:Q,onSaved:Y,onEditorStateChange:Z,viMode:X=!1,onContentMutate:ee,onEnterInsertMode:et,onViSave:en,viStateRef:er,initialCursorLine:eo,initialCursorCol:es,onInitialCursorSet:ea,onContentSearch:el},ei){let{t:ec}=(0,s.Bd)(),ed=(0,o.useRef)(e),eu=(0,o.useRef)(!1),[eh,em]=(0,o.useState)(!1),[ep,ef]=(0,o.useState)(!1),[eg,ex]=(0,o.useState)(()=>e.split("\n").length),eb=(0,o.useRef)(e.split("\n").length),[ev,ey]=(0,o.useState)({show:!1}),ew=(0,o.useRef)(null),ek=(0,o.useRef)(null),eC=(0,o.useRef)(J),ej=(0,o.useRef)(null),eN=(0,o.useRef)(!1),eS=(0,o.useRef)(!1),{parentRef:eT,containerRef:eE,searchInputRef:eL,floatingToolbarRef:eM,suppressHoverRef:eR,bumpToolbarRef:eA,savedSelectionRef:eP,highlightedLines:eF,isMounted:eI,cmdHeld:eD,flashLine:e$,isSearchVisible:eB,searchQuery:e_,caseSensitive:eO,wholeWord:eH,currentMatchIndex:eV,viewingComment:eU,addCommentInput:eW,sendToAIInput:eq,aiBridge:ez,commentsEnabled:eK,updateComment:eG,deleteComment:eJ,lines:eQ,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:to,handleToolbarExplain:ts,handleToolbarSearch:ta,handleCommentSubmit:tl,handleSendToAISubmit:ti,handleCommentSendToAI:tc,getHighlightedLineHtml:td,suppressMatchScrollRef:tu,inlineBlameLineRef:th,inlineBlameVersion:tm}=function({content:e,filePath:t,showSearch:n=!0,cwd:r,enableComments:s=!1,scrollToLine:a=null,scrollToLineAlign:l="center",onScrollToLineComplete:i,visibleLineRef:c,onContentSearch:d}){let[u,p]=(0,o.useState)(!1),f=(0,o.useRef)(null),x=(0,o.useRef)(null),b=(0,o.useRef)(null),v=(0,N.r)();(0,o.useEffect)(()=>{p(!0)},[]);let[y,w]=(0,o.useState)(!1),[E,L]=(0,o.useState)(null),M=(0,o.useRef)(null),[R,A]=(0,o.useState)(!1),[P,F]=(0,o.useState)(""),[I,D]=(0,o.useState)(!1),[$,B]=(0,o.useState)(!1),[_,O]=(0,o.useState)(0),[H,V]=(0,o.useState)(0),U=(0,o.useRef)(!1),[W,q]=(0,o.useState)(null),z=(0,o.useRef)(!1),K=(0,o.useRef)(null),[G,J]=(0,o.useState)(null),[Q,Y]=(0,o.useState)(null),Z=(0,o.useMemo)(()=>e.split("\n"),[e]),[X,ee]=(0,o.useState)(null);(0,o.useEffect)(()=>{f.current!==X&&ee(f.current)});let et=s&&!!r,{toolbarRef:en,bumpRef:er,clearToolbar:eo}=(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")}),es=(0,o.useRef)(null),[ea,el]=(0,o.useState)(0),{comments:ei,addComment:ec,updateComment:ed,deleteComment:eu,refresh:eh}=(0,C._)({cwd:r||"",filePath:t}),em=(0,h.C)(Z,t),ep=(0,o.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,o.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,o.useMemo)(()=>(0,m.Np)(Z,P,I,$),[Z,P,I,$]);(0,o.useEffect)(()=>{eg.length>0&&O(0)},[eg.length,P,I,$]);let ex=(0,o.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,o.useEffect)(()=>{if(!c)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"&&(c.current=t.lineIndex+1);return}};return e.addEventListener("scroll",t,{passive:!0}),t(),()=>e.removeEventListener("scroll",t)},[c,ex]),(0,o.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,o.useEffect)(()=>{if(!n)return;let e=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),A(!0),setTimeout(()=>b.current?.focus(),0)),"Escape"===e.key&&(R?(A(!1),F("")):Q?Y(null):G?J(null):en.current?eo():W&&q(null))},t=x.current;if(t)return t.addEventListener("keydown",e),()=>t.removeEventListener("keydown",e)},[n,R,Q,G,W]),(0,o.useEffect)(()=>{if(U.current){U.current=!1;return}if(eg.length>0&&_>=0&&_<eg.length){let e=eg[_],t=ex.findIndex(t=>"code"===t.type&&t.lineIndex===e.lineIndex);t>=0&&eb.scrollToIndex(t,{align:"center"})}},[_,eg,eb,ex,H]);let ev=(0,o.useCallback)(()=>{0!==eg.length&&(O(e=>(e+1)%eg.length),V(e=>e+1))},[eg.length]),ey=(0,o.useCallback)(()=>{0!==eg.length&&(O(e=>(e-1+eg.length)%eg.length),V(e=>e+1))},[eg.length]),ew=(0,o.useRef)(a);ew.current=a,(0,o.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),L(null),requestAnimationFrame(()=>L(e)),M.current=setTimeout(()=>L(null),1600)),i?.()};"start"===l?requestAnimationFrame(t):setTimeout(t,150)}}},[a,l,ex.length,eb,i]);let ek=(0,o.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?ey():ev()),"Escape"===e.key&&(A(!1),F(""))},[ev,ey]),eC=(0,o.useCallback)((e,t)=>{et&&(t.stopPropagation(),q({comment:e,x:t.clientX,y:t.clientY}),eo(),J(null),Y(null))},[et,eo]);(0,o.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 o=n.startContainer,s=n.endContainer,a=(o.nodeType===Node.TEXT_NODE?o.parentElement:o)?.closest("[data-line]"),l=(s.nodeType===Node.TEXT_NODE?s.parentElement:s)?.closest("[data-line]");if(!a||!l)return;let i=parseInt(a.getAttribute("data-line")||"0",10),c=parseInt(l.getAttribute("data-line")||"0",10);i&&c&&(z.current=!0,K.current={startLine:i,startOffset:T(a,n.startContainer,n.startOffset),endLine:c,endOffset:T(l,n.endContainer,n.endOffset)})},o=()=>{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",o),()=>{e?.removeEventListener("mousedown",n),document.removeEventListener("mouseup",r),document.removeEventListener("selectionchange",o)}},[et]),(0,o.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!==es.current&&(es.current=null,el(e=>e+1));return}let o=window.getSelection();if(o&&!o.isCollapsed&&o.toString().trim())return;let s=(n=t.target,(r=n.closest?.("[data-line]"))?parseInt(r.getAttribute("data-line")||"0",10):null);s!==es.current&&(es.current=s,requestAnimationFrame(()=>el(e=>e+1)))};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]);let ej=(0,o.useCallback)(()=>{let e=en.current;e&&(J({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),eo())},[eo,en]),eN=(0,o.useCallback)(()=>{let e=en.current;e&&(Y({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),eo())},[eo,en]),eS=(0,o.useCallback)(()=>{let e=en.current;e&&v&&(eo(),(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,eo,en]),eT=(0,o.useCallback)(()=>{let e=en.current;if(!e||!d)return;let t=e.selectedText.trim();eo(),t&&d(t)},[d,eo,en]),eE=(0,o.useCallback)(async e=>{G&&(await ec(G.range.start,G.range.end,e,G.selectedText),J(null))},[G,ec]),eL=(0,o.useCallback)(async(e,n)=>{if(v&&r)try{let o=await (0,j.$3)(r),s=[];for(let e of o)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});s.push({filePath:t,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot});let a=(0,j.Gw)(s,n);v.sendMessage(a),await (0,j.RP)(r),eh()}catch(e){console.error("Failed to send to AI:",e)}},[v,t,r,eh]),eM=(0,o.useCallback)(e=>{Q&&eL(Q,e)},[Q,eL]),eR=(0,o.useCallback)(e=>{G&&eL(G,e)},[G,eL]),eA=(0,o.useCallback)((e,t,n)=>{let r=Z[e];if(!r)return t;let o=[];if(P&&eg.length>0)for(let t of eg.filter(t=>t.lineIndex===e)){let n=eg[_]?.lineIndex===e&&eg[_]?.startCol===t.startCol;o.push({start:t.startCol,end:t.endCol,cls:n?"hl-cur":"hl-m"})}if(n&&!P&&n.length>=1){let e=n.toLowerCase(),t=r.toLowerCase(),s=0;for(;-1!==(s=t.indexOf(e,s));)o.push({start:s,end:s+n.length,cls:"hl-kw"}),s+=1}if(0===o.length)return t;if(o.sort((e,t)=>e.start-t.start||e.end-t.end),o.length>m.ZR){let e=o.findIndex(e=>"hl-cur"===e.cls),t=o.slice(0,m.ZR);e>=m.ZR&&(t[t.length-1]=o[e]),o=t}let s=[],a=0;for(let e of o){if(e.start<a)continue;e.start>a&&s.push((0,m.ZD)(r.substring(a,e.start)));let t=(0,m.ZD)(r.substring(e.start,e.end));s.push(`<span class="${e.cls}">${t}</span>`),a=e.end}if(a<r.length&&s.push((0,m.ZD)(r.substring(a))),t!==(0,m.ZD)(r)){let e=t;for(let t of o){let n=r.substring(t.start,t.end),o=(0,m.ZD)(n),s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=RegExp(`(?<=>)([^<]*?)(${s})`,""),l=`$1<span class="${t.cls}">${o}</span>`,i=e.replace(a,l);i.length>e.length+200||(e=i)}return e}return s.join("")},[P,eg,_,Z]);return{parentRef:f,containerRef:x,searchInputRef:b,floatingToolbarRef:en,suppressHoverRef:z,savedSelectionRef:K,highlightedLines:em,isMounted:u,cmdHeld:y,flashLine:E,isSearchVisible:R,searchQuery:P,caseSensitive:I,wholeWord:$,currentMatchIndex:_,viewingComment:W,bumpToolbarRef:er,addCommentInput:G,sendToAIInput:Q,aiBridge:v,commentsEnabled:et,comments:ei,updateComment:ed,deleteComment:eu,lines:Z,matches:eg,rowData:ex,virtualizer:eb,commentsByEndLine:ep,linesWithComments:ef,setIsSearchVisible:A,setSearchQuery:F,suppressMatchScrollRef:U,setCaseSensitive:D,setWholeWord:B,setViewingComment:q,setAddCommentInput:J,setSendToAIInput:Y,goToNextMatch:ev,goToPrevMatch:ey,handleSearchKeyDown:ek,handleCommentBubbleClick:eC,handleToolbarAddComment:ej,handleToolbarSendToAI:eN,handleToolbarExplain:eS,handleToolbarSearch:eT,handleCommentSubmit:eE,handleSendToAISubmit:eM,handleCommentSendToAI:eR,getHighlightedLineHtml:eA,inlineBlameLineRef:es,inlineBlameVersion:ea}}({content:e,filePath:t,showSearch:x,cwd:v,enableComments:!G&&I,scrollToLine:G?null:D,scrollToLineAlign:G?"center":$,onScrollToLineComplete:G?void 0:B,visibleLineRef:G?void 0:O,onContentSearch:el}),tp=(0,d.iN)(),tf=(0,o.useRef)(null),tg=(0,o.useRef)(null),tx=(0,o.useRef)({line:0,col:0}),tb=(0,o.useRef)({line:0,col:0}),tv=function({lines:e,enabled:t,onContentChange:n,onEnterInsert:r,onSave:s,getVisibleLineCount:a,scrollToLine:l,onSearchExecute:i,onSearchNext:c,onSearchPrev:d,onSearchClear:u}){let[h,m]=(0,o.useState)("normal"),[p,f]=(0,o.useState)(-1),[g,x]=(0,o.useState)(0),[b,v]=(0,o.useState)(!1),[y,w]=(0,o.useState)(""),[k,C]=(0,o.useState)(""),[j,N]=(0,o.useState)(""),[S,T]=(0,o.useState)(""),E=(0,o.useRef)([]),L=(0,o.useRef)([]),M=(0,o.useRef)([]),R=(0,o.useRef)(null),A=(0,o.useRef)(e);(0,o.useEffect)(()=>{A.current=e}),(0,o.useEffect)(()=>{0!==e.length&&queueMicrotask(()=>f(t=>Math.min(t,e.length-1)))},[e.length]);let P=(0,o.useCallback)((e,t)=>Math.max(0,Math.min(t,Math.max(0,(A.current[e]??"").length-1))),[]),F=(0,o.useRef)(e.length);(0,o.useEffect)(()=>{let t=Math.abs(e.length-F.current);F.current=e.length,t>10&&(queueMicrotask(()=>{f(-1),x(0),v(!1)}),E.current=[],L.current=[],M.current=[])},[e]);let I=(0,o.useCallback)(()=>{R.current&&(clearTimeout(R.current),R.current=null),w("")},[]),D=(0,o.useCallback)(()=>{R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{w(""),R.current=null},500)},[]),$=(0,o.useCallback)((e,t)=>{E.current.push(t),L.current=[],v(!0),n(e.join("\n"))},[n]),B=(0,o.useCallback)((e,t)=>{let n=Math.max(0,Math.min(e,A.current.length-1));f(n),x(P(n,t??0)),l(n,"auto")},[l,P]),_=(0,o.useCallback)(e=>{f(t=>{let n=Math.max(0,Math.min(t+e,A.current.length-1));return l(n,"auto"),x(e=>Math.max(0,Math.min(e,Math.max(0,(A.current[n]??"").length-1)))),n})},[l]),O=(0,o.useCallback)(()=>{let e=A.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 o=Math.min(t,r.length-1);$(r,{lineIndex:t,oldLines:[n],newLines:[],cursorLine:t}),f(o),x(0)},[p,$]),H=(0,o.useCallback)(()=>{let e=A.current,t=Math.min(p,e.length-1);e.length>0&&(M.current=[e[t]])},[p]),V=(0,o.useCallback)(()=>{let e=M.current;if(0===e.length)return;let t=A.current,n=Math.min(p,t.length-1)+1,r=[...t];r.splice(n,0,...e),$(r,{lineIndex:n,oldLines:[],newLines:[...e],cursorLine:p}),f(n),x(0),l(n,"auto")},[p,$,l]),U=(0,o.useCallback)(()=>{let e=A.current,t=Math.min(p,e.length-1),n=e[t];if(!n||0===n.length)return;let r=n.substring(1),o=[...e];o[t]=r,$(o,{lineIndex:t,oldLines:[n],newLines:[r],cursorLine:p})},[p,$]),W=(0,o.useCallback)(()=>{let e=E.current;if(0===e.length)return;let t=e.pop(),r=[...A.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),L.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,o.useCallback)(()=>{let e=L.current;if(0===e.length)return;let t=e.pop(),r=[...A.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 o=t.lineIndex+Math.max(0,t.newLines.length-1);f(Math.min(o,r.length-1)),l(Math.min(o,r.length-1),"auto")},[n,l]),z=(0,o.useCallback)(e=>{let t=A.current,n=Math.min(p,t.length-1);if("o"===e||"O"===e){let r="o"===e?n+1:n,o=[...t];o.splice(r,0,""),$(o,{lineIndex:r,oldLines:[],newLines:[""],cursorLine:p}),n=r,f(r)}m("insert"),r(n,g,e)},[p,g,$,r]),K=(0,o.useCallback)(()=>{m("normal"),I()},[I]),G=(0,o.useCallback)(()=>{m("command"),C("")},[]),J=(0,o.useCallback)(()=>{m("normal"),C("")},[]),Q=(0,o.useCallback)(()=>{m("search"),N("")},[]),Y=(0,o.useCallback)(()=>{m("normal"),N("")},[]),Z=(0,o.useCallback)(e=>{let t=e.trim();if("w"===t){s?.(),m("normal"),C("");return}if("q"===t){m("normal"),C("");return}if("wq"===t){s?.(),m("normal"),C("");return}if("noh"===t||"nohlsearch"===t){u?.(),m("normal"),C("");return}let n=parseInt(t,10);if(!isNaN(n)&&n>0){let e=Math.min(n-1,A.current.length-1);f(e),l(e,"center"),m("normal"),C("");return}m("normal"),C("")},[s,u,l]),X=(0,o.useCallback)(e=>{if(!e){m("normal"),N("");return}T(e),i?.(e),m("normal"),N("")},[i]),ee=(0,o.useCallback)(e=>{if(!t)return!1;let n=e.ctrlKey&&"c"===e.key&&!e.metaKey&&!e.shiftKey;if("insert"===h)return("Escape"===e.key||!!n)&&(K(),!0);if("command"===h)return!e.isComposing&&("Escape"===e.key||n?J():"Enter"===e.key?Z(k):"Backspace"===e.key?0===k.length?J():C(e=>e.slice(0,-1)):1!==e.key.length||e.metaKey||e.ctrlKey||C(t=>t+e.key),!0);if("search"===h)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?(_(Math.max(1,Math.floor(a()/2))),I(),!0):"u"===e.key?(_(-Math.max(1,Math.floor(a()/2))),I(),!0):"r"===e.key&&(q(),I(),!0);let r=e.key,o=y+r;if("g"===o)return w("g"),D(),!0;if("gg"===o)return B(0),I(),!0;if("d"===o)return w("d"),D(),!0;if("dd"===o)return O(),I(),!0;if("y"===o)return w("y"),D(),!0;if("yy"===o)return H(),I(),!0;if(y&&o!==r&&I(),"j"===r||"ArrowDown"===r)return _(1),!0;if("k"===r||"ArrowUp"===r)return _(-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,(A.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,(A.current[p]??"").length-1)),!0;if("^"===r){let e=(A.current[p]??"").search(/\S/);return x(e>=0?e:0),!0}return"G"===r?(B(A.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?(Q(),!0):"n"===r?(c?.(),!0):"N"===r?(d?.(),!0):":"===r?(G(),!0):"Escape"!==r&&1===r.length},[t,h,y,k,j,p,K,z,G,J,Q,Y,Z,X,_,B,a,O,H,V,U,W,q,I,D,c,d]);return{state:{mode:h,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,o.useCallback)(()=>{E.current=[],L.current=[]},[])}}({lines:eQ,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=(eQ[e]??"").length;else if("I"===n){let t=(eQ[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,o.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,o.useRef)(null);(0,o.useEffect)(()=>{X&&!G&&null!=eo&&t&&ty.current!==t&&(ty.current=t,tv.setCursorLine(eo-1),null!=es&&tv.setCursorCol(es-1),ea?.())},[X,G,eo,es,t]),(0,o.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,o.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,o.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,o=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),s=0;for(;e=o.nextNode();){if(e===t.startContainer){s+=t.startOffset;break}s+=e.textContent?.length||0}let a=eQ[n-1]??"";tv.setCursorCol(Math.max(0,Math.min(s,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,eQ]),tk=(0,o.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,o.useEffect)(()=>{"command"===tv.state.mode?setTimeout(()=>tf.current?.focus(),0):"search"===tv.state.mode&&setTimeout(()=>tg.current?.focus(),0)},[tv.state.mode]),(0,o.useEffect)(()=>{let e=eT.current;if(!e)return;let t=()=>{(W??U)?.()};return e.addEventListener("mousedown",t),()=>e.removeEventListener("mousedown",t)},[W,U]),(0,o.useEffect)(()=>{eW||eq?(eR.current=!0,U?.()):eM.current||(eR.current=!1)},[eW,eq,U]),(0,o.useLayoutEffect)(()=>{let e=eP.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}"]`),o=n.querySelector(`[data-line="${e.endLine}"]`);if(!r||!o)return;let s=E(r,e.startOffset),a=E(o,e.endOffset);if(s&&a)try{let e=document.createRange();e.setStart(s.node,s.offset),e.setEnd(a.node,a.offset),t?.removeAllRanges(),t?.addRange(e)}catch{}});let tC=(0,o.useCallback)((e,t,n)=>{eR.current||V?.(e,t,n)},[V]),tj=(0,o.useCallback)((e,t)=>{eR.current||H?.(e,t)},[H]),tN=Math.max(4,String(G?eg:eQ.length).length),tS=(0,o.useMemo)(()=>{let e=0;for(let t of eQ){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},[eQ]);(0,o.useEffect)(()=>{if(G){ed.current=e;let t=e.split("\n").length;eb.current=t,ex(t),eu.current=!1,em(!1),ey({show:!1}),eC.current=J}},[G,e,J]),(0,o.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,m.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((O?.current??1)-1,n.length-1)),r=0),t.focus(),P(t,{line:e,offset:r});let o=O?.current??1;ek.current&&(ek.current.scrollTop=(o-1)*20)})},[G]),(0,o.useEffect)(()=>{G&&Z?.({isDirty:eh,isSaving:ep})},[G,eh,ep,Z]);let tT=(0,o.useCallback)(()=>{let e=ew.current;if(!e)return ed.current;let t=[];for(let n of e.childNodes){let e=n.textContent||"";t.push(" "===e?"":e)}return t.join("\n")},[]),tE=(0,o.useCallback)(()=>{ej.current&&clearTimeout(ej.current),ej.current=setTimeout(async()=>{let e=ew.current;if(e&&!eS.current){ed.current=tT();try{let n=await (0,m.kS)(),r=(0,m.sQ)(t),o=document.documentElement.classList.contains("dark"),s=ed.current.split("\n"),a=n.codeToTokens(s.join("\n"),{lang:r,theme:o?"github-dark":"github-light"}).tokens.map(e=>(0,m.b8)(e)),l=A(e);eN.current=!0,e.innerHTML=F(a),eN.current=!1,l&&P(e,l)}catch{}}},300)},[t,tT]);(0,o.useEffect)(()=>{if(G)return()=>{ej.current&&clearTimeout(ej.current)}},[G]);let tL=(0,o.useCallback)(()=>{let e=ew.current;if(!e)return;eu.current||(eu.current=!0,em(!0));let t=e.children.length;t!==eb.current&&(eb.current=t,ex(t))},[]),tM=(0,o.useCallback)(()=>{eN.current||eS.current||(tL(),tE())},[tL,tE]),tR=(0,o.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 o=r.startContainer;for(;o&&o.parentElement!==t;)o=o.parentElement;if(!o||!(o instanceof HTMLElement))return;let s=A(t),a=Array.from(t.children).indexOf(o),l=o.textContent||"",i=s?.offset??l.length,c=l.substring(0,i),d=l.substring(i);o.innerHTML=(0,m.ZD)(c||" ");let u=document.createElement("div");u.setAttribute("style",R),u.innerHTML=(0,m.ZD)(d||" "),o.after(u),P(t,{line:a+1,offset:0}),tL(),tE()}},[tL,tE]),tA=(0,o.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)},[]),tP=(0,o.useCallback)(async(e=!1)=>{if(!v)return;ed.current=tT(),ef(!0);let n=await l.t4.runPromiseExit((0,i.OJ)({cwd:v,path:t,content:ed.current,expectedMtime:e?void 0:eC.current}));if("Failure"===n._tag){console.error("Error saving file:",n.cause),(0,M.oR)(ec("toast.saveFailed"),"error"),ef(!1);return}let r=n.value,o=r.data;if(409===r.status&&o?.conflict){let e=await l.t4.runPromiseExit((0,c.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)(ec("toast.saveFailed"),"error"),ef(!1);return}let s=o?.mtime;s&&(eC.current=s),eu.current=!1,em(!1),ey({show:!1}),(0,M.oR)(ec("toast.savedSuccess"),"success"),Y?.(),ef(!1)},[v,t,tT,Y,ec]),tF=(0,o.useCallback)(async()=>{eh&&!ep&&await tP(!1)},[eh,ep,tP]),tI=(0,o.useCallback)(async()=>{ey({show:!1}),await tP(!0)},[tP]),tD=(0,o.useCallback)(()=>{if(void 0!==ev.diskContent){ed.current=ev.diskContent;let t=ev.diskContent.split("\n").length;eb.current=t,ex(t);let n=ev.diskContent!==e;eu.current=n,em(n);let r=ew.current;r&&(r.innerHTML=F(ev.diskContent.split("\n").map(e=>(0,m.ZD)(e||" "))),tE())}ey({show:!1}),Y?.()},[ev.diskContent,e,Y,tE]),t$=(0,o.useCallback)(()=>{let e=ek.current;return e?Math.floor(e.scrollTop/20)+1:O?.current??1},[O]),tB=(0,o.useCallback)(async()=>{(!eh||await (0,M.lJ)(ec("codeViewer.unsavedConfirm"),{danger:!0,confirmText:ec("codeViewer.discardChanges"),cancelText:ec("codeViewer.continueEditing")}))&&Q?.(t$())},[eh,Q,t$]);(0,o.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 t_=(0,o.useCallback)(()=>{let e=tT();ee?.(e);let t=ew.current,n=t?A(t):null,r=t$();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));Q?.(r)},[tT,ee,t$,Q,tv]);(0,o.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)(ec("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:ec("codeViewer.discardChanges"),cancelText:ec("codeViewer.continueEditing")}).then(e=>{e&&t_()}):t_():tB())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[G,X,tB,t_]);let tO=(0,o.useCallback)(()=>{eu.current||(eu.current=!0,em(!0))},[]);(0,o.useImperativeHandle)(ei,()=>({save:tF,close:tB,markDirty:tO,get isDirty(){return eu.current},get isSaving(){return ep}}),[tF,tB,tO,ep]);let tH=!!(q&&q.length>0),tV=(0,o.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,o.useState)(null),[tq,tz]=(0,o.useState)(null);(0,o.useEffect)(()=>{tW(null),tz(null)},[q]);let tK=(0,o.useCallback)((e,t)=>{tW(e.author);let n=t.currentTarget.getBoundingClientRect();tz({line:e,x:n.right+8,y:n.top})},[]),tG=(0,o.useCallback)(()=>{tW(null),tz(null)},[]),tJ=(0,o.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]),tQ=`${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:ec("codeViewer.fileModifiedExternally")}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:tD,className:"px-3 py-1 text-sm rounded border border-border hover:bg-hover transition-colors",children:ec("codeViewer.useDiskVersion")}),(0,r.jsx)("button",{onClick:tI,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:ec("codeViewer.forceOverwrite")})]})]}),!G&&x&&eB&&(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:eL,type:"text",value:e_,onChange:e=>e5(e.target.value),onKeyDown:tt,placeholder:ec("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:ec("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:ec("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:eY.length>0?`${eV+1}/${eY.length}`:ec("common.noMatch")}),(0,r.jsx)("button",{onClick:te,disabled:0===eY.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ec("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:ec("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:ec("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:tQ},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:tR,onPaste:tA,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${eD?" 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 o=t.lineIndex,s=o+1,a=eF[o]||(0,m.ZD)(eQ[o]||""),l=td(o,a,_),i=e1.has(s),c=e0.get(s),d=c?.[0],u=!!(eW&&s>=eW.range.start&&s<=eW.range.end),h=tm>=0?th.current:null,p=!G&&z&&h===s?z[o]??null:null,f=tH?q[o]:void 0,g=tH&&o>0?q[o-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:s,highlightedHtml:l,hasComments:i,firstComment:d,lineCommentsCount:c?.length,isInRange:u,showLineNumbers:n,lineNumChars:tN,commentsEnabled:eK,virtualItemSize:e.size,virtualItemStart:e.start,onCommentBubbleClick:tn,onCmdClick:tj,onTokenHover:tC,onTokenHoverLeave:U,flashLine:e$,blameLine:f,showBlameInfo:x,blameAuthorColor:b,isBlameHovered:!!(f&&tU===f.author),onBlameClick:tJ,onBlameMouseEnter:tK,onBlameMouseLeave:tG,inlineBlameData:p,onInlineBlameClick:tJ,isCursorLine:X&&!G&&tv.state.cursorLine===o,cursorCol:X&&!G&&tv.state.cursorLine===o?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]})]}),eI&&tp&&(0,a.createPortal)((0,r.jsxs)(r.Fragment,{children:[!G&&(0,r.jsx)(p.fS,{floatingToolbarRef:eM,bumpRef:eA,container:tp,onAddComment:tr,onSendToAI:to,onSearch:el?ta:void 0,onExplain:ez?ts: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?tc: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:eJ}),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,L.fw)(tq.line.time)," \xb7 ",new Date(1e3*tq.line.time).toLocaleString(),(0,r.jsx)("span",{className:"ml-2 text-brand",children:ec("codeViewer.clickToViewDetails")})]})]})]}),tp)]})});function D({content:e,filePath:t,className:n=""}){let s=(0,o.useMemo)(()=>e.split("\n"),[e]),a=(0,h.C)(s,t),l=Math.max(4,String(s.length).length);return(0,r.jsx)("pre",{className:`overflow-auto text-sm font-mono bg-muted p-2 ${n}`,children:s.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,m.ZD)(e||" ")}})]},t))})}},43595:(e,t,n)=>{n.d(t,{U:()=>l});var r=n(48764),o=n(58250),s=n(51536);let a={add:r.L5,notify:o.k,namespace:"skills",failureKey:"skills.addFailed"},l=()=>(0,s.X)(a)},45619:(e,t,n)=>{n.d(t,{xU:()=>E,xZ:()=>T});var r=n(95155),o=n(12115),s=n(79114),a=n(64702),l=n(22576),i=n(19502),c=n(34075),d=n(56978),u=n(17196);function h({lines:e,containerRef:t}){let n=(0,o.useRef)(null),[s,a]=(0,o.useState)({top:0,height:0});if((0,o.useEffect)(()=>{let e=t.current;if(!e)return;let r=()=>{let{scrollTop:t,scrollHeight:r,clientHeight:o}=e,s=n.current?.clientHeight||0;if(r<=o)a({top:0,height:s});else{let e=s/r;a({top:t*e,height:o*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,o=n.current;if(!r||!o)return;let s=o.getBoundingClientRect(),a=(e.clientY-s.top)/s.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:`${s.top}px`,height:`${Math.max(s.height,10)}px`}})]})}var m=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:s,containerEl:a,onContentSearch:l}){let i=(0,x.iN)(),c=(0,b.r)(),d=t&&!!e,{comments:u,addComment:h,updateComment:j,deleteComment:N,refresh:S}=(0,p._)({cwd:e||"",filePath:n}),[T,E]=(0,o.useState)(null),{toolbarRef:L,bumpRef:M,clearToolbar:R}=(0,k.L)({enabled:d,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 o of s)("unchanged"===o.type||"added"===o.type)&&++r>=e&&r<=t&&n.push(o.content);return n.join("\n")}}),[A,P]=(0,o.useState)(null),[F,I]=(0,o.useState)(null),[D,$]=(0,o.useState)(!1);(0,o.useEffect)(()=>{$(!0)},[]);let B=(0,o.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]),_=(0,o.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,o.useCallback)((e,t)=>{t.stopPropagation(),E({comment:e,x:t.clientX,y:t.clientY}),R(),P(null),I(null)},[R]),H=(0,o.useCallback)(()=>{let e=L.current;e&&(P({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),R())},[R,L]),V=(0,o.useCallback)(()=>{let e=L.current;e&&(I({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),R())},[R,L]),U=(0,o.useCallback)(()=>{let e=L.current;e&&c&&(R(),(0,f.Ff)(c.sendMessage,{filePath:n,startLine:e.range.start,endLine:e.range.end,codeContent:e.lineSnapshot},g.A.t("explain.selectionMessage")))},[c,n,R,L]),W=(0,o.useCallback)(()=>{let e=L.current;if(!e||!l)return;let t=e.selectedText.trim();R(),t&&l(t)},[l,R,L]),q=(0,o.useCallback)(async(t,r)=>{if(c&&e)try{let o=await (0,f.$3)(e),s=[];for(let e of o)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});s.push({filePath:n,startLine:t.range.start,endLine:t.range.end,codeContent:t.lineSnapshot});let a=(0,f.Gw)(s,r);c.sendMessage(a),await (0,f.RP)(e),S()}catch(e){console.error("Failed to send to AI:",e)}},[c,n,e,S]),z=(0,o.useCallback)(e=>{F&&q(F,e)},[F,q]),K=(0,o.useCallback)(e=>{A&&q(A,e)},[A,q]),G=(0,o.useCallback)(async e=>{A&&(await h(A.range.start,A.range.end,e,A.selectedText),P(null))},[A,h]),J=D&&i?(0,m.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.fS,{floatingToolbarRef:L,bumpRef:M,container:i,onAddComment:H,onSendToAI:V,onSearch:l?W:void 0,onExplain:c?U:void 0,isChatLoading:c?.isLoading??!1}),A&&(0,r.jsx)(y.t,{x:A.x,y:A.y,range:A.range,filePath:n,lineSnapshot:A.lineSnapshot,container:i,onSubmit:G,onSendToAI:c?K:void 0,onClose:()=>P(null),isChatLoading:c?.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:()=>I(null),isChatLoading:c?.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:d,linesWithComments:B,commentsByEndLine:_,handleCommentBubbleClick:O,addCommentRange:A?.range??null,sendToAIRange:F?.range??null,commentPortal:J}}var j=n(96497);function N(e){return(0,o.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:m=!1,isDeleted:p=!1,cwd:f,enableComments:g=!1,onPreview:x,previewLabel:b,headerLeading:v,onContentSearch:y,targetLine:w,compact:k=!1,symbols:j,onTokenHover:E,onTokenHoverLeave:L,onTokenHoverCancel:M}){let{t:R}=(0,s.Bd)(),A=N(E),P=b??R("common.preview"),F=(0,o.useMemo)(()=>(0,l.X)(e,t),[e,t]),I=(0,o.useRef)(null),D=(0,o.useRef)(null),$=(0,o.useRef)(null),B=(0,o.useRef)(!1),[_,O]=(0,o.useState)(null);(0,o.useEffect)(()=>{$.current!==_&&O($.current)});let{commentsEnabled:H,linesWithComments:V,commentsByEndLine:U,handleCommentBubbleClick:W,addCommentRange:q,sendToAIRange:z,commentPortal:K}=C({cwd:f,enableComments:g,filePath:n,diffLines:F,containerEl:_,onContentSearch:y});(0,o.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),o=()=>n(t,e);return e.addEventListener("scroll",r),t.addEventListener("scroll",o),()=>{e.removeEventListener("scroll",r),t.removeEventListener("scroll",o)}},[]);let{leftLines:G,rightLines:J}=(0,o.useMemo)(()=>{let e=[],t=[],n=0,r=0;for(let o=0;o<F.length;o++){let s=F[o];if("unchanged"===s.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:s.content,type:"unchanged",originalIdx:o}),t.push({lineNum:r,content:s.content,type:"unchanged",originalIdx:o})}else"removed"===s.type?(n++,e.push({lineNum:n,content:s.content,type:"removed",originalIdx:o})):"added"===s.type&&(r++,t.push({lineNum:r,content:s.content,type:"added",originalIdx:o}))}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]),Q=(0,o.useMemo)(()=>F.map(e=>e.content),[F]),Y=(0,d.C)(Q,n),[Z,X]=(0,o.useState)(()=>new Map);(0,o.useLayoutEffect)(()=>{X(new Map),el.measure()},[G,J]);let ee=(0,o.useMemo)(()=>j??[],[j]),{rows:et,gaps:en}=(0,o.useMemo)(()=>k?(0,i.pU)(G,J,Z,ee):{rows:G.map((e,t)=>({kind:"diff",idx:t})),gaps:[]},[k,G,G,J,Z,ee]),er=(0,o.useCallback)((e,t)=>{let n=en.find(t=>t.id===e);n&&X(r=>{let o=r.get(e)??{topRevealed:0,bottomRevealed:0},s=n.endIdx-n.startIdx+1-o.topRevealed-o.bottomRevealed;if(s<=0)return r;let a=Math.min(i.YO,s),l="up"===t?{...o,topRevealed:o.topRevealed+a}:{...o,bottomRevealed:o.bottomRevealed+a};return new Map(r).set(e,l)})},[en]),eo=(0,o.useCallback)(e=>{for(let t of en)if(e>=t.startIdx&&e<=t.endIdx)return t.id;return null},[en]),es=(0,o.useCallback)(e=>et[e]?.kind==="gap-label"?28:20,[et]),ea=(0,o.useCallback)(e=>{let t=et[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=G[t.idx],r=J[t.idx];return`d:${n?.lineNum??"x"}:${n?.type??"x"}:${r?.lineNum??"x"}:${r?.type??"x"}`},[et,G,J]),el=(0,a.Te)({count:et.length,getScrollElement:()=>I.current,estimateSize:es,getItemKey:ea,overscan:20}),ei=m?"w-1/4":p?"w-3/4":"w-1/2",ec=m?"w-3/4":p?"w-1/4":"w-1/2",ed=(0,o.useMemo)(()=>et.map(e=>{if("diff"!==e.kind)return{type:"unchanged"};let t=G[e.idx],n=J[e.idx];return"removed"===t.type?{type:"removed"}:n?.type==="added"?{type:"added"}:{type:"unchanged"}}),[et,G,J]),eu=el.getTotalSize(),eh=el.getVirtualItems();return(0,o.useEffect)(()=>{if(!w)return;let e=("after"===w.side?J:G).findIndex(e=>e.lineNum===w.line);if(-1===e)return;let t=et.findIndex(t=>"diff"===t.kind&&t.idx===e);if(-1===t){let t=eo(e);if(null!==t){let e=en.find(e=>e.id===t);if(!e)return;let n=e.endIdx-e.startIdx+1;X(e=>{let r=e.get(t)??{topRevealed:0,bottomRevealed:0};if(r.topRevealed+r.bottomRevealed>=n)return e;let o=new Map(e);return o.set(t,{topRevealed:n,bottomRevealed:0}),o})}return}let n=requestAnimationFrame(()=>{el.scrollToIndex(t,{align:"start"})});return()=>cancelAnimationFrame(n)},[w,G,J,et]),(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:`${ei} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:m?"(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,c.oR)(R("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:R("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:I,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,r.jsxs)("div",{className:"flex",style:{height:`${eu}px`},children:[(0,r.jsx)("div",{ref:D,className:`${ei} 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=et[e.index];if("gap-expand"===t.kind||"gap-label"===t.kind){let n="gap-label"===t.kind;return(0,r.jsx)("div",{ref:el.measureElement,"data-index":e.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,es(e.index))}px`,transform:`translateY(${e.start}px)`},className:n?"bg-accent border-y border-border":""},e.key)}let n=G[t.idx];return(0,r.jsxs)("div",{ref:el.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,es(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&&Y[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=et[e.index];if("gap-expand"===t.kind)return(0,r.jsx)("button",{ref:el.measureElement,"data-index":e.index,type:"button",onClick:()=>er(t.gapId,t.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,es(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:R("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),"aria-label":R("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),children:(0,r.jsx)("span",{className:"select-none",children:R("diffViewer.gap.more",{count:t.revealCount})})},e.key);if("gap-label"===t.kind)return(0,r.jsxs)("div",{ref:el.measureElement,"data-index":e.index,"data-gap-id":t.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,es(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:R("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),children:S(t.enclosingFn)})]})]},e.key);let n=J[t.idx],o=n?.lineNum||0,s=o>0&&V.has(o),a=U.get(o),l=a?.[0],i=q&&o>=q.start&&o<=q.end,c=z&&o>=z.start&&o<=z.end,d=i||c;return(0,r.jsxs)("div",{ref:el.measureElement,"data-index":e.index,"data-new-line":o||void 0,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,es(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${d?"bg-blue-9/20":s?"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 ${d?"bg-blue-9/30":""}`,style:{width:H?"52px":"40px"},children:[H&&o>0&&s&&l&&(0,r.jsx)("button",{onClick:e=>W(l,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:R("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"})})}),H&&o>0&&!s&&(0,r.jsx)("span",{className:"w-4"}),(0,r.jsx)("span",{className:"flex-1 text-right pr-1",children:o||""})]}),(0,r.jsx)("span",{className:"whitespace-pre pl-2",onMouseOver:E?e=>A(e,o):void 0,onMouseLeave:E?L:void 0,onMouseDown:E?M:void 0,dangerouslySetInnerHTML:{__html:n?.originalIdx>=0&&Y[n.originalIdx]||(0,u.ZD)(n?.content||" ")}})]},e.key)})})})]})}),(0,r.jsx)(h,{lines:ed,containerRef:I})]}),K]})}function E({oldContent:e,newContent:t,filePath:n,cwd:m,enableComments:p=!1,onPreview:f,previewLabel:g,headerLeading:x,onContentSearch:b,compact:v=!1,onTokenHover:y,onTokenHoverLeave:w,onTokenHoverCancel:k}){let{t:j}=(0,s.Bd)(),S=N(y),T=g??j("common.preview"),L=(0,o.useMemo)(()=>(0,l.X)(e,t),[e,t]),M=(0,o.useRef)(null),R=(0,o.useMemo)(()=>L.map(e=>e.content),[L]),A=(0,d.C)(R,n),[P,F]=(0,o.useState)(null);(0,o.useEffect)(()=>{M.current!==P&&F(M.current)});let{commentsEnabled:I,linesWithComments:D,commentsByEndLine:$,handleCommentBubbleClick:B,addCommentRange:_,sendToAIRange:O,commentPortal:H}=C({cwd:m,enableComments:p,filePath:n,diffLines:L,containerEl:P,onContentSearch:b}),[V,U]=(0,o.useState)(()=>new Set);(0,o.useEffect)(()=>{U(new Set)},[e,t,n]);let W=(0,o.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 o=Math.max(0,t-i.aj),s=Math.min(n-1,t+i.aj);for(let e=o;e<=s;e++)r[e]=!0}let o=[],s=0,a=0;for(;a<n;){if(r[a]){o.push({kind:"line",line:e[a],index:a}),a++;continue}let l=a;for(;l<n&&!r[l];)l++;let i=s++;if(t.has(i))for(let t=a;t<l;t++)o.push({kind:"line",line:e[t],index:t});else o.push({kind:"gap",id:i,count:l-a});a=l}return o}(L,V):L.map((e,t)=>({kind:"line",line:e,index:t})),[v,L,V]),q=(0,o.useCallback)(e=>{let t=W[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"}`},[W]),z=(0,a.Te)({count:W.length,getScrollElement:()=>M.current,estimateSize:()=>20,getItemKey:q,overscan:20}),K=(0,o.useMemo)(()=>W.map(e=>"gap"===e.kind?{type:"unchanged"}:{type:e.line.type}),[W]);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:T}),t&&(0,r.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,c.oR)(j("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:j("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:M,className:"flex-1 min-w-0 overflow-auto",children:(0,r.jsx)("div",{style:{height:`${z.getTotalSize()}px`,position:"relative"},children:z.getVirtualItems().map(e=>{let t=W[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 o=j("diffViewer.gap.hidden",{count:t.count});return(0,r.jsx)("div",{style:n,onClick:()=>U(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":o,children:(0,r.jsx)("span",{className:"w-full text-center",children:o})},e.key)}let o=t.line,s="removed"!==o.type?o.newLineNum??0:0,a=s>0&&D.has(s),l=$.get(s),i=l?.[0],c=_&&s>=_.start&&s<=_.end,d=O&&s>=O.start&&s<=O.end;return(0,r.jsxs)("div",{style:n,"data-new-line":s||void 0,className:`flex ${c||d?"bg-blue-9/20":a?"bg-amber-9/10":"removed"===o.type?"bg-red-9/15 dark:bg-red-9/25":"added"===o.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[I&&(0,r.jsx)("span",{className:"w-5 flex-shrink-0 flex items-center justify-center select-none",children:s>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:j("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"!==o.type?o.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"!==o.type?o.newLineNum:""}),(0,r.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===o.type?"text-red-11":"added"===o.type?"text-green-11":"text-foreground-subtle"}`,children:"removed"===o.type?"-":"added"===o.type?"+":" "}),(0,r.jsx)("span",{className:"flex-1 whitespace-pre pl-1",onMouseOver:y?e=>S(e,s):void 0,onMouseLeave:y?w:void 0,onMouseDown:y?k:void 0,dangerouslySetInnerHTML:{__html:A[t.index]||(0,u.ZD)(o.content||" ")}})]},e.key)})})}),(0,r.jsx)(h,{lines:K,containerRef:M})]}),H]})}},46456:(e,t,n)=>{n.d(t,{$:()=>i,BC:()=>c,Tu:()=>u,lb:()=>l,tj:()=>h,vv:()=>d});var r=n(49433),o=n(82680);let s=(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 o.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),a=(e,t)=>r.$mh({try:async()=>{let n=await fetch(e,t);if(!n.ok)throw Error(`HTTP ${n.status}`)},catch:n=>new o.uV({message:`${t.method} ${e} failed`,cause:n})}),l=(e,t)=>s(`/api/comments?cwd=${encodeURIComponent(e)}${t?`&filePath=${encodeURIComponent(t)}`:""}`),i=e=>s(`/api/comments?cwd=${encodeURIComponent(e)}&all=true`),c=e=>s("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),d=(e,t,n)=>s("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,id:t,content:n})}),u=(e,t)=>a(`/api/comments?cwd=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`,{method:"DELETE"}),h=e=>a(`/api/comments?cwd=${encodeURIComponent(e)}&all=true`,{method:"DELETE"})},47176:(e,t,n)=>{n.d(t,{l:()=>i});var r=n(95155),o=n(12115),s=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"}){let{t:c}=(0,s.Bd)(),d=(0,o.useMemo)(()=>(function(e){let t=[],n=e.split("\n"),r=!1;for(let e=0;e<n.length;e++){let o=n[e];if(o.trimStart().startsWith("```")){r=!r;continue}if(r)continue;let s=/^(#{1,6})\s+(.+)$/.exec(o);s&&t.push({level:s[1].length,text:s[2].replace(/\s*#+\s*$/,"").replace(/\\([!-\/:-@[-`{-~])/g,"$1"),sourceLine:e+1})}return t})(e),[e]),[u,h]=(0,o.useState)(!1),[m,p]=(0,o.useState)(null),f=(0,o.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,o.useEffect)(()=>{let e=t.current;if(!e||0===d.length)return;let n=()=>{let t=[];for(let n of d){let r=e.querySelector(l(n.sourceLine));if(r){let o=r.getBoundingClientRect().top-e.getBoundingClientRect().top;t.push({line:n.sourceLine,top:o})}}let n=null;for(let e of t)e.top<=60&&(n=e.line);null===n&&t.length>0&&(n=t[0].line),p(n)},r=setTimeout(n,150);return e.addEventListener("scroll",n,{passive:!0}),()=>{clearTimeout(r),e.removeEventListener("scroll",n)}},[d,e,t]),0===d.length)?null:(0,r.jsxs)("div",{className:`border-r border-border flex-shrink-0 flex flex-col transition-[width] duration-200 ${u?"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:[!u&&(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(u?"editor.expandToc":"editor.collapseToc"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u?(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"})})})]}),!u&&(0,r.jsx)("nav",{className:"flex-1 overflow-y-auto py-1",children:d.map((e,t)=>(0,r.jsx)(a.m,{content:e.text,delay:400,children:(0,r.jsx)("button",{onClick:()=>f(e.sourceLine),className:`block w-full text-left text-sm py-1 px-2 truncate transition-colors hover:bg-hover ${m===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:()=>s,oK:()=>C,u:()=>f,xb:()=>c,zs:()=>m});var r=n(12115),o=n(69809);function s(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 c(e,t=l){try{let n=JSON.parse(e);return h(n,0,t)}catch{return e}}let d=(e,t)=>r.createElement("span",{style:{color:e}},t);function u({label:e,labelColor:t,value:n,indent:s,colors:a}){let l=r.useContext(i),[c,m]=r.useState(null),p=c&&c.version===l.version?c.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(),m({version:l.version,collapsed:!p}))},style:{cursor:"pointer"}};if(x&&p&&"string"==typeof n){let s=n.replace(/\\n/g,"\n").split("\n")[0],l=n.replace(/\\n/g,"\n").split("\n").length;return r.createElement("span",b,d(t,e),d(a.punct,": "),d(a.str,s),d(a.fold,` ${o.A.t("toolCall.foldedLines",{count:l})}`))}let v=r.createElement(r.Fragment,null,d(t,e),d(a.punct,": "),h(n,s,a));return x?r.createElement("span",b,v):v}function h(e,t,n){let o=" ".repeat(t);if(null===e)return d(n.bool,"null");if(void 0===e)return d(n.bool,"undefined");if("string"==typeof e){let t=e.replace(/\\n/g,"\n").replace(/\n/g,"\n"+o);return d(n.str,t)}if("number"==typeof e)return d(n.num,String(e));if("boolean"==typeof e)return d(n.bool,String(e));if(Array.isArray(e))return 0===e.length?d(n.punct,"[]"):r.createElement(r.Fragment,null,d(n.punct,"["),"\n",...e.map((s,a)=>r.createElement("span",{key:a},o+" ",r.createElement(u,{label:`[${a}]`,labelColor:n.key,value:s,indent:t+1,colors:n}),a<e.length-1?r.createElement(r.Fragment,null,d(n.punct,","),"\n"):"\n")),o,d(n.punct,"]"));if("object"==typeof e){let s=Object.entries(e);return 0===s.length?d(n.punct,"{}"):r.createElement(r.Fragment,null,d(n.punct,"{"),"\n",...s.map(([e,a],l)=>r.createElement("span",{key:e},o+" ",r.createElement(u,{label:e,labelColor:n.key,value:a,indent:t+1,colors:n}),l<s.length-1?r.createElement(r.Fragment,null,d(n.punct,","),"\n"):"\n")),o,d(n.punct,"}"))}return String(e)}function m(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}},48347:(e,t,n)=>{n.d(t,{H:()=>a,r:()=>l});var r=n(95155),o=n(12115);let s=(0,o.createContext)(null);function a({value:e,children:t}){return(0,r.jsx)(s.Provider,{value:e,children:t})}function l(){return(0,o.useContext)(s)}},48661:(e,t,n)=>{n.d(t,{q:()=>s});var r=n(95155),o=n(79114);function s({value:e,onChange:t,className:n}){let{t:a}=(0,o.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:()=>l,Hy:()=>o,L5:()=>s,hp:()=>a});var r=n(37640);let o=()=>(0,r.zi)("/api/skills"),s=e=>(0,r.zi)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),a=e=>(0,r.zi)(`/api/skills/${encodeURIComponent(e)}`,{method:"DELETE"}),l=e=>(0,r.zi)(`/api/skills/content?id=${encodeURIComponent(e)}`)},50605:(e,t,n)=>{function r(e){return/^~(?=$|[/\\])/.test(e.trim())}function o(e,t){return t&&r(e)?t.replace(/[/\\]+$/,"")+e.trim().slice(1):e}n.d(t,{D:()=>o,P:()=>r})},50860:(e,t,n)=>{n.d(t,{I:()=>l});var r=n(95155),o=n(12115),s=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,c="absPath"in e&&"string"==typeof e.absPath,d=c?void 0:e.cwd,u=c?void 0:e.path,h=c?e.absPath:void 0,[m,p]=(0,o.useState)({kind:"loading"}),f=(0,o.useRef)(0);if((0,o.useEffect)(()=>{let e=++f.current;return p({kind:"loading"}),(async()=>{if(c){if(e!==f.current)return;p({kind:"ready",etag:null,size:0});return}let t=await s.t4.runPromiseExit((0,a.r6)(d,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++}},[c,d,u,h,t]),"loading"===m.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"===m.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"===m.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(m.size/1024/1024)," MB)"]})});if("error"===m.kind)return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("div",{className:"text-sm text-red-11",children:m.message})});let g=c?`/api/file?path=${encodeURIComponent(h)}&raw=true`:`/api/files/read?cwd=${encodeURIComponent(d)}&path=${encodeURIComponent(u)}&v=${encodeURIComponent(m.etag)}`;return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("img",{src:g,alt:i??(u||h),className:l})})}},51145:(e,t,n)=>{n.d(t,{K:()=>s});var r=n(49433),o=n(82680);let s=(e,t)=>{let n,s;return n=`/api/files/text?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,s={cache:"no-store"},r.$mh({try:async()=>{let e=await fetch(n,s),t=null;try{t=await e.json()}catch{}return{status:e.status,ok:e.ok,data:t}},catch:e=>new o.uV({message:`GET ${n} failed`,cause:e})})}},51536:(e,t,n)=>{n.d(t,{X:()=>i});var r=n(12115),o=n(79114),s=n(34075),a=n(37640),l=n(86957);function i({add:e,notify:t,namespace:n,failureKey:c}){let{t:d}=(0,o.Bd)();return(0,r.useCallback)(async r=>{let o=await l.t4.runPromiseExit(e(r));"Success"===o._tag?o.value.alreadyExists?(0,s.oR)(d(`${n}.alreadyAdded`),"info"):((0,s.oR)(d(`${n}.added`),"success"),t()):(0,s.oR)((0,a.oh)(o.cause,d(c)),"error")},[e,t,n,c,d])}},52839:(e,t,n)=>{n.d(t,{S:()=>a,q:()=>s});let r=[/(^|\/)__tests__\//,/(^|\/)tests?\//,/\.(test|spec)\.[^/]+$/],o=[/\.(md|mdx)$/i,/(^|\/)docs\//,/(^|\/)README[^/]*$/i,/(^|\/)LICENSE[^/]*$/i,/(^|\/)CHANGELOG[^/]*$/i];function s(e){return r.some(t=>t.test(e))?"test":o.some(t=>t.test(e))?"docs":null}function a(e){if(0===e.length)return null;let t=s(e[0]);return null===t?null:e.every(e=>s(e)===t)?t:null}},54271:(e,t,n)=>{n.d(t,{zB:()=>V,e$:()=>H,vP:()=>$});var r=n(95155),o=n(12115),s=n(79114),a=n(49433),l=n(77725),i=n(62111),c=n(70188),d=n(72312),u=n(64428),h=n(52839),m=n(79237),p=n(67889),f=n(33210),g=n(56058),x=n(32880),b=n(12710),v=n(33024),y=n(32967),w=n(88780),k=n(30133),C=n(48661),j=n(20080),N=n(45619),S=n(47215),T=n(5135),E=n(24602),L=n(9573),M=n(4055);function R(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),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),o=r.split("\n"),s=o.length>n?o.slice(0,n).join("\n"):r,a=s.length>t?s.slice(0,t):s;return o.length>n||s.length>t?`${a.trimEnd()}…`:a}function I(e,t){return t&&(0,m.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 o=I(e.file_path,t);n.push({key:r.id,toolName:"Edit",subject:`[Edit] ${o}`,legacy:!0,changeClass:(0,h.q)(o),files:[{path:o,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 o=I(e.file_path,t);n.push({key:r.id,toolName:"Write",subject:`[Write] ${o}`,legacy:!0,changeClass:(0,h.q)(o),files:[{path:o,status:"added",old_string:"",new_string:e.content}]})}}return n}function $(e,t,n){var r;let o,s=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=>R(e,t))}});return r=s.length>0?s:D(t,n),o=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}(o.get(e.key));return t?{...e,fullSubject:`[${e.toolName}] ${t}`}:e})}function B(e){let t=!1,n=0,r=0;for(let o of e)(void 0!==o.additions||void 0!==o.deletions)&&(t=!0),n+=o.additions??0,r+=o.deletions??0;return t?{additions:n,deletions:r}:null}function _({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 O(e){let t=new Date(1e3*e),n=new Date,r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),l=`${r}-${o} ${s}:${a}`;return t.getFullYear()===n.getFullYear()?l:`${t.getFullYear()}-${l}`}function H({toolCalls:e,cwd:t,sessionId:n,onClose:u,onContentSearch:h,fullscreen:m,onToggleFullscreen:I}){let{t:V}=(0,s.Bd)(),U=(0,o.useRef)(null),[W,q]=(0,o.useState)(null);(0,o.useEffect)(()=>{q(U.current)},[]);let z=(0,o.useMemo)(()=>e.map(e=>e.id).filter(Boolean),[e]),K=z.join(","),[G,J]=(0,o.useState)(0);(0,o.useEffect)(()=>{J(0)},[K]);let Q=(0,l.Z)(t&&z.length>0?(0,L.se)(t,z,n):a.PyW([]),[t,n,K,G]),Y=(0,o.useMemo)(()=>e.filter(e=>(0,M.h)(e.name)).map(e=>e.id),[e]);(0,o.useEffect)(()=>{if("success"!==Q.status||G>=2)return;let e=new Set(Q.data.map(e=>e.commit.toolId));if(Y.some(t=>!e.has(t))){let e=setTimeout(()=>J(e=>e+1),2e3);return()=>clearTimeout(e)}},[Q,G,Y]);let Z=(0,o.useRef)([]),X="loading"===Q.status&&0===Z.current.length,ee=(0,o.useMemo)(()=>{if("success"===Q.status){let n=$(Q.data,e,t);return n.length>0&&(Z.current=n),n}return"loading"===Q.status&&Z.current.length>0?Z.current:"loading"===Q.status?[]:D(e,t)},[Q,e,t]),[et,en]=(0,o.useState)(!1),[er,eo]=(0,o.useState)(!1),es=(0,o.useMemo)(()=>ee.filter(e=>e.hash),[ee]),ea=(0,o.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})(es),[es]),el=(0,o.useMemo)(()=>er?es:es.slice(ea),[es,er,ea]),ei=(0,o.useMemo)(()=>{if(er||0===ea)return ee;let e=new Set(es.slice(0,ea).map(e=>e.key));return ee.filter(t=>!e.has(t.key))},[ee,es,er,ea]),ec=(0,o.useMemo)(()=>0===el.length||el.length<2&&0===ea?null:{base:el[0].parent??null,head:el[el.length-1].hash},[el,ea]),ed=!!t&&ee.length>=2,eu=null===ec;(0,o.useEffect)(()=>{et&&!ec&&en(!1)},[et,ec]);let eh=(0,l.Z)(et&&t&&ec?(0,L.Tt)(t,ec.base,ec.head):a.PyW(null),[et,t,ec?.base??"",ec?.head??""]),em=(0,o.useMemo)(()=>0===el.length||el.some(e=>!e.declared||0===e.declared.length)?null:new Set(el.flatMap(e=>e.declared)),[el]),ep=(0,o.useMemo)(()=>"success"===eh.status&&eh.data?eh.data.files.map(e=>R(e,em)):[],[eh,em]),ef="success"===eh.status&&eh.data?.truncated===!0,eg=et&&"loading"===eh.status,ex=et&&"error"===eh.status,[eb,ev]=(0,o.useState)(null),[ey,ew]=(0,o.useState)(null),[ek,eC]=(0,o.useState)(new Set),[ej,eN]=(0,o.useState)(()=>window.innerWidth>=768),[eS,eT]=(0,o.useState)("compact"),[eE,eL]=(0,o.useState)("unified"),[eM,eR]=(0,o.useState)(!1),[eA,eP]=(0,o.useState)(!1),[eF,eI]=(0,o.useState)(null),eD=(0,o.useMemo)(()=>ee.find(e=>e.key===eb)??null,[ee,eb]),e$=(0,o.useRef)(null);(0,o.useEffect)(()=>{eD&&(e$.current=eD)},[eD]);let eB=eD??e$.current,e_=(0,o.useMemo)(()=>et?ep:eB?.files??[],[et,ep,eB]),eO=(0,o.useMemo)(()=>(0,w.Do)(e_),[e_]),eH=(0,o.useMemo)(()=>e_.find(e=>e.path===ey)??null,[e_,ey]),eV=(0,o.useMemo)(()=>B(e_),[e_]),eU=(0,o.useCallback)(e=>{ev(e.key),ew(e.files[0]?.path??null),eC(new Set((0,w.Sz)((0,w.Do)(e.files))))},[]);(0,o.useEffect)(()=>{ei.length>0&&null==eb&&eU(ei[0])},[ei,eb,eU]),(0,o.useEffect)(()=>{null==eb||0===ei.length||ei.some(e=>e.key===eb)||ee.some(e=>e.key===eb)&&eU(ei[0])},[ee,ei,eb,eU]),(0,o.useEffect)(()=>{0===e_.length||ey&&e_.some(e=>e.path===ey)||ew(e_[0].path)},[e_,ey]),(0,o.useEffect)(()=>{et&&0!==ep.length&&eC(new Set((0,w.Sz)((0,w.Do)(ep))))},[et,ep]),(0,o.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(eM)return void eR(!1);if(eA)return void eP(!1);if(eF)return void eI(null);(0,i.k)(),u()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u,eM,eA,eF]);let eW=(0,o.useMemo)(()=>ei.reduce((e,t)=>e+t.files.length,0),[ei]),eq=e=>(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:e});return(0,r.jsx)(c.SU,{container:W,children:(0,r.jsxs)("div",{ref:U,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:`${p.o} px-3`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{onClick:u,"aria-label":V("common.close"),title:V("common.close"),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(f.A,{className:"w-4 h-4"})}),I&&(0,r.jsx)("button",{onClick:I,"aria-label":m?V("diffViewer.exitFull"):V("diffViewer.expandFull"),title:m?V("diffViewer.exitFull"):V("diffViewer.expandFull"),"aria-pressed":!0===m,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:m?(0,r.jsx)(g.A,{className:"w-4 h-4"}):(0,r.jsx)(x.A,{className:"w-4 h-4"})}),ed&&(0,r.jsx)("button",{onClick:()=>en(e=>!e),disabled:eu,"aria-pressed":et,title:eu?V("diffViewer.aggregateUnavailable"):et?V("diffViewer.aggregateOff"):V("diffViewer.aggregateOn"),className:`ml-0.5 px-2 py-0.5 text-xs rounded border transition-colors ${eu?"border-border text-foreground-subtle opacity-60 cursor-not-allowed":et?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:V("diffViewer.aggregate")})]}),(0,r.jsx)("div",{className:"w-px h-4 bg-border flex-shrink-0"}),(0,r.jsx)("button",{onClick:()=>eN(e=>!e),"aria-label":V("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors flex-shrink-0 ${ej?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:(0,r.jsx)(b.A,{className:"w-4 h-4"})}),(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground truncate",children:et?V("diffViewer.fileChangesAggregate",{count:e_.length}):V("diffViewer.fileChanges",{count:eW})})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[ej&&!et&&(0,r.jsxs)("div",{className:"w-60 flex-shrink-0 border-r border-border overflow-y-auto",children:[ea>0&&(0,r.jsx)("button",{onClick:()=>eo(e=>!e),"data-tooltip":V("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:er?V("diffViewer.callsBaselineShown",{count:ea}):V("diffViewer.callsBaselineHidden",{count:ea})}),ei.map(e=>{let t;return(0,r.jsxs)("div",{onClick:()=>eU(e),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${eb===e.key?"bg-brand/10":""}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.changeClass&&(0,r.jsx)(d.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:O(e.timestamp)})]}),(0,r.jsx)("div",{className:"text-sm text-foreground whitespace-pre-wrap break-words mt-0.5","data-tooltip":P(e),children:F(e,320,10)}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:V("commitDetail.nChanges",{count:e.files.length})}),(t=B(e.files))&&(t.additions>0||t.deletions>0)?(0,r.jsx)(_,{additions:t.additions,deletions:t.deletions}):null]})]},e.key)})]}),(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:X?eq(V("diffViewer.loadingSnapshots")):0===ee.length?eq(V("diffViewer.noChanges")):et||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:[et?(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"}),V("diffViewer.aggregateSummary",{count:e_.length,calls:el.length})]}),ea>0&&(0,r.jsx)("button",{onClick:()=>eo(e=>!e),"data-tooltip":V("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:er?V("diffViewer.aggregateBaselineIncluded",{count:ea}):V("diffViewer.aggregateBaselineSkipped",{count:ea})}),eV&&(eV.additions>0||eV.deletions>0)&&(0,r.jsx)(_,{additions:eV.additions,deletions:eV.deletions}),ef&&(0,r.jsx)("span",{className:"text-amber-11",children:V("diffViewer.truncated")})]}):eB?(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"}),eB.toolName]}),eB.shortHash&&(0,r.jsx)("span",{className:"font-mono text-brand",children:eB.shortHash}),void 0!==eB.timestamp&&(0,r.jsx)("span",{children:O(eB.timestamp)}),(0,r.jsx)("span",{className:"flex-1 min-w-0 whitespace-pre-wrap break-words","data-tooltip":P(eB),children:F(eB,640,6)}),eB.truncated&&(0,r.jsx)("span",{className:"text-amber-11",children:V("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":V("diffViewer.reconstructedHint"),children:V("diffViewer.reconstructed")})]}):null,(0,r.jsx)("div",{className:"ml-auto flex items-center gap-2",children:!eH?.isImage&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(k.y,{value:eS,onChange:eT}),(0,r.jsx)(C.q,{value:eE,onChange:eL})]})})]}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[ej&&(0,r.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:eg?(0,r.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:V("diffViewer.aggregateLoading")}):(0,r.jsx)(w.VO,{files:eO,selectedPath:ey,expandedPaths:ek,onToggle:e=>eC(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{!e.isDirectory&&e.file&&(ew(e.file.path),window.innerWidth<768&&eN(!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":V("diffViewer.externalChange")})}):null}})}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:eH?eH.isImage?(0,r.jsx)(j.K,{filePath:eH.path,oldSrc:t&&eH.oldRev?A(t,eH.oldRev,eH.path):null,newSrc:t&&eH.newRev?A(t,eH.newRev,eH.path):null}):eH.unviewable?(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:V("diffViewer.notViewable")}):"unified"===eE?(0,r.jsx)(N.xU,{oldContent:eH.old_string,newContent:eH.new_string,filePath:eH.path,cwd:t,enableComments:!0,onContentSearch:h,compact:"compact"===eS,onPreview:"deleted"===eH.status?void 0:(0,S.e$)(eH.path)?()=>eR(!0):(0,S.aR)(eH.path)?()=>eP(!0):eH.path.endsWith(".json")?()=>eI({content:eH.new_string,filePath:eH.path}):void 0,previewLabel:eH.path.endsWith(".json")?V("common.readable"):V("common.preview")}):(0,r.jsx)(N.xZ,{oldContent:eH.old_string,newContent:eH.new_string,filePath:eH.path,isNew:"added"===eH.status,isDeleted:"deleted"===eH.status,cwd:t,enableComments:!0,onContentSearch:h,compact:"compact"===eS,onPreview:"deleted"===eH.status?void 0:(0,S.e$)(eH.path)?()=>eR(!0):(0,S.aR)(eH.path)?()=>eP(!0):eH.path.endsWith(".json")?()=>eI({content:eH.new_string,filePath:eH.path}):void 0,previewLabel:eH.path.endsWith(".json")?V("common.readable"):V("common.preview")}):(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:eg?V("diffViewer.aggregateLoading"):ex?V("diffViewer.aggregateFailed"):et&&0===e_.length?V("diffViewer.aggregateEmpty"):V("diffViewer.selectFileToView")})})]})]}):eq(V("diffViewer.selectFileToView"))})]}),eM&&eH&&(0,r.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>eR(!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)(T.M,{content:eH.new_string,filePath:eH.path,cwd:t||"",onClose:()=>eR(!1)})})}),eA&&eH&&(0,r.jsx)(E.N,{filePath:eH.path,content:eH.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:()=>eI(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:()=>eI(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,r.jsx)(f.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,S.xb)(eF.content)})})]})})]})})}function V({toolCalls:e,cwd:t,sessionId:n,onClose:o,onContentSearch:s}){return(0,r.jsx)(u.ZL,{children:(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:o,children:(0,r.jsx)(H,{toolCalls:e,cwd:t,sessionId:n,onClose:o,onContentSearch:s?e=>{o(),s(e)}:void 0})})})}},56045:(e,t,n)=>{n.d(t,{_:()=>l,o:()=>a});var r=n(12115),o=n(69809);let s="json-search-highlight-style";function a(e){let[t,n]=(0,r.useState)(!1),[o,a]=(0,r.useState)(""),[l,i]=(0,r.useState)(!1),[c,d]=(0,r.useState)(0),[u,h]=(0,r.useState)(0),m=(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||!o){d(0),h(0);return}!function(){if(document.getElementById(s))return;let e=document.createElement("style");e.id=s,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?o:o.toLowerCase(),i=l?r:r.toLowerCase(),c=[],u=0;for(;u<i.length;){let e=i.indexOf(a,u);if(-1===e)break;c.push([e,e+a.length]),u=e+1}if(0===c.length){d(0),h(0);return}let m=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),f=0,g=0,x=[],b=null,v=0;for(;(t=m.nextNode())&&g<c.length;){let e=t.textContent?.length||0,n=f,r=f+e;for(;g<c.length;){let[e,o]=c[g];if(e>=r)break;if(!b)if(e>=n)(b=document.createRange()).setStart(t,e-n),v=o;else break;if(v<=r)b.setEnd(t,v-n),x.push(b),b=null,g++;else break}f=r}p.current=x,d(x.length),h(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,o,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(),o=e.current?.parentElement;o&&g(o,r)},[e,g]);(0,r.useEffect)(()=>{queueMicrotask(()=>f())},[f]),(0,r.useEffect)(()=>{x(u)},[u,c,x]),(0,r.useEffect)(()=>{let t=e.current;if(!t||!o)return;let n=new MutationObserver(()=>f());return n.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>n.disconnect()},[e,o,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!==c&&h(e=>(e+1)%c)},[c]),v=(0,r.useCallback)(()=>{0!==c&&h(e=>(e-1+c)%c)},[c]),y=(0,r.useCallback)(()=>{n(!0),setTimeout(()=>m.current?.focus(),0)},[]),w=(0,r.useCallback)(()=>{n(!1),a(""),h(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:o,setQuery:a,caseSensitive:l,setCaseSensitive:i,matchCount:c,currentIndex:u,searchInputRef:m,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:o.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:o.A.t("codeViewer.caseSensitive")},"Aa"),r.createElement("span",{className:"text-xs text-muted-foreground"},e.matchCount>0?`${e.currentIndex+1}/${e.matchCount}`:o.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:o.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:o.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:o.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:()=>s});var r=n(12115),o=n(17196);function s(e,t){let[n,s]=(0,r.useState)(null),[a,l]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=()=>{l(document.documentElement.classList.contains("dark"))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);let i=(0,r.useMemo)(()=>e.join("\n"),[e]),c=`${i}:${t}:${a}`,d=(0,r.useMemo)(()=>n&&n.key===c?n.html:e.map(e=>(0,o.ZD)(e||" ")),[e,c,n]);return(0,r.useEffect)(()=>{if(0===e.length)return;let n=!1;return(async()=>{try{let r=await (0,o.kS)();if(n)return;let l=(0,o.sQ)(t),i=e.join("\n"),d=r.codeToTokens(i,{lang:l,theme:a?"github-dark":"github-light"}),u=[];for(let e=0;e<d.tokens.length;e++)if(u[e]=(0,o.b8)(d.tokens[e]),e%500==0&&e>0&&(await new Promise(e=>setTimeout(e,0)),n))return;s({key:c,html:u})}catch(e){console.error("Line highlight error:",e)}})(),()=>{n=!0}},[i,t,a]),d}},57125:(e,t,n)=>{n.d(t,{$T:()=>m,Aw:()=>p,CX:()=>c,Fx:()=>h,H:()=>a,XY:()=>b,ch:()=>l,eV:()=>g,hG:()=>x,pe:()=>d,yI:()=>u,ys:()=>f});var r=n(95155);n(12115);var o=n(94514),s=n(66088);let a={claude:"Claude",codex:"Codex",deepseek:"DeepSeek",kimi:"Kimi",glm:"GLM",ollama:"Ollama"};function l(e){return!!e&&e in a}let i={claude:0,codex:1,deepseek:2,glm:3,kimi:4,ollama:5},c=Object.keys(i).sort((e,t)=>i[e]-i[t]),d={claude:"text-[#c6532d] dark:text-[#D97757]",codex:"text-emerald-600 dark:text-emerald-400",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"},u="bg-accent font-medium text-foreground",h="focus:border-brand",m="bg-brand text-white hover:bg-brand/90",p="text-rose-600 dark:text-rose-400",f="fixed z-[9999] max-h-[70vh] overflow-y-auto rounded-lg border border-border bg-popover py-2 shadow-lv2";function g({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 x({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 b({label:e,title:t,onClick:n,buttonRef:o,icon:a,labelClassName:l,labelMaxWidth:i="max-w-[160px]",testId:c}){return(0,r.jsxs)("button",{ref:o,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",title:t,"data-testid":c,children:[a,(0,r.jsx)("span",{className:`truncate ${i} ${l??""}`,children:e}),(0,r.jsx)(s.A,{className:"h-3 w-3 flex-shrink-0"})]})}},58250:(e,t,n)=>{n.d(t,{U:()=>s,k:()=>o});let r=(0,n(93964).N)("cockpit-skills"),o=r.notify,s=r.subscribe},60938:(e,t,n)=>{n.d(t,{DZ:()=>i,Ft:()=>h,Nn:()=>v,OJ:()=>g,VK:()=>y,YW:()=>u,__:()=>b,dt:()=>x,eA:()=>f,eE:()=>m,gZ:()=>c,mP:()=>l,nM:()=>w,r6:()=>p,r9:()=>d});var r=n(49433),o=n(82680);let s=(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 o.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 o.uV({message:`POST ${e} failed`,cause:t})}),l=e=>s(`/api/files/init?cwd=${encodeURIComponent(e)}`),i=e=>s(`/api/files/index?cwd=${encodeURIComponent(e)}`),c=(e,t)=>s(`/api/files/readdir?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`),d=e=>s(`/api/files/recent?cwd=${encodeURIComponent(e)}`),u=(e,t,n)=>a("/api/files/recent",{cwd:e,file:t,...n??{}}),h=(e,t)=>a("/api/files/expanded",{cwd:e,paths:t}),m=(e,t)=>s(`/api/files/blame?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`).pipe(r.h9N(e=>r.PyW({error:e.message}))),p=(e,t)=>{let n,s;return n=`/api/files/stat?cwd=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`,s={cache:"no-store"},r.$mh({try:async()=>{let e=await fetch(n,s),t=null;try{t=await e.json()}catch{}return{status:e.status,ok:e.ok,data:t}},catch:e=>new o.uV({message:`GET ${n} failed`,cause:e})})},f=e=>s(`/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 o.uV({message:"POST /api/files/save failed",cause:e})}),x=()=>s("/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 o.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 o.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 o.uV({message:"POST /api/files/delete failed",cause:e})}),w=e=>s(`/api/file?path=${encodeURIComponent(e)}`)},62111:(e,t,n)=>{n.d(t,{E:()=>s,k:()=>o});var r=n(12115);function o(){"u">typeof document&&document.activeElement instanceof HTMLElement&&document.activeElement.blur()}function s(e,t=!0){(0,r.useEffect)(()=>{if(!t)return;let n=t=>{"Escape"===t.key&&(o(),e())};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,t])}},63040:(e,t,n)=>{n.d(t,{m3:()=>a,mi:()=>o,ot:()=>s});var r=n(37640);let o=()=>(0,r.zi)("/api/html-apps"),s=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:()=>h,ZL:()=>d,a9:()=>u});var r=n(95155),o=n(12115),s=n(47650);let a=()=>()=>{},l=()=>document.body,i=()=>null,c=(0,o.createContext)(null);function d({children:e}){let t=(0,o.useContext)(c),n=(0,o.useSyncExternalStore)(a,l,i),r=t??n;return r?(0,s.createPortal)(e,r):null}function u({children:e}){let[t,n]=(0,o.useState)(null);return(0,r.jsxs)("div",{className:"relative w-full h-full",style:{transform:"translateZ(0)"},children:[(0,r.jsx)(c.Provider,{value:t,children:e}),(0,r.jsx)("div",{ref:n,className:"absolute inset-0 pointer-events-none [&>*]:pointer-events-auto"})]})}function h(){return(0,o.useContext)(c)}},65153:(e,t,n)=>{n.d(t,{u:()=>i});var r=n(12115),o=n(2111),s=n(19095),a=n(14594),l=n(98245);function i(e,t,n,i,c){let d=(0,r.useRef)(null),u=(0,r.useRef)(0),h=(0,r.useRef)(0),m=(0,r.useRef)(!1),p=(0,r.useRef)(!1),f=(0,r.useRef)(!1),g=(0,r.useRef)(void 0),x=(0,r.useRef)(!1),b=()=>{let e=`live-asst-${++u.current}`;return d.current=e,t(t=>[...t,{id:e,role:"assistant",content:"",isStreaming:!0}]),e},v=e=>{if((0,a.Nn)(e))return;let n=e=>{c?.onLiveOutputTokens?.({outputTokens:Math.max(0,Math.round(e))})},r=e=>{!m.current&&"string"==typeof e&&e&&(h.current+=(0,s.r)(e),n(h.current))};if("system"===e.type&&"init"===e.subtype){let e=p.current;f.current=!0,e||(h.current=0,m.current=!1,c?.onLiveOutputTokens?.(null),c?.onRunStartedAt?.(Date.now())),x.current=!1,b();return}if("usage_update"===e.type){"number"==typeof e.output_tokens&&Number.isFinite(e.output_tokens)&&(m.current=!0,h.current=Math.max(h.current,Math.round(e.output_tokens)),n(h.current));return}if("stream_event"===e.type){let n=e.event;if(x.current&&n?.type==="message_start"){x.current=!1;let e=d.current;e&&t(t=>t.map(t=>t.id===e?{...t,isStreaming:!1}:t)),b()}n?.type==="content_block_delta"&&n.delta?.type==="text_delta"&&r(n.delta.text)}if("system"===e.type&&"background_tasks_changed"===e.subtype){let t=e.tasks??[];c?.onBackgroundTasks?.(t.filter(e=>!e.ambient).map(e=>({task_id:e.task_id,description:e.description})));return}if((0,a.A7)(e)&&(c?.taskStore?.applyEvent(e),t(t=>(0,a.FM)(t,e,{engine:i,assistantId:d.current??""})),"task_notification"!==e.subtype))return;if("system"===e.type&&"task_notification"===e.subtype){if(!f.current){let n=`live-tasknotif-${e.task_id||++u.current}`,r=`<task-notification>
|
|
728
728
|
`+(e.task_id?`<task-id>${e.task_id}</task-id>
|
|
729
729
|
`:"")+(e.tool_use_id?`<tool-use-id>${e.tool_use_id}</tool-use-id>
|
|
730
730
|
`:"")+(e.status?`<status>${e.status}</status>
|
|
731
731
|
`:"")+(e.summary?`<summary>${e.summary}</summary>
|
|
732
732
|
`:"")+(e.output_file?`<output-file>${e.output_file}</output-file>
|
|
733
|
-
`:"")+"</task-notification>";t(t=>[...t,{id:n,role:"system",content:e.summary||"",systemEvent:{kind:"task-notification",...e.status?{status:e.status}:{},detail:r}}])}return}if("system"===e.type&&"notice"===e.subtype){let n=(0,l.C)(e,`live-notice-${++u.current}`);n&&t(e=>[...e,n]);return}if("user"===e.type&&e._human){let n=e.message?.content,r="string"==typeof n?n:Array.isArray(n)?n.map(e=>e?.text||"").join(""):"",o="string"==typeof e._turnId?e._turnId:null;o&&(g.current=o);let s="number"==typeof e._ts?e._ts:null,a=o?`live-user-${o}`:`live-user-${++u.current}`;t(e=>{if(o&&e.some(e=>e.id===a))return e;for(let t=e.length-1;t>=0;t--){if("user"!==e[t].role)continue;let n=e[t].timestamp?Date.parse(e[t].timestamp):NaN;if(null===s||Number.isNaN(n)){if(e[t].content===r)return e}else if(n>=s)return e;break}return[...e,{id:a,role:"user",content:r}]});return}if("result"===e.type&&(f.current=!1,p.current=!0),"assistant"===e.type&&Array.isArray(e.message?.content))for(let t of e.message.content)t.text?r(t.text):t.name&&r(`${t.name} ${JSON.stringify(t.input??{})}`);if("user"===e.type&&Array.isArray(e.message?.content))for(let t of e.message.content)r("string"==typeof t.content?t.content:JSON.stringify(t.content??""));let o=d.current??x();t(t=>(0,a.FM)(t,e,{engine:i,assistantId:o}))};(0,o.h)({url:e?`/ws/session-stream?sessionId=${encodeURIComponent(e)}`:"/ws/session-stream",enabled:n&&!!e,onMessage:e=>{if("run-snapshot"===e.type&&Array.isArray(e.events)){if("string"==typeof e.runId&&e.runId&&(g.current=e.runId),"running"!==e.status){c?.onRunningChange?.(!1),c?.onLiveOutputTokens?.(null),c?.onRunStartedAt?.(null),c?.onBackgroundTasks?.([]),t(a.fD),c?.taskStore?.settleRunning(),h.current=0,m.current=!1,p.current=!1;return}let n=e.events.find(e=>e?.type==="user"&&e?._human),r=n?.message?.content,o="string"==typeof r?r:"",s=new Set,l=new Set;for(let t of e.events){let e=t?.uuid;if("string"==typeof e&&s.add(e),t?.type==="assistant"&&Array.isArray(t.message?.content))for(let e of t.message.content)e?.name&&"string"==typeof e.id&&l.add(e.id)}let i="number"==typeof e.startedAt?e.startedAt:null;t(e=>{let t=e.filter(e=>!("string"==typeof e.id&&e.id.startsWith("live-"))),n=t[t.length-1],r=n?.timestamp?Date.parse(n.timestamp):NaN;if(null!==i&&!Number.isNaN(r)){let e=t.length;for(;e>0;){let n=t[e-1],r=n.timestamp?Date.parse(n.timestamp):NaN;if(!Number.isNaN(r)&&r>=i)e--;else break}return e<t.length?t.slice(0,e):t}if(!o)return t;let a=-1;for(let e=t.length-1;e>=0;e--)if("user"===t[e].role){t[e].content===o&&(a=e);break}return -1===a?t:t.slice(a+1).every(e=>"assistant"===e.role&&("string"==typeof e.id&&s.has(e.id)||!!e.toolCalls?.length&&e.toolCalls.every(e=>l.has(e.id))))?t.slice(0,a):t}),d.current=null,u.current=0,h.current=0,m.current=!1,p.current=!1,f.current=!1;let x="number"==typeof e.outputTokens&&Number.isFinite(e.outputTokens)?Math.max(0,Math.round(e.outputTokens)):null;for(let t of(null!==x&&(h.current=x,m.current=!0,c?.onLiveOutputTokens?.({outputTokens:x})),e.events))b(t);c?.onRunningChange?.(!0),c?.onRunStartedAt?.("number"==typeof e.startedAt?e.startedAt:Date.now())}else if("run-event"===e.type&&e.message){if("run-ended"===e.message.type){c?.onRunningChange?.(!1),c?.onLiveOutputTokens?.(null),c?.onRunStartedAt?.(null),c?.onBackgroundTasks?.([]),t(a.fD),c?.taskStore?.settleRunning(),h.current=0,m.current=!1,p.current=!1,c?.onComplete?.();return}b(e.message),c?.onRunningChange?.(!0)}else"run-idle"===e.type&&(c?.onRunningChange?.(!1),c?.onLiveOutputTokens?.(null),c?.onRunStartedAt?.(null),c?.onBackgroundTasks?.([]),t(a.fD),c?.taskStore?.settleRunning(),h.current=0,m.current=!1,p.current=!1)}})}},67589:(e,t,n)=>{n.d(t,{z:()=>l,m:()=>c});var r=n(12115),o=n(49433),s=n(86957),a=n(82680);let l=e=>o.$mh({try:async()=>{let t=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?await t.json():null},catch:e=>new a.uV({message:"session-by-path failed",cause:e})}),i=new Map;function c(e,t,n,{cwd:d,initialSessionId:u,onSessionId:h,onTitleChange:m,onTokenUsage:p,liveRunningRef:f}){let[g,x]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[y,w]=(0,r.useState)(!1),[k,C]=(0,r.useState)(void 0),[j,N]=(0,r.useState)(0),[S,T]=(0,r.useState)(null),[E,L]=(0,r.useState)(null),[M,R]=(0,r.useState)(null),A=(0,r.useRef)(null);A.current=S;let P=(0,r.useRef)(m);P.current=m;let F=(0,r.useRef)(p);F.current=p;let I=(0,r.useRef)(void 0),$=(0,r.useRef)(0),D=(0,r.useCallback)(async(e,n,r=!1,o,a,c=!1)=>{if(r){let e=Date.now();if(!c&&e-$.current<5e3)return;$.current=e}let d=(e,r)=>{e.fingerprint&&(I.current=e.fingerprint),void 0!==e.totalTurns&&N(e.totalTurns),void 0!==e.hasMore&&w(e.hasMore),e.messages&&e.messages.length>0&&(r?t(t=>(function(e,t){if(0===t.length)return e;let n=0;if(e.length>0&&e[0].id!==t[0].id){n=-1;for(let r=e.length-1;r>=0;r--)if(e[r].id===t[0].id){n=r;break}}if(n<0)return t;let r=e.slice(n),o=0;for(let e=0;e<Math.min(r.length,t.length)&&r[e].id===t[e].id&&r[e].content===t[e].content;e++)o=e+1;return o===r.length&&o===t.length?e:o===r.length&&o<t.length?[...e,...t.slice(o)]:[...e.slice(0,n),...r.slice(0,o),...t.slice(o)]})(t,e.messages)):f?.current||t(e.messages),T(n)),e.sessionId&&h(e.sessionId),e.engine&&L(e.engine),R(e.bot??null),e.title&&P.current?.(e.title),e.usage&&F.current?.({inputTokens:e.usage.input_tokens||0,outputTokens:e.usage.output_tokens||0,cacheCreationInputTokens:e.usage.cache_creation_input_tokens||0,cacheReadInputTokens:e.usage.cache_read_input_tokens||0,totalCostUsd:0})},u=`${e}::${n}`;c&&i.delete(u);let m=!r&&void 0===a,p=m?i.get(u):void 0;r||(p?d(p.data,!1):x(!0));try{let t={cwd:e,sessionId:n,limit:o,beforeTurnIndex:a};r&&I.current?t.ifFingerprint=I.current:p&&(t.ifFingerprint=p.fingerprint);let c=await s.t4.runPromiseExit(l(t));if("Success"===c._tag&&c.value){let e=c.value;if(e.notModified)return;if(d(e,r),m&&e.fingerprint&&e.messages&&e.messages.length>0&&(i.delete(u),i.set(u,{data:e,fingerprint:e.fingerprint}),i.size>20)){let e=i.keys().next().value;void 0!==e&&i.delete(e)}}}catch(e){console.error("Failed to load history by cwd and sessionId:",e)}finally{r||x(!1)}},[t,h]),B=(0,r.useCallback)(async()=>{if(d&&n&&!b&&y){v(!0);try{let r=void 0!==k?k:j-Math.ceil(e.filter(e=>"user"===e.role).length),o=await s.t4.runPromiseExit(l({cwd:d,sessionId:n,limit:10,beforeTurnIndex:r>0?r:void 0}));if("Success"===o._tag&&o.value){let e=o.value;if(e.messages&&e.messages.length>0){t(t=>[...e.messages,...t]);let o=e.messages.filter(e=>"user"===e.role).length;C(e.startTurnIndex??r-o),T(n)}void 0!==e.hasMore&&w(e.hasMore),e.fingerprint&&(I.current=e.fingerprint)}else"Failure"===o._tag&&console.error("Failed to load more history:",o.cause)}finally{v(!1)}}},[d,n,b,y,k,j,e,t]),O=(0,r.useCallback)(async e=>{let r=A.current??n;if(d&&r&&!(e<0)){v(!0);try{let n=await s.t4.runPromiseExit(l({cwd:d,sessionId:r,fromTurnIndex:e}));if("Failure"===n._tag)return void console.error("Failed to load turns for jump:",n.cause);if(!n.value||A.current&&A.current!==r)return;let o=n.value;if(o.messages&&o.messages.length>0){let n=o.messages;t(e=>(function(e,t){if(0===t.length)return e;let n=new Set(t.map(e=>e.id)),r=e.map(e=>n.has(e.id)).lastIndexOf(!0);if(r<0)return t;let o=e.slice(r+1);return 0===o.length?t:[...t,...o]})(e,n)),C(o.startTurnIndex??e),T(r)}void 0!==o.totalTurns&&N(o.totalTurns),void 0!==o.hasMore&&w(o.hasMore),o.fingerprint&&(I.current=o.fingerprint)}finally{v(!1)}}},[d,n,t]),_=(0,r.useCallback)(async e=>{if(!d)return;x(!0);let n=o.$mh({try:async()=>{let t=await fetch(`/api/session/${encodeURIComponent(e)}/history?cwd=${encodeURIComponent(d)}`);return t.ok?await t.json():null},catch:e=>new a.uV({message:"load session history failed",cause:e})}),r=await s.t4.runPromiseExit(n);"Success"===r._tag&&r.value?.messages&&r.value.messages.length>0?(t(r.value.messages),T(e)):"Failure"===r._tag&&console.error("Failed to load history:",r.cause),x(!1)},[d,t]);return(0,r.useEffect)(()=>{d&&u&&D(d,u,!1,10)},[]),{isLoadingHistory:g,isLoadingMore:b,hasMoreHistory:y,loadMoreHistory:B,ensureTurnLoaded:O,loadHistory:_,loadHistoryByCwdAndSessionId:D,loadedSessionId:S,loadedEngine:E,loadedBot:M}}},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"},69809:(e,t,n)=>{n.d(t,{A:()=>a});var r=n(50931);let o=JSON.parse('{"common":{"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":{"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","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 is outside this project — only Markdown, CSV and images can be previewed","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.","reloadNow":"Reload","upgradeCommandCopied":"Copied `cockpit update`","projectNotes":"Project Notes","closeProject":"Close project","bots":"Bots"},"mobile":{"useDesktop":"Desktop","messagePlaceholder":"Message…","send":"Send","stop":"Stop","enableNotifications":"Enable notifications","disableNotifications":"Disable notifications","notifyError":"Could not enable notifications"},"sessions":{"recentSessions":"Recent Sessions","favorites":"Favorite Sessions","noFavorites":"No favorite sessions yet. Click the star in the tab bar to add.","addFavorite":"Add to favorites","removeFavorite":"Remove from favorites","runningCount":"{{count}} running","unreadCount":"{{count}} unread","noSessions":"No sessions yet","running":"Running","done":"Done","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..."},"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 ({{minutes}}min)","everyNMinutes":"Every {{minutes}}min","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}})","groupPendingReview":"Finished \xb7 to review","groupUpcoming":"Running \xb7 upcoming","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","customMinutes":"Custom minutes","cronPlaceholder":"e.g. 0 9 * * 1-5 (weekdays at 9am)","cronFormat":"Format: min hour day month weekday (e.g. 0 9 * * 1-5)","minutesPlaceholder":"Minutes","limitTimeRange":"Limit execution time range","to":"to","saveBtn":"Save ({{modKey}}↩)","createBtn":"Create ({{modKey}}↩)","5minLater":"In 5 minutes","15minLater":"In 15 minutes","30minLater":"In 30 minutes","1hourLater":"In 1 hour","every15min":"Every 15 min","every30min":"Every 30 min","every1hour":"Every 1 hour","every2hours":"Every 2 hours","daily9am":"Daily 09:00","daily6pm":"Daily 18:00","weeklyMon9am":"Mon 09:00","monthly1st9am":"1st of month 09:00"},"runningTerminals":{"title":"Terminals","status":"{{count}} terminal(s) \xb7 {{projects}} project(s)","keys":"↑↓ select \xb7 Enter 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","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","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","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":{"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","deleteTurn":"Delete turn","deletingTurn":"Deleting…","deleteTurnConfirm":"Delete this question, answer, and its 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","toolCalls":"{{count}} tool calls","collapse":"▲ Collapse","expand":"▼ Expand","showMore":"Show more","showLess":"Show less","subagent":"Subagent","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","placeholder":"Type a message, Enter to send (Shift+Enter for new line, paste images; start a line with / (skill), /@ (skill in a subagent) or @ (bot in a subagent), multiple allowed)","placeholderDisabled":"Generating... you can keep typing (ESC to cancel; if stuck, cancel and resend \'continue\')","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.","outputStyle":"Output style","outputStyleNone":"None","noOutputStyles":"No output styles yet — add one with the pencil","editOutputStyles":"Edit output styles","outputStylesMarkdownHint":"Start each style with \\"# Name\\". Everything up to the next \\"# \\" is appended verbatim to the end of the system prompt (multi-line; deeper headings like ## are content).","outputStylesMarkdownPlaceholder":"# Concise\\nAnswer in at most three sentences, no preamble.\\n\\n# Teacher\\nExplain why before how.","outputStylesError":{"content-before-heading":"Line {{line}}: content must come after a \\"# Name\\" heading.","empty-style":"Line {{line}}: a style needs both a name and content.","duplicate-name":"Line {{line}}: duplicate style name."},"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","namePlaceholder":"Name","commandPlaceholder":"Command","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","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":"Cockpit Bridge installed","extensionNotInstalled":"Cockpit Bridge not installed","extensionDescription":"After installing the Chrome extension, link navigation in iframes will be intercepted: new tab links create new bubbles, page navigation updates the current bubble.","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"},"editor":{"placeholder":"Write something... Type / for commands","noteTitle":"{{name}} - Notes","noteUntitled":"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","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…","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 tab","closeAll":"Close all tabs","newTab":"New tab"},"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"},"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":{"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","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"}}'),s=JSON.parse('{"common":{"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":{"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":"无效","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":"文件在当前项目之外,仅支持预览 Markdown、CSV 和图片","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 已在后台更新。","reloadNow":"刷新","upgradeCommandCopied":"已复制 `cockpit update`","projectNotes":"项目笔记","closeProject":"关闭项目","bots":"机器人"},"mobile":{"useDesktop":"桌面版","messagePlaceholder":"发消息…","send":"发送","stop":"停止","enableNotifications":"开启通知","disableNotifications":"关闭通知","notifyError":"无法开启通知"},"sessions":{"recentSessions":"最近会话","favorites":"收藏会话","noFavorites":"暂无收藏会话,在 Tab 栏点击星标可添加","addFavorite":"收藏此会话","removeFavorite":"取消收藏","runningCount":"{{count}} 运行中","unreadCount":"{{count}} 未读","noSessions":"暂无会话记录","running":"运行中","done":"完成","editTitle":"编辑标题","projectSessions":"项目会话","browseAllSessions":"浏览所有会话","sessionList":"会话列表","search":"搜索","searchSessions":"搜索会话...","searchRecentSessions":"搜索最近会话","loadSessionsFailed":"加载会话失败","loadingSessions":"加载会话中...","noMatchingSessions":"未找到匹配的会话","noSessionsYet":"暂无会话","projectList":"项目列表","openFolder":"打开文件夹","loadingHistory":"加载历史消息..."},"scheduledTasks":{"title":"定时任务","aboutToTrigger":"即将触发","secondsLater":"{{count}}秒后","minutesLater":"{{count}}分钟后","hoursMinutesLater":"{{h}}小时{{m}}分后","hoursLater":"{{h}}小时后","onceType":"一次性 ({{minutes}}分钟)","everyNMinutes":"每{{minutes}}分钟","completed":"已完成","paused":"已暂停","activeCount":"{{running}} 个活跃","pausedCount":"{{paused}} 个暂停","noScheduledTasks":"暂无定时任务,在聊天输入栏点击时钟按钮创建","lastResult":"上次","runNow":"立即运行","deleteFailed":"删除任务失败","resume":"恢复","pause":"暂停","completedCount":"已完成 ({{count}})","groupPendingReview":"运行完成待查看","groupUpcoming":"运行中 \xb7 待运行","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 表达式","customMinutes":"自定义分钟数","cronPlaceholder":"例: 0 9 * * 1-5 (工作日9点)","cronFormat":"格式:分 时 日 月 星期(如 0 9 * * 1-5)","minutesPlaceholder":"分钟数","limitTimeRange":"限制执行时段","to":"至","saveBtn":"保存 ({{modKey}}↩)","createBtn":"创建 ({{modKey}}↩)","5minLater":"5 分钟后","15minLater":"15 分钟后","30minLater":"30 分钟后","1hourLater":"1 小时后","every15min":"每 15 分钟","every30min":"每 30 分钟","every1hour":"每 1 小时","every2hours":"每 2 小时","daily9am":"每天 09:00","daily6pm":"每天 18:00","weeklyMon9am":"每周一 09:00","monthly1st9am":"每月 1 号 09:00"},"runningTerminals":{"title":"终端","status":"{{count}} 个终端 \xb7 {{projects}} 个项目","keys":"↑↓ 选择 \xb7 Enter 跳转 \xb7 Del 停止 \xb7 Esc 关闭","empty":"没有正在运行的终端","currentProject":"当前项目","stop":"停止","confirmStop":"停止这个进程?","stopping":"停止中…","stopFailed":"停止终端失败","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":"重新构建项目图","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":"无差异文件","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":{"startConversation":"开始对话吧","loadMoreHistory":"加载更多...","scrollUpForMore":"↑ 向上滚动加载更多历史","jumpToStart":"跳转到开始","jumpToLatest":"跳转到最新","jumpToPrevUserMessage":"上一条用户消息","jumpToNextUserMessage":"下一条用户消息","recentUserMessages":"最近的用户消息","moreUserMessages":"更多","userMessage":"用户消息","recentUserMessageNumber":"最近用户消息 {{index}}/{{total}}","imageMessage":"图片消息","copyMessage":"复制消息","copyImage":"复制图片","copiedImage":"已复制图片","forkSession":"从此处分叉会话","excerptTurn":"摘录本轮到新会话","newSession":"新建会话","continueFromHere":"延续到此处","continueFromHereDesc":"保留截至本轮的全部上下文","onlyThisTurn":"仅提取本轮","onlyThisTurnDesc":"只带这一轮问答","deleteTurn":"删除本轮","deletingTurn":"正在删除…","deleteTurnConfirm":"确定删除这一轮的问题、回答及工具记录吗?此操作无法撤销。","deleteTurnConfirmAction":"删除本轮","deleteTurnWhileRunning":"会话运行期间不能删除","sendToPeerPane":"发送本条消息到另一栏","imageN":"图片 {{index}}","imagePreview":"图片预览","toolCalls":"{{count}} 个工具调用","collapse":"▲ 收起","expand":"▼ 展开","showMore":"显示更多","showLess":"收起","subagent":"子代理","subagentEmpty":"未找到子代理消息记录","subagentViewTitle":"查看子代理执行过程","workflowRun":"运行详情","workflowViewTitle":"查看工作流运行详情","workflowEmpty":"未找到工作流运行记录","workflowAgents":"个代理","workflowViewAgent":"查看","workflowUngrouped":"未分组","viewQuestions":"查看提问","viewAllFileChanges":"查看所有文件变更","requestFailed":"请求失败","cannotReadStream":"无法读取响应流","errorRetry":"发生错误,请重试","codexResumeFailed":"原会话被其他 Codex 客户端占用,已新建会话,历史未继承","codexResumeFailedPrevious":"原会话","codexResumeFailedNew":"新会话","placeholder":"输入消息,Enter 发送(Shift+Enter 换行,可粘贴图片;行首 /(skill)、/@(子代理执行 skill)或 @(子代理执行机器人),支持多行多命令)","placeholderDisabled":"生成中... 可继续输入 (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":"不带历史上下文:每条消息单独发给模型,不带之前的对话。上方的会话记录照常保留。","outputStyle":"输出风格","outputStyleNone":"无","noOutputStyles":"暂无输出风格,点右上角铅笔添加","editOutputStyles":"编辑输出风格","outputStylesMarkdownHint":"每个风格以「# 名称」开头,下面直到下一个「# 」之间的内容原样追加到 System Prompt 末尾(可多行,## 等更深标题视为正文)。","outputStylesMarkdownPlaceholder":"# 简洁\\n回答不超过三句话,不要开场白。\\n\\n# 教学\\n先讲为什么,再讲怎么做。","outputStylesError":{"content-before-heading":"第 {{line}} 行:内容必须写在「# 名称」之后。","empty-style":"第 {{line}} 行:风格需要名称和内容。","duplicate-name":"第 {{line}} 行:风格名称重复。"},"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":"暂无自定义命令","namePlaceholder":"名称","commandPlaceholder":"命令","restoreTooltip":"还原 ({{modKey}}M / ESC)","screenshotting":"截图中...","outputFileDeleted":"[输出文件已删除]"},"browser":{"blankPage":"空白页","copyUrl":"复制网址","openInNewWindow":"在新窗口打开","exitMaximize":"退出最大化 ({{modKey}}M)","maximize":"最大化 ({{modKey}}M)","pageLoadFailed":"页面加载失败","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":"Cockpit Bridge 已安装","extensionNotInstalled":"Cockpit Bridge 未安装","extensionDescription":"安装 Chrome 插件后,iframe 内的链接跳转将被拦截:新标签链接创建新气泡,页面内导航更新当前气泡。","installSteps":"安装步骤:","step1":"1. 打开 Chrome 地址栏输入","step2":"2. 开启右上角「开发者模式」","step3":"3. 点击「加载已解压的扩展程序」","step4mac":"4. 按 <kbd>Cmd+Shift+G</kbd> → 粘贴下方路径 → 回车","copyExtensionPath":"复制插件目录路径","reloadExtension":"重载插件","about":"关于","language":"语言","languageAuto":"跟随系统","switchDark":"切换暗色","switchLight":"切换亮色","agentsBundled":"内置"},"editor":{"placeholder":"写点什么... 输入 / 打开快捷命令","noteTitle":"{{name}} - 笔记","noteUntitled":"笔记","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":"结果","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":"正在加载快照…","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"},"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":{"title":"机器人","search":"搜索机器人","addExisting":"添加机器人","addTooltip":"添加为机器人","emptyNoMatch":"没有匹配的机器人。","emptyNoBots":"还没有你自己的机器人。","emptyCreatePrefix":"在聊天里使用","emptyCreateSuffix":"创建一个。","emptyAddExisting":"添加已有的机器人目录","invalid":"无效","builtin":"内置","remove":"移除注册","open":"作为项目打开","pathPlaceholder":"机器人目录或其 BOT.md 的绝对路径","addHint":"目录中必须包含 BOT.md,不会改动其中的文件。","added":"机器人已添加","alreadyAdded":"已添加过","removed":"已移除机器人注册,目录文件仍保留。","loadFailed":"加载机器人失败","saveFailed":"添加机器人失败","removeFailed":"移除机器人失败"}}');r.Ay.isInitialized||r.Ay.init({resources:{en:{translation:o},zh:{translation:s}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});let a=r.Ay},70188:(e,t,n)=>{n.d(t,{Ee:()=>h,SU:()=>c,ft:()=>u,iN:()=>d});var r=n(95155),o=n(12115),s=n(79114),a=n(47650),l=n(34075);let i=(0,o.createContext)(null);function c({container:e,children:t}){return(0,r.jsx)(i.Provider,{value:e,children:t})}function d(){return(0,o.useContext)(i)}function u({x:e,y:t,path:n,cwd:c,isDirectory:d,onClose:h,onCreateFile:m,onDelete:p,onRefresh:f,onCopyFile:g,onPaste:x,onExplain:b,explainDisabled:v}){let{t:y}=(0,s.Bd)(),w=(0,o.useRef)(null),k=(0,o.useContext)(i),C=n.split("/").pop()||n,j=`${c}/${n}`,N=n.includes("/")?n.substring(0,n.lastIndexOf("/")):"",S=N?`${c}/${N}`:c,T=d?n:N,E=d?j:S;(0,o.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&h()},t=e=>{"Escape"===e.key&&h()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[h]);let[L,M]=(0,o.useState)({x:0,y:0});(0,o.useEffect)(()=>{if(w.current&&k){let n=k.getBoundingClientRect(),r=w.current.getBoundingClientRect(),o=e-n.left,s=t-n.top;o=Math.min(o,n.width-r.width-8),s=Math.min(s,n.height-r.height-8),M({x:o=Math.max(8,o),y:s=Math.max(8,s)})}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 R=(0,o.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")}h()},[h,y]),A=d?n:N,P=!!b&&!d,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:d?y("fileContextMenu.copyFolderName"):y("fileContextMenu.copyFileName"),value:C}],I=(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:L.x,top:L.y},children:[P&&(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:()=>{h(),b(n)},children:y("explain.action")}),P&&(0,r.jsx)("div",{className:"my-1 border-t border-border"}),m&&(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:()=>{h(),m(A)},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:()=>{h(),g(n)},children:d?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:()=>{h(),x(A)},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:()=>{h(),p(n,d,C)},children:d?y("fileContextMenu.deleteFolder"):y("fileContextMenu.deleteFile")}),!!(m||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:()=>R(e.value,e.label),children:e.label},t))]});return k?(0,a.createPortal)(I,k):I}function h(){let[e,t]=(0,o.useState)(null);return{contextMenu:e,showContextMenu:(0,o.useCallback)((e,n,r)=>{e.preventDefault(),e.stopPropagation(),t({x:e.clientX,y:e.clientY,path:n,isDirectory:r})},[]),hideContextMenu:(0,o.useCallback)(()=>{t(null)},[])}}},72312:(e,t,n)=>{n.d(t,{N:()=>o});var r=n(95155);function o({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})}},74086:(e,t,n)=>{n.d(t,{I$:()=>a,hC:()=>s,v2:()=>l});var r=n(12115),o=n(14594);function s(){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 s=(0,o.Uy)(e.get(r),t);e.set(r,s),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:()=>o});var r=n(88292);let o={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")}},77725:(e,t,n)=>{n.d(t,{Z:()=>d});var r=n(12115),o=n(10592),s=n(86359),a=n(80905),l=n(49433),i=n(80286),c=n(86957);function d(e,t){let[n,d]=(0,r.useState)({status:"loading"});return(0,r.useEffect)(()=>{d({status:"loading"});let t=c.t4.runFork(e);return t.addObserver(e=>{o.YW(e,{onSuccess:e=>d({status:"success",data:e}),onFailure:e=>{if(s.t9(e))return;let t=s.od(e);d({status:"error",error:a.Ru(t)?t.value:e})}})}),()=>{l.MY7(i.G(t))}},t),n}},79237:(e,t,n)=>{n.d(t,{y:()=>o});let r=e=>"/"===e||"\\"===e;function o(e,t){let n;if(!e)return null;let o=""===(n=e.replace(/[/\\]+$/,""))||/^[A-Za-z]:$/.test(n)?e:n;return t===o?"":t.startsWith(o)?r(o[o.length-1])?t.slice(o.length):r(t[o.length])?t.slice(o.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 o(e,t){if(!e)return"";let n=r(t,e);if(n?.isDirectory)return e;let o=e.split("/");return o.pop(),o.join("/")}function s(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],o=t===e.length-1,s=e.slice(0,t+1).join("/"),a=r.find(e=>e.name===n);a||(a={name:n,path:s,isDirectory:!o,children:o?void 0:[]},r.push(a)),!o&&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:()=>d,MB:()=>r,S7:()=>o,fw:()=>u,q3:()=>c,r6:()=>h,tE:()=>m,tW:()=>a,u:()=>i,v3:()=>s});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 c(e,t,n=!1){let r=new Set;if(!t)return r;let o=t.toLowerCase(),s=e=>{if(r.add(e.path),e.children)for(let t of e.children)s(t)},a=(e,t)=>{let l=e.name.toLowerCase(),i=n?l===o:l.includes(o);if(i&&e.children)return s(e),t.forEach(e=>r.add(e)),!0;let c=!1;if(e.children)for(let n of e.children)a(n,[...t,e.path])&&(c=!0);return(!!i||!!c)&&(r.add(e.path),t.forEach(e=>r.add(e)),!0)};for(let t of e)a(t,[]);return r}function d(e,t,n=!1){let r=new Set;if(!t)return r;let o=t.toLowerCase();for(let t of e){let e=t.split("/");for(let t=0;t<e.length;t++){let s=e[t].toLowerCase();if(n?s===o:s.includes(o)){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),o=Math.floor(r/30),s=Math.floor(r/365);return s>0?`${s}y ago`:o>0?`${o}mo ago`:r>0?`${r}d ago`:n>0?`${n}h ago`:t>0?`${t}m ago`:"just now"}function h(e){let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return r?`${o}-${s} ${a}:${l}`:`${t.getFullYear()}-${o}-${s} ${a}:${l}`}let m=()=>{},p=50},82680:(e,t,n)=>{n.d(t,{m_:()=>s,uV:()=>o});var r=n(50584);class o extends r.rN("AppError"){}r.rN("DBError"),r.rN("WSError"),r.rN("FSError"),r.rN("AgentError"),r.rN("ValidationError");class s extends r.rN("NotFoundError"){}r.rN("PermissionError")},83448:(e,t,n)=>{n.d(t,{$N:()=>N,$x:()=>I,Cr:()=>A,DF:()=>B,F4:()=>b,Fi:()=>f,Hw:()=>h,JC:()=>k,K4:()=>D,K9:()=>i,M5:()=>y,Ny:()=>m,QW:()=>S,Vm:()=>L,ZQ:()=>F,Zr:()=>j,_9:()=>P,an:()=>R,dM:()=>x,dQ:()=>p,em:()=>u,hZ:()=>$,he:()=>g,l1:()=>w,nM:()=>c,n_:()=>C,qD:()=>M,td:()=>d,yS:()=>v,z2:()=>T});var r=n(49433),o=n(82680);let s=(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 o.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),a=(e,t)=>s(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=(e,t)=>s(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=e=>s(`/api/project-state?cwd=${encodeURIComponent(e)}`),c=(e,t)=>a("/api/session/user-messages",{cwd:e,sessionId:t}),d=()=>s("/api/settings"),u=e=>l("/api/settings",e),h=e=>s(`/api/${e}/credentials`),m=e=>s(`/api/${e}/credentials?reveal=1`),p=(e,t)=>l(`/api/${e}/credentials`,{apiKey:t}),f=e=>s(`/api/${e}/models`),g=()=>s("/api/deepseek/balance"),x=e=>s(`/api/${e}/usage`),b=()=>s("/api/ollama/config"),v=e=>l("/api/ollama/config",e),y=()=>s("/api/commands"),w=()=>s("/api/skills"),k=e=>a("/api/bash",e),C=e=>r.$mh({try:async()=>{let t=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?await t.json():null},catch:e=>new o.uV({message:"POST /api/session-by-path failed",cause:e})}),j=(e,t)=>a(`/api/session/${encodeURIComponent(e)}/fork`,t),N=(e,t)=>s(`/api/session/${encodeURIComponent(e)}/turn`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),S=e=>s(`/api/sessions/projects/${encodeURIComponent(e)}`),T=()=>s("/api/global-state").pipe(r.TjK(e=>e.sessions??[])),E=()=>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 o.uV({message:"fetch ollama models failed",cause:e})}),L=()=>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)),M=e=>r.JkU(function*(){let t=yield*E();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 o.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 s=yield*E();return"not-running"===s._tag?{_tag:"error",message:s.reason??t.reason??"Ollama started but cannot fetch models"}:s}),R=e=>s(`/api/file?path=${encodeURIComponent(e)}`),A=()=>s("/api/claude-stats"),P=e=>Array.isArray(e.items),F=()=>s("/api/instructions/config?scope=global"),I=e=>s(`/api/instructions/config?cwd=${encodeURIComponent(e)}`),$=e=>a("/api/instructions/config",e),D=()=>s("/api/output-styles/config"),B=e=>a("/api/output-styles/config",{styles:e})},83897:(e,t,n)=>{n.d(t,{k_:()=>l,nH:()=>i});var r=n(95155),o=n(12115),s=n(48347);let a=(0,o.createContext)(null);function l({children:e}){let t=(0,o.useRef)(new Map),n=(0,o.useRef)(null),[i,c]=(0,o.useState)(()=>new Set),d=i.size>0,u=(0,o.useCallback)((e,t)=>{c(n=>{if(t===n.has(e))return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),h=(0,o.useCallback)((e,n)=>{t.current.set(n,e)},[]),m=(0,o.useCallback)(e=>{t.current.delete(e),c(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),p=(0,o.useCallback)(e=>{n.current=e},[]),f=(0,o.useCallback)(e=>{let r=n.current;if(!r)return void console.warn("No active tab to send message");let o=t.current.get(r);o?o(e):console.warn(`No chat sender registered for tab ${r}`)},[]),g=(0,o.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,o.useMemo)(()=>({sendMessage:f,sendToTab:g,isLoading:d,registerChat:h,unregisterChat:m,setActiveTab:p,setChatLoading:u}),[f,g,d,h,m,p,u]),b=(0,o.useMemo)(()=>({sendMessage:f,isLoading:d}),[f,d]);return(0,r.jsx)(a.Provider,{value:x,children:(0,r.jsx)(s.H,{value:b,children:e})})}function i(){return(0,o.useContext)(a)}},84444:(e,t,n)=>{n.d(t,{H:()=>o});let r=e=>"unread"===e?0:"loading"===e?1:2;function o(e){return[...e].sort((e,t)=>r(e.status)-r(t.status)||t.lastActive-e.lastActive)}},85269:(e,t,n)=>{n.d(t,{O:()=>h});var r=n(95155),o=n(12115),s=n(48347),a=n(89109),l=n(7320),i=n(34582),c=n(1058),d=n(90717),u=n(69809);function h({content:e,filePath:t,cwd:n,onContentSearch:m,reloadKey:p=0}){let f=(0,s.r)(),g=!!n,x=(0,o.useMemo)(()=>{if((0,i.qF)(t,n))return{mode:"url",url:(0,i.Xe)(t,n)};let r=e??"",o=(0,i.J4)(t,n),s="https:"===window.location.protocol?"wss:":"ws:",a=`${s}//${window.location.host}/ws/bash?cwd=${encodeURIComponent(o)}`;return{mode:"srcdoc",html:(0,i.OP)(r,{cwd:o,wsUrl:a})}},[e,t,n]),{addComment:b,refresh:v}=(0,c._)({cwd:n||"",filePath:t}),[y,w]=(0,o.useState)(null),k=(0,o.useRef)(null),C=(0,o.useRef)(null),j=(0,o.useRef)(()=>{}),[N,S]=(0,o.useState)(null),[T,E]=(0,o.useState)(null),L=(0,o.useRef)(!1);(0,o.useEffect)(()=>{L.current=!!(N||T)},[N,T]);let M=(0,o.useCallback)(()=>{C.current&&(C.current=null,j.current())},[]),R=(0,o.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(L.current)return;let n=e.contentWindow?.getSelection(),r=n&&!n.isCollapsed?n.toString().trim():"";if(!r)return void M();let o=e.getBoundingClientRect();C.current={x:o.left+t.clientX,y:o.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]),A=(0,o.useCallback)(()=>{let e=C.current;e&&(S({x:e.x,y:e.y,text:e.selectedText}),M(),k.current?.contentWindow?.getSelection()?.removeAllRanges())},[M]),P=(0,o.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,o.useCallback)(()=>{let e=C.current;e&&f&&(M(),k.current?.contentWindow?.getSelection()?.removeAllRanges(),(0,d.Ff)(f.sendMessage,{filePath:t,startLine:0,endLine:0,codeContent:e.selectedText},u.A.t("explain.selectionMessage")))},[f,t,M]),I=(0,o.useCallback)(()=>{let e=C.current;if(!e||!m)return;let t=e.selectedText.trim();M(),k.current?.contentWindow?.getSelection()?.removeAllRanges(),t&&m(t)},[m,M]),$=(0,o.useCallback)(async e=>{N&&(await b(0,0,e,N.text),S(null))},[N,b]),D=(0,o.useCallback)(async(e,r)=>{if(f&&n)try{let o=(await (0,d.$3)(n)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));o.push({filePath:t,startLine:0,endLine:0,codeContent:e});let s=(0,d.Gw)(o,r);f.sendMessage(s),await (0,d.RP)(n),v()}catch(e){console.error("[HtmlAppFrame] send to AI failed:",e)}},[f,n,t,v]),B=(0,o.useCallback)(e=>{T&&D(T.text,e)},[T,D]),O=(0,o.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:R},`${t}:${p}`),g&&y&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.fS,{floatingToolbarRef:C,bumpRef:j,container:y,onAddComment:A,onSendToAI:P,onSearch:m?I: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:B,onClose:()=>E(null),isChatLoading:f?.isLoading})]})]})}},86304:(e,t,n)=>{n.d(t,{P:()=>c});var r=n(12115),o=n(79114),s=n(34075),a=n(86957),l=n(63040),i=n(63563);function c(){let{t:e}=(0,o.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,s.oR)(e("htmlApps.alreadyAdded"),"info"):((0,s.oR)(e("htmlApps.added"),"success"),(0,i.N)());else{let t="Fail"===n.cause._tag?n.cause.error:null,r=t?.cause,o=r instanceof Error?r.message:e("htmlApps.addFailed");(0,s.oR)(o,"error")}},[e])}},86957:(e,t,n)=>{n.d(t,{t4:()=>B});var r=n(59257),o=n(74565),s=n(49433),a=n(93404),l=n(22484),i=n(41463);let c=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 d=n(80905),u=n(98953);let h=globalThis,m=h.__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,o,s){this.name=e,this.parent=t,this.context=n,this.startTime=o,this.kind=s,this._tag="Span",this.sampled=!0,this.attributes=new Map,this.events=[],this.traceId=d.Ru(t)?t.value.traceId:p(32),this.spanId=p(16),this.status={_tag:"Started",startTime:o},this.links=Array.from(r),function(e){if(m.buffer.push(e),m.index.set(e.spanId,m.buffer.length-1),m.buffer.length>500){m.buffer.shift(),m.index.clear();for(let e=0;e<m.buffer.length;e++)m.index.set(m.buffer[e].spanId,e)}}(function(e,t,n,r,o,s){return{traceId:t,spanId:e,parentSpanId:n,name:r,kind:o,startTimeNs:s.toString(),endTimeNs:null,durationMs:null,attributes:{},events:[],status:"started"}}(this.spanId,this.traceId,function(e){return d.Ru(e)?e.value.spanId:null}(t),e,s,o))}end(e,t){this.status={_tag:"Ended",endTime:e,exit:t,startTime:this.status.startTime},function(e,t,n){let r=m.index.get(e);if(void 0===r)return;let o=m.buffer[r];if(!o)return;let s=Number(t-BigInt(o.startTimeNs))/1e6;m.buffer[r]={...o,endTimeNs:t.toString(),durationMs:Math.round(100*s)/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=m.index.get(e);if(void 0===r)return;let o=m.buffer[r];o&&(m.buffer[r]={...o,attributes:{...o.attributes,[t]:n}})}(this.spanId,e,t)}event(e,t,n){this.events.push([e,t,n??{}]),function(e,t,n,r){let o=m.index.get(e);if(void 0===o)return;let s=m.buffer[o];s&&(m.buffer[o]={...s,events:[...s.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,o,s)=>new f(e,t,n,r,o,s),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)),L=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(4));s.JkU(function*(){let e=yield*y,t=yield*w,n=yield*k,r=yield*C,o=yield*j,a=yield*N,l=yield*S,i=yield*T,c=yield*E,d=yield*L,u=yield*M,h=yield*s.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:h,openProject:r,openBrowser:!o,logLevel:a,logFile:h+"/logs/cockpit.log",snapshotKeepDays:l,snapshotRepoTtlDays:i,snapshotMaxFileKb:c,sessionKeepDays:d,delegateMaxConcurrent:u}}).pipe(s.QgK);let R=r.Ie;var A=n(38147),P=n(23363),F=n(88292);let I=r.P1(F.d,s.JkU(function*(){let e=yield*A.dT();return yield*s.Q56(s.OH5(()=>{let t=t=>{s.MY7(A.mk(e,t))};return window.addEventListener("message",t),t}),e=>s.OH5(()=>{window.removeEventListener("message",e)})),F.d.of({publish:(e,t)=>s.OH5(()=>{let n={type:e.legacyType,topic:e.id,msg:t,..."object"==typeof t&&null!==t?t:{}};window.parent.postMessage(n,"*")}),subscribe:t=>P.qdp(e).pipe(P.pbD(e=>{var n;return n=e.data,!!n&&"object"==typeof n&&(n.topic===t.id||n.type===t.legacyType)}),P.TjK(e=>((e,t)=>{if(e.topic===t.id)return e.msg;let{type:n,...r}=e;return r})(e.data,t)))})})),$=r.Um(c,x,R),D=r.Um($,I),B=o.L8(D);s.rIH},88292:(e,t,n)=>{n.d(t,{R:()=>o,d:()=>s});var r=n(50995);let o=(e,t)=>({id:e,legacyType:t??e.replace(/-/g,"_").toUpperCase()}),s=r.Io("@cockpit/IframeBus")},88403:(e,t,n)=>{n.d(t,{Q:()=>l});var r=n(23348),o=n(33442),s=n(51536);let a={add:r.zB,notify:o._,namespace:"bots",failureKey:"bots.saveFailed"},l=()=>(0,s.X)(a)},88780:(e,t,n)=>{n.d(t,{Do:()=>m,Sz:()=>p,VO:()=>h,wI:()=>f});var r=n(95155),o=n(12115),s=n(79114),a=n(14575),l=n(72312),i=n(70188),c=n(52839);function d({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=o.memo(function e({node:t,level:n,selectedPath:s,expandedPaths:i,onSelect:u,onToggle:h,onContextMenu:m,showChanges:p=!1,showChangeClass:f=!1,hideIndicatorsOnHover:g=!1,renderActions:x}){let b,v=s===t.path,y=i.has(t.path),w=(0,o.useCallback)(()=>{t.isDirectory?h(t.path):u(t)},[t,u,h]),k=(0,o.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),m(e,t.path,t.isDirectory)},[t.path,t.isDirectory,m]);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:s,expandedPaths:i,onSelect:u,onToggle:h,onContextMenu:m,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,c.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)(d,{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 h({files:e,selectedPath:t,expandedPaths:n,onSelect:o,onToggle:a,cwd:l,showChanges:c=!1,showChangeClass:d=!1,hideIndicatorsOnHover:m=!1,renderActions:p,emptyMessage:f,className:g,onExplain:x,explainDisabled:b}){let{t:v}=(0,s.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:o,onToggle:a,onContextMenu:k,showChanges:c,showChangeClass:d,hideIndicatorsOnHover:m,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 m(e){let t=[];for(let n of e){let e=n.path.split("/"),r=t;for(let t=0;t<e.length;t++){let o=e[t],s=t===e.length-1,a=e.slice(0,t+1).join("/"),l=r.find(e=>e.name===o);l||(l={name:o,path:a,isDirectory:!s,children:[],...s&&{status:n.status,additions:n.additions,deletions:n.deletions,oldPath:n.oldPath,file:n}},r.push(l)),s||(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}},89109:(e,t,n)=>{n.d(t,{SZ:()=>a,fS:()=>c});var r=n(95155),o=n(12115),s=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:c,onMouseLeave:d}){let{t:u}=(0,s.Bd)(),h=(0,o.useRef)(null);return(0,o.useEffect)(()=>{h.current&&n(h.current.getBoundingClientRect().height)},[n,e]),(0,r.jsxs)("div",{ref:h,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:c,onMouseLeave:d,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:c,onAddComment:d,onSendToAI:u,onSearch:h,onExplain:m,onQuickReply:p,quickReplyRows:f,onEditQuickReplies:g,isChatLoading:x}){let{t:b}=(0,s.Bd)(),v=(0,o.useRef)(null),[y,w]=(0,o.useState)({w:0,h:0}),[k,C]=(0,o.useState)(0),[j,N]=(0,o.useState)(null),S=(0,o.useRef)(null);(0,o.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,o.useCallback)(e=>{C(t=>t===e?t:e)},[]);(0,o.useEffect)(()=>{n||N(null)},[n]);let E=(0,o.useCallback)(()=>{S.current&&(clearTimeout(S.current),S.current=null)},[]),L=(0,o.useCallback)(e=>{E(),N(e)},[E]),M=(0,o.useCallback)(()=>{E(),S.current=setTimeout(()=>N(null),150)},[E]);(0,o.useEffect)(()=>E,[E]);let R=c.getBoundingClientRect(),A=e-R.left,P=Math.max(0,t-R.top-40),F=Math.max(0,Math.min(A+8,R.width-y.w-8)),I=k>0&&P+y.h+8+k>R.height,$=(0,o.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:I,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:P,visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none"},children:[(0,r.jsxs)("div",{className:"relative",onMouseEnter:()=>L("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:d,children:b("floatingToolbar.addComment")}),D("comment")]}),(0,r.jsxs)("div",{className:"relative",onMouseEnter:()=>{x||L("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")]}),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 disabled:opacity-50 disabled:cursor-not-allowed",onClick:m,disabled:x,title:x?b("comments.aiResponding"):void 0,children:b("explain.action")}),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",onClick:h,children:b("floatingToolbar.search")})]})}let c=(0,o.memo)(function({floatingToolbarRef:e,bumpRef:t,container:n,onAddComment:s,onSendToAI:a,onSearch:l,onExplain:c,onQuickReply:d,quickReplyRows:u,onEditQuickReplies:h,isChatLoading:m}){let[p,f]=(0,o.useState)(0);(0,o.useEffect)(()=>{t.current=()=>f(e=>e+1)},[t]);let g=(0,o.useMemo)(()=>e.current,[p]);return(0,r.jsx)(i,{x:g?.x??0,y:g?.y??0,visible:!!g,container:n,onAddComment:s,onSendToAI:a,onSearch:l,onExplain:c,onQuickReply:d,quickReplyRows:u,onEditQuickReplies:h,isChatLoading:m})})},90717:(e,t,n)=>{n.d(t,{$3:()=>u,Cm:()=>d,Ff:()=>f,Gw:()=>p,RP:()=>h,Un:()=>m,zL:()=>c});var r=n(69809),o=n(49433),s=n(86957),a=n(82680),l=n(46456);let i=new Set;function c(e){return i.add(e),()=>i.delete(e)}function d(){i.forEach(e=>e())}async function u(e){let t=await s.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 s.t4.runPromiseExit(o.$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 c=[];for(let e of n){if(e.selectedText){c.push({...e,codeContent:e.selectedText});continue}let t=i.get(e.filePath),n="";if(t){let r=Math.max(0,e.startLine-1),o=Math.min(t.length,e.endLine);n=t.slice(r,o).join("\n")}c.push({...e,codeContent:n})}return c}async function h(e){let t=await s.t4.runPromiseExit((0,l.tj)(e));return"Success"===t._tag?(d(),!0):(console.error("Failed to clear comments:",t.cause),!1)}let m="__chat__";function p(e,t){let n=e.filter(e=>e.filePath===m),o=e.filter(e=>e.filePath!==m),s=[];for(let e of(o.length>0&&(s.push(`${r.A.t("comments.codeRef")}`,""),o.forEach((e,t)=>{let n=e.startLine>0||e.endLine>0?`:${e.startLine}-${e.endLine}`:"";s.push(`[${t+1}] ${e.filePath}${n}`),s.push("```"),s.push(e.codeContent),s.push("```"),e.note&&s.push(r.A.t("comments.note",{content:e.note})),s.push("")})),n)){let t=e.codeContent.split("\n").map(e=>`> ${e}`).join("\n");s.push(t),e.note&&s.push(e.note),s.push("")}if(t.trim()){for(;s.length>0&&""===s[s.length-1];)s.pop();s.push(t.trim())}return s.join("\n").trim()}function f(e,t,n){e(p([t],n))}},93964:(e,t,n)=>{n.d(t,{N:()=>o});let r=e=>"u"<typeof BroadcastChannel?null:new BroadcastChannel(e),o=e=>({notify:()=>{let t=r(e);if(t)try{t.postMessage({type:"changed"})}finally{t.close()}},subscribe:t=>{let n=r(e);if(!n)return()=>void 0;let o=e=>{e.data?.type==="changed"&&t()};return n.addEventListener("message",o),()=>{n.removeEventListener("message",o),n.close()}}})},94287:(e,t,n)=>{n.d(t,{m:()=>s});var r=n(95155),o=n(12115);function s({content:e,children:t,className:n}){if(n)return(0,r.jsx)("div",{"data-tooltip":e,className:n,children:t});let a=o.Children.toArray(t);if(1===a.length&&(0,o.isValidElement)(a[0])){let t=a[0];return(0,o.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),o=n(88292),s=n(86957);let a=(e,t)=>{s.t4.runFork(r.qIB(o.d,n=>n.publish(e,t)))}},95686:(e,t,n)=>{n.d(t,{x:()=>i});var r=n(95155),o=n(12115),s=n(64428),a=n(70188),l=n(5135);function i({filePath:e,content:t,cwd:n,onClose:c,zClassName:d="z-50"}){let[u,h]=(0,o.useState)(null);return(0,r.jsx)(s.ZL,{children:(0,r.jsx)("div",{className:`fixed inset-0 ${d} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:c,children:(0,r.jsx)("div",{ref:h,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:c})})})})})}},95927:(e,t,n)=>{n.d(t,{T:()=>L});var r=n(95155),o=n(46361),s=n(79204),a=n(98164),l=n(77815),i=n(97720),c=n(88374);n(84559),n(21227);var d=n(91334),u=n(38194),h=n(88522),m=n(12115),p=n(34582),f=n(3238),g=n(11890),x=n(73620);function b(e){return{type:"tableCell",children:[{type:"text",value:e}]}}let v=[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=x.Ay.load(n.value??"");e&&"object"==typeof e&&!Array.isArray(e)&&(r=e)}catch{r=null}let o=r?Object.entries(r):[];if(0===o.length){t.splice(e,1),e--;continue}let s={type:"tableRow",children:[b("Field"),b("Value")]},a=o.map(([e,t])=>({type:"tableRow",children:[b(e),b(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:[s,...a]}}}}];function y(e){return!(!e.trim()||/\n[ \t]*\n/.test(e)||e.includes("$"))}function w(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)=>y(t)?`$$${t}$$`:e).replace(/\\\(([^\u0000]*?)\\\)/g,(e,t)=>y(t)?`$${t}$`:e).replace(/\u0000MATHMASK(\d+)\u0000/g,(e,n)=>t[+n])}let k=[...v,s.A,a.A,function(){return(e,t)=>{let n=String(t?.value??"");n&&function e(t,n){let r=t.children;if(r)for(let o=0;o<r.length;o++)n(r[o],o,t),e(r[o],n)}(e,(e,t,r)=>{var o;if("inlineMath"!==e.type)return;let s=e.position?.start?.offset,a=e.position?.end?.offset;void 0!==s&&void 0!==a&&(o=e.value??"","$$"!==n.slice(s,s+2)&&(!o||/^\s|\s$/.test(o)||/\d/.test(n[s-1]??"")||/\d/.test(n[a]??"")||0)&&(r.children[t]={type:"text",value:n.slice(s,a),position:e.position}))})}},l.jb],C=[...v,s.A,l.jb],j=[i.A,c.A],N=[i.A];function S(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 T=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 E(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 T.has(n)||n.includes("-")?e:e.replace(/</g,"<").replace(/>/g,">")}).replace(/\u0000MASK(\d+)\u0000/g,(e,n)=>t[+n])}let L=(0,m.memo)(function({content:e,isUser:t=!1,isStreaming:n=!1,enableMath:s=!0,isDark:a,rehypePlugins:l,onLinkClick:i,basePath:c}){let x=(0,f.Ql)(),b=a??x?.resolvedTheme==="dark",v=(0,m.useRef)(null),y=(0,m.useMemo)(()=>({code({className:e,children:t,node:n,...o}){let s=/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",...o,children:t});let a=String(t);if(!s&&!e&&!a.includes("\n"))return(0,r.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent font-mono",...o,children:t});let l=a.replace(/\n$/,""),i=s?.[1]||"text",c=Number(o["data-source-start"])||0,m=c?c+1:0,p=0;return(0,r.jsx)(d.A,{style:b?u.A:h.A,language:i,PreTag:"div",className:"md-figure",customStyle:{margin:"1.35em 0",borderRadius:"0.375rem",fontSize:"0.92em"},wrapLines:!0,lineProps:()=>{let e=m+p;return p++,{"data-source-start":e,"data-source-end":e,style:{display:"block"}}},children: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,...o})=>(0,r.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand hover:underline",...o,onClick:t=>{if(e){if(e.startsWith("#")){(0,g.O)(v.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:o,width:s,style:a,...l})=>{let i=c&&"string"==typeof e?(0,p.xh)(e,c):e;if(!(o||s||a))return(0,r.jsx)("img",{src:i,alt:t||"",className:"max-w-full h-auto rounded-lg my-3",...l});let d=e=>e?/^\d+$/.test(String(e))?`${e}px`:String(e):void 0,u={...a,height:d(o)??a?.height,width:d(s)??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})}),[b,i,c]),T=s?k:C,L=s?j:N,M=(0,m.useMemo)(()=>{if(t||n)return E(e);let r=E(S(!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 s?w(r):r},[e,t,n,s]),R=(0,m.useMemo)(()=>l?.length?[...L,...l]:L,[l,L]);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:v,children:[(0,r.jsx)(o.oz,{remarkPlugins:T,rehypePlugins:L,components:y,children:s?w(E(S(n))):E(S(n))}),a&&(0,r.jsx)("span",{className:"md-tail whitespace-pre-wrap",children:a})]})}return(0,r.jsx)("div",{className:"markdown-body",ref:v,children:(0,r.jsx)(o.oz,{remarkPlugins:T,rehypePlugins:R,components:y,children:M})})})},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 o=r.startContainer,s=r.startOffset,a=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),l=1;for(;n=a.nextNode();){if(n===o){l+=s;break}l+=n.textContent?.length||0}return l}function o(e,t){if(0!==e.buttons)return null;let n=window.getSelection();if(n&&!n.isCollapsed)return null;let o=e.target;if("SPAN"!==o.tagName||!o.style.color)return null;let s=o.getBoundingClientRect();return{column:r(e,t),rect:{x:s.left,y:s.bottom+4}}}n.d(t,{A:()=>o,j:()=>r})},97251:(e,t,n)=>{n.d(t,{W:()=>s});var r=n(48250);let o=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","table","tr","hr","div","ul","ol"]);function s(){return e=>{(0,r.YR)(e,"element",e=>{if(o.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)}})}}},98245:(e,t,n)=>{n.d(t,{C:()=>o});var r=n(69809);function o(e,t){if("codex_resume_failed"!==e.notice)return null;let n=e.previous_session_id||"",o=r.A.t("chat.codexResumeFailed",{defaultValue:"Previous session is in use by another Codex client — started a new session; history was not carried over"}),s=[...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=[o,...s.length?["",...s]:[],...e.error?["",e.error]:[]].join("\n");return{id:t,role:"system",content:o,systemEvent:{kind:"meta",detail:a}}}}}]);
|
|
733
|
+
`:"")+"</task-notification>";t(t=>[...t,{id:n,role:"system",content:e.summary||"",systemEvent:{kind:"task-notification",...e.status?{status:e.status}:{},detail:r}}])}return}if("system"===e.type&&"notice"===e.subtype){let n=(0,l.C)(e,`live-notice-${++u.current}`);n&&t(e=>[...e,n]);return}if("user"===e.type&&e._human){let n=e.message?.content,r="string"==typeof n?n:Array.isArray(n)?n.map(e=>e?.text||"").join(""):"",o="string"==typeof e._turnId?e._turnId:null;o&&(g.current=o),(f.current||p.current)&&(x.current=!0);let s="number"==typeof e._ts?e._ts:null,a=o?`live-user-${o}`:`live-user-${++u.current}`;t(t=>{if(o&&t.some(e=>e.id===a))return t;for(let e=t.length-1;e>=0;e--){if("user"!==t[e].role)continue;if("string"==typeof t[e].id&&t[e].id.startsWith("live-user-"))break;let n=t[e].timestamp?Date.parse(t[e].timestamp):NaN;if(null===s||Number.isNaN(n)){if(t[e].content===r)return t}else if(n>=s)return t;break}return[...t,{id:a,role:"user",content:r,...e._images?.length?{images:e._images}:{}}]});return}if("result"===e.type&&(f.current=!1,p.current=!0),"assistant"===e.type&&Array.isArray(e.message?.content))for(let t of e.message.content)t.text?r(t.text):t.name&&r(`${t.name} ${JSON.stringify(t.input??{})}`);if("user"===e.type&&Array.isArray(e.message?.content))for(let t of e.message.content)r("string"==typeof t.content?t.content:JSON.stringify(t.content??""));let o=d.current??b();t(t=>(0,a.FM)(t,e,{engine:i,assistantId:o}))};(0,o.h)({url:e?`/ws/session-stream?sessionId=${encodeURIComponent(e)}`:"/ws/session-stream",enabled:n&&!!e,onMessage:e=>{if("run-snapshot"===e.type&&Array.isArray(e.events)){if("string"==typeof e.runId&&e.runId&&(g.current=e.runId),"running"!==e.status){c?.onRunningChange?.(!1),c?.onLiveOutputTokens?.(null),c?.onRunStartedAt?.(null),c?.onBackgroundTasks?.([]),t(a.fD),c?.taskStore?.settleRunning(),h.current=0,m.current=!1,p.current=!1;return}let n=e.events.find(e=>e?.type==="user"&&e?._human),r=n?.message?.content,o="string"==typeof r?r:"",s=new Set,l=new Set;for(let t of e.events){let e=t?.uuid;if("string"==typeof e&&s.add(e),t?.type==="assistant"&&Array.isArray(t.message?.content))for(let e of t.message.content)e?.name&&"string"==typeof e.id&&l.add(e.id)}let i="number"==typeof e.startedAt?e.startedAt:null;t(e=>{let t=e.filter(e=>!("string"==typeof e.id&&e.id.startsWith("live-"))),n=t[t.length-1],r=n?.timestamp?Date.parse(n.timestamp):NaN;if(null!==i&&!Number.isNaN(r)){let e=t.length;for(;e>0;){let n=t[e-1],r=n.timestamp?Date.parse(n.timestamp):NaN;if(!Number.isNaN(r)&&r>=i)e--;else break}return e<t.length?t.slice(0,e):t}if(!o)return t;let a=-1;for(let e=t.length-1;e>=0;e--)if("user"===t[e].role){t[e].content===o&&(a=e);break}return -1===a?t:t.slice(a+1).every(e=>"assistant"===e.role&&("string"==typeof e.id&&s.has(e.id)||!!e.toolCalls?.length&&e.toolCalls.every(e=>l.has(e.id))))?t.slice(0,a):t}),d.current=null,u.current=0,h.current=0,m.current=!1,p.current=!1,f.current=!1,x.current=!1;let b="number"==typeof e.outputTokens&&Number.isFinite(e.outputTokens)?Math.max(0,Math.round(e.outputTokens)):null;for(let t of(null!==b&&(h.current=b,m.current=!0,c?.onLiveOutputTokens?.({outputTokens:b})),e.events))v(t);c?.onRunningChange?.(!0),c?.onRunStartedAt?.("number"==typeof e.startedAt?e.startedAt:Date.now())}else if("run-event"===e.type&&e.message){if("run-ended"===e.message.type){c?.onRunningChange?.(!1),c?.onLiveOutputTokens?.(null),c?.onRunStartedAt?.(null),c?.onBackgroundTasks?.([]),t(a.fD),c?.taskStore?.settleRunning(),h.current=0,m.current=!1,p.current=!1,c?.onComplete?.();return}v(e.message),c?.onRunningChange?.(!0)}else"run-idle"===e.type&&(c?.onRunningChange?.(!1),c?.onLiveOutputTokens?.(null),c?.onRunStartedAt?.(null),c?.onBackgroundTasks?.([]),t(a.fD),c?.taskStore?.settleRunning(),h.current=0,m.current=!1,p.current=!1)}})}},67589:(e,t,n)=>{n.d(t,{z:()=>l,m:()=>c});var r=n(12115),o=n(49433),s=n(86957),a=n(82680);let l=e=>o.$mh({try:async()=>{let t=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?await t.json():null},catch:e=>new a.uV({message:"session-by-path failed",cause:e})}),i=new Map;function c(e,t,n,{cwd:d,initialSessionId:u,onSessionId:h,onTitleChange:m,onTokenUsage:p,liveRunningRef:f}){let[g,x]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[y,w]=(0,r.useState)(!1),[k,C]=(0,r.useState)(void 0),[j,N]=(0,r.useState)(0),[S,T]=(0,r.useState)(null),[E,L]=(0,r.useState)(null),[M,R]=(0,r.useState)(null),A=(0,r.useRef)(null);A.current=S;let P=(0,r.useRef)(m);P.current=m;let F=(0,r.useRef)(p);F.current=p;let I=(0,r.useRef)(void 0),D=(0,r.useRef)(0),$=(0,r.useCallback)(async(e,n,r=!1,o,a,c=!1)=>{if(r){let e=Date.now();if(!c&&e-D.current<5e3)return;D.current=e}let d=(e,r)=>{e.fingerprint&&(I.current=e.fingerprint),void 0!==e.totalTurns&&N(e.totalTurns),void 0!==e.hasMore&&w(e.hasMore),e.messages&&e.messages.length>0&&(r?t(t=>(function(e,t){if(0===t.length)return e;let n=0;if(e.length>0&&e[0].id!==t[0].id){n=-1;for(let r=e.length-1;r>=0;r--)if(e[r].id===t[0].id){n=r;break}}if(n<0)return t;let r=e.slice(n),o=0;for(let e=0;e<Math.min(r.length,t.length)&&r[e].id===t[e].id&&r[e].content===t[e].content;e++)o=e+1;return o===r.length&&o===t.length?e:o===r.length&&o<t.length?[...e,...t.slice(o)]:[...e.slice(0,n),...r.slice(0,o),...t.slice(o)]})(t,e.messages)):f?.current||t(e.messages),T(n)),e.sessionId&&h(e.sessionId),e.engine&&L(e.engine),R(e.bot??null),e.title&&P.current?.(e.title),e.usage&&F.current?.({inputTokens:e.usage.input_tokens||0,outputTokens:e.usage.output_tokens||0,cacheCreationInputTokens:e.usage.cache_creation_input_tokens||0,cacheReadInputTokens:e.usage.cache_read_input_tokens||0,totalCostUsd:0})},u=`${e}::${n}`;c&&i.delete(u);let m=!r&&void 0===a,p=m?i.get(u):void 0;r||(p?d(p.data,!1):x(!0));try{let t={cwd:e,sessionId:n,limit:o,beforeTurnIndex:a};r&&I.current?t.ifFingerprint=I.current:p&&(t.ifFingerprint=p.fingerprint);let c=await s.t4.runPromiseExit(l(t));if("Success"===c._tag&&c.value){let e=c.value;if(e.notModified)return;if(d(e,r),m&&e.fingerprint&&e.messages&&e.messages.length>0&&(i.delete(u),i.set(u,{data:e,fingerprint:e.fingerprint}),i.size>20)){let e=i.keys().next().value;void 0!==e&&i.delete(e)}}}catch(e){console.error("Failed to load history by cwd and sessionId:",e)}finally{r||x(!1)}},[t,h]),B=(0,r.useCallback)(async()=>{if(d&&n&&!b&&y){v(!0);try{let r=void 0!==k?k:j-Math.ceil(e.filter(e=>"user"===e.role).length),o=await s.t4.runPromiseExit(l({cwd:d,sessionId:n,limit:10,beforeTurnIndex:r>0?r:void 0}));if("Success"===o._tag&&o.value){let e=o.value;if(e.messages&&e.messages.length>0){t(t=>[...e.messages,...t]);let o=e.messages.filter(e=>"user"===e.role).length;C(e.startTurnIndex??r-o),T(n)}void 0!==e.hasMore&&w(e.hasMore),e.fingerprint&&(I.current=e.fingerprint)}else"Failure"===o._tag&&console.error("Failed to load more history:",o.cause)}finally{v(!1)}}},[d,n,b,y,k,j,e,t]),_=(0,r.useCallback)(async e=>{let r=A.current??n;if(d&&r&&!(e<0)){v(!0);try{let n=await s.t4.runPromiseExit(l({cwd:d,sessionId:r,fromTurnIndex:e}));if("Failure"===n._tag)return void console.error("Failed to load turns for jump:",n.cause);if(!n.value||A.current&&A.current!==r)return;let o=n.value;if(o.messages&&o.messages.length>0){let n=o.messages;t(e=>(function(e,t){if(0===t.length)return e;let n=new Set(t.map(e=>e.id)),r=e.map(e=>n.has(e.id)).lastIndexOf(!0);if(r<0)return t;let o=e.slice(r+1);return 0===o.length?t:[...t,...o]})(e,n)),C(o.startTurnIndex??e),T(r)}void 0!==o.totalTurns&&N(o.totalTurns),void 0!==o.hasMore&&w(o.hasMore),o.fingerprint&&(I.current=o.fingerprint)}finally{v(!1)}}},[d,n,t]),O=(0,r.useCallback)(async e=>{if(!d)return;x(!0);let n=o.$mh({try:async()=>{let t=await fetch(`/api/session/${encodeURIComponent(e)}/history?cwd=${encodeURIComponent(d)}`);return t.ok?await t.json():null},catch:e=>new a.uV({message:"load session history failed",cause:e})}),r=await s.t4.runPromiseExit(n);"Success"===r._tag&&r.value?.messages&&r.value.messages.length>0?(t(r.value.messages),T(e)):"Failure"===r._tag&&console.error("Failed to load history:",r.cause),x(!1)},[d,t]);return(0,r.useEffect)(()=>{d&&u&&$(d,u,!1,10)},[]),{isLoadingHistory:g,isLoadingMore:b,hasMoreHistory:y,loadMoreHistory:B,ensureTurnLoaded:_,loadHistory:O,loadHistoryByCwdAndSessionId:$,loadedSessionId:S,loadedEngine:E,loadedBot:M}}},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"},69809:(e,t,n)=>{n.d(t,{A:()=>a});var r=n(50931);let o=JSON.parse('{"common":{"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":{"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","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 is outside this project — only Markdown, CSV and images can be previewed","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.","reloadNow":"Reload","upgradeCommandCopied":"Copied `cockpit update`","projectNotes":"Project Notes","closeProject":"Close project","bots":"Bots"},"mobile":{"useDesktop":"Desktop","messagePlaceholder":"Message…","send":"Send","stop":"Stop","enableNotifications":"Enable notifications","disableNotifications":"Disable notifications","notifyError":"Could not enable notifications"},"sessions":{"recentSessions":"Recent Sessions","favorites":"Favorite Sessions","noFavorites":"No favorite sessions yet. Click the star in the tab bar to add.","addFavorite":"Add to favorites","removeFavorite":"Remove from favorites","runningCount":"{{count}} running","unreadCount":"{{count}} unread","noSessions":"No sessions yet","running":"Running","done":"Done","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..."},"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}})","groupPendingReview":"Finished \xb7 to review","groupUpcoming":"Running \xb7 upcoming","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 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","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","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","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":{"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","deleteTurn":"Delete turn","deletingTurn":"Deleting…","deleteTurnConfirm":"Delete this question, answer, and its 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","toolCalls":"{{count}} tool calls","collapse":"▲ Collapse","expand":"▼ Expand","showMore":"Show more","showLess":"Show less","subagent":"Subagent","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","placeholder":"Type a message, Enter to send (Shift+Enter for new line, paste images; start a line with / (skill), /@ (skill in a subagent) or @ (bot in a subagent), multiple allowed)","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.","outputStyle":"Output style","outputStyleNone":"None","noOutputStyles":"No output styles yet — add one with the pencil","editOutputStyles":"Edit output styles","outputStylesMarkdownHint":"Start each style with \\"# Name\\". Everything up to the next \\"# \\" is appended verbatim to the end of the system prompt (multi-line; deeper headings like ## are content).","outputStylesMarkdownPlaceholder":"# Concise\\nAnswer in at most three sentences, no preamble.\\n\\n# Teacher\\nExplain why before how.","outputStylesError":{"content-before-heading":"Line {{line}}: content must come after a \\"# Name\\" heading.","empty-style":"Line {{line}}: a style needs both a name and content.","duplicate-name":"Line {{line}}: duplicate style name."},"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","namePlaceholder":"Name","commandPlaceholder":"Command","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","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":"Cockpit Bridge installed","extensionNotInstalled":"Cockpit Bridge not installed","extensionDescription":"After installing the Chrome extension, link navigation in iframes will be intercepted: new tab links create new bubbles, page navigation updates the current bubble.","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"},"editor":{"placeholder":"Write something... Type / for commands","noteTitle":"{{name}} - Notes","noteUntitled":"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","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…","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 tab","closeAll":"Close all tabs","newTab":"New tab"},"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"},"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":{"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","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"}}'),s=JSON.parse('{"common":{"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":{"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":"无效","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":"文件在当前项目之外,仅支持预览 Markdown、CSV 和图片","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 已在后台更新。","reloadNow":"刷新","upgradeCommandCopied":"已复制 `cockpit update`","projectNotes":"项目笔记","closeProject":"关闭项目","bots":"机器人"},"mobile":{"useDesktop":"桌面版","messagePlaceholder":"发消息…","send":"发送","stop":"停止","enableNotifications":"开启通知","disableNotifications":"关闭通知","notifyError":"无法开启通知"},"sessions":{"recentSessions":"最近会话","favorites":"收藏会话","noFavorites":"暂无收藏会话,在 Tab 栏点击星标可添加","addFavorite":"收藏此会话","removeFavorite":"取消收藏","runningCount":"{{count}} 运行中","unreadCount":"{{count}} 未读","noSessions":"暂无会话记录","running":"运行中","done":"完成","editTitle":"编辑标题","projectSessions":"项目会话","browseAllSessions":"浏览所有会话","sessionList":"会话列表","search":"搜索","searchSessions":"搜索会话...","searchRecentSessions":"搜索最近会话","loadSessionsFailed":"加载会话失败","loadingSessions":"加载会话中...","noMatchingSessions":"未找到匹配的会话","noSessionsYet":"暂无会话","projectList":"项目列表","openFolder":"打开文件夹","loadingHistory":"加载历史消息..."},"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}})","groupPendingReview":"运行完成待查看","groupUpcoming":"运行中 \xb7 待运行","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":"停止终端失败","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":"重新构建项目图","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":"无差异文件","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":{"startConversation":"开始对话吧","loadMoreHistory":"加载更多...","scrollUpForMore":"↑ 向上滚动加载更多历史","jumpToStart":"跳转到开始","jumpToLatest":"跳转到最新","jumpToPrevUserMessage":"上一条用户消息","jumpToNextUserMessage":"下一条用户消息","recentUserMessages":"最近的用户消息","moreUserMessages":"更多","userMessage":"用户消息","recentUserMessageNumber":"最近用户消息 {{index}}/{{total}}","imageMessage":"图片消息","copyMessage":"复制消息","copyImage":"复制图片","copiedImage":"已复制图片","forkSession":"从此处分叉会话","excerptTurn":"摘录本轮到新会话","newSession":"新建会话","continueFromHere":"延续到此处","continueFromHereDesc":"保留截至本轮的全部上下文","onlyThisTurn":"仅提取本轮","onlyThisTurnDesc":"只带这一轮问答","deleteTurn":"删除本轮","deletingTurn":"正在删除…","deleteTurnConfirm":"确定删除这一轮的问题、回答及工具记录吗?此操作无法撤销。","deleteTurnConfirmAction":"删除本轮","deleteTurnWhileRunning":"会话运行期间不能删除","sendToPeerPane":"发送本条消息到另一栏","imageN":"图片 {{index}}","imagePreview":"图片预览","toolCalls":"{{count}} 个工具调用","collapse":"▲ 收起","expand":"▼ 展开","showMore":"显示更多","showLess":"收起","subagent":"子代理","subagentEmpty":"未找到子代理消息记录","subagentViewTitle":"查看子代理执行过程","workflowRun":"运行详情","workflowViewTitle":"查看工作流运行详情","workflowEmpty":"未找到工作流运行记录","workflowAgents":"个代理","workflowViewAgent":"查看","workflowUngrouped":"未分组","viewQuestions":"查看提问","viewAllFileChanges":"查看所有文件变更","requestFailed":"请求失败","cannotReadStream":"无法读取响应流","errorRetry":"发生错误,请重试","codexResumeFailed":"原会话被其他 Codex 客户端占用,已新建会话,历史未继承","codexResumeFailedPrevious":"原会话","codexResumeFailedNew":"新会话","placeholder":"输入消息,Enter 发送(Shift+Enter 换行,可粘贴图片;行首 /(skill)、/@(子代理执行 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":"不带历史上下文:每条消息单独发给模型,不带之前的对话。上方的会话记录照常保留。","outputStyle":"输出风格","outputStyleNone":"无","noOutputStyles":"暂无输出风格,点右上角铅笔添加","editOutputStyles":"编辑输出风格","outputStylesMarkdownHint":"每个风格以「# 名称」开头,下面直到下一个「# 」之间的内容原样追加到 System Prompt 末尾(可多行,## 等更深标题视为正文)。","outputStylesMarkdownPlaceholder":"# 简洁\\n回答不超过三句话,不要开场白。\\n\\n# 教学\\n先讲为什么,再讲怎么做。","outputStylesError":{"content-before-heading":"第 {{line}} 行:内容必须写在「# 名称」之后。","empty-style":"第 {{line}} 行:风格需要名称和内容。","duplicate-name":"第 {{line}} 行:风格名称重复。"},"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":"暂无自定义命令","namePlaceholder":"名称","commandPlaceholder":"命令","restoreTooltip":"还原 ({{modKey}}M / ESC)","screenshotting":"截图中...","outputFileDeleted":"[输出文件已删除]"},"browser":{"blankPage":"空白页","copyUrl":"复制网址","openInNewWindow":"在新窗口打开","exitMaximize":"退出最大化 ({{modKey}}M)","maximize":"最大化 ({{modKey}}M)","pageLoadFailed":"页面加载失败","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":"Cockpit Bridge 已安装","extensionNotInstalled":"Cockpit Bridge 未安装","extensionDescription":"安装 Chrome 插件后,iframe 内的链接跳转将被拦截:新标签链接创建新气泡,页面内导航更新当前气泡。","installSteps":"安装步骤:","step1":"1. 打开 Chrome 地址栏输入","step2":"2. 开启右上角「开发者模式」","step3":"3. 点击「加载已解压的扩展程序」","step4mac":"4. 按 <kbd>Cmd+Shift+G</kbd> → 粘贴下方路径 → 回车","copyExtensionPath":"复制插件目录路径","reloadExtension":"重载插件","about":"关于","language":"语言","languageAuto":"跟随系统","switchDark":"切换暗色","switchLight":"切换亮色","agentsBundled":"内置"},"editor":{"placeholder":"写点什么... 输入 / 打开快捷命令","noteTitle":"{{name}} - 笔记","noteUntitled":"笔记","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":"结果","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":"正在加载快照…","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"},"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":{"title":"机器人","search":"搜索机器人","addExisting":"添加机器人","addTooltip":"添加为机器人","emptyNoMatch":"没有匹配的机器人。","emptyNoBots":"还没有你自己的机器人。","emptyCreatePrefix":"在聊天里使用","emptyCreateSuffix":"创建一个。","emptyAddExisting":"添加已有的机器人目录","invalid":"无效","builtin":"内置","remove":"移除注册","open":"作为项目打开","pathPlaceholder":"机器人目录或其 BOT.md 的绝对路径","addHint":"目录中必须包含 BOT.md,不会改动其中的文件。","added":"机器人已添加","alreadyAdded":"已添加过","removed":"已移除机器人注册,目录文件仍保留。","loadFailed":"加载机器人失败","saveFailed":"添加机器人失败","removeFailed":"移除机器人失败"}}');r.Ay.isInitialized||r.Ay.init({resources:{en:{translation:o},zh:{translation:s}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});let a=r.Ay},70188:(e,t,n)=>{n.d(t,{Ee:()=>h,SU:()=>c,ft:()=>u,iN:()=>d});var r=n(95155),o=n(12115),s=n(79114),a=n(47650),l=n(34075);let i=(0,o.createContext)(null);function c({container:e,children:t}){return(0,r.jsx)(i.Provider,{value:e,children:t})}function d(){return(0,o.useContext)(i)}function u({x:e,y:t,path:n,cwd:c,isDirectory:d,onClose:h,onCreateFile:m,onDelete:p,onRefresh:f,onCopyFile:g,onPaste:x,onExplain:b,explainDisabled:v}){let{t:y}=(0,s.Bd)(),w=(0,o.useRef)(null),k=(0,o.useContext)(i),C=n.split("/").pop()||n,j=`${c}/${n}`,N=n.includes("/")?n.substring(0,n.lastIndexOf("/")):"",S=N?`${c}/${N}`:c,T=d?n:N,E=d?j:S;(0,o.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&h()},t=e=>{"Escape"===e.key&&h()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[h]);let[L,M]=(0,o.useState)({x:0,y:0});(0,o.useEffect)(()=>{if(w.current&&k){let n=k.getBoundingClientRect(),r=w.current.getBoundingClientRect(),o=e-n.left,s=t-n.top;o=Math.min(o,n.width-r.width-8),s=Math.min(s,n.height-r.height-8),M({x:o=Math.max(8,o),y:s=Math.max(8,s)})}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 R=(0,o.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")}h()},[h,y]),A=d?n:N,P=!!b&&!d,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:d?y("fileContextMenu.copyFolderName"):y("fileContextMenu.copyFileName"),value:C}],I=(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:L.x,top:L.y},children:[P&&(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:()=>{h(),b(n)},children:y("explain.action")}),P&&(0,r.jsx)("div",{className:"my-1 border-t border-border"}),m&&(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:()=>{h(),m(A)},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:()=>{h(),g(n)},children:d?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:()=>{h(),x(A)},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:()=>{h(),p(n,d,C)},children:d?y("fileContextMenu.deleteFolder"):y("fileContextMenu.deleteFile")}),!!(m||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:()=>R(e.value,e.label),children:e.label},t))]});return k?(0,a.createPortal)(I,k):I}function h(){let[e,t]=(0,o.useState)(null);return{contextMenu:e,showContextMenu:(0,o.useCallback)((e,n,r)=>{e.preventDefault(),e.stopPropagation(),t({x:e.clientX,y:e.clientY,path:n,isDirectory:r})},[]),hideContextMenu:(0,o.useCallback)(()=>{t(null)},[])}}},72312:(e,t,n)=>{n.d(t,{N:()=>o});var r=n(95155);function o({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})}},74086:(e,t,n)=>{n.d(t,{I$:()=>a,hC:()=>s,v2:()=>l});var r=n(12115),o=n(14594);function s(){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 s=(0,o.Uy)(e.get(r),t);e.set(r,s),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:()=>o});var r=n(88292);let o={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")}},77725:(e,t,n)=>{n.d(t,{Z:()=>d});var r=n(12115),o=n(10592),s=n(86359),a=n(80905),l=n(49433),i=n(80286),c=n(86957);function d(e,t){let[n,d]=(0,r.useState)({status:"loading"});return(0,r.useEffect)(()=>{d({status:"loading"});let t=c.t4.runFork(e);return t.addObserver(e=>{o.YW(e,{onSuccess:e=>d({status:"success",data:e}),onFailure:e=>{if(s.t9(e))return;let t=s.od(e);d({status:"error",error:a.Ru(t)?t.value:e})}})}),()=>{l.MY7(i.G(t))}},t),n}},79237:(e,t,n)=>{n.d(t,{y:()=>o});let r=e=>"/"===e||"\\"===e;function o(e,t){let n;if(!e)return null;let o=""===(n=e.replace(/[/\\]+$/,""))||/^[A-Za-z]:$/.test(n)?e:n;return t===o?"":t.startsWith(o)?r(o[o.length-1])?t.slice(o.length):r(t[o.length])?t.slice(o.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 o(e,t){if(!e)return"";let n=r(t,e);if(n?.isDirectory)return e;let o=e.split("/");return o.pop(),o.join("/")}function s(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],o=t===e.length-1,s=e.slice(0,t+1).join("/"),a=r.find(e=>e.name===n);a||(a={name:n,path:s,isDirectory:!o,children:o?void 0:[]},r.push(a)),!o&&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:()=>d,MB:()=>r,S7:()=>o,fw:()=>u,q3:()=>c,r6:()=>h,tE:()=>m,tW:()=>a,u:()=>i,v3:()=>s});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 c(e,t,n=!1){let r=new Set;if(!t)return r;let o=t.toLowerCase(),s=e=>{if(r.add(e.path),e.children)for(let t of e.children)s(t)},a=(e,t)=>{let l=e.name.toLowerCase(),i=n?l===o:l.includes(o);if(i&&e.children)return s(e),t.forEach(e=>r.add(e)),!0;let c=!1;if(e.children)for(let n of e.children)a(n,[...t,e.path])&&(c=!0);return(!!i||!!c)&&(r.add(e.path),t.forEach(e=>r.add(e)),!0)};for(let t of e)a(t,[]);return r}function d(e,t,n=!1){let r=new Set;if(!t)return r;let o=t.toLowerCase();for(let t of e){let e=t.split("/");for(let t=0;t<e.length;t++){let s=e[t].toLowerCase();if(n?s===o:s.includes(o)){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),o=Math.floor(r/30),s=Math.floor(r/365);return s>0?`${s}y ago`:o>0?`${o}mo ago`:r>0?`${r}d ago`:n>0?`${n}h ago`:t>0?`${t}m ago`:"just now"}function h(e){let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return r?`${o}-${s} ${a}:${l}`:`${t.getFullYear()}-${o}-${s} ${a}:${l}`}let m=()=>{},p=50},82680:(e,t,n)=>{n.d(t,{m_:()=>s,uV:()=>o});var r=n(50584);class o extends r.rN("AppError"){}r.rN("DBError"),r.rN("WSError"),r.rN("FSError"),r.rN("AgentError"),r.rN("ValidationError");class s extends r.rN("NotFoundError"){}r.rN("PermissionError")},83448:(e,t,n)=>{n.d(t,{$N:()=>N,$x:()=>I,Cr:()=>A,DF:()=>B,F4:()=>b,Fi:()=>f,Hw:()=>h,JC:()=>k,K4:()=>$,K9:()=>i,M5:()=>y,Ny:()=>m,QW:()=>S,Vm:()=>L,ZQ:()=>F,Zr:()=>j,_9:()=>P,an:()=>R,dM:()=>x,dQ:()=>p,em:()=>u,hZ:()=>D,he:()=>g,l1:()=>w,nM:()=>c,n_:()=>C,qD:()=>M,td:()=>d,yS:()=>v,z2:()=>T});var r=n(49433),o=n(82680);let s=(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 o.uV({message:`${t?.method??"GET"} ${e} failed`,cause:n})}),a=(e,t)=>s(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=(e,t)=>s(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=e=>s(`/api/project-state?cwd=${encodeURIComponent(e)}`),c=(e,t)=>a("/api/session/user-messages",{cwd:e,sessionId:t}),d=()=>s("/api/settings"),u=e=>l("/api/settings",e),h=e=>s(`/api/${e}/credentials`),m=e=>s(`/api/${e}/credentials?reveal=1`),p=(e,t)=>l(`/api/${e}/credentials`,{apiKey:t}),f=e=>s(`/api/${e}/models`),g=()=>s("/api/deepseek/balance"),x=e=>s(`/api/${e}/usage`),b=()=>s("/api/ollama/config"),v=e=>l("/api/ollama/config",e),y=()=>s("/api/commands"),w=()=>s("/api/skills"),k=e=>a("/api/bash",e),C=e=>r.$mh({try:async()=>{let t=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?await t.json():null},catch:e=>new o.uV({message:"POST /api/session-by-path failed",cause:e})}),j=(e,t)=>a(`/api/session/${encodeURIComponent(e)}/fork`,t),N=(e,t)=>s(`/api/session/${encodeURIComponent(e)}/turn`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),S=e=>s(`/api/sessions/projects/${encodeURIComponent(e)}`),T=()=>s("/api/global-state").pipe(r.TjK(e=>e.sessions??[])),E=()=>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 o.uV({message:"fetch ollama models failed",cause:e})}),L=()=>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)),M=e=>r.JkU(function*(){let t=yield*E();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 o.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 s=yield*E();return"not-running"===s._tag?{_tag:"error",message:s.reason??t.reason??"Ollama started but cannot fetch models"}:s}),R=e=>s(`/api/file?path=${encodeURIComponent(e)}`),A=()=>s("/api/claude-stats"),P=e=>Array.isArray(e.items),F=()=>s("/api/instructions/config?scope=global"),I=e=>s(`/api/instructions/config?cwd=${encodeURIComponent(e)}`),D=e=>a("/api/instructions/config",e),$=()=>s("/api/output-styles/config"),B=e=>a("/api/output-styles/config",{styles:e})},83897:(e,t,n)=>{n.d(t,{k_:()=>l,nH:()=>i});var r=n(95155),o=n(12115),s=n(48347);let a=(0,o.createContext)(null);function l({children:e}){let t=(0,o.useRef)(new Map),n=(0,o.useRef)(null),[i,c]=(0,o.useState)(()=>new Set),d=i.size>0,u=(0,o.useCallback)((e,t)=>{c(n=>{if(t===n.has(e))return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),h=(0,o.useCallback)((e,n)=>{t.current.set(n,e)},[]),m=(0,o.useCallback)(e=>{t.current.delete(e),c(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),p=(0,o.useCallback)(e=>{n.current=e},[]),f=(0,o.useCallback)(e=>{let r=n.current;if(!r)return void console.warn("No active tab to send message");let o=t.current.get(r);o?o(e):console.warn(`No chat sender registered for tab ${r}`)},[]),g=(0,o.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,o.useMemo)(()=>({sendMessage:f,sendToTab:g,isLoading:d,registerChat:h,unregisterChat:m,setActiveTab:p,setChatLoading:u}),[f,g,d,h,m,p,u]),b=(0,o.useMemo)(()=>({sendMessage:f,isLoading:d}),[f,d]);return(0,r.jsx)(a.Provider,{value:x,children:(0,r.jsx)(s.H,{value:b,children:e})})}function i(){return(0,o.useContext)(a)}},84444:(e,t,n)=>{n.d(t,{H:()=>o});let r=e=>"unread"===e?0:"loading"===e?1:2;function o(e){return[...e].sort((e,t)=>r(e.status)-r(t.status)||t.lastActive-e.lastActive)}},85269:(e,t,n)=>{n.d(t,{O:()=>h});var r=n(95155),o=n(12115),s=n(48347),a=n(89109),l=n(7320),i=n(34582),c=n(1058),d=n(90717),u=n(69809);function h({content:e,filePath:t,cwd:n,onContentSearch:m,reloadKey:p=0}){let f=(0,s.r)(),g=!!n,x=(0,o.useMemo)(()=>{if((0,i.qF)(t,n))return{mode:"url",url:(0,i.Xe)(t,n)};let r=e??"",o=(0,i.J4)(t,n),s="https:"===window.location.protocol?"wss:":"ws:",a=`${s}//${window.location.host}/ws/bash?cwd=${encodeURIComponent(o)}`;return{mode:"srcdoc",html:(0,i.OP)(r,{cwd:o,wsUrl:a})}},[e,t,n]),{addComment:b,refresh:v}=(0,c._)({cwd:n||"",filePath:t}),[y,w]=(0,o.useState)(null),k=(0,o.useRef)(null),C=(0,o.useRef)(null),j=(0,o.useRef)(()=>{}),[N,S]=(0,o.useState)(null),[T,E]=(0,o.useState)(null),L=(0,o.useRef)(!1);(0,o.useEffect)(()=>{L.current=!!(N||T)},[N,T]);let M=(0,o.useCallback)(()=>{C.current&&(C.current=null,j.current())},[]),R=(0,o.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(L.current)return;let n=e.contentWindow?.getSelection(),r=n&&!n.isCollapsed?n.toString().trim():"";if(!r)return void M();let o=e.getBoundingClientRect();C.current={x:o.left+t.clientX,y:o.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]),A=(0,o.useCallback)(()=>{let e=C.current;e&&(S({x:e.x,y:e.y,text:e.selectedText}),M(),k.current?.contentWindow?.getSelection()?.removeAllRanges())},[M]),P=(0,o.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,o.useCallback)(()=>{let e=C.current;e&&f&&(M(),k.current?.contentWindow?.getSelection()?.removeAllRanges(),(0,d.Ff)(f.sendMessage,{filePath:t,startLine:0,endLine:0,codeContent:e.selectedText},u.A.t("explain.selectionMessage")))},[f,t,M]),I=(0,o.useCallback)(()=>{let e=C.current;if(!e||!m)return;let t=e.selectedText.trim();M(),k.current?.contentWindow?.getSelection()?.removeAllRanges(),t&&m(t)},[m,M]),D=(0,o.useCallback)(async e=>{N&&(await b(0,0,e,N.text),S(null))},[N,b]),$=(0,o.useCallback)(async(e,r)=>{if(f&&n)try{let o=(await (0,d.$3)(n)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));o.push({filePath:t,startLine:0,endLine:0,codeContent:e});let s=(0,d.Gw)(o,r);f.sendMessage(s),await (0,d.RP)(n),v()}catch(e){console.error("[HtmlAppFrame] send to AI failed:",e)}},[f,n,t,v]),B=(0,o.useCallback)(e=>{T&&$(T.text,e)},[T,$]),_=(0,o.useCallback)(e=>{N&&$(N.text,e)},[N,$]);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:R},`${t}:${p}`),g&&y&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.fS,{floatingToolbarRef:C,bumpRef:j,container:y,onAddComment:A,onSendToAI:P,onSearch:m?I: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:D,onSendToAI:f?_: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:B,onClose:()=>E(null),isChatLoading:f?.isLoading})]})]})}},85958:(e,t,n)=>{n.d(t,{T:()=>A});var r=n(95155),o=n(46361),s=n(79204),a=n(98164),l=n(77815),i=n(97720),c=n(88374);n(84559),n(21227);var d=n(91334),u=n(38194),h=n(88522),m=n(12115),p=n(34582),f=n(3238),g=n(11890),x=n(73620);function b(e){return{type:"tableCell",children:[{type:"text",value:e}]}}let v=[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=x.Ay.load(n.value??"");e&&"object"==typeof e&&!Array.isArray(e)&&(r=e)}catch{r=null}let o=r?Object.entries(r):[];if(0===o.length){t.splice(e,1),e--;continue}let s={type:"tableRow",children:[b("Field"),b("Value")]},a=o.map(([e,t])=>({type:"tableRow",children:[b(e),b(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:[s,...a]}}}}];function y(e){return!(!e.trim()||/\n[ \t]*\n/.test(e)||e.includes("$"))}function w(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)=>y(t)?`$$${t}$$`:e).replace(/\\\(([^\u0000]*?)\\\)/g,(e,t)=>y(t)?`$${t}$`:e).replace(/\u0000MATHMASK(\d+)\u0000/g,(e,n)=>t[+n])}var k=n(44902),C=n(70570);let j=[k.A,C.A],N=[...v,s.A,...j,a.A,function(){return(e,t)=>{let n=String(t?.value??"");n&&function e(t,n){let r=t.children;if(r)for(let o=0;o<r.length;o++)n(r[o],o,t),e(r[o],n)}(e,(e,t,r)=>{var o;if("inlineMath"!==e.type)return;let s=e.position?.start?.offset,a=e.position?.end?.offset;void 0!==s&&void 0!==a&&(o=e.value??"","$$"!==n.slice(s,s+2)&&(!o||/^\s|\s$/.test(o)||/\d/.test(n[s-1]??"")||/\d/.test(n[a]??"")||0)&&(r.children[t]={type:"text",value:n.slice(s,a),position:e.position}))})}},l.jb],S=[...v,s.A,...j,l.jb],T=[i.A,c.A],E=[i.A];function L(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 M=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 R(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 M.has(n)||n.includes("-")?e:e.replace(/</g,"<").replace(/>/g,">")}).replace(/\u0000MASK(\d+)\u0000/g,(e,n)=>t[+n])}let A=(0,m.memo)(function({content:e,isUser:t=!1,isStreaming:n=!1,enableMath:s=!0,isDark:a,rehypePlugins:l,onLinkClick:i,basePath:c}){let x=(0,f.Ql)(),b=a??x?.resolvedTheme==="dark",v=(0,m.useRef)(null),y=(0,m.useMemo)(()=>({code({className:e,children:t,node:n,...o}){let s=/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",...o,children:t});let a=String(t);if(!s&&!e&&!a.includes("\n"))return(0,r.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent font-mono",...o,children:t});let l=a.replace(/\n$/,""),i=s?.[1]||"text",c=Number(o["data-source-start"])||0,m=c?c+1:0,p=0;return(0,r.jsx)(d.A,{style:b?u.A:h.A,language:i,PreTag:"div",className:"md-figure",customStyle:{margin:"1.35em 0",borderRadius:"0.375rem",fontSize:"0.92em"},wrapLines:!0,lineProps:()=>{let e=m+p;return p++,{"data-source-start":e,"data-source-end":e,style:{display:"block"}}},children: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,...o})=>(0,r.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand hover:underline",...o,onClick:t=>{if(e){if(e.startsWith("#")){(0,g.O)(v.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:o,width:s,style:a,...l})=>{let i=c&&"string"==typeof e?(0,p.xh)(e,c):e;if(!(o||s||a))return(0,r.jsx)("img",{src:i,alt:t||"",className:"max-w-full h-auto rounded-lg my-3",...l});let d=e=>e?/^\d+$/.test(String(e))?`${e}px`:String(e):void 0,u={...a,height:d(o)??a?.height,width:d(s)??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})}),[b,i,c]),k=s?N:S,C=s?T:E,j=(0,m.useMemo)(()=>{if(t||n)return R(e);let r=R(L(!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 s?w(r):r},[e,t,n,s]),M=(0,m.useMemo)(()=>l?.length?[...C,...l]:C,[l,C]);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:v,children:[(0,r.jsx)(o.oz,{remarkPlugins:k,rehypePlugins:C,components:y,children:s?w(R(L(n))):R(L(n))}),a&&(0,r.jsx)("span",{className:"md-tail whitespace-pre-wrap",children:a})]})}return(0,r.jsx)("div",{className:"markdown-body",ref:v,children:(0,r.jsx)(o.oz,{remarkPlugins:k,rehypePlugins:M,components:y,children:j})})})},86304:(e,t,n)=>{n.d(t,{P:()=>c});var r=n(12115),o=n(79114),s=n(34075),a=n(86957),l=n(63040),i=n(63563);function c(){let{t:e}=(0,o.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,s.oR)(e("htmlApps.alreadyAdded"),"info"):((0,s.oR)(e("htmlApps.added"),"success"),(0,i.N)());else{let t="Fail"===n.cause._tag?n.cause.error:null,r=t?.cause,o=r instanceof Error?r.message:e("htmlApps.addFailed");(0,s.oR)(o,"error")}},[e])}},86957:(e,t,n)=>{n.d(t,{t4:()=>B});var r=n(59257),o=n(74565),s=n(49433),a=n(93404),l=n(22484),i=n(41463);let c=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 d=n(80905),u=n(98953);let h=globalThis,m=h.__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,o,s){this.name=e,this.parent=t,this.context=n,this.startTime=o,this.kind=s,this._tag="Span",this.sampled=!0,this.attributes=new Map,this.events=[],this.traceId=d.Ru(t)?t.value.traceId:p(32),this.spanId=p(16),this.status={_tag:"Started",startTime:o},this.links=Array.from(r),function(e){if(m.buffer.push(e),m.index.set(e.spanId,m.buffer.length-1),m.buffer.length>500){m.buffer.shift(),m.index.clear();for(let e=0;e<m.buffer.length;e++)m.index.set(m.buffer[e].spanId,e)}}(function(e,t,n,r,o,s){return{traceId:t,spanId:e,parentSpanId:n,name:r,kind:o,startTimeNs:s.toString(),endTimeNs:null,durationMs:null,attributes:{},events:[],status:"started"}}(this.spanId,this.traceId,function(e){return d.Ru(e)?e.value.spanId:null}(t),e,s,o))}end(e,t){this.status={_tag:"Ended",endTime:e,exit:t,startTime:this.status.startTime},function(e,t,n){let r=m.index.get(e);if(void 0===r)return;let o=m.buffer[r];if(!o)return;let s=Number(t-BigInt(o.startTimeNs))/1e6;m.buffer[r]={...o,endTimeNs:t.toString(),durationMs:Math.round(100*s)/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=m.index.get(e);if(void 0===r)return;let o=m.buffer[r];o&&(m.buffer[r]={...o,attributes:{...o.attributes,[t]:n}})}(this.spanId,e,t)}event(e,t,n){this.events.push([e,t,n??{}]),function(e,t,n,r){let o=m.index.get(e);if(void 0===o)return;let s=m.buffer[o];s&&(m.buffer[o]={...s,events:[...s.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,o,s)=>new f(e,t,n,r,o,s),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)),L=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(4));s.JkU(function*(){let e=yield*y,t=yield*w,n=yield*k,r=yield*C,o=yield*j,a=yield*N,l=yield*S,i=yield*T,c=yield*E,d=yield*L,u=yield*M,h=yield*s.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:h,openProject:r,openBrowser:!o,logLevel:a,logFile:h+"/logs/cockpit.log",snapshotKeepDays:l,snapshotRepoTtlDays:i,snapshotMaxFileKb:c,sessionKeepDays:d,delegateMaxConcurrent:u}}).pipe(s.QgK);let R=r.Ie;var A=n(38147),P=n(23363),F=n(88292);let I=r.P1(F.d,s.JkU(function*(){let e=yield*A.dT();return yield*s.Q56(s.OH5(()=>{let t=t=>{s.MY7(A.mk(e,t))};return window.addEventListener("message",t),t}),e=>s.OH5(()=>{window.removeEventListener("message",e)})),F.d.of({publish:(e,t)=>s.OH5(()=>{let n={type:e.legacyType,topic:e.id,msg:t,..."object"==typeof t&&null!==t?t:{}};window.parent.postMessage(n,"*")}),subscribe:t=>P.qdp(e).pipe(P.pbD(e=>{var n;return n=e.data,!!n&&"object"==typeof n&&(n.topic===t.id||n.type===t.legacyType)}),P.TjK(e=>((e,t)=>{if(e.topic===t.id)return e.msg;let{type:n,...r}=e;return r})(e.data,t)))})})),D=r.Um(c,x,R),$=r.Um(D,I),B=o.L8($);s.rIH},88292:(e,t,n)=>{n.d(t,{R:()=>o,d:()=>s});var r=n(50995);let o=(e,t)=>({id:e,legacyType:t??e.replace(/-/g,"_").toUpperCase()}),s=r.Io("@cockpit/IframeBus")},88403:(e,t,n)=>{n.d(t,{Q:()=>l});var r=n(23348),o=n(33442),s=n(51536);let a={add:r.zB,notify:o._,namespace:"bots",failureKey:"bots.saveFailed"},l=()=>(0,s.X)(a)},88780:(e,t,n)=>{n.d(t,{Do:()=>m,Sz:()=>p,VO:()=>h,wI:()=>f});var r=n(95155),o=n(12115),s=n(79114),a=n(14575),l=n(72312),i=n(70188),c=n(52839);function d({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=o.memo(function e({node:t,level:n,selectedPath:s,expandedPaths:i,onSelect:u,onToggle:h,onContextMenu:m,showChanges:p=!1,showChangeClass:f=!1,hideIndicatorsOnHover:g=!1,renderActions:x}){let b,v=s===t.path,y=i.has(t.path),w=(0,o.useCallback)(()=>{t.isDirectory?h(t.path):u(t)},[t,u,h]),k=(0,o.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),m(e,t.path,t.isDirectory)},[t.path,t.isDirectory,m]);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:s,expandedPaths:i,onSelect:u,onToggle:h,onContextMenu:m,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,c.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)(d,{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 h({files:e,selectedPath:t,expandedPaths:n,onSelect:o,onToggle:a,cwd:l,showChanges:c=!1,showChangeClass:d=!1,hideIndicatorsOnHover:m=!1,renderActions:p,emptyMessage:f,className:g,onExplain:x,explainDisabled:b}){let{t:v}=(0,s.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:o,onToggle:a,onContextMenu:k,showChanges:c,showChangeClass:d,hideIndicatorsOnHover:m,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 m(e){let t=[];for(let n of e){let e=n.path.split("/"),r=t;for(let t=0;t<e.length;t++){let o=e[t],s=t===e.length-1,a=e.slice(0,t+1).join("/"),l=r.find(e=>e.name===o);l||(l={name:o,path:a,isDirectory:!s,children:[],...s&&{status:n.status,additions:n.additions,deletions:n.deletions,oldPath:n.oldPath,file:n}},r.push(l)),s||(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}},89109:(e,t,n)=>{n.d(t,{SZ:()=>a,fS:()=>c});var r=n(95155),o=n(12115),s=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:c,onMouseLeave:d}){let{t:u}=(0,s.Bd)(),h=(0,o.useRef)(null);return(0,o.useEffect)(()=>{h.current&&n(h.current.getBoundingClientRect().height)},[n,e]),(0,r.jsxs)("div",{ref:h,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:c,onMouseLeave:d,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:c,onAddComment:d,onSendToAI:u,onSearch:h,onExplain:m,onQuickReply:p,quickReplyRows:f,onEditQuickReplies:g,isChatLoading:x}){let{t:b}=(0,s.Bd)(),v=(0,o.useRef)(null),[y,w]=(0,o.useState)({w:0,h:0}),[k,C]=(0,o.useState)(0),[j,N]=(0,o.useState)(null),S=(0,o.useRef)(null);(0,o.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,o.useCallback)(e=>{C(t=>t===e?t:e)},[]);(0,o.useEffect)(()=>{n||N(null)},[n]);let E=(0,o.useCallback)(()=>{S.current&&(clearTimeout(S.current),S.current=null)},[]),L=(0,o.useCallback)(e=>{E(),N(e)},[E]),M=(0,o.useCallback)(()=>{E(),S.current=setTimeout(()=>N(null),150)},[E]);(0,o.useEffect)(()=>E,[E]);let R=c.getBoundingClientRect(),A=e-R.left,P=Math.max(0,t-R.top-40),F=Math.max(0,Math.min(A+8,R.width-y.w-8)),I=k>0&&P+y.h+8+k>R.height,D=(0,o.useMemo)(()=>f??a.map(e=>e.map(e=>b(e))),[f,b]),$=e=>p&&j===e?(0,r.jsx)(l,{rows:D,onEdit:g,placeAbove:I,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:P,visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none"},children:[(0,r.jsxs)("div",{className:"relative",onMouseEnter:()=>L("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:d,children:b("floatingToolbar.addComment")}),$("comment")]}),(0,r.jsxs)("div",{className:"relative",onMouseEnter:()=>{x||L("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")}),$("ai")]}),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 disabled:opacity-50 disabled:cursor-not-allowed",onClick:m,disabled:x,title:x?b("comments.aiResponding"):void 0,children:b("explain.action")}),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",onClick:h,children:b("floatingToolbar.search")})]})}let c=(0,o.memo)(function({floatingToolbarRef:e,bumpRef:t,container:n,onAddComment:s,onSendToAI:a,onSearch:l,onExplain:c,onQuickReply:d,quickReplyRows:u,onEditQuickReplies:h,isChatLoading:m}){let[p,f]=(0,o.useState)(0);(0,o.useEffect)(()=>{t.current=()=>f(e=>e+1)},[t]);let g=(0,o.useMemo)(()=>e.current,[p]);return(0,r.jsx)(i,{x:g?.x??0,y:g?.y??0,visible:!!g,container:n,onAddComment:s,onSendToAI:a,onSearch:l,onExplain:c,onQuickReply:d,quickReplyRows:u,onEditQuickReplies:h,isChatLoading:m})})},90717:(e,t,n)=>{n.d(t,{$3:()=>u,Cm:()=>d,Ff:()=>f,Gw:()=>p,RP:()=>h,Un:()=>m,zL:()=>c});var r=n(69809),o=n(49433),s=n(86957),a=n(82680),l=n(46456);let i=new Set;function c(e){return i.add(e),()=>i.delete(e)}function d(){i.forEach(e=>e())}async function u(e){let t=await s.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 s.t4.runPromiseExit(o.$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 c=[];for(let e of n){if(e.selectedText){c.push({...e,codeContent:e.selectedText});continue}let t=i.get(e.filePath),n="";if(t){let r=Math.max(0,e.startLine-1),o=Math.min(t.length,e.endLine);n=t.slice(r,o).join("\n")}c.push({...e,codeContent:n})}return c}async function h(e){let t=await s.t4.runPromiseExit((0,l.tj)(e));return"Success"===t._tag?(d(),!0):(console.error("Failed to clear comments:",t.cause),!1)}let m="__chat__";function p(e,t){let n=e.filter(e=>e.filePath===m),o=e.filter(e=>e.filePath!==m),s=[];for(let e of(o.length>0&&(s.push(`${r.A.t("comments.codeRef")}`,""),o.forEach((e,t)=>{let n=e.startLine>0||e.endLine>0?`:${e.startLine}-${e.endLine}`:"";s.push(`[${t+1}] ${e.filePath}${n}`),s.push("```"),s.push(e.codeContent),s.push("```"),e.note&&s.push(r.A.t("comments.note",{content:e.note})),s.push("")})),n)){let t=e.codeContent.split("\n").map(e=>`> ${e}`).join("\n");s.push(t),e.note&&s.push(e.note),s.push("")}if(t.trim()){for(;s.length>0&&""===s[s.length-1];)s.pop();s.push(t.trim())}return s.join("\n").trim()}function f(e,t,n){e(p([t],n))}},93964:(e,t,n)=>{n.d(t,{N:()=>o});let r=e=>"u"<typeof BroadcastChannel?null:new BroadcastChannel(e),o=e=>({notify:()=>{let t=r(e);if(t)try{t.postMessage({type:"changed"})}finally{t.close()}},subscribe:t=>{let n=r(e);if(!n)return()=>void 0;let o=e=>{e.data?.type==="changed"&&t()};return n.addEventListener("message",o),()=>{n.removeEventListener("message",o),n.close()}}})},94287:(e,t,n)=>{n.d(t,{m:()=>s});var r=n(95155),o=n(12115);function s({content:e,children:t,className:n}){if(n)return(0,r.jsx)("div",{"data-tooltip":e,className:n,children:t});let a=o.Children.toArray(t);if(1===a.length&&(0,o.isValidElement)(a[0])){let t=a[0];return(0,o.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),o=n(88292),s=n(86957);let a=(e,t)=>{s.t4.runFork(r.qIB(o.d,n=>n.publish(e,t)))}},95686:(e,t,n)=>{n.d(t,{x:()=>i});var r=n(95155),o=n(12115),s=n(64428),a=n(70188),l=n(5135);function i({filePath:e,content:t,cwd:n,onClose:c,zClassName:d="z-50"}){let[u,h]=(0,o.useState)(null);return(0,r.jsx)(s.ZL,{children:(0,r.jsx)("div",{className:`fixed inset-0 ${d} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:c,children:(0,r.jsx)("div",{ref:h,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:c})})})})})}},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 o=r.startContainer,s=r.startOffset,a=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),l=1;for(;n=a.nextNode();){if(n===o){l+=s;break}l+=n.textContent?.length||0}return l}function o(e,t){if(0!==e.buttons)return null;let n=window.getSelection();if(n&&!n.isCollapsed)return null;let o=e.target;if("SPAN"!==o.tagName||!o.style.color)return null;let s=o.getBoundingClientRect();return{column:r(e,t),rect:{x:s.left,y:s.bottom+4}}}n.d(t,{A:()=>o,j:()=>r})},97251:(e,t,n)=>{n.d(t,{W:()=>s});var r=n(48250);let o=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","table","tr","hr","div","ul","ol"]);function s(){return e=>{(0,r.YR)(e,"element",e=>{if(o.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)}})}}},98245:(e,t,n)=>{n.d(t,{C:()=>o});var r=n(69809);function o(e,t){if("codex_resume_failed"!==e.notice)return null;let n=e.previous_session_id||"",o=r.A.t("chat.codexResumeFailed",{defaultValue:"Previous session is in use by another Codex client — started a new session; history was not carried over"}),s=[...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=[o,...s.length?["",...s]:[],...e.error?["",e.error]:[]].join("\n");return{id:t,role:"system",content:o,systemEvent:{kind:"meta",detail:a}}}}}]);
|