@surething/cockpit 1.0.232 → 1.0.233
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/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/_global-error.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_index.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.nft.json +1 -1
- package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/_not-found.html +2 -2
- package/.next-prod/server/app/_not-found.rsc +3 -3
- package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next-prod/server/app/api/agent/test/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/bash/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/codex/route.js +1 -1
- package/.next-prod/server/app/api/chat/codex/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/deepseek/route.js +1 -1
- package/.next-prod/server/app/api/chat/deepseek/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/kimi/route.js +1 -1
- package/.next-prod/server/app/api/chat/kimi/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/ollama/route.js +1 -1
- package/.next-prod/server/app/api/chat/ollama/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/chat/pty-input/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 +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/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/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/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/jupyter/load/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/jupyter/save/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/jupyter/shutdown/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/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/pick-folder/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/review/[id]/comments/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/[id]/replies/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/[id]/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/identify/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/order/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/share-info/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/review/users/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/scheduled-tasks/route.js +2 -2
- package/.next-prod/server/app/api/scheduled-tasks/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/services/config/route.js.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.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-by-path/route.js +1 -1
- package/.next-prod/server/app/api/session-by-path/route.js.nft.json +1 -1
- package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js.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/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/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/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/version/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.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.nft.json +1 -1
- package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/project/page.js.nft.json +1 -1
- package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/review/[id]/page.js.nft.json +1 -1
- package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app-paths-manifest.json +2 -2
- package/.next-prod/server/chunks/{3633.js → 1035.js} +373 -3
- package/.next-prod/server/chunks/3863.js +2 -2
- package/.next-prod/server/chunks/9658.js +5 -5
- 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/{217-4f8250a204080159.js → 217-92f800c2c438c550.js} +4 -4
- package/.next-prod/static/chunks/{2576-6420f6bad0b8ffb3.js → 2576-11e41242c7dd98f1.js} +2 -2
- package/.next-prod/static/css/fa7218e60ff464b5.css +1 -0
- package/.next-prod/trace +13 -13
- package/.next-prod/trace-build +1 -1
- package/dist/scheduledTasks.mjs +436 -2
- package/package.json +1 -1
- package/.next-prod/static/css/2a854655f4108c3a.css +0 -1
- /package/.next-prod/static/{Z3Em1C_kM7x4RjcH7E7v2 → WfNQMmytl62j_8KtgCW9_}/_buildManifest.js +0 -0
- /package/.next-prod/static/{Z3Em1C_kM7x4RjcH7E7v2 → WfNQMmytl62j_8KtgCW9_}/_ssgManifest.js +0 -0
|
@@ -30,22 +30,22 @@ Error: ${c.message}`,exitCode:1,isRunning:!1,pid:void 0}:d))}},[l,G,u,E,c,a,Y,ad
|
|
|
30
30
|
`:"")+"</task-notification>";b(b=>[...b,{id:c,role:"system",content:a.summary||"",systemEvent:{kind:"task-notification",...a.status?{status:a.status}:{},detail:d}}])}return}if("user"===a.type&&a._human){let c=a.message?.content,d="string"==typeof c?c:Array.isArray(c)?c.map(a=>a?.text||"").join(""):"",e=`live-user-${++j.current}`;b(a=>{for(let b=a.length-1;b>=0;b--)if("user"===a[b].role){if(a[b].content===d)return a;break}return[...a,{id:e,role:"user",content:d}]});return}"result"===a.type&&(k.current=!1);let c=i.current??l();b(b=>(0,g.F)(b,a,{engine:d,assistantId:c}))};(0,f.h)({url:a?`/ws/session-stream?sessionId=${encodeURIComponent(a)}`:"/ws/session-stream",enabled:c&&!!a,onMessage:a=>{if("run-snapshot"===a.type&&Array.isArray(a.events)){if("running"!==a.status)return void h?.onRunningChange?.(!1);let c=a.events.find(a=>a?.type==="user"&&a?._human),d=c?.message?.content,e="string"==typeof d?d:"",f=new Set,g=new Set;for(let b of a.events){let a=b?.uuid;if("string"==typeof a&&f.add(a),b?.type==="assistant"&&Array.isArray(b.message?.content))for(let a of b.message.content)a?.name&&"string"==typeof a.id&&g.add(a.id)}for(let c of(b(a=>{let b=a.filter(a=>!("string"==typeof a.id&&a.id.startsWith("live-")));if(!e)return b;let c=-1;for(let a=b.length-1;a>=0;a--)if("user"===b[a].role){b[a].content===e&&(c=a);break}return -1===c?b:b.slice(c+1).every(a=>"assistant"===a.role&&("string"==typeof a.id&&f.has(a.id)||!!a.toolCalls?.length&&a.toolCalls.every(a=>g.has(a.id))))?b.slice(0,c):b}),i.current=null,j.current=0,k.current=!1,a.events))m(c);h?.onRunningChange?.(!0)}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type){h?.onRunningChange?.(!1),h?.onComplete?.();return}m(a.message),h?.onRunningChange?.(!0)}else"run-idle"===a.type&&h?.onRunningChange?.(!1)}})}d()}catch(a){d(a)}})},41051:(a,b,c)=>{"use strict";c.d(b,{f:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,visible:c,container:e,onAddComment:h,onSendToAI:i,onSearch:j,isChatLoading:k}){let{t:l}=(0,f.Bd)(),m=e.getBoundingClientRect(),n=a-m.left,o=Math.max(0,b-m.top-40);return(0,d.jsxs)("div",{className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-xl p-1.5",style:{left:n+8,top:o,visibility:c?"visible":"hidden",pointerEvents:c?"auto":"none"},children:[(0,d.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:l("floatingToolbar.addComment")}),(0,d.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:i,disabled:k,title:l(k?"comments.aiResponding":"floatingToolbar.sendToAI"),children:l("floatingToolbar.sendToAI")}),j&&(0,d.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:j,children:l("floatingToolbar.search")})]})}let h=(0,e.memo)(function({floatingToolbarRef:a,bumpRef:b,container:c,onAddComment:f,onSendToAI:h,onSearch:i,isChatLoading:j}){let[k,l]=(0,e.useState)(0),m=(0,e.useMemo)(()=>a.current,[k]);return(0,d.jsx)(g,{x:m?.x??0,y:m?.y??0,visible:!!m,container:c,onAddComment:f,onSendToAI:h,onSearch:i,isChatLoading:j})})},41224:(a,b,c)=>{"use strict";c.d(b,{Cr:()=>t,JC:()=>l,M5:()=>j,QW:()=>o,Zr:()=>n,an:()=>s,em:()=>i,l1:()=>k,n_:()=>m,qD:()=>r,td:()=>h,z2:()=>p});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=()=>f("/api/settings"),i=a=>f("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),j=()=>f("/api/commands"),k=()=>f("/api/skills"),l=a=>g("/api/bash",a),m=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});return b.ok?await b.json():null},catch:a=>new e.uV({message:"POST /api/session-by-path failed",cause:a})}),n=(a,b)=>g(`/api/session/${encodeURIComponent(a)}/fork`,b),o=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),p=()=>f("/api/global-state").pipe(d.map(a=>a.sessions??[])),q=()=>d.tryPromise({try:async()=>{let a=await fetch("/api/ollama/models");return 503===a.status?{_tag:"not-running"}:a.ok?{_tag:"ok",models:(await a.json()).models??[]}:{_tag:"error",message:"Failed to fetch models"}},catch:a=>new e.uV({message:"fetch ollama models failed",cause:a})}),r=a=>d.gen(function*(){let b=yield*q();if("not-running"!==b._tag)return b;a&&(yield*d.sync(a));let c=yield*d.tryPromise({try:async()=>{let a=await fetch("/api/ollama/start",{method:"POST"}),b=await a.json().catch(()=>({}));return 404===a.status?{_tag:"not-installed",message:b.message||"Ollama is not installed"}:a.ok?{_tag:"started"}:{_tag:"error",message:"Failed to start Ollama"}},catch:a=>new e.uV({message:"start ollama failed",cause:a})});if("not-installed"===c._tag)return{_tag:"not-installed",message:c.message};if("error"===c._tag)return{_tag:"error",message:c.message};let f=yield*q();return"not-running"===f._tag?{_tag:"error",message:"Ollama started but cannot fetch models"}:f}),s=a=>f(`/api/file?path=${encodeURIComponent(a)}`),t=a=>f(`/api/claude-stats?engine=${encodeURIComponent(a)}`)},42140:(a,b,c)=>{"use strict";c.d(b,{G:()=>h,t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,range:c,lineSnapshot:h,container:i,onSubmit:j,onClose:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)(!1),q=(0,e.useRef)(null),r=(0,e.useRef)(null),[s,t]=(0,e.useState)({x:0,y:0}),u=h?.split("\n").slice(0,5).join("\n"),v=!!h&&h.split("\n").length>5;return(0,d.jsxs)("div",{ref:q,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:s.x,top:s.y},children:[(0,d.jsx)("div",{className:"px-3 py-2 bg-amber-9/10 border-b border-border",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-amber-11",children:l("comments.addComment")}),(c.start>0||c.end>0)&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:l("comments.lineRange",{start:c.start,end:c.end})})]})}),h&&(0,d.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,d.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[u,v&&(0,d.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsx)("textarea",{ref:r,value:m,onChange:a=>n(a.target.value),placeholder:l("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:o,onKeyDown:a=>{"Enter"===a.key&&!a.shiftKey&&!a.nativeEvent.isComposing&&(a.preventDefault(),!o&&m.trim()&&(p(!0),j(m.trim()))),"Escape"!==a.key||o||k()}}),(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:l(o?"comments.submitting":"comments.enterSubmit")})]})]})}function h({x:a,y:b,range:c,filePath:g,lineSnapshot:i,container:j,onSubmit:k,onClose:l,isChatLoading:m}){let{t:n}=(0,f.Bd)(),[o,p]=(0,e.useState)(""),q=(0,e.useRef)(null),r=(0,e.useRef)(null),[s,t]=(0,e.useState)({x:0,y:0}),u=i?.split("\n").slice(0,5).join("\n"),v=!!i&&i.split("\n").length>5;return(0,d.jsxs)("div",{ref:q,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:s.x,top:s.y},children:[(0,d.jsxs)("div",{className:"px-3 py-2 bg-brand/10 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-brand",children:n("comments.askAI")}),(c.start>0||c.end>0)&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:n("comments.lineRange",{start:c.start,end:c.end})})]}),g&&(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:g})]}),i&&(0,d.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,d.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[u,v&&(0,d.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsx)("textarea",{ref:r,value:o,onChange:a=>p(a.target.value),placeholder:n("comments.inputQuestion"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:m,onKeyDown:a=>{"Enter"===a.key&&!a.shiftKey&&!a.nativeEvent.isComposing&&(a.preventDefault(),!m&&o.trim()&&(k(o.trim()),l())),"Escape"===a.key&&l()}}),(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:n(m?"comments.aiGenerating":"comments.enterSend")})]})]})}},43037:(a,b,c)=>{"use strict";c.d(b,{E3:()=>d});let d=c(32891).YY.create({name:"markdownTaskListFix",addStorage:()=>({markdown:{parse:{updateDOM(a){!function(a){for(let b of Array.from(a.querySelectorAll("ul.contains-task-list"))){let a=Array.from(b.children).filter(a=>"LI"===a.tagName);if(0===a.length)continue;let c=function(a){let b=[];for(let c of a){let a=b[b.length-1];a&&a.isTask===c.isTask?a.items.push(c):b.push({isTask:c.isTask,items:[c]})}return b}(a.map(a=>({isTask:a.classList.contains("task-list-item"),el:a})));if(c.length<=1){c[0]?.isTask&&b.setAttribute("data-type","taskList");continue}let d=b.ownerDocument,e=d.createDocumentFragment();for(let a of c){let b=d.createElement("ul");for(let{el:c}of(a.isTask&&(b.setAttribute("class","contains-task-list"),b.setAttribute("data-type","taskList")),a.items))b.appendChild(c);e.appendChild(b)}b.replaceWith(e)}}(a)}}}})})},43321:(a,b,c)=>{"use strict";c.d(b,{D:()=>f});let d=/^\s*[-*+]\s+(?:\\?\[ \\?\]|\\?\[[xX]\\?\])\s*$/,e=/^\s*(```|~~~)/;function f(a){if(!a)return a;let b=a.split("\n"),c=[],f=!1;for(let a of b){if(e.test(a)){f=!f,c.push(a);continue}if(f){c.push(a);continue}d.test(a)||c.push(a)}let g=[],h=0,i=!1;for(let a of c){if(e.test(a)){i=!i,g.push(a),h=0;continue}if(!i&&""===a.trim()){if((h+=1)>=2)continue;g.push(a);continue}h=0,g.push(a)}return g.join("\n")}},43489:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,60440,23)),Promise.resolve().then(c.t.bind(c,84342,23)),Promise.resolve().then(c.t.bind(c,82265,23)),Promise.resolve().then(c.t.bind(c,35421,23)),Promise.resolve().then(c.t.bind(c,61335,23)),Promise.resolve().then(c.t.bind(c,70664,23)),Promise.resolve().then(c.bind(c,74661))},44256:(a,b,c)=>{"use strict";c.d(b,{F2:()=>m,ZL:()=>k,a9:()=>l});var d=c(48249),e=c(67484),f=c(74429);let g=()=>()=>{},h=()=>document.body,i=()=>null,j=(0,e.createContext)(null);function k({children:a}){let b=(0,e.useContext)(j),c=(0,e.useSyncExternalStore)(g,h,i),d=b??c;return d?(0,f.createPortal)(a,d):null}function l({children:a}){let[b,c]=(0,e.useState)(null);return(0,d.jsxs)("div",{className:"relative w-full h-full",style:{transform:"translateZ(0)"},children:[(0,d.jsx)(j.Provider,{value:b,children:a}),(0,d.jsx)("div",{ref:c,className:"absolute inset-0 pointer-events-none [&>*]:pointer-events-auto"})]})}function m(){return(0,e.useContext)(j)}},44616:(a,b,c)=>{Promise.resolve().then(c.bind(c,67045))},47111:(a,b,c)=>{"use strict";c.a(a,async(a,b)=>{try{var d=c(48249),e=c(3560),f=c(13812),g=c(74493),h=a([f]);f=(h.then?(await h)():h)[0],(0,e.Aq)({type:"redis",idPrefix:"redis",match(a){let b=a.trim().toLowerCase();return b.startsWith("redis://")||b.startsWith("rediss://")},parse(a){let b=a.trim(),c=b;try{let a=new URL(b),d=a.pathname.replace(/^\//,"")||"0";c=`db${d}@${a.hostname}${a.port?":"+a.port:":6379"}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l}){return(0,d.jsx)(f.k,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l})},async onClose(a){await (0,g.ax)("redis",a.id)}}),b()}catch(a){b(a)}})},47818:(a,b,c)=>{"use strict";c.d(b,{EE:()=>h,K2:()=>i,ri:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(31002);let h=80,i=24,j=(0,e.forwardRef)(function({visible:a,running:b,onInput:c},j){let{t:k}=(0,f.Bd)(),l=(0,e.useRef)(c);(0,e.useEffect)(()=>{l.current=c},[c]);let[m,n]=(0,e.useState)(!1),o=(0,e.useRef)(!1);(0,e.useEffect)(()=>{b&&!o.current?n(!0):!b&&o.current&&n(!1),o.current=b},[b]);let p=(0,e.useRef)(null),q=(0,e.useRef)(null),r=(0,e.useRef)(""),s=(0,e.useCallback)(()=>{if(q.current||!p.current)return;let a=new g.B({cols:h,rows:i,fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, "Courier New", monospace',convertEol:!1,scrollback:2e3,theme:{background:"#0a0a0a",foreground:"#d4d4d8"},disableStdin:!1,allowProposedApi:!0});a.open(p.current),a.onData(a=>l.current?.(a)),r.current&&a.write(r.current),q.current=a},[]);return((0,e.useEffect)(()=>{m&&a?s():(q.current?.dispose(),q.current=null)},[m,a,s]),(0,e.useImperativeHandle)(j,()=>({write:a=>{r.current+=a,r.current.length>2e5&&(r.current=r.current.slice(-15e4)),q.current?.write(a)},clear:()=>{r.current="",q.current?.clear()}}),[]),a)?(0,d.jsxs)("div",{className:"absolute top-12 right-3 z-30 rounded-lg border border-border bg-card shadow-lg overflow-hidden",style:{width:m?"auto":180},"data-testid":"pty-floating-window",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>n(a=>!a),"data-testid":"pty-floating-toggle",className:"w-full flex items-center justify-between gap-3 px-2.5 py-1.5 text-xs bg-accent/60 hover:bg-accent",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${b?"bg-green-500 animate-pulse":"bg-muted-foreground"}`}),(0,d.jsxs)("span",{className:"text-muted-foreground",children:[k("chat.ptyTerminal"),b?` \xb7 ${k("chat.ptyRunning")}`:""]})]}),(0,d.jsx)("span",{className:"text-muted-foreground",children:m?`${k("chat.ptyCollapse")} ▾`:`${k("chat.ptyExpand")} ▸`})]}),(0,d.jsx)("div",{ref:p,"data-testid":"pty-floating-term",style:{display:m?"block":"none",padding:4},className:"bg-[#0a0a0a]"})]}):null})},47938:(a,b,c)=>{"use strict";c.d(b,{SessionBrowser:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call SessionBrowser() from the server but SessionBrowser is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/SessionBrowser.tsx","SessionBrowser")},49924:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{mp:()=>k,nb:()=>l});var e=c(48249),f=c(44384),g=c(96286),h=c(46674),i=c(72529),j=c(53716);function k({entries:a,onSelect:b,onClear:c}){let{t:d}=(0,f.Bd)();return(0,e.jsxs)("div",{className:"w-56 flex-shrink-0 bg-card border-l border-border flex flex-col","data-testid":"function-history-drawer",children:[(0,e.jsxs)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border flex items-center justify-between gap-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground font-mono min-w-0",children:[(0,e.jsx)(g.A,{className:"w-3 h-3 flex-shrink-0"}),(0,e.jsx)("span",{className:"truncate",children:0===a.length?d("blockViewer.history.title"):`${d("blockViewer.history.title")} \xb7 ${a.length}/15`})]}),a.length>0&&(0,e.jsx)(i.m,{content:d("blockViewer.history.clear"),children:(0,e.jsx)("button",{onClick:c,className:"flex-shrink-0 text-muted-foreground hover:text-foreground p-0.5 rounded hover:bg-secondary",children:(0,e.jsx)(h.A,{className:"w-3 h-3"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===a.length?(0,e.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:d("blockViewer.history.empty")}):a.map((a,c)=>{var d;let f;return(0,e.jsx)(i.m,{content:`${a.qname} \xb7 ${a.filePath}`,children:(0,e.jsxs)("button",{onClick:()=>b(a),className:"w-full text-left px-2 py-1.5 border-b border-border/50 hover:bg-secondary/60 transition-colors group flex items-start gap-1.5",children:[(0,e.jsx)(j.y,{kind:a.kind??"unknown",qname:a.qname,className:"w-3 h-3 mt-0.5 flex-shrink-0"}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("div",{className:"text-xs font-mono font-medium truncate",children:a.name}),(0,e.jsxs)("div",{className:"text-[10px] text-muted-foreground/70 truncate",children:[(f=(d=a.filePath).lastIndexOf("/"))>=0?d.slice(f+1):d,a.kind&&(0,e.jsxs)("span",{className:"ml-1 opacity-60",children:["\xb7 ",a.kind]})]})]})]})},`${a.filePath}::${a.qname}::${c}`)})})]})}function l(a,b){let c=a.filter(a=>a.filePath!==b.filePath||a.qname!==b.qname),d=[b,...c];return d.length>15?d.slice(0,15):d}d()}catch(a){d(a)}})},49950:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{J:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(36295),i=c(39222),j=c(32465),k=c(4354),l=c(55579),m=c(18191),n=c(63963),o=c(9780),p=c(33281),q=c(79606),r=c(23328),s=a([o,m,h,k]);[o,m,h,k]=s.then?(await s)():s;let u=[{key:"command",label:"console.bubbleCommand",triggers:["ls","git status","npm run dev"]},{key:"pty",label:"console.bubbleInteractive",triggers:["zsh","vim","python","top"]},{key:"browser",label:"console.bubbleBrowser",triggers:["https://…"],notes:["console.bubbleBrowserNoteIframe","console.bubbleBrowserNoteCookie"]},{key:"database",label:"console.bubbleDatabase",triggers:["postgresql://","mysql://","redis://","neo4j://"]},{key:"notebook",label:"console.bubbleNotebook",triggers:["*.ipynb"]}];function t({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:d,onOpenNote:s}){let{t:v}=(0,g.Bd)(),{consoleItems:w,scrollRef:x,selectedCommandId:y,setSelectedCommandId:z,interruptCommand:A,sendStdin:B,deleteCommand:C,rerunCommand:D,ptySizeRef:E,resizePty:F,executeCommand:G,addPluginItem:H,closePluginItem:I,sleepingBubbles:J,handleBubbleSleep:K,handleBubbleWake:L,scrollToBottom:M,currentCwd:N,commandHistoryRef:O,setCustomEnv:P,setAliases:Q,saveBubbleOrder:R,hasMoreHistory:S,loadHistory:T,currentPage:U,isLoadingHistory:V,subscribePtyOutput:W,subscribePtyReset:X,subscribePtyRefresh:Y}=(0,m.cK)({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:d}),[Z,$]=(0,f.useState)(null),[_,aa]=(0,f.useState)(0),[ab,ac]=(0,f.useState)(0),[ad,ae]=(0,f.useState)(!0),[af,ag]=(0,f.useState)(!1),[ah,ai]=(0,f.useState)(!1),[aj,ak]=(0,f.useState)(!1),[al,am]=(0,f.useState)(!1),an=(0,f.useRef)(null),ao=(0,f.useRef)(null),ap=(0,f.useRef)(null),aq=(0,f.useRef)(!1),ar=(0,f.useRef)(null),as=(0,f.useRef)(null),at=(0,f.useRef)([]),au=(0,f.useCallback)(()=>{let a=x.current;return!a||a.scrollHeight-a.scrollTop-a.clientHeight<50},[x]),av=(0,f.useCallback)(()=>{let a=x.current;return!a||a.scrollTop<50},[x]),aw=(0,f.useCallback)(()=>{ak(!av()),am(!au())},[au,av]),ax=(0,f.useCallback)(()=>{ao.current?.scrollIntoView({behavior:"smooth"})},[]),ay=(0,f.useCallback)(()=>{aq.current=!0},[]),az=(0,f.useCallback)((a,b)=>{if(!aq.current)return void a.preventDefault();aq.current=!1,ar.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b),a.currentTarget.style.opacity="0.4";let c=a.currentTarget.querySelector("[data-drag-handle]");if(c){let b=c.cloneNode(!0);b.style.cssText="position:fixed;top:-9999px;left:-9999px;width:"+c.offsetWidth+"px;background:var(--card);border-radius:8px;padding:4px 12px;opacity:0.9;",document.body.appendChild(b),a.dataTransfer.setDragImage(b,20,16),requestAnimationFrame(()=>document.body.removeChild(b))}},[]),aA=(0,f.useCallback)((a,b)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",as.current=b},[]),aB=(0,f.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.add("ring-2","ring-brand")},[]),aC=(0,f.useCallback)(a=>{a.currentTarget.classList.remove("ring-2","ring-brand")},[]),aD=(0,f.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.remove("ring-2","ring-brand")},[]),aE=(0,f.useCallback)(a=>{a.currentTarget.style.opacity="1";let b=ar.current,c=as.current;if(ar.current=null,as.current=null,!b||!c||b===c)return;let d=at.current.map(a=>a.data.id),e=d.indexOf(b),f=d.indexOf(c);if(-1===e||-1===f)return;let g=[...d];g[e]=c,g[f]=b,R(g)},[R]),aF=(0,f.useCallback)(a=>{$(b=>b===a?null:a)},[]),aG=ab>0?Math.floor((ab-32-12)/2-41):void 0;return(0,e.jsxs)("div",{ref:an,className:"h-full flex flex-col bg-background relative",children:[(0,e.jsx)("div",{ref:x,onScroll:aw,className:`console-scroll-root flex-1 overflow-y-auto ${Z?"":"py-4 px-4"}`,children:0===w.length?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsxs)("div",{className:"w-full max-w-md flex flex-col gap-4 text-sm",children:[(0,e.jsx)("p",{className:"text-muted-foreground",children:v("console.emptyIntro")}),(0,e.jsx)("ul",{className:"flex flex-col gap-2",children:u.map(a=>(0,e.jsxs)("li",{className:"flex items-start gap-3",children:[(0,e.jsx)("span",{className:"w-16 flex-shrink-0 text-foreground font-medium",children:v(a.label)}),(0,e.jsxs)("span",{className:"flex-1 flex flex-col gap-1",children:[(0,e.jsx)("span",{className:"flex flex-wrap gap-1",children:a.triggers.map(a=>(0,e.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-xs font-mono text-muted-foreground",children:a},a))}),a.notes?.map(a=>(0,e.jsx)("span",{className:"text-xs leading-snug text-muted-foreground/70",children:v(a)},a))]})]},a.key))}),(0,e.jsxs)("button",{type:"button",onClick:()=>G("zsh"),title:v("console.launchZsh"),className:"self-start flex items-center gap-2 px-4 py-2 rounded-lg border border-input bg-background text-sm text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 transition-all",children:[(0,e.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,e.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}),"New PTY"]})]})}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{ref:ao}),S&&(0,e.jsx)("div",{className:"flex justify-center mb-4",children:(0,e.jsx)("button",{onClick:()=>T(U+1),disabled:V,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-50",children:V?v("console.loadingMore"):v("console.loadMoreHistory")})}),(0,e.jsx)("div",{className:Z?"flex flex-col gap-3":ad?"grid grid-cols-2 gap-3":"flex flex-col gap-3",children:w.map(b=>{let d={draggable:!0,onDragStart:a=>az(a,b.data.id),onDragOver:a=>aA(a,b.data.id),onDragEnter:aB,onDragLeave:aC,onDrop:aD,onDragEnd:aE};if("command"===b.type){let f=b.data;return(0,e.jsx)("div",{"data-bubble-id":f.id,className:"group/cmd rounded-lg transition-shadow",...d,children:(0,e.jsx)(h.G,{commandId:f.id,tabId:c,projectCwd:a,command:f.command,output:f.output,exitCode:f.exitCode,isRunning:f.isRunning,selected:y===f.id,onSelect:()=>{z(f.id)},onInterrupt:f.isRunning?()=>A(f.id):void 0,onStdin:f.isRunning?a=>B(f.id,a):void 0,onDelete:()=>{f.isRunning&&f.pid&&(0,n.HV)(f.pid),C(f.id)},onRerun:()=>D(f.id),timestamp:f.timestamp,usePty:f.usePty,subscribePtyOutput:f.usePty?W:void 0,subscribePtyReset:f.usePty?X:void 0,subscribePtyRefresh:f.usePty?Y:void 0,onPtyResize:(a,b)=>{E.current.set(f.id,{cols:a,rows:b}),F(f.id,a,b)},onToggleMaximize:()=>aF(f.id),maximized:Z===f.id,expandedHeight:_,bubbleContentHeight:aG,onTitleMouseDown:ay})},f.id)}let f=(0,o.sd)(b.type);if(!f)return null;let g=f.Component,i=b.data;return(0,e.jsx)("div",{"data-bubble-id":i.id,className:"rounded-lg transition-shadow",...d,children:(0,e.jsx)(g,{item:i,selected:y===i.id,maximized:Z===i.id,expandedHeight:_,bubbleContentHeight:aG,timestamp:i.timestamp,onSelect:()=>{z(i.id)},onClose:()=>I(i.id),onToggleMaximize:()=>aF(i.id),onTitleMouseDown:ay,extra:{addBrowserItem:(a,b)=>H("browser",a,b),initialSleeping:J.has(i.id),onSleep:K,onWake:L,projectCwd:a,tabId:c}})},i.id)})}),(0,e.jsx)("div",{ref:ap})]})}),!Z&&w.length>0&&(0,e.jsx)(l.w,{showTop:aj,showBottom:al,onScrollTop:ax,onScrollBottom:M}),(0,e.jsx)(k.D,{cwd:a,currentCwd:N,commandHistoryRef:O,gridLayout:ad,onGridLayoutChange:b=>{ae(b),p.t4.runFork((0,r.Yn)({cwd:a,settings:{gridLayout:b}}).pipe(q.tapError(a=>q.sync(()=>console.error("Failed to save project settings:",a))),q.orElse(()=>q.void)))},onExecute:G,onAddPluginItem:H,onShowEnvManager:()=>ag(!0),onOpenZsh:()=>G("zsh"),onOpenNote:s}),af&&(0,e.jsx)(i.v,{cwd:a,tabId:c,onClose:()=>ag(!1),onSave:a=>P(a)}),ah&&(0,e.jsx)(j.Y,{onClose:()=>ai(!1),onSave:a=>Q(a)})]})}d()}catch(a){d(a)}})},51520:(a,b,c)=>{"use strict";c.a(a,async(a,b)=>{try{var d=c(48249),e=c(3560),f=c(77016),g=c(74493),h=a([f]);f=(h.then?(await h)():h)[0],(0,e.Aq)({type:"mysql",idPrefix:"mysql",match:a=>a.trim().toLowerCase().startsWith("mysql://"),parse(a){let b=a.trim(),c=b;try{let a=new URL(b),d=a.pathname.replace(/^\//,"")||"mysql";c=`${d}@${a.hostname}${a.port?":"+a.port:""}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l}){return(0,d.jsx)(f.b,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l})},async onClose(a){await (0,g.ax)("mysql",a.id)}}),b()}catch(a){b(a)}})},53036:(a,b,c)=>{"use strict";c.d(b,{I:()=>f});var d=c(48249),e=c(67484);function f(a){let{refreshKey:b,className:c="h-full flex items-center justify-center p-4 bg-secondary",imgClassName:f="max-w-full max-h-full object-contain",alt:g}=a,h="absPath"in a&&"string"==typeof a.absPath,i=h?void 0:a.cwd,j=h?void 0:a.path,k=h?a.absPath:void 0,[l,m]=(0,e.useState)({kind:"loading"});if((0,e.useRef)(0),"loading"===l.kind)return(0,d.jsx)("div",{className:c,children:(0,d.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})});if("missing"===l.kind)return(0,d.jsx)("div",{className:c,children:(0,d.jsx)("div",{className:"text-sm text-muted-foreground",children:"File not found"})});if("too-large"===l.kind)return(0,d.jsx)("div",{className:c,children:(0,d.jsxs)("div",{className:"text-sm text-muted-foreground",children:["Image too large to preview (",Math.round(l.size/1024/1024)," MB)"]})});if("error"===l.kind)return(0,d.jsx)("div",{className:c,children:(0,d.jsx)("div",{className:"text-sm text-red-11",children:l.message})});let n=h?`/api/file?path=${encodeURIComponent(k)}&raw=true`:`/api/files/read?cwd=${encodeURIComponent(i)}&path=${encodeURIComponent(j)}&v=${encodeURIComponent(l.etag)}`;return(0,d.jsx)("div",{className:c,children:(0,d.jsx)("img",{src:n,alt:g??(j||k),className:f})})}c(33281),c(87808)},53113:(a,b,c)=>{Promise.resolve().then(c.bind(c,4462)),Promise.resolve().then(c.bind(c,29491)),Promise.resolve().then(c.bind(c,34001)),Promise.resolve().then(c.bind(c,83179)),Promise.resolve().then(c.bind(c,25608)),Promise.resolve().then(c.bind(c,8077)),Promise.resolve().then(c.bind(c,76552)),Promise.resolve().then(c.bind(c,77120)),Promise.resolve().then(c.bind(c,77220)),Promise.resolve().then(c.bind(c,3588)),Promise.resolve().then(c.bind(c,77462)),Promise.resolve().then(c.bind(c,38878)),Promise.resolve().then(c.bind(c,37129)),Promise.resolve().then(c.bind(c,99033))},53716:(a,b,c)=>{"use strict";c.d(b,{y:()=>l});var d=c(48249),e=c(80600),f=c(33982),g=c(34622),h=c(34948),i=c(26875),j=c(87148),k=c(82633);function l({kind:a,qname:b,className:c}){let m=`${(function(a,b){if("__file__"===b||"__preamble__"===b||b&&b.startsWith("__heading_"))return"text-muted-foreground/60";switch(a){case"function":case"method":return"text-violet-11";case"class":return"text-amber-11";case"interface":return"text-blue-11";default:return"text-muted-foreground/60"}})(a,b)} ${c??""}`.trim();if("__file__"===b)return(0,d.jsx)(e.A,{className:m});if("__preamble__"===b)return(0,d.jsx)(f.A,{className:m});if(b&&b.startsWith("__heading_"))return(0,d.jsx)(g.A,{className:m});switch(a){case"function":case"method":return(0,d.jsx)(h.A,{className:m});case"class":return(0,d.jsx)(i.A,{className:m});case"interface":return(0,d.jsx)(j.A,{className:m});default:return(0,d.jsx)(k.A,{className:m})}}},54038:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(65543),i=c(72529),j=c(53716);function k({functions:a,currentQname:b,onSelect:c,notIndexed:d,onRebuild:l}){let{t:m}=(0,g.Bd)(),n=(0,f.useMemo)(()=>a.filter(h._),[a]);return(0,e.jsxs)("div",{className:"w-56 flex-shrink-0 bg-card border-r border-border flex flex-col","data-testid":"file-toc-section",children:[(0,e.jsx)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border text-xs text-muted-foreground font-mono truncate",children:0===n.length?m("blockViewer.toc.title"):`${m("blockViewer.toc.title")} \xb7 ${n.length}`}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===n.length?d?(0,e.jsxs)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/80 leading-relaxed flex flex-col gap-2",children:[(0,e.jsx)("span",{className:"italic",children:m("blockViewer.toc.notIndexed")}),l&&(0,e.jsx)("button",{type:"button",onClick:l,className:"self-start px-2 py-1 rounded border border-border bg-secondary/60 hover:bg-secondary text-[10px] text-foreground transition-colors",children:m("blockViewer.refresh")})]}):(0,e.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:m("blockViewer.toc.empty")}):n.map(a=>{let d=b===a.qualifiedName;return(0,e.jsx)(i.m,{content:`${a.qualifiedName} \xb7 L${a.startLine}`,children:(0,e.jsxs)("button",{onClick:()=>c(a.qualifiedName,a.startLine),className:`w-full text-left px-2 py-1 transition-colors flex items-center gap-1.5 min-w-0 ${d?"bg-brand/15 hover:bg-brand/20":"hover:bg-secondary/60"}`,children:[(0,e.jsx)(j.y,{kind:a.kind,qname:a.qualifiedName,className:"w-3 h-3 flex-shrink-0"}),(0,e.jsx)("span",{className:`text-xs font-mono truncate ${d?"font-semibold text-brand":""}`,children:a.name})]})},a.qualifiedName)})})]})}d()}catch(a){d(a)}})},55287:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Cv:()=>B,XO:()=>z});var e=c(48249),f=c(67484),g=c(44384),h=c(74429),i=c(33281),j=c(87808),k=c(7122),l=c(42140),m=c(38896),n=c(36984),o=c(41051),p=c(70596),q=c(40159),r=c(13512),s=c(9804),t=c(7833),u=c(83377),v=a([r,n,q,m]);[r,n,q,m]=v.then?(await v)():v;let A="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function w(a){let b=window.getSelection();if(!b?.rangeCount)return null;let c=b.getRangeAt(0),d=c.startContainer;for(;d&&d.parentElement!==a;)d=d.parentElement;if(!d)return null;let e=Array.from(a.children).indexOf(d);if(e<0)return null;let f=document.createRange();f.selectNodeContents(d),f.setEnd(c.startContainer,c.startOffset);let g=f.toString().length;return{line:e,offset:g}}function x(a,b){let c,d=a.children[b.line];if(!d)return;let e=document.createTreeWalker(d,NodeFilter.SHOW_TEXT),f=b.offset;for(;c=e.nextNode();){let a=c.textContent?.length||0;if(f<=a){let a=window.getSelection(),b=document.createRange();b.setStart(c,f),b.collapse(!0),a?.removeAllRanges(),a?.addRange(b);return}f-=a}let g=window.getSelection(),h=document.createRange();h.selectNodeContents(d),h.collapse(!1),g?.removeAllRanges(),g?.addRange(h)}function y(a){return a.map(a=>`<div style="${A}">${a}</div>`).join("")}let B=(0,f.forwardRef)(function({content:a,filePath:b,showLineNumbers:c=!0,showSearch:d=!0,className:m="",cwd:v,enableComments:z=!1,scrollToLine:B=null,scrollToLineAlign:C="center",onScrollToLineComplete:D,highlightKeyword:E=null,visibleLineRef:F,onCmdClick:G,onTokenHover:H,onTokenHoverLeave:I,onTokenHoverCancel:J,blameLines:K,inlineBlameLines:L,onSelectCommit:M,editable:N=!1,initialMtime:O,onEditorClose:P,onSaved:Q,onEditorStateChange:R,viMode:S=!1,onContentMutate:T,onEnterInsertMode:U,onViSave:V,viStateRef:W,initialCursorLine:X,initialCursorCol:Y,onInitialCursorSet:Z,onContentSearch:$},_){let{t:aa}=(0,g.Bd)(),ab=(0,f.useRef)(a),ac=(0,f.useRef)(!1),[ad,ae]=(0,f.useState)(!1),[af,ag]=(0,f.useState)(!1),[ah,ai]=(0,f.useState)(()=>a.split("\n").length),aj=(0,f.useRef)(a.split("\n").length),[ak,al]=(0,f.useState)({show:!1}),am=(0,f.useRef)(null),an=(0,f.useRef)(null),ao=(0,f.useRef)(O),ap=(0,f.useRef)(null),aq=(0,f.useRef)(!1),ar=(0,f.useRef)(!1),{parentRef:as,containerRef:at,searchInputRef:au,floatingToolbarRef:av,suppressHoverRef:aw,bumpToolbarRef:ax,savedSelectionRef:ay,highlightedLines:az,isMounted:aA,cmdHeld:aB,flashLine:aC,isSearchVisible:aD,searchQuery:aE,caseSensitive:aF,wholeWord:aG,currentMatchIndex:aH,viewingComment:aI,addCommentInput:aJ,sendToAIInput:aK,aiBridge:aL,commentsEnabled:aM,updateComment:aN,deleteComment:aO,lines:aP,matches:aQ,rowData:aR,virtualizer:aS,commentsByEndLine:aT,linesWithComments:aU,setIsSearchVisible:aV,setSearchQuery:aW,setCaseSensitive:aX,setWholeWord:aY,setViewingComment:aZ,setAddCommentInput:a$,setSendToAIInput:a_,goToNextMatch:a0,goToPrevMatch:a1,handleSearchKeyDown:a2,handleCommentBubbleClick:a3,handleToolbarAddComment:a4,handleToolbarSendToAI:a5,handleToolbarSearch:a6,handleCommentSubmit:a7,handleSendToAISubmit:a8,getHighlightedLineHtml:a9,suppressMatchScrollRef:ba,inlineBlameLineRef:bb,inlineBlameVersion:bc}=(0,r.d)({content:a,filePath:b,showSearch:d,cwd:v,enableComments:!N&&z,scrollToLine:N?null:B,scrollToLineAlign:N?"center":C,onScrollToLineComplete:N?void 0:D,visibleLineRef:N?void 0:F,onContentSearch:$}),bd=(0,k.iN)(),be=(0,f.useRef)(null),bf=(0,f.useRef)(null),bg=(0,f.useRef)({line:0,col:0}),bh=(0,f.useRef)({line:0,col:0}),bi=(0,u.A)({lines:aP,enabled:S&&!N,onContentChange:a=>{bg.current={line:bh.current.line,col:bh.current.col},T?.(a)},onEnterInsert:(a,b,c)=>{let d=b;if("a"===c)d=b+1;else if("A"===c)d=(aP[a]??"").length;else if("I"===c){let b=(aP[a]??"").search(/\S/);d=b>=0?b:0}else("o"===c||"O"===c)&&(d=0);bg.current={line:a,col:d},U?.(a)},onSave:V,getVisibleLineCount:()=>{let a=as.current;return a?Math.floor(a.clientHeight/20):20},scrollToLine:(a,b)=>{let c=aR.findIndex(b=>"code"===b.type&&b.lineIndex===a);c>=0&&aS.scrollToIndex(c,{align:b||"auto"})},onSearchExecute:a=>{aW(a),aV(!1)},onSearchNext:a0,onSearchPrev:a1,onSearchClear:()=>{aW("")}});(0,f.useEffect)(()=>{W&&(W.current={cursorLine:bi.state.cursorLine,cursorCol:bi.state.cursorCol}),bh.current={line:bi.state.cursorLine,col:bi.state.cursorCol}},[W,bi.state.cursorLine,bi.state.cursorCol]);let bj=(0,f.useRef)(null);(0,f.useEffect)(()=>{S&&!N&&null!=X&&b&&bj.current!==b&&(bj.current=b,bi.setCursorLine(X-1),null!=Y&&bi.setCursorCol(Y-1),Z?.())},[S,N,X,Y,b]),(0,f.useEffect)(()=>{if(!S||N)return;let a=at.current;if(!a)return;let b=a=>{let b=a.target;"TEXTAREA"===b.tagName||"INPUT"===b.tagName||b.isContentEditable||bi.handleKeyDown(a)&&(a.preventDefault(),a.stopPropagation())};return a.addEventListener("keydown",b,!0),()=>a.removeEventListener("keydown",b,!0)},[S,N,bi.handleKeyDown]),(0,f.useEffect)(()=>{if(!S||N)return;let a=at.current;a&&"normal"===bi.state.mode&&requestAnimationFrame(()=>{let b=document.activeElement;b&&("TEXTAREA"===b.tagName||"INPUT"===b.tagName||b.isContentEditable)||a.focus()})},[S,N,bi.state.mode,a]);let bk=(0,f.useCallback)(a=>{if(!S||N)return;let b=a.target.closest("[data-line]");if(b){let c=parseInt(b.getAttribute("data-line"),10);if(!isNaN(c)){bi.setCursorLine(c-1);let d=b.querySelector("[data-code-content]");if(d){let b=document.caretRangeFromPoint(a.clientX,a.clientY);if(b&&d.contains(b.startContainer)){let a,e=document.createTreeWalker(d,NodeFilter.SHOW_TEXT),f=0;for(;a=e.nextNode();){if(a===b.startContainer){f+=b.startOffset;break}f+=a.textContent?.length||0}let g=aP[c-1]??"";bi.setCursorCol(Math.max(0,Math.min(f,Math.max(0,g.length-1))))}}}}let c=a.target;if("TEXTAREA"===c.tagName||"INPUT"===c.tagName||c.isContentEditable)return;let d=at.current;d&&d.focus()},[S,N,bi.setCursorLine,bi.setCursorCol,aP]),bl=(0,f.useCallback)(a=>{S&&!N&&requestAnimationFrame(()=>{let a=window.getSelection(),b=a?.toString().trim();b&&/^\S+$/.test(b)&&(ba.current=!0,aW(b))})},[S,N,aW,ba]);(0,f.useEffect)(()=>{"command"===bi.state.mode?setTimeout(()=>be.current?.focus(),0):"search"===bi.state.mode&&setTimeout(()=>bf.current?.focus(),0)},[bi.state.mode]),(0,f.useEffect)(()=>{let a=as.current;if(!a)return;let b=()=>{(J??I)?.()};return a.addEventListener("mousedown",b),()=>a.removeEventListener("mousedown",b)},[J,I]),(0,f.useEffect)(()=>{aJ||aK?(aw.current=!0,I?.()):av.current||(aw.current=!1)},[aJ,aK,I]),(0,f.useLayoutEffect)(()=>{let a=ay.current;if(!a)return;let b=window.getSelection();if(b&&!b.isCollapsed)return;let c=as.current;if(!c)return;let d=c.querySelector(`[data-line="${a.startLine}"]`),e=c.querySelector(`[data-line="${a.endLine}"]`);if(!d||!e)return;let f=(0,r.o)(d,a.startOffset),g=(0,r.o)(e,a.endOffset);if(f&&g)try{let a=document.createRange();a.setStart(f.node,f.offset),a.setEnd(g.node,g.offset),b?.removeAllRanges(),b?.addRange(a)}catch{}});let bm=(0,f.useCallback)((a,b,c)=>{aw.current||H?.(a,b,c)},[H]),bn=(0,f.useCallback)((a,b)=>{aw.current||G?.(a,b)},[G]),bo=Math.max(4,String(N?ah:aP.length).length),bp=(0,f.useMemo)(()=>{let a=0;for(let b of aP){let c=0;for(let a=0;a<b.length;a++)" "===b[a]?c+=2-c%2:c+=1;c>a&&(a=c)}return a},[aP]);(0,f.useEffect)(()=>{if(N){ab.current=a;let b=a.split("\n").length;aj.current=b,ai(b),ac.current=!1,ae(!1),al({show:!1}),ao.current=O}},[N,a,O]),(0,f.useEffect)(()=>{if(!N)return;let b=am.current;if(!b)return;let c=a.split("\n"),d=c.map((a,b)=>az[b]||(0,n.ZD)(a||" "));b.innerHTML=y(d),requestAnimationFrame(()=>{let a,d;S?(a=Math.max(0,Math.min(bg.current.line,c.length-1)),d=bg.current.col):(a=Math.max(0,Math.min((F?.current??1)-1,c.length-1)),d=0),b.focus(),x(b,{line:a,offset:d});let e=F?.current??1;an.current&&(an.current.scrollTop=(e-1)*20)})},[N]),(0,f.useEffect)(()=>{N&&R?.({isDirty:ad,isSaving:af})},[N,ad,af,R]);let bq=(0,f.useCallback)(()=>{let a=am.current;if(!a)return ab.current;let b=[];for(let c of a.childNodes){let a=c.textContent||"";b.push(" "===a?"":a)}return b.join("\n")},[]),br=(0,f.useCallback)(()=>{ap.current&&clearTimeout(ap.current),ap.current=setTimeout(async()=>{let a=am.current;if(a&&!ar.current){ab.current=bq();try{let c=await (0,n.kS)(),d=(0,n.sQ)(b),e=document.documentElement.classList.contains("dark"),f=ab.current.split("\n"),g=c.codeToTokens(f.join("\n"),{lang:d,theme:e?"github-dark":"github-light"}).tokens.map(a=>(0,n.b8)(a)),h=w(a);aq.current=!0,a.innerHTML=y(g),aq.current=!1,h&&x(a,h)}catch{}}},300)},[b,bq]);(0,f.useEffect)(()=>{if(N)return()=>{ap.current&&clearTimeout(ap.current)}},[N]);let bs=(0,f.useCallback)(()=>{let a=am.current;if(!a)return;ac.current||(ac.current=!0,ae(!0));let b=a.children.length;b!==aj.current&&(aj.current=b,ai(b))},[]),bt=(0,f.useCallback)(()=>{aq.current||ar.current||(bs(),br())},[bs,br]),bu=(0,f.useCallback)(a=>{if(!a.nativeEvent.isComposing&&("Tab"===a.key&&(a.preventDefault(),document.execCommand("insertText",!1," ")),"Enter"===a.key)){a.preventDefault();let b=am.current;if(!b)return;let c=window.getSelection();if(!c?.rangeCount)return;let d=c.getRangeAt(0);d.deleteContents();let e=d.startContainer;for(;e&&e.parentElement!==b;)e=e.parentElement;if(!e||!(e instanceof HTMLElement))return;let f=w(b),g=Array.from(b.children).indexOf(e),h=e.textContent||"",i=f?.offset??h.length,j=h.substring(0,i),k=h.substring(i);e.innerHTML=(0,n.ZD)(j||" ");let l=document.createElement("div");l.setAttribute("style",A),l.innerHTML=(0,n.ZD)(k||" "),e.after(l),x(b,{line:g+1,offset:0}),bs(),br()}},[bs,br]),bv=(0,f.useCallback)(a=>{a.preventDefault();let b=a.clipboardData.getData("text/plain");document.execCommand("insertText",!1,b)},[]),bw=(0,f.useCallback)(async(a=!1)=>{if(!v)return;ab.current=bq(),ag(!0);let c=await i.t4.runPromiseExit((0,j.OJ)({cwd:v,path:b,content:ab.current,expectedMtime:a?void 0:ao.current}));if("Failure"===c._tag){console.error("Error saving file:",c.cause),(0,t.oR)(aa("toast.saveFailed"),"error"),ag(!1);return}let d=c.value,e=d.data;if(409===d.status&&e?.conflict){let a=await i.t4.runPromiseExit((0,j.K9)(v,b));"Success"===a._tag&&a.value.ok&&"string"==typeof a.value.data?.content?al({show:!0,diskContent:a.value.data.content}):al({show:!0}),ag(!1);return}if(!d.ok){console.error("Error saving file: status",d.status),(0,t.oR)(aa("toast.saveFailed"),"error"),ag(!1);return}let f=e?.mtime;f&&(ao.current=f),ac.current=!1,ae(!1),al({show:!1}),(0,t.oR)(aa("toast.savedSuccess"),"success"),Q?.(),ag(!1)},[v,b,bq,Q,aa]),bx=(0,f.useCallback)(async()=>{ad&&!af&&await bw(!1)},[ad,af,bw]),by=(0,f.useCallback)(async()=>{al({show:!1}),await bw(!0)},[bw]),bz=(0,f.useCallback)(()=>{if(void 0!==ak.diskContent){ab.current=ak.diskContent;let b=ak.diskContent.split("\n").length;aj.current=b,ai(b);let c=ak.diskContent!==a;ac.current=c,ae(c);let d=am.current;if(d){let a=ak.diskContent.split("\n");d.innerHTML=y(a.map(a=>(0,n.ZD)(a||" "))),br()}}al({show:!1}),Q?.()},[ak.diskContent,a,Q,br]),bA=(0,f.useCallback)(()=>{let a=an.current;return a?Math.floor(a.scrollTop/20)+1:F?.current??1},[F]),bB=(0,f.useCallback)(async()=>{(!ad||await (0,t.lJ)(aa("codeViewer.unsavedConfirm"),{danger:!0,confirmText:aa("codeViewer.discardChanges"),cancelText:aa("codeViewer.continueEditing")}))&&P?.(bA())},[ad,P,bA]);(0,f.useEffect)(()=>{if(!N)return;let a=a=>{(a.metaKey||a.ctrlKey)&&"s"===a.key&&(a.preventDefault(),bx())};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[N,bx]);let bC=(0,f.useCallback)(()=>{let a=bq();T?.(a);let b=am.current,c=b?w(b):null,d=bA();if(bi.enterNormal(),c){bi.setCursorLine(c.line);let b=a.split("\n")[c.line]??"";bi.setCursorCol(Math.max(0,Math.min(c.offset,Math.max(0,b.length-1))))}else bi.setCursorLine(Math.max(0,d-1));P?.(d)},[bq,T,bA,P,bi]);(0,f.useEffect)(()=>{if(!N)return;let a=a=>{let b="Escape"===a.key,c=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;(b||S&&c)&&(a.preventDefault(),a.stopPropagation(),S?ac.current?(0,t.lJ)(aa("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:aa("codeViewer.discardChanges"),cancelText:aa("codeViewer.continueEditing")}).then(a=>{a&&bC()}):bC():bB())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[N,S,bB,bC]);let bD=(0,f.useCallback)(()=>{ac.current||(ac.current=!0,ae(!0))},[]);(0,f.useImperativeHandle)(_,()=>({save:bx,close:bB,markDirty:bD,get isDirty(){return ac.current},get isSaving(){return af}}),[bx,bB,bD,af]);let bE=!!(K&&K.length>0),bF=(0,f.useMemo)(()=>{if(!K)return new Map;let a=[...new Set(K.map(a=>a.author))],b=new Map;return a.forEach((a,c)=>{b.set(a,q.j[c%q.j.length])}),b},[K]),[bG,bH]=(0,f.useState)(null),[bI,bJ]=(0,f.useState)(null);(0,f.useEffect)(()=>{bH(null),bJ(null)},[K]);let bK=(0,f.useCallback)((a,b)=>{bH(a.author);let c=b.currentTarget.getBoundingClientRect();bJ({line:a,x:c.right+8,y:c.top})},[]),bL=(0,f.useCallback)(()=>{bH(null),bJ(null)},[]),bM=(0,f.useCallback)(a=>{if(!M)return;let b={hash:a.hashFull,shortHash:a.hash,author:a.author,authorEmail:a.authorEmail,date:new Date(1e3*a.time).toISOString(),subject:a.message.split("\n")[0]||"",body:a.message.split("\n").slice(1).join("\n").trim(),time:a.time};M(b),bJ(null)},[M]),bN=`${bo+2}ch`;return(0,e.jsxs)("div",{ref:at,className:`h-full flex flex-col outline-none ${m}`,tabIndex:0,onClick:bk,onDoubleClick:bl,children:[N&&ak.show&&(0,e.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,e.jsx)("svg",{className:"w-5 h-5 text-amber-500 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("span",{className:"text-sm text-foreground flex-1",children:aa("codeViewer.fileModifiedExternally")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:bz,className:"px-3 py-1 text-sm rounded border border-border hover:bg-accent transition-colors",children:aa("codeViewer.useDiskVersion")}),(0,e.jsx)("button",{onClick:by,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:aa("codeViewer.forceOverwrite")})]})]}),!N&&d&&aD&&(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border",children:[(0,e.jsx)("input",{ref:au,type:"text",value:aE,onChange:a=>aW(a.target.value),onKeyDown:a2,placeholder:aa("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,e.jsx)("button",{onClick:()=>aX(!aF),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${aF?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:aa("codeViewer.caseSensitive"),children:"Aa"}),(0,e.jsx)("button",{onClick:()=>aY(!aG),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${aG?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:aa("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:aQ.length>0?`${aH+1}/${aQ.length}`:aa("common.noMatch")}),(0,e.jsx)("button",{onClick:a1,disabled:0===aQ.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:aa("common.previous"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,e.jsx)("button",{onClick:a0,disabled:0===aQ.length,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:aa("common.next"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,e.jsx)("button",{onClick:()=>{aV(!1),aW("")},className:"p-1 rounded hover:bg-accent",title:aa("common.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),N?(0,e.jsx)("div",{ref:an,className:"flex-1 overflow-auto bg-secondary",children:(0,e.jsxs)("div",{className:"flex",style:{minHeight:"100%"},children:[(0,e.jsx)("div",{className:"flex-shrink-0 font-mono text-sm select-none sticky left-0 z-[2] bg-secondary",style:{width:bN},children:Array.from({length:ah},(a,b)=>(0,e.jsx)("div",{className:"text-right text-muted-foreground/50 pr-3",style:{height:20,lineHeight:"20px"},children:b+1},b))}),(0,e.jsx)("div",{ref:am,contentEditable:!0,suppressContentEditableWarning:!0,onInput:bt,onKeyDown:bu,onPaste:bv,onCompositionStart:()=>{ar.current=!0},onCompositionEnd:()=>{ar.current=!1,bt()},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",className:"flex-1 font-mono text-sm outline-none",style:{caretColor:"var(--foreground)",tabSize:2}})]})}):(0,e.jsx)("div",{ref:as,className:`flex-1 overflow-auto font-mono text-sm bg-secondary${aB?" cmd-held-container":""}`,children:(0,e.jsx)("div",{style:{height:`${aS.getTotalSize()}px`,minWidth:"100%",width:bE?`calc(${bo+bp+10}ch + 13rem)`:`${bo+bp+10}ch`,position:"relative"},children:aS.getVirtualItems().map(a=>{let b=aR[a.index];if("code"!==b.type)return null;let d=b.lineIndex,f=d+1,g=az[d]||(0,n.ZD)(aP[d]||""),h=a9(d,g,E),i=aU.has(f),j=aT.get(f),k=j?.[0],l=!!(aJ&&f>=aJ.range.start&&f<=aJ.range.end),m=bc>=0?bb.current:null,o=!N&&L&&m===f?L[d]??null:null,p=bE?K[d]:void 0,r=bE&&d>0?K[d-1]:void 0,s=!!p&&(!r||r.hash!==p.hash),t=p?bF.get(p.author):void 0;return(0,e.jsx)(q.S,{virtualKey:a.key,lineNum:f,highlightedHtml:h,hasComments:i,firstComment:k,lineCommentsCount:j?.length,isInRange:l,showLineNumbers:c,lineNumChars:bo,commentsEnabled:aM,virtualItemSize:a.size,virtualItemStart:a.start,onCommentBubbleClick:a3,onCmdClick:bn,onTokenHover:bm,onTokenHoverLeave:I,flashLine:aC,blameLine:p,showBlameInfo:s,blameAuthorColor:t,isBlameHovered:!!(p&&bG===p.author),onBlameClick:bM,onBlameMouseEnter:bK,onBlameMouseLeave:bL,inlineBlameData:o,onInlineBlameClick:bM,isCursorLine:S&&!N&&bi.state.cursorLine===d,cursorCol:S&&!N&&bi.state.cursorLine===d?bi.state.cursorCol:void 0},a.key)})})}),S&&(0,e.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"===bi.state.mode&&(0,e.jsx)("span",{className:"text-green-11 font-medium",children:"NORMAL"}),"insert"===bi.state.mode&&(0,e.jsx)("span",{className:"text-blue-11 font-medium",children:"INSERT"}),"command"===bi.state.mode&&(0,e.jsxs)("div",{className:"flex items-center flex-1",children:[(0,e.jsx)("span",{className:"text-foreground",children:":"}),(0,e.jsx)("input",{ref:be,value:bi.state.commandInput,onChange:a=>bi.setCommandInput(a.target.value),onKeyDown:a=>{if(a.nativeEvent.isComposing)return;let b=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;("Enter"===a.key||"Escape"===a.key||b)&&(a.preventDefault(),a.stopPropagation(),bi.handleKeyDown(a.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),"search"===bi.state.mode&&(0,e.jsxs)("div",{className:"flex items-center flex-1",children:[(0,e.jsx)("span",{className:"text-foreground",children:"/"}),(0,e.jsx)("input",{ref:bf,value:bi.state.searchInput,onChange:a=>bi.setSearchInput(a.target.value),onKeyDown:a=>{if(a.nativeEvent.isComposing)return;let b=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;("Enter"===a.key||"Escape"===a.key||b)&&(a.preventDefault(),a.stopPropagation(),bi.handleKeyDown(a.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),bi.state.keyBuffer&&"normal"===bi.state.mode&&(0,e.jsx)("span",{className:"ml-2 text-muted-foreground",children:bi.state.keyBuffer}),bi.state.isDirty&&("normal"===bi.state.mode||"command"===bi.state.mode)&&(0,e.jsx)("span",{className:"ml-2 text-amber-11",children:"[+]"}),(0,e.jsxs)("span",{className:"ml-auto text-muted-foreground",children:[bi.state.cursorLine+1,":",bi.state.cursorCol+1]})]}),aA&&bd&&(0,h.createPortal)((0,e.jsxs)(e.Fragment,{children:[!N&&(0,e.jsx)(o.f,{floatingToolbarRef:av,bumpRef:ax,container:bd,onAddComment:a4,onSendToAI:a5,onSearch:$?a6:void 0,isChatLoading:aL?.isLoading}),!N&&aJ&&(0,e.jsx)(l.t,{x:aJ.x,y:aJ.y,range:aJ.range,lineSnapshot:aJ.lineSnapshot,container:bd,onSubmit:a7,onClose:()=>a$(null)}),!N&&aK&&(0,e.jsx)(l.G,{x:aK.x,y:aK.y,range:aK.range,filePath:b,lineSnapshot:aK.lineSnapshot,container:bd,onSubmit:a8,onClose:()=>a_(null),isChatLoading:aL?.isLoading}),!N&&aI&&(0,e.jsx)(p.t,{x:aI.x,y:aI.y,comment:aI.comment,container:bd,onClose:()=>aZ(null),onUpdateComment:aN,onDeleteComment:aO}),bI&&(0,e.jsxs)("div",{className:"fixed z-50 bg-card border border-border rounded-lg shadow-lg p-3 max-w-lg",style:{left:Math.min(bI.x,window.innerWidth-450),top:Math.max(8,Math.min(bI.y,window.innerHeight-200))},children:[(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)("div",{className:"px-2 py-0.5 rounded text-xs font-mono font-medium text-white flex-shrink-0",style:{backgroundColor:bF.get(bI.line.author)?.border||"#666"},children:bI.line.hash}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground",children:bI.line.author}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:bI.line.authorEmail})]})]}),(0,e.jsx)("div",{className:"mt-2 text-sm text-foreground whitespace-pre-wrap max-h-48 overflow-y-auto",children:bI.line.message}),(0,e.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground border-t border-border pt-2",children:[(0,s.fw)(bI.line.time)," \xb7 ",new Date(1e3*bI.line.time).toLocaleString(),(0,e.jsx)("span",{className:"ml-2 text-brand",children:aa("codeViewer.clickToViewDetails")})]})]})]}),bd)]})});function z({content:a,filePath:b,className:c=""}){let d=(0,f.useMemo)(()=>a.split("\n"),[a]),g=(0,m.C)(d,b),h=Math.max(4,String(d.length).length);return(0,e.jsx)("pre",{className:`overflow-auto text-sm font-mono bg-secondary p-2 ${c}`,children:d.map((a,b)=>(0,e.jsxs)("div",{className:"flex",children:[(0,e.jsx)("span",{className:"text-slate-9 select-none pr-4 text-right",style:{minWidth:`${h+2}ch`},children:b+1}),(0,e.jsx)("span",{className:"flex-1",dangerouslySetInnerHTML:{__html:g[b]||(0,n.ZD)(a||" ")}})]},b))})}d()}catch(a){d(a)}})},55579:(a,b,c)=>{"use strict";c.d(b,{w:()=>f});var d=c(48249),e=c(44384);function f({showTop:a,showBottom:b,onScrollTop:c,onScrollBottom:g}){let{t:h}=(0,e.Bd)();return(0,d.jsxs)(d.Fragment,{children:[a&&(0,d.jsx)("button",{onClick:c,className:"absolute top-2 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-md rounded-full transition-all hover:shadow-lg active:scale-95 z-10",title:h("chat.jumpToStart"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),b&&(0,d.jsx)("button",{onClick:g,className:"absolute bottom-20 left-1/2 -translate-x-1/2 p-2 bg-card text-muted-foreground hover:text-foreground shadow-md rounded-full transition-all hover:shadow-lg active:scale-95 z-10",title:h("chat.jumpToLatest"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})}},55632:(a,b,c)=>{"use strict";c.d(b,{EmptyState:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call EmptyState() from the server but EmptyState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/EmptyState.tsx","EmptyState")},56696:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>r});var e=c(48249),f=c(67484),g=c(44256),h=c(36295),i=c(7833),j=c(28602),k=c(44384),l=c(74493),m=a([h]);h=(m.then?(await m)():m)[0];let w=[{value:"=",label:"="},{value:"!=",label:"≠"},{value:">",label:">"},{value:"<",label:"<"},{value:">=",label:"≥"},{value:"<=",label:"≤"},{value:"LIKE",label:"LIKE"},{value:"NOT LIKE",label:"NOT LIKE"},{value:"IN",label:"IN"},{value:"IS NULL",label:"IS NULL"},{value:"IS NOT NULL",label:"IS NOT NULL"}];function n(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}function o(a){return`"${a.replace(/"/g,'""')}"`}function p(a){return null==a?"":"object"==typeof a?JSON.stringify(a):String(a)}function q({text:a}){let[b,c]=(0,f.useState)(!1),[d,h]=(0,f.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),i=(0,f.useRef)(null),j=(0,f.useRef)(null),k=(0,f.useRef)(!1),l=(0,g.F2)(),m=(0,f.useCallback)(()=>{j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{k.current||c(!1)},80)},[]),n=(0,f.useCallback)(()=>{j.current&&clearTimeout(j.current),k.current=!1,j.current=setTimeout(()=>{let a=i.current;if(!a||a.scrollWidth<=a.clientWidth)return;let b=a.getBoundingClientRect(),d=l?.getBoundingClientRect(),e=d?.left??0,f=d?.top??0,g=d?.width??window.innerWidth,j=d?.height??window.innerHeight,k=b.left-e,m=b.top-f,n=b.bottom-f,o=Math.min(600,g-k-8),p=o<200?Math.max(8,g-600-8):k,q=o<200?Math.min(600,g-16):o,r=m-8,s=j-n-8,t=r>s&&r>80,u=t?r-4:s-4;h({x:p,y:t?m-4:n+4,maxW:q,maxH:Math.max(60,u),above:t}),c(!0)},350)},[l]),o=(0,f.useCallback)(()=>{m()},[m]),p=(0,f.useCallback)(()=>{k.current=!0,j.current&&clearTimeout(j.current)},[]),r=(0,f.useCallback)(()=>{k.current=!1,m()},[m]);return(0,e.jsxs)("span",{ref:i,className:"block truncate",onMouseEnter:n,onMouseLeave:o,children:[a,b&&(0,e.jsx)(g.ZL,{children:(0,e.jsx)("div",{className:"fixed z-[9999] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lg whitespace-pre-wrap break-all select-text cursor-text",style:{left:d.x,top:d.y,maxWidth:d.maxW,maxHeight:d.maxH,transform:d.above?"translateY(-100%)":void 0},onMouseEnter:p,onMouseLeave:r,children:function(a){try{let b=JSON.parse(a);if("object"==typeof b&&null!==b)return JSON.stringify(b,null,2)}catch{}return a}(a)})})]})}function r({id:a,connectionString:b,displayName:c,selected:d,maximized:g,expandedHeight:m,bubbleContentHeight:t,onSelect:w,onClose:x,onToggleMaximize:y,timestamp:z,onTitleMouseDown:A}){let{t:B}=(0,k.Bd)(),{showToast:C}=(0,i.dj)(),[D,E]=(0,f.useState)("connecting"),[F,G]=(0,f.useState)(""),[H,I]=(0,f.useState)([]),[J,K]=(0,f.useState)("public"),[L,M]=(0,f.useState)([]),[N,O]=(0,f.useState)(null),[P,Q]=(0,f.useState)("table"),[R,S]=(0,f.useState)("data"),[T,U]=(0,f.useState)([]),[V,W]=(0,f.useState)([]),[X,Y]=(0,f.useState)([]),[Z,$]=(0,f.useState)([]),[_,aa]=(0,f.useState)(null),[ab,ac]=(0,f.useState)(0),[ad,ae]=(0,f.useState)(!1),[af,ag]=(0,f.useState)(0),[ah,ai]=(0,f.useState)(new Set),[aj,ak]=(0,f.useState)(!1),[al,am]=(0,f.useState)(null),[an,ao]=(0,f.useState)({}),[ap,aq]=(0,f.useState)(!1),[ar,as]=(0,f.useState)({}),[at,au]=(0,f.useState)({}),[av,aw]=(0,f.useState)(null),[ax,ay]=(0,f.useState)(""),[az,aA]=(0,f.useState)(null),[aB,aC]=(0,f.useState)(""),[aD,aE]=(0,f.useState)(!1),aF=(0,f.useRef)(null),aG=(0,f.useCallback)(async()=>{E("connecting"),G("");try{let c=await (0,l.GW)("/api/db/connect",{id:a,connectionString:b});I(c.schemas||[]),c.schemas?.length>0&&!c.schemas.includes("public")&&K(c.schemas[0]),E("connected")}catch(a){G(a instanceof Error?a.message:String(a)),E("error")}},[a,b]),aH=(0,f.useCallback)(async()=>{if("connected"===D)try{let c=await (0,l.Ey)("/api/db/schemas",{id:a,connectionString:b,schema:J});M(c.tables||[])}catch{}},[a,b,J,D]),aI=(0,f.useCallback)(async(c,d,e,f)=>{ae(!0);let g=e??at,h=void 0!==f?f:av;try{let e=`${o(J)}.${o(c)}`,{where:f,params:i}=function(a){let b=[],c=[],d=1;for(let[e,f]of Object.entries(a)){if(!f.enabled)continue;let a=o(e);if("IS NULL"===f.op)b.push(`${a} IS NULL`);else if("IS NOT NULL"===f.op)b.push(`${a} IS NOT NULL`);else if("IN"===f.op){let e=f.value.split(",").map(a=>a.trim()).filter(Boolean);if(0===e.length)continue;let g=e.map(a=>(c.push(a),`$${d++}`));b.push(`${a}::text IN (${g.join(", ")})`)}else"LIKE"===f.op||f.op,b.push(`${a}::text ${f.op} $${d++}`),c.push(f.value)}return{where:b.length>0?` WHERE ${b.join(" AND ")}`:"",params:c}}(g),j=h?` ORDER BY ${o(h.column)} ${h.dir}`:"",k=`SELECT * FROM ${e}${f}${j} LIMIT 50 OFFSET ${50*d}`,m=await (0,l.GW)("/api/db/query",{id:a,connectionString:b,sql:k,params:i});aa(m);let n=`SELECT count(*)::int AS cnt FROM ${e}${f}`,p=await (0,l.GW)("/api/db/query",{id:a,connectionString:b,sql:n,params:i});ag(p.rows?.[0]?.cnt??0)}catch{}ae(!1)},[a,b,J,at,av]),aJ=(0,f.useCallback)(async c=>{O(c),ac(0),am(null),aq(!1),ai(new Set),ak(!1),au({}),aw(null);try{let d=await (0,l.Ey)("/api/db/columns",{id:a,connectionString:b,schema:J,table:c});U(d.columns||[]),W(d.primaryKeys||[]),Y(d.foreignKeys||[]),$(d.indexes||[])}catch{}aI(c,0,{},null)},[a,b,J,aI]),aK=(0,f.useCallback)(async()=>{if(ax.trim()){aE(!0),aC(""),aA(null);try{let c=await (0,l.GW)("/api/db/query",{id:a,connectionString:b,sql:ax});aA(c)}catch(a){aC(a instanceof Error?a.message:String(a))}aE(!1)}},[a,b,ax]),aL=(0,f.useCallback)(async()=>{if(null===al||!_||!N)return;let c=_.rows[al],d=[],e=[],f=1;for(let a of T)void 0!==an[a.name]&&an[a.name]!==p(c[a.name]??"")&&(d.push(`${o(a.name)} = $${f}`),e.push(""===an[a.name]&&a.nullable?null:an[a.name]),f++);if(0===d.length)return void am(null);let g=V.length>0?V:T.map(a=>a.name),h=[];for(let a of g)null===c[a]||void 0===c[a]?h.push(`${o(a)} IS NULL`):(h.push(`${o(a)} = $${f}`),e.push(c[a]),f++);let i=`UPDATE ${o(J)}.${o(N)} SET ${d.join(", ")} WHERE ${h.join(" AND ")}`;try{await (0,l.GW)("/api/db/query",{id:a,connectionString:b,sql:i,params:e}),am(null),aI(N,ab,at,av)}catch(a){alert(`Update failed: ${a instanceof Error?a.message:String(a)}`)}},[al,_,N,T,V,an,a,b,J,aI,ab,at,av]),aM=(0,f.useCallback)(async()=>{if(!N)return;let c=[],d=[],e=[],f=1;for(let a of T)void 0!==ar[a.name]&&""!==ar[a.name]&&(c.push(o(a.name)),d.push(ar[a.name]),e.push(`$${f}`),f++);if(0===c.length)return;let g=`INSERT INTO ${o(J)}.${o(N)} (${c.join(", ")}) VALUES (${e.join(", ")})`;try{await (0,l.GW)("/api/db/query",{id:a,connectionString:b,sql:g,params:d}),aq(!1),as({}),aI(N,ab,at,av)}catch(a){alert(`Insert failed: ${a instanceof Error?a.message:String(a)}`)}},[N,T,ar,a,b,J,aI,ab,at,av]),aN=(0,f.useCallback)(async()=>{if(0===ah.size||!_||!N)return;let c=V.length>0?V:T.map(a=>a.name),d=0;for(let e of Array.from(ah).sort((a,b)=>b-a)){let f=_.rows[e];if(!f)continue;let g=[],h=[],i=1;for(let a of c)null===f[a]||void 0===f[a]?g.push(`${o(a)} IS NULL`):(g.push(`${o(a)} = $${i}`),h.push(f[a]),i++);let j=`DELETE FROM ${o(J)}.${o(N)} WHERE ctid = (SELECT ctid FROM ${o(J)}.${o(N)} WHERE ${g.join(" AND ")} LIMIT 1)`;try{await (0,l.GW)("/api/db/query",{id:a,connectionString:b,sql:j,params:h})}catch{d++}}ai(new Set),ak(!1),aI(N,ab,at,av),d>0&&alert(B("database.deleteRowsFailed",{count:d}))},[ah,_,N,V,T,a,b,J,aI,ab,at,av]),aO=(0,f.useCallback)(async c=>{if(!N)return;if(ah.size>0&&_){let a,b=_.fields.map(a=>a.name),d=Array.from(ah).sort((a,b)=>a-b).map(a=>_.rows[a]).filter(Boolean);if("json"===c)a=JSON.stringify(d,null,2);else{let c=[b.join(",")];for(let a of d)c.push(b.map(b=>{let c=a[b];if(null==c)return"";let d="object"==typeof c?JSON.stringify(c):String(c);return d.includes(",")||d.includes('"')||d.includes("\n")?`"${d.replace(/"/g,'""')}"`:d}).join(","));a=c.join("\n")}navigator.clipboard.writeText(a);return}let d=`SELECT * FROM ${o(J)}.${o(N)}`;try{let e=await (0,l.HS)("/api/db/export",{id:a,connectionString:b,sql:d,format:c}),f=URL.createObjectURL(e),g=document.createElement("a");g.href=f,g.download=`${N}.${c}`,g.click(),URL.revokeObjectURL(f)}catch(a){alert(`Export failed: ${a instanceof Error?a.message:String(a)}`)}},[N,a,b,J,ah,_]),aP=(0,f.useCallback)(a=>{(a.metaKey||a.ctrlKey)&&"Enter"===a.key&&(a.preventDefault(),aK())},[aK]),aQ=g&&m?m-41:t??h.p,aR=Math.max(1,Math.ceil(af/50)),aS=(0,f.useCallback)(a=>{N&&(ac(a),aI(N,a,at,av))},[N,aI,at,av]),aT=(0,f.useCallback)((a,b)=>{let c={...at};b?c[a]=b:delete c[a],au(c),ac(0),ai(new Set),N&&aI(N,0,c,av)},[at,av,N,aI]),aU=(0,f.useCallback)(()=>{au({}),ac(0),ai(new Set),N&&aI(N,0,{},av)},[av,N,aI]),aV=(0,f.useCallback)(a=>{aw(a),ac(0),ai(new Set),N&&aI(N,0,at,a)},[at,N,aI]);return(0,e.jsx)("div",{className:"flex flex-col items-start",children:(0,e.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
31
31
|
relative transition-colors cursor-pointer
|
|
32
32
|
${g?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
33
|
-
${g?"":d?"border-brand":"border-brand/30"}`,onClick:g?void 0:w,children:[(0,e.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:y,onMouseDown:A,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${g?"bg-card":"bg-card/50"}`,style:g?{height:41}:void 0,children:[(0,e.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDC18"}),(0,e.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===D&&(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===D&&(0,e.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:B("database.connectionFailed")}),"connected"===D&&(0,e.jsx)("span",{className:"text-[10px] text-emerald-500 flex-shrink-0",children:B("database.connected")}),(0,e.jsx)("span",{className:"flex-1"}),z&&(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:n(z)}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),y()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:g?B("browser.exitMaximize",{modKey:(0,j.Mu)()}):B("browser.maximize",{modKey:(0,j.Mu)()}),children:g?(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),x()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:B("common.close"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{style:{height:aQ},className:"flex overflow-hidden",children:["connecting"===D&&(0,e.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),B("database.connecting")]}),"error"===D&&(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,e.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:F}),(0,e.jsx)("button",{onClick:aG,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:B("common.retry")})]}),"connected"===D&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[H.length>1?(0,e.jsx)("select",{value:J,onChange:a=>{K(a.target.value),O(null)},className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1",children:H.map(a=>(0,e.jsx)("option",{value:a,children:a},a))}):(0,e.jsx)("span",{className:"flex-1 min-w-0 text-xs text-muted-foreground truncate",children:J}),(0,e.jsx)("button",{onClick:aH,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent active:bg-accent/50 transition-colors",title:B("database.refreshTableList"),children:(0,e.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("path",{d:"M1 1v5h5"}),(0,e.jsx)("path",{d:"M15 15v-5h-5"}),(0,e.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,e.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,e.jsx)("div",{className:"flex items-center border-b border-border",children:["table","view"].map(a=>(0,e.jsx)("button",{onClick:()=>Q(a),className:`flex-1 py-1 text-[10px] font-medium transition-colors ${P===a?"text-brand border-b border-brand":"text-muted-foreground hover:text-foreground"}`,children:{table:B("database.filterTable"),view:B("database.filterView")}[a]},a))}),(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[L.filter(a=>"table"===P?"view"!==a.type:"view"===a.type).map(a=>(0,e.jsxs)("div",{onClick:()=>aJ(a.name),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer truncate transition-colors ${N===a.name?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,e.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground",children:"view"===a.type?"V":"T"}),(0,e.jsx)("span",{className:"truncate min-w-0 flex-1",children:(0,e.jsx)(q,{text:a.name})}),(0,e.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.rowEstimate>0?`~${a.rowEstimate}`:""})]},a.name)),0===L.length&&(0,e.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:B("database.noTables")})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["structure","data","sql"].map(a=>(0,e.jsx)("button",{onClick:()=>S(a),className:`px-3 py-1.5 text-xs transition-colors ${R===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{structure:B("database.tabStructure"),data:B("database.tabData"),sql:"SQL"}[a]},a)),N&&"data"===R&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[Object.values(at).some(a=>a.enabled)&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-[10px] text-brand",children:B("database.filterActive",{count:Object.values(at).filter(a=>a.enabled).length})}),(0,e.jsx)("button",{onClick:aU,className:"px-1 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",title:B("database.clearAllFilters"),children:"✕"}),(0,e.jsx)("span",{className:"text-border",children:"|"})]}),ah.size>0&&!aj&&(0,e.jsx)("button",{onClick:()=>ak(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:B("database.deleteNRows",{count:ah.size})}),aj&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-[10px] text-destructive",children:B("database.confirmDeleteRows")}),(0,e.jsx)("button",{onClick:aN,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:B("common.confirm")}),(0,e.jsx)("button",{onClick:()=>ak(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:B("common.cancel")})]}),(0,e.jsx)("button",{onClick:()=>aO("csv"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:ah.size>0?B("database.copyCsvSelected"):B("database.copyCsvAll"),children:ah.size>0?B("database.copyCSV"):B("database.CSV")}),(0,e.jsx)("button",{onClick:()=>aO("json"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:ah.size>0?B("database.copyJsonSelected"):B("database.copyJsonAll"),children:ah.size>0?B("database.copyJSON"):B("database.JSON")})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:N||"sql"===R?"structure"===R?(0,e.jsx)(s,{columns:T,primaryKeys:V,foreignKeys:X,indexes:Z}):"data"===R?(0,e.jsx)(u,{result:_,loading:ad,columns:T,page:ab,totalPages:aR,totalRows:af,onPageChange:aS,filters:at,sort:av,onFilterChange:aT,onSortChange:aV,selectedRows:ah,onSelectedRowsChange:a=>{ai(a),ak(!1)},editingRowIdx:al,editValues:an,onStartEdit:a=>{if(!_)return;let b=_.rows[a],c={};for(let a of T)c[a.name]=null==b[a.name]?"":p(b[a.name]);ao(c),am(a)},onEditChange:(a,b)=>ao(c=>({...c,[a]:b})),onSaveEdit:aL,onCancelEdit:()=>am(null),isAddingRow:ap,newRowValues:ar,onStartAdd:()=>{aq(!0),as({})},onNewRowChange:(a,b)=>as(c=>({...c,[a]:b})),onSaveNewRow:aM,onCancelAdd:()=>{aq(!1),as({})},onCellCopy:a=>{navigator.clipboard.writeText(a),C(B("common.copied"))}}):(0,e.jsx)(v,{sqlInput:ax,onSqlChange:ay,onExecute:aK,onKeyDown:aP,result:az,error:aB,loading:aD,sqlRef:aF,onCellCopy:a=>{navigator.clipboard.writeText(a),C(B("common.copied"))}}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:B("database.selectTable")})})]})]})]}),!g&&(0,e.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===D?"bg-green-500":"error"===D?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,e.jsx)("span",{children:{connecting:B("common.connecting"),connected:B("common.connected"),error:B("common.connectionFailed")}[D]}),"connected"===D&&N&&(0,e.jsx)("span",{className:"text-muted-foreground/70",children:N}),(0,e.jsx)("span",{className:"flex-1"}),z&&(0,e.jsx)("span",{className:"text-[11px] flex-shrink-0",children:n(z)})]})]})})}function s({columns:a,primaryKeys:b,foreignKeys:c,indexes:d}){let{t:f}=(0,k.Bd)();return 0===a.length?(0,e.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:f("database.selectTableToView")}):(0,e.jsxs)("div",{className:"p-2 space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:f("database.columns")}),(0,e.jsxs)("table",{className:"w-full text-xs",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border",children:[(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("database.colName")}),(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("database.colType")}),(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("database.colNullable")}),(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("database.colDefault")})]})}),(0,e.jsx)("tbody",{children:a.map(a=>(0,e.jsxs)("tr",{className:"border-b border-border/50 hover:bg-accent/50",children:[(0,e.jsxs)("td",{className:"px-1.5 py-1 font-mono",children:[a.isPrimaryKey&&(0,e.jsx)("span",{className:"text-amber-500 mr-1",title:f("database.primaryKey"),children:"\uD83D\uDD11"}),a.name]}),(0,e.jsxs)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono",children:[a.type,a.maxLength?`(${a.maxLength})`:""]}),(0,e.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground",children:a.nullable?"YES":"NO"}),(0,e.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono truncate max-w-[120px]",children:a.default||""})]},a.name))})]})]}),c.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:f("database.foreignKeys")}),(0,e.jsx)("div",{className:"space-y-0.5",children:c.map((a,b)=>(0,e.jsxs)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground",children:[a.column," → ",a.refSchema,".",a.refTable,".",a.refColumn]},b))})]}),d.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:f("database.indexes")}),(0,e.jsx)("div",{className:"space-y-0.5",children:d.map(a=>(0,e.jsx)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground truncate",title:a.definition,children:a.name},a.name))})]})]})}function t({filter:a,onApply:b,onClear:c,onToggle:d,onClose:h,colName:i,anchorRect:j}){let{t:l}=(0,k.Bd)(),[m,n]=(0,f.useState)(a?.op||"="),[o,p]=(0,f.useState)(a?.value||""),q=(0,f.useRef)(null),r=(0,g.F2)(),s="IS NULL"!==m&&"IS NOT NULL"!==m,u=()=>{(!s||o.trim())&&b({op:m,value:o.trim(),enabled:!0})},v=r?.getBoundingClientRect(),x=v?.left??0,y=v?.top??0,z=v?.width??1e3,A=j.left-x;A+220>z-8&&(A=z-220-8),A<8&&(A=8);let B=j.bottom+2-y;return(0,e.jsx)(g.ZL,{children:(0,e.jsxs)("div",{ref:q,className:"fixed z-[9998] w-[220px] bg-popover border border-border rounded-md shadow-lg p-2 space-y-2",style:{left:A,top:B},onClick:a=>a.stopPropagation(),children:[a&&(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:a.enabled,onChange:a=>d(a.target.checked),className:"w-3 h-3 accent-brand"}),l("database.enable")]}),(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono truncate max-w-[120px]",children:i})]}),(0,e.jsx)("select",{value:m,onChange:a=>n(a.target.value),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-ring",children:w.map(a=>(0,e.jsx)("option",{value:a.value,children:a.label},a.value))}),s&&(0,e.jsx)("input",{type:"text",value:o,onChange:a=>p(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),u())},placeholder:l("IN"===m?"database.commaValues":"LIKE"===m?"database.likePattern":"database.valuePlaceholder"),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:u,disabled:s&&!o.trim(),className:"flex-1 px-2 py-1 text-[10px] bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-40 transition-colors",children:l("database.apply")}),a&&(0,e.jsx)("button",{onClick:c,className:"flex-1 px-2 py-1 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground transition-colors",children:l("database.clearFilter")})]})]})})}function u({result:a,loading:b,columns:c,page:d,totalPages:g,totalRows:h,onPageChange:i,filters:j,sort:l,onFilterChange:m,onSortChange:n,selectedRows:o,onSelectedRowsChange:r,editingRowIdx:s,editValues:v,onStartEdit:w,onEditChange:x,onSaveEdit:y,onCancelEdit:z,isAddingRow:A,newRowValues:B,onStartAdd:C,onNewRowChange:D,onSaveNewRow:E,onCancelAdd:F,onCellCopy:G}){let{t:H}=(0,k.Bd)(),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)({left:0,bottom:0});if(!a&&!b)return(0,e.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:H("database.selectTableForData")});let M=a?.fields||[],N=a?.rows||[],O={};for(let a of c)O[a.name]=a.type+(a.maxLength?`(${a.maxLength})`:"");let P=N.length>0&&o.size===N.length,Q=o.size>0&&!P;return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",children:[b&&(0,e.jsx)("div",{className:"absolute inset-0 bg-background/50 flex items-center justify-center z-10",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),(0,e.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,e.jsx)("thead",{className:"sticky top-0 bg-card z-[2]",children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{className:"px-1 py-1 border-b border-border w-8 text-center",children:(0,e.jsx)("input",{type:"checkbox",checked:P,ref:a=>{a&&(a.indeterminate=Q)},onChange:()=>{P?r(new Set):r(new Set(N.map((a,b)=>b)))},className:"w-3 h-3 accent-brand cursor-pointer"})}),M.map(a=>{let b=l?.column===a.name?l.dir:null,c=j[a.name],d=c?.enabled;return(0,e.jsxs)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono relative",children:[(0,e.jsxs)("span",{className:"cursor-pointer select-none hover:text-foreground transition-colors",onClick:()=>{var b;return b=a.name,void(l?.column===b?"ASC"===l.dir?n({column:b,dir:"DESC"}):n(null):n({column:b,dir:"ASC"}))},children:[a.name,O[a.name]&&(0,e.jsx)("span",{className:"ml-1 text-[9px] text-muted-foreground/60 font-normal",children:O[a.name]}),"ASC"===b&&(0,e.jsx)("span",{className:"ml-0.5 text-brand",children:"↑"}),"DESC"===b&&(0,e.jsx)("span",{className:"ml-0.5 text-brand",children:"↓"})]}),(0,e.jsx)("button",{onClick:b=>{if(b.stopPropagation(),I===a.name)return void J(null);let c=b.currentTarget.closest("th").getBoundingClientRect();L({left:c.left,bottom:c.bottom}),J(a.name)},className:`ml-1 inline-flex items-center transition-colors ${d?"text-brand":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:(0,e.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,e.jsx)("path",{d:"M1 2h14l-5.5 6.5V14l-3-2v-3.5z"})})}),I===a.name&&(0,e.jsx)(t,{filter:c||null,onApply:b=>{m(a.name,b),J(null)},onClear:()=>{m(a.name,null),J(null)},onToggle:b=>{c&&m(a.name,{...c,enabled:b})},onClose:()=>J(null),colName:a.name,anchorRect:K})]},a.name)})]})}),(0,e.jsxs)("tbody",{children:[A&&(0,e.jsxs)("tr",{className:"bg-emerald-500/5",children:[(0,e.jsx)("td",{className:"px-1 py-0.5 border-b border-border text-center",children:(0,e.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,e.jsx)("button",{onClick:E,className:"text-[10px] text-emerald-500 hover:text-emerald-400",title:H("common.save"),children:"✓"}),(0,e.jsx)("button",{onClick:F,className:"text-[10px] text-muted-foreground hover:text-foreground",title:H("common.cancel"),children:"✕"})]})}),M.map(a=>(0,e.jsx)("td",{className:"px-0.5 py-0.5 border-b border-border",children:(0,e.jsx)("input",{type:"text",value:B[a.name]??"",onChange:b=>D(a.name,b.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]",placeholder:"NULL"})},a.name))]}),N.map((a,b)=>(0,e.jsxs)("tr",{className:`hover:bg-accent/50 ${o.has(b)?"bg-brand/5":""} ${s===b?"bg-blue-500/5":""}`,children:[(0,e.jsx)("td",{className:"px-1 py-0.5 border-b border-border/50 text-center",children:s===b?(0,e.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,e.jsx)("button",{onClick:y,className:"text-[10px] text-emerald-500 hover:text-emerald-400",title:H("common.save"),children:"✓"}),(0,e.jsx)("button",{onClick:z,className:"text-[10px] text-muted-foreground hover:text-foreground",title:H("common.cancel"),children:"✕"})]}):(0,e.jsx)("input",{type:"checkbox",checked:o.has(b),onChange:()=>{let a;(a=new Set(o)).has(b)?a.delete(b):a.add(b),r(a)},className:"w-3 h-3 accent-brand cursor-pointer"})}),M.map(c=>(0,e.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onDoubleClick:()=>{null===s&&w(b)},onContextMenu:b=>{b.preventDefault(),G(p(a[c.name]))},children:s===b?(0,e.jsx)("input",{type:"text",value:v[c.name]??"",onChange:a=>x(c.name,a.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]"}):null===a[c.name]||void 0===a[c.name]?(0,e.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,e.jsx)(q,{text:p(a[c.name])})},c.name))]},b))]})]}),0===N.length&&!b&&(0,e.jsx)("div",{className:"p-4 text-xs text-muted-foreground text-center",children:H("common.noData")})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-t border-border text-[10px] text-muted-foreground bg-card/30 flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:C,disabled:A,className:"px-1.5 py-0.5 text-[10px] text-emerald-500 hover:text-emerald-400 disabled:opacity-30",children:H("database.addRow")}),(0,e.jsx)("span",{children:H("database.totalRows",{count:h})}),a?.duration!==void 0&&(0,e.jsxs)("span",{children:[a.duration,"ms"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:()=>i(d-1),disabled:0===d,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"◀"}),(0,e.jsxs)("span",{children:[d+1," / ",g]}),(0,e.jsx)("button",{onClick:()=>i(d+1),disabled:d>=g-1,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"▶"})]})]})]})}function v({sqlInput:a,onSqlChange:b,onExecute:c,onKeyDown:d,result:f,error:g,loading:h,sqlRef:i,onCellCopy:l}){let{t:m}=(0,k.Bd)();return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex-shrink-0 p-2 border-b border-border",children:[(0,e.jsx)("textarea",{ref:i,value:a,onChange:a=>b(a.target.value),onKeyDown:d,placeholder:m("database.sqlPlaceholder",{modKey:(0,j.Mu)()}),className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,e.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,e.jsx)("button",{onClick:c,disabled:h||!a.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:m(h?"database.executing":"database.execute")}),f?.duration!==void 0&&(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[f.command&&!f.fields?m("database.rowsAffected",{command:f.command,count:f.rowCount,duration:f.duration}):m("database.queryRows",{count:f.rows?.length??0,duration:f.duration}),f.truncated&&` ${m("database.resultTruncated")}`]})]})]}),g&&(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-destructive bg-destructive/5 border-b border-border break-all",children:g}),f?.fields&&f.rows&&(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,e.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,e.jsx)("tr",{children:f.fields.map(a=>(0,e.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:a.name},a.name))})}),(0,e.jsx)("tbody",{children:f.rows.map((a,b)=>(0,e.jsx)("tr",{className:"hover:bg-accent/50",children:f.fields.map(b=>(0,e.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onContextMenu:c=>{c.preventDefault(),l(p(a[b.name]))},children:null===a[b.name]||void 0===a[b.name]?(0,e.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,e.jsx)(q,{text:p(a[b.name])})},b.name))},b))})]})})]})}d()}catch(a){d(a)}})},57014:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{m:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(35208),j=c(73887),k=c(60591),l=c(18921),m=c(72529),n=c(85984),o=c(65543),p=c(25667),q=c(53036),r=c(9804),s=a([p,i,j]);function t({cwd:a,selected:b,diff:c,showMarkdownPreview:d,setShowMarkdownPreview:s,changedFiles:u,fileGitStatusMap:v,onContentSearch:w,locateInTree:x,jsonPreview:y,setJsonPreview:z,jsonPreviewSearch:A,jsonPreviewPreRef:B}){let{t:C}=(0,g.Bd)(),[D,E]=(0,f.useState)("file"),[F,G]=(0,f.useState)("compact"),H=b.file.path,I=(0,r.u)(H),{state:J}=(0,n.V)(a,H),K=(0,f.useMemo)(()=>{if("ready"===J.state)return J.data.functions.filter(o._).map(a=>({name:a.name,startLine:a.startLine,endLine:a.endLine,params:a.params}))},[J]);return(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[I||"map"!==D?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:H}),(0,e.jsx)(m.m,{content:C("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),navigator.clipboard.writeText(`${a}/${H}`),(0,h.oR)(C("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)(m.m,{content:C("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),x(H)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),(0,e.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${"staged"===b.type?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===b.type?C("fileBrowser.staged"):C("fileBrowser.unstaged")}),(0,e.jsx)("div",{className:"flex-1"}),!I&&"file"===D&&(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["compact","full"].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),G(a)},className:`px-2 py-0.5 text-xs transition-colors ${F===a?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:C("compact"===a?"diffViewer.compact":"diffViewer.full")},a))}),!I&&(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),E(a)},className:`px-2 py-0.5 text-xs transition-colors ${D===a?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:C("file"===a?"common.file":"common.codeMap")},a))})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:I?(0,e.jsx)(q.I,{cwd:a,path:H,className:"p-4 flex items-center justify-center",imgClassName:"max-w-full max-h-[60vh] object-contain",alt:H}):(0,e.jsx)(i.xZ,{oldContent:c.oldContent,newContent:c.newContent,filePath:c.filePath,isNew:c.isNew,isDeleted:c.isDeleted,cwd:a,enableComments:!0,compact:"compact"===F,symbols:K,onPreview:!c.isDeleted&&(0,k.e$)(H)?()=>s(!0):!c.isDeleted&&H.endsWith(".json")?()=>z({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:H.endsWith(".json")?C("common.readable"):C("common.preview"),onContentSearch:w})})]}):(0,e.jsx)(p.r,{cwd:a,filePath:c.filePath,oldContent:c.oldContent,newContent:c.newContent,isNew:c.isNew,isDeleted:c.isDeleted,changedFiles:u,fileGitStatusMap:v,enableComments:!0,onContentSearch:w,headerExtraLeft:({focalFile:b})=>{if(!b)return null;let c=v.get(b);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(m.m,{content:C("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${a}/${b}`),(0,h.oR)(C("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)(m.m,{content:C("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),x(b)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,e.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),c&&(0,e.jsx)("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${"staged"===c?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===c?C("fileBrowser.staged"):C("fileBrowser.unstaged")})]})},headerExtraRight:()=>(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),E(a)},className:`px-2 py-0.5 text-[11px] transition-colors ${D===a?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:C("file"===a?"common.file":"common.codeMap")},a))})}),d&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>s(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(j.M,{content:c.newContent,filePath:c.filePath,cwd:a,onClose:()=>s(!1)})})}),y&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>z(null),children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90%] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:y.filePath}),(0,e.jsx)("button",{onClick:()=>z(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(l._,{search:A}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,e.jsx)("pre",{ref:B,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,k.xb)(y.content)})})]})})]})}[p,i,j]=s.then?(await s)():s,d()}catch(a){d(a)}})},57031:(a,b,c)=>{"use strict";c.d(b,{F:()=>g});var d=c(79606),e=c(23734),f=c(33281);let g=(a,b)=>{f.t4.runFork(d.flatMap(e.d,c=>c.publish(a,b)))}},57632:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{z:()=>r});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(80600),j=c(44218),k=c(19794),l=c(67216),m=c(46674),n=c(35208),o=a([n]);function p(a,b){if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}return a}function q({node:a,selectedUid:b,onSelect:c,depth:d=0}){let[g,h]=(0,f.useState)(!0);if(a.isFile&&a.change){let f=b===a.change.uid;return(0,e.jsxs)("button",{onClick:()=>c(a.change),className:`w-full flex items-center gap-1.5 px-2 py-1 text-xs text-left rounded transition-colors ${f?"bg-brand/15 text-brand":"text-foreground hover:bg-accent"}`,style:{paddingLeft:`${12*d+8}px`},"data-tooltip":a.fullPath,children:[(0,e.jsx)(i.A,{className:"w-3.5 h-3.5 flex-shrink-0 opacity-60"}),(0,e.jsx)("span",{className:"truncate",children:a.name}),(0,e.jsx)("span",{className:`ml-auto text-[10px] flex-shrink-0 ${"write"===a.change.type?"text-green-500":"text-yellow-500"}`,children:"write"===a.change.type?"new":"edit"})]})}return(0,e.jsxs)("div",{children:[(0,e.jsxs)("button",{onClick:()=>h(!g),className:"w-full flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors",style:{paddingLeft:`${12*d+8}px`},children:[g?(0,e.jsx)(j.A,{className:"w-3 h-3"}):(0,e.jsx)(k.A,{className:"w-3 h-3"}),(0,e.jsx)("span",{className:"truncate",children:a.name})]}),g&&a.children.map((a,f)=>(0,e.jsx)(q,{node:a,selectedUid:b,onSelect:c,depth:d+1},a.isFile&&a.change?a.change.uid:`${a.fullPath}-${f}`))]})}function r({toolCalls:a,cwd:b,onClose:c}){let{t:d}=(0,g.Bd)(),i=(0,f.useMemo)(()=>(function(a,b){let c=[],d=0;for(let e of a)if("Edit"===e.name){let a=e.input;a.file_path&&"string"==typeof a.old_string&&"string"==typeof a.new_string&&c.push({filePath:p(a.file_path,b),uid:`change-${d++}`,type:"edit",old_string:a.old_string,new_string:a.new_string})}else if("Write"===e.name){let a=e.input;a.file_path&&"string"==typeof a.content&&c.push({filePath:p(a.file_path,b),uid:`change-${d++}`,type:"write",old_string:"",new_string:a.content})}return c})(a,b),[a,b]),j=(0,f.useMemo)(()=>(function a(b){return b.map(b=>{if(!b.isFile&&1===b.children.length&&!b.children[0].isFile){let c=b.children[0];return{...c,name:b.name+"/"+c.name,children:a(c.children)}}return{...b,children:a(b.children)}})})(function(a){let b=[];for(let c of a){let a=c.filePath.split("/").filter(Boolean),d=b;for(let b=0;b<a.length;b++){let e=a[b],f=b===a.length-1,g=a.slice(0,b+1).join("/");if(f){let a={name:e,fullPath:g,isFile:!0,children:[],change:c};d.push(a)}else{let a=d.find(a=>a.name===e&&!a.isFile);a||(a={name:e,fullPath:g,isFile:!1,children:[]},d.push(a)),d=a.children}}}return b}(i)),[i]),[k,o]=(0,f.useState)(i[0]||null),[s,t]=(0,f.useState)("unified"),u=(0,f.useRef)(null),[v,w]=(0,f.useState)(()=>!0);if(0===i.length)return null;let x=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-0 md:p-4",onClick:c,children:(0,e.jsxs)("div",{className:"bg-card shadow-xl w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:()=>w(a=>!a),"aria-label":d("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors ${v?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,children:(0,e.jsx)(l.A,{className:"w-4 h-4"})}),(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:d("diffViewer.fileChanges",{count:i.length})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[(0,e.jsx)("button",{onClick:()=>t("unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"unified"===s?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Unified"}),(0,e.jsx)("button",{onClick:()=>t("split"),className:`px-2 py-1 text-xs rounded transition-colors ${"split"===s?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Split"})]}),(0,e.jsx)("button",{onClick:c,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)(m.A,{className:"w-5 h-5"})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[v&&(0,e.jsx)("div",{ref:u,className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto py-2",children:j.map((a,b)=>(0,e.jsx)(q,{node:a,selectedUid:k?.uid||"",onSelect:a=>{o(a)}},a.isFile&&a.change?a.change.uid:`${a.fullPath}-${b}`))}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:k?"unified"===s?(0,e.jsx)(n.xU,{oldContent:k.old_string,newContent:k.new_string,filePath:k.filePath}):(0,e.jsx)(n.xZ,{oldContent:k.old_string,newContent:k.new_string,filePath:k.filePath,isNew:"write"===k.type}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:d("diffViewer.selectFileToView")})})]})]})});return(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(h.ZL,{children:x})})}n=(o.then?(await o)():o)[0],d()}catch(a){d(a)}})},58554:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{r:()=>C});var e=c(48249),f=c(67484),g=c(77949),h=c(7833),i=c(40699),j=c(33281),k=c(41224),l=c(57031),m=c(88214),n=c(63041),o=c(62473),p=c(86686),q=c(75513),r=c(38087),s=c(97951),t=c(99843),u=c(62336),v=c(47818),w=c(67115),x=c(95401),y=c(90298),z=c(84844),A=c(44384),B=a([q,s,i,x,y,t,u,z,p]);function C({tabId:a,initialCwd:b,initialSessionId:c,engine:d,ollamaModel:B,onOllamaModelChange:D,deepseekModel:E,onDeepseekModelChange:F,chatMode:G,onChatModeChange:H,planMode:I,onPlanModeChange:J,hideHeader:K,hideSidebar:L,isActive:M=!0,onLoadingChange:N,onSessionIdChange:O,onTitleChange:P,onShowGitStatus:Q,onOpenNote:R,onCreateScheduledTask:S,onOpenSession:T,onContentSearch:U,onOpenSessionBrowser:V,onOpenSettings:W}){let{t:X}=(0,A.Bd)();(0,q.nH)();let[Y,Z]=(0,f.useState)([]),[$,_]=(0,f.useState)(null),[aa,ab]=(0,f.useState)(!1),[ac,ad]=(0,f.useState)(!1),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(null),[ak,al]=(0,f.useState)("sdk"),am=G??ak,an=(0,f.useCallback)(a=>{al(a),H?.(a)},[H]),[ao,ap]=(0,f.useState)(!1),aq=I??ao,ar=(0,f.useCallback)(a=>{ap(a),J?.(a)},[J]),as=!d||"claude"===d||"claude2"===d,at=(0,f.useRef)(null),au=(0,f.useCallback)(a=>{at.current?.write(a)},[]),av=(0,f.useCallback)(a=>{$&&fetch("/api/chat/pty-input",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:$,data:a})}).catch(()=>{})},[$]);(0,f.useRef)(!1);let aw=(0,f.useRef)(null);(0,f.useRef)(null);let ax=(0,f.useCallback)(async a=>{if(!b)return;let c=await j.t4.runPromiseExit((0,k.n_)({cwd:b,sessionId:a}));"Success"===c._tag&&c.value&&"string"==typeof c.value.title?P?.(c.value.title):"Failure"===c._tag&&console.error("Failed to fetch session title:",c.cause)},[b,P]),{isLoading:ay,tokenUsage:az,rateLimitInfo:aA,apiRetryInfo:aB,ptyNotice:aC,handleSend:aD,handleStop:aE}=(0,s.e)(Y,Z,{sessionId:$,cwd:b,engine:d,chatMode:am,planMode:aq,ollamaModel:B,deepseekModel:E,onSessionId:_,onFetchTitle:ax,onPtyOutput:au}),aF=(0,f.useCallback)(async(a,c)=>{let d=a.split("\n")[0];if(as&&"sdk"===am){let b=/^\/plan(?:\s+([\s\S]*))?$/.exec(a.trim());if(b){let a=(b[1]??"").trim();"off"===a.toLowerCase()?(ar(!1),(0,h.oR)(X("chat.planModeOff",{defaultValue:"Plan mode off"}),"info")):""===a?(ar(!0),(0,h.oR)(X("chat.planModeOn",{defaultValue:"Plan mode on"}),"success")):(ar(!0),aD(a,c,{permissionMode:"plan"}));return}}if(d.startsWith("!")&&d.length>1){let e=d.slice(1).trim();if(!e)return void aD(a,c);let f=a.split("\n").slice(1).join("\n").trim(),g=await j.t4.runPromiseExit((0,k.JC)({command:e,cwd:b}));if("Success"===g._tag){let a=g.value,b=[a.stdout,a.stderr].filter(Boolean).join("\n")||"(no output)",d=a.exitCode?` (exit code: ${a.exitCode})`:"",h=X("chat.executedCommand",{command:e,exitInfo:d,output:b});f&&(h+=`
|
|
33
|
+
${g?"":d?"border-brand":"border-brand/30"}`,onClick:g?void 0:w,children:[(0,e.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:y,onMouseDown:A,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${g?"bg-card":"bg-card/50"}`,style:g?{height:41}:void 0,children:[(0,e.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDC18"}),(0,e.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===D&&(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===D&&(0,e.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:B("database.connectionFailed")}),"connected"===D&&(0,e.jsx)("span",{className:"text-[10px] text-emerald-500 flex-shrink-0",children:B("database.connected")}),(0,e.jsx)("span",{className:"flex-1"}),z&&(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:n(z)}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),y()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:g?B("browser.exitMaximize",{modKey:(0,j.Mu)()}):B("browser.maximize",{modKey:(0,j.Mu)()}),children:g?(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),x()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:B("common.close"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{style:{height:aQ},className:"flex overflow-hidden",children:["connecting"===D&&(0,e.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),B("database.connecting")]}),"error"===D&&(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,e.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:F}),(0,e.jsx)("button",{onClick:aG,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:B("common.retry")})]}),"connected"===D&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[H.length>1?(0,e.jsx)("select",{value:J,onChange:a=>{K(a.target.value),O(null)},className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1",children:H.map(a=>(0,e.jsx)("option",{value:a,children:a},a))}):(0,e.jsx)("span",{className:"flex-1 min-w-0 text-xs text-muted-foreground truncate",children:J}),(0,e.jsx)("button",{onClick:aH,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent active:bg-accent/50 transition-colors",title:B("database.refreshTableList"),children:(0,e.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("path",{d:"M1 1v5h5"}),(0,e.jsx)("path",{d:"M15 15v-5h-5"}),(0,e.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,e.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,e.jsx)("div",{className:"flex items-center border-b border-border",children:["table","view"].map(a=>(0,e.jsx)("button",{onClick:()=>Q(a),className:`flex-1 py-1 text-[10px] font-medium transition-colors ${P===a?"text-brand border-b border-brand":"text-muted-foreground hover:text-foreground"}`,children:{table:B("database.filterTable"),view:B("database.filterView")}[a]},a))}),(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[L.filter(a=>"table"===P?"view"!==a.type:"view"===a.type).map(a=>(0,e.jsxs)("div",{onClick:()=>aJ(a.name),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer truncate transition-colors ${N===a.name?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,e.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground",children:"view"===a.type?"V":"T"}),(0,e.jsx)("span",{className:"truncate min-w-0 flex-1",children:(0,e.jsx)(q,{text:a.name})}),(0,e.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.rowEstimate>0?`~${a.rowEstimate}`:""})]},a.name)),0===L.length&&(0,e.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:B("database.noTables")})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["structure","data","sql"].map(a=>(0,e.jsx)("button",{onClick:()=>S(a),className:`px-3 py-1.5 text-xs transition-colors ${R===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{structure:B("database.tabStructure"),data:B("database.tabData"),sql:"SQL"}[a]},a)),N&&"data"===R&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[Object.values(at).some(a=>a.enabled)&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-[10px] text-brand",children:B("database.filterActive",{count:Object.values(at).filter(a=>a.enabled).length})}),(0,e.jsx)("button",{onClick:aU,className:"px-1 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",title:B("database.clearAllFilters"),children:"✕"}),(0,e.jsx)("span",{className:"text-border",children:"|"})]}),ah.size>0&&!aj&&(0,e.jsx)("button",{onClick:()=>ak(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:B("database.deleteNRows",{count:ah.size})}),aj&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-[10px] text-destructive",children:B("database.confirmDeleteRows")}),(0,e.jsx)("button",{onClick:aN,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:B("common.confirm")}),(0,e.jsx)("button",{onClick:()=>ak(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:B("common.cancel")})]}),(0,e.jsx)("button",{onClick:()=>aO("csv"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:ah.size>0?B("database.copyCsvSelected"):B("database.copyCsvAll"),children:ah.size>0?B("database.copyCSV"):B("database.CSV")}),(0,e.jsx)("button",{onClick:()=>aO("json"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:ah.size>0?B("database.copyJsonSelected"):B("database.copyJsonAll"),children:ah.size>0?B("database.copyJSON"):B("database.JSON")})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:N||"sql"===R?"structure"===R?(0,e.jsx)(s,{columns:T,primaryKeys:V,foreignKeys:X,indexes:Z}):"data"===R?(0,e.jsx)(u,{result:_,loading:ad,columns:T,page:ab,totalPages:aR,totalRows:af,onPageChange:aS,filters:at,sort:av,onFilterChange:aT,onSortChange:aV,selectedRows:ah,onSelectedRowsChange:a=>{ai(a),ak(!1)},editingRowIdx:al,editValues:an,onStartEdit:a=>{if(!_)return;let b=_.rows[a],c={};for(let a of T)c[a.name]=null==b[a.name]?"":p(b[a.name]);ao(c),am(a)},onEditChange:(a,b)=>ao(c=>({...c,[a]:b})),onSaveEdit:aL,onCancelEdit:()=>am(null),isAddingRow:ap,newRowValues:ar,onStartAdd:()=>{aq(!0),as({})},onNewRowChange:(a,b)=>as(c=>({...c,[a]:b})),onSaveNewRow:aM,onCancelAdd:()=>{aq(!1),as({})},onCellCopy:a=>{navigator.clipboard.writeText(a),C(B("common.copied"))}}):(0,e.jsx)(v,{sqlInput:ax,onSqlChange:ay,onExecute:aK,onKeyDown:aP,result:az,error:aB,loading:aD,sqlRef:aF,onCellCopy:a=>{navigator.clipboard.writeText(a),C(B("common.copied"))}}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:B("database.selectTable")})})]})]})]}),!g&&(0,e.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===D?"bg-green-500":"error"===D?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,e.jsx)("span",{children:{connecting:B("common.connecting"),connected:B("common.connected"),error:B("common.connectionFailed")}[D]}),"connected"===D&&N&&(0,e.jsx)("span",{className:"text-muted-foreground/70",children:N}),(0,e.jsx)("span",{className:"flex-1"}),z&&(0,e.jsx)("span",{className:"text-[11px] flex-shrink-0",children:n(z)})]})]})})}function s({columns:a,primaryKeys:b,foreignKeys:c,indexes:d}){let{t:f}=(0,k.Bd)();return 0===a.length?(0,e.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:f("database.selectTableToView")}):(0,e.jsxs)("div",{className:"p-2 space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:f("database.columns")}),(0,e.jsxs)("table",{className:"w-full text-xs",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border",children:[(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("database.colName")}),(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("database.colType")}),(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("database.colNullable")}),(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("database.colDefault")})]})}),(0,e.jsx)("tbody",{children:a.map(a=>(0,e.jsxs)("tr",{className:"border-b border-border/50 hover:bg-accent/50",children:[(0,e.jsxs)("td",{className:"px-1.5 py-1 font-mono",children:[a.isPrimaryKey&&(0,e.jsx)("span",{className:"text-amber-500 mr-1",title:f("database.primaryKey"),children:"\uD83D\uDD11"}),a.name]}),(0,e.jsxs)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono",children:[a.type,a.maxLength?`(${a.maxLength})`:""]}),(0,e.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground",children:a.nullable?"YES":"NO"}),(0,e.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono truncate max-w-[120px]",children:a.default||""})]},a.name))})]})]}),c.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:f("database.foreignKeys")}),(0,e.jsx)("div",{className:"space-y-0.5",children:c.map((a,b)=>(0,e.jsxs)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground",children:[a.column," → ",a.refSchema,".",a.refTable,".",a.refColumn]},b))})]}),d.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:f("database.indexes")}),(0,e.jsx)("div",{className:"space-y-0.5",children:d.map(a=>(0,e.jsx)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground truncate",title:a.definition,children:a.name},a.name))})]})]})}function t({filter:a,onApply:b,onClear:c,onToggle:d,onClose:h,colName:i,anchorRect:j}){let{t:l}=(0,k.Bd)(),[m,n]=(0,f.useState)(a?.op||"="),[o,p]=(0,f.useState)(a?.value||""),q=(0,f.useRef)(null),r=(0,g.F2)(),s="IS NULL"!==m&&"IS NOT NULL"!==m,u=()=>{(!s||o.trim())&&b({op:m,value:o.trim(),enabled:!0})},v=r?.getBoundingClientRect(),x=v?.left??0,y=v?.top??0,z=v?.width??1e3,A=j.left-x;A+220>z-8&&(A=z-220-8),A<8&&(A=8);let B=j.bottom+2-y;return(0,e.jsx)(g.ZL,{children:(0,e.jsxs)("div",{ref:q,className:"fixed z-[9998] w-[220px] bg-popover border border-border rounded-md shadow-lg p-2 space-y-2",style:{left:A,top:B},onClick:a=>a.stopPropagation(),children:[a&&(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:a.enabled,onChange:a=>d(a.target.checked),className:"w-3 h-3 accent-brand"}),l("database.enable")]}),(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono truncate max-w-[120px]",children:i})]}),(0,e.jsx)("select",{value:m,onChange:a=>n(a.target.value),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-ring",children:w.map(a=>(0,e.jsx)("option",{value:a.value,children:a.label},a.value))}),s&&(0,e.jsx)("input",{type:"text",value:o,onChange:a=>p(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),u())},placeholder:l("IN"===m?"database.commaValues":"LIKE"===m?"database.likePattern":"database.valuePlaceholder"),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:u,disabled:s&&!o.trim(),className:"flex-1 px-2 py-1 text-[10px] bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-40 transition-colors",children:l("database.apply")}),a&&(0,e.jsx)("button",{onClick:c,className:"flex-1 px-2 py-1 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground transition-colors",children:l("database.clearFilter")})]})]})})}function u({result:a,loading:b,columns:c,page:d,totalPages:g,totalRows:h,onPageChange:i,filters:j,sort:l,onFilterChange:m,onSortChange:n,selectedRows:o,onSelectedRowsChange:r,editingRowIdx:s,editValues:v,onStartEdit:w,onEditChange:x,onSaveEdit:y,onCancelEdit:z,isAddingRow:A,newRowValues:B,onStartAdd:C,onNewRowChange:D,onSaveNewRow:E,onCancelAdd:F,onCellCopy:G}){let{t:H}=(0,k.Bd)(),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)({left:0,bottom:0});if(!a&&!b)return(0,e.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:H("database.selectTableForData")});let M=a?.fields||[],N=a?.rows||[],O={};for(let a of c)O[a.name]=a.type+(a.maxLength?`(${a.maxLength})`:"");let P=N.length>0&&o.size===N.length,Q=o.size>0&&!P;return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",children:[b&&(0,e.jsx)("div",{className:"absolute inset-0 bg-background/50 flex items-center justify-center z-10",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),(0,e.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,e.jsx)("thead",{className:"sticky top-0 bg-card z-[2]",children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{className:"px-1 py-1 border-b border-border w-8 text-center",children:(0,e.jsx)("input",{type:"checkbox",checked:P,ref:a=>{a&&(a.indeterminate=Q)},onChange:()=>{P?r(new Set):r(new Set(N.map((a,b)=>b)))},className:"w-3 h-3 accent-brand cursor-pointer"})}),M.map(a=>{let b=l?.column===a.name?l.dir:null,c=j[a.name],d=c?.enabled;return(0,e.jsxs)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono relative",children:[(0,e.jsxs)("span",{className:"cursor-pointer select-none hover:text-foreground transition-colors",onClick:()=>{var b;return b=a.name,void(l?.column===b?"ASC"===l.dir?n({column:b,dir:"DESC"}):n(null):n({column:b,dir:"ASC"}))},children:[a.name,O[a.name]&&(0,e.jsx)("span",{className:"ml-1 text-[9px] text-muted-foreground/60 font-normal",children:O[a.name]}),"ASC"===b&&(0,e.jsx)("span",{className:"ml-0.5 text-brand",children:"↑"}),"DESC"===b&&(0,e.jsx)("span",{className:"ml-0.5 text-brand",children:"↓"})]}),(0,e.jsx)("button",{onClick:b=>{if(b.stopPropagation(),I===a.name)return void J(null);let c=b.currentTarget.closest("th").getBoundingClientRect();L({left:c.left,bottom:c.bottom}),J(a.name)},className:`ml-1 inline-flex items-center transition-colors ${d?"text-brand":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:(0,e.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,e.jsx)("path",{d:"M1 2h14l-5.5 6.5V14l-3-2v-3.5z"})})}),I===a.name&&(0,e.jsx)(t,{filter:c||null,onApply:b=>{m(a.name,b),J(null)},onClear:()=>{m(a.name,null),J(null)},onToggle:b=>{c&&m(a.name,{...c,enabled:b})},onClose:()=>J(null),colName:a.name,anchorRect:K})]},a.name)})]})}),(0,e.jsxs)("tbody",{children:[A&&(0,e.jsxs)("tr",{className:"bg-emerald-500/5",children:[(0,e.jsx)("td",{className:"px-1 py-0.5 border-b border-border text-center",children:(0,e.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,e.jsx)("button",{onClick:E,className:"text-[10px] text-emerald-500 hover:text-emerald-400",title:H("common.save"),children:"✓"}),(0,e.jsx)("button",{onClick:F,className:"text-[10px] text-muted-foreground hover:text-foreground",title:H("common.cancel"),children:"✕"})]})}),M.map(a=>(0,e.jsx)("td",{className:"px-0.5 py-0.5 border-b border-border",children:(0,e.jsx)("input",{type:"text",value:B[a.name]??"",onChange:b=>D(a.name,b.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]",placeholder:"NULL"})},a.name))]}),N.map((a,b)=>(0,e.jsxs)("tr",{className:`hover:bg-accent/50 ${o.has(b)?"bg-brand/5":""} ${s===b?"bg-blue-500/5":""}`,children:[(0,e.jsx)("td",{className:"px-1 py-0.5 border-b border-border/50 text-center",children:s===b?(0,e.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,e.jsx)("button",{onClick:y,className:"text-[10px] text-emerald-500 hover:text-emerald-400",title:H("common.save"),children:"✓"}),(0,e.jsx)("button",{onClick:z,className:"text-[10px] text-muted-foreground hover:text-foreground",title:H("common.cancel"),children:"✕"})]}):(0,e.jsx)("input",{type:"checkbox",checked:o.has(b),onChange:()=>{let a;(a=new Set(o)).has(b)?a.delete(b):a.add(b),r(a)},className:"w-3 h-3 accent-brand cursor-pointer"})}),M.map(c=>(0,e.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onDoubleClick:()=>{null===s&&w(b)},onContextMenu:b=>{b.preventDefault(),G(p(a[c.name]))},children:s===b?(0,e.jsx)("input",{type:"text",value:v[c.name]??"",onChange:a=>x(c.name,a.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]"}):null===a[c.name]||void 0===a[c.name]?(0,e.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,e.jsx)(q,{text:p(a[c.name])})},c.name))]},b))]})]}),0===N.length&&!b&&(0,e.jsx)("div",{className:"p-4 text-xs text-muted-foreground text-center",children:H("common.noData")})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-t border-border text-[10px] text-muted-foreground bg-card/30 flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:C,disabled:A,className:"px-1.5 py-0.5 text-[10px] text-emerald-500 hover:text-emerald-400 disabled:opacity-30",children:H("database.addRow")}),(0,e.jsx)("span",{children:H("database.totalRows",{count:h})}),a?.duration!==void 0&&(0,e.jsxs)("span",{children:[a.duration,"ms"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:()=>i(d-1),disabled:0===d,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"◀"}),(0,e.jsxs)("span",{children:[d+1," / ",g]}),(0,e.jsx)("button",{onClick:()=>i(d+1),disabled:d>=g-1,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"▶"})]})]})]})}function v({sqlInput:a,onSqlChange:b,onExecute:c,onKeyDown:d,result:f,error:g,loading:h,sqlRef:i,onCellCopy:l}){let{t:m}=(0,k.Bd)();return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex-shrink-0 p-2 border-b border-border",children:[(0,e.jsx)("textarea",{ref:i,value:a,onChange:a=>b(a.target.value),onKeyDown:d,placeholder:m("database.sqlPlaceholder",{modKey:(0,j.Mu)()}),className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,e.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,e.jsx)("button",{onClick:c,disabled:h||!a.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:m(h?"database.executing":"database.execute")}),f?.duration!==void 0&&(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[f.command&&!f.fields?m("database.rowsAffected",{command:f.command,count:f.rowCount,duration:f.duration}):m("database.queryRows",{count:f.rows?.length??0,duration:f.duration}),f.truncated&&` ${m("database.resultTruncated")}`]})]})]}),g&&(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-destructive bg-destructive/5 border-b border-border break-all",children:g}),f?.fields&&f.rows&&(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,e.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,e.jsx)("tr",{children:f.fields.map(a=>(0,e.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:a.name},a.name))})}),(0,e.jsx)("tbody",{children:f.rows.map((a,b)=>(0,e.jsx)("tr",{className:"hover:bg-accent/50",children:f.fields.map(b=>(0,e.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onContextMenu:c=>{c.preventDefault(),l(p(a[b.name]))},children:null===a[b.name]||void 0===a[b.name]?(0,e.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,e.jsx)(q,{text:p(a[b.name])})},b.name))},b))})]})})]})}d()}catch(a){d(a)}})},57014:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{m:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(35208),j=c(73887),k=c(60591),l=c(18921),m=c(72529),n=c(85984),o=c(65543),p=c(25667),q=c(53036),r=c(9804),s=a([p,i,j]);function t({cwd:a,selected:b,diff:c,showMarkdownPreview:d,setShowMarkdownPreview:s,changedFiles:u,fileGitStatusMap:v,onContentSearch:w,locateInTree:x,jsonPreview:y,setJsonPreview:z,jsonPreviewSearch:A,jsonPreviewPreRef:B}){let{t:C}=(0,g.Bd)(),[D,E]=(0,f.useState)("file"),[F,G]=(0,f.useState)("compact"),H=b.file.path,I=(0,r.u)(H),{state:J}=(0,n.V)(a,H),K=(0,f.useMemo)(()=>{if("ready"===J.state)return J.data.functions.filter(o._).map(a=>({name:a.name,startLine:a.startLine,endLine:a.endLine,params:a.params}))},[J]);return(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[I||"map"!==D?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:H}),(0,e.jsx)(m.m,{content:C("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),navigator.clipboard.writeText(`${a}/${H}`),(0,h.oR)(C("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)(m.m,{content:C("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),x(H)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),(0,e.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${"staged"===b.type?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===b.type?C("fileBrowser.staged"):C("fileBrowser.unstaged")}),(0,e.jsx)("div",{className:"flex-1"}),!I&&"file"===D&&(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["compact","full"].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),G(a)},className:`px-2 py-0.5 text-xs transition-colors ${F===a?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:C("compact"===a?"diffViewer.compact":"diffViewer.full")},a))}),!I&&(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),E(a)},className:`px-2 py-0.5 text-xs transition-colors ${D===a?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:C("file"===a?"common.file":"common.codeMap")},a))})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:I?(0,e.jsx)(q.I,{cwd:a,path:H,className:"p-4 flex items-center justify-center",imgClassName:"max-w-full max-h-[60vh] object-contain",alt:H}):(0,e.jsx)(i.xZ,{oldContent:c.oldContent,newContent:c.newContent,filePath:c.filePath,isNew:c.isNew,isDeleted:c.isDeleted,cwd:a,enableComments:!0,compact:"compact"===F,symbols:K,onPreview:!c.isDeleted&&(0,k.e$)(H)?()=>s(!0):!c.isDeleted&&H.endsWith(".json")?()=>z({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:H.endsWith(".json")?C("common.readable"):C("common.preview"),onContentSearch:w})})]}):(0,e.jsx)(p.r,{cwd:a,filePath:c.filePath,oldContent:c.oldContent,newContent:c.newContent,isNew:c.isNew,isDeleted:c.isDeleted,changedFiles:u,fileGitStatusMap:v,enableComments:!0,onContentSearch:w,headerExtraLeft:({focalFile:b})=>{if(!b)return null;let c=v.get(b);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(m.m,{content:C("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${a}/${b}`),(0,h.oR)(C("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)(m.m,{content:C("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),x(b)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,e.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),c&&(0,e.jsx)("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${"staged"===c?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===c?C("fileBrowser.staged"):C("fileBrowser.unstaged")})]})},headerExtraRight:()=>(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),E(a)},className:`px-2 py-0.5 text-[11px] transition-colors ${D===a?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:C("file"===a?"common.file":"common.codeMap")},a))})}),d&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>s(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(j.M,{content:c.newContent,filePath:c.filePath,cwd:a,onClose:()=>s(!1)})})}),y&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>z(null),children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90%] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:y.filePath}),(0,e.jsx)("button",{onClick:()=>z(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(l._,{search:A}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,e.jsx)("pre",{ref:B,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,k.xb)(y.content)})})]})})]})}[p,i,j]=s.then?(await s)():s,d()}catch(a){d(a)}})},57031:(a,b,c)=>{"use strict";c.d(b,{F:()=>g});var d=c(79606),e=c(23734),f=c(33281);let g=(a,b)=>{f.t4.runFork(d.flatMap(e.d,c=>c.publish(a,b)))}},57632:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{z:()=>r});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(80600),j=c(44218),k=c(19794),l=c(67216),m=c(46674),n=c(35208),o=a([n]);function p(a,b){if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}return a}function q({node:a,selectedUid:b,onSelect:c,depth:d=0}){let[g,h]=(0,f.useState)(!0);if(a.isFile&&a.change){let f=b===a.change.uid;return(0,e.jsxs)("button",{onClick:()=>c(a.change),className:`w-full flex items-center gap-1.5 px-2 py-1 text-xs text-left rounded transition-colors ${f?"bg-brand/15 text-brand":"text-foreground hover:bg-accent"}`,style:{paddingLeft:`${12*d+8}px`},"data-tooltip":a.fullPath,children:[(0,e.jsx)(i.A,{className:"w-3.5 h-3.5 flex-shrink-0 opacity-60"}),(0,e.jsx)("span",{className:"truncate",children:a.name}),(0,e.jsx)("span",{className:`ml-auto text-[10px] flex-shrink-0 ${"write"===a.change.type?"text-green-500":"text-yellow-500"}`,children:"write"===a.change.type?"new":"edit"})]})}return(0,e.jsxs)("div",{children:[(0,e.jsxs)("button",{onClick:()=>h(!g),className:"w-full flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors",style:{paddingLeft:`${12*d+8}px`},children:[g?(0,e.jsx)(j.A,{className:"w-3 h-3"}):(0,e.jsx)(k.A,{className:"w-3 h-3"}),(0,e.jsx)("span",{className:"truncate",children:a.name})]}),g&&a.children.map((a,f)=>(0,e.jsx)(q,{node:a,selectedUid:b,onSelect:c,depth:d+1},a.isFile&&a.change?a.change.uid:`${a.fullPath}-${f}`))]})}function r({toolCalls:a,cwd:b,onClose:c}){let{t:d}=(0,g.Bd)(),i=(0,f.useMemo)(()=>(function(a,b){let c=[],d=0;for(let e of a)if("Edit"===e.name){let a=e.input;a.file_path&&"string"==typeof a.old_string&&"string"==typeof a.new_string&&c.push({filePath:p(a.file_path,b),uid:`change-${d++}`,type:"edit",old_string:a.old_string,new_string:a.new_string})}else if("Write"===e.name){let a=e.input;a.file_path&&"string"==typeof a.content&&c.push({filePath:p(a.file_path,b),uid:`change-${d++}`,type:"write",old_string:"",new_string:a.content})}return c})(a,b),[a,b]),j=(0,f.useMemo)(()=>(function a(b){return b.map(b=>{if(!b.isFile&&1===b.children.length&&!b.children[0].isFile){let c=b.children[0];return{...c,name:b.name+"/"+c.name,children:a(c.children)}}return{...b,children:a(b.children)}})})(function(a){let b=[];for(let c of a){let a=c.filePath.split("/").filter(Boolean),d=b;for(let b=0;b<a.length;b++){let e=a[b],f=b===a.length-1,g=a.slice(0,b+1).join("/");if(f){let a={name:e,fullPath:g,isFile:!0,children:[],change:c};d.push(a)}else{let a=d.find(a=>a.name===e&&!a.isFile);a||(a={name:e,fullPath:g,isFile:!1,children:[]},d.push(a)),d=a.children}}}return b}(i)),[i]),[k,o]=(0,f.useState)(i[0]||null),[s,t]=(0,f.useState)("unified"),u=(0,f.useRef)(null),[v,w]=(0,f.useState)(()=>!0);if(0===i.length)return null;let x=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-0 md:p-4",onClick:c,children:(0,e.jsxs)("div",{className:"bg-card shadow-xl w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:()=>w(a=>!a),"aria-label":d("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors ${v?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,children:(0,e.jsx)(l.A,{className:"w-4 h-4"})}),(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:d("diffViewer.fileChanges",{count:i.length})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[(0,e.jsx)("button",{onClick:()=>t("unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"unified"===s?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Unified"}),(0,e.jsx)("button",{onClick:()=>t("split"),className:`px-2 py-1 text-xs rounded transition-colors ${"split"===s?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Split"})]}),(0,e.jsx)("button",{onClick:c,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)(m.A,{className:"w-5 h-5"})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[v&&(0,e.jsx)("div",{ref:u,className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto py-2",children:j.map((a,b)=>(0,e.jsx)(q,{node:a,selectedUid:k?.uid||"",onSelect:a=>{o(a)}},a.isFile&&a.change?a.change.uid:`${a.fullPath}-${b}`))}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:k?"unified"===s?(0,e.jsx)(n.xU,{oldContent:k.old_string,newContent:k.new_string,filePath:k.filePath}):(0,e.jsx)(n.xZ,{oldContent:k.old_string,newContent:k.new_string,filePath:k.filePath,isNew:"write"===k.type}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:d("diffViewer.selectFileToView")})})]})]})});return(0,e.jsx)(e.Fragment,{children:(0,e.jsx)(h.ZL,{children:x})})}n=(o.then?(await o)():o)[0],d()}catch(a){d(a)}})},58554:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{r:()=>C});var e=c(48249),f=c(67484),g=c(77949),h=c(7833),i=c(40699),j=c(33281),k=c(41224),l=c(57031),m=c(88214),n=c(63041),o=c(62473),p=c(86686),q=c(75513),r=c(38087),s=c(97951),t=c(99843),u=c(62336),v=c(47818),w=c(67115),x=c(95401),y=c(90298),z=c(84844),A=c(44384),B=a([q,s,i,x,y,t,u,z,p]);function C({tabId:a,initialCwd:b,initialSessionId:c,engine:d,ollamaModel:B,onOllamaModelChange:D,deepseekModel:E,onDeepseekModelChange:F,chatMode:G,onChatModeChange:H,planMode:I,onPlanModeChange:J,hideHeader:K,hideSidebar:L,isActive:M=!0,onLoadingChange:N,onSessionIdChange:O,onTitleChange:P,onShowGitStatus:Q,onOpenNote:R,onCreateScheduledTask:S,onOpenSession:T,onContentSearch:U,onOpenSessionBrowser:V,onOpenSettings:W}){let{t:X}=(0,A.Bd)();(0,q.nH)();let[Y,Z]=(0,f.useState)([]),[$,_]=(0,f.useState)(null),[aa,ab]=(0,f.useState)(!1),[ac,ad]=(0,f.useState)(!1),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(null),[ak,al]=(0,f.useState)("sdk"),am=G??ak,an=(0,f.useCallback)(a=>{al(a),H?.(a)},[H]),[ao,ap]=(0,f.useState)(!1),aq=I??ao,ar=(0,f.useCallback)(a=>{ap(a),J?.(a)},[J]),as=!d||"claude"===d||"claude2"===d,at=(0,f.useRef)(null),au=(0,f.useCallback)(a=>{at.current?.write(a)},[]),av=(0,f.useCallback)(a=>{$&&fetch("/api/chat/pty-input",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:$,data:a})}).catch(()=>{})},[$]);(0,f.useRef)(!1);let aw=(0,f.useRef)(null);(0,f.useRef)(null);let ax=(0,f.useCallback)(async a=>{if(!b)return;let c=await j.t4.runPromiseExit((0,k.n_)({cwd:b,sessionId:a}));"Success"===c._tag&&c.value&&"string"==typeof c.value.title?P?.(c.value.title):"Failure"===c._tag&&console.error("Failed to fetch session title:",c.cause)},[b,P]),ay=(0,f.useRef)(null),{isLoading:az,tokenUsage:aA,rateLimitInfo:aB,apiRetryInfo:aC,ptyNotice:aD,handleSend:aE,handleStop:aF}=(0,s.e)(Y,Z,{sessionId:$,cwd:b,engine:d,chatMode:am,planMode:aq,ollamaModel:B,deepseekModel:E,onSessionId:_,onFetchTitle:ax,onPtyOutput:au,onRunComplete:()=>ay.current?.()}),aG=(0,f.useCallback)(async(a,c)=>{let d=a.split("\n")[0];if(as&&"sdk"===am){let b=/^\/plan(?:\s+([\s\S]*))?$/.exec(a.trim());if(b){let a=(b[1]??"").trim();"off"===a.toLowerCase()?(ar(!1),(0,h.oR)(X("chat.planModeOff",{defaultValue:"Plan mode off"}),"info")):""===a?(ar(!0),(0,h.oR)(X("chat.planModeOn",{defaultValue:"Plan mode on"}),"success")):(ar(!0),aE(a,c,{permissionMode:"plan"}));return}}if(d.startsWith("!")&&d.length>1){let e=d.slice(1).trim();if(!e)return void aE(a,c);let f=a.split("\n").slice(1).join("\n").trim(),g=await j.t4.runPromiseExit((0,k.JC)({command:e,cwd:b}));if("Success"===g._tag){let a=g.value,b=[a.stdout,a.stderr].filter(Boolean).join("\n")||"(no output)",d=a.exitCode?` (exit code: ${a.exitCode})`:"",h=X("chat.executedCommand",{command:e,exitInfo:d,output:b});f&&(h+=`
|
|
34
34
|
|
|
35
|
-
${f}`),aD(h,c)}else aD(X("chat.executedCommandFailed",{command:e,error:g.cause}),c);return}aD(a,c)},[aD,b,X,as,am,ar]),aG=(0,f.useCallback)(()=>{ar(!1),aD(X("chat.approvePlanPrompt",{defaultValue:"已批准,按上述计划开始执行。"}),void 0,{permissionMode:null})},[aD,ar,X]),[aH,aI]=(0,f.useState)(!1),aJ=(0,f.useRef)(!1),{isLoadingHistory:aK,isLoadingMore:aL,hasMoreHistory:aM,loadMoreHistory:aN,loadHistoryByCwdAndSessionId:aO,loadedSessionId:aP}=(0,r.m)(Y,Z,$,{cwd:b,initialSessionId:c,onSessionId:_,onTitleChange:P,onTokenUsage:aj,liveRunningRef:aJ}),aQ=aP||$,aR=M&&!ay&&!!aQ;(0,i.u)(aQ,Z,aR,d,{onRunningChange:a=>{aJ.current=a,aI(a)},onComplete:()=>{b&&aQ&&aO(b,aQ,!0)}}),(0,f.useRef)(M);let aS=az||ai;(0,f.useRef)(!1);let aT=(0,f.useCallback)(async a=>{let c=aP??$;if(!b||!c)return;let d=await j.t4.runPromiseExit((0,k.Zr)(c,{cwd:b,fromMessageUuid:a}));if("Success"===d._tag&&d.value.newSessionId){let a=d.value.newSessionId;T?T(a,"Fork"):(0,l.F)(m.n.OpenProject,{cwd:b,sessionId:a})}else"Failure"===d._tag&&console.error("Fork failed:",d.cause)},[b,aP,$,T]),aU=(0,f.useCallback)(()=>{af(!0)},[]),aV=(0,f.useCallback)(()=>{ah(!0)},[]),aW=(0,f.useMemo)(()=>{if(S&&b&&a&&$)return c=>{S({...c,cwd:b,tabId:a,sessionId:$,engine:d,..."ollama"===d&&B&&{model:B},..."deepseek"===d&&E&&{model:E}})}},[S,b,a,$,d,B,E]);return(0,e.jsxs)("div",{className:`flex ${K&&L?"h-full":"h-screen"} bg-card`,children:[(0,e.jsxs)("div",{id:"chat-screen",className:"flex-1 flex flex-col min-w-0 relative",onMouseEnter:()=>ab(!0),onMouseLeave:()=>ab(!1),children:[!K&&(0,e.jsx)(n.e,{cwd:b,sessionId:$,onOpenProjectSessions:()=>ad(!0),onOpenSessionBrowser:V,onOpenSettings:W}),as&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card/50",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:X("chat.executionMode",{defaultValue:"Execution mode"})}),(0,e.jsxs)("div",{className:"inline-flex rounded-md border border-border overflow-hidden text-xs",role:"group","data-testid":"chatmode-toggle",children:[(0,e.jsx)("button",{type:"button","data-testid":"chatmode-sdk",onClick:()=>an("sdk"),className:`px-2 py-0.5 ${"sdk"===am?"bg-brand text-white":"bg-transparent text-muted-foreground hover:bg-accent"}`,children:"Claude Agent SDK"}),(0,e.jsx)("button",{type:"button","data-testid":"chatmode-pty",onClick:()=>an("pty"),className:`px-2 py-0.5 ${"pty"===am?"bg-brand text-white":"bg-transparent text-muted-foreground hover:bg-accent"}`,title:X("chat.ptyModeHint",{defaultValue:"Subscription-billing mode: driven by the interactive claude CLI"}),children:"Claude Code CLI"})]}),"sdk"===am&&(0,e.jsxs)("label",{className:"flex items-center gap-1.5 ml-2 pl-3 border-l border-border text-xs cursor-pointer select-none",title:X("chat.planModeHint",{defaultValue:"Plan mode: read-only exploration that produces a plan without editing. Uncheck and resend to implement."}),children:[(0,e.jsx)("input",{type:"checkbox","data-testid":"planmode-toggle",checked:aq,onChange:a=>ar(a.target.checked),className:"accent-brand"}),(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(g.A,{className:"w-3.5 h-3.5"}),X("chat.planMode",{defaultValue:"Plan mode"})]}),(0,e.jsx)("span",{className:"text-muted-foreground",children:X("chat.planModeDesc",{defaultValue:"read-only \xb7 plan first, no edits"})})]})]}),"ollama"===d&&D&&(0,e.jsx)("div",{className:"flex items-center px-3 py-1.5 border-b border-border bg-card/50",children:(0,e.jsx)(x.m,{currentModel:B,onModelChange:D})}),"deepseek"===d&&F&&(0,e.jsx)("div",{className:"flex items-center px-3 py-1.5 border-b border-border bg-card/50",children:(0,e.jsx)(y.r,{currentModel:E,onModelChange:F})}),aK?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"text-muted-foreground",children:X("sessions.loadingHistory")})}):(0,e.jsx)(t.M,{ref:aw,messages:Y,isLoading:ay||aH,cwd:b,sessionId:$,engine:d,apiRetryInfo:aB,ptyNotice:aC,hasMoreHistory:aM,isLoadingMore:aL,onLoadMore:aN,onFork:aT,isActive:M,onContentSearch:U,onApprovePlan:aG}),aS&&(0,e.jsx)(o.g,{tokenUsage:aS,rateLimitInfo:aA}),(0,e.jsx)(u.V,{onSend:aF,disabled:ay||aH,cwd:b,engine:d,onShowGitStatus:Q,onShowComments:b?aU:void 0,onShowUserMessages:aV,onOpenNote:R,onCreateScheduledTask:aW}),(0,e.jsx)(v.ri,{ref:at,visible:as&&"pty"===am,running:ay,onInput:av})]}),!K&&b&&(0,e.jsx)(w.Q,{isOpen:ac,onClose:()=>ad(!1),cwd:b}),b&&(0,e.jsx)(z.i,{isOpen:ae,onClose:()=>af(!1),cwd:b}),(0,e.jsx)(p.f,{isOpen:ag,onClose:()=>ah(!1),messages:Y,onSelectMessage:a=>{aw.current?.scrollToMessage(a)}})]})}[q,s,i,x,y,t,u,z,p]=B.then?(await B)():B,d()}catch(a){d(a)}})},58904:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e:()=>m});var e=c(67484),f=c(20586),g=c(7833),h=c(208),i=c(79606),j=c(33281),k=c(85655),l=a([f]);function m({cwd:a,addToRecentFiles:b}){let[c,d]=(0,e.useState)(null),[l,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(new Set),[y,z]=(0,e.useState)(new Set),[A,B]=(0,e.useState)([]),[C,D]=(0,e.useState)([]),E=(0,e.useMemo)(()=>{let a=new Set((0,f.Sz)(A));for(let b of w)a.delete(b);return a},[A,w]),F=(0,e.useMemo)(()=>{let a=new Set((0,f.Sz)(C));for(let b of y)a.delete(b);return a},[C,y]),[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)(0),K=(0,e.useCallback)(async()=>{n(!0),p(null),await j.t4.runPromise((0,k.lv)(a).pipe(i.match({onSuccess:a=>{d(a);let b=(0,f.Do)(a.staged),c=(0,f.Do)(a.unstaged);B(b),D(c)},onFailure:a=>{let b=a.cause instanceof Error?a.cause.message:"Unknown error";p(b)}}))),n(!1)},[a]),L=(0,e.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),M=(0,e.useCallback)(a=>{z(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),N=(0,e.useCallback)((a,c)=>{r({file:a,type:c}),b(a.path)},[b]),O=(0,e.useCallback)(async(a,b,c,d)=>{let e=await j.t4.runPromiseExit(a);"Success"===e._tag?(await K(),(0,g.oR)(b,"success")):(console.error(c,e.cause),(0,g.oR)(d,"error"))},[K]),P=(0,e.useCallback)(b=>O((0,k.Iz)(a,[b]),h.A.t("toast.staged"),"Error staging file:",h.A.t("toast.stageFailed")),[a,O]),Q=(0,e.useCallback)(b=>O((0,k.X0)(a,[b]),h.A.t("toast.unstaged"),"Error unstaging file:",h.A.t("toast.unstageFailed")),[a,O]),R=(0,e.useCallback)(async b=>{0!==b.length&&await O((0,k.Iz)(a,b),h.A.t("toast.stagedNFiles",{count:b.length}),"Error staging files:",h.A.t("toast.stageFailed"))},[a,O]),S=(0,e.useCallback)(async b=>{0!==b.length&&await O((0,k.X0)(a,b),h.A.t("toast.unstagedNFiles",{count:b.length}),"Error unstaging files:",h.A.t("toast.unstageFailed"))},[a,O]),T=(0,e.useCallback)(async b=>{if(0===b.length)return;let c=b.filter(a=>"untracked"===a.status).map(a=>a.path),d=b.filter(a=>"untracked"!==a.status).map(a=>a.path),e=i.gen(function*(){c.length>0&&(yield*(0,k.Ub)(a,c,!0)),d.length>0&&(yield*(0,k.Ub)(a,d,!1))});await O(e,h.A.t("toast.discardedNFiles",{count:b.length}),"Error discarding files:",h.A.t("toast.discardFailed"))},[a,O]),U=(0,e.useCallback)(async()=>{c?.unstaged.length&&await O((0,k.Iz)(a,c.unstaged.map(a=>a.path)),h.A.t("toast.stagedNFiles",{count:c.unstaged.length}),"Error staging all files:",h.A.t("toast.stageFailed"))},[a,c,O]),V=(0,e.useCallback)(async()=>{c?.staged.length&&await O((0,k.X0)(a,c.staged.map(a=>a.path)),h.A.t("toast.unstagedNFiles",{count:c.staged.length}),"Error unstaging all files:",h.A.t("toast.unstageFailed"))},[a,c,O]),W=(0,e.useCallback)(async b=>{let c="untracked"===b.status;await O((0,k.Ub)(a,[b.path],c),c?h.A.t("toast.deletedFile"):h.A.t("toast.discardedChanges"),"Error discarding file:",h.A.t("toast.discardFailed"))},[a,O]),X=(0,e.useCallback)(async()=>{if(!c?.unstaged.length||!await (0,g.lJ)(h.A.t("git.discardAllConfirm",{count:c.unstaged.length}),{danger:!0}))return;let b=c.unstaged.filter(a=>"untracked"===a.status).map(a=>a.path),d=c.unstaged.filter(a=>"untracked"!==a.status).map(a=>a.path),e=c.unstaged.length,f=i.gen(function*(){d.length>0&&(yield*(0,k.Ub)(a,d,!1)),b.length>0&&(yield*(0,k.Ub)(a,b,!0))});await O(f,h.A.t("toast.discardedNFiles",{count:e}),"Error discarding all:",h.A.t("toast.discardFailed"))},[a,c,O]);return{status:c,setStatus:d,statusLoading:l,statusError:o,statusSelectedFile:q,statusDiff:s,statusDiffLoading:u,stagedExpandedPaths:E,unstagedExpandedPaths:F,stagedTree:A,setStagedTree:B,unstagedTree:C,setUnstagedTree:D,showStatusDiffPreview:G,setShowStatusDiffPreview:H,fetchStatus:K,handleStagedToggle:L,handleUnstagedToggle:M,handleStatusFileSelect:N,handleStage:P,handleUnstage:Q,handleStageFiles:R,handleUnstageFiles:S,handleDiscardFiles:T,handleStageAll:U,handleUnstageAll:V,handleDiscardFile:W,handleDiscardAll:X,refreshDiff:(0,e.useCallback)(()=>J(a=>a+1),[])}}f=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},60591:(a,b,c)=>{"use strict";c.d(b,{C6:()=>h,WU:()=>v,aR:()=>u,e$:()=>t,jU:()=>g,oK:()=>w,u:()=>s,xb:()=>i,zs:()=>q});var d=c(67484),e=c.n(d),f=c(208);function g(a){try{return JSON.parse(a),!0}catch{return!1}}function h(a){try{let b=JSON.parse(a);return JSON.stringify(b,null,2)}catch{return a}}function i(a){try{let b=JSON.parse(a);return p(b,0)}catch{return a}}let j="#79c0ff",k="#a5d6ff",l="#ff7b72",m="#8b949e",n=(a,b)=>e().createElement("span",{style:{color:a}},b);function o({label:a,labelColor:b,value:c,indent:d}){let[g,h]=e().useState(!1),[i,j]=e().useState({x:0,y:0}),l="string"==typeof c&&c.replace(/\\n/g,"\n").split("\n").length>3,q={onMouseDown:a=>{j({x:a.clientX,y:a.clientY})},onClick:a=>{let b=a.clientX-i.x,c=a.clientY-i.y;b*b+c*c>25||(a.stopPropagation(),h(a=>!a))},style:{cursor:"pointer"}};if(l&&g&&"string"==typeof c){let d=c.replace(/\\n/g,"\n").split("\n")[0],g=c.replace(/\\n/g,"\n").split("\n").length;return e().createElement("span",q,n(b,a),n(m,": "),n(k,d),n("#6e7681",` ${f.A.t("toolCall.foldedLines",{count:g})}`))}let r=e().createElement(e().Fragment,null,n(b,a),n(m,": "),p(c,d));return l?e().createElement("span",q,r):r}function p(a,b){let c=" ".repeat(b);if(null===a)return n(l,"null");if(void 0===a)return n(l,"undefined");if("string"==typeof a)return n(k,a.replace(/\\n/g,"\n").replace(/\n/g,"\n"+c));if("number"==typeof a)return n("#79c0ff",String(a));if("boolean"==typeof a)return n(l,String(a));if(Array.isArray(a))return 0===a.length?n(m,"[]"):e().createElement(e().Fragment,null,n(m,"["),"\n",...a.map((d,f)=>e().createElement("span",{key:f},c+" ",e().createElement(o,{label:`[${f}]`,labelColor:j,value:d,indent:b+1}),f<a.length-1?e().createElement(e().Fragment,null,n(m,","),"\n"):"\n")),c,n(m,"]"));if("object"==typeof a){let d=Object.entries(a);return 0===d.length?n(m,"{}"):e().createElement(e().Fragment,null,n(m,"{"),"\n",...d.map(([a,f],g)=>e().createElement("span",{key:a},c+" ",e().createElement(o,{label:a,labelColor:j,value:f,indent:b+1}),g<d.length-1?e().createElement(e().Fragment,null,n(m,","),"\n"):"\n")),c,n(m,"}"))}return String(a)}function q(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path&&"string"==typeof b.old_string&&"string"==typeof b.new_string)return b}catch{}return null}let r=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function s(a){let b=a.slice(a.lastIndexOf(".")).toLowerCase();return r.has(b)}function t(a){return a.toLowerCase().endsWith(".md")}function u(a){let b=a.toLowerCase();return b.endsWith(".html")||b.endsWith(".htm")}function v(a,b){let c=b.startsWith("/")?[]:a.split("/").slice(0,-1);for(let a of b.replace(/^\//,"").split("/"))""!==a&&"."!==a&&(".."===a?c.pop():c.push(a));return c.join("/")}function w(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path)return b.file_path}catch{let b=a.trim();if(b.startsWith("/")&&!b.includes("\n")&&b.length<500)return b}return null}},61130:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{ReviewCommentsListModal:()=>l});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(7833),j=c(208);function k(a,b,c){let d=(a,c)=>b[a]||c,e=[],f=null!=c?`[${c+1}] `:"",g=a.anchor.selectedText.length>200?a.anchor.selectedText.slice(0,197)+"...":a.anchor.selectedText;for(let b of(e.push(`${f}${j.A.t("review.quoteRef",{text:g})}`),e.push(j.A.t("review.commentAuthor",{author:d(a.authorId,a.author),content:a.content})),a.replies))e.push(j.A.t("review.replyAuthor",{author:d(b.authorId,b.author),content:b.content}));return e.join("\n")}function l({isOpen:a,onClose:b,comments:c,reviewTitle:d,userNameMap:n,onCommentClick:o}){let{t:p}=(0,g.Bd)(),[q,r]=(0,f.useState)(null),[s,t]=(0,f.useState)(!1);if(!a)return null;let u=[...c].sort((a,b)=>a.anchor.startOffset-b.anchor.startOffset),v=(a,b)=>n[a]||b,w=async a=>{r(a.id);try{let b=k(a,n);await navigator.clipboard.writeText(b),(0,i.oR)(p("toast.copiedComment"))}catch{(0,i.oR)(p("toast.copyFailed"),"error")}finally{r(null)}},x=async()=>{if(0!==c.length){t(!0);try{let a=function(a,b,c){if(0===a.length)return"";let d=[...a].sort((a,b)=>a.anchor.startOffset-b.anchor.startOffset),e=[j.A.t("review.reviewSummary",{title:b}),""];return d.forEach((a,b)=>{e.push(k(a,c,b)),e.push("")}),e.push(j.A.t("review.totalNComments",{count:a.length})),e.join("\n").trim()}(c,d,n);await navigator.clipboard.writeText(a),(0,i.oR)(p("toast.copiedAllComments"))}catch{(0,i.oR)(p("toast.copyFailed"),"error")}finally{t(!1)}}},y=a=>{o?.(a),b()},z=u.filter(a=>!a.closed),A=u.filter(a=>a.closed),B=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,e.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-xl flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:p("review.allCommentsTitle")}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[p("review.commentsCountBrief",{count:c.length}),A.length>0&&` (${p("review.closedCount",{count:A.length})})`]}),c.length>0&&(0,e.jsx)("button",{onClick:x,disabled:s,className:"p-1 rounded hover:bg-accent text-muted-foreground disabled:opacity-50",title:p("review.copyAllComments"),children:s?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:b,className:"p-1 rounded hover:bg-accent text-muted-foreground",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-3",children:0===c.length?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,e.jsx)("div",{className:"text-2xl mb-2",children:"\uD83D\uDCAC"}),(0,e.jsx)("span",{className:"text-sm",children:p("review.noComments")})]}):(0,e.jsxs)("div",{className:"space-y-2",children:[z.map((a,b)=>(0,e.jsx)(m,{comment:a,index:b,resolveAuthor:v,copyingId:q,onCopy:w,onClick:y},a.id)),A.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"text-[11px] text-muted-foreground/60 pt-2 pb-1 px-1",children:p("review.closedComments",{count:A.length})}),A.map((a,b)=>(0,e.jsx)(m,{comment:a,index:z.length+b,resolveAuthor:v,copyingId:q,onCopy:w,onClick:y,closed:!0},a.id))]})]})})]})});return(0,e.jsx)(h.ZL,{children:B})}function m({comment:a,index:b,resolveAuthor:c,copyingId:d,onCopy:f,onClick:g,closed:h}){var i;let k=a.anchor.selectedText.length>100?a.anchor.selectedText.slice(0,97)+"...":a.anchor.selectedText;return(0,e.jsxs)("div",{className:`rounded-lg border border-border hover:border-muted-foreground/30 transition-all cursor-pointer group ${h?"opacity-50":""}`,onClick:()=>g(a.id),children:[(0,e.jsx)("div",{className:"px-3 pt-2.5 pb-1",children:(0,e.jsx)("div",{className:"text-xs bg-yellow-500/10 border-l-2 border-yellow-500 px-2 py-1 rounded-r text-muted-foreground truncate",children:k})}),(0,e.jsxs)("div",{className:"px-3 pt-1.5 pb-2 flex items-start gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,e.jsx)("span",{className:"w-4 h-4 rounded-full bg-brand/20 text-brand flex items-center justify-center text-[9px] font-bold flex-shrink-0",children:c(a.authorId,a.author).charAt(0)}),(0,e.jsx)("span",{className:"text-xs font-medium",children:c(a.authorId,a.author)}),(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(i=a.createdAt,new Date(i).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}))}),h&&(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground/60",children:j.A.t("review.closedLabel")})]}),(0,e.jsx)("p",{className:"text-sm text-foreground line-clamp-2 pl-6",children:a.content}),a.replies.length>0&&(0,e.jsxs)("div",{className:"pl-6 mt-1 space-y-0.5",children:[a.replies.slice(0,3).map(a=>(0,e.jsxs)("div",{className:"text-xs text-muted-foreground truncate",children:[(0,e.jsx)("span",{className:"font-medium",children:c(a.authorId,a.author)}),": ",a.content]},a.id)),a.replies.length>3&&(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground/60",children:j.A.t("review.moreReplies",{count:a.replies.length-3})})]})]}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),f(a)},disabled:d===a.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-accent text-muted-foreground transition-opacity disabled:opacity-50 flex-shrink-0 mt-0.5",title:j.A.t("review.copyComment"),children:d===a.id?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})})]})]})}d()}catch(a){d(a)}})},61135:()=>{},61349:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>u});var e=c(48249),f=c(67484),g=c(44384),h=c(44256);c(33281),c(87808);var i=c(35208),j=c(55287),k=c(98356),l=c(24680),m=c(84835),n=c(7833),o=c(18921),p=c(53036),q=c(60591),r=a([j,i]);function s({filePath:a}){let[b,c]=(0,f.useState)(null),[d,g]=(0,f.useState)(!0),[h,i]=(0,f.useState)(null);(0,f.useRef)(!1);let k=(0,q.e$)(a);return((0,q.u)(a),h)?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-red-11",children:h})}):d?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):(0,q.u)(a)?(0,e.jsx)(p.I,{absPath:a,className:"flex items-center justify-center h-full overflow-auto",imgClassName:"max-w-full max-h-full object-contain",alt:a.split("/").pop()||"image"}):b?k?(0,e.jsx)(t,{content:b}):(0,e.jsx)(j.Cv,{content:b,filePath:a,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}[j,i]=r.then?(await r)():r;let v=[m.W];function t({content:a}){let b=(0,f.useRef)(null);return(0,e.jsxs)("div",{className:"h-full flex",children:[(0,e.jsx)(l.l,{content:a,containerRef:b}),(0,e.jsx)("div",{ref:b,className:"flex-1 overflow-auto p-4",children:(0,e.jsx)(k.T,{content:a,rehypePlugins:v})})]})}function u({title:a,content:b,toolName:c,onClose:d}){let{t:j}=(0,g.Bd)(),k=(0,q.jU)(b),l=(0,q.zs)(b),m=(0,q.oK)(b),p=!!l,r=!!m,[t,v]=(0,f.useState)(("Read"===c||"Write"===c)&&r?"file":p?"diff-unified":k?"readable":"json"),w=(0,f.useRef)(null),x=(0,o.o)(w),y=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-0 md:p-4",onClick:d,children:(0,e.jsxs)("div",{className:"bg-card shadow-xl w-full max-w-[90%] h-full md:h-[90vh] rounded-none md:rounded-lg flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a}),m&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(m),(0,n.oR)(j("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:j("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsxs)("div",{className:"flex items-center gap-3",children:[k&&(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[p&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>v("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.sideBySide"),children:"Split"}),(0,e.jsx)("button",{onClick:()=>v("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.unified"),children:"Unified"})]}),r&&(0,e.jsx)("button",{onClick:()=>v("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.previewFile"),children:"File"}),(0,e.jsx)("button",{onClick:()=>v("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:j("common.readable")}),(0,e.jsx)("button",{onClick:()=>v("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===t&&m?(0,e.jsx)(s,{filePath:m}):"diff-unified"===t&&l?(0,e.jsx)(i.xU,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"diff-split"===t&&l?(0,e.jsx)(i.xZ,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"readable"===t&&k?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o._,{search:x}),(0,e.jsx)("pre",{ref:w,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,q.xb)(b)})]}):(0,e.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:k?(0,q.C6)(b):b})})]})});return(0,e.jsx)(h.ZL,{children:y})}d()}catch(a){d(a)}})},61591:(a,b,c)=>{"use strict";c.d(b,{o:()=>g});var d=c(48249);c(67484);let e={ts:"#3178c6",tsx:"#3178c6",js:"#f1e05a",jsx:"#61dafb",mjs:"#f1e05a",cjs:"#f1e05a",html:"#e44d26",css:"#563d7c",scss:"#cd6799",sass:"#cd6799",less:"#1d365d",vue:"#41b883",svelte:"#ff3e00",json:"#cbcb41",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4121",xml:"#e37933",env:"#ecd53f",md:"#519aba",mdx:"#519aba",txt:"#89898a",py:"#3572a5",go:"#00add8",rs:"#dea584",java:"#b07219",kt:"#a97bff",kts:"#a97bff",c:"#555555",h:"#555555",cpp:"#f34b7d",hpp:"#f34b7d",rb:"#701516",php:"#4f5d95",sh:"#89e051",bash:"#89e051",zsh:"#89e051",png:"#a074c4",jpg:"#a074c4",jpeg:"#a074c4",gif:"#a074c4",svg:"#ffb13b",webp:"#a074c4",ico:"#a074c4",lock:"#89898a",gitignore:"#f14e32",dockerfile:"#2496ed",sql:"#e38c00",graphql:"#e535ab",gql:"#e535ab",default:"#8a8a8a"},f={"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 g({name:a,className:b="",size:c=16}){let h,i=f[h=a.toLowerCase()]?f[h]:e[a.split(".").pop()?.toLowerCase()||""]||e.default,j=a.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.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"===j||"tsx"===j&&a.includes("component")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.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,d.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,d.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:i})]}):["md","mdx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.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(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.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,d.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,d.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:i}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:i,strokeWidth:"2",fill:"none"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:i}),(0,d.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:i,strokeWidth:"2",strokeLinecap:"round"})]}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:i}),(0,d.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"html"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.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(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.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(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,d.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===j||".gitignore"===a.toLowerCase()?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:i}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,d.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===j||"dockerfile"===a.toLowerCase()||a.toLowerCase().startsWith("dockerfile")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:i}),(0,d.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"===j||a.startsWith(".env")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:i}),(0,d.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"vue"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:i}),(0,d.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M14 3v5h5",stroke:i,strokeWidth:"1.5",fill:"none"})]})}},61632:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{y:()=>m});var e=c(67484),f=c(20586),g=c(9804),h=c(208),i=c(79606),j=c(33281),k=c(85655),l=a([f]);function m({cwd:a,addToRecentFiles:b}){let[c,d]=(0,e.useState)(null),[l,n]=(0,e.useState)(""),[o,p]=(0,e.useState)([]),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)([]),[u,v]=(0,e.useState)([]),[w,x]=(0,e.useState)(new Set),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(null),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)(!0),[K,L]=(0,e.useState)(!1),[M,N]=(0,e.useState)(!1),[O,P]=(0,e.useState)(null),Q=(0,e.useRef)(null),[R,S]=(0,e.useState)(null),[T,U]=(0,e.useState)(!1),[V,W]=(0,e.useState)(""),[X,Y]=(0,e.useState)(""),[Z,$]=(0,e.useState)([]),[_,aa]=(0,e.useState)([]),[ab,ac]=(0,e.useState)(new Set),[ad,ae]=(0,e.useState)(null),[af,ag]=(0,e.useState)(null),[ah,ai]=(0,e.useState)(!1),[aj,ak]=(0,e.useState)(!1),al=(0,e.useCallback)(()=>{D(!0),P(null),j.t4.runPromise((0,k.r4)(a).pipe(i.match({onSuccess:a=>{a.local&&a.current?(d(a),n(a.current),a.upstream&&W(a.upstream)):(P(h.A.t("git.cannotGetBranches")),d(null))},onFailure:a=>{console.error(a),"NotFoundError"===a._tag?P(h.A.t("git.notGitRepo")):P(h.A.t("git.getBranchesFailed")),d(null)}}))).finally(()=>D(!1))},[a]),am=(0,e.useCallback)(b=>{F(!0),r(null),t([]),v([]),z(null),B(null),J(!0),j.t4.runPromise((0,k.Bj)(a,b,g.B_).pipe(i.match({onSuccess:a=>{let b=a.commits||[];p(b),J(b.length>=g.B_)},onFailure:a=>{console.error(a)}}))).finally(()=>F(!1))},[a]),an=(0,e.useCallback)(()=>{if(G||!I||!l)return;H(!0);let b=o.length;j.t4.runPromise((0,k.Bj)(a,l,g.B_,b).pipe(i.match({onSuccess:a=>{let b=a.commits||[];b.length>0&&p(a=>[...a,...b]),J(b.length>=g.B_)},onFailure:a=>{console.error(a)}}))).finally(()=>H(!1))},[a,l,o.length,G,I]),ao=(0,e.useCallback)(a=>{let{scrollTop:b,scrollHeight:c,clientHeight:d}=a.target;c-b-d<100&&an()},[an]),ap=(0,e.useCallback)(b=>{r(b),z(null),B(null),L(!0),j.t4.runPromise((0,k.Zi)(a,b.hash).pipe(i.match({onSuccess:a=>{let b=a.files||[];t(b);let c=(0,f.Do)(b);v(c),x(new Set((0,f.Sz)(c)))},onFailure:a=>{console.error(a)}}))).finally(()=>L(!1))},[a]),aq=(0,e.useCallback)(c=>{q&&(z(c),b(c.path),N(!0),j.t4.runPromise((0,k.Zi)(a,q.hash,c.path).pipe(i.match({onSuccess:a=>B(a),onFailure:a=>{console.error(a)}}))).finally(()=>N(!1)))},[a,q,b]),ar=(0,e.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),as=(0,e.useCallback)(b=>{ai(!0),ae(null),ag(null),j.t4.runPromise((0,k.yy)(a,b).pipe(i.match({onSuccess:a=>{let b=a.files||[];$(b);let c=(0,f.Do)(b);aa(c),ac(new Set((0,f.Sz)(c)))},onFailure:a=>{console.error(a)}}))).finally(()=>ai(!1))},[a]),at=(0,e.useCallback)(c=>{ae(c),b(c.path),ak(!0),j.t4.runPromise((0,k.yy)(a,X,c.path).pipe(i.match({onSuccess:a=>ag(a),onFailure:a=>{console.error(a)}}))).finally(()=>ak(!1))},[a,X,b]),au=(0,e.useCallback)(a=>{ac(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),av=(0,e.useCallback)(a=>{if(U(a),a){let a="origin/main";Y(a),as(a)}else $([]),aa([]),ae(null),ag(null),Y("")},[V,as]),aw=(0,e.useCallback)(a=>{S({x:a.clientX,y:a.clientY})},[]),ax=(0,e.useCallback)(()=>{S(null)},[]);return{branches:c,selectedBranch:l,setSelectedBranch:n,commits:o,setCommits:p,selectedCommit:q,setSelectedCommit:r,historyFiles:s,historyFileTree:u,historyExpandedPaths:w,historySelectedFile:y,historyFileDiff:A,isLoadingBranches:C,isLoadingCommits:E,isLoadingMore:G,hasMoreCommits:I,setHasMoreCommits:J,isLoadingHistoryFiles:K,isLoadingHistoryDiff:M,historyError:O,commitListRef:Q,tooltipPos:R,loadBranches:al,loadCommits:am,loadMoreCommits:an,handleCommitListScroll:ao,handleSelectCommit:ap,handleSelectHistoryFile:aq,handleHistoryToggle:ar,handleCommitInfoMouseMove:aw,handleCommitInfoMouseLeave:ax,compareMode:T,toggleCompareMode:av,compareBaseBranch:X,setCompareBaseBranch:Y,upstreamBranch:V,compareFiles:Z,compareFileTree:_,compareExpandedPaths:ab,compareSelectedFile:ad,compareFileDiff:af,isLoadingCompareFiles:ah,isLoadingCompareDiff:aj,handleSelectCompareFile:at,handleCompareToggle:au,loadCompareFiles:as}}f=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},62336:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{V:()=>a});var e=c(48249),f=c(67484),g=c(7833),h=c(44384),i=c(83003),j=c(30458),k=c(62751),l=c(33281),m=c(85655),n=c(41224);let a=(0,f.memo)(function({onSend:a,disabled:b,cwd:c,engine:d,onShowGitStatus:o,onShowComments:p,onShowUserMessages:q,onOpenNote:r,onCreateScheduledTask:s}){let{t}=(0,h.Bd)(),[u,v]=(0,f.useState)(""),[w,x]=(0,f.useState)(0),[y,z]=(0,f.useState)([]),[A,B]=(0,f.useState)([]),[C,D]=(0,f.useState)([]),[E,F]=(0,f.useState)(!1),[G,H]=(0,f.useState)(0),[I,J]=(0,f.useState)(!1),K=(0,f.useRef)(null),L=(0,f.useRef)(null),M=(0,f.useCallback)(()=>{let a=K.current;if(!a)return;a.style.height="auto";let b=Math.max(38,Math.min(a.scrollHeight,200));a.style.height=`${b}px`},[]);(0,f.useLayoutEffect)(()=>{M()},[u,M]),(0,f.useEffect)(()=>{l.t4.runPromiseExit((0,n.M5)()).then(a=>{"Success"===a._tag?B(a.value):console.error("Failed to load commands:",a.cause)})},[]);let N=(0,f.useCallback)(async()=>{let a=await l.t4.runPromiseExit((0,n.l1)());if("Success"===a._tag){let b=a.value.skills??a.value,c=(Array.isArray(b)?b:[]).filter(a=>a.valid&&!!a.name).map(a=>({name:`/${a.name}`,description:a.description||"",source:"skill",skillPath:a.path,argumentHint:a.argumentHint}));D(c)}else console.error("Failed to load skills:",a.cause)},[]);(0,f.useEffect)(()=>(N(),(0,k.U)(N)),[N]);let O=(0,f.useMemo)(()=>{let a=0===w?0:u.lastIndexOf("\n",w-1)+1,b=u.indexOf("\n",w),c=-1===b?u.length:b;return{text:u.slice(a,c),start:a,end:c}},[u,w]),P=(0,f.useMemo)(()=>{let a=O.text.match(/^\s*([/@])([a-zA-Z0-9-]*)$/);return a?{marker:a[1],verb:a[2].toLowerCase()}:null},[O.text]),Q=(0,f.useMemo)(()=>d&&"claude"!==d&&"claude2"!==d?[]:[{name:"/plan",description:"Enable plan mode (read-only). /plan <task> to plan a task; /plan off to disable.",source:"builtin",argumentHint:"[task|off]"}],[d]),R=(0,f.useMemo)(()=>{if(!P)return[];let{verb:a}=P,b=b=>b.name.slice(1).toLowerCase().startsWith(a);return[...Q.filter(b),...A.filter(b),...C.filter(b)]},[P,Q,A,C]),S=!I&&!!P&&R.length>0,T=(0,f.useRef)(u);(0,f.useLayoutEffect)(()=>{T.current!==u&&(queueMicrotask(()=>H(0)),I&&queueMicrotask(()=>J(!1)),T.current=u)},[u,I]),(0,f.useLayoutEffect)(()=>{if(S&&L.current){let a=L.current.children[G];a&&a.scrollIntoView({block:"nearest"})}},[G,S]);let U=(0,f.useCallback)(()=>{let c=u.trim();(c||y.length>0)&&!b&&(a(c,y.length>0?y:void 0),v(""),z([]),K.current&&(K.current.style.height="auto"))},[u,y,b,a]),V=(0,f.useCallback)(a=>{let b=P?.marker??"/",c=`${b}${a.name.slice(1)} `,d=u.slice(0,O.start),e=u.slice(O.end),f=d+c+e,g=d.length+c.length;v(f),x(g),requestAnimationFrame(()=>{let a=K.current;a&&(a.focus(),a.setSelectionRange(g,g))})},[u,O,P]),W=(0,f.useCallback)(a=>{if(!a.nativeEvent.isComposing){if(S&&R.length>0){if("ArrowDown"===a.key){a.preventDefault(),H(a=>(a+1)%R.length);return}if("ArrowUp"===a.key){a.preventDefault(),H(a=>(a-1+R.length)%R.length);return}if("Enter"===a.key){a.preventDefault(),V(R[G]);return}if("Escape"===a.key){a.preventDefault(),J(!0);return}if("Tab"===a.key){a.preventDefault(),V(R[G]);return}}"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),U())}},[S,R,G,V,U]),X=(0,f.useCallback)(a=>{let b=a.clipboardData?.items;if(!b)return;let c=["image/png","image/jpeg","image/webp","image/gif"];for(let d of Array.from(b)){let b=c.find(a=>d.type===a);if(b){a.preventDefault();let c=d.getAsFile();if(!c)continue;if(c.size>5242880){alert(t("chat.imageSizeLimit",{size:(c.size/1024/1024).toFixed(2)}));continue}let e=new FileReader;e.onload=a=>{let c=a.target?.result;if(!c)return;let d=c.replace(/^data:image\/\w+;base64,/,""),e={id:`img-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,data:d,preview:c,media_type:b};z(a=>[...a,e])},e.readAsDataURL(c)}}},[t]),Y=(0,f.useCallback)(a=>{z(b=>b.filter(b=>b.id!==a))},[]);return(0,e.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,e.jsx)(i.k,{images:y,onRemove:Y,disabled:b}),S&&R.length>0&&(0,e.jsx)("div",{ref:L,className:"absolute bottom-full left-0 right-0 mx-4 mb-2 max-h-64 overflow-y-auto bg-card border border-border rounded-lg shadow-lg",children:R.map((a,b)=>{let c=b>0?R[b-1]:null,d="skill"===a.source&&(!c||"skill"!==c.source),f="skill"!==a.source&&0===b;return(0,e.jsxs)("div",{children:[f&&(0,e.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Commands"}),d&&(0,e.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Skills"}),(0,e.jsxs)("div",{onClick:()=>V(a),className:`px-4 py-2 cursor-pointer ${b===G?"bg-brand/10":"hover:bg-accent"}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("span",{className:"font-mono text-sm font-medium text-foreground",children:(P?.marker??"/")+a.name.slice(1)}),(0,e.jsx)("span",{className:"flex-1 text-sm text-muted-foreground truncate",children:"builtin"===a.source?t(`commands.${a.name.slice(1)}`,{defaultValue:a.description}):a.description}),(0,e.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${(a=>{switch(a){case"builtin":return"bg-brand/15 text-brand dark:bg-brand/25 dark:text-teal-11";case"skill":return"bg-purple-9/15 text-purple-11 dark:bg-purple-9/25 dark:text-purple-11"}})(a.source)}`,children:(a=>{switch(a){case"builtin":return t("common.builtin");case"skill":return"Skill"}})(a.source)})]}),"skill"===a.source&&a.argumentHint&&(0,e.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 pl-0 truncate",children:a.argumentHint})]})]},a.name)})}),(0,e.jsxs)("div",{className:"flex gap-2 items-end p-4",children:[(0,e.jsx)("button",{onClick:async()=>{if(!c)return;let a=await l.t4.runPromiseExit((0,m.Iz)(c,["."]));"Success"===a._tag?((0,g.oR)(t("toast.stagedAllFiles"),"success"),window.dispatchEvent(new CustomEvent("git-status-changed"))):(console.error("Error staging files:",a.cause),(0,g.oR)(t("toast.stageFailed"),"error"))},className:"p-2 text-green-11 hover:text-green-10 hover:bg-green-9/10 active:bg-green-9/20 active:scale-95 rounded-lg transition-all",title:t("chat.stageAll"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),o&&(0,e.jsx)("button",{onClick:o,className:"p-2 text-brand hover:text-teal-10 hover:bg-brand/10 active:bg-brand/20 active:scale-95 rounded-lg transition-all",title:t("chat.viewGitChanges"),children:(0,e.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"6",cy:"6",r:"2",strokeWidth:2}),(0,e.jsx)("circle",{cx:"18",cy:"6",r:"2",strokeWidth:2}),(0,e.jsx)("circle",{cx:"6",cy:"18",r:"2",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 8v10M18 8v4c0 2-2 4-6 4"})]})}),p&&(0,e.jsx)("button",{onClick:p,className:"p-2 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95 rounded-lg transition-all",title:t("chat.viewAllComments"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),q&&(0,e.jsx)("button",{onClick:q,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:t("chat.userMessages"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),r&&(0,e.jsx)("button",{onClick:r,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:t("chat.projectNotes"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})}),s&&(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("button",{onClick:()=>F(!E),className:`p-2 rounded-lg transition-all ${E?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95"}`,title:t("chat.scheduledTasks"),children:(0,e.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]})}),E&&(0,e.jsx)(j.E,{onClose:()=>F(!1),onCreate:s})]}),(0,e.jsx)("textarea",{ref:K,value:u,onChange:a=>{v(a.target.value),x(a.target.selectionStart??a.target.value.length)},onSelect:a=>x(a.currentTarget.selectionStart??0),onKeyDown:W,onPaste:X,placeholder:b?t("chat.placeholderDisabled"):t("chat.placeholder"),rows:1,className:"flex-1 resize-none px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-ring bg-card text-foreground placeholder-slate-9"})]})]})});d()}catch(a){d(a)}})},62473:(a,b,c)=>{"use strict";c.d(b,{g:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({tokenUsage:a,rateLimitInfo:b}){let{t:c}=(0,f.Bd)(),[h,i]=(0,e.useState)(()=>Date.now()),j=b?.status==="rejected"?"text-red-500":b?.status==="allowed_warning"?"text-yellow-500":"text-muted-foreground",k=b?.status==="rejected"?c("chat.rateLimitRejected","Rate Limited"):b?.status==="allowed_warning"?c("chat.rateLimitWarning","Approaching Limit"):null,l=a=>{if(!a)return"";let b=(a<1e12?1e3*a:a)-h;if(b<=0)return"";let c=Math.ceil(b/6e4);if(c<60)return`${c}m`;let d=Math.floor(c/60),e=c%60;return e>0?`${d}h${e}m`:`${d}h`},m=a=>a?a.replace(/_/g," "):"";return(0,d.jsx)("div",{className:"px-4 py-1.5 border-t border-border bg-secondary",children:(0,d.jsxs)("div",{className:"flex items-center justify-end gap-4 text-xs text-muted-foreground",children:[b&&k&&(0,d.jsxs)("span",{className:`flex items-center gap-1 ${j}`,title:[b.rateLimitType&&`Type: ${m(b.rateLimitType)}`,null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&`Resets in: ${l(b.resetsAt)}`,b.isUsingOverage&&"Using overage"].filter(Boolean).join(" \xb7 "),children:["rejected"===b.status?(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:[(0,d.jsx)("strong",{children:k}),null!=b.utilization&&` ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&` \xb7 ${l(b.resetsAt)}`]})]}),b&&!k&&b.resetsAt&&(0,d.jsxs)("span",{className:"flex items-center gap-1.5",title:[b.rateLimitType&&m(b.rateLimitType),null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,`Resets in: ${l(b.resetsAt)}`].filter(Boolean).join(" \xb7 "),children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),null!=b.utilization?(0,d.jsxs)("span",{children:[(100*b.utilization).toFixed(0),"%"]}):(0,d.jsx)("span",{children:l(b.resetsAt)})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsxs)("span",{children:[c("chat.context"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens).toLocaleString()})]})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),(0,d.jsxs)("span",{children:[c("chat.output"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:a.outputTokens.toLocaleString()})]})]}),(a.cacheReadInputTokens>0||a.cacheCreationInputTokens>0)&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-brand",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})}),(0,d.jsxs)("span",{children:["Cache: ",(a.cacheReadInputTokens/(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens)*100).toFixed(0),"%"]})]}),a.totalCostUsd>0&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-green-11",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:["$",a.totalCostUsd.toFixed(4)]})]})]})})}},62751:(a,b,c)=>{"use strict";function d(){}function e(a){return()=>{}}c.d(b,{U:()=>e,k:()=>d})},63041:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({cwd:a,sessionId:b,onOpenProjectSessions:c,onOpenSessionBrowser:h,onOpenSettings:i}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1);return(0,d.jsx)("div",{className:"border-b border-border px-4 py-3 bg-card",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6"}),(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"One seat. One AI. Everything under control."})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[a&&(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help",title:`CWD: ${a}`,children:a}),!a&&b&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Session: ",b.slice(0,8),"..."]}),a&&(0,d.jsx)("button",{onClick:c,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:h,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("sessions.browseAllSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),b&&(0,d.jsx)("button",{onClick:()=>{let a=`claude -r ${b}`;navigator.clipboard.writeText(a).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},className:`p-2 rounded-lg transition-colors ${k?"text-green-500 bg-green-500/10":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:k?j("chat.copiedCommandTooltip"):j("chat.copyCommandTooltip",{sessionId:b}),children:k?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),(0,d.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("settings.title"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})]})})}},63913:(a,b,c)=>{"use strict";c.a(a,async(a,b)=>{try{var d=c(48249),e=c(3560),f=c(56696),g=c(74493),h=a([f]);f=(h.then?(await h)():h)[0],(0,e.Aq)({type:"database",idPrefix:"db",match(a){let b=a.trim().toLowerCase();return b.startsWith("postgresql://")||b.startsWith("postgres://")},parse(a){let b=a.trim(),c=b;try{let a=new URL(b),d=a.pathname.replace(/^\//,"")||"postgres";c=`${d}@${a.hostname}${a.port?":"+a.port:""}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l}){return(0,d.jsx)(f.M,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l})},async onClose(a){await (0,g.ax)("db",a.id)}}),b()}catch(a){b(a)}})},63963:(a,b,c)=>{"use strict";c.d(b,{AS:()=>w,HV:()=>t,If:()=>u,RS:()=>p,TN:()=>q,mO:()=>s,tr:()=>r});let d=null,e="",f=0,g=null,h=!1,i=new Map,j=null,k=null;function l(a){let b;try{b=JSON.parse(a.data)}catch{return}let c=b.type;if("ping"===c)return;if("running"===c){j&&(j(b.commands),j=null);return}let d=b.commandId;if(!d)return;let e=i.get(d);if(e){if("error"===c)e.onError(b.error);else{let{commandId:a,type:d,...f}=b;e.onData(c,f)}("exit"===c||"error"===c)&&i.delete(d)}}function m(a){d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify(a))}function n(a){let b,c=(b="https:"===window.location.protocol?"wss:":"ws:",`${b}//${window.location.host}/ws/terminal?projectCwd=${encodeURIComponent(a)}`);e===c&&d||(w(),h=!1,e=c,function a(){if(h||!e)return;let b=new WebSocket(e);d=b,b.onopen=()=>{for(let a of(f=0,i.keys()))b.send(JSON.stringify({type:"attach",commandId:a}))},b.onmessage=l,b.onclose=()=>{if(d!==b||(d=null,h))return;g&&clearTimeout(g);let c=Math.min(1e3*Math.pow(1.5,f),1e4);f++,g=setTimeout(a,c)},b.onerror=()=>{}}())}function o(){return new Promise((a,b)=>{if(d?.readyState===WebSocket.OPEN)return void a();let c=setInterval(()=>{d?.readyState===WebSocket.OPEN&&(clearInterval(c),clearTimeout(e),a())},50),e=setTimeout(()=>{clearInterval(c),b(Error("WebSocket connection timeout"))},5e3)})}async function p(a){let{cwd:b,command:c,commandId:d,tabId:e,projectCwd:f,env:g,usePty:h,cols:j,rows:k,sourceId:l,onData:p,onError:q}=a;n(f);try{await o()}catch{q("WebSocket connection failed");return}i.delete(d),i.set(d,{onData:p,onError:q}),m({type:"exec",commandId:d,command:c,cwd:b,tabId:e,env:g,...h?{usePty:!0}:{},...j?{cols:j,rows:k}:{},...l?{sourceId:l}:{}})}async function q(a){let{commandId:b,projectCwd:c,onData:d,onError:e}=a;n(c);try{await o()}catch{e("WebSocket connection failed");return}i.set(b,{onData:d,onError:e}),m({type:"attach",commandId:b})}function r(a,b){m({type:"stdin",commandId:a,data:b})}function s(a,b,c){m({type:"resize",commandId:a,cols:b,rows:c})}function t(a){m({type:"interrupt",pid:a})}function u(a){return k||(k=v(a))}async function v(a){try{n(a);try{await o()}catch{return[]}return await new Promise(a=>{j=b=>{a(b)},m({type:"running"}),setTimeout(()=>{j&&(j=null,a([]))},3e3)})}finally{k=null}}function w(){if(h=!0,g&&(clearTimeout(g),g=null),d){let a=d;d=null,a.close()}i.clear(),j&&(j([]),j=null),k=null,e="",f=0}},64340:(a,b,c)=>{"use strict";c.d(b,{r:()=>e});var d=c(67484);function e(){let[a,b]=(0,d.useState)(),[c,e]=(0,d.useState)(),f=!!a&&!!c&&function(a,b){let c=a=>a.replace(/^v/,"").split("-")[0].split(".").map(a=>parseInt(a,10)||0),d=c(a),e=c(b),f=Math.max(d.length,e.length);for(let a=0;a<f;a++){let b=d[a]??0,c=e[a]??0;if(b!==c)return b-c}return 0}(c,a)>0;return{current:a,latest:c,hasUpdate:f}}c(33281),c(65484)},65395:(a,b,c)=>{"use strict";c.d(b,{useTabState:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call useTabState() from the server but useTabState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","useTabState")},65484:(a,b,c)=>{"use strict";c.d(b,{Cq:()=>n,D0:()=>q,DZ:()=>i,H7:()=>o,It:()=>s,Kl:()=>w,M5:()=>h,Or:()=>k,Q1:()=>u,QW:()=>p,Wr:()=>j,Yn:()=>r,b2:()=>v,em:()=>t,zF:()=>m});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=()=>f("/api/settings"),i=a=>f("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),j=()=>f("/api/version"),k=()=>f("/api/extension/version"),l=a=>a?`/api/note?cwd=${encodeURIComponent(a)}`:"/api/note",m=a=>f(l(a)),n=(a,b)=>g(l(a),{content:b}),o=()=>f("/api/sessions/projects"),p=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),q=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),r=a=>g("/api/project-settings",a),s=()=>f("/api/pick-folder"),t=a=>g("/api/open-vscode",{cwd:a}),u=a=>g("/api/open-cursor",{cwd:a}),v=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),w=a=>g("/api/git/worktree",a)},65543:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});let d=new Set(["function","class","method"]);function e(a){return d.has(a.kind)}},67045:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(48249);function e({error:a,reset:b}){return(0,d.jsx)("html",{children:(0,d.jsx)("body",{children:(0,d.jsxs)("div",{style:{padding:"2rem",fontFamily:"system-ui, sans-serif"},children:[(0,d.jsx)("h2",{children:"Something went wrong"}),(0,d.jsx)("p",{style:{color:"#666"},children:a.message}),(0,d.jsx)("button",{onClick:b,style:{marginTop:"1rem",padding:"0.5rem 1rem",cursor:"pointer",borderRadius:"0.375rem",border:"1px solid #ccc",background:"#fff"},children:"Try again"})]})})})}},67115:(a,b,c)=>{"use strict";c.d(b,{Q:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(57031),h=c(88214),i=c(33281),j=c(41224);function k({isOpen:a,onClose:b,cwd:c,onSelectSession:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)(""),v=(0,e.useRef)(null);(0,e.useCallback)(async()=>{if(!c)return;q(!0),s(null);let a=c.replace(/\//g,"-"),b=await i.t4.runPromiseExit((0,j.QW)(a));"Success"===b._tag?o(b.value):s("Failed to load sessions"),q(!1)},[c]);let w=n.filter(a=>{if(!t)return!0;let b=t.toLowerCase();return void 0!==a.searchText?a.searchText.includes(b):a.title.toLowerCase().includes(b)||a.firstMessages.some(a=>a.toLowerCase().includes(b))||a.lastMessages.some(a=>a.toLowerCase().includes(b))});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:b}),(0,d.jsxs)("div",{className:"relative w-full max-w-7xl h-[90vh] mx-4 bg-card rounded-lg shadow-xl flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:m("sessions.sessionList")}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:c,children:c})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsx)("input",{ref:v,type:"text",placeholder:m("sessions.searchSessions"),value:t,onChange:a=>u(a.target.value),className:"px-2 py-1 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[p&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:m("sessions.loadingSessions")})]})}),r&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:r})}),!p&&!r&&0===w.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:m(t?"sessions.noMatchingSessions":"sessions.noSessionsYet")})}),!p&&!r&&w.length>0&&(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:w.map(a=>(0,d.jsxs)("div",{onClick:()=>{let d;return d=(a.path.split("/").pop()||"").replace(".jsonl",""),void(l?(l(d,a.title),b()):(0,g.F)(h.n.OpenProject,{cwd:c,sessionId:d}))},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[a.engine&&"claude"!==a.engine&&(0,d.jsx)("span",{className:`shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded ${"claude2"===a.engine?"bg-orange-500/15 text-orange-11":"ollama"===a.engine?"bg-blue-500/15 text-blue-11":"codex"===a.engine?"bg-green-500/15 text-green-11":"kimi"===a.engine?"bg-purple-500/15 text-purple-11":"bg-muted text-muted-foreground"}`,children:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate",title:a.title,children:a.title})]}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(a.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[a.firstMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`first-${b}`)),a.lastMessages.length>0&&(0,d.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),a.lastMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`last-${b}`))]})]},a.path))})]})]})]}):null}},69424:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(44256),j=c(74118),k=c(15273),l=c(46674),m=c(99941),n=c(44643),o=c(32026),p=c(11732),q=c(75513),r=a([q]);function s(a){let b=a.input?.questions||[],c=a.input?.answers||{},d={};if(a.result)try{let b=JSON.parse(a.result);b?.answers&&(d=b.answers)}catch{}return{questions:b,answers:{...c,...d}}}function t({toolCalls:a,onClose:b}){let{t:c}=(0,g.Bd)(),d=(0,q.nH)(),[r,u]=(0,f.useState)({}),[v,w]=(0,f.useState)({}),[x,y]=(0,f.useState)({}),[z,A]=(0,f.useState)({}),B=a.reduce((a,b)=>{let{questions:c}=s(b);return a+c.length},0),C=Object.values(z).filter(Boolean).length,D=(0,f.useCallback)((a,b)=>{u(c=>({...c,[a]:b})),w(b=>({...b,[a]:!1}))},[]),E=(0,f.useCallback)(a=>{w(b=>{let c=!b[a];if(c){let b=x[a]||"";b&&u(c=>({...c,[a]:b}))}return{...b,[a]:c}})},[x]),F=(0,f.useCallback)((a,b)=>{y(c=>({...c,[a]:b})),b&&u(c=>({...c,[a]:b}))},[]),G=(0,f.useCallback)(a=>{A(b=>({...b,[a]:!b[a]}))},[]),H=(0,f.useCallback)(()=>{let b=C>0,d=[];return a.forEach((a,e)=>{let{questions:f}=s(a);f.forEach((a,f)=>{let g=`${e}-${f}`;if(b&&!z[g])return;let h=r[g];d.push(`Q: ${a.question}`),d.push(`A: ${h||c("askQuestion.notSelected")}`),d.push("")})}),d.join("\n").trim()},[a,r,z,C,c]),I=(0,f.useCallback)(()=>{navigator.clipboard.writeText(H()),(0,h.oR)(C>0?c("toast.copiedQA",{count:C}):c("toast.copiedAllQA"))},[H,C,c]),J=(0,f.useCallback)(()=>{d?(d.sendMessage(H()),(0,h.oR)(c("toast.sentQA")),b()):(0,h.oR)(c("askQuestion.sendNoChat"))},[d,H,b,c]),K=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:c("askQuestion.title")}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[c("askQuestion.nQuestions",{count:B}),C>0&&` \xb7 ${c("askQuestion.checkedN",{count:C})}`]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:J,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:C>0?c("askQuestion.sendChecked",{count:C}):c("askQuestion.sendAll"),children:(0,e.jsx)(j.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:I,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:C>0?c("askQuestion.copyChecked",{count:C}):c("askQuestion.copyAll"),children:(0,e.jsx)(k.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)(l.A,{className:"w-5 h-5"})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:a.map((b,d)=>{let{questions:f}=s(b);return f.map((b,g)=>{let h=`${d}-${g}`,i=r[h],j=v[h]||!1,k=z[h]||!1;return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-start gap-2",children:[(0,e.jsx)("button",{onClick:()=>G(h),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-accent transition-colors",title:c("askQuestion.checkToCopy"),children:k?(0,e.jsx)(m.A,{className:"w-4 h-4 text-brand"}):(0,e.jsx)(n.A,{className:"w-4 h-4 text-muted-foreground"})}),b.header&&(0,e.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:b.header}),(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:b.question})]}),(0,e.jsxs)("div",{className:"space-y-1 ml-7",children:[b.options.map((a,b)=>{let c=i===a.label&&!j;return(0,e.jsxs)("button",{onClick:()=>D(h,a.label),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${c?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,e.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:c?(0,e.jsx)(o.A,{className:"w-3.5 h-3.5 text-brand"}):(0,e.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("div",{className:`text-sm ${c?"text-foreground font-medium":"text-foreground"}`,children:a.label}),a.description&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]})]},b)}),(0,e.jsxs)("button",{onClick:()=>E(h),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${j?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,e.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:j?(0,e.jsx)(o.A,{className:"w-3.5 h-3.5 text-brand"}):(0,e.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(p.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:c("askQuestion.custom")})]})]}),j&&(0,e.jsx)("div",{className:"ml-6 mt-1",children:(0,e.jsx)("input",{type:"text",autoFocus:!0,value:x[h]||"",onChange:a=>F(h,a.target.value),placeholder:c("askQuestion.customPlaceholder"),className:"w-full px-3 py-1.5 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-brand text-foreground placeholder:text-muted-foreground"})})]}),(d!==a.length-1||g!==f.length-1)&&(0,e.jsx)("div",{className:"border-b border-border/50 mt-3"})]},h)})})})]})});return(0,e.jsx)(i.ZL,{children:K})}q=(r.then?(await r)():r)[0],d()}catch(a){d(a)}})},70151:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>S});var e=c(48249),f=c(67484),g=c(74429),h=c(44256),i=c(33281),j=c(87808),k=c(85655),l=c(21538),m=c(35208),n=c(7833),o=c(24724),p=c(20586),q=c(7122),r=c(55287),s=c(60591),t=c(9804),u=c(73887),v=c(3353),w=c(25465),x=c(94239),y=c(29939),z=c(23860),A=c(90018),B=c(57014),C=c(94308),D=c(53036),E=c(6662),F=c(20291),G=c(58904),H=c(61632),I=c(76855),J=c(4857),K=c(44384),L=c(18921),M=c(28797),N=c(23881),O=c(21672),P=c(21482),Q=c(94192),R=a([G,H,p,o,l,A,w,u,r,B,m,x,P,O]);function S({onClose:a,cwd:b,initialTab:c="tree",tabSwitchTrigger:d,initialSearchQuery:R,searchQueryTrigger:T}){let{t:U}=(0,K.Bd)(),{activeView:V,onViewChange:W}=(0,Q.R8)(),[X,Y]=(0,f.useState)(c),[Z,$]=(0,f.useState)("code"),_=(0,f.useRef)(null),aa=(0,f.useRef)(!1),[ab,ac]=(0,f.useState)(null),[ad,ae]=(0,f.useState)(null),[af,ag]=(0,f.useState)(!1),ah=(0,f.useRef)(1),ai=(0,f.useRef)(null),[aj,ak]=(0,f.useState)(null),al=(0,f.useRef)(null),[am,an]=(0,f.useState)({isDirty:!1,isSaving:!1}),[ao,ap]=(0,f.useState)(!1),[aq,ar]=(0,f.useState)(!1),[as,at]=(0,f.useState)(null),au=(0,f.useRef)(null),av=(0,L.o)(au),aw=(0,f.useRef)(null),ax=(0,L.o)(aw),ay=(0,I.Sn)(b),az=(0,I.Xm)(b),aA=(0,I.po)(b),aB=(0,J.Q)(),aC=(0,z.F)(),aD=(0,E.W)({cwd:b});(0,I.JL)(b,aD.selectedPath);let aE=(0,F.p)({cwd:b,onSearchComplete:()=>ap(!0)}),aF=(0,G.e)({cwd:b,addToRecentFiles:aD.addToRecentFiles}),aG=(0,f.useMemo)(()=>{let a=new Set;if(aF.status){for(let b of aF.status.staged)a.add(b.path);for(let b of aF.status.unstaged)a.add(b.path)}return a},[aF.status]),aH=(0,f.useMemo)(()=>{let a=new Map;if(aF.status){for(let b of aF.status.staged)a.set(b.path,"staged");for(let b of aF.status.unstaged)a.set(b.path,"unstaged")}return a},[aF.status]),aI=(0,H.y)({cwd:b,addToRecentFiles:aD.addToRecentFiles}),aJ=(0,f.useRef)(!1),aK=(0,f.useCallback)(a=>{aD.setFileContent(b=>b?.type==="text"?{...b,content:a}:b),aD.showEditor||(aJ.current=!0,aD.setShowEditor(!0))},[aD]),aL=(0,f.useCallback)(a=>{aD.setShowEditor(!0)},[aD]),aM=(0,f.useCallback)(async()=>{if(!aD.fileContent||"text"!==aD.fileContent.type||!aD.fileContent.content)return;let a=await i.t4.runPromiseExit((0,j.OJ)({cwd:b,path:aD.selectedPath,content:aD.fileContent.content}));try{if("Failure"===a._tag||!a.value.ok)throw Error("Failed to save file");let b=a.value.data?.mtime;b&&aD.setFileContent(a=>a?.type==="text"?{...a,mtime:b}:a),(0,n.oR)(U("toast.savedSuccess"),"success")}catch{(0,n.oR)(U("toast.saveFailed"),"error")}},[b,aD]),aN=(0,f.useCallback)(()=>{if(!aD.selectedPath)return;let a=ah.current,b=ai.current;a>0&&aD.updateRecentFilePosition(aD.selectedPath,a,b?b.cursorLine+1:a,b?b.cursorCol+1:1)},[aD]),aO=(0,f.useCallback)(async(a,b)=>{let c=a!==aD.selectedPath;if(c&&aD.showEditor){if(am.isDirty&&(!await (0,n.lJ)(U("fileBrowser.saveBeforeSwitch"),{confirmText:U("fileBrowser.saveAndSwitch"),cancelText:U("common.cancel")})||(await al.current?.save(),al.current?.isDirty)))return;aD.setShowEditor(!1)}c&&aN(),aD.handleSelectFile(a,b)},[aD,aN,am.isDirty,U]),aP=(0,f.useMemo)(()=>{let a=aE.contentSearchResults;if(0===a.length)return{files:[],expandDirs:new Set,matchMap:new Map};let b=new Map,c=[];for(let d of a)b.set(d.path,d),c.push(d.path);let d=(0,t.v3)(c),e=new Set((0,t.tW)(d));return{files:d,expandDirs:e,matchMap:b}},[aE.contentSearchResults]),[aQ,aR]=(0,f.useState)(new Set),aS=(0,f.useCallback)(a=>{aR(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),aT=(0,f.useCallback)(a=>{if(a.isDirectory)return null;let b=aP.matchMap.get(a.path);return b?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:b.matches.length}):null},[aP.matchMap]),aU=ao&&aE.contentSearchResults.length>0,[aV,aW]=(0,f.useState)("selected"),aX=!!aD.selectedPath&&null!==(0,M.c)(aD.selectedPath),aY=(0,f.useCallback)(async(a,c)=>{if(!aD.selectedPath||!aX)return;let d=await ay.goToDefinition(aD.selectedPath,a,c);if(0===d.length)return;let e=d[0],f=b.endsWith("/")?b:b+"/",g=e.file.startsWith(f)?e.file.slice(f.length):e.file;aB.push({filePath:aD.selectedPath,lineNumber:ah.current}),g===aD.selectedPath?aD.setTargetLineNumber(e.line):aO(g,e.line)},[aD,b,aX,ay,aB]),aZ=(0,f.useCallback)((a,b,c)=>{aD.selectedPath&&aX&&az.onTokenMouseEnter(aD.selectedPath,a,b,c)},[aD.selectedPath,aX,az]),a$=(0,f.useCallback)(a=>{let c=b.endsWith("/")?b:b+"/",d=a.file.startsWith(c)?a.file.slice(c.length):a.file;aD.selectedPath&&aB.push({filePath:aD.selectedPath,lineNumber:ah.current}),d===aD.selectedPath?aD.setTargetLineNumber(a.line):aO(d,a.line)},[aD,b,aB]),a_=(0,f.useMemo)(()=>{if(!aF.status)return null;let a=new Map,b=a=>{switch(a){case"modified":default:return"M";case"added":return"A";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?"}};for(let c of aF.status.staged)a.set(c.path,b(c.status));for(let c of aF.status.unstaged)a.set(c.path,b(c.status));return a},[aF.status]),a0=(0,f.useCallback)(a=>{Y(a),aD.setBlameSelectedCommit(null),"history"===a&&aI.selectedBranch&&aI.loadCommits(aI.selectedBranch)},[aD,aI.selectedBranch,aI.loadCommits]);(0,f.useCallback)(()=>{if(!aD.selectedPath)return;let a={filePath:aD.selectedPath,lineNumber:ah.current},b=aB.goBack(a);b&&(b.filePath===aD.selectedPath?aD.setTargetLineNumber(b.lineNumber):aO(b.filePath,b.lineNumber))},[aD,aB]),(0,f.useCallback)(()=>{if(!aD.selectedPath)return;let a={filePath:aD.selectedPath,lineNumber:ah.current},b=aB.goForward(a);b&&(b.filePath===aD.selectedPath?aD.setTargetLineNumber(b.lineNumber):aO(b.filePath,b.lineNumber))},[aD,aB]);let a1=(0,f.useCallback)(async a=>{let c=a.split("/").pop()||a,d=await i.t4.runPromiseExit((0,j.__)({cwd:b,paths:[a],op:"copy"}));"Success"===d._tag?(0,n.oR)(U("toast.copiedName",{name:c}),"success"):(0,n.oR)(U("toast.copyFailed"),"error")},[b,U]),a2=(0,f.useCallback)(async a=>{let c=await i.t4.runPromiseExit((0,j.dt)());if("Success"!==c._tag||!c.value.path)return void(0,n.oR)(U("toast.noFileToPaste"),"info");let d=c.value.path,e=await i.t4.runPromiseExit((0,j.Nn)({cwd:b,targetDir:a,sourceAbsPath:d}));if("Success"===e._tag)(0,n.oR)(U("toast.pastedFile",{name:e.value.newName}),"success"),aD.loadDirectory(a),aD.loadFileIndex();else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:U("toast.pasteFailed");(0,n.oR)(c,"error")}},[b,aD,U]);(0,f.useRef)(0),(0,f.useRef)(aC),(0,f.useRef)(X);let a3=(0,f.useRef)(aI.selectedBranch);a3.current=aI.selectedBranch;let a4=(0,f.useRef)(aD.selectedPath);a4.current=aD.selectedPath;let a5=(0,f.useRef)(aD.fileContent?.type);a5.current=aD.fileContent?.type;let a6=(0,f.useCallback)(async a=>{try{let{data:c}=a;if(!c)return;let d=c.some(a=>"git"===a.type),e=c.some(a=>"file"===a.type),f=[];if((e||d)&&(f.push(i.t4.runPromise((0,j.mP)(b)).then(a=>{a.error||aD.setFiles(b=>(0,t.HR)(a.files??[],b))}).catch(()=>{})),f.push(i.t4.runPromise((0,j.DZ)(b)).then(a=>{a.paths&&aD.setFileIndex(a.paths)}).catch(()=>{})),f.push(i.t4.runPromise((0,j.r9)(b)).then(a=>{aD.setRecentFiles(a.files??[])}).catch(()=>{}))),d||e){f.push(i.t4.runPromise((0,k.lv)(b)).then(a=>{aF.setStatus(a);let b=(0,p.Do)(a.staged),c=(0,p.Do)(a.unstaged);aF.setStagedTree(b),aF.setUnstagedTree(c)}).catch(()=>{})),aF.refreshDiff(),d&&aI.loadBranches();let a=a3.current;a&&f.push(i.t4.runPromise((0,k.Bj)(b,a,t.B_)).then(a=>{let b=a.commits??[];aI.setCommits(b),aI.setHasMoreCommits(b.length>=t.B_)}).catch(()=>{}))}let g=a4.current,h=a5.current;g&&"text"===h&&f.push(i.t4.runPromise((0,j.K9)(b,g)).then(a=>{let b=a.ok?a.data:null;b&&"string"==typeof b.content&&aD.setFileContent({type:"text",content:b.content,size:b.size,mtime:b.mtimeMs,...b.isSymlink?{isSymlink:!0,symlinkTarget:b.symlinkTarget}:{}})}).catch(()=>{})),await Promise.all(f)}catch(a){console.error("File watch handler error:",a)}},[b]);(0,y.h)({url:`/ws/watch?cwd=${encodeURIComponent(b)}`,onMessage:a6,enabled:aC});let a7=(0,f.useCallback)(a=>{aO(a),aD.setShouldScrollToSelected(!0),Y("tree")},[aD,aO]),[a8,a9]=(0,f.useState)(null),ba=(0,f.useCallback)((a,b)=>{aD.setPreviewMarkdown(!0),a7(a),a9(b),b&&setTimeout(()=>a9(null),400)},[aD,a7]);return(0,e.jsxs)(q.SU,{container:ab,children:[(0,e.jsxs)("div",{ref:_,className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsxs)("div",{className:"w-80 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex border-b border-border",children:[(0,e.jsx)("button",{onClick:()=>a0("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===X?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:U("fileBrowser.directoryTree")}),(0,e.jsx)("button",{onClick:()=>a0("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===X?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:U("fileBrowser.searchTab")}),(0,e.jsx)("button",{onClick:()=>a0("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===X?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:U("fileBrowser.recentTab")}),(0,e.jsx)("button",{onClick:()=>a0("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===X?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:U("fileBrowser.changesTab")}),(0,e.jsx)("button",{onClick:()=>a0("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===X?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:U("fileBrowser.historyTab")})]}),"tree"===X&&(0,e.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:aD.searchInputRef,type:"text",value:aD.searchQuery,onChange:a=>aD.setSearchQuery(a.target.value),placeholder:U("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),aD.searchQuery&&(0,e.jsx)("button",{onClick:()=>aD.setSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:U("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>aD.setSearchDirExact(a=>!a),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${aD.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:aD.searchExactMatch?U("fileBrowser.exactMatchOn"):U("fileBrowser.exactMatchOff"),children:"ab"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>aD.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:U("fileBrowser.refreshTree"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:()=>aD.searchTreeExpandedPaths?aD.setSearchTreeExpandedPaths(new Set):aD.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:U("fileBrowser.collapseAll"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===X&&(0,e.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:aE.contentSearchInputRef,type:"text",value:aE.contentSearchQuery,onChange:a=>aE.setContentSearchQuery(a.target.value),onKeyDown:a=>{"Enter"===a.key&&aE.performContentSearch(aE.contentSearchQuery)},placeholder:U("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),aE.contentSearchQuery&&(0,e.jsx)("button",{onClick:()=>aE.setContentSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:U("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>aE.performContentSearch(aE.contentSearchQuery),disabled:aE.isSearching||!aE.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:aE.isSearching?"...":U("common.search")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:aE.searchOptions.caseSensitive,onChange:a=>aE.setSearchOptions(b=>({...b,caseSensitive:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:U("fileBrowser.caseSensitive")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:aE.searchOptions.wholeWord,onChange:a=>aE.setSearchOptions(b=>({...b,wholeWord:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:U("fileBrowser.wholeWord")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:aE.searchOptions.regex,onChange:a=>aE.setSearchOptions(b=>({...b,regex:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:U("fileBrowser.regex")})]}),(0,e.jsx)("input",{type:"text",value:aE.searchOptions.fileType,onChange:a=>aE.setSearchOptions(b=>({...b,fileType:a.target.value})),placeholder:U("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9"})]})]}),"history"===X&&(0,e.jsx)("div",{className:"p-3 border-b border-border",children:aI.compareMode?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,e.jsx)("span",{className:"truncate",children:aI.branches?.current||"HEAD"}),(0,e.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:"HEAD"})]}),(0,e.jsx)("button",{onClick:()=>aI.toggleCompareMode(!1),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors bg-brand text-white",title:U("fileBrowser.compareModeOff"),children:U("fileBrowser.compareMode")})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0 pl-1",children:"vs"}),(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(C.e,{branches:aI.branches,selectedBranch:aI.compareBaseBranch,onSelect:a=>{aI.setCompareBaseBranch(a),aI.loadCompareFiles(a)},isLoading:aI.isLoadingBranches,pinnedBranches:["origin/main",...aI.upstreamBranch&&"origin/main"!==aI.upstreamBranch?[aI.upstreamBranch]:[]]})})]})]}):(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(C.e,{branches:aI.branches,selectedBranch:aI.selectedBranch,onSelect:a=>{aI.setSelectedBranch(a)},isLoading:aI.isLoadingBranches,pinnedBranches:["origin/main",...aI.upstreamBranch&&"origin/main"!==aI.upstreamBranch?[aI.upstreamBranch]:[]]})}),(0,e.jsx)("button",{onClick:()=>aI.toggleCompareMode(!0),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors text-muted-foreground hover:text-foreground hover:bg-accent border border-border",title:U("fileBrowser.compareModeOn"),children:U("fileBrowser.compareMode")})]})}),(0,e.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,e.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===X?"":"hidden"}`,children:[aD.creatingItem&&(0,e.jsxs)("div",{className:"px-2 py-1.5 border-b border-border bg-secondary flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:aD.creatingItem.parentPath?U("fileBrowser.createFileIn",{path:aD.creatingItem.parentPath}):U("fileBrowser.createFile")}),(0,e.jsx)("input",{type:"text",autoFocus:!0,placeholder:U("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{aa.current=!0},onCompositionEnd:()=>{aa.current=!1},onKeyDown:async a=>{if("Enter"===a.key){if(aa.current)return;let c=a.target.value.trim();if(!c)return;let d=aD.creatingItem.parentPath,e=d?`${d}/${c}`:c,f=await i.t4.runPromiseExit((0,j.OJ)({cwd:b,path:e,content:""}));if("Success"===f._tag&&f.value.ok)(0,n.oR)(U("toast.createdFile",{name:c}),"success"),aD.setCreatingItem(null),aD.loadDirectory(d),aD.loadFileIndex(),d&&aD.setExpandedPaths(a=>new Set([...a,d])),aO(e);else if("Success"===f._tag){let a=f.value.data?.error;(0,n.oR)(a||U("toast.createFailed"),"error")}else(0,n.oR)(U("toast.createFailed"),"error")}else"Escape"===a.key&&aD.setCreatingItem(null)},onBlur:()=>aD.setCreatingItem(null)})]}),aD.isLoadingFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("common.loading")}):aD.fileError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:aD.fileError}):(0,e.jsx)(o.h,{files:aD.files,selectedPath:aD.selectedPath,expandedPaths:aD.effectiveExpandedPaths,matchedPaths:aD.matchedPaths,gitStatusMap:a_,loadingDirs:aD.loadingDirs,onSelect:a=>{aD.setShouldScrollToSelected(!1),aO(a)},onToggle:aD.handleToggle,cwd:b,shouldScrollToSelected:aD.shouldScrollToSelected,onScrolledToSelected:()=>aD.setShouldScrollToSelected(!1),onCreateFile:a=>aD.setCreatingItem({type:"file",parentPath:a}),onDelete:(a,b,c)=>ae({path:a,isDirectory:b,name:c}),onRefresh:()=>aD.loadFiles(),onCopyFile:a1,onPaste:a2})]}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===X?"":"hidden"}`,children:aE.isSearching?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aE.searchError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:aE.searchError}):0===aE.contentSearchResults.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:aE.contentSearchQuery?U("fileBrowser.noContentSearchResults"):U("fileBrowser.enterKeywordToSearch")}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[aE.searchStats&&(0,e.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-secondary border-b border-border flex-shrink-0",children:[U("fileBrowser.nFilesNMatches",{files:aE.searchStats.totalFiles,matches:aE.searchStats.totalMatches}),aE.searchStats.truncated&&(0,e.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",U("fileBrowser.resultsTruncated"),")"]})]}),(0,e.jsx)(o.h,{files:aP.files,selectedPath:aD.selectedPath,expandedPaths:aQ,onSelect:a=>{let b=aP.matchMap.get(a);aO(a,b?.matches[0]?.lineNumber),ao||ap(!0)},onToggle:aS,cwd:b,renderActions:aT,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===X?"":"hidden"}`,children:0===aD.recentFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("fileBrowser.noRecentFiles")}):(0,e.jsx)(o.h,{files:aD.recentFilesTree,selectedPath:aD.selectedPath,expandedPaths:aD.recentTreeDirPaths,onSelect:aO,onToggle:t.tE,cwd:b})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===X?"":"hidden"}`,children:aF.statusLoading?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aF.statusError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,e.jsx)("span",{className:"text-red-11 text-sm",children:aF.statusError})}):(0,e.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,e.jsxs)("div",{className:"border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:U("fileBrowser.stagingArea",{count:aF.status?.staged.length||0})}),(0,e.jsx)("button",{onClick:()=>aF.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:U("fileBrowser.refreshChanges"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})})]}),(aF.status?.staged.length||0)>0&&(0,e.jsx)("button",{onClick:aF.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:U("fileBrowser.unstageAll")})]}),(0,e.jsx)(p.VO,{files:aF.stagedTree,selectedPath:aF.statusSelectedFile?.type==="staged"?aF.statusSelectedFile.file.path:null,expandedPaths:aF.stagedExpandedPaths,onSelect:a=>a.file&&aF.handleStatusFileSelect(a.file,"staged"),onToggle:aF.handleStagedToggle,cwd:b,emptyMessage:U("fileBrowser.noStagedFiles"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,p.wI)(a);return 0===b.length?null:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aF.handleUnstageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:U("fileBrowser.unstageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),aF.handleUnstage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:U("fileBrowser.unstageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:U("fileBrowser.workspace",{count:aF.status?.unstaged.length||0})}),(aF.status?.unstaged.length||0)>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:aF.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:U("fileBrowser.discardAll")}),(0,e.jsx)("button",{onClick:aF.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:U("fileBrowser.stageAll")})]})]}),(0,e.jsx)(p.VO,{files:aF.unstagedTree,selectedPath:aF.statusSelectedFile?.type==="unstaged"?aF.statusSelectedFile.file.path:null,expandedPaths:aF.unstagedExpandedPaths,onSelect:a=>a.file&&aF.handleStatusFileSelect(a.file,"unstaged"),onToggle:aF.handleUnstagedToggle,cwd:b,emptyMessage:U("fileBrowser.noUnstagedChanges"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,p.wI)(a);if(0===b.length)return null;let c=b.map(a=>a.file).filter(Boolean);return(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aF.handleDiscardFiles(c)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:U("fileBrowser.discardNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aF.handleStageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:U("fileBrowser.stageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return a.file?(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),aF.handleDiscardFile(a.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:U("fileBrowser.discardChanges"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),aF.handleStage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:U("fileBrowser.stageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===X?"":"hidden"}`,children:aI.historyError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,e.jsx)("p",{className:"text-muted-foreground",children:aI.historyError})]})}):aI.compareMode?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:aI.isLoadingCompareFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("fileBrowser.loadingDiff")}):0===aI.compareFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("fileBrowser.noDiffFiles")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:U("fileBrowser.nFilesChanged",{count:aI.compareFiles.length,branch:aI.compareBaseBranch})})}),(0,e.jsx)(p.VO,{files:aI.compareFileTree,expandedPaths:aI.compareExpandedPaths,onToggle:aI.handleCompareToggle,selectedPath:aI.compareSelectedFile?.path||null,onSelect:a=>{a.file&&aI.handleSelectCompareFile(a.file)},cwd:b,showChanges:!0})]})}):(0,e.jsx)("div",{ref:aI.commitListRef,className:"flex-1 overflow-y-auto",onScroll:aI.handleCommitListScroll,children:aI.isLoadingCommits?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("fileBrowser.loadingCommits")}):0===aI.commits.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("fileBrowser.noCommits")}):(0,e.jsxs)(e.Fragment,{children:[aI.commits.map(a=>(0,e.jsxs)("div",{onClick:()=>aI.handleSelectCommit(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-accent ${aI.selectedCommit?.hash===a.hash?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),(0,e.jsxs)("span",{className:"text-xs text-slate-9",title:a.date,children:[a.relativeDate," \xb7 ",(0,t.r6)(a.date)]})]}),(0,e.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":a.subject,children:a.subject}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.author})]},a.hash)),aI.isLoadingMore&&(0,e.jsx)("div",{className:"p-3 text-center",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!aI.hasMoreCommits&&aI.commits.length>0&&(0,e.jsx)("div",{className:"p-3 text-center text-xs text-slate-9",children:U("fileBrowser.allLoaded",{count:aI.commits.length})})]})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[("tree"===X||"search"===X||"recent"===X)&&(aD.blameSelectedCommit?(0,e.jsx)(l.n,{isOpen:!0,onClose:()=>aD.setBlameSelectedCommit(null),commit:aD.blameSelectedCommit,cwd:b,embedded:!0,initialFilePath:aD.selectedPath||void 0,onContentSearch:a=>{Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)}}):"map"===Z?(0,e.jsx)(A.O,{cwd:b,highlightedFilePath:aD.selectedPath,changedFiles:aG,onSwitchToCode:()=>$("code"),enableComments:!0,onContentSearch:a=>{Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)},headerExtraLeft:({focalFile:a})=>a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${b}/${a}`),(0,n.oR)(U("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:U("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:b=>{b.stopPropagation(),a7(a)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:U("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]})}):aD.selectedPath?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:aD.selectedPath}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${aD.selectedPath}`),(0,n.oR)(U("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:U("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:a=>{a.stopPropagation(),a7(aD.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:U("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:aD.showEditor?(0,e.jsxs)(e.Fragment,{children:[am.isDirty&&(0,e.jsx)("span",{className:"text-xs text-amber-11",children:U("fileBrowser.unsaved")}),(0,e.jsx)("button",{onClick:()=>al.current?.save(),disabled:!am.isDirty||am.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${am.isDirty&&!am.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:am.isSaving?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):U("common.save")}),(0,e.jsx)("button",{onClick:()=>al.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:U("fileBrowser.closeEdit"),children:U("fileBrowser.closeBtn")})]}):(0,e.jsxs)(e.Fragment,{children:[aD.fileContent?.type==="text"&&(0,s.e$)(aD.selectedPath)&&(0,e.jsx)(w.ShareReviewToggle,{content:aD.fileContent.content||"",sourceFile:aD.selectedPath&&b&&aD.selectedPath.startsWith(b)?aD.selectedPath.slice(b.endsWith("/")?b.length:b.length+1):aD.selectedPath||""}),aD.selectedPath?.endsWith(".json")&&aD.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>ar(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aq?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,title:U("fileBrowser.toggleJsonReadable"),children:U("common.readable")}),aD.fileContent?.type==="text"&&((0,s.e$)(aD.selectedPath)||(0,s.aR)(aD.selectedPath))&&(0,e.jsx)(e.Fragment,{children:(0,e.jsx)("button",{onClick:()=>aD.setPreviewMarkdown(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aD.previewMarkdown?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,title:aD.previewMarkdown?U("fileBrowser.exitPreview"):U("common.preview"),children:aD.previewMarkdown?U("fileBrowser.exitPreview"):U("common.preview")})}),aD.fileContent?.type==="text"&&!(aD.previewMarkdown&&((0,s.e$)(aD.selectedPath)||(0,s.aR)(aD.selectedPath)))&&(0,e.jsx)("button",{onClick:aD.handleToggleBlame,disabled:aD.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aD.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-accent"} disabled:opacity-50`,title:U("fileBrowser.viewBlame"),children:aD.isLoadingBlame?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),aD.fileContent?.type==="text"&&!(aD.previewMarkdown&&((0,s.e$)(aD.selectedPath)||(0,s.aR)(aD.selectedPath)))&&(0,e.jsx)("button",{onClick:()=>aD.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:U("fileBrowser.editFile"),children:U("common.edit")}),aD.fileContent?.type==="text"&&aD.fileContent.content&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(aD.fileContent.content),(0,n.oR)(U("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:U("fileBrowser.copyFileContent"),children:U("common.copy")}),aD.fileContent?.type==="text"&&!(0,s.e$)(aD.selectedPath)&&!(0,s.aR)(aD.selectedPath)&&(0,e.jsx)("button",{onClick:()=>$("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:U("blockViewer.viewerToggle.toBlock"),children:U("common.codeMap")})]})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:aD.isLoadingContent?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aD.fileContent?"text"===aD.fileContent.type&&"string"==typeof aD.fileContent.content?aD.showBlame&&aD.blameError?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-red-11",children:aD.blameError}),(0,e.jsx)("button",{onClick:()=>aD.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:U("fileBrowser.backToPreview")})]})}):aD.showBlame&&0===aD.blameLines.length&&aD.isLoadingBlame?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aq&&aD.selectedPath?.endsWith(".json")?(0,e.jsxs)("div",{className:"h-full flex flex-col bg-[#0d1117]",children:[(0,e.jsx)(L._,{search:av}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,e.jsx)("pre",{ref:au,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,s.xb)(aD.fileContent.content)})})]}):aD.previewMarkdown&&(0,s.e$)(aD.selectedPath)&&!aD.showBlame?(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(u.M,{content:aD.fileContent.content,filePath:aD.selectedPath,cwd:b,embedded:!0,onLocalMdLink:ba,scrollToAnchor:a8})}):aD.previewMarkdown&&(0,s.aR)(aD.selectedPath)&&!aD.showBlame?(0,e.jsx)(v.E,{content:aD.fileContent.content,filePath:aD.selectedPath}):(0,e.jsx)(r.Cv,{ref:al,content:aD.fileContent.content,filePath:aD.selectedPath,cwd:b,enableComments:!0,scrollToLine:aj??aD.targetLineNumber,scrollToLineAlign:null!=aj?"start":aD.targetScrollAlign,onScrollToLineComplete:()=>{ak(null),aD.setTargetLineNumber(null)},highlightKeyword:"search"===X?aE.contentSearchQuery:null,visibleLineRef:ah,viStateRef:ai,initialCursorLine:aD.initialCursorLine,initialCursorCol:aD.initialCursorCol,onInitialCursorSet:()=>{aD.setInitialCursorLine(null),aD.setInitialCursorCol(null)},onCmdClick:aX?aY:void 0,onTokenHover:aX?aZ:void 0,onTokenHoverLeave:aX?az.onTokenMouseLeave:void 0,onTokenHoverCancel:aX?az.clearHover:void 0,blameLines:aD.showBlame&&aD.blameLines.length>0?aD.blameLines:void 0,inlineBlameLines:aD.blameLines.length>0?aD.blameLines:void 0,onSelectCommit:aD.setBlameSelectedCommit,editable:aD.showEditor,initialMtime:aD.fileContent.mtime,onEditorClose:a=>{aD.setShowEditor(!1),ak(a)},onSaved:()=>{let a=ah.current??1;aD.loadFileContent(aD.selectedPath),aD.setShowEditor(!1),ak(a)},onEditorStateChange:an,viMode:!0,onContentMutate:aK,onEnterInsertMode:aL,onViSave:aM,onContentSearch:a=>{Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)}}):"image"===aD.fileContent.type&&aD.selectedPath?(0,e.jsx)(D.I,{cwd:b,path:aD.selectedPath,refreshKey:aD.fileContent.mtime,alt:aD.selectedPath}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,e.jsx)("p",{children:aD.fileContent.message||U("fileBrowser.cannotPreview")})]})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:U("fileBrowser.selectFileToPreview")})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,e.jsx)("p",{children:U("fileBrowser.selectFileToPreview")})]})})),"status"===X&&(aF.statusSelectedFile&&aF.statusDiff?(0,e.jsx)(B.m,{cwd:b,selected:aF.statusSelectedFile,diff:aF.statusDiff,showMarkdownPreview:aF.showStatusDiffPreview,setShowMarkdownPreview:aF.setShowStatusDiffPreview,changedFiles:aG,fileGitStatusMap:aH,onContentSearch:a=>{Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)},locateInTree:a7,jsonPreview:as,setJsonPreview:at,jsonPreviewSearch:ax,jsonPreviewPreRef:aw}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:U("fileBrowser.selectFileToViewDiff")})})),"history"===X&&!aI.historyError&&(aI.compareMode?aI.isLoadingCompareDiff?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:U("fileBrowser.loadingDiffContent")}):aI.compareFileDiff?(0,e.jsx)(m.xZ,{oldContent:aI.compareFileDiff.oldContent,newContent:aI.compareFileDiff.newContent,filePath:aI.compareFileDiff.filePath,isNew:aI.compareFileDiff.isNew,isDeleted:aI.compareFileDiff.isDeleted,cwd:b,enableComments:!0,onPreview:!aI.compareFileDiff.isDeleted&&aI.compareFileDiff.filePath.endsWith(".json")?()=>at({content:aI.compareFileDiff.newContent,filePath:aI.compareFileDiff.filePath}):void 0,previewLabel:U("common.readable"),onContentSearch:a=>{Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:aI.compareFiles.length>0?U("fileBrowser.selectFileToViewDiff"):U("fileBrowser.clickCompareToLoad")})}):aI.selectedCommit?(0,e.jsx)(l.n,{isOpen:!0,onClose:()=>aI.setSelectedCommit(null),commit:aI.selectedCommit,cwd:b,embedded:!0,onContentSearch:a=>{Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:U("fileBrowser.selectCommitToView")})}))]})]}),af&&(0,e.jsx)(x.c,{files:aD.files,fileIndex:aD.fileIndex,recentFiles:aD.recentFilePaths,onSelectFile:a=>{aO(a),aD.setShouldScrollToSelected(!0),Y("tree")},onClose:()=>ag(!1)}),(aU||aA.visible)&&(0,e.jsxs)("div",{className:`flex ${aA.visible&&aU?"":"flex-col"}`,children:[aU&&(0,e.jsx)("div",{className:aA.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,e.jsx)(P.D,{results:aE.contentSearchResults,loading:aE.isSearching,totalMatches:aE.searchStats?.totalMatches??0,onSelect:(a,b)=>{aD.selectedPath&&aB.push({filePath:aD.selectedPath,lineNumber:ah.current}),aO(a,b)},onClose:()=>ap(!1),scope:aV,onScopeChange:aW,selectedPath:aD.selectedPath})}),aA.visible&&(0,e.jsx)("div",{className:aU?"flex-1 min-w-0":"",children:(0,e.jsx)(O.D,{references:aA.references,loading:aA.loading,onSelect:a$,onClose:aA.closeReferences})})]})]}),ad&&(0,e.jsx)(h.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-black/50",onClick:()=>ae(null),children:(0,e.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:U("fileBrowser.confirmDelete")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:U("fileBrowser.confirmDeleteMessage",{name:ad.name}).split(/<\/?file>/g).map((a,b)=>1===b?(0,e.jsx)("span",{className:"font-mono text-foreground",children:a},b):a)}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)("button",{onClick:()=>ae(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-accent transition-colors",children:U("common.cancel")}),(0,e.jsx)("button",{onClick:async()=>{let{path:a,name:c}=ad;ae(null);let d=await i.t4.runPromiseExit((0,j.VK)({cwd:b,path:a}));if("Success"===d._tag){(0,n.oR)(U("toast.movedToTrash",{name:c}),"success");let b=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"";aD.loadDirectory(b),aD.loadFileIndex(),aD.selectedPath===a&&aO("")}else{let a="Fail"===d.cause._tag?d.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:U("toast.deleteFailed");(0,n.oR)(c,"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:U("common.delete")})]})]})})}),az.hoverInfo&&ab&&(0,g.createPortal)((0,e.jsx)(N.s,{ref:az.setTooltipEl,displayString:az.hoverInfo.displayString,documentation:az.hoverInfo.documentation,x:az.hoverInfo.x,y:az.hoverInfo.y,container:ab,onMouseEnter:az.onCardMouseEnter,onMouseLeave:az.onCardMouseLeave,onFindReferences:()=>{let{filePath:a,line:b,column:c}=az.hoverInfo;az.clearHover(),aA.findReferences(a,b,c)},onSearch:a=>{az.clearHover(),Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)}}),ab)]})}[G,H,p,o,l,A,w,u,r,B,m,x,P,O]=R.then?(await R)():R,d()}catch(a){d(a)}})},70404:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484);function f(a,b){for(let c=0;c<a.blocks.length;c++){let d=a.blocks[c];if(b>=d.startLine&&b<=d.endLine)return a.prefix[c]+(b-d.startLine)}return null}function g({addedLines:a,blockRanges:b,viewportRange:c,onJumpToLine:h}){let i,j=(0,e.useRef)(null),k=(0,e.useMemo)(()=>(function(a){let b=[...a].sort((a,b)=>a.startLine-b.startLine),c=[0];for(let a of b){let b=Math.max(0,a.endLine-a.startLine+1);c.push(c[c.length-1]+b)}return{blocks:b,prefix:c,total:c[c.length-1]}})(b),[b]),l=(0,e.useMemo)(()=>{if(k.total<=0||0===a.size)return[];let b=[];for(let c of a){let a=k.blocks.find(a=>c>=a.startLine&&c<=a.endLine);a&&b.push({line:c,qname:a.qname})}b.sort((a,b)=>a.line-b.line);let c=[],d=null;for(let a of b)d&&a.line===d.end+1&&a.qname===d.qname?d.end=a.line:(d&&c.push(d),d={start:a.line,end:a.line,qname:a.qname});return d&&c.push(d),c},[a,k]);if(k.total<=0)return null;let m=(a,b)=>{let c=f(k,a),d=f(k,b);return null===c||null===d?null:{top:c/k.total*100,heightPct:(d-c+1)/k.total*100}};return(0,d.jsxs)("div",{ref:j,onClick:a=>{let b=j.current;if(!b)return;let c=b.getBoundingClientRect();if(c.height<=0)return;let d=function(a,b){if(a.total<=0)return null;let c=Math.max(0,Math.min(a.total-1,b));for(let b=0;b<a.blocks.length;b++){let d=a.prefix[b],e=a.prefix[b+1];if(c>=d&&c<e){let e=a.blocks[b];return{qname:e.qname,line:e.startLine+Math.round(c-d)}}}return null}(k,(a.clientY-c.top)/c.height*k.total);if(!d)return;let e=d.line,g=l.find(a=>a.qname===d.qname&&e>=a.start&&e<=a.end);if(g)return void h(g.qname,e);if(l.length>0){let a=Math.max(2,Math.round(.05*k.total)),b=f(k,e);if(null!==b){let c=null,d=1/0;for(let a of l){let e=f(k,a.start),g=f(k,a.end);if(null===e||null===g)continue;let h=b<e?e-b:b>g?b-g:0;h<d&&(c=a,d=h)}if(c&&d<=a){let a=e<c.start?c.start:e>c.end?c.end:e;h(c.qname,a);return}}}let i=k.blocks.find(a=>a.qname===d.qname);i&&h(i.qname,i.startLine)},className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",title:"Diff minimap — click to jump",children:[l.map(a=>{let b=m(a.start,a.end);return b?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-green-9 pointer-events-none",style:{top:`${b.top}%`,height:`${b.heightPct}%`,minHeight:"2px"}},`run:${a.qname}:${a.start}-${a.end}`):null}),c&&c.end>=c.start&&((i=m(c.start,c.end))?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border pointer-events-none",style:{top:`${i.top}%`,height:`${Math.max(1.2,i.heightPct)}%`}}):null)]})}},70440:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(88868);let e=async a=>[{type:"image/x-icon",sizes:"16x16",url:(0,d.fillMetadataSegment)(".",await a.params,"favicon.ico",!0)+"?603d046c9a6fdfbb"}]},70596:(a,b,c)=>{"use strict";c.d(b,{t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,comment:c,container:h,onClose:i,onUpdateComment:j,onDeleteComment:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(c.content),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({x:0,y:0}),t=async()=>{o.trim()&&(await j(c.id,o.trim()),n(!1))},u=async()=>{await k(c.id),i()};return(0,d.jsx)("div",{ref:q,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:r.x,top:r.y},children:(0,d.jsx)("div",{className:"p-3",children:m?(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("textarea",{value:o,onChange:a=>p(a.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:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),t()),"Escape"===a.key&&(n(!1),p(c.content))}}),(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>{n(!1),p(c.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:l("common.cancel")}),(0,d.jsx)("button",{onClick:t,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:l("common.save")})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:c.content}),(0,d.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:l("comments.lineRange",{start:c.startLine,end:c.endLine})}),(0,d.jsxs)("div",{className:"flex gap-1",children:[(0,d.jsx)("button",{onClick:()=>n(!0),className:"p-1 rounded hover:bg-accent text-muted-foreground",title:l("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:u,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-red-9",title:l("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})})]})]})]})})})}},71192:(a,b,c)=>{"use strict";c.d(b,{m_:()=>f,uV:()=>e});var d=c(81218);class e extends d.rN("AppError"){}d.rN("DBError"),d.rN("WSError"),d.rN("FSError"),d.rN("AgentError"),d.rN("ValidationError");class f extends d.rN("NotFoundError"){}d.rN("PermissionError")},72399:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectSidebar() from the server but ProjectSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/ProjectSidebar.tsx","ProjectSidebar")},72529:(a,b,c)=>{"use strict";c.d(b,{m:()=>f});var d=c(48249),e=c(67484);function f({content:a,children:b,className:c}){if(c)return(0,d.jsx)("div",{"data-tooltip":a,className:c,children:b});let g=e.Children.toArray(b);if(1===g.length&&(0,e.isValidElement)(g[0])){let b=g[0];return(0,e.cloneElement)(b,{"data-tooltip":a})}return(0,d.jsx)("div",{"data-tooltip":a,style:{display:"contents"},children:b})}},73414:(a,b,c)=>{"use strict";c.d(b,{YO:()=>d,pU:()=>e});let d=20;function e(a,b,c,f=[]){let g=a.length,h=c=>"unchanged"!==a[c].type||"unchanged"!==b[c].type,i=new Set;for(let a=0;a<g;a++){if(!h(a))continue;let b=Math.max(0,a-3),c=Math.min(g-1,a+3);for(let a=b;a<=c;a++)i.add(a)}let j=[];for(let a=0;a<g;a++){if(i.has(a))continue;let b=a;for(;a<g&&!i.has(a);)a++;j.push({id:j.length,startIdx:b,endIdx:a-1}),a--}for(let a of j){let b=c.get(a.id)??{topRevealed:0,bottomRevealed:0},d=a.endIdx-a.startIdx+1,e=Math.max(0,Math.min(b.topRevealed,d)),f=Math.max(0,Math.min(b.bottomRevealed,d-e));for(let b=a.startIdx;b<a.startIdx+e;b++)i.add(b);for(let b=a.endIdx-f+1;b<=a.endIdx;b++)i.add(b)}let k=[];for(let a=0;a<g;a++){let c;if(i.has(a)){k.push({kind:"diff",idx:a});continue}let e=a;for(;a<g&&!i.has(a);)a++;let h=a-1;a--;let l=j.find(a=>a.startIdx<=e&&h<=a.endIdx);if(!l)continue;let m=h-e+1,n=Math.min(d,m);if(f.length>0&&h+1<g)for(let a=h+1;a<g;a++){let d=b[a].lineNum;if(!(d<=0)){c=function(a,b){let c=null;for(let d of a)d.startLine<=b&&b<=d.endLine&&(!c||d.endLine-d.startLine<c.endLine-c.startLine)&&(c=d);return c}(f,d)??void 0;break}}k.push({kind:"gap-expand",gapId:l.id,direction:"up",revealCount:n}),k.push({kind:"gap-label",gapId:l.id,hiddenCount:m,enclosingFn:c}),k.push({kind:"gap-expand",gapId:l.id,direction:"down",revealCount:n})}return{rows:k,gaps:j}}},73887:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>w});var e=c(48249),f=c(67484),g=c(44384),h=c(74429),i=c(7122),j=c(41051),k=c(42140),l=c(70596),m=c(74754),n=c(7031),o=c(91579),p=c(98356),q=c(84835);c(15466);var r=c(60591),s=c(24680),t=c(25465),u=c(37690),v=a([t]);t=(v.then?(await v)():v)[0];let x=[q.W];function w({content:a,filePath:b,cwd:c,onClose:d,sourceFile:q,embedded:v=!1,onLocalMdLink:y,scrollToAnchor:z}){let A=q||(c&&b.startsWith(c)?b.slice(c.endsWith("/")?c.length:c.length+1):b),{t:B}=(0,g.Bd)(),C=(0,i.iN)(),D=(0,n.r)(),{comments:E,addComment:F,updateComment:G,deleteComment:H,refresh:I}=(0,m._)({cwd:c,filePath:b}),[J,K]=(0,f.useState)(!1),[L,M]=(0,f.useState)(null),[N,O]=(0,f.useState)(null),[P,Q]=(0,f.useState)(null),R=(0,f.useMemo)(()=>a.split("\n"),[a]),[S,T]=(0,f.useState)(null),U=(0,f.useRef)(null),V=(0,f.useCallback)(a=>{if(!y||/^[a-z][a-z0-9+.-]*:/i.test(a))return!1;let b=a.indexOf("#"),c=b>=0?a.slice(0,b):a,d=b>=0?a.slice(b+1):null;if(!c)return!1;let e=c;try{e=decodeURIComponent(c)}catch{}return!!(0,r.e$)(e)&&(y((0,r.WU)(A,e),d),!0)},[y,A]),{toolbarRef:W,bumpRef:X,clearToolbar:Y}=(0,u.L)({enabled:!0,container:S,resolveLineRange:a=>{let b=function(a){let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a;if(!b||!("closest"in b))return null;let c=b.closest("[data-source-start]");if(!c)return null;let d=c.getAttribute("data-source-start"),e=c.getAttribute("data-source-end");return d&&e?{start:parseInt(d,10),end:parseInt(e,10)}:null}(a);return b?{start:b.start,end:b.end}:null},buildLineSnapshot:({start:a,end:b})=>{let c=Math.max(0,a-1),d=Math.min(R.length,b);return R.slice(c,d).join("\n")}}),Z=(0,f.useCallback)(()=>{let a=W.current;a&&(M({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),Y())},[Y,W]),$=(0,f.useCallback)(()=>{let a=W.current;a&&(O({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),Y())},[Y,W]),_=(0,f.useCallback)(async a=>{L&&(await F(L.range.start,L.range.end,a,L.selectedText),M(null))},[L,F]),aa=(0,f.useCallback)(async a=>{if(N&&D)try{let d=await (0,o.$3)(c),e=[];for(let a of d)e.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});e.push({filePath:b,startLine:N.range.start,endLine:N.range.end,codeContent:N.lineSnapshot});let f=(0,o.Gw)(e,a);D.sendMessage(f),await (0,o.RP)(c),I(),O(null)}catch(a){console.error("Failed to send to AI:",a)}},[N,D,b,c,I]);(0,f.useMemo)(()=>{if(0===E.length)return[];let a=new Map;for(let b of E){let c=`${b.startLine}-${b.endLine}`;a.has(c)||a.set(c,[]),a.get(c).push(b)}return Array.from(a.entries()).map(([a,b])=>({key:a,startLine:b[0].startLine,endLine:b[0].endLine,comments:b}))},[E]);let[ab,ac]=(0,f.useState)([]);return(0,e.jsxs)(e.Fragment,{children:[!v&&(0,e.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:b}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(t.ShareReviewToggle,{content:a,sourceFile:A}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:B("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)(s.l,{content:a,containerRef:U}),(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:U,children:[(0,e.jsx)("div",{className:"p-6",children:(0,e.jsx)(p.T,{content:a,rehypePlugins:x,onLinkClick:V})}),ab.map(({key:a,top:b,comments:c})=>(0,e.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:b},onClick:a=>{a.stopPropagation(),Q({comment:c[0],x:a.clientX,y:a.clientY})},children:(0,e.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-sm hover:bg-amber-500 transition-colors",children:c.length})},a))]})]}),J&&C&&(0,h.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(j.f,{floatingToolbarRef:W,bumpRef:X,container:C,onAddComment:Z,onSendToAI:$,isChatLoading:D?.isLoading}),L&&(0,e.jsx)(k.t,{x:L.x,y:L.y,range:L.range,lineSnapshot:L.lineSnapshot,container:C,onSubmit:_,onClose:()=>M(null)}),N&&(0,e.jsx)(k.G,{x:N.x,y:N.y,range:N.range,filePath:b,lineSnapshot:N.lineSnapshot,container:C,onSubmit:aa,onClose:()=>O(null),isChatLoading:D?.isLoading}),P&&(0,e.jsx)(l.t,{x:P.x,y:P.y,comment:P.comment,container:C,onClose:()=>Q(null),onUpdateComment:G,onDeleteComment:H})]}),C)]})}d()}catch(a){d(a)}})},74493:(a,b,c)=>{"use strict";c.d(b,{Ey:()=>n,GW:()=>m,HS:()=>o,Hj:()=>i,ax:()=>h,qM:()=>j});var d=c(79606),e=c(33281),f=c(71192);let g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new f.uV({message:`POST ${a} failed`,cause:b})}),h=(a,b)=>e.t4.runPromise(g(`/api/${a}/disconnect`,{id:b}).pipe(d.orElse(()=>d.void))),i=a=>e.t4.runPromise(g("/api/jupyter/shutdown",{bubbleId:a}).pipe(d.orElse(()=>d.void))),j=a=>e.t4.runPromise(g("/api/browser/unregister",{id:a}).pipe(d.orElse(()=>d.void))),k=a=>e.t4.runPromise(a.pipe(d.catchAll(a=>d.sync(()=>{if(a.cause instanceof Error)throw a.cause;throw Error(a.message)})))),l=(a,b)=>{if(a&&"object"==typeof a&&"error"in a){let b=a.error;if("string"==typeof b&&b.length>0)return b;if(b&&"object"==typeof b){let a=b.message;if("string"==typeof a&&a.length>0)return a;let c=b._tag;if("string"==typeof c&&c.length>0)return c}}return`HTTP ${b}`},m=(a,b)=>k(d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok)throw Error(l(d,c.status));return d},catch:b=>new f.uV({message:`POST ${a} failed`,cause:b})})),n=(a,b)=>k(d.tryPromise({try:async()=>{let c=new URLSearchParams(b),d=await fetch(`${a}?${c}`),e=await d.json();if(!d.ok)throw Error(l(e,d.status));return e},catch:b=>new f.uV({message:`GET ${a} failed`,cause:b})})),o=(a,b)=>k(d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return c.blob()},catch:b=>new f.uV({message:`POST blob ${a} failed`,cause:b})}))},74542:(a,b,c)=>{"use strict";c.d(b,{b:()=>f});var d=c(48249),e=c(67484);function f({lines:a,containerRef:b}){let c=(0,e.useRef)(null),[g,h]=(0,e.useState)({top:0,height:0});if(0===a.length)return null;let i=100/a.length;return(0,d.jsxs)("div",{ref:c,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:a=>{let d=b.current,e=c.current;if(!d||!e)return;let f=e.getBoundingClientRect(),g=(a.clientY-f.top)/f.height*d.scrollHeight-d.clientHeight/2;d.scrollTo({top:Math.max(0,g),behavior:"smooth"})},children:[a.map((a,b)=>"unchanged"!==a.type&&(0,d.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===a.type?"bg-red-9":"bg-green-9"}`,style:{top:`${b*i}%`,height:`${Math.max(i,.5)}%`,minHeight:"2px"}},b)),(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${g.top}px`,height:`${Math.max(g.height,10)}px`}})]})}},74754:(a,b,c)=>{"use strict";c.d(b,{_:()=>g});var d=c(67484);c(91579);var e=c(33281),f=c(89800);function g({cwd:a,filePath:b}){let[c,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(!1),[k,l]=(0,d.useState)(null),m=(0,d.useCallback)(async()=>{if(!a||!b)return;j(!0),l(null);let c=await e.t4.runPromiseExit((0,f.lb)(a,b));if("Success"===c._tag)h(c.value.comments??[]);else{let a="Fail"===c.cause._tag?c.cause.error:null,b=a?.cause;l(b instanceof Error?b.message:"Failed to load comments")}j(!1)},[a,b]),n=(0,d.useCallback)(async(c,d,g,i)=>{let j=await e.t4.runPromiseExit((0,f.BC)({cwd:a,filePath:b,startLine:c,endLine:d,content:g,...i?{selectedText:i}:{}}));if("Success"===j._tag&&j.value.comment){let a=j.value.comment;return h(b=>[...b,a]),a}return"Failure"===j._tag&&console.error("Failed to add comment:",j.cause),null},[a,b]),o=(0,d.useCallback)(async(b,c)=>{let d=await e.t4.runPromiseExit((0,f.vv)(a,b,c));if("Success"===d._tag&&d.value.comment){let a=d.value.comment;return h(c=>c.map(c=>c.id===b?a:c)),!0}return"Failure"===d._tag&&console.error("Failed to update comment:",d.cause),!1},[a]),p=(0,d.useCallback)(async b=>{let c=await e.t4.runPromiseExit((0,f.Tu)(a,b));return"Success"===c._tag?(h(a=>a.filter(a=>a.id!==b)),!0):(console.error("Failed to delete comment:",c.cause),!1)},[a]),q=(0,d.useCallback)(a=>c.filter(b=>a>=b.startLine&&a<=b.endLine),[c]);return{comments:c,isLoading:i,error:k,addComment:n,updateComment:o,deleteComment:p,refresh:m,getCommentsForLine:q}}},74837:(a,b,c)=>{"use strict";c.d(b,{NoteToolbar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call NoteToolbar() from the server but NoteToolbar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/NoteToolbar.tsx","NoteToolbar")},74991:(a,b,c)=>{"use strict";c.d(b,{I:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(30458);function h(a,b){if("once"===a.type)return b("scheduledTasks.onceType",{minutes:a.delayMinutes});if("interval"===a.type){let c=b("scheduledTasks.everyNMinutes",{minutes:a.intervalMinutes});return a.activeFrom&&a.activeTo?`${c} (${a.activeFrom}-${a.activeTo})`:c}return"cron"===a.type?a.cron||"cron":a.type}function i(a){return a.unread?"bg-red-500":a.completed?"bg-muted-foreground":a.paused?"bg-yellow-500":"error"===a.lastResult?"bg-red-500":"bg-green-500"}function j({collapsed:a,tasks:b,unreadCount:c,onSwitchProject:k,onPause:l,onResume:m,onTrigger:n,onDelete:o,onMarkRead:p,onUpdateTask:q,onReorder:r}){let{t:s}=(0,f.Bd)(),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),x=(0,e.useRef)(null),y=b.filter(a=>!a.completed),z=y.filter(a=>!a.paused).length,A=b.filter(a=>a.completed),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(null),F=(0,e.useCallback)(a=>{C(a)},[]),G=(0,e.useCallback)((a,b)=>{a.preventDefault(),E(b)},[]),H=(0,e.useCallback)(a=>{if(null===B||B===a){C(null),E(null);return}let b=[...y],[c]=b.splice(B,1);b.splice(a,0,c),r([...b,...A].map(a=>a.id)),C(null),E(null)},[B,y,A,r]),I=(0,e.useCallback)(()=>{C(null),E(null)},[]),[,J]=(0,e.useState)(0);return(0,d.jsxs)("div",{className:"relative",ref:x,children:[(0,d.jsxs)("button",{onClick:()=>u(!t),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${a?"w-full justify-center":"w-full"}`,title:s("scheduledTasks.title"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]}),!a&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:s("scheduledTasks.title")}),c>0?(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-red-500 ${a?"absolute -top-1 -right-1":""}`,children:c}):a&&b.length>0?(0,d.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-accent",children:b.length}):null]}),t&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-96 max-h-[500px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium",children:s("scheduledTasks.title")}),y.length>0&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[s("scheduledTasks.activeCount",{running:z}),y.length-z>0?` \xb7 ${s("scheduledTasks.pausedCount",{paused:y.length-z})}`:""]})]}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:s("scheduledTasks.noScheduledTasks")}):(0,d.jsxs)(d.Fragment,{children:[y.map((a,b)=>{var c;return(0,d.jsx)("div",{draggable:!0,onDragStart:()=>F(b),onDragOver:a=>G(a,b),onDrop:()=>H(b),onDragEnd:I,className:`group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 cursor-pointer ${a.unread?"bg-brand/5":""} ${B===b?"opacity-50":""} ${D===b?"border-t-2 border-brand":""}`,onClick:()=>{k(a.cwd,a.sessionId),a.unread&&p(a.id),u(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${i(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:(c=a.cwd).split("/").pop()||c}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"\xb7"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:a.completed?s("scheduledTasks.completed"):a.paused?s("scheduledTasks.paused"):s("common.running")})]}),(0,d.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5",title:a.message,children:a.message}),(0,d.jsxs)("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{children:h(a,s)}),(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsx)("span",{children:a.paused?s("scheduledTasks.paused"):function(a,b){if(!a)return"-";let c=a-Date.now();if(c<=0)return b("scheduledTasks.aboutToTrigger");if(c<6e4)return b("scheduledTasks.secondsLater",{count:Math.ceil(c/1e3)});if(c<36e5)return b("scheduledTasks.minutesLater",{count:Math.ceil(c/6e4)});if(c<864e5){let a=Math.floor(c/36e5),d=Math.ceil(c%36e5/6e4);return d>0?b("scheduledTasks.hoursMinutesLater",{h:a,m:d}):b("scheduledTasks.hoursLater",{h:a})}return new Date(a).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(a.nextFireTime,s)}),a.lastFiredAt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsxs)("span",{children:[s("scheduledTasks.lastResult"),": ","success"===a.lastResult?"✓":"✗"]})]})]})]}),(0,d.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),n(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-brand",title:s("scheduledTasks.runNow"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M8 5v14l11-7z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),w(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:s("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})}),a.paused?(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),m(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-green-500",title:s("scheduledTasks.resume"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"})})}):(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),l(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-yellow-500",title:s("scheduledTasks.pause"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 9v6m4-6v6"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),o(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:s("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})},a.id)}),A.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-muted/30 border-b border-border/50",children:s("scheduledTasks.completedCount",{count:A.length})}),A.map(a=>(0,d.jsx)("div",{className:"group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 opacity-60 cursor-pointer",onClick:()=>{k(a.cwd,a.sessionId),u(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${i(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm text-foreground truncate",children:a.message}),(0,d.jsxs)("div",{className:"text-xs text-muted-foreground mt-0.5",children:[h(a,s)," \xb7 ","success"===a.lastResult?s("scheduledTasks.success"):s("scheduledTasks.failure")]})]}),(0,d.jsx)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),o(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:s("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]})},a.id))]})]})})]}),v&&(0,d.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30",onClick:()=>w(null)}),(0,d.jsx)("div",{className:"relative",children:(0,d.jsx)(g.E,{onClose:()=>w(null),onCreate:()=>{},editTask:{id:v.id,message:v.message,type:v.type,delayMinutes:v.delayMinutes,intervalMinutes:v.intervalMinutes,activeFrom:v.activeFrom,activeTo:v.activeTo,cron:v.cron},onUpdate:(a,b)=>{q(a,b),w(null)}})})]})]})}},75513:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{k_:()=>h,nH:()=>i});var e=c(48249),f=c(67484),g=c(7031);let a=(0,f.createContext)(null);function h({children:b}){let c=(0,f.useRef)(new Map),d=(0,f.useRef)(null),[i,j]=(0,f.useState)(!1),k=(0,f.useCallback)((a,b)=>{c.current.set(b,a)},[]),l=(0,f.useCallback)(a=>{c.current.delete(a)},[]),m=(0,f.useCallback)(a=>{d.current=a},[]),n=(0,f.useCallback)(a=>{let b=d.current;if(!b)return void console.warn("No active tab to send message");let e=c.current.get(b);e?e(a):console.warn(`No chat sender registered for tab ${b}`)},[]),o=(0,f.useMemo)(()=>({sendMessage:n,isLoading:i,registerChat:k,unregisterChat:l,setActiveTab:m,setIsLoading:j}),[n,i,k,l,m]),p=(0,f.useMemo)(()=>({sendMessage:n,isLoading:i}),[n,i]);return(0,e.jsx)(a.Provider,{value:o,children:(0,e.jsx)(g.H,{value:p,children:b})})}function i(){return(0,f.useContext)(a)}d()}catch(a){d(a)}})},76334:(a,b,c)=>{"use strict";function d(a){let b=function(a){let b=0xffffffff;for(let c=0;c<a.length;c++){b^=a.charCodeAt(c);for(let a=0;a<8;a++)b=b>>>1^(1&b?0xedb88320:0)}return(0xffffffff^b)>>>0}(a),c="",d=b;for(let a=0;a<4;a++)c+=String.fromCharCode(97+d%26),d=Math.floor(d/26);return c}c.d(b,{p:()=>d})},76537:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>q,metadata:()=>o,viewport:()=>p});var d=c(5735),e=c(45864),f=c.n(e),g=c(87764),h=c.n(g),i=c(76055),j=c.n(i),k=c(29021),l=c(33873);c(61135);var m=c(25702);let n="";try{n=(0,k.readFileSync)((0,l.join)(process.cwd(),"public","boot.js"),"utf8")}catch{}let o={title:"OpenCockpit",description:"OpenCockpit is a local-first AI development hub with chat agents, a file explorer, terminals, and browser bubbles in one swipeable workspace. One seat. One AI.",appleWebApp:{capable:!0,statusBarStyle:"default",title:"Cockpit"},icons:{icon:"/icons/icon-192x192.png",apple:"/icons/icon-192x192.png"}},p={themeColor:[{media:"(prefers-color-scheme: light)",color:"#f9f9fb"},{media:"(prefers-color-scheme: dark)",color:"#111113"}]};function q({children:a}){return(0,d.jsxs)("html",{lang:"en",suppressHydrationWarning:!0,className:"overflow-hidden",children:[(0,d.jsx)("head",{children:(0,d.jsx)("script",{dangerouslySetInnerHTML:{__html:n}})}),(0,d.jsx)("body",{className:`${f().variable} ${h().variable} ${j().variable} antialiased overflow-hidden`,children:(0,d.jsx)(m.Providers,{children:a})})]})}},76552:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Providers:()=>j});var e=c(48249),f=c(29491),g=c(83768),h=c(7833),i=c(34102);function j({children:a}){return(0,e.jsx)(f.I18nProvider,{children:(0,e.jsx)(g.N,{children:(0,e.jsxs)(h.tE,{children:[a,(0,e.jsx)(i.B,{})]})})})}d()}catch(a){d(a)}})},76855:(a,b,c)=>{"use strict";c.d(b,{Sn:()=>i,Xm:()=>j,po:()=>k,JL:()=>l});var d=c(67484);c(28797);var e=c(79606),f=c(33281),g=c(71192);let h=(a,b)=>e.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:b=>new g.uV({message:`${a} failed`,cause:b})});function i(a){let[b,c]=(0,d.useState)(!1);return{goToDefinition:(0,d.useCallback)(async(b,d,e)=>{c(!0);let g=await f.t4.runPromiseExit(h("/api/lsp/definition",{cwd:a,filePath:b,line:d,column:e}));return(c(!1),"Success"===g._tag)?g.value.definitions??[]:(console.error("[useLSP] definition error:",g.cause),[])},[a]),loading:b}}function j(a){let[b,c]=(0,d.useState)(null),e=(0,d.useRef)(null),g=(0,d.useRef)(null),i=(0,d.useRef)(0),j=(0,d.useRef)(!1),k=(0,d.useRef)(null),l=(0,d.useRef)({x:0,y:0}),m=(0,d.useCallback)(a=>{k.current=a},[]),n=(0,d.useRef)(!1),o=(0,d.useRef)(null),p=(0,d.useCallback)(()=>{let a=k.current;a&&n.current&&(a.style.pointerEvents="none"),n.current=!1,o.current&&(k.current?.removeEventListener("mouseleave",o.current),o.current=null)},[]),q=(0,d.useCallback)(()=>{let a=k.current;if(!a||n.current)return;n.current=!0,j.current=!0,a.style.pointerEvents="auto";let b=()=>{j.current=!1,p(),i.current++,c(null)};o.current=b,a.addEventListener("mouseleave",b)},[p]),r=(0,d.useCallback)((b,d,j,k)=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current);let l=++i.current;e.current=setTimeout(async()=>{let e=await f.t4.runPromiseExit(h("/api/lsp/hover",{cwd:a,filePath:b,line:d,column:j}));if(l!==i.current||"Success"!==e._tag)return;let g=e.value.hover;g&&g.displayString&&c({...g,x:k.x,y:k.y,filePath:b,line:d,column:j})},300)},[a]),s=(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),i.current++,g.current=setTimeout(function(){if(j.current)return;let a=k.current;if(a){let b=a.getBoundingClientRect(),{x:c,y:d}=l.current;if(c>=b.left&&c<=b.right&&d>=b.top&&d<=b.bottom)return void q()}c(null)},150)},[q]),t=(0,d.useCallback)(()=>{j.current=!0,g.current&&clearTimeout(g.current)},[]);return{hoverInfo:b,onTokenMouseEnter:r,onTokenMouseLeave:s,onCardMouseEnter:t,onCardMouseLeave:(0,d.useCallback)(()=>{j.current=!1,i.current++,c(null)},[]),clearHover:(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current),j.current=!1,p(),i.current++,c(null)},[p]),setTooltipEl:m}}function k(a){let[b,c]=(0,d.useState)([]),[e,g]=(0,d.useState)(!1),[i,j]=(0,d.useState)(!1);return{references:b,loading:e,visible:i,findReferences:(0,d.useCallback)(async(b,d,e)=>{g(!0),j(!0);let i=await f.t4.runPromiseExit(h("/api/lsp/references",{cwd:a,filePath:b,line:d,column:e}));"Success"===i._tag?c(i.value.references??[]):(console.error("[useLSP] references error:",i.cause),c([])),g(!1)},[a]),closeReferences:(0,d.useCallback)(()=>{j(!1),c([])},[])}}function l(a,b){(0,d.useRef)(null)}},77016:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{b:()=>s});var e=c(48249),f=c(67484),g=c(44256),h=c(36295),i=c(7833),j=c(28602),k=c(44384),l=c(74493),m=a([h]);h=(m.then?(await m)():m)[0];let x=[{value:"=",label:"="},{value:"!=",label:"!="},{value:">",label:">"},{value:"<",label:"<"},{value:">=",label:">="},{value:"<=",label:"<="},{value:"LIKE",label:"LIKE"},{value:"NOT LIKE",label:"NOT LIKE"},{value:"IN",label:"IN"},{value:"IS NULL",label:"IS NULL"},{value:"IS NOT NULL",label:"IS NOT NULL"}];function n(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}function o(a){return`\`${a.replace(/`/g,"``")}\``}function p(a){try{let b=a.match(/\/\/[^/]+\/([^?]+)/);if(b)return b[1]}catch{}return""}function q(a){return null==a?"":"object"==typeof a?JSON.stringify(a):String(a)}function r({text:a}){let[b,c]=(0,f.useState)(!1),[d,h]=(0,f.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),i=(0,f.useRef)(null),j=(0,f.useRef)(null),k=(0,f.useRef)(!1),l=(0,g.F2)(),m=(0,f.useCallback)(()=>{j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{k.current||c(!1)},80)},[]),n=(0,f.useCallback)(()=>{j.current&&clearTimeout(j.current),k.current=!1,j.current=setTimeout(()=>{let a=i.current;if(!a||a.scrollWidth<=a.clientWidth)return;let b=a.getBoundingClientRect(),d=l?.getBoundingClientRect(),e=d?.left??0,f=d?.top??0,g=d?.width??window.innerWidth,j=d?.height??window.innerHeight,k=b.left-e,m=b.top-f,n=b.bottom-f,o=Math.min(600,g-k-8),p=o<200?Math.max(8,g-600-8):k,q=o<200?Math.min(600,g-16):o,r=m-8,s=j-n-8,t=r>s&&r>80,u=t?r-4:s-4;h({x:p,y:t?m-4:n+4,maxW:q,maxH:Math.max(60,u),above:t}),c(!0)},350)},[l]),o=(0,f.useCallback)(()=>{m()},[m]),p=(0,f.useCallback)(()=>{k.current=!0,j.current&&clearTimeout(j.current)},[]),q=(0,f.useCallback)(()=>{k.current=!1,m()},[m]);return(0,e.jsxs)("span",{ref:i,className:"block truncate",onMouseEnter:n,onMouseLeave:o,children:[a,b&&(0,e.jsx)(g.ZL,{children:(0,e.jsx)("div",{className:"fixed z-[9999] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lg whitespace-pre-wrap break-all select-text cursor-text",style:{left:d.x,top:d.y,maxWidth:d.maxW,maxHeight:d.maxH,transform:d.above?"translateY(-100%)":void 0},onMouseEnter:p,onMouseLeave:q,children:function(a){try{let b=JSON.parse(a);if("object"==typeof b&&null!==b)return JSON.stringify(b,null,2)}catch{}return a}(a)})})]})}function s({id:a,connectionString:b,displayName:c,selected:d,maximized:g,expandedHeight:m,bubbleContentHeight:u,onSelect:x,onClose:y,onToggleMaximize:z,timestamp:A,onTitleMouseDown:B}){let{t:C}=(0,k.Bd)(),{showToast:D}=(0,i.dj)(),[E,F]=(0,f.useState)("connecting"),[G,H]=(0,f.useState)(""),[I,J]=(0,f.useState)([]),[K,L]=(0,f.useState)(()=>p(b)),[M,N]=(0,f.useState)([]),[O,P]=(0,f.useState)(null),[Q,R]=(0,f.useState)("table"),[S,T]=(0,f.useState)("data"),[U,V]=(0,f.useState)([]),[W,X]=(0,f.useState)([]),[Y,Z]=(0,f.useState)([]),[$,_]=(0,f.useState)([]),[aa,ab]=(0,f.useState)(null),[ac,ad]=(0,f.useState)(0),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(0),[ai,aj]=(0,f.useState)(new Set),[ak,al]=(0,f.useState)(!1),[am,an]=(0,f.useState)(null),[ao,ap]=(0,f.useState)({}),[aq,ar]=(0,f.useState)(!1),[as,at]=(0,f.useState)({}),[au,av]=(0,f.useState)({}),[aw,ax]=(0,f.useState)(null),[ay,az]=(0,f.useState)(""),[aA,aB]=(0,f.useState)(null),[aC,aD]=(0,f.useState)(""),[aE,aF]=(0,f.useState)(!1),aG=(0,f.useRef)(null),aH=(0,f.useCallback)(async()=>{F("connecting"),H("");try{let c=await (0,l.GW)("/api/mysql/connect",{id:a,connectionString:b});J(c.schemas||[]);let d=p(b);c.schemas?.length>0&&d&&c.schemas.includes(d)?L(d):c.schemas?.length>0&&L(c.schemas[0]),F("connected")}catch(a){H(a instanceof Error?a.message:String(a)),F("error")}},[a,b]),aI=(0,f.useCallback)(async()=>{if("connected"===E)try{let c=await (0,l.Ey)("/api/mysql/schemas",{id:a,connectionString:b,schema:K});N(c.tables||[])}catch{}},[a,b,K,E]),aJ=(0,f.useCallback)(async(c,d,e,f)=>{af(!0);let g=e??au,h=void 0!==f?f:aw;try{let e=`${o(K)}.${o(c)}`,{where:f,params:i}=function(a){let b=[],c=[];for(let[d,e]of Object.entries(a)){if(!e.enabled)continue;let a=o(d);if("IS NULL"===e.op)b.push(`${a} IS NULL`);else if("IS NOT NULL"===e.op)b.push(`${a} IS NOT NULL`);else if("IN"===e.op){let d=e.value.split(",").map(a=>a.trim()).filter(Boolean);if(0===d.length)continue;let f=d.map(a=>(c.push(a),"?"));b.push(`${a} IN (${f.join(", ")})`)}else"LIKE"===e.op||e.op,b.push(`${a} ${e.op} ?`),c.push(e.value)}return{where:b.length>0?` WHERE ${b.join(" AND ")}`:"",params:c}}(g),j=h?` ORDER BY ${o(h.column)} ${h.dir}`:"",k=`SELECT * FROM ${e}${f}${j} LIMIT 50 OFFSET ${50*d}`,m=await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:k,params:i});ab(m);let n=`SELECT count(*) AS cnt FROM ${e}${f}`,p=await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:n,params:i});ah(p.rows?.[0]?.cnt??0)}catch{}af(!1)},[a,b,K,au,aw]),aK=(0,f.useCallback)(async c=>{P(c),ad(0),an(null),ar(!1),aj(new Set),al(!1),av({}),ax(null);try{let d=await (0,l.Ey)("/api/mysql/columns",{id:a,connectionString:b,schema:K,table:c});V(d.columns||[]),X(d.primaryKeys||[]),Z(d.foreignKeys||[]),_(d.indexes||[])}catch{}aJ(c,0,{},null)},[a,b,K,aJ]),aL=(0,f.useCallback)(async()=>{if(ay.trim()){aF(!0),aD(""),aB(null);try{let c=await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:ay});aB(c)}catch(a){aD(a instanceof Error?a.message:String(a))}aF(!1)}},[a,b,ay]),aM=(0,f.useCallback)(async()=>{if(null===am||!aa||!O)return;let c=aa.rows[am],d=[],e=[];for(let a of U)void 0!==ao[a.name]&&ao[a.name]!==q(c[a.name]??"")&&(d.push(`${o(a.name)} = ?`),e.push(""===ao[a.name]&&a.nullable?null:ao[a.name]));if(0===d.length)return void an(null);let f=W.length>0?W:U.map(a=>a.name),g=[];for(let a of f)null===c[a]||void 0===c[a]?g.push(`${o(a)} IS NULL`):(g.push(`${o(a)} = ?`),e.push(c[a]));let h=`UPDATE ${o(K)}.${o(O)} SET ${d.join(", ")} WHERE ${g.join(" AND ")}`;try{await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:h,params:e}),an(null),aJ(O,ac,au,aw)}catch(a){alert(`Update failed: ${a instanceof Error?a.message:String(a)}`)}},[am,aa,O,U,W,ao,a,b,K,aJ,ac,au,aw]),aN=(0,f.useCallback)(async()=>{if(!O)return;let c=[],d=[],e=[];for(let a of U)void 0!==as[a.name]&&""!==as[a.name]&&(c.push(o(a.name)),d.push(as[a.name]),e.push("?"));if(0===c.length)return;let f=`INSERT INTO ${o(K)}.${o(O)} (${c.join(", ")}) VALUES (${e.join(", ")})`;try{await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:f,params:d}),ar(!1),at({}),aJ(O,ac,au,aw)}catch(a){alert(`Insert failed: ${a instanceof Error?a.message:String(a)}`)}},[O,U,as,a,b,K,aJ,ac,au,aw]),aO=(0,f.useCallback)(async()=>{if(0===ai.size||!aa||!O)return;let c=W.length>0?W:U.map(a=>a.name),d=0;for(let e of Array.from(ai).sort((a,b)=>b-a)){let f=aa.rows[e];if(!f)continue;let g=[],h=[];for(let a of c)null===f[a]||void 0===f[a]?g.push(`${o(a)} IS NULL`):(g.push(`${o(a)} = ?`),h.push(f[a]));let i=`DELETE FROM ${o(K)}.${o(O)} WHERE ${g.join(" AND ")} LIMIT 1`;try{await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:i,params:h})}catch{d++}}aj(new Set),al(!1),aJ(O,ac,au,aw),d>0&&alert(C("mysql.deleteRowsFailed",{count:d}))},[ai,aa,O,W,U,a,b,K,aJ,ac,au,aw]),aP=(0,f.useCallback)(async c=>{if(!O)return;if(ai.size>0&&aa){let a,b=aa.fields.map(a=>a.name),d=Array.from(ai).sort((a,b)=>a-b).map(a=>aa.rows[a]).filter(Boolean);if("json"===c)a=JSON.stringify(d,null,2);else{let c=[b.join(",")];for(let a of d)c.push(b.map(b=>{let c=a[b];if(null==c)return"";let d="object"==typeof c?JSON.stringify(c):String(c);return d.includes(",")||d.includes('"')||d.includes("\n")?`"${d.replace(/"/g,'""')}"`:d}).join(","));a=c.join("\n")}navigator.clipboard.writeText(a);return}let d=`SELECT * FROM ${o(K)}.${o(O)}`;try{let e=await (0,l.HS)("/api/mysql/export",{id:a,connectionString:b,sql:d,format:c}),f=URL.createObjectURL(e),g=document.createElement("a");g.href=f,g.download=`${O}.${c}`,g.click(),URL.revokeObjectURL(f)}catch(a){alert(`Export failed: ${a instanceof Error?a.message:String(a)}`)}},[O,a,b,K,ai,aa]),aQ=(0,f.useCallback)(a=>{(a.metaKey||a.ctrlKey)&&"Enter"===a.key&&(a.preventDefault(),aL())},[aL]),aR=g&&m?m-41:u??h.p,aS=Math.max(1,Math.ceil(ag/50)),aT=(0,f.useCallback)(a=>{O&&(ad(a),aJ(O,a,au,aw))},[O,aJ,au,aw]),aU=(0,f.useCallback)((a,b)=>{let c={...au};b?c[a]=b:delete c[a],av(c),ad(0),aj(new Set),O&&aJ(O,0,c,aw)},[au,aw,O,aJ]),aV=(0,f.useCallback)(()=>{av({}),ad(0),aj(new Set),O&&aJ(O,0,{},aw)},[aw,O,aJ]),aW=(0,f.useCallback)(a=>{ax(a),ad(0),aj(new Set),O&&aJ(O,0,au,a)},[au,O,aJ]);return(0,e.jsx)("div",{className:"flex flex-col items-start",children:(0,e.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
35
|
+
${f}`),aE(h,c)}else aE(X("chat.executedCommandFailed",{command:e,error:g.cause}),c);return}aE(a,c)},[aE,b,X,as,am,ar]),aH=(0,f.useCallback)(()=>{ar(!1),aE(X("chat.approvePlanPrompt",{defaultValue:"已批准,按上述计划开始执行。"}),void 0,{permissionMode:null})},[aE,ar,X]),[aI,aJ]=(0,f.useState)(!1),aK=(0,f.useRef)(!1),{isLoadingHistory:aL,isLoadingMore:aM,hasMoreHistory:aN,loadMoreHistory:aO,loadHistoryByCwdAndSessionId:aP,loadedSessionId:aQ}=(0,r.m)(Y,Z,$,{cwd:b,initialSessionId:c,onSessionId:_,onTitleChange:P,onTokenUsage:aj,liveRunningRef:aK}),aR=aQ||$,aS=M&&!az&&!!aR;(0,i.u)(aR,Z,aS,d,{onRunningChange:a=>{aK.current=a,aJ(a)},onComplete:()=>{b&&aR&&aP(b,aR,!0)}}),(0,f.useRef)(M);let aT=aA||ai;(0,f.useRef)(!1);let aU=(0,f.useCallback)(async a=>{let c=aQ??$;if(!b||!c)return;let d=await j.t4.runPromiseExit((0,k.Zr)(c,{cwd:b,fromMessageUuid:a}));if("Success"===d._tag&&d.value.newSessionId){let a=d.value.newSessionId;T?T(a,"Fork"):(0,l.F)(m.n.OpenProject,{cwd:b,sessionId:a})}else"Failure"===d._tag&&console.error("Fork failed:",d.cause)},[b,aQ,$,T]),aV=(0,f.useCallback)(()=>{af(!0)},[]),aW=(0,f.useCallback)(()=>{ah(!0)},[]),aX=(0,f.useMemo)(()=>{if(S&&b&&a&&$)return c=>{S({...c,cwd:b,tabId:a,sessionId:$,engine:d,..."ollama"===d&&B&&{model:B},..."deepseek"===d&&E&&{model:E}})}},[S,b,a,$,d,B,E]);return(0,e.jsxs)("div",{className:`flex ${K&&L?"h-full":"h-screen"} bg-card`,children:[(0,e.jsxs)("div",{id:"chat-screen",className:"flex-1 flex flex-col min-w-0 relative",onMouseEnter:()=>ab(!0),onMouseLeave:()=>ab(!1),children:[!K&&(0,e.jsx)(n.e,{cwd:b,sessionId:$,onOpenProjectSessions:()=>ad(!0),onOpenSessionBrowser:V,onOpenSettings:W}),as&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card/50",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:X("chat.executionMode",{defaultValue:"Execution mode"})}),(0,e.jsxs)("div",{className:"inline-flex rounded-md border border-border overflow-hidden text-xs",role:"group","data-testid":"chatmode-toggle",children:[(0,e.jsx)("button",{type:"button","data-testid":"chatmode-sdk",onClick:()=>an("sdk"),className:`px-2 py-0.5 ${"sdk"===am?"bg-brand text-white":"bg-transparent text-muted-foreground hover:bg-accent"}`,children:"Claude Agent SDK"}),(0,e.jsx)("button",{type:"button","data-testid":"chatmode-pty",onClick:()=>an("pty"),className:`px-2 py-0.5 ${"pty"===am?"bg-brand text-white":"bg-transparent text-muted-foreground hover:bg-accent"}`,title:X("chat.ptyModeHint",{defaultValue:"Subscription-billing mode: driven by the interactive claude CLI"}),children:"Claude Code CLI"})]}),"sdk"===am&&(0,e.jsxs)("label",{className:"flex items-center gap-1.5 ml-2 pl-3 border-l border-border text-xs cursor-pointer select-none",title:X("chat.planModeHint",{defaultValue:"Plan mode: read-only exploration that produces a plan without editing. Uncheck and resend to implement."}),children:[(0,e.jsx)("input",{type:"checkbox","data-testid":"planmode-toggle",checked:aq,onChange:a=>ar(a.target.checked),className:"accent-brand"}),(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(g.A,{className:"w-3.5 h-3.5"}),X("chat.planMode",{defaultValue:"Plan mode"})]}),(0,e.jsx)("span",{className:"text-muted-foreground",children:X("chat.planModeDesc",{defaultValue:"read-only \xb7 plan first, no edits"})})]})]}),"ollama"===d&&D&&(0,e.jsx)("div",{className:"flex items-center px-3 py-1.5 border-b border-border bg-card/50",children:(0,e.jsx)(x.m,{currentModel:B,onModelChange:D})}),"deepseek"===d&&F&&(0,e.jsx)("div",{className:"flex items-center px-3 py-1.5 border-b border-border bg-card/50",children:(0,e.jsx)(y.r,{currentModel:E,onModelChange:F})}),aL?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"text-muted-foreground",children:X("sessions.loadingHistory")})}):(0,e.jsx)(t.M,{ref:aw,messages:Y,isLoading:az||aI,cwd:b,sessionId:$,engine:d,apiRetryInfo:aC,ptyNotice:aD,hasMoreHistory:aN,isLoadingMore:aM,onLoadMore:aO,onFork:aU,isActive:M,onContentSearch:U,onApprovePlan:aH}),aT&&(0,e.jsx)(o.g,{tokenUsage:aT,rateLimitInfo:aB}),(0,e.jsx)(u.V,{onSend:aG,disabled:az||aI,cwd:b,engine:d,onShowGitStatus:Q,onShowComments:b?aV:void 0,onShowUserMessages:aW,onOpenNote:R,onCreateScheduledTask:aX}),(0,e.jsx)(v.ri,{ref:at,visible:as&&"pty"===am,running:az,onInput:av})]}),!K&&b&&(0,e.jsx)(w.Q,{isOpen:ac,onClose:()=>ad(!1),cwd:b}),b&&(0,e.jsx)(z.i,{isOpen:ae,onClose:()=>af(!1),cwd:b}),(0,e.jsx)(p.f,{isOpen:ag,onClose:()=>ah(!1),messages:Y,onSelectMessage:a=>{aw.current?.scrollToMessage(a)}})]})}[q,s,i,x,y,t,u,z,p]=B.then?(await B)():B,d()}catch(a){d(a)}})},58904:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e:()=>m});var e=c(67484),f=c(20586),g=c(7833),h=c(208),i=c(79606),j=c(33281),k=c(85655),l=a([f]);function m({cwd:a,addToRecentFiles:b}){let[c,d]=(0,e.useState)(null),[l,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(new Set),[y,z]=(0,e.useState)(new Set),[A,B]=(0,e.useState)([]),[C,D]=(0,e.useState)([]),E=(0,e.useMemo)(()=>{let a=new Set((0,f.Sz)(A));for(let b of w)a.delete(b);return a},[A,w]),F=(0,e.useMemo)(()=>{let a=new Set((0,f.Sz)(C));for(let b of y)a.delete(b);return a},[C,y]),[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)(0),K=(0,e.useCallback)(async()=>{n(!0),p(null),await j.t4.runPromise((0,k.lv)(a).pipe(i.match({onSuccess:a=>{d(a);let b=(0,f.Do)(a.staged),c=(0,f.Do)(a.unstaged);B(b),D(c)},onFailure:a=>{let b=a.cause instanceof Error?a.cause.message:"Unknown error";p(b)}}))),n(!1)},[a]),L=(0,e.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),M=(0,e.useCallback)(a=>{z(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),N=(0,e.useCallback)((a,c)=>{r({file:a,type:c}),b(a.path)},[b]),O=(0,e.useCallback)(async(a,b,c,d)=>{let e=await j.t4.runPromiseExit(a);"Success"===e._tag?(await K(),(0,g.oR)(b,"success")):(console.error(c,e.cause),(0,g.oR)(d,"error"))},[K]),P=(0,e.useCallback)(b=>O((0,k.Iz)(a,[b]),h.A.t("toast.staged"),"Error staging file:",h.A.t("toast.stageFailed")),[a,O]),Q=(0,e.useCallback)(b=>O((0,k.X0)(a,[b]),h.A.t("toast.unstaged"),"Error unstaging file:",h.A.t("toast.unstageFailed")),[a,O]),R=(0,e.useCallback)(async b=>{0!==b.length&&await O((0,k.Iz)(a,b),h.A.t("toast.stagedNFiles",{count:b.length}),"Error staging files:",h.A.t("toast.stageFailed"))},[a,O]),S=(0,e.useCallback)(async b=>{0!==b.length&&await O((0,k.X0)(a,b),h.A.t("toast.unstagedNFiles",{count:b.length}),"Error unstaging files:",h.A.t("toast.unstageFailed"))},[a,O]),T=(0,e.useCallback)(async b=>{if(0===b.length)return;let c=b.filter(a=>"untracked"===a.status).map(a=>a.path),d=b.filter(a=>"untracked"!==a.status).map(a=>a.path),e=i.gen(function*(){c.length>0&&(yield*(0,k.Ub)(a,c,!0)),d.length>0&&(yield*(0,k.Ub)(a,d,!1))});await O(e,h.A.t("toast.discardedNFiles",{count:b.length}),"Error discarding files:",h.A.t("toast.discardFailed"))},[a,O]),U=(0,e.useCallback)(async()=>{c?.unstaged.length&&await O((0,k.Iz)(a,c.unstaged.map(a=>a.path)),h.A.t("toast.stagedNFiles",{count:c.unstaged.length}),"Error staging all files:",h.A.t("toast.stageFailed"))},[a,c,O]),V=(0,e.useCallback)(async()=>{c?.staged.length&&await O((0,k.X0)(a,c.staged.map(a=>a.path)),h.A.t("toast.unstagedNFiles",{count:c.staged.length}),"Error unstaging all files:",h.A.t("toast.unstageFailed"))},[a,c,O]),W=(0,e.useCallback)(async b=>{let c="untracked"===b.status;await O((0,k.Ub)(a,[b.path],c),c?h.A.t("toast.deletedFile"):h.A.t("toast.discardedChanges"),"Error discarding file:",h.A.t("toast.discardFailed"))},[a,O]),X=(0,e.useCallback)(async()=>{if(!c?.unstaged.length||!await (0,g.lJ)(h.A.t("git.discardAllConfirm",{count:c.unstaged.length}),{danger:!0}))return;let b=c.unstaged.filter(a=>"untracked"===a.status).map(a=>a.path),d=c.unstaged.filter(a=>"untracked"!==a.status).map(a=>a.path),e=c.unstaged.length,f=i.gen(function*(){d.length>0&&(yield*(0,k.Ub)(a,d,!1)),b.length>0&&(yield*(0,k.Ub)(a,b,!0))});await O(f,h.A.t("toast.discardedNFiles",{count:e}),"Error discarding all:",h.A.t("toast.discardFailed"))},[a,c,O]);return{status:c,setStatus:d,statusLoading:l,statusError:o,statusSelectedFile:q,statusDiff:s,statusDiffLoading:u,stagedExpandedPaths:E,unstagedExpandedPaths:F,stagedTree:A,setStagedTree:B,unstagedTree:C,setUnstagedTree:D,showStatusDiffPreview:G,setShowStatusDiffPreview:H,fetchStatus:K,handleStagedToggle:L,handleUnstagedToggle:M,handleStatusFileSelect:N,handleStage:P,handleUnstage:Q,handleStageFiles:R,handleUnstageFiles:S,handleDiscardFiles:T,handleStageAll:U,handleUnstageAll:V,handleDiscardFile:W,handleDiscardAll:X,refreshDiff:(0,e.useCallback)(()=>J(a=>a+1),[])}}f=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},60591:(a,b,c)=>{"use strict";c.d(b,{C6:()=>h,WU:()=>v,aR:()=>u,e$:()=>t,jU:()=>g,oK:()=>w,u:()=>s,xb:()=>i,zs:()=>q});var d=c(67484),e=c.n(d),f=c(208);function g(a){try{return JSON.parse(a),!0}catch{return!1}}function h(a){try{let b=JSON.parse(a);return JSON.stringify(b,null,2)}catch{return a}}function i(a){try{let b=JSON.parse(a);return p(b,0)}catch{return a}}let j="#79c0ff",k="#a5d6ff",l="#ff7b72",m="#8b949e",n=(a,b)=>e().createElement("span",{style:{color:a}},b);function o({label:a,labelColor:b,value:c,indent:d}){let[g,h]=e().useState(!1),[i,j]=e().useState({x:0,y:0}),l="string"==typeof c&&c.replace(/\\n/g,"\n").split("\n").length>3,q={onMouseDown:a=>{j({x:a.clientX,y:a.clientY})},onClick:a=>{let b=a.clientX-i.x,c=a.clientY-i.y;b*b+c*c>25||(a.stopPropagation(),h(a=>!a))},style:{cursor:"pointer"}};if(l&&g&&"string"==typeof c){let d=c.replace(/\\n/g,"\n").split("\n")[0],g=c.replace(/\\n/g,"\n").split("\n").length;return e().createElement("span",q,n(b,a),n(m,": "),n(k,d),n("#6e7681",` ${f.A.t("toolCall.foldedLines",{count:g})}`))}let r=e().createElement(e().Fragment,null,n(b,a),n(m,": "),p(c,d));return l?e().createElement("span",q,r):r}function p(a,b){let c=" ".repeat(b);if(null===a)return n(l,"null");if(void 0===a)return n(l,"undefined");if("string"==typeof a)return n(k,a.replace(/\\n/g,"\n").replace(/\n/g,"\n"+c));if("number"==typeof a)return n("#79c0ff",String(a));if("boolean"==typeof a)return n(l,String(a));if(Array.isArray(a))return 0===a.length?n(m,"[]"):e().createElement(e().Fragment,null,n(m,"["),"\n",...a.map((d,f)=>e().createElement("span",{key:f},c+" ",e().createElement(o,{label:`[${f}]`,labelColor:j,value:d,indent:b+1}),f<a.length-1?e().createElement(e().Fragment,null,n(m,","),"\n"):"\n")),c,n(m,"]"));if("object"==typeof a){let d=Object.entries(a);return 0===d.length?n(m,"{}"):e().createElement(e().Fragment,null,n(m,"{"),"\n",...d.map(([a,f],g)=>e().createElement("span",{key:a},c+" ",e().createElement(o,{label:a,labelColor:j,value:f,indent:b+1}),g<d.length-1?e().createElement(e().Fragment,null,n(m,","),"\n"):"\n")),c,n(m,"}"))}return String(a)}function q(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path&&"string"==typeof b.old_string&&"string"==typeof b.new_string)return b}catch{}return null}let r=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function s(a){let b=a.slice(a.lastIndexOf(".")).toLowerCase();return r.has(b)}function t(a){return a.toLowerCase().endsWith(".md")}function u(a){let b=a.toLowerCase();return b.endsWith(".html")||b.endsWith(".htm")}function v(a,b){let c=b.startsWith("/")?[]:a.split("/").slice(0,-1);for(let a of b.replace(/^\//,"").split("/"))""!==a&&"."!==a&&(".."===a?c.pop():c.push(a));return c.join("/")}function w(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path)return b.file_path}catch{let b=a.trim();if(b.startsWith("/")&&!b.includes("\n")&&b.length<500)return b}return null}},61130:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{ReviewCommentsListModal:()=>l});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(7833),j=c(208);function k(a,b,c){let d=(a,c)=>b[a]||c,e=[],f=null!=c?`[${c+1}] `:"",g=a.anchor.selectedText.length>200?a.anchor.selectedText.slice(0,197)+"...":a.anchor.selectedText;for(let b of(e.push(`${f}${j.A.t("review.quoteRef",{text:g})}`),e.push(j.A.t("review.commentAuthor",{author:d(a.authorId,a.author),content:a.content})),a.replies))e.push(j.A.t("review.replyAuthor",{author:d(b.authorId,b.author),content:b.content}));return e.join("\n")}function l({isOpen:a,onClose:b,comments:c,reviewTitle:d,userNameMap:n,onCommentClick:o}){let{t:p}=(0,g.Bd)(),[q,r]=(0,f.useState)(null),[s,t]=(0,f.useState)(!1);if(!a)return null;let u=[...c].sort((a,b)=>a.anchor.startOffset-b.anchor.startOffset),v=(a,b)=>n[a]||b,w=async a=>{r(a.id);try{let b=k(a,n);await navigator.clipboard.writeText(b),(0,i.oR)(p("toast.copiedComment"))}catch{(0,i.oR)(p("toast.copyFailed"),"error")}finally{r(null)}},x=async()=>{if(0!==c.length){t(!0);try{let a=function(a,b,c){if(0===a.length)return"";let d=[...a].sort((a,b)=>a.anchor.startOffset-b.anchor.startOffset),e=[j.A.t("review.reviewSummary",{title:b}),""];return d.forEach((a,b)=>{e.push(k(a,c,b)),e.push("")}),e.push(j.A.t("review.totalNComments",{count:a.length})),e.join("\n").trim()}(c,d,n);await navigator.clipboard.writeText(a),(0,i.oR)(p("toast.copiedAllComments"))}catch{(0,i.oR)(p("toast.copyFailed"),"error")}finally{t(!1)}}},y=a=>{o?.(a),b()},z=u.filter(a=>!a.closed),A=u.filter(a=>a.closed),B=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,e.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-xl flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:p("review.allCommentsTitle")}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[p("review.commentsCountBrief",{count:c.length}),A.length>0&&` (${p("review.closedCount",{count:A.length})})`]}),c.length>0&&(0,e.jsx)("button",{onClick:x,disabled:s,className:"p-1 rounded hover:bg-accent text-muted-foreground disabled:opacity-50",title:p("review.copyAllComments"),children:s?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:b,className:"p-1 rounded hover:bg-accent text-muted-foreground",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-3",children:0===c.length?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,e.jsx)("div",{className:"text-2xl mb-2",children:"\uD83D\uDCAC"}),(0,e.jsx)("span",{className:"text-sm",children:p("review.noComments")})]}):(0,e.jsxs)("div",{className:"space-y-2",children:[z.map((a,b)=>(0,e.jsx)(m,{comment:a,index:b,resolveAuthor:v,copyingId:q,onCopy:w,onClick:y},a.id)),A.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"text-[11px] text-muted-foreground/60 pt-2 pb-1 px-1",children:p("review.closedComments",{count:A.length})}),A.map((a,b)=>(0,e.jsx)(m,{comment:a,index:z.length+b,resolveAuthor:v,copyingId:q,onCopy:w,onClick:y,closed:!0},a.id))]})]})})]})});return(0,e.jsx)(h.ZL,{children:B})}function m({comment:a,index:b,resolveAuthor:c,copyingId:d,onCopy:f,onClick:g,closed:h}){var i;let k=a.anchor.selectedText.length>100?a.anchor.selectedText.slice(0,97)+"...":a.anchor.selectedText;return(0,e.jsxs)("div",{className:`rounded-lg border border-border hover:border-muted-foreground/30 transition-all cursor-pointer group ${h?"opacity-50":""}`,onClick:()=>g(a.id),children:[(0,e.jsx)("div",{className:"px-3 pt-2.5 pb-1",children:(0,e.jsx)("div",{className:"text-xs bg-yellow-500/10 border-l-2 border-yellow-500 px-2 py-1 rounded-r text-muted-foreground truncate",children:k})}),(0,e.jsxs)("div",{className:"px-3 pt-1.5 pb-2 flex items-start gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,e.jsx)("span",{className:"w-4 h-4 rounded-full bg-brand/20 text-brand flex items-center justify-center text-[9px] font-bold flex-shrink-0",children:c(a.authorId,a.author).charAt(0)}),(0,e.jsx)("span",{className:"text-xs font-medium",children:c(a.authorId,a.author)}),(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(i=a.createdAt,new Date(i).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}))}),h&&(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground/60",children:j.A.t("review.closedLabel")})]}),(0,e.jsx)("p",{className:"text-sm text-foreground line-clamp-2 pl-6",children:a.content}),a.replies.length>0&&(0,e.jsxs)("div",{className:"pl-6 mt-1 space-y-0.5",children:[a.replies.slice(0,3).map(a=>(0,e.jsxs)("div",{className:"text-xs text-muted-foreground truncate",children:[(0,e.jsx)("span",{className:"font-medium",children:c(a.authorId,a.author)}),": ",a.content]},a.id)),a.replies.length>3&&(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground/60",children:j.A.t("review.moreReplies",{count:a.replies.length-3})})]})]}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),f(a)},disabled:d===a.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-accent text-muted-foreground transition-opacity disabled:opacity-50 flex-shrink-0 mt-0.5",title:j.A.t("review.copyComment"),children:d===a.id?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})})]})]})}d()}catch(a){d(a)}})},61135:()=>{},61349:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>u});var e=c(48249),f=c(67484),g=c(44384),h=c(44256);c(33281),c(87808);var i=c(35208),j=c(55287),k=c(98356),l=c(24680),m=c(84835),n=c(7833),o=c(18921),p=c(53036),q=c(60591),r=a([j,i]);function s({filePath:a}){let[b,c]=(0,f.useState)(null),[d,g]=(0,f.useState)(!0),[h,i]=(0,f.useState)(null);(0,f.useRef)(!1);let k=(0,q.e$)(a);return((0,q.u)(a),h)?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-red-11",children:h})}):d?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):(0,q.u)(a)?(0,e.jsx)(p.I,{absPath:a,className:"flex items-center justify-center h-full overflow-auto",imgClassName:"max-w-full max-h-full object-contain",alt:a.split("/").pop()||"image"}):b?k?(0,e.jsx)(t,{content:b}):(0,e.jsx)(j.Cv,{content:b,filePath:a,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}[j,i]=r.then?(await r)():r;let v=[m.W];function t({content:a}){let b=(0,f.useRef)(null);return(0,e.jsxs)("div",{className:"h-full flex",children:[(0,e.jsx)(l.l,{content:a,containerRef:b}),(0,e.jsx)("div",{ref:b,className:"flex-1 overflow-auto p-4",children:(0,e.jsx)(k.T,{content:a,rehypePlugins:v})})]})}function u({title:a,content:b,toolName:c,onClose:d}){let{t:j}=(0,g.Bd)(),k=(0,q.jU)(b),l=(0,q.zs)(b),m=(0,q.oK)(b),p=!!l,r=!!m,[t,v]=(0,f.useState)(("Read"===c||"Write"===c)&&r?"file":p?"diff-unified":k?"readable":"json"),w=(0,f.useRef)(null),x=(0,o.o)(w),y=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-0 md:p-4",onClick:d,children:(0,e.jsxs)("div",{className:"bg-card shadow-xl w-full max-w-[90%] h-full md:h-[90vh] rounded-none md:rounded-lg flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a}),m&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(m),(0,n.oR)(j("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:j("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsxs)("div",{className:"flex items-center gap-3",children:[k&&(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[p&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>v("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.sideBySide"),children:"Split"}),(0,e.jsx)("button",{onClick:()=>v("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.unified"),children:"Unified"})]}),r&&(0,e.jsx)("button",{onClick:()=>v("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.previewFile"),children:"File"}),(0,e.jsx)("button",{onClick:()=>v("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:j("common.readable")}),(0,e.jsx)("button",{onClick:()=>v("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===t&&m?(0,e.jsx)(s,{filePath:m}):"diff-unified"===t&&l?(0,e.jsx)(i.xU,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"diff-split"===t&&l?(0,e.jsx)(i.xZ,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"readable"===t&&k?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o._,{search:x}),(0,e.jsx)("pre",{ref:w,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,q.xb)(b)})]}):(0,e.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:k?(0,q.C6)(b):b})})]})});return(0,e.jsx)(h.ZL,{children:y})}d()}catch(a){d(a)}})},61591:(a,b,c)=>{"use strict";c.d(b,{o:()=>g});var d=c(48249);c(67484);let e={ts:"#3178c6",tsx:"#3178c6",js:"#f1e05a",jsx:"#61dafb",mjs:"#f1e05a",cjs:"#f1e05a",html:"#e44d26",css:"#563d7c",scss:"#cd6799",sass:"#cd6799",less:"#1d365d",vue:"#41b883",svelte:"#ff3e00",json:"#cbcb41",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4121",xml:"#e37933",env:"#ecd53f",md:"#519aba",mdx:"#519aba",txt:"#89898a",py:"#3572a5",go:"#00add8",rs:"#dea584",java:"#b07219",kt:"#a97bff",kts:"#a97bff",c:"#555555",h:"#555555",cpp:"#f34b7d",hpp:"#f34b7d",rb:"#701516",php:"#4f5d95",sh:"#89e051",bash:"#89e051",zsh:"#89e051",png:"#a074c4",jpg:"#a074c4",jpeg:"#a074c4",gif:"#a074c4",svg:"#ffb13b",webp:"#a074c4",ico:"#a074c4",lock:"#89898a",gitignore:"#f14e32",dockerfile:"#2496ed",sql:"#e38c00",graphql:"#e535ab",gql:"#e535ab",default:"#8a8a8a"},f={"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 g({name:a,className:b="",size:c=16}){let h,i=f[h=a.toLowerCase()]?f[h]:e[a.split(".").pop()?.toLowerCase()||""]||e.default,j=a.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.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"===j||"tsx"===j&&a.includes("component")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.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,d.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,d.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:i})]}):["md","mdx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.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(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.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,d.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,d.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:i}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:i,strokeWidth:"2",fill:"none"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:i}),(0,d.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:i,strokeWidth:"2",strokeLinecap:"round"})]}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:i}),(0,d.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"html"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.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(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.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(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,d.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===j||".gitignore"===a.toLowerCase()?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:i}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,d.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===j||"dockerfile"===a.toLowerCase()||a.toLowerCase().startsWith("dockerfile")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:i}),(0,d.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"===j||a.startsWith(".env")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:i}),(0,d.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"vue"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:i}),(0,d.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M14 3v5h5",stroke:i,strokeWidth:"1.5",fill:"none"})]})}},61632:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{y:()=>m});var e=c(67484),f=c(20586),g=c(9804),h=c(208),i=c(79606),j=c(33281),k=c(85655),l=a([f]);function m({cwd:a,addToRecentFiles:b}){let[c,d]=(0,e.useState)(null),[l,n]=(0,e.useState)(""),[o,p]=(0,e.useState)([]),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)([]),[u,v]=(0,e.useState)([]),[w,x]=(0,e.useState)(new Set),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(null),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)(!0),[K,L]=(0,e.useState)(!1),[M,N]=(0,e.useState)(!1),[O,P]=(0,e.useState)(null),Q=(0,e.useRef)(null),[R,S]=(0,e.useState)(null),[T,U]=(0,e.useState)(!1),[V,W]=(0,e.useState)(""),[X,Y]=(0,e.useState)(""),[Z,$]=(0,e.useState)([]),[_,aa]=(0,e.useState)([]),[ab,ac]=(0,e.useState)(new Set),[ad,ae]=(0,e.useState)(null),[af,ag]=(0,e.useState)(null),[ah,ai]=(0,e.useState)(!1),[aj,ak]=(0,e.useState)(!1),al=(0,e.useCallback)(()=>{D(!0),P(null),j.t4.runPromise((0,k.r4)(a).pipe(i.match({onSuccess:a=>{a.local&&a.current?(d(a),n(a.current),a.upstream&&W(a.upstream)):(P(h.A.t("git.cannotGetBranches")),d(null))},onFailure:a=>{console.error(a),"NotFoundError"===a._tag?P(h.A.t("git.notGitRepo")):P(h.A.t("git.getBranchesFailed")),d(null)}}))).finally(()=>D(!1))},[a]),am=(0,e.useCallback)(b=>{F(!0),r(null),t([]),v([]),z(null),B(null),J(!0),j.t4.runPromise((0,k.Bj)(a,b,g.B_).pipe(i.match({onSuccess:a=>{let b=a.commits||[];p(b),J(b.length>=g.B_)},onFailure:a=>{console.error(a)}}))).finally(()=>F(!1))},[a]),an=(0,e.useCallback)(()=>{if(G||!I||!l)return;H(!0);let b=o.length;j.t4.runPromise((0,k.Bj)(a,l,g.B_,b).pipe(i.match({onSuccess:a=>{let b=a.commits||[];b.length>0&&p(a=>[...a,...b]),J(b.length>=g.B_)},onFailure:a=>{console.error(a)}}))).finally(()=>H(!1))},[a,l,o.length,G,I]),ao=(0,e.useCallback)(a=>{let{scrollTop:b,scrollHeight:c,clientHeight:d}=a.target;c-b-d<100&&an()},[an]),ap=(0,e.useCallback)(b=>{r(b),z(null),B(null),L(!0),j.t4.runPromise((0,k.Zi)(a,b.hash).pipe(i.match({onSuccess:a=>{let b=a.files||[];t(b);let c=(0,f.Do)(b);v(c),x(new Set((0,f.Sz)(c)))},onFailure:a=>{console.error(a)}}))).finally(()=>L(!1))},[a]),aq=(0,e.useCallback)(c=>{q&&(z(c),b(c.path),N(!0),j.t4.runPromise((0,k.Zi)(a,q.hash,c.path).pipe(i.match({onSuccess:a=>B(a),onFailure:a=>{console.error(a)}}))).finally(()=>N(!1)))},[a,q,b]),ar=(0,e.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),as=(0,e.useCallback)(b=>{ai(!0),ae(null),ag(null),j.t4.runPromise((0,k.yy)(a,b).pipe(i.match({onSuccess:a=>{let b=a.files||[];$(b);let c=(0,f.Do)(b);aa(c),ac(new Set((0,f.Sz)(c)))},onFailure:a=>{console.error(a)}}))).finally(()=>ai(!1))},[a]),at=(0,e.useCallback)(c=>{ae(c),b(c.path),ak(!0),j.t4.runPromise((0,k.yy)(a,X,c.path).pipe(i.match({onSuccess:a=>ag(a),onFailure:a=>{console.error(a)}}))).finally(()=>ak(!1))},[a,X,b]),au=(0,e.useCallback)(a=>{ac(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),av=(0,e.useCallback)(a=>{if(U(a),a){let a="origin/main";Y(a),as(a)}else $([]),aa([]),ae(null),ag(null),Y("")},[V,as]),aw=(0,e.useCallback)(a=>{S({x:a.clientX,y:a.clientY})},[]),ax=(0,e.useCallback)(()=>{S(null)},[]);return{branches:c,selectedBranch:l,setSelectedBranch:n,commits:o,setCommits:p,selectedCommit:q,setSelectedCommit:r,historyFiles:s,historyFileTree:u,historyExpandedPaths:w,historySelectedFile:y,historyFileDiff:A,isLoadingBranches:C,isLoadingCommits:E,isLoadingMore:G,hasMoreCommits:I,setHasMoreCommits:J,isLoadingHistoryFiles:K,isLoadingHistoryDiff:M,historyError:O,commitListRef:Q,tooltipPos:R,loadBranches:al,loadCommits:am,loadMoreCommits:an,handleCommitListScroll:ao,handleSelectCommit:ap,handleSelectHistoryFile:aq,handleHistoryToggle:ar,handleCommitInfoMouseMove:aw,handleCommitInfoMouseLeave:ax,compareMode:T,toggleCompareMode:av,compareBaseBranch:X,setCompareBaseBranch:Y,upstreamBranch:V,compareFiles:Z,compareFileTree:_,compareExpandedPaths:ab,compareSelectedFile:ad,compareFileDiff:af,isLoadingCompareFiles:ah,isLoadingCompareDiff:aj,handleSelectCompareFile:at,handleCompareToggle:au,loadCompareFiles:as}}f=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},62336:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{V:()=>a});var e=c(48249),f=c(67484),g=c(7833),h=c(44384),i=c(83003),j=c(30458),k=c(62751),l=c(33281),m=c(85655),n=c(41224);let a=(0,f.memo)(function({onSend:a,disabled:b,cwd:c,engine:d,onShowGitStatus:o,onShowComments:p,onShowUserMessages:q,onOpenNote:r,onCreateScheduledTask:s}){let{t}=(0,h.Bd)(),[u,v]=(0,f.useState)(""),[w,x]=(0,f.useState)(0),[y,z]=(0,f.useState)([]),[A,B]=(0,f.useState)([]),[C,D]=(0,f.useState)([]),[E,F]=(0,f.useState)(!1),[G,H]=(0,f.useState)(0),[I,J]=(0,f.useState)(!1),K=(0,f.useRef)(null),L=(0,f.useRef)(null),M=(0,f.useCallback)(()=>{let a=K.current;if(!a)return;a.style.height="auto";let b=Math.max(38,Math.min(a.scrollHeight,200));a.style.height=`${b}px`},[]);(0,f.useLayoutEffect)(()=>{M()},[u,M]),(0,f.useEffect)(()=>{l.t4.runPromiseExit((0,n.M5)()).then(a=>{"Success"===a._tag?B(a.value):console.error("Failed to load commands:",a.cause)})},[]);let N=(0,f.useCallback)(async()=>{let a=await l.t4.runPromiseExit((0,n.l1)());if("Success"===a._tag){let b=a.value.skills??a.value,c=(Array.isArray(b)?b:[]).filter(a=>a.valid&&!!a.name).map(a=>({name:`/${a.name}`,description:a.description||"",source:"skill",skillPath:a.path,argumentHint:a.argumentHint}));D(c)}else console.error("Failed to load skills:",a.cause)},[]);(0,f.useEffect)(()=>(N(),(0,k.U)(N)),[N]);let O=(0,f.useMemo)(()=>{let a=0===w?0:u.lastIndexOf("\n",w-1)+1,b=u.indexOf("\n",w),c=-1===b?u.length:b;return{text:u.slice(a,c),start:a,end:c}},[u,w]),P=(0,f.useMemo)(()=>{let a=O.text.match(/^\s*([/@])([a-zA-Z0-9-]*)$/);return a?{marker:a[1],verb:a[2].toLowerCase()}:null},[O.text]),Q=(0,f.useMemo)(()=>d&&"claude"!==d&&"claude2"!==d?[]:[{name:"/plan",description:"Enable plan mode (read-only). /plan <task> to plan a task; /plan off to disable.",source:"builtin",argumentHint:"[task|off]"}],[d]),R=(0,f.useMemo)(()=>{if(!P)return[];let{verb:a}=P,b=b=>b.name.slice(1).toLowerCase().startsWith(a);return[...Q.filter(b),...A.filter(b),...C.filter(b)]},[P,Q,A,C]),S=!I&&!!P&&R.length>0,T=(0,f.useRef)(u);(0,f.useLayoutEffect)(()=>{T.current!==u&&(queueMicrotask(()=>H(0)),I&&queueMicrotask(()=>J(!1)),T.current=u)},[u,I]),(0,f.useLayoutEffect)(()=>{if(S&&L.current){let a=L.current.children[G];a&&a.scrollIntoView({block:"nearest"})}},[G,S]);let U=(0,f.useCallback)(()=>{let c=u.trim();(c||y.length>0)&&!b&&(a(c,y.length>0?y:void 0),v(""),z([]),K.current&&(K.current.style.height="auto"))},[u,y,b,a]),V=(0,f.useCallback)(a=>{let b=P?.marker??"/",c=`${b}${a.name.slice(1)} `,d=u.slice(0,O.start),e=u.slice(O.end),f=d+c+e,g=d.length+c.length;v(f),x(g),requestAnimationFrame(()=>{let a=K.current;a&&(a.focus(),a.setSelectionRange(g,g))})},[u,O,P]),W=(0,f.useCallback)(a=>{if(!a.nativeEvent.isComposing){if(S&&R.length>0){if("ArrowDown"===a.key){a.preventDefault(),H(a=>(a+1)%R.length);return}if("ArrowUp"===a.key){a.preventDefault(),H(a=>(a-1+R.length)%R.length);return}if("Enter"===a.key){a.preventDefault(),V(R[G]);return}if("Escape"===a.key){a.preventDefault(),J(!0);return}if("Tab"===a.key){a.preventDefault(),V(R[G]);return}}"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),U())}},[S,R,G,V,U]),X=(0,f.useCallback)(a=>{let b=a.clipboardData?.items;if(!b)return;let c=["image/png","image/jpeg","image/webp","image/gif"];for(let d of Array.from(b)){let b=c.find(a=>d.type===a);if(b){a.preventDefault();let c=d.getAsFile();if(!c)continue;if(c.size>5242880){alert(t("chat.imageSizeLimit",{size:(c.size/1024/1024).toFixed(2)}));continue}let e=new FileReader;e.onload=a=>{let c=a.target?.result;if(!c)return;let d=c.replace(/^data:image\/\w+;base64,/,""),e={id:`img-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,data:d,preview:c,media_type:b};z(a=>[...a,e])},e.readAsDataURL(c)}}},[t]),Y=(0,f.useCallback)(a=>{z(b=>b.filter(b=>b.id!==a))},[]);return(0,e.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,e.jsx)(i.k,{images:y,onRemove:Y,disabled:b}),S&&R.length>0&&(0,e.jsx)("div",{ref:L,className:"absolute bottom-full left-0 right-0 mx-4 mb-2 max-h-64 overflow-y-auto bg-card border border-border rounded-lg shadow-lg",children:R.map((a,b)=>{let c=b>0?R[b-1]:null,d="skill"===a.source&&(!c||"skill"!==c.source),f="skill"!==a.source&&0===b;return(0,e.jsxs)("div",{children:[f&&(0,e.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Commands"}),d&&(0,e.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Skills"}),(0,e.jsxs)("div",{onClick:()=>V(a),className:`px-4 py-2 cursor-pointer ${b===G?"bg-brand/10":"hover:bg-accent"}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("span",{className:"font-mono text-sm font-medium text-foreground",children:(P?.marker??"/")+a.name.slice(1)}),(0,e.jsx)("span",{className:"flex-1 text-sm text-muted-foreground truncate",children:"builtin"===a.source?t(`commands.${a.name.slice(1)}`,{defaultValue:a.description}):a.description}),(0,e.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${(a=>{switch(a){case"builtin":return"bg-brand/15 text-brand dark:bg-brand/25 dark:text-teal-11";case"skill":return"bg-purple-9/15 text-purple-11 dark:bg-purple-9/25 dark:text-purple-11"}})(a.source)}`,children:(a=>{switch(a){case"builtin":return t("common.builtin");case"skill":return"Skill"}})(a.source)})]}),"skill"===a.source&&a.argumentHint&&(0,e.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 pl-0 truncate",children:a.argumentHint})]})]},a.name)})}),(0,e.jsxs)("div",{className:"flex gap-2 items-end p-4",children:[(0,e.jsx)("button",{onClick:async()=>{if(!c)return;let a=await l.t4.runPromiseExit((0,m.Iz)(c,["."]));"Success"===a._tag?((0,g.oR)(t("toast.stagedAllFiles"),"success"),window.dispatchEvent(new CustomEvent("git-status-changed"))):(console.error("Error staging files:",a.cause),(0,g.oR)(t("toast.stageFailed"),"error"))},className:"p-2 text-green-11 hover:text-green-10 hover:bg-green-9/10 active:bg-green-9/20 active:scale-95 rounded-lg transition-all",title:t("chat.stageAll"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),o&&(0,e.jsx)("button",{onClick:o,className:"p-2 text-brand hover:text-teal-10 hover:bg-brand/10 active:bg-brand/20 active:scale-95 rounded-lg transition-all",title:t("chat.viewGitChanges"),children:(0,e.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"6",cy:"6",r:"2",strokeWidth:2}),(0,e.jsx)("circle",{cx:"18",cy:"6",r:"2",strokeWidth:2}),(0,e.jsx)("circle",{cx:"6",cy:"18",r:"2",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 8v10M18 8v4c0 2-2 4-6 4"})]})}),p&&(0,e.jsx)("button",{onClick:p,className:"p-2 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95 rounded-lg transition-all",title:t("chat.viewAllComments"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),q&&(0,e.jsx)("button",{onClick:q,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:t("chat.userMessages"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),r&&(0,e.jsx)("button",{onClick:r,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95 rounded-lg transition-all",title:t("chat.projectNotes"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})}),s&&(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("button",{onClick:()=>F(!E),className:`p-2 rounded-lg transition-all ${E?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-accent active:bg-muted active:scale-95"}`,title:t("chat.scheduledTasks"),children:(0,e.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]})}),E&&(0,e.jsx)(j.E,{onClose:()=>F(!1),onCreate:s})]}),(0,e.jsx)("textarea",{ref:K,value:u,onChange:a=>{v(a.target.value),x(a.target.selectionStart??a.target.value.length)},onSelect:a=>x(a.currentTarget.selectionStart??0),onKeyDown:W,onPaste:X,placeholder:b?t("chat.placeholderDisabled"):t("chat.placeholder"),rows:1,className:"flex-1 resize-none px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-ring bg-card text-foreground placeholder-slate-9"})]})]})});d()}catch(a){d(a)}})},62473:(a,b,c)=>{"use strict";c.d(b,{g:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({tokenUsage:a,rateLimitInfo:b}){let{t:c}=(0,f.Bd)(),[h,i]=(0,e.useState)(()=>Date.now()),j=b?.status==="rejected"?"text-red-500":b?.status==="allowed_warning"?"text-yellow-500":"text-muted-foreground",k=b?.status==="rejected"?c("chat.rateLimitRejected","Rate Limited"):b?.status==="allowed_warning"?c("chat.rateLimitWarning","Approaching Limit"):null,l=a=>{if(!a)return"";let b=(a<1e12?1e3*a:a)-h;if(b<=0)return"";let c=Math.ceil(b/6e4);if(c<60)return`${c}m`;let d=Math.floor(c/60),e=c%60;return e>0?`${d}h${e}m`:`${d}h`},m=a=>a?a.replace(/_/g," "):"";return(0,d.jsx)("div",{className:"px-4 py-1.5 border-t border-border bg-secondary",children:(0,d.jsxs)("div",{className:"flex items-center justify-end gap-4 text-xs text-muted-foreground",children:[b&&k&&(0,d.jsxs)("span",{className:`flex items-center gap-1 ${j}`,title:[b.rateLimitType&&`Type: ${m(b.rateLimitType)}`,null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&`Resets in: ${l(b.resetsAt)}`,b.isUsingOverage&&"Using overage"].filter(Boolean).join(" \xb7 "),children:["rejected"===b.status?(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:[(0,d.jsx)("strong",{children:k}),null!=b.utilization&&` ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&` \xb7 ${l(b.resetsAt)}`]})]}),b&&!k&&b.resetsAt&&(0,d.jsxs)("span",{className:"flex items-center gap-1.5",title:[b.rateLimitType&&m(b.rateLimitType),null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,`Resets in: ${l(b.resetsAt)}`].filter(Boolean).join(" \xb7 "),children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),null!=b.utilization?(0,d.jsxs)("span",{children:[(100*b.utilization).toFixed(0),"%"]}):(0,d.jsx)("span",{children:l(b.resetsAt)})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsxs)("span",{children:[c("chat.context"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens).toLocaleString()})]})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),(0,d.jsxs)("span",{children:[c("chat.output"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:a.outputTokens.toLocaleString()})]})]}),(a.cacheReadInputTokens>0||a.cacheCreationInputTokens>0)&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-brand",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})}),(0,d.jsxs)("span",{children:["Cache: ",(a.cacheReadInputTokens/(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens)*100).toFixed(0),"%"]})]}),a.totalCostUsd>0&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-green-11",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:["$",a.totalCostUsd.toFixed(4)]})]})]})})}},62751:(a,b,c)=>{"use strict";function d(){}function e(a){return()=>{}}c.d(b,{U:()=>e,k:()=>d})},63041:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({cwd:a,sessionId:b,onOpenProjectSessions:c,onOpenSessionBrowser:h,onOpenSettings:i}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1);return(0,d.jsx)("div",{className:"border-b border-border px-4 py-3 bg-card",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6"}),(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"One seat. One AI. Everything under control."})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[a&&(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help",title:`CWD: ${a}`,children:a}),!a&&b&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Session: ",b.slice(0,8),"..."]}),a&&(0,d.jsx)("button",{onClick:c,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:h,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("sessions.browseAllSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),b&&(0,d.jsx)("button",{onClick:()=>{let a=`claude -r ${b}`;navigator.clipboard.writeText(a).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},className:`p-2 rounded-lg transition-colors ${k?"text-green-500 bg-green-500/10":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:k?j("chat.copiedCommandTooltip"):j("chat.copyCommandTooltip",{sessionId:b}),children:k?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),(0,d.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:j("settings.title"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})]})})}},63913:(a,b,c)=>{"use strict";c.a(a,async(a,b)=>{try{var d=c(48249),e=c(3560),f=c(56696),g=c(74493),h=a([f]);f=(h.then?(await h)():h)[0],(0,e.Aq)({type:"database",idPrefix:"db",match(a){let b=a.trim().toLowerCase();return b.startsWith("postgresql://")||b.startsWith("postgres://")},parse(a){let b=a.trim(),c=b;try{let a=new URL(b),d=a.pathname.replace(/^\//,"")||"postgres";c=`${d}@${a.hostname}${a.port?":"+a.port:""}`}catch{}return{connectionString:b,displayName:c}},fromHistory:a=>({connectionString:a.connectionString,displayName:a.displayName||a.connectionString}),toHistory:a=>({connectionString:a.connectionString,displayName:a.displayName}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l}){return(0,d.jsx)(f.M,{id:a.id,connectionString:a.connectionString,displayName:a.displayName,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l})},async onClose(a){await (0,g.ax)("db",a.id)}}),b()}catch(a){b(a)}})},63963:(a,b,c)=>{"use strict";c.d(b,{AS:()=>w,HV:()=>t,If:()=>u,RS:()=>p,TN:()=>q,mO:()=>s,tr:()=>r});let d=null,e="",f=0,g=null,h=!1,i=new Map,j=null,k=null;function l(a){let b;try{b=JSON.parse(a.data)}catch{return}let c=b.type;if("ping"===c)return;if("running"===c){j&&(j(b.commands),j=null);return}let d=b.commandId;if(!d)return;let e=i.get(d);if(e){if("error"===c)e.onError(b.error);else{let{commandId:a,type:d,...f}=b;e.onData(c,f)}("exit"===c||"error"===c)&&i.delete(d)}}function m(a){d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify(a))}function n(a){let b,c=(b="https:"===window.location.protocol?"wss:":"ws:",`${b}//${window.location.host}/ws/terminal?projectCwd=${encodeURIComponent(a)}`);e===c&&d||(w(),h=!1,e=c,function a(){if(h||!e)return;let b=new WebSocket(e);d=b,b.onopen=()=>{for(let a of(f=0,i.keys()))b.send(JSON.stringify({type:"attach",commandId:a}))},b.onmessage=l,b.onclose=()=>{if(d!==b||(d=null,h))return;g&&clearTimeout(g);let c=Math.min(1e3*Math.pow(1.5,f),1e4);f++,g=setTimeout(a,c)},b.onerror=()=>{}}())}function o(){return new Promise((a,b)=>{if(d?.readyState===WebSocket.OPEN)return void a();let c=setInterval(()=>{d?.readyState===WebSocket.OPEN&&(clearInterval(c),clearTimeout(e),a())},50),e=setTimeout(()=>{clearInterval(c),b(Error("WebSocket connection timeout"))},5e3)})}async function p(a){let{cwd:b,command:c,commandId:d,tabId:e,projectCwd:f,env:g,usePty:h,cols:j,rows:k,sourceId:l,onData:p,onError:q}=a;n(f);try{await o()}catch{q("WebSocket connection failed");return}i.delete(d),i.set(d,{onData:p,onError:q}),m({type:"exec",commandId:d,command:c,cwd:b,tabId:e,env:g,...h?{usePty:!0}:{},...j?{cols:j,rows:k}:{},...l?{sourceId:l}:{}})}async function q(a){let{commandId:b,projectCwd:c,onData:d,onError:e}=a;n(c);try{await o()}catch{e("WebSocket connection failed");return}i.set(b,{onData:d,onError:e}),m({type:"attach",commandId:b})}function r(a,b){m({type:"stdin",commandId:a,data:b})}function s(a,b,c){m({type:"resize",commandId:a,cols:b,rows:c})}function t(a){m({type:"interrupt",pid:a})}function u(a){return k||(k=v(a))}async function v(a){try{n(a);try{await o()}catch{return[]}return await new Promise(a=>{j=b=>{a(b)},m({type:"running"}),setTimeout(()=>{j&&(j=null,a([]))},3e3)})}finally{k=null}}function w(){if(h=!0,g&&(clearTimeout(g),g=null),d){let a=d;d=null,a.close()}i.clear(),j&&(j([]),j=null),k=null,e="",f=0}},64340:(a,b,c)=>{"use strict";c.d(b,{r:()=>e});var d=c(67484);function e(){let[a,b]=(0,d.useState)(),[c,e]=(0,d.useState)(),f=!!a&&!!c&&function(a,b){let c=a=>a.replace(/^v/,"").split("-")[0].split(".").map(a=>parseInt(a,10)||0),d=c(a),e=c(b),f=Math.max(d.length,e.length);for(let a=0;a<f;a++){let b=d[a]??0,c=e[a]??0;if(b!==c)return b-c}return 0}(c,a)>0;return{current:a,latest:c,hasUpdate:f}}c(33281),c(65484)},65395:(a,b,c)=>{"use strict";c.d(b,{useTabState:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call useTabState() from the server but useTabState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","useTabState")},65484:(a,b,c)=>{"use strict";c.d(b,{Cq:()=>n,D0:()=>q,DZ:()=>i,H7:()=>o,It:()=>s,Kl:()=>w,M5:()=>h,Or:()=>k,Q1:()=>u,QW:()=>p,Wr:()=>j,Yn:()=>r,b2:()=>v,em:()=>t,zF:()=>m});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=()=>f("/api/settings"),i=a=>f("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),j=()=>f("/api/version"),k=()=>f("/api/extension/version"),l=a=>a?`/api/note?cwd=${encodeURIComponent(a)}`:"/api/note",m=a=>f(l(a)),n=(a,b)=>g(l(a),{content:b}),o=()=>f("/api/sessions/projects"),p=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),q=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),r=a=>g("/api/project-settings",a),s=()=>f("/api/pick-folder"),t=a=>g("/api/open-vscode",{cwd:a}),u=a=>g("/api/open-cursor",{cwd:a}),v=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),w=a=>g("/api/git/worktree",a)},65543:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});let d=new Set(["function","class","method"]);function e(a){return d.has(a.kind)}},67045:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(48249);function e({error:a,reset:b}){return(0,d.jsx)("html",{children:(0,d.jsx)("body",{children:(0,d.jsxs)("div",{style:{padding:"2rem",fontFamily:"system-ui, sans-serif"},children:[(0,d.jsx)("h2",{children:"Something went wrong"}),(0,d.jsx)("p",{style:{color:"#666"},children:a.message}),(0,d.jsx)("button",{onClick:b,style:{marginTop:"1rem",padding:"0.5rem 1rem",cursor:"pointer",borderRadius:"0.375rem",border:"1px solid #ccc",background:"#fff"},children:"Try again"})]})})})}},67115:(a,b,c)=>{"use strict";c.d(b,{Q:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(57031),h=c(88214),i=c(33281),j=c(41224);function k({isOpen:a,onClose:b,cwd:c,onSelectSession:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)(""),v=(0,e.useRef)(null);(0,e.useCallback)(async()=>{if(!c)return;q(!0),s(null);let a=c.replace(/\//g,"-"),b=await i.t4.runPromiseExit((0,j.QW)(a));"Success"===b._tag?o(b.value):s("Failed to load sessions"),q(!1)},[c]);let w=n.filter(a=>{if(!t)return!0;let b=t.toLowerCase();return void 0!==a.searchText?a.searchText.includes(b):a.title.toLowerCase().includes(b)||a.firstMessages.some(a=>a.toLowerCase().includes(b))||a.lastMessages.some(a=>a.toLowerCase().includes(b))});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:b}),(0,d.jsxs)("div",{className:"relative w-full max-w-7xl h-[90vh] mx-4 bg-card rounded-lg shadow-xl flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:m("sessions.sessionList")}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:c,children:c})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsx)("input",{ref:v,type:"text",placeholder:m("sessions.searchSessions"),value:t,onChange:a=>u(a.target.value),className:"px-2 py-1 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[p&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:m("sessions.loadingSessions")})]})}),r&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:r})}),!p&&!r&&0===w.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:m(t?"sessions.noMatchingSessions":"sessions.noSessionsYet")})}),!p&&!r&&w.length>0&&(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:w.map(a=>(0,d.jsxs)("div",{onClick:()=>{let d;return d=(a.path.split("/").pop()||"").replace(".jsonl",""),void(l?(l(d,a.title),b()):(0,g.F)(h.n.OpenProject,{cwd:c,sessionId:d}))},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[a.engine&&"claude"!==a.engine&&(0,d.jsx)("span",{className:`shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded ${"claude2"===a.engine?"bg-orange-500/15 text-orange-11":"ollama"===a.engine?"bg-blue-500/15 text-blue-11":"codex"===a.engine?"bg-green-500/15 text-green-11":"kimi"===a.engine?"bg-purple-500/15 text-purple-11":"bg-muted text-muted-foreground"}`,children:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate",title:a.title,children:a.title})]}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(a.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[a.firstMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`first-${b}`)),a.lastMessages.length>0&&(0,d.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),a.lastMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`last-${b}`))]})]},a.path))})]})]})]}):null}},69424:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(44256),j=c(74118),k=c(15273),l=c(46674),m=c(99941),n=c(44643),o=c(32026),p=c(11732),q=c(75513),r=a([q]);function s(a){let b=a.input?.questions||[],c=a.input?.answers||{},d={};if(a.result)try{let b=JSON.parse(a.result);b?.answers&&(d=b.answers)}catch{}return{questions:b,answers:{...c,...d}}}function t({toolCalls:a,onClose:b}){let{t:c}=(0,g.Bd)(),d=(0,q.nH)(),[r,u]=(0,f.useState)({}),[v,w]=(0,f.useState)({}),[x,y]=(0,f.useState)({}),[z,A]=(0,f.useState)({}),B=a.reduce((a,b)=>{let{questions:c}=s(b);return a+c.length},0),C=Object.values(z).filter(Boolean).length,D=(0,f.useCallback)((a,b)=>{u(c=>({...c,[a]:b})),w(b=>({...b,[a]:!1}))},[]),E=(0,f.useCallback)(a=>{w(b=>{let c=!b[a];if(c){let b=x[a]||"";b&&u(c=>({...c,[a]:b}))}return{...b,[a]:c}})},[x]),F=(0,f.useCallback)((a,b)=>{y(c=>({...c,[a]:b})),b&&u(c=>({...c,[a]:b}))},[]),G=(0,f.useCallback)(a=>{A(b=>({...b,[a]:!b[a]}))},[]),H=(0,f.useCallback)(()=>{let b=C>0,d=[];return a.forEach((a,e)=>{let{questions:f}=s(a);f.forEach((a,f)=>{let g=`${e}-${f}`;if(b&&!z[g])return;let h=r[g];d.push(`Q: ${a.question}`),d.push(`A: ${h||c("askQuestion.notSelected")}`),d.push("")})}),d.join("\n").trim()},[a,r,z,C,c]),I=(0,f.useCallback)(()=>{navigator.clipboard.writeText(H()),(0,h.oR)(C>0?c("toast.copiedQA",{count:C}):c("toast.copiedAllQA"))},[H,C,c]),J=(0,f.useCallback)(()=>{d?(d.sendMessage(H()),(0,h.oR)(c("toast.sentQA")),b()):(0,h.oR)(c("askQuestion.sendNoChat"))},[d,H,b,c]),K=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:c("askQuestion.title")}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[c("askQuestion.nQuestions",{count:B}),C>0&&` \xb7 ${c("askQuestion.checkedN",{count:C})}`]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:J,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:C>0?c("askQuestion.sendChecked",{count:C}):c("askQuestion.sendAll"),children:(0,e.jsx)(j.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:I,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:C>0?c("askQuestion.copyChecked",{count:C}):c("askQuestion.copyAll"),children:(0,e.jsx)(k.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)(l.A,{className:"w-5 h-5"})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:a.map((b,d)=>{let{questions:f}=s(b);return f.map((b,g)=>{let h=`${d}-${g}`,i=r[h],j=v[h]||!1,k=z[h]||!1;return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-start gap-2",children:[(0,e.jsx)("button",{onClick:()=>G(h),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-accent transition-colors",title:c("askQuestion.checkToCopy"),children:k?(0,e.jsx)(m.A,{className:"w-4 h-4 text-brand"}):(0,e.jsx)(n.A,{className:"w-4 h-4 text-muted-foreground"})}),b.header&&(0,e.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:b.header}),(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:b.question})]}),(0,e.jsxs)("div",{className:"space-y-1 ml-7",children:[b.options.map((a,b)=>{let c=i===a.label&&!j;return(0,e.jsxs)("button",{onClick:()=>D(h,a.label),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${c?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,e.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:c?(0,e.jsx)(o.A,{className:"w-3.5 h-3.5 text-brand"}):(0,e.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("div",{className:`text-sm ${c?"text-foreground font-medium":"text-foreground"}`,children:a.label}),a.description&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]})]},b)}),(0,e.jsxs)("button",{onClick:()=>E(h),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-accent/50 ${j?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,e.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:j?(0,e.jsx)(o.A,{className:"w-3.5 h-3.5 text-brand"}):(0,e.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(p.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:c("askQuestion.custom")})]})]}),j&&(0,e.jsx)("div",{className:"ml-6 mt-1",children:(0,e.jsx)("input",{type:"text",autoFocus:!0,value:x[h]||"",onChange:a=>F(h,a.target.value),placeholder:c("askQuestion.customPlaceholder"),className:"w-full px-3 py-1.5 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-brand text-foreground placeholder:text-muted-foreground"})})]}),(d!==a.length-1||g!==f.length-1)&&(0,e.jsx)("div",{className:"border-b border-border/50 mt-3"})]},h)})})})]})});return(0,e.jsx)(i.ZL,{children:K})}q=(r.then?(await r)():r)[0],d()}catch(a){d(a)}})},70151:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>S});var e=c(48249),f=c(67484),g=c(74429),h=c(44256),i=c(33281),j=c(87808),k=c(85655),l=c(21538),m=c(35208),n=c(7833),o=c(24724),p=c(20586),q=c(7122),r=c(55287),s=c(60591),t=c(9804),u=c(73887),v=c(3353),w=c(25465),x=c(94239),y=c(29939),z=c(23860),A=c(90018),B=c(57014),C=c(94308),D=c(53036),E=c(6662),F=c(20291),G=c(58904),H=c(61632),I=c(76855),J=c(4857),K=c(44384),L=c(18921),M=c(28797),N=c(23881),O=c(21672),P=c(21482),Q=c(94192),R=a([G,H,p,o,l,A,w,u,r,B,m,x,P,O]);function S({onClose:a,cwd:b,initialTab:c="tree",tabSwitchTrigger:d,initialSearchQuery:R,searchQueryTrigger:T}){let{t:U}=(0,K.Bd)(),{activeView:V,onViewChange:W}=(0,Q.R8)(),[X,Y]=(0,f.useState)(c),[Z,$]=(0,f.useState)("code"),_=(0,f.useRef)(null),aa=(0,f.useRef)(!1),[ab,ac]=(0,f.useState)(null),[ad,ae]=(0,f.useState)(null),[af,ag]=(0,f.useState)(!1),ah=(0,f.useRef)(1),ai=(0,f.useRef)(null),[aj,ak]=(0,f.useState)(null),al=(0,f.useRef)(null),[am,an]=(0,f.useState)({isDirty:!1,isSaving:!1}),[ao,ap]=(0,f.useState)(!1),[aq,ar]=(0,f.useState)(!1),[as,at]=(0,f.useState)(null),au=(0,f.useRef)(null),av=(0,L.o)(au),aw=(0,f.useRef)(null),ax=(0,L.o)(aw),ay=(0,I.Sn)(b),az=(0,I.Xm)(b),aA=(0,I.po)(b),aB=(0,J.Q)(),aC=(0,z.F)(),aD=(0,E.W)({cwd:b});(0,I.JL)(b,aD.selectedPath);let aE=(0,F.p)({cwd:b,onSearchComplete:()=>ap(!0)}),aF=(0,G.e)({cwd:b,addToRecentFiles:aD.addToRecentFiles}),aG=(0,f.useMemo)(()=>{let a=new Set;if(aF.status){for(let b of aF.status.staged)a.add(b.path);for(let b of aF.status.unstaged)a.add(b.path)}return a},[aF.status]),aH=(0,f.useMemo)(()=>{let a=new Map;if(aF.status){for(let b of aF.status.staged)a.set(b.path,"staged");for(let b of aF.status.unstaged)a.set(b.path,"unstaged")}return a},[aF.status]),aI=(0,H.y)({cwd:b,addToRecentFiles:aD.addToRecentFiles}),aJ=(0,f.useRef)(!1),aK=(0,f.useCallback)(a=>{aD.setFileContent(b=>b?.type==="text"?{...b,content:a}:b),aD.showEditor||(aJ.current=!0,aD.setShowEditor(!0))},[aD]),aL=(0,f.useCallback)(a=>{aD.setShowEditor(!0)},[aD]),aM=(0,f.useCallback)(async()=>{if(!aD.fileContent||"text"!==aD.fileContent.type||!aD.fileContent.content)return;let a=await i.t4.runPromiseExit((0,j.OJ)({cwd:b,path:aD.selectedPath,content:aD.fileContent.content}));try{if("Failure"===a._tag||!a.value.ok)throw Error("Failed to save file");let b=a.value.data?.mtime;b&&aD.setFileContent(a=>a?.type==="text"?{...a,mtime:b}:a),(0,n.oR)(U("toast.savedSuccess"),"success")}catch{(0,n.oR)(U("toast.saveFailed"),"error")}},[b,aD]),aN=(0,f.useCallback)(()=>{if(!aD.selectedPath)return;let a=ah.current,b=ai.current;a>0&&aD.updateRecentFilePosition(aD.selectedPath,a,b?b.cursorLine+1:a,b?b.cursorCol+1:1)},[aD]),aO=(0,f.useCallback)(async(a,b)=>{let c=a!==aD.selectedPath;if(c&&aD.showEditor){if(am.isDirty&&(!await (0,n.lJ)(U("fileBrowser.saveBeforeSwitch"),{confirmText:U("fileBrowser.saveAndSwitch"),cancelText:U("common.cancel")})||(await al.current?.save(),al.current?.isDirty)))return;aD.setShowEditor(!1)}c&&aN(),aD.handleSelectFile(a,b)},[aD,aN,am.isDirty,U]),aP=(0,f.useMemo)(()=>{let a=aE.contentSearchResults;if(0===a.length)return{files:[],expandDirs:new Set,matchMap:new Map};let b=new Map,c=[];for(let d of a)b.set(d.path,d),c.push(d.path);let d=(0,t.v3)(c),e=new Set((0,t.tW)(d));return{files:d,expandDirs:e,matchMap:b}},[aE.contentSearchResults]),[aQ,aR]=(0,f.useState)(new Set),aS=(0,f.useCallback)(a=>{aR(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),aT=(0,f.useCallback)(a=>{if(a.isDirectory)return null;let b=aP.matchMap.get(a.path);return b?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:b.matches.length}):null},[aP.matchMap]),aU=ao&&aE.contentSearchResults.length>0,[aV,aW]=(0,f.useState)("selected"),aX=!!aD.selectedPath&&null!==(0,M.c)(aD.selectedPath),aY=(0,f.useCallback)(async(a,c)=>{if(!aD.selectedPath||!aX)return;let d=await ay.goToDefinition(aD.selectedPath,a,c);if(0===d.length)return;let e=d[0],f=b.endsWith("/")?b:b+"/",g=e.file.startsWith(f)?e.file.slice(f.length):e.file;aB.push({filePath:aD.selectedPath,lineNumber:ah.current}),g===aD.selectedPath?aD.setTargetLineNumber(e.line):aO(g,e.line)},[aD,b,aX,ay,aB]),aZ=(0,f.useCallback)((a,b,c)=>{aD.selectedPath&&aX&&az.onTokenMouseEnter(aD.selectedPath,a,b,c)},[aD.selectedPath,aX,az]),a$=(0,f.useCallback)(a=>{let c=b.endsWith("/")?b:b+"/",d=a.file.startsWith(c)?a.file.slice(c.length):a.file;aD.selectedPath&&aB.push({filePath:aD.selectedPath,lineNumber:ah.current}),d===aD.selectedPath?aD.setTargetLineNumber(a.line):aO(d,a.line)},[aD,b,aB]),a_=(0,f.useMemo)(()=>{if(!aF.status)return null;let a=new Map,b=a=>{switch(a){case"modified":default:return"M";case"added":return"A";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?"}};for(let c of aF.status.staged)a.set(c.path,b(c.status));for(let c of aF.status.unstaged)a.set(c.path,b(c.status));return a},[aF.status]),a0=(0,f.useCallback)(a=>{Y(a),aD.setBlameSelectedCommit(null),"history"===a&&aI.selectedBranch&&aI.loadCommits(aI.selectedBranch)},[aD,aI.selectedBranch,aI.loadCommits]);(0,f.useCallback)(()=>{if(!aD.selectedPath)return;let a={filePath:aD.selectedPath,lineNumber:ah.current},b=aB.goBack(a);b&&(b.filePath===aD.selectedPath?aD.setTargetLineNumber(b.lineNumber):aO(b.filePath,b.lineNumber))},[aD,aB]),(0,f.useCallback)(()=>{if(!aD.selectedPath)return;let a={filePath:aD.selectedPath,lineNumber:ah.current},b=aB.goForward(a);b&&(b.filePath===aD.selectedPath?aD.setTargetLineNumber(b.lineNumber):aO(b.filePath,b.lineNumber))},[aD,aB]);let a1=(0,f.useCallback)(async a=>{let c=a.split("/").pop()||a,d=await i.t4.runPromiseExit((0,j.__)({cwd:b,paths:[a],op:"copy"}));"Success"===d._tag?(0,n.oR)(U("toast.copiedName",{name:c}),"success"):(0,n.oR)(U("toast.copyFailed"),"error")},[b,U]),a2=(0,f.useCallback)(async a=>{let c=await i.t4.runPromiseExit((0,j.dt)());if("Success"!==c._tag||!c.value.path)return void(0,n.oR)(U("toast.noFileToPaste"),"info");let d=c.value.path,e=await i.t4.runPromiseExit((0,j.Nn)({cwd:b,targetDir:a,sourceAbsPath:d}));if("Success"===e._tag)(0,n.oR)(U("toast.pastedFile",{name:e.value.newName}),"success"),aD.loadDirectory(a),aD.loadFileIndex();else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:U("toast.pasteFailed");(0,n.oR)(c,"error")}},[b,aD,U]);(0,f.useRef)(0),(0,f.useRef)(aC),(0,f.useRef)(X);let a3=(0,f.useRef)(aI.selectedBranch);a3.current=aI.selectedBranch;let a4=(0,f.useRef)(aD.selectedPath);a4.current=aD.selectedPath;let a5=(0,f.useRef)(aD.fileContent?.type);a5.current=aD.fileContent?.type;let a6=(0,f.useCallback)(async a=>{try{let{data:c}=a;if(!c)return;let d=c.some(a=>"git"===a.type),e=c.some(a=>"file"===a.type),f=[];if((e||d)&&(f.push(i.t4.runPromise((0,j.mP)(b)).then(a=>{a.error||aD.setFiles(b=>(0,t.HR)(a.files??[],b))}).catch(()=>{})),f.push(i.t4.runPromise((0,j.DZ)(b)).then(a=>{a.paths&&aD.setFileIndex(a.paths)}).catch(()=>{})),f.push(i.t4.runPromise((0,j.r9)(b)).then(a=>{aD.setRecentFiles(a.files??[])}).catch(()=>{}))),d||e){f.push(i.t4.runPromise((0,k.lv)(b)).then(a=>{aF.setStatus(a);let b=(0,p.Do)(a.staged),c=(0,p.Do)(a.unstaged);aF.setStagedTree(b),aF.setUnstagedTree(c)}).catch(()=>{})),aF.refreshDiff(),d&&aI.loadBranches();let a=a3.current;a&&f.push(i.t4.runPromise((0,k.Bj)(b,a,t.B_)).then(a=>{let b=a.commits??[];aI.setCommits(b),aI.setHasMoreCommits(b.length>=t.B_)}).catch(()=>{}))}let g=a4.current,h=a5.current;g&&"text"===h&&f.push(i.t4.runPromise((0,j.K9)(b,g)).then(a=>{let b=a.ok?a.data:null;b&&"string"==typeof b.content&&aD.setFileContent({type:"text",content:b.content,size:b.size,mtime:b.mtimeMs,...b.isSymlink?{isSymlink:!0,symlinkTarget:b.symlinkTarget}:{}})}).catch(()=>{})),await Promise.all(f)}catch(a){console.error("File watch handler error:",a)}},[b]);(0,y.h)({url:`/ws/watch?cwd=${encodeURIComponent(b)}`,onMessage:a6,enabled:aC});let a7=(0,f.useCallback)(a=>{aO(a),aD.setShouldScrollToSelected(!0),Y("tree")},[aD,aO]),[a8,a9]=(0,f.useState)(null),ba=(0,f.useCallback)((a,b)=>{aD.setPreviewMarkdown(!0),a7(a),a9(b),b&&setTimeout(()=>a9(null),400)},[aD,a7]);return(0,e.jsxs)(q.SU,{container:ab,children:[(0,e.jsxs)("div",{ref:_,className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsxs)("div",{className:"w-80 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex border-b border-border",children:[(0,e.jsx)("button",{onClick:()=>a0("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===X?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:U("fileBrowser.directoryTree")}),(0,e.jsx)("button",{onClick:()=>a0("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===X?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:U("fileBrowser.searchTab")}),(0,e.jsx)("button",{onClick:()=>a0("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===X?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:U("fileBrowser.recentTab")}),(0,e.jsx)("button",{onClick:()=>a0("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===X?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:U("fileBrowser.changesTab")}),(0,e.jsx)("button",{onClick:()=>a0("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===X?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:U("fileBrowser.historyTab")})]}),"tree"===X&&(0,e.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:aD.searchInputRef,type:"text",value:aD.searchQuery,onChange:a=>aD.setSearchQuery(a.target.value),placeholder:U("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),aD.searchQuery&&(0,e.jsx)("button",{onClick:()=>aD.setSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:U("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>aD.setSearchDirExact(a=>!a),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${aD.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:aD.searchExactMatch?U("fileBrowser.exactMatchOn"):U("fileBrowser.exactMatchOff"),children:"ab"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>aD.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:U("fileBrowser.refreshTree"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:()=>aD.searchTreeExpandedPaths?aD.setSearchTreeExpandedPaths(new Set):aD.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:U("fileBrowser.collapseAll"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===X&&(0,e.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:aE.contentSearchInputRef,type:"text",value:aE.contentSearchQuery,onChange:a=>aE.setContentSearchQuery(a.target.value),onKeyDown:a=>{"Enter"===a.key&&aE.performContentSearch(aE.contentSearchQuery)},placeholder:U("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),aE.contentSearchQuery&&(0,e.jsx)("button",{onClick:()=>aE.setContentSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:U("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>aE.performContentSearch(aE.contentSearchQuery),disabled:aE.isSearching||!aE.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:aE.isSearching?"...":U("common.search")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:aE.searchOptions.caseSensitive,onChange:a=>aE.setSearchOptions(b=>({...b,caseSensitive:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:U("fileBrowser.caseSensitive")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:aE.searchOptions.wholeWord,onChange:a=>aE.setSearchOptions(b=>({...b,wholeWord:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:U("fileBrowser.wholeWord")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:aE.searchOptions.regex,onChange:a=>aE.setSearchOptions(b=>({...b,regex:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:U("fileBrowser.regex")})]}),(0,e.jsx)("input",{type:"text",value:aE.searchOptions.fileType,onChange:a=>aE.setSearchOptions(b=>({...b,fileType:a.target.value})),placeholder:U("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9"})]})]}),"history"===X&&(0,e.jsx)("div",{className:"p-3 border-b border-border",children:aI.compareMode?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,e.jsx)("span",{className:"truncate",children:aI.branches?.current||"HEAD"}),(0,e.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:"HEAD"})]}),(0,e.jsx)("button",{onClick:()=>aI.toggleCompareMode(!1),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors bg-brand text-white",title:U("fileBrowser.compareModeOff"),children:U("fileBrowser.compareMode")})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0 pl-1",children:"vs"}),(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(C.e,{branches:aI.branches,selectedBranch:aI.compareBaseBranch,onSelect:a=>{aI.setCompareBaseBranch(a),aI.loadCompareFiles(a)},isLoading:aI.isLoadingBranches,pinnedBranches:["origin/main",...aI.upstreamBranch&&"origin/main"!==aI.upstreamBranch?[aI.upstreamBranch]:[]]})})]})]}):(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(C.e,{branches:aI.branches,selectedBranch:aI.selectedBranch,onSelect:a=>{aI.setSelectedBranch(a)},isLoading:aI.isLoadingBranches,pinnedBranches:["origin/main",...aI.upstreamBranch&&"origin/main"!==aI.upstreamBranch?[aI.upstreamBranch]:[]]})}),(0,e.jsx)("button",{onClick:()=>aI.toggleCompareMode(!0),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors text-muted-foreground hover:text-foreground hover:bg-accent border border-border",title:U("fileBrowser.compareModeOn"),children:U("fileBrowser.compareMode")})]})}),(0,e.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,e.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===X?"":"hidden"}`,children:[aD.creatingItem&&(0,e.jsxs)("div",{className:"px-2 py-1.5 border-b border-border bg-secondary flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:aD.creatingItem.parentPath?U("fileBrowser.createFileIn",{path:aD.creatingItem.parentPath}):U("fileBrowser.createFile")}),(0,e.jsx)("input",{type:"text",autoFocus:!0,placeholder:U("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{aa.current=!0},onCompositionEnd:()=>{aa.current=!1},onKeyDown:async a=>{if("Enter"===a.key){if(aa.current)return;let c=a.target.value.trim();if(!c)return;let d=aD.creatingItem.parentPath,e=d?`${d}/${c}`:c,f=await i.t4.runPromiseExit((0,j.OJ)({cwd:b,path:e,content:""}));if("Success"===f._tag&&f.value.ok)(0,n.oR)(U("toast.createdFile",{name:c}),"success"),aD.setCreatingItem(null),aD.loadDirectory(d),aD.loadFileIndex(),d&&aD.setExpandedPaths(a=>new Set([...a,d])),aO(e);else if("Success"===f._tag){let a=f.value.data?.error;(0,n.oR)(a||U("toast.createFailed"),"error")}else(0,n.oR)(U("toast.createFailed"),"error")}else"Escape"===a.key&&aD.setCreatingItem(null)},onBlur:()=>aD.setCreatingItem(null)})]}),aD.isLoadingFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("common.loading")}):aD.fileError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:aD.fileError}):(0,e.jsx)(o.h,{files:aD.files,selectedPath:aD.selectedPath,expandedPaths:aD.effectiveExpandedPaths,matchedPaths:aD.matchedPaths,gitStatusMap:a_,loadingDirs:aD.loadingDirs,onSelect:a=>{aD.setShouldScrollToSelected(!1),aO(a)},onToggle:aD.handleToggle,cwd:b,shouldScrollToSelected:aD.shouldScrollToSelected,onScrolledToSelected:()=>aD.setShouldScrollToSelected(!1),onCreateFile:a=>aD.setCreatingItem({type:"file",parentPath:a}),onDelete:(a,b,c)=>ae({path:a,isDirectory:b,name:c}),onRefresh:()=>aD.loadFiles(),onCopyFile:a1,onPaste:a2})]}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===X?"":"hidden"}`,children:aE.isSearching?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aE.searchError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:aE.searchError}):0===aE.contentSearchResults.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:aE.contentSearchQuery?U("fileBrowser.noContentSearchResults"):U("fileBrowser.enterKeywordToSearch")}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[aE.searchStats&&(0,e.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-secondary border-b border-border flex-shrink-0",children:[U("fileBrowser.nFilesNMatches",{files:aE.searchStats.totalFiles,matches:aE.searchStats.totalMatches}),aE.searchStats.truncated&&(0,e.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",U("fileBrowser.resultsTruncated"),")"]})]}),(0,e.jsx)(o.h,{files:aP.files,selectedPath:aD.selectedPath,expandedPaths:aQ,onSelect:a=>{let b=aP.matchMap.get(a);aO(a,b?.matches[0]?.lineNumber),ao||ap(!0)},onToggle:aS,cwd:b,renderActions:aT,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===X?"":"hidden"}`,children:0===aD.recentFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("fileBrowser.noRecentFiles")}):(0,e.jsx)(o.h,{files:aD.recentFilesTree,selectedPath:aD.selectedPath,expandedPaths:aD.recentTreeDirPaths,onSelect:aO,onToggle:t.tE,cwd:b})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===X?"":"hidden"}`,children:aF.statusLoading?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aF.statusError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,e.jsx)("span",{className:"text-red-11 text-sm",children:aF.statusError})}):(0,e.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,e.jsxs)("div",{className:"border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:U("fileBrowser.stagingArea",{count:aF.status?.staged.length||0})}),(0,e.jsx)("button",{onClick:()=>aF.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:U("fileBrowser.refreshChanges"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})})]}),(aF.status?.staged.length||0)>0&&(0,e.jsx)("button",{onClick:aF.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:U("fileBrowser.unstageAll")})]}),(0,e.jsx)(p.VO,{files:aF.stagedTree,selectedPath:aF.statusSelectedFile?.type==="staged"?aF.statusSelectedFile.file.path:null,expandedPaths:aF.stagedExpandedPaths,onSelect:a=>a.file&&aF.handleStatusFileSelect(a.file,"staged"),onToggle:aF.handleStagedToggle,cwd:b,emptyMessage:U("fileBrowser.noStagedFiles"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,p.wI)(a);return 0===b.length?null:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aF.handleUnstageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:U("fileBrowser.unstageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),aF.handleUnstage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:U("fileBrowser.unstageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:U("fileBrowser.workspace",{count:aF.status?.unstaged.length||0})}),(aF.status?.unstaged.length||0)>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:aF.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:U("fileBrowser.discardAll")}),(0,e.jsx)("button",{onClick:aF.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:U("fileBrowser.stageAll")})]})]}),(0,e.jsx)(p.VO,{files:aF.unstagedTree,selectedPath:aF.statusSelectedFile?.type==="unstaged"?aF.statusSelectedFile.file.path:null,expandedPaths:aF.unstagedExpandedPaths,onSelect:a=>a.file&&aF.handleStatusFileSelect(a.file,"unstaged"),onToggle:aF.handleUnstagedToggle,cwd:b,emptyMessage:U("fileBrowser.noUnstagedChanges"),className:"py-1",renderActions:a=>{if(a.isDirectory){let b=(0,p.wI)(a);if(0===b.length)return null;let c=b.map(a=>a.file).filter(Boolean);return(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aF.handleDiscardFiles(c)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:U("fileBrowser.discardNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),aF.handleStageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:U("fileBrowser.stageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return a.file?(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),aF.handleDiscardFile(a.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:U("fileBrowser.discardChanges"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),aF.handleStage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:U("fileBrowser.stageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===X?"":"hidden"}`,children:aI.historyError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,e.jsx)("p",{className:"text-muted-foreground",children:aI.historyError})]})}):aI.compareMode?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:aI.isLoadingCompareFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("fileBrowser.loadingDiff")}):0===aI.compareFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("fileBrowser.noDiffFiles")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:U("fileBrowser.nFilesChanged",{count:aI.compareFiles.length,branch:aI.compareBaseBranch})})}),(0,e.jsx)(p.VO,{files:aI.compareFileTree,expandedPaths:aI.compareExpandedPaths,onToggle:aI.handleCompareToggle,selectedPath:aI.compareSelectedFile?.path||null,onSelect:a=>{a.file&&aI.handleSelectCompareFile(a.file)},cwd:b,showChanges:!0})]})}):(0,e.jsx)("div",{ref:aI.commitListRef,className:"flex-1 overflow-y-auto",onScroll:aI.handleCommitListScroll,children:aI.isLoadingCommits?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("fileBrowser.loadingCommits")}):0===aI.commits.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:U("fileBrowser.noCommits")}):(0,e.jsxs)(e.Fragment,{children:[aI.commits.map(a=>(0,e.jsxs)("div",{onClick:()=>aI.handleSelectCommit(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-accent ${aI.selectedCommit?.hash===a.hash?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),(0,e.jsxs)("span",{className:"text-xs text-slate-9",title:a.date,children:[a.relativeDate," \xb7 ",(0,t.r6)(a.date)]})]}),(0,e.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":a.subject,children:a.subject}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.author})]},a.hash)),aI.isLoadingMore&&(0,e.jsx)("div",{className:"p-3 text-center",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!aI.hasMoreCommits&&aI.commits.length>0&&(0,e.jsx)("div",{className:"p-3 text-center text-xs text-slate-9",children:U("fileBrowser.allLoaded",{count:aI.commits.length})})]})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[("tree"===X||"search"===X||"recent"===X)&&(aD.blameSelectedCommit?(0,e.jsx)(l.n,{isOpen:!0,onClose:()=>aD.setBlameSelectedCommit(null),commit:aD.blameSelectedCommit,cwd:b,embedded:!0,initialFilePath:aD.selectedPath||void 0,onContentSearch:a=>{Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)}}):"map"===Z?(0,e.jsx)(A.O,{cwd:b,highlightedFilePath:aD.selectedPath,changedFiles:aG,onSwitchToCode:()=>$("code"),enableComments:!0,onContentSearch:a=>{Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)},headerExtraLeft:({focalFile:a})=>a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${b}/${a}`),(0,n.oR)(U("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:U("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:b=>{b.stopPropagation(),a7(a)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:U("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]})}):aD.selectedPath?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:aD.selectedPath}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${aD.selectedPath}`),(0,n.oR)(U("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:U("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:a=>{a.stopPropagation(),a7(aD.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:U("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:aD.showEditor?(0,e.jsxs)(e.Fragment,{children:[am.isDirty&&(0,e.jsx)("span",{className:"text-xs text-amber-11",children:U("fileBrowser.unsaved")}),(0,e.jsx)("button",{onClick:()=>al.current?.save(),disabled:!am.isDirty||am.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${am.isDirty&&!am.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:am.isSaving?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):U("common.save")}),(0,e.jsx)("button",{onClick:()=>al.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:U("fileBrowser.closeEdit"),children:U("fileBrowser.closeBtn")})]}):(0,e.jsxs)(e.Fragment,{children:[aD.fileContent?.type==="text"&&(0,s.e$)(aD.selectedPath)&&(0,e.jsx)(w.ShareReviewToggle,{content:aD.fileContent.content||"",sourceFile:aD.selectedPath&&b&&aD.selectedPath.startsWith(b)?aD.selectedPath.slice(b.endsWith("/")?b.length:b.length+1):aD.selectedPath||""}),aD.selectedPath?.endsWith(".json")&&aD.fileContent?.type==="text"&&(0,e.jsx)("button",{onClick:()=>ar(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aq?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,title:U("fileBrowser.toggleJsonReadable"),children:U("common.readable")}),aD.fileContent?.type==="text"&&((0,s.e$)(aD.selectedPath)||(0,s.aR)(aD.selectedPath))&&(0,e.jsx)(e.Fragment,{children:(0,e.jsx)("button",{onClick:()=>aD.setPreviewMarkdown(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aD.previewMarkdown?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,title:aD.previewMarkdown?U("fileBrowser.exitPreview"):U("common.preview"),children:aD.previewMarkdown?U("fileBrowser.exitPreview"):U("common.preview")})}),aD.fileContent?.type==="text"&&!(aD.previewMarkdown&&((0,s.e$)(aD.selectedPath)||(0,s.aR)(aD.selectedPath)))&&(0,e.jsx)("button",{onClick:aD.handleToggleBlame,disabled:aD.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aD.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-accent"} disabled:opacity-50`,title:U("fileBrowser.viewBlame"),children:aD.isLoadingBlame?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),aD.fileContent?.type==="text"&&!(aD.previewMarkdown&&((0,s.e$)(aD.selectedPath)||(0,s.aR)(aD.selectedPath)))&&(0,e.jsx)("button",{onClick:()=>aD.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:U("fileBrowser.editFile"),children:U("common.edit")}),aD.fileContent?.type==="text"&&aD.fileContent.content&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(aD.fileContent.content),(0,n.oR)(U("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:U("fileBrowser.copyFileContent"),children:U("common.copy")}),aD.fileContent?.type==="text"&&!(0,s.e$)(aD.selectedPath)&&!(0,s.aR)(aD.selectedPath)&&(0,e.jsx)("button",{onClick:()=>$("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:U("blockViewer.viewerToggle.toBlock"),children:U("common.codeMap")})]})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:aD.isLoadingContent?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aD.fileContent?"text"===aD.fileContent.type&&"string"==typeof aD.fileContent.content?aD.showBlame&&aD.blameError?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-red-11",children:aD.blameError}),(0,e.jsx)("button",{onClick:()=>aD.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:U("fileBrowser.backToPreview")})]})}):aD.showBlame&&0===aD.blameLines.length&&aD.isLoadingBlame?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):aq&&aD.selectedPath?.endsWith(".json")?(0,e.jsxs)("div",{className:"h-full flex flex-col bg-[#0d1117]",children:[(0,e.jsx)(L._,{search:av}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,e.jsx)("pre",{ref:au,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,s.xb)(aD.fileContent.content)})})]}):aD.previewMarkdown&&(0,s.e$)(aD.selectedPath)&&!aD.showBlame?(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(u.M,{content:aD.fileContent.content,filePath:aD.selectedPath,cwd:b,embedded:!0,onLocalMdLink:ba,scrollToAnchor:a8})}):aD.previewMarkdown&&(0,s.aR)(aD.selectedPath)&&!aD.showBlame?(0,e.jsx)(v.E,{content:aD.fileContent.content,filePath:aD.selectedPath}):(0,e.jsx)(r.Cv,{ref:al,content:aD.fileContent.content,filePath:aD.selectedPath,cwd:b,enableComments:!0,scrollToLine:aj??aD.targetLineNumber,scrollToLineAlign:null!=aj?"start":aD.targetScrollAlign,onScrollToLineComplete:()=>{ak(null),aD.setTargetLineNumber(null)},highlightKeyword:"search"===X?aE.contentSearchQuery:null,visibleLineRef:ah,viStateRef:ai,initialCursorLine:aD.initialCursorLine,initialCursorCol:aD.initialCursorCol,onInitialCursorSet:()=>{aD.setInitialCursorLine(null),aD.setInitialCursorCol(null)},onCmdClick:aX?aY:void 0,onTokenHover:aX?aZ:void 0,onTokenHoverLeave:aX?az.onTokenMouseLeave:void 0,onTokenHoverCancel:aX?az.clearHover:void 0,blameLines:aD.showBlame&&aD.blameLines.length>0?aD.blameLines:void 0,inlineBlameLines:aD.blameLines.length>0?aD.blameLines:void 0,onSelectCommit:aD.setBlameSelectedCommit,editable:aD.showEditor,initialMtime:aD.fileContent.mtime,onEditorClose:a=>{aD.setShowEditor(!1),ak(a)},onSaved:()=>{let a=ah.current??1;aD.loadFileContent(aD.selectedPath),aD.setShowEditor(!1),ak(a)},onEditorStateChange:an,viMode:!0,onContentMutate:aK,onEnterInsertMode:aL,onViSave:aM,onContentSearch:a=>{Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)}}):"image"===aD.fileContent.type&&aD.selectedPath?(0,e.jsx)(D.I,{cwd:b,path:aD.selectedPath,refreshKey:aD.fileContent.mtime,alt:aD.selectedPath}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,e.jsx)("p",{children:aD.fileContent.message||U("fileBrowser.cannotPreview")})]})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:U("fileBrowser.selectFileToPreview")})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,e.jsx)("p",{children:U("fileBrowser.selectFileToPreview")})]})})),"status"===X&&(aF.statusSelectedFile&&aF.statusDiff?(0,e.jsx)(B.m,{cwd:b,selected:aF.statusSelectedFile,diff:aF.statusDiff,showMarkdownPreview:aF.showStatusDiffPreview,setShowMarkdownPreview:aF.setShowStatusDiffPreview,changedFiles:aG,fileGitStatusMap:aH,onContentSearch:a=>{Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)},locateInTree:a7,jsonPreview:as,setJsonPreview:at,jsonPreviewSearch:ax,jsonPreviewPreRef:aw}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:U("fileBrowser.selectFileToViewDiff")})})),"history"===X&&!aI.historyError&&(aI.compareMode?aI.isLoadingCompareDiff?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:U("fileBrowser.loadingDiffContent")}):aI.compareFileDiff?(0,e.jsx)(m.xZ,{oldContent:aI.compareFileDiff.oldContent,newContent:aI.compareFileDiff.newContent,filePath:aI.compareFileDiff.filePath,isNew:aI.compareFileDiff.isNew,isDeleted:aI.compareFileDiff.isDeleted,cwd:b,enableComments:!0,onPreview:!aI.compareFileDiff.isDeleted&&aI.compareFileDiff.filePath.endsWith(".json")?()=>at({content:aI.compareFileDiff.newContent,filePath:aI.compareFileDiff.filePath}):void 0,previewLabel:U("common.readable"),onContentSearch:a=>{Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:aI.compareFiles.length>0?U("fileBrowser.selectFileToViewDiff"):U("fileBrowser.clickCompareToLoad")})}):aI.selectedCommit?(0,e.jsx)(l.n,{isOpen:!0,onClose:()=>aI.setSelectedCommit(null),commit:aI.selectedCommit,cwd:b,embedded:!0,onContentSearch:a=>{Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,e.jsx)("span",{children:U("fileBrowser.selectCommitToView")})}))]})]}),af&&(0,e.jsx)(x.c,{files:aD.files,fileIndex:aD.fileIndex,recentFiles:aD.recentFilePaths,onSelectFile:a=>{aO(a),aD.setShouldScrollToSelected(!0),Y("tree")},onClose:()=>ag(!1)}),(aU||aA.visible)&&(0,e.jsxs)("div",{className:`flex ${aA.visible&&aU?"":"flex-col"}`,children:[aU&&(0,e.jsx)("div",{className:aA.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,e.jsx)(P.D,{results:aE.contentSearchResults,loading:aE.isSearching,totalMatches:aE.searchStats?.totalMatches??0,onSelect:(a,b)=>{aD.selectedPath&&aB.push({filePath:aD.selectedPath,lineNumber:ah.current}),aO(a,b)},onClose:()=>ap(!1),scope:aV,onScopeChange:aW,selectedPath:aD.selectedPath})}),aA.visible&&(0,e.jsx)("div",{className:aU?"flex-1 min-w-0":"",children:(0,e.jsx)(O.D,{references:aA.references,loading:aA.loading,onSelect:a$,onClose:aA.closeReferences})})]})]}),ad&&(0,e.jsx)(h.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-black/50",onClick:()=>ae(null),children:(0,e.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:U("fileBrowser.confirmDelete")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:U("fileBrowser.confirmDeleteMessage",{name:ad.name}).split(/<\/?file>/g).map((a,b)=>1===b?(0,e.jsx)("span",{className:"font-mono text-foreground",children:a},b):a)}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)("button",{onClick:()=>ae(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-accent transition-colors",children:U("common.cancel")}),(0,e.jsx)("button",{onClick:async()=>{let{path:a,name:c}=ad;ae(null);let d=await i.t4.runPromiseExit((0,j.VK)({cwd:b,path:a}));if("Success"===d._tag){(0,n.oR)(U("toast.movedToTrash",{name:c}),"success");let b=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"";aD.loadDirectory(b),aD.loadFileIndex(),aD.selectedPath===a&&aO("")}else{let a="Fail"===d.cause._tag?d.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:U("toast.deleteFailed");(0,n.oR)(c,"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:U("common.delete")})]})]})})}),az.hoverInfo&&ab&&(0,g.createPortal)((0,e.jsx)(N.s,{ref:az.setTooltipEl,displayString:az.hoverInfo.displayString,documentation:az.hoverInfo.documentation,x:az.hoverInfo.x,y:az.hoverInfo.y,container:ab,onMouseEnter:az.onCardMouseEnter,onMouseLeave:az.onCardMouseLeave,onFindReferences:()=>{let{filePath:a,line:b,column:c}=az.hoverInfo;az.clearHover(),aA.findReferences(a,b,c)},onSearch:a=>{az.clearHover(),Y("search"),aE.setContentSearchQuery(a),aE.performContentSearch(a)}}),ab)]})}[G,H,p,o,l,A,w,u,r,B,m,x,P,O]=R.then?(await R)():R,d()}catch(a){d(a)}})},70404:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484);function f(a,b){for(let c=0;c<a.blocks.length;c++){let d=a.blocks[c];if(b>=d.startLine&&b<=d.endLine)return a.prefix[c]+(b-d.startLine)}return null}function g({addedLines:a,blockRanges:b,viewportRange:c,onJumpToLine:h}){let i,j=(0,e.useRef)(null),k=(0,e.useMemo)(()=>(function(a){let b=[...a].sort((a,b)=>a.startLine-b.startLine),c=[0];for(let a of b){let b=Math.max(0,a.endLine-a.startLine+1);c.push(c[c.length-1]+b)}return{blocks:b,prefix:c,total:c[c.length-1]}})(b),[b]),l=(0,e.useMemo)(()=>{if(k.total<=0||0===a.size)return[];let b=[];for(let c of a){let a=k.blocks.find(a=>c>=a.startLine&&c<=a.endLine);a&&b.push({line:c,qname:a.qname})}b.sort((a,b)=>a.line-b.line);let c=[],d=null;for(let a of b)d&&a.line===d.end+1&&a.qname===d.qname?d.end=a.line:(d&&c.push(d),d={start:a.line,end:a.line,qname:a.qname});return d&&c.push(d),c},[a,k]);if(k.total<=0)return null;let m=(a,b)=>{let c=f(k,a),d=f(k,b);return null===c||null===d?null:{top:c/k.total*100,heightPct:(d-c+1)/k.total*100}};return(0,d.jsxs)("div",{ref:j,onClick:a=>{let b=j.current;if(!b)return;let c=b.getBoundingClientRect();if(c.height<=0)return;let d=function(a,b){if(a.total<=0)return null;let c=Math.max(0,Math.min(a.total-1,b));for(let b=0;b<a.blocks.length;b++){let d=a.prefix[b],e=a.prefix[b+1];if(c>=d&&c<e){let e=a.blocks[b];return{qname:e.qname,line:e.startLine+Math.round(c-d)}}}return null}(k,(a.clientY-c.top)/c.height*k.total);if(!d)return;let e=d.line,g=l.find(a=>a.qname===d.qname&&e>=a.start&&e<=a.end);if(g)return void h(g.qname,e);if(l.length>0){let a=Math.max(2,Math.round(.05*k.total)),b=f(k,e);if(null!==b){let c=null,d=1/0;for(let a of l){let e=f(k,a.start),g=f(k,a.end);if(null===e||null===g)continue;let h=b<e?e-b:b>g?b-g:0;h<d&&(c=a,d=h)}if(c&&d<=a){let a=e<c.start?c.start:e>c.end?c.end:e;h(c.qname,a);return}}}let i=k.blocks.find(a=>a.qname===d.qname);i&&h(i.qname,i.startLine)},className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",title:"Diff minimap — click to jump",children:[l.map(a=>{let b=m(a.start,a.end);return b?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-green-9 pointer-events-none",style:{top:`${b.top}%`,height:`${b.heightPct}%`,minHeight:"2px"}},`run:${a.qname}:${a.start}-${a.end}`):null}),c&&c.end>=c.start&&((i=m(c.start,c.end))?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border pointer-events-none",style:{top:`${i.top}%`,height:`${Math.max(1.2,i.heightPct)}%`}}):null)]})}},70440:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(88868);let e=async a=>[{type:"image/x-icon",sizes:"16x16",url:(0,d.fillMetadataSegment)(".",await a.params,"favicon.ico",!0)+"?603d046c9a6fdfbb"}]},70596:(a,b,c)=>{"use strict";c.d(b,{t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,comment:c,container:h,onClose:i,onUpdateComment:j,onDeleteComment:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(c.content),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({x:0,y:0}),t=async()=>{o.trim()&&(await j(c.id,o.trim()),n(!1))},u=async()=>{await k(c.id),i()};return(0,d.jsx)("div",{ref:q,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:r.x,top:r.y},children:(0,d.jsx)("div",{className:"p-3",children:m?(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("textarea",{value:o,onChange:a=>p(a.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:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),t()),"Escape"===a.key&&(n(!1),p(c.content))}}),(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>{n(!1),p(c.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:l("common.cancel")}),(0,d.jsx)("button",{onClick:t,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:l("common.save")})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:c.content}),(0,d.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:l("comments.lineRange",{start:c.startLine,end:c.endLine})}),(0,d.jsxs)("div",{className:"flex gap-1",children:[(0,d.jsx)("button",{onClick:()=>n(!0),className:"p-1 rounded hover:bg-accent text-muted-foreground",title:l("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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,d.jsx)("button",{onClick:u,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-red-9",title:l("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})})]})]})]})})})}},71192:(a,b,c)=>{"use strict";c.d(b,{m_:()=>f,uV:()=>e});var d=c(81218);class e extends d.rN("AppError"){}d.rN("DBError"),d.rN("WSError"),d.rN("FSError"),d.rN("AgentError"),d.rN("ValidationError");class f extends d.rN("NotFoundError"){}d.rN("PermissionError")},72399:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectSidebar() from the server but ProjectSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/ProjectSidebar.tsx","ProjectSidebar")},72529:(a,b,c)=>{"use strict";c.d(b,{m:()=>f});var d=c(48249),e=c(67484);function f({content:a,children:b,className:c}){if(c)return(0,d.jsx)("div",{"data-tooltip":a,className:c,children:b});let g=e.Children.toArray(b);if(1===g.length&&(0,e.isValidElement)(g[0])){let b=g[0];return(0,e.cloneElement)(b,{"data-tooltip":a})}return(0,d.jsx)("div",{"data-tooltip":a,style:{display:"contents"},children:b})}},73414:(a,b,c)=>{"use strict";c.d(b,{YO:()=>d,pU:()=>e});let d=20;function e(a,b,c,f=[]){let g=a.length,h=c=>"unchanged"!==a[c].type||"unchanged"!==b[c].type,i=new Set;for(let a=0;a<g;a++){if(!h(a))continue;let b=Math.max(0,a-3),c=Math.min(g-1,a+3);for(let a=b;a<=c;a++)i.add(a)}let j=[];for(let a=0;a<g;a++){if(i.has(a))continue;let b=a;for(;a<g&&!i.has(a);)a++;j.push({id:j.length,startIdx:b,endIdx:a-1}),a--}for(let a of j){let b=c.get(a.id)??{topRevealed:0,bottomRevealed:0},d=a.endIdx-a.startIdx+1,e=Math.max(0,Math.min(b.topRevealed,d)),f=Math.max(0,Math.min(b.bottomRevealed,d-e));for(let b=a.startIdx;b<a.startIdx+e;b++)i.add(b);for(let b=a.endIdx-f+1;b<=a.endIdx;b++)i.add(b)}let k=[];for(let a=0;a<g;a++){let c;if(i.has(a)){k.push({kind:"diff",idx:a});continue}let e=a;for(;a<g&&!i.has(a);)a++;let h=a-1;a--;let l=j.find(a=>a.startIdx<=e&&h<=a.endIdx);if(!l)continue;let m=h-e+1,n=Math.min(d,m);if(f.length>0&&h+1<g)for(let a=h+1;a<g;a++){let d=b[a].lineNum;if(!(d<=0)){c=function(a,b){let c=null;for(let d of a)d.startLine<=b&&b<=d.endLine&&(!c||d.endLine-d.startLine<c.endLine-c.startLine)&&(c=d);return c}(f,d)??void 0;break}}k.push({kind:"gap-expand",gapId:l.id,direction:"up",revealCount:n}),k.push({kind:"gap-label",gapId:l.id,hiddenCount:m,enclosingFn:c}),k.push({kind:"gap-expand",gapId:l.id,direction:"down",revealCount:n})}return{rows:k,gaps:j}}},73887:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>w});var e=c(48249),f=c(67484),g=c(44384),h=c(74429),i=c(7122),j=c(41051),k=c(42140),l=c(70596),m=c(74754),n=c(7031),o=c(91579),p=c(98356),q=c(84835);c(15466);var r=c(60591),s=c(24680),t=c(25465),u=c(37690),v=a([t]);t=(v.then?(await v)():v)[0];let x=[q.W];function w({content:a,filePath:b,cwd:c,onClose:d,sourceFile:q,embedded:v=!1,onLocalMdLink:y,scrollToAnchor:z}){let A=q||(c&&b.startsWith(c)?b.slice(c.endsWith("/")?c.length:c.length+1):b),{t:B}=(0,g.Bd)(),C=(0,i.iN)(),D=(0,n.r)(),{comments:E,addComment:F,updateComment:G,deleteComment:H,refresh:I}=(0,m._)({cwd:c,filePath:b}),[J,K]=(0,f.useState)(!1),[L,M]=(0,f.useState)(null),[N,O]=(0,f.useState)(null),[P,Q]=(0,f.useState)(null),R=(0,f.useMemo)(()=>a.split("\n"),[a]),[S,T]=(0,f.useState)(null),U=(0,f.useRef)(null),V=(0,f.useCallback)(a=>{if(!y||/^[a-z][a-z0-9+.-]*:/i.test(a))return!1;let b=a.indexOf("#"),c=b>=0?a.slice(0,b):a,d=b>=0?a.slice(b+1):null;if(!c)return!1;let e=c;try{e=decodeURIComponent(c)}catch{}return!!(0,r.e$)(e)&&(y((0,r.WU)(A,e),d),!0)},[y,A]),{toolbarRef:W,bumpRef:X,clearToolbar:Y}=(0,u.L)({enabled:!0,container:S,resolveLineRange:a=>{let b=function(a){let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a;if(!b||!("closest"in b))return null;let c=b.closest("[data-source-start]");if(!c)return null;let d=c.getAttribute("data-source-start"),e=c.getAttribute("data-source-end");return d&&e?{start:parseInt(d,10),end:parseInt(e,10)}:null}(a);return b?{start:b.start,end:b.end}:null},buildLineSnapshot:({start:a,end:b})=>{let c=Math.max(0,a-1),d=Math.min(R.length,b);return R.slice(c,d).join("\n")}}),Z=(0,f.useCallback)(()=>{let a=W.current;a&&(M({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),Y())},[Y,W]),$=(0,f.useCallback)(()=>{let a=W.current;a&&(O({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),Y())},[Y,W]),_=(0,f.useCallback)(async a=>{L&&(await F(L.range.start,L.range.end,a,L.selectedText),M(null))},[L,F]),aa=(0,f.useCallback)(async a=>{if(N&&D)try{let d=await (0,o.$3)(c),e=[];for(let a of d)e.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});e.push({filePath:b,startLine:N.range.start,endLine:N.range.end,codeContent:N.lineSnapshot});let f=(0,o.Gw)(e,a);D.sendMessage(f),await (0,o.RP)(c),I(),O(null)}catch(a){console.error("Failed to send to AI:",a)}},[N,D,b,c,I]);(0,f.useMemo)(()=>{if(0===E.length)return[];let a=new Map;for(let b of E){let c=`${b.startLine}-${b.endLine}`;a.has(c)||a.set(c,[]),a.get(c).push(b)}return Array.from(a.entries()).map(([a,b])=>({key:a,startLine:b[0].startLine,endLine:b[0].endLine,comments:b}))},[E]);let[ab,ac]=(0,f.useState)([]);return(0,e.jsxs)(e.Fragment,{children:[!v&&(0,e.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:b}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(t.ShareReviewToggle,{content:a,sourceFile:A}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:B("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)(s.l,{content:a,containerRef:U}),(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:U,children:[(0,e.jsx)("div",{className:"p-6",children:(0,e.jsx)(p.T,{content:a,rehypePlugins:x,onLinkClick:V})}),ab.map(({key:a,top:b,comments:c})=>(0,e.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:b},onClick:a=>{a.stopPropagation(),Q({comment:c[0],x:a.clientX,y:a.clientY})},children:(0,e.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-sm hover:bg-amber-500 transition-colors",children:c.length})},a))]})]}),J&&C&&(0,h.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(j.f,{floatingToolbarRef:W,bumpRef:X,container:C,onAddComment:Z,onSendToAI:$,isChatLoading:D?.isLoading}),L&&(0,e.jsx)(k.t,{x:L.x,y:L.y,range:L.range,lineSnapshot:L.lineSnapshot,container:C,onSubmit:_,onClose:()=>M(null)}),N&&(0,e.jsx)(k.G,{x:N.x,y:N.y,range:N.range,filePath:b,lineSnapshot:N.lineSnapshot,container:C,onSubmit:aa,onClose:()=>O(null),isChatLoading:D?.isLoading}),P&&(0,e.jsx)(l.t,{x:P.x,y:P.y,comment:P.comment,container:C,onClose:()=>Q(null),onUpdateComment:G,onDeleteComment:H})]}),C)]})}d()}catch(a){d(a)}})},74493:(a,b,c)=>{"use strict";c.d(b,{Ey:()=>n,GW:()=>m,HS:()=>o,Hj:()=>i,ax:()=>h,qM:()=>j});var d=c(79606),e=c(33281),f=c(71192);let g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new f.uV({message:`POST ${a} failed`,cause:b})}),h=(a,b)=>e.t4.runPromise(g(`/api/${a}/disconnect`,{id:b}).pipe(d.orElse(()=>d.void))),i=a=>e.t4.runPromise(g("/api/jupyter/shutdown",{bubbleId:a}).pipe(d.orElse(()=>d.void))),j=a=>e.t4.runPromise(g("/api/browser/unregister",{id:a}).pipe(d.orElse(()=>d.void))),k=a=>e.t4.runPromise(a.pipe(d.catchAll(a=>d.sync(()=>{if(a.cause instanceof Error)throw a.cause;throw Error(a.message)})))),l=(a,b)=>{if(a&&"object"==typeof a&&"error"in a){let b=a.error;if("string"==typeof b&&b.length>0)return b;if(b&&"object"==typeof b){let a=b.message;if("string"==typeof a&&a.length>0)return a;let c=b._tag;if("string"==typeof c&&c.length>0)return c}}return`HTTP ${b}`},m=(a,b)=>k(d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok)throw Error(l(d,c.status));return d},catch:b=>new f.uV({message:`POST ${a} failed`,cause:b})})),n=(a,b)=>k(d.tryPromise({try:async()=>{let c=new URLSearchParams(b),d=await fetch(`${a}?${c}`),e=await d.json();if(!d.ok)throw Error(l(e,d.status));return e},catch:b=>new f.uV({message:`GET ${a} failed`,cause:b})})),o=(a,b)=>k(d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return c.blob()},catch:b=>new f.uV({message:`POST blob ${a} failed`,cause:b})}))},74542:(a,b,c)=>{"use strict";c.d(b,{b:()=>f});var d=c(48249),e=c(67484);function f({lines:a,containerRef:b}){let c=(0,e.useRef)(null),[g,h]=(0,e.useState)({top:0,height:0});if(0===a.length)return null;let i=100/a.length;return(0,d.jsxs)("div",{ref:c,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:a=>{let d=b.current,e=c.current;if(!d||!e)return;let f=e.getBoundingClientRect(),g=(a.clientY-f.top)/f.height*d.scrollHeight-d.clientHeight/2;d.scrollTo({top:Math.max(0,g),behavior:"smooth"})},children:[a.map((a,b)=>"unchanged"!==a.type&&(0,d.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===a.type?"bg-red-9":"bg-green-9"}`,style:{top:`${b*i}%`,height:`${Math.max(i,.5)}%`,minHeight:"2px"}},b)),(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${g.top}px`,height:`${Math.max(g.height,10)}px`}})]})}},74754:(a,b,c)=>{"use strict";c.d(b,{_:()=>g});var d=c(67484);c(91579);var e=c(33281),f=c(89800);function g({cwd:a,filePath:b}){let[c,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(!1),[k,l]=(0,d.useState)(null),m=(0,d.useCallback)(async()=>{if(!a||!b)return;j(!0),l(null);let c=await e.t4.runPromiseExit((0,f.lb)(a,b));if("Success"===c._tag)h(c.value.comments??[]);else{let a="Fail"===c.cause._tag?c.cause.error:null,b=a?.cause;l(b instanceof Error?b.message:"Failed to load comments")}j(!1)},[a,b]),n=(0,d.useCallback)(async(c,d,g,i)=>{let j=await e.t4.runPromiseExit((0,f.BC)({cwd:a,filePath:b,startLine:c,endLine:d,content:g,...i?{selectedText:i}:{}}));if("Success"===j._tag&&j.value.comment){let a=j.value.comment;return h(b=>[...b,a]),a}return"Failure"===j._tag&&console.error("Failed to add comment:",j.cause),null},[a,b]),o=(0,d.useCallback)(async(b,c)=>{let d=await e.t4.runPromiseExit((0,f.vv)(a,b,c));if("Success"===d._tag&&d.value.comment){let a=d.value.comment;return h(c=>c.map(c=>c.id===b?a:c)),!0}return"Failure"===d._tag&&console.error("Failed to update comment:",d.cause),!1},[a]),p=(0,d.useCallback)(async b=>{let c=await e.t4.runPromiseExit((0,f.Tu)(a,b));return"Success"===c._tag?(h(a=>a.filter(a=>a.id!==b)),!0):(console.error("Failed to delete comment:",c.cause),!1)},[a]),q=(0,d.useCallback)(a=>c.filter(b=>a>=b.startLine&&a<=b.endLine),[c]);return{comments:c,isLoading:i,error:k,addComment:n,updateComment:o,deleteComment:p,refresh:m,getCommentsForLine:q}}},74837:(a,b,c)=>{"use strict";c.d(b,{NoteToolbar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call NoteToolbar() from the server but NoteToolbar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/NoteToolbar.tsx","NoteToolbar")},74991:(a,b,c)=>{"use strict";c.d(b,{I:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(30458);function h(a,b){if("once"===a.type)return b("scheduledTasks.onceType",{minutes:a.delayMinutes});if("interval"===a.type){let c=b("scheduledTasks.everyNMinutes",{minutes:a.intervalMinutes});return a.activeFrom&&a.activeTo?`${c} (${a.activeFrom}-${a.activeTo})`:c}return"cron"===a.type?a.cron||"cron":a.type}function i(a){return a.unread?"bg-red-500":a.completed?"bg-muted-foreground":a.paused?"bg-yellow-500":"error"===a.lastResult?"bg-red-500":"bg-green-500"}function j({collapsed:a,tasks:b,unreadCount:c,onSwitchProject:k,onPause:l,onResume:m,onTrigger:n,onDelete:o,onMarkRead:p,onUpdateTask:q,onReorder:r}){let{t:s}=(0,f.Bd)(),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),x=(0,e.useRef)(null),y=b.filter(a=>!a.completed),z=y.filter(a=>!a.paused).length,A=b.filter(a=>a.completed),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(null),F=(0,e.useCallback)(a=>{C(a)},[]),G=(0,e.useCallback)((a,b)=>{a.preventDefault(),E(b)},[]),H=(0,e.useCallback)(a=>{if(null===B||B===a){C(null),E(null);return}let b=[...y],[c]=b.splice(B,1);b.splice(a,0,c),r([...b,...A].map(a=>a.id)),C(null),E(null)},[B,y,A,r]),I=(0,e.useCallback)(()=>{C(null),E(null)},[]),[,J]=(0,e.useState)(0);return(0,d.jsxs)("div",{className:"relative",ref:x,children:[(0,d.jsxs)("button",{onClick:()=>u(!t),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${a?"w-full justify-center":"w-full"}`,title:s("scheduledTasks.title"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]}),!a&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:s("scheduledTasks.title")}),c>0?(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-red-500 ${a?"absolute -top-1 -right-1":""}`,children:c}):a&&b.length>0?(0,d.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-accent",children:b.length}):null]}),t&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-96 max-h-[500px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium",children:s("scheduledTasks.title")}),y.length>0&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[s("scheduledTasks.activeCount",{running:z}),y.length-z>0?` \xb7 ${s("scheduledTasks.pausedCount",{paused:y.length-z})}`:""]})]}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:s("scheduledTasks.noScheduledTasks")}):(0,d.jsxs)(d.Fragment,{children:[y.map((a,b)=>{var c;return(0,d.jsx)("div",{draggable:!0,onDragStart:()=>F(b),onDragOver:a=>G(a,b),onDrop:()=>H(b),onDragEnd:I,className:`group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 cursor-pointer ${a.unread?"bg-brand/5":""} ${B===b?"opacity-50":""} ${D===b?"border-t-2 border-brand":""}`,onClick:()=>{k(a.cwd,a.sessionId),a.unread&&p(a.id),u(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${i(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:(c=a.cwd).split("/").pop()||c}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"\xb7"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:a.completed?s("scheduledTasks.completed"):a.paused?s("scheduledTasks.paused"):s("common.running")})]}),(0,d.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5",title:a.message,children:a.message}),(0,d.jsxs)("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{children:h(a,s)}),(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsx)("span",{children:a.paused?s("scheduledTasks.paused"):function(a,b){if(!a)return"-";let c=a-Date.now();if(c<=0)return b("scheduledTasks.aboutToTrigger");if(c<6e4)return b("scheduledTasks.secondsLater",{count:Math.ceil(c/1e3)});if(c<36e5)return b("scheduledTasks.minutesLater",{count:Math.ceil(c/6e4)});if(c<864e5){let a=Math.floor(c/36e5),d=Math.ceil(c%36e5/6e4);return d>0?b("scheduledTasks.hoursMinutesLater",{h:a,m:d}):b("scheduledTasks.hoursLater",{h:a})}return new Date(a).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(a.nextFireTime,s)}),a.lastFiredAt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsxs)("span",{children:[s("scheduledTasks.lastResult"),": ","success"===a.lastResult?"✓":"✗"]})]})]})]}),(0,d.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),n(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-brand",title:s("scheduledTasks.runNow"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M8 5v14l11-7z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),w(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:s("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.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"})})}),a.paused?(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),m(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-green-500",title:s("scheduledTasks.resume"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"})})}):(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),l(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-yellow-500",title:s("scheduledTasks.pause"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 9v6m4-6v6"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),o(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:s("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})},a.id)}),A.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-muted/30 border-b border-border/50",children:s("scheduledTasks.completedCount",{count:A.length})}),A.map(a=>(0,d.jsx)("div",{className:"group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 opacity-60 cursor-pointer",onClick:()=>{k(a.cwd,a.sessionId),u(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${i(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm text-foreground truncate",children:a.message}),(0,d.jsxs)("div",{className:"text-xs text-muted-foreground mt-0.5",children:[h(a,s)," \xb7 ","success"===a.lastResult?s("scheduledTasks.success"):s("scheduledTasks.failure")]})]}),(0,d.jsx)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),o(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:s("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]})},a.id))]})]})})]}),v&&(0,d.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30",onClick:()=>w(null)}),(0,d.jsx)("div",{className:"relative",children:(0,d.jsx)(g.E,{onClose:()=>w(null),onCreate:()=>{},editTask:{id:v.id,message:v.message,type:v.type,delayMinutes:v.delayMinutes,intervalMinutes:v.intervalMinutes,activeFrom:v.activeFrom,activeTo:v.activeTo,cron:v.cron},onUpdate:(a,b)=>{q(a,b),w(null)}})})]})]})}},75513:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{k_:()=>h,nH:()=>i});var e=c(48249),f=c(67484),g=c(7031);let a=(0,f.createContext)(null);function h({children:b}){let c=(0,f.useRef)(new Map),d=(0,f.useRef)(null),[i,j]=(0,f.useState)(!1),k=(0,f.useCallback)((a,b)=>{c.current.set(b,a)},[]),l=(0,f.useCallback)(a=>{c.current.delete(a)},[]),m=(0,f.useCallback)(a=>{d.current=a},[]),n=(0,f.useCallback)(a=>{let b=d.current;if(!b)return void console.warn("No active tab to send message");let e=c.current.get(b);e?e(a):console.warn(`No chat sender registered for tab ${b}`)},[]),o=(0,f.useMemo)(()=>({sendMessage:n,isLoading:i,registerChat:k,unregisterChat:l,setActiveTab:m,setIsLoading:j}),[n,i,k,l,m]),p=(0,f.useMemo)(()=>({sendMessage:n,isLoading:i}),[n,i]);return(0,e.jsx)(a.Provider,{value:o,children:(0,e.jsx)(g.H,{value:p,children:b})})}function i(){return(0,f.useContext)(a)}d()}catch(a){d(a)}})},76334:(a,b,c)=>{"use strict";function d(a){let b=function(a){let b=0xffffffff;for(let c=0;c<a.length;c++){b^=a.charCodeAt(c);for(let a=0;a<8;a++)b=b>>>1^(1&b?0xedb88320:0)}return(0xffffffff^b)>>>0}(a),c="",d=b;for(let a=0;a<4;a++)c+=String.fromCharCode(97+d%26),d=Math.floor(d/26);return c}c.d(b,{p:()=>d})},76537:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>q,metadata:()=>o,viewport:()=>p});var d=c(5735),e=c(45864),f=c.n(e),g=c(87764),h=c.n(g),i=c(76055),j=c.n(i),k=c(29021),l=c(33873);c(61135);var m=c(25702);let n="";try{n=(0,k.readFileSync)((0,l.join)(process.cwd(),"public","boot.js"),"utf8")}catch{}let o={title:"OpenCockpit",description:"OpenCockpit is a local-first AI development hub with chat agents, a file explorer, terminals, and browser bubbles in one swipeable workspace. One seat. One AI.",appleWebApp:{capable:!0,statusBarStyle:"default",title:"Cockpit"},icons:{icon:"/icons/icon-192x192.png",apple:"/icons/icon-192x192.png"}},p={themeColor:[{media:"(prefers-color-scheme: light)",color:"#f9f9fb"},{media:"(prefers-color-scheme: dark)",color:"#111113"}]};function q({children:a}){return(0,d.jsxs)("html",{lang:"en",suppressHydrationWarning:!0,className:"overflow-hidden",children:[(0,d.jsx)("head",{children:(0,d.jsx)("script",{dangerouslySetInnerHTML:{__html:n}})}),(0,d.jsx)("body",{className:`${f().variable} ${h().variable} ${j().variable} antialiased overflow-hidden`,children:(0,d.jsx)(m.Providers,{children:a})})]})}},76552:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Providers:()=>j});var e=c(48249),f=c(29491),g=c(83768),h=c(7833),i=c(34102);function j({children:a}){return(0,e.jsx)(f.I18nProvider,{children:(0,e.jsx)(g.N,{children:(0,e.jsxs)(h.tE,{children:[a,(0,e.jsx)(i.B,{})]})})})}d()}catch(a){d(a)}})},76855:(a,b,c)=>{"use strict";c.d(b,{Sn:()=>i,Xm:()=>j,po:()=>k,JL:()=>l});var d=c(67484);c(28797);var e=c(79606),f=c(33281),g=c(71192);let h=(a,b)=>e.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:b=>new g.uV({message:`${a} failed`,cause:b})});function i(a){let[b,c]=(0,d.useState)(!1);return{goToDefinition:(0,d.useCallback)(async(b,d,e)=>{c(!0);let g=await f.t4.runPromiseExit(h("/api/lsp/definition",{cwd:a,filePath:b,line:d,column:e}));return(c(!1),"Success"===g._tag)?g.value.definitions??[]:(console.error("[useLSP] definition error:",g.cause),[])},[a]),loading:b}}function j(a){let[b,c]=(0,d.useState)(null),e=(0,d.useRef)(null),g=(0,d.useRef)(null),i=(0,d.useRef)(0),j=(0,d.useRef)(!1),k=(0,d.useRef)(null),l=(0,d.useRef)({x:0,y:0}),m=(0,d.useCallback)(a=>{k.current=a},[]),n=(0,d.useRef)(!1),o=(0,d.useRef)(null),p=(0,d.useCallback)(()=>{let a=k.current;a&&n.current&&(a.style.pointerEvents="none"),n.current=!1,o.current&&(k.current?.removeEventListener("mouseleave",o.current),o.current=null)},[]),q=(0,d.useCallback)(()=>{let a=k.current;if(!a||n.current)return;n.current=!0,j.current=!0,a.style.pointerEvents="auto";let b=()=>{j.current=!1,p(),i.current++,c(null)};o.current=b,a.addEventListener("mouseleave",b)},[p]),r=(0,d.useCallback)((b,d,j,k)=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current);let l=++i.current;e.current=setTimeout(async()=>{let e=await f.t4.runPromiseExit(h("/api/lsp/hover",{cwd:a,filePath:b,line:d,column:j}));if(l!==i.current||"Success"!==e._tag)return;let g=e.value.hover;g&&g.displayString&&c({...g,x:k.x,y:k.y,filePath:b,line:d,column:j})},300)},[a]),s=(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),i.current++,g.current=setTimeout(function(){if(j.current)return;let a=k.current;if(a){let b=a.getBoundingClientRect(),{x:c,y:d}=l.current;if(c>=b.left&&c<=b.right&&d>=b.top&&d<=b.bottom)return void q()}c(null)},150)},[q]),t=(0,d.useCallback)(()=>{j.current=!0,g.current&&clearTimeout(g.current)},[]);return{hoverInfo:b,onTokenMouseEnter:r,onTokenMouseLeave:s,onCardMouseEnter:t,onCardMouseLeave:(0,d.useCallback)(()=>{j.current=!1,i.current++,c(null)},[]),clearHover:(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current),j.current=!1,p(),i.current++,c(null)},[p]),setTooltipEl:m}}function k(a){let[b,c]=(0,d.useState)([]),[e,g]=(0,d.useState)(!1),[i,j]=(0,d.useState)(!1);return{references:b,loading:e,visible:i,findReferences:(0,d.useCallback)(async(b,d,e)=>{g(!0),j(!0);let i=await f.t4.runPromiseExit(h("/api/lsp/references",{cwd:a,filePath:b,line:d,column:e}));"Success"===i._tag?c(i.value.references??[]):(console.error("[useLSP] references error:",i.cause),c([])),g(!1)},[a]),closeReferences:(0,d.useCallback)(()=>{j(!1),c([])},[])}}function l(a,b){(0,d.useRef)(null)}},77016:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{b:()=>s});var e=c(48249),f=c(67484),g=c(44256),h=c(36295),i=c(7833),j=c(28602),k=c(44384),l=c(74493),m=a([h]);h=(m.then?(await m)():m)[0];let x=[{value:"=",label:"="},{value:"!=",label:"!="},{value:">",label:">"},{value:"<",label:"<"},{value:">=",label:">="},{value:"<=",label:"<="},{value:"LIKE",label:"LIKE"},{value:"NOT LIKE",label:"NOT LIKE"},{value:"IN",label:"IN"},{value:"IS NULL",label:"IS NULL"},{value:"IS NOT NULL",label:"IS NOT NULL"}];function n(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}function o(a){return`\`${a.replace(/`/g,"``")}\``}function p(a){try{let b=a.match(/\/\/[^/]+\/([^?]+)/);if(b)return b[1]}catch{}return""}function q(a){return null==a?"":"object"==typeof a?JSON.stringify(a):String(a)}function r({text:a}){let[b,c]=(0,f.useState)(!1),[d,h]=(0,f.useState)({x:0,y:0,maxW:600,maxH:300,above:!0}),i=(0,f.useRef)(null),j=(0,f.useRef)(null),k=(0,f.useRef)(!1),l=(0,g.F2)(),m=(0,f.useCallback)(()=>{j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{k.current||c(!1)},80)},[]),n=(0,f.useCallback)(()=>{j.current&&clearTimeout(j.current),k.current=!1,j.current=setTimeout(()=>{let a=i.current;if(!a||a.scrollWidth<=a.clientWidth)return;let b=a.getBoundingClientRect(),d=l?.getBoundingClientRect(),e=d?.left??0,f=d?.top??0,g=d?.width??window.innerWidth,j=d?.height??window.innerHeight,k=b.left-e,m=b.top-f,n=b.bottom-f,o=Math.min(600,g-k-8),p=o<200?Math.max(8,g-600-8):k,q=o<200?Math.min(600,g-16):o,r=m-8,s=j-n-8,t=r>s&&r>80,u=t?r-4:s-4;h({x:p,y:t?m-4:n+4,maxW:q,maxH:Math.max(60,u),above:t}),c(!0)},350)},[l]),o=(0,f.useCallback)(()=>{m()},[m]),p=(0,f.useCallback)(()=>{k.current=!0,j.current&&clearTimeout(j.current)},[]),q=(0,f.useCallback)(()=>{k.current=!1,m()},[m]);return(0,e.jsxs)("span",{ref:i,className:"block truncate",onMouseEnter:n,onMouseLeave:o,children:[a,b&&(0,e.jsx)(g.ZL,{children:(0,e.jsx)("div",{className:"fixed z-[9999] overflow-y-auto px-2 py-1.5 text-xs font-mono bg-popover text-popover-foreground border border-border rounded shadow-lg whitespace-pre-wrap break-all select-text cursor-text",style:{left:d.x,top:d.y,maxWidth:d.maxW,maxHeight:d.maxH,transform:d.above?"translateY(-100%)":void 0},onMouseEnter:p,onMouseLeave:q,children:function(a){try{let b=JSON.parse(a);if("object"==typeof b&&null!==b)return JSON.stringify(b,null,2)}catch{}return a}(a)})})]})}function s({id:a,connectionString:b,displayName:c,selected:d,maximized:g,expandedHeight:m,bubbleContentHeight:u,onSelect:x,onClose:y,onToggleMaximize:z,timestamp:A,onTitleMouseDown:B}){let{t:C}=(0,k.Bd)(),{showToast:D}=(0,i.dj)(),[E,F]=(0,f.useState)("connecting"),[G,H]=(0,f.useState)(""),[I,J]=(0,f.useState)([]),[K,L]=(0,f.useState)(()=>p(b)),[M,N]=(0,f.useState)([]),[O,P]=(0,f.useState)(null),[Q,R]=(0,f.useState)("table"),[S,T]=(0,f.useState)("data"),[U,V]=(0,f.useState)([]),[W,X]=(0,f.useState)([]),[Y,Z]=(0,f.useState)([]),[$,_]=(0,f.useState)([]),[aa,ab]=(0,f.useState)(null),[ac,ad]=(0,f.useState)(0),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(0),[ai,aj]=(0,f.useState)(new Set),[ak,al]=(0,f.useState)(!1),[am,an]=(0,f.useState)(null),[ao,ap]=(0,f.useState)({}),[aq,ar]=(0,f.useState)(!1),[as,at]=(0,f.useState)({}),[au,av]=(0,f.useState)({}),[aw,ax]=(0,f.useState)(null),[ay,az]=(0,f.useState)(""),[aA,aB]=(0,f.useState)(null),[aC,aD]=(0,f.useState)(""),[aE,aF]=(0,f.useState)(!1),aG=(0,f.useRef)(null),aH=(0,f.useCallback)(async()=>{F("connecting"),H("");try{let c=await (0,l.GW)("/api/mysql/connect",{id:a,connectionString:b});J(c.schemas||[]);let d=p(b);c.schemas?.length>0&&d&&c.schemas.includes(d)?L(d):c.schemas?.length>0&&L(c.schemas[0]),F("connected")}catch(a){H(a instanceof Error?a.message:String(a)),F("error")}},[a,b]),aI=(0,f.useCallback)(async()=>{if("connected"===E)try{let c=await (0,l.Ey)("/api/mysql/schemas",{id:a,connectionString:b,schema:K});N(c.tables||[])}catch{}},[a,b,K,E]),aJ=(0,f.useCallback)(async(c,d,e,f)=>{af(!0);let g=e??au,h=void 0!==f?f:aw;try{let e=`${o(K)}.${o(c)}`,{where:f,params:i}=function(a){let b=[],c=[];for(let[d,e]of Object.entries(a)){if(!e.enabled)continue;let a=o(d);if("IS NULL"===e.op)b.push(`${a} IS NULL`);else if("IS NOT NULL"===e.op)b.push(`${a} IS NOT NULL`);else if("IN"===e.op){let d=e.value.split(",").map(a=>a.trim()).filter(Boolean);if(0===d.length)continue;let f=d.map(a=>(c.push(a),"?"));b.push(`${a} IN (${f.join(", ")})`)}else"LIKE"===e.op||e.op,b.push(`${a} ${e.op} ?`),c.push(e.value)}return{where:b.length>0?` WHERE ${b.join(" AND ")}`:"",params:c}}(g),j=h?` ORDER BY ${o(h.column)} ${h.dir}`:"",k=`SELECT * FROM ${e}${f}${j} LIMIT 50 OFFSET ${50*d}`,m=await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:k,params:i});ab(m);let n=`SELECT count(*) AS cnt FROM ${e}${f}`,p=await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:n,params:i});ah(p.rows?.[0]?.cnt??0)}catch{}af(!1)},[a,b,K,au,aw]),aK=(0,f.useCallback)(async c=>{P(c),ad(0),an(null),ar(!1),aj(new Set),al(!1),av({}),ax(null);try{let d=await (0,l.Ey)("/api/mysql/columns",{id:a,connectionString:b,schema:K,table:c});V(d.columns||[]),X(d.primaryKeys||[]),Z(d.foreignKeys||[]),_(d.indexes||[])}catch{}aJ(c,0,{},null)},[a,b,K,aJ]),aL=(0,f.useCallback)(async()=>{if(ay.trim()){aF(!0),aD(""),aB(null);try{let c=await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:ay});aB(c)}catch(a){aD(a instanceof Error?a.message:String(a))}aF(!1)}},[a,b,ay]),aM=(0,f.useCallback)(async()=>{if(null===am||!aa||!O)return;let c=aa.rows[am],d=[],e=[];for(let a of U)void 0!==ao[a.name]&&ao[a.name]!==q(c[a.name]??"")&&(d.push(`${o(a.name)} = ?`),e.push(""===ao[a.name]&&a.nullable?null:ao[a.name]));if(0===d.length)return void an(null);let f=W.length>0?W:U.map(a=>a.name),g=[];for(let a of f)null===c[a]||void 0===c[a]?g.push(`${o(a)} IS NULL`):(g.push(`${o(a)} = ?`),e.push(c[a]));let h=`UPDATE ${o(K)}.${o(O)} SET ${d.join(", ")} WHERE ${g.join(" AND ")}`;try{await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:h,params:e}),an(null),aJ(O,ac,au,aw)}catch(a){alert(`Update failed: ${a instanceof Error?a.message:String(a)}`)}},[am,aa,O,U,W,ao,a,b,K,aJ,ac,au,aw]),aN=(0,f.useCallback)(async()=>{if(!O)return;let c=[],d=[],e=[];for(let a of U)void 0!==as[a.name]&&""!==as[a.name]&&(c.push(o(a.name)),d.push(as[a.name]),e.push("?"));if(0===c.length)return;let f=`INSERT INTO ${o(K)}.${o(O)} (${c.join(", ")}) VALUES (${e.join(", ")})`;try{await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:f,params:d}),ar(!1),at({}),aJ(O,ac,au,aw)}catch(a){alert(`Insert failed: ${a instanceof Error?a.message:String(a)}`)}},[O,U,as,a,b,K,aJ,ac,au,aw]),aO=(0,f.useCallback)(async()=>{if(0===ai.size||!aa||!O)return;let c=W.length>0?W:U.map(a=>a.name),d=0;for(let e of Array.from(ai).sort((a,b)=>b-a)){let f=aa.rows[e];if(!f)continue;let g=[],h=[];for(let a of c)null===f[a]||void 0===f[a]?g.push(`${o(a)} IS NULL`):(g.push(`${o(a)} = ?`),h.push(f[a]));let i=`DELETE FROM ${o(K)}.${o(O)} WHERE ${g.join(" AND ")} LIMIT 1`;try{await (0,l.GW)("/api/mysql/query",{id:a,connectionString:b,sql:i,params:h})}catch{d++}}aj(new Set),al(!1),aJ(O,ac,au,aw),d>0&&alert(C("mysql.deleteRowsFailed",{count:d}))},[ai,aa,O,W,U,a,b,K,aJ,ac,au,aw]),aP=(0,f.useCallback)(async c=>{if(!O)return;if(ai.size>0&&aa){let a,b=aa.fields.map(a=>a.name),d=Array.from(ai).sort((a,b)=>a-b).map(a=>aa.rows[a]).filter(Boolean);if("json"===c)a=JSON.stringify(d,null,2);else{let c=[b.join(",")];for(let a of d)c.push(b.map(b=>{let c=a[b];if(null==c)return"";let d="object"==typeof c?JSON.stringify(c):String(c);return d.includes(",")||d.includes('"')||d.includes("\n")?`"${d.replace(/"/g,'""')}"`:d}).join(","));a=c.join("\n")}navigator.clipboard.writeText(a);return}let d=`SELECT * FROM ${o(K)}.${o(O)}`;try{let e=await (0,l.HS)("/api/mysql/export",{id:a,connectionString:b,sql:d,format:c}),f=URL.createObjectURL(e),g=document.createElement("a");g.href=f,g.download=`${O}.${c}`,g.click(),URL.revokeObjectURL(f)}catch(a){alert(`Export failed: ${a instanceof Error?a.message:String(a)}`)}},[O,a,b,K,ai,aa]),aQ=(0,f.useCallback)(a=>{(a.metaKey||a.ctrlKey)&&"Enter"===a.key&&(a.preventDefault(),aL())},[aL]),aR=g&&m?m-41:u??h.p,aS=Math.max(1,Math.ceil(ag/50)),aT=(0,f.useCallback)(a=>{O&&(ad(a),aJ(O,a,au,aw))},[O,aJ,au,aw]),aU=(0,f.useCallback)((a,b)=>{let c={...au};b?c[a]=b:delete c[a],av(c),ad(0),aj(new Set),O&&aJ(O,0,c,aw)},[au,aw,O,aJ]),aV=(0,f.useCallback)(()=>{av({}),ad(0),aj(new Set),O&&aJ(O,0,{},aw)},[aw,O,aJ]),aW=(0,f.useCallback)(a=>{ax(a),ad(0),aj(new Set),O&&aJ(O,0,au,a)},[au,O,aJ]);return(0,e.jsx)("div",{className:"flex flex-col items-start",children:(0,e.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
36
36
|
relative transition-colors cursor-pointer
|
|
37
37
|
${g?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
38
38
|
${g?"":d?"border-brand":"border-brand/30"}`,onClick:g?void 0:x,children:[(0,e.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:z,onMouseDown:B,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${g?"bg-card":"bg-card/50"}`,style:g?{height:41}:void 0,children:[(0,e.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDC2C"}),(0,e.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===E&&(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"error"===E&&(0,e.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:C("mysql.connectionFailed")}),"connected"===E&&(0,e.jsx)("span",{className:"text-[10px] text-emerald-500 flex-shrink-0",children:C("mysql.connected")}),(0,e.jsx)("span",{className:"flex-1"}),A&&(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:n(A)}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),z()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:g?C("browser.exitMaximize",{modKey:(0,j.Mu)()}):C("browser.maximize",{modKey:(0,j.Mu)()}),children:g?(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),y()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:C("common.close"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{style:{height:aR},className:"flex overflow-hidden",children:["connecting"===E&&(0,e.jsxs)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:[(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin mr-2"}),C("mysql.connecting")]}),"error"===E&&(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,e.jsx)("span",{className:"text-sm text-destructive text-center break-all",children:G}),(0,e.jsx)("button",{onClick:aH,className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:C("common.retry")})]}),"connected"===E&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"w-52 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"p-1.5 border-b border-border flex items-center gap-1",children:[I.length>1?(0,e.jsx)("select",{value:K,onChange:a=>{L(a.target.value),P(null)},className:"flex-1 min-w-0 text-xs bg-background border border-input rounded px-1.5 py-1",children:I.map(a=>(0,e.jsx)("option",{value:a,children:a},a))}):(0,e.jsx)("span",{className:"flex-1 min-w-0 text-xs text-muted-foreground truncate",children:K}),(0,e.jsx)("button",{onClick:aI,className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent active:bg-accent/50 transition-colors",title:C("mysql.refreshTableList"),children:(0,e.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("path",{d:"M1 1v5h5"}),(0,e.jsx)("path",{d:"M15 15v-5h-5"}),(0,e.jsx)("path",{d:"M13.5 6A6 6 0 0 0 3.2 3.2L1 6"}),(0,e.jsx)("path",{d:"M2.5 10a6 6 0 0 0 10.3 2.8L15 10"})]})})]}),(0,e.jsx)("div",{className:"flex items-center border-b border-border",children:["table","view"].map(a=>(0,e.jsx)("button",{onClick:()=>R(a),className:`flex-1 py-1 text-[10px] font-medium transition-colors ${Q===a?"text-brand border-b border-brand":"text-muted-foreground hover:text-foreground"}`,children:{table:C("mysql.filterTable"),view:C("mysql.filterView")}[a]},a))}),(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[M.filter(a=>"table"===Q?"view"!==a.type:"view"===a.type).map(a=>(0,e.jsxs)("div",{onClick:()=>aK(a.name),className:`flex items-center gap-1.5 px-2 py-1 cursor-pointer truncate transition-colors ${O===a.name?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,e.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground",children:"view"===a.type?"V":"T"}),(0,e.jsx)("span",{className:"truncate min-w-0 flex-1",children:(0,e.jsx)(r,{text:a.name})}),(0,e.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.rowEstimate>0?`~${a.rowEstimate}`:""})]},a.name)),0===M.length&&(0,e.jsx)("div",{className:"p-2 text-muted-foreground text-center",children:C("mysql.noTables")})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:[["structure","data","sql"].map(a=>(0,e.jsx)("button",{onClick:()=>T(a),className:`px-3 py-1.5 text-xs transition-colors ${S===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{structure:C("mysql.tabStructure"),data:C("mysql.tabData"),sql:"SQL"}[a]},a)),O&&"data"===S&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[Object.values(au).some(a=>a.enabled)&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-[10px] text-brand",children:C("mysql.filterActive",{count:Object.values(au).filter(a=>a.enabled).length})}),(0,e.jsx)("button",{onClick:aV,className:"px-1 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",title:C("mysql.clearAllFilters"),children:"✕"}),(0,e.jsx)("span",{className:"text-border",children:"|"})]}),ai.size>0&&!ak&&(0,e.jsx)("button",{onClick:()=>al(!0),className:"px-1.5 py-0.5 text-[10px] text-destructive hover:text-destructive/80 bg-destructive/10 rounded transition-colors",children:C("mysql.deleteNRows",{count:ai.size})}),ak&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-[10px] text-destructive",children:C("mysql.confirmDeleteRows")}),(0,e.jsx)("button",{onClick:aO,className:"px-1.5 py-0.5 text-[10px] text-white bg-destructive rounded transition-colors hover:bg-destructive/80",children:C("common.confirm")}),(0,e.jsx)("button",{onClick:()=>al(!1),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",children:C("common.cancel")})]}),(0,e.jsx)("button",{onClick:()=>aP("csv"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:ai.size>0?C("mysql.copyCsvSelected"):C("mysql.copyCsvAll"),children:ai.size>0?C("mysql.copyCSV"):C("mysql.CSV")}),(0,e.jsx)("button",{onClick:()=>aP("json"),className:"px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground bg-muted rounded transition-colors",title:ai.size>0?C("mysql.copyJsonSelected"):C("mysql.copyJsonAll"),children:ai.size>0?C("mysql.copyJSON"):C("mysql.JSON")})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:O||"sql"===S?"structure"===S?(0,e.jsx)(t,{columns:U,primaryKeys:W,foreignKeys:Y,indexes:$}):"data"===S?(0,e.jsx)(v,{result:aa,loading:ae,columns:U,page:ac,totalPages:aS,totalRows:ag,onPageChange:aT,filters:au,sort:aw,onFilterChange:aU,onSortChange:aW,selectedRows:ai,onSelectedRowsChange:a=>{aj(a),al(!1)},editingRowIdx:am,editValues:ao,onStartEdit:a=>{if(!aa)return;let b=aa.rows[a],c={};for(let a of U)c[a.name]=null==b[a.name]?"":q(b[a.name]);ap(c),an(a)},onEditChange:(a,b)=>ap(c=>({...c,[a]:b})),onSaveEdit:aM,onCancelEdit:()=>an(null),isAddingRow:aq,newRowValues:as,onStartAdd:()=>{ar(!0),at({})},onNewRowChange:(a,b)=>at(c=>({...c,[a]:b})),onSaveNewRow:aN,onCancelAdd:()=>{ar(!1),at({})},onCellCopy:a=>{navigator.clipboard.writeText(a),D(C("common.copied"))}}):(0,e.jsx)(w,{sqlInput:ay,onSqlChange:az,onExecute:aL,onKeyDown:aQ,result:aA,error:aC,loading:aE,sqlRef:aG,onCellCopy:a=>{navigator.clipboard.writeText(a),D(C("common.copied"))}}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:C("mysql.selectTable")})})]})]})]}),!g&&(0,e.jsxs)("div",{className:"border-t border-border px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${"connected"===E?"bg-green-500":"error"===E?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,e.jsx)("span",{children:{connecting:C("common.connecting"),connected:C("common.connected"),error:C("common.connectionFailed")}[E]}),"connected"===E&&O&&(0,e.jsx)("span",{className:"text-muted-foreground/70",children:O}),(0,e.jsx)("span",{className:"flex-1"}),A&&(0,e.jsx)("span",{className:"text-[11px] flex-shrink-0",children:n(A)})]})]})})}function t({columns:a,primaryKeys:b,foreignKeys:c,indexes:d}){let{t:f}=(0,k.Bd)();return 0===a.length?(0,e.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:f("mysql.selectTableToView")}):(0,e.jsxs)("div",{className:"p-2 space-y-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:f("mysql.columns")}),(0,e.jsxs)("table",{className:"w-full text-xs",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border",children:[(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("mysql.colName")}),(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("mysql.colType")}),(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("mysql.colNullable")}),(0,e.jsx)("th",{className:"px-1.5 py-1 font-medium",children:f("mysql.colDefault")})]})}),(0,e.jsx)("tbody",{children:a.map(a=>(0,e.jsxs)("tr",{className:"border-b border-border/50 hover:bg-accent/50",children:[(0,e.jsxs)("td",{className:"px-1.5 py-1 font-mono",children:[a.isPrimaryKey&&(0,e.jsx)("span",{className:"text-amber-500 mr-1",title:f("mysql.primaryKey"),children:"\uD83D\uDD11"}),a.name]}),(0,e.jsxs)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono",children:[a.type,a.maxLength?`(${a.maxLength})`:""]}),(0,e.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground",children:a.nullable?"YES":"NO"}),(0,e.jsx)("td",{className:"px-1.5 py-1 text-muted-foreground font-mono truncate max-w-[120px]",children:a.default||""})]},a.name))})]})]}),c.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:f("mysql.foreignKeys")}),(0,e.jsx)("div",{className:"space-y-0.5",children:c.map((a,b)=>(0,e.jsxs)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground",children:[a.column," → ",a.refSchema,".",a.refTable,".",a.refColumn]},b))})]}),d.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wide px-1 mb-1",children:f("mysql.indexes")}),(0,e.jsx)("div",{className:"space-y-0.5",children:d.map(a=>(0,e.jsx)("div",{className:"text-xs font-mono px-1.5 text-muted-foreground truncate",title:a.definition,children:a.name},a.name))})]})]})}function u({filter:a,onApply:b,onClear:c,onToggle:d,onClose:h,colName:i,anchorRect:j}){let{t:l}=(0,k.Bd)(),[m,n]=(0,f.useState)(a?.op||"="),[o,p]=(0,f.useState)(a?.value||""),q=(0,f.useRef)(null),r=(0,g.F2)(),s="IS NULL"!==m&&"IS NOT NULL"!==m,t=()=>{(!s||o.trim())&&b({op:m,value:o.trim(),enabled:!0})},v=r?.getBoundingClientRect(),w=v?.left??0,y=v?.top??0,z=v?.width??1e3,A=j.left-w;A+220>z-8&&(A=z-220-8),A<8&&(A=8);let B=j.bottom+2-y;return(0,e.jsx)(g.ZL,{children:(0,e.jsxs)("div",{ref:q,className:"fixed z-[9998] w-[220px] bg-popover border border-border rounded-md shadow-lg p-2 space-y-2",style:{left:A,top:B},onClick:a=>a.stopPropagation(),children:[a&&(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:a.enabled,onChange:a=>d(a.target.checked),className:"w-3 h-3 accent-brand"}),l("mysql.enable")]}),(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono truncate max-w-[120px]",children:i})]}),(0,e.jsx)("select",{value:m,onChange:a=>n(a.target.value),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-ring",children:x.map(a=>(0,e.jsx)("option",{value:a.value,children:a.label},a.value))}),s&&(0,e.jsx)("input",{type:"text",value:o,onChange:a=>p(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),t())},placeholder:l("IN"===m?"mysql.commaValues":"LIKE"===m?"mysql.likePattern":"mysql.valuePlaceholder"),className:"w-full text-xs bg-background border border-input rounded px-1.5 py-1 font-mono focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:t,disabled:s&&!o.trim(),className:"flex-1 px-2 py-1 text-[10px] bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-40 transition-colors",children:l("mysql.apply")}),a&&(0,e.jsx)("button",{onClick:c,className:"flex-1 px-2 py-1 text-[10px] text-muted-foreground bg-muted rounded hover:text-foreground transition-colors",children:l("mysql.clearFilter")})]})]})})}function v({result:a,loading:b,columns:c,page:d,totalPages:g,totalRows:h,onPageChange:i,filters:j,sort:l,onFilterChange:m,onSortChange:n,selectedRows:o,onSelectedRowsChange:p,editingRowIdx:s,editValues:t,onStartEdit:w,onEditChange:x,onSaveEdit:y,onCancelEdit:z,isAddingRow:A,newRowValues:B,onStartAdd:C,onNewRowChange:D,onSaveNewRow:E,onCancelAdd:F,onCellCopy:G}){let{t:H}=(0,k.Bd)(),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)({left:0,bottom:0});if(!a&&!b)return(0,e.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:H("mysql.selectTableForData")});let M=a?.fields||[],N=a?.rows||[],O={};for(let a of c)O[a.name]=a.type+(a.maxLength?`(${a.maxLength})`:"");let P=N.length>0&&o.size===N.length,Q=o.size>0&&!P;return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",children:[b&&(0,e.jsx)("div",{className:"absolute inset-0 bg-background/50 flex items-center justify-center z-10",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),(0,e.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,e.jsx)("thead",{className:"sticky top-0 bg-card z-[2]",children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{className:"px-1 py-1 border-b border-border w-8 text-center",children:(0,e.jsx)("input",{type:"checkbox",checked:P,ref:a=>{a&&(a.indeterminate=Q)},onChange:()=>{P?p(new Set):p(new Set(N.map((a,b)=>b)))},className:"w-3 h-3 accent-brand cursor-pointer"})}),M.map(a=>{let b=l?.column===a.name?l.dir:null,c=j[a.name],d=c?.enabled;return(0,e.jsxs)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono relative",children:[(0,e.jsxs)("span",{className:"cursor-pointer select-none hover:text-foreground transition-colors",onClick:()=>{var b;return b=a.name,void(l?.column===b?"ASC"===l.dir?n({column:b,dir:"DESC"}):n(null):n({column:b,dir:"ASC"}))},children:[a.name,O[a.name]&&(0,e.jsx)("span",{className:"ml-1 text-[9px] text-muted-foreground/60 font-normal",children:O[a.name]}),"ASC"===b&&(0,e.jsx)("span",{className:"ml-0.5 text-brand",children:"↑"}),"DESC"===b&&(0,e.jsx)("span",{className:"ml-0.5 text-brand",children:"↓"})]}),(0,e.jsx)("button",{onClick:b=>{if(b.stopPropagation(),I===a.name)return void J(null);let c=b.currentTarget.closest("th").getBoundingClientRect();L({left:c.left,bottom:c.bottom}),J(a.name)},className:`ml-1 inline-flex items-center transition-colors ${d?"text-brand":"text-muted-foreground/40 hover:text-muted-foreground"}`,children:(0,e.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,e.jsx)("path",{d:"M1 2h14l-5.5 6.5V14l-3-2v-3.5z"})})}),I===a.name&&(0,e.jsx)(u,{filter:c||null,onApply:b=>{m(a.name,b),J(null)},onClear:()=>{m(a.name,null),J(null)},onToggle:b=>{c&&m(a.name,{...c,enabled:b})},onClose:()=>J(null),colName:a.name,anchorRect:K})]},a.name)})]})}),(0,e.jsxs)("tbody",{children:[A&&(0,e.jsxs)("tr",{className:"bg-emerald-500/5",children:[(0,e.jsx)("td",{className:"px-1 py-0.5 border-b border-border text-center",children:(0,e.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,e.jsx)("button",{onClick:E,className:"text-[10px] text-emerald-500 hover:text-emerald-400",title:H("common.save"),children:"✓"}),(0,e.jsx)("button",{onClick:F,className:"text-[10px] text-muted-foreground hover:text-foreground",title:H("common.cancel"),children:"✕"})]})}),M.map(a=>(0,e.jsx)("td",{className:"px-0.5 py-0.5 border-b border-border",children:(0,e.jsx)("input",{type:"text",value:B[a.name]??"",onChange:b=>D(a.name,b.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]",placeholder:"NULL"})},a.name))]}),N.map((a,b)=>(0,e.jsxs)("tr",{className:`hover:bg-accent/50 ${o.has(b)?"bg-brand/5":""} ${s===b?"bg-blue-500/5":""}`,children:[(0,e.jsx)("td",{className:"px-1 py-0.5 border-b border-border/50 text-center",children:s===b?(0,e.jsxs)("div",{className:"flex gap-0.5 justify-center",children:[(0,e.jsx)("button",{onClick:y,className:"text-[10px] text-emerald-500 hover:text-emerald-400",title:H("common.save"),children:"✓"}),(0,e.jsx)("button",{onClick:z,className:"text-[10px] text-muted-foreground hover:text-foreground",title:H("common.cancel"),children:"✕"})]}):(0,e.jsx)("input",{type:"checkbox",checked:o.has(b),onChange:()=>{let a;(a=new Set(o)).has(b)?a.delete(b):a.add(b),p(a)},className:"w-3 h-3 accent-brand cursor-pointer"})}),M.map(c=>(0,e.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onDoubleClick:()=>{null===s&&w(b)},onContextMenu:b=>{b.preventDefault(),G(q(a[c.name]))},children:s===b?(0,e.jsx)("input",{type:"text",value:t[c.name]??"",onChange:a=>x(c.name,a.target.value),className:"w-full px-1 py-0.5 text-xs bg-background border border-input rounded font-mono min-w-[60px]"}):null===a[c.name]||void 0===a[c.name]?(0,e.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,e.jsx)(r,{text:q(a[c.name])})},c.name))]},b))]})]}),0===N.length&&!b&&(0,e.jsx)("div",{className:"p-4 text-xs text-muted-foreground text-center",children:H("common.noData")})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-t border-border text-[10px] text-muted-foreground bg-card/30 flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:C,disabled:A,className:"px-1.5 py-0.5 text-[10px] text-emerald-500 hover:text-emerald-400 disabled:opacity-30",children:H("mysql.addRow")}),(0,e.jsx)("span",{children:H("mysql.totalRows",{count:h})}),a?.duration!==void 0&&(0,e.jsxs)("span",{children:[a.duration,"ms"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:()=>i(d-1),disabled:0===d,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"◀"}),(0,e.jsxs)("span",{children:[d+1," / ",g]}),(0,e.jsx)("button",{onClick:()=>i(d+1),disabled:d>=g-1,className:"px-1 py-0.5 hover:text-foreground disabled:opacity-30",children:"▶"})]})]})]})}function w({sqlInput:a,onSqlChange:b,onExecute:c,onKeyDown:d,result:f,error:g,loading:h,sqlRef:i,onCellCopy:l}){let{t:m}=(0,k.Bd)();return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex-shrink-0 p-2 border-b border-border",children:[(0,e.jsx)("textarea",{ref:i,value:a,onChange:a=>b(a.target.value),onKeyDown:d,placeholder:m("mysql.sqlPlaceholder",{modKey:(0,j.Mu)()}),className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,e.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,e.jsx)("button",{onClick:c,disabled:h||!a.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:m(h?"mysql.executing":"mysql.execute")}),f?.duration!==void 0&&(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[f.command&&!f.fields?m("mysql.rowsAffected",{command:f.command,count:f.rowCount,duration:f.duration}):m("mysql.queryRows",{count:f.rows?.length??0,duration:f.duration}),f.truncated&&` ${m("mysql.resultTruncated")}`]})]})]}),g&&(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-destructive bg-destructive/5 border-b border-border break-all",children:g}),f?.fields&&f.rows&&(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:(0,e.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,e.jsx)("thead",{className:"sticky top-0 bg-card z-[1]",children:(0,e.jsx)("tr",{children:f.fields.map(a=>(0,e.jsx)("th",{className:"px-1.5 py-1 text-left text-muted-foreground font-medium border-b border-border whitespace-nowrap font-mono",children:a.name},a.name))})}),(0,e.jsx)("tbody",{children:f.rows.map((a,b)=>(0,e.jsx)("tr",{className:"hover:bg-accent/50",children:f.fields.map(b=>(0,e.jsx)("td",{className:"px-1.5 py-0.5 border-b border-border/50 font-mono whitespace-nowrap max-w-[200px] truncate",onContextMenu:c=>{c.preventDefault(),l(q(a[b.name]))},children:null===a[b.name]||void 0===a[b.name]?(0,e.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):(0,e.jsx)(r,{text:q(a[b.name])})},b.name))},b))})]})})]})}d()}catch(a){d(a)}})},77120:(a,b,c)=>{"use strict";c.d(b,{SessionBrowser:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(57031),h=c(88214),i=c(33281),j=c(65484);function k({isOpen:a,onClose:b,onSelectSession:c,onAddProject:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)([]),[r,s]=(0,e.useState)({}),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),[x,y]=(0,e.useState)(""),z=(0,e.useRef)(null);(0,e.useCallback)(async()=>{u(!0),w(null),s({});let a=await i.t4.runPromiseExit((0,j.H7)());"Success"===a._tag?q(a.value):w("Failed to load projects"),u(!1)},[]);let A=(0,e.useCallback)(async a=>{s(b=>({...b,[a]:{...b[a],isExpanded:!0,isLoading:!0,sessions:[],error:null}}));let b=await i.t4.runPromiseExit((0,j.QW)(a));"Success"===b._tag?s(c=>({...c,[a]:{...c[a],isLoading:!1,sessions:b.value}})):s(b=>({...b,[a]:{...b[a],isLoading:!1,error:"Failed to load sessions"}}))},[]),B=(0,e.useCallback)(a=>{let b=r[a];b?.isExpanded?s(b=>({...b,[a]:{...b[a],isExpanded:!1}})):b?.sessions?.length?s(b=>({...b,[a]:{...b[a],isExpanded:!0}})):A(a)},[r,A]),C=(0,e.useCallback)(async()=>{if(n)return;o(!0);let a=await i.t4.runPromiseExit((0,j.It)());"Success"===a._tag&&a.value.folder&&l&&(l(a.value.folder),b()),o(!1)},[n,l,b]);return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:b}),(0,d.jsxs)("div",{className:"relative w-full max-w-7xl h-[90vh] mx-4 bg-card rounded-lg shadow-xl flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:m("sessions.projectList")}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("input",{ref:z,type:"text",placeholder:m("workspace.searchProjectPath"),value:x,onChange:a=>y(a.target.value),className:"px-2 py-1 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),l&&(0,d.jsxs)("button",{onClick:C,disabled:n,className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50",title:m("sessions.openFolder"),children:[(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 10v6m3-3H9m-4 7h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),n?m("sessions.selectingFolder"):m("sessions.openFolder")]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[t&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:m("workspace.loadingProjects")})]})}),v&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:v})}),!t&&!v&&0===p.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:m("workspace.projectNotFound")})}),!t&&!v&&p.filter(a=>a.fullPath.toLowerCase().includes(x.toLowerCase())).map(a=>{let b=r[a.encodedPath]||{isExpanded:!1,isLoading:!1,sessions:[],error:null};return(0,d.jsxs)("div",{className:"mb-3",children:[(0,d.jsxs)("button",{onClick:()=>B(a.encodedPath),className:"w-full flex items-center gap-2 p-2 rounded hover:bg-accent transition-colors text-left",children:[(0,d.jsx)("svg",{className:`w-3 h-3 text-muted-foreground transition-transform ${b.isExpanded?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,d.jsx)("span",{className:"flex-1 text-xs font-medium text-foreground truncate",title:a.fullPath,children:a.fullPath}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",a.sessionCount,")"]})]}),b.isExpanded&&(0,d.jsxs)("div",{className:"ml-6 mt-2",children:[b.isLoading&&(0,d.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-3 w-3",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:m("sessions.loadingSessions")})]}),b.error&&(0,d.jsx)("div",{className:"p-3 text-xs text-red-11",children:b.error}),!b.isLoading&&!b.error&&(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:b.sessions.map(b=>(0,d.jsxs)("div",{onClick:()=>{var d;let e;return d=a.fullPath,e=(b.path.split("/").pop()||"").replace(".jsonl",""),void(c?c(d,e):(0,g.F)(h.n.OpenProject,{cwd:d,sessionId:e}))},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[b.engine&&"claude"!==b.engine&&(0,d.jsx)("span",{className:`shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded ${"claude2"===b.engine?"bg-orange-500/15 text-orange-11":"ollama"===b.engine?"bg-blue-500/15 text-blue-11":"codex"===b.engine?"bg-green-500/15 text-green-11":"kimi"===b.engine?"bg-purple-500/15 text-purple-11":"bg-muted text-muted-foreground"}`,children:b.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate",title:b.title,children:b.title})]}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(b.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[b.firstMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`first-${b}`)),b.lastMessages.length>0&&(0,d.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),b.lastMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`last-${b}`))]})]},b.path))})]})]},a.encodedPath)})]})]})]}):null}},77220:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{SettingsModal:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(83768),i=c(7833),j=c(28602),k=c(15105),l=c(33281),m=c(79606),n=c(65484);function o({isOpen:a,onClose:b}){let{t:c,i18n:d}=(0,g.Bd)(),{theme:p,setTheme:q}=(0,h.D)(),r=(0,k.G)(),[s,t]=(0,f.useState)(""),[u,v]=(0,f.useState)(""),[w,x]=(0,f.useState)("auto"),y=(0,f.useCallback)(a=>{x(a),l.t4.runFork((0,n.DZ)({language:a}).pipe(m.orElse(()=>m.void)));let b="auto"===a?navigator.language.startsWith("zh")?"zh":"en":a;d.changeLanguage(b)},[d]),z=r?"installed":"not-installed",A=r?.version??null;if(!a)return null;let B=[{value:"system",label:c("settings.themeSystem"),icon:"\uD83D\uDCBB"},{value:"light",label:c("settings.themeLight"),icon:"☀️"},{value:"dark",label:c("settings.themeDark"),icon:"\uD83C\uDF19"}];return(0,e.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:b}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-md mx-4 overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:c("settings.title")}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{className:"p-4 space-y-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.theme")}),(0,e.jsx)("div",{className:"grid grid-cols-3 gap-2",children:B.map(a=>(0,e.jsxs)("button",{onClick:()=>q(a.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${p===a.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,e.jsx)("span",{className:"text-xl",children:a.icon}),(0,e.jsx)("span",{className:"text-xs font-medium",children:a.label})]},a.value))})]}),(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.language")}),(0,e.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{value:"auto",label:c("settings.languageAuto"),icon:"\uD83C\uDF10"},{value:"en",label:"English",icon:"\uD83C\uDDFA\uD83C\uDDF8"},{value:"zh",label:"中文",icon:"\uD83C\uDDE8\uD83C\uDDF3"}].map(a=>(0,e.jsxs)("button",{onClick:()=>y(a.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${w===a.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,e.jsx)("span",{className:"text-xl",children:a.icon}),(0,e.jsx)("span",{className:"text-xs font-medium",children:a.label})]},a.value))})]}),(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.browserExtension")}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${"installed"===z?"bg-green-500":"bg-slate-400"}`}),(0,e.jsxs)("span",{children:["installed"===z&&`${c("settings.extensionInstalled")}${A?` (v${A})`:""}`,"not-installed"===z&&c("settings.extensionNotInstalled")]})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:c("settings.extensionDescription")}),"installed"!==z&&(0,e.jsxs)("div",{className:"text-xs text-muted-foreground bg-muted/50 rounded-md p-2 space-y-1",children:[(0,e.jsx)("p",{className:"font-medium text-foreground",children:c("settings.installSteps")}),(0,e.jsxs)("p",{children:[c("settings.step1")," ",(0,e.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-foreground",children:"chrome://extensions"})]}),(0,e.jsx)("p",{children:c("settings.step2")}),(0,e.jsx)("p",{children:c("settings.step3")}),(0,j.L)()&&(0,e.jsx)("p",{dangerouslySetInnerHTML:{__html:c("settings.step4mac")}})]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("button",{onClick:()=>{let a=s||"chrome-extension";navigator.clipboard.writeText(a),(0,i.oR)(c("toast.copiedName",{name:a}))},className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:c("settings.copyExtensionPath")}),"installed"===z&&(0,e.jsx)("button",{onClick:()=>{r?.id&&window.chrome?.runtime?.sendMessage&&(window.chrome.runtime.sendMessage(r.id,{type:"reload"}),(0,i.oR)(c("toast.pluginReloading")))},className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-muted transition-colors",children:c("settings.reloadExtension")})]}),s&&(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono truncate",children:s})]})]}),(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.about")}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground space-y-1",children:[(0,e.jsxs)("p",{children:["Cockpit",u?` v${u}`:""]}),(0,e.jsx)("p",{className:"text-muted-foreground/60",children:"One seat. One AI. Everything under control."})]})]})]})]})]})}d()}catch(a){d(a)}})},77396:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{_:()=>h});var e=c(48249),f=c(22341),g=c(72529);function h({comments:a,startLine:b,endLine:c,lineHeight:d,bodyTopOffset:i,onCommentClick:j}){let k=new Map;for(let d of a){if(d.endLine<b||d.endLine>c)continue;let a=k.get(d.endLine);a?a.push(d):k.set(d.endLine,[d])}return 0===k.size?null:(0,e.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-6 pointer-events-none",children:Array.from(k.entries()).map(([a,c])=>{let h=i+(a-b)*d,k=c[0],l=c.length-1;return(0,e.jsx)(g.m,{content:1===c.length?k.content:`${c.length} comments — click to view`,children:(0,e.jsxs)("button",{onClick:a=>j(k,a),className:"pointer-events-auto absolute right-1 w-4 h-4 rounded-full bg-amber-9/70 hover:bg-amber-11 text-white flex items-center justify-center shadow-sm transition-colors",style:{top:`${h+d/2-8}px`},children:[(0,e.jsx)(f.A,{className:"w-2.5 h-2.5"}),l>0&&(0,e.jsx)("span",{className:"absolute -top-1 -right-1 bg-amber-11 text-white rounded-full text-[8px] leading-none w-3 h-3 flex items-center justify-center",children:l+1})]})},a)})})}d()}catch(a){d(a)}})},77462:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManager:()=>C});var e=c(48249),f=c(67484),g=c(44384),h=c(67115),i=c(70151),j=c(6900),k=c(49950),l=c(32465),m=c(75513),n=c(94192),o=c(44256),p=c(37129),q=c(38878),r=c(3588),s=c(18946),t=c(29939),u=c(98982),v=c(13054),w=c(79606),x=c(23734),y=c(88214),z=c(33281),A=c(65484);c(37388);var B=a([p,m,q,r,s,i,k,j]);function C({initialCwd:a,initialSessionId:b}){let{t:c}=(0,g.Bd)(),[d,B]=(0,f.useState)("agent"),{tabs:D,activeTabId:E,activeTab:F,unreadTabs:G,dragTabIndex:H,dragOverTabIndex:I,closeTab:J,switchTab:K,handleSelectSession:L,handleNewTab:M,handleNewClaude2Tab:N,handleNewCodexTab:O,handleNewKimiTab:P,handleNewOllamaTab:Q,handleNewDeepseekTab:R,handleOpenSession:S,updateTabState:T,updateTabOllamaModel:U,updateTabDeepseekModel:V,updateTabChatMode:W,updateTabPlanMode:X,handleTabDragStart:Y,handleTabDragOver:Z,handleTabDrop:$,handleTabDragEnd:_}=(0,p.useTabState)({initialCwd:a,initialSessionId:b,activeView:d}),{isPinned:aa,pinSession:ab,unpinSession:ac}=(0,u.P)(),{createTask:ad}=(0,v.n)(),ae=(0,f.useCallback)(a=>{let b=D.find(b=>b.id===a);return!!b?.sessionId&&aa(b.sessionId)},[D,aa]),af=(0,f.useCallback)(b=>{let c=D.find(a=>a.id===b);c?.sessionId&&(aa(c.sessionId)?ac(c.sessionId):ab(c.sessionId,c.cwd||a||"",c.title))},[D,aa,ab,ac,a]),[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(!1),[ak,al]=(0,f.useState)(!1),[am,an]=(0,f.useState)(null),[ao,ap]=(0,f.useState)(!1),[aq,ar]=(0,f.useState)("tree"),[as,at]=(0,f.useState)(0),[au,av]=(0,f.useState)(null),[aw,ax]=(0,f.useState)(0),[ay,az]=(0,f.useState)(!1);(0,f.useRef)(null);let aA=(0,f.useCallback)(b=>{B(b),a&&(z.t4.runFork((0,A.Yn)({cwd:a,settings:{activeView:b}}).pipe(w.orElse(()=>w.void))),z.t4.runFork(w.flatMap(x.d,c=>c.publish(y.n.ViewChange,{cwd:a,view:b}))))},[a]),aB=(0,f.useCallback)(async()=>{if(!a)return;let b=await z.t4.runPromiseExit((0,A.b2)(a));if("Success"===b._tag){let c=b.value;if(ap(!!c.isGitRepo),c.isGitRepo&&c.worktrees&&c.worktrees.length>0){let b=c.worktrees.find(b=>b.path===a);b&&an(b.branch)}}else console.error("Failed to load git info:",b.cause)},[a]),aC=(0,f.useCallback)(a=>{let{data:b}=a;b?.some(a=>"git"===a.type)&&aB()},[aB]);(0,t.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"")}`,onMessage:aC,enabled:!!a});let aD=(0,f.useCallback)(()=>{ar("status"),at(a=>a+1),aA("explorer")},[aA]),aE=(0,f.useCallback)(a=>{av(a),ax(a=>a+1),aA("explorer")},[aA]),aF=(0,f.useCallback)(()=>{a&&z.t4.runFork(w.flatMap(x.d,b=>b.publish(y.n.OpenNote,{cwd:a})))},[a]);return(0,e.jsx)(m.k_,{children:(0,e.jsx)(n.fY,{activeView:d,onViewChange:aA,children:(0,e.jsxs)("div",{className:"flex h-screen bg-card",children:[(0,e.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,e.jsx)(q.TabManagerTopBar,{initialCwd:a,activeTab:F,isGitRepo:ao,currentBranch:am,onOpenWorktree:()=>aj(!0),onOpenAliasManager:()=>al(!0),onBranchSwitched:aB}),ay&&(0,e.jsxs)("div",{className:"flex items-center justify-center gap-2 py-1 bg-brand/15 text-brand text-xs font-medium border-b border-brand/20",children:[(0,e.jsx)("span",{className:"animate-pulse",children:"●"}),c("console.screenshotting")]}),a?(0,e.jsxs)(n.c0,{children:[(0,e.jsx)("div",{className:"w-1/3 h-full flex flex-col overflow-hidden",children:(0,e.jsx)(o.a9,{children:(0,e.jsxs)("div",{className:"w-full h-full flex flex-col",children:[(0,e.jsx)(r.TabBar,{tabs:D,activeTabId:E,unreadTabs:G,dragTabIndex:H,dragOverTabIndex:I,isPinned:ae,onTogglePin:af,onSwitchTab:K,onCloseTab:J,onNewTab:M,onNewClaude2Tab:N,onNewCodexTab:O,onNewKimiTab:P,onNewOllamaTab:Q,onNewDeepseekTab:R,onOpenProjectSessions:()=>ah(!0),onDragStart:Y,onDragOver:Z,onDrop:$,onDragEnd:_}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:D.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===E?"block":"hidden"}`,children:(0,e.jsx)(s.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,ollamaModel:a.ollamaModel,onOllamaModelChange:U,deepseekModel:a.deepseekModel,onDeepseekModelChange:V,chatMode:a.chatMode,onChatModeChange:W,planMode:a.planMode,onPlanModeChange:X,isActive:a.id===E&&"agent"===d,onStateChange:T,onShowGitStatus:aD,onContentSearch:aE,onOpenNote:aF,onCreateScheduledTask:ad,onOpenSession:S})},a.id))})]})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(o.a9,{children:(0,e.jsx)(i.g,{onClose:()=>aA("agent"),cwd:a,initialTab:aq,tabSwitchTrigger:as,initialSearchQuery:au,searchQueryTrigger:aw})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(o.a9,{children:(0,e.jsx)(k.J,{cwd:a,tabId:"default",onOpenNote:aF})})})]}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsx)(r.TabBar,{tabs:D,activeTabId:E,unreadTabs:G,dragTabIndex:H,dragOverTabIndex:I,isPinned:ae,onTogglePin:af,onSwitchTab:K,onCloseTab:J,onNewTab:M,onNewClaude2Tab:N,onNewCodexTab:O,onNewKimiTab:P,onNewDeepseekTab:R,onDragStart:Y,onDragOver:Z,onDrop:$,onDragEnd:_}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:D.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===E?"block":"hidden"}`,children:(0,e.jsx)(s.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,ollamaModel:a.ollamaModel,onOllamaModelChange:U,deepseekModel:a.deepseekModel,onDeepseekModelChange:V,chatMode:a.chatMode,onChatModeChange:W,planMode:a.planMode,onPlanModeChange:X,isActive:a.id===E,onStateChange:T,onCreateScheduledTask:ad,onOpenSession:S})},a.id))})]})]}),a&&(0,e.jsx)(h.Q,{isOpen:ag,onClose:()=>ah(!1),cwd:a,onSelectSession:L}),a&&ao&&(0,e.jsx)(j.x,{isOpen:ai,onClose:()=>aj(!1),cwd:a}),ak&&(0,e.jsx)(l.Y,{onClose:()=>al(!1),onSave:()=>al(!1)})]})})})}[p,m,q,r,s,i,k,j]=B.then?(await B)():B,d()}catch(a){d(a)}})},78335:()=>{},78684:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{o:()=>m});var e=c(48249),f=c(67484),g=c(36295),h=c(7833),i=c(28602),j=c(39712),k=c(74493),l=a([g,j]);function m({id:a,filePath:b,displayName:c,cwd:d,selected:l,maximized:n,expandedHeight:o,bubbleContentHeight:p,timestamp:q,onSelect:r,onClose:s,onToggleMaximize:t,onTitleMouseDown:u}){let{showToast:v}=(0,h.dj)(),[w,x]=(0,f.useState)([]),[y,z]=(0,f.useState)(!0),[A,B]=(0,f.useState)(null),[C,D]=(0,f.useState)(!1),[E,F]=(0,f.useState)(!1),[G,H]=(0,f.useState)(null),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)("disconnected"),[M,N]=(0,f.useState)(null),O=(0,f.useRef)(null),P=(0,f.useRef)(new Map),Q=(0,f.useRef)(null),R=(0,f.useRef)(w);R.current=w;let S=(0,f.useCallback)(async()=>{z(!0),B(null);try{let a=await (0,k.GW)("/api/jupyter/load",{filePath:b,cwd:d});x(a.cells.map((a,b)=>({...a,index:b,isExecuting:!1}))),D(!1)}catch(a){B(a.message)}finally{z(!1)}},[b,d]),T=(0,f.useCallback)(async()=>{if(!E){F(!0);try{await (0,k.GW)("/api/jupyter/save",{filePath:b,cwd:d,cells:w.map(a=>({cell_type:a.cell_type,source:a.source,outputs:a.outputs,execution_count:a.execution_count,metadata:a.metadata}))}),D(!1),v("Saved","success")}catch(a){v(a.message,"error")}finally{F(!1)}}},[b,d,w,E,v]),U=(0,f.useCallback)(()=>{if(O.current&&O.current.readyState<=1)return;L("starting"),N(null);let b="https:"===window.location.protocol?"wss:":"ws:",c=new WebSocket(`${b}//${window.location.host}/ws/jupyter?bubbleId=${encodeURIComponent(a)}&cwd=${encodeURIComponent(d)}`);O.current=c,c.onopen=()=>{},c.onmessage=a=>{let b;try{b=JSON.parse(a.data)}catch{return}let c=b.type;if("ready"===c)L("idle"),N(null);else if("status"===c){let a=b.execution_state;"idle"===a?L("idle"):"busy"===a&&L("busy")}else if("output"===c){let a=b.msg_id,c=b.msg_type,d=b.content,e=P.current.get(a);if(void 0===e)return;x(a=>a.map((a,b)=>{if(b!==e)return a;let f={output_type:"execute_result"===c?"execute_result":"display_data"===c?"display_data":"update_display_data"===c?"update_display_data":"stream"===c?"stream":"error"===c?"error":"display_data"};return"stream"===c?(f.name=d.name,f.text=d.text):"error"===c?(f.ename=d.ename,f.evalue=d.evalue,f.traceback=d.traceback):(f.data=d.data,f.metadata=d.metadata,"execute_result"===c&&(f.execution_count=d.execution_count)),{...a,outputs:[...a.outputs,f]}}))}else if("kernel_error"===c)L("error"),N(b.message);else if("kernel_died"===c){for(let[,a]of(L("dead"),N("Kernel died"),P.current))x(b=>b.map((b,c)=>c===a?{...b,isExecuting:!1}:b));P.current.clear()}},c.onclose=()=>{"error"!==K&&"dead"!==K&&L("disconnected")},c.onerror=()=>{L("error")}},[a,d,K]),V=(0,f.useRef)(null),W=(0,f.useCallback)(a=>{let b=R.current[a];if(!b||"code"!==b.cell_type)return;if(!O.current||O.current.readyState!==WebSocket.OPEN){U();let b=setInterval(()=>{O.current?.readyState===WebSocket.OPEN&&(clearInterval(b),V.current?.(a))},200);setTimeout(()=>clearInterval(b),15e3);return}let c=`cell-${a}-${Date.now()}`;P.current.set(c,a),x(b=>b.map((b,c)=>c===a?{...b,outputs:[],isExecuting:!0,execution_count:null}:b)),O.current.send(JSON.stringify({type:"execute",msg_id:c,code:b.source})),setTimeout(()=>{P.current.has(c)&&(P.current.delete(c),x(b=>b.map((b,c)=>c===a?{...b,isExecuting:!1}:b)))},3e5)},[U]);V.current=W;let X=(0,f.useCallback)(()=>{let a=[...w.map((a,b)=>({cell:a,index:b})).filter(a=>"code"===a.cell.cell_type)],b=()=>{if(0===a.length)return;let{index:c}=a.shift();W(c);let d=setInterval(()=>{let a=R.current[c];a&&!a.isExecuting&&(clearInterval(d),b())},200)};b()},[w,W]),Y=(0,f.useCallback)(()=>{O.current?.send(JSON.stringify({type:"interrupt"}))},[]),Z=(0,f.useCallback)((a,b)=>{x(c=>c.map((c,d)=>d===a?{...c,source:b}:c)),D(!0)},[]),$=(0,f.useCallback)(a=>{x(b=>b.filter((b,c)=>c!==a)),D(!0),G===a&&H(null)},[G]),_=(0,f.useCallback)((a,b)=>{x(c=>{let d=[...c],e="up"===b?a-1:a+1;return e<0||e>=d.length?c:([d[a],d[e]]=[d[e],d[a]],d)}),D(!0),H("up"===b?a-1:a+1)},[]),aa=(0,f.useCallback)(a=>{x(b=>b.map((b,c)=>{if(c!==a)return b;let d="code"===b.cell_type?"markdown":"markdown"===b.cell_type?"raw":"code";return{...b,cell_type:d,outputs:"code"===d?b.outputs:[]}})),D(!0)},[]),ab=(0,f.useCallback)((a,b)=>{let c={index:0,cell_type:a,source:"",outputs:[],execution_count:null,metadata:{},isExecuting:!1};x(a=>{let d=[...a],e=void 0!==b?b+1:d.length;return d.splice(e,0,c),d}),D(!0);let d=void 0!==b?b+1:w.length;H(d),J(d)},[w.length]),ac=n&&o?o-41:p??g.p,ad=(0,f.useMemo)(()=>{switch(K){case"idle":return(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500 inline-block",title:"Kernel idle"});case"busy":return(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse inline-block",title:"Kernel busy"});case"starting":return(0,e.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin inline-block",title:"Starting kernel"});case"error":return(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-500 inline-block",title:M||"Kernel error"});case"dead":return(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-500 inline-block",title:"Kernel died"});default:return(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-gray-500 inline-block",title:"Disconnected"})}},[K,M]);return(0,e.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
39
39
|
relative transition-colors cursor-pointer
|
|
40
40
|
${n?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
41
|
-
${n?"":l?"border-brand":"border-brand/30"}`,onClick:n?void 0:r,children:[(0,e.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:t,onMouseDown:u,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${n?"bg-card":"bg-card/50"}`,style:n?{height:41}:void 0,children:[(0,e.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDCD3"}),(0,e.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),ad,C&&(0,e.jsx)("span",{className:"text-[10px] text-amber-500 flex-shrink-0",children:"unsaved"}),(0,e.jsx)("span",{className:"flex-1"}),q&&(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:function(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}(q)}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),t()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:n?`Exit maximize (${(0,i.Mu)()}+M)`:`Maximize (${(0,i.Mu)()}+M)`,children:n?(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),s()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:"Close",children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 px-3 py-1 border-b border-border/50 bg-surface-secondary/50 text-[11px]",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),X()},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Run All",children:"▶ All"}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),Y()},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Interrupt",disabled:"busy"!==K,children:"⬛ Stop"}),(0,e.jsx)("div",{className:"w-px h-3 bg-border/50 mx-1"}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),ab("code",G??w.length-1)},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Add code cell",children:"+ Code"}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),ab("markdown",G??w.length-1)},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Add markdown cell",children:"+ Md"}),(0,e.jsx)("div",{className:"w-px h-3 bg-border/50 mx-1"}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),T()},className:`px-1.5 py-0.5 rounded hover:bg-accent transition-colors ${C?"text-brand":"text-muted-foreground hover:text-foreground"}`,title:`Save (${(0,i.Mu)()}+S)`,disabled:E,children:E?"Saving...":"Save"}),(0,e.jsx)("span",{className:"flex-1"}),M&&(0,e.jsx)("span",{className:"text-[10px] text-red-400 truncate max-w-[50%]",title:M,children:M}),"dead"===K&&(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),U()},className:"px-1.5 py-0.5 rounded text-brand hover:bg-accent transition-colors",children:"Restart"})]}),(0,e.jsx)("div",{ref:Q,className:"overflow-y-auto",style:{height:ac-30},children:y?(0,e.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground text-sm",children:"Loading notebook..."}):A?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center h-32 gap-2",children:[(0,e.jsx)("span",{className:"text-red-400 text-sm",children:A}),(0,e.jsx)("button",{onClick:S,className:"text-xs text-brand hover:underline",children:"Retry"})]}):0===w.length?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center h-32 gap-2 text-muted-foreground text-sm",children:[(0,e.jsx)("span",{children:"Empty notebook"}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("button",{onClick:()=>ab("code"),className:"text-xs text-brand hover:underline",children:"+ Code cell"}),(0,e.jsx)("button",{onClick:()=>ab("markdown"),className:"text-xs text-brand hover:underline",children:"+ Markdown cell"})]})]}):(0,e.jsxs)("div",{className:"flex flex-col gap-1 p-2",children:[w.map((a,b)=>(0,e.jsx)(j.w,{cell:a,isActive:G===b,isEditing:I===b,onSelect:()=>H(b),onEdit:()=>{H(b),J(b)},onStopEdit:()=>J(null),onSourceChange:a=>Z(b,a),onRun:()=>{"code"===a.cell_type&&W(b),b<w.length-1&&H(b+1)},onDelete:()=>$(b),onMoveUp:()=>_(b,"up"),onMoveDown:()=>_(b,"down"),onToggleType:()=>aa(b),isFirst:0===b,isLast:b===w.length-1},`${b}-${a.cell_type}`)),(0,e.jsxs)("div",{className:"flex justify-center gap-2 py-2 opacity-0 hover:opacity-100 transition-opacity",children:[(0,e.jsx)("button",{onClick:()=>ab("code",w.length-1),className:"text-[10px] text-muted-foreground hover:text-foreground px-2 py-0.5 rounded border border-border/50 hover:border-border transition-colors",children:"+ Code"}),(0,e.jsx)("button",{onClick:()=>ab("markdown",w.length-1),className:"text-[10px] text-muted-foreground hover:text-foreground px-2 py-0.5 rounded border border-border/50 hover:border-border transition-colors",children:"+ Markdown"})]})]})})]})}[g,j]=l.then?(await l)():l,d()}catch(a){d(a)}})},80532:(a,b,c)=>{"use strict";c.d(b,{Bz:()=>j,Hy:()=>g,L5:()=>h,hp:()=>i});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=()=>f("/api/skills"),h=a=>f("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),i=a=>f(`/api/skills/${encodeURIComponent(a)}`,{method:"DELETE"}),j=a=>f(`/api/skills/content?id=${encodeURIComponent(a)}`)},80983:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>m});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(23700),j=c(92701),k=c(61349),l=a([k,i,j]);[k,i,j]=l.then?(await l)():l;let n={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D",Workflow:"\uD83E\uDDE9",Skill:"\uD83D\uDEE0️"};function m({toolCall:a,cwd:b,sessionId:c}){var d;let{t:l}=(0,g.Bd)(),[o,p]=(0,f.useState)(!1),[q,r]=(0,f.useState)(null),[s,t]=(0,f.useState)(!1),[u,v]=(0,f.useState)(!1),w=n[a.name]||"\uD83D\uDD27",x="Agent"===a.name||"Task"===a.name,y=x&&!!b&&!!c,z="Workflow"===a.name,A=z&&(d=a.result)?d.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,B=z&&!!A&&!!b&&!!c,C="Skill"===a.name,D=x||z||C,E=(()=>{let b=a.input;if("Bash"===a.name&&b.command&&"string"==typeof b.command)return b.command;if(x&&b.description&&"string"==typeof b.description)return b.description;if(z){let a="string"==typeof b.name?b.name:"",c="string"==typeof b.args?b.args:"string"==typeof b.resumeFromRunId?b.resumeFromRunId:"",d=[a,c].filter(Boolean).join(" \xb7 ");if(d)return d}if(C&&"string"==typeof b.skill){let a="string"==typeof b.args?b.args:"";return[b.skill,a].filter(Boolean).join(" \xb7 ")}return"Glob"===a.name&&b.pattern&&"string"==typeof b.pattern||"Grep"===a.name&&b.pattern&&"string"==typeof b.pattern?b.pattern:"ToolSearch"===a.name&&b.query&&"string"==typeof b.query?b.query:"TaskCreate"===a.name&&b.subject&&"string"==typeof b.subject?b.subject:b.file_path&&"string"==typeof b.file_path?b.file_path:b.path&&"string"==typeof b.path?b.path:null})(),F="Glob"===a.name||"Grep"===a.name||"Bash"===a.name||x||z||C,G=E?F?E:(a=>{if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}let c=a.split("/");return c.length>2?".../"+c.slice(-2).join("/"):a})(E):null,H=b=>{let c="input"===b?l("toolCall.inputParams"):l("toolCall.resultLabel"),d="input"===b?JSON.stringify(a.input,null,2):"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2);r({title:`${a.name}${G?` ${G}`:""} - ${c}`,content:d,toolName:a.name})};return(0,e.jsxs)("div",{className:"my-1 border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,e.jsxs)("button",{onClick:()=>p(!o),className:"w-full px-3 py-1.5 flex items-center gap-2 text-left hover:bg-accent transition-colors",children:[(0,e.jsx)("span",{className:"text-sm",children:w}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:a.name}),G&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:E||"",children:G}),!D&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),E&&(navigator.clipboard.writeText(E),(0,h.oR)(l("common.copiedPath")))},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),E&&(navigator.clipboard.writeText(E),(0,h.oR)(l("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0 cursor-pointer",title:l("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[y&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),t(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),t(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:l("chat.subagentViewTitle"),children:l("chat.subagent")}),B&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),v(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),v(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:l("chat.workflowViewTitle"),children:l("chat.workflowRun")}),o&&!a.isLoading&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),H("input")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),H("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:l("toolCall.inputParamsTitle"),children:l("toolCall.input")}),a.result&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),H("result")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),H("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:l("toolCall.resultTitle"),children:l("toolCall.result")})]}),a.isLoading?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("span",{className:"text-slate-9 text-xs",children:o?"▲":"▼"})]})]}),o&&(0,e.jsxs)("div",{className:"border-t border-border",children:[(0,e.jsxs)("div",{className:"px-3 py-2",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[l("toolCall.inputParams"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(a.input,null,2)})]}),a.result&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-border",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[l("toolCall.resultLabel"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2)})]}),a.skillContent&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-border",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[l("toolCall.skillContent",{defaultValue:"Skill content"}),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-60 overflow-y-auto text-foreground whitespace-pre-wrap",children:a.skillContent})]})]}),q&&(0,e.jsx)(k.M,{title:q.title,content:q.content,toolName:q.toolName,onClose:()=>r(null)}),s&&b&&c&&(0,e.jsx)(i.f,{cwd:b,sessionId:c,toolCall:a,onClose:()=>t(!1)}),u&&b&&c&&A&&(0,e.jsx)(j.K,{cwd:b,sessionId:c,runId:A,isRunning:!!a.isLoading,onClose:()=>v(!1)})]})}d()}catch(a){d(a)}})},81064:(a,b,c)=>{Promise.resolve().then(c.bind(c,81227))},81227:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx","default")},82795:(a,b,c)=>{"use strict";c.d(b,{e:()=>i});var d=c(48249),e=c(67484),f=c(44384),g=c(33281),h=c(41224);function i({isOpen:a,onClose:b,onSwitchProject:c}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)([]),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(""),s=(0,e.useRef)(null);(0,e.useCallback)(async()=>{n(!0),p(null);let a=await g.t4.runPromiseExit((0,h.z2)());"Success"===a._tag?l([...a.value]):p(j("sessions.loadSessionsFailed")),n(!1)},[j]);let t=k.filter(a=>{if(!q)return!0;let b=q.toLowerCase();return void 0!==a.searchText?a.searchText.includes(b):a.cwd.toLowerCase().includes(b)||(a.title?.toLowerCase().includes(b)??!1)||(a.lastUserMessage?.toLowerCase().includes(b)??!1)||(a.firstMessages?.some(a=>a.toLowerCase().includes(b))??!1)||(a.lastMessages?.some(a=>a.toLowerCase().includes(b))??!1)});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:b}),(0,d.jsxs)("div",{className:"relative w-full max-w-7xl h-[90vh] mx-4 bg-card rounded-lg shadow-xl flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsx)("div",{className:"flex-1 min-w-0",children:(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:j("sessions.recentSessions")})}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsx)("input",{ref:s,type:"text",placeholder:j("sessions.searchSessions"),value:q,onChange:a=>r(a.target.value),className:"px-2 py-1 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[m&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:j("sessions.loadingSessions")})]})}),o&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:o})}),!m&&!o&&0===t.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:q?j("sessions.noMatchingSessions"):j("sessions.noSessions")})}),!m&&!o&&t.length>0&&(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:t.map(a=>{let e;return(0,d.jsxs)("div",{onClick:()=>{c(a.cwd,a.sessionId),b()},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,d.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${"loading"===a.status?"bg-orange-9 animate-pulse":"unread"===a.status?"bg-red-500":"bg-muted-foreground/30"}`}),a.engine&&"claude"!==a.engine&&(0,d.jsx)("span",{className:`shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded ${"claude2"===a.engine?"bg-orange-500/15 text-orange-11":"ollama"===a.engine?"bg-blue-500/15 text-blue-11":"codex"===a.engine?"bg-green-500/15 text-green-11":"kimi"===a.engine?"bg-purple-500/15 text-purple-11":"bg-muted text-muted-foreground"}`,children:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate flex-1",title:a.cwd,children:(e=a.cwd).split("/").pop()||e}),"loading"===a.status&&(0,d.jsx)("span",{className:"text-[10px] text-orange-11 flex-shrink-0",children:j("sessions.running")}),"unread"===a.status&&(0,d.jsx)("span",{className:"text-[10px] text-red-500 flex-shrink-0",children:j("sessions.done")})]}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(a.lastActive).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(a.firstMessages?.length??0)>0||(a.lastMessages?.length??0)>0?(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[a.firstMessages?.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`first-${b}`)),(a.lastMessages?.length??0)>0&&(0,d.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),a.lastMessages?.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`last-${b}`))]}):a.lastUserMessage||a.title?(0,d.jsxs)("div",{className:"text-xs text-foreground truncate",title:a.lastUserMessage||a.title,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a.lastUserMessage||a.title]}):null]},`${a.cwd}-${a.sessionId}`)})})]})]})]}):null}},83003:(a,b,c)=>{"use strict";c.d(b,{k:()=>i});var d=c(48249),e=c(67484),f=c(44384),g=c(44256);function h({image:a,onClose:b}){let{t:c}=(0,f.Bd)(),e=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:b,children:(0,d.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,d.jsx)("img",{src:a.preview,alt:c("imagePreview.previewImage"),className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:a=>a.stopPropagation()}),(0,d.jsx)("button",{onClick:b,className:"absolute -top-3 -right-3 w-8 h-8 bg-card text-foreground hover:text-foreground rounded-full shadow-lg flex items-center justify-center transition-colors",title:c("common.close"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})});return(0,d.jsx)(g.ZL,{children:e})}function i({images:a,onRemove:b,disabled:c}){let{t:g}=(0,f.Bd)(),[j,k]=(0,e.useState)(null);return 0===a.length?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"flex flex-wrap gap-2 p-2 bg-secondary border-b border-border",children:a.map(a=>(0,d.jsxs)("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-border cursor-pointer",onClick:()=>k(a),children:[(0,d.jsx)("img",{src:a.preview,alt:g("imagePreview.previewImage"),className:"w-full h-full object-cover hover:opacity-90 transition-opacity"}),(0,d.jsx)("button",{onClick:c=>{c.stopPropagation(),b(a.id)},className:"absolute top-0 right-0 w-5 h-5 bg-black/60 hover:bg-black/80 text-white text-xs flex items-center justify-center rounded-bl-lg opacity-0 group-hover:opacity-100 transition-opacity",title:g("imagePreview.deleteImage"),children:"✕"})]},a.id))}),j&&(0,d.jsx)(h,{image:j,onClose:()=>k(null)})]})}},83022:(a,b,c)=>{"use strict";c.d(b,{TabBar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call TabBar() from the server but TabBar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/TabBar.tsx","TabBar")},83120:(a,b,c)=>{"use strict";c.d(b,{BL:()=>q,Gm:()=>n,JK:()=>l,Wr:()=>o,Y8:()=>t,Y_:()=>k,_c:()=>r,bx:()=>m,dU:()=>s,i7:()=>x,jw:()=>u,mu:()=>v,vy:()=>w,z1:()=>p});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=(a,b)=>f(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>f(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),j=a=>f(a,{method:"DELETE"}),k=()=>f("/api/review"),l=a=>{let b;return b=`/api/review/${encodeURIComponent(a)}`,d.tryPromise({try:async()=>{let a=await fetch(b);if(404===a.status)throw Object.assign(Error("not found"),{__404__:!0});if(!a.ok)throw Error(`HTTP ${a.status}`);return await a.json()},catch:a=>a?.__404__?new e.m_({resource:"review",id:b}):new e.uV({message:`GET ${b} failed`,cause:a})})},m=a=>g("/api/review",a),n=(a,b)=>i(`/api/review/${encodeURIComponent(a)}`,b),o=a=>j(`/api/review/${encodeURIComponent(a)}`),p=a=>i("/api/review/order",{order:a}),q=()=>f("/api/review/users"),r=()=>f("/api/review/share-info"),s=(a,b)=>g(`/api/review/${encodeURIComponent(a)}/comments`,b),t=(a,b)=>h(`/api/review/${encodeURIComponent(a)}/comments`,b),u=(a,b)=>j(`/api/review/${encodeURIComponent(a)}/comments?commentId=${encodeURIComponent(b)}`),v=(a,b)=>g(`/api/review/${encodeURIComponent(a)}/replies`,b),w=(a,b)=>h(`/api/review/${encodeURIComponent(a)}/replies`,b),x=(a,b,c)=>j(`/api/review/${encodeURIComponent(a)}/replies?commentId=${encodeURIComponent(b)}&replyId=${encodeURIComponent(c)}`)},83179:(a,b,c)=>{"use strict";c.d(b,{NoteToolbar:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({editor:a,onClose:b,position:c}){let{t:h}=(0,f.Bd)(),[i,j]=(0,e.useState)(()=>a.getAttributes("link").href||""),k=(0,e.useRef)(null),l=()=>{let c=i.trim();if(c){let b=c.match(/^https?:\/\//)?c:`https://${c}`;a.chain().focus().extendMarkRange("link").setLink({href:b}).run()}else a.chain().focus().extendMarkRange("link").unsetLink().run();b()},m=c?{top:c.top,left:c.left}:{};return(0,d.jsxs)("div",{className:`${c?"fixed":"absolute top-full left-0 mt-1"} z-[60] bg-popover border border-border rounded-lg shadow-lg p-2 flex items-center gap-2`,style:m,children:[(0,d.jsx)("input",{ref:k,type:"text",value:i,onChange:a=>j(a.target.value),onKeyDown:a=>{"Enter"===a.key?(a.preventDefault(),l()):"Escape"===a.key&&(a.preventDefault(),b())},placeholder:h("editor.linkPlaceholder"),className:"bg-background border border-border rounded px-2 py-1 text-sm w-64 outline-none focus:border-brand"}),(0,d.jsx)("button",{onClick:l,className:"p-1 rounded text-sm font-medium text-brand hover:bg-brand/10 transition-colors",title:h("editor.confirmLink"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})})}),a.isActive("link")&&(0,d.jsx)("button",{onClick:()=>{a.chain().focus().extendMarkRange("link").unsetLink().run(),b()},className:"p-1 rounded text-sm font-medium text-red-500 hover:bg-red-500/10 transition-colors",title:h("editor.removeLink"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})}function h({editor:a}){let{t:b}=(0,f.Bd)(),[c,i]=(0,e.useState)(!1),j=(0,e.useRef)(null),[,k]=(0,e.useState)(0);if(!a)return null;let l=a=>`p-1.5 rounded text-xs font-medium transition-colors ${a?"bg-brand/15 text-brand":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,m="w-px h-5 bg-border mx-0.5",n=a.isActive("table");return(0,d.jsxs)("div",{className:"flex items-center gap-0.5 px-4 py-1.5 border-b border-border flex-shrink-0 flex-wrap",children:[(0,d.jsx)("button",{className:l(a.isActive("heading",{level:1})),onClick:()=>a.chain().focus().toggleHeading({level:1}).run(),title:b("editor.heading1"),children:"H1"}),(0,d.jsx)("button",{className:l(a.isActive("heading",{level:2})),onClick:()=>a.chain().focus().toggleHeading({level:2}).run(),title:b("editor.heading2"),children:"H2"}),(0,d.jsx)("button",{className:l(a.isActive("heading",{level:3})),onClick:()=>a.chain().focus().toggleHeading({level:3}).run(),title:b("editor.heading3"),children:"H3"}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(a.isActive("bold")),onClick:()=>a.chain().focus().toggleBold().run(),title:b("editor.bold"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"})})}),(0,d.jsx)("button",{className:l(a.isActive("italic")),onClick:()=>a.chain().focus().toggleItalic().run(),title:b("editor.italic"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"})})}),(0,d.jsx)("button",{className:l(a.isActive("strike")),onClick:()=>a.chain().focus().toggleStrike().run(),title:b("editor.strikethrough"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"})})}),(0,d.jsx)("button",{className:l(a.isActive("code")),onClick:()=>a.chain().focus().toggleCode().run(),title:b("editor.inlineCode"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"})})}),(0,d.jsx)("div",{className:m}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{ref:j,className:l(a.isActive("link")),onClick:()=>i(!c),title:b("editor.link"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})})}),c&&(0,d.jsx)(g,{editor:a,onClose:()=>i(!1),position:null})]}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(a.isActive("bulletList")),onClick:()=>a.chain().focus().toggleBulletList().run(),title:b("editor.bulletList"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"})})}),(0,d.jsx)("button",{className:l(a.isActive("orderedList")),onClick:()=>a.chain().focus().toggleOrderedList().run(),title:b("editor.orderedList"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"})})}),(0,d.jsx)("button",{className:l(a.isActive("taskList")),onClick:()=>a.chain().focus().toggleTaskList().run(),title:b("editor.taskList"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM17.99 9l-1.41-1.42-6.59 6.59-2.58-2.57-1.42 1.41 4 3.99z"})})}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(a.isActive("blockquote")),onClick:()=>a.chain().focus().toggleBlockquote().run(),title:b("editor.blockquote"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})}),(0,d.jsx)("button",{className:l(a.isActive("codeBlock")),onClick:()=>a.chain().focus().toggleCodeBlock().run(),title:b("editor.codeBlock"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H4V5h16v14zm-7.5-4.5L15 12l-2.5-2.5L11 11l1.5 1.5L11 14l1.5 1.5zM9.5 14.5L7 12l2.5-2.5L11 11 9.5 12.5 11 14l-1.5.5z"})})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:b("editor.table"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-9 15H4v-4h7v4zm0-6H4V7h7v4zm9 6h-7v-4h7v4zm0-6h-7V7h7v4z"})})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().setHorizontalRule().run(),title:b("editor.horizontalRule"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M4 11h16v2H4z"})})}),n&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addRowBefore().run(),title:b("editor.insertRowAbove"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zM11 17H4v-2h7v2zm0-4H4v-2h7v2zm9 4h-7v-2h7v2zm0-4h-7v-2h7v2z"}),(0,d.jsx)("path",{d:"M14 1h-4v2H8v2h2v2h4V5h2V3h-2z",opacity:".6"})]})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addRowAfter().run(),title:b("editor.insertRowBelow"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v10h20V6c0-1.1-.9-2-2-2zM11 12H4v-2h7v2zm0-4H4V6h7v2zm9 4h-7v-2h7v2zm0-4h-7V6h7v2z"}),(0,d.jsx)("path",{d:"M14 19h-4v2H8v2h2v-2h4v2h2v-2h-2z",opacity:".6"})]})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addColumnBefore().run(),title:b("editor.insertColumnLeft"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 11H10v-2h7v2zm0-4H10V9h7v2z"}),(0,d.jsx)("path",{d:"M1 14v-4h2V8h2v2h-2v4h2v2H3v-2z",opacity:".6"})]})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addColumnAfter().run(),title:b("editor.insertColumnRight"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M4 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h10V4H4zm7 11H4v-2h7v2zm0-4H4V9h7v2z"}),(0,d.jsx)("path",{d:"M18 4v20h2c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-2z"}),(0,d.jsx)("path",{d:"M21 14v-4h2V8h2v2h-2v4h2v2h-2v-2z",opacity:".6"})]})}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-500 hover:bg-orange-500/10",onClick:()=>a.chain().focus().deleteRow().run(),title:b("editor.deleteRow"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zm-8 8H4v-2h8v2z"}),(0,d.jsx)("path",{d:"M15 13l-1.41 1.41L15.17 16l-1.58 1.59L15 19l1.59-1.59L18.17 19l1.42-1.41L18 16l1.59-1.59L18.17 13 16.59 14.41z",fill:"currentColor"})]})}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-500 hover:bg-orange-500/10",onClick:()=>a.chain().focus().deleteColumn().run(),title:b("editor.deleteColumn"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 7H10V9h7v2z"}),(0,d.jsx)("path",{d:"M13 16l-1.41 1.41L13.17 19l-1.58 1.59L13 22l1.59-1.59L16.17 22l1.42-1.41L16 19l1.59-1.59L16.17 16l-1.58 1.41z",fill:"currentColor"})]})}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-500 hover:bg-red-500/10",onClick:()=>a.chain().focus().deleteTable().run(),title:b("editor.deleteTable"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]}),a.isActive("codeBlock")&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-500 hover:bg-red-500/10",onClick:()=>a.chain().focus().toggleCodeBlock().run(),title:b("editor.deleteCodeBlock"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})]})}},83377:(a,b,c)=>{"use strict";c.d(b,{A:()=>e});var d=c(67484);function e({lines:a,enabled:b,onContentChange:c,onEnterInsert:f,onSave:g,getVisibleLineCount:h,scrollToLine:i,onSearchExecute:j,onSearchNext:k,onSearchPrev:l,onSearchClear:m}){let[n,o]=(0,d.useState)("normal"),[p,q]=(0,d.useState)(-1),[r,s]=(0,d.useState)(0),[t,u]=(0,d.useState)(!1),[v,w]=(0,d.useState)(""),[x,y]=(0,d.useState)(""),[z,A]=(0,d.useState)(""),[B,C]=(0,d.useState)(""),D=(0,d.useRef)([]),E=(0,d.useRef)([]),F=(0,d.useRef)([]),G=(0,d.useRef)(null),H=(0,d.useRef)(a),I=(0,d.useCallback)((a,b)=>Math.max(0,Math.min(b,Math.max(0,(H.current[a]??"").length-1))),[]);(0,d.useRef)(a.length);let J=(0,d.useCallback)(()=>{G.current&&(clearTimeout(G.current),G.current=null),w("")},[]),K=(0,d.useCallback)(()=>{G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{w(""),G.current=null},500)},[]),L=(0,d.useCallback)((a,b)=>{D.current.push(b),E.current=[],u(!0),c(a.join("\n"))},[c]),M=(0,d.useCallback)((a,b)=>{let c=Math.max(0,Math.min(a,H.current.length-1));q(c),s(I(c,b??0)),i(c,"auto")},[i,I]),N=(0,d.useCallback)(a=>{q(b=>{let c=Math.max(0,Math.min(b+a,H.current.length-1));return i(c,"auto"),s(a=>Math.max(0,Math.min(a,Math.max(0,(H.current[c]??"").length-1)))),c})},[i]),O=(0,d.useCallback)(()=>{let a=H.current,b=Math.min(p,a.length-1);if(0===a.length)return;let c=a[b];F.current=[c];let d=[...a];d.splice(b,1),0===d.length&&d.push("");let e=Math.min(b,d.length-1);L(d,{lineIndex:b,oldLines:[c],newLines:[],cursorLine:b}),q(e),s(0)},[p,L]),P=(0,d.useCallback)(()=>{let a=H.current,b=Math.min(p,a.length-1);a.length>0&&(F.current=[a[b]])},[p]),Q=(0,d.useCallback)(()=>{let a=F.current;if(0===a.length)return;let b=H.current,c=Math.min(p,b.length-1)+1,d=[...b];d.splice(c,0,...a),L(d,{lineIndex:c,oldLines:[],newLines:[...a],cursorLine:p}),q(c),s(0),i(c,"auto")},[p,L,i]),R=(0,d.useCallback)(()=>{let a=H.current,b=Math.min(p,a.length-1),c=a[b];if(!c||0===c.length)return;let d=c.substring(1),e=[...a];e[b]=d,L(e,{lineIndex:b,oldLines:[c],newLines:[d],cursorLine:p})},[p,L]),S=(0,d.useCallback)(()=>{let a=D.current;if(0===a.length)return;let b=a.pop(),d=[...H.current];0===b.newLines.length&&b.oldLines.length>0?d.splice(b.lineIndex,0,...b.oldLines):0===b.oldLines.length&&b.newLines.length>0?(d.splice(b.lineIndex,b.newLines.length),0===d.length&&d.push("")):d.splice(b.lineIndex,b.newLines.length,...b.oldLines),E.current.push(b),c(d.join("\n")),q(Math.min(b.cursorLine,d.length-1)),i(Math.min(b.cursorLine,d.length-1),"auto"),0===a.length&&u(!1)},[c,i]),T=(0,d.useCallback)(()=>{let a=E.current;if(0===a.length)return;let b=a.pop(),d=[...H.current];0===b.newLines.length&&b.oldLines.length>0?(d.splice(b.lineIndex,b.oldLines.length),0===d.length&&d.push("")):0===b.oldLines.length&&b.newLines.length>0?d.splice(b.lineIndex,0,...b.newLines):d.splice(b.lineIndex,b.oldLines.length,...b.newLines),D.current.push(b),u(!0),c(d.join("\n"));let e=b.lineIndex+Math.max(0,b.newLines.length-1);q(Math.min(e,d.length-1)),i(Math.min(e,d.length-1),"auto")},[c,i]),U=(0,d.useCallback)(a=>{let b=H.current,c=Math.min(p,b.length-1);if("o"===a||"O"===a){let d="o"===a?c+1:c,e=[...b];e.splice(d,0,""),L(e,{lineIndex:d,oldLines:[],newLines:[""],cursorLine:p}),c=d,q(d)}o("insert"),f(c,r,a)},[p,r,L,f]),V=(0,d.useCallback)(()=>{o("normal"),J()},[J]),W=(0,d.useCallback)(()=>{o("command"),y("")},[]),X=(0,d.useCallback)(()=>{o("normal"),y("")},[]),Y=(0,d.useCallback)(()=>{o("search"),A("")},[]),Z=(0,d.useCallback)(()=>{o("normal"),A("")},[]),$=(0,d.useCallback)(a=>{let b=a.trim();if("w"===b){g?.(),o("normal"),y("");return}if("q"===b){o("normal"),y("");return}if("wq"===b){g?.(),o("normal"),y("");return}if("noh"===b||"nohlsearch"===b){m?.(),o("normal"),y("");return}let c=parseInt(b,10);if(!isNaN(c)&&c>0){let a=Math.min(c-1,H.current.length-1);q(a),i(a,"center"),o("normal"),y("");return}o("normal"),y("")},[g,m,i]),_=(0,d.useCallback)(a=>{if(!a){o("normal"),A("");return}C(a),j?.(a),o("normal"),A("")},[j]),aa=(0,d.useCallback)(a=>{if(!b)return!1;let c=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;if("insert"===n)return("Escape"===a.key||!!c)&&(V(),!0);if("command"===n)return!a.isComposing&&("Escape"===a.key||c?X():"Enter"===a.key?$(x):"Backspace"===a.key?0===x.length?X():y(a=>a.slice(0,-1)):1!==a.key.length||a.metaKey||a.ctrlKey||y(b=>b+a.key),!0);if("search"===n)return!a.isComposing&&("Escape"===a.key||c?Z():"Enter"===a.key?_(z):"Backspace"===a.key?0===z.length?Z():A(a=>a.slice(0,-1)):1!==a.key.length||a.metaKey||a.ctrlKey||A(b=>b+a.key),!0);if(p<0&&(q(0),s(0)),a.metaKey)return!1;if(a.ctrlKey)return"d"===a.key?(N(Math.max(1,Math.floor(h()/2))),J(),!0):"u"===a.key?(N(-Math.max(1,Math.floor(h()/2))),J(),!0):"r"===a.key&&(T(),J(),!0);let d=a.key,e=v+d;if("g"===e)return w("g"),K(),!0;if("gg"===e)return M(0),J(),!0;if("d"===e)return w("d"),K(),!0;if("dd"===e)return O(),J(),!0;if("y"===e)return w("y"),K(),!0;if("yy"===e)return P(),J(),!0;if(v&&e!==d&&J(),"j"===d||"ArrowDown"===d)return N(1),!0;if("k"===d||"ArrowUp"===d)return N(-1),!0;if("h"===d||"ArrowLeft"===d)return s(a=>Math.max(0,a-1)),!0;if("l"===d||"ArrowRight"===d){let a=Math.max(0,(H.current[p]??"").length-1);return s(b=>Math.min(a,b+1)),!0}if("0"===d)return s(0),!0;if("$"===d)return s(Math.max(0,(H.current[p]??"").length-1)),!0;if("^"===d){let a=(H.current[p]??"").search(/\S/);return s(a>=0?a:0),!0}return"G"===d?(M(H.current.length-1),!0):"x"===d?(R(),!0):"p"===d?(Q(),!0):"u"===d?(S(),!0):"i"===d||"a"===d||"I"===d||"A"===d||"o"===d||"O"===d?(U(d),!0):"/"===d?(Y(),!0):"n"===d?(k?.(),!0):"N"===d?(l?.(),!0):":"===d?(W(),!0):"Escape"!==d&&1===d.length},[b,n,v,x,z,p,V,U,W,X,Y,Z,$,_,N,M,h,O,P,Q,R,S,T,J,K,k,l]);return{state:{mode:n,cursorLine:p,cursorCol:r,isDirty:t,keyBuffer:v,commandInput:x,searchInput:z,lastSearch:B},handleKeyDown:aa,enterNormal:V,enterInsert:U,setCursorLine:q,setCursorCol:s,setCommandInput:y,setSearchInput:A,setIsDirty:u,clearUndoHistory:(0,d.useCallback)(()=>{D.current=[],E.current=[]},[])}}},83768:(a,b,c)=>{"use strict";c.d(b,{D:()=>g,N:()=>h});var d=c(48249),e=c(67484);let f=(0,e.createContext)(null);function g(){let a=(0,e.useContext)(f);if(!a)throw Error("useTheme must be used within a ThemeProvider");return a}function h({children:a}){let[b,c]=(0,e.useState)("system"),[g,i]=(0,e.useState)("light"),j=(0,e.useCallback)(()=>"light",[]),k=(0,e.useCallback)(a=>{let b=document.documentElement;b.classList.remove("light","dark"),b.classList.add(a),i(a);let c=document.querySelector('meta[name="theme-color"]'),d="dark"===a?"#111113":"#f9f9fb";c&&c.setAttribute("content",d)},[]),l=(0,e.useCallback)(a=>{c(a),localStorage.setItem("theme",a),k("system"===a?j():a),document.querySelectorAll("iframe").forEach(b=>{b.contentWindow?.postMessage({type:"THEME_CHANGE",theme:a},"*")})},[j,k]);return(0,d.jsx)(f.Provider,{value:{theme:b,resolvedTheme:g,setTheme:l},children:a})}},84398:(a,b,c)=>{"use strict";function d(a){let b=a.split("/").pop()?.toLowerCase()??"";switch(b.includes(".")?b.split(".").pop():""){case"ts":return"typescript";case"tsx":case"jsx":return"tsx";case"js":case"mjs":case"cjs":return"javascript";case"py":case"pyi":return"python";case"go":return"go";case"rs":return"rust";default:return null}}c.d(b,{k:()=>d})},84747:(a,b,c)=>{"use strict";c.d(b,{Workspace:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call Workspace() from the server but Workspace is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/Workspace.tsx","Workspace")},84835:(a,b,c)=>{"use strict";c.d(b,{W:()=>f});var d=c(50300);let e=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","table","tr","hr","div","ul","ol"]);function f(){return a=>{(0,d.YR)(a,"element",a=>{if(e.has(a.tagName)&&a.position&&(a.properties||(a.properties={}),a.properties["data-source-start"]=a.position.start.line,a.properties["data-source-end"]=a.position.end.line,"pre"===a.tagName)){let b=a.children?.find(a=>"element"===a.type&&"code"===a.tagName);b&&(b.properties||(b.properties={}),b.properties["data-source-start"]=a.position.start.line,b.properties["data-source-end"]=a.position.end.line)}})}}},84844:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{i:()=>p});var e=c(48249),f=c(67484),g=c(44384),h=c(208),i=c(91579),j=c(44256),k=c(7833),l=c(33281),m=c(89800),n=c(87808);function o(a){if(0===a.length)return"";let b=[h.A.t("comments.codeRef"),""],c=a.filter(a=>a.filePath===i.Un),d=a.filter(a=>a.filePath!==i.Un);for(let a of(d.length>0&&d.forEach((a,c)=>{b.push(`[${c+1}] ${a.filePath}:${a.startLine}-${a.endLine}`),b.push("```"),b.push(a.codeContent),b.push("```"),a.content&&b.push(h.A.t("comments.note",{content:a.content})),b.push("")}),c)){let c=a.codeContent.split("\n").map(a=>`> ${a}`).join("\n");b.push(c),a.content&&b.push(a.content),b.push("")}return b.join("\n").trim()}function p({isOpen:a,onClose:b,cwd:c,onNavigateToComment:d}){let{t:h}=(0,g.Bd)(),[q,r]=(0,f.useState)([]),[s,t]=(0,f.useState)(!1),[u,v]=(0,f.useState)(null),[w,x]=(0,f.useState)(!1);(0,f.useCallback)(async()=>{if(!c)return;t(!0);let a=await l.t4.runPromiseExit((0,m.$)(c));"Success"===a._tag?r(a.value.comments??[]):console.error("Failed to load comments:",a.cause),t(!1)},[c]);let y=async a=>{let b=await l.t4.runPromiseExit((0,m.Tu)(c,a));"Success"===b._tag?(r(b=>b.filter(b=>b.id!==a)),(0,i.Cm)()):console.error("Failed to delete comment:",b.cause)},z=async a=>{v(a.id);try{let b="";if(a.selectedText)b=a.selectedText;else{let d=await l.t4.runPromiseExit((0,n.K9)(c,a.filePath));if("Success"!==d._tag||!d.value.ok)throw Error("Failed to read file");b=(d.value.data?.content||"").split("\n").slice(a.startLine-1,a.endLine).join("\n")}let d={filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,content:a.content,codeContent:b},e=o([d]);await navigator.clipboard.writeText(e),(0,k.oR)(h("toast.copiedComment"))}catch(a){console.error("Failed to copy comment:",a)}finally{v(null)}},A=async()=>{if(0!==q.length){x(!0);try{let a=await (0,i.$3)(c),b=o(a);await navigator.clipboard.writeText(b),(0,k.oR)(h("toast.copiedAllComments"))}catch(a){console.error("Failed to copy all comments:",a)}finally{x(!1)}}},B=q.reduce((a,b)=>(a[b.filePath]||(a[b.filePath]=[]),a[b.filePath].push(b),a),{});if(!a)return null;let C=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,e.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-xl flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:h("comments.allComments")}),q.length>0&&(0,e.jsx)("button",{onClick:A,disabled:w,className:"p-1 rounded hover:bg-accent text-muted-foreground disabled:opacity-50",title:h("comments.copyAllComments"),children:w?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:b,className:"p-1 rounded hover:bg-accent text-muted-foreground",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:s?(0,e.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:h("common.loading")}):0===q.length?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,e.jsx)("svg",{className:"w-12 h-12 mb-3 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,e.jsx)("span",{children:h("comments.noComments")})]}):(0,e.jsx)("div",{className:"space-y-4",children:Object.entries(B).map(([a,b])=>(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,e.jsxs)("div",{className:"px-3 py-2 bg-secondary border-b border-border",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground font-mono",children:a===i.Un?h("comments.aiReply"):a}),(0,e.jsxs)("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",h("comments.nComments",{count:b.length}),")"]})]}),(0,e.jsx)("div",{className:"divide-y divide-border",children:b.map(a=>{var b;return(0,e.jsx)("div",{className:"px-3 py-2 hover:bg-accent/50 cursor-pointer group",onClick:()=>d?.(a),children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.startLine>0||a.endLine>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{className:"text-xs text-brand font-mono",children:[h("common.line")," ",a.startLine===a.endLine?a.startLine:`${a.startLine}-${a.endLine}`]}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",h("comments.linesCount",{count:a.endLine-a.startLine+1}),")"]})]}):a.selectedText?(0,e.jsxs)("span",{className:"text-xs text-muted-foreground italic truncate max-w-[200px]",children:["“",a.selectedText.slice(0,50),a.selectedText.length>50?"...":"","”"]}):null,(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:(b=a.updatedAt||a.createdAt)?new Date(b).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):""})]}),(0,e.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.content||(0,e.jsx)("span",{className:"text-muted-foreground italic",children:h("comments.noContent")})})]}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),z(a)},disabled:u===a.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-accent text-muted-foreground transition-opacity disabled:opacity-50",title:h("common.copy"),children:u===a.id?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:b=>{b.stopPropagation(),y(a.id)},className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-accent text-muted-foreground hover:text-red-9 transition-opacity",title:h("common.delete"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})})]})},a.id)})})]},a))})}),(0,e.jsxs)("div",{className:"px-4 py-3 border-t border-border bg-secondary flex items-center justify-between",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:h("comments.totalComments",{count:q.length})}),(0,e.jsx)("button",{onClick:async()=>{0===q.length||await (0,i.RP)(c)&&r([])},disabled:0===q.length,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 disabled:opacity-50 disabled:cursor-not-allowed",children:h("comments.clearAll")})]})]})});return(0,e.jsx)(j.ZL,{children:C})}d()}catch(a){d(a)}})},85655:(a,b,c)=>{"use strict";c.d(b,{Bj:()=>j,CM:()=>t,FK:()=>s,Iz:()=>n,MB:()=>u,Ub:()=>p,X0:()=>o,Zi:()=>k,lv:()=>m,oh:()=>r,r4:()=>h,ue:()=>i,w2:()=>q,yy:()=>l});var d=c(79606),e=c(71192);let f=a=>d.tryPromise({try:async()=>{let b=await fetch(a);if(!b.ok){let a;try{a=(await b.json()).error}catch{}throw Error(a||`HTTP ${b.status}`)}return await b.json()},catch:b=>new e.uV({message:`fetch ${a} failed`,cause:b})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new e.uV({message:`POST ${a} failed`,cause:b})}),h=a=>f(`/api/git/branches?cwd=${encodeURIComponent(a)}`).pipe(d.flatMap(b=>"Failed to get branches"===b.error?d.fail(new e.m_({resource:"git-repo",id:a})):d.succeed(b))),i=a=>f(`/api/git/current-branch?cwd=${encodeURIComponent(a)}`),j=(a,b,c,d)=>f(`/api/git/commits?cwd=${encodeURIComponent(a)}&branch=${encodeURIComponent(b)}&limit=${c}${"number"==typeof d?`&offset=${d}`:""}`),k=(a,b,c)=>f(`/api/git/commit-diff?cwd=${encodeURIComponent(a)}&hash=${encodeURIComponent(b)}${c?`&file=${encodeURIComponent(c)}`:""}`),l=(a,b,c)=>f(`/api/git/branch-diff?cwd=${encodeURIComponent(a)}&base=${encodeURIComponent(b)}${c?`&file=${encodeURIComponent(c)}`:""}`),m=a=>f(`/api/git/status?cwd=${encodeURIComponent(a)}`),n=(a,b)=>g("/api/git/stage",{cwd:a,files:b}),o=(a,b)=>g("/api/git/unstage",{cwd:a,files:b}),p=(a,b,c)=>g("/api/git/discard",{cwd:a,files:b,isUntracked:c}),q=(a,b,c)=>{let d=new URLSearchParams({cwd:a,file:b,type:c});return f(`/api/git/diff?${d}`)},r=a=>f(`/api/git/diff?${a.toString()}`),s=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),t=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/git/worktree failed",cause:a})}),u=a=>f(`/api/projectGraph/search?${a.toString()}`)},85906:(a,b,c)=>{"use strict";c.d(b,{ProjectItem:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectItem() from the server but ProjectItem is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/ProjectItem.tsx","ProjectItem")},85984:(a,b,c)=>{"use strict";c.d(b,{V:()=>k});var d=c(67484),e=c(79606),f=c(33281),g=c(71192);let h=new Map,i=new Map;async function j(a,b,c=!1){let d=`${a}::${b}`;if(c)!function(a){if(!a){h.clear(),i.clear();return}let b=`${a}::`;for(let a of h.keys())a.startsWith(b)&&h.delete(a);for(let a of i.keys())a.startsWith(b)&&i.delete(a)}(a);else{let a=h.get(d);if(a)return a;let b=i.get(d);if(b)return b}let k=e.tryPromise({try:async()=>{let e=new URLSearchParams({cwd:a,path:b});c&&e.set("refresh","1");let f=await fetch(`/api/projectGraph/file-functions?${e}`);if(404===f.status)return"not-found";if(!f.ok)throw Error((await f.json().catch(()=>({error:`HTTP ${f.status}`}))).error||`HTTP ${f.status}`);let g=await f.json();return h.set(d,g),g},catch:a=>new g.uV({message:"fetchFileFunctions failed",cause:a})}),l=f.t4.runPromiseExit(k).then(a=>{if("Success"===a._tag)return a.value;let b="Fail"===a.cause._tag?a.cause.error:null,c=b?.cause;if(c instanceof Error)throw c;throw Error(b?.message??"fetchFileFunctions failed")}).finally(()=>i.delete(d));return i.set(d,l),l}function k(a,b){let[c,e]=(0,d.useState)({state:"idle"}),f=(0,d.useRef)(!0),g=(0,d.useCallback)((a,b,c)=>{e({state:"loading"}),j(a,b,c).then(a=>{f.current&&("not-found"===a?e({state:"notFound"}):e({state:"ready",data:a}))}).catch(a=>{f.current&&e({state:"error",message:a.message})})},[]);return{state:c,refresh:(0,d.useCallback)(()=>{a&&b&&g(a,b,!0)},[a,b,g])}}},86686:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{f:()=>h});var e=c(48249);c(67484);var f=c(44384),g=c(44256);function h({isOpen:a,onClose:b,messages:c,onSelectMessage:d}){let{t:i}=(0,f.Bd)();if(!a)return null;let j=c.filter(a=>"user"===a.role),k=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-lg max-h-[70vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:i("userMessages.title")}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===j.length?(0,e.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:i("userMessages.noMessages")}):(0,e.jsx)("div",{className:"divide-y divide-border",children:j.map((a,c)=>{let f,g,h,i=(f=a.id.match(/^user-(\d+)/))?parseInt(f[1],10):null,j=i?(g=new Date(i),h=new Date,g.toDateString()===h.toDateString()?g.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):g.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})):"";return(0,e.jsx)("button",{onClick:()=>{var c;return c=a.id,void(d(c),b())},className:"w-full px-4 py-3 text-left hover:bg-accent transition-colors",children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsxs)("span",{className:"text-xs text-muted-foreground font-mono w-6 shrink-0 pt-0.5",children:[c+1,"."]}),(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)("p",{className:"text-sm text-foreground break-words",children:function(a,b=50){let c=a.replace(/\s+/g," ").trim();return c.length<=b?c:c.slice(0,b)+"..."}(a.content)})}),j&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground shrink-0 pt-0.5",children:j})]})},a.id)})})})]})});return(0,e.jsx)(g.ZL,{children:k})}d()}catch(a){d(a)}})},87238:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$:()=>r,j:()=>s});var e=c(48249),f=c(67484),g=c(44384),h=c(24520),i=c(88282),j=c(46674),k=c(72529),l=c(9780),m=c(33281),n=c(23328),o=a([l]);function p({onAdd:a,onCancel:b}){let{t:c}=(0,g.Bd)(),[d,h]=(0,f.useState)(""),[i,j]=(0,f.useState)("");return(0,e.jsxs)("div",{className:"flex gap-1 mb-1",children:[(0,e.jsx)("input",{type:"text",value:d,onChange:a=>h(a.target.value),placeholder:c("console.namePlaceholder"),className:"w-24 flex-shrink-0 px-2 py-1 text-xs rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0,onKeyDown:a=>{"Escape"===a.key&&b()}}),(0,e.jsx)("input",{type:"text",value:i,onChange:a=>j(a.target.value),placeholder:c("console.commandPlaceholder"),className:"flex-1 min-w-0 px-2 py-1 text-xs font-mono rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring",onKeyDown:c=>{"Enter"!==c.key||c.nativeEvent.isComposing?"Escape"===c.key&&b():(c.preventDefault(),c.stopPropagation(),d.trim()&&i.trim()&&a(d.trim(),i.trim()))}})]})}function q({label:a,commands:b,isAdding:c,onStartAdd:d,onAdd:f,onCancelAdd:l,onDelete:m,onExecute:n}){let{t:o}=(0,g.Bd)();return(0,e.jsxs)("div",{className:"p-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1",children:a}),(0,e.jsx)("button",{type:"button",onClick:d,className:"p-0.5 text-muted-foreground hover:text-foreground rounded",children:(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),c&&(0,e.jsx)(p,{onAdd:(a,b)=>f(a,b),onCancel:l}),0===b.length&&!c&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:o("console.noCustomCommands")}),b.map((a,b)=>(0,e.jsx)(k.m,{content:a.command,children:(0,e.jsxs)("div",{className:"flex items-center group min-w-0",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>n(a.command),className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1.5 text-left text-sm rounded hover:bg-accent transition-colors",children:[(0,e.jsx)(i.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,e.jsx)("span",{className:"truncate",children:a.name})]}),(0,e.jsx)("button",{type:"button",onClick:()=>m(b),className:"p-1 text-muted-foreground hover:text-destructive rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:(0,e.jsx)(j.A,{className:"w-3 h-3"})})]})},b))]})}function r({cwd:a,show:b,onClose:c,onExecute:d,onAddPluginItem:h}){let{t:i}=(0,g.Bd)(),[j,k]=(0,f.useState)([]),[o,p]=(0,f.useState)([]),[s,t]=(0,f.useState)(null),u=(0,f.useRef)(null);(0,f.useCallback)(async()=>{let[b,c]=await Promise.all([m.t4.runPromiseExit((0,n.Yj)()),m.t4.runPromiseExit((0,n.UV)(a))]);if("Success"===b._tag){let a=b.value;k(a.customCommands||[])}if("Success"===c._tag){let a=c.value;p(a.customCommands||[])}},[a]);let v=(0,f.useCallback)(async a=>{k(a);let b=await m.t4.runPromiseExit((0,n.Cb)({scope:"global",customCommands:a}));"Failure"===b._tag&&console.error("Failed to save global commands:",b.cause)},[]),w=(0,f.useCallback)(async b=>{p(b);let c=await m.t4.runPromiseExit((0,n.Cb)({cwd:a,customCommands:b}));"Failure"===c._tag&&console.error("Failed to save project commands:",c.cause)},[a]),x=(0,f.useCallback)(a=>{c();let b=(0,l.sk)(a);b?h?.(b.type,a.trim()):d(a)},[c,d,h]);return b?(0,e.jsxs)("div",{ref:u,className:"absolute bottom-full left-0 mb-2 w-72 bg-popover border border-border rounded-lg shadow-lg z-50 max-h-[70vh] overflow-y-auto",children:[(0,e.jsx)(q,{label:i("console.globalCommands"),commands:j,isAdding:"global"===s,onStartAdd:()=>t("global"),onAdd:(a,b)=>{v([...j,{name:a,command:b}]),t(null)},onCancelAdd:()=>t(null),onDelete:a=>v(j.filter((b,c)=>c!==a)),onExecute:x}),(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsx)(q,{label:i("console.projectCommands"),commands:o,isAdding:"project"===s,onStartAdd:()=>t("project"),onAdd:(a,b)=>{w([...o,{name:a,command:b}]),t(null)},onCancelAdd:()=>t(null),onDelete:a=>w(o.filter((b,c)=>c!==a)),onExecute:x})]}):null}function s(a){let[b,c]=(0,f.useState)([]),[d,e]=(0,f.useState)([]),g=(0,f.useCallback)(async()=>{let[b,d]=await Promise.all([m.t4.runPromiseExit((0,n.UV)(a)),m.t4.runPromiseExit((0,n.Yj)())]);if("Success"===b._tag){let a=b.value;c(a.customCommands||[])}if("Success"===d._tag){let a=d.value;e(a.customCommands||[])}},[a]),h=[...b,...d],i=(0,f.useCallback)(a=>{let c=a.trim().split(/\s+/),e=c[0];if(!e.startsWith("/")||e.length<=1)return null;let f=e.slice(1),g=b.find(a=>a.name===f)??d.find(a=>a.name===f);return g?g.command+(c.length>1?" "+c.slice(1).join(" "):""):null},[b,d]);return{quickCustomCommands:h,projectCommands:b,globalCommands:d,expandCustomCommand:i,loadQuickCommands:g}}l=(o.then?(await o)():o)[0],d()}catch(a){d(a)}})},87808:(a,b,c)=>{"use strict";c.d(b,{DZ:()=>j,Ft:()=>n,K9:()=>q,Nn:()=>v,OJ:()=>s,VK:()=>w,YW:()=>m,__:()=>u,dt:()=>t,eA:()=>r,eE:()=>o,gZ:()=>k,mP:()=>i,nM:()=>x,r6:()=>p,r9:()=>l});var d=c(79606),e=c(71192);let f=(a,b={})=>d.tryPromise({try:async()=>{let c=await fetch(a,b.init);if(b.passThroughStatuses&&b.passThroughStatuses.includes(c.status))return await c.json().catch(()=>({}));if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:b=>new e.uV({message:`GET ${a} failed`,cause:b})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b),d=null;try{d=await c.json()}catch{}return{status:c.status,ok:c.ok,data:d}},catch:b=>new e.uV({message:`GET ${a} failed`,cause:b})}),h=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new e.uV({message:`POST ${a} failed`,cause:b})}),i=a=>f(`/api/files/init?cwd=${encodeURIComponent(a)}`),j=a=>f(`/api/files/index?cwd=${encodeURIComponent(a)}`),k=(a,b)=>f(`/api/files/readdir?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`),l=a=>f(`/api/files/recent?cwd=${encodeURIComponent(a)}`),m=(a,b,c)=>h("/api/files/recent",{cwd:a,file:b,...c??{}}),n=(a,b)=>h("/api/files/expanded",{cwd:a,paths:b}),o=(a,b)=>f(`/api/files/blame?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`).pipe(d.catchAll(a=>d.succeed({error:a.message}))),p=(a,b)=>g(`/api/files/stat?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`,{cache:"no-store"}),q=(a,b)=>g(`/api/files/text?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`,{cache:"no-store"}),r=a=>f(`/api/files/text?${a.toString()}`),s=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=null;try{c=await b.json()}catch{}return{status:b.status,ok:b.ok,data:c}},catch:a=>new e.uV({message:"POST /api/files/save failed",cause:a})}),t=()=>f("/api/files/clipboard"),u=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/clipboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"POST /api/files/clipboard failed",cause:a})}),v=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/files/paste failed",cause:a})}),w=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/files/delete failed",cause:a})}),x=a=>f(`/api/file?path=${encodeURIComponent(a)}`)},87819:(a,b,c)=>{"use strict";c.d(b,{Z:()=>e});var d=c(67484);function e(a,b){let[c,e]=(0,d.useState)({status:"loading"});return c}c(13426),c(79883),c(1239),c(79606),c(95046),c(33281)},88214:(a,b,c)=>{"use strict";c.d(b,{n:()=>e});var d=c(23734);let e={SessionChange:(0,d.R)("session-change"),ViewChange:(0,d.R)("view-change"),OpenNote:(0,d.R)("open-note"),LangChange:(0,d.R)("lang-change"),TabAdd:(0,d.R)("tab-add"),TabClose:(0,d.R)("tab-close"),SwitchSession:(0,d.R)("switch-session"),ProjectChange:(0,d.R)("project-change"),OpenProject:(0,d.R)("open-project"),SessionComplete:(0,d.R)("session-complete"),OpenTokenStats:(0,d.R)("open-token-stats"),PinnedSessionsChanged:(0,d.R)("pinned-sessions-changed"),ScheduledTasksChanged:(0,d.R)("scheduled-tasks-changed"),ScreenshotPrepare:(0,d.R)("screenshot-prepare"),ScreenshotDone:(0,d.R)("screenshot-done")}},89800:(a,b,c)=>{"use strict";c.d(b,{$:()=>i,BC:()=>j,Tu:()=>l,lb:()=>h,tj:()=>m,vv:()=>k});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:c=>new e.uV({message:`${b.method} ${a} failed`,cause:c})}),h=(a,b)=>f(`/api/comments?cwd=${encodeURIComponent(a)}${b?`&filePath=${encodeURIComponent(b)}`:""}`),i=a=>f(`/api/comments?cwd=${encodeURIComponent(a)}&all=true`),j=a=>f("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),k=(a,b,c)=>f("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,id:b,content:c})}),l=(a,b)=>g(`/api/comments?cwd=${encodeURIComponent(a)}&id=${encodeURIComponent(b)}`,{method:"DELETE"}),m=a=>g(`/api/comments?cwd=${encodeURIComponent(a)}&all=true`,{method:"DELETE"})},90018:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{O:()=>K});var e=c(48249),f=c(67484),g=c(44384),h=c(10316),i=c(46674),j=c(80600),k=c(69924);c(33281),c(85655),c(87808);var l=c(53716),m=c(85984),n=c(7031),o=c(74754),p=c(91579),q=c(83768),r=c(36984),s=c(49924),t=c(54038),u=c(37690),v=c(77396),w=c(70404),x=c(41051),y=c(42140),z=c(70596),A=a([r,v,s,t]);function B(a){let b=a.lastIndexOf("/");return b>=0?a.slice(b+1):a}function C({symbol:a,fileSource:b,hasChange:c,onHighlighted:d,comments:g,onCommentClick:h,addedLines:i}){let{resolvedTheme:j}=(0,q.D)();(0,f.useMemo)(()=>(0,r.sQ)(a.filePath),[a.filePath]);let[k,m]=(0,f.useState)(null),[n,o]=(0,f.useState)(null);return(0,e.jsxs)("div",{className:"flex-1 min-w-0 bg-card border border-border rounded overflow-hidden relative",children:[(0,e.jsxs)("div",{"data-block-header":!0,className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-border bg-secondary/40 text-xs",children:[(0,e.jsx)(l.y,{kind:a.kind,qname:a.qualifiedName,className:"w-3.5 h-3.5 flex-shrink-0"}),(0,e.jsxs)("span",{className:"font-mono truncate min-w-0",children:[(0,e.jsx)("span",{className:"font-medium",children:a.name}),void 0!==a.params&&(0,e.jsxs)("span",{className:"text-muted-foreground/80",children:["(",a.params.join(", "),")"]})]}),(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 flex-shrink-0",children:[a.kind," \xb7 L",a.startLine,"-",a.endLine]}),(0,e.jsx)("span",{className:"flex-1"}),c&&(0,e.jsx)("span",{className:"flex-shrink-0 w-2 h-2 rounded-full bg-amber-11","data-tooltip":"File has uncommitted change"})]}),(0,e.jsxs)("div",{"data-block-body":!0,className:"text-[11px] font-mono px-2 py-2 overflow-auto",style:{lineHeight:`${N}px`},children:[!b&&(0,e.jsx)("span",{className:"text-muted-foreground",children:"Loading…"}),n&&(0,e.jsx)("span",{className:"text-red-11",children:n}),k&&(0,e.jsx)("div",{dangerouslySetInnerHTML:{__html:k}})]}),g&&g.length>0&&h&&(0,e.jsx)(v._,{comments:g,startLine:a.startLine,endLine:a.endLine,lineHeight:N,bodyTopOffset:O+P,onCommentClick:h})]})}function D({side:a,pin:b,accent:c,onClick:d}){let f,g,h,i,j,k,l,m=b.lines.length;"ext"===b.kind?(f="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",g="ext",h="text-muted-foreground/60",i=b.name,j=b.packageSpec,k="external",l=b.packageSpec):"method"===b.kind?(f="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",g="method",h="text-muted-foreground/60",i=`${b.receiverName}.${b.methodName}`,j=null,k="method (unresolved)",l=m>0?`at line${m>1?"s":""} ${b.lines.join(", ")}`:""):"self"===b.kind?(f="bg-secondary/40 border-border hover:border-muted-foreground",g="self",h="text-muted-foreground/70",i=b.external.name,j=null,k="same-file",l=m>0?`at line${m>1?"s":""} ${b.lines.join(", ")}`:""):(f="in"===a?"bg-amber-9/15 border-amber-9/40 hover:border-amber-11":"bg-green-9/15 border-green-9/40 hover:border-green-11",g=a,h="in"===a?"text-amber-11":"text-green-11",i=b.external.name,j=B(b.external.filePath),k="in"===a?"caller":"callee",l=b.external.filePath);let n=c&&"ext"!==b.kind&&"method"!==b.kind?" ring-1 ring-amber-9/70 ring-offset-0":"";return(0,e.jsxs)("button",{onClick:a=>{a.stopPropagation(),d()},className:`${f}${n} w-full text-left border rounded px-1.5 py-0.5 text-[10px] font-mono cursor-pointer transition-colors flex items-center gap-1.5`,"data-tooltip":`${k}${l?" \xb7 "+l:""}`,children:[(0,e.jsx)("span",{className:`${h} text-[9px] uppercase tracking-wider font-semibold flex-shrink-0`,children:g}),(0,e.jsxs)("span",{className:"truncate flex-1 min-w-0",children:[(0,e.jsx)("span",{className:"font-medium",children:i}),j&&(0,e.jsx)("span",{className:"text-muted-foreground/70 ml-1",children:j}),m>1&&(0,e.jsxs)("span",{className:"text-muted-foreground/60 ml-1",children:["\xb7",m,"\xd7"]})]})]})}[r,v,s,t]=A.then?(await A)():A;let N=18,O=29,P=8;function E(a,b){switch(b.kind){case"cross":return`${a}:x:${b.external.filePath}::${b.external.qualifiedName}`;case"self":return`${a}:s:${b.external.filePath}::${b.external.qualifiedName}`;case"ext":return`${a}:e:${b.packageSpec}::${b.name}`;case"method":return`${a}:m:${b.receiverName}::${b.methodName}`}}function F(a,b){return"ext"!==a.kind&&"method"!==a.kind&&(b?.has(a.external.qualifiedName)??!1)}function G(a){return{filePath:a.filePath,qname:a.qualifiedName,name:a.name,kind:a.kind}}function H({symbol:a,fileSource:b,hasChange:c,upstream:d,downstream:f,onPinClick:g,onHighlighted:h,comments:i,onCommentClick:j,accentQnames:k,addedLines:l}){let m=function(a,b){if(0===a.length)return[];let c=a.map((a,c)=>{var d,e,f;return{i:c,line:(d=a.lines[0]??b.startLine,e=b.startLine,f=b.endLine,Math.max(e,Math.min(f,d)))}});c.sort((a,b)=>a.line-b.line||a.i-b.i);let d=Array(a.length).fill(0),e=-1/0;for(let{i:a,line:f}of c){let c=O+P+(f-b.startLine)*N,g=Math.max(c,e);d[a]=g,e=g+22}return d}(f,a);return(0,e.jsxs)("div",{"data-block-qname":a.qualifiedName,"data-start-line":a.startLine,"data-end-line":a.endLine,className:"flex gap-2 items-stretch scroll-mt-2",children:[(0,e.jsx)("div",{className:"w-44 flex-shrink-0 flex flex-col gap-1 pt-1",children:0===d.length?(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5",children:"no callers"}):d.map(b=>(0,e.jsx)(D,{side:"in",pin:b,accent:F(b,k),onClick:()=>g(b,a)},E("in",b)))}),(0,e.jsx)(C,{symbol:a,fileSource:b,hasChange:c,onHighlighted:h,comments:i,onCommentClick:j,addedLines:l}),(0,e.jsx)("div",{className:"w-44 flex-shrink-0 relative",children:0===f.length?(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5 pt-1",children:"no callees"}):f.map((b,c)=>(0,e.jsx)("div",{className:"absolute left-0 right-0",style:{top:`${m[c]}px`},children:(0,e.jsx)(D,{side:"out",pin:b,accent:F(b,k),onClick:()=>g(b,a)})},E("out",b)))})]})}function I({cwd:a,onSelect:b,onClose:c}){let{t:d}=(0,g.Bd)(),[j,k]=(0,f.useState)(""),[l,m]=(0,f.useState)({files:[],symbols:[]}),[n,o]=(0,f.useState)(0),[p,q]=(0,f.useState)(!1),r=(0,f.useMemo)(()=>[...l.files,...l.symbols],[l]),s=(0,f.useCallback)(a=>{if("Escape"===a.key)return void c();if(0!==r.length){if("ArrowDown"===a.key)a.preventDefault(),o(a=>Math.min(a+1,r.length-1));else if("ArrowUp"===a.key)a.preventDefault(),o(a=>Math.max(a-1,0));else if("Enter"===a.key){a.preventDefault();let c=r[n];c&&b(c)}}},[r,n,c,b]);return(0,e.jsx)("div",{className:"absolute inset-0 bg-background/40 z-20 flex items-start justify-center pt-24",onClick:c,children:(0,e.jsxs)("div",{className:"w-[480px] max-w-[80%] bg-card border border-border rounded shadow-2xl overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,e.jsx)(h.A,{className:"w-4 h-4 text-muted-foreground"}),(0,e.jsx)("input",{autoFocus:!0,value:j,onChange:a=>k(a.target.value),onKeyDown:s,placeholder:d("blockViewer.search.hint","Start typing to search"),className:"flex-1 bg-transparent border-0 outline-none text-sm"}),p&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"…"}),(0,e.jsx)("button",{onClick:c,className:"text-muted-foreground hover:text-foreground",children:(0,e.jsx)(i.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsxs)("div",{className:"max-h-96 overflow-y-auto",children:[0===r.length&&j&&!p&&(0,e.jsx)("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:d("blockViewer.search.noResults","No matches")}),(0,e.jsx)(J,{label:d("blockViewer.search.files","Files"),hits:l.files,startIdx:0,activeIdx:n,onSelect:b,setActive:o}),(0,e.jsx)(J,{label:d("blockViewer.search.symbols","Symbols"),hits:l.symbols,startIdx:l.files.length,activeIdx:n,onSelect:b,setActive:o})]})]})})}function J({label:a,hits:b,startIdx:c,activeIdx:d,onSelect:f,setActive:g}){return 0===b.length?null:(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-secondary/40",children:a}),b.map((a,b)=>{let h=c+b,i=h===d;return(0,e.jsxs)("button",{onMouseEnter:()=>g(h),onClick:()=>f(a),className:`w-full text-left px-3 py-1.5 text-xs flex items-start gap-2 ${i?"bg-secondary":"hover:bg-secondary/60"}`,children:["file"===a.target.kind?(0,e.jsx)(j.A,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-muted-foreground"}):(0,e.jsx)(l.y,{kind:a.target.symbolKind,qname:a.target.qualifiedName,className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),(0,e.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,e.jsx)("span",{className:"font-mono truncate",children:a.label}),a.hint&&(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground truncate",children:a.hint})]})]},`${a.type}:${a.label}:${b}`)})]})}function K({cwd:a,highlightedFilePath:b,changedFiles:c,onSwitchToCode:d,enableComments:h=!1,onContentSearch:i,onFocalChange:j,qnameFilter:k,qnameFilterFile:l,accentQnames:q,accentFile:r,addedLines:v,addedLinesFile:A,headerExtraLeft:C,headerExtraRight:D}){let{t:E}=(0,g.Bd)(),[F,J]=(0,f.useState)(null),N=F??b??null,{state:O,refresh:P}=(0,m.V)(a,N),[Q,R]=(0,f.useState)(null);(0,f.useRef)(null);let[S,T]=(0,f.useState)([]),[U,V]=(0,f.useState)(!1),[W,X]=(0,f.useState)(null),Y=(0,f.useRef)(0);(0,f.useRef)(0);let[Z,$]=(0,f.useState)(()=>new Set);"ready"===O.state&&O.data.filePath;let _=(0,f.useCallback)(a=>{$(b=>{if(b.has(a))return b;let c=new Set(b);return c.add(a),c})},[]),aa=(0,f.useCallback)((a,b)=>{if("ext"===a.kind||"method"===a.kind){let a=b.filePath;if(!a)return;Y.current+=1,X({filePath:a,qname:"__imports__",nonce:Y.current});return}let c=G(b),d=G(a.external);T(a=>(0,s.nb)((0,s.nb)(a,c),d)),J(d.filePath),Y.current+=1,X({filePath:d.filePath,qname:d.qname,nonce:Y.current})},[]),ab=(0,f.useCallback)(a=>{J(a.filePath),Y.current+=1,X({filePath:a.filePath,qname:a.qname,nonce:Y.current})},[]),ac=(0,f.useCallback)(a=>{V(!1),J(a.target.filePath),"symbol"===a.target.kind&&(Y.current+=1,X({filePath:a.target.filePath,qname:a.target.qualifiedName,line:a.target.line,nonce:Y.current}))},[]),ad=(0,f.useCallback)((a,b)=>{N&&(Y.current+=1,X({filePath:N,qname:a,line:b,nonce:Y.current}))},[N]),[ae,af]=(0,f.useState)(null),[ag,ah]=(0,f.useState)(null),ai=(0,f.useMemo)(()=>{if("ready"!==O.state||!ag)return null;let a=O.data.functions;if(0===a.length)return null;let b=(ag.start+ag.end)/2;for(let c of a)if(c.startLine<=b&&b<=c.endLine)return c.qualifiedName;let c=null;for(let b of a)b.startLine<=ag.start&&(!c||b.startLine>c.startLine)&&(c=b);return c?.qualifiedName??null},[O,ag]),aj=h&&!!a&&!!N,ak=(0,n.r)(),{comments:al,addComment:am,updateComment:an,deleteComment:ao,refresh:ap}=(0,o._)({cwd:a,filePath:N??""}),[aq,ar]=(0,f.useState)(null),{toolbarRef:as,bumpRef:at,clearToolbar:au}=(0,u.L)({enabled:aj,container:aq,resolveLineRange:a=>{if(!document.contains(a))return null;let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a,c=b?.closest("[data-line]");if(!c||!aq||!aq.contains(c))return null;let d=c.getAttribute("data-line");if(!d)return null;let e=parseInt(d,10);return Number.isFinite(e)?{start:e,end:e}:null},buildLineSnapshot:({start:a,end:b})=>{let c=Q?.content;return c?c.split("\n").slice(a-1,b).join("\n"):""}}),[av,aw]=(0,f.useState)(null),[ax,ay]=(0,f.useState)(null),[az,aA]=(0,f.useState)(null),aB=(0,f.useCallback)(()=>{let a=as.current;a&&(aw({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),au())},[au,as]),aC=(0,f.useCallback)(()=>{let a=as.current;a&&(ay({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),au())},[au,as]),aD=(0,f.useCallback)(()=>{let a=as.current;if(!a||!i)return;let b=a.selectedText.trim();au(),b&&i(b)},[i,au,as]),aE=(0,f.useCallback)(async a=>{av&&(await am(av.range.start,av.range.end,a,av.selectedText),aw(null))},[av,am]),aF=(0,f.useCallback)(async b=>{if(ax&&ak&&a&&N)try{let c=(await (0,p.$3)(a)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0}));c.push({filePath:N,startLine:ax.range.start,endLine:ax.range.end,codeContent:ax.lineSnapshot});let d=(0,p.Gw)(c,b);ak.sendMessage(d),await (0,p.RP)(a),ap(),ay(null)}catch(a){console.error("[BlockViewer] send to AI failed:",a)}},[ax,ak,a,N,ap]),aG=(0,f.useCallback)((a,b)=>{b.stopPropagation(),aA({comment:a,x:b.clientX,y:b.clientY}),au(),aw(null),ay(null)},[au]);if(!N)return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(M,{focalFile:null,fileCount:null,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,refreshDisabled:!0,extraLeft:C,extraRight:D}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-sm text-muted-foreground gap-2 px-4 text-center",children:[(0,e.jsx)("span",{children:E("blockViewer.empty.body","Select a file in the left tree to see its function call graph.")}),(0,e.jsx)("span",{className:"text-xs",children:E("blockViewer.empty.hint","or press ⌘K to search.")})]}),U&&(0,e.jsx)(I,{cwd:a,onSelect:ac,onClose:()=>V(!1)})]});if("idle"===O.state||"loading"===O.state)return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(M,{focalFile:N,fileCount:null,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,refreshDisabled:!0,extraLeft:C,extraRight:D}),(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:E("blockViewer.fileMode.loading","Loading…")})]});if("notFound"===O.state)return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(M,{focalFile:N,fileCount:null,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,extraLeft:C,extraRight:D}),(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground px-4 text-center",children:E("blockViewer.fileMode.notFound","This file is not indexed (unsupported language or beyond the file cap).")}),U&&(0,e.jsx)(I,{cwd:a,onSelect:ac,onClose:()=>V(!1)})]});if("error"===O.state)return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(M,{focalFile:N,fileCount:null,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,extraLeft:C,extraRight:D}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-sm",children:[(0,e.jsx)("span",{className:"text-red-11",children:O.message}),(0,e.jsx)("button",{onClick:P,className:"px-3 py-1 rounded bg-secondary hover:bg-secondary/80",children:E("blockViewer.retry","Retry")})]})]});let aH=O.data,aI=aH.functions;if(0===aI.length&&Q){let a=Math.max(1,Q.content.split("\n").length);aI=[{filePath:aH.filePath,qualifiedName:"__file__",name:B(aH.filePath),kind:"unknown",startLine:1,endLine:a}]}let aJ=l&&l===aH.filePath,aK=r&&r===aH.filePath,aL=A&&A===aH.filePath;aJ&&k&&(aI=aI.filter(a=>k.has(a.qualifiedName)));let aM=aK?q:void 0,aN=aL?v:void 0,aO=L(aH.upstreamCalls),aP=L(aH.downstreamCalls),aQ=new Map(aI.map(a=>[a.qualifiedName,a])),aR=new Map,aS=new Map;for(let a of aH.intraCalls){let b=aQ.get(a.to),c=aQ.get(a.from);if(b){let c=aR.get(a.from),d={kind:"self",external:b,lines:a.lines};c?c.push(d):aR.set(a.from,[d])}if(c){let b=aS.get(a.to),d={kind:"self",external:c,lines:a.lines};b?b.push(d):aS.set(a.to,[d])}}let aT=new Map;for(let a of aH.externalCalls??[]){let b=aT.get(a.focalQname),c={kind:"ext",name:a.external.name,packageSpec:a.external.packageSpec,lines:a.lines};b?b.push(c):aT.set(a.focalQname,[c])}let aU=new Map;for(let a of aH.methodCalls??[]){let b=aU.get(a.focalQname),c={kind:"method",receiverName:a.receiverName,methodName:a.methodName,lines:a.lines};b?b.push(c):aU.set(a.focalQname,[c])}let aV=c.has(aH.filePath);return(0,e.jsxs)("div",{className:"h-full flex flex-col relative",children:[(0,e.jsx)(M,{focalFile:N,fileCount:aH.fileCount,functionCount:aH.functions.length,upstreamCount:aH.upstreamCalls.length,downstreamCount:aH.downstreamCalls.length,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,extraLeft:C,extraRight:D}),(0,e.jsxs)("div",{ref:ar,className:"flex-1 relative min-h-0 flex",children:[(0,e.jsx)(t.g,{functions:aI,currentQname:ai,onSelect:ad,notIndexed:aH.notIndexed,onRebuild:P}),(0,e.jsx)("div",{ref:af,className:"flex-1 min-w-0 overflow-auto",children:(0,e.jsx)("div",{className:"flex flex-col gap-3 p-3",children:aI.map(a=>{let b,c,d,f,g,h;return(0,e.jsx)(H,{symbol:a,fileSource:Q?.content??null,hasChange:aV,upstream:(b=aO.get(a.qualifiedName),c=aS.get(a.qualifiedName),[...(b??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...c??[]]),downstream:(d=aP.get(a.qualifiedName),f=aR.get(a.qualifiedName),g=aU.get(a.qualifiedName),h=aT.get(a.qualifiedName),[...(d??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...f??[],...g??[],...h??[]]),onPinClick:aa,onHighlighted:_,comments:aj?al:void 0,onCommentClick:aj?aG:void 0,accentQnames:aM,addedLines:aN},a.qualifiedName)})})}),aj&&aq&&(0,e.jsx)(x.f,{floatingToolbarRef:as,bumpRef:at,container:aq,onAddComment:aB,onSendToAI:aC,onSearch:i?aD:void 0,isChatLoading:ak?.isLoading}),aj&&av&&(0,e.jsx)(y.t,{x:av.x,y:av.y,range:av.range,lineSnapshot:av.lineSnapshot,container:aq,onSubmit:aE,onClose:()=>aw(null)}),aj&&ax&&N&&(0,e.jsx)(y.G,{x:ax.x,y:ax.y,range:ax.range,filePath:N,lineSnapshot:ax.lineSnapshot,container:aq,onSubmit:aF,onClose:()=>ay(null),isChatLoading:ak?.isLoading}),aj&&az&&(0,e.jsx)(z.t,{x:az.x,y:az.y,comment:az.comment,container:aq,onClose:()=>aA(null),onUpdateComment:an,onDeleteComment:ao}),aN&&aN.size>0&&aI.length>0&&(0,e.jsx)(w.e,{addedLines:aN,blockRanges:aI.map(a=>({qname:a.qualifiedName,startLine:a.startLine,endLine:a.endLine})),viewportRange:ag,onJumpToLine:ad}),(0,e.jsx)(s.mp,{entries:S,onSelect:ab,onClear:()=>T([])}),U&&(0,e.jsx)(I,{cwd:a,onSelect:ac,onClose:()=>V(!1)})]})]})}function L(a){let b=new Map;for(let c of a){let a=b.get(c.focalQname);if(!a){b.set(c.focalQname,[c]);continue}a.some(a=>a.external.filePath===c.external.filePath&&a.external.qualifiedName===c.external.qualifiedName)||a.push(c)}return b}function M({focalFile:a,fileCount:b,functionCount:c,upstreamCount:d,downstreamCount:f,onSwitchToCode:i,onSearch:j,onRefresh:l,refreshDisabled:m,extraLeft:n,extraRight:o}){let{t:p}=(0,g.Bd)(),q={focalFile:a,blockCount:c??0,upstreamCount:d??0,downstreamCount:f??0};return(0,e.jsxs)("div",{className:"flex-shrink-0 px-3 py-2 border-b border-border flex items-center justify-between bg-secondary/30 gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0 text-xs text-muted-foreground font-mono",children:[(0,e.jsx)("span",{className:"truncate min-w-0",children:a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-foreground",children:a}),"number"==typeof c&&(0,e.jsxs)("span",{className:"ml-2",children:["\xb7 ",c," blocks"]}),"number"==typeof d&&"number"==typeof f&&(0,e.jsxs)("span",{className:"ml-2",children:["\xb7 ",d," in \xb7 ",f," out"]})]}):(0,e.jsx)("span",{children:null!==b?`${b} files`:"…"})}),n&&(0,e.jsx)("span",{className:"flex items-center gap-1 flex-shrink-0",children:n(q)})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o&&(0,e.jsx)("span",{className:"flex items-center gap-1",children:o(q)}),(0,e.jsxs)("button",{onClick:j,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground flex items-center gap-1","data-tooltip":p("blockViewer.search.tooltip","Search (⌘K)"),children:[(0,e.jsx)(h.A,{className:"w-3 h-3"})," ⌘K"]}),(0,e.jsx)("button",{onClick:l,disabled:m,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:hover:bg-transparent","data-tooltip":p("blockViewer.refresh","Rebuild project graph"),children:(0,e.jsx)(k.A,{className:"w-3 h-3"})}),i&&(0,e.jsx)("button",{onClick:i,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground",children:"Code"})]})]})}d()}catch(a){d(a)}})},90298:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{r:()=>j});var e=c(48249),f=c(67484),g=c(44256),h=c(33281),i=c(41224);let a=[{value:"deepseek-v4-flash",label:"deepseek-v4-flash"},{value:"deepseek-v4-pro",label:"deepseek-v4-pro"}];function j({currentModel:b,onModelChange:c}){let[d,k]=(0,f.useState)(!1),[l,m]=(0,f.useState)(""),[n,o]=(0,f.useState)(""),[p,q]=(0,f.useState)(!1),[r,s]=(0,f.useState)(!1),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(null),x=(0,f.useRef)(null),y=(0,f.useRef)(null),z=(0,f.useRef)(null),[A,B]=(0,f.useState)({top:0,left:0}),C=(0,g.F2)(),D=(0,f.useCallback)(async()=>{s(!0),w(null);let d=await h.t4.runPromiseExit((0,i.td)());if("Failure"===d._tag){w("Failed to load settings"),s(!1);return}let e=d.value,f=e?.engines?.deepseek?.apiKey||"";m(f),o(""),q(!1);let g=e?.engines?.deepseek?.model;!b&&g&&a.some(a=>a.value===g)&&c(g),s(!1)},[b,c]),E=(0,f.useCallback)(async a=>{let b=await h.t4.runPromiseExit((0,i.td)()),c=("Success"===b._tag?b.value:{}).engines||{},d={...c,deepseek:{...c.deepseek||{},...a}},e=await h.t4.runPromiseExit((0,i.em)({engines:d}));if("Failure"===e._tag)throw Error("Failed to save settings")},[]),F=async()=>{let a=n.trim();if(a){u(!0),w(null);try{await E({apiKey:a}),m(a),o(""),q(!1)}catch(a){w(a instanceof Error?a.message:"Save failed")}finally{u(!1)}}},G=async()=>{u(!0),w(null);try{await E({apiKey:""}),m(""),o(""),q(!1)}catch(a){w(a instanceof Error?a.message:"Clear failed")}finally{u(!1)}},H=async a=>{c(a);try{await E({model:a})}catch{}},I=!!l,J=I?b||"deepseek-v4-flash":"Set API key",K=I?"text-sky-400":"text-amber-400",L=d?(0,e.jsx)(g.ZL,{children:(0,e.jsx)("div",{ref:y,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-2 min-w-[280px]",style:{top:A.top,left:A.left},children:r?(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-3 py-1.5",children:[(0,e.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"API Key"}),I&&!p?(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:l?l.length<=8?l.replace(/./g,"•"):`${l.slice(0,3)}${"•".repeat(Math.max(4,l.length-7))}${l.slice(-4)}`:""}),(0,e.jsx)("button",{onClick:()=>{q(!0),o(""),setTimeout(()=>z.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",disabled:t,children:"Edit"}),(0,e.jsx)("button",{onClick:G,className:"text-[11px] px-2 py-1 rounded text-red-400 hover:bg-red-500/10 transition-colors",disabled:t,children:"Clear"})]}):(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("input",{ref:z,type:"password",value:n,onChange:a=>o(a.target.value),onKeyDown:a=>{"Enter"===a.key&&F()},placeholder:"sk-...",className:"flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:border-sky-500 focus:outline-none font-mono",autoFocus:!0}),(0,e.jsx)("button",{onClick:F,disabled:t||!n.trim(),className:"text-[11px] px-2 py-1 rounded bg-sky-500/20 hover:bg-sky-500/30 text-sky-300 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:t?"Saving...":"Save"}),I&&(0,e.jsx)("button",{onClick:()=>{q(!1),o("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),v&&(0,e.jsx)("div",{className:"mt-1 text-[11px] text-red-400",children:v})]}),(0,e.jsx)("div",{className:"my-1 border-t border-border"}),(0,e.jsxs)("div",{className:"px-3 py-1.5",children:[(0,e.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Model"}),(0,e.jsx)("div",{className:"flex flex-col gap-0.5",children:a.map(a=>{let c=(b||"deepseek-v4-flash")===a.value;return(0,e.jsxs)("button",{onClick:()=>H(a.value),className:`flex items-center gap-2 px-2 py-1 text-xs rounded transition-colors ${c?"bg-sky-500/15 text-sky-300":"text-foreground hover:bg-accent"}`,children:[(0,e.jsx)("span",{className:`w-3 h-3 rounded-full border-2 flex items-center justify-center ${c?"border-sky-400":"border-muted-foreground"}`,children:c&&(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-sky-400"})}),(0,e.jsx)("span",{children:a.label})]},a.value)})})]})]})})}):null;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{ref:x,onClick:()=>{if(!d){if(x.current){let a=x.current.getBoundingClientRect(),b=C?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;B({top:a.bottom+4-d,left:a.left-c})}D()}k(a=>!a)},className:"flex items-center gap-1 px-2 py-0.5 text-[11px] rounded bg-sky-500/15 hover:bg-sky-500/25 transition-colors",title:"Configure DeepSeek",children:[(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-sky-500 flex-shrink-0"}),(0,e.jsx)("span",{className:`truncate max-w-[160px] ${K}`,children:J}),(0,e.jsx)("svg",{className:"w-3 h-3 flex-shrink-0 text-sky-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),L]})}d()}catch(a){d(a)}})},90677:(a,b,c)=>{"use strict";c.a(a,async(a,b)=>{try{var d=c(48249),e=c(3560),f=c(78684),g=c(74493),h=a([f]);f=(h.then?(await h)():h)[0],(0,e.Aq)({type:"jupyter",idPrefix:"nb",match:a=>a.trim().endsWith(".ipynb"),parse(a){let b=a.trim(),c=b.split("/"),d=c[c.length-1]||b;return{filePath:b,displayName:d,cwd:""}},fromHistory:a=>({filePath:a.filePath,displayName:a.displayName||"",cwd:a.cwd||""}),toHistory:a=>({filePath:a.filePath,displayName:a.displayName,cwd:a.cwd}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l}){return(0,d.jsx)(f.o,{id:a.id,filePath:a.filePath,displayName:a.displayName,cwd:a.cwd,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l})},async onClose(a){await (0,g.Hj)(a.id)}}),b()}catch(a){b(a)}})},91579:(a,b,c)=>{"use strict";c.d(b,{$3:()=>l,Cm:()=>k,Gw:()=>o,RP:()=>m,Un:()=>n,zL:()=>j});var d=c(208),e=c(79606),f=c(33281),g=c(71192),h=c(89800);let i=new Set;function j(a){return i.add(a),()=>i.delete(a)}function k(){i.forEach(a=>a())}async function l(a){let b=await f.t4.runPromiseExit((0,h.lb)(a));if("Success"!==b._tag)throw Error("Failed to fetch comments");let c=b.value.comments??[];if(0===c.length)return[];let d=new Map;for(let a of c)a.selectedText||(d.has(a.filePath)||d.set(a.filePath,[]),d.get(a.filePath).push(a));let i=new Map;await Promise.all(Array.from(d.keys()).map(async b=>{let c=await f.t4.runPromiseExit(e.tryPromise({try:async()=>{let c=await fetch(`/api/files/text?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`);return c.ok?await c.json():null},catch:a=>new g.uV({message:`read file text ${b} failed`,cause:a})}));"Success"===c._tag&&c.value&&"string"==typeof c.value.content?i.set(b,c.value.content.split("\n")):"Failure"===c._tag&&console.error(`Failed to read file ${b}:`,c.cause)}));let j=[];for(let a of c){if(a.selectedText){j.push({...a,codeContent:a.selectedText});continue}let b=i.get(a.filePath),c="";if(b){let d=Math.max(0,a.startLine-1),e=Math.min(b.length,a.endLine);c=b.slice(d,e).join("\n")}j.push({...a,codeContent:c})}return j}async function m(a){let b=await f.t4.runPromiseExit((0,h.tj)(a));return"Success"===b._tag?(k(),!0):(console.error("Failed to clear comments:",b.cause),!1)}let n="__chat__";function o(a,b){let c=a.filter(a=>a.filePath===n),e=a.filter(a=>a.filePath!==n),f=[];for(let a of(e.length>0&&(f.push(`${d.A.t("comments.codeRef")}`,""),e.forEach((a,b)=>{f.push(`[${b+1}] ${a.filePath}:${a.startLine}-${a.endLine}`),f.push("```"),f.push(a.codeContent),f.push("```"),a.note&&f.push(d.A.t("comments.note",{content:a.note})),f.push("")})),c)){let b=a.codeContent.split("\n").map(a=>`> ${a}`).join("\n");f.push(b),a.note&&f.push(a.note),f.push("")}return f.push(d.A.t("comments.question",{question:b})),f.join("\n")}},92451:(a,b,c)=>{"use strict";c.d(b,{U:()=>g});var d=c(48249),e=c(67484),f=c(19545);function g({editor:a,query:b,position:c,onClose:h}){let[i,j]=(0,e.useState)(0),k=(0,e.useRef)(null),l=(0,f.Qe)().filter(a=>a.label.toLowerCase().includes(b.toLowerCase())||a.description.toLowerCase().includes(b.toLowerCase()));return 0===l.length?null:(0,d.jsx)("div",{ref:k,className:"slash-command-menu fixed z-[60] bg-popover border border-border rounded-lg shadow-lg py-1 w-56 max-h-64 overflow-y-auto",style:{top:c.top,left:c.left},children:l.map((c,e)=>(0,d.jsxs)("button",{className:`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors ${e===i?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>{a.chain().focus().deleteRange({from:a.state.selection.from-b.length-1,to:a.state.selection.from}).run(),c.action(a),h()},onMouseEnter:()=>j(e),children:[(0,d.jsx)("span",{className:"w-6 text-center text-xs font-mono flex-shrink-0",children:c.icon}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"font-medium",children:c.label}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:c.description})]})]},c.label))})}},92701:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(33281),j=c(38087),k=c(23700),l=a([k]);function m(a){return a?a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}k`:String(a):"0"}function n(a){if(!a)return"–";let b=Math.round(a/1e3);if(b<60)return`${b}s`;let c=Math.floor(b/60);return`${c}m${b%60}s`}k=(l.then?(await l)():l)[0];let q={done:"text-green-9",running:"text-brand",queued:"text-muted-foreground",error:"text-red-9",failed:"text-red-9"};function o({cwd:a,sessionId:b,runId:c,isRunning:d,onClose:l}){let{t:q}=(0,g.Bd)(),[r,s]=(0,f.useState)(null),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(null),x=(0,f.useRef)(void 0),y=d||null!=r&&"completed"!==r.status&&"failed"!==r.status;(0,f.useCallback)(async()=>{let d=await i.t4.runPromiseExit((0,j.z)({cwd:a,sessionId:b,workflowId:c,ifFingerprint:x.current}));if(u(!0),"Success"!==d._tag||!d.value)return;let e=d.value;e.fingerprint&&(x.current=e.fingerprint),!e.notModified&&e.workflow&&s(e.workflow)},[a,b,c]);let z=[];if(r?.agents){let a=new Map;for(let b of r.agents){let c=b.phaseTitle||q("chat.workflowUngrouped");a.has(c)||a.set(c,[]),a.get(c).push(b)}for(let[b,c]of a)z.push({title:b,agents:c})}let A=r?[r.workflowName,r.status,`${r.agentCount??r.agents?.length??0} ${q("chat.workflowAgents")}`,`${m(r.totalTokens)} tok`,n(r.durationMs)].filter(Boolean).join(" \xb7 "):"";return(0,e.jsxs)(h.ZL,{children:[(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:l,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-base",children:"\uD83E\uDDE9"}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:q("chat.workflowRun")}),A&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:A,children:A}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[y&&(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,e.jsx)("button",{onClick:l,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:q("common.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:null===r?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:q(t?"chat.workflowEmpty":"common.loading")}):(0,e.jsxs)(e.Fragment,{children:[r.summary&&(0,e.jsx)("div",{className:"mb-3 text-xs text-muted-foreground whitespace-pre-wrap",children:r.summary}),z.map(a=>(0,e.jsxs)(f.Fragment,{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-foreground/80 mt-3 mb-1 sticky top-0 bg-card py-1",children:a.title}),a.agents.map(a=>(0,e.jsx)(p,{agent:a,onOpen:()=>a.agentId&&w({runId:c,agentId:a.agentId,label:a.label,running:"done"!==a.state&&y})},`${a.index}-${a.agentId}`))]},a.title))]})})]})}),v&&(0,e.jsx)(k.f,{cwd:a,sessionId:b,workflowRef:v,onClose:()=>w(null)})]})}function p({agent:a,onOpen:b}){let{t:c}=(0,g.Bd)(),[d,h]=(0,f.useState)(!1),i=a.state&&q[a.state]||"text-muted-foreground",j=a.resultPreview||a.promptPreview||"";return(0,e.jsxs)("div",{className:"border border-border rounded-md mb-1 bg-secondary/50",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,e.jsx)("button",{onClick:()=>h(a=>!a),className:"text-slate-9 text-xs flex-shrink-0",title:c(d?"chat.collapse":"chat.expand"),children:d?"▲":"▼"}),(0,e.jsx)("span",{className:"text-xs text-foreground truncate flex-1 min-w-0",title:a.label||"",children:a.label||a.agentId}),(0,e.jsx)("span",{className:`text-[10px] flex-shrink-0 ${i}`,children:a.state}),(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[m(a.tokens)," tok \xb7 ",n(a.durationMs)]}),a.agentId&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:b,onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&b()},className:"text-xs text-brand hover:text-teal-10 cursor-pointer flex-shrink-0",title:c("chat.subagentViewTitle"),children:c("chat.workflowViewAgent")})]}),d&&j&&(0,e.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:j})]})}d()}catch(a){d(a)}})},93448:(a,b,c)=>{"use strict";c.d(b,{TabManagerTopBar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call TabManagerTopBar() from the server but TabManagerTopBar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/TabManagerTopBar.tsx","TabManagerTopBar")},94192:(a,b,c)=>{"use strict";c.d(b,{R8:()=>i,c0:()=>k,fY:()=>j,gT:()=>l});var d=c(48249),e=c(67484);let f=["agent","explorer","console"],g={agent:"AGENT",explorer:"EXPLORER",console:"CONSOLE"},h=(0,e.createContext)(null);function i(){let a=(0,e.useContext)(h);if(!a)throw Error("useSwipeContext must be used within SwipeableViewContainer");return a}function j({activeView:a,onViewChange:b,children:c}){(0,e.useRef)(null),(0,e.useRef)(!1),(0,e.useRef)(0);let[g,i]=(0,e.useState)(0),[k,l]=(0,e.useState)(!1);f.indexOf(a),f.length;let[m,n]=(0,e.useState)(!1),o={activeView:a,onViewChange:b,dragOffset:(()=>{if(!m)return 0;let a=window.innerWidth;return a?g/a:0})(),isDragging:m&&k};return(0,d.jsx)(h.Provider,{value:o,children:c})}function k({children:a}){let b,c,{activeView:g,dragOffset:h,isDragging:j}=i(),l=(0,e.useRef)(null),m=(0,e.useRef)(null),n=f.indexOf(g),o=f.length;return(0,d.jsx)("div",{ref:l,className:"flex-1 overflow-hidden relative",style:{overscrollBehaviorX:"none"},children:(0,d.jsx)("div",{ref:m,className:j?"flex":"flex transition-transform duration-100 ease-out",style:{position:"absolute",top:"0px",bottom:"0px",left:"0px",width:`${100*f.length}%`,transform:(b=h/o*100,c=-(100/o*n)+(Number.isFinite(b)?b:0),`translateX(${c}%)`)},children:a})})}function l(){let{activeView:a,onViewChange:b,dragOffset:c,isDragging:h}=i(),j=(0,e.useRef)(null),k=(0,e.useRef)([]),[l,m]=(0,e.useState)({left:0,width:0}),n=f.indexOf(a),o=Number.isFinite(c)?c:0,p=Math.round(Math.max(0,Math.min(f.length-1,n-o)));return(0,d.jsxs)("div",{ref:j,className:"relative flex gap-4",children:[f.map((a,c)=>(0,d.jsx)("button",{ref:a=>{k.current[c]=a},onClick:()=>b(a),className:`px-4 py-1 text-sm font-medium transition-colors ${p===c?"text-brand":"text-muted-foreground hover:text-foreground"}`,children:g[a]},a)),(0,d.jsx)("div",{className:`absolute bottom-0 h-0.5 bg-brand ${h?"":"transition-all duration-100 ease-out"}`,style:{left:l.left,width:l.width}})]})}},94239:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{c:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(61591),i=c(44256);function j({path:a,matchedIndices:b}){let c=(0,f.useMemo)(()=>new Set(b),[b]),d=a.lastIndexOf("/"),g=d>=0?a.slice(0,d+1):"",h=d>=0?a.slice(d+1):a,i=(a,b,d)=>{let f=[],g="",h=!1;for(let d=0;d<a.length;d++){let i=b+d,j=c.has(i);j!==h&&g&&(f.push(h?(0,e.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-${d}`):(0,e.jsx)("span",{children:g},`${b}-${d}`)),g=""),h=j,g+=a[d]}return g&&f.push(h?(0,e.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-end`):(0,e.jsx)("span",{children:g},`${b}-end`)),(0,e.jsx)("span",{className:d,children:f})};return(0,e.jsxs)("span",{className:"truncate",children:[g&&i(g,0,"text-muted-foreground"),i(h,g.length,"text-foreground")]})}function k({files:a,fileIndex:b,recentFiles:c,onSelectFile:d,onClose:l}){let{t:m}=(0,g.Bd)(),[n,o]=(0,f.useState)(""),[p,q]=(0,f.useState)(0),r=(0,f.useRef)(null),s=(0,f.useRef)(null),t=(0,f.useMemo)(()=>{let c,d;return b??(c=[],(d=a=>{for(let b of a)b.isDirectory&&b.children?d(b.children):b.isDirectory||c.push(b.path)})(a),c)},[b,a]),u=(0,f.useMemo)(()=>{if(!n.trim()){let a=new Set(c),b=c.map(a=>({path:a,score:0,matchedIndices:[]})),d=t.filter(b=>!a.has(b)).slice(0,50).map(a=>({path:a,score:0,matchedIndices:[]}));return[...b,...d]}let a=[];for(let b of t){let d=function(a,b){let c=a.toLowerCase(),d=b.toLowerCase(),e=[],f=0,g=0,h=-1;for(let i=0;i<c.length&&f<d.length;i++)if(c[i]===d[f]){e.push(i),h===i-1&&(g+=5),(0===i||"/"===a[i-1]||"."===a[i-1]||"-"===a[i-1]||"_"===a[i-1])&&(g+=10);let c=a.lastIndexOf("/");i>c&&(g+=3),a[i]===b[f]&&(g+=1),h=i,f++}return f<d.length?null:(g-=.1*a.length,{path:a,score:g,matchedIndices:e})}(b,n.trim());d&&(c.includes(b)&&(d.score+=20),a.push(d))}return a.sort((a,b)=>b.score-a.score),a.slice(0,50)},[n,t,c]),v=(0,f.useCallback)(a=>{o(a),q(0)},[]),w=(0,f.useCallback)(a=>{d(a),l()},[d,l]),x=(0,f.useCallback)(a=>{if(!a.nativeEvent.isComposing)switch(a.key){case"ArrowDown":a.preventDefault(),q(a=>Math.min(a+1,u.length-1));break;case"ArrowUp":a.preventDefault(),q(a=>Math.max(a-1,0));break;case"Enter":a.preventDefault(),u[p]&&w(u[p].path);break;case"Escape":a.preventDefault(),l()}},[u,p,w,l]);return(0,e.jsx)(i.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-start justify-center pt-[15vh]",onClick:l,children:(0,e.jsxs)("div",{className:"w-[680px] max-h-[60vh] bg-card border border-border rounded-lg shadow-2xl overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,e.jsx)("input",{ref:r,value:n,onChange:a=>v(a.target.value),onKeyDown:x,placeholder:m("quickFileOpen.placeholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",autoCorrect:"off",spellCheck:"false"}),(0,e.jsx)("kbd",{className:"text-[10px] text-muted-foreground px-1.5 py-0.5 rounded border border-border bg-secondary",children:"ESC"})]}),(0,e.jsx)("div",{ref:s,className:"flex-1 overflow-y-auto py-1",children:0===u.length?(0,e.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:m("quickFileOpen.noMatch")}):u.map((a,b)=>(0,e.jsxs)("div",{className:`px-3 py-1.5 flex items-center gap-2 cursor-pointer transition-colors ${b===p?"bg-brand/15 text-foreground":"hover:bg-accent text-foreground"}`,"data-tooltip":a.path,onClick:()=>w(a.path),children:[(0,e.jsx)(h.o,{name:a.path.split("/").pop()||"",className:"w-4 h-4 flex-shrink-0"}),(0,e.jsx)(j,{path:a.path,matchedIndices:a.matchedIndices}),!n.trim()&&c.includes(a.path)&&(0,e.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground px-1.5 py-0.5 rounded bg-secondary flex-shrink-0",children:m("quickFileOpen.recent")})]},a.path))}),(0,e.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex items-center gap-3 text-[10px] text-muted-foreground",children:[(0,e.jsxs)("span",{className:"flex items-center gap-1",children:[(0,e.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"↑↓"})," ",m("quickFileOpen.selectHint")]}),(0,e.jsxs)("span",{className:"flex items-center gap-1",children:[(0,e.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Enter"})," ",m("quickFileOpen.openHint")]}),(0,e.jsxs)("span",{className:"flex items-center gap-1",children:[(0,e.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Esc"})," ",m("quickFileOpen.closeHint")]})]})]})})})}d()}catch(a){d(a)}})},94308:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({branches:a,selectedBranch:b,onSelect:c,isLoading:h,pinnedBranches:i=[]}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),o=(0,e.useRef)(null),p=(0,e.useRef)(null),q=m.toLowerCase(),r=new Set([...a?.local||[],...a?.remote||[]]),s=i.filter(a=>r.has(a)&&a.toLowerCase().includes(q)),t=new Set(s),u=a?.local.filter(a=>!t.has(a)&&a.toLowerCase().includes(q))||[],v=a?.remote.filter(a=>!t.has(a)&&a.toLowerCase().includes(q))||[],w=a=>{c(a),l(!1),n("")};return(0,d.jsxs)("div",{className:"relative",ref:o,children:[(0,d.jsxs)("button",{onClick:()=>l(!k),disabled:h,className:"w-full px-3 py-1.5 text-sm border border-border rounded bg-card text-foreground text-left flex items-center justify-between hover:border-slate-6 dark:hover:border-slate-6 transition-colors",children:[(0,d.jsxs)("span",{className:"truncate flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),b||j("git.selectBranch"),a?.current===b&&(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["(",j("git.currentBranch"),")"]})]}),(0,d.jsx)("svg",{className:`w-4 h-4 text-slate-9 transition-transform ${k?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),k&&(0,d.jsxs)("div",{className:"absolute z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lg max-h-80 flex flex-col",children:[(0,d.jsx)("div",{className:"p-2 border-b border-border",children:(0,d.jsx)("input",{ref:p,type:"text",value:m,onChange:a=>n(a.target.value),placeholder:j("git.searchBranch"),className:"w-full px-2 py-1 text-sm border border-border rounded bg-secondary text-foreground placeholder-slate-9"})}),(0,d.jsxs)("div",{className:"overflow-y-auto flex-1",children:[s.length>0&&s.map(c=>(0,d.jsxs)("div",{onClick:()=>w(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:j("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},`pinned-${c}`)),u.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:j("git.localBranches")}),u.map(c=>(0,d.jsxs)("div",{onClick:()=>w(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:j("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},c))]}),v.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:j("git.remoteBranches")}),v.map(a=>(0,d.jsxs)("div",{onClick:()=>w(a),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${a===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:a}),a===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},a))]}),0===s.length&&0===u.length&&0===v.length&&(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:j("git.noMatchingBranches")})]})]})]})}},95388:(a,b,c)=>{"use strict";c.d(b,{V:()=>h});var d=c(48249),e=c(67484),f=c(74429),g=c(44384);function h({open:a,anchorRef:b,initialValue:c,onCancel:i,onSave:j}){let{t:k}=(0,g.Bd)(),[l,m]=(0,e.useState)(c),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(null),r=(0,e.useRef)(null),s=(0,e.useRef)(null);if((0,e.useCallback)(()=>{let a=b.current;if(!a)return;let c=a.getBoundingClientRect(),d=s.current?.offsetHeight??0,e=c.bottom+4;if(d&&e+d>window.innerHeight-8){let a=c.top-4-d;a>=8&&(e=a)}let f=c.left;q({top:e,left:f=Math.max(f=Math.min(f,window.innerWidth-260-8),8)})},[b]),!a||"u"<typeof document)return null;let t=async()=>{if(!n){o(!0);try{await j(l.trim())}finally{o(!1)}}};return(0,f.createPortal)((0,d.jsxs)("div",{ref:s,style:{top:p?.top??0,left:p?.left??0,width:260,visibility:p?"visible":"hidden"},className:"fixed z-[100] rounded-lg border border-border bg-card p-3 shadow-xl",children:[(0,d.jsx)("div",{className:"mb-2 text-sm font-medium text-foreground",children:k("shortIdBadge.dialogTitle")}),(0,d.jsx)("input",{ref:r,type:"text",value:l,onChange:a=>m(a.target.value.slice(0,64)),onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||229===a.keyCode||(a.preventDefault(),t())},placeholder:k("shortIdBadge.dialogPlaceholder"),maxLength:64,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm font-mono outline-none focus:border-brand"}),(0,d.jsxs)("div",{className:"mt-3 flex justify-end gap-2 text-sm",children:[(0,d.jsx)("button",{onClick:i,className:"rounded px-3 py-1 text-muted-foreground hover:bg-accent",disabled:n,children:k("common.cancel")}),(0,d.jsx)("button",{onClick:()=>void t(),className:"rounded bg-brand px-3 py-1 text-white hover:opacity-90 disabled:opacity-50",disabled:n,children:n?"…":k("common.save")})]})]}),document.body)}},95401:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{m:()=>j});var e=c(48249),f=c(67484),g=c(44256),h=c(33281),i=c(41224);function j({currentModel:a,onModelChange:b}){let[c,d]=(0,f.useState)(!1),[k,l]=(0,f.useState)([]),[m,n]=(0,f.useState)(!1),[o,p]=(0,f.useState)(null),[q,r]=(0,f.useState)(!1),s=(0,f.useRef)(null),t=(0,f.useRef)(null),[u,v]=(0,f.useState)({top:0,left:0}),w=(0,g.F2)(),x=(0,f.useCallback)(async()=>{n(!0),p(null);let a=await h.t4.runPromiseExit((0,i.qD)(()=>r(!0)));if(r(!1),"Failure"===a._tag)p("Connection error");else{let b=a.value;switch(b._tag){case"ok":l(b.models);break;case"not-installed":case"error":p(b.message);break;case"not-running":p("Ollama is not running")}}n(!1)},[]),y=a?a.replace(/:latest$/,""):"Select model",z=c?(0,e.jsx)(g.ZL,{children:(0,e.jsx)("div",{ref:t,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-1 min-w-[200px] max-h-[300px] overflow-y-auto",style:{top:u.top,left:u.left},children:m||q?(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),q?"Starting Ollama...":"Loading models..."]}):o?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-red-400",children:o}):0===k.length?(0,e.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models found. Run ",(0,e.jsx)("code",{className:"bg-secondary px-1 rounded",children:"ollama pull <model>"})]}):k.map(c=>{var f;return(0,e.jsxs)("button",{onClick:()=>{var a;return a=c.name,void(b(a),d(!1))},className:`w-full flex items-center justify-between gap-2 px-3 py-1.5 text-xs hover:bg-brand/10 transition-colors ${c.name===a?"text-brand":"text-foreground"}`,children:[(0,e.jsx)("span",{className:"truncate",children:c.name.replace(/:latest$/,"")}),(0,e.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:c.parameter_size||((f=c.size)<1e9?`${(f/1e6).toFixed(0)}M`:`${(f/1e9).toFixed(1)}G`)})]},c.name)})})}):null;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{ref:s,onClick:()=>{if(!c){if(s.current){let a=s.current.getBoundingClientRect(),b=w?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;v({top:a.bottom+4-d,left:a.left-c})}x()}d(a=>!a)},className:"flex items-center gap-1 px-2 py-0.5 text-[11px] rounded bg-violet-500/15 text-violet-400 hover:bg-violet-500/25 transition-colors",title:"Switch Ollama model",children:[(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-violet-500 flex-shrink-0"}),(0,e.jsx)("span",{className:"truncate max-w-[120px]",children:y}),(0,e.jsx)("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),z]})}d()}catch(a){d(a)}})},96487:()=>{},97572:(a,b,c)=>{"use strict";c.d(b,{g:()=>g,v:()=>f});var d=c(79606),e=c(71192);let f=d.tryPromise({try:async()=>{let a=await fetch("/api/projects");if(!a.ok)throw Error(`HTTP ${a.status}`);return await a.json()},catch:a=>new e.uV({message:"fetch /api/projects failed",cause:a})}),g=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/projects",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"save /api/projects failed",cause:a})})},97951:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e:()=>j});var e=c(67484),f=c(19872),g=c(208),h=c(29939),i=c(47818);function j(a,b,{sessionId:c,cwd:d,engine:k,chatMode:l,planMode:m,ollamaModel:n,deepseekModel:o,onSessionId:p,onFetchTitle:q,onPtyOutput:r}){let[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(null),C=(0,e.useRef)(null),[D,E]=(0,e.useState)(null),F=(0,e.useRef)(D);F.current=D;let G=(0,e.useRef)(!1),H=(0,e.useRef)(null),I=(0,e.useRef)(c);I.current=c;let J=(0,e.useRef)(null),K=(0,e.useRef)(null),L=(0,e.useRef)(null),M=(0,e.useRef)(!1),N=(0,e.useRef)(!1),O=(0,e.useRef)(0),P=(0,e.useCallback)(()=>{let a=J.current;if(a&&a.text){let{messageId:c,text:d}=a;b(a=>(0,f.F)(a,{type:"stream_event",event:{type:"content_block_delta",delta:{type:"text_delta",text:d}}},{engine:k,assistantId:c})),J.current={messageId:c,text:""}}K.current=null},[b,k]),Q=(0,e.useCallback)(()=>{K.current&&(clearTimeout(K.current),K.current=null),H.current&&(clearTimeout(H.current),H.current=null),P(),t(!1);let a=F.current,c=L.current;a&&b(b=>b.map(b=>b.id===a.assistantId||b.id===c?{...b,isStreaming:!1}:b)),E(null)},[P,b]),R=(0,e.useCallback)(()=>{let a=F.current;fetch("/api/chat/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:I.current,runId:a?.runKey})}).catch(()=>{}),Q()},[Q]),S=(0,e.useCallback)((a,c)=>{let e=a.type;if("pty_output"===e)return void r?.(a.data);if("pty_notice"===e){let d=a.messageKey?g.A.t(a.messageKey,a.params||{}):a.message;if(!d)return;a.terminal?b(a=>a.map(a=>a.id===c?{...a,content:d,isStreaming:!1}:a)):B(d);return}if("system"===e&&"init"===a.subtype){let c=a.session_id;if(p(c),I.current=c,z(null),M.current){let a=`auto-asst-${++O.current}`;L.current=a,b(b=>[...b,{id:a,role:"assistant",content:"",toolCalls:[],isStreaming:!0}])}N.current=!0;return}if("system"===e&&"task_notification"===a.subtype){if(!N.current){let c=a.status,d=a.summary||"",e=a.task_id,f=`<task-notification>
|
|
41
|
+
${n?"":l?"border-brand":"border-brand/30"}`,onClick:n?void 0:r,children:[(0,e.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:t,onMouseDown:u,className:`flex items-center gap-2 px-4 py-1.5 border-b border-border ${n?"bg-card":"bg-card/50"}`,style:n?{height:41}:void 0,children:[(0,e.jsx)("span",{className:"text-sm flex-shrink-0",children:"\uD83D\uDCD3"}),(0,e.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),ad,C&&(0,e.jsx)("span",{className:"text-[10px] text-amber-500 flex-shrink-0",children:"unsaved"}),(0,e.jsx)("span",{className:"flex-1"}),q&&(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:function(a){if(!a)return"";let b=new Date(a);if(isNaN(b.getTime()))return"";let c=String(b.getMonth()+1).padStart(2,"0"),d=String(b.getDate()).padStart(2,"0"),e=String(b.getHours()).padStart(2,"0"),f=String(b.getMinutes()).padStart(2,"0");return`${c}-${d} ${e}:${f}`}(q)}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),t()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:n?`Exit maximize (${(0,i.Mu)()}+M)`:`Maximize (${(0,i.Mu)()}+M)`,children:n?(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),s()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:"Close",children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 px-3 py-1 border-b border-border/50 bg-surface-secondary/50 text-[11px]",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),X()},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Run All",children:"▶ All"}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),Y()},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Interrupt",disabled:"busy"!==K,children:"⬛ Stop"}),(0,e.jsx)("div",{className:"w-px h-3 bg-border/50 mx-1"}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),ab("code",G??w.length-1)},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Add code cell",children:"+ Code"}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),ab("markdown",G??w.length-1)},className:"px-1.5 py-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",title:"Add markdown cell",children:"+ Md"}),(0,e.jsx)("div",{className:"w-px h-3 bg-border/50 mx-1"}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),T()},className:`px-1.5 py-0.5 rounded hover:bg-accent transition-colors ${C?"text-brand":"text-muted-foreground hover:text-foreground"}`,title:`Save (${(0,i.Mu)()}+S)`,disabled:E,children:E?"Saving...":"Save"}),(0,e.jsx)("span",{className:"flex-1"}),M&&(0,e.jsx)("span",{className:"text-[10px] text-red-400 truncate max-w-[50%]",title:M,children:M}),"dead"===K&&(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),U()},className:"px-1.5 py-0.5 rounded text-brand hover:bg-accent transition-colors",children:"Restart"})]}),(0,e.jsx)("div",{ref:Q,className:"overflow-y-auto",style:{height:ac-30},children:y?(0,e.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground text-sm",children:"Loading notebook..."}):A?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center h-32 gap-2",children:[(0,e.jsx)("span",{className:"text-red-400 text-sm",children:A}),(0,e.jsx)("button",{onClick:S,className:"text-xs text-brand hover:underline",children:"Retry"})]}):0===w.length?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center h-32 gap-2 text-muted-foreground text-sm",children:[(0,e.jsx)("span",{children:"Empty notebook"}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("button",{onClick:()=>ab("code"),className:"text-xs text-brand hover:underline",children:"+ Code cell"}),(0,e.jsx)("button",{onClick:()=>ab("markdown"),className:"text-xs text-brand hover:underline",children:"+ Markdown cell"})]})]}):(0,e.jsxs)("div",{className:"flex flex-col gap-1 p-2",children:[w.map((a,b)=>(0,e.jsx)(j.w,{cell:a,isActive:G===b,isEditing:I===b,onSelect:()=>H(b),onEdit:()=>{H(b),J(b)},onStopEdit:()=>J(null),onSourceChange:a=>Z(b,a),onRun:()=>{"code"===a.cell_type&&W(b),b<w.length-1&&H(b+1)},onDelete:()=>$(b),onMoveUp:()=>_(b,"up"),onMoveDown:()=>_(b,"down"),onToggleType:()=>aa(b),isFirst:0===b,isLast:b===w.length-1},`${b}-${a.cell_type}`)),(0,e.jsxs)("div",{className:"flex justify-center gap-2 py-2 opacity-0 hover:opacity-100 transition-opacity",children:[(0,e.jsx)("button",{onClick:()=>ab("code",w.length-1),className:"text-[10px] text-muted-foreground hover:text-foreground px-2 py-0.5 rounded border border-border/50 hover:border-border transition-colors",children:"+ Code"}),(0,e.jsx)("button",{onClick:()=>ab("markdown",w.length-1),className:"text-[10px] text-muted-foreground hover:text-foreground px-2 py-0.5 rounded border border-border/50 hover:border-border transition-colors",children:"+ Markdown"})]})]})})]})}[g,j]=l.then?(await l)():l,d()}catch(a){d(a)}})},80532:(a,b,c)=>{"use strict";c.d(b,{Bz:()=>j,Hy:()=>g,L5:()=>h,hp:()=>i});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=()=>f("/api/skills"),h=a=>f("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),i=a=>f(`/api/skills/${encodeURIComponent(a)}`,{method:"DELETE"}),j=a=>f(`/api/skills/content?id=${encodeURIComponent(a)}`)},80983:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>m});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(23700),j=c(92701),k=c(61349),l=a([k,i,j]);[k,i,j]=l.then?(await l)():l;let n={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D",Workflow:"\uD83E\uDDE9",Skill:"\uD83D\uDEE0️"};function m({toolCall:a,cwd:b,sessionId:c}){var d;let{t:l}=(0,g.Bd)(),[o,p]=(0,f.useState)(!1),[q,r]=(0,f.useState)(null),[s,t]=(0,f.useState)(!1),[u,v]=(0,f.useState)(!1),w=n[a.name]||"\uD83D\uDD27",x="Agent"===a.name||"Task"===a.name,y=x&&!!b&&!!c,z="Workflow"===a.name,A=z&&(d=a.result)?d.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,B=z&&!!A&&!!b&&!!c,C="Skill"===a.name,D=x||z||C,E=(()=>{let b=a.input;if("Bash"===a.name&&b.command&&"string"==typeof b.command)return b.command;if(x&&b.description&&"string"==typeof b.description)return b.description;if(z){let a="string"==typeof b.name?b.name:"",c="string"==typeof b.args?b.args:"string"==typeof b.resumeFromRunId?b.resumeFromRunId:"",d=[a,c].filter(Boolean).join(" \xb7 ");if(d)return d}if(C&&"string"==typeof b.skill){let a="string"==typeof b.args?b.args:"";return[b.skill,a].filter(Boolean).join(" \xb7 ")}return"Glob"===a.name&&b.pattern&&"string"==typeof b.pattern||"Grep"===a.name&&b.pattern&&"string"==typeof b.pattern?b.pattern:"ToolSearch"===a.name&&b.query&&"string"==typeof b.query?b.query:"TaskCreate"===a.name&&b.subject&&"string"==typeof b.subject?b.subject:b.file_path&&"string"==typeof b.file_path?b.file_path:b.path&&"string"==typeof b.path?b.path:null})(),F="Glob"===a.name||"Grep"===a.name||"Bash"===a.name||x||z||C,G=E?F?E:(a=>{if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}let c=a.split("/");return c.length>2?".../"+c.slice(-2).join("/"):a})(E):null,H=b=>{let c="input"===b?l("toolCall.inputParams"):l("toolCall.resultLabel"),d="input"===b?JSON.stringify(a.input,null,2):"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2);r({title:`${a.name}${G?` ${G}`:""} - ${c}`,content:d,toolName:a.name})};return(0,e.jsxs)("div",{className:"my-1 border border-border rounded-lg overflow-hidden bg-secondary",children:[(0,e.jsxs)("button",{onClick:()=>p(!o),className:"w-full px-3 py-1.5 flex items-center gap-2 text-left hover:bg-accent transition-colors",children:[(0,e.jsx)("span",{className:"text-sm",children:w}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:a.name}),G&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:E||"",children:G}),!D&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),E&&(navigator.clipboard.writeText(E),(0,h.oR)(l("common.copiedPath")))},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),E&&(navigator.clipboard.writeText(E),(0,h.oR)(l("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0 cursor-pointer",title:l("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[y&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),t(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),t(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:l("chat.subagentViewTitle"),children:l("chat.subagent")}),B&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),v(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),v(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:l("chat.workflowViewTitle"),children:l("chat.workflowRun")}),o&&!a.isLoading&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),H("input")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),H("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:l("toolCall.inputParamsTitle"),children:l("toolCall.input")}),a.result&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),H("result")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),H("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:l("toolCall.resultTitle"),children:l("toolCall.result")})]}),a.isLoading?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("span",{className:"text-slate-9 text-xs",children:o?"▲":"▼"})]})]}),o&&(0,e.jsxs)("div",{className:"border-t border-border",children:[(0,e.jsxs)("div",{className:"px-3 py-2",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[l("toolCall.inputParams"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(a.input,null,2)})]}),a.result&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-border",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[l("toolCall.resultLabel"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2)})]}),a.skillContent&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-border",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[l("toolCall.skillContent",{defaultValue:"Skill content"}),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-secondary p-2 rounded overflow-x-auto max-h-60 overflow-y-auto text-foreground whitespace-pre-wrap",children:a.skillContent})]})]}),q&&(0,e.jsx)(k.M,{title:q.title,content:q.content,toolName:q.toolName,onClose:()=>r(null)}),s&&b&&c&&(0,e.jsx)(i.f,{cwd:b,sessionId:c,toolCall:a,onClose:()=>t(!1)}),u&&b&&c&&A&&(0,e.jsx)(j.K,{cwd:b,sessionId:c,runId:A,isRunning:!!a.isLoading,onClose:()=>v(!1)})]})}d()}catch(a){d(a)}})},81064:(a,b,c)=>{Promise.resolve().then(c.bind(c,81227))},81227:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx","default")},82795:(a,b,c)=>{"use strict";c.d(b,{e:()=>i});var d=c(48249),e=c(67484),f=c(44384),g=c(33281),h=c(41224);function i({isOpen:a,onClose:b,onSwitchProject:c}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)([]),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(""),s=(0,e.useRef)(null);(0,e.useCallback)(async()=>{n(!0),p(null);let a=await g.t4.runPromiseExit((0,h.z2)());"Success"===a._tag?l([...a.value]):p(j("sessions.loadSessionsFailed")),n(!1)},[j]);let t=k.filter(a=>{if(!q)return!0;let b=q.toLowerCase();return void 0!==a.searchText?a.searchText.includes(b):a.cwd.toLowerCase().includes(b)||(a.title?.toLowerCase().includes(b)??!1)||(a.lastUserMessage?.toLowerCase().includes(b)??!1)||(a.firstMessages?.some(a=>a.toLowerCase().includes(b))??!1)||(a.lastMessages?.some(a=>a.toLowerCase().includes(b))??!1)});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:b}),(0,d.jsxs)("div",{className:"relative w-full max-w-7xl h-[90vh] mx-4 bg-card rounded-lg shadow-xl flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsx)("div",{className:"flex-1 min-w-0",children:(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:j("sessions.recentSessions")})}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsx)("input",{ref:s,type:"text",placeholder:j("sessions.searchSessions"),value:q,onChange:a=>r(a.target.value),className:"px-2 py-1 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[m&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:j("sessions.loadingSessions")})]})}),o&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:o})}),!m&&!o&&0===t.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:q?j("sessions.noMatchingSessions"):j("sessions.noSessions")})}),!m&&!o&&t.length>0&&(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:t.map(a=>{let e;return(0,d.jsxs)("div",{onClick:()=>{c(a.cwd,a.sessionId),b()},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,d.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${"loading"===a.status?"bg-orange-9 animate-pulse":"unread"===a.status?"bg-red-500":"bg-muted-foreground/30"}`}),a.engine&&"claude"!==a.engine&&(0,d.jsx)("span",{className:`shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded ${"claude2"===a.engine?"bg-orange-500/15 text-orange-11":"ollama"===a.engine?"bg-blue-500/15 text-blue-11":"codex"===a.engine?"bg-green-500/15 text-green-11":"kimi"===a.engine?"bg-purple-500/15 text-purple-11":"bg-muted text-muted-foreground"}`,children:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate flex-1",title:a.cwd,children:(e=a.cwd).split("/").pop()||e}),"loading"===a.status&&(0,d.jsx)("span",{className:"text-[10px] text-orange-11 flex-shrink-0",children:j("sessions.running")}),"unread"===a.status&&(0,d.jsx)("span",{className:"text-[10px] text-red-500 flex-shrink-0",children:j("sessions.done")})]}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(a.lastActive).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(a.firstMessages?.length??0)>0||(a.lastMessages?.length??0)>0?(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[a.firstMessages?.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`first-${b}`)),(a.lastMessages?.length??0)>0&&(0,d.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),a.lastMessages?.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate",title:a,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`last-${b}`))]}):a.lastUserMessage||a.title?(0,d.jsxs)("div",{className:"text-xs text-foreground truncate",title:a.lastUserMessage||a.title,children:[(0,d.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a.lastUserMessage||a.title]}):null]},`${a.cwd}-${a.sessionId}`)})})]})]})]}):null}},83003:(a,b,c)=>{"use strict";c.d(b,{k:()=>i});var d=c(48249),e=c(67484),f=c(44384),g=c(44256);function h({image:a,onClose:b}){let{t:c}=(0,f.Bd)(),e=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:b,children:(0,d.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,d.jsx)("img",{src:a.preview,alt:c("imagePreview.previewImage"),className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:a=>a.stopPropagation()}),(0,d.jsx)("button",{onClick:b,className:"absolute -top-3 -right-3 w-8 h-8 bg-card text-foreground hover:text-foreground rounded-full shadow-lg flex items-center justify-center transition-colors",title:c("common.close"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})});return(0,d.jsx)(g.ZL,{children:e})}function i({images:a,onRemove:b,disabled:c}){let{t:g}=(0,f.Bd)(),[j,k]=(0,e.useState)(null);return 0===a.length?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"flex flex-wrap gap-2 p-2 bg-secondary border-b border-border",children:a.map(a=>(0,d.jsxs)("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-border cursor-pointer",onClick:()=>k(a),children:[(0,d.jsx)("img",{src:a.preview,alt:g("imagePreview.previewImage"),className:"w-full h-full object-cover hover:opacity-90 transition-opacity"}),(0,d.jsx)("button",{onClick:c=>{c.stopPropagation(),b(a.id)},className:"absolute top-0 right-0 w-5 h-5 bg-black/60 hover:bg-black/80 text-white text-xs flex items-center justify-center rounded-bl-lg opacity-0 group-hover:opacity-100 transition-opacity",title:g("imagePreview.deleteImage"),children:"✕"})]},a.id))}),j&&(0,d.jsx)(h,{image:j,onClose:()=>k(null)})]})}},83022:(a,b,c)=>{"use strict";c.d(b,{TabBar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call TabBar() from the server but TabBar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/TabBar.tsx","TabBar")},83120:(a,b,c)=>{"use strict";c.d(b,{BL:()=>q,Gm:()=>n,JK:()=>l,Wr:()=>o,Y8:()=>t,Y_:()=>k,_c:()=>r,bx:()=>m,dU:()=>s,i7:()=>x,jw:()=>u,mu:()=>v,vy:()=>w,z1:()=>p});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=(a,b)=>f(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>f(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),j=a=>f(a,{method:"DELETE"}),k=()=>f("/api/review"),l=a=>{let b;return b=`/api/review/${encodeURIComponent(a)}`,d.tryPromise({try:async()=>{let a=await fetch(b);if(404===a.status)throw Object.assign(Error("not found"),{__404__:!0});if(!a.ok)throw Error(`HTTP ${a.status}`);return await a.json()},catch:a=>a?.__404__?new e.m_({resource:"review",id:b}):new e.uV({message:`GET ${b} failed`,cause:a})})},m=a=>g("/api/review",a),n=(a,b)=>i(`/api/review/${encodeURIComponent(a)}`,b),o=a=>j(`/api/review/${encodeURIComponent(a)}`),p=a=>i("/api/review/order",{order:a}),q=()=>f("/api/review/users"),r=()=>f("/api/review/share-info"),s=(a,b)=>g(`/api/review/${encodeURIComponent(a)}/comments`,b),t=(a,b)=>h(`/api/review/${encodeURIComponent(a)}/comments`,b),u=(a,b)=>j(`/api/review/${encodeURIComponent(a)}/comments?commentId=${encodeURIComponent(b)}`),v=(a,b)=>g(`/api/review/${encodeURIComponent(a)}/replies`,b),w=(a,b)=>h(`/api/review/${encodeURIComponent(a)}/replies`,b),x=(a,b,c)=>j(`/api/review/${encodeURIComponent(a)}/replies?commentId=${encodeURIComponent(b)}&replyId=${encodeURIComponent(c)}`)},83179:(a,b,c)=>{"use strict";c.d(b,{NoteToolbar:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({editor:a,onClose:b,position:c}){let{t:h}=(0,f.Bd)(),[i,j]=(0,e.useState)(()=>a.getAttributes("link").href||""),k=(0,e.useRef)(null),l=()=>{let c=i.trim();if(c){let b=c.match(/^https?:\/\//)?c:`https://${c}`;a.chain().focus().extendMarkRange("link").setLink({href:b}).run()}else a.chain().focus().extendMarkRange("link").unsetLink().run();b()},m=c?{top:c.top,left:c.left}:{};return(0,d.jsxs)("div",{className:`${c?"fixed":"absolute top-full left-0 mt-1"} z-[60] bg-popover border border-border rounded-lg shadow-lg p-2 flex items-center gap-2`,style:m,children:[(0,d.jsx)("input",{ref:k,type:"text",value:i,onChange:a=>j(a.target.value),onKeyDown:a=>{"Enter"===a.key?(a.preventDefault(),l()):"Escape"===a.key&&(a.preventDefault(),b())},placeholder:h("editor.linkPlaceholder"),className:"bg-background border border-border rounded px-2 py-1 text-sm w-64 outline-none focus:border-brand"}),(0,d.jsx)("button",{onClick:l,className:"p-1 rounded text-sm font-medium text-brand hover:bg-brand/10 transition-colors",title:h("editor.confirmLink"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})})}),a.isActive("link")&&(0,d.jsx)("button",{onClick:()=>{a.chain().focus().extendMarkRange("link").unsetLink().run(),b()},className:"p-1 rounded text-sm font-medium text-red-500 hover:bg-red-500/10 transition-colors",title:h("editor.removeLink"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})}function h({editor:a}){let{t:b}=(0,f.Bd)(),[c,i]=(0,e.useState)(!1),j=(0,e.useRef)(null),[,k]=(0,e.useState)(0);if(!a)return null;let l=a=>`p-1.5 rounded text-xs font-medium transition-colors ${a?"bg-brand/15 text-brand":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,m="w-px h-5 bg-border mx-0.5",n=a.isActive("table");return(0,d.jsxs)("div",{className:"flex items-center gap-0.5 px-4 py-1.5 border-b border-border flex-shrink-0 flex-wrap",children:[(0,d.jsx)("button",{className:l(a.isActive("heading",{level:1})),onClick:()=>a.chain().focus().toggleHeading({level:1}).run(),title:b("editor.heading1"),children:"H1"}),(0,d.jsx)("button",{className:l(a.isActive("heading",{level:2})),onClick:()=>a.chain().focus().toggleHeading({level:2}).run(),title:b("editor.heading2"),children:"H2"}),(0,d.jsx)("button",{className:l(a.isActive("heading",{level:3})),onClick:()=>a.chain().focus().toggleHeading({level:3}).run(),title:b("editor.heading3"),children:"H3"}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(a.isActive("bold")),onClick:()=>a.chain().focus().toggleBold().run(),title:b("editor.bold"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"})})}),(0,d.jsx)("button",{className:l(a.isActive("italic")),onClick:()=>a.chain().focus().toggleItalic().run(),title:b("editor.italic"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"})})}),(0,d.jsx)("button",{className:l(a.isActive("strike")),onClick:()=>a.chain().focus().toggleStrike().run(),title:b("editor.strikethrough"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"})})}),(0,d.jsx)("button",{className:l(a.isActive("code")),onClick:()=>a.chain().focus().toggleCode().run(),title:b("editor.inlineCode"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"})})}),(0,d.jsx)("div",{className:m}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{ref:j,className:l(a.isActive("link")),onClick:()=>i(!c),title:b("editor.link"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})})}),c&&(0,d.jsx)(g,{editor:a,onClose:()=>i(!1),position:null})]}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(a.isActive("bulletList")),onClick:()=>a.chain().focus().toggleBulletList().run(),title:b("editor.bulletList"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"})})}),(0,d.jsx)("button",{className:l(a.isActive("orderedList")),onClick:()=>a.chain().focus().toggleOrderedList().run(),title:b("editor.orderedList"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"})})}),(0,d.jsx)("button",{className:l(a.isActive("taskList")),onClick:()=>a.chain().focus().toggleTaskList().run(),title:b("editor.taskList"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM17.99 9l-1.41-1.42-6.59 6.59-2.58-2.57-1.42 1.41 4 3.99z"})})}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(a.isActive("blockquote")),onClick:()=>a.chain().focus().toggleBlockquote().run(),title:b("editor.blockquote"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})}),(0,d.jsx)("button",{className:l(a.isActive("codeBlock")),onClick:()=>a.chain().focus().toggleCodeBlock().run(),title:b("editor.codeBlock"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H4V5h16v14zm-7.5-4.5L15 12l-2.5-2.5L11 11l1.5 1.5L11 14l1.5 1.5zM9.5 14.5L7 12l2.5-2.5L11 11 9.5 12.5 11 14l-1.5.5z"})})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:b("editor.table"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-9 15H4v-4h7v4zm0-6H4V7h7v4zm9 6h-7v-4h7v4zm0-6h-7V7h7v4z"})})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().setHorizontalRule().run(),title:b("editor.horizontalRule"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M4 11h16v2H4z"})})}),n&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addRowBefore().run(),title:b("editor.insertRowAbove"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zM11 17H4v-2h7v2zm0-4H4v-2h7v2zm9 4h-7v-2h7v2zm0-4h-7v-2h7v2z"}),(0,d.jsx)("path",{d:"M14 1h-4v2H8v2h2v2h4V5h2V3h-2z",opacity:".6"})]})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addRowAfter().run(),title:b("editor.insertRowBelow"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v10h20V6c0-1.1-.9-2-2-2zM11 12H4v-2h7v2zm0-4H4V6h7v2zm9 4h-7v-2h7v2zm0-4h-7V6h7v2z"}),(0,d.jsx)("path",{d:"M14 19h-4v2H8v2h2v-2h4v2h2v-2h-2z",opacity:".6"})]})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addColumnBefore().run(),title:b("editor.insertColumnLeft"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 11H10v-2h7v2zm0-4H10V9h7v2z"}),(0,d.jsx)("path",{d:"M1 14v-4h2V8h2v2h-2v4h2v2H3v-2z",opacity:".6"})]})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addColumnAfter().run(),title:b("editor.insertColumnRight"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M4 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h10V4H4zm7 11H4v-2h7v2zm0-4H4V9h7v2z"}),(0,d.jsx)("path",{d:"M18 4v20h2c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-2z"}),(0,d.jsx)("path",{d:"M21 14v-4h2V8h2v2h-2v4h2v2h-2v-2z",opacity:".6"})]})}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-500 hover:bg-orange-500/10",onClick:()=>a.chain().focus().deleteRow().run(),title:b("editor.deleteRow"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zm-8 8H4v-2h8v2z"}),(0,d.jsx)("path",{d:"M15 13l-1.41 1.41L15.17 16l-1.58 1.59L15 19l1.59-1.59L18.17 19l1.42-1.41L18 16l1.59-1.59L18.17 13 16.59 14.41z",fill:"currentColor"})]})}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-500 hover:bg-orange-500/10",onClick:()=>a.chain().focus().deleteColumn().run(),title:b("editor.deleteColumn"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 7H10V9h7v2z"}),(0,d.jsx)("path",{d:"M13 16l-1.41 1.41L13.17 19l-1.58 1.59L13 22l1.59-1.59L16.17 22l1.42-1.41L16 19l1.59-1.59L16.17 16l-1.58 1.41z",fill:"currentColor"})]})}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-500 hover:bg-red-500/10",onClick:()=>a.chain().focus().deleteTable().run(),title:b("editor.deleteTable"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]}),a.isActive("codeBlock")&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-500 hover:bg-red-500/10",onClick:()=>a.chain().focus().toggleCodeBlock().run(),title:b("editor.deleteCodeBlock"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})]})}},83377:(a,b,c)=>{"use strict";c.d(b,{A:()=>e});var d=c(67484);function e({lines:a,enabled:b,onContentChange:c,onEnterInsert:f,onSave:g,getVisibleLineCount:h,scrollToLine:i,onSearchExecute:j,onSearchNext:k,onSearchPrev:l,onSearchClear:m}){let[n,o]=(0,d.useState)("normal"),[p,q]=(0,d.useState)(-1),[r,s]=(0,d.useState)(0),[t,u]=(0,d.useState)(!1),[v,w]=(0,d.useState)(""),[x,y]=(0,d.useState)(""),[z,A]=(0,d.useState)(""),[B,C]=(0,d.useState)(""),D=(0,d.useRef)([]),E=(0,d.useRef)([]),F=(0,d.useRef)([]),G=(0,d.useRef)(null),H=(0,d.useRef)(a),I=(0,d.useCallback)((a,b)=>Math.max(0,Math.min(b,Math.max(0,(H.current[a]??"").length-1))),[]);(0,d.useRef)(a.length);let J=(0,d.useCallback)(()=>{G.current&&(clearTimeout(G.current),G.current=null),w("")},[]),K=(0,d.useCallback)(()=>{G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{w(""),G.current=null},500)},[]),L=(0,d.useCallback)((a,b)=>{D.current.push(b),E.current=[],u(!0),c(a.join("\n"))},[c]),M=(0,d.useCallback)((a,b)=>{let c=Math.max(0,Math.min(a,H.current.length-1));q(c),s(I(c,b??0)),i(c,"auto")},[i,I]),N=(0,d.useCallback)(a=>{q(b=>{let c=Math.max(0,Math.min(b+a,H.current.length-1));return i(c,"auto"),s(a=>Math.max(0,Math.min(a,Math.max(0,(H.current[c]??"").length-1)))),c})},[i]),O=(0,d.useCallback)(()=>{let a=H.current,b=Math.min(p,a.length-1);if(0===a.length)return;let c=a[b];F.current=[c];let d=[...a];d.splice(b,1),0===d.length&&d.push("");let e=Math.min(b,d.length-1);L(d,{lineIndex:b,oldLines:[c],newLines:[],cursorLine:b}),q(e),s(0)},[p,L]),P=(0,d.useCallback)(()=>{let a=H.current,b=Math.min(p,a.length-1);a.length>0&&(F.current=[a[b]])},[p]),Q=(0,d.useCallback)(()=>{let a=F.current;if(0===a.length)return;let b=H.current,c=Math.min(p,b.length-1)+1,d=[...b];d.splice(c,0,...a),L(d,{lineIndex:c,oldLines:[],newLines:[...a],cursorLine:p}),q(c),s(0),i(c,"auto")},[p,L,i]),R=(0,d.useCallback)(()=>{let a=H.current,b=Math.min(p,a.length-1),c=a[b];if(!c||0===c.length)return;let d=c.substring(1),e=[...a];e[b]=d,L(e,{lineIndex:b,oldLines:[c],newLines:[d],cursorLine:p})},[p,L]),S=(0,d.useCallback)(()=>{let a=D.current;if(0===a.length)return;let b=a.pop(),d=[...H.current];0===b.newLines.length&&b.oldLines.length>0?d.splice(b.lineIndex,0,...b.oldLines):0===b.oldLines.length&&b.newLines.length>0?(d.splice(b.lineIndex,b.newLines.length),0===d.length&&d.push("")):d.splice(b.lineIndex,b.newLines.length,...b.oldLines),E.current.push(b),c(d.join("\n")),q(Math.min(b.cursorLine,d.length-1)),i(Math.min(b.cursorLine,d.length-1),"auto"),0===a.length&&u(!1)},[c,i]),T=(0,d.useCallback)(()=>{let a=E.current;if(0===a.length)return;let b=a.pop(),d=[...H.current];0===b.newLines.length&&b.oldLines.length>0?(d.splice(b.lineIndex,b.oldLines.length),0===d.length&&d.push("")):0===b.oldLines.length&&b.newLines.length>0?d.splice(b.lineIndex,0,...b.newLines):d.splice(b.lineIndex,b.oldLines.length,...b.newLines),D.current.push(b),u(!0),c(d.join("\n"));let e=b.lineIndex+Math.max(0,b.newLines.length-1);q(Math.min(e,d.length-1)),i(Math.min(e,d.length-1),"auto")},[c,i]),U=(0,d.useCallback)(a=>{let b=H.current,c=Math.min(p,b.length-1);if("o"===a||"O"===a){let d="o"===a?c+1:c,e=[...b];e.splice(d,0,""),L(e,{lineIndex:d,oldLines:[],newLines:[""],cursorLine:p}),c=d,q(d)}o("insert"),f(c,r,a)},[p,r,L,f]),V=(0,d.useCallback)(()=>{o("normal"),J()},[J]),W=(0,d.useCallback)(()=>{o("command"),y("")},[]),X=(0,d.useCallback)(()=>{o("normal"),y("")},[]),Y=(0,d.useCallback)(()=>{o("search"),A("")},[]),Z=(0,d.useCallback)(()=>{o("normal"),A("")},[]),$=(0,d.useCallback)(a=>{let b=a.trim();if("w"===b){g?.(),o("normal"),y("");return}if("q"===b){o("normal"),y("");return}if("wq"===b){g?.(),o("normal"),y("");return}if("noh"===b||"nohlsearch"===b){m?.(),o("normal"),y("");return}let c=parseInt(b,10);if(!isNaN(c)&&c>0){let a=Math.min(c-1,H.current.length-1);q(a),i(a,"center"),o("normal"),y("");return}o("normal"),y("")},[g,m,i]),_=(0,d.useCallback)(a=>{if(!a){o("normal"),A("");return}C(a),j?.(a),o("normal"),A("")},[j]),aa=(0,d.useCallback)(a=>{if(!b)return!1;let c=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;if("insert"===n)return("Escape"===a.key||!!c)&&(V(),!0);if("command"===n)return!a.isComposing&&("Escape"===a.key||c?X():"Enter"===a.key?$(x):"Backspace"===a.key?0===x.length?X():y(a=>a.slice(0,-1)):1!==a.key.length||a.metaKey||a.ctrlKey||y(b=>b+a.key),!0);if("search"===n)return!a.isComposing&&("Escape"===a.key||c?Z():"Enter"===a.key?_(z):"Backspace"===a.key?0===z.length?Z():A(a=>a.slice(0,-1)):1!==a.key.length||a.metaKey||a.ctrlKey||A(b=>b+a.key),!0);if(p<0&&(q(0),s(0)),a.metaKey)return!1;if(a.ctrlKey)return"d"===a.key?(N(Math.max(1,Math.floor(h()/2))),J(),!0):"u"===a.key?(N(-Math.max(1,Math.floor(h()/2))),J(),!0):"r"===a.key&&(T(),J(),!0);let d=a.key,e=v+d;if("g"===e)return w("g"),K(),!0;if("gg"===e)return M(0),J(),!0;if("d"===e)return w("d"),K(),!0;if("dd"===e)return O(),J(),!0;if("y"===e)return w("y"),K(),!0;if("yy"===e)return P(),J(),!0;if(v&&e!==d&&J(),"j"===d||"ArrowDown"===d)return N(1),!0;if("k"===d||"ArrowUp"===d)return N(-1),!0;if("h"===d||"ArrowLeft"===d)return s(a=>Math.max(0,a-1)),!0;if("l"===d||"ArrowRight"===d){let a=Math.max(0,(H.current[p]??"").length-1);return s(b=>Math.min(a,b+1)),!0}if("0"===d)return s(0),!0;if("$"===d)return s(Math.max(0,(H.current[p]??"").length-1)),!0;if("^"===d){let a=(H.current[p]??"").search(/\S/);return s(a>=0?a:0),!0}return"G"===d?(M(H.current.length-1),!0):"x"===d?(R(),!0):"p"===d?(Q(),!0):"u"===d?(S(),!0):"i"===d||"a"===d||"I"===d||"A"===d||"o"===d||"O"===d?(U(d),!0):"/"===d?(Y(),!0):"n"===d?(k?.(),!0):"N"===d?(l?.(),!0):":"===d?(W(),!0):"Escape"!==d&&1===d.length},[b,n,v,x,z,p,V,U,W,X,Y,Z,$,_,N,M,h,O,P,Q,R,S,T,J,K,k,l]);return{state:{mode:n,cursorLine:p,cursorCol:r,isDirty:t,keyBuffer:v,commandInput:x,searchInput:z,lastSearch:B},handleKeyDown:aa,enterNormal:V,enterInsert:U,setCursorLine:q,setCursorCol:s,setCommandInput:y,setSearchInput:A,setIsDirty:u,clearUndoHistory:(0,d.useCallback)(()=>{D.current=[],E.current=[]},[])}}},83768:(a,b,c)=>{"use strict";c.d(b,{D:()=>g,N:()=>h});var d=c(48249),e=c(67484);let f=(0,e.createContext)(null);function g(){let a=(0,e.useContext)(f);if(!a)throw Error("useTheme must be used within a ThemeProvider");return a}function h({children:a}){let[b,c]=(0,e.useState)("system"),[g,i]=(0,e.useState)("light"),j=(0,e.useCallback)(()=>"light",[]),k=(0,e.useCallback)(a=>{let b=document.documentElement;b.classList.remove("light","dark"),b.classList.add(a),i(a);let c=document.querySelector('meta[name="theme-color"]'),d="dark"===a?"#111113":"#f9f9fb";c&&c.setAttribute("content",d)},[]),l=(0,e.useCallback)(a=>{c(a),localStorage.setItem("theme",a),k("system"===a?j():a),document.querySelectorAll("iframe").forEach(b=>{b.contentWindow?.postMessage({type:"THEME_CHANGE",theme:a},"*")})},[j,k]);return(0,d.jsx)(f.Provider,{value:{theme:b,resolvedTheme:g,setTheme:l},children:a})}},84398:(a,b,c)=>{"use strict";function d(a){let b=a.split("/").pop()?.toLowerCase()??"";switch(b.includes(".")?b.split(".").pop():""){case"ts":return"typescript";case"tsx":case"jsx":return"tsx";case"js":case"mjs":case"cjs":return"javascript";case"py":case"pyi":return"python";case"go":return"go";case"rs":return"rust";default:return null}}c.d(b,{k:()=>d})},84747:(a,b,c)=>{"use strict";c.d(b,{Workspace:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call Workspace() from the server but Workspace is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/Workspace.tsx","Workspace")},84835:(a,b,c)=>{"use strict";c.d(b,{W:()=>f});var d=c(50300);let e=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","table","tr","hr","div","ul","ol"]);function f(){return a=>{(0,d.YR)(a,"element",a=>{if(e.has(a.tagName)&&a.position&&(a.properties||(a.properties={}),a.properties["data-source-start"]=a.position.start.line,a.properties["data-source-end"]=a.position.end.line,"pre"===a.tagName)){let b=a.children?.find(a=>"element"===a.type&&"code"===a.tagName);b&&(b.properties||(b.properties={}),b.properties["data-source-start"]=a.position.start.line,b.properties["data-source-end"]=a.position.end.line)}})}}},84844:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{i:()=>p});var e=c(48249),f=c(67484),g=c(44384),h=c(208),i=c(91579),j=c(44256),k=c(7833),l=c(33281),m=c(89800),n=c(87808);function o(a){if(0===a.length)return"";let b=[h.A.t("comments.codeRef"),""],c=a.filter(a=>a.filePath===i.Un),d=a.filter(a=>a.filePath!==i.Un);for(let a of(d.length>0&&d.forEach((a,c)=>{b.push(`[${c+1}] ${a.filePath}:${a.startLine}-${a.endLine}`),b.push("```"),b.push(a.codeContent),b.push("```"),a.content&&b.push(h.A.t("comments.note",{content:a.content})),b.push("")}),c)){let c=a.codeContent.split("\n").map(a=>`> ${a}`).join("\n");b.push(c),a.content&&b.push(a.content),b.push("")}return b.join("\n").trim()}function p({isOpen:a,onClose:b,cwd:c,onNavigateToComment:d}){let{t:h}=(0,g.Bd)(),[q,r]=(0,f.useState)([]),[s,t]=(0,f.useState)(!1),[u,v]=(0,f.useState)(null),[w,x]=(0,f.useState)(!1);(0,f.useCallback)(async()=>{if(!c)return;t(!0);let a=await l.t4.runPromiseExit((0,m.$)(c));"Success"===a._tag?r(a.value.comments??[]):console.error("Failed to load comments:",a.cause),t(!1)},[c]);let y=async a=>{let b=await l.t4.runPromiseExit((0,m.Tu)(c,a));"Success"===b._tag?(r(b=>b.filter(b=>b.id!==a)),(0,i.Cm)()):console.error("Failed to delete comment:",b.cause)},z=async a=>{v(a.id);try{let b="";if(a.selectedText)b=a.selectedText;else{let d=await l.t4.runPromiseExit((0,n.K9)(c,a.filePath));if("Success"!==d._tag||!d.value.ok)throw Error("Failed to read file");b=(d.value.data?.content||"").split("\n").slice(a.startLine-1,a.endLine).join("\n")}let d={filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,content:a.content,codeContent:b},e=o([d]);await navigator.clipboard.writeText(e),(0,k.oR)(h("toast.copiedComment"))}catch(a){console.error("Failed to copy comment:",a)}finally{v(null)}},A=async()=>{if(0!==q.length){x(!0);try{let a=await (0,i.$3)(c),b=o(a);await navigator.clipboard.writeText(b),(0,k.oR)(h("toast.copiedAllComments"))}catch(a){console.error("Failed to copy all comments:",a)}finally{x(!1)}}},B=q.reduce((a,b)=>(a[b.filePath]||(a[b.filePath]=[]),a[b.filePath].push(b),a),{});if(!a)return null;let C=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,e.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-xl flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:h("comments.allComments")}),q.length>0&&(0,e.jsx)("button",{onClick:A,disabled:w,className:"p-1 rounded hover:bg-accent text-muted-foreground disabled:opacity-50",title:h("comments.copyAllComments"),children:w?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:b,className:"p-1 rounded hover:bg-accent text-muted-foreground",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:s?(0,e.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:h("common.loading")}):0===q.length?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,e.jsx)("svg",{className:"w-12 h-12 mb-3 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,e.jsx)("span",{children:h("comments.noComments")})]}):(0,e.jsx)("div",{className:"space-y-4",children:Object.entries(B).map(([a,b])=>(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,e.jsxs)("div",{className:"px-3 py-2 bg-secondary border-b border-border",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground font-mono",children:a===i.Un?h("comments.aiReply"):a}),(0,e.jsxs)("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",h("comments.nComments",{count:b.length}),")"]})]}),(0,e.jsx)("div",{className:"divide-y divide-border",children:b.map(a=>{var b;return(0,e.jsx)("div",{className:"px-3 py-2 hover:bg-accent/50 cursor-pointer group",onClick:()=>d?.(a),children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.startLine>0||a.endLine>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{className:"text-xs text-brand font-mono",children:[h("common.line")," ",a.startLine===a.endLine?a.startLine:`${a.startLine}-${a.endLine}`]}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",h("comments.linesCount",{count:a.endLine-a.startLine+1}),")"]})]}):a.selectedText?(0,e.jsxs)("span",{className:"text-xs text-muted-foreground italic truncate max-w-[200px]",children:["“",a.selectedText.slice(0,50),a.selectedText.length>50?"...":"","”"]}):null,(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:(b=a.updatedAt||a.createdAt)?new Date(b).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):""})]}),(0,e.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.content||(0,e.jsx)("span",{className:"text-muted-foreground italic",children:h("comments.noContent")})})]}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),z(a)},disabled:u===a.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-accent text-muted-foreground transition-opacity disabled:opacity-50",title:h("common.copy"),children:u===a.id?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:b=>{b.stopPropagation(),y(a.id)},className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-accent text-muted-foreground hover:text-red-9 transition-opacity",title:h("common.delete"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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"})})})]})},a.id)})})]},a))})}),(0,e.jsxs)("div",{className:"px-4 py-3 border-t border-border bg-secondary flex items-center justify-between",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:h("comments.totalComments",{count:q.length})}),(0,e.jsx)("button",{onClick:async()=>{0===q.length||await (0,i.RP)(c)&&r([])},disabled:0===q.length,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 disabled:opacity-50 disabled:cursor-not-allowed",children:h("comments.clearAll")})]})]})});return(0,e.jsx)(j.ZL,{children:C})}d()}catch(a){d(a)}})},85655:(a,b,c)=>{"use strict";c.d(b,{Bj:()=>j,CM:()=>t,FK:()=>s,Iz:()=>n,MB:()=>u,Ub:()=>p,X0:()=>o,Zi:()=>k,lv:()=>m,oh:()=>r,r4:()=>h,ue:()=>i,w2:()=>q,yy:()=>l});var d=c(79606),e=c(71192);let f=a=>d.tryPromise({try:async()=>{let b=await fetch(a);if(!b.ok){let a;try{a=(await b.json()).error}catch{}throw Error(a||`HTTP ${b.status}`)}return await b.json()},catch:b=>new e.uV({message:`fetch ${a} failed`,cause:b})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new e.uV({message:`POST ${a} failed`,cause:b})}),h=a=>f(`/api/git/branches?cwd=${encodeURIComponent(a)}`).pipe(d.flatMap(b=>"Failed to get branches"===b.error?d.fail(new e.m_({resource:"git-repo",id:a})):d.succeed(b))),i=a=>f(`/api/git/current-branch?cwd=${encodeURIComponent(a)}`),j=(a,b,c,d)=>f(`/api/git/commits?cwd=${encodeURIComponent(a)}&branch=${encodeURIComponent(b)}&limit=${c}${"number"==typeof d?`&offset=${d}`:""}`),k=(a,b,c)=>f(`/api/git/commit-diff?cwd=${encodeURIComponent(a)}&hash=${encodeURIComponent(b)}${c?`&file=${encodeURIComponent(c)}`:""}`),l=(a,b,c)=>f(`/api/git/branch-diff?cwd=${encodeURIComponent(a)}&base=${encodeURIComponent(b)}${c?`&file=${encodeURIComponent(c)}`:""}`),m=a=>f(`/api/git/status?cwd=${encodeURIComponent(a)}`),n=(a,b)=>g("/api/git/stage",{cwd:a,files:b}),o=(a,b)=>g("/api/git/unstage",{cwd:a,files:b}),p=(a,b,c)=>g("/api/git/discard",{cwd:a,files:b,isUntracked:c}),q=(a,b,c)=>{let d=new URLSearchParams({cwd:a,file:b,type:c});return f(`/api/git/diff?${d}`)},r=a=>f(`/api/git/diff?${a.toString()}`),s=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),t=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/git/worktree failed",cause:a})}),u=a=>f(`/api/projectGraph/search?${a.toString()}`)},85906:(a,b,c)=>{"use strict";c.d(b,{ProjectItem:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectItem() from the server but ProjectItem is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/ProjectItem.tsx","ProjectItem")},85984:(a,b,c)=>{"use strict";c.d(b,{V:()=>k});var d=c(67484),e=c(79606),f=c(33281),g=c(71192);let h=new Map,i=new Map;async function j(a,b,c=!1){let d=`${a}::${b}`;if(c)!function(a){if(!a){h.clear(),i.clear();return}let b=`${a}::`;for(let a of h.keys())a.startsWith(b)&&h.delete(a);for(let a of i.keys())a.startsWith(b)&&i.delete(a)}(a);else{let a=h.get(d);if(a)return a;let b=i.get(d);if(b)return b}let k=e.tryPromise({try:async()=>{let e=new URLSearchParams({cwd:a,path:b});c&&e.set("refresh","1");let f=await fetch(`/api/projectGraph/file-functions?${e}`);if(404===f.status)return"not-found";if(!f.ok)throw Error((await f.json().catch(()=>({error:`HTTP ${f.status}`}))).error||`HTTP ${f.status}`);let g=await f.json();return h.set(d,g),g},catch:a=>new g.uV({message:"fetchFileFunctions failed",cause:a})}),l=f.t4.runPromiseExit(k).then(a=>{if("Success"===a._tag)return a.value;let b="Fail"===a.cause._tag?a.cause.error:null,c=b?.cause;if(c instanceof Error)throw c;throw Error(b?.message??"fetchFileFunctions failed")}).finally(()=>i.delete(d));return i.set(d,l),l}function k(a,b){let[c,e]=(0,d.useState)({state:"idle"}),f=(0,d.useRef)(!0),g=(0,d.useCallback)((a,b,c)=>{e({state:"loading"}),j(a,b,c).then(a=>{f.current&&("not-found"===a?e({state:"notFound"}):e({state:"ready",data:a}))}).catch(a=>{f.current&&e({state:"error",message:a.message})})},[]);return{state:c,refresh:(0,d.useCallback)(()=>{a&&b&&g(a,b,!0)},[a,b,g])}}},86686:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{f:()=>h});var e=c(48249);c(67484);var f=c(44384),g=c(44256);function h({isOpen:a,onClose:b,messages:c,onSelectMessage:d}){let{t:i}=(0,f.Bd)();if(!a)return null;let j=c.filter(a=>"user"===a.role),k=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:b,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-lg max-h-[70vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:i("userMessages.title")}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===j.length?(0,e.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:i("userMessages.noMessages")}):(0,e.jsx)("div",{className:"divide-y divide-border",children:j.map((a,c)=>{let f,g,h,i=(f=a.id.match(/^user-(\d+)/))?parseInt(f[1],10):null,j=i?(g=new Date(i),h=new Date,g.toDateString()===h.toDateString()?g.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):g.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})):"";return(0,e.jsx)("button",{onClick:()=>{var c;return c=a.id,void(d(c),b())},className:"w-full px-4 py-3 text-left hover:bg-accent transition-colors",children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsxs)("span",{className:"text-xs text-muted-foreground font-mono w-6 shrink-0 pt-0.5",children:[c+1,"."]}),(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)("p",{className:"text-sm text-foreground break-words",children:function(a,b=50){let c=a.replace(/\s+/g," ").trim();return c.length<=b?c:c.slice(0,b)+"..."}(a.content)})}),j&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground shrink-0 pt-0.5",children:j})]})},a.id)})})})]})});return(0,e.jsx)(g.ZL,{children:k})}d()}catch(a){d(a)}})},87238:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$:()=>r,j:()=>s});var e=c(48249),f=c(67484),g=c(44384),h=c(24520),i=c(88282),j=c(46674),k=c(72529),l=c(9780),m=c(33281),n=c(23328),o=a([l]);function p({onAdd:a,onCancel:b}){let{t:c}=(0,g.Bd)(),[d,h]=(0,f.useState)(""),[i,j]=(0,f.useState)("");return(0,e.jsxs)("div",{className:"flex gap-1 mb-1",children:[(0,e.jsx)("input",{type:"text",value:d,onChange:a=>h(a.target.value),placeholder:c("console.namePlaceholder"),className:"w-24 flex-shrink-0 px-2 py-1 text-xs rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring",autoFocus:!0,onKeyDown:a=>{"Escape"===a.key&&b()}}),(0,e.jsx)("input",{type:"text",value:i,onChange:a=>j(a.target.value),placeholder:c("console.commandPlaceholder"),className:"flex-1 min-w-0 px-2 py-1 text-xs font-mono rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring",onKeyDown:c=>{"Enter"!==c.key||c.nativeEvent.isComposing?"Escape"===c.key&&b():(c.preventDefault(),c.stopPropagation(),d.trim()&&i.trim()&&a(d.trim(),i.trim()))}})]})}function q({label:a,commands:b,isAdding:c,onStartAdd:d,onAdd:f,onCancelAdd:l,onDelete:m,onExecute:n}){let{t:o}=(0,g.Bd)();return(0,e.jsxs)("div",{className:"p-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1",children:a}),(0,e.jsx)("button",{type:"button",onClick:d,className:"p-0.5 text-muted-foreground hover:text-foreground rounded",children:(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),c&&(0,e.jsx)(p,{onAdd:(a,b)=>f(a,b),onCancel:l}),0===b.length&&!c&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:o("console.noCustomCommands")}),b.map((a,b)=>(0,e.jsx)(k.m,{content:a.command,children:(0,e.jsxs)("div",{className:"flex items-center group min-w-0",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>n(a.command),className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1.5 text-left text-sm rounded hover:bg-accent transition-colors",children:[(0,e.jsx)(i.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,e.jsx)("span",{className:"truncate",children:a.name})]}),(0,e.jsx)("button",{type:"button",onClick:()=>m(b),className:"p-1 text-muted-foreground hover:text-destructive rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:(0,e.jsx)(j.A,{className:"w-3 h-3"})})]})},b))]})}function r({cwd:a,show:b,onClose:c,onExecute:d,onAddPluginItem:h}){let{t:i}=(0,g.Bd)(),[j,k]=(0,f.useState)([]),[o,p]=(0,f.useState)([]),[s,t]=(0,f.useState)(null),u=(0,f.useRef)(null);(0,f.useCallback)(async()=>{let[b,c]=await Promise.all([m.t4.runPromiseExit((0,n.Yj)()),m.t4.runPromiseExit((0,n.UV)(a))]);if("Success"===b._tag){let a=b.value;k(a.customCommands||[])}if("Success"===c._tag){let a=c.value;p(a.customCommands||[])}},[a]);let v=(0,f.useCallback)(async a=>{k(a);let b=await m.t4.runPromiseExit((0,n.Cb)({scope:"global",customCommands:a}));"Failure"===b._tag&&console.error("Failed to save global commands:",b.cause)},[]),w=(0,f.useCallback)(async b=>{p(b);let c=await m.t4.runPromiseExit((0,n.Cb)({cwd:a,customCommands:b}));"Failure"===c._tag&&console.error("Failed to save project commands:",c.cause)},[a]),x=(0,f.useCallback)(a=>{c();let b=(0,l.sk)(a);b?h?.(b.type,a.trim()):d(a)},[c,d,h]);return b?(0,e.jsxs)("div",{ref:u,className:"absolute bottom-full left-0 mb-2 w-72 bg-popover border border-border rounded-lg shadow-lg z-50 max-h-[70vh] overflow-y-auto",children:[(0,e.jsx)(q,{label:i("console.globalCommands"),commands:j,isAdding:"global"===s,onStartAdd:()=>t("global"),onAdd:(a,b)=>{v([...j,{name:a,command:b}]),t(null)},onCancelAdd:()=>t(null),onDelete:a=>v(j.filter((b,c)=>c!==a)),onExecute:x}),(0,e.jsx)("div",{className:"border-t border-border"}),(0,e.jsx)(q,{label:i("console.projectCommands"),commands:o,isAdding:"project"===s,onStartAdd:()=>t("project"),onAdd:(a,b)=>{w([...o,{name:a,command:b}]),t(null)},onCancelAdd:()=>t(null),onDelete:a=>w(o.filter((b,c)=>c!==a)),onExecute:x})]}):null}function s(a){let[b,c]=(0,f.useState)([]),[d,e]=(0,f.useState)([]),g=(0,f.useCallback)(async()=>{let[b,d]=await Promise.all([m.t4.runPromiseExit((0,n.UV)(a)),m.t4.runPromiseExit((0,n.Yj)())]);if("Success"===b._tag){let a=b.value;c(a.customCommands||[])}if("Success"===d._tag){let a=d.value;e(a.customCommands||[])}},[a]),h=[...b,...d],i=(0,f.useCallback)(a=>{let c=a.trim().split(/\s+/),e=c[0];if(!e.startsWith("/")||e.length<=1)return null;let f=e.slice(1),g=b.find(a=>a.name===f)??d.find(a=>a.name===f);return g?g.command+(c.length>1?" "+c.slice(1).join(" "):""):null},[b,d]);return{quickCustomCommands:h,projectCommands:b,globalCommands:d,expandCustomCommand:i,loadQuickCommands:g}}l=(o.then?(await o)():o)[0],d()}catch(a){d(a)}})},87808:(a,b,c)=>{"use strict";c.d(b,{DZ:()=>j,Ft:()=>n,K9:()=>q,Nn:()=>v,OJ:()=>s,VK:()=>w,YW:()=>m,__:()=>u,dt:()=>t,eA:()=>r,eE:()=>o,gZ:()=>k,mP:()=>i,nM:()=>x,r6:()=>p,r9:()=>l});var d=c(79606),e=c(71192);let f=(a,b={})=>d.tryPromise({try:async()=>{let c=await fetch(a,b.init);if(b.passThroughStatuses&&b.passThroughStatuses.includes(c.status))return await c.json().catch(()=>({}));if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:b=>new e.uV({message:`GET ${a} failed`,cause:b})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b),d=null;try{d=await c.json()}catch{}return{status:c.status,ok:c.ok,data:d}},catch:b=>new e.uV({message:`GET ${a} failed`,cause:b})}),h=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new e.uV({message:`POST ${a} failed`,cause:b})}),i=a=>f(`/api/files/init?cwd=${encodeURIComponent(a)}`),j=a=>f(`/api/files/index?cwd=${encodeURIComponent(a)}`),k=(a,b)=>f(`/api/files/readdir?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`),l=a=>f(`/api/files/recent?cwd=${encodeURIComponent(a)}`),m=(a,b,c)=>h("/api/files/recent",{cwd:a,file:b,...c??{}}),n=(a,b)=>h("/api/files/expanded",{cwd:a,paths:b}),o=(a,b)=>f(`/api/files/blame?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`).pipe(d.catchAll(a=>d.succeed({error:a.message}))),p=(a,b)=>g(`/api/files/stat?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`,{cache:"no-store"}),q=(a,b)=>g(`/api/files/text?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`,{cache:"no-store"}),r=a=>f(`/api/files/text?${a.toString()}`),s=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=null;try{c=await b.json()}catch{}return{status:b.status,ok:b.ok,data:c}},catch:a=>new e.uV({message:"POST /api/files/save failed",cause:a})}),t=()=>f("/api/files/clipboard"),u=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/clipboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"POST /api/files/clipboard failed",cause:a})}),v=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/files/paste failed",cause:a})}),w=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/files/delete failed",cause:a})}),x=a=>f(`/api/file?path=${encodeURIComponent(a)}`)},87819:(a,b,c)=>{"use strict";c.d(b,{Z:()=>e});var d=c(67484);function e(a,b){let[c,e]=(0,d.useState)({status:"loading"});return c}c(13426),c(79883),c(1239),c(79606),c(95046),c(33281)},88214:(a,b,c)=>{"use strict";c.d(b,{n:()=>e});var d=c(23734);let e={SessionChange:(0,d.R)("session-change"),ViewChange:(0,d.R)("view-change"),OpenNote:(0,d.R)("open-note"),LangChange:(0,d.R)("lang-change"),TabAdd:(0,d.R)("tab-add"),TabClose:(0,d.R)("tab-close"),SwitchSession:(0,d.R)("switch-session"),ProjectChange:(0,d.R)("project-change"),OpenProject:(0,d.R)("open-project"),SessionComplete:(0,d.R)("session-complete"),OpenTokenStats:(0,d.R)("open-token-stats"),PinnedSessionsChanged:(0,d.R)("pinned-sessions-changed"),ScheduledTasksChanged:(0,d.R)("scheduled-tasks-changed"),ScreenshotPrepare:(0,d.R)("screenshot-prepare"),ScreenshotDone:(0,d.R)("screenshot-done")}},89800:(a,b,c)=>{"use strict";c.d(b,{$:()=>i,BC:()=>j,Tu:()=>l,lb:()=>h,tj:()=>m,vv:()=>k});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:c=>new e.uV({message:`${b.method} ${a} failed`,cause:c})}),h=(a,b)=>f(`/api/comments?cwd=${encodeURIComponent(a)}${b?`&filePath=${encodeURIComponent(b)}`:""}`),i=a=>f(`/api/comments?cwd=${encodeURIComponent(a)}&all=true`),j=a=>f("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),k=(a,b,c)=>f("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,id:b,content:c})}),l=(a,b)=>g(`/api/comments?cwd=${encodeURIComponent(a)}&id=${encodeURIComponent(b)}`,{method:"DELETE"}),m=a=>g(`/api/comments?cwd=${encodeURIComponent(a)}&all=true`,{method:"DELETE"})},90018:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{O:()=>K});var e=c(48249),f=c(67484),g=c(44384),h=c(10316),i=c(46674),j=c(80600),k=c(69924);c(33281),c(85655),c(87808);var l=c(53716),m=c(85984),n=c(7031),o=c(74754),p=c(91579),q=c(83768),r=c(36984),s=c(49924),t=c(54038),u=c(37690),v=c(77396),w=c(70404),x=c(41051),y=c(42140),z=c(70596),A=a([r,v,s,t]);function B(a){let b=a.lastIndexOf("/");return b>=0?a.slice(b+1):a}function C({symbol:a,fileSource:b,hasChange:c,onHighlighted:d,comments:g,onCommentClick:h,addedLines:i}){let{resolvedTheme:j}=(0,q.D)();(0,f.useMemo)(()=>(0,r.sQ)(a.filePath),[a.filePath]);let[k,m]=(0,f.useState)(null),[n,o]=(0,f.useState)(null);return(0,e.jsxs)("div",{className:"flex-1 min-w-0 bg-card border border-border rounded overflow-hidden relative",children:[(0,e.jsxs)("div",{"data-block-header":!0,className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-border bg-secondary/40 text-xs",children:[(0,e.jsx)(l.y,{kind:a.kind,qname:a.qualifiedName,className:"w-3.5 h-3.5 flex-shrink-0"}),(0,e.jsxs)("span",{className:"font-mono truncate min-w-0",children:[(0,e.jsx)("span",{className:"font-medium",children:a.name}),void 0!==a.params&&(0,e.jsxs)("span",{className:"text-muted-foreground/80",children:["(",a.params.join(", "),")"]})]}),(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 flex-shrink-0",children:[a.kind," \xb7 L",a.startLine,"-",a.endLine]}),(0,e.jsx)("span",{className:"flex-1"}),c&&(0,e.jsx)("span",{className:"flex-shrink-0 w-2 h-2 rounded-full bg-amber-11","data-tooltip":"File has uncommitted change"})]}),(0,e.jsxs)("div",{"data-block-body":!0,className:"text-[11px] font-mono px-2 py-2 overflow-auto",style:{lineHeight:`${N}px`},children:[!b&&(0,e.jsx)("span",{className:"text-muted-foreground",children:"Loading…"}),n&&(0,e.jsx)("span",{className:"text-red-11",children:n}),k&&(0,e.jsx)("div",{dangerouslySetInnerHTML:{__html:k}})]}),g&&g.length>0&&h&&(0,e.jsx)(v._,{comments:g,startLine:a.startLine,endLine:a.endLine,lineHeight:N,bodyTopOffset:O+P,onCommentClick:h})]})}function D({side:a,pin:b,accent:c,onClick:d}){let f,g,h,i,j,k,l,m=b.lines.length;"ext"===b.kind?(f="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",g="ext",h="text-muted-foreground/60",i=b.name,j=b.packageSpec,k="external",l=b.packageSpec):"method"===b.kind?(f="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",g="method",h="text-muted-foreground/60",i=`${b.receiverName}.${b.methodName}`,j=null,k="method (unresolved)",l=m>0?`at line${m>1?"s":""} ${b.lines.join(", ")}`:""):"self"===b.kind?(f="bg-secondary/40 border-border hover:border-muted-foreground",g="self",h="text-muted-foreground/70",i=b.external.name,j=null,k="same-file",l=m>0?`at line${m>1?"s":""} ${b.lines.join(", ")}`:""):(f="in"===a?"bg-amber-9/15 border-amber-9/40 hover:border-amber-11":"bg-green-9/15 border-green-9/40 hover:border-green-11",g=a,h="in"===a?"text-amber-11":"text-green-11",i=b.external.name,j=B(b.external.filePath),k="in"===a?"caller":"callee",l=b.external.filePath);let n=c&&"ext"!==b.kind&&"method"!==b.kind?" ring-1 ring-amber-9/70 ring-offset-0":"";return(0,e.jsxs)("button",{onClick:a=>{a.stopPropagation(),d()},className:`${f}${n} w-full text-left border rounded px-1.5 py-0.5 text-[10px] font-mono cursor-pointer transition-colors flex items-center gap-1.5`,"data-tooltip":`${k}${l?" \xb7 "+l:""}`,children:[(0,e.jsx)("span",{className:`${h} text-[9px] uppercase tracking-wider font-semibold flex-shrink-0`,children:g}),(0,e.jsxs)("span",{className:"truncate flex-1 min-w-0",children:[(0,e.jsx)("span",{className:"font-medium",children:i}),j&&(0,e.jsx)("span",{className:"text-muted-foreground/70 ml-1",children:j}),m>1&&(0,e.jsxs)("span",{className:"text-muted-foreground/60 ml-1",children:["\xb7",m,"\xd7"]})]})]})}[r,v,s,t]=A.then?(await A)():A;let N=18,O=29,P=8;function E(a,b){switch(b.kind){case"cross":return`${a}:x:${b.external.filePath}::${b.external.qualifiedName}`;case"self":return`${a}:s:${b.external.filePath}::${b.external.qualifiedName}`;case"ext":return`${a}:e:${b.packageSpec}::${b.name}`;case"method":return`${a}:m:${b.receiverName}::${b.methodName}`}}function F(a,b){return"ext"!==a.kind&&"method"!==a.kind&&(b?.has(a.external.qualifiedName)??!1)}function G(a){return{filePath:a.filePath,qname:a.qualifiedName,name:a.name,kind:a.kind}}function H({symbol:a,fileSource:b,hasChange:c,upstream:d,downstream:f,onPinClick:g,onHighlighted:h,comments:i,onCommentClick:j,accentQnames:k,addedLines:l}){let m=function(a,b){if(0===a.length)return[];let c=a.map((a,c)=>{var d,e,f;return{i:c,line:(d=a.lines[0]??b.startLine,e=b.startLine,f=b.endLine,Math.max(e,Math.min(f,d)))}});c.sort((a,b)=>a.line-b.line||a.i-b.i);let d=Array(a.length).fill(0),e=-1/0;for(let{i:a,line:f}of c){let c=O+P+(f-b.startLine)*N,g=Math.max(c,e);d[a]=g,e=g+22}return d}(f,a);return(0,e.jsxs)("div",{"data-block-qname":a.qualifiedName,"data-start-line":a.startLine,"data-end-line":a.endLine,className:"flex gap-2 items-stretch scroll-mt-2",children:[(0,e.jsx)("div",{className:"w-44 flex-shrink-0 flex flex-col gap-1 pt-1",children:0===d.length?(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5",children:"no callers"}):d.map(b=>(0,e.jsx)(D,{side:"in",pin:b,accent:F(b,k),onClick:()=>g(b,a)},E("in",b)))}),(0,e.jsx)(C,{symbol:a,fileSource:b,hasChange:c,onHighlighted:h,comments:i,onCommentClick:j,addedLines:l}),(0,e.jsx)("div",{className:"w-44 flex-shrink-0 relative",children:0===f.length?(0,e.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5 pt-1",children:"no callees"}):f.map((b,c)=>(0,e.jsx)("div",{className:"absolute left-0 right-0",style:{top:`${m[c]}px`},children:(0,e.jsx)(D,{side:"out",pin:b,accent:F(b,k),onClick:()=>g(b,a)})},E("out",b)))})]})}function I({cwd:a,onSelect:b,onClose:c}){let{t:d}=(0,g.Bd)(),[j,k]=(0,f.useState)(""),[l,m]=(0,f.useState)({files:[],symbols:[]}),[n,o]=(0,f.useState)(0),[p,q]=(0,f.useState)(!1),r=(0,f.useMemo)(()=>[...l.files,...l.symbols],[l]),s=(0,f.useCallback)(a=>{if("Escape"===a.key)return void c();if(0!==r.length){if("ArrowDown"===a.key)a.preventDefault(),o(a=>Math.min(a+1,r.length-1));else if("ArrowUp"===a.key)a.preventDefault(),o(a=>Math.max(a-1,0));else if("Enter"===a.key){a.preventDefault();let c=r[n];c&&b(c)}}},[r,n,c,b]);return(0,e.jsx)("div",{className:"absolute inset-0 bg-background/40 z-20 flex items-start justify-center pt-24",onClick:c,children:(0,e.jsxs)("div",{className:"w-[480px] max-w-[80%] bg-card border border-border rounded shadow-2xl overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,e.jsx)(h.A,{className:"w-4 h-4 text-muted-foreground"}),(0,e.jsx)("input",{autoFocus:!0,value:j,onChange:a=>k(a.target.value),onKeyDown:s,placeholder:d("blockViewer.search.hint","Start typing to search"),className:"flex-1 bg-transparent border-0 outline-none text-sm"}),p&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"…"}),(0,e.jsx)("button",{onClick:c,className:"text-muted-foreground hover:text-foreground",children:(0,e.jsx)(i.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsxs)("div",{className:"max-h-96 overflow-y-auto",children:[0===r.length&&j&&!p&&(0,e.jsx)("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:d("blockViewer.search.noResults","No matches")}),(0,e.jsx)(J,{label:d("blockViewer.search.files","Files"),hits:l.files,startIdx:0,activeIdx:n,onSelect:b,setActive:o}),(0,e.jsx)(J,{label:d("blockViewer.search.symbols","Symbols"),hits:l.symbols,startIdx:l.files.length,activeIdx:n,onSelect:b,setActive:o})]})]})})}function J({label:a,hits:b,startIdx:c,activeIdx:d,onSelect:f,setActive:g}){return 0===b.length?null:(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-secondary/40",children:a}),b.map((a,b)=>{let h=c+b,i=h===d;return(0,e.jsxs)("button",{onMouseEnter:()=>g(h),onClick:()=>f(a),className:`w-full text-left px-3 py-1.5 text-xs flex items-start gap-2 ${i?"bg-secondary":"hover:bg-secondary/60"}`,children:["file"===a.target.kind?(0,e.jsx)(j.A,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-muted-foreground"}):(0,e.jsx)(l.y,{kind:a.target.symbolKind,qname:a.target.qualifiedName,className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),(0,e.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,e.jsx)("span",{className:"font-mono truncate",children:a.label}),a.hint&&(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground truncate",children:a.hint})]})]},`${a.type}:${a.label}:${b}`)})]})}function K({cwd:a,highlightedFilePath:b,changedFiles:c,onSwitchToCode:d,enableComments:h=!1,onContentSearch:i,onFocalChange:j,qnameFilter:k,qnameFilterFile:l,accentQnames:q,accentFile:r,addedLines:v,addedLinesFile:A,headerExtraLeft:C,headerExtraRight:D}){let{t:E}=(0,g.Bd)(),[F,J]=(0,f.useState)(null),N=F??b??null,{state:O,refresh:P}=(0,m.V)(a,N),[Q,R]=(0,f.useState)(null);(0,f.useRef)(null);let[S,T]=(0,f.useState)([]),[U,V]=(0,f.useState)(!1),[W,X]=(0,f.useState)(null),Y=(0,f.useRef)(0);(0,f.useRef)(0);let[Z,$]=(0,f.useState)(()=>new Set);"ready"===O.state&&O.data.filePath;let _=(0,f.useCallback)(a=>{$(b=>{if(b.has(a))return b;let c=new Set(b);return c.add(a),c})},[]),aa=(0,f.useCallback)((a,b)=>{if("ext"===a.kind||"method"===a.kind){let a=b.filePath;if(!a)return;Y.current+=1,X({filePath:a,qname:"__imports__",nonce:Y.current});return}let c=G(b),d=G(a.external);T(a=>(0,s.nb)((0,s.nb)(a,c),d)),J(d.filePath),Y.current+=1,X({filePath:d.filePath,qname:d.qname,nonce:Y.current})},[]),ab=(0,f.useCallback)(a=>{J(a.filePath),Y.current+=1,X({filePath:a.filePath,qname:a.qname,nonce:Y.current})},[]),ac=(0,f.useCallback)(a=>{V(!1),J(a.target.filePath),"symbol"===a.target.kind&&(Y.current+=1,X({filePath:a.target.filePath,qname:a.target.qualifiedName,line:a.target.line,nonce:Y.current}))},[]),ad=(0,f.useCallback)((a,b)=>{N&&(Y.current+=1,X({filePath:N,qname:a,line:b,nonce:Y.current}))},[N]),[ae,af]=(0,f.useState)(null),[ag,ah]=(0,f.useState)(null),ai=(0,f.useMemo)(()=>{if("ready"!==O.state||!ag)return null;let a=O.data.functions;if(0===a.length)return null;let b=(ag.start+ag.end)/2;for(let c of a)if(c.startLine<=b&&b<=c.endLine)return c.qualifiedName;let c=null;for(let b of a)b.startLine<=ag.start&&(!c||b.startLine>c.startLine)&&(c=b);return c?.qualifiedName??null},[O,ag]),aj=h&&!!a&&!!N,ak=(0,n.r)(),{comments:al,addComment:am,updateComment:an,deleteComment:ao,refresh:ap}=(0,o._)({cwd:a,filePath:N??""}),[aq,ar]=(0,f.useState)(null),{toolbarRef:as,bumpRef:at,clearToolbar:au}=(0,u.L)({enabled:aj,container:aq,resolveLineRange:a=>{if(!document.contains(a))return null;let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a,c=b?.closest("[data-line]");if(!c||!aq||!aq.contains(c))return null;let d=c.getAttribute("data-line");if(!d)return null;let e=parseInt(d,10);return Number.isFinite(e)?{start:e,end:e}:null},buildLineSnapshot:({start:a,end:b})=>{let c=Q?.content;return c?c.split("\n").slice(a-1,b).join("\n"):""}}),[av,aw]=(0,f.useState)(null),[ax,ay]=(0,f.useState)(null),[az,aA]=(0,f.useState)(null),aB=(0,f.useCallback)(()=>{let a=as.current;a&&(aw({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),au())},[au,as]),aC=(0,f.useCallback)(()=>{let a=as.current;a&&(ay({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),au())},[au,as]),aD=(0,f.useCallback)(()=>{let a=as.current;if(!a||!i)return;let b=a.selectedText.trim();au(),b&&i(b)},[i,au,as]),aE=(0,f.useCallback)(async a=>{av&&(await am(av.range.start,av.range.end,a,av.selectedText),aw(null))},[av,am]),aF=(0,f.useCallback)(async b=>{if(ax&&ak&&a&&N)try{let c=(await (0,p.$3)(a)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0}));c.push({filePath:N,startLine:ax.range.start,endLine:ax.range.end,codeContent:ax.lineSnapshot});let d=(0,p.Gw)(c,b);ak.sendMessage(d),await (0,p.RP)(a),ap(),ay(null)}catch(a){console.error("[BlockViewer] send to AI failed:",a)}},[ax,ak,a,N,ap]),aG=(0,f.useCallback)((a,b)=>{b.stopPropagation(),aA({comment:a,x:b.clientX,y:b.clientY}),au(),aw(null),ay(null)},[au]);if(!N)return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(M,{focalFile:null,fileCount:null,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,refreshDisabled:!0,extraLeft:C,extraRight:D}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-sm text-muted-foreground gap-2 px-4 text-center",children:[(0,e.jsx)("span",{children:E("blockViewer.empty.body","Select a file in the left tree to see its function call graph.")}),(0,e.jsx)("span",{className:"text-xs",children:E("blockViewer.empty.hint","or press ⌘K to search.")})]}),U&&(0,e.jsx)(I,{cwd:a,onSelect:ac,onClose:()=>V(!1)})]});if("idle"===O.state||"loading"===O.state)return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(M,{focalFile:N,fileCount:null,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,refreshDisabled:!0,extraLeft:C,extraRight:D}),(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:E("blockViewer.fileMode.loading","Loading…")})]});if("notFound"===O.state)return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(M,{focalFile:N,fileCount:null,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,extraLeft:C,extraRight:D}),(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground px-4 text-center",children:E("blockViewer.fileMode.notFound","This file is not indexed (unsupported language or beyond the file cap).")}),U&&(0,e.jsx)(I,{cwd:a,onSelect:ac,onClose:()=>V(!1)})]});if("error"===O.state)return(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)(M,{focalFile:N,fileCount:null,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,extraLeft:C,extraRight:D}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-sm",children:[(0,e.jsx)("span",{className:"text-red-11",children:O.message}),(0,e.jsx)("button",{onClick:P,className:"px-3 py-1 rounded bg-secondary hover:bg-secondary/80",children:E("blockViewer.retry","Retry")})]})]});let aH=O.data,aI=aH.functions;if(0===aI.length&&Q){let a=Math.max(1,Q.content.split("\n").length);aI=[{filePath:aH.filePath,qualifiedName:"__file__",name:B(aH.filePath),kind:"unknown",startLine:1,endLine:a}]}let aJ=l&&l===aH.filePath,aK=r&&r===aH.filePath,aL=A&&A===aH.filePath;aJ&&k&&(aI=aI.filter(a=>k.has(a.qualifiedName)));let aM=aK?q:void 0,aN=aL?v:void 0,aO=L(aH.upstreamCalls),aP=L(aH.downstreamCalls),aQ=new Map(aI.map(a=>[a.qualifiedName,a])),aR=new Map,aS=new Map;for(let a of aH.intraCalls){let b=aQ.get(a.to),c=aQ.get(a.from);if(b){let c=aR.get(a.from),d={kind:"self",external:b,lines:a.lines};c?c.push(d):aR.set(a.from,[d])}if(c){let b=aS.get(a.to),d={kind:"self",external:c,lines:a.lines};b?b.push(d):aS.set(a.to,[d])}}let aT=new Map;for(let a of aH.externalCalls??[]){let b=aT.get(a.focalQname),c={kind:"ext",name:a.external.name,packageSpec:a.external.packageSpec,lines:a.lines};b?b.push(c):aT.set(a.focalQname,[c])}let aU=new Map;for(let a of aH.methodCalls??[]){let b=aU.get(a.focalQname),c={kind:"method",receiverName:a.receiverName,methodName:a.methodName,lines:a.lines};b?b.push(c):aU.set(a.focalQname,[c])}let aV=c.has(aH.filePath);return(0,e.jsxs)("div",{className:"h-full flex flex-col relative",children:[(0,e.jsx)(M,{focalFile:N,fileCount:aH.fileCount,functionCount:aH.functions.length,upstreamCount:aH.upstreamCalls.length,downstreamCount:aH.downstreamCalls.length,onSwitchToCode:d,onSearch:()=>V(!0),onRefresh:P,extraLeft:C,extraRight:D}),(0,e.jsxs)("div",{ref:ar,className:"flex-1 relative min-h-0 flex",children:[(0,e.jsx)(t.g,{functions:aI,currentQname:ai,onSelect:ad,notIndexed:aH.notIndexed,onRebuild:P}),(0,e.jsx)("div",{ref:af,className:"flex-1 min-w-0 overflow-auto",children:(0,e.jsx)("div",{className:"flex flex-col gap-3 p-3",children:aI.map(a=>{let b,c,d,f,g,h;return(0,e.jsx)(H,{symbol:a,fileSource:Q?.content??null,hasChange:aV,upstream:(b=aO.get(a.qualifiedName),c=aS.get(a.qualifiedName),[...(b??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...c??[]]),downstream:(d=aP.get(a.qualifiedName),f=aR.get(a.qualifiedName),g=aU.get(a.qualifiedName),h=aT.get(a.qualifiedName),[...(d??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...f??[],...g??[],...h??[]]),onPinClick:aa,onHighlighted:_,comments:aj?al:void 0,onCommentClick:aj?aG:void 0,accentQnames:aM,addedLines:aN},a.qualifiedName)})})}),aj&&aq&&(0,e.jsx)(x.f,{floatingToolbarRef:as,bumpRef:at,container:aq,onAddComment:aB,onSendToAI:aC,onSearch:i?aD:void 0,isChatLoading:ak?.isLoading}),aj&&av&&(0,e.jsx)(y.t,{x:av.x,y:av.y,range:av.range,lineSnapshot:av.lineSnapshot,container:aq,onSubmit:aE,onClose:()=>aw(null)}),aj&&ax&&N&&(0,e.jsx)(y.G,{x:ax.x,y:ax.y,range:ax.range,filePath:N,lineSnapshot:ax.lineSnapshot,container:aq,onSubmit:aF,onClose:()=>ay(null),isChatLoading:ak?.isLoading}),aj&&az&&(0,e.jsx)(z.t,{x:az.x,y:az.y,comment:az.comment,container:aq,onClose:()=>aA(null),onUpdateComment:an,onDeleteComment:ao}),aN&&aN.size>0&&aI.length>0&&(0,e.jsx)(w.e,{addedLines:aN,blockRanges:aI.map(a=>({qname:a.qualifiedName,startLine:a.startLine,endLine:a.endLine})),viewportRange:ag,onJumpToLine:ad}),(0,e.jsx)(s.mp,{entries:S,onSelect:ab,onClear:()=>T([])}),U&&(0,e.jsx)(I,{cwd:a,onSelect:ac,onClose:()=>V(!1)})]})]})}function L(a){let b=new Map;for(let c of a){let a=b.get(c.focalQname);if(!a){b.set(c.focalQname,[c]);continue}a.some(a=>a.external.filePath===c.external.filePath&&a.external.qualifiedName===c.external.qualifiedName)||a.push(c)}return b}function M({focalFile:a,fileCount:b,functionCount:c,upstreamCount:d,downstreamCount:f,onSwitchToCode:i,onSearch:j,onRefresh:l,refreshDisabled:m,extraLeft:n,extraRight:o}){let{t:p}=(0,g.Bd)(),q={focalFile:a,blockCount:c??0,upstreamCount:d??0,downstreamCount:f??0};return(0,e.jsxs)("div",{className:"flex-shrink-0 px-3 py-2 border-b border-border flex items-center justify-between bg-secondary/30 gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0 text-xs text-muted-foreground font-mono",children:[(0,e.jsx)("span",{className:"truncate min-w-0",children:a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-foreground",children:a}),"number"==typeof c&&(0,e.jsxs)("span",{className:"ml-2",children:["\xb7 ",c," blocks"]}),"number"==typeof d&&"number"==typeof f&&(0,e.jsxs)("span",{className:"ml-2",children:["\xb7 ",d," in \xb7 ",f," out"]})]}):(0,e.jsx)("span",{children:null!==b?`${b} files`:"…"})}),n&&(0,e.jsx)("span",{className:"flex items-center gap-1 flex-shrink-0",children:n(q)})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o&&(0,e.jsx)("span",{className:"flex items-center gap-1",children:o(q)}),(0,e.jsxs)("button",{onClick:j,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground flex items-center gap-1","data-tooltip":p("blockViewer.search.tooltip","Search (⌘K)"),children:[(0,e.jsx)(h.A,{className:"w-3 h-3"})," ⌘K"]}),(0,e.jsx)("button",{onClick:l,disabled:m,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:hover:bg-transparent","data-tooltip":p("blockViewer.refresh","Rebuild project graph"),children:(0,e.jsx)(k.A,{className:"w-3 h-3"})}),i&&(0,e.jsx)("button",{onClick:i,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground",children:"Code"})]})]})}d()}catch(a){d(a)}})},90298:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{r:()=>j});var e=c(48249),f=c(67484),g=c(44256),h=c(33281),i=c(41224);let a=[{value:"deepseek-v4-flash",label:"deepseek-v4-flash"},{value:"deepseek-v4-pro",label:"deepseek-v4-pro"}];function j({currentModel:b,onModelChange:c}){let[d,k]=(0,f.useState)(!1),[l,m]=(0,f.useState)(""),[n,o]=(0,f.useState)(""),[p,q]=(0,f.useState)(!1),[r,s]=(0,f.useState)(!1),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(null),x=(0,f.useRef)(null),y=(0,f.useRef)(null),z=(0,f.useRef)(null),[A,B]=(0,f.useState)({top:0,left:0}),C=(0,g.F2)(),D=(0,f.useCallback)(async()=>{s(!0),w(null);let d=await h.t4.runPromiseExit((0,i.td)());if("Failure"===d._tag){w("Failed to load settings"),s(!1);return}let e=d.value,f=e?.engines?.deepseek?.apiKey||"";m(f),o(""),q(!1);let g=e?.engines?.deepseek?.model;!b&&g&&a.some(a=>a.value===g)&&c(g),s(!1)},[b,c]),E=(0,f.useCallback)(async a=>{let b=await h.t4.runPromiseExit((0,i.td)()),c=("Success"===b._tag?b.value:{}).engines||{},d={...c,deepseek:{...c.deepseek||{},...a}},e=await h.t4.runPromiseExit((0,i.em)({engines:d}));if("Failure"===e._tag)throw Error("Failed to save settings")},[]),F=async()=>{let a=n.trim();if(a){u(!0),w(null);try{await E({apiKey:a}),m(a),o(""),q(!1)}catch(a){w(a instanceof Error?a.message:"Save failed")}finally{u(!1)}}},G=async()=>{u(!0),w(null);try{await E({apiKey:""}),m(""),o(""),q(!1)}catch(a){w(a instanceof Error?a.message:"Clear failed")}finally{u(!1)}},H=async a=>{c(a);try{await E({model:a})}catch{}},I=!!l,J=I?b||"deepseek-v4-flash":"Set API key",K=I?"text-sky-400":"text-amber-400",L=d?(0,e.jsx)(g.ZL,{children:(0,e.jsx)("div",{ref:y,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-2 min-w-[280px]",style:{top:A.top,left:A.left},children:r?(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-3 py-1.5",children:[(0,e.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"API Key"}),I&&!p?(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:l?l.length<=8?l.replace(/./g,"•"):`${l.slice(0,3)}${"•".repeat(Math.max(4,l.length-7))}${l.slice(-4)}`:""}),(0,e.jsx)("button",{onClick:()=>{q(!0),o(""),setTimeout(()=>z.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",disabled:t,children:"Edit"}),(0,e.jsx)("button",{onClick:G,className:"text-[11px] px-2 py-1 rounded text-red-400 hover:bg-red-500/10 transition-colors",disabled:t,children:"Clear"})]}):(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("input",{ref:z,type:"password",value:n,onChange:a=>o(a.target.value),onKeyDown:a=>{"Enter"===a.key&&F()},placeholder:"sk-...",className:"flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:border-sky-500 focus:outline-none font-mono",autoFocus:!0}),(0,e.jsx)("button",{onClick:F,disabled:t||!n.trim(),className:"text-[11px] px-2 py-1 rounded bg-sky-500/20 hover:bg-sky-500/30 text-sky-300 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:t?"Saving...":"Save"}),I&&(0,e.jsx)("button",{onClick:()=>{q(!1),o("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),v&&(0,e.jsx)("div",{className:"mt-1 text-[11px] text-red-400",children:v})]}),(0,e.jsx)("div",{className:"my-1 border-t border-border"}),(0,e.jsxs)("div",{className:"px-3 py-1.5",children:[(0,e.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Model"}),(0,e.jsx)("div",{className:"flex flex-col gap-0.5",children:a.map(a=>{let c=(b||"deepseek-v4-flash")===a.value;return(0,e.jsxs)("button",{onClick:()=>H(a.value),className:`flex items-center gap-2 px-2 py-1 text-xs rounded transition-colors ${c?"bg-sky-500/15 text-sky-300":"text-foreground hover:bg-accent"}`,children:[(0,e.jsx)("span",{className:`w-3 h-3 rounded-full border-2 flex items-center justify-center ${c?"border-sky-400":"border-muted-foreground"}`,children:c&&(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-sky-400"})}),(0,e.jsx)("span",{children:a.label})]},a.value)})})]})]})})}):null;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{ref:x,onClick:()=>{if(!d){if(x.current){let a=x.current.getBoundingClientRect(),b=C?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;B({top:a.bottom+4-d,left:a.left-c})}D()}k(a=>!a)},className:"flex items-center gap-1 px-2 py-0.5 text-[11px] rounded bg-sky-500/15 hover:bg-sky-500/25 transition-colors",title:"Configure DeepSeek",children:[(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-sky-500 flex-shrink-0"}),(0,e.jsx)("span",{className:`truncate max-w-[160px] ${K}`,children:J}),(0,e.jsx)("svg",{className:"w-3 h-3 flex-shrink-0 text-sky-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),L]})}d()}catch(a){d(a)}})},90677:(a,b,c)=>{"use strict";c.a(a,async(a,b)=>{try{var d=c(48249),e=c(3560),f=c(78684),g=c(74493),h=a([f]);f=(h.then?(await h)():h)[0],(0,e.Aq)({type:"jupyter",idPrefix:"nb",match:a=>a.trim().endsWith(".ipynb"),parse(a){let b=a.trim(),c=b.split("/"),d=c[c.length-1]||b;return{filePath:b,displayName:d,cwd:""}},fromHistory:a=>({filePath:a.filePath,displayName:a.displayName||"",cwd:a.cwd||""}),toHistory:a=>({filePath:a.filePath,displayName:a.displayName,cwd:a.cwd}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l}){return(0,d.jsx)(f.o,{id:a.id,filePath:a.filePath,displayName:a.displayName,cwd:a.cwd,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l})},async onClose(a){await (0,g.Hj)(a.id)}}),b()}catch(a){b(a)}})},91579:(a,b,c)=>{"use strict";c.d(b,{$3:()=>l,Cm:()=>k,Gw:()=>o,RP:()=>m,Un:()=>n,zL:()=>j});var d=c(208),e=c(79606),f=c(33281),g=c(71192),h=c(89800);let i=new Set;function j(a){return i.add(a),()=>i.delete(a)}function k(){i.forEach(a=>a())}async function l(a){let b=await f.t4.runPromiseExit((0,h.lb)(a));if("Success"!==b._tag)throw Error("Failed to fetch comments");let c=b.value.comments??[];if(0===c.length)return[];let d=new Map;for(let a of c)a.selectedText||(d.has(a.filePath)||d.set(a.filePath,[]),d.get(a.filePath).push(a));let i=new Map;await Promise.all(Array.from(d.keys()).map(async b=>{let c=await f.t4.runPromiseExit(e.tryPromise({try:async()=>{let c=await fetch(`/api/files/text?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`);return c.ok?await c.json():null},catch:a=>new g.uV({message:`read file text ${b} failed`,cause:a})}));"Success"===c._tag&&c.value&&"string"==typeof c.value.content?i.set(b,c.value.content.split("\n")):"Failure"===c._tag&&console.error(`Failed to read file ${b}:`,c.cause)}));let j=[];for(let a of c){if(a.selectedText){j.push({...a,codeContent:a.selectedText});continue}let b=i.get(a.filePath),c="";if(b){let d=Math.max(0,a.startLine-1),e=Math.min(b.length,a.endLine);c=b.slice(d,e).join("\n")}j.push({...a,codeContent:c})}return j}async function m(a){let b=await f.t4.runPromiseExit((0,h.tj)(a));return"Success"===b._tag?(k(),!0):(console.error("Failed to clear comments:",b.cause),!1)}let n="__chat__";function o(a,b){let c=a.filter(a=>a.filePath===n),e=a.filter(a=>a.filePath!==n),f=[];for(let a of(e.length>0&&(f.push(`${d.A.t("comments.codeRef")}`,""),e.forEach((a,b)=>{f.push(`[${b+1}] ${a.filePath}:${a.startLine}-${a.endLine}`),f.push("```"),f.push(a.codeContent),f.push("```"),a.note&&f.push(d.A.t("comments.note",{content:a.note})),f.push("")})),c)){let b=a.codeContent.split("\n").map(a=>`> ${a}`).join("\n");f.push(b),a.note&&f.push(a.note),f.push("")}return f.push(d.A.t("comments.question",{question:b})),f.join("\n")}},92451:(a,b,c)=>{"use strict";c.d(b,{U:()=>g});var d=c(48249),e=c(67484),f=c(19545);function g({editor:a,query:b,position:c,onClose:h}){let[i,j]=(0,e.useState)(0),k=(0,e.useRef)(null),l=(0,f.Qe)().filter(a=>a.label.toLowerCase().includes(b.toLowerCase())||a.description.toLowerCase().includes(b.toLowerCase()));return 0===l.length?null:(0,d.jsx)("div",{ref:k,className:"slash-command-menu fixed z-[60] bg-popover border border-border rounded-lg shadow-lg py-1 w-56 max-h-64 overflow-y-auto",style:{top:c.top,left:c.left},children:l.map((c,e)=>(0,d.jsxs)("button",{className:`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors ${e===i?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>{a.chain().focus().deleteRange({from:a.state.selection.from-b.length-1,to:a.state.selection.from}).run(),c.action(a),h()},onMouseEnter:()=>j(e),children:[(0,d.jsx)("span",{className:"w-6 text-center text-xs font-mono flex-shrink-0",children:c.icon}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"font-medium",children:c.label}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:c.description})]})]},c.label))})}},92701:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(33281),j=c(38087),k=c(23700),l=a([k]);function m(a){return a?a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}k`:String(a):"0"}function n(a){if(!a)return"–";let b=Math.round(a/1e3);if(b<60)return`${b}s`;let c=Math.floor(b/60);return`${c}m${b%60}s`}k=(l.then?(await l)():l)[0];let q={done:"text-green-9",running:"text-brand",queued:"text-muted-foreground",error:"text-red-9",failed:"text-red-9"};function o({cwd:a,sessionId:b,runId:c,isRunning:d,onClose:l}){let{t:q}=(0,g.Bd)(),[r,s]=(0,f.useState)(null),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(null),x=(0,f.useRef)(void 0),y=d||null!=r&&"completed"!==r.status&&"failed"!==r.status;(0,f.useCallback)(async()=>{let d=await i.t4.runPromiseExit((0,j.z)({cwd:a,sessionId:b,workflowId:c,ifFingerprint:x.current}));if(u(!0),"Success"!==d._tag||!d.value)return;let e=d.value;e.fingerprint&&(x.current=e.fingerprint),!e.notModified&&e.workflow&&s(e.workflow)},[a,b,c]);let z=[];if(r?.agents){let a=new Map;for(let b of r.agents){let c=b.phaseTitle||q("chat.workflowUngrouped");a.has(c)||a.set(c,[]),a.get(c).push(b)}for(let[b,c]of a)z.push({title:b,agents:c})}let A=r?[r.workflowName,r.status,`${r.agentCount??r.agents?.length??0} ${q("chat.workflowAgents")}`,`${m(r.totalTokens)} tok`,n(r.durationMs)].filter(Boolean).join(" \xb7 "):"";return(0,e.jsxs)(h.ZL,{children:[(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:l,children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsx)("span",{className:"text-base",children:"\uD83E\uDDE9"}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:q("chat.workflowRun")}),A&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:A,children:A}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[y&&(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,e.jsx)("button",{onClick:l,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:q("common.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:null===r?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:q(t?"chat.workflowEmpty":"common.loading")}):(0,e.jsxs)(e.Fragment,{children:[r.summary&&(0,e.jsx)("div",{className:"mb-3 text-xs text-muted-foreground whitespace-pre-wrap",children:r.summary}),z.map(a=>(0,e.jsxs)(f.Fragment,{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-foreground/80 mt-3 mb-1 sticky top-0 bg-card py-1",children:a.title}),a.agents.map(a=>(0,e.jsx)(p,{agent:a,onOpen:()=>a.agentId&&w({runId:c,agentId:a.agentId,label:a.label,running:"done"!==a.state&&y})},`${a.index}-${a.agentId}`))]},a.title))]})})]})}),v&&(0,e.jsx)(k.f,{cwd:a,sessionId:b,workflowRef:v,onClose:()=>w(null)})]})}function p({agent:a,onOpen:b}){let{t:c}=(0,g.Bd)(),[d,h]=(0,f.useState)(!1),i=a.state&&q[a.state]||"text-muted-foreground",j=a.resultPreview||a.promptPreview||"";return(0,e.jsxs)("div",{className:"border border-border rounded-md mb-1 bg-secondary/50",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,e.jsx)("button",{onClick:()=>h(a=>!a),className:"text-slate-9 text-xs flex-shrink-0",title:c(d?"chat.collapse":"chat.expand"),children:d?"▲":"▼"}),(0,e.jsx)("span",{className:"text-xs text-foreground truncate flex-1 min-w-0",title:a.label||"",children:a.label||a.agentId}),(0,e.jsx)("span",{className:`text-[10px] flex-shrink-0 ${i}`,children:a.state}),(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[m(a.tokens)," tok \xb7 ",n(a.durationMs)]}),a.agentId&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:b,onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&b()},className:"text-xs text-brand hover:text-teal-10 cursor-pointer flex-shrink-0",title:c("chat.subagentViewTitle"),children:c("chat.workflowViewAgent")})]}),d&&j&&(0,e.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:j})]})}d()}catch(a){d(a)}})},93448:(a,b,c)=>{"use strict";c.d(b,{TabManagerTopBar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call TabManagerTopBar() from the server but TabManagerTopBar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/TabManagerTopBar.tsx","TabManagerTopBar")},94192:(a,b,c)=>{"use strict";c.d(b,{R8:()=>i,c0:()=>k,fY:()=>j,gT:()=>l});var d=c(48249),e=c(67484);let f=["agent","explorer","console"],g={agent:"AGENT",explorer:"EXPLORER",console:"CONSOLE"},h=(0,e.createContext)(null);function i(){let a=(0,e.useContext)(h);if(!a)throw Error("useSwipeContext must be used within SwipeableViewContainer");return a}function j({activeView:a,onViewChange:b,children:c}){(0,e.useRef)(null),(0,e.useRef)(!1),(0,e.useRef)(0);let[g,i]=(0,e.useState)(0),[k,l]=(0,e.useState)(!1);f.indexOf(a),f.length;let[m,n]=(0,e.useState)(!1),o={activeView:a,onViewChange:b,dragOffset:(()=>{if(!m)return 0;let a=window.innerWidth;return a?g/a:0})(),isDragging:m&&k};return(0,d.jsx)(h.Provider,{value:o,children:c})}function k({children:a}){let b,c,{activeView:g,dragOffset:h,isDragging:j}=i(),l=(0,e.useRef)(null),m=(0,e.useRef)(null),n=f.indexOf(g),o=f.length;return(0,d.jsx)("div",{ref:l,className:"flex-1 overflow-hidden relative",style:{overscrollBehaviorX:"none"},children:(0,d.jsx)("div",{ref:m,className:j?"flex":"flex transition-transform duration-100 ease-out",style:{position:"absolute",top:"0px",bottom:"0px",left:"0px",width:`${100*f.length}%`,transform:(b=h/o*100,c=-(100/o*n)+(Number.isFinite(b)?b:0),`translateX(${c}%)`)},children:a})})}function l(){let{activeView:a,onViewChange:b,dragOffset:c,isDragging:h}=i(),j=(0,e.useRef)(null),k=(0,e.useRef)([]),[l,m]=(0,e.useState)({left:0,width:0}),n=f.indexOf(a),o=Number.isFinite(c)?c:0,p=Math.round(Math.max(0,Math.min(f.length-1,n-o)));return(0,d.jsxs)("div",{ref:j,className:"relative flex gap-4",children:[f.map((a,c)=>(0,d.jsx)("button",{ref:a=>{k.current[c]=a},onClick:()=>b(a),className:`px-4 py-1 text-sm font-medium transition-colors ${p===c?"text-brand":"text-muted-foreground hover:text-foreground"}`,children:g[a]},a)),(0,d.jsx)("div",{className:`absolute bottom-0 h-0.5 bg-brand ${h?"":"transition-all duration-100 ease-out"}`,style:{left:l.left,width:l.width}})]})}},94239:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{c:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(61591),i=c(44256);function j({path:a,matchedIndices:b}){let c=(0,f.useMemo)(()=>new Set(b),[b]),d=a.lastIndexOf("/"),g=d>=0?a.slice(0,d+1):"",h=d>=0?a.slice(d+1):a,i=(a,b,d)=>{let f=[],g="",h=!1;for(let d=0;d<a.length;d++){let i=b+d,j=c.has(i);j!==h&&g&&(f.push(h?(0,e.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-${d}`):(0,e.jsx)("span",{children:g},`${b}-${d}`)),g=""),h=j,g+=a[d]}return g&&f.push(h?(0,e.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-end`):(0,e.jsx)("span",{children:g},`${b}-end`)),(0,e.jsx)("span",{className:d,children:f})};return(0,e.jsxs)("span",{className:"truncate",children:[g&&i(g,0,"text-muted-foreground"),i(h,g.length,"text-foreground")]})}function k({files:a,fileIndex:b,recentFiles:c,onSelectFile:d,onClose:l}){let{t:m}=(0,g.Bd)(),[n,o]=(0,f.useState)(""),[p,q]=(0,f.useState)(0),r=(0,f.useRef)(null),s=(0,f.useRef)(null),t=(0,f.useMemo)(()=>{let c,d;return b??(c=[],(d=a=>{for(let b of a)b.isDirectory&&b.children?d(b.children):b.isDirectory||c.push(b.path)})(a),c)},[b,a]),u=(0,f.useMemo)(()=>{if(!n.trim()){let a=new Set(c),b=c.map(a=>({path:a,score:0,matchedIndices:[]})),d=t.filter(b=>!a.has(b)).slice(0,50).map(a=>({path:a,score:0,matchedIndices:[]}));return[...b,...d]}let a=[];for(let b of t){let d=function(a,b){let c=a.toLowerCase(),d=b.toLowerCase(),e=[],f=0,g=0,h=-1;for(let i=0;i<c.length&&f<d.length;i++)if(c[i]===d[f]){e.push(i),h===i-1&&(g+=5),(0===i||"/"===a[i-1]||"."===a[i-1]||"-"===a[i-1]||"_"===a[i-1])&&(g+=10);let c=a.lastIndexOf("/");i>c&&(g+=3),a[i]===b[f]&&(g+=1),h=i,f++}return f<d.length?null:(g-=.1*a.length,{path:a,score:g,matchedIndices:e})}(b,n.trim());d&&(c.includes(b)&&(d.score+=20),a.push(d))}return a.sort((a,b)=>b.score-a.score),a.slice(0,50)},[n,t,c]),v=(0,f.useCallback)(a=>{o(a),q(0)},[]),w=(0,f.useCallback)(a=>{d(a),l()},[d,l]),x=(0,f.useCallback)(a=>{if(!a.nativeEvent.isComposing)switch(a.key){case"ArrowDown":a.preventDefault(),q(a=>Math.min(a+1,u.length-1));break;case"ArrowUp":a.preventDefault(),q(a=>Math.max(a-1,0));break;case"Enter":a.preventDefault(),u[p]&&w(u[p].path);break;case"Escape":a.preventDefault(),l()}},[u,p,w,l]);return(0,e.jsx)(i.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-start justify-center pt-[15vh]",onClick:l,children:(0,e.jsxs)("div",{className:"w-[680px] max-h-[60vh] bg-card border border-border rounded-lg shadow-2xl overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,e.jsx)("input",{ref:r,value:n,onChange:a=>v(a.target.value),onKeyDown:x,placeholder:m("quickFileOpen.placeholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",autoCorrect:"off",spellCheck:"false"}),(0,e.jsx)("kbd",{className:"text-[10px] text-muted-foreground px-1.5 py-0.5 rounded border border-border bg-secondary",children:"ESC"})]}),(0,e.jsx)("div",{ref:s,className:"flex-1 overflow-y-auto py-1",children:0===u.length?(0,e.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:m("quickFileOpen.noMatch")}):u.map((a,b)=>(0,e.jsxs)("div",{className:`px-3 py-1.5 flex items-center gap-2 cursor-pointer transition-colors ${b===p?"bg-brand/15 text-foreground":"hover:bg-accent text-foreground"}`,"data-tooltip":a.path,onClick:()=>w(a.path),children:[(0,e.jsx)(h.o,{name:a.path.split("/").pop()||"",className:"w-4 h-4 flex-shrink-0"}),(0,e.jsx)(j,{path:a.path,matchedIndices:a.matchedIndices}),!n.trim()&&c.includes(a.path)&&(0,e.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground px-1.5 py-0.5 rounded bg-secondary flex-shrink-0",children:m("quickFileOpen.recent")})]},a.path))}),(0,e.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex items-center gap-3 text-[10px] text-muted-foreground",children:[(0,e.jsxs)("span",{className:"flex items-center gap-1",children:[(0,e.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"↑↓"})," ",m("quickFileOpen.selectHint")]}),(0,e.jsxs)("span",{className:"flex items-center gap-1",children:[(0,e.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Enter"})," ",m("quickFileOpen.openHint")]}),(0,e.jsxs)("span",{className:"flex items-center gap-1",children:[(0,e.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Esc"})," ",m("quickFileOpen.closeHint")]})]})]})})})}d()}catch(a){d(a)}})},94308:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({branches:a,selectedBranch:b,onSelect:c,isLoading:h,pinnedBranches:i=[]}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),o=(0,e.useRef)(null),p=(0,e.useRef)(null),q=m.toLowerCase(),r=new Set([...a?.local||[],...a?.remote||[]]),s=i.filter(a=>r.has(a)&&a.toLowerCase().includes(q)),t=new Set(s),u=a?.local.filter(a=>!t.has(a)&&a.toLowerCase().includes(q))||[],v=a?.remote.filter(a=>!t.has(a)&&a.toLowerCase().includes(q))||[],w=a=>{c(a),l(!1),n("")};return(0,d.jsxs)("div",{className:"relative",ref:o,children:[(0,d.jsxs)("button",{onClick:()=>l(!k),disabled:h,className:"w-full px-3 py-1.5 text-sm border border-border rounded bg-card text-foreground text-left flex items-center justify-between hover:border-slate-6 dark:hover:border-slate-6 transition-colors",children:[(0,d.jsxs)("span",{className:"truncate flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),b||j("git.selectBranch"),a?.current===b&&(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["(",j("git.currentBranch"),")"]})]}),(0,d.jsx)("svg",{className:`w-4 h-4 text-slate-9 transition-transform ${k?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),k&&(0,d.jsxs)("div",{className:"absolute z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lg max-h-80 flex flex-col",children:[(0,d.jsx)("div",{className:"p-2 border-b border-border",children:(0,d.jsx)("input",{ref:p,type:"text",value:m,onChange:a=>n(a.target.value),placeholder:j("git.searchBranch"),className:"w-full px-2 py-1 text-sm border border-border rounded bg-secondary text-foreground placeholder-slate-9"})}),(0,d.jsxs)("div",{className:"overflow-y-auto flex-1",children:[s.length>0&&s.map(c=>(0,d.jsxs)("div",{onClick:()=>w(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:j("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},`pinned-${c}`)),u.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:j("git.localBranches")}),u.map(c=>(0,d.jsxs)("div",{onClick:()=>w(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:j("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},c))]}),v.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:j("git.remoteBranches")}),v.map(a=>(0,d.jsxs)("div",{onClick:()=>w(a),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${a===b?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:a}),a===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},a))]}),0===s.length&&0===u.length&&0===v.length&&(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:j("git.noMatchingBranches")})]})]})]})}},95388:(a,b,c)=>{"use strict";c.d(b,{V:()=>h});var d=c(48249),e=c(67484),f=c(74429),g=c(44384);function h({open:a,anchorRef:b,initialValue:c,onCancel:i,onSave:j}){let{t:k}=(0,g.Bd)(),[l,m]=(0,e.useState)(c),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(null),r=(0,e.useRef)(null),s=(0,e.useRef)(null);if((0,e.useCallback)(()=>{let a=b.current;if(!a)return;let c=a.getBoundingClientRect(),d=s.current?.offsetHeight??0,e=c.bottom+4;if(d&&e+d>window.innerHeight-8){let a=c.top-4-d;a>=8&&(e=a)}let f=c.left;q({top:e,left:f=Math.max(f=Math.min(f,window.innerWidth-260-8),8)})},[b]),!a||"u"<typeof document)return null;let t=async()=>{if(!n){o(!0);try{await j(l.trim())}finally{o(!1)}}};return(0,f.createPortal)((0,d.jsxs)("div",{ref:s,style:{top:p?.top??0,left:p?.left??0,width:260,visibility:p?"visible":"hidden"},className:"fixed z-[100] rounded-lg border border-border bg-card p-3 shadow-xl",children:[(0,d.jsx)("div",{className:"mb-2 text-sm font-medium text-foreground",children:k("shortIdBadge.dialogTitle")}),(0,d.jsx)("input",{ref:r,type:"text",value:l,onChange:a=>m(a.target.value.slice(0,64)),onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||229===a.keyCode||(a.preventDefault(),t())},placeholder:k("shortIdBadge.dialogPlaceholder"),maxLength:64,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm font-mono outline-none focus:border-brand"}),(0,d.jsxs)("div",{className:"mt-3 flex justify-end gap-2 text-sm",children:[(0,d.jsx)("button",{onClick:i,className:"rounded px-3 py-1 text-muted-foreground hover:bg-accent",disabled:n,children:k("common.cancel")}),(0,d.jsx)("button",{onClick:()=>void t(),className:"rounded bg-brand px-3 py-1 text-white hover:opacity-90 disabled:opacity-50",disabled:n,children:n?"…":k("common.save")})]})]}),document.body)}},95401:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{m:()=>j});var e=c(48249),f=c(67484),g=c(44256),h=c(33281),i=c(41224);function j({currentModel:a,onModelChange:b}){let[c,d]=(0,f.useState)(!1),[k,l]=(0,f.useState)([]),[m,n]=(0,f.useState)(!1),[o,p]=(0,f.useState)(null),[q,r]=(0,f.useState)(!1),s=(0,f.useRef)(null),t=(0,f.useRef)(null),[u,v]=(0,f.useState)({top:0,left:0}),w=(0,g.F2)(),x=(0,f.useCallback)(async()=>{n(!0),p(null);let a=await h.t4.runPromiseExit((0,i.qD)(()=>r(!0)));if(r(!1),"Failure"===a._tag)p("Connection error");else{let b=a.value;switch(b._tag){case"ok":l(b.models);break;case"not-installed":case"error":p(b.message);break;case"not-running":p("Ollama is not running")}}n(!1)},[]),y=a?a.replace(/:latest$/,""):"Select model",z=c?(0,e.jsx)(g.ZL,{children:(0,e.jsx)("div",{ref:t,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-1 min-w-[200px] max-h-[300px] overflow-y-auto",style:{top:u.top,left:u.left},children:m||q?(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),q?"Starting Ollama...":"Loading models..."]}):o?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-red-400",children:o}):0===k.length?(0,e.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models found. Run ",(0,e.jsx)("code",{className:"bg-secondary px-1 rounded",children:"ollama pull <model>"})]}):k.map(c=>{var f;return(0,e.jsxs)("button",{onClick:()=>{var a;return a=c.name,void(b(a),d(!1))},className:`w-full flex items-center justify-between gap-2 px-3 py-1.5 text-xs hover:bg-brand/10 transition-colors ${c.name===a?"text-brand":"text-foreground"}`,children:[(0,e.jsx)("span",{className:"truncate",children:c.name.replace(/:latest$/,"")}),(0,e.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:c.parameter_size||((f=c.size)<1e9?`${(f/1e6).toFixed(0)}M`:`${(f/1e9).toFixed(1)}G`)})]},c.name)})})}):null;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{ref:s,onClick:()=>{if(!c){if(s.current){let a=s.current.getBoundingClientRect(),b=w?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;v({top:a.bottom+4-d,left:a.left-c})}x()}d(a=>!a)},className:"flex items-center gap-1 px-2 py-0.5 text-[11px] rounded bg-violet-500/15 text-violet-400 hover:bg-violet-500/25 transition-colors",title:"Switch Ollama model",children:[(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-violet-500 flex-shrink-0"}),(0,e.jsx)("span",{className:"truncate max-w-[120px]",children:y}),(0,e.jsx)("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),z]})}d()}catch(a){d(a)}})},96487:()=>{},97572:(a,b,c)=>{"use strict";c.d(b,{g:()=>g,v:()=>f});var d=c(79606),e=c(71192);let f=d.tryPromise({try:async()=>{let a=await fetch("/api/projects");if(!a.ok)throw Error(`HTTP ${a.status}`);return await a.json()},catch:a=>new e.uV({message:"fetch /api/projects failed",cause:a})}),g=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/projects",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"save /api/projects failed",cause:a})})},97951:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e:()=>j});var e=c(67484),f=c(19872),g=c(208),h=c(29939),i=c(47818);function j(a,b,{sessionId:c,cwd:d,engine:k,chatMode:l,planMode:m,ollamaModel:n,deepseekModel:o,onSessionId:p,onFetchTitle:q,onPtyOutput:r,onRunComplete:s}){let[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),[x,y]=(0,e.useState)(null),[z,A]=(0,e.useState)(null),[B,C]=(0,e.useState)(null),D=(0,e.useRef)(null),[E,F]=(0,e.useState)(null),G=(0,e.useRef)(E);G.current=E;let H=(0,e.useRef)(s);H.current=s;let I=(0,e.useRef)(!1),J=(0,e.useRef)(null),K=(0,e.useRef)(c);K.current=c;let L=(0,e.useRef)(null),M=(0,e.useRef)(null),N=(0,e.useRef)(null),O=(0,e.useRef)(!1),P=(0,e.useRef)(!1),Q=(0,e.useRef)(0),R=(0,e.useCallback)(()=>{let a=L.current;if(a&&a.text){let{messageId:c,text:d}=a;b(a=>(0,f.F)(a,{type:"stream_event",event:{type:"content_block_delta",delta:{type:"text_delta",text:d}}},{engine:k,assistantId:c})),L.current={messageId:c,text:""}}M.current=null},[b,k]),S=(0,e.useCallback)(()=>{M.current&&(clearTimeout(M.current),M.current=null),J.current&&(clearTimeout(J.current),J.current=null),R(),u(!1);let a=G.current,c=N.current;a&&b(b=>b.map(b=>b.id===a.assistantId||b.id===c?{...b,isStreaming:!1}:b)),F(null),H.current?.()},[R,b]),T=(0,e.useCallback)(()=>{let a=G.current;fetch("/api/chat/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:K.current,runId:a?.runKey})}).catch(()=>{}),S()},[S]),U=(0,e.useCallback)((a,c)=>{let e=a.type;if("pty_output"===e)return void r?.(a.data);if("pty_notice"===e){let d=a.messageKey?g.A.t(a.messageKey,a.params||{}):a.message;if(!d)return;a.terminal?b(a=>a.map(a=>a.id===c?{...a,content:d,isStreaming:!1}:a)):C(d);return}if("system"===e&&"init"===a.subtype){let c=a.session_id;if(p(c),K.current=c,A(null),O.current){let a=`auto-asst-${++Q.current}`;N.current=a,b(b=>[...b,{id:a,role:"assistant",content:"",toolCalls:[],isStreaming:!0,runKey:G.current?.runKey}])}P.current=!0;return}if("system"===e&&"task_notification"===a.subtype){if(!P.current){let c=a.status,d=a.summary||"",e=a.task_id,f=`<task-notification>
|
|
42
42
|
`+(e?`<task-id>${e}</task-id>
|
|
43
43
|
`:"")+(c?`<status>${c}</status>
|
|
44
44
|
`:"")+(d?`<summary>${d}</summary>
|
|
45
45
|
`:"")+(a.output_file?`<output-file>${a.output_file}</output-file>
|
|
46
|
-
`:"")+"</task-notification>",g=`auto-tasknotif-${e||++
|
|
46
|
+
`:"")+"</task-notification>",g=`auto-tasknotif-${e||++Q.current}`;b(a=>[...a,{id:g,role:"system",content:d,systemEvent:{kind:"task-notification",...c?{status:c}:{},detail:f},runKey:G.current?.runKey}])}return}if("system"===e&&"api_retry"===a.subtype)return void A({attempt:a.attempt??0,maxRetries:a.max_retries??0,delayMs:a.retry_delay_ms??0,errorStatus:a.error_status,error:a.error});if("rate_limit_event"===e){let b=a.rate_limit_info;b&&y({status:b.status||"allowed",resetsAt:b.resetsAt,rateLimitType:b.rateLimitType,utilization:b.utilization,overageStatus:b.overageStatus,overageDisabledReason:b.overageDisabledReason,isUsingOverage:b.isUsingOverage,surpassedThreshold:b.surpassedThreshold});return}if("error"===e){let d=a.error||g.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});A(null),M.current&&(clearTimeout(M.current),M.current=null),R(),b(a=>a.map(a=>a.id===c?{...a,content:a.content?`${a.content}
|
|
47
47
|
|
|
48
|
-
⚠️ ${d}`:`⚠️ ${d}`,isStreaming:!1}:a));return}if("stream_event"===e){z(a=>a?null:a),B(a=>a?null:a);let b=a.event;if(b?.type==="content_block_delta"&&b.delta?.type==="text_delta"){let a=b.delta.text||"";J.current&&J.current.messageId===c?J.current.text+=a:J.current={messageId:c,text:a},K.current||(K.current=setTimeout(P,50))}return}if("assistant"===e&&b(b=>(0,f.F)(b,a,{engine:k,assistantId:c})),"user"===e&&b(b=>(0,f.F)(b,a,{engine:k,assistantId:c})),"result"===e){N.current=!1,M.current=!0,z(null),K.current&&(clearTimeout(K.current),K.current=null),P();let e=I.current;e&&d&&b(a=>(2===a.length&&q(e),a));let g=a.usage,h=a.total_cost_usd;g&&v({inputTokens:g.input_tokens||0,outputTokens:g.output_tokens||0,cacheCreationInputTokens:g.cache_creation_input_tokens||0,cacheReadInputTokens:g.cache_read_input_tokens||0,totalCostUsd:h||0}),b(b=>(0,f.F)(b,a,{engine:k,assistantId:c}))}},[b,P,p,q,d,k,r]);(0,h.h)({url:D?`/ws/session-stream?sessionId=${encodeURIComponent(D.runKey)}`:"/ws/session-stream",enabled:!!D,onMessage:a=>{G.current=!0,H.current&&(clearTimeout(H.current),H.current=null);let c=F.current;if(c)if("run-snapshot"===a.type&&Array.isArray(a.events)){for(let d of(K.current&&(clearTimeout(K.current),K.current=null),J.current=null,L.current=c.assistantId,M.current=!1,N.current=!1,b(a=>a.filter(a=>!("string"==typeof a.id&&a.id.startsWith("auto-"))).map(a=>a.id===c.assistantId?{...a,content:"",toolCalls:[]}:a)),a.events))S(d,L.current??c.assistantId);a.status&&"running"!==a.status&&Q()}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type)return void Q();S(a.message,L.current??c.assistantId)}else"run-idle"===a.type&&Q()}});let T=(0,e.useCallback)(async(a,c,e)=>{let f=e&&"permissionMode"in e?"plan"===e.permissionMode:m,h=c?.map(a=>({type:"base64",media_type:a.media_type,data:a.data})),j={id:`user-${Date.now()}`,role:"user",content:a,images:h};b(a=>[...a,j]),t(!0),z(null),B(null);let p=`assistant-${Date.now()}`,q={id:p,role:"assistant",content:"",toolCalls:[],isStreaming:!0};b(a=>[...a,q]),L.current=p,M.current=!1,N.current=!1;let r=!k||"claude"===k||"claude2"===k,s="pty"===l&&r,u=function(){try{return crypto.randomUUID()}catch{return`run-${Date.now()}-${Math.floor(1e9*Math.random())}`}}();try{if("ollama"===k&&!n)throw Error("Please select an Ollama model first (click the model picker above)");let c="codex"===k?"/api/chat/codex":"kimi"===k?"/api/chat/kimi":"ollama"===k?"/api/chat/ollama":"deepseek"===k?"/api/chat/deepseek":"/api/chat",e=await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a,sessionId:I.current,runId:u,images:h,cwd:d,language:g.A.language,..."ollama"===k&&n&&{model:n},..."deepseek"===k&&o&&{model:o},..."claude2"===k&&{engine:"claude2"},...s&&{mode:"pty",ptyCols:i.EE,ptyRows:i.K2},...f&&!s&&r&&{permissionMode:"plan"}})});if(400===e.status&&"deepseek"===k){let a=await e.json().catch(()=>null);throw Error(a?.error||"DeepSeek request failed")}if(!e.ok)throw Error(g.A.t("chat.requestFailed",{defaultValue:"Request failed"}));let j=await e.json().catch(()=>({}));E({runKey:j.runKey||u,assistantId:p}),G.current=!1,H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{F.current&&!G.current&&(b(a=>a.map(a=>a.id!==p||a.content?a:{...a,content:g.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."})})),Q())},15e3)}catch(c){console.error("Chat error:",c);let a=c instanceof Error?c.message:g.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});b(b=>b.map(b=>b.id===p?{...b,content:a,isStreaming:!1}:b)),t(!1),E(null)}},[d,k,l,m,n,o,b,Q]);return{isLoading:s,tokenUsage:u,rateLimitInfo:w,apiRetryInfo:y,ptyNotice:A,handleSend:T,handleStop:R,abortControllerRef:C}}d()}catch(a){d(a)}})},98356:(a,b,c)=>{"use strict";c.d(b,{T:()=>B});var d=c(48249),e=c(98051),f=c(38368),g=c(33972),h=c(10841),i=c(99773),j=c(36513);c(55583),c(87023);var k=c(50757),l=c(27454),m=c(37752),n=c(67484),o=c(83768),p=c(15466),q=c(49216);function r(a){return{type:"tableCell",children:[{type:"text",value:a}]}}let s=[c(4014).A,function(){return a=>{let b=a.children;for(let a=0;a<b.length;a++){let c=b[a];if("yaml"!==c.type)continue;let d=null;try{let a=q.Ay.load(c.value??"");a&&"object"==typeof a&&!Array.isArray(a)&&(d=a)}catch{d=null}let e=d?Object.entries(d):[];if(0===e.length){b.splice(a,1),a--;continue}let f={type:"tableRow",children:[r("Field"),r("Value")]},g=e.map(([a,b])=>({type:"tableRow",children:[r(a),r(function(a){if(null==a)return"";if("string"==typeof a)return a.replace(/\s*\n\s*/g," ").trim();if("number"==typeof a||"boolean"==typeof a)return String(a);try{return JSON.stringify(a)}catch{return String(a)}}(b))]}));b[a]={type:"table",align:["left","left"],children:[f,...g]}}}}],t=[...s,f.A,g.A,h.jb],u=[...s,f.A,h.jb],v=[i.A,j.A],w=[i.A];function x(a){let b=[],c=a=>(b.push(a),` MASK${b.length-1} `);return a.replace(/```[\s\S]*?```/g,a=>c(a)).replace(/~~~[\s\S]*?~~~/g,a=>c(a)).replace(/^(\|.+\|)$/gm,a=>/^\|[\s:|-]+\|$/.test(a)?a:a.replace(/`([^`]*)`/g,(a,b)=>b.includes("|")?"`"+b.replace(/\|/g,"\\|")+"`":a)).replace(/ MASK(\d+) /g,(a,c)=>b[+c])}function y(a){return a.replace(/\$(\d)/g,"\\$$1")}let z=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 A(a){let b=[],c=a=>(b.push(a),`\0MASK${b.length-1}\0`);return a.replace(/```[\s\S]*?```/g,a=>c(a)).replace(/~~~[\s\S]*?~~~/g,a=>c(a)).replace(/`[^`\n]+`/g,a=>c(a)).replace(/<\/?([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(a,b)=>{let c=b.toLowerCase();return z.has(c)||c.includes("-")?a:a.replace(/</g,"<").replace(/>/g,">")}).replace(/MASK(\d+)/g,(a,c)=>b[+c])}let B=(0,n.memo)(function({content:a,isUser:b=!1,isStreaming:c=!1,enableMath:f=!0,rehypePlugins:g,onLinkClick:h}){let{resolvedTheme:i}=(0,o.D)(),j="dark"===i,q=(0,n.useRef)(null),r=(0,n.useMemo)(()=>({code({className:a,children:b,node:c,...e}){let f=/language-(\w+)/.exec(a||"");if(!("string"==typeof b||"number"==typeof b||Array.isArray(b)&&b.every(a=>"string"==typeof a||"number"==typeof a)))return(0,d.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent text-sm font-mono",...e,children:b});let g=String(b);if(!f&&!a&&!g.includes("\n"))return(0,d.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent text-sm font-mono",...e,children:b});let h=g.replace(/\n$/,""),i=f?.[1]||"text",n=Number(e["data-source-start"])||0,o=n?n+1:0,p=0;return(0,d.jsx)(k.A,{style:j?l.A:m.A,language:i,PreTag:"div",customStyle:{margin:"0.75rem 0",borderRadius:"0.375rem",fontSize:"0.875rem"},wrapLines:!0,lineProps:()=>{let a=o+p;return p++,{"data-source-start":a,"data-source-end":a,style:{display:"block"}}},children:h})},p:({children:a,node:b,...c})=>(0,d.jsx)("p",{className:"mb-3 last:mb-0",...c,children:a}),h1:({children:a,node:b,...c})=>(0,d.jsx)("h1",{className:"text-xl font-bold mb-3 mt-4 first:mt-0",...c,children:a}),h2:({children:a,node:b,...c})=>(0,d.jsx)("h2",{className:"text-lg font-bold mb-2 mt-3 first:mt-0",...c,children:a}),h3:({children:a,node:b,...c})=>(0,d.jsx)("h3",{className:"text-base font-bold mb-2 mt-3 first:mt-0",...c,children:a}),ul:({children:a,node:b,...c})=>(0,d.jsx)("ul",{className:"list-disc list-inside mb-3 space-y-1",...c,children:a}),ol:({children:a,node:b,...c})=>(0,d.jsx)("ol",{className:"list-decimal list-inside mb-3 space-y-1",...c,children:a}),li:({children:a,node:b,...c})=>(0,d.jsx)("li",{className:"leading-relaxed",...c,children:a}),blockquote:({children:a,node:b,...c})=>(0,d.jsx)("blockquote",{className:"border-l-4 border-border pl-4 my-3 italic text-muted-foreground",...c,children:a}),a:({href:a,children:b,node:c,...e})=>(0,d.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-brand hover:underline",...e,onClick:b=>{if(a){if(a.startsWith("#")){(0,p.O)(q.current,a.slice(1))&&b.preventDefault();return}h?.(a)&&b.preventDefault()}},children:b}),table:({children:a,node:b,...c})=>(0,d.jsx)("div",{className:"overflow-x-auto my-3",...c,children:(0,d.jsx)("table",{className:"min-w-full border border-border",children:a})}),thead:({children:a,node:b,...c})=>(0,d.jsx)("thead",{className:"bg-accent",...c,children:a}),th:({children:a,node:b,...c})=>(0,d.jsx)("th",{className:"px-4 py-2 text-left font-semibold border-b border-border",...c,children:a}),td:({children:a,node:b,...c})=>(0,d.jsx)("td",{className:"px-4 py-2 border-b border-border",...c,children:a}),hr:({node:a,...b})=>(0,d.jsx)("hr",{className:"my-4 border-border",...b}),img:({src:a,alt:b,node:c,height:e,width:f,style:g,...h})=>{if(!(e||f||g))return(0,d.jsx)("img",{src:a,alt:b||"",className:"max-w-full h-auto rounded-lg my-3",...h});let i=a=>a?/^\d+$/.test(String(a))?`${a}px`:String(a):void 0,j={...g,height:i(e)??g?.height,width:i(f)??g?.width};return(0,d.jsx)("img",{src:a,alt:b||"",style:j,className:"inline-block align-middle",...h})},strong:({children:a,node:b,...c})=>(0,d.jsx)("strong",{className:"font-bold",...c,children:a}),em:({children:a,node:b,...c})=>(0,d.jsx)("em",{className:"italic",...c,children:a}),del:({children:a,node:b,...c})=>(0,d.jsx)("del",{className:"line-through",...c,children:a})}),[j,h]),s=f?t:u,z=f?v:w,B=(0,n.useMemo)(()=>{if(b||c)return A(a);let d=A(x(!function(a){if(/^\|[\s:|-]+\|$/m.test(a))return!1;if(/[┌┐└┘│─├┤┬┴┼╔╗╚╝║═╭╮╯╰▲▼◀▶△▽◁▷]/.test(a)||/\+[-=]{2,}\+/.test(a))return!0;let b=a.split("\n").filter(a=>/^\s*\||\|\s*$/.test(a));if(b.length>=3){let a=b.map(a=>(a.match(/\|/g)||[]).length);return!a.every(b=>b===a[0])||!(a[0]>=3)}return!1}(a)||/^```[\s\S]*```$/m.test(a.trim())?a:"```text\n"+a.trim()+"\n```"));return f?y(d):d},[a,b,c,f]),C=(0,n.useMemo)(()=>g?.length?[...z,...g]:z,[g,z]);if(b)return(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words",children:a});if(c){let b=a.lastIndexOf("\n");if(-1===b)return(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words",children:a});let c=a.slice(0,b+1),g=a.slice(b+1);return(0,d.jsxs)("div",{className:"markdown-body",ref:q,children:[(0,d.jsx)(e.oz,{remarkPlugins:s,rehypePlugins:z,components:r,children:f?y(A(x(c))):A(x(c))}),g&&(0,d.jsx)("span",{className:"whitespace-pre-wrap",children:g})]})}return(0,d.jsx)("div",{className:"markdown-body",ref:q,children:(0,d.jsx)(e.oz,{remarkPlugins:s,rehypePlugins:C,components:r,children:B})})})},98420:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{V:()=>q});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(36295),j=c(33988),k=c(30894),l=c(28602),m=c(74493),n=c(15105),o=a([i,k]);async function p(a){let b=(0,n.f)()?.id??null;return!!b&&new Promise(c=>{try{let d=globalThis.chrome?.runtime;if(!d?.sendMessage)return void c(!1);let e=setTimeout(()=>c(!1),2e3);d.sendMessage(b,{type:"prepare-iframe",url:a},a=>{clearTimeout(e),c(a?.ok??!1)})}catch{c(!1)}})}function q({url:a,id:b,selected:c,maximized:d,expandedHeight:n,bubbleContentHeight:o,onSelect:r,onClose:s,onToggleMaximize:t,onNewTab:u,timestamp:v,onTitleMouseDown:w,initialSleeping:x,onSleep:y,onWake:z,projectCwd:A,tabId:B}){let{t:C}=(0,g.Bd)(),[D,E]=(0,f.useState)(!1),[F,G]=(0,f.useState)(null),[H,I]=(0,f.useState)(a),[J,K]=(0,f.useState)(null),[L,M]=(0,f.useState)(x??!1),N=(0,f.useRef)(null),O=(0,f.useRef)(null),P=(0,f.useRef)(null);(0,f.useRef)(!0),(0,f.useCallback)(()=>{L||(M(!0),K(null),y?.(b))},[L,b,y]),(0,f.useCallback)(()=>{N.current&&(clearTimeout(N.current),N.current=null)},[]);let Q=!!J&&!L&&!D,{shortId:R,connected:S,connect:T,disconnect:U}=(0,j.B)(b,P,Q,A,B);(0,f.useRef)(S).current=S;let V=(0,f.useCallback)(()=>{M(!1),z?.(b);let c=function(a){if(!a)return a;try{let b=new URL(a);return b.searchParams.set("_cockpit","1"),b.toString()}catch{let b=a.includes("?")?"&":"?";return`${a}${b}_cockpit=1`}}(a);!function(a){try{let b=new URL(a).hostname;return"localhost"===b||"127.0.0.1"===b}catch{return!1}}(a)?p(a).then(()=>K(c)):K(c)},[a,b,z]),W=(0,f.useCallback)(()=>E(!1),[]),X=(0,f.useCallback)(()=>{E(!1),G(C("browser.pageLoadFailed"))},[]),Y=(0,f.useCallback)(()=>{if(L)return void V();let a=O.current?.querySelector("iframe");if(a&&J){E(!0),G(null);let b=a.src;a.src="",setTimeout(()=>{a.src=b},0)}},[L,V,J]),Z=(0,f.useCallback)(()=>{H&&window.open(H,"_blank")},[H]),$=function(a){if(!a)return"";try{let b=new URL(a);return b.port?`${b.hostname}:${b.port}`:b.hostname}catch{return a}}(H),_=d&&n?n-41:o??i.p;return(0,e.jsx)("div",{className:"flex flex-col items-start",children:(0,e.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
48
|
+
⚠️ ${d}`:`⚠️ ${d}`,isStreaming:!1}:a));return}if("stream_event"===e){A(a=>a?null:a),C(a=>a?null:a);let b=a.event;if(b?.type==="content_block_delta"&&b.delta?.type==="text_delta"){let a=b.delta.text||"";L.current&&L.current.messageId===c?L.current.text+=a:L.current={messageId:c,text:a},M.current||(M.current=setTimeout(R,50))}return}if("assistant"===e&&b(b=>(0,f.F)(b,a,{engine:k,assistantId:c})),"user"===e&&b(b=>(0,f.F)(b,a,{engine:k,assistantId:c})),"result"===e){P.current=!1,O.current=!0,A(null),M.current&&(clearTimeout(M.current),M.current=null),R();let e=K.current;e&&d&&b(a=>(2===a.length&&q(e),a));let g=a.usage,h=a.total_cost_usd;g&&w({inputTokens:g.input_tokens||0,outputTokens:g.output_tokens||0,cacheCreationInputTokens:g.cache_creation_input_tokens||0,cacheReadInputTokens:g.cache_read_input_tokens||0,totalCostUsd:h||0}),b(b=>(0,f.F)(b,a,{engine:k,assistantId:c}))}},[b,R,p,q,d,k,r]);(0,h.h)({url:E?`/ws/session-stream?sessionId=${encodeURIComponent(E.runKey)}`:"/ws/session-stream",enabled:!!E,onMessage:a=>{I.current=!0,J.current&&(clearTimeout(J.current),J.current=null);let c=G.current;if(c)if("run-snapshot"===a.type&&Array.isArray(a.events)){for(let d of(M.current&&(clearTimeout(M.current),M.current=null),L.current=null,N.current=c.assistantId,O.current=!1,P.current=!1,b(a=>a.filter(a=>!("string"==typeof a.id&&a.id.startsWith("auto-")&&a.runKey===c.runKey)).map(a=>a.id===c.assistantId?{...a,content:"",toolCalls:[]}:a)),a.events))U(d,N.current??c.assistantId);a.status&&"running"!==a.status&&S()}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type)return void S();U(a.message,N.current??c.assistantId)}else"run-idle"===a.type&&S()}});let V=(0,e.useCallback)(async(a,c,e)=>{let f=e&&"permissionMode"in e?"plan"===e.permissionMode:m,h=c?.map(a=>({type:"base64",media_type:a.media_type,data:a.data})),j={id:`user-${Date.now()}`,role:"user",content:a,images:h};b(a=>[...a,j]),u(!0),A(null),C(null);let p=`assistant-${Date.now()}`,q={id:p,role:"assistant",content:"",toolCalls:[],isStreaming:!0};b(a=>[...a,q]),N.current=p,O.current=!1,P.current=!1;let r=!k||"claude"===k||"claude2"===k,s="pty"===l&&r,t=function(){try{return crypto.randomUUID()}catch{return`run-${Date.now()}-${Math.floor(1e9*Math.random())}`}}();try{if("ollama"===k&&!n)throw Error("Please select an Ollama model first (click the model picker above)");let c="codex"===k?"/api/chat/codex":"kimi"===k?"/api/chat/kimi":"ollama"===k?"/api/chat/ollama":"deepseek"===k?"/api/chat/deepseek":"/api/chat",e=await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a,sessionId:K.current,runId:t,images:h,cwd:d,language:g.A.language,..."ollama"===k&&n&&{model:n},..."deepseek"===k&&o&&{model:o},..."claude2"===k&&{engine:"claude2"},...s&&{mode:"pty",ptyCols:i.EE,ptyRows:i.K2},...f&&!s&&r&&{permissionMode:"plan"}})});if(400===e.status&&"deepseek"===k){let a=await e.json().catch(()=>null);throw Error(a?.error||"DeepSeek request failed")}if(!e.ok)throw Error(g.A.t("chat.requestFailed",{defaultValue:"Request failed"}));let j=await e.json().catch(()=>({}));F({runKey:j.runKey||t,assistantId:p}),I.current=!1,J.current&&clearTimeout(J.current),J.current=setTimeout(()=>{G.current&&!I.current&&(b(a=>a.map(a=>a.id!==p||a.content?a:{...a,content:g.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."})})),S())},15e3)}catch(c){console.error("Chat error:",c);let a=c instanceof Error?c.message:g.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});b(b=>b.map(b=>b.id===p?{...b,content:a,isStreaming:!1}:b)),u(!1),F(null)}},[d,k,l,m,n,o,b,S]);return{isLoading:t,tokenUsage:v,rateLimitInfo:x,apiRetryInfo:z,ptyNotice:B,handleSend:V,handleStop:T,abortControllerRef:D}}d()}catch(a){d(a)}})},98356:(a,b,c)=>{"use strict";c.d(b,{T:()=>B});var d=c(48249),e=c(98051),f=c(38368),g=c(33972),h=c(10841),i=c(99773),j=c(36513);c(55583),c(87023);var k=c(50757),l=c(27454),m=c(37752),n=c(67484),o=c(83768),p=c(15466),q=c(49216);function r(a){return{type:"tableCell",children:[{type:"text",value:a}]}}let s=[c(4014).A,function(){return a=>{let b=a.children;for(let a=0;a<b.length;a++){let c=b[a];if("yaml"!==c.type)continue;let d=null;try{let a=q.Ay.load(c.value??"");a&&"object"==typeof a&&!Array.isArray(a)&&(d=a)}catch{d=null}let e=d?Object.entries(d):[];if(0===e.length){b.splice(a,1),a--;continue}let f={type:"tableRow",children:[r("Field"),r("Value")]},g=e.map(([a,b])=>({type:"tableRow",children:[r(a),r(function(a){if(null==a)return"";if("string"==typeof a)return a.replace(/\s*\n\s*/g," ").trim();if("number"==typeof a||"boolean"==typeof a)return String(a);try{return JSON.stringify(a)}catch{return String(a)}}(b))]}));b[a]={type:"table",align:["left","left"],children:[f,...g]}}}}],t=[...s,f.A,g.A,h.jb],u=[...s,f.A,h.jb],v=[i.A,j.A],w=[i.A];function x(a){let b=[],c=a=>(b.push(a),` MASK${b.length-1} `);return a.replace(/```[\s\S]*?```/g,a=>c(a)).replace(/~~~[\s\S]*?~~~/g,a=>c(a)).replace(/^(\|.+\|)$/gm,a=>/^\|[\s:|-]+\|$/.test(a)?a:a.replace(/`([^`]*)`/g,(a,b)=>b.includes("|")?"`"+b.replace(/\|/g,"\\|")+"`":a)).replace(/ MASK(\d+) /g,(a,c)=>b[+c])}function y(a){return a.replace(/\$(\d)/g,"\\$$1")}let z=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 A(a){let b=[],c=a=>(b.push(a),`\0MASK${b.length-1}\0`);return a.replace(/```[\s\S]*?```/g,a=>c(a)).replace(/~~~[\s\S]*?~~~/g,a=>c(a)).replace(/`[^`\n]+`/g,a=>c(a)).replace(/<\/?([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(a,b)=>{let c=b.toLowerCase();return z.has(c)||c.includes("-")?a:a.replace(/</g,"<").replace(/>/g,">")}).replace(/MASK(\d+)/g,(a,c)=>b[+c])}let B=(0,n.memo)(function({content:a,isUser:b=!1,isStreaming:c=!1,enableMath:f=!0,rehypePlugins:g,onLinkClick:h}){let{resolvedTheme:i}=(0,o.D)(),j="dark"===i,q=(0,n.useRef)(null),r=(0,n.useMemo)(()=>({code({className:a,children:b,node:c,...e}){let f=/language-(\w+)/.exec(a||"");if(!("string"==typeof b||"number"==typeof b||Array.isArray(b)&&b.every(a=>"string"==typeof a||"number"==typeof a)))return(0,d.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent text-sm font-mono",...e,children:b});let g=String(b);if(!f&&!a&&!g.includes("\n"))return(0,d.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent text-sm font-mono",...e,children:b});let h=g.replace(/\n$/,""),i=f?.[1]||"text",n=Number(e["data-source-start"])||0,o=n?n+1:0,p=0;return(0,d.jsx)(k.A,{style:j?l.A:m.A,language:i,PreTag:"div",customStyle:{margin:"0.75rem 0",borderRadius:"0.375rem",fontSize:"0.875rem"},wrapLines:!0,lineProps:()=>{let a=o+p;return p++,{"data-source-start":a,"data-source-end":a,style:{display:"block"}}},children:h})},p:({children:a,node:b,...c})=>(0,d.jsx)("p",{className:"mb-3 last:mb-0",...c,children:a}),h1:({children:a,node:b,...c})=>(0,d.jsx)("h1",{className:"text-xl font-bold mb-3 mt-4 first:mt-0",...c,children:a}),h2:({children:a,node:b,...c})=>(0,d.jsx)("h2",{className:"text-lg font-bold mb-2 mt-3 first:mt-0",...c,children:a}),h3:({children:a,node:b,...c})=>(0,d.jsx)("h3",{className:"text-base font-bold mb-2 mt-3 first:mt-0",...c,children:a}),ul:({children:a,node:b,...c})=>(0,d.jsx)("ul",{className:"list-disc list-inside mb-3 space-y-1",...c,children:a}),ol:({children:a,node:b,...c})=>(0,d.jsx)("ol",{className:"list-decimal list-inside mb-3 space-y-1",...c,children:a}),li:({children:a,node:b,...c})=>(0,d.jsx)("li",{className:"leading-relaxed",...c,children:a}),blockquote:({children:a,node:b,...c})=>(0,d.jsx)("blockquote",{className:"border-l-4 border-border pl-4 my-3 italic text-muted-foreground",...c,children:a}),a:({href:a,children:b,node:c,...e})=>(0,d.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-brand hover:underline",...e,onClick:b=>{if(a){if(a.startsWith("#")){(0,p.O)(q.current,a.slice(1))&&b.preventDefault();return}h?.(a)&&b.preventDefault()}},children:b}),table:({children:a,node:b,...c})=>(0,d.jsx)("div",{className:"overflow-x-auto my-3",...c,children:(0,d.jsx)("table",{className:"min-w-full border border-border",children:a})}),thead:({children:a,node:b,...c})=>(0,d.jsx)("thead",{className:"bg-accent",...c,children:a}),th:({children:a,node:b,...c})=>(0,d.jsx)("th",{className:"px-4 py-2 text-left font-semibold border-b border-border",...c,children:a}),td:({children:a,node:b,...c})=>(0,d.jsx)("td",{className:"px-4 py-2 border-b border-border",...c,children:a}),hr:({node:a,...b})=>(0,d.jsx)("hr",{className:"my-4 border-border",...b}),img:({src:a,alt:b,node:c,height:e,width:f,style:g,...h})=>{if(!(e||f||g))return(0,d.jsx)("img",{src:a,alt:b||"",className:"max-w-full h-auto rounded-lg my-3",...h});let i=a=>a?/^\d+$/.test(String(a))?`${a}px`:String(a):void 0,j={...g,height:i(e)??g?.height,width:i(f)??g?.width};return(0,d.jsx)("img",{src:a,alt:b||"",style:j,className:"inline-block align-middle",...h})},strong:({children:a,node:b,...c})=>(0,d.jsx)("strong",{className:"font-bold",...c,children:a}),em:({children:a,node:b,...c})=>(0,d.jsx)("em",{className:"italic",...c,children:a}),del:({children:a,node:b,...c})=>(0,d.jsx)("del",{className:"line-through",...c,children:a})}),[j,h]),s=f?t:u,z=f?v:w,B=(0,n.useMemo)(()=>{if(b||c)return A(a);let d=A(x(!function(a){if(/^\|[\s:|-]+\|$/m.test(a))return!1;if(/[┌┐└┘│─├┤┬┴┼╔╗╚╝║═╭╮╯╰▲▼◀▶△▽◁▷]/.test(a)||/\+[-=]{2,}\+/.test(a))return!0;let b=a.split("\n").filter(a=>/^\s*\||\|\s*$/.test(a));if(b.length>=3){let a=b.map(a=>(a.match(/\|/g)||[]).length);return!a.every(b=>b===a[0])||!(a[0]>=3)}return!1}(a)||/^```[\s\S]*```$/m.test(a.trim())?a:"```text\n"+a.trim()+"\n```"));return f?y(d):d},[a,b,c,f]),C=(0,n.useMemo)(()=>g?.length?[...z,...g]:z,[g,z]);if(b)return(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words",children:a});if(c){let b=a.lastIndexOf("\n");if(-1===b)return(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words",children:a});let c=a.slice(0,b+1),g=a.slice(b+1);return(0,d.jsxs)("div",{className:"markdown-body",ref:q,children:[(0,d.jsx)(e.oz,{remarkPlugins:s,rehypePlugins:z,components:r,children:f?y(A(x(c))):A(x(c))}),g&&(0,d.jsx)("span",{className:"whitespace-pre-wrap",children:g})]})}return(0,d.jsx)("div",{className:"markdown-body",ref:q,children:(0,d.jsx)(e.oz,{remarkPlugins:s,rehypePlugins:C,components:r,children:B})})})},98420:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{V:()=>q});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(36295),j=c(33988),k=c(30894),l=c(28602),m=c(74493),n=c(15105),o=a([i,k]);async function p(a){let b=(0,n.f)()?.id??null;return!!b&&new Promise(c=>{try{let d=globalThis.chrome?.runtime;if(!d?.sendMessage)return void c(!1);let e=setTimeout(()=>c(!1),2e3);d.sendMessage(b,{type:"prepare-iframe",url:a},a=>{clearTimeout(e),c(a?.ok??!1)})}catch{c(!1)}})}function q({url:a,id:b,selected:c,maximized:d,expandedHeight:n,bubbleContentHeight:o,onSelect:r,onClose:s,onToggleMaximize:t,onNewTab:u,timestamp:v,onTitleMouseDown:w,initialSleeping:x,onSleep:y,onWake:z,projectCwd:A,tabId:B}){let{t:C}=(0,g.Bd)(),[D,E]=(0,f.useState)(!1),[F,G]=(0,f.useState)(null),[H,I]=(0,f.useState)(a),[J,K]=(0,f.useState)(null),[L,M]=(0,f.useState)(x??!1),N=(0,f.useRef)(null),O=(0,f.useRef)(null),P=(0,f.useRef)(null);(0,f.useRef)(!0),(0,f.useCallback)(()=>{L||(M(!0),K(null),y?.(b))},[L,b,y]),(0,f.useCallback)(()=>{N.current&&(clearTimeout(N.current),N.current=null)},[]);let Q=!!J&&!L&&!D,{shortId:R,connected:S,connect:T,disconnect:U}=(0,j.B)(b,P,Q,A,B);(0,f.useRef)(S).current=S;let V=(0,f.useCallback)(()=>{M(!1),z?.(b);let c=function(a){if(!a)return a;try{let b=new URL(a);return b.searchParams.set("_cockpit","1"),b.toString()}catch{let b=a.includes("?")?"&":"?";return`${a}${b}_cockpit=1`}}(a);!function(a){try{let b=new URL(a).hostname;return"localhost"===b||"127.0.0.1"===b}catch{return!1}}(a)?p(a).then(()=>K(c)):K(c)},[a,b,z]),W=(0,f.useCallback)(()=>E(!1),[]),X=(0,f.useCallback)(()=>{E(!1),G(C("browser.pageLoadFailed"))},[]),Y=(0,f.useCallback)(()=>{if(L)return void V();let a=O.current?.querySelector("iframe");if(a&&J){E(!0),G(null);let b=a.src;a.src="",setTimeout(()=>{a.src=b},0)}},[L,V,J]),Z=(0,f.useCallback)(()=>{H&&window.open(H,"_blank")},[H]),$=function(a){if(!a)return"";try{let b=new URL(a);return b.port?`${b.hostname}:${b.port}`:b.hostname}catch{return a}}(H),_=d&&n?n-41:o??i.p;return(0,e.jsx)("div",{className:"flex flex-col items-start",children:(0,e.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
49
49
|
relative transition-colors cursor-pointer
|
|
50
50
|
${d?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
51
51
|
${d?"":c?"border-brand":"border-brand/30"}`,onClick:d?void 0:r,children:[d?(0,e.jsxs)("div",{onDoubleClick:t,className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41},children:[(0,e.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})})}),R&&(0,e.jsx)(k.j,{shortId:R,type:"browser",onRegister:()=>T(),onUnregister:async()=>{U(),await (0,m.qM)(R)},fullId:b,projectCwd:A,tabId:B}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate font-mono",children:H||C("browser.blankPage")}),H&&(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(H),(0,h.oR)(C("toast.copiedUrl"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:C("browser.copyUrl"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("span",{className:"flex-1"}),D&&(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),(0,e.jsx)("button",{onClick:Y,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:C("common.refresh"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.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,e.jsx)("button",{onClick:Z,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:C("browser.openInNewWindow"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),(0,e.jsx)("button",{onClick:t,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:C("browser.exitMaximize",{modKey:(0,l.Mu)()}),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})})})]}):(0,e.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>w?.(),onDoubleClick:a=>{a.stopPropagation(),t()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing
|